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