xref: /aoo42x/main/sw/source/core/inc/flyfrm.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef SW_FLYFRM_HXX
28 #define SW_FLYFRM_HXX
29 
30 #include "layfrm.hxx"
31 #include <list>
32 #include "frmfmt.hxx"
33 
34 class SwPageFrm;
35 class SwFmtFrmSize;
36 struct SwCrsrMoveState;
37 class SwBorderAttrs;
38 class SwVirtFlyDrawObj;
39 class SwSpzFrmFmts;
40 class SwAttrSetChg;
41 class PolyPolygon;
42 class SwFlyDrawContact;
43 class SwDrawContact;
44 class SwFmt;
45 
46 #include <anchoredobject.hxx>
47 
48 //Sucht ausgehend von pOldAnch einen Anker fuer Absatzgebundene Rahmen.
49 //Wird beim Draggen von Absatzgebundenen Objekten zur Ankeranzeige sowie
50 //fuer Ankerwechsel benoetigt.
51 //implementiert in layout/flycnt.cxx
52 const SwCntntFrm *FindAnchor( const SwFrm *pOldAnch, const Point &rNew,
53 							  const sal_Bool bBody = sal_False );
54 
55 // berechnet das Rechteck, in dem das Objekt bewegt bzw. resized werden darf
56 sal_Bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, sal_Bool bMove = sal_True );
57 
58 //allg. Basisklasse fuer alle Freifliegenden Rahmen
59 // OD 2004-03-22 #i26791# - inherit also from <SwAnchoredFlyFrm>
60 class SwFlyFrm : public SwLayoutFrm, public SwAnchoredObject
61 {
62 	//darf Locken. Definiert in frmtool.cxx
63 	friend void AppendObjs   ( const SwSpzFrmFmts *, sal_uLong, SwFrm *, SwPageFrm * );
64     friend void Notify( SwFlyFrm *, SwPageFrm *pOld, const SwRect &rOld,
65                         const SwRect* pOldPrt );
66 
67 	void InitDrawObj( sal_Bool bNotify );	//Wird von den CToren gerufen.
68 	void FinitDrawObj();				//Wird vom CTor gerufen.
69 
70 	void _UpdateAttr( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
71 					  SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 );
72 
73     using SwLayoutFrm::CalcRel;
74 
75     sal_uInt32 _GetOrdNumForNewRef( const SwFlyDrawContact* );
76     SwVirtFlyDrawObj* CreateNewRef( SwFlyDrawContact* );
77 
78 protected:
79 
80 	SwFlyFrm *pPrevLink,        // Vorgaenger/Nachfolger fuer Verkettung mit
81 			 *pNextLink;		// Textfluss
82 
83     // OD 2004-05-27 #i26791# - moved to <SwAnchoredObject>
84 //    Point aRelPos;   //Die Relative Position zum Master
85 
86 private:
87 	sal_Bool bLocked	:1;	//Cntnt-gebundene Flys muessen derart blockiert werden
88 						//koennen, dass sie nicht Formatiert werden; :MakeAll
89 						//returnt dann sofort. Dies ist bei Seitenwechseln
90 						//waehrend der Formatierung notwendig.
91 						//Auch wahrend des RootCTors ist dies notwendig da
92 						//sonst der Anker formatiert wird obwohl die Root noch
93 						//nicht korrekt an der Shell haengt und weil sonst
94 						//initial zuviel Formatiert wuerde.
95 	sal_Bool bNotifyBack:1;	//sal_True wenn am Ende eines MakeAll() der Background
96 						//vom NotifyDTor benachrichtigt werden muss.
97 protected:
98 
99 	sal_Bool bInvalid :1; 	//Pos, PrtArea od. SSize wurden Invalidiert, sie werden
100 						//gleich wieder Validiert, denn sie muessen _immer_
101 						//gueltig sein. Damit in LayAction korrekt gearbeitet
102 						//werden kann muss hier festgehalten werden, dass sie
103 						//invalidiert wurden. Ausnahmen bestaetigen die Regelt!
104 	sal_Bool bMinHeight:1;	//sal_True wenn die vom Attribut vorgegebene Hoehe eine
105 						//eine Minimalhoehe ist (der Frm also bei Bedarf
106 						//darueberhinaus wachsen kann).
107 	sal_Bool bHeightClipped	:1; //sal_True wenn der Fly nicht die Pos/Size anhand der Attrs
108 	sal_Bool bWidthClipped	:1;	//formatieren konnte, weil z.B. nicht genug Raum vorh.
109 							//war.
110 	sal_Bool bFormatHeightOnly	:1; //Damit nach einer Anpassung der Breite
111 								//(CheckClip) nur das Format aufgerufen wird;
112 								//nicht aber die Breite anhand der Attribute
113 								//wieder bestimmt wird.
114     sal_Bool bInCnt         :1; // FLY_AS_CHAR, anchored as character
115     sal_Bool bAtCnt         :1; // FLY_AT_PARA, anchored at paragraph
116     sal_Bool bLayout        :1; // FLY_AT_PAGE, FLY_AT_FLY, at page or at frame
117     sal_Bool bAutoPosition  :1; // FLY_AT_CHAR, anchored at character
118     sal_Bool bNoShrink      :1; // temporary forbud of shrinking to avoid loops
119     sal_Bool bLockDeleteContent :1;           // If the flag is set, the content of the
120                                         // fly frame is not deleted if moved to
121                                         // invisible layer.
122 
123 	friend class SwNoTxtFrm; // Darf NotifyBackground rufen
124 //    virtual void NotifyBackground( SwPageFrm *pPage,
125 //                                   const SwRect& rRect, PrepareHint eHint) = 0;
126 
127 	virtual void Format( const SwBorderAttrs *pAttrs = 0 );
128 	void MakePrtArea( const SwBorderAttrs &rAttrs );
129 
130 	void Lock()			{ bLocked = sal_True; }
131 	void Unlock()		{ bLocked = sal_False; }
132 
133 	void SetMinHeight()	 { bMinHeight = sal_True; }
134 	void ResetMinHeight(){ bMinHeight = sal_False; }
135 
136     Size CalcRel( const SwFmtFrmSize &rSz ) const;
137     SwTwips CalcAutoWidth() const;
138 
139 	SwFlyFrm( SwFlyFrmFmt*, SwFrm*, SwFrm *pAnchor );
140 
141     /** method to assure that anchored object is registered at the correct
142         page frame
143 
144         OD 2004-07-02 #i28701#
145 
146         @author OD
147     */
148     virtual void RegisterAtCorrectPage();
149 
150     virtual bool _SetObjTop( const SwTwips _nTop );
151     virtual bool _SetObjLeft( const SwTwips _nLeft );
152 
153     virtual const SwRect GetObjBoundRect() const;
154 	virtual	void Modify( const SfxPoolItem*, const SfxPoolItem* );
155 
156 public:
157     // OD 2004-03-23 #i26791#
158     TYPEINFO();
159 
160 	virtual ~SwFlyFrm();
161 		// erfrage vom Client Informationen
162 	virtual sal_Bool GetInfo( SfxPoolItem& ) const;
163     virtual void Paint( SwRect const&,
164                         SwPrintData const*const pPrintData = NULL ) const;
165 	virtual Size ChgSize( const Size& aNewSize );
166 	virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
167                               SwCrsrMoveState* = 0 ) const;
168 
169     virtual void  CheckDirection( sal_Bool bVert );
170 	virtual void Cut();
171 #ifdef DBG_UTIL
172 	virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
173 #endif
174 
175     SwTwips _Shrink( SwTwips, sal_Bool bTst );
176     SwTwips _Grow  ( SwTwips, sal_Bool bTst );
177 	void 	_Invalidate( SwPageFrm *pPage = 0 );
178 
179 	sal_Bool FrmSizeChg( const SwFmtFrmSize & );
180 
181 	SwFlyFrm *GetPrevLink() const { return pPrevLink; }
182 	SwFlyFrm *GetNextLink() const { return pNextLink; }
183 
184 	static void	ChainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow );
185 	static void UnchainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow );
186 
187 	SwFlyFrm *FindChainNeighbour( SwFrmFmt &rFmt, SwFrm *pAnch = 0 );
188 
189     // OD 2004-03-24 #i26791#
190     const SwVirtFlyDrawObj* GetVirtDrawObj() const;
191     SwVirtFlyDrawObj *GetVirtDrawObj();
192     void NotifyDrawObj();
193 
194 	void ChgRelPos( const Point &rAbsPos );
195     sal_Bool IsInvalid() const { return bInvalid; }
196 	void Invalidate() const { ((SwFlyFrm*)this)->bInvalid = sal_True; }
197 	void Validate() const { ((SwFlyFrm*)this)->bInvalid = sal_False; }
198 
199 	sal_Bool IsMinHeight()	const { return bMinHeight; }
200 	sal_Bool IsLocked()		const { return bLocked; }
201 	sal_Bool IsAutoPos()	const { return bAutoPosition; }
202 	sal_Bool IsFlyInCntFrm() const { return bInCnt; }
203 	sal_Bool IsFlyFreeFrm() const { return bAtCnt || bLayout; }
204 	sal_Bool IsFlyLayFrm() const { return bLayout; }
205 	sal_Bool IsFlyAtCntFrm() const { return bAtCnt; }
206 
207 	sal_Bool IsNotifyBack()	const { return bNotifyBack; }
208 	void SetNotifyBack()	  { bNotifyBack = sal_True; }
209 	void ResetNotifyBack()	  { bNotifyBack = sal_False; }
210     sal_Bool IsNoShrink()   const { return bNoShrink; }
211     void SetNoShrink( sal_Bool bNew ) { bNoShrink = bNew; }
212     sal_Bool IsLockDeleteContent()  const { return bLockDeleteContent; }
213     void SetLockDeleteContent( sal_Bool bNew ) { bLockDeleteContent = bNew; }
214 
215 
216 	sal_Bool IsClipped()		const	{ return bHeightClipped || bWidthClipped; }
217 	sal_Bool IsHeightClipped()	const	{ return bHeightClipped; }
218 	sal_Bool IsWidthClipped()	const	{ return bWidthClipped;  }
219 
220     sal_Bool IsLowerOf( const SwLayoutFrm* pUpper ) const;
221     inline sal_Bool IsUpperOf( const SwFlyFrm& _rLower ) const
222     {
223         return _rLower.IsLowerOf( this );
224     }
225 
226     SwFrm *FindLastLower();
227 
228     // OD 16.04.2003 #i13147# - add parameter <_bForPaint> to avoid load of
229     // the graphic during paint. Default value: sal_False
230     sal_Bool GetContour( PolyPolygon&   rContour,
231                      const sal_Bool _bForPaint = sal_False ) const;
232 
233 
234 	//Auf dieser Shell painten (PreView, Print-Flag usw. rekursiv beachten)?.
235 	static sal_Bool IsPaint( SdrObject *pObj, const ViewShell *pSh );
236 
237     /** SwFlyFrm::IsBackgroundTransparent - for feature #99657#
238 
239         OD 12.08.2002
240         determines, if background of fly frame has to be drawn transparent
241         definition found in /core/layout/paintfrm.cxx
242 
243         @author OD
244 
245         @return true, if background color is transparent or a existing background
246         graphic is transparent.
247     */
248     sal_Bool IsBackgroundTransparent() const;
249 
250     /** SwFlyFrm::IsShadowTransparent - for feature #99657#
251 
252         OD 05.08.2002
253         determine, if shadow color of fly frame has to be drawn transparent
254         definition found in /core/layout/paintfrm.cxx
255 
256         @author OD
257 
258         @return true, if shadow color is transparent.
259     */
260     sal_Bool IsShadowTransparent() const;
261 
262     // OD 2004-01-19 #110582#
263     void Chain( SwFrm* _pAnchor );
264     void Unchain();
265     void InsertCnt();
266     void DeleteCnt();
267     // OD 2004-02-12 #110582#-2
268     void InsertColumns();
269 
270     // OD 2004-03-23 #i26791# - pure virtual methods of base class <SwAnchoredObject>
271     virtual void MakeObjPos();
272     virtual void InvalidateObjPos();
273 
274     virtual SwFrmFmt& GetFrmFmt();
275     virtual const SwFrmFmt& GetFrmFmt() const;
276 
277     virtual const SwRect GetObjRect() const;
278 
279     /** method to determine, if a format on the Writer fly frame is possible
280 
281         OD 2004-05-11 #i28701#
282         refine 'IsFormatPossible'-conditions of method
283         <SwAnchoredObject::IsFormatPossible()> by:
284         format isn't possible, if Writer fly frame is locked resp. col-locked.
285 
286         @author OD
287     */
288     virtual bool IsFormatPossible() const;
289     static void GetAnchoredObjects( std::list<SwAnchoredObject*>&, const SwFmt& rFmt );
290 
291     // overwriting "SwFrmFmt *SwLayoutFrm::GetFmt" to provide the correct derived return type.
292     // (This is in order to skip on the otherwise necessary casting of the result to
293     // 'SwFlyFrmFmt *' after calls to this function. The casting is now done in this function.)
294     virtual const SwFlyFrmFmt *GetFmt() const;
295     virtual       SwFlyFrmFmt *GetFmt();
296 };
297 #endif
298