/src/libreoffice/sd/inc/sdpage.hxx
Line | Count | Source |
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 | | #ifndef INCLUDED_SD_INC_SDPAGE_HXX |
21 | | #define INCLUDED_SD_INC_SDPAGE_HXX |
22 | | |
23 | | #include <com/sun/star/drawing/XDrawPage.hpp> |
24 | | #include <com/sun/star/presentation/FadeEffect.hpp> |
25 | | #include <com/sun/star/office/XAnnotation.hpp> |
26 | | |
27 | | #include <memory> |
28 | | #include <string_view> |
29 | | #include <vector> |
30 | | #include <editeng/flditem.hxx> |
31 | | #include <svx/svdobj.hxx> |
32 | | #include <svx/fmpage.hxx> |
33 | | #include <xmloff/autolayout.hxx> |
34 | | #include "diadef.h" |
35 | | #include "pres.hxx" |
36 | | #include "shapelist.hxx" |
37 | | #include "misc/scopelock.hxx" |
38 | | #include "sddllapi.h" |
39 | | #include <tools/json_writer.hxx> |
40 | | |
41 | | namespace com::sun::star::animations { |
42 | | class XAnimationNode; |
43 | | } |
44 | | |
45 | | class SfxStyleSheet; |
46 | | class SdDrawDocument; |
47 | | class SdrOutliner; |
48 | | class SdrTextObj; |
49 | | class SdPageLink; |
50 | | class SfxItemSet; |
51 | | class Paragraph; |
52 | | class Outliner; |
53 | | class SdStyleSheet; |
54 | | class Graphic; |
55 | | |
56 | | namespace sd |
57 | | { |
58 | | class MainSequence; |
59 | | } |
60 | | |
61 | | namespace sd { |
62 | | |
63 | | struct SD_DLLPUBLIC HeaderFooterSettings |
64 | | { |
65 | | bool mbHeaderVisible; |
66 | | OUString maHeaderText; |
67 | | |
68 | | bool mbFooterVisible; |
69 | | OUString maFooterText; |
70 | | |
71 | | bool mbSlideNumberVisible; |
72 | | |
73 | | bool mbDateTimeVisible; |
74 | | bool mbDateTimeIsFixed; |
75 | | OUString maDateTimeText; |
76 | | SvxDateFormat meDateFormat; |
77 | | SvxTimeFormat meTimeFormat; |
78 | | |
79 | | HeaderFooterSettings(); |
80 | | |
81 | | bool operator==( const HeaderFooterSettings& rSettings ) const; |
82 | | }; |
83 | | } |
84 | | |
85 | | namespace sd { |
86 | | class UndoAnimation; |
87 | | class UndoTransition; |
88 | | class UndoGeoObject; |
89 | | class UndoAttrObject; |
90 | | } |
91 | | |
92 | | class SAL_DLLPUBLIC_RTTI SdPage final : public FmFormPage, public SdrObjUserCall |
93 | | { |
94 | | SdPage& operator=(const SdPage&) = delete; |
95 | | SdPage(const SdPage&) = delete; |
96 | | |
97 | | friend class SdGenericDrawPage; |
98 | | friend class SdDrawPage; |
99 | | friend class sd::UndoAnimation; |
100 | | friend class sd::UndoTransition; |
101 | | friend class ModifyPageUndoAction; |
102 | | friend class sd::UndoGeoObject; |
103 | | friend class sd::UndoAttrObject; |
104 | | |
105 | | PageKind mePageKind; ///< page type |
106 | | AutoLayout meAutoLayout; ///< AutoLayout |
107 | | sd::ShapeList maPresentationShapeList;///< presentation objects |
108 | | sd::ScopeLock maLockAutoLayoutArrangement; |
109 | | bool mbSelected; ///< selection identifier |
110 | | PresChange mePresChange; ///< manual / automatic / semi automatic |
111 | | double mfTime; ///< Display time in seconds |
112 | | bool mbSoundOn; ///< with / without sound. |
113 | | bool mbExcluded; ///< will (not) be displayed during show. |
114 | | OUString maLayoutName; ///< Name of the layout |
115 | | OUString maSoundFile; ///< Path to sound file (MS-DOS notation). |
116 | | bool mbLoopSound; |
117 | | bool mbStopSound; |
118 | | OUString maCreatedPageName; ///< generated page name by GetPageName. |
119 | | OUString maFileName; ///< file name. |
120 | | OUString maBookmarkName; ///< Bookmark name. |
121 | | bool mbScaleObjects; ///< Objects should be scaled |
122 | | rtl_TextEncoding meCharSet; ///< Text encoding |
123 | | sal_uInt16 mnPaperBin; ///< PaperBin |
124 | | SdPageLink* mpPageLink; ///< Page link (at left sides only) |
125 | | bool mbIsCanvasPage; ///< whether the page is a canvas page |
126 | | bool mbIsCanvasMasterPage; ///< whether it is the master page of canvas page |
127 | | |
128 | | // PDF link annotations for read-only pdfium |
129 | | std::vector<std::pair<basegfx::B2DRectangle, OUString>> maLinkAnnotations; |
130 | | |
131 | | /** holds the smil animation sequences for this page */ |
132 | | css::uno::Reference< css::animations::XAnimationNode > mxAnimationNode; |
133 | | |
134 | | /** a helper class to manipulate effects inside the main sequence */ |
135 | | std::shared_ptr< sd::MainSequence > mpMainSequence; |
136 | | |
137 | | virtual css::uno::Reference< css::uno::XInterface > createUnoPage() override; |
138 | | |
139 | | std::unique_ptr<SfxItemSet> mpItems; |
140 | | |
141 | | SfxItemSet* getOrCreateItems(); |
142 | | |
143 | | sd::HeaderFooterSettings maHeaderFooterSettings; |
144 | | |
145 | | // new transition settings |
146 | | sal_Int16 mnTransitionType; |
147 | | sal_Int16 mnTransitionSubtype; |
148 | | bool mbTransitionDirection; |
149 | | sal_Int32 mnTransitionFadeColor; |
150 | | double mfTransitionDuration; |
151 | | |
152 | | void lateInit(const SdPage& rSrcPage); |
153 | | |
154 | | public: |
155 | | |
156 | | SdPage(SdDrawDocument& rNewDoc, bool bMasterPage); |
157 | | virtual ~SdPage() override; |
158 | | |
159 | | virtual rtl::Reference<SdrPage> CloneSdrPage(SdrModel& rTargetModel) const override; |
160 | | |
161 | | virtual void SetSize(const Size& aSize) override; |
162 | | virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr) override; |
163 | | virtual void SetLeftBorder(sal_Int32 nBorder) override; |
164 | | virtual void SetRightBorder(sal_Int32 nBorder) override; |
165 | | virtual void SetUpperBorder(sal_Int32 nBorder) override; |
166 | | virtual void SetLowerBorder(sal_Int32 nBorder) override; |
167 | | virtual bool IsReadOnly() const override; |
168 | | |
169 | 0 | sd::ShapeList& GetPresentationShapeList() { return maPresentationShapeList; } |
170 | | |
171 | | void EnsureMasterPageDefaultBackground(); |
172 | | SD_DLLPUBLIC SdrObject* CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, const OUString& rCustomPrompt = OUString(), const sal_uInt16 nPagePreviewNum = 0xffff); |
173 | | SD_DLLPUBLIC rtl::Reference<SdrObject> CreateDefaultPresObj(PresObjKind eObjKind); |
174 | | SD_DLLPUBLIC void DestroyDefaultPresObj(PresObjKind eObjKind); |
175 | | SD_DLLPUBLIC SdrObject* GetPresObj(PresObjKind eObjKind, int nIndex = 1, bool bFuzzySearch = false ); |
176 | | PresObjKind GetPresObjKind(SdrObject* pObj) const; |
177 | | OUString GetPresObjText(PresObjKind eObjKind) const; |
178 | | SfxStyleSheet* GetStyleSheetForMasterPageBackground() const; |
179 | | SfxStyleSheet* GetStyleSheetForPresObj(PresObjKind eObjKind) const; |
180 | | void GetPageInfo(::tools::JsonWriter& jsonWriter); |
181 | | void NotifyPagePropertyChanges(); |
182 | | bool RestoreDefaultText( SdrObject* pObj, const OUString& rStr ) override; |
183 | | |
184 | | /** @return true if the given SdrObject is inside the presentation object list */ |
185 | | bool IsPresObj(const SdrObject* pObj); |
186 | | |
187 | | /** removes the given SdrObject from the presentation object list */ |
188 | | void RemovePresObj(const SdrObject* pObj); |
189 | | |
190 | | /** inserts the given SdrObject into the presentation object list */ |
191 | | void InsertPresObj(SdrObject* pObj, PresObjKind eKind ); |
192 | | |
193 | | SD_DLLPUBLIC void SetAutoLayout(AutoLayout eLayout, bool bInit=false, bool bCreate=false); |
194 | 621k | AutoLayout GetAutoLayout() const { return meAutoLayout; } |
195 | | void CreateTitleAndLayout(bool bInit=false, bool bCreate=false); |
196 | | SdrObject* InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, const OUString& rCustomPrompt, bool bInit); |
197 | | |
198 | | virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override; |
199 | | virtual rtl::Reference<SdrObject> NbcRemoveObject(size_t nObjNum) override; |
200 | | virtual rtl::Reference<SdrObject> RemoveObject(size_t nObjNum) override; |
201 | | |
202 | | /** Also override ReplaceObject methods to realize when |
203 | | objects are removed with this mechanism instead of RemoveObject*/ |
204 | | virtual rtl::Reference<SdrObject> ReplaceObject(SdrObject* pNewObj, size_t nObjNum) override; |
205 | | |
206 | | void SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, std::u16string_view rStr ); |
207 | | |
208 | 401k | void SetPageKind(PageKind ePgType) { mePageKind = ePgType; } |
209 | 108M | PageKind GetPageKind() const { return mePageKind; } |
210 | | |
211 | 0 | void SetSelected(bool bSel) { mbSelected = bSel; } |
212 | 0 | bool IsSelected() const { return mbSelected; } |
213 | | |
214 | | void SetFadeEffect(css::presentation::FadeEffect eNewEffect); |
215 | | css::presentation::FadeEffect GetFadeEffect() const; |
216 | | |
217 | 3.66k | void SetPresChange(PresChange eChange) { mePresChange = eChange; } |
218 | 0 | PresChange GetPresChange() const { return mePresChange; } |
219 | | |
220 | 338 | void SetTime(double fNewTime) { mfTime = fNewTime; } |
221 | 0 | double GetTime() const { return mfTime; } |
222 | | |
223 | 919 | void SetSound(bool bNewSoundOn) { mbSoundOn = bNewSoundOn; } |
224 | 0 | bool IsSoundOn() const { return mbSoundOn; } |
225 | | |
226 | 2.85k | void SetExcluded(bool bNewExcluded) { mbExcluded = bNewExcluded; } |
227 | 243 | bool IsExcluded() const { return mbExcluded; } |
228 | | |
229 | 0 | bool IsScaleObjects() const { return mbScaleObjects; } |
230 | | |
231 | 919 | void SetSoundFile(const OUString& rStr) { maSoundFile = rStr; } |
232 | 0 | const OUString& GetSoundFile() const { return maSoundFile; } |
233 | | |
234 | 75 | void SetLoopSound( bool bLoopSound ) { mbLoopSound = bLoopSound; } |
235 | 0 | bool IsLoopSound() const { return mbLoopSound; } |
236 | | |
237 | 49 | void SetStopSound( bool bStopSound ) { mbStopSound = bStopSound; } |
238 | 0 | bool IsStopSound() const { return mbStopSound; } |
239 | | |
240 | 0 | sal_Int16 getTransitionType() const { return mnTransitionType;} |
241 | | void setTransitionType( sal_Int16 nTransitionType ); |
242 | | |
243 | 0 | sal_Int16 getTransitionSubtype() const { return mnTransitionSubtype;} |
244 | | void setTransitionSubtype( sal_Int16 nTransitionSubtype ); |
245 | | |
246 | 0 | bool getTransitionDirection() const { return mbTransitionDirection;} |
247 | | void setTransitionDirection( bool bTransitionbDirection ); |
248 | | |
249 | 0 | sal_Int32 getTransitionFadeColor() const { return mnTransitionFadeColor;} |
250 | | void setTransitionFadeColor( sal_Int32 nTransitionFadeColor ); |
251 | | |
252 | 0 | double getTransitionDuration() const { return mfTransitionDuration;} |
253 | | void setTransitionDuration( double fTransitionDuration ); |
254 | | |
255 | | virtual void Changed(const SdrObject& rObj, SdrUserCallType eType, |
256 | | const ::tools::Rectangle& rOldBoundRect) override; |
257 | | |
258 | | void SetLayoutName(const OUString& aName); |
259 | 3.78M | const OUString& GetLayoutName() const { return maLayoutName; } |
260 | | |
261 | 0 | void SetFileName(const OUString& aName) { maFileName = aName; } |
262 | 8 | const OUString& GetFileName() const { return maFileName; } |
263 | 0 | void SetBookmarkName(const OUString& aName) { maBookmarkName = aName; } |
264 | 0 | const OUString& GetBookmarkName() const { return maBookmarkName; } |
265 | | |
266 | | void ConnectLink(); |
267 | | void DisconnectLink(); |
268 | | |
269 | | void ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rNewBorderRect, |
270 | | bool bScaleAllObj); |
271 | | |
272 | | SD_DLLPUBLIC const OUString& GetName() const; |
273 | 1.06M | OUString const & GetRealName() const { return FmFormPage::GetName(); }; |
274 | | |
275 | | void SetPresentationLayout(std::u16string_view rLayoutName, |
276 | | bool bReplaceStyleSheets = true, |
277 | | bool bSetMasterPage = true, |
278 | | bool bReverseOrder = false); |
279 | | void EndListenOutlineText(); |
280 | | |
281 | 0 | void SetPaperBin(sal_uInt16 nBin) { mnPaperBin = nBin; } |
282 | 0 | sal_uInt16 GetPaperBin() const { return mnPaperBin; } |
283 | | virtual void SetOrientation(Orientation eOrient) override; |
284 | | virtual Orientation GetOrientation() const override; |
285 | | |
286 | | virtual SfxStyleSheet* GetTextStyleSheetForObject( SdrObject* pObj ) const override; |
287 | | |
288 | | bool setAlienAttributes( const css::uno::Any& rAttributes ); |
289 | | void getAlienAttributes( css::uno::Any& rAttributes ); |
290 | | |
291 | | /** @return the main animation node |
292 | | |
293 | | @throws css::uno::RuntimeException |
294 | | */ |
295 | | css::uno::Reference< css::animations::XAnimationNode > const & getAnimationNode(); |
296 | | |
297 | | /** sets the main animation node |
298 | | |
299 | | @throws css::uno::RuntimeException |
300 | | */ |
301 | | void setAnimationNode( css::uno::Reference< css::animations::XAnimationNode > const & xNode ); |
302 | | |
303 | | /// @return a helper class to manipulate effects inside the main sequence |
304 | | std::shared_ptr< sd::MainSequence > const & getMainSequence(); |
305 | | |
306 | | /** quick check if this slide has an animation node. |
307 | | This can be used to have a cost free check if there are no animations ad this slide. |
308 | | If it returns true this does not mean that there are animations available. |
309 | | */ |
310 | | bool hasAnimationNode() const; |
311 | | |
312 | | /// @return the SdPage implementation for the given XDrawPage or 0 if not available |
313 | | static SdPage* getImplementation( const css::uno::Reference< css::drawing::XDrawPage >& xPage ); |
314 | | |
315 | | /** removes all custom animations for the given shape */ |
316 | | void removeAnimations( const SdrObject* pObj ); |
317 | | |
318 | | /** Notify that the object has been renamed and the animation effects has to update. */ |
319 | | void notifyObjectRenamed(const SdrObject* pObj); |
320 | | |
321 | | /** Set the name of the page and broadcast a model change. |
322 | | */ |
323 | | SD_DLLPUBLIC void SetName(const OUString& rName, bool bUpdatePageRelativeURLs = true); |
324 | | |
325 | | SD_DLLPUBLIC const sd::HeaderFooterSettings& getHeaderFooterSettings() const; |
326 | | SD_DLLPUBLIC void setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings ); |
327 | | |
328 | | /** |
329 | | @return true if the object from the ViewObjectContact should |
330 | | be visible on this page while rendering. |
331 | | |
332 | | bEdit selects if visibility test is for an editing view or a final render, |
333 | | like printing. |
334 | | */ |
335 | | virtual bool checkVisibility( |
336 | | const sdr::contact::ViewObjectContact& rOriginal, |
337 | | const sdr::contact::DisplayInfo& rDisplayInfo, |
338 | | bool bEdit ) override; |
339 | | |
340 | | /** callback from the sd::View when a new paragraph for one object on this page is created */ |
341 | | void onParagraphInserted( const ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj ); |
342 | | |
343 | | /** callback from the sd::View when a paragraph from one object on this page is removed */ |
344 | | void onParagraphRemoving( const ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj ); |
345 | | |
346 | | /** callback from the sd::View when an object just left text edit mode */ |
347 | | void onEndTextEdit( SdrObject* pObj ); |
348 | | |
349 | | /** @return the presentation style with the given helpid from this masterpage or this |
350 | | slides masterpage */ |
351 | | SD_DLLPUBLIC SdStyleSheet* getPresentationStyle( sal_uInt32 nHelpId ) const; |
352 | | |
353 | | /** removes all empty presentation objects from this slide */ |
354 | | void RemoveEmptyPresentationObjects(); |
355 | | |
356 | | ::tools::Rectangle GetTitleRect() const; |
357 | | ::tools::Rectangle GetLayoutRect() const; |
358 | | |
359 | | static void CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< ::tools::Rectangle >& rAreas, Orientation eOrient ); |
360 | | |
361 | | /** Set the "precious" flag to the given value. |
362 | | */ |
363 | | void SetPrecious (const bool bIsPrecious); |
364 | | |
365 | | /** The "precious" flag is used for master pages to prevent some unused |
366 | | master pages from being deleted automatically. For pages |
367 | | other than master pages this flag can be ignored. |
368 | | @return |
369 | | When this method returns <TRUE/> for a master page then this |
370 | | master page should not be deleted automatically. |
371 | | */ |
372 | 0 | bool IsPrecious() const { return mbIsPrecious; } |
373 | | |
374 | | SD_DLLPUBLIC rtl::Reference<sdr::annotation::Annotation> createAnnotation() override; |
375 | | SD_DLLPUBLIC void addAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, int nIndex = -1) override; |
376 | | void addAnnotationNoNotify(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, int nIndex = -1) override; |
377 | | |
378 | | SD_DLLPUBLIC void removeAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation) override; |
379 | | void removeAnnotationNoNotify(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation) override; |
380 | | |
381 | | void setLinkAnnotations(const std::vector<std::pair<basegfx::B2DRectangle, OUString>>& rLinks) |
382 | 13 | { |
383 | 13 | maLinkAnnotations = rLinks; |
384 | 13 | } |
385 | | const std::vector<std::pair<basegfx::B2DRectangle, OUString>>& getLinkAnnotations() const |
386 | 0 | { |
387 | 0 | return maLinkAnnotations; |
388 | 0 | } |
389 | | |
390 | | bool Equals(const SdPage&) const; |
391 | | virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
392 | 0 | sal_uInt16 getPageId() const { return mnPageId; } |
393 | | |
394 | | /** |
395 | | Returns graphics objects from the page that can be prefetched before it's painted. |
396 | | The pointers are temporary and should not be kept. |
397 | | */ |
398 | | void getGraphicsForPrefetch(std::vector<Graphic*>& graphics) const; |
399 | | |
400 | | static AutoLayout stringToAutoLayout(std::u16string_view rLayoutName); |
401 | | static OUString autoLayoutToString(AutoLayout nLayoutId); |
402 | | |
403 | | static sal_uInt16 mnLastPageId; |
404 | | |
405 | 441k | bool IsCanvasPage() const { return mbIsCanvasPage; } |
406 | | void SetCanvasPage(); |
407 | | |
408 | 0 | bool IsCanvasMasterPage() const { return mbIsCanvasMasterPage; } |
409 | 0 | void SetCanvasMasterPage() { mbIsCanvasMasterPage = true; } |
410 | | |
411 | | private: |
412 | | bool mbIsPrecious; |
413 | | |
414 | | // page id of this page |
415 | | sal_uInt16 mnPageId; |
416 | | |
417 | | /** clone the animations from this and set them to rTargetPage |
418 | | * TTTT: Order is strange, should be the other way around by |
419 | | * convention/convenience and makes usage a little dangerous... |
420 | | */ |
421 | | void cloneAnimations( SdPage& rTargetPage ) const; |
422 | | |
423 | | /** called before a shape is removed or replaced from this slide */ |
424 | | void onRemoveObject( SdrObject* pObject ); |
425 | | }; |
426 | | |
427 | | #endif // INCLUDED_SD_INC_SDPAGE_HXX |
428 | | |
429 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |