1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <com/sun/star/lang/Locale.hpp>
24 #include <com/sun/star/text/WritingMode.hpp>
25 #include <com/sun/star/frame/XModel.hpp>
26 #include <vcl/print.hxx>
27 #include <svx/fmmodel.hxx>
29 #include <svx/pageitem.hxx>
30 #include <unotools/charclass.hxx>
31 #include <sot/storage.hxx>
32 #include <rsc/rscsfx.hxx>
34 #include <svx/svdundo.hxx>
48 namespace presentation
66 class SdAnimationInfo
;
69 class SdStyleSheetPool
;
76 struct SpellCallbackInfo
;
77 struct StyleRequestData
;
80 class SdCustomShowList
;
84 #ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED
85 #define SV_DECL_DRAW_DOC_SHELL_DEFINED
86 SV_DECL_REF(DrawDocShell
)
94 class ImpDrawPageListWatcher
;
95 class ImpMasterPageListWatcher
;
97 struct StyleReplaceData
99 SfxStyleFamily nFamily
;
100 SfxStyleFamily nNewFamily
;
113 struct PresentationSettings
118 sal_Bool mbCustomShow
;
120 sal_Bool mbMouseVisible
;
121 sal_Bool mbMouseAsPen
;
122 sal_Bool mbLockedPages
;
123 sal_Bool mbAlwaysOnTop
;
124 sal_Bool mbFullScreen
;
125 sal_Bool mbAnimationAllowed
;
126 sal_Int32 mnPauseTimeout
;
127 sal_Bool mbShowPauseLogo
;
128 sal_Bool mbStartWithNavigator
;
130 PresentationSettings();
131 PresentationSettings( const PresentationSettings
& r
);
136 // ------------------
137 // - SdDrawDocument -
138 // ------------------
140 class SdDrawDocument
: public FmFormModel
143 ::sd::Outliner
* mpOutliner
; ///< local outliner for outline mode
144 ::sd::Outliner
* mpInternalOutliner
; ///< internal outliner for creation of text objects
145 Timer
* mpWorkStartupTimer
;
146 Timer
* mpOnlineSpellingTimer
;
147 sd::ShapeList
* mpOnlineSpellingList
;
148 SvxSearchItem
* mpOnlineSearchItem
;
149 std::vector
<sd::FrameView
*> maFrameViewList
;
150 SdCustomShowList
* mpCustomShowList
;
151 ::sd::DrawDocShell
* mpDocSh
;
152 SdTransferable
* mpCreatingTransferable
;
153 sal_Bool mbHasOnlineSpellErrors
;
154 sal_Bool mbInitialOnlineSpellingEnabled
;
155 String maBookmarkFile
;
156 ::sd::DrawDocShellRef mxBookmarkDocShRef
;
158 sd::PresentationSettings maPresentationSettings
;
160 ::com::sun::star::uno::Reference
< ::com::sun::star::presentation::XPresentation2
> mxPresentation
;
162 sal_Bool mbNewOrLoadCompleted
;
164 sal_Bool mbOnlineSpell
;
165 sal_Bool mbSummationOfParagraphs
;
166 bool mbStartWithPresentation
; ///< is set to true when starting with command line parameter -start
167 bool mbExitAfterPresenting
; ///< true if mbStartWithPresentation AND Presentation was shown fully
168 LanguageType meLanguage
;
169 LanguageType meLanguageCJK
;
170 LanguageType meLanguageCTL
;
171 SvxNumType mePageNumType
;
172 ::sd::DrawDocShellRef mxAllocedDocShRef
; // => AllocModel()
173 sal_Bool mbAllocDocSh
; // => AllocModel()
174 DocumentType meDocType
;
175 CharClass
* mpCharClass
;
176 ::com::sun::star::lang::Locale
* mpLocale
;
178 ::std::auto_ptr
<ImpDrawPageListWatcher
> mpDrawPageListWatcher
;
179 ::std::auto_ptr
<ImpMasterPageListWatcher
> mpMasterPageListWatcher
;
181 void UpdatePageObjectsInNotes(sal_uInt16 nStartPos
);
182 void UpdatePageRelativeURLs(SdPage
* pPage
, sal_uInt16 nPos
, sal_Int32 nIncrement
);
183 void FillOnlineSpellingList(SdPage
* pPage
);
184 void SpellObject(SdrTextObj
* pObj
);
186 DECL_LINK(WorkStartupHdl
, void *);
187 DECL_LINK(OnlineSpellingHdl
, void *);
188 DECL_LINK(OnlineSpellEventHdl
, EditStatus
*);
190 std::vector
< OUString
> maAnnotationAuthors
;
192 bool mbUseEmbedFonts
;
196 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> createUnoModel();
202 SdDrawDocument(DocumentType eType
, SfxObjectShell
* pDocSh
);
205 virtual SdrModel
* AllocModel() const;
206 virtual SdrPage
* AllocPage(bool bMasterPage
);
207 virtual bool IsReadOnly() const;
208 virtual void SetChanged(sal_Bool bFlag
= sal_True
);
210 SfxItemPool
& GetPool() { return( *pItemPool
); }
212 ::sd::Outliner
* GetOutliner(sal_Bool bCreateOutliner
=sal_True
);
213 SD_DLLPUBLIC ::sd::Outliner
* GetInternalOutliner(sal_Bool bCreateOutliner
=sal_True
);
215 ::sd::DrawDocShell
* GetDocSh() const { return mpDocSh
; }
217 LanguageType
GetLanguage( const sal_uInt16 nId
) const;
218 void SetLanguage( const LanguageType eLang
, const sal_uInt16 nId
);
220 SvxNumType
GetPageNumType() const;
221 void SetPageNumType(SvxNumType eType
) { mePageNumType
= eType
; }
222 SD_DLLPUBLIC String
CreatePageNumValue(sal_uInt16 nNum
) const;
224 DocumentType
GetDocumentType() const { return meDocType
; }
226 void SetAllocDocSh(sal_Bool bAlloc
);
228 void CreatingDataObj( SdTransferable
* pTransferable
) { mpCreatingTransferable
= pTransferable
; }
230 /** if the document does not contain at least one handout, one slide and one notes page with
231 at least one master each this methods creates them.
232 If a reference document is given, the sizes and border settings of that document are used
233 for newly created slides.
235 SD_DLLPUBLIC
void CreateFirstPages( SdDrawDocument
* pRefDocument
= 0 );
236 SD_DLLPUBLIC sal_Bool
CreateMissingNotesAndHandoutPages();
238 void MovePage(sal_uInt16 nPgNum
, sal_uInt16 nNewPos
);
239 void InsertPage(SdrPage
* pPage
, sal_uInt16 nPos
=0xFFFF);
240 void DeletePage(sal_uInt16 nPgNum
);
241 SdrPage
* RemovePage(sal_uInt16 nPgNum
);
243 virtual void InsertMasterPage(SdrPage
* pPage
, sal_uInt16 nPos
=0xFFFF);
244 virtual SdrPage
* RemoveMasterPage(sal_uInt16 nPgNum
);
246 void RemoveUnnecessaryMasterPages( SdPage
* pMaster
=NULL
, sal_Bool bOnlyDuplicatePages
=sal_False
, sal_Bool bUndo
=sal_True
);
247 SD_DLLPUBLIC
void SetMasterPage(sal_uInt16 nSdPageNum
, const String
& rLayoutName
,
248 SdDrawDocument
* pSourceDoc
, sal_Bool bMaster
, sal_Bool bCheckMasters
);
250 SD_DLLPUBLIC SdDrawDocument
* OpenBookmarkDoc(const String
& rBookmarkFile
);
251 SdDrawDocument
* OpenBookmarkDoc(SfxMedium
& rMedium
);
253 sal_Bool
InsertBookmark(const std::vector
<OUString
> &rBookmarkList
,
254 std::vector
<OUString
> &rExchangeList
, sal_Bool bLink
,
255 sal_Bool bReplace
, sal_uInt16 nPgPos
, sal_Bool bNoDialogs
,
256 ::sd::DrawDocShell
* pBookmarkDocSh
, sal_Bool bCopy
,
259 bool IsStartWithPresentation() const;
260 void SetStartWithPresentation( bool bStartWithPresentation
);
262 bool IsExitAfterPresenting() const;
263 void SetExitAfterPresenting( bool bExitAfterPresenting
);
265 /** Insert pages into this document
267 This method inserts whole pages into this document, either
268 selected ones (specified via pBookmarkList/pExchangeList), or
269 all from the source document.
271 @attention Beware! This method in it's current state does not
272 handle all combinations of their input parameters
273 correctly. For example, for pBookmarkList=NULL, bReplace=sal_True
274 is ignored (no replace happens).
277 A list of strings, denoting the names of the pages to be copied
280 A list of strings, denoting the names of the pages to be renamed
283 Whether the inserted pages should be links to the bookmark document
286 Whether the pages should not be inserted, but replace the pages in
287 the destination document
290 Insertion point/start of replacement
293 Whether query dialogs are allowed (e.g. for page scaling)
295 @param pBookmarkDocSh
296 DocShell of the source document (used e.g. to extract the filename
300 Whether the source document should be treated as immutable (i.e.
301 inserted pages are not removed from it, but cloned)
303 @param bMergeMasterPages
304 Whether the source document's master pages should be copied, too.
306 @param bPreservePageNames
307 Whether the replace operation should take the name from the new
308 page, or preserve the old name
311 sal_Bool
InsertBookmarkAsPage(const std::vector
<OUString
> &rBookmarkList
,
312 std::vector
<OUString
> *pExchangeList
,
313 sal_Bool bLink
, sal_Bool bReplace
, sal_uInt16 nPgPos
,
314 sal_Bool bNoDialogs
, ::sd::DrawDocShell
* pBookmarkDocSh
,
315 sal_Bool bCopy
, sal_Bool bMergeMasterPages
,
316 sal_Bool bPreservePageNames
);
318 sal_Bool
InsertBookmarkAsObject(const std::vector
<OUString
> &rBookmarkList
,
319 const std::vector
<OUString
> &rExchangeList
,
320 sal_Bool bLink
, ::sd::DrawDocShell
* pBookmarkDocSh
,
321 Point
* pObjPos
, bool bCalcObjCount
= false);
323 SD_DLLPUBLIC
void CloseBookmarkDoc();
325 SdrObject
* GetObj(const String
& rObjName
) const;
327 /** Return the first page that has the given name. Regular pages and
328 notes pages are searched first. When not found then the master
331 Name of the page to return.
332 @param rbIsMasterPage
333 Is set by the method to indicate whether the returned index
334 belongs to a master page (<TRUE/>) or a regular or notes page
335 (<FALSE/>). The given value is ignored.
337 Returns the index of the page with the given name or
338 SDRPAGE_NOTFOUND (=0xffff) when such a page does not exist.
340 sal_uInt16
GetPageByName(const String
& rPgName
, sal_Bool
& rbIsMasterPage
) const;
341 SD_DLLPUBLIC SdPage
*GetSdPage(sal_uInt16 nPgNum
, PageKind ePgKind
) const;
342 SD_DLLPUBLIC sal_uInt16
GetSdPageCount(PageKind ePgKind
) const;
344 void SetSelected(SdPage
* pPage
, sal_Bool bSelect
);
345 sal_Bool
MovePages(sal_uInt16 nTargetPage
);
347 SD_DLLPUBLIC SdPage
*GetMasterSdPage(sal_uInt16 nPgNum
, PageKind ePgKind
);
348 SD_DLLPUBLIC sal_uInt16
GetMasterSdPageCount(PageKind ePgKind
) const;
350 SD_DLLPUBLIC sal_uInt16
GetActiveSdPageCount() const;
352 sal_uInt16
GetMasterPageUserCount(SdrPage
* pMaster
) const;
354 const sd::PresentationSettings
& getPresentationSettings() const { return maPresentationSettings
; }
355 sd::PresentationSettings
& getPresentationSettings() { return maPresentationSettings
; }
357 const ::com::sun::star::uno::Reference
< ::com::sun::star::presentation::XPresentation2
>& getPresentation() const;
359 void SetSummationOfParagraphs( sal_Bool bOn
= sal_True
) { mbSummationOfParagraphs
= bOn
; }
360 sal_Bool
IsSummationOfParagraphs() const { return mbSummationOfParagraphs
; }
362 /** Set the mode that controls whether (and later how) the formatting of the document
363 depends on the current printer metrics.
366 scope="com::sun::star::document::PrinterIndependentLayout">ENABLED</const>
367 to make formatting printer-independent and <const
368 scope="com::sun::star::document::PrinterIndependentLayout">DISABLED</const>
369 to make formatting depend on the current printer metrics.
371 void SetPrinterIndependentLayout (sal_Int32 nMode
);
373 /** Get the flag that controls whether the formatting of the document
374 depends on the current printer metrics.
377 scope="com::sun::star::document::PrinterIndependentLayout">ENABLED</const>
378 when formatting is printer-independent and <const
379 scope="com::sun::star::document::PrinterIndependentLayout">DISABLED</const>
380 when formatting depends on the current printer metrics.
382 sal_Int32
GetPrinterIndependentLayout (void);
384 void SetOnlineSpell( sal_Bool bIn
);
385 sal_Bool
GetOnlineSpell() const { return mbOnlineSpell
; }
386 void StopOnlineSpelling();
387 void StartOnlineSpelling(sal_Bool bForceSpelling
=sal_True
);
389 void ImpOnlineSpellCallback(SpellCallbackInfo
* pInfo
, SdrObject
* pObj
, SdrOutliner
* pOutl
);
391 void InsertObject(SdrObject
* pObj
, SdPage
* pPage
);
392 void RemoveObject(SdrObject
* pObj
, SdPage
* pPage
);
394 sal_uLong
GetLinkCount();
396 std::vector
<sd::FrameView
*>& GetFrameViewList() { return maFrameViewList
; }
397 SD_DLLPUBLIC SdCustomShowList
* GetCustomShowList(sal_Bool bCreate
= sal_False
);
399 void NbcSetChanged(sal_Bool bFlag
= sal_True
);
401 void SetTextDefaults() const;
403 void CreateLayoutTemplates();
404 void RenameLayoutTemplate(const String
& rOldLayoutName
, const String
& rNewName
);
406 void CreateDefaultCellStyles();
408 SD_DLLPUBLIC
void StopWorkStartupDelay();
410 void NewOrLoadCompleted(DocCreationMode eMode
);
411 void NewOrLoadCompleted( SdPage
* pPage
, SdStyleSheetPool
* pSPool
);
412 sal_Bool
IsNewOrLoadCompleted() const {return mbNewOrLoadCompleted
; }
414 ::sd::FrameView
* GetFrameView(sal_uLong nPos
) {
415 return nPos
< maFrameViewList
.size() ? maFrameViewList
[nPos
] : NULL
; }
418 SdAnimationInfo
* GetAnimationInfo(SdrObject
* pObject
) const;
420 SD_DLLPUBLIC
static SdAnimationInfo
* GetShapeUserData(SdrObject
& rObject
, bool bCreate
= false );
422 SdIMapInfo
* GetIMapInfo( SdrObject
* pObject
) const;
423 IMapObject
* GetHitIMapObject( SdrObject
* pObject
, const Point
& rWinPoint
, const ::Window
& rCmpWnd
);
425 CharClass
* GetCharClass() const { return mpCharClass
; }
427 void RestoreLayerNames();
429 void UpdateAllLinks();
431 void CheckMasterPages();
433 void Merge(SdrModel
& rSourceModel
,
434 sal_uInt16 nFirstPageNum
=0, sal_uInt16 nLastPageNum
=0xFFFF,
435 sal_uInt16 nDestPos
=0xFFFF,
436 bool bMergeMasterPages
= false, bool bAllMasterPages
= false,
437 bool bUndo
= true, bool bTreadSourceAsConst
= false);
439 SD_DLLPUBLIC ::com::sun::star::text::WritingMode
GetDefaultWritingMode() const;
440 void SetDefaultWritingMode( ::com::sun::star::text::WritingMode eMode
);
442 /** replacespOldPage from all custom shows with pNewPage or removes pOldPage from
443 all custom shows if pNewPage is 0.
445 void ReplacePageInCustomShows( const SdPage
* pOldPage
, const SdPage
* pNewPage
);
449 static SdDrawDocument
* pDocLockedInsertingLinks
; // static to prevent recursions while resolving links
451 /** Create and insert a set of two new pages: a standard (draw) page and
452 the associated notes page. The new pages are inserted direclty
453 after the specified page set.
455 This page is used to retrieve the layout for the page to
458 This specifies whether <argument>pCurrentPage</argument> is a
459 standard (draw) page or a notes page.
460 @param sStandardPageName
461 Name of the standard page. An empty string leads to using an
462 automatically created name.
463 @param sNotesPageName
464 Name of the standard page. An empty string leads to using an
465 automatically created name.
466 @param eStandardLayout
467 Layout to use for the new standard page. Note that this layout
468 is not used when the given <argument>pCurrentPage</argument> is
469 not a standard page. In this case the layout is taken from the
470 standard page associated with <argument>pCurrentPage</argument>.
472 Layout to use for the new notes page. Note that this layout
473 is not used when the given <argument>pCurrentPage</argument> is
474 not a notes page. In this case the layout is taken from the
475 notes page associated with <argument>pCurrentPage</argument>.
477 This flag indicates whether to show the background shape.
479 This flag indicates whether to show the shapes on the master page.
480 @param nInsertPosition
481 Position where to insert the standard page. When -1 then the
482 new page set is inserted after the current page.
485 Returns an index of the inserted pages that can be used with the
486 <member>GetSdPage()</member> method.
488 sal_uInt16
CreatePage (
489 SdPage
* pCurrentPage
,
491 const String
& sStandardPageName
,
492 const String
& sNotesPageName
,
493 AutoLayout eStandardLayout
,
494 AutoLayout eNotesLayout
,
495 sal_Bool bIsPageBack
,
497 const sal_Int32 nInsertPosition
= -1);
499 /** This method acts as a simplified front end for the more complex
500 <member>DuplicatePage()</member> method.
502 The page number as passed to the <member>GetSdPage()</member>
503 method for which the standard page and the notes page are to be
506 Returns an index of the inserted pages that can be used with the
507 <member>GetSdPage()</member> method.
509 sal_uInt16
DuplicatePage (sal_uInt16 nPageNum
);
511 /** Create and insert a set of two new pages that are copies of the
512 given <argument>pCurrentPage</argument> and its associated notes
513 resp. standard page. The copies are inserted directly after the
516 This page and its associated notes/standard page is copied.
518 This specifies whether <argument>pCurrentPage</argument> is a
519 standard (draw) page or a notes page.
520 @param sStandardPageName
521 Name of the standard page. An empty string leads to using an
522 automatically created name.
523 @param sNotesPageName
524 Name of the standard page. An empty string leads to using an
525 automatically created name.
527 This flag indicates whether to show the background shape.
529 This flag indicates whether to show the shapes on the master page.
530 @param nInsertPosition
531 Position where to insert the standard page. When -1 then the
532 new page set is inserted after the current page.
535 Returns an index of the inserted pages that can be used with the
536 <member>GetSdPage()</member> method.
538 sal_uInt16
DuplicatePage (
539 SdPage
* pCurrentPage
,
541 const String
& sStandardPageName
,
542 const String
& sNotesPageName
,
543 sal_Bool bIsPageBack
,
545 const sal_Int32 nInsertPosition
= -1);
547 /** return the document fonts for latin, cjk and ctl according to the current
548 languages set at this document */
549 void getDefaultFonts( Font
& rLatinFont
, Font
& rCJKFont
, Font
& rCTLFont
);
551 sd::UndoManager
* GetUndoManager() const;
553 /** converts the given western font height to a corresponding ctl font height, deppending on the system language */
554 static sal_uInt32
convertFontHeightToCTL( sal_uInt32 nWesternFontHeight
);
556 /** Get the style sheet pool if it was a SdStyleSheetPool.
558 SD_DLLPUBLIC SdStyleSheetPool
* GetSdStyleSheetPool() const;
560 void UpdatePageRelativeURLs(const String
& rOldName
, const String
& rNewName
);
562 void SetCalcFieldValueHdl( ::Outliner
* pOutliner
);
564 sal_uInt16
GetAnnotationAuthorIndex( const OUString
& rAuthor
);
566 bool IsUsingEmbededFonts() { return mbUseEmbedFonts
; }
567 void SetIsUsingEmbededFonts( bool bUse
) { mbUseEmbedFonts
= bUse
; }
570 /** This member stores the printer independent layout mode. Please
571 refer to <member>SetPrinterIndependentLayout()</member> for its
574 sal_Int32 mnPrinterIndependentLayout
;
576 /** Insert a given set of standard and notes page after the given <argument>pCurrentPage</argument>.
578 This page and its associated notes/standard page is copied.
580 This specifies whether <argument>pCurrentPage</argument> is a
581 standard (draw) page or a notes page.
582 @param sStandardPageName
583 Name of the standard page. An empty string leads to using an
584 automatically created name.
585 @param sNotesPageName
586 Name of the standard page. An empty string leads to using an
587 automatically created name.
589 This flag indicates whether to show the background shape.
591 This flag indicates whether to show the shapes on the master page.
593 The standard page to insert.
595 The notes page to insert.
596 @param nInsertPosition
597 Position where to insert the standard page. When -1 then the
598 new page set is inserted after the current page.
601 Returns an index of the inserted pages that can be used with the
602 <member>GetSdPage()</member> method.
604 sal_uInt16
InsertPageSet (
605 SdPage
* pCurrentPage
,
607 const String
& sStandardPageName
,
608 const String
& sNotesPageName
,
609 sal_Bool bIsPageBack
,
611 SdPage
* pStandardPage
,
613 sal_Int32 nInsertPosition
= -1);
615 /** Set up a newly created page and insert it into the list of pages.
617 A page to take the size and border geometry from.
619 This is the page to set up and insert.
621 The name of the new page.
622 @param nInsertionPoint
623 Index of the page before which the new page will be inserted.
625 This flag indicates whether to show the background shape.
627 This flag indicates whether to show the shapes on the master
631 SdPage
* pPreviousPage
,
633 const String
& sPageName
,
634 sal_uInt16 nInsertionPoint
,
635 sal_Bool bIsPageBack
,
636 sal_Bool bIsPageObj
);
638 virtual void PageListChanged();
639 virtual void MasterPageListChanged();
645 /**an instance of this guard disables modification of a document
646 during its lifetime*/
650 ModifyGuard( SdDrawDocument
* pDoc
);
656 DrawDocShell
* mpDocShell
;
657 SdDrawDocument
* mpDoc
;
658 sal_Bool mbIsEnableSetModified
;
659 sal_Bool mbIsDocumentChanged
;
664 #endif // _DRAWDOC_HXX
666 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */