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 .
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>
28 #include <string_view>
30 #include <editeng/flditem.hxx>
31 #include <svx/svdobj.hxx>
32 #include <svx/fmpage.hxx>
33 #include <xmloff/autolayout.hxx>
36 #include "shapelist.hxx"
37 #include "misc/scopelock.hxx"
40 namespace com::sun::star::animations
{
62 struct SD_DLLPUBLIC HeaderFooterSettings
65 OUString maHeaderText
;
68 OUString maFooterText
;
70 bool mbSlideNumberVisible
;
72 bool mbDateTimeVisible
;
73 bool mbDateTimeIsFixed
;
74 OUString maDateTimeText
;
75 SvxDateFormat meDateFormat
;
76 SvxTimeFormat meTimeFormat
;
78 HeaderFooterSettings();
80 bool operator==( const HeaderFooterSettings
& rSettings
) const;
83 typedef std::vector
< rtl::Reference
< Annotation
> > AnnotationVector
;
93 class SD_DLLPUBLIC SdPage final
: public FmFormPage
, public SdrObjUserCall
95 SdPage
& operator=(const SdPage
&) = delete;
96 SdPage(const SdPage
&) = delete;
98 friend class SdGenericDrawPage
;
99 friend class SdDrawPage
;
100 friend class sd::UndoAnimation
;
101 friend class sd::UndoTransition
;
102 friend class ModifyPageUndoAction
;
103 friend class sd::UndoGeoObject
;
104 friend class sd::UndoAttrObject
;
106 PageKind mePageKind
; ///< page type
107 AutoLayout meAutoLayout
; ///< AutoLayout
108 sd::ShapeList maPresentationShapeList
;///< presentation objects
109 sd::ScopeLock maLockAutoLayoutArrangement
;
110 bool mbSelected
; ///< selection identifier
111 PresChange mePresChange
; ///< manual / automatic / semi automatic
112 double mfTime
; ///< Display time in seconds
113 bool mbSoundOn
; ///< with / without sound.
114 bool mbExcluded
; ///< will (not) be displayed during show.
115 OUString maLayoutName
; ///< Name of the layout
116 OUString maSoundFile
; ///< Path to sound file (MS-DOS notation).
119 OUString maCreatedPageName
; ///< generated page name by GetPageName.
120 OUString maFileName
; ///< file name.
121 OUString maBookmarkName
; ///< Bookmark name.
122 bool mbScaleObjects
; ///< Objects should be scaled
123 rtl_TextEncoding meCharSet
; ///< Text encoding
124 sal_uInt16 mnPaperBin
; ///< PaperBin
125 SdPageLink
* mpPageLink
; ///< Page link (at left sides only)
127 sd::AnnotationVector maAnnotations
;
129 /** holds the smil animation sequences for this page */
130 css::uno::Reference
< css::animations::XAnimationNode
> mxAnimationNode
;
132 /** a helper class to manipulate effects inside the main sequence */
133 std::shared_ptr
< sd::MainSequence
> mpMainSequence
;
135 virtual css::uno::Reference
< css::uno::XInterface
> createUnoPage() override
;
137 std::unique_ptr
<SfxItemSet
> mpItems
;
139 SfxItemSet
* getOrCreateItems();
141 sd::HeaderFooterSettings maHeaderFooterSettings
;
143 // new transition settings
144 sal_Int16 mnTransitionType
;
145 sal_Int16 mnTransitionSubtype
;
146 bool mbTransitionDirection
;
147 sal_Int32 mnTransitionFadeColor
;
148 double mfTransitionDuration
;
150 void lateInit(const SdPage
& rSrcPage
);
154 SdPage(SdDrawDocument
& rNewDoc
, bool bMasterPage
);
155 virtual ~SdPage() override
;
157 virtual rtl::Reference
<SdrPage
> CloneSdrPage(SdrModel
& rTargetModel
) 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 SetLeftBorder(sal_Int32 nBorder
) override
;
162 virtual void SetRightBorder(sal_Int32 nBorder
) override
;
163 virtual void SetUpperBorder(sal_Int32 nBorder
) override
;
164 virtual void SetLowerBorder(sal_Int32 nBorder
) override
;
165 virtual bool IsReadOnly() const override
;
167 sd::ShapeList
& GetPresentationShapeList() { return maPresentationShapeList
; }
169 void EnsureMasterPageDefaultBackground();
170 SdrObject
* CreatePresObj(PresObjKind eObjKind
, bool bVertical
, const ::tools::Rectangle
& rRect
);
171 rtl::Reference
<SdrObject
> CreateDefaultPresObj(PresObjKind eObjKind
);
172 void DestroyDefaultPresObj(PresObjKind eObjKind
);
173 SdrObject
* GetPresObj(PresObjKind eObjKind
, int nIndex
= 1, bool bFuzzySearch
= false );
174 PresObjKind
GetPresObjKind(SdrObject
* pObj
) const;
175 OUString
GetPresObjText(PresObjKind eObjKind
) const;
176 SfxStyleSheet
* GetStyleSheetForMasterPageBackground() const;
177 SfxStyleSheet
* GetStyleSheetForPresObj(PresObjKind eObjKind
) const;
178 sal_Int64
GetHashCode() const;
179 bool RestoreDefaultText( SdrObject
* pObj
);
181 /** @return true if the given SdrObject is inside the presentation object list */
182 bool IsPresObj(const SdrObject
* pObj
);
184 /** removes the given SdrObject from the presentation object list */
185 void RemovePresObj(const SdrObject
* pObj
);
187 /** inserts the given SdrObject into the presentation object list */
188 void InsertPresObj(SdrObject
* pObj
, PresObjKind eKind
);
190 void SetAutoLayout(AutoLayout eLayout
, bool bInit
=false, bool bCreate
=false);
191 AutoLayout
GetAutoLayout() const { return meAutoLayout
; }
192 void CreateTitleAndLayout(bool bInit
=false, bool bCreate
=false);
193 SdrObject
* InsertAutoLayoutShape(SdrObject
* pObj
, PresObjKind eObjKind
, bool bVertical
, const ::tools::Rectangle
& rRect
, bool bInit
);
195 virtual void NbcInsertObject(SdrObject
* pObj
, size_t nPos
=SAL_MAX_SIZE
) override
;
196 virtual rtl::Reference
<SdrObject
> NbcRemoveObject(size_t nObjNum
) override
;
197 virtual rtl::Reference
<SdrObject
> RemoveObject(size_t nObjNum
) override
;
199 /** Also override ReplaceObject methods to realize when
200 objects are removed with this mechanism instead of RemoveObject*/
201 virtual rtl::Reference
<SdrObject
> ReplaceObject(SdrObject
* pNewObj
, size_t nObjNum
) override
;
203 void SetObjText(SdrTextObj
* pObj
, SdrOutliner
* pOutliner
, PresObjKind eObjKind
, std::u16string_view rStr
);
205 void SetPageKind(PageKind ePgType
) { mePageKind
= ePgType
; }
206 PageKind
GetPageKind() const { return mePageKind
; }
208 void SetSelected(bool bSel
) { mbSelected
= bSel
; }
209 bool IsSelected() const { return mbSelected
; }
211 void SetFadeEffect(css::presentation::FadeEffect eNewEffect
);
212 css::presentation::FadeEffect
GetFadeEffect() const;
214 void SetPresChange(PresChange eChange
) { mePresChange
= eChange
; }
215 PresChange
GetPresChange() const { return mePresChange
; }
217 void SetTime(double fNewTime
) { mfTime
= fNewTime
; }
218 double GetTime() const { return mfTime
; }
220 void SetSound(bool bNewSoundOn
) { mbSoundOn
= bNewSoundOn
; }
221 bool IsSoundOn() const { return mbSoundOn
; }
223 void SetExcluded(bool bNewExcluded
) { mbExcluded
= bNewExcluded
; }
224 bool IsExcluded() const { return mbExcluded
; }
226 bool IsScaleObjects() const { return mbScaleObjects
; }
228 void SetSoundFile(const OUString
& rStr
) { maSoundFile
= rStr
; }
229 const OUString
& GetSoundFile() const { return maSoundFile
; }
231 void SetLoopSound( bool bLoopSound
) { mbLoopSound
= bLoopSound
; }
232 bool IsLoopSound() const { return mbLoopSound
; }
234 void SetStopSound( bool bStopSound
) { mbStopSound
= bStopSound
; }
235 bool IsStopSound() const { return mbStopSound
; }
237 sal_Int16
getTransitionType() const { return mnTransitionType
;}
238 void setTransitionType( sal_Int16 nTransitionType
);
240 sal_Int16
getTransitionSubtype() const { return mnTransitionSubtype
;}
241 void setTransitionSubtype( sal_Int16 nTransitionSubtype
);
243 bool getTransitionDirection() const { return mbTransitionDirection
;}
244 void setTransitionDirection( bool bTransitionbDirection
);
246 sal_Int32
getTransitionFadeColor() const { return mnTransitionFadeColor
;}
247 void setTransitionFadeColor( sal_Int32 nTransitionFadeColor
);
249 double getTransitionDuration() const { return mfTransitionDuration
;}
250 void setTransitionDuration( double fTransitionDuration
);
252 virtual void Changed(const SdrObject
& rObj
, SdrUserCallType eType
,
253 const ::tools::Rectangle
& rOldBoundRect
) override
;
255 void SetLayoutName(const OUString
& aName
);
256 virtual OUString
GetLayoutName() const override
{ return maLayoutName
; }
258 void SetFileName(const OUString
& aName
) { maFileName
= aName
; }
259 const OUString
& GetFileName() const { return maFileName
; }
260 void SetBookmarkName(const OUString
& aName
) { maBookmarkName
= aName
; }
261 const OUString
& GetBookmarkName() const { return maBookmarkName
; }
264 void DisconnectLink();
266 void ScaleObjects(const Size
& rNewPageSize
, const ::tools::Rectangle
& rNewBorderRect
,
269 const OUString
& GetName() const;
270 OUString
const & GetRealName() const { return FmFormPage::GetName(); };
272 void SetPresentationLayout(std::u16string_view rLayoutName
,
273 bool bReplaceStyleSheets
= true,
274 bool bSetMasterPage
= true,
275 bool bReverseOrder
= false);
276 void EndListenOutlineText();
278 void SetPaperBin(sal_uInt16 nBin
) { mnPaperBin
= nBin
; }
279 sal_uInt16
GetPaperBin() const { return mnPaperBin
; }
280 virtual void SetOrientation(Orientation eOrient
) override
;
281 virtual Orientation
GetOrientation() const override
;
283 virtual SfxStyleSheet
* GetTextStyleSheetForObject( SdrObject
* pObj
) const override
;
285 bool setAlienAttributes( const css::uno::Any
& rAttributes
);
286 void getAlienAttributes( css::uno::Any
& rAttributes
);
288 /** @return the main animation node
290 @throws css::uno::RuntimeException
292 css::uno::Reference
< css::animations::XAnimationNode
> const & getAnimationNode();
294 /** sets the main animation node
296 @throws css::uno::RuntimeException
298 void setAnimationNode( css::uno::Reference
< css::animations::XAnimationNode
> const & xNode
);
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 /** Notify that the object has been renamed and the animation effects has to update. */
316 void notifyObjectRenamed(const SdrObject
* pObj
);
318 /** Set the name of the page and broadcast a model change.
320 void SetName (const OUString
& rName
);
322 const sd::HeaderFooterSettings
& getHeaderFooterSettings() const;
323 void setHeaderFooterSettings( const sd::HeaderFooterSettings
& rNewSettings
);
326 @return true if the object from the ViewObjectContact should
327 be visible on this page while rendering.
329 bEdit selects if visibility test is for an editing view or a final render,
332 virtual bool checkVisibility(
333 const sdr::contact::ViewObjectContact
& rOriginal
,
334 const sdr::contact::DisplayInfo
& rDisplayInfo
,
335 bool bEdit
) override
;
337 /** callback from the sd::View when a new paragraph for one object on this page is created */
338 void onParagraphInserted( const ::Outliner
* pOutliner
, Paragraph
const * pPara
, SdrObject
* pObj
);
340 /** callback from the sd::View when a paragraph from one object on this page is removed */
341 void onParagraphRemoving( const ::Outliner
* pOutliner
, Paragraph
const * pPara
, SdrObject
* pObj
);
343 /** callback from the sd::View when an object just left text edit mode */
344 void onEndTextEdit( SdrObject
* pObj
);
346 /** @return the presentation style with the given helpid from this masterpage or this
348 SdStyleSheet
* getPresentationStyle( sal_uInt32 nHelpId
) const;
350 /** removes all empty presentation objects from this slide */
351 void RemoveEmptyPresentationObjects();
353 ::tools::Rectangle
GetTitleRect() const;
354 ::tools::Rectangle
GetLayoutRect() const;
356 static void CalculateHandoutAreas( SdDrawDocument
& rModel
, AutoLayout eLayout
, bool bHorizontal
, std::vector
< ::tools::Rectangle
>& rAreas
);
358 /** Set the "precious" flag to the given value.
360 void SetPrecious (const bool bIsPrecious
);
362 /** The "precious" flag is used for master pages to prevent some unused
363 master pages from being deleted automatically. For pages
364 other than master pages this flag can be ignored.
366 When this method returns <TRUE/> for a master page then this
367 master page should not be deleted automatically.
369 bool IsPrecious() const { return mbIsPrecious
; }
371 void createAnnotation( rtl::Reference
< sd::Annotation
>& xAnnotation
);
372 void addAnnotation( const rtl::Reference
< sd::Annotation
>& xAnnotation
, int nIndex
);
373 void removeAnnotation( const rtl::Reference
< sd::Annotation
>& xAnnotation
);
374 const sd::AnnotationVector
& getAnnotations() const { return maAnnotations
; }
375 bool Equals(const SdPage
&) const;
376 virtual void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
377 sal_uInt16
getPageId() const { return mnPageId
; }
380 Returns graphics objects from the page that can be prefetched before it's painted.
381 The pointers are temporary and should not be kept.
383 void getGraphicsForPrefetch(std::vector
<Graphic
*>& graphics
) const;
385 static sal_uInt16 mnLastPageId
;
390 // page id of this page
393 /** clone the animations from this and set them to rTargetPage
394 * TTTT: Order is strange, should be the other way around by
395 * convention/convenience and makes usage a little dangerous...
397 void cloneAnimations( SdPage
& rTargetPage
) const;
399 /** called before a shape is removed or replaced from this slide */
400 void onRemoveObject( SdrObject
* pObject
);
403 #endif // INCLUDED_SD_INC_SDPAGE_HXX
405 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */