1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drawdoc2.cxx,v $
10 * $Revision: 1.46.76.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include <com/sun/star/embed/XVisualObject.hpp>
36 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
37 #include <vcl/wrkwin.hxx>
38 #include <sfx2/printer.hxx>
39 #include <sfx2/app.hxx>
40 #ifndef SD_OUTLINE_HXX
41 #include "Outliner.hxx"
43 #include <svx/paperinf.hxx>
44 #include <svx/svdopage.hxx>
45 #include <svx/svdoole2.hxx>
46 #include <svx/svdotext.hxx>
47 #include <svx/svdograf.hxx>
48 #include <svx/svdundo.hxx>
49 #include <vcl/svapp.hxx>
50 #include <svx/eeitem.hxx>
51 #include <svx/langitem.hxx>
52 #include <svtools/itempool.hxx>
53 #include <svx/svdpool.hxx>
54 #include <svx/flditem.hxx>
56 #include <svx/linkmgr.hxx>
57 #include <svx/editdata.hxx>
58 #include <svx/dialogs.hrc>
59 #include <svx/dialmgr.hxx> // SVX_RESSTR
62 #include <svx/svditer.hxx>
63 #include <svtools/imapobj.hxx>
66 #include "sdresid.hxx"
67 #include "drawdoc.hxx"
72 #include "stlpool.hxx"
73 #include "sdiocmpt.hxx"
74 #include "anminfo.hxx"
75 #include "imapinfo.hxx"
76 #include "cusshow.hxx"
77 #include "undo/undomanager.hxx"
79 #include "../ui/inc/DrawDocShell.hxx"
80 #include "../ui/inc/FrameView.hxx"
81 #include "../ui/inc/cfgids.hxx"
82 #include "../ui/inc/strings.hrc"
84 #include "PageListWatcher.hxx"
85 #include <vcl/virdev.hxx>
89 const long PRINT_OFFSET
= 30; // siehe \svx\source\dialog\page.cxx (PB)
91 using namespace com::sun::star
;
93 /*************************************************************************
95 |* Sucht ein Objekt per Name
97 \************************************************************************/
99 SdrObject
* SdDrawDocument::GetObj(const String
& rObjName
) const
101 SdrObject
* pObj
= NULL
;
102 SdrObject
* pObjFound
= NULL
;
103 SdPage
* pPage
= NULL
;
105 /**************************************************************************
106 * Zuerst alle Pages durchsuchen
107 **************************************************************************/
109 const USHORT nMaxPages
= GetPageCount();
111 while (nPage
< nMaxPages
&& !pObjFound
)
113 pPage
= (SdPage
*) GetPage(nPage
);
114 SdrObjListIter
aIter(*pPage
, IM_DEEPWITHGROUPS
);
116 while (aIter
.IsMore() && !pObjFound
)
120 if( ( rObjName
== pObj
->GetName() ) ||
121 ( SdrInventor
== pObj
->GetObjInventor() &&
122 OBJ_OLE2
== pObj
->GetObjIdentifier() &&
123 rObjName
== static_cast< SdrOle2Obj
* >( pObj
)->GetPersistName() ) )
132 /**************************************************************************
133 * Wenn nicht gefunden, dann alle MasterPages durchsuchen
134 **************************************************************************/
136 const USHORT nMaxMasterPages
= GetMasterPageCount();
138 while (nPage
< nMaxMasterPages
&& !pObjFound
)
140 pPage
= (SdPage
*) GetMasterPage(nPage
);
141 SdrObjListIter
aIter(*pPage
, IM_DEEPWITHGROUPS
);
143 while (aIter
.IsMore() && !pObjFound
)
147 if( ( rObjName
== pObj
->GetName() ) ||
148 ( SdrInventor
== pObj
->GetObjInventor() &&
149 OBJ_OLE2
== pObj
->GetObjIdentifier() &&
150 rObjName
== static_cast< SdrOle2Obj
* >( pObj
)->GetPersistName() ) )
163 /*************************************************************************
165 |* Sucht die SdPage per Name
167 \************************************************************************/
169 USHORT
SdDrawDocument::GetPageByName(const String
& rPgName
, BOOL
& rbIsMasterPage
) const
171 SdPage
* pPage
= NULL
;
173 const USHORT nMaxPages
= GetPageCount();
174 USHORT nPageNum
= SDRPAGE_NOTFOUND
;
176 rbIsMasterPage
= FALSE
;
178 // Search all regular pages and all notes pages (handout pages are
180 while (nPage
< nMaxPages
&& nPageNum
== SDRPAGE_NOTFOUND
)
182 pPage
= const_cast<SdPage
*>(static_cast<const SdPage
*>(
186 && pPage
->GetPageKind() != PK_HANDOUT
187 && pPage
->GetName() == rPgName
)
195 // Search all master pages when not found among non-master pages.
196 const USHORT nMaxMasterPages
= GetMasterPageCount();
199 while (nPage
< nMaxMasterPages
&& nPageNum
== SDRPAGE_NOTFOUND
)
201 pPage
= const_cast<SdPage
*>(static_cast<const SdPage
*>(
202 GetMasterPage(nPage
)));
204 if (pPage
&& pPage
->GetName() == rPgName
)
207 rbIsMasterPage
= TRUE
;
217 /*************************************************************************
221 \************************************************************************/
223 SdPage
* SdDrawDocument::GetSdPage(USHORT nPgNum
, PageKind ePgKind
) const
226 return mpDrawPageListWatcher
->GetSdPage(ePgKind
, sal_uInt32(nPgNum
));
229 /*************************************************************************
233 \************************************************************************/
235 USHORT
SdDrawDocument::GetSdPageCount(PageKind ePgKind
) const
238 return (sal_uInt16
)mpDrawPageListWatcher
->GetSdPageCount(ePgKind
);
241 /*************************************************************************
245 \************************************************************************/
247 SdPage
* SdDrawDocument::GetMasterSdPage(USHORT nPgNum
, PageKind ePgKind
)
250 return mpMasterPageListWatcher
->GetSdPage(ePgKind
, sal_uInt32(nPgNum
));
253 /*************************************************************************
257 \************************************************************************/
259 USHORT
SdDrawDocument::GetMasterSdPageCount(PageKind ePgKind
) const
262 return (sal_uInt16
)mpMasterPageListWatcher
->GetSdPageCount(ePgKind
);
265 /*************************************************************************
267 |* die in den Seitenobjekten der Notizseiten eingetragenen
268 |* Seitennummern anpassen
270 \************************************************************************/
272 void SdDrawDocument::UpdatePageObjectsInNotes(USHORT nStartPos
)
274 USHORT nPageCount
= GetPageCount();
275 SdPage
* pPage
= NULL
;
277 for (USHORT nPage
= nStartPos
; nPage
< nPageCount
; nPage
++)
279 pPage
= (SdPage
*)GetPage(nPage
);
281 // wenn es eine Notizseite ist, Seitenobjekt suchen
282 // und Nummer korrigieren
283 if (pPage
&& pPage
->GetPageKind() == PK_NOTES
)
285 ULONG nObjCount
= pPage
->GetObjCount();
286 SdrObject
* pObj
= NULL
;
287 for (ULONG nObj
= 0; nObj
< nObjCount
; nObj
++)
289 pObj
= pPage
->GetObj(nObj
);
290 if (pObj
->GetObjIdentifier() == OBJ_PAGE
&&
291 pObj
->GetObjInventor() == SdrInventor
)
293 // das Seitenobjekt stellt die vorhergende Seite (also
294 // die Zeichenseite) dar
295 DBG_ASSERTWARNING(nStartPos
, "Notizseitenpos. darf nicht 0 sein");
297 DBG_ASSERTWARNING(nPage
> 1, "Seitenobjekt darf nicht Handzettel darstellen");
299 if (nStartPos
> 0 && nPage
> 1)
300 ((SdrPageObj
*)pObj
)->SetReferencedPage(GetPage(nPage
- 1));
307 void SdDrawDocument::UpdatePageRelativeURLs(const String
& rOldName
, const String
& rNewName
)
309 if (rNewName
.Len() == 0)
312 SfxItemPool
& pPool(GetPool());
313 USHORT nCount
= pPool
.GetItemCount(EE_FEATURE_FIELD
);
314 for (USHORT nOff
= 0; nOff
< nCount
; nOff
++)
316 const SfxPoolItem
*pItem
= pPool
.GetItem(EE_FEATURE_FIELD
, nOff
);
317 const SvxFieldItem
* pFldItem
= dynamic_cast< const SvxFieldItem
* > (pItem
);
321 SvxURLField
* pURLField
= const_cast< SvxURLField
* >( dynamic_cast<const SvxURLField
*>( pFldItem
->GetField() ) );
325 XubString aURL
= pURLField
->GetURL();
327 if (aURL
.Len() && (aURL
.GetChar(0) == 35) && (aURL
.Search(rOldName
, 1) == 1))
329 if (aURL
.Len() == rOldName
.Len() + 1) // standard page name
331 aURL
.Erase (1, aURL
.Len() - 1);
333 pURLField
->SetURL(aURL
);
337 const XubString sNotes
= SdResId(STR_NOTES
);
338 if (aURL
.Len() == rOldName
.Len() + 2 + sNotes
.Len() && aURL
.Search(sNotes
, rOldName
.Len() + 2) == rOldName
.Len() + 2)
340 aURL
.Erase (1, aURL
.Len() - 1);
344 pURLField
->SetURL(aURL
);
353 void SdDrawDocument::UpdatePageRelativeURLs(SdPage
* pPage
, USHORT nPos
, sal_Int32 nIncrement
)
355 bool bNotes
= (pPage
->GetPageKind() == PK_NOTES
);
357 SfxItemPool
& pPool(GetPool());
358 USHORT nCount
= pPool
.GetItemCount(EE_FEATURE_FIELD
);
359 for (USHORT nOff
= 0; nOff
< nCount
; nOff
++)
361 const SfxPoolItem
*pItem
= pPool
.GetItem(EE_FEATURE_FIELD
, nOff
);
362 const SvxFieldItem
* pFldItem
;
364 if ((pFldItem
= dynamic_cast< const SvxFieldItem
* > (pItem
)) != 0)
366 SvxURLField
* pURLField
= const_cast< SvxURLField
* >( dynamic_cast<const SvxURLField
*>( pFldItem
->GetField() ) );
370 XubString aURL
= pURLField
->GetURL();
372 if (aURL
.Len() && (aURL
.GetChar(0) == 35))
374 XubString
aHashSlide('#');
375 aHashSlide
+= SdResId(STR_PAGE
);
377 if (aURL
.CompareTo(aHashSlide
, aHashSlide
.Len()) == COMPARE_EQUAL
)
379 XubString aURLCopy
= aURL
;
380 const XubString sNotes
= SdResId(STR_NOTES
);
382 aURLCopy
.Erase(0, aHashSlide
.Len());
384 bool bNotesLink
= (aURLCopy
.Len() >= sNotes
.Len() + 3 && aURLCopy
.Search(sNotes
, aURLCopy
.Len() - sNotes
.Len()) == aURLCopy
.Len() - sNotes
.Len());
386 if (bNotesLink
^ bNotes
)
387 continue; // no compatible link and page
390 aURLCopy
.Erase(aURLCopy
.Len() - sNotes
.Len(), sNotes
.Len());
392 sal_Int32 number
= aURLCopy
.ToInt32();
393 USHORT realPageNumber
= (nPos
+ 1)/ 2;
395 if ( number
>= realPageNumber
)
397 // update link page number
398 number
+= nIncrement
;
399 aURL
.Erase (aHashSlide
.Len() + 1, aURL
.Len() - aHashSlide
.Len() - 1);
400 aURL
+= XubString::CreateFromInt32(number
);
406 pURLField
->SetURL(aURL
);
415 /*************************************************************************
419 \************************************************************************/
421 void SdDrawDocument::MovePage(USHORT nPgNum
, USHORT nNewPos
)
424 FmFormModel::MovePage(nPgNum
, nNewPos
);
426 USHORT nMin
= Min(nPgNum
, nNewPos
);
428 UpdatePageObjectsInNotes(nMin
);
431 /*************************************************************************
435 \************************************************************************/
437 void SdDrawDocument::InsertPage(SdrPage
* pPage
, USHORT nPos
)
439 bool bLast
= (nPos
== GetPageCount());
441 FmFormModel::InsertPage(pPage
, nPos
);
443 ((SdPage
*)pPage
)->ConnectLink();
445 UpdatePageObjectsInNotes(nPos
);
448 UpdatePageRelativeURLs(static_cast<SdPage
*>( pPage
), nPos
, 1);
452 /*************************************************************************
456 \************************************************************************/
458 void SdDrawDocument::DeletePage(USHORT nPgNum
)
460 FmFormModel::DeletePage(nPgNum
);
462 UpdatePageObjectsInNotes(nPgNum
);
465 /*************************************************************************
469 \************************************************************************/
471 SdrPage
* SdDrawDocument::RemovePage(USHORT nPgNum
)
473 SdrPage
* pPage
= FmFormModel::RemovePage(nPgNum
);
475 bool bLast
= ((nPgNum
+1)/2 == (GetPageCount()+1)/2);
477 ((SdPage
*)pPage
)->DisconnectLink();
478 ReplacePageInCustomShows( dynamic_cast< SdPage
* >( pPage
), 0 );
479 UpdatePageObjectsInNotes(nPgNum
);
482 UpdatePageRelativeURLs((SdPage
*)pPage
, nPgNum
, -1);
487 // Warning: This is not called for new master pages created from SdrModel::Merge,
488 // you also have to modify code in SdDrawDocument::Merge!
489 void SdDrawDocument::InsertMasterPage(SdrPage
* pPage
, USHORT nPos
)
491 FmFormModel::InsertMasterPage( pPage
, nPos
);
492 if( pPage
&& pPage
->IsMasterPage() && (static_cast<SdPage
*>(pPage
)->GetPageKind() == PK_STANDARD
) )
494 // new master page created, add its style family
495 SdStyleSheetPool
* pStylePool
= (SdStyleSheetPool
*) GetStyleSheetPool();
497 pStylePool
->AddStyleFamily( static_cast<SdPage
*>(pPage
) );
501 SdrPage
* SdDrawDocument::RemoveMasterPage(USHORT nPgNum
)
503 SdPage
* pPage
= static_cast<SdPage
*>(GetMasterPage(nPgNum
));
504 if( pPage
&& pPage
->IsMasterPage() && (pPage
->GetPageKind() == PK_STANDARD
) )
506 // master page removed, remove its style family
507 SdStyleSheetPool
* pStylePool
= (SdStyleSheetPool
*) GetStyleSheetPool();
509 pStylePool
->RemoveStyleFamily( pPage
);
512 return FmFormModel::RemoveMasterPage(nPgNum
);
515 /*************************************************************************
517 |* Seiten selektieren
519 \************************************************************************/
521 void SdDrawDocument::SetSelected(SdPage
* pPage
, BOOL bSelect
)
523 PageKind ePageKind
= pPage
->GetPageKind();
525 if (ePageKind
== PK_STANDARD
)
527 pPage
->SetSelected(bSelect
);
529 const sal_uInt16
nDestPageNum(pPage
->GetPageNum() + 1);
530 SdPage
* pNotesPage
= 0L;
532 if(nDestPageNum
< GetPageCount())
534 pNotesPage
= (SdPage
*)GetPage(nDestPageNum
);
537 if (pNotesPage
&& pNotesPage
->GetPageKind() == PK_NOTES
)
539 pNotesPage
->SetSelected(bSelect
);
542 else if (ePageKind
== PK_NOTES
)
544 pPage
->SetSelected(bSelect
);
545 SdPage
* pStandardPage
= (SdPage
*) GetPage( pPage
->GetPageNum() - 1 );
547 if (pStandardPage
&& pStandardPage
->GetPageKind() == PK_STANDARD
)
548 pStandardPage
->SetSelected(bSelect
);
552 /*************************************************************************
554 |* Sofern noch keine Seiten vorhanden sind, werden nun Seiten erzeugt
556 \************************************************************************/
558 void SdDrawDocument::CreateFirstPages( SdDrawDocument
* pRefDocument
/* = 0 */ )
560 /**************************************************************************
561 * Wenn noch keine Seite im Model vorhanden ist (Datei-Neu), wird
562 * eine neue Seite eingefuegt
563 **************************************************************************/
564 USHORT nPageCount
= GetPageCount();
568 // #i57181# Paper size depends on Language, like in Writer
569 Size aDefSize
= SvxPaperInfo::GetDefaultPaperSize( MAP_100TH_MM
);
571 /**********************************************************************
572 * Handzettel-Seite einfuegen
573 **********************************************************************/
575 SdPage
* pHandoutPage
= dynamic_cast< SdPage
* >( AllocPage(bMasterPage
=FALSE
) );
577 SdPage
* pRefPage
= NULL
;
580 pRefPage
= pRefDocument
->GetSdPage( 0, PK_HANDOUT
);
584 pHandoutPage
->SetSize(pRefPage
->GetSize());
585 pHandoutPage
->SetBorder( pRefPage
->GetLftBorder(), pRefPage
->GetUppBorder(), pRefPage
->GetRgtBorder(), pRefPage
->GetLwrBorder() );
589 pHandoutPage
->SetSize(aDefSize
);
590 pHandoutPage
->SetBorder(0, 0, 0, 0);
593 pHandoutPage
->SetPageKind(PK_HANDOUT
);
594 pHandoutPage
->SetName( String (SdResId(STR_HANDOUT
) ) );
595 InsertPage(pHandoutPage
, 0);
597 /**********************************************************************
598 * MasterPage einfuegen und an der Handzettel-Seite vermerken
599 **********************************************************************/
600 SdPage
* pHandoutMPage
= (SdPage
*) AllocPage(bMasterPage
=TRUE
);
601 pHandoutMPage
->SetSize( pHandoutPage
->GetSize() );
602 pHandoutMPage
->SetPageKind(PK_HANDOUT
);
603 pHandoutMPage
->SetBorder( pHandoutPage
->GetLftBorder(),
604 pHandoutPage
->GetUppBorder(),
605 pHandoutPage
->GetRgtBorder(),
606 pHandoutPage
->GetLwrBorder() );
607 InsertMasterPage(pHandoutMPage
, 0);
608 pHandoutPage
->TRG_SetMasterPage( *pHandoutMPage
);
610 /**********************************************************************
612 * Sofern nPageCount==1 ist, wurde das Model fuers Clipboad erzeugt.
613 * Eine Standard-Seite ist daher schon vorhanden.
614 **********************************************************************/
616 BOOL bClipboard
= FALSE
;
619 pRefPage
= pRefDocument
->GetSdPage( 0, PK_STANDARD
);
623 pPage
= dynamic_cast< SdPage
* >( AllocPage(bMasterPage
=FALSE
) );
627 pPage
->SetSize( pRefPage
->GetSize() );
628 pPage
->SetBorder( pRefPage
->GetLftBorder(), pRefPage
->GetUppBorder(), pRefPage
->GetRgtBorder(), pRefPage
->GetLwrBorder() );
630 else if (meDocType
== DOCUMENT_TYPE_DRAW
)
632 // Draw: stets Default-Groesse mit Raendern
633 pPage
->SetSize(aDefSize
);
635 SfxPrinter
* pPrinter
= mpDocSh
->GetPrinter(FALSE
);
636 if (pPrinter
&& pPrinter
->IsValid())
638 Size
aOutSize(pPrinter
->GetOutputSize());
639 Point
aPageOffset(pPrinter
->GetPageOffset());
640 aPageOffset
-= pPrinter
->PixelToLogic( Point() );
641 long nOffset
= !aPageOffset
.X() && !aPageOffset
.X() ? 0 : PRINT_OFFSET
;
643 ULONG nTop
= aPageOffset
.Y();
644 ULONG nLeft
= aPageOffset
.X();
645 ULONG nBottom
= Max((long)(aDefSize
.Height() - aOutSize
.Height() - nTop
+ nOffset
), 0L);
646 ULONG nRight
= Max((long)(aDefSize
.Width() - aOutSize
.Width() - nLeft
+ nOffset
), 0L);
648 pPage
->SetBorder(nLeft
, nTop
, nRight
, nBottom
);
652 // The printer is not available. Use a border of 10mm
653 // on each side instead.
654 // This has to be kept synchronized with the border
656 // SvxPageDescPage::PaperSizeSelect_Impl callback.
657 pPage
->SetBorder(1000, 1000, 1000, 1000);
662 // Impress: stets Bildschirmformat, quer
663 Size
aSz( SvxPaperInfo::GetPaperSize(PAPER_SCREEN
, MAP_100TH_MM
) );
664 pPage
->SetSize( Size( aSz
.Height(), aSz
.Width() ) );
665 pPage
->SetBorder(0, 0, 0, 0);
668 InsertPage(pPage
, 1);
673 pPage
= (SdPage
*) GetPage(1);
676 /**********************************************************************
677 * MasterPage einfuegen und an der Seite vermerken
678 **********************************************************************/
679 SdPage
* pMPage
= (SdPage
*) AllocPage(bMasterPage
=TRUE
);
680 pMPage
->SetSize( pPage
->GetSize() );
681 pMPage
->SetBorder( pPage
->GetLftBorder(),
682 pPage
->GetUppBorder(),
683 pPage
->GetRgtBorder(),
684 pPage
->GetLwrBorder() );
685 InsertMasterPage(pMPage
, 1);
686 pPage
->TRG_SetMasterPage( *pMPage
);
688 pMPage
->SetLayoutName( pPage
->GetLayoutName() );
690 /**********************************************************************
691 * Notizen-Seite einfuegen
692 **********************************************************************/
693 SdPage
* pNotesPage
= (SdPage
*) AllocPage(bMasterPage
=FALSE
);
696 pRefPage
= pRefDocument
->GetSdPage( 0, PK_NOTES
);
700 pNotesPage
->SetSize( pRefPage
->GetSize() );
701 pNotesPage
->SetBorder( pRefPage
->GetLftBorder(), pRefPage
->GetUppBorder(), pRefPage
->GetRgtBorder(), pRefPage
->GetLwrBorder() );
706 if (aDefSize
.Height() >= aDefSize
.Width())
708 pNotesPage
->SetSize(aDefSize
);
712 pNotesPage
->SetSize( Size(aDefSize
.Height(), aDefSize
.Width()) );
715 pNotesPage
->SetBorder(0, 0, 0, 0);
717 pNotesPage
->SetPageKind(PK_NOTES
);
718 InsertPage(pNotesPage
, 2);
720 pNotesPage
->SetLayoutName( pPage
->GetLayoutName() );
722 /**********************************************************************
723 * MasterPage einfuegen und an der Notizen-Seite vermerken
724 **********************************************************************/
725 SdPage
* pNotesMPage
= (SdPage
*) AllocPage(bMasterPage
=TRUE
);
726 pNotesMPage
->SetSize( pNotesPage
->GetSize() );
727 pNotesMPage
->SetPageKind(PK_NOTES
);
728 pNotesMPage
->SetBorder( pNotesPage
->GetLftBorder(),
729 pNotesPage
->GetUppBorder(),
730 pNotesPage
->GetRgtBorder(),
731 pNotesPage
->GetLwrBorder() );
732 InsertMasterPage(pNotesMPage
, 2);
733 pNotesPage
->TRG_SetMasterPage( *pNotesMPage
);
735 pNotesMPage
->SetLayoutName( pPage
->GetLayoutName() );
737 mpWorkStartupTimer
= new Timer();
738 mpWorkStartupTimer
->SetTimeoutHdl( LINK(this, SdDrawDocument
, WorkStartupHdl
) );
739 mpWorkStartupTimer
->SetTimeout(2000);
740 mpWorkStartupTimer
->Start();
746 /*************************************************************************
748 |* Erzeugt fehlende Notiz und Handzettelseiten (nach PowerPoint-Import)
749 |* Es wird davon ausgegangen, dass mindestens eine Standard-Seite und
750 |* eine Standard-MasterPage vorhanden sind.
752 \************************************************************************/
754 BOOL
SdDrawDocument::CreateMissingNotesAndHandoutPages()
757 USHORT nPageCount
= GetPageCount();
761 /**********************************************************************
763 **********************************************************************/
764 SdPage
* pHandoutMPage
= (SdPage
*) GetMasterPage(0);
765 pHandoutMPage
->SetPageKind(PK_HANDOUT
);
767 SdPage
* pHandoutPage
= (SdPage
*) GetPage(0);
768 pHandoutPage
->SetPageKind(PK_HANDOUT
);
769 pHandoutPage
->TRG_SetMasterPage( *pHandoutMPage
);
771 for (USHORT i
= 1; i
< nPageCount
; i
= i
+ 2)
773 SdPage
* pPage
= (SdPage
*) GetPage(i
);
775 if(!pPage
->TRG_HasMasterPage())
777 // Keine MasterPage gesetzt -> erste Standard-MasterPage nehmen
778 // (Wenn bei PPT keine Standard-Seite vorhanden war)
779 pPage
->TRG_SetMasterPage(*GetMasterPage(1));
782 SdPage
* pNotesPage
= (SdPage
*) GetPage(i
+1);
783 pNotesPage
->SetPageKind(PK_NOTES
);
785 // Notiz-MasterPages setzen
786 sal_uInt16 nMasterPageAfterPagesMasterPage
= (pPage
->TRG_GetMasterPage()).GetPageNum() + 1;
787 pNotesPage
->TRG_SetMasterPage(*GetMasterPage(nMasterPageAfterPagesMasterPage
));
791 StopWorkStartupDelay();
798 /*************************************************************************
800 |* - selektierte Seiten hinter genannte Seite schieben
801 |* (nTargetPage = (USHORT)-1 --> vor erste Seite schieben)
802 |* - ergibt TRUE, wenn Seiten verschoben wurden
804 \************************************************************************/
806 BOOL
SdDrawDocument::MovePages(USHORT nTargetPage
)
808 SdPage
* pTargetPage
= NULL
;
809 SdPage
* pPage
= NULL
;
811 USHORT nNoOfPages
= GetSdPageCount(PK_STANDARD
);
812 BOOL bSomethingHappened
= FALSE
;
814 const bool bUndo
= IsUndoEnabled();
817 BegUndo(String(SdResId(STR_UNDO_MOVEPAGES
)));
819 // Liste mit selektierten Seiten
821 for (nPage
= 0; nPage
< nNoOfPages
; nPage
++)
823 pPage
= GetSdPage(nPage
, PK_STANDARD
);
824 if (pPage
->IsSelected())
826 aPageList
.Insert(pPage
, LIST_APPEND
);
830 // falls noetig, nach vorne hangeln, bis nicht selektierte Seite gefunden
832 if (nPage
!= (USHORT
)-1)
834 pPage
= GetSdPage(nPage
, PK_STANDARD
);
835 while (nPage
> 0 && pPage
->IsSelected())
838 pPage
= GetSdPage(nPage
, PK_STANDARD
);
841 if (pPage
->IsSelected())
847 // vor der ersten Seite einfuegen
848 if (nPage
== (USHORT
)-1)
850 while (aPageList
.Count() > 0)
854 nPage
= ( (SdPage
*) aPageList
.GetCurObject() )->GetPageNum();
857 SdrPage
* pPg
= GetPage(nPage
);
859 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
, 1));
861 pPg
= GetPage(nPage
+1);
863 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
+1, 2));
864 MovePage(nPage
+1, 2);
865 bSomethingHappened
= TRUE
;
870 // hinter <nPage> einfuegen
873 pTargetPage
= GetSdPage(nPage
, PK_STANDARD
);
875 nTargetPage
= 2 * nTargetPage
+ 1; // PK_STANDARD --> absolut
876 while (aPageList
.Count() > 0)
878 pPage
= (SdPage
*)aPageList
.GetObject(0);
879 nPage
= pPage
->GetPageNum();
880 if (nPage
> nTargetPage
)
882 nTargetPage
+= 2; // hinter (!) der Seite einfuegen
884 if (nPage
!= nTargetPage
)
886 SdrPage
* pPg
= GetPage(nPage
);
888 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
, nTargetPage
));
889 MovePage(nPage
, nTargetPage
);
890 pPg
= GetPage(nPage
+1);
892 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
+1, nTargetPage
+1));
893 MovePage(nPage
+1, nTargetPage
+1);
894 bSomethingHappened
= TRUE
;
899 if (nPage
!= nTargetPage
)
901 SdrPage
* pPg
= GetPage(nPage
+1);
903 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
+1, nTargetPage
+1));
904 MovePage(nPage
+1, nTargetPage
+1);
905 pPg
= GetPage(nPage
);
907 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*pPg
, nPage
, nTargetPage
));
908 MovePage(nPage
, nTargetPage
);
909 bSomethingHappened
= TRUE
;
912 aPageList
.Remove((ULONG
)0);
913 nTargetPage
= pPage
->GetPageNum();
920 return bSomethingHappened
;
924 /*************************************************************************
926 |* Anzahl der Links im LinkManager zurueckgeben
928 \************************************************************************/
930 ULONG
SdDrawDocument::GetLinkCount()
932 return ( pLinkManager
->GetLinks().Count() );
935 /*************************************************************************
939 \************************************************************************/
941 void SdDrawDocument::SetLanguage( const LanguageType eLang
, const USHORT nId
)
943 BOOL bChanged
= FALSE
;
945 if( nId
== EE_CHAR_LANGUAGE
&& meLanguage
!= eLang
)
950 else if( nId
== EE_CHAR_LANGUAGE_CJK
&& meLanguageCJK
!= eLang
)
952 meLanguageCJK
= eLang
;
955 else if( nId
== EE_CHAR_LANGUAGE_CTL
&& meLanguageCTL
!= eLang
)
957 meLanguageCTL
= eLang
;
963 GetDrawOutliner().SetDefaultLanguage( Application::GetSettings().GetLanguage() );
964 pHitTestOutliner
->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
965 pItemPool
->SetPoolDefaultItem( SvxLanguageItem( eLang
, nId
) );
966 SetChanged( bChanged
);
971 /*************************************************************************
975 \************************************************************************/
977 LanguageType
SdDrawDocument::GetLanguage( const USHORT nId
) const
979 LanguageType eLangType
= meLanguage
;
981 if( nId
== EE_CHAR_LANGUAGE_CJK
)
982 eLangType
= meLanguageCJK
;
983 else if( nId
== EE_CHAR_LANGUAGE_CTL
)
984 eLangType
= meLanguageCTL
;
990 /*************************************************************************
992 |* WorkStartup einleiten
994 \************************************************************************/
996 IMPL_LINK( SdDrawDocument
, WorkStartupHdl
, Timer
*, EMPTYARG
)
999 mpDocSh
->SetWaitCursor( TRUE
);
1001 BOOL bChanged
= IsChanged(); // merken
1003 // Autolayouts initialisieren
1004 SdPage
* pHandoutMPage
= GetMasterSdPage(0, PK_HANDOUT
);
1006 if (pHandoutMPage
->GetAutoLayout() == AUTOLAYOUT_NONE
)
1008 // AutoLayout wurde noch nicht umgesetzt -> Initialisieren
1009 pHandoutMPage
->SetAutoLayout(AUTOLAYOUT_HANDOUT6
, TRUE
, TRUE
);
1012 SdPage
* pPage
= GetSdPage(0, PK_STANDARD
);
1014 if (pPage
->GetAutoLayout() == AUTOLAYOUT_NONE
)
1016 // AutoLayout wurde noch nicht umgesetzt -> Initialisieren
1017 pPage
->SetAutoLayout(AUTOLAYOUT_NONE
, TRUE
, TRUE
);
1020 SdPage
* pNotesPage
= GetSdPage(0, PK_NOTES
);
1022 if (pNotesPage
->GetAutoLayout() == AUTOLAYOUT_NONE
)
1024 // AutoLayout wurde noch nicht umgesetzt -> Initialisieren
1025 pNotesPage
->SetAutoLayout(AUTOLAYOUT_NOTES
, TRUE
, TRUE
);
1028 SetChanged(bChanged
|| FALSE
);
1031 mpDocSh
->SetWaitCursor( FALSE
);
1036 /*************************************************************************
1038 |* Wenn der WorkStartupTimer erzeugt worden ist (das erfolgt ausschliesslich
1039 |* in SdDrawViewShell::Consruct() ), so wird der Timer ggf. gestoppt und
1040 |* das WorkStartup eingeleitet
1042 \************************************************************************/
1044 void SdDrawDocument::StopWorkStartupDelay()
1046 if (mpWorkStartupTimer
)
1048 if ( mpWorkStartupTimer
->IsActive() )
1050 // Timer war noch nicht abgelaufen -> WorkStartup wird eingeleitet
1051 mpWorkStartupTimer
->Stop();
1052 WorkStartupHdl(NULL
);
1055 delete mpWorkStartupTimer
;
1056 mpWorkStartupTimer
= NULL
;
1060 /*************************************************************************
1062 |* Wenn der WorkStartupTimer erzeugt worden ist (das erfolgt ausschliesslich
1063 |* in SdDrawViewShell::Consruct() ), so wird der Timer ggf. gestoppt und
1064 |* das WorkStartup eingeleitet
1066 \************************************************************************/
1068 SdAnimationInfo
* SdDrawDocument::GetAnimationInfo(SdrObject
* pObject
) const
1070 DBG_ASSERT(pObject
, "sd::SdDrawDocument::GetAnimationInfo(), invalid argument!");
1072 return GetShapeUserData( *pObject
, false );
1077 SdAnimationInfo
* SdDrawDocument::GetShapeUserData(SdrObject
& rObject
, bool bCreate
/* = false */ )
1080 USHORT nUDCount
= rObject
.GetUserDataCount();
1081 SdrObjUserData
* pUD
= 0;
1082 SdAnimationInfo
* pRet
= 0;
1084 // gibt es in den User-Daten eine Animationsinformation?
1085 for (nUD
= 0; nUD
< nUDCount
; nUD
++)
1087 pUD
= rObject
.GetUserData(nUD
);
1088 if((pUD
->GetInventor() == SdUDInventor
) && (pUD
->GetId() == SD_ANIMATIONINFO_ID
))
1090 pRet
= dynamic_cast<SdAnimationInfo
*>(pUD
);
1095 if( (pRet
== 0) && bCreate
)
1097 pRet
= new SdAnimationInfo( rObject
);
1098 rObject
.InsertUserData( pRet
);
1105 /*************************************************************************
1109 \************************************************************************/
1111 SdIMapInfo
* SdDrawDocument::GetIMapInfo( SdrObject
* pObject
) const
1113 DBG_ASSERT(pObject
, "ohne Objekt keine IMapInfo");
1115 SdrObjUserData
* pUserData
= NULL
;
1116 SdIMapInfo
* pIMapInfo
= NULL
;
1117 USHORT nCount
= pObject
->GetUserDataCount();
1119 // gibt es in den User-Daten eine IMap-Information?
1120 for ( USHORT i
= 0; i
< nCount
; i
++ )
1122 pUserData
= pObject
->GetUserData( i
);
1124 if ( ( pUserData
->GetInventor() == SdUDInventor
) && ( pUserData
->GetId() == SD_IMAPINFO_ID
) )
1125 pIMapInfo
= (SdIMapInfo
*) pUserData
;
1132 /*************************************************************************
1136 \************************************************************************/
1138 IMapObject
* SdDrawDocument::GetHitIMapObject( SdrObject
* pObj
,
1139 const Point
& rWinPoint
,
1140 const ::Window
& /* rCmpWnd */ )
1142 SdIMapInfo
* pIMapInfo
= GetIMapInfo( pObj
);
1143 IMapObject
* pIMapObj
= NULL
;
1147 const MapMode
aMap100( MAP_100TH_MM
);
1149 Point
aRelPoint( rWinPoint
);
1150 ImageMap
& rImageMap
= (ImageMap
&) pIMapInfo
->GetImageMap();
1151 const Rectangle
& rRect
= pObj
->GetLogicRect();
1152 BOOL bObjSupported
= FALSE
;
1154 // HitTest ausfuehren
1155 if ( pObj
->ISA( SdrGrafObj
) ) // einfaches Grafik-Objekt
1157 const SdrGrafObj
* pGrafObj
= (const SdrGrafObj
*) pObj
;
1158 const GeoStat
& rGeo
= pGrafObj
->GetGeoStat();
1159 SdrGrafObjGeoData
* pGeoData
= (SdrGrafObjGeoData
*) pGrafObj
->GetGeoData();
1161 // Drehung rueckgaengig
1162 if ( rGeo
.nDrehWink
)
1163 RotatePoint( aRelPoint
, rRect
.TopLeft(), -rGeo
.nSin
, rGeo
.nCos
);
1165 // Spiegelung rueckgaengig
1166 if ( pGeoData
->bMirrored
)
1167 aRelPoint
.X() = rRect
.Right() + rRect
.Left() - aRelPoint
.X();
1170 if ( rGeo
.nShearWink
)
1171 ShearPoint( aRelPoint
, rRect
.TopLeft(), -rGeo
.nTan
);
1173 if ( pGrafObj
->GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL
)
1174 aGraphSize
= Application::GetDefaultDevice()->PixelToLogic( pGrafObj
->GetGrafPrefSize(), aMap100
);
1176 aGraphSize
= OutputDevice::LogicToLogic( pGrafObj
->GetGrafPrefSize(),
1177 pGrafObj
->GetGrafPrefMapMode(), aMap100
);
1180 bObjSupported
= TRUE
;
1182 else if ( pObj
->ISA( SdrOle2Obj
) ) // OLE-Objekt
1184 aGraphSize
= ( (SdrOle2Obj
*) pObj
)->GetOrigObjSize();
1185 bObjSupported
= TRUE
;
1188 // hat alles geklappt, dann HitTest ausfuehren
1189 if ( bObjSupported
)
1191 // relativen Mauspunkt berechnen
1192 aRelPoint
-= rRect
.TopLeft();
1193 pIMapObj
= rImageMap
.GetHitIMapObject( aGraphSize
, rRect
.GetSize(), aRelPoint
);
1195 // Deaktivierte Objekte wollen wir nicht
1196 if ( pIMapObj
&& !pIMapObj
->IsActive() )
1204 /** this method enforces that the masterpages are in the currect order,
1205 that is at position 1 is a PK_STANDARD masterpage followed by a
1206 PK_NOTES masterpage and so on. #
1208 void SdDrawDocument::CheckMasterPages()
1210 // RemoveMasterPage(2); // code to test the creation of notes pages
1212 USHORT nMaxPages
= GetMasterPageCount();
1214 // we need at least a handout master and one master page
1220 SdPage
* pPage
= NULL
;
1221 SdPage
* pNotesPage
= NULL
;
1225 // first see if the page order is correct
1226 for( nPage
= 1; nPage
< nMaxPages
; nPage
++ )
1228 pPage
= static_cast<SdPage
*> (GetMasterPage( nPage
));
1229 // if an odd page is not a standard page or an even page is not a notes page
1230 if( ((1 == (nPage
& 1)) && (pPage
->GetPageKind() != PK_STANDARD
) ) ||
1231 ((0 == (nPage
& 1)) && (pPage
->GetPageKind() != PK_NOTES
) ) )
1232 break; // then we have a fatal error
1235 if( nPage
< nMaxPages
)
1237 // there is a fatal error in the master page order,
1238 // we need to repair the document
1239 sal_Bool bChanged
= sal_False
;
1242 while( nPage
< nMaxPages
)
1244 pPage
= static_cast<SdPage
*> (GetMasterPage( nPage
));
1245 if( pPage
->GetPageKind() != PK_STANDARD
)
1247 bChanged
= sal_True
;
1248 USHORT nFound
= nPage
+ 1;
1249 while( nFound
< nMaxPages
)
1251 pPage
= static_cast<SdPage
*>(GetMasterPage( nFound
));
1252 if( PK_STANDARD
== pPage
->GetPageKind() )
1254 MoveMasterPage( nFound
, nPage
);
1255 pPage
->SetInserted(sal_True
);
1263 // if we don't have any more standard pages, were done
1264 if( nMaxPages
== nFound
)
1270 if( nPage
< nMaxPages
)
1271 pNotesPage
= static_cast<SdPage
*>(GetMasterPage( nPage
));
1275 if( (NULL
== pNotesPage
) || (pNotesPage
->GetPageKind() != PK_NOTES
) || ( pPage
->GetLayoutName() != pNotesPage
->GetLayoutName() ) )
1277 bChanged
= sal_True
;
1279 USHORT nFound
= nPage
+ 1;
1280 while( nFound
< nMaxPages
)
1282 pNotesPage
= static_cast<SdPage
*>(GetMasterPage( nFound
));
1283 if( (PK_NOTES
== pNotesPage
->GetPageKind()) && ( pPage
->GetLayoutName() == pNotesPage
->GetLayoutName() ) )
1285 MoveMasterPage( nFound
, nPage
);
1286 pNotesPage
->SetInserted(sal_True
);
1293 // looks like we lost a notes page
1294 if( nMaxPages
== nFound
)
1298 // first find a reference notes page for size
1299 SdPage
* pRefNotesPage
= NULL
;
1301 while( nFound
< nMaxPages
)
1303 pRefNotesPage
= static_cast<SdPage
*>(GetMasterPage( nFound
));
1304 if( PK_NOTES
== pRefNotesPage
->GetPageKind() )
1308 if( nFound
== nMaxPages
)
1309 pRefNotesPage
= NULL
;
1311 SdPage
* pNewNotesPage
= static_cast<SdPage
*>(AllocPage(sal_True
));
1312 pNewNotesPage
->SetPageKind(PK_NOTES
);
1315 pNewNotesPage
->SetSize( pRefNotesPage
->GetSize() );
1316 pNewNotesPage
->SetBorder( pRefNotesPage
->GetLftBorder(),
1317 pRefNotesPage
->GetUppBorder(),
1318 pRefNotesPage
->GetRgtBorder(),
1319 pRefNotesPage
->GetLwrBorder() );
1321 InsertMasterPage(pNewNotesPage
, nPage
);
1322 pNewNotesPage
->SetLayoutName( pPage
->GetLayoutName() );
1323 pNewNotesPage
->SetAutoLayout(AUTOLAYOUT_NOTES
, sal_True
, sal_True
);
1331 // now remove all remaining and unused non PK_STANDARD slides
1332 while( nPage
< nMaxPages
)
1334 bChanged
= sal_True
;
1336 RemoveMasterPage( nPage
);
1342 DBG_ERROR( "master pages where in a wrong order" );
1343 RecalcPageNums( sal_True
);
1351 USHORT
SdDrawDocument::CreatePage (USHORT nPageNum
)
1353 PageKind ePageKind
= PK_STANDARD
;
1355 // Get current page.
1356 SdPage
* pActualPage
= GetSdPage(nPageNum
, ePageKind
);
1358 // Get background flags.
1359 SdrLayerAdmin
& rLayerAdmin
= GetLayerAdmin();
1360 BYTE aBckgrnd
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRND
)), FALSE
);
1361 BYTE aBckgrndObj
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ
)), FALSE
);
1362 SetOfByte aVisibleLayers
= pActualPage
->TRG_GetMasterPageVisibleLayers();
1364 // Get layout from current page.
1365 AutoLayout eAutoLayout
= pActualPage
->GetAutoLayout();
1368 pActualPage
, ePageKind
,
1369 // No names for the new slides.
1371 eAutoLayout
, eAutoLayout
,
1372 aVisibleLayers
.IsSet(aBckgrnd
),
1373 aVisibleLayers
.IsSet(aBckgrndObj
));
1379 USHORT
SdDrawDocument::CreatePage (
1380 SdPage
* pActualPage
,
1382 const String
& sStandardPageName
,
1383 const String
& sNotesPageName
,
1384 AutoLayout eStandardLayout
,
1385 AutoLayout eNotesLayout
,
1389 SdPage
* pPreviousStandardPage
;
1390 SdPage
* pPreviousNotesPage
;
1391 SdPage
* pStandardPage
;
1394 // From the given page determine the standard page and notes page of which
1395 // to take the layout and the position where to insert the new pages.
1396 if (ePageKind
== PK_NOTES
)
1398 pPreviousNotesPage
= pActualPage
;
1399 USHORT nNotesPageNum
= pPreviousNotesPage
->GetPageNum() + 2;
1400 pPreviousStandardPage
= (SdPage
*) GetPage(nNotesPageNum
- 3);
1401 eStandardLayout
= pPreviousStandardPage
->GetAutoLayout();
1405 pPreviousStandardPage
= pActualPage
;
1406 USHORT nStandardPageNum
= pPreviousStandardPage
->GetPageNum() + 2;
1407 pPreviousNotesPage
= (SdPage
*) GetPage(nStandardPageNum
- 1);
1408 eNotesLayout
= pPreviousNotesPage
->GetAutoLayout();
1411 // Create new standard page and set it up.
1412 pStandardPage
= (SdPage
*) AllocPage(FALSE
);
1415 // Set the size here since else the presobj autolayout
1417 pStandardPage
->SetSize( pPreviousStandardPage
->GetSize() );
1418 pStandardPage
->SetBorder( pPreviousStandardPage
->GetLftBorder(),
1419 pPreviousStandardPage
->GetUppBorder(),
1420 pPreviousStandardPage
->GetRgtBorder(),
1421 pPreviousStandardPage
->GetLwrBorder() );
1423 // Use master page of current page.
1424 pStandardPage
->TRG_SetMasterPage(pPreviousStandardPage
->TRG_GetMasterPage());
1426 // User layout of current standard page.
1427 pStandardPage
->SetLayoutName( pPreviousStandardPage
->GetLayoutName() );
1428 pStandardPage
->SetAutoLayout(eStandardLayout
, TRUE
);
1429 pStandardPage
->setHeaderFooterSettings( pPreviousStandardPage
->getHeaderFooterSettings() );
1431 // transition settings of current page
1432 pStandardPage
->setTransitionType( pPreviousStandardPage
->getTransitionType() );
1433 pStandardPage
->setTransitionSubtype( pPreviousStandardPage
->getTransitionSubtype() );
1434 pStandardPage
->setTransitionDirection( pPreviousStandardPage
->getTransitionDirection() );
1435 pStandardPage
->setTransitionFadeColor( pPreviousStandardPage
->getTransitionFadeColor() );
1436 pStandardPage
->setTransitionDuration( pPreviousStandardPage
->getTransitionDuration() );
1438 // apply previous animation timing
1439 pStandardPage
->SetPresChange( pPreviousStandardPage
->GetPresChange() );
1440 pStandardPage
->SetTime( pPreviousStandardPage
->GetTime() );
1442 // Create new notes page and set it up.
1443 pNotesPage
= (SdPage
*) AllocPage(FALSE
);
1444 pNotesPage
->SetPageKind(PK_NOTES
);
1446 // Use master page of current page.
1447 pNotesPage
->TRG_SetMasterPage(pPreviousNotesPage
->TRG_GetMasterPage());
1449 // Use layout of current notes page.
1450 pNotesPage
->SetLayoutName( pPreviousNotesPage
->GetLayoutName() );
1451 pNotesPage
->SetAutoLayout(eNotesLayout
, TRUE
);
1452 pNotesPage
->setHeaderFooterSettings( pPreviousNotesPage
->getHeaderFooterSettings() );
1454 return InsertPageSet (
1455 pActualPage
, ePageKind
,
1470 USHORT
SdDrawDocument::DuplicatePage (USHORT nPageNum
)
1472 PageKind ePageKind
= PK_STANDARD
;
1474 // Get current page.
1475 SdPage
* pActualPage
= GetSdPage(nPageNum
, ePageKind
);
1477 // Get background flags.
1478 SdrLayerAdmin
& rLayerAdmin
= GetLayerAdmin();
1479 BYTE aBckgrnd
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRND
)), FALSE
);
1480 BYTE aBckgrndObj
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ
)), FALSE
);
1481 SetOfByte aVisibleLayers
= pActualPage
->TRG_GetMasterPageVisibleLayers();
1483 // Get layout from current page.
1484 AutoLayout eAutoLayout
= pActualPage
->GetAutoLayout();
1486 return DuplicatePage (
1487 pActualPage
, ePageKind
,
1488 // No names for the new slides.
1490 eAutoLayout
, eAutoLayout
,
1491 aVisibleLayers
.IsSet(aBckgrnd
),
1492 aVisibleLayers
.IsSet(aBckgrndObj
));
1498 USHORT
SdDrawDocument::DuplicatePage (
1499 SdPage
* pActualPage
,
1501 const String
& sStandardPageName
,
1502 const String
& sNotesPageName
,
1503 AutoLayout eStandardLayout
,
1504 AutoLayout eNotesLayout
,
1508 SdPage
* pPreviousStandardPage
;
1509 SdPage
* pPreviousNotesPage
;
1510 SdPage
* pStandardPage
;
1513 // From the given page determine the standard page and the notes page
1514 // of which to make copies.
1515 if (ePageKind
== PK_NOTES
)
1517 pPreviousNotesPage
= pActualPage
;
1518 USHORT nNotesPageNum
= pPreviousNotesPage
->GetPageNum() + 2;
1519 pPreviousStandardPage
= (SdPage
*) GetPage(nNotesPageNum
- 3);
1523 pPreviousStandardPage
= pActualPage
;
1524 USHORT nStandardPageNum
= pPreviousStandardPage
->GetPageNum() + 2;
1525 pPreviousNotesPage
= (SdPage
*) GetPage(nStandardPageNum
- 1);
1528 // Create duplicates of a standard page and the associated notes page.
1529 pStandardPage
= (SdPage
*) pPreviousStandardPage
->Clone();
1530 pNotesPage
= (SdPage
*) pPreviousNotesPage
->Clone();
1532 return InsertPageSet (
1533 pActualPage
, ePageKind
,
1548 USHORT
SdDrawDocument::InsertPageSet (
1549 SdPage
* pActualPage
,
1551 const String
& sStandardPageName
,
1552 const String
& sNotesPageName
,
1553 AutoLayout eStandardLayout
,
1554 AutoLayout eNotesLayout
,
1558 SdPage
* pStandardPage
,
1561 SdPage
* pPreviousStandardPage
;
1562 SdPage
* pPreviousNotesPage
;
1563 USHORT nStandardPageNum
;
1564 USHORT nNotesPageNum
;
1565 String aStandardPageName
= sStandardPageName
;
1566 String aNotesPageName
= sNotesPageName
;
1568 // Gather some information about the standard page and the notes page
1569 // that are to be inserted. This makes sure that there is allways one
1570 // standard page followed by one notes page.
1571 if (ePageKind
== PK_NOTES
)
1573 pPreviousNotesPage
= pActualPage
;
1574 nNotesPageNum
= pPreviousNotesPage
->GetPageNum() + 2;
1575 pPreviousStandardPage
= (SdPage
*) GetPage(nNotesPageNum
- 3);
1576 nStandardPageNum
= nNotesPageNum
- 1;
1577 eStandardLayout
= pPreviousStandardPage
->GetAutoLayout();
1581 pPreviousStandardPage
= pActualPage
;
1582 nStandardPageNum
= pPreviousStandardPage
->GetPageNum() + 2;
1583 pPreviousNotesPage
= (SdPage
*) GetPage(nStandardPageNum
- 1);
1584 nNotesPageNum
= nStandardPageNum
+ 1;
1585 aNotesPageName
= aStandardPageName
;
1586 eNotesLayout
= pPreviousNotesPage
->GetAutoLayout();
1590 // Set up and insert the standard page.
1592 pPreviousStandardPage
,
1599 // Set up and insert the notes page.
1600 pNotesPage
->SetPageKind(PK_NOTES
);
1609 // Return an index that allows the caller to access the newly inserted
1610 // pages by using GetSdPage().
1611 return pStandardPage
->GetPageNum() / 2;
1617 void SdDrawDocument::SetupNewPage (
1618 SdPage
* pPreviousPage
,
1620 const String
& sPageName
,
1621 USHORT nInsertionPoint
,
1625 if (pPreviousPage
!= NULL
)
1627 pPage
->SetSize( pPreviousPage
->GetSize() );
1628 pPage
->SetBorder( pPreviousPage
->GetLftBorder(),
1629 pPreviousPage
->GetUppBorder(),
1630 pPreviousPage
->GetRgtBorder(),
1631 pPreviousPage
->GetLwrBorder() );
1633 pPage
->SetName(sPageName
);
1635 InsertPage(pPage
, nInsertionPoint
);
1637 if (pPreviousPage
!= NULL
)
1639 SdrLayerAdmin
& rLayerAdmin
= GetLayerAdmin();
1640 BYTE aBckgrnd
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRND
)), FALSE
);
1641 BYTE aBckgrndObj
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ
)), FALSE
);
1642 SetOfByte aVisibleLayers
= pPreviousPage
->TRG_GetMasterPageVisibleLayers();
1643 aVisibleLayers
.Set(aBckgrnd
, bIsPageBack
);
1644 aVisibleLayers
.Set(aBckgrndObj
, bIsPageObj
);
1645 pPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
1649 sd::UndoManager
* SdDrawDocument::GetUndoManager() const
1651 return mpDocSh
? dynamic_cast< sd::UndoManager
* >(mpDocSh
->GetUndoManager()) : 0;