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