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