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