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: drawdoc.hxx,v $
10 * $Revision: 1.49.108.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 ************************************************************************/
34 #include <com/sun/star/lang/Locale.hpp>
35 #include <com/sun/star/text/WritingMode.hpp>
36 #include <com/sun/star/frame/XModel.hdl>
37 #include <vcl/print.hxx>
38 #include <svx/fmmodel.hxx>
40 #include <svx/pageitem.hxx>
41 #include <unotools/charclass.hxx>
42 #include <sot/storage.hxx>
43 #include <rsc/rscsfx.hxx>
44 #include <com/sun/star/lang/Locale.hpp>
45 #include <com/sun/star/text/WritingMode.hpp>
48 #include <svx/svdundo.hxx>
52 #ifndef INCLUDED_MEMORY
54 #define INCLUDED_MEMORY
73 namespace presentation
92 class SdAnimationInfo
;
95 class SdStyleSheetPool
;
103 class SdTransferable
;
104 struct SpellCallbackInfo
;
105 struct StyleRequestData
;
106 class SdDrawDocument
;
110 #ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED
111 #define SV_DECL_DRAW_DOC_SHELL_DEFINED
112 SV_DECL_REF(DrawDocShell
)
119 class ImpDrawPageListWatcher
;
120 class ImpMasterPageListWatcher
;
122 struct StyleReplaceData
124 SfxStyleFamily nFamily
;
125 SfxStyleFamily nNewFamily
;
138 struct PresentationSettings
140 rtl::OUString maPresPage
;
143 sal_Bool mbCustomShow
;
145 sal_Bool mbMouseVisible
;
146 sal_Bool mbMouseAsPen
;
147 sal_Bool mbLockedPages
;
148 sal_Bool mbAlwaysOnTop
;
149 sal_Bool mbFullScreen
;
150 sal_Bool mbAnimationAllowed
;
151 sal_Int32 mnPauseTimeout
;
152 sal_Bool mbShowPauseLogo
;
153 sal_Bool mbStartWithNavigator
;
155 PresentationSettings();
156 PresentationSettings( const PresentationSettings
& r
);
160 // ------------------
161 // - SdDrawDocument -
162 // ------------------
164 class SdDrawDocument
: public FmFormModel
167 ::sd::Outliner
* mpOutliner
; // local outliner for outline mode
168 ::sd::Outliner
* mpInternalOutliner
; // internal outliner for creation of text objects
169 Timer
* mpWorkStartupTimer
;
170 Timer
* mpOnlineSpellingTimer
;
171 sd::ShapeList
* mpOnlineSpellingList
;
172 SvxSearchItem
* mpOnlineSearchItem
;
173 List
* mpFrameViewList
;
174 List
* mpCustomShowList
;
175 ::sd::DrawDocShell
* mpDocSh
;
176 SdTransferable
* mpCreatingTransferable
;
177 BOOL mbHasOnlineSpellErrors
;
178 BOOL mbInitialOnlineSpellingEnabled
;
179 String maBookmarkFile
;
180 ::sd::DrawDocShellRef mxBookmarkDocShRef
;
182 sd::PresentationSettings maPresentationSettings
;
184 ::com::sun::star::uno::Reference
< ::com::sun::star::presentation::XPresentation2
> mxPresentation
;
186 BOOL mbNewOrLoadCompleted
;
189 BOOL mbSummationOfParagraphs
;
190 bool mbStartWithPresentation
; // is set to true when starting with command line parameter -start
191 LanguageType meLanguage
;
192 LanguageType meLanguageCJK
;
193 LanguageType meLanguageCTL
;
194 SvxNumType mePageNumType
;
195 ::sd::DrawDocShellRef mxAllocedDocShRef
; // => AllocModel()
196 BOOL mbAllocDocSh
; // => AllocModel()
197 DocumentType meDocType
;
198 CharClass
* mpCharClass
;
199 ::com::sun::star::lang::Locale
* mpLocale
;
202 ::std::auto_ptr
<ImpDrawPageListWatcher
> mpDrawPageListWatcher
;
203 ::std::auto_ptr
<ImpMasterPageListWatcher
> mpMasterPageListWatcher
;
205 void UpdatePageObjectsInNotes(USHORT nStartPos
);
206 void UpdatePageRelativeURLs(SdPage
* pPage
, USHORT nPos
, sal_Int32 nIncrement
);
207 void FillOnlineSpellingList(SdPage
* pPage
);
208 void SpellObject(SdrTextObj
* pObj
);
210 DECL_LINK(WorkStartupHdl
, Timer
*);
211 DECL_LINK(OnlineSpellingHdl
, Timer
*);
212 DECL_LINK(OnlineSpellEventHdl
, EditStatus
*);
214 std::vector
< rtl::OUString
> maAnnotationAuthors
;
218 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> createUnoModel();
222 class InsertBookmarkAsPage_PageFunctorBase
;
226 SdDrawDocument(DocumentType eType
, SfxObjectShell
* pDocSh
);
229 virtual SdrModel
* AllocModel() const;
230 virtual SdrPage
* AllocPage(FASTBOOL bMasterPage
);
231 virtual const SdrModel
* LoadModel(const String
& rFileName
);
232 virtual void DisposeLoadedModels();
233 virtual FASTBOOL
IsReadOnly() const;
234 virtual void SetChanged(sal_Bool bFlag
= sal_True
);
235 virtual SvStream
* GetDocumentStream(SdrDocumentStreamInfo
& rStreamInfo
) const;
237 SfxItemPool
& GetPool() { return( *pItemPool
); }
239 ::sd::Outliner
* GetOutliner(BOOL bCreateOutliner
=TRUE
);
240 SD_DLLPUBLIC ::sd::Outliner
* GetInternalOutliner(BOOL bCreateOutliner
=TRUE
);
242 ::sd::DrawDocShell
* GetDocSh() const { return mpDocSh
; }
244 LanguageType
GetLanguage( const USHORT nId
) const;
245 void SetLanguage( const LanguageType eLang
, const USHORT nId
);
247 SvxNumType
GetPageNumType() const;
248 void SetPageNumType(SvxNumType eType
) { mePageNumType
= eType
; }
249 SD_DLLPUBLIC String
CreatePageNumValue(USHORT nNum
) const;
251 DocumentType
GetDocumentType() const { return meDocType
; }
253 void SetAllocDocSh(BOOL bAlloc
);
255 void CreatingDataObj( SdTransferable
* pTransferable
) { mpCreatingTransferable
= pTransferable
; }
257 /** if the document does not contain at least one handout, one slide and one notes page with
258 at least one master each this methods creates them.
259 If a reference document is given, the sizes and border settings of that document are used
260 for newly created slides.
262 SD_DLLPUBLIC
void CreateFirstPages( SdDrawDocument
* pRefDocument
= 0 );
263 SD_DLLPUBLIC BOOL
CreateMissingNotesAndHandoutPages();
265 void MovePage(USHORT nPgNum
, USHORT nNewPos
);
266 void InsertPage(SdrPage
* pPage
, USHORT nPos
=0xFFFF);
267 void DeletePage(USHORT nPgNum
);
268 SdrPage
* RemovePage(USHORT nPgNum
);
270 virtual void InsertMasterPage(SdrPage
* pPage
, USHORT nPos
=0xFFFF);
271 virtual SdrPage
* RemoveMasterPage(USHORT nPgNum
);
273 void RemoveUnnecessaryMasterPages( SdPage
* pMaster
=NULL
, BOOL bOnlyDuplicatePages
=FALSE
, BOOL bUndo
=TRUE
);
274 SD_DLLPUBLIC
void SetMasterPage(USHORT nSdPageNum
, const String
& rLayoutName
,
275 SdDrawDocument
* pSourceDoc
, BOOL bMaster
, BOOL bCheckMasters
);
277 SD_DLLPUBLIC SdDrawDocument
* OpenBookmarkDoc(const String
& rBookmarkFile
);
278 SdDrawDocument
* OpenBookmarkDoc(SfxMedium
& rMedium
);
279 BOOL
InsertBookmark(List
* pBookmarkList
, List
* pExchangeList
, BOOL bLink
,
280 BOOL bReplace
, USHORT nPgPos
, BOOL bNoDialogs
,
281 ::sd::DrawDocShell
* pBookmarkDocSh
, BOOL bCopy
,
284 bool IsStartWithPresentation() const;
285 void SetStartWithPresentation( bool bStartWithPresentation
);
287 /** Insert pages into this document
289 This method inserts whole pages into this document, either
290 selected ones (specified via pBookmarkList/pExchangeList), or
291 all from the source document.
293 @attention Beware! This method in it's current state does not
294 handle all combinations of their input parameters
295 correctly. For example, for pBookmarkList=NULL, bReplace=TRUE
296 is ignored (no replace happens).
299 A list of strings, denoting the names of the pages to be copied
302 A list of strings, denoting the names of the pages to be renamed
305 Whether the inserted pages should be links to the bookmark document
308 Whether the pages should not be inserted, but replace the pages in
309 the destination document
312 Insertion point/start of replacement
315 Whether query dialogs are allowed (e.g. for page scaling)
317 @param pBookmarkDocSh
318 DocShell of the source document (used e.g. to extract the filename
322 Whether the source document should be treated as immutable (i.e.
323 inserted pages are not removed from it, but cloned)
325 @param bMergeMasterPages
326 Whether the source document's master pages should be copied, too.
328 @param bPreservePageNames
329 Whether the replace operation should take the name from the new
330 page, or preserve the old name
332 BOOL
InsertBookmarkAsPage(List
* pBookmarkList
, List
* pExchangeList
,
333 BOOL bLink
, BOOL bReplace
, USHORT nPgPos
,
334 BOOL bNoDialogs
, ::sd::DrawDocShell
* pBookmarkDocSh
,
335 BOOL bCopy
, BOOL bMergeMasterPages
,
336 BOOL bPreservePageNames
);
337 BOOL
InsertBookmarkAsObject(List
* pBookmarkList
, List
* pExchangeListL
,
338 BOOL bLink
, ::sd::DrawDocShell
* pBookmarkDocSh
,
340 void IterateBookmarkPages( SdDrawDocument
* pBookmarkDoc
, List
* pBookmarkList
,
341 USHORT nBMSdPageCount
,
342 InsertBookmarkAsPage_PageFunctorBase
& rPageIterator
);
343 SD_DLLPUBLIC
void CloseBookmarkDoc();
345 SdrObject
* GetObj(const String
& rObjName
) const;
347 /** Return the first page that has the given name. Regular pages and
348 notes pages are searched first. When not found then the master
351 Name of the page to return.
352 @param rbIsMasterPage
353 Is set by the method to indicate whether the returned index
354 belongs to a master page (<TRUE/>) or a regular or notes page
355 (<FALSE/>). The given value is ignored.
357 Returns the index of the page with the given name or
358 SDRPAGE_NOTFOUND (=0xffff) when such a page does not exist.
360 USHORT
GetPageByName(const String
& rPgName
, BOOL
& rbIsMasterPage
) const;
361 SD_DLLPUBLIC SdPage
*GetSdPage(USHORT nPgNum
, PageKind ePgKind
) const;
362 SD_DLLPUBLIC USHORT
GetSdPageCount(PageKind ePgKind
) const;
364 void SetSelected(SdPage
* pPage
, BOOL bSelect
);
365 BOOL
MovePages(USHORT nTargetPage
);
367 SD_DLLPUBLIC SdPage
*GetMasterSdPage(USHORT nPgNum
, PageKind ePgKind
);
368 SD_DLLPUBLIC USHORT
GetMasterSdPageCount(PageKind ePgKind
) const;
370 USHORT
GetMasterPageUserCount(SdrPage
* pMaster
) const;
372 const sd::PresentationSettings
& getPresentationSettings() const { return maPresentationSettings
; }
373 sd::PresentationSettings
& getPresentationSettings() { return maPresentationSettings
; }
375 const ::com::sun::star::uno::Reference
< ::com::sun::star::presentation::XPresentation2
>& getPresentation() const;
377 void SetSummationOfParagraphs( BOOL bOn
= TRUE
) { mbSummationOfParagraphs
= bOn
; }
378 BOOL
IsSummationOfParagraphs() const { return mbSummationOfParagraphs
; }
380 /** Set the mode that controls whether (and later how) the formatting of the document
381 depends on the current printer metrics.
384 scope="com::sun::star::document::PrinterIndependentLayout">ENABLED</const>
385 to make formatting printer-independent and <const
386 scope="com::sun::star::document::PrinterIndependentLayout">DISABLED</const>
387 to make formatting depend on the current printer metrics.
389 void SetPrinterIndependentLayout (sal_Int32 nMode
);
391 /** Get the flag that controls whether the formatting of the document
392 depends on the current printer metrics.
395 scope="com::sun::star::document::PrinterIndependentLayout">ENABLED</const>
396 when formatting is printer-independent and <const
397 scope="com::sun::star::document::PrinterIndependentLayout">DISABLED</const>
398 when formatting depends on the current printer metrics.
400 sal_Int32
GetPrinterIndependentLayout (void);
402 void SetOnlineSpell( BOOL bIn
);
403 BOOL
GetOnlineSpell() const { return mbOnlineSpell
; }
404 void StopOnlineSpelling();
405 void StartOnlineSpelling(BOOL bForceSpelling
=TRUE
);
407 void ImpOnlineSpellCallback(SpellCallbackInfo
* pInfo
, SdrObject
* pObj
, SdrOutliner
* pOutl
);
409 void InsertObject(SdrObject
* pObj
, SdPage
* pPage
);
410 void RemoveObject(SdrObject
* pObj
, SdPage
* pPage
);
412 ULONG
GetLinkCount();
414 List
* GetFrameViewList() const { return mpFrameViewList
; }
415 SD_DLLPUBLIC List
* GetCustomShowList(BOOL bCreate
= FALSE
);
417 void NbcSetChanged(sal_Bool bFlag
= sal_True
);
419 void SetTextDefaults() const;
421 void CreateLayoutTemplates();
422 void RenameLayoutTemplate(const String
& rOldLayoutName
, const String
& rNewName
);
424 void CreateDefaultCellStyles();
426 SD_DLLPUBLIC
void StopWorkStartupDelay();
428 void NewOrLoadCompleted(DocCreationMode eMode
);
429 void NewOrLoadCompleted( SdPage
* pPage
, SdStyleSheetPool
* pSPool
);
430 BOOL
IsNewOrLoadCompleted() const {return mbNewOrLoadCompleted
; }
432 ::sd::FrameView
* GetFrameView(ULONG nPos
) {
433 return static_cast< ::sd::FrameView
*>(
434 mpFrameViewList
->GetObject(nPos
));}
437 SdAnimationInfo
* GetAnimationInfo(SdrObject
* pObject
) const;
439 SD_DLLPUBLIC
static SdAnimationInfo
* GetShapeUserData(SdrObject
& rObject
, bool bCreate
= false );
441 SdIMapInfo
* GetIMapInfo( SdrObject
* pObject
) const;
442 IMapObject
* GetHitIMapObject( SdrObject
* pObject
, const Point
& rWinPoint
, const ::Window
& rCmpWnd
);
444 CharClass
* GetCharClass() const { return mpCharClass
; }
446 void RestoreLayerNames();
447 void MakeUniqueLayerNames();
449 void UpdateAllLinks();
451 void CheckMasterPages();
453 void Merge(SdrModel
& rSourceModel
,
454 USHORT nFirstPageNum
=0, USHORT nLastPageNum
=0xFFFF,
455 USHORT nDestPos
=0xFFFF,
456 FASTBOOL bMergeMasterPages
=FALSE
, FASTBOOL bAllMasterPages
=FALSE
,
457 FASTBOOL bUndo
=TRUE
, FASTBOOL bTreadSourceAsConst
=FALSE
);
459 SD_DLLPUBLIC ::com::sun::star::text::WritingMode
GetDefaultWritingMode() const;
460 void SetDefaultWritingMode( ::com::sun::star::text::WritingMode eMode
);
462 /** replacespOldPage from all custom shows with pNewPage or removes pOldPage from
463 all custom shows if pNewPage is 0.
465 void ReplacePageInCustomShows( const SdPage
* pOldPage
, const SdPage
* pNewPage
);
469 static SdDrawDocument
* pDocLockedInsertingLinks
; // static to prevent recursions while resolving links
471 /** This method acts as a simplified front end for the more complex
472 <member>CreatePage()</member> method.
474 The page number as passed to the <member>GetSdPage()</member>
475 method from which to use certain properties for the new pages.
476 These include the auto layout.
478 Returns an index of the inserted pages that can be used with the
479 <member>GetSdPage()</member> method.
481 USHORT
CreatePage (USHORT nPageNum
);
483 /** Create and insert a set of two new pages: a standard (draw) page and
484 the associated notes page. The new pages are inserted direclty
485 after the specified page set.
487 This page is used to retrieve the layout for the page to
490 This specifies whether <argument>pCurrentPage</argument> is a
491 standard (draw) page or a notes page.
492 @param sStandardPageName
493 Name of the standard page. An empty string leads to using an
494 automatically created name.
495 @param sNotesPageName
496 Name of the standard page. An empty string leads to using an
497 automatically created name.
498 @param eStandardLayout
499 Layout to use for the new standard page. Note that this layout
500 is not used when the given <argument>pCurrentPage</argument> is
501 not a standard page. In this case the layout is taken from the
502 standard page associated with <argument>pCurrentPage</argument>.
504 Layout to use for the new notes page. Note that this layout
505 is not used when the given <argument>pCurrentPage</argument> is
506 not a notes page. In this case the layout is taken from the
507 notes page associated with <argument>pCurrentPage</argument>.
509 This flag indicates whether to show the background shape.
511 This flag indicates whether to show the shapes on the master page.
514 Returns an index of the inserted pages that can be used with the
515 <member>GetSdPage()</member> method.
518 SdPage
* pCurrentPage
,
520 const String
& sStandardPageName
,
521 const String
& sNotesPageName
,
522 AutoLayout eStandardLayout
,
523 AutoLayout eNotesLayout
,
527 /** This method acts as a simplified front end for the more complex
528 <member>DuplicatePage()</member> method.
530 The page number as passed to the <member>GetSdPage()</member>
531 method for which the standard page and the notes page are to be
534 Returns an index of the inserted pages that can be used with the
535 <member>GetSdPage()</member> method.
537 USHORT
DuplicatePage (USHORT nPageNum
);
539 /** Create and insert a set of two new pages that are copies of the
540 given <argument>pCurrentPage</argument> and its associated notes
541 resp. standard page. The copies are inserted directly after the
544 This page and its associated notes/standard page is copied.
546 This specifies whether <argument>pCurrentPage</argument> is a
547 standard (draw) page or a notes page.
548 @param sStandardPageName
549 Name of the standard page. An empty string leads to using an
550 automatically created name.
551 @param sNotesPageName
552 Name of the standard page. An empty string leads to using an
553 automatically created name.
554 @param eStandardLayout
555 Layout to use for the new standard page. Note that this layout
556 is not used when the given <argument>pCurrentPage</argument> is
557 not a standard page. In this case the layout is taken from the
558 standard page associated with <argument>pCurrentPage</argument>.
560 Layout to use for the new notes page. Note that this layout
561 is not used when the given <argument>pCurrentPage</argument> is
562 not a notes page. In this case the layout is taken from the
563 notes page associated with <argument>pCurrentPage</argument>.
565 This flag indicates whether to show the background shape.
567 This flag indicates whether to show the shapes on the master page.
570 Returns an index of the inserted pages that can be used with the
571 <member>GetSdPage()</member> method.
573 USHORT
DuplicatePage (
574 SdPage
* pCurrentPage
,
576 const String
& sStandardPageName
,
577 const String
& sNotesPageName
,
578 AutoLayout eStandardLayout
,
579 AutoLayout eNotesLayout
,
583 /** return the document fonts for latin, cjk and ctl according to the current
584 languages set at this document */
585 void getDefaultFonts( Font
& rLatinFont
, Font
& rCJKFont
, Font
& rCTLFont
);
587 sd::UndoManager
* GetUndoManager() const;
589 /* converts the given western font height to a corresponding ctl font height, deppending on the system language */
590 static sal_uInt32
convertFontHeightToCTL( sal_uInt32 nWesternFontHeight
);
592 /** Get the style sheet pool if it was a SdStyleSheetPool.
594 SD_DLLPUBLIC SdStyleSheetPool
* GetSdStyleSheetPool() const;
596 void UpdatePageRelativeURLs(const String
& rOldName
, const String
& rNewName
);
598 void SetCalcFieldValueHdl( ::Outliner
* pOutliner
);
600 sal_uInt16
GetAnnotationAuthorIndex( const rtl::OUString
& rAuthor
);
603 /** This member stores the printer independent layout mode. Please
604 refer to <member>SetPrinterIndependentLayout()</member> for its
607 sal_Int32 mnPrinterIndependentLayout
;
609 /** Insert a given set of standard and notes page after the given <argument>pCurrentPage</argument>.
611 This page and its associated notes/standard page is copied.
613 This specifies whether <argument>pCurrentPage</argument> is a
614 standard (draw) page or a notes page.
615 @param sStandardPageName
616 Name of the standard page. An empty string leads to using an
617 automatically created name.
618 @param sNotesPageName
619 Name of the standard page. An empty string leads to using an
620 automatically created name.
621 @param eStandardLayout
622 Layout to use for the new standard page. Note that this layout
623 is not used when the given <argument>pCurrentPage</argument> is
624 not a standard page. In this case the layout is taken from the
625 standard page associated with <argument>pCurrentPage</argument>.
627 Layout to use for the new notes page. Note that this layout
628 is not used when the given <argument>pCurrentPage</argument> is
629 not a notes page. In this case the layout is taken from the
630 notes page associated with <argument>pCurrentPage</argument>.
632 This flag indicates whether to show the background shape.
634 This flag indicates whether to show the shapes on the master page.
636 The standard page to insert.
638 The notes page to insert.
641 Returns an index of the inserted pages that can be used with the
642 <member>GetSdPage()</member> method.
644 USHORT
InsertPageSet (
645 SdPage
* pCurrentPage
,
647 const String
& sStandardPageName
,
648 const String
& sNotesPageName
,
649 AutoLayout eStandardLayout
,
650 AutoLayout eNotesLayout
,
654 SdPage
* pStandardPage
,
657 /** Set up a newly created page and insert it into the list of pages.
659 A page to take the size and border geometry from.
661 This is the page to set up and insert.
663 The name of the new page.
664 @param nInsertionPoint
665 Index of the page before which the new page will be inserted.
667 This flag indicates whether to show the background shape.
669 This flag indicates whether to show the shapes on the master
673 SdPage
* pPreviousPage
,
675 const String
& sPageName
,
676 USHORT nInsertionPoint
,
681 virtual void PageListChanged();
682 virtual void MasterPageListChanged();
688 // an instance of this guard disables modification of a document
689 // during its lifetime
693 ModifyGuard( DrawDocShell
* pDocShell
);
694 ModifyGuard( SdDrawDocument
* pDoc
);
700 DrawDocShell
* mpDocShell
;
701 SdDrawDocument
* mpDoc
;
702 BOOL mbIsEnableSetModified
;
703 BOOL mbIsDocumentChanged
;
708 #endif // _DRAWDOC_HXX