xref: /aoo42x/main/sw/inc/frmfmt.hxx (revision cdf0e10c)
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 #ifndef _FRMFMT_HXX
28 #define _FRMFMT_HXX
29 
30 #include <com/sun/star/text/PositionLayoutDir.hpp>
31 #include <cppuhelper/weakref.hxx>
32 #include <tools/gen.hxx>
33 #include <format.hxx>
34 #include "swdllapi.h"
35 
36 class SwFlyFrm;
37 class SwAnchoredObject;
38 class Graphic;
39 class Point;
40 class ImageMap;
41 class IMapObject;
42 class SwRect;
43 class SwContact;
44 class SdrObject;
45 
46 class SW_DLLPUBLIC SwFrmFmt: public SwFmt
47 {
48 	friend class SwDoc;
49 	friend class SwPageDesc;	//darf den protected CTor rufen.
50 
51     ::com::sun::star::uno::WeakReference<
52         ::com::sun::star::uno::XInterface> m_wXObject;
53 
54 protected:
55 	SwFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
56 				SwFrmFmt *pDrvdFrm, sal_uInt16 nFmtWhich = RES_FRMFMT,
57 				const sal_uInt16* pWhichRange = 0 )
58 	  	: SwFmt( rPool, pFmtNm, (pWhichRange ? pWhichRange : aFrmFmtSetRange),
59 				pDrvdFrm, nFmtWhich )
60 	{}
61 
62 	SwFrmFmt( SwAttrPool& rPool, const String &rFmtNm,
63 				SwFrmFmt *pDrvdFrm, sal_uInt16 nFmtWhich = RES_FRMFMT,
64 				const sal_uInt16* pWhichRange = 0 )
65 	  	: SwFmt( rPool, rFmtNm, (pWhichRange ? pWhichRange : aFrmFmtSetRange),
66 				pDrvdFrm, nFmtWhich )
67 	{}
68 
69    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue );
70 
71 public:
72 	TYPEINFO();		//Bereits in Basisklasse Client drin.
73 
74 	//Vernichtet alle Frms in aDepend (Frms werden per PTR_CAST erkannt).
75 	virtual void DelFrms();
76 
77 	//Erzeugt die Ansichten
78 	virtual void MakeFrms();
79 
80 	virtual Graphic MakeGraphic( ImageMap* pMap = NULL );
81 
82 	// returnt das IMapObject, das an dem Format (Fly), in der ImageMap
83 	// an der Point Position definiert ist.
84 	// 	rPoint - teste auf der DocPosition
85 	//	pFly - optionaler FlyFrame, falls der schon bekannt ist.
86 	IMapObject* GetIMapObject( const Point& rPoint,
87 								const SwFlyFrm *pFly = 0 ) const;
88 
89 	// Gibt die tatsaechlche Groesse des Frames zurueck bzw. ein leeres
90 	// Rechteck, wenn kein Layout existiert. Wird pPoint angegeben, dann
91 	// wird der am dichtesten liegende Frame gesucht.
92 	SwRect FindLayoutRect( const sal_Bool bPrtArea = sal_False,
93 							const Point* pPoint = 0,
94 							const sal_Bool bCalcFrm = sal_False ) const;
95 
96 	// Sucht das SdrObject. Der SdrObjUserCall ist Client vom Format.
97 	// Der UserCall kennt sein SdrObject.
98 		  SwContact *FindContactObj();
99 	const SwContact *FindContactObj() const
100 		{ return ((SwFrmFmt*)this)->FindContactObj(); }
101 
102 	// returns the SdrObject, that ist connected to the ContactObject.
103 	// Only DrawFrmFmts are connected to the "real SdrObject". FlyFrmFmts
104 	// are connected to a Master and all FlyFrms has the "real SdrObject".
105 	// "Real SdrObject" has position and a Z-order.
106 		  SdrObject *FindSdrObject();
107 	const SdrObject *FindSdrObject() const
108 		{ return ((SwFrmFmt*)this)->FindSdrObject(); }
109 
110 		  SdrObject *FindRealSdrObject();
111 	const SdrObject *FindRealSdrObject() const
112 		{ return ((SwFrmFmt*)this)->FindRealSdrObject(); }
113 
114 	sal_Bool IsLowerOf( const SwFrmFmt& rFmt ) const;
115 
116     // --> OD 2004-07-27 #i31698#
117     enum tLayoutDir
118     {
119         HORI_L2R,
120         HORI_R2L,
121         VERT_R2L,
122         VERT_L2R    // not supported yet
123     };
124 
125     virtual SwFrmFmt::tLayoutDir GetLayoutDir() const;
126     virtual void SetLayoutDir( const SwFrmFmt::tLayoutDir _eLayoutDir );
127     // <--
128 
129     // --> OD 2004-08-06 #i28749#
130     virtual sal_Int16 GetPositionLayoutDir() const;
131     virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
132     // <--
133 
134     virtual String GetDescription() const;
135 
136     SW_DLLPRIVATE ::com::sun::star::uno::WeakReference<
137         ::com::sun::star::uno::XInterface> const& GetXObject() const
138             { return m_wXObject; }
139     SW_DLLPRIVATE void SetXObject(::com::sun::star::uno::Reference<
140                     ::com::sun::star::uno::XInterface> const& xObject)
141             { m_wXObject = xObject; }
142 
143 	DECL_FIXEDMEMPOOL_NEWDEL_DLL(SwFrmFmt)
144     void RegisterToFormat( SwFmt& rFmt );
145 };
146 
147 //Das FlyFrame-Format ------------------------------
148 
149 class SW_DLLPUBLIC SwFlyFrmFmt: public SwFrmFmt
150 {
151 	friend class SwDoc;
152 
153     // #i972:
154     // it stores the previous position of Prt rectangle from RequestObjectResize
155     // so it can be used to move frames of non-resizable objects to align them correctly
156     // when they get borders (this is done in SwWrtShell::CalcAndGetScale)
157     Point   m_aLastFlyFrmPrtRectPos;
158 
159     //Beide nicht vorhanden.
160 	SwFlyFrmFmt( const SwFlyFrmFmt &rCpy );
161 	SwFlyFrmFmt &operator=( const SwFlyFrmFmt &rCpy );
162 
163 protected:
164 	SwFlyFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
165 					SwFrmFmt *pDrvdFrm )
166 		: SwFrmFmt( rPool, pFmtNm, pDrvdFrm, RES_FLYFRMFMT )
167 	{}
168 	SwFlyFrmFmt( SwAttrPool& rPool, const String &rFmtNm,
169 					SwFrmFmt *pDrvdFrm )
170 		: SwFrmFmt( rPool, rFmtNm, pDrvdFrm, RES_FLYFRMFMT )
171 	{}
172 
173 public:
174 	TYPEINFO();
175 	~SwFlyFrmFmt();
176 
177 	//Erzeugt die Ansichten
178 	virtual void MakeFrms();
179 
180 	SwFlyFrm* GetFrm( const Point* pDocPos = 0,
181 						const sal_Bool bCalcFrm = sal_False ) const;
182 
183     SwAnchoredObject* GetAnchoredObj( const Point* pDocPos = 0,
184                                       const sal_Bool bCalcFrm = sal_False ) const;
185 
186 	virtual Graphic MakeGraphic( ImageMap* pMap = NULL );
187 
188 	virtual sal_Bool GetInfo( SfxPoolItem& rInfo ) const;
189 
190     // --> OD 2009-07-14 #i73249#
191     const String GetObjTitle() const;
192     void SetObjTitle( const String& rTitle,
193                       bool bBroadcast = false );
194     const String GetObjDescription() const;
195     void SetObjDescription( const String& rDescription,
196                             bool bBroadcast = false );
197     // <--
198 
199     /** SwFlyFrmFmt::IsBackgroundTransparent - for #99657#
200 
201         OD 22.08.2002 - overloading virtual method and its default implementation,
202         because format of fly frame provides transparent backgrounds.
203         Method determines, if background of fly frame is transparent.
204 
205         @author OD
206 
207         @return true, if background color is transparent, but not "no fill"
208         or a existing background graphic is transparent.
209     */
210     virtual sal_Bool IsBackgroundTransparent() const;
211 
212     /** SwFlyFrmFmt::IsBackgroundBrushInherited - for #103898#
213 
214         OD 08.10.2002 - method to determine, if the brush for drawing the
215         background is "inherited" from its parent/grandparent.
216         This is the case, if no background graphic is set and the background
217         color is "no fill"/"auto fill"
218 
219         @author OD
220 
221         @return true, if background brush is "inherited" from parent/grandparent
222     */
223     sal_Bool IsBackgroundBrushInherited() const;
224 
225     const Point & GetLastFlyFrmPrtRectPos() const       { return m_aLastFlyFrmPrtRectPos; }
226     void SetLastFlyFrmPrtRectPos( const Point &rPoint ) { m_aLastFlyFrmPrtRectPos = rPoint; }
227 
228 	DECL_FIXEDMEMPOOL_NEWDEL(SwFlyFrmFmt)
229 };
230 
231 //Das DrawFrame-Format -----------------------------
232 
233 class SW_DLLPUBLIC SwDrawFrmFmt: public SwFrmFmt
234 {
235 	friend class SwDoc;
236 
237     mutable const SdrObject * pSdrObjCached;
238     mutable String sSdrObjCachedComment;
239 
240 	//Beide nicht vorhanden.
241 	SwDrawFrmFmt( const SwDrawFrmFmt &rCpy );
242 	SwDrawFrmFmt &operator=( const SwDrawFrmFmt &rCpy );
243 
244     // --> OD 2004-07-27 #i31698#
245     SwFrmFmt::tLayoutDir meLayoutDir;
246     // <--
247     // --> OD 2004-08-06 #i28749#
248     sal_Int16 mnPositionLayoutDir;
249     // <--
250     // --> OD 2005-03-11 #i44334#, #i44681#
251     bool mbPosAttrSet;
252     // <--
253 protected:
254 	SwDrawFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
255 					SwFrmFmt *pDrvdFrm )
256         : SwFrmFmt( rPool, pFmtNm, pDrvdFrm, RES_DRAWFRMFMT ),
257           pSdrObjCached(NULL),
258           // --> OD 2004-07-28 #i31698#
259           meLayoutDir( SwFrmFmt::HORI_L2R ),
260           // <--
261           // --> OD 2004-08-06 #i28749#
262           // --> OD 2005-03-10 #i44344#, #i44681# - undo change of issue #i36010#
263           mnPositionLayoutDir( com::sun::star::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
264           // <--
265           // --> OD 2005-03-11 #i44334#, #i44681#
266           mbPosAttrSet( false )
267           // <--
268 
269 	{}
270 	SwDrawFrmFmt( SwAttrPool& rPool, const String &rFmtNm,
271 					SwFrmFmt *pDrvdFrm )
272         : SwFrmFmt( rPool, rFmtNm, pDrvdFrm, RES_DRAWFRMFMT ),
273           pSdrObjCached(NULL),
274           // --> OD 2004-07-28 #i31698#
275           meLayoutDir( SwFrmFmt::HORI_L2R ),
276           // <--
277           // --> OD 2004-08-06 #i28749#
278           // --> OD 2005-03-10 #i44344#, #i44681# - undo change of issue #i36010#
279           mnPositionLayoutDir( com::sun::star::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
280           // <--
281           // --> OD 2005-03-11 #i44334#, #i44681#
282           mbPosAttrSet( false )
283           // <--
284 	{}
285 
286 public:
287 	TYPEINFO();
288 	~SwDrawFrmFmt();
289 
290 	//DrawObjecte werden aus den Arrays am Layout entfernt. Die DrawObjecte
291 	//werden als geloescht gekennzeichnet.
292 	virtual void DelFrms();
293 
294 	//Anmelden der DrawObjecte in den Arrays am Layout. Loeschkennzeichen
295 	//werden zurueckgesetzt.
296 	virtual void MakeFrms();
297 
298 	virtual Graphic MakeGraphic( ImageMap* pMap = NULL );
299 
300     // --> OD 2004-07-27 #i31698#
301     virtual SwFrmFmt::tLayoutDir GetLayoutDir() const;
302     virtual void SetLayoutDir( const SwFrmFmt::tLayoutDir _eLayoutDir );
303     // <--
304 
305     // --> OD 2004-08-06 #i28749#
306     virtual sal_Int16 GetPositionLayoutDir() const;
307     virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
308     // <--
309 
310     // --> OD 2005-03-11 #i44334#, #i44681#
311     inline bool IsPosAttrSet() const { return mbPosAttrSet; }
312     inline void PosAttrSet() { mbPosAttrSet = true; }
313     // <--
314 
315     // --> OD 2005-08-16 #i53320#
316     inline void ResetPosAttr()
317     {
318         mbPosAttrSet = false;
319     }
320     // <--
321 
322     virtual String GetDescription() const;
323 
324     DECL_FIXEDMEMPOOL_NEWDEL(SwDrawFrmFmt);
325 };
326 
327 
328 #endif
329 
330