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