Files
libreoffice/sd/source/core/drawdoc2.cxx

1508 lines
49 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 23:16:46 +00:00
#include <vcl/wrkwin.hxx>
#include <vcl/settings.hxx>
2000-09-18 23:16:46 +00:00
#include <sfx2/printer.hxx>
#include <sfx2/app.hxx>
#include "Outliner.hxx"
#include <editeng/paperinf.hxx>
2000-09-18 23:16:46 +00:00
#include <svx/svdopage.hxx>
#include <svx/svdoole2.hxx>
#include <svx/svdotext.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdundo.hxx>
#include <vcl/svapp.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/langitem.hxx>
#include <svl/itempool.hxx>
2009-05-19 16:03:18 +00:00
#include <svx/svdpool.hxx>
#include <editeng/flditem.hxx>
2000-09-18 23:16:46 +00:00
2010-01-13 22:25:07 +01:00
#include <sfx2/linkmgr.hxx>
#include <editeng/editdata.hxx>
2000-09-18 23:16:46 +00:00
#include <svx/dialogs.hrc>
#include <svx/dialmgr.hxx>
2000-09-18 23:16:46 +00:00
#include <editeng/outliner.hxx>
2000-09-18 23:16:46 +00:00
#include <svx/svditer.hxx>
#include <svtools/imapobj.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <boost/property_tree/json_parser.hpp>
#include <comphelper/lok.hxx>
#include <xmloff/autolayout.hxx>
2000-09-18 23:16:46 +00:00
#include "sdresid.hxx"
#include "drawdoc.hxx"
#include "sdpage.hxx"
#include "pglink.hxx"
#include "glob.hrc"
#include "glob.hxx"
#include "stlpool.hxx"
#include "sdiocmpt.hxx"
#include "anminfo.hxx"
#include "imapinfo.hxx"
#include "cusshow.hxx"
#include "undo/undomanager.hxx"
2000-09-18 23:16:46 +00:00
#include "DrawDocShell.hxx"
#include "FrameView.hxx"
#include "cfgids.hxx"
#include "strings.hrc"
2000-09-18 23:16:46 +00:00
#include "PageListWatcher.hxx"
#include <vcl/virdev.hxx>
#include "customshowlist.hxx"
using namespace ::sd;
const long PRINT_OFFSET = 30; // see /svx/source/dialog/page.cxx
2000-09-18 23:16:46 +00:00
using namespace com::sun::star;
2000-09-18 23:16:46 +00:00
// Looks up an object by name
SdrObject* SdDrawDocument::GetObj(const OUString& rObjName) const
2000-09-18 23:16:46 +00:00
{
SdrObject* pObj = nullptr;
SdrObject* pObjFound = nullptr;
const SdPage* pPage = nullptr;
2000-09-18 23:16:46 +00:00
// First search in all pages
sal_uInt16 nPage = 0;
const sal_uInt16 nMaxPages = GetPageCount();
2000-09-18 23:16:46 +00:00
while (nPage < nMaxPages && !pObjFound)
{
pPage = static_cast<const SdPage*>( GetPage(nPage) );
SdrObjListIter aIter(*pPage, SdrIterMode::DeepWithGroups);
2000-09-18 23:16:46 +00:00
while (aIter.IsMore() && !pObjFound)
{
pObj = aIter.Next();
if( ( pObj->GetName().equals(rObjName) ) ||
( SdrInventor::Default == pObj->GetObjInventor() &&
OBJ_OLE2 == pObj->GetObjIdentifier() &&
rObjName == static_cast< SdrOle2Obj* >( pObj )->GetPersistName() ) )
2000-09-18 23:16:46 +00:00
{
pObjFound = pObj;
}
}
nPage++;
}
// If it couldn't be found, look through all master pages
2000-09-18 23:16:46 +00:00
nPage = 0;
const sal_uInt16 nMaxMasterPages = GetMasterPageCount();
2000-09-18 23:16:46 +00:00
while (nPage < nMaxMasterPages && !pObjFound)
{
pPage = static_cast<const SdPage*>( GetMasterPage(nPage) );
SdrObjListIter aIter(*pPage, SdrIterMode::DeepWithGroups);
2000-09-18 23:16:46 +00:00
while (aIter.IsMore() && !pObjFound)
{
pObj = aIter.Next();
if( ( pObj->GetName().equals(rObjName) ) ||
( SdrInventor::Default == pObj->GetObjInventor() &&
OBJ_OLE2 == pObj->GetObjIdentifier() &&
rObjName == static_cast< SdrOle2Obj* >( pObj )->GetPersistName() ) )
2000-09-18 23:16:46 +00:00
{
pObjFound = pObj;
}
}
nPage++;
}
return pObjFound;
2000-09-18 23:16:46 +00:00
}
// Find SdPage by name
sal_uInt16 SdDrawDocument::GetPageByName(const OUString& rPgName, bool& rbIsMasterPage) const
2000-09-18 23:16:46 +00:00
{
SdPage* pPage = nullptr;
sal_uInt16 nPage = 0;
const sal_uInt16 nMaxPages = GetPageCount();
sal_uInt16 nPageNum = SDRPAGE_NOTFOUND;
2000-09-18 23:16:46 +00:00
rbIsMasterPage = false;
// Search all regular pages and all notes pages (handout pages are
// ignored)
2000-09-18 23:16:46 +00:00
while (nPage < nMaxPages && nPageNum == SDRPAGE_NOTFOUND)
{
pPage = const_cast<SdPage*>(static_cast<const SdPage*>(
GetPage(nPage)));
2000-09-18 23:16:46 +00:00
if (pPage != nullptr
&& pPage->GetPageKind() != PageKind::Handout
&& pPage->GetName() == rPgName)
2000-09-18 23:16:46 +00:00
{
nPageNum = nPage;
}
nPage++;
}
// Search all master pages when not found among non-master pages
const sal_uInt16 nMaxMasterPages = GetMasterPageCount();
2000-09-18 23:16:46 +00:00
nPage = 0;
while (nPage < nMaxMasterPages && nPageNum == SDRPAGE_NOTFOUND)
{
pPage = const_cast<SdPage*>(static_cast<const SdPage*>(
GetMasterPage(nPage)));
2000-09-18 23:16:46 +00:00
if (pPage && pPage->GetName() == rPgName)
{
nPageNum = nPage;
rbIsMasterPage = true;
2000-09-18 23:16:46 +00:00
}
nPage++;
}
return nPageNum;
2000-09-18 23:16:46 +00:00
}
bool SdDrawDocument::IsPageNameUnique( const OUString& rPgName ) const
{
sal_uInt16 nCount = 0;
SdPage* pPage = nullptr;
// Search all regular pages and all notes pages (handout pages are ignored)
sal_uInt16 nPage = 0;
sal_uInt16 nMaxPages = GetPageCount();
while (nPage < nMaxPages)
{
pPage = const_cast<SdPage*>(static_cast<const SdPage*>(GetPage(nPage)));
if (pPage && pPage->GetName() == rPgName && pPage->GetPageKind() != PageKind::Handout)
nCount++;
nPage++;
}
// Search all master pages
nPage = 0;
nMaxPages = GetMasterPageCount();
while (nPage < nMaxPages)
{
pPage = const_cast<SdPage*>(static_cast<const SdPage*>(GetMasterPage(nPage)));
if (pPage && pPage->GetName() == rPgName)
nCount++;;
nPage++;
}
return nCount == 1;
}
SdPage* SdDrawDocument::GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
2000-09-18 23:16:46 +00:00
{
return mpDrawPageListWatcher->GetSdPage(ePgKind, sal_uInt32(nPgNum));
2000-09-18 23:16:46 +00:00
}
sal_uInt16 SdDrawDocument::GetSdPageCount(PageKind ePgKind) const
2000-09-18 23:16:46 +00:00
{
return (sal_uInt16)mpDrawPageListWatcher->GetSdPageCount(ePgKind);
2000-09-18 23:16:46 +00:00
}
SdPage* SdDrawDocument::GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind)
2000-09-18 23:16:46 +00:00
{
return mpMasterPageListWatcher->GetSdPage(ePgKind, sal_uInt32(nPgNum));
2000-09-18 23:16:46 +00:00
}
sal_uInt16 SdDrawDocument::GetMasterSdPageCount(PageKind ePgKind) const
2000-09-18 23:16:46 +00:00
{
return (sal_uInt16)mpMasterPageListWatcher->GetSdPageCount(ePgKind);
2000-09-18 23:16:46 +00:00
}
sal_uInt16 SdDrawDocument::GetActiveSdPageCount() const
{
return (sal_uInt16)mpDrawPageListWatcher->GetVisibleSdPageCount();
}
// Adapt the page numbers that are registered in the page objects of the notes
// pages
void SdDrawDocument::UpdatePageObjectsInNotes(sal_uInt16 nStartPos)
2000-09-18 23:16:46 +00:00
{
sal_uInt16 nPageCount = GetPageCount();
SdPage* pPage = nullptr;
2000-09-18 23:16:46 +00:00
for (sal_uInt16 nPage = nStartPos; nPage < nPageCount; nPage++)
2000-09-18 23:16:46 +00:00
{
pPage = static_cast<SdPage*>( GetPage(nPage) );
2000-09-18 23:16:46 +00:00
// If this is a notes page, find its page object and correct the page
// number
if (pPage && pPage->GetPageKind() == PageKind::Notes)
2000-09-18 23:16:46 +00:00
{
const size_t nObjCount = pPage->GetObjCount();
for (size_t nObj = 0; nObj < nObjCount; ++nObj)
2000-09-18 23:16:46 +00:00
{
SdrObject* pObj = pPage->GetObj(nObj);
2000-09-18 23:16:46 +00:00
if (pObj->GetObjIdentifier() == OBJ_PAGE &&
pObj->GetObjInventor() == SdrInventor::Default)
2000-09-18 23:16:46 +00:00
{
// The page object is the preceding page (drawing page)
SAL_WARN_IF(!nStartPos, "sd", "Position of notes page must not be 0.");
2000-09-18 23:16:46 +00:00
SAL_WARN_IF(nPage <= 1, "sd", "Page object must not be a handout.");
2000-09-18 23:16:46 +00:00
if (nStartPos > 0 && nPage > 1)
static_cast<SdrPageObj*>(pObj)->SetReferencedPage(GetPage(nPage - 1));
2000-09-18 23:16:46 +00:00
}
}
}
}
}
void SdDrawDocument::UpdatePageRelativeURLs(const OUString& rOldName, const OUString& rNewName)
2009-05-19 16:03:18 +00:00
{
if (rNewName.isEmpty())
2009-05-19 16:03:18 +00:00
return;
SfxItemPool& rPool(GetPool());
sal_uInt32 nCount = rPool.GetItemCount2(EE_FEATURE_FIELD);
for (sal_uInt32 nOff = 0; nOff < nCount; nOff++)
2009-05-19 16:03:18 +00:00
{
const SfxPoolItem *pItem = rPool.GetItem2(EE_FEATURE_FIELD, nOff);
2009-05-19 16:03:18 +00:00
const SvxFieldItem* pFldItem = dynamic_cast< const SvxFieldItem * > (pItem);
if(pFldItem)
{
SvxURLField* pURLField = const_cast< SvxURLField* >( dynamic_cast<const SvxURLField*>( pFldItem->GetField() ) );
if(pURLField)
{
OUString aURL = pURLField->GetURL();
2009-05-19 16:03:18 +00:00
if (!aURL.isEmpty() && (aURL[0] == 35) && (aURL.indexOf(rOldName, 1) == 1))
2009-05-19 16:03:18 +00:00
{
if (aURL.getLength() == rOldName.getLength() + 1) // standard page name
2009-05-19 16:03:18 +00:00
{
aURL = aURL.replaceAt(1, aURL.getLength() - 1, "");
2009-05-19 16:03:18 +00:00
aURL += rNewName;
pURLField->SetURL(aURL);
}
else
{
const OUString sNotes(SD_RESSTR(STR_NOTES));
if (aURL.getLength() == rOldName.getLength() + 2 + sNotes.getLength()
&& aURL.indexOf(sNotes, rOldName.getLength() + 2) == rOldName.getLength() + 2)
2009-05-19 16:03:18 +00:00
{
aURL = aURL.replaceAt(1, aURL.getLength() - 1, "");
aURL += rNewName + " " + sNotes;
2009-05-19 16:03:18 +00:00
pURLField->SetURL(aURL);
}
}
}
}
}
}
}
void SdDrawDocument::UpdatePageRelativeURLs(SdPage* pPage, sal_uInt16 nPos, sal_Int32 nIncrement)
2009-05-19 16:03:18 +00:00
{
bool bNotes = (pPage->GetPageKind() == PageKind::Notes);
2009-05-19 16:03:18 +00:00
SfxItemPool& rPool(GetPool());
sal_uInt32 nCount = rPool.GetItemCount2(EE_FEATURE_FIELD);
for (sal_uInt32 nOff = 0; nOff < nCount; nOff++)
2009-05-19 16:03:18 +00:00
{
const SfxPoolItem *pItem = rPool.GetItem2(EE_FEATURE_FIELD, nOff);
2009-05-19 16:03:18 +00:00
const SvxFieldItem* pFldItem;
if ((pFldItem = dynamic_cast< const SvxFieldItem * > (pItem)) != nullptr)
2009-05-19 16:03:18 +00:00
{
SvxURLField* pURLField = const_cast< SvxURLField* >( dynamic_cast<const SvxURLField*>( pFldItem->GetField() ) );
if(pURLField)
{
OUString aURL = pURLField->GetURL();
2009-05-19 16:03:18 +00:00
if (!aURL.isEmpty() && (aURL[0] == 35))
2009-05-19 16:03:18 +00:00
{
OUString aHashSlide("#");
aHashSlide += SD_RESSTR(STR_PAGE);
2009-05-19 16:03:18 +00:00
if (aURL.startsWith(aHashSlide))
2009-05-19 16:03:18 +00:00
{
OUString aURLCopy = aURL;
const OUString sNotes(SD_RESSTR(STR_NOTES));
2009-05-19 16:03:18 +00:00
aURLCopy = aURLCopy.replaceAt(0, aHashSlide.getLength(), "");
2009-05-19 16:03:18 +00:00
bool bNotesLink = ( aURLCopy.getLength() >= sNotes.getLength() + 3
&& aURLCopy.endsWith(sNotes) );
2009-05-19 16:03:18 +00:00
if (bNotesLink != bNotes)
2009-05-19 16:03:18 +00:00
continue; // no compatible link and page
if (bNotes)
aURLCopy = aURLCopy.replaceAt(aURLCopy.getLength() - sNotes.getLength(), sNotes.getLength(), "");
2009-05-19 16:03:18 +00:00
sal_Int32 number = aURLCopy.toInt32();
sal_uInt16 realPageNumber = (nPos + 1)/ 2;
2009-05-19 16:03:18 +00:00
if ( number >= realPageNumber )
{
// update link page number
number += nIncrement;
aURL = aURL.replaceAt(aHashSlide.getLength() + 1, aURL.getLength() - aHashSlide.getLength() - 1, "");
aURL += OUString::number(number);
2009-05-19 16:03:18 +00:00
if (bNotes)
{
aURL += " " + sNotes;
2009-05-19 16:03:18 +00:00
}
pURLField->SetURL(aURL);
}
}
}
}
}
}
}
CWS-TOOLING: integrate CWS impress169 2009-05-13 17:37:21 +0200 sj r271865 : #i100942# applied patch, removed oversafe buffer check (now without warnings on 64 bit platform) 2009-05-13 12:27:18 +0200 sj r271855 : #i101769# fixed line/fill attributes for graphic objects 2009-05-12 10:25:17 +0200 cl r271799 : report correct minimum cell hight for empty cells 2009-04-28 17:29:46 +0200 cl r271334 : fixed merge error 2009-04-28 16:18:01 +0200 cl r271330 : fixed build error 2009-04-28 12:38:09 +0200 cl r271320 : #i100129# images for new layouts 2009-04-27 19:12:06 +0200 cl r271302 : CWS-TOOLING: rebase CWS impress169 to trunk@270723 (milestone: DEV300:m46) 2009-04-20 19:13:28 +0200 sj r271012 : #i100942# applied patch, removed oversafe buffer check 2009-04-09 18:00:01 +0200 sj r270719 : #158488# added rectangular gradient support 2009-04-09 17:49:52 +0200 sj r270718 : #158488# added rectangular gradient support 2009-04-09 17:46:24 +0200 sj r270717 : #158488# added rectangular gradient support 2009-03-26 18:16:34 +0100 cl r270098 : #i99867# applied patch from jlcheng to correctly register table design pane 2009-03-26 18:12:11 +0100 cl r270097 : #i100220# leave some items default so they are not overridden if a new table style is set 2009-03-26 18:11:10 +0100 cl r270096 : #i100220# clear only those items that are also in the style when assigning a new table layout 2009-03-26 15:56:24 +0100 cl r270085 : #i99977# listen to outliner and dispose if outliner dies 2009-03-26 15:47:29 +0100 cl r270084 : #i99977# made the Outliner a SfxBroadcaster so others can listen for its death 2009-03-24 19:10:05 +0100 sj r269991 : #i100490# fixed text resize problem 2009-03-23 14:31:11 +0100 sj r269872 : #i96083# added patch, (dubious && and ||) 2009-03-19 17:55:11 +0100 sj r269764 : #i100275# applied patch, row height is now correct even for rows containing no text 2009-03-18 18:10:52 +0100 sj r269701 : #i93616# solved performance problem when loading document 2009-03-18 16:20:40 +0100 sj r269688 : removing unused code 2009-03-18 16:19:22 +0100 sj r269687 : removing unused code 2009-03-18 16:17:54 +0100 sj r269686 : removing unused code 2009-03-18 10:28:07 +0100 cl r269643 : #i100029# let cells be disposed as soon as the table model is disposed 2009-03-17 15:56:50 +0100 cl r269614 : #i99984# new impress photo layouts 3x2 and 2x2 2009-03-17 15:36:35 +0100 cl r269611 : #i99984# adding new impress photo layouts 3x2 and 2x2 2009-03-16 18:43:48 +0100 cl r269564 : #i55224# correct internal links if pages are changed 2009-03-16 16:40:38 +0100 cl r269559 : #i55224# correct internal hyperlinks if slides are changed/renamed 2009-03-16 15:34:12 +0100 cl r269553 : #i99427# invalidate slots after promote/demote 2009-03-13 18:18:20 +0100 sj r269492 : #i92421# fixed loop if loading encrypted ppt file 2009-03-13 14:51:58 +0100 sj r269481 : #i93002# fixed crash if saving presentation without master title placeholder 2009-03-13 12:26:21 +0100 sj r269468 : #i100147# do not exceed the max point count if creating simple polygon via ::GetSimple 2009-03-12 17:00:45 +0100 sj r269427 : #i82518# justifying rectangles for arc/pie and chord actions, fixed round rectangle problem
2009-05-19 09:32:45 +00:00
// Move page
void SdDrawDocument::MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos)
2000-09-18 23:16:46 +00:00
{
FmFormModel::MovePage(nPgNum, nNewPos);
sal_uInt16 nMin = std::min(nPgNum, nNewPos);
2000-09-18 23:16:46 +00:00
UpdatePageObjectsInNotes(nMin);
}
// Insert page
void SdDrawDocument::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
2000-09-18 23:16:46 +00:00
{
2009-05-19 16:03:18 +00:00
bool bLast = (nPos == GetPageCount());
CWS-TOOLING: integrate CWS impress169 2009-05-13 17:37:21 +0200 sj r271865 : #i100942# applied patch, removed oversafe buffer check (now without warnings on 64 bit platform) 2009-05-13 12:27:18 +0200 sj r271855 : #i101769# fixed line/fill attributes for graphic objects 2009-05-12 10:25:17 +0200 cl r271799 : report correct minimum cell hight for empty cells 2009-04-28 17:29:46 +0200 cl r271334 : fixed merge error 2009-04-28 16:18:01 +0200 cl r271330 : fixed build error 2009-04-28 12:38:09 +0200 cl r271320 : #i100129# images for new layouts 2009-04-27 19:12:06 +0200 cl r271302 : CWS-TOOLING: rebase CWS impress169 to trunk@270723 (milestone: DEV300:m46) 2009-04-20 19:13:28 +0200 sj r271012 : #i100942# applied patch, removed oversafe buffer check 2009-04-09 18:00:01 +0200 sj r270719 : #158488# added rectangular gradient support 2009-04-09 17:49:52 +0200 sj r270718 : #158488# added rectangular gradient support 2009-04-09 17:46:24 +0200 sj r270717 : #158488# added rectangular gradient support 2009-03-26 18:16:34 +0100 cl r270098 : #i99867# applied patch from jlcheng to correctly register table design pane 2009-03-26 18:12:11 +0100 cl r270097 : #i100220# leave some items default so they are not overridden if a new table style is set 2009-03-26 18:11:10 +0100 cl r270096 : #i100220# clear only those items that are also in the style when assigning a new table layout 2009-03-26 15:56:24 +0100 cl r270085 : #i99977# listen to outliner and dispose if outliner dies 2009-03-26 15:47:29 +0100 cl r270084 : #i99977# made the Outliner a SfxBroadcaster so others can listen for its death 2009-03-24 19:10:05 +0100 sj r269991 : #i100490# fixed text resize problem 2009-03-23 14:31:11 +0100 sj r269872 : #i96083# added patch, (dubious && and ||) 2009-03-19 17:55:11 +0100 sj r269764 : #i100275# applied patch, row height is now correct even for rows containing no text 2009-03-18 18:10:52 +0100 sj r269701 : #i93616# solved performance problem when loading document 2009-03-18 16:20:40 +0100 sj r269688 : removing unused code 2009-03-18 16:19:22 +0100 sj r269687 : removing unused code 2009-03-18 16:17:54 +0100 sj r269686 : removing unused code 2009-03-18 10:28:07 +0100 cl r269643 : #i100029# let cells be disposed as soon as the table model is disposed 2009-03-17 15:56:50 +0100 cl r269614 : #i99984# new impress photo layouts 3x2 and 2x2 2009-03-17 15:36:35 +0100 cl r269611 : #i99984# adding new impress photo layouts 3x2 and 2x2 2009-03-16 18:43:48 +0100 cl r269564 : #i55224# correct internal links if pages are changed 2009-03-16 16:40:38 +0100 cl r269559 : #i55224# correct internal hyperlinks if slides are changed/renamed 2009-03-16 15:34:12 +0100 cl r269553 : #i99427# invalidate slots after promote/demote 2009-03-13 18:18:20 +0100 sj r269492 : #i92421# fixed loop if loading encrypted ppt file 2009-03-13 14:51:58 +0100 sj r269481 : #i93002# fixed crash if saving presentation without master title placeholder 2009-03-13 12:26:21 +0100 sj r269468 : #i100147# do not exceed the max point count if creating simple polygon via ::GetSimple 2009-03-12 17:00:45 +0100 sj r269427 : #i82518# justifying rectangles for arc/pie and chord actions, fixed round rectangle problem
2009-05-19 09:32:45 +00:00
2000-09-18 23:16:46 +00:00
FmFormModel::InsertPage(pPage, nPos);
static_cast<SdPage*>(pPage)->ConnectLink();
2000-09-18 23:16:46 +00:00
UpdatePageObjectsInNotes(nPos);
CWS-TOOLING: integrate CWS impress169 2009-05-13 17:37:21 +0200 sj r271865 : #i100942# applied patch, removed oversafe buffer check (now without warnings on 64 bit platform) 2009-05-13 12:27:18 +0200 sj r271855 : #i101769# fixed line/fill attributes for graphic objects 2009-05-12 10:25:17 +0200 cl r271799 : report correct minimum cell hight for empty cells 2009-04-28 17:29:46 +0200 cl r271334 : fixed merge error 2009-04-28 16:18:01 +0200 cl r271330 : fixed build error 2009-04-28 12:38:09 +0200 cl r271320 : #i100129# images for new layouts 2009-04-27 19:12:06 +0200 cl r271302 : CWS-TOOLING: rebase CWS impress169 to trunk@270723 (milestone: DEV300:m46) 2009-04-20 19:13:28 +0200 sj r271012 : #i100942# applied patch, removed oversafe buffer check 2009-04-09 18:00:01 +0200 sj r270719 : #158488# added rectangular gradient support 2009-04-09 17:49:52 +0200 sj r270718 : #158488# added rectangular gradient support 2009-04-09 17:46:24 +0200 sj r270717 : #158488# added rectangular gradient support 2009-03-26 18:16:34 +0100 cl r270098 : #i99867# applied patch from jlcheng to correctly register table design pane 2009-03-26 18:12:11 +0100 cl r270097 : #i100220# leave some items default so they are not overridden if a new table style is set 2009-03-26 18:11:10 +0100 cl r270096 : #i100220# clear only those items that are also in the style when assigning a new table layout 2009-03-26 15:56:24 +0100 cl r270085 : #i99977# listen to outliner and dispose if outliner dies 2009-03-26 15:47:29 +0100 cl r270084 : #i99977# made the Outliner a SfxBroadcaster so others can listen for its death 2009-03-24 19:10:05 +0100 sj r269991 : #i100490# fixed text resize problem 2009-03-23 14:31:11 +0100 sj r269872 : #i96083# added patch, (dubious && and ||) 2009-03-19 17:55:11 +0100 sj r269764 : #i100275# applied patch, row height is now correct even for rows containing no text 2009-03-18 18:10:52 +0100 sj r269701 : #i93616# solved performance problem when loading document 2009-03-18 16:20:40 +0100 sj r269688 : removing unused code 2009-03-18 16:19:22 +0100 sj r269687 : removing unused code 2009-03-18 16:17:54 +0100 sj r269686 : removing unused code 2009-03-18 10:28:07 +0100 cl r269643 : #i100029# let cells be disposed as soon as the table model is disposed 2009-03-17 15:56:50 +0100 cl r269614 : #i99984# new impress photo layouts 3x2 and 2x2 2009-03-17 15:36:35 +0100 cl r269611 : #i99984# adding new impress photo layouts 3x2 and 2x2 2009-03-16 18:43:48 +0100 cl r269564 : #i55224# correct internal links if pages are changed 2009-03-16 16:40:38 +0100 cl r269559 : #i55224# correct internal hyperlinks if slides are changed/renamed 2009-03-16 15:34:12 +0100 cl r269553 : #i99427# invalidate slots after promote/demote 2009-03-13 18:18:20 +0100 sj r269492 : #i92421# fixed loop if loading encrypted ppt file 2009-03-13 14:51:58 +0100 sj r269481 : #i93002# fixed crash if saving presentation without master title placeholder 2009-03-13 12:26:21 +0100 sj r269468 : #i100147# do not exceed the max point count if creating simple polygon via ::GetSimple 2009-03-12 17:00:45 +0100 sj r269427 : #i82518# justifying rectangles for arc/pie and chord actions, fixed round rectangle problem
2009-05-19 09:32:45 +00:00
2009-05-19 16:03:18 +00:00
if (!bLast)
UpdatePageRelativeURLs(static_cast<SdPage*>( pPage ), nPos, 1);
CWS-TOOLING: integrate CWS impress169 2009-05-13 17:37:21 +0200 sj r271865 : #i100942# applied patch, removed oversafe buffer check (now without warnings on 64 bit platform) 2009-05-13 12:27:18 +0200 sj r271855 : #i101769# fixed line/fill attributes for graphic objects 2009-05-12 10:25:17 +0200 cl r271799 : report correct minimum cell hight for empty cells 2009-04-28 17:29:46 +0200 cl r271334 : fixed merge error 2009-04-28 16:18:01 +0200 cl r271330 : fixed build error 2009-04-28 12:38:09 +0200 cl r271320 : #i100129# images for new layouts 2009-04-27 19:12:06 +0200 cl r271302 : CWS-TOOLING: rebase CWS impress169 to trunk@270723 (milestone: DEV300:m46) 2009-04-20 19:13:28 +0200 sj r271012 : #i100942# applied patch, removed oversafe buffer check 2009-04-09 18:00:01 +0200 sj r270719 : #158488# added rectangular gradient support 2009-04-09 17:49:52 +0200 sj r270718 : #158488# added rectangular gradient support 2009-04-09 17:46:24 +0200 sj r270717 : #158488# added rectangular gradient support 2009-03-26 18:16:34 +0100 cl r270098 : #i99867# applied patch from jlcheng to correctly register table design pane 2009-03-26 18:12:11 +0100 cl r270097 : #i100220# leave some items default so they are not overridden if a new table style is set 2009-03-26 18:11:10 +0100 cl r270096 : #i100220# clear only those items that are also in the style when assigning a new table layout 2009-03-26 15:56:24 +0100 cl r270085 : #i99977# listen to outliner and dispose if outliner dies 2009-03-26 15:47:29 +0100 cl r270084 : #i99977# made the Outliner a SfxBroadcaster so others can listen for its death 2009-03-24 19:10:05 +0100 sj r269991 : #i100490# fixed text resize problem 2009-03-23 14:31:11 +0100 sj r269872 : #i96083# added patch, (dubious && and ||) 2009-03-19 17:55:11 +0100 sj r269764 : #i100275# applied patch, row height is now correct even for rows containing no text 2009-03-18 18:10:52 +0100 sj r269701 : #i93616# solved performance problem when loading document 2009-03-18 16:20:40 +0100 sj r269688 : removing unused code 2009-03-18 16:19:22 +0100 sj r269687 : removing unused code 2009-03-18 16:17:54 +0100 sj r269686 : removing unused code 2009-03-18 10:28:07 +0100 cl r269643 : #i100029# let cells be disposed as soon as the table model is disposed 2009-03-17 15:56:50 +0100 cl r269614 : #i99984# new impress photo layouts 3x2 and 2x2 2009-03-17 15:36:35 +0100 cl r269611 : #i99984# adding new impress photo layouts 3x2 and 2x2 2009-03-16 18:43:48 +0100 cl r269564 : #i55224# correct internal links if pages are changed 2009-03-16 16:40:38 +0100 cl r269559 : #i55224# correct internal hyperlinks if slides are changed/renamed 2009-03-16 15:34:12 +0100 cl r269553 : #i99427# invalidate slots after promote/demote 2009-03-13 18:18:20 +0100 sj r269492 : #i92421# fixed loop if loading encrypted ppt file 2009-03-13 14:51:58 +0100 sj r269481 : #i93002# fixed crash if saving presentation without master title placeholder 2009-03-13 12:26:21 +0100 sj r269468 : #i100147# do not exceed the max point count if creating simple polygon via ::GetSimple 2009-03-12 17:00:45 +0100 sj r269427 : #i82518# justifying rectangles for arc/pie and chord actions, fixed round rectangle problem
2009-05-19 09:32:45 +00:00
if (comphelper::LibreOfficeKit::isActive() && static_cast<SdPage*>(pPage)->GetPageKind() == PageKind::Standard)
{
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
2000-09-18 23:16:46 +00:00
}
// Delete page
void SdDrawDocument::DeletePage(sal_uInt16 nPgNum)
2000-09-18 23:16:46 +00:00
{
FmFormModel::DeletePage(nPgNum);
UpdatePageObjectsInNotes(nPgNum);
}
// Remove page
SdrPage* SdDrawDocument::RemovePage(sal_uInt16 nPgNum)
2000-09-18 23:16:46 +00:00
{
SdrPage* pPage = FmFormModel::RemovePage(nPgNum);
2009-05-19 16:03:18 +00:00
bool bLast = ((nPgNum+1)/2 == (GetPageCount()+1)/2);
2000-09-18 23:16:46 +00:00
static_cast<SdPage*>(pPage)->DisconnectLink();
ReplacePageInCustomShows( dynamic_cast< SdPage* >( pPage ), nullptr );
2000-09-18 23:16:46 +00:00
UpdatePageObjectsInNotes(nPgNum);
2009-05-19 16:03:18 +00:00
if (!bLast)
UpdatePageRelativeURLs(static_cast<SdPage*>(pPage), nPgNum, -1);
CWS-TOOLING: integrate CWS impress169 2009-05-13 17:37:21 +0200 sj r271865 : #i100942# applied patch, removed oversafe buffer check (now without warnings on 64 bit platform) 2009-05-13 12:27:18 +0200 sj r271855 : #i101769# fixed line/fill attributes for graphic objects 2009-05-12 10:25:17 +0200 cl r271799 : report correct minimum cell hight for empty cells 2009-04-28 17:29:46 +0200 cl r271334 : fixed merge error 2009-04-28 16:18:01 +0200 cl r271330 : fixed build error 2009-04-28 12:38:09 +0200 cl r271320 : #i100129# images for new layouts 2009-04-27 19:12:06 +0200 cl r271302 : CWS-TOOLING: rebase CWS impress169 to trunk@270723 (milestone: DEV300:m46) 2009-04-20 19:13:28 +0200 sj r271012 : #i100942# applied patch, removed oversafe buffer check 2009-04-09 18:00:01 +0200 sj r270719 : #158488# added rectangular gradient support 2009-04-09 17:49:52 +0200 sj r270718 : #158488# added rectangular gradient support 2009-04-09 17:46:24 +0200 sj r270717 : #158488# added rectangular gradient support 2009-03-26 18:16:34 +0100 cl r270098 : #i99867# applied patch from jlcheng to correctly register table design pane 2009-03-26 18:12:11 +0100 cl r270097 : #i100220# leave some items default so they are not overridden if a new table style is set 2009-03-26 18:11:10 +0100 cl r270096 : #i100220# clear only those items that are also in the style when assigning a new table layout 2009-03-26 15:56:24 +0100 cl r270085 : #i99977# listen to outliner and dispose if outliner dies 2009-03-26 15:47:29 +0100 cl r270084 : #i99977# made the Outliner a SfxBroadcaster so others can listen for its death 2009-03-24 19:10:05 +0100 sj r269991 : #i100490# fixed text resize problem 2009-03-23 14:31:11 +0100 sj r269872 : #i96083# added patch, (dubious && and ||) 2009-03-19 17:55:11 +0100 sj r269764 : #i100275# applied patch, row height is now correct even for rows containing no text 2009-03-18 18:10:52 +0100 sj r269701 : #i93616# solved performance problem when loading document 2009-03-18 16:20:40 +0100 sj r269688 : removing unused code 2009-03-18 16:19:22 +0100 sj r269687 : removing unused code 2009-03-18 16:17:54 +0100 sj r269686 : removing unused code 2009-03-18 10:28:07 +0100 cl r269643 : #i100029# let cells be disposed as soon as the table model is disposed 2009-03-17 15:56:50 +0100 cl r269614 : #i99984# new impress photo layouts 3x2 and 2x2 2009-03-17 15:36:35 +0100 cl r269611 : #i99984# adding new impress photo layouts 3x2 and 2x2 2009-03-16 18:43:48 +0100 cl r269564 : #i55224# correct internal links if pages are changed 2009-03-16 16:40:38 +0100 cl r269559 : #i55224# correct internal hyperlinks if slides are changed/renamed 2009-03-16 15:34:12 +0100 cl r269553 : #i99427# invalidate slots after promote/demote 2009-03-13 18:18:20 +0100 sj r269492 : #i92421# fixed loop if loading encrypted ppt file 2009-03-13 14:51:58 +0100 sj r269481 : #i93002# fixed crash if saving presentation without master title placeholder 2009-03-13 12:26:21 +0100 sj r269468 : #i100147# do not exceed the max point count if creating simple polygon via ::GetSimple 2009-03-12 17:00:45 +0100 sj r269427 : #i82518# justifying rectangles for arc/pie and chord actions, fixed round rectangle problem
2009-05-19 09:32:45 +00:00
if (comphelper::LibreOfficeKit::isActive() && static_cast<SdPage*>(pPage)->GetPageKind() == PageKind::Standard)
{
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
2000-09-18 23:16:46 +00:00
return pPage;
}
// Warning: This is not called for new master pages created from SdrModel::Merge,
// you also have to modify code in SdDrawDocument::Merge!
void SdDrawDocument::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos )
{
FmFormModel::InsertMasterPage( pPage, nPos );
if( pPage->IsMasterPage() && (static_cast<SdPage*>(pPage)->GetPageKind() == PageKind::Standard) )
{
// new master page created, add its style family
SdStyleSheetPool* pStylePool = static_cast<SdStyleSheetPool*>( GetStyleSheetPool() );
if( pStylePool )
pStylePool->AddStyleFamily( static_cast<SdPage*>(pPage) );
}
}
SdrPage* SdDrawDocument::RemoveMasterPage(sal_uInt16 nPgNum)
{
SdPage* pPage = static_cast<SdPage*>(GetMasterPage(nPgNum ));
if( pPage && pPage->IsMasterPage() && (pPage->GetPageKind() == PageKind::Standard) )
{
// master page removed, remove its style family
SdStyleSheetPool* pStylePool = static_cast<SdStyleSheetPool*>( GetStyleSheetPool() );
if( pStylePool )
pStylePool->RemoveStyleFamily( pPage );
}
return FmFormModel::RemoveMasterPage(nPgNum);
}
//Select pages
void SdDrawDocument::SetSelected(SdPage* pPage, bool bSelect)
2000-09-18 23:16:46 +00:00
{
PageKind ePageKind = pPage->GetPageKind();
if (ePageKind == PageKind::Standard)
2000-09-18 23:16:46 +00:00
{
pPage->SetSelected(bSelect);
const sal_uInt16 nDestPageNum(pPage->GetPageNum() + 1);
SdPage* pNotesPage = nullptr;
if(nDestPageNum < GetPageCount())
{
pNotesPage = static_cast<SdPage*>(GetPage(nDestPageNum));
}
2000-09-18 23:16:46 +00:00
if (pNotesPage && pNotesPage->GetPageKind() == PageKind::Notes)
{
2000-09-18 23:16:46 +00:00
pNotesPage->SetSelected(bSelect);
}
2000-09-18 23:16:46 +00:00
}
else if (ePageKind == PageKind::Notes)
2000-09-18 23:16:46 +00:00
{
pPage->SetSelected(bSelect);
SdPage* pStandardPage = static_cast<SdPage*>( GetPage( pPage->GetPageNum() - 1 ) );
2000-09-18 23:16:46 +00:00
if (pStandardPage && pStandardPage->GetPageKind() == PageKind::Standard)
2000-09-18 23:16:46 +00:00
pStandardPage->SetSelected(bSelect);
}
}
// If no pages exist yet, create them now
void SdDrawDocument::CreateFirstPages( SdDrawDocument* pRefDocument /* = 0 */ )
2000-09-18 23:16:46 +00:00
{
// If no page exists yet in the model, (File -> New), insert a page
sal_uInt16 nPageCount = GetPageCount();
2000-09-18 23:16:46 +00:00
if (nPageCount <= 1)
{
// #i57181# Paper size depends on Language, like in Writer
Size aDefSize = SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM );
2000-09-18 23:16:46 +00:00
// Insert handout page
SdPage* pHandoutPage = AllocSdPage(false);
2000-09-18 23:16:46 +00:00
SdPage* pRefPage = nullptr;
if( pRefDocument )
pRefPage = pRefDocument->GetSdPage( 0, PageKind::Handout );
if( pRefPage )
2000-09-18 23:16:46 +00:00
{
pHandoutPage->SetSize(pRefPage->GetSize());
pHandoutPage->SetBorder( pRefPage->GetLftBorder(), pRefPage->GetUppBorder(), pRefPage->GetRgtBorder(), pRefPage->GetLwrBorder() );
2000-09-18 23:16:46 +00:00
}
else
{
pHandoutPage->SetSize(aDefSize);
pHandoutPage->SetBorder(0, 0, 0, 0);
}
pHandoutPage->SetPageKind(PageKind::Handout);
pHandoutPage->SetName( SD_RESSTR(STR_HANDOUT) );
2000-09-18 23:16:46 +00:00
InsertPage(pHandoutPage, 0);
// Insert master page and register this with the handout page
SdPage* pHandoutMPage = AllocSdPage(true);
2000-09-18 23:16:46 +00:00
pHandoutMPage->SetSize( pHandoutPage->GetSize() );
pHandoutMPage->SetPageKind(PageKind::Handout);
2000-09-18 23:16:46 +00:00
pHandoutMPage->SetBorder( pHandoutPage->GetLftBorder(),
pHandoutPage->GetUppBorder(),
pHandoutPage->GetRgtBorder(),
pHandoutPage->GetLwrBorder() );
InsertMasterPage(pHandoutMPage, 0);
pHandoutPage->TRG_SetMasterPage( *pHandoutMPage );
2000-09-18 23:16:46 +00:00
// Insert page
// If nPageCount==1 is, the model for the clipboard was created, thus a
// default page must already exist
2000-09-18 23:16:46 +00:00
SdPage* pPage;
bool bClipboard = false;
2000-09-18 23:16:46 +00:00
if( pRefDocument )
pRefPage = pRefDocument->GetSdPage( 0, PageKind::Standard );
2000-09-18 23:16:46 +00:00
if (nPageCount == 0)
{
pPage = AllocSdPage(false);
2000-09-18 23:16:46 +00:00
if( pRefPage )
{
pPage->SetSize( pRefPage->GetSize() );
pPage->SetBorder( pRefPage->GetLftBorder(), pRefPage->GetUppBorder(), pRefPage->GetRgtBorder(), pRefPage->GetLwrBorder() );
}
else if (meDocType == DocumentType::Draw)
2000-09-18 23:16:46 +00:00
{
// Draw: always use default size with margins
2000-09-18 23:16:46 +00:00
pPage->SetSize(aDefSize);
SfxPrinter* pPrinter = mpDocSh->GetPrinter(false);
if (pPrinter && pPrinter->IsValid())
2000-09-18 23:16:46 +00:00
{
Size aOutSize(pPrinter->GetOutputSize());
Point aPageOffset(pPrinter->GetPageOffset());
aPageOffset -= pPrinter->PixelToLogic( Point() );
long nOffset = !aPageOffset.X() && !aPageOffset.Y() ? 0 : PRINT_OFFSET;
2000-09-18 23:16:46 +00:00
sal_uLong nTop = aPageOffset.Y();
sal_uLong nLeft = aPageOffset.X();
sal_uLong nBottom = std::max((long)(aDefSize.Height() - aOutSize.Height() - nTop + nOffset), 0L);
sal_uLong nRight = std::max((long)(aDefSize.Width() - aOutSize.Width() - nLeft + nOffset), 0L);
2000-09-18 23:16:46 +00:00
pPage->SetBorder(nLeft, nTop, nRight, nBottom);
}
else
{
// The printer is not available. Use a border of 10mm
// on each side instead.
// This has to be kept synchronized with the border
// width set in the
// SvxPageDescPage::PaperSizeSelect_Impl callback.
pPage->SetBorder(1000, 1000, 1000, 1000);
2000-09-18 23:16:46 +00:00
}
}
else
{
// Impress: always use screen format, landscape.
Size aSz( SvxPaperInfo::GetPaperSize(PAPER_SCREEN_4_3, MapUnit::Map100thMM) );
pPage->SetSize( Size( aSz.Height(), aSz.Width() ) );
2000-09-18 23:16:46 +00:00
pPage->SetBorder(0, 0, 0, 0);
}
InsertPage(pPage, 1);
}
else
{
bClipboard = true;
pPage = static_cast<SdPage*>( GetPage(1) );
2000-09-18 23:16:46 +00:00
}
// Insert master page, then register this with the page
SdPage* pMPage = AllocSdPage(true);
2000-09-18 23:16:46 +00:00
pMPage->SetSize( pPage->GetSize() );
pMPage->SetBorder( pPage->GetLftBorder(),
pPage->GetUppBorder(),
pPage->GetRgtBorder(),
pPage->GetLwrBorder() );
InsertMasterPage(pMPage, 1);
pPage->TRG_SetMasterPage( *pMPage );
2000-09-18 23:16:46 +00:00
if( bClipboard )
pMPage->SetLayoutName( pPage->GetLayoutName() );
// Insert notes page
SdPage* pNotesPage = AllocSdPage(false);
2000-09-18 23:16:46 +00:00
if( pRefDocument )
pRefPage = pRefDocument->GetSdPage( 0, PageKind::Notes );
if( pRefPage )
2000-09-18 23:16:46 +00:00
{
pNotesPage->SetSize( pRefPage->GetSize() );
pNotesPage->SetBorder( pRefPage->GetLftBorder(), pRefPage->GetUppBorder(), pRefPage->GetRgtBorder(), pRefPage->GetLwrBorder() );
2000-09-18 23:16:46 +00:00
}
else
{
// Always use portrait format
if (aDefSize.Height() >= aDefSize.Width())
{
pNotesPage->SetSize(aDefSize);
}
else
{
pNotesPage->SetSize( Size(aDefSize.Height(), aDefSize.Width()) );
}
2000-09-18 23:16:46 +00:00
pNotesPage->SetBorder(0, 0, 0, 0);
}
pNotesPage->SetPageKind(PageKind::Notes);
2000-09-18 23:16:46 +00:00
InsertPage(pNotesPage, 2);
if( bClipboard )
pNotesPage->SetLayoutName( pPage->GetLayoutName() );
// Insert master page, then register this with the notes page
SdPage* pNotesMPage = AllocSdPage(true);
2000-09-18 23:16:46 +00:00
pNotesMPage->SetSize( pNotesPage->GetSize() );
pNotesMPage->SetPageKind(PageKind::Notes);
2000-09-18 23:16:46 +00:00
pNotesMPage->SetBorder( pNotesPage->GetLftBorder(),
pNotesPage->GetUppBorder(),
pNotesPage->GetRgtBorder(),
pNotesPage->GetLwrBorder() );
InsertMasterPage(pNotesMPage, 2);
pNotesPage->TRG_SetMasterPage( *pNotesMPage );
2000-09-18 23:16:46 +00:00
if( bClipboard )
pNotesMPage->SetLayoutName( pPage->GetLayoutName() );
if( !pRefPage && (meDocType != DocumentType::Draw) )
pPage->SetAutoLayout( AUTOLAYOUT_TITLE, true, true );
2010-03-25 13:20:49 +01:00
mpWorkStartupTimer = new Timer("DrawWorkStartupTimer");
mpWorkStartupTimer->SetInvokeHandler( LINK(this, SdDrawDocument, WorkStartupHdl) );
mpWorkStartupTimer->SetTimeout(2000);
mpWorkStartupTimer->Start();
2000-09-18 23:16:46 +00:00
SetChanged(false);
2000-09-18 23:16:46 +00:00
}
}
// Creates missing notes and handout pages (after PowerPoint import).
// We assume that at least one default page and one default master page exist.
2000-09-18 23:16:46 +00:00
bool SdDrawDocument::CreateMissingNotesAndHandoutPages()
2000-09-18 23:16:46 +00:00
{
bool bOK = false;
sal_uInt16 nPageCount = GetPageCount();
2000-09-18 23:16:46 +00:00
if (nPageCount != 0)
{
// Set PageKind
SdPage* pHandoutMPage = static_cast<SdPage*>( GetMasterPage(0) );
pHandoutMPage->SetPageKind(PageKind::Handout);
2000-09-18 23:16:46 +00:00
SdPage* pHandoutPage = static_cast<SdPage*>( GetPage(0) );
pHandoutPage->SetPageKind(PageKind::Handout);
pHandoutPage->TRG_SetMasterPage( *pHandoutMPage );
2000-09-18 23:16:46 +00:00
for (sal_uInt16 i = 1; i < nPageCount; i = i + 2)
2000-09-18 23:16:46 +00:00
{
SdPage* pPage = static_cast<SdPage*>( GetPage(i) );
2000-09-18 23:16:46 +00:00
if(!pPage->TRG_HasMasterPage())
2000-09-18 23:16:46 +00:00
{
// No master page set -> use first default master page
// (If there was no default page in the PPT)
pPage->TRG_SetMasterPage(*GetMasterPage(1));
2000-09-18 23:16:46 +00:00
}
SdPage* pNotesPage = static_cast<SdPage*>( GetPage(i+1) );
pNotesPage->SetPageKind(PageKind::Notes);
2000-09-18 23:16:46 +00:00
// Set notes master page
sal_uInt16 nMasterPageAfterPagesMasterPage = (pPage->TRG_GetMasterPage()).GetPageNum() + 1;
pNotesPage->TRG_SetMasterPage(*GetMasterPage(nMasterPageAfterPagesMasterPage));
2000-09-18 23:16:46 +00:00
}
bOK = true;
2000-09-18 23:16:46 +00:00
StopWorkStartupDelay();
SetChanged(false);
2000-09-18 23:16:46 +00:00
}
return bOK;
2000-09-18 23:16:46 +00:00
}
void SdDrawDocument::UnselectAllPages()
{
sal_uInt16 nNoOfPages = GetSdPageCount(PageKind::Standard);
for (sal_uInt16 nPage = 0; nPage < nNoOfPages; ++nPage)
{
SdPage* pPage = GetSdPage(nPage, PageKind::Standard);
pPage->SetSelected(false);
}
}
// + Move selected pages after said page
// (nTargetPage = (sal_uInt16)-1 --> move before first page)
// + Returns sal_True when the page has been moved
bool SdDrawDocument::MovePages(sal_uInt16 nTargetPage)
2000-09-18 23:16:46 +00:00
{
SdPage* pPage = nullptr;
sal_uInt16 nPage;
sal_uInt16 nNoOfPages = GetSdPageCount(PageKind::Standard);
bool bSomethingHappened = false;
2000-09-18 23:16:46 +00:00
const bool bUndo = IsUndoEnabled();
if( bUndo )
BegUndo(SD_RESSTR(STR_UNDO_MOVEPAGES));
2000-09-18 23:16:46 +00:00
// List of selected pages
std::vector<SdPage*> aPageList;
2000-09-18 23:16:46 +00:00
for (nPage = 0; nPage < nNoOfPages; nPage++)
{
pPage = GetSdPage(nPage, PageKind::Standard);
if (pPage->IsSelected()) {
aPageList.push_back(pPage);
}
2000-09-18 23:16:46 +00:00
}
// If necessary, look backwards, until we find a page that wasn't selected
2000-09-18 23:16:46 +00:00
nPage = nTargetPage;
if (nPage != (sal_uInt16)-1)
2000-09-18 23:16:46 +00:00
{
pPage = GetSdPage(nPage, PageKind::Standard);
2000-09-18 23:16:46 +00:00
while (nPage > 0 && pPage->IsSelected())
{
nPage--;
pPage = GetSdPage(nPage, PageKind::Standard);
2000-09-18 23:16:46 +00:00
}
if (pPage->IsSelected())
{
nPage = (sal_uInt16)-1;
2000-09-18 23:16:46 +00:00
}
}
// Insert before the first page
if (nPage == (sal_uInt16)-1)
2000-09-18 23:16:46 +00:00
{
std::vector<SdPage*>::reverse_iterator iter;
for (iter = aPageList.rbegin(); iter != aPageList.rend(); ++iter)
2000-09-18 23:16:46 +00:00
{
nPage = (*iter)->GetPageNum();
2000-09-18 23:16:46 +00:00
if (nPage != 0)
{
SdrPage* pPg = GetPage(nPage);
if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, 1));
2000-09-18 23:16:46 +00:00
MovePage(nPage, 1);
pPg = GetPage(nPage+1);
if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, 2));
2000-09-18 23:16:46 +00:00
MovePage(nPage+1, 2);
bSomethingHappened = true;
2000-09-18 23:16:46 +00:00
}
}
}
// Insert after <nPage>
2000-09-18 23:16:46 +00:00
else
{
nTargetPage = nPage;
nTargetPage = 2 * nTargetPage + 1; // PageKind::Standard --> absolute
std::vector<SdPage*>::iterator iter;
for (iter = aPageList.begin(); iter != aPageList.end(); ++iter)
2000-09-18 23:16:46 +00:00
{
pPage = *iter;
2000-09-18 23:16:46 +00:00
nPage = pPage->GetPageNum();
if (nPage > nTargetPage)
{
nTargetPage += 2; // Insert _after_ the page
2000-09-18 23:16:46 +00:00
if (nPage != nTargetPage)
{
SdrPage* pPg = GetPage(nPage);
if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, nTargetPage));
2000-09-18 23:16:46 +00:00
MovePage(nPage, nTargetPage);
pPg = GetPage(nPage+1);
if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, nTargetPage+1));
2000-09-18 23:16:46 +00:00
MovePage(nPage+1, nTargetPage+1);
bSomethingHappened = true;
2000-09-18 23:16:46 +00:00
}
}
else
{
if (nPage != nTargetPage)
{
SdrPage* pPg = GetPage(nPage+1);
if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage+1, nTargetPage+1));
2000-09-18 23:16:46 +00:00
MovePage(nPage+1, nTargetPage+1);
pPg = GetPage(nPage);
if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg, nPage, nTargetPage));
2000-09-18 23:16:46 +00:00
MovePage(nPage, nTargetPage);
bSomethingHappened = true;
2000-09-18 23:16:46 +00:00
}
}
nTargetPage = pPage->GetPageNum();
}
}
if( bUndo )
EndUndo();
2000-09-18 23:16:46 +00:00
return bSomethingHappened;
}
// Return number of links in sfx2::LinkManager
sal_uLong SdDrawDocument::GetLinkCount()
2000-09-18 23:16:46 +00:00
{
return pLinkManager->GetLinks().size();
2000-09-18 23:16:46 +00:00
}
// Set Language
void SdDrawDocument::SetLanguage( const LanguageType eLang, const sal_uInt16 nId )
2000-09-18 23:16:46 +00:00
{
bool bChanged = false;
2000-12-08 12:31:46 +00:00
if( nId == EE_CHAR_LANGUAGE && meLanguage != eLang )
2000-12-08 12:31:46 +00:00
{
meLanguage = eLang;
bChanged = true;
2000-12-08 12:31:46 +00:00
}
else if( nId == EE_CHAR_LANGUAGE_CJK && meLanguageCJK != eLang )
2000-12-08 12:31:46 +00:00
{
meLanguageCJK = eLang;
bChanged = true;
2000-12-08 12:31:46 +00:00
}
else if( nId == EE_CHAR_LANGUAGE_CTL && meLanguageCTL != eLang )
2000-12-08 12:31:46 +00:00
{
meLanguageCTL = eLang;
bChanged = true;
2000-12-08 12:31:46 +00:00
}
if( bChanged )
2000-11-27 08:13:01 +00:00
{
GetDrawOutliner().SetDefaultLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() );
pHitTestOutliner->SetDefaultLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() );
2000-12-13 15:05:11 +00:00
pItemPool->SetPoolDefaultItem( SvxLanguageItem( eLang, nId ) );
2000-12-08 12:31:46 +00:00
SetChanged( bChanged );
2000-11-27 08:13:01 +00:00
}
2000-09-18 23:16:46 +00:00
}
// Return language
LanguageType SdDrawDocument::GetLanguage( const sal_uInt16 nId ) const
2000-09-18 23:16:46 +00:00
{
LanguageType eLangType = meLanguage;
2000-11-27 08:13:01 +00:00
2000-12-08 12:31:46 +00:00
if( nId == EE_CHAR_LANGUAGE_CJK )
eLangType = meLanguageCJK;
2000-12-08 12:31:46 +00:00
else if( nId == EE_CHAR_LANGUAGE_CTL )
eLangType = meLanguageCTL;
2000-11-27 08:13:01 +00:00
2000-12-08 12:31:46 +00:00
return eLangType;
2000-09-18 23:16:46 +00:00
}
// Initiate WorkStartup
IMPL_LINK_NOARG(SdDrawDocument, WorkStartupHdl, Timer *, void)
2000-09-18 23:16:46 +00:00
{
if (IsTransportContainer())
return;
if( mpDocSh )
mpDocSh->SetWaitCursor( true );
2000-09-18 23:16:46 +00:00
bool bChanged = IsChanged(); // remember this
2000-09-18 23:16:46 +00:00
// Initialize Autolayouts
SdPage* pHandoutMPage = GetMasterSdPage(0, PageKind::Handout);
2000-09-18 23:16:46 +00:00
if (pHandoutMPage->GetAutoLayout() == AUTOLAYOUT_NONE)
{
// No AutoLayout yet -> initialize
pHandoutMPage->SetAutoLayout(AUTOLAYOUT_HANDOUT6, true, true);
2000-09-18 23:16:46 +00:00
}
SdPage* pPage = GetSdPage(0, PageKind::Standard);
2000-09-18 23:16:46 +00:00
if (pPage->GetAutoLayout() == AUTOLAYOUT_NONE)
{
// No AutoLayout yet -> initialize
pPage->SetAutoLayout(AUTOLAYOUT_NONE, true, true);
2000-09-18 23:16:46 +00:00
}
SdPage* pNotesPage = GetSdPage(0, PageKind::Notes);
2000-09-18 23:16:46 +00:00
if (pNotesPage->GetAutoLayout() == AUTOLAYOUT_NONE)
{
// No AutoLayout yet -> initialize
pNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true);
2000-09-18 23:16:46 +00:00
}
SetChanged(bChanged);
2000-09-18 23:16:46 +00:00
if( mpDocSh )
mpDocSh->SetWaitCursor( false );
2000-09-18 23:16:46 +00:00
}
// When the WorkStartupTimer has been created (this only happens in
// SdDrawViewShell::Construct() ), the timer may be stopped and the WorkStartup
// may be initiated.
2000-09-18 23:16:46 +00:00
void SdDrawDocument::StopWorkStartupDelay()
{
if (mpWorkStartupTimer)
2000-09-18 23:16:46 +00:00
{
if ( mpWorkStartupTimer->IsActive() )
2000-09-18 23:16:46 +00:00
{
// Timer not yet expired -> initiate WorkStartup
mpWorkStartupTimer->Stop();
WorkStartupHdl(nullptr);
2000-09-18 23:16:46 +00:00
}
delete mpWorkStartupTimer;
mpWorkStartupTimer = nullptr;
2000-09-18 23:16:46 +00:00
}
}
// When the WorkStartupTimer has been created (this only happens in
// SdDrawViewShell::Construct() ), the timer may be stopped and the WorkStartup
// may be initiated.
SdAnimationInfo* SdDrawDocument::GetAnimationInfo(SdrObject* pObject)
2000-09-18 23:16:46 +00:00
{
DBG_ASSERT(pObject, "sd::SdDrawDocument::GetAnimationInfo(), invalid argument!");
if( pObject )
return GetShapeUserData( *pObject );
else
return nullptr;
}
SdAnimationInfo* SdDrawDocument::GetShapeUserData(SdrObject& rObject, bool bCreate /* = false */ )
{
sal_uInt16 nUD = 0;
sal_uInt16 nUDCount = rObject.GetUserDataCount();
SdAnimationInfo* pRet = nullptr;
2000-09-18 23:16:46 +00:00
// Can we find animation information within the user data?
2000-09-18 23:16:46 +00:00
for (nUD = 0; nUD < nUDCount; nUD++)
{
SdrObjUserData* pUD = rObject.GetUserData(nUD);
if((pUD->GetInventor() == SdrInventor::StarDrawUserData) && (pUD->GetId() == SD_ANIMATIONINFO_ID))
2000-09-18 23:16:46 +00:00
{
pRet = dynamic_cast<SdAnimationInfo*>(pUD);
break;
2000-09-18 23:16:46 +00:00
}
}
if( (pRet == nullptr) && bCreate )
{
CWS-TOOLING: integrate CWS impress169 2009-05-13 17:37:21 +0200 sj r271865 : #i100942# applied patch, removed oversafe buffer check (now without warnings on 64 bit platform) 2009-05-13 12:27:18 +0200 sj r271855 : #i101769# fixed line/fill attributes for graphic objects 2009-05-12 10:25:17 +0200 cl r271799 : report correct minimum cell hight for empty cells 2009-04-28 17:29:46 +0200 cl r271334 : fixed merge error 2009-04-28 16:18:01 +0200 cl r271330 : fixed build error 2009-04-28 12:38:09 +0200 cl r271320 : #i100129# images for new layouts 2009-04-27 19:12:06 +0200 cl r271302 : CWS-TOOLING: rebase CWS impress169 to trunk@270723 (milestone: DEV300:m46) 2009-04-20 19:13:28 +0200 sj r271012 : #i100942# applied patch, removed oversafe buffer check 2009-04-09 18:00:01 +0200 sj r270719 : #158488# added rectangular gradient support 2009-04-09 17:49:52 +0200 sj r270718 : #158488# added rectangular gradient support 2009-04-09 17:46:24 +0200 sj r270717 : #158488# added rectangular gradient support 2009-03-26 18:16:34 +0100 cl r270098 : #i99867# applied patch from jlcheng to correctly register table design pane 2009-03-26 18:12:11 +0100 cl r270097 : #i100220# leave some items default so they are not overridden if a new table style is set 2009-03-26 18:11:10 +0100 cl r270096 : #i100220# clear only those items that are also in the style when assigning a new table layout 2009-03-26 15:56:24 +0100 cl r270085 : #i99977# listen to outliner and dispose if outliner dies 2009-03-26 15:47:29 +0100 cl r270084 : #i99977# made the Outliner a SfxBroadcaster so others can listen for its death 2009-03-24 19:10:05 +0100 sj r269991 : #i100490# fixed text resize problem 2009-03-23 14:31:11 +0100 sj r269872 : #i96083# added patch, (dubious && and ||) 2009-03-19 17:55:11 +0100 sj r269764 : #i100275# applied patch, row height is now correct even for rows containing no text 2009-03-18 18:10:52 +0100 sj r269701 : #i93616# solved performance problem when loading document 2009-03-18 16:20:40 +0100 sj r269688 : removing unused code 2009-03-18 16:19:22 +0100 sj r269687 : removing unused code 2009-03-18 16:17:54 +0100 sj r269686 : removing unused code 2009-03-18 10:28:07 +0100 cl r269643 : #i100029# let cells be disposed as soon as the table model is disposed 2009-03-17 15:56:50 +0100 cl r269614 : #i99984# new impress photo layouts 3x2 and 2x2 2009-03-17 15:36:35 +0100 cl r269611 : #i99984# adding new impress photo layouts 3x2 and 2x2 2009-03-16 18:43:48 +0100 cl r269564 : #i55224# correct internal links if pages are changed 2009-03-16 16:40:38 +0100 cl r269559 : #i55224# correct internal hyperlinks if slides are changed/renamed 2009-03-16 15:34:12 +0100 cl r269553 : #i99427# invalidate slots after promote/demote 2009-03-13 18:18:20 +0100 sj r269492 : #i92421# fixed loop if loading encrypted ppt file 2009-03-13 14:51:58 +0100 sj r269481 : #i93002# fixed crash if saving presentation without master title placeholder 2009-03-13 12:26:21 +0100 sj r269468 : #i100147# do not exceed the max point count if creating simple polygon via ::GetSimple 2009-03-12 17:00:45 +0100 sj r269427 : #i82518# justifying rectangles for arc/pie and chord actions, fixed round rectangle problem
2009-05-19 09:32:45 +00:00
pRet = new SdAnimationInfo( rObject );
rObject.AppendUserData( pRet);
}
return pRet;
2000-09-18 23:16:46 +00:00
}
SdIMapInfo* SdDrawDocument::GetIMapInfo( SdrObject* pObject )
2000-09-18 23:16:46 +00:00
{
DBG_ASSERT(pObject, "Without an object there is no IMapInfo");
2000-09-18 23:16:46 +00:00
SdIMapInfo* pIMapInfo = nullptr;
sal_uInt16 nCount = pObject->GetUserDataCount();
2000-09-18 23:16:46 +00:00
// Can we find IMap information within the user data?
for ( sal_uInt16 i = 0; i < nCount; i++ )
2000-09-18 23:16:46 +00:00
{
SdrObjUserData* pUserData = pObject->GetUserData( i );
2000-09-18 23:16:46 +00:00
if ( ( pUserData->GetInventor() == SdrInventor::StarDrawUserData ) && ( pUserData->GetId() == SD_IMAPINFO_ID ) )
pIMapInfo = static_cast<SdIMapInfo*>(pUserData);
2000-09-18 23:16:46 +00:00
}
return pIMapInfo;
}
IMapObject* SdDrawDocument::GetHitIMapObject( SdrObject* pObj,
const Point& rWinPoint )
2000-09-18 23:16:46 +00:00
{
SdIMapInfo* pIMapInfo = GetIMapInfo( pObj );
IMapObject* pIMapObj = nullptr;
2000-09-18 23:16:46 +00:00
if ( pIMapInfo )
{
const MapMode aMap100( MapUnit::Map100thMM );
2000-09-18 23:16:46 +00:00
Size aGraphSize;
Point aRelPoint( rWinPoint );
ImageMap& rImageMap = (ImageMap&) pIMapInfo->GetImageMap();
const ::tools::Rectangle& rRect = pObj->GetLogicRect();
bool bObjSupported = false;
2000-09-18 23:16:46 +00:00
// execute HitTest
if ( dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr ) // simple graphics object
2000-09-18 23:16:46 +00:00
{
const SdrGrafObj* pGrafObj = static_cast<const SdrGrafObj*>(pObj);
2000-09-18 23:16:46 +00:00
const GeoStat& rGeo = pGrafObj->GetGeoStat();
SdrGrafObjGeoData* pGeoData = static_cast<SdrGrafObjGeoData*>( pGrafObj->GetGeoData() );
2000-09-18 23:16:46 +00:00
// Undo rotation
if ( rGeo.nRotationAngle )
2000-09-18 23:16:46 +00:00
RotatePoint( aRelPoint, rRect.TopLeft(), -rGeo.nSin, rGeo.nCos );
// Undo mirroring
2000-09-18 23:16:46 +00:00
if ( pGeoData->bMirrored )
aRelPoint.X() = rRect.Right() + rRect.Left() - aRelPoint.X();
// Undo shearing
if ( rGeo.nShearAngle )
2000-09-18 23:16:46 +00:00
ShearPoint( aRelPoint, rRect.TopLeft(), -rGeo.nTan );
if ( pGrafObj->GetGrafPrefMapMode().GetMapUnit() == MapUnit::MapPixel )
2000-09-18 23:16:46 +00:00
aGraphSize = Application::GetDefaultDevice()->PixelToLogic( pGrafObj->GetGrafPrefSize(), aMap100 );
else
aGraphSize = OutputDevice::LogicToLogic( pGrafObj->GetGrafPrefSize(),
pGrafObj->GetGrafPrefMapMode(), aMap100 );
delete pGeoData;
bObjSupported = true;
2000-09-18 23:16:46 +00:00
}
else if ( dynamic_cast<const SdrOle2Obj* >(pObj) != nullptr ) // OLE object
2000-09-18 23:16:46 +00:00
{
aGraphSize = static_cast<SdrOle2Obj*>( pObj )->GetOrigObjSize();
bObjSupported = true;
2000-09-18 23:16:46 +00:00
}
// Everything worked out well, thus execute HitTest
2000-09-18 23:16:46 +00:00
if ( bObjSupported )
{
// Calculate relative position of mouse cursor
2000-09-18 23:16:46 +00:00
aRelPoint -= rRect.TopLeft();
pIMapObj = rImageMap.GetHitIMapObject( aGraphSize, rRect.GetSize(), aRelPoint );
// We don't care about deactivated objects
2000-09-18 23:16:46 +00:00
if ( pIMapObj && !pIMapObj->IsActive() )
pIMapObj = nullptr;
2000-09-18 23:16:46 +00:00
}
}
return pIMapObj;
}
ImageMap* SdDrawDocument::GetImageMapForObject(SdrObject* pObj)
{
SdIMapInfo* pIMapInfo = GetIMapInfo( pObj );
if ( pIMapInfo )
{
return const_cast<ImageMap*>( &(pIMapInfo->GetImageMap()) );
}
return nullptr;
}
2014-04-10 09:58:13 +02:00
/** this method enforces that the masterpages are in the correct order,
that is at position 1 is a PageKind::Standard masterpage followed by a
PageKind::Notes masterpage and so on. #
2002-01-18 14:36:06 +00:00
*/
void SdDrawDocument::CheckMasterPages()
{
sal_uInt16 nMaxPages = GetMasterPageCount();
2002-01-18 14:36:06 +00:00
// we need at least a handout master and one master page
if( nMaxPages < 2 )
{
return;
}
SdPage* pPage = nullptr;
2002-01-18 14:36:06 +00:00
sal_uInt16 nPage;
2002-01-18 14:36:06 +00:00
// first see if the page order is correct
for( nPage = 1; nPage < nMaxPages; nPage++ )
{
pPage = static_cast<SdPage*> (GetMasterPage( nPage ));
// if an odd page is not a standard page or an even page is not a notes page
if( ((1 == (nPage & 1)) && (pPage->GetPageKind() != PageKind::Standard) ) ||
((0 == (nPage & 1)) && (pPage->GetPageKind() != PageKind::Notes) ) )
2002-01-18 14:36:06 +00:00
break; // then we have a fatal error
}
if( nPage < nMaxPages )
{
SdPage* pNotesPage = nullptr;
2002-01-18 14:36:06 +00:00
// there is a fatal error in the master page order,
// we need to repair the document
bool bChanged = false;
2002-01-18 14:36:06 +00:00
nPage = 1;
while( nPage < nMaxPages )
{
pPage = static_cast<SdPage*> (GetMasterPage( nPage ));
if( pPage->GetPageKind() != PageKind::Standard )
2002-01-18 14:36:06 +00:00
{
bChanged = true;
sal_uInt16 nFound = nPage + 1;
2002-01-18 14:36:06 +00:00
while( nFound < nMaxPages )
{
pPage = static_cast<SdPage*>(GetMasterPage( nFound ));
if( PageKind::Standard == pPage->GetPageKind() )
2002-01-18 14:36:06 +00:00
{
MoveMasterPage( nFound, nPage );
pPage->SetInserted();
2002-01-18 14:36:06 +00:00
break;
}
nFound++;
}
// if we don't have any more standard pages, were done
if( nMaxPages == nFound )
break;
}
nPage++;
if( nPage < nMaxPages )
pNotesPage = static_cast<SdPage*>(GetMasterPage( nPage ));
else
pNotesPage = nullptr;
2002-01-18 14:36:06 +00:00
if( (nullptr == pNotesPage) || (pNotesPage->GetPageKind() != PageKind::Notes) || ( pPage->GetLayoutName() != pNotesPage->GetLayoutName() ) )
2002-01-18 14:36:06 +00:00
{
bChanged = true;
2002-01-18 14:36:06 +00:00
sal_uInt16 nFound = nPage + 1;
2002-01-18 14:36:06 +00:00
while( nFound < nMaxPages )
{
pNotesPage = static_cast<SdPage*>(GetMasterPage( nFound ));
if( (PageKind::Notes == pNotesPage->GetPageKind()) && ( pPage->GetLayoutName() == pNotesPage->GetLayoutName() ) )
2002-01-18 14:36:06 +00:00
{
MoveMasterPage( nFound, nPage );
pNotesPage->SetInserted();
2002-01-18 14:36:06 +00:00
break;
}
2000-09-18 23:16:46 +00:00
2002-01-18 14:36:06 +00:00
nFound++;
}
// looks like we lost a notes page
if( nMaxPages == nFound )
{
// so create one
2000-09-18 23:16:46 +00:00
2002-01-18 14:36:06 +00:00
// first find a reference notes page for size
SdPage* pRefNotesPage = nullptr;
2002-01-18 14:36:06 +00:00
nFound = 0;
while( nFound < nMaxPages )
{
pRefNotesPage = static_cast<SdPage*>(GetMasterPage( nFound ));
if( PageKind::Notes == pRefNotesPage->GetPageKind() )
2002-01-18 14:36:06 +00:00
break;
nFound++;
}
if( nFound == nMaxPages )
pRefNotesPage = nullptr;
2002-01-18 14:36:06 +00:00
SdPage* pNewNotesPage = AllocSdPage(true);
pNewNotesPage->SetPageKind(PageKind::Notes);
2002-01-18 14:36:06 +00:00
if( pRefNotesPage )
{
pNewNotesPage->SetSize( pRefNotesPage->GetSize() );
pNewNotesPage->SetBorder( pRefNotesPage->GetLftBorder(),
2002-01-18 14:36:06 +00:00
pRefNotesPage->GetUppBorder(),
pRefNotesPage->GetRgtBorder(),
pRefNotesPage->GetLwrBorder() );
}
InsertMasterPage(pNewNotesPage, nPage );
pNewNotesPage->SetLayoutName( pPage->GetLayoutName() );
pNewNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true );
2002-01-18 14:36:06 +00:00
nMaxPages++;
}
}
nPage++;
}
// now remove all remaining and unused non PageKind::Standard slides
2002-01-18 14:36:06 +00:00
while( nPage < nMaxPages )
{
bChanged = true;
2002-01-18 14:36:06 +00:00
RemoveMasterPage( nPage );
nMaxPages--;
}
if( bChanged )
{
2011-03-01 19:06:55 +01:00
OSL_FAIL( "master pages where in a wrong order" );
RecalcPageNums( true);
2002-01-18 14:36:06 +00:00
}
}
}
sal_uInt16 SdDrawDocument::CreatePage (
SdPage* pActualPage,
PageKind ePageKind,
const OUString& sStandardPageName,
const OUString& sNotesPageName,
AutoLayout eStandardLayout,
AutoLayout eNotesLayout,
bool bIsPageBack,
bool bIsPageObj,
const sal_Int32 nInsertPosition)
{
SdPage* pPreviousStandardPage;
SdPage* pPreviousNotesPage;
SdPage* pStandardPage;
SdPage* pNotesPage;
// From the given page determine the standard page and notes page of which
// to take the layout and the position where to insert the new pages.
if (ePageKind == PageKind::Notes)
{
pPreviousNotesPage = pActualPage;
sal_uInt16 nNotesPageNum = pPreviousNotesPage->GetPageNum() + 2;
pPreviousStandardPage = static_cast<SdPage*>( GetPage(nNotesPageNum - 3) );
eStandardLayout = pPreviousStandardPage->GetAutoLayout();
}
else
{
pPreviousStandardPage = pActualPage;
sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
pPreviousNotesPage = static_cast<SdPage*>( GetPage(nStandardPageNum - 1) );
eNotesLayout = pPreviousNotesPage->GetAutoLayout();
}
// Create new standard page and set it up
pStandardPage = AllocSdPage(false);
// Set the size here since else the presobj autolayout
// will be wrong.
pStandardPage->SetSize( pPreviousStandardPage->GetSize() );
pStandardPage->SetBorder( pPreviousStandardPage->GetLftBorder(),
pPreviousStandardPage->GetUppBorder(),
pPreviousStandardPage->GetRgtBorder(),
pPreviousStandardPage->GetLwrBorder() );
// Use master page of current page.
pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage());
// User layout of current standard page
pStandardPage->SetLayoutName( pPreviousStandardPage->GetLayoutName() );
pStandardPage->SetAutoLayout(eStandardLayout, true);
pStandardPage->setHeaderFooterSettings( pPreviousStandardPage->getHeaderFooterSettings() );
// transition settings of current page
pStandardPage->setTransitionType( pPreviousStandardPage->getTransitionType() );
pStandardPage->setTransitionSubtype( pPreviousStandardPage->getTransitionSubtype() );
pStandardPage->setTransitionDirection( pPreviousStandardPage->getTransitionDirection() );
pStandardPage->setTransitionFadeColor( pPreviousStandardPage->getTransitionFadeColor() );
pStandardPage->setTransitionDuration( pPreviousStandardPage->getTransitionDuration() );
// apply previous animation timing
pStandardPage->SetPresChange( pPreviousStandardPage->GetPresChange() );
pStandardPage->SetTime( pPreviousStandardPage->GetTime() );
// Create new notes page and set it up
pNotesPage = AllocSdPage(false);
pNotesPage->SetPageKind(PageKind::Notes);
// Use master page of current page
pNotesPage->TRG_SetMasterPage(pPreviousNotesPage->TRG_GetMasterPage());
// Use layout of current notes page
pNotesPage->SetLayoutName( pPreviousNotesPage->GetLayoutName() );
pNotesPage->SetAutoLayout(eNotesLayout, true);
pNotesPage->setHeaderFooterSettings( pPreviousNotesPage->getHeaderFooterSettings() );
return InsertPageSet (
pActualPage,
ePageKind,
sStandardPageName,
sNotesPageName,
bIsPageBack,
bIsPageObj,
pStandardPage,
pNotesPage,
nInsertPosition);
}
sal_uInt16 SdDrawDocument::DuplicatePage (sal_uInt16 nPageNum)
{
PageKind ePageKind = PageKind::Standard;
// Get current page
SdPage* pActualPage = GetSdPage(nPageNum, ePageKind);
// Get background flags
SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
SdrLayerIDSet aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
return DuplicatePage (
pActualPage, ePageKind,
// No names for the new slides
OUString(), OUString(),
aVisibleLayers.IsSet(aBckgrnd),
aVisibleLayers.IsSet(aBckgrndObj), -1);
}
sal_uInt16 SdDrawDocument::DuplicatePage (
SdPage* pActualPage,
PageKind ePageKind,
const OUString& sStandardPageName,
const OUString& sNotesPageName,
bool bIsPageBack,
bool bIsPageObj,
const sal_Int32 nInsertPosition)
{
SdPage* pPreviousStandardPage;
SdPage* pPreviousNotesPage;
SdPage* pStandardPage;
SdPage* pNotesPage;
// From the given page determine the standard page and the notes page
// of which to make copies.
if (ePageKind == PageKind::Notes)
{
pPreviousNotesPage = pActualPage;
sal_uInt16 nNotesPageNum = pPreviousNotesPage->GetPageNum() + 2;
pPreviousStandardPage = static_cast<SdPage*>( GetPage(nNotesPageNum - 3) );
}
else
{
pPreviousStandardPage = pActualPage;
sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
pPreviousNotesPage = static_cast<SdPage*>( GetPage(nStandardPageNum - 1) );
}
// Create duplicates of a standard page and the associated notes page
pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->Clone() );
pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->Clone() );
return InsertPageSet (
pActualPage,
ePageKind,
sStandardPageName,
sNotesPageName,
bIsPageBack,
bIsPageObj,
pStandardPage,
pNotesPage,
nInsertPosition);
}
sal_uInt16 SdDrawDocument::InsertPageSet (
SdPage* pActualPage,
PageKind ePageKind,
const OUString& sStandardPageName,
const OUString& sNotesPageName,
bool bIsPageBack,
bool bIsPageObj,
SdPage* pStandardPage,
SdPage* pNotesPage,
sal_Int32 nInsertPosition)
{
SdPage* pPreviousStandardPage;
SdPage* pPreviousNotesPage;
sal_uInt16 nStandardPageNum;
sal_uInt16 nNotesPageNum;
OUString aNotesPageName(sNotesPageName);
// Gather some information about the standard page and the notes page
// that are to be inserted. This makes sure that there is always one
// standard page followed by one notes page.
if (ePageKind == PageKind::Notes)
{
pPreviousNotesPage = pActualPage;
nNotesPageNum = pPreviousNotesPage->GetPageNum() + 2;
pPreviousStandardPage = static_cast<SdPage*>( GetPage(nNotesPageNum - 3) );
nStandardPageNum = nNotesPageNum - 1;
}
else
{
pPreviousStandardPage = pActualPage;
nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
pPreviousNotesPage = static_cast<SdPage*>( GetPage(nStandardPageNum - 1) );
nNotesPageNum = nStandardPageNum + 1;
aNotesPageName = sStandardPageName;
}
OSL_ASSERT(nNotesPageNum==nStandardPageNum+1);
if (nInsertPosition < 0)
nInsertPosition = nStandardPageNum;
// Set up and insert the standard page
SetupNewPage (
pPreviousStandardPage,
pStandardPage,
sStandardPageName,
nInsertPosition,
bIsPageBack,
bIsPageObj);
// Set up and insert the notes page
pNotesPage->SetPageKind(PageKind::Notes);
SetupNewPage (
pPreviousNotesPage,
pNotesPage,
aNotesPageName,
nInsertPosition+1,
bIsPageBack,
bIsPageObj);
// Return an index that allows the caller to access the newly inserted
// pages by using GetSdPage()
return pStandardPage->GetPageNum() / 2;
}
void SdDrawDocument::SetupNewPage (
SdPage* pPreviousPage,
SdPage* pPage,
const OUString& sPageName,
sal_uInt16 nInsertionPoint,
bool bIsPageBack,
bool bIsPageObj)
{
if (pPreviousPage != nullptr)
{
pPage->SetSize( pPreviousPage->GetSize() );
pPage->SetBorder( pPreviousPage->GetLftBorder(),
pPreviousPage->GetUppBorder(),
pPreviousPage->GetRgtBorder(),
pPreviousPage->GetLwrBorder() );
}
pPage->SetName(sPageName);
InsertPage(pPage, nInsertionPoint);
if (pPreviousPage != nullptr)
{
SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND));
SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
SdrLayerIDSet aVisibleLayers = pPreviousPage->TRG_GetMasterPageVisibleLayers();
aVisibleLayers.Set(aBckgrnd, bIsPageBack);
aVisibleLayers.Set(aBckgrndObj, bIsPageObj);
pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
}
}
sd::UndoManager* SdDrawDocument::GetUndoManager() const
{
return mpDocSh ? dynamic_cast< sd::UndoManager* >(mpDocSh->GetUndoManager()) : nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */