xref: /trunk/main/sd/inc/sdpage.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SDPAGE_HXX
29 #define _SDPAGE_HXX
30 
31 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
32 #include <boost/shared_ptr.hpp>
33 #endif
34 
35 #ifndef INCLUDED_FUNCTIONAL
36 #include <functional>
37 #define INCLUDED_FUNCTIONAL
38 #endif
39 #include <com/sun/star/drawing/XDrawPage.hpp>
40 #include <com/sun/star/presentation/FadeEffect.hpp>
41 #include <com/sun/star/office/XAnnotation.hpp>
42 
43 #include <list>
44 #include <functional>
45 #include <vector>
46 #include <svx/svdobj.hxx>
47 #ifndef _FM_FMPAGE_HXX //autogen
48 #include <svx/fmpage.hxx>
49 #endif
50 #include "fadedef.h"
51 #include "diadef.h"
52 #ifndef _PRESENTATION
53 #include "pres.hxx"
54 #endif
55 #include "shapelist.hxx"
56 #include "misc/scopelock.hxx"
57 #include "sddllapi.h"
58 
59 namespace com { namespace sun { namespace star { namespace animations {
60     class XAnimationNode;
61 } } } }
62 
63 class SfxStyleSheet;
64 class SdDrawDocument;
65 class SdrTextObj;
66 class SdPageLink;
67 class StarBASIC;
68 class SfxItemSet;
69 struct StyleRequestData;
70 class SdPage;
71 class Paragraph;
72 class Outliner;
73 class SdStyleSheet;
74 
75 namespace sd
76 {
77     class MainSequence;
78 }
79 
80 namespace boost
81 {
82     template<class X> class shared_ptr;
83 }
84 
85 namespace sd {
86 
87     struct SD_DLLPUBLIC HeaderFooterSettings
88     {
89         bool mbHeaderVisible;
90         String maHeaderText;
91 
92         bool mbFooterVisible;
93         String maFooterText;
94 
95         bool mbSlideNumberVisible;
96 
97         bool mbDateTimeVisible;
98         bool mbDateTimeIsFixed;
99         String maDateTimeText;
100         int meDateTimeFormat;
101 
102         HeaderFooterSettings();
103 
104         bool operator==( const HeaderFooterSettings& rSettings ) const;
105     };
106 
107     typedef std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > > AnnotationVector;
108 }
109 
110 namespace sd {
111     class UndoAnimation;
112     class UndoTransition;
113     class UndoGeoObject;
114     class UndoAttrObject;
115 }
116 
117 class SD_DLLPUBLIC SdPage : public FmFormPage, public SdrObjUserCall
118 {
119 friend class SdGenericDrawPage;
120 friend class SdDrawPage;
121 friend class sd::UndoAnimation;
122 friend class sd::UndoTransition;
123 friend class ModifyPageUndoAction;
124 friend class sd::UndoGeoObject;
125 friend class sd::UndoAttrObject;
126 
127 protected:
128     PageKind    mePageKind;               // Seitentyp
129     AutoLayout  meAutoLayout;             // AutoLayout
130     sd::ShapeList maPresentationShapeList;            // Praesentationsobjekte
131     sd::ScopeLock maLockAutoLayoutArrangement;
132     sal_Bool        mbSelected;               // Selektionskennung
133     PresChange  mePresChange;             // manuell/automatisch/halbautomatisch
134     sal_uInt32      mnTime;                   // Anzeigedauer in Sekunden
135     sal_Bool        mbSoundOn;                // mit/ohne Sound (sal_True/sal_False)
136     sal_Bool        mbExcluded;               // wird in der Show nicht/doch
137                                           // angezeigt (sal_True/sal_False)
138     String      maLayoutName;             // Name des Layouts
139     String      maSoundFile;               // Pfad zum Soundfile (MSDOS-Notation)
140     bool        mbLoopSound;
141     bool        mbStopSound;
142     String      maCreatedPageName;         // von GetPageName erzeugter Seitenname
143     String      maFileName;                // Filename
144     String      maBookmarkName;           // Bookmarkname
145     sal_Bool        mbScaleObjects;           // Objekte sollen skaliert werden
146     sal_Bool        mbBackgroundFullSize;     // Hintergrundobjekt auf ganze Seite darstellen
147     rtl_TextEncoding meCharSet;            // Text-Encoding
148     sal_uInt16      mnPaperBin;                // PaperBin
149     Orientation meOrientation;             // Print-Orientation
150     SdPageLink* mpPageLink;               // PageLink (nur bei gelinkten Seiten)
151 
152     sd::AnnotationVector    maAnnotations;
153 
154     /** holds the smil animation sequences for this page */
155     ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > mxAnimationNode;
156 
157     /** a helper class to manipulate effects inside the main sequence */
158     boost::shared_ptr< sd::MainSequence > mpMainSequence;
159 
160     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoPage();
161 
162     SfxItemSet* mpItems;
163 
164     SfxItemSet* getOrCreateItems();
165 
166     sd::HeaderFooterSettings    maHeaderFooterSettings;
167 
168     // new transition settings
169     sal_Int16 mnTransitionType;
170     sal_Int16 mnTransitionSubtype;
171     sal_Bool mbTransitionDirection;
172     sal_Int32 mnTransitionFadeColor;
173     double mfTransitionDuration;
174 
175 public:
176     TYPEINFO();
177 
178     SdPage(SdDrawDocument& rNewDoc, StarBASIC* pBasic, sal_Bool bMasterPage=sal_False);
179     SdPage(const SdPage& rSrcPage);
180     ~SdPage();
181     virtual SdrPage* Clone() const;
182     virtual SdrPage* Clone(SdrModel* pNewModel) const;
183 
184     virtual void    SetSize(const Size& aSize);
185     virtual void    SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr);
186     virtual void    SetLftBorder(sal_Int32 nBorder);
187     virtual void    SetRgtBorder(sal_Int32 nBorder);
188     virtual void    SetUppBorder(sal_Int32 nBorder);
189     virtual void    SetLwrBorder(sal_Int32 nBorder);
190     virtual void    SetModel(SdrModel* pNewModel);
191     virtual FASTBOOL IsReadOnly() const;
192 
193     sd::ShapeList&  GetPresentationShapeList() { return maPresentationShapeList; }
194 
195     void EnsureMasterPageDefaultBackground();
196     SdrObject*      CreatePresObj(PresObjKind eObjKind, sal_Bool bVertical, const Rectangle& rRect, sal_Bool bInsert=sal_False);
197     SdrObject*      CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert);
198     SdrObject*      GetPresObj(PresObjKind eObjKind, int nIndex = 1, bool bFuzzySearch = false );
199     PresObjKind     GetPresObjKind(SdrObject* pObj) const;
200     String          GetPresObjText(PresObjKind eObjKind) const;
201     SfxStyleSheet* GetStyleSheetForMasterPageBackground() const;
202     SfxStyleSheet*  GetStyleSheetForPresObj(PresObjKind eObjKind) const;
203     bool            RestoreDefaultText( SdrObject* pObj );
204 
205     /** returns true if the given SdrObject is inside the presentation object list */
206     bool            IsPresObj(const SdrObject* pObj);
207 
208     /** removes the given SdrObject from the presentation object list */
209     void            RemovePresObj(const SdrObject* pObj);
210 
211     /** inserts the given SdrObject into the presentation object list */
212     void            InsertPresObj(SdrObject* pObj, PresObjKind eKind );
213 
214     void            SetAutoLayout(AutoLayout eLayout, sal_Bool bInit=sal_False, sal_Bool bCreate=sal_False);
215     AutoLayout      GetAutoLayout() const { return meAutoLayout; }
216     void            CreateTitleAndLayout(sal_Bool bInit=sal_False, sal_Bool bCreate=sal_False);
217     SdrObject*      InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, bool bVertical, Rectangle aRect, bool bInit );
218 
219     virtual void       NbcInsertObject(SdrObject* pObj, sal_uLong nPos=CONTAINER_APPEND,
220                                        const SdrInsertReason* pReason=NULL);
221     virtual SdrObject* NbcRemoveObject(sal_uLong nObjNum);
222     virtual SdrObject* RemoveObject(sal_uLong nObjNum);
223 
224     // #95876# Also overload ReplaceObject methods to realize when
225     // objects are removed with this mechanism instead of RemoveObject
226     virtual SdrObject* NbcReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum);
227     virtual SdrObject* ReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum);
228 
229     virtual void SetLinkData(const String& rLinkName, const String& rLinkData);
230 
231     void        SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, const String& rStr );
232 
233     void        SetPageKind(PageKind ePgType)        { mePageKind = ePgType; }
234     PageKind    GetPageKind() const                  { return mePageKind; }
235 
236     void        SetSelected(sal_Bool bSel)               { mbSelected = bSel; }
237     sal_Bool        IsSelected() const                   { return mbSelected; }
238 
239     void        SetFadeEffect(::com::sun::star::presentation::FadeEffect eNewEffect);
240     ::com::sun::star::presentation::FadeEffect  GetFadeEffect() const;
241 
242     void        SetPresChange(PresChange eChange)    { mePresChange = eChange; }
243     PresChange  GetPresChange() const                { return mePresChange; }
244 
245     void        SetTime(sal_uInt32 nNewTime)             { mnTime = nNewTime; }
246     sal_uInt32      GetTime() const                      { return mnTime; }
247 
248     void        SetSound(sal_Bool bNewSoundOn)           { mbSoundOn = bNewSoundOn; }
249     sal_Bool        IsSoundOn() const                    { return mbSoundOn; }
250 
251     void        SetExcluded(sal_Bool bNewExcluded)      { mbExcluded = bNewExcluded; }
252     sal_Bool        IsExcluded() const                  { return mbExcluded; }
253 
254     void        SetScaleObjects(sal_Bool bScale)        { mbScaleObjects = bScale; }
255     sal_Bool        IsScaleObjects() const              { return mbScaleObjects; }
256 
257     void        SetSoundFile(const String& rStr)    { maSoundFile = rStr; }
258     String      GetSoundFile() const                { return maSoundFile; }
259 
260     void        SetLoopSound( bool bLoopSound ) { mbLoopSound = bLoopSound; }
261     bool        IsLoopSound() const                 { return mbLoopSound; }
262 
263     void        SetStopSound( bool bStopSound ) { mbStopSound = bStopSound; }
264     bool        IsStopSound() const             { return mbStopSound; }
265 
266     sal_Int16   getTransitionType() const;
267     void        setTransitionType( sal_Int16 nTransitionType );
268 
269     sal_Int16   getTransitionSubtype() const;
270     void        setTransitionSubtype( sal_Int16 nTransitionSubtype );
271 
272     sal_Bool    getTransitionDirection() const;
273     void        setTransitionDirection( sal_Bool bTransitionbDirection );
274 
275     sal_Int32   getTransitionFadeColor() const;
276     void        setTransitionFadeColor( sal_Int32 nTransitionFadeColor );
277 
278     double      getTransitionDuration() const;
279     void        setTransitionDuration( double fTranstionDuration );
280 
281     // Virtuelle Methoden von SdrObjUserCall
282     virtual void Changed(const SdrObject& rObj, SdrUserCallType eType,
283                          const Rectangle& rOldBoundRect);
284 
285     void            SetLayoutName(String aName);
286     virtual String  GetLayoutName() const       { return maLayoutName; }
287 
288     void            SetFileName(const String& aName) { maFileName = aName; }
289     virtual String  GetFileName() const       { return maFileName; }
290     void            SetBookmarkName(const String& aName) { maBookmarkName = aName; }
291     virtual String  GetBookmarkName() const       { return maBookmarkName; }
292     SdPageLink*     GetLink() { return mpPageLink; }
293 
294     void            ConnectLink();
295     void            DisconnectLink();
296 
297     void    ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderRect,
298                          sal_Bool bScaleAllObj);
299 
300     const String&   GetName() const;
301     String          GetRealName() const { return FmFormPage::GetName(); };
302 
303     void    SetPresentationLayout(const String& rLayoutName,
304                                   sal_Bool bReplaceStyleSheets = sal_True,
305                                   sal_Bool bSetMasterPage = sal_True,
306                                   sal_Bool bReverseOrder = sal_False);
307     void    EndListenOutlineText();
308 
309     void    SetBackgroundFullSize( sal_Bool bIn );
310     sal_Bool    IsBackgroundFullSize() const { return mbBackgroundFullSize; }
311 
312     rtl_TextEncoding GetCharSet() { return(meCharSet); }
313 
314     void    SetPaperBin(sal_uInt16 nBin) { mnPaperBin = nBin; }
315     sal_uInt16  GetPaperBin() const { return mnPaperBin; }
316     virtual void        SetOrientation(Orientation eOrient);
317     virtual Orientation GetOrientation() const;
318 
319     virtual SfxStyleSheet* GetTextStyleSheetForObject( SdrObject* pObj ) const;
320 
321     sal_Bool setAlienAttributes( const com::sun::star::uno::Any& rAttributes );
322     void getAlienAttributes( com::sun::star::uno::Any& rAttributes );
323 
324     /** returns the main animation node */
325     ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > getAnimationNode() throw (::com::sun::star::uno::RuntimeException);
326 
327     /** sets the main animation node */
328     void setAnimationNode( ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode ) throw (::com::sun::star::uno::RuntimeException);
329 
330     /** returns a helper class to manipulate effects inside the main sequence */
331     boost::shared_ptr< sd::MainSequence > getMainSequence();
332 
333     /** quick check if this slide has an animation node.
334         This can be used to have a cost free check if there are no animations ad this slide.
335         If it returns true this does not mean that there are animations available.
336     */
337     bool hasAnimationNode() const;
338 
339     /** returns the SdPage implementation for the given XDrawPage or 0 if not available */
340     static SdPage* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage );
341 
342     /** removes all custom animations for the given shape */
343     void removeAnimations( const SdrObject* pObj );
344 
345     /** Set the name of the page and broadcast a model change.
346     */
347     virtual void SetName (const String& rName);
348 
349     const sd::HeaderFooterSettings& getHeaderFooterSettings() const;
350     void setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings );
351 
352     /** this method returns true if the object from the ViewObjectContact should
353         be visible on this page while rendering.
354         bEdit selects if visibility test is for an editing view or a final render,
355         like printing.
356     */
357     virtual bool checkVisibility(
358         const sdr::contact::ViewObjectContact& rOriginal,
359         const sdr::contact::DisplayInfo& rDisplayInfo,
360         bool bEdit );
361 
362     /** callback from the sd::View when a new paragraph for one object on this page is created */
363     void onParagraphInserted( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj );
364 
365     /** callback from the sd::View when a paragraph from one object on this page is removed */
366     void onParagraphRemoving( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj );
367 
368     /** callback from the sd::View when an object just left text edit mode */
369     void onEndTextEdit( SdrObject* pObj );
370 
371     /** returns the presentation style with the given helpid from this masterpage or this
372         slides masterpage */
373     SdStyleSheet* getPresentationStyle( sal_uInt32 nHelpId ) const;
374 
375     /** removes all empty presentation objects from this slide */
376     void RemoveEmptyPresentationObjects();
377 
378     Rectangle   GetTitleRect() const;
379     Rectangle   GetLayoutRect() const;
380 
381     static void CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< Rectangle >& rAreas );
382 
383     /** Set the "precious" flag to the given value.
384     */
385     void SetPrecious (const bool bIsPrecious);
386 
387     /** The "precious" flag is used for master pages to prevent some unused
388         master pages from being deleted automatically.  For pages
389         other than master pages this flag can be ignored.
390         @return
391             When this method returns <TRUE/> for a master page then this
392             master page should not be deleted automatically.
393     */
394     bool IsPrecious (void) const;
395 
396     void createAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation );
397     void addAnnotation( const ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation, int nIndex = -1 );
398     void removeAnnotation( const ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation );
399     const sd::AnnotationVector& getAnnotations() const { return maAnnotations; }
400     bool hasAnnotations() const { return !maAnnotations.empty(); }
401 
402 private:
403     bool mbIsPrecious;
404 
405     /** clone the animations from this and set them to rTargetPage
406     */
407     void cloneAnimations( SdPage& rTargetPage ) const;
408 
409     /** called before a shape is removed or replaced from this slide */
410     void onRemoveObject( SdrObject* pObject );
411 };
412 
413 #endif     // _SDPAGE_HXX
414