1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
32 #include <com/sun/star/embed/XVisualObject.hpp>
33 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
34 #include <vcl/wrkwin.hxx>
35 #include <sfx2/printer.hxx>
36 #include <sfx2/app.hxx>
37 #ifndef SD_OUTLINE_HXX
38 #include "Outliner.hxx"
40 #include <editeng/paperinf.hxx>
41 #include <svx/svdopage.hxx>
42 #include <svx/svdoole2.hxx>
43 #include <svx/svdotext.hxx>
44 #include <svx/svdograf.hxx>
45 #include <svx/svdundo.hxx>
46 #include <vcl/svapp.hxx>
47 #include <editeng/eeitem.hxx>
48 #include <editeng/langitem.hxx>
49 #include <svl/itempool.hxx>
50 #include <svx/svdpool.hxx>
51 #include <editeng/flditem.hxx>
53 #include <sfx2/linkmgr.hxx>
54 #include <editeng/editdata.hxx>
55 #include <svx/dialogs.hrc>
56 #include <svx/dialmgr.hxx> // SVX_RESSTR
59 #include <svx/svditer.hxx>
60 #include <svtools/imapobj.hxx>
63 #include "sdresid.hxx"
64 #include "drawdoc.hxx"
69 #include "stlpool.hxx"
70 #include "sdiocmpt.hxx"
71 #include "anminfo.hxx"
72 #include "imapinfo.hxx"
73 #include "cusshow.hxx"
74 #include "undo/undomanager.hxx"
76 #include "../ui/inc/DrawDocShell.hxx"
77 #include "../ui/inc/FrameView.hxx"
78 #include "../ui/inc/cfgids.hxx"
79 #include "../ui/inc/strings.hrc"
81 #include "PageListWatcher.hxx"
82 #include <vcl/virdev.hxx>
86 const long PRINT_OFFSET
= 30; // siehe \svx\source\dialog\page.cxx (PB)
88 using namespace com::sun::star
;
90 /*************************************************************************
92 |* Sucht ein Objekt per Name
94 \************************************************************************/
96 SdrObject
* SdDrawDocument::GetObj(const String
& rObjName
) const
98 SdrObject
* pObj
= NULL
;
99 SdrObject
* pObjFound
= NULL
;
100 SdPage
* pPage
= NULL
;
102 /**************************************************************************
103 * Zuerst alle Pages durchsuchen
104 **************************************************************************/
105 sal_uInt16 nPage
= 0;
106 const sal_uInt16 nMaxPages
= GetPageCount();
108 while (nPage
< nMaxPages
&& !pObjFound
)
110 pPage
= (SdPage
*) GetPage(nPage
);
111 SdrObjListIter
aIter(*pPage
, IM_DEEPWITHGROUPS
);
113 while (aIter
.IsMore() && !pObjFound
)
117 if( ( rObjName
== pObj
->GetName() ) ||
118 ( SdrInventor
== pObj
->GetObjInventor() &&
119 OBJ_OLE2
== pObj
->GetObjIdentifier() &&
120 rObjName
== static_cast< SdrOle2Obj
* >( pObj
)->GetPersistName() ) )
129 /**************************************************************************
130 * Wenn nicht gefunden, dann alle MasterPages durchsuchen
131 **************************************************************************/
133 const sal_uInt16 nMaxMasterPages
= GetMasterPageCount();
135 while (nPage
< nMaxMasterPages
&& !pObjFound
)
137 pPage
= (SdPage
*) GetMasterPage(nPage
);
138 SdrObjListIter
aIter(*pPage
, IM_DEEPWITHGROUPS
);
140 while (aIter
.IsMore() && !pObjFound
)
144 if( ( rObjName
== pObj
->GetName() ) ||
145 ( SdrInventor
== pObj
->GetObjInventor() &&
146 OBJ_OLE2
== pObj
->GetObjIdentifier() &&
147 rObjName
== static_cast< SdrOle2Obj
* >( pObj
)->GetPersistName() ) )
160 /*************************************************************************
162 |* Sucht die SdPage per Name
164 \************************************************************************/
166 sal_uInt16
SdDrawDocument::GetPageByName(const String
& rPgName
, sal_Bool
& rbIsMasterPage
) const
168 SdPage
* pPage
= NULL
;
169 sal_uInt16 nPage
= 0;
170 const sal_uInt16 nMaxPages
= GetPageCount();
171 sal_uInt16 nPageNum
= SDRPAGE_NOTFOUND
;
173 rbIsMasterPage
= sal_False
;
175 // Search all regular pages and all notes pages (handout pages are
177 while (nPage
< nMaxPages
&& nPageNum
== SDRPAGE_NOTFOUND
)
179 pPage
= const_cast<SdPage
*>(static_cast<const SdPage
*>(
183 && pPage
->GetPageKind() != PK_HANDOUT
184 && pPage
->GetName() == rPgName
)
192 // Search all master pages when not found among non-master pages.
193 const sal_uInt16 nMaxMasterPages
= GetMasterPageCount();
196 while (nPage
< nMaxMasterPages
&& nPageNum
== SDRPAGE_NOTFOUND
)
198 pPage
= const_cast<SdPage
*>(static_cast<const SdPage
*>(
199 GetMasterPage(nPage
)));
201 if (pPage
&& pPage
->GetName() == rPgName
)
204 rbIsMasterPage
= sal_True
;
214 /*************************************************************************
218 \************************************************************************/
220 SdPage
* SdDrawDocument::GetSdPage(sal_uInt16 nPgNum
, PageKind ePgKind
) const
223 return mpDrawPageListWatcher
->GetSdPage(ePgKind
, sal_uInt32(nPgNum
));
226 /*************************************************************************
230 \************************************************************************/
232 sal_uInt16
SdDrawDocument::GetSdPageCount(PageKind ePgKind
) const
235 return (sal_uInt16
)mpDrawPageListWatcher
->GetSdPageCount(ePgKind
);
238 /*************************************************************************
242 \************************************************************************/
244 SdPage
* SdDrawDocument::GetMasterSdPage(sal_uInt16 nPgNum
, PageKind ePgKind
)
247 return mpMasterPageListWatcher
->GetSdPage(ePgKind
, sal_uInt32(nPgNum
));
250 /*************************************************************************
254 \************************************************************************/
256 sal_uInt16
SdDrawDocument::GetMasterSdPageCount(PageKind ePgKind
) const
259 return (sal_uInt16
)mpMasterPageListWatcher
->GetSdPageCount(ePgKind
);
262 /*************************************************************************
264 |* die in den Seitenobjekten der Notizseiten eingetragenen
265 |* Seitennummern anpassen
267 \************************************************************************/
269 void SdDrawDocument::UpdatePageObjectsInNotes(sal_uInt16 nStartPos
)
271 sal_uInt16 nPageCount
= GetPageCount();
272 SdPage
* pPage
= NULL
;
274 for (sal_uInt16 nPage
= nStartPos
; nPage
< nPageCount
; nPage
++)
276 pPage
= (SdPage
*)GetPage(nPage
);
278 // wenn es eine Notizseite ist, Seitenobjekt suchen
279 // und Nummer korrigieren
280 if (pPage
&& pPage
->GetPageKind() == PK_NOTES
)
282 sal_uLong nObjCount
= pPage
->GetObjCount();
283 SdrObject
* pObj
= NULL
;
284 for (sal_uLong nObj
= 0; nObj
< nObjCount
; nObj
++)
286 pObj
= pPage
->GetObj(nObj
);
287 if (pObj
->GetObjIdentifier() == OBJ_PAGE
&&
288 pObj
->GetObjInventor() == SdrInventor
)
290 // das Seitenobjekt stellt die vorhergende Seite (also
291 // die Zeichenseite) dar
292 DBG_ASSERTWARNING(nStartPos
, "Notizseitenpos. darf nicht 0 sein");
294 DBG_ASSERTWARNING(nPage
> 1, "Seitenobjekt darf nicht Handzettel darstellen");
296 if (nStartPos
> 0 && nPage
> 1)
297 ((SdrPageObj
*)pObj
)->SetReferencedPage(GetPage(nPage
- 1));
304 void SdDrawDocument::UpdatePageRelativeURLs(const String
& rOldName
, const String
& rNewName
)
306 if (rNewName
.Len() == 0)
309 SfxItemPool
& pPool(GetPool());
310 sal_uInt32 nCount
= pPool
.GetItemCount2(EE_FEATURE_FIELD
);
311 for (sal_uInt32 nOff
= 0; nOff
< nCount
; nOff
++)
313 const SfxPoolItem
*pItem
= pPool
.GetItem2(EE_FEATURE_FIELD
, nOff
);
314 const SvxFieldItem
* pFldItem
= dynamic_cast< const SvxFieldItem
* > (pItem
);
318 SvxURLField
* pURLField
= const_cast< SvxURLField
* >( dynamic_cast<const SvxURLField
*>( pFldItem
->GetField() ) );
322 XubString aURL
= pURLField
->GetURL();
324 if (aURL
.Len() && (aURL
.GetChar(0) == 35) && (aURL
.Search(rOldName
, 1) == 1))
326 if (aURL
.Len() == rOldName
.Len() + 1) // standard page name
328 aURL
.Erase (1, aURL
.Len() - 1);
330 pURLField
->SetURL(aURL
);
334 const XubString sNotes
= SdResId(STR_NOTES
);
335 if (aURL
.Len() == rOldName
.Len() + 2 + sNotes
.Len() && aURL
.Search(sNotes
, rOldName
.Len() + 2) == rOldName
.Len() + 2)
337 aURL
.Erase (1, aURL
.Len() - 1);
341 pURLField
->SetURL(aURL
);
350 void SdDrawDocument::UpdatePageRelativeURLs(SdPage
* pPage
, sal_uInt16 nPos
, sal_Int32 nIncrement
)
352 bool bNotes
= (pPage
->GetPageKind() == PK_NOTES
);
354 SfxItemPool
& pPool(GetPool());
355 sal_uInt32 nCount
= pPool
.GetItemCount2(EE_FEATURE_FIELD
);
356 for (sal_uInt32 nOff
= 0; nOff
< nCount
; nOff
++)
358 const SfxPoolItem
*pItem
= pPool
.GetItem2(EE_FEATURE_FIELD
, nOff
);
359 const SvxFieldItem
* pFldItem
;
361 if ((pFldItem
= dynamic_cast< const SvxFieldItem
* > (pItem
)) != 0)
363 SvxURLField
* pURLField
= const_cast< SvxURLField
* >( dynamic_cast<const SvxURLField
*>( pFldItem
->GetField() ) );
367 XubString aURL
= pURLField
->GetURL();
369 if (aURL
.Len() && (aURL
.GetChar(0) == 35))
371 XubString
aHashSlide('#');
372 aHashSlide
+= SdResId(STR_PAGE
);
374 if (aURL
.CompareTo(aHashSlide
, aHashSlide
.Len()) == COMPARE_EQUAL
)
376 XubString aURLCopy
= aURL
;
377 const XubString sNotes
= SdResId(STR_NOTES
);
379 aURLCopy
.Erase(0, aHashSlide
.Len());
381 bool bNotesLink
= (aURLCopy
.Len() >= sNotes
.Len() + 3 && aURLCopy
.Search(sNotes
, aURLCopy
.Len() - sNotes
.Len()) == aURLCopy
.Len() - sNotes
.Len());
383 if (bNotesLink
^ bNotes
)
384 continue; // no compatible link and page
387 aURLCopy
.Erase(aURLCopy
.Len() - sNotes
.Len(), sNotes
.Len());
389 sal_Int32 number
= aURLCopy
.ToInt32();
390 sal_uInt16 realPageNumber
= (nPos
+ 1)/ 2;
392 if ( number
>= realPageNumber
)
394 // update link page number
395 number
+= nIncrement
;
396 aURL
.Erase (aHashSlide
.Len() + 1, aURL
.Len() - aHashSlide
.Len() - 1);
397 aURL
+= XubString::CreateFromInt32(number
);
403 pURLField
->SetURL(aURL
);
412 /*************************************************************************
416 \************************************************************************/
418 void SdDrawDocument::MovePage(sal_uInt16 nPgNum
, sal_uInt16 nNewPos
)
421 FmFormModel::MovePage(nPgNum
, nNewPos
);
423 sal_uInt16 nMin
= Min(nPgNum
, nNewPos
);
425 UpdatePageObjectsInNotes(nMin
);
428 /*************************************************************************
432 \************************************************************************/
434 void SdDrawDocument::InsertPage(SdrPage
* pPage
, sal_uInt16 nPos
)
436 bool bLast
= (nPos
== GetPageCount());
438 FmFormModel::InsertPage(pPage
, nPos
);
440 ((SdPage
*)pPage
)->ConnectLink();
442 UpdatePageObjectsInNotes(nPos
);
445 UpdatePageRelativeURLs(static_cast<SdPage
*>( pPage
), nPos
, 1);
449 /*************************************************************************
453 \************************************************************************/
455 void SdDrawDocument::DeletePage(sal_uInt16 nPgNum
)
457 FmFormModel::DeletePage(nPgNum
);
459 UpdatePageObjectsInNotes(nPgNum
);
462 /*************************************************************************
466 \************************************************************************/
468 SdrPage
* SdDrawDocument::RemovePage(sal_uInt16 nPgNum
)
470 SdrPage
* pPage
= FmFormModel::RemovePage(nPgNum
);
472 bool bLast
= ((nPgNum
+1)/2 == (GetPageCount()+1)/2);
474 ((SdPage
*)pPage
)->DisconnectLink();
475 ReplacePageInCustomShows( dynamic_cast< SdPage
* >( pPage
), 0 );
476 UpdatePageObjectsInNotes(nPgNum
);
479 UpdatePageRelativeURLs((SdPage
*)pPage
, nPgNum
, -1);
484 // Warning: This is not called for new master pages created from SdrModel::Merge,
485 // you also have to modify code in SdDrawDocument::Merge!
486 void SdDrawDocument::InsertMasterPage(SdrPage
* pPage
, sal_uInt16 nPos
)
488 FmFormModel::InsertMasterPage( pPage
, nPos
);
489 if( pPage
&& pPage
->IsMasterPage() && (static_cast<SdPage
*>(pPage
)->GetPageKind() == PK_STANDARD
) )
491 // new master page created, add its style family
492 SdStyleSheetPool
* pStylePool
= (SdStyleSheetPool
*) GetStyleSheetPool();
494 pStylePool
->AddStyleFamily( static_cast<SdPage
*>(pPage
) );
498 SdrPage
* SdDrawDocument::RemoveMasterPage(sal_uInt16 nPgNum
)
500 SdPage
* pPage
= static_cast<SdPage
*>(GetMasterPage(nPgNum
));
501 if( pPage
&& pPage
->IsMasterPage() && (pPage
->GetPageKind() == PK_STANDARD
) )
503 // master page removed, remove its style family
504 SdStyleSheetPool
* pStylePool
= (SdStyleSheetPool
*) GetStyleSheetPool();
506 pStylePool
->RemoveStyleFamily( pPage
);
509 return FmFormModel::RemoveMasterPage(nPgNum
);
512 /*************************************************************************
514 |* Seiten selektieren
516 \************************************************************************/
518 void SdDrawDocument::SetSelected(SdPage
* pPage
, sal_Bool bSelect
)
520 PageKind ePageKind
= pPage
->GetPageKind();
522 if (ePageKind
== PK_STANDARD
)
524 pPage
->SetSelected(bSelect
);
526 const sal_uInt16
nDestPageNum(pPage
->GetPageNum() + 1);
527 SdPage
* pNotesPage
= 0L;
529 if(nDestPageNum
< GetPageCount())
531 pNotesPage
= (SdPage
*)GetPage(nDestPageNum
);
534 if (pNotesPage
&& pNotesPage
->GetPageKind() == PK_NOTES
)
536 pNotesPage
->SetSelected(bSelect
);
539 else if (ePageKind
== PK_NOTES
)
541 pPage
->SetSelected(bSelect
);
542 SdPage
* pStandardPage
= (SdPage
*) GetPage( pPage
->GetPageNum() - 1 );
544 if (pStandardPage
&& pStandardPage
->GetPageKind() == PK_STANDARD
)
545 pStandardPage
->SetSelected(bSelect
);
549 /*************************************************************************
551 |* Sofern noch keine Seiten vorhanden sind, werden nun Seiten erzeugt
553 \************************************************************************/
555 void SdDrawDocument::CreateFirstPages( SdDrawDocument
* pRefDocument
/* = 0 */ )
557 /**************************************************************************
558 * Wenn noch keine Seite im Model vorhanden ist (Datei-Neu), wird
559 * eine neue Seite eingefuegt
560 **************************************************************************/
561 sal_uInt16 nPageCount
= GetPageCount();
565 // #i57181# Paper size depends on Language, like in Writer
566 Size aDefSize
= SvxPaperInfo::GetDefaultPaperSize( MAP_100TH_MM
);
568 /**********************************************************************
569 * Handzettel-Seite einfuegen
570 **********************************************************************/
571 sal_Bool bMasterPage
;
572 SdPage
* pHandoutPage
= dynamic_cast< SdPage
* >( AllocPage(bMasterPage
=sal_False
) );
574 SdPage
* pRefPage
= NULL
;
577 pRefPage
= pRefDocument
->GetSdPage( 0, PK_HANDOUT
);
581 pHandoutPage
->SetSize(pRefPage
->GetSize());
582 pHandoutPage
->SetBorder( pRefPage
->GetLftBorder(), pRefPage
->GetUppBorder(), pRefPage
->GetRgtBorder(), pRefPage
->GetLwrBorder() );
586 pHandoutPage
->SetSize(aDefSize
);
587 pHandoutPage
->SetBorder(0, 0, 0, 0);
590 pHandoutPage
->SetPageKind(PK_HANDOUT
);
591 pHandoutPage
->SetName( String (SdResId(STR_HANDOUT
) ) );
592 InsertPage(pHandoutPage
, 0);
594 /**********************************************************************
595 * MasterPage einfuegen und an der Handzettel-Seite vermerken
596 **********************************************************************/
597 SdPage
* pHandoutMPage
= (SdPage
*) AllocPage(bMasterPage
=sal_True
);
598 pHandoutMPage
->SetSize( pHandoutPage
->GetSize() );
599 pHandoutMPage
->SetPageKind(PK_HANDOUT
);
600 pHandoutMPage
->SetBorder( pHandoutPage
->GetLftBorder(),
601 pHandoutPage
->GetUppBorder(),
602 pHandoutPage
->GetRgtBorder(),
603 pHandoutPage
->GetLwrBorder() );
604 InsertMasterPage(pHandoutMPage
, 0);
605 pHandoutPage
->TRG_SetMasterPage( *pHandoutMPage
);
607 /**********************************************************************
609 * Sofern nPageCount==1 ist, wurde das Model fuers Clipboad erzeugt.
610 * Eine Standard-Seite ist daher schon vorhanden.
611 **********************************************************************/
613 sal_Bool bClipboard
= sal_False
;
616 pRefPage
= pRefDocument
->GetSdPage( 0, PK_STANDARD
);
620 pPage
= dynamic_cast< SdPage
* >( AllocPage(bMasterPage
=sal_False
) );
624 pPage
->SetSize( pRefPage
->GetSize() );
625 pPage
->SetBorder( pRefPage
->GetLftBorder(), pRefPage
->GetUppBorder(), pRefPage
->GetRgtBorder(), pRefPage
->GetLwrBorder() );
627 else if (meDocType
== DOCUMENT_TYPE_DRAW
)
629 // Draw: stets Default-Groesse mit Raendern
630 pPage
->SetSize(aDefSize
);
632 SfxPrinter
* pPrinter
= mpDocSh
->GetPrinter(sal_False
);
633 if (pPrinter
&& pPrinter
->IsValid())
635 Size
aOutSize(pPrinter
->GetOutputSize());
636 Point
aPageOffset(pPrinter
->GetPageOffset());
637 aPageOffset
-= pPrinter
->PixelToLogic( Point() );
638 long nOffset
= !aPageOffset
.X() && !aPageOffset
.X() ? 0 : PRINT_OFFSET
;
640 sal_uLong nTop
= aPageOffset
.Y();
641 sal_uLong nLeft
= aPageOffset
.X();
642 sal_uLong nBottom
= Max((long)(aDefSize
.Height() - aOutSize
.Height() - nTop
+ nOffset
), 0L);
643 sal_uLong nRight
= Max((long)(aDefSize
.Width() - aOutSize
.Width() - nLeft
+ nOffset
), 0L);
645 pPage
->SetBorder(nLeft
, nTop
, nRight
, nBottom
);
649 // The printer is not available. Use a border of 10mm
650 // on each side instead.
651 // This has to be kept synchronized with the border
653 // SvxPageDescPage::PaperSizeSelect_Impl callback.
654 pPage
->SetBorder(1000, 1000, 1000, 1000);
659 // Impress: stets Bildschirmformat, quer
660 Size
aSz( SvxPaperInfo::GetPaperSize(PAPER_SCREEN
, MAP_100TH_MM
) );
661 pPage
->SetSize( Size( aSz
.Height(), aSz
.Width() ) );
662 pPage
->SetBorder(0, 0, 0, 0);
665 InsertPage(pPage
, 1);
669 bClipboard
= sal_True
;
670 pPage
= (SdPage
*) GetPage(1);
673 /**********************************************************************
674 * MasterPage einfuegen und an der Seite vermerken
675 **********************************************************************/
676 SdPage
* pMPage
= (SdPage
*) AllocPage(bMasterPage
=sal_True
);
677 pMPage
->SetSize( pPage
->GetSize() );
678 pMPage
->SetBorder( pPage
->GetLftBorder(),
679 pPage
->GetUppBorder(),
680 pPage
->GetRgtBorder(),
681 pPage
->GetLwrBorder() );
682 InsertMasterPage(pMPage
, 1);
683 pPage
->TRG_SetMasterPage( *pMPage
);
685 pMPage
->SetLayoutName( pPage
->GetLayoutName() );
687 /**********************************************************************
688 * Notizen-Seite einfuegen
689 **********************************************************************/
690 SdPage
* pNotesPage
= (SdPage
*) AllocPage(bMasterPage
=sal_False
);
693 pRefPage
= pRefDocument
->GetSdPage( 0, PK_NOTES
);
697 pNotesPage
->SetSize( pRefPage
->GetSize() );
698 pNotesPage
->SetBorder( pRefPage
->GetLftBorder(), pRefPage
->GetUppBorder(), pRefPage
->GetRgtBorder(), pRefPage
->GetLwrBorder() );
703 if (aDefSize
.Height() >= aDefSize
.Width())
705 pNotesPage
->SetSize(aDefSize
);
709 pNotesPage
->SetSize( Size(aDefSize
.Height(), aDefSize
.Width()) );
712 pNotesPage
->SetBorder(0, 0, 0, 0);
714 pNotesPage
->SetPageKind(PK_NOTES
);
715 InsertPage(pNotesPage
, 2);
717 pNotesPage
->SetLayoutName( pPage
->GetLayoutName() );
719 /**********************************************************************
720 * MasterPage einfuegen und an der Notizen-Seite vermerken
721 **********************************************************************/
722 SdPage
* pNotesMPage
= (SdPage
*) AllocPage(bMasterPage
=sal_True
);
723 pNotesMPage
->SetSize( pNotesPage
->GetSize() );
724 pNotesMPage
->SetPageKind(PK_NOTES
);
725 pNotesMPage
->SetBorder( pNotesPage
->GetLftBorder(),
726 pNotesPage
->GetUppBorder(),
727 pNotesPage
->GetRgtBorder(),
728 pNotesPage
->GetLwrBorder() );
729 InsertMasterPage(pNotesMPage
, 2);
730 pNotesPage
->TRG_SetMasterPage( *pNotesMPage
);
732 pNotesMPage
->SetLayoutName( pPage
->GetLayoutName() );
735 if( !pRefPage
&& (meDocType
!= DOCUMENT_TYPE_DRAW
) )
736 pPage
->SetAutoLayout( AUTOLAYOUT_TITLE
, sal_True
, sal_True
);
738 mpWorkStartupTimer
= new Timer();
739 mpWorkStartupTimer
->SetTimeoutHdl( LINK(this, SdDrawDocument
, WorkStartupHdl
) );
740 mpWorkStartupTimer
->SetTimeout(2000);
741 mpWorkStartupTimer
->Start();
743 SetChanged(sal_False
);
747 /*************************************************************************
749 |* Erzeugt fehlende Notiz und Handzettelseiten (nach PowerPoint-Import)
750 |* Es wird davon ausgegangen, dass mindestens eine Standard-Seite und
751 |* eine Standard-MasterPage vorhanden sind.
753 \************************************************************************/
755 sal_Bool
SdDrawDocument::CreateMissingNotesAndHandoutPages()
757 sal_Bool bOK
= sal_False
;
758 sal_uInt16 nPageCount
= GetPageCount();
762 /**********************************************************************
764 **********************************************************************/
765 SdPage
* pHandoutMPage
= (SdPage
*) GetMasterPage(0);
766 pHandoutMPage
->SetPageKind(PK_HANDOUT
);
768 SdPage
* pHandoutPage
= (SdPage
*) GetPage(0);
769 pHandoutPage
->SetPageKind(PK_HANDOUT
);
770 pHandoutPage
->TRG_SetMasterPage( *pHandoutMPage
);
772 for (sal_uInt16 i
= 1; i
< nPageCount
; i
= i
+ 2)
774 SdPage
* pPage
= (SdPage
*) GetPage(i
);
776 if(!pPage
->TRG_HasMasterPage())
778 // Keine MasterPage gesetzt -> erste Standard-MasterPage nehmen
779 // (Wenn bei PPT keine Standard-Seite vorhanden war)
780 pPage
->TRG_SetMasterPage(*GetMasterPage(1));
783 SdPage
* pNotesPage
= (SdPage
*) GetPage(i
+1);
784 pNotesPage
->SetPageKind(PK_NOTES
);
786 // Notiz-MasterPages setzen
787 sal_uInt16 nMasterPageAfterPagesMasterPage
= (pPage
->TRG_GetMasterPage()).GetPageNum() + 1;
788 pNotesPage
->TRG_SetMasterPage(*GetMasterPage(nMasterPageAfterPagesMasterPage
));
792 StopWorkStartupDelay();
793 SetChanged(sal_False
);
799 /*************************************************************************
801 |* - selektierte Seiten hinter genannte Seite schieben
802 |* (nTargetPage = (sal_uInt16)-1 --> vor erste Seite schieben)
803 |* - ergibt sal_True, wenn Seiten verschoben wurden
805 \************************************************************************/
807 sal_Bool
SdDrawDocument::MovePages(sal_uInt16 nTargetPage
)
809 SdPage
* pTargetPage
= NULL
;
810 SdPage
* pPage
= NULL
;
812 sal_uInt16 nNoOfPages
= GetSdPageCount(PK_STANDARD
);
813 sal_Bool bSomethingHappened
= sal_False
;
815 const bool bUndo
= IsUndoEnabled();
818 BegUndo(String(SdResId(STR_UNDO_MOVEPAGES
)));
820 // Liste mit selektierten Seiten
822 for (nPage
= 0; nPage
< nNoOfPages
; nPage
++)
824 pPage
= GetSdPage(nPage
, PK_STANDARD
);
825 if (pPage
->IsSelected())
827 aPageList
.Insert(pPage
, LIST_APPEND
);
831 // falls noetig, nach vorne hangeln, bis nicht selektierte Seite gefunden
833 if (nPage
!= (sal_uInt16
)-1)
835 pPage
= GetSdPage(nPage
, PK_STANDARD
);
836 while (nPage
> 0 && pPage
->IsSelected())
839 pPage
= GetSdPage(nPage
, PK_STANDARD
);
842 if (pPage
->IsSelected())
844 nPage
= (sal_uInt16
)-1;
848 // vor der ersten Seite einfuegen
849 if (nPage
== (sal_uInt16
)-1)
851 while (aPageList
.Count() > 0)
855 nPage
= ( (SdPage
*) aPageList
.GetCurObject() )->GetPageNum();
858 SdrPage
* pPg
= GetPage(nPage
);
860 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
, 1));
862 pPg
= GetPage(nPage
+1);
864 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
+1, 2));
865 MovePage(nPage
+1, 2);
866 bSomethingHappened
= sal_True
;
871 // hinter <nPage> einfuegen
874 pTargetPage
= GetSdPage(nPage
, PK_STANDARD
);
876 nTargetPage
= 2 * nTargetPage
+ 1; // PK_STANDARD --> absolut
877 while (aPageList
.Count() > 0)
879 pPage
= (SdPage
*)aPageList
.GetObject(0);
880 nPage
= pPage
->GetPageNum();
881 if (nPage
> nTargetPage
)
883 nTargetPage
+= 2; // hinter (!) der Seite einfuegen
885 if (nPage
!= nTargetPage
)
887 SdrPage
* pPg
= GetPage(nPage
);
889 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
, nTargetPage
));
890 MovePage(nPage
, nTargetPage
);
891 pPg
= GetPage(nPage
+1);
893 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
+1, nTargetPage
+1));
894 MovePage(nPage
+1, nTargetPage
+1);
895 bSomethingHappened
= sal_True
;
900 if (nPage
!= nTargetPage
)
902 SdrPage
* pPg
= GetPage(nPage
+1);
904 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
+1, nTargetPage
+1));
905 MovePage(nPage
+1, nTargetPage
+1);
906 pPg
= GetPage(nPage
);
908 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
, nTargetPage
));
909 MovePage(nPage
, nTargetPage
);
910 bSomethingHappened
= sal_True
;
913 aPageList
.Remove((sal_uLong
)0);
914 nTargetPage
= pPage
->GetPageNum();
921 return bSomethingHappened
;
925 /*************************************************************************
927 |* Anzahl der Links im sfx2::LinkManager zurueckgeben
929 \************************************************************************/
931 sal_uLong
SdDrawDocument::GetLinkCount()
933 return ( pLinkManager
->GetLinks().Count() );
936 /*************************************************************************
940 \************************************************************************/
942 void SdDrawDocument::SetLanguage( const LanguageType eLang
, const sal_uInt16 nId
)
944 sal_Bool bChanged
= sal_False
;
946 if( nId
== EE_CHAR_LANGUAGE
&& meLanguage
!= eLang
)
951 else if( nId
== EE_CHAR_LANGUAGE_CJK
&& meLanguageCJK
!= eLang
)
953 meLanguageCJK
= eLang
;
956 else if( nId
== EE_CHAR_LANGUAGE_CTL
&& meLanguageCTL
!= eLang
)
958 meLanguageCTL
= eLang
;
964 GetDrawOutliner().SetDefaultLanguage( Application::GetSettings().GetLanguage() );
965 pHitTestOutliner
->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
966 pItemPool
->SetPoolDefaultItem( SvxLanguageItem( eLang
, nId
) );
967 SetChanged( bChanged
);
972 /*************************************************************************
976 \************************************************************************/
978 LanguageType
SdDrawDocument::GetLanguage( const sal_uInt16 nId
) const
980 LanguageType eLangType
= meLanguage
;
982 if( nId
== EE_CHAR_LANGUAGE_CJK
)
983 eLangType
= meLanguageCJK
;
984 else if( nId
== EE_CHAR_LANGUAGE_CTL
)
985 eLangType
= meLanguageCTL
;
991 /*************************************************************************
993 |* WorkStartup einleiten
995 \************************************************************************/
997 IMPL_LINK( SdDrawDocument
, WorkStartupHdl
, Timer
*, EMPTYARG
)
1000 mpDocSh
->SetWaitCursor( sal_True
);
1002 sal_Bool bChanged
= IsChanged(); // merken
1004 // Autolayouts initialisieren
1005 SdPage
* pHandoutMPage
= GetMasterSdPage(0, PK_HANDOUT
);
1007 if (pHandoutMPage
->GetAutoLayout() == AUTOLAYOUT_NONE
)
1009 // AutoLayout wurde noch nicht umgesetzt -> Initialisieren
1010 pHandoutMPage
->SetAutoLayout(AUTOLAYOUT_HANDOUT6
, sal_True
, sal_True
);
1013 SdPage
* pPage
= GetSdPage(0, PK_STANDARD
);
1015 if (pPage
->GetAutoLayout() == AUTOLAYOUT_NONE
)
1017 // AutoLayout wurde noch nicht umgesetzt -> Initialisieren
1018 pPage
->SetAutoLayout(AUTOLAYOUT_NONE
, sal_True
, sal_True
);
1021 SdPage
* pNotesPage
= GetSdPage(0, PK_NOTES
);
1023 if (pNotesPage
->GetAutoLayout() == AUTOLAYOUT_NONE
)
1025 // AutoLayout wurde noch nicht umgesetzt -> Initialisieren
1026 pNotesPage
->SetAutoLayout(AUTOLAYOUT_NOTES
, sal_True
, sal_True
);
1029 SetChanged(bChanged
|| sal_False
);
1032 mpDocSh
->SetWaitCursor( sal_False
);
1037 /*************************************************************************
1039 |* Wenn der WorkStartupTimer erzeugt worden ist (das erfolgt ausschliesslich
1040 |* in SdDrawViewShell::Consruct() ), so wird der Timer ggf. gestoppt und
1041 |* das WorkStartup eingeleitet
1043 \************************************************************************/
1045 void SdDrawDocument::StopWorkStartupDelay()
1047 if (mpWorkStartupTimer
)
1049 if ( mpWorkStartupTimer
->IsActive() )
1051 // Timer war noch nicht abgelaufen -> WorkStartup wird eingeleitet
1052 mpWorkStartupTimer
->Stop();
1053 WorkStartupHdl(NULL
);
1056 delete mpWorkStartupTimer
;
1057 mpWorkStartupTimer
= NULL
;
1061 /*************************************************************************
1063 |* Wenn der WorkStartupTimer erzeugt worden ist (das erfolgt ausschliesslich
1064 |* in SdDrawViewShell::Consruct() ), so wird der Timer ggf. gestoppt und
1065 |* das WorkStartup eingeleitet
1067 \************************************************************************/
1069 SdAnimationInfo
* SdDrawDocument::GetAnimationInfo(SdrObject
* pObject
) const
1071 DBG_ASSERT(pObject
, "sd::SdDrawDocument::GetAnimationInfo(), invalid argument!");
1073 return GetShapeUserData( *pObject
, false );
1078 SdAnimationInfo
* SdDrawDocument::GetShapeUserData(SdrObject
& rObject
, bool bCreate
/* = false */ )
1081 sal_uInt16 nUDCount
= rObject
.GetUserDataCount();
1082 SdrObjUserData
* pUD
= 0;
1083 SdAnimationInfo
* pRet
= 0;
1085 // gibt es in den User-Daten eine Animationsinformation?
1086 for (nUD
= 0; nUD
< nUDCount
; nUD
++)
1088 pUD
= rObject
.GetUserData(nUD
);
1089 if((pUD
->GetInventor() == SdUDInventor
) && (pUD
->GetId() == SD_ANIMATIONINFO_ID
))
1091 pRet
= dynamic_cast<SdAnimationInfo
*>(pUD
);
1096 if( (pRet
== 0) && bCreate
)
1098 pRet
= new SdAnimationInfo( rObject
);
1099 rObject
.InsertUserData( pRet
);
1106 /*************************************************************************
1110 \************************************************************************/
1112 SdIMapInfo
* SdDrawDocument::GetIMapInfo( SdrObject
* pObject
) const
1114 DBG_ASSERT(pObject
, "ohne Objekt keine IMapInfo");
1116 SdrObjUserData
* pUserData
= NULL
;
1117 SdIMapInfo
* pIMapInfo
= NULL
;
1118 sal_uInt16 nCount
= pObject
->GetUserDataCount();
1120 // gibt es in den User-Daten eine IMap-Information?
1121 for ( sal_uInt16 i
= 0; i
< nCount
; i
++ )
1123 pUserData
= pObject
->GetUserData( i
);
1125 if ( ( pUserData
->GetInventor() == SdUDInventor
) && ( pUserData
->GetId() == SD_IMAPINFO_ID
) )
1126 pIMapInfo
= (SdIMapInfo
*) pUserData
;
1133 /*************************************************************************
1137 \************************************************************************/
1139 IMapObject
* SdDrawDocument::GetHitIMapObject( SdrObject
* pObj
,
1140 const Point
& rWinPoint
,
1141 const ::Window
& /* rCmpWnd */ )
1143 SdIMapInfo
* pIMapInfo
= GetIMapInfo( pObj
);
1144 IMapObject
* pIMapObj
= NULL
;
1148 const MapMode
aMap100( MAP_100TH_MM
);
1150 Point
aRelPoint( rWinPoint
);
1151 ImageMap
& rImageMap
= (ImageMap
&) pIMapInfo
->GetImageMap();
1152 const Rectangle
& rRect
= pObj
->GetLogicRect();
1153 sal_Bool bObjSupported
= sal_False
;
1155 // HitTest ausfuehren
1156 if ( pObj
->ISA( SdrGrafObj
) ) // einfaches Grafik-Objekt
1158 const SdrGrafObj
* pGrafObj
= (const SdrGrafObj
*) pObj
;
1159 const GeoStat
& rGeo
= pGrafObj
->GetGeoStat();
1160 SdrGrafObjGeoData
* pGeoData
= (SdrGrafObjGeoData
*) pGrafObj
->GetGeoData();
1162 // Drehung rueckgaengig
1163 if ( rGeo
.nDrehWink
)
1164 RotatePoint( aRelPoint
, rRect
.TopLeft(), -rGeo
.nSin
, rGeo
.nCos
);
1166 // Spiegelung rueckgaengig
1167 if ( pGeoData
->bMirrored
)
1168 aRelPoint
.X() = rRect
.Right() + rRect
.Left() - aRelPoint
.X();
1171 if ( rGeo
.nShearWink
)
1172 ShearPoint( aRelPoint
, rRect
.TopLeft(), -rGeo
.nTan
);
1174 if ( pGrafObj
->GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL
)
1175 aGraphSize
= Application::GetDefaultDevice()->PixelToLogic( pGrafObj
->GetGrafPrefSize(), aMap100
);
1177 aGraphSize
= OutputDevice::LogicToLogic( pGrafObj
->GetGrafPrefSize(),
1178 pGrafObj
->GetGrafPrefMapMode(), aMap100
);
1181 bObjSupported
= sal_True
;
1183 else if ( pObj
->ISA( SdrOle2Obj
) ) // OLE-Objekt
1185 aGraphSize
= ( (SdrOle2Obj
*) pObj
)->GetOrigObjSize();
1186 bObjSupported
= sal_True
;
1189 // hat alles geklappt, dann HitTest ausfuehren
1190 if ( bObjSupported
)
1192 // relativen Mauspunkt berechnen
1193 aRelPoint
-= rRect
.TopLeft();
1194 pIMapObj
= rImageMap
.GetHitIMapObject( aGraphSize
, rRect
.GetSize(), aRelPoint
);
1196 // Deaktivierte Objekte wollen wir nicht
1197 if ( pIMapObj
&& !pIMapObj
->IsActive() )
1205 /** this method enforces that the masterpages are in the currect order,
1206 that is at position 1 is a PK_STANDARD masterpage followed by a
1207 PK_NOTES masterpage and so on. #
1209 void SdDrawDocument::CheckMasterPages()
1211 // RemoveMasterPage(2); // code to test the creation of notes pages
1213 sal_uInt16 nMaxPages
= GetMasterPageCount();
1215 // we need at least a handout master and one master page
1221 SdPage
* pPage
= NULL
;
1222 SdPage
* pNotesPage
= NULL
;
1226 // first see if the page order is correct
1227 for( nPage
= 1; nPage
< nMaxPages
; nPage
++ )
1229 pPage
= static_cast<SdPage
*> (GetMasterPage( nPage
));
1230 // if an odd page is not a standard page or an even page is not a notes page
1231 if( ((1 == (nPage
& 1)) && (pPage
->GetPageKind() != PK_STANDARD
) ) ||
1232 ((0 == (nPage
& 1)) && (pPage
->GetPageKind() != PK_NOTES
) ) )
1233 break; // then we have a fatal error
1236 if( nPage
< nMaxPages
)
1238 // there is a fatal error in the master page order,
1239 // we need to repair the document
1240 sal_Bool bChanged
= sal_False
;
1243 while( nPage
< nMaxPages
)
1245 pPage
= static_cast<SdPage
*> (GetMasterPage( nPage
));
1246 if( pPage
->GetPageKind() != PK_STANDARD
)
1248 bChanged
= sal_True
;
1249 sal_uInt16 nFound
= nPage
+ 1;
1250 while( nFound
< nMaxPages
)
1252 pPage
= static_cast<SdPage
*>(GetMasterPage( nFound
));
1253 if( PK_STANDARD
== pPage
->GetPageKind() )
1255 MoveMasterPage( nFound
, nPage
);
1256 pPage
->SetInserted(sal_True
);
1264 // if we don't have any more standard pages, were done
1265 if( nMaxPages
== nFound
)
1271 if( nPage
< nMaxPages
)
1272 pNotesPage
= static_cast<SdPage
*>(GetMasterPage( nPage
));
1276 if( (NULL
== pNotesPage
) || (pNotesPage
->GetPageKind() != PK_NOTES
) || ( pPage
->GetLayoutName() != pNotesPage
->GetLayoutName() ) )
1278 bChanged
= sal_True
;
1280 sal_uInt16 nFound
= nPage
+ 1;
1281 while( nFound
< nMaxPages
)
1283 pNotesPage
= static_cast<SdPage
*>(GetMasterPage( nFound
));
1284 if( (PK_NOTES
== pNotesPage
->GetPageKind()) && ( pPage
->GetLayoutName() == pNotesPage
->GetLayoutName() ) )
1286 MoveMasterPage( nFound
, nPage
);
1287 pNotesPage
->SetInserted(sal_True
);
1294 // looks like we lost a notes page
1295 if( nMaxPages
== nFound
)
1299 // first find a reference notes page for size
1300 SdPage
* pRefNotesPage
= NULL
;
1302 while( nFound
< nMaxPages
)
1304 pRefNotesPage
= static_cast<SdPage
*>(GetMasterPage( nFound
));
1305 if( PK_NOTES
== pRefNotesPage
->GetPageKind() )
1309 if( nFound
== nMaxPages
)
1310 pRefNotesPage
= NULL
;
1312 SdPage
* pNewNotesPage
= static_cast<SdPage
*>(AllocPage(sal_True
));
1313 pNewNotesPage
->SetPageKind(PK_NOTES
);
1316 pNewNotesPage
->SetSize( pRefNotesPage
->GetSize() );
1317 pNewNotesPage
->SetBorder( pRefNotesPage
->GetLftBorder(),
1318 pRefNotesPage
->GetUppBorder(),
1319 pRefNotesPage
->GetRgtBorder(),
1320 pRefNotesPage
->GetLwrBorder() );
1322 InsertMasterPage(pNewNotesPage
, nPage
);
1323 pNewNotesPage
->SetLayoutName( pPage
->GetLayoutName() );
1324 pNewNotesPage
->SetAutoLayout(AUTOLAYOUT_NOTES
, sal_True
, sal_True
);
1332 // now remove all remaining and unused non PK_STANDARD slides
1333 while( nPage
< nMaxPages
)
1335 bChanged
= sal_True
;
1337 RemoveMasterPage( nPage
);
1343 DBG_ERROR( "master pages where in a wrong order" );
1344 RecalcPageNums( sal_True
);
1349 sal_uInt16
SdDrawDocument::CreatePage (
1350 SdPage
* pActualPage
,
1352 const String
& sStandardPageName
,
1353 const String
& sNotesPageName
,
1354 AutoLayout eStandardLayout
,
1355 AutoLayout eNotesLayout
,
1356 sal_Bool bIsPageBack
,
1357 sal_Bool bIsPageObj
,
1358 const sal_Int32 nInsertPosition
)
1360 SdPage
* pPreviousStandardPage
;
1361 SdPage
* pPreviousNotesPage
;
1362 SdPage
* pStandardPage
;
1365 // From the given page determine the standard page and notes page of which
1366 // to take the layout and the position where to insert the new pages.
1367 if (ePageKind
== PK_NOTES
)
1369 pPreviousNotesPage
= pActualPage
;
1370 sal_uInt16 nNotesPageNum
= pPreviousNotesPage
->GetPageNum() + 2;
1371 pPreviousStandardPage
= (SdPage
*) GetPage(nNotesPageNum
- 3);
1372 eStandardLayout
= pPreviousStandardPage
->GetAutoLayout();
1376 pPreviousStandardPage
= pActualPage
;
1377 sal_uInt16 nStandardPageNum
= pPreviousStandardPage
->GetPageNum() + 2;
1378 pPreviousNotesPage
= (SdPage
*) GetPage(nStandardPageNum
- 1);
1379 eNotesLayout
= pPreviousNotesPage
->GetAutoLayout();
1382 // Create new standard page and set it up.
1383 pStandardPage
= (SdPage
*) AllocPage(sal_False
);
1386 // Set the size here since else the presobj autolayout
1388 pStandardPage
->SetSize( pPreviousStandardPage
->GetSize() );
1389 pStandardPage
->SetBorder( pPreviousStandardPage
->GetLftBorder(),
1390 pPreviousStandardPage
->GetUppBorder(),
1391 pPreviousStandardPage
->GetRgtBorder(),
1392 pPreviousStandardPage
->GetLwrBorder() );
1394 // Use master page of current page.
1395 pStandardPage
->TRG_SetMasterPage(pPreviousStandardPage
->TRG_GetMasterPage());
1397 // User layout of current standard page.
1398 pStandardPage
->SetLayoutName( pPreviousStandardPage
->GetLayoutName() );
1399 pStandardPage
->SetAutoLayout(eStandardLayout
, sal_True
);
1400 pStandardPage
->setHeaderFooterSettings( pPreviousStandardPage
->getHeaderFooterSettings() );
1402 // transition settings of current page
1403 pStandardPage
->setTransitionType( pPreviousStandardPage
->getTransitionType() );
1404 pStandardPage
->setTransitionSubtype( pPreviousStandardPage
->getTransitionSubtype() );
1405 pStandardPage
->setTransitionDirection( pPreviousStandardPage
->getTransitionDirection() );
1406 pStandardPage
->setTransitionFadeColor( pPreviousStandardPage
->getTransitionFadeColor() );
1407 pStandardPage
->setTransitionDuration( pPreviousStandardPage
->getTransitionDuration() );
1409 // apply previous animation timing
1410 pStandardPage
->SetPresChange( pPreviousStandardPage
->GetPresChange() );
1411 pStandardPage
->SetTime( pPreviousStandardPage
->GetTime() );
1413 // Create new notes page and set it up.
1414 pNotesPage
= (SdPage
*) AllocPage(sal_False
);
1415 pNotesPage
->SetPageKind(PK_NOTES
);
1417 // Use master page of current page.
1418 pNotesPage
->TRG_SetMasterPage(pPreviousNotesPage
->TRG_GetMasterPage());
1420 // Use layout of current notes page.
1421 pNotesPage
->SetLayoutName( pPreviousNotesPage
->GetLayoutName() );
1422 pNotesPage
->SetAutoLayout(eNotesLayout
, sal_True
);
1423 pNotesPage
->setHeaderFooterSettings( pPreviousNotesPage
->getHeaderFooterSettings() );
1425 return InsertPageSet (
1442 sal_uInt16
SdDrawDocument::DuplicatePage (sal_uInt16 nPageNum
)
1444 PageKind ePageKind
= PK_STANDARD
;
1446 // Get current page.
1447 SdPage
* pActualPage
= GetSdPage(nPageNum
, ePageKind
);
1449 // Get background flags.
1450 SdrLayerAdmin
& rLayerAdmin
= GetLayerAdmin();
1451 sal_uInt8 aBckgrnd
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRND
)), sal_False
);
1452 sal_uInt8 aBckgrndObj
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ
)), sal_False
);
1453 SetOfByte aVisibleLayers
= pActualPage
->TRG_GetMasterPageVisibleLayers();
1455 // Get layout from current page.
1456 AutoLayout eAutoLayout
= pActualPage
->GetAutoLayout();
1458 return DuplicatePage (
1459 pActualPage
, ePageKind
,
1460 // No names for the new slides.
1462 eAutoLayout
, eAutoLayout
,
1463 aVisibleLayers
.IsSet(aBckgrnd
),
1464 aVisibleLayers
.IsSet(aBckgrndObj
));
1470 sal_uInt16
SdDrawDocument::DuplicatePage (
1471 SdPage
* pActualPage
,
1473 const String
& sStandardPageName
,
1474 const String
& sNotesPageName
,
1475 AutoLayout eStandardLayout
,
1476 AutoLayout eNotesLayout
,
1477 sal_Bool bIsPageBack
,
1478 sal_Bool bIsPageObj
,
1479 const sal_Int32 nInsertPosition
)
1481 SdPage
* pPreviousStandardPage
;
1482 SdPage
* pPreviousNotesPage
;
1483 SdPage
* pStandardPage
;
1486 // From the given page determine the standard page and the notes page
1487 // of which to make copies.
1488 if (ePageKind
== PK_NOTES
)
1490 pPreviousNotesPage
= pActualPage
;
1491 sal_uInt16 nNotesPageNum
= pPreviousNotesPage
->GetPageNum() + 2;
1492 pPreviousStandardPage
= (SdPage
*) GetPage(nNotesPageNum
- 3);
1496 pPreviousStandardPage
= pActualPage
;
1497 sal_uInt16 nStandardPageNum
= pPreviousStandardPage
->GetPageNum() + 2;
1498 pPreviousNotesPage
= (SdPage
*) GetPage(nStandardPageNum
- 1);
1501 // Create duplicates of a standard page and the associated notes page.
1502 pStandardPage
= (SdPage
*) pPreviousStandardPage
->Clone();
1503 pNotesPage
= (SdPage
*) pPreviousNotesPage
->Clone();
1505 return InsertPageSet (
1522 sal_uInt16
SdDrawDocument::InsertPageSet (
1523 SdPage
* pActualPage
,
1525 const String
& sStandardPageName
,
1526 const String
& sNotesPageName
,
1527 AutoLayout eStandardLayout
,
1528 AutoLayout eNotesLayout
,
1529 sal_Bool bIsPageBack
,
1530 sal_Bool bIsPageObj
,
1531 SdPage
* pStandardPage
,
1533 sal_Int32 nInsertPosition
)
1535 SdPage
* pPreviousStandardPage
;
1536 SdPage
* pPreviousNotesPage
;
1537 sal_uInt16 nStandardPageNum
;
1538 sal_uInt16 nNotesPageNum
;
1539 String aStandardPageName
= sStandardPageName
;
1540 String aNotesPageName
= sNotesPageName
;
1542 // Gather some information about the standard page and the notes page
1543 // that are to be inserted. This makes sure that there is allways one
1544 // standard page followed by one notes page.
1545 if (ePageKind
== PK_NOTES
)
1547 pPreviousNotesPage
= pActualPage
;
1548 nNotesPageNum
= pPreviousNotesPage
->GetPageNum() + 2;
1549 pPreviousStandardPage
= (SdPage
*) GetPage(nNotesPageNum
- 3);
1550 nStandardPageNum
= nNotesPageNum
- 1;
1551 eStandardLayout
= pPreviousStandardPage
->GetAutoLayout();
1555 pPreviousStandardPage
= pActualPage
;
1556 nStandardPageNum
= pPreviousStandardPage
->GetPageNum() + 2;
1557 pPreviousNotesPage
= (SdPage
*) GetPage(nStandardPageNum
- 1);
1558 nNotesPageNum
= nStandardPageNum
+ 1;
1559 aNotesPageName
= aStandardPageName
;
1560 eNotesLayout
= pPreviousNotesPage
->GetAutoLayout();
1563 OSL_ASSERT(nNotesPageNum
==nStandardPageNum
+1);
1564 if (nInsertPosition
< 0)
1565 nInsertPosition
= nStandardPageNum
;
1567 // Set up and insert the standard page.
1569 pPreviousStandardPage
,
1576 // Set up and insert the notes page.
1577 pNotesPage
->SetPageKind(PK_NOTES
);
1586 // Return an index that allows the caller to access the newly inserted
1587 // pages by using GetSdPage().
1588 return pStandardPage
->GetPageNum() / 2;
1594 void SdDrawDocument::SetupNewPage (
1595 SdPage
* pPreviousPage
,
1597 const String
& sPageName
,
1598 sal_uInt16 nInsertionPoint
,
1599 sal_Bool bIsPageBack
,
1600 sal_Bool bIsPageObj
)
1602 if (pPreviousPage
!= NULL
)
1604 pPage
->SetSize( pPreviousPage
->GetSize() );
1605 pPage
->SetBorder( pPreviousPage
->GetLftBorder(),
1606 pPreviousPage
->GetUppBorder(),
1607 pPreviousPage
->GetRgtBorder(),
1608 pPreviousPage
->GetLwrBorder() );
1610 pPage
->SetName(sPageName
);
1612 InsertPage(pPage
, nInsertionPoint
);
1614 if (pPreviousPage
!= NULL
)
1616 SdrLayerAdmin
& rLayerAdmin
= GetLayerAdmin();
1617 sal_uInt8 aBckgrnd
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRND
)), sal_False
);
1618 sal_uInt8 aBckgrndObj
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ
)), sal_False
);
1619 SetOfByte aVisibleLayers
= pPreviousPage
->TRG_GetMasterPageVisibleLayers();
1620 aVisibleLayers
.Set(aBckgrnd
, bIsPageBack
);
1621 aVisibleLayers
.Set(aBckgrndObj
, bIsPageObj
);
1622 pPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
1626 sd::UndoManager
* SdDrawDocument::GetUndoManager() const
1628 return mpDocSh
? dynamic_cast< sd::UndoManager
* >(mpDocSh
->GetUndoManager()) : 0;