build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / sd / inc / sdpage.hxx
blob885f01e0395852bcee78ba2a84786c3b0f3fd926
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_SD_INC_SDPAGE_HXX
21 #define INCLUDED_SD_INC_SDPAGE_HXX
23 #include <com/sun/star/drawing/XDrawPage.hpp>
24 #include <com/sun/star/presentation/FadeEffect.hpp>
25 #include <com/sun/star/office/XAnnotation.hpp>
27 #include <functional>
28 #include <list>
29 #include <memory>
30 #include <vector>
31 #include <svx/svdobj.hxx>
32 #include <svx/fmpage.hxx>
33 #include "fadedef.h"
34 #include "diadef.h"
35 #include "pres.hxx"
36 #include "shapelist.hxx"
37 #include "misc/scopelock.hxx"
38 #include "sddllapi.h"
40 namespace com { namespace sun { namespace star { namespace animations {
41 class XAnimationNode;
42 } } } }
44 class SfxStyleSheet;
45 class SdDrawDocument;
46 class SdrTextObj;
47 class SdPageLink;
48 class SfxItemSet;
49 class Paragraph;
50 class Outliner;
51 class SdStyleSheet;
53 namespace sd
55 class MainSequence;
58 namespace sd {
60 struct SD_DLLPUBLIC HeaderFooterSettings
62 bool mbHeaderVisible;
63 OUString maHeaderText;
65 bool mbFooterVisible;
66 OUString maFooterText;
68 bool mbSlideNumberVisible;
70 bool mbDateTimeVisible;
71 bool mbDateTimeIsFixed;
72 OUString maDateTimeText;
73 int meDateTimeFormat;
75 HeaderFooterSettings();
77 bool operator==( const HeaderFooterSettings& rSettings ) const;
80 typedef std::vector< css::uno::Reference< css::office::XAnnotation > > AnnotationVector;
83 namespace sd {
84 class UndoAnimation;
85 class UndoTransition;
86 class UndoGeoObject;
87 class UndoAttrObject;
90 class SD_DLLPUBLIC SdPage : public FmFormPage, public SdrObjUserCall
92 SdPage& operator=(const SdPage&) = delete;
94 friend class SdGenericDrawPage;
95 friend class SdDrawPage;
96 friend class sd::UndoAnimation;
97 friend class sd::UndoTransition;
98 friend class ModifyPageUndoAction;
99 friend class sd::UndoGeoObject;
100 friend class sd::UndoAttrObject;
102 protected:
103 PageKind mePageKind; ///< page type
104 AutoLayout meAutoLayout; ///< AutoLayout
105 sd::ShapeList maPresentationShapeList;///< presentation objects
106 sd::ScopeLock maLockAutoLayoutArrangement;
107 bool mbSelected; ///< selection identifier
108 PresChange mePresChange; ///< manual / automatic / semi automatic
109 double mfTime; ///< Display time in seconds
110 bool mbSoundOn; ///< with / without sound.
111 bool mbExcluded; ///< will (not) be displayed during show.
112 OUString maLayoutName; ///< Name of the layout
113 OUString maSoundFile; ///< Path to sound file (MSDOS notation).
114 bool mbLoopSound;
115 bool mbStopSound;
116 OUString maCreatedPageName; ///< generated page name by GetPageName.
117 OUString maFileName; ///< file name.
118 OUString maBookmarkName; ///< Bookmark name.
119 bool mbScaleObjects; ///< Objects should be scaled
120 bool mbBackgroundFullSize; ///< Background object to represent the whole page.
121 rtl_TextEncoding meCharSet; ///< Text encoding
122 sal_uInt16 mnPaperBin; ///< PaperBin
123 Orientation meOrientation; ///< Print orientation.
124 SdPageLink* mpPageLink; ///< Page link (at left sides only)
126 sd::AnnotationVector maAnnotations;
128 /** holds the smil animation sequences for this page */
129 css::uno::Reference< css::animations::XAnimationNode > mxAnimationNode;
131 /** a helper class to manipulate effects inside the main sequence */
132 std::shared_ptr< sd::MainSequence > mpMainSequence;
134 virtual css::uno::Reference< css::uno::XInterface > createUnoPage() override;
136 SfxItemSet* mpItems;
138 SfxItemSet* getOrCreateItems();
140 sd::HeaderFooterSettings maHeaderFooterSettings;
142 // new transition settings
143 sal_Int16 mnTransitionType;
144 sal_Int16 mnTransitionSubtype;
145 bool mbTransitionDirection;
146 sal_Int32 mnTransitionFadeColor;
147 double mfTransitionDuration;
149 SdPage(const SdPage& rSrcPage);
150 void lateInit(const SdPage& rSrcPage);
152 public:
154 SdPage(SdDrawDocument& rNewDoc, bool bMasterPage);
155 virtual ~SdPage() override;
156 virtual SdrPage* Clone() const override;
157 virtual SdrPage* Clone(SdrModel* pNewModel) const override;
159 virtual void SetSize(const Size& aSize) override;
160 virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr) override;
161 virtual void SetLftBorder(sal_Int32 nBorder) override;
162 virtual void SetRgtBorder(sal_Int32 nBorder) override;
163 virtual void SetUppBorder(sal_Int32 nBorder) override;
164 virtual void SetLwrBorder(sal_Int32 nBorder) override;
165 virtual void SetModel(SdrModel* pNewModel) override;
166 virtual bool IsReadOnly() const override;
168 sd::ShapeList& GetPresentationShapeList() { return maPresentationShapeList; }
170 void EnsureMasterPageDefaultBackground();
171 SdrObject* CreatePresObj(PresObjKind eObjKind, bool bVertical, const Rectangle& rRect, bool bInsert=false);
172 SdrObject* CreateDefaultPresObj(PresObjKind eObjKind);
173 void DestroyDefaultPresObj(PresObjKind eObjKind);
174 SdrObject* GetPresObj(PresObjKind eObjKind, int nIndex = 1, bool bFuzzySearch = false );
175 PresObjKind GetPresObjKind(SdrObject* pObj) const;
176 OUString GetPresObjText(PresObjKind eObjKind) const;
177 SfxStyleSheet* GetStyleSheetForMasterPageBackground() const;
178 SfxStyleSheet* GetStyleSheetForPresObj(PresObjKind eObjKind) const;
179 sal_Int64 GetHashCode() const;
180 bool RestoreDefaultText( SdrObject* pObj );
182 /** @return true if the given SdrObject is inside the presentation object list */
183 bool IsPresObj(const SdrObject* pObj);
185 /** removes the given SdrObject from the presentation object list */
186 void RemovePresObj(const SdrObject* pObj);
188 /** inserts the given SdrObject into the presentation object list */
189 void InsertPresObj(SdrObject* pObj, PresObjKind eKind );
191 void SetAutoLayout(AutoLayout eLayout, bool bInit=false, bool bCreate=false);
192 AutoLayout GetAutoLayout() const { return meAutoLayout; }
193 void CreateTitleAndLayout(bool bInit=false, bool bCreate=false);
194 SdrObject* InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, bool bVertical, const Rectangle& rRect, bool bInit);
196 virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE,
197 const SdrInsertReason* pReason=nullptr) override;
198 virtual SdrObject* NbcRemoveObject(size_t nObjNum) override;
199 virtual SdrObject* RemoveObject(size_t nObjNum) override;
201 /** Also override ReplaceObject methods to realize when
202 objects are removed with this mechanism instead of RemoveObject*/
203 virtual SdrObject* NbcReplaceObject(SdrObject* pNewObj, size_t nObjNum) override;
204 virtual SdrObject* ReplaceObject(SdrObject* pNewObj, size_t nObjNum) override;
206 void SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, const OUString& rStr );
208 void SetPageKind(PageKind ePgType) { mePageKind = ePgType; }
209 PageKind GetPageKind() const { return mePageKind; }
211 void SetSelected(bool bSel) { mbSelected = bSel; }
212 bool IsSelected() const { return mbSelected; }
214 void SetFadeEffect(css::presentation::FadeEffect eNewEffect);
215 css::presentation::FadeEffect GetFadeEffect() const;
217 void SetPresChange(PresChange eChange) { mePresChange = eChange; }
218 PresChange GetPresChange() const { return mePresChange; }
220 void SetTime(double fNewTime) { mfTime = fNewTime; }
221 double GetTime() const { return mfTime; }
223 void SetSound(bool bNewSoundOn) { mbSoundOn = bNewSoundOn; }
224 bool IsSoundOn() const { return mbSoundOn; }
226 void SetExcluded(bool bNewExcluded) { mbExcluded = bNewExcluded; }
227 bool IsExcluded() const { return mbExcluded; }
229 bool IsScaleObjects() const { return mbScaleObjects; }
231 void SetSoundFile(const OUString& rStr) { maSoundFile = rStr; }
232 const OUString& GetSoundFile() const { return maSoundFile; }
234 void SetLoopSound( bool bLoopSound ) { mbLoopSound = bLoopSound; }
235 bool IsLoopSound() const { return mbLoopSound; }
237 void SetStopSound( bool bStopSound ) { mbStopSound = bStopSound; }
238 bool IsStopSound() const { return mbStopSound; }
240 sal_Int16 getTransitionType() const { return mnTransitionType;}
241 void setTransitionType( sal_Int16 nTransitionType );
243 sal_Int16 getTransitionSubtype() const { return mnTransitionSubtype;}
244 void setTransitionSubtype( sal_Int16 nTransitionSubtype );
246 bool getTransitionDirection() const { return mbTransitionDirection;}
247 void setTransitionDirection( bool bTransitionbDirection );
249 sal_Int32 getTransitionFadeColor() const { return mnTransitionFadeColor;}
250 void setTransitionFadeColor( sal_Int32 nTransitionFadeColor );
252 double getTransitionDuration() const { return mfTransitionDuration;}
253 void setTransitionDuration( double fTranstionDuration );
255 virtual void Changed(const SdrObject& rObj, SdrUserCallType eType,
256 const Rectangle& rOldBoundRect) override;
258 void SetLayoutName(const OUString& aName);
259 virtual OUString GetLayoutName() const override { return maLayoutName; }
261 void SetFileName(const OUString& aName) { maFileName = aName; }
262 const OUString& GetFileName() const { return maFileName; }
263 void SetBookmarkName(const OUString& aName) { maBookmarkName = aName; }
264 const OUString& GetBookmarkName() const { return maBookmarkName; }
266 void ConnectLink();
267 void DisconnectLink();
269 void ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderRect,
270 bool bScaleAllObj);
272 const OUString& GetName() const;
273 OUString GetRealName() const { return FmFormPage::GetName(); };
275 void SetPresentationLayout(const OUString& rLayoutName,
276 bool bReplaceStyleSheets = true,
277 bool bSetMasterPage = true,
278 bool bReverseOrder = false);
279 void EndListenOutlineText();
281 void SetBackgroundFullSize( bool bIn );
282 bool IsBackgroundFullSize() const { return mbBackgroundFullSize; }
284 void SetPaperBin(sal_uInt16 nBin) { mnPaperBin = nBin; }
285 sal_uInt16 GetPaperBin() const { return mnPaperBin; }
286 virtual void SetOrientation(Orientation eOrient) override;
287 virtual Orientation GetOrientation() const override;
289 virtual SfxStyleSheet* GetTextStyleSheetForObject( SdrObject* pObj ) const override;
291 bool setAlienAttributes( const css::uno::Any& rAttributes );
292 void getAlienAttributes( css::uno::Any& rAttributes );
294 /** @return the main animation node */
295 css::uno::Reference< css::animations::XAnimationNode > const & getAnimationNode() throw (css::uno::RuntimeException);
297 /** sets the main animation node */
298 void setAnimationNode( css::uno::Reference< css::animations::XAnimationNode >& xNode ) throw (css::uno::RuntimeException);
300 /// @return a helper class to manipulate effects inside the main sequence
301 std::shared_ptr< sd::MainSequence > const & getMainSequence();
303 /** quick check if this slide has an animation node.
304 This can be used to have a cost free check if there are no animations ad this slide.
305 If it returns true this does not mean that there are animations available.
307 bool hasAnimationNode() const;
309 /// @return the SdPage implementation for the given XDrawPage or 0 if not available
310 static SdPage* getImplementation( const css::uno::Reference< css::drawing::XDrawPage >& xPage );
312 /** removes all custom animations for the given shape */
313 void removeAnimations( const SdrObject* pObj );
315 /** Set the name of the page and broadcast a model change.
317 void SetName (const OUString& rName);
319 const sd::HeaderFooterSettings& getHeaderFooterSettings() const;
320 void setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings );
323 @return true if the object from the ViewObjectContact should
324 be visible on this page while rendering.
326 bEdit selects if visibility test is for an editing view or a final render,
327 like printing.
329 virtual bool checkVisibility(
330 const sdr::contact::ViewObjectContact& rOriginal,
331 const sdr::contact::DisplayInfo& rDisplayInfo,
332 bool bEdit ) override;
334 /** callback from the sd::View when a new paragraph for one object on this page is created */
335 void onParagraphInserted( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj );
337 /** callback from the sd::View when a paragraph from one object on this page is removed */
338 void onParagraphRemoving( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj );
340 /** callback from the sd::View when an object just left text edit mode */
341 void onEndTextEdit( SdrObject* pObj );
343 /** @return the presentation style with the given helpid from this masterpage or this
344 slides masterpage */
345 SdStyleSheet* getPresentationStyle( sal_uInt32 nHelpId ) const;
347 /** removes all empty presentation objects from this slide */
348 void RemoveEmptyPresentationObjects();
350 Rectangle GetTitleRect() const;
351 Rectangle GetLayoutRect() const;
353 static void CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< Rectangle >& rAreas );
355 /** Set the "precious" flag to the given value.
357 void SetPrecious (const bool bIsPrecious);
359 /** The "precious" flag is used for master pages to prevent some unused
360 master pages from being deleted automatically. For pages
361 other than master pages this flag can be ignored.
362 @return
363 When this method returns <TRUE/> for a master page then this
364 master page should not be deleted automatically.
366 bool IsPrecious() const { return mbIsPrecious; }
368 void createAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation );
369 void addAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, int nIndex );
370 void removeAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation );
371 const sd::AnnotationVector& getAnnotations() const { return maAnnotations; }
372 OString stringify() const;
373 virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
374 sal_uInt16 getPageId() { return mnPageId; }
376 static sal_uInt16 mnLastPageId;
378 private:
379 bool mbIsPrecious;
381 // page id of this page
382 sal_uInt16 mnPageId;
384 /** clone the animations from this and set them to rTargetPage
386 void cloneAnimations( SdPage& rTargetPage ) const;
388 /** called before a shape is removed or replaced from this slide */
389 void onRemoveObject( SdrObject* pObject );
392 #endif // INCLUDED_SD_INC_SDPAGE_HXX
394 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */