1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <com/sun/star/text/WritingMode.hpp>
23 #include <svl/style.hxx>
24 #include <svx/fmmodel.hxx>
25 #include <vcl/prntypes.hxx>
26 #include <xmloff/autolayout.hxx>
27 
28 #include <vector>
29 #include <memory>
30 #include <string_view>
31 
32 #include "sddllapi.h"
33 #include "pres.hxx"
34 
35 namespace com::sun::star::xml::dom { class XNode; }
36 namespace com::sun::star::uno { class XInterface; }
37 namespace vcl { class Font; }
38 namespace com::sun::star::presentation { class XPresentation2; }
39 class SdOutliner;
40 class Timer;
41 class SfxObjectShell;
42 class SdPage;
43 class SdAnimationInfo;
44 class SdStyleSheetPool;
45 class SfxMedium;
46 class SvxSearchItem;
47 class EditStatus;
48 class Point;
49 class SdTransferable;
50 struct SpellCallbackInfo;
51 class SdCustomShowList;
52 class SdUndoGroup;
53 class SdrObject;
54 class CharClass;
55 class Idle;
56 class ImageMap;
57 class Outliner;
58 class SdrModel;
59 class SdrOutliner;
60 class SdrPage;
61 class SdrTextObj;
62 class SfxItemPool;
63 class Size;
64 
65 namespace sd
66 {
67 class DrawDocShell;
68 #ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED
69 #define SV_DECL_DRAW_DOC_SHELL_DEFINED
70 typedef ::tools::SvRef<DrawDocShell> DrawDocShellRef;
71 #endif
72 class UndoManager;
73 class ShapeList;
74 class FrameView;
75 }
76 
77 class ImpDrawPageListWatcher;
78 class ImpMasterPageListWatcher;
79 
80 struct StyleReplaceData
81 {
82     SfxStyleFamily  nFamily;
83     SfxStyleFamily  nNewFamily;
84     OUString        aName;
85     OUString        aNewName;
86 };
87 
88 enum class DocCreationMode
89 {
90     New,
91     Loaded
92 };
93 
94 namespace sd
95 {
96     struct PresentationSettings
97     {
98         OUString maPresPage;
99         bool mbAll;
100         bool mbEndless;
101         bool mbCustomShow;
102         bool mbManual;
103         bool mbMouseVisible;
104         bool mbMouseAsPen;
105         bool mbLockedPages;
106         bool mbAlwaysOnTop;
107         bool mbFullScreen;
108         bool mbAnimationAllowed;
109         sal_Int32 mnPauseTimeout;
110         bool mbShowPauseLogo;
111         bool mbStartCustomShow;
112 
113         PresentationSettings();
114     };
115 }
116 
117 // SdDrawDocument
118 class SD_DLLPUBLIC SdDrawDocument final : public FmFormModel
119 {
120 public:
setDocAccTitle(const OUString & rTitle)121     SAL_DLLPRIVATE void setDocAccTitle( const OUString& rTitle ) { msDocAccTitle = rTitle; }
getDocAccTitle() const122     SAL_DLLPRIVATE const OUString& getDocAccTitle() const { return msDocAccTitle; }
getDocReadOnly() const123     SAL_DLLPRIVATE bool getDocReadOnly() const { return m_bReadOnly; }
124 private:
125     OUString            msDocAccTitle;
126     std::unique_ptr<SdOutliner>
127                         mpOutliner;          ///< local outliner for outline mode
128     std::unique_ptr<SdOutliner>
129                         mpInternalOutliner;  ///< internal outliner for creation of text objects
130     std::unique_ptr<Timer> mpWorkStartupTimer;
131     std::unique_ptr<Idle>
132                         mpOnlineSpellingIdle;
133     std::unique_ptr<sd::ShapeList>
134                         mpOnlineSpellingList;
135     std::unique_ptr<SvxSearchItem>
136                         mpOnlineSearchItem;
137     std::vector<std::unique_ptr<sd::FrameView>>
138                         maFrameViewList;
139     std::unique_ptr<SdCustomShowList>   mpCustomShowList;
140     ::sd::DrawDocShell* mpDocSh;
141     SdTransferable *    mpCreatingTransferable;
142     bool                mbHasOnlineSpellErrors;
143     bool                mbInitialOnlineSpellingEnabled;
144     OUString            maBookmarkFile;
145     ::sd::DrawDocShellRef   mxBookmarkDocShRef;
146 
147     sd::PresentationSettings maPresentationSettings;
148 
149     css::uno::Reference< css::presentation::XPresentation2 > mxPresentation;
150 
151     bool                mbNewOrLoadCompleted;
152 
153     bool                mbOnlineSpell;
154     bool                mbSummationOfParagraphs;
155     bool                mbStartWithPresentation;        ///< is set to true when starting with command line parameter -start
156     bool                mbExitAfterPresenting;         ///< true if mbStartWithPresentation AND Presentation was shown fully
157     LanguageType        meLanguage;
158     LanguageType        meLanguageCJK;
159     LanguageType        meLanguageCTL;
160     SvxNumType          mePageNumType;
161     ::sd::DrawDocShellRef   mxAllocedDocShRef;   // => AllocModel()
162     bool                mbAllocDocSh;       // => AllocModel()
163     DocumentType        meDocType;
164     std::unique_ptr<CharClass>
165                         mpCharClass;
166 
167     ::std::unique_ptr<ImpDrawPageListWatcher> mpDrawPageListWatcher;
168     ::std::unique_ptr<ImpMasterPageListWatcher> mpMasterPageListWatcher;
169 
170     SAL_DLLPRIVATE void                UpdatePageObjectsInNotes(sal_uInt16 nStartPos);
171     SAL_DLLPRIVATE void                UpdatePageRelativeURLs(SdPage const * pPage, sal_uInt16 nPos, sal_Int32 nIncrement);
172     SAL_DLLPRIVATE void                FillOnlineSpellingList(SdPage const * pPage);
173     SAL_DLLPRIVATE void                SpellObject(SdrTextObj* pObj);
174 
175                         DECL_DLLPRIVATE_LINK(WorkStartupHdl, Timer *, void);
176                         DECL_DLLPRIVATE_LINK(OnlineSpellingHdl, Timer *, void);
177                         DECL_DLLPRIVATE_LINK(OnlineSpellEventHdl, EditStatus&, void);
178 
179     std::vector< OUString > maAnnotationAuthors;
180     std::vector<css::uno::Reference< css::xml::dom::XNode> > maLayoutInfo;
181 
182     std::vector<css::uno::Reference< css::xml::dom::XNode> > maPresObjectInfo;
183 
184     bool mbEmbedFonts : 1;
185     bool mbEmbedUsedFontsOnly : 1;
186     bool mbEmbedFontScriptLatin : 1;
187     bool mbEmbedFontScriptAsian : 1;
188     bool mbEmbedFontScriptComplex : 1;
189 
190     SAL_DLLPRIVATE virtual css::uno::Reference< css::uno::XInterface > createUnoModel() override;
191 
192 public:
193 
194 
195     SAL_DLLPRIVATE SdDrawDocument(DocumentType eType, SfxObjectShell* pDocSh);
196     SAL_DLLPRIVATE virtual ~SdDrawDocument() override;
197 
198     // Adapt to given Size and Borders scaling all contained data, maybe
199     // including PresObj's in higher derivations
200     virtual void adaptSizeAndBorderForAllPages(
201         const Size& rNewSize,
202         tools::Long nLeft = 0,
203         tools::Long nRight = 0,
204         tools::Long nUpper = 0,
205         tools::Long nLower = 0) override;
206 
207     // Adapt PageSize for all Pages of PageKind ePageKind. Also
208     // set Borders to left/right/upper/lower, ScaleAll, Orientation,
209     // PaperBin and BackgroundFullSize. Create Undo-Actions when
210     // a SdUndoGroup is given (then used from the View probably)
211     void AdaptPageSizeForAllPages(
212         const Size& rNewSize,
213         PageKind ePageKind,
214         SdUndoGroup* pUndoGroup = nullptr,
215         tools::Long nLeft = 0,
216         tools::Long nRight = 0,
217         tools::Long nUpper = 0,
218         tools::Long nLower = 0,
219         bool bScaleAll = false,
220         Orientation eOrientation = Orientation::Landscape,
221         sal_uInt16 nPaperBin = 0,
222         bool bBackgroundFullSize = false);
223 
224     SAL_DLLPRIVATE SdDrawDocument*     AllocSdDrawDocument() const;
225     SAL_DLLPRIVATE virtual SdrModel*   AllocModel() const override; //forwards to AllocSdDrawDocument
226 
227     SAL_DLLPRIVATE rtl::Reference<SdPage>          AllocSdPage(bool bMasterPage);
228     SAL_DLLPRIVATE virtual rtl::Reference<SdrPage> AllocPage(bool bMasterPage) override; //forwards to AllocSdPage
229 
230     SAL_DLLPRIVATE virtual bool        IsReadOnly() const override;
231     SAL_DLLPRIVATE virtual void        SetChanged(bool bFlag = true) override;
232 
GetPool()233     SAL_DLLPRIVATE SfxItemPool&        GetPool() { return( *m_pItemPool ); }
234 
235     SAL_DLLPRIVATE SdOutliner* GetOutliner(bool bCreateOutliner=true);
236     SdOutliner* GetInternalOutliner(bool bCreateOutliner=true);
237 
GetDocSh() const238     SAL_DLLPRIVATE ::sd::DrawDocShell*     GetDocSh() const { return mpDocSh; }
239 
240     SAL_DLLPRIVATE LanguageType        GetLanguage( const sal_uInt16 nId ) const;
241     SAL_DLLPRIVATE void                SetLanguage( const LanguageType eLang, const sal_uInt16 nId );
242 
243     SAL_DLLPRIVATE SvxNumType          GetPageNumType() const override;
SetPageNumType(SvxNumType eType)244     SAL_DLLPRIVATE void                SetPageNumType(SvxNumType eType) { mePageNumType = eType; }
245     OUString CreatePageNumValue(sal_uInt16 nNum) const;
246 
GetDocumentType() const247     SAL_DLLPRIVATE DocumentType        GetDocumentType() const { return meDocType; }
248 
249     SAL_DLLPRIVATE void                SetAllocDocSh(bool bAlloc);
250 
CreatingDataObj(SdTransferable * pTransferable)251     SAL_DLLPRIVATE void                CreatingDataObj( SdTransferable* pTransferable ) { mpCreatingTransferable = pTransferable; }
IsCreatingDataObj() const252     SAL_DLLPRIVATE virtual bool        IsCreatingDataObj() const override { return mpCreatingTransferable != nullptr; }
253 
254     /** if the document does not contain at least one handout, one slide and one notes page with
255         at least one master each this methods creates them.
256         If a reference document is given, the sizes and border settings of that document are used
257         for newly created slides.
258     */
259     void   CreateFirstPages( SdDrawDocument const * pRefDocument = nullptr );
260     bool                CreateMissingNotesAndHandoutPages();
261 
262     SAL_DLLPRIVATE void                MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos) override;
263     SAL_DLLPRIVATE void                InsertPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF) override;
264     SAL_DLLPRIVATE void                DeletePage(sal_uInt16 nPgNum) override;
265     SAL_DLLPRIVATE rtl::Reference<SdrPage> RemovePage(sal_uInt16 nPgNum) override;
266 
267     SAL_DLLPRIVATE virtual void     InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos=0xFFFF) override;
268     SAL_DLLPRIVATE virtual rtl::Reference<SdrPage> RemoveMasterPage(sal_uInt16 nPgNum) override;
269 
270     SAL_DLLPRIVATE void                RemoveUnnecessaryMasterPages( SdPage* pMaster=nullptr, bool bOnlyDuplicatePages=false, bool bUndo=true );
271     void   SetMasterPage(sal_uInt16 nSdPageNum, std::u16string_view rLayoutName,
272                                       SdDrawDocument* pSourceDoc, bool bMaster, bool bCheckMasters);
273 
274     SdDrawDocument* OpenBookmarkDoc(const OUString& rBookmarkFile);
275     SAL_DLLPRIVATE SdDrawDocument* OpenBookmarkDoc(SfxMedium* pMedium);
276 
277     SAL_DLLPRIVATE void InsertBookmark(const std::vector<OUString> &rBookmarkList,
278                             std::vector<OUString> &rExchangeList, bool bLink,
279                             sal_uInt16 nPgPos,
280                             ::sd::DrawDocShell* pBookmarkDocSh,
281                             Point const * pObjPos);
282 
IsStartWithPresentation() const283     SAL_DLLPRIVATE bool IsStartWithPresentation() const { return mbStartWithPresentation;}
284     SAL_DLLPRIVATE void SetStartWithPresentation( bool bStartWithPresentation );
285 
IsExitAfterPresenting() const286     SAL_DLLPRIVATE bool IsExitAfterPresenting() const { return mbExitAfterPresenting;}
287     SAL_DLLPRIVATE void SetExitAfterPresenting( bool bExitAfterPresenting );
288 
289     /// load xml-based impress layout definitions into document
290     SAL_DLLPRIVATE void InitLayoutVector();
291     /// return reference to vector of Impress layout definitions
GetLayoutVector() const292     SAL_DLLPRIVATE const std::vector<css::uno::Reference< css::xml::dom::XNode> >& GetLayoutVector() const
293     { return maLayoutInfo; }
294 
295    /// load xml-based impress master presentation object definitions into document
296     SAL_DLLPRIVATE void InitObjectVector();
297     /// return reference to vector of master presentation object definitions
GetObjectVector() const298     SAL_DLLPRIVATE const std::vector<css::uno::Reference<css::xml::dom::XNode> >& GetObjectVector() const { return maPresObjectInfo; }
299     /** Insert pages into this document
300 
301         This method inserts whole pages into this document, either
302         selected ones (specified via pBookmarkList/pExchangeList), or
303         all from the source document.
304 
305         @attention Beware! This method in its current state does not
306         handle all combinations of their input parameters
307         correctly. For example, for pBookmarkList=NULL, bReplace=true
308         is ignored (no replace happens).
309 
310         @param pBookmarkList
311         A list of strings, denoting the names of the pages to be copied
312 
313         @param pExchangeList
314         A list of strings, denoting the names of the pages to be renamed
315 
316         @param bLink
317         Whether the inserted pages should be linked to the bookmark document
318 
319         @param bReplace
320         Whether the pages should not be inserted, but replace the pages in
321         the destination document
322 
323         @param nPgPos
324         Insertion point/start of replacement
325 
326         @param bNoDialogs
327         Whether query dialogs are allowed (e.g. for page scaling)
328 
329         @param pBookmarkDocSh
330         DocShell of the source document (used e.g. to extract the filename
331         for linked pages)
332 
333         @param bCopy
334         Whether the source document should be treated as immutable (i.e.
335         inserted pages are not removed from it, but cloned)
336 
337         @param bMergeMasterPages
338         Whether the source document's master pages should be copied, too.
339 
340         @param bPreservePageNames
341         Whether the replace operation should take the name from the new
342         page, or preserve the old name
343      */
344 
345     SAL_DLLPRIVATE bool InsertBookmarkAsPage(const std::vector<OUString> &rBookmarkList,
346                                   std::vector<OUString> *pExchangeList,
347                               bool bLink, bool bReplace, sal_uInt16 nPgPos,
348                               bool bNoDialogs, ::sd::DrawDocShell* pBookmarkDocSh,
349                               bool bCopy, bool bMergeMasterPages,
350                               bool bPreservePageNames);
351 
352     SAL_DLLPRIVATE bool InsertBookmarkAsObject(const std::vector<OUString> &rBookmarkList,
353                                     const std::vector<OUString> &rExchangeList,
354                                     ::sd::DrawDocShell* pBookmarkDocSh,
355                                     Point const * pObjPos, bool bCalcObjCount);
356 
357     void   CloseBookmarkDoc();
358 
359     SAL_DLLPRIVATE SdrObject*          GetObj(std::u16string_view rObjName) const;
360 
361     /** Return the first page that has the given name.  Regular pages and
362         notes pages are searched first.  When not found then the master
363         pages are searched.
364         @param rPgName
365             Name of the page to return.
366         @param rbIsMasterPage
367             Is set by the method to indicate whether the returned index
368             belongs to a master page (<TRUE/>) or a regular or notes page
369             (<FALSE/>). The given value is ignored.
370         @return
371             Returns the index of the page with the given name or
372             SDRPAGE_NOTFOUND (=0xffff) when such a page does not exist.
373     */
374     SAL_DLLPRIVATE sal_uInt16 GetPageByName(std::u16string_view rPgName, bool& rbIsMasterPage ) const;
375     /** checks, if the given name is a *unique* name for an *existing* slide
376 
377         @param rPageName the name of an existing slide
378 
379         @return true, if the name is unique and the slide exists
380     */
381     bool IsPageNameUnique( std::u16string_view rPageName ) const;
382     SdPage*GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const;
383     sal_uInt16 GetSdPageCount(PageKind ePgKind) const;
384 
385     SAL_DLLPRIVATE void                SetSelected(SdPage* pPage, bool bSelect);
386     SAL_DLLPRIVATE void                UnselectAllPages();
387     SAL_DLLPRIVATE bool                MovePages(sal_uInt16 nTargetPage);
388 
389     SdPage*GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind);
390     sal_uInt16 GetMasterSdPageCount(PageKind ePgKind) const;
391 
392     sal_uInt16 GetActiveSdPageCount() const;
393 
394     SAL_DLLPRIVATE sal_uInt16              GetMasterPageUserCount(SdrPage const * pMaster) const;
395 
getPresentationSettings() const396     SAL_DLLPRIVATE const sd::PresentationSettings& getPresentationSettings() const { return maPresentationSettings; }
getPresentationSettings()397     SAL_DLLPRIVATE sd::PresentationSettings& getPresentationSettings() { return maPresentationSettings; }
398 
399     SAL_DLLPRIVATE const css::uno::Reference< css::presentation::XPresentation2 >& getPresentation() const;
400 
SetSummationOfParagraphs(bool bOn=true)401     SAL_DLLPRIVATE void                SetSummationOfParagraphs( bool bOn = true ) { mbSummationOfParagraphs = bOn; }
IsSummationOfParagraphs() const402     SAL_DLLPRIVATE bool            IsSummationOfParagraphs() const { return mbSummationOfParagraphs; }
403 
404     /** Set the mode that controls whether (and later how) the formatting of the document
405         depends on the current printer metrics.
406         @param nMode
407             Use <const
408             scope="css::document::PrinterIndependentLayout">ENABLED</const>
409             to make formatting printer-independent and <const
410             scope="css::document::PrinterIndependentLayout">DISABLED</const>
411             to make formatting depend on the current printer metrics.
412     */
413     SAL_DLLPRIVATE void SetPrinterIndependentLayout (sal_Int32 nMode);
414 
415     /** Get the flag that controls whether the formatting of the document
416         depends on the current printer metrics.
417         @return
418             Use <const
419             scope="css::document::PrinterIndependentLayout">ENABLED</const>
420             when formatting is printer-independent and <const
421             scope="css::document::PrinterIndependentLayout">DISABLED</const>
422             when formatting depends on the current printer metrics.
423     */
GetPrinterIndependentLayout() const424     SAL_DLLPRIVATE sal_Int32 GetPrinterIndependentLayout() const { return mnPrinterIndependentLayout;}
425 
426     SAL_DLLPRIVATE void                SetOnlineSpell( bool bIn );
GetOnlineSpell() const427     SAL_DLLPRIVATE bool                GetOnlineSpell() const { return mbOnlineSpell; }
428     SAL_DLLPRIVATE void                StopOnlineSpelling();
429     SAL_DLLPRIVATE void                StartOnlineSpelling(bool bForceSpelling=true);
430 
431     SAL_DLLPRIVATE void                ImpOnlineSpellCallback(SpellCallbackInfo const * pInfo, SdrObject* pObj, SdrOutliner const * pOutl);
432 
433     SAL_DLLPRIVATE void                InsertObject(SdrObject* pObj);
434     SAL_DLLPRIVATE void                RemoveObject(SdrObject* pObj);
435 
436     SAL_DLLPRIVATE sal_uLong           GetLinkCount() const;
437 
GetFrameViewList()438     SAL_DLLPRIVATE std::vector<std::unique_ptr<sd::FrameView>>& GetFrameViewList() { return maFrameViewList; }
439     SdCustomShowList* GetCustomShowList(bool bCreate = false);
440 
441     SAL_DLLPRIVATE void                NbcSetChanged(bool bFlag);
442 
443     SAL_DLLPRIVATE void                SetTextDefaults() const;
444 
445     SAL_DLLPRIVATE void                CreateLayoutTemplates();
446     SAL_DLLPRIVATE void                RenameLayoutTemplate(const OUString& rOldLayoutName, const OUString& rNewName);
447 
448     SAL_DLLPRIVATE void                CreateDefaultCellStyles();
449 
450     void   StopWorkStartupDelay();
451 
452     SAL_DLLPRIVATE void                NewOrLoadCompleted(DocCreationMode eMode);
453     SAL_DLLPRIVATE void                NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool );
IsNewOrLoadCompleted() const454     SAL_DLLPRIVATE bool                IsNewOrLoadCompleted() const {return mbNewOrLoadCompleted; }
455 
GetFrameView(sal_uLong nPos)456     SAL_DLLPRIVATE ::sd::FrameView* GetFrameView(sal_uLong nPos) {
457         return nPos < maFrameViewList.size() ? maFrameViewList[nPos].get() : nullptr; }
458 
459     /** deprecated*/
460     SAL_DLLPRIVATE static SdAnimationInfo* GetAnimationInfo(SdrObject* pObject);
461 
462     static     SdAnimationInfo* GetShapeUserData(SdrObject& rObject, bool bCreate = false );
463 
GetCharClass() const464     SAL_DLLPRIVATE CharClass*          GetCharClass() const { return mpCharClass.get(); }
465 
466     SAL_DLLPRIVATE void                UpdateAllLinks();
467 
468     SAL_DLLPRIVATE void                CheckMasterPages();
469 
470     SAL_DLLPRIVATE void                Merge(SdrModel& rSourceModel,
471                                 sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
472                                 sal_uInt16 nDestPos,
473                                 bool bMergeMasterPages, bool bAllMasterPages,
474                                 bool bUndo = true, bool bTreadSourceAsConst = false) override;
475 
476     css::text::WritingMode GetDefaultWritingMode() const;
477     SAL_DLLPRIVATE void SetDefaultWritingMode( css::text::WritingMode eMode );
478 
479     /** replacespOldPage from all custom shows with pNewPage or removes pOldPage from
480         all custom shows if pNewPage is 0.
481     */
482     SAL_DLLPRIVATE void ReplacePageInCustomShows( const SdPage* pOldPage, const SdPage* pNewPage );
483 
484 public:
485 
486     /// static to prevent recursions while resolving links
487     SAL_DLLPRIVATE static SdDrawDocument* s_pDocLockedInsertingLinks;
488 
489     /** Create and insert a set of two new pages: a standard (draw) page and
490         the associated notes page.  The new pages are inserted directly
491         after the specified page set.
492         @param pCurrentPage
493             This page is used to retrieve the layout for the page to
494             create.
495         @param ePageKind
496             This specifies whether <argument>pCurrentPage</argument> is a
497             standard (draw) page or a notes page.
498         @param sStandardPageName
499             Name of the standard page.  An empty string leads to using an
500             automatically created name.
501         @param sNotesPageName
502             Name of the standard page.  An empty string leads to using an
503             automatically created name.
504         @param eStandardLayout
505             Layout to use for the new standard page.  Note that this layout
506             is not used when the given <argument>pCurrentPage</argument> is
507             not a standard page.  In this case the layout is taken from the
508             standard page associated with <argument>pCurrentPage</argument>.
509         @param eNotesLayout
510             Layout to use for the new notes page.  Note that this layout
511             is not used when the given <argument>pCurrentPage</argument> is
512             not a notes page.  In this case the layout is taken from the
513             notes page associated with <argument>pCurrentPage</argument>.
514         @param bIsPageBack
515             This flag indicates whether to show the background shape.
516         @param bIsPageObj
517             This flag indicates whether to show the shapes on the master page.
518         @param nInsertPosition
519             Position where to insert the standard page.  When -1 then the
520             new page set is inserted after the current page.
521 
522         @return
523             Returns an index of the inserted pages that can be used with the
524             <member>GetSdPage()</member> method.
525     */
526     SAL_DLLPRIVATE sal_uInt16 CreatePage (
527         SdPage* pCurrentPage,
528         PageKind ePageKind,
529         const OUString& sStandardPageName,
530         const OUString& sNotesPageName,
531         AutoLayout eStandardLayout,
532         AutoLayout eNotesLayout,
533         bool bIsPageBack,
534         bool bIsPageObj,
535         const sal_Int32 nInsertPosition);
536 
537     /** This method acts as a simplified front end for the more complex
538         <member>DuplicatePage()</member> method.
539         @param nPageNum
540             The page number as passed to the <member>GetSdPage()</member>
541             method for which the standard page and the notes page are to be
542             copied.
543         @return
544             Returns an index of the inserted pages that can be used with the
545             <member>GetSdPage()</member> method.
546     */
547     SAL_DLLPRIVATE sal_uInt16 DuplicatePage (sal_uInt16 nPageNum);
548 
549     /** Create and insert a set of two new pages that are copies of the
550         given <argument>pCurrentPage</argument> and its associated notes
551         resp. standard page.  The copies are inserted directly after the
552         specified page set.
553         @param pCurrentPage
554             This page and its associated notes/standard page is copied.
555         @param ePageKind
556             This specifies whether <argument>pCurrentPage</argument> is a
557             standard (draw) page or a notes page.
558         @param sStandardPageName
559             Name of the standard page.  An empty string leads to using an
560             automatically created name.
561         @param sNotesPageName
562             Name of the standard page.  An empty string leads to using an
563             automatically created name.
564         @param bIsPageBack
565             This flag indicates whether to show the background shape.
566         @param bIsPageObj
567             This flag indicates whether to show the shapes on the master page.
568         @param nInsertPosition
569             Position where to insert the standard page.  When -1 then the
570             new page set is inserted after the current page.
571 
572         @return
573             Returns an index of the inserted pages that can be used with the
574             <member>GetSdPage()</member> method.
575     */
576     SAL_DLLPRIVATE sal_uInt16 DuplicatePage (
577         SdPage* pCurrentPage,
578         PageKind ePageKind,
579         const OUString& sStandardPageName,
580         const OUString& sNotesPageName,
581         bool bIsPageBack,
582         bool bIsPageObj,
583         const sal_Int32 nInsertPosition);
584 
585     /** return the document fonts for latin, cjk and ctl according to the current
586         languages set at this document */
587     SAL_DLLPRIVATE void getDefaultFonts( vcl::Font& rLatinFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont );
588 
589     sd::UndoManager* GetUndoManager() const;
590 
591     /** converts the given western font height to a corresponding ctl font height, depending on the system language */
592     SAL_DLLPRIVATE static sal_uInt32 convertFontHeightToCTL( sal_uInt32 nWesternFontHeight );
593 
594     /** Get the style sheet pool if it was a SdStyleSheetPool.
595      */
596     SdStyleSheetPool* GetSdStyleSheetPool() const;
597 
598     SAL_DLLPRIVATE void UpdatePageRelativeURLs(
599         const OUString& rOldName, std::u16string_view rNewName);
600 
601     SAL_DLLPRIVATE static void SetCalcFieldValueHdl( ::Outliner* pOutliner);
602 
603     SAL_DLLPRIVATE sal_uInt16 GetAnnotationAuthorIndex( const OUString& rAuthor );
604 
IsEmbedFonts() const605     SAL_DLLPRIVATE bool IsEmbedFonts() const { return mbEmbedFonts; }
IsEmbedUsedFontsOnly() const606     SAL_DLLPRIVATE bool IsEmbedUsedFontsOnly() const { return mbEmbedUsedFontsOnly; }
IsEmbedFontScriptLatin() const607     SAL_DLLPRIVATE bool IsEmbedFontScriptLatin() const { return mbEmbedFontScriptLatin; }
IsEmbedFontScriptAsian() const608     SAL_DLLPRIVATE bool IsEmbedFontScriptAsian() const { return mbEmbedFontScriptAsian; }
IsEmbedFontScriptComplex() const609     SAL_DLLPRIVATE bool IsEmbedFontScriptComplex() const { return mbEmbedFontScriptComplex; }
610 
SetEmbedFonts(bool bUse)611     SAL_DLLPRIVATE void SetEmbedFonts(bool bUse) { mbEmbedFonts = bUse; }
SetEmbedUsedFontsOnly(bool bUse)612     SAL_DLLPRIVATE void SetEmbedUsedFontsOnly(bool bUse) { mbEmbedUsedFontsOnly = bUse; }
SetEmbedFontScriptLatin(bool bUse)613     SAL_DLLPRIVATE void SetEmbedFontScriptLatin(bool bUse) { mbEmbedFontScriptLatin = bUse; }
SetEmbedFontScriptAsian(bool bUse)614     SAL_DLLPRIVATE void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; }
SetEmbedFontScriptComplex(bool bUse)615     SAL_DLLPRIVATE void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = bUse; }
616 
617     void dumpAsXml(xmlTextWriterPtr pWriter) const override;
618 
619 private:
620     /** This member stores the printer independent layout mode.  Please
621         refer to <member>SetPrinterIndependentLayout()</member> for its
622         values.
623     */
624     sal_Int32 mnPrinterIndependentLayout;
625 
626     /** Insert a given set of standard and notes page after the given <argument>pCurrentPage</argument>.
627         @param pCurrentPage
628             This page and its associated notes/standard page is copied.
629         @param ePageKind
630             This specifies whether <argument>pCurrentPage</argument> is a
631             standard (draw) page or a notes page.
632         @param sStandardPageName
633             Name of the standard page.  An empty string leads to using an
634             automatically created name.
635         @param sNotesPageName
636             Name of the standard page.  An empty string leads to using an
637             automatically created name.
638         @param bIsPageBack
639             This flag indicates whether to show the background shape.
640         @param bIsPageObj
641             This flag indicates whether to show the shapes on the master page.
642         @param pStandardPage
643             The standard page to insert.
644         @param pNotesPage
645             The notes page to insert.
646         @param nInsertPosition
647             Position where to insert the standard page.  When -1 then the
648             new page set is inserted after the current page.
649 
650         @return
651             Returns an index of the inserted pages that can be used with the
652             <member>GetSdPage()</member> method.
653     */
654     SAL_DLLPRIVATE sal_uInt16 InsertPageSet (
655         SdPage* pCurrentPage,
656         PageKind ePageKind,
657         const OUString& sStandardPageName,
658         const OUString& sNotesPageName,
659         bool bIsPageBack,
660         bool bIsPageObj,
661         SdPage* pStandardPage,
662         SdPage* pNotesPage,
663         sal_Int32 nInsertPosition);
664 
665     /** Set up a newly created page and insert it into the list of pages.
666         @param pPreviousPage
667             A page to take the size and border geometry from.
668         @param pPage
669             This is the page to set up and insert.
670         @param sPageName
671             The name of the new page.
672         @param nInsertionPoint
673             Index of the page before which the new page will be inserted.
674         @param bIsPageBack
675             This flag indicates whether to show the background shape.
676         @param bIsPageObj
677             This flag indicates whether to show the shapes on the master
678             page.
679     */
680     SAL_DLLPRIVATE void SetupNewPage (
681         SdPage const * pPreviousPage,
682         SdPage* pPage,
683         const OUString& sPageName,
684         sal_uInt16 nInsertionPoint,
685         bool bIsPageBack,
686         bool bIsPageObj);
687 
688     SAL_DLLPRIVATE virtual void PageListChanged() override;
689     SAL_DLLPRIVATE virtual void MasterPageListChanged() override;
690 };
691 
692 namespace sd
693 {
694 
695 /**an instance of this guard disables modification of a document
696  during its lifetime*/
697 class ModifyGuard
698 {
699 public:
700     ModifyGuard( SdDrawDocument* pDoc );
701     ~ModifyGuard();
702 
703 private:
704     void init();
705 
706     DrawDocShell* mpDocShell;
707     SdDrawDocument* mpDoc;
708     bool mbIsEnableSetModified;
709     bool mbIsDocumentChanged;
710 };
711 
712 }
713 
714 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
715