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>
29 #include <editeng/flditem.hxx>
30 #include <svx/svdobj.hxx>
31 #include <svx/fmpage.hxx>
32 #include <xmloff/autolayout.hxx>
35 #include "shapelist.hxx"
36 #include "misc/scopelock.hxx"
39 namespace com
{ namespace sun
{ namespace star
{ namespace animations
{
59 struct SD_DLLPUBLIC HeaderFooterSettings
62 OUString maHeaderText
;
65 OUString maFooterText
;
67 bool mbSlideNumberVisible
;
69 bool mbDateTimeVisible
;
70 bool mbDateTimeIsFixed
;
71 OUString maDateTimeText
;
72 SvxDateFormat meDateFormat
;
73 SvxTimeFormat meTimeFormat
;
75 HeaderFooterSettings();
77 bool operator==( const HeaderFooterSettings
& rSettings
) const;
80 typedef std::vector
< css::uno::Reference
< css::office::XAnnotation
> > AnnotationVector
;
90 class SD_DLLPUBLIC SdPage final
: public FmFormPage
, public SdrObjUserCall
92 SdPage
& operator=(const SdPage
&) = delete;
93 SdPage(const SdPage
&) = delete;
95 friend class SdGenericDrawPage
;
96 friend class SdDrawPage
;
97 friend class sd::UndoAnimation
;
98 friend class sd::UndoTransition
;
99 friend class ModifyPageUndoAction
;
100 friend class sd::UndoGeoObject
;
101 friend class sd::UndoAttrObject
;
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).
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 SdPageLink
* mpPageLink
; ///< Page link (at left sides only)
125 sd::AnnotationVector maAnnotations
;
127 /** holds the smil animation sequences for this page */
128 css::uno::Reference
< css::animations::XAnimationNode
> mxAnimationNode
;
130 /** a helper class to manipulate effects inside the main sequence */
131 std::shared_ptr
< sd::MainSequence
> mpMainSequence
;
133 virtual css::uno::Reference
< css::uno::XInterface
> createUnoPage() override
;
135 std::unique_ptr
<SfxItemSet
> mpItems
;
137 SfxItemSet
* getOrCreateItems();
139 sd::HeaderFooterSettings maHeaderFooterSettings
;
141 // new transition settings
142 sal_Int16 mnTransitionType
;
143 sal_Int16 mnTransitionSubtype
;
144 bool mbTransitionDirection
;
145 sal_Int32 mnTransitionFadeColor
;
146 double mfTransitionDuration
;
148 void lateInit(const SdPage
& rSrcPage
);
152 SdPage(SdDrawDocument
& rNewDoc
, bool bMasterPage
);
153 virtual ~SdPage() override
;
155 virtual SdrPage
* CloneSdrPage(SdrModel
& rTargetModel
) const override
;
157 virtual void SetSize(const Size
& aSize
) override
;
158 virtual void SetBorder(sal_Int32 nLft
, sal_Int32 nUpp
, sal_Int32 nRgt
, sal_Int32 Lwr
) override
;
159 virtual void SetLeftBorder(sal_Int32 nBorder
) override
;
160 virtual void SetRightBorder(sal_Int32 nBorder
) override
;
161 virtual void SetUpperBorder(sal_Int32 nBorder
) override
;
162 virtual void SetLowerBorder(sal_Int32 nBorder
) override
;
163 virtual bool IsReadOnly() const override
;
165 sd::ShapeList
& GetPresentationShapeList() { return maPresentationShapeList
; }
167 void EnsureMasterPageDefaultBackground();
168 SdrObject
* CreatePresObj(PresObjKind eObjKind
, bool bVertical
, const ::tools::Rectangle
& rRect
);
169 SdrObject
* CreateDefaultPresObj(PresObjKind eObjKind
);
170 void DestroyDefaultPresObj(PresObjKind eObjKind
);
171 SdrObject
* GetPresObj(PresObjKind eObjKind
, int nIndex
= 1, bool bFuzzySearch
= false );
172 PresObjKind
GetPresObjKind(SdrObject
* pObj
) const;
173 OUString
GetPresObjText(PresObjKind eObjKind
) const;
174 SfxStyleSheet
* GetStyleSheetForMasterPageBackground() const;
175 SfxStyleSheet
* GetStyleSheetForPresObj(PresObjKind eObjKind
) const;
176 sal_Int64
GetHashCode() const;
177 bool RestoreDefaultText( SdrObject
* pObj
);
179 /** @return true if the given SdrObject is inside the presentation object list */
180 bool IsPresObj(const SdrObject
* pObj
);
182 /** removes the given SdrObject from the presentation object list */
183 void RemovePresObj(const SdrObject
* pObj
);
185 /** inserts the given SdrObject into the presentation object list */
186 void InsertPresObj(SdrObject
* pObj
, PresObjKind eKind
);
188 void SetAutoLayout(AutoLayout eLayout
, bool bInit
=false, bool bCreate
=false);
189 AutoLayout
GetAutoLayout() const { return meAutoLayout
; }
190 void CreateTitleAndLayout(bool bInit
=false, bool bCreate
=false);
191 SdrObject
* InsertAutoLayoutShape(SdrObject
* pObj
, PresObjKind eObjKind
, bool bVertical
, const ::tools::Rectangle
& rRect
, bool bInit
);
193 virtual void NbcInsertObject(SdrObject
* pObj
, size_t nPos
=SAL_MAX_SIZE
) override
;
194 virtual SdrObject
* NbcRemoveObject(size_t nObjNum
) override
;
195 virtual SdrObject
* RemoveObject(size_t nObjNum
) override
;
197 /** Also override ReplaceObject methods to realize when
198 objects are removed with this mechanism instead of RemoveObject*/
199 virtual SdrObject
* ReplaceObject(SdrObject
* pNewObj
, size_t nObjNum
) override
;
201 void SetObjText(SdrTextObj
* pObj
, SdrOutliner
* pOutliner
, PresObjKind eObjKind
, const OUString
& rStr
);
203 void SetPageKind(PageKind ePgType
) { mePageKind
= ePgType
; }
204 PageKind
GetPageKind() const { return mePageKind
; }
206 void SetSelected(bool bSel
) { mbSelected
= bSel
; }
207 bool IsSelected() const { return mbSelected
; }
209 void SetFadeEffect(css::presentation::FadeEffect eNewEffect
);
210 css::presentation::FadeEffect
GetFadeEffect() const;
212 void SetPresChange(PresChange eChange
) { mePresChange
= eChange
; }
213 PresChange
GetPresChange() const { return mePresChange
; }
215 void SetTime(double fNewTime
) { mfTime
= fNewTime
; }
216 double GetTime() const { return mfTime
; }
218 void SetSound(bool bNewSoundOn
) { mbSoundOn
= bNewSoundOn
; }
219 bool IsSoundOn() const { return mbSoundOn
; }
221 void SetExcluded(bool bNewExcluded
) { mbExcluded
= bNewExcluded
; }
222 bool IsExcluded() const { return mbExcluded
; }
224 bool IsScaleObjects() const { return mbScaleObjects
; }
226 void SetSoundFile(const OUString
& rStr
) { maSoundFile
= rStr
; }
227 const OUString
& GetSoundFile() const { return maSoundFile
; }
229 void SetLoopSound( bool bLoopSound
) { mbLoopSound
= bLoopSound
; }
230 bool IsLoopSound() const { return mbLoopSound
; }
232 void SetStopSound( bool bStopSound
) { mbStopSound
= bStopSound
; }
233 bool IsStopSound() const { return mbStopSound
; }
235 sal_Int16
getTransitionType() const { return mnTransitionType
;}
236 void setTransitionType( sal_Int16 nTransitionType
);
238 sal_Int16
getTransitionSubtype() const { return mnTransitionSubtype
;}
239 void setTransitionSubtype( sal_Int16 nTransitionSubtype
);
241 bool getTransitionDirection() const { return mbTransitionDirection
;}
242 void setTransitionDirection( bool bTransitionbDirection
);
244 sal_Int32
getTransitionFadeColor() const { return mnTransitionFadeColor
;}
245 void setTransitionFadeColor( sal_Int32 nTransitionFadeColor
);
247 double getTransitionDuration() const { return mfTransitionDuration
;}
248 void setTransitionDuration( double fTranstionDuration
);
250 virtual void Changed(const SdrObject
& rObj
, SdrUserCallType eType
,
251 const ::tools::Rectangle
& rOldBoundRect
) override
;
253 void SetLayoutName(const OUString
& aName
);
254 virtual OUString
GetLayoutName() const override
{ return maLayoutName
; }
256 void SetFileName(const OUString
& aName
) { maFileName
= aName
; }
257 const OUString
& GetFileName() const { return maFileName
; }
258 void SetBookmarkName(const OUString
& aName
) { maBookmarkName
= aName
; }
259 const OUString
& GetBookmarkName() const { return maBookmarkName
; }
262 void DisconnectLink();
264 void ScaleObjects(const Size
& rNewPageSize
, const ::tools::Rectangle
& rNewBorderRect
,
267 const OUString
& GetName() const;
268 OUString
const & GetRealName() const { return FmFormPage::GetName(); };
270 void SetPresentationLayout(const OUString
& rLayoutName
,
271 bool bReplaceStyleSheets
= true,
272 bool bSetMasterPage
= true,
273 bool bReverseOrder
= false);
274 void EndListenOutlineText();
276 void SetBackgroundFullSize( bool bIn
);
277 bool IsBackgroundFullSize() const { return mbBackgroundFullSize
; }
279 void SetPaperBin(sal_uInt16 nBin
) { mnPaperBin
= nBin
; }
280 sal_uInt16
GetPaperBin() const { return mnPaperBin
; }
281 virtual void SetOrientation(Orientation eOrient
) override
;
282 virtual Orientation
GetOrientation() const override
;
284 virtual SfxStyleSheet
* GetTextStyleSheetForObject( SdrObject
* pObj
) const override
;
286 bool setAlienAttributes( const css::uno::Any
& rAttributes
);
287 void getAlienAttributes( css::uno::Any
& rAttributes
);
289 /** @return the main animation node
291 @throws css::uno::RuntimeException
293 css::uno::Reference
< css::animations::XAnimationNode
> const & getAnimationNode();
295 /** sets the main animation node
297 @throws css::uno::RuntimeException
299 void setAnimationNode( css::uno::Reference
< css::animations::XAnimationNode
> const & xNode
);
301 /// @return a helper class to manipulate effects inside the main sequence
302 std::shared_ptr
< sd::MainSequence
> const & getMainSequence();
304 /** quick check if this slide has an animation node.
305 This can be used to have a cost free check if there are no animations ad this slide.
306 If it returns true this does not mean that there are animations available.
308 bool hasAnimationNode() const;
310 /// @return the SdPage implementation for the given XDrawPage or 0 if not available
311 static SdPage
* getImplementation( const css::uno::Reference
< css::drawing::XDrawPage
>& xPage
);
313 /** removes all custom animations for the given shape */
314 void removeAnimations( const SdrObject
* pObj
);
316 /** Notify that the object has been renamed and the animation effects has to update. */
317 void notifyObjectRenamed(const SdrObject
* pObj
);
319 /** Set the name of the page and broadcast a model change.
321 void SetName (const OUString
& rName
);
323 const sd::HeaderFooterSettings
& getHeaderFooterSettings() const;
324 void setHeaderFooterSettings( const sd::HeaderFooterSettings
& rNewSettings
);
327 @return true if the object from the ViewObjectContact should
328 be visible on this page while rendering.
330 bEdit selects if visibility test is for an editing view or a final render,
333 virtual bool checkVisibility(
334 const sdr::contact::ViewObjectContact
& rOriginal
,
335 const sdr::contact::DisplayInfo
& rDisplayInfo
,
336 bool bEdit
) override
;
338 /** callback from the sd::View when a new paragraph for one object on this page is created */
339 void onParagraphInserted( ::Outliner
* pOutliner
, Paragraph
const * pPara
, SdrObject
* pObj
);
341 /** callback from the sd::View when a paragraph from one object on this page is removed */
342 void onParagraphRemoving( ::Outliner
* pOutliner
, Paragraph
const * pPara
, SdrObject
* pObj
);
344 /** callback from the sd::View when an object just left text edit mode */
345 void onEndTextEdit( SdrObject
* pObj
);
347 /** @return the presentation style with the given helpid from this masterpage or this
349 SdStyleSheet
* getPresentationStyle( sal_uInt32 nHelpId
) const;
351 /** removes all empty presentation objects from this slide */
352 void RemoveEmptyPresentationObjects();
354 ::tools::Rectangle
GetTitleRect() const;
355 ::tools::Rectangle
GetLayoutRect() const;
357 static void CalculateHandoutAreas( SdDrawDocument
& rModel
, AutoLayout eLayout
, bool bHorizontal
, std::vector
< ::tools::Rectangle
>& rAreas
);
359 /** Set the "precious" flag to the given value.
361 void SetPrecious (const bool bIsPrecious
);
363 /** The "precious" flag is used for master pages to prevent some unused
364 master pages from being deleted automatically. For pages
365 other than master pages this flag can be ignored.
367 When this method returns <TRUE/> for a master page then this
368 master page should not be deleted automatically.
370 bool IsPrecious() const { return mbIsPrecious
; }
372 void createAnnotation( css::uno::Reference
< css::office::XAnnotation
>& xAnnotation
);
373 void addAnnotation( const css::uno::Reference
< css::office::XAnnotation
>& xAnnotation
, int nIndex
);
374 void removeAnnotation( const css::uno::Reference
< css::office::XAnnotation
>& xAnnotation
);
375 const sd::AnnotationVector
& getAnnotations() const { return maAnnotations
; }
376 bool Equals(const SdPage
&) const;
377 virtual void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
378 sal_uInt16
getPageId() { return mnPageId
; }
380 static sal_uInt16 mnLastPageId
;
385 // page id of this page
386 sal_uInt16
const mnPageId
;
388 /** clone the animations from this and set them to rTargetPage
389 * TTTT: Order is strange, should be the other way around by
390 * convention/convenience and makes usage a little dangerous...
392 void cloneAnimations( SdPage
& rTargetPage
) const;
394 /** called before a shape is removed or replaced from this slide */
395 void onRemoveObject( SdrObject
* pObject
);
398 #endif // INCLUDED_SD_INC_SDPAGE_HXX
400 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */