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