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