xref: /trunk/main/sw/source/core/inc/flyfrm.hxx (revision 91100364)
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 
Lock()126 	void Lock()			{ bLocked = sal_True; }
Unlock()127 	void Unlock()		{ bLocked = sal_False; }
128 
SetMinHeight()129 	void SetMinHeight()	 { bMinHeight = sal_True; }
ResetMinHeight()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 //Bug 120881:Modify here for Directly Page Numbering
154 	sal_Bool IsPageNumberingFrm();
155 //Bug 120881(End)
156     // OD 2004-03-23 #i26791#
157     TYPEINFO();
158 
159 	virtual ~SwFlyFrm();
160 		// erfrage vom Client Informationen
161 	virtual sal_Bool GetInfo( SfxPoolItem& ) const;
162     virtual void Paint( SwRect const&,
163                         SwPrintData const*const pPrintData = NULL ) const;
164 	virtual Size ChgSize( const Size& aNewSize );
165 	virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
166                               SwCrsrMoveState* = 0 ) const;
167 
168     virtual void  CheckDirection( sal_Bool bVert );
169 	virtual void Cut();
170 #ifdef DBG_UTIL
171 	virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
172 #endif
173 
174     SwTwips _Shrink( SwTwips, sal_Bool bTst );
175     SwTwips _Grow  ( SwTwips, sal_Bool bTst );
176 	void 	_Invalidate( SwPageFrm *pPage = 0 );
177 
178 	sal_Bool FrmSizeChg( const SwFmtFrmSize & );
179 
GetPrevLink() const180 	SwFlyFrm *GetPrevLink() const { return pPrevLink; }
GetNextLink() const181 	SwFlyFrm *GetNextLink() const { return pNextLink; }
182 
183 	static void	ChainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow );
184 	static void UnchainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow );
185 
186 	SwFlyFrm *FindChainNeighbour( SwFrmFmt &rFmt, SwFrm *pAnch = 0 );
187 
188     // OD 2004-03-24 #i26791#
189     const SwVirtFlyDrawObj* GetVirtDrawObj() const;
190     SwVirtFlyDrawObj *GetVirtDrawObj();
191     void NotifyDrawObj();
192 
193 	void ChgRelPos( const Point &rAbsPos );
IsInvalid() const194     sal_Bool IsInvalid() const { return bInvalid; }
Invalidate() const195 	void Invalidate() const { ((SwFlyFrm*)this)->bInvalid = sal_True; }
Validate() const196 	void Validate() const { ((SwFlyFrm*)this)->bInvalid = sal_False; }
197 
IsMinHeight() const198 	sal_Bool IsMinHeight()	const { return bMinHeight; }
IsLocked() const199 	sal_Bool IsLocked()		const { return bLocked; }
IsAutoPos() const200 	sal_Bool IsAutoPos()	const { return bAutoPosition; }
IsFlyInCntFrm() const201 	sal_Bool IsFlyInCntFrm() const { return bInCnt; }
IsFlyFreeFrm() const202 	sal_Bool IsFlyFreeFrm() const { return bAtCnt || bLayout; }
IsFlyLayFrm() const203 	sal_Bool IsFlyLayFrm() const { return bLayout; }
IsFlyAtCntFrm() const204 	sal_Bool IsFlyAtCntFrm() const { return bAtCnt; }
205 
IsNotifyBack() const206 	sal_Bool IsNotifyBack()	const { return bNotifyBack; }
SetNotifyBack()207 	void SetNotifyBack()	  { bNotifyBack = sal_True; }
ResetNotifyBack()208 	void ResetNotifyBack()	  { bNotifyBack = sal_False; }
IsNoShrink() const209     sal_Bool IsNoShrink()   const { return bNoShrink; }
SetNoShrink(sal_Bool bNew)210     void SetNoShrink( sal_Bool bNew ) { bNoShrink = bNew; }
IsLockDeleteContent() const211     sal_Bool IsLockDeleteContent()  const { return bLockDeleteContent; }
SetLockDeleteContent(sal_Bool bNew)212     void SetLockDeleteContent( sal_Bool bNew ) { bLockDeleteContent = bNew; }
213 
214 
IsClipped() const215 	sal_Bool IsClipped()		const	{ return bHeightClipped || bWidthClipped; }
IsHeightClipped() const216 	sal_Bool IsHeightClipped()	const	{ return bHeightClipped; }
IsWidthClipped() const217 	sal_Bool IsWidthClipped()	const	{ return bWidthClipped;  }
218 
219     sal_Bool IsLowerOf( const SwLayoutFrm* pUpper ) const;
IsUpperOf(const SwFlyFrm & _rLower) const220     inline sal_Bool IsUpperOf( const SwFlyFrm& _rLower ) const
221     {
222         return _rLower.IsLowerOf( this );
223     }
224 
225     SwFrm *FindLastLower();
226 
227     // OD 16.04.2003 #i13147# - add parameter <_bForPaint> to avoid load of
228     // the graphic during paint. Default value: sal_False
229     sal_Bool GetContour( PolyPolygon&   rContour,
230                      const sal_Bool _bForPaint = sal_False ) const;
231 
232 
233 	//Auf dieser Shell painten (PreView, Print-Flag usw. rekursiv beachten)?.
234 	static sal_Bool IsPaint( SdrObject *pObj, const ViewShell *pSh );
235 
236     /** SwFlyFrm::IsBackgroundTransparent - for feature #99657#
237 
238         OD 12.08.2002
239         determines, if background of fly frame has to be drawn transparent
240         definition found in /core/layout/paintfrm.cxx
241 
242         @author OD
243 
244         @return true, if background color is transparent or a existing background
245         graphic is transparent.
246     */
247     sal_Bool IsBackgroundTransparent() const;
248 
249     /** SwFlyFrm::IsShadowTransparent - for feature #99657#
250 
251         OD 05.08.2002
252         determine, if shadow color of fly frame has to be drawn transparent
253         definition found in /core/layout/paintfrm.cxx
254 
255         @author OD
256 
257         @return true, if shadow color is transparent.
258     */
259     sal_Bool IsShadowTransparent() const;
260 
261     // OD 2004-01-19 #110582#
262     void Chain( SwFrm* _pAnchor );
263     void Unchain();
264     void InsertCnt();
265     void DeleteCnt();
266     // OD 2004-02-12 #110582#-2
267     void InsertColumns();
268 
269     // OD 2004-03-23 #i26791# - pure virtual methods of base class <SwAnchoredObject>
270     virtual void MakeObjPos();
271     virtual void InvalidateObjPos();
272 
273     virtual SwFrmFmt& GetFrmFmt();
274     virtual const SwFrmFmt& GetFrmFmt() const;
275 
276     virtual const SwRect GetObjRect() const;
277 
278     /** method to determine, if a format on the Writer fly frame is possible
279 
280         OD 2004-05-11 #i28701#
281         refine 'IsFormatPossible'-conditions of method
282         <SwAnchoredObject::IsFormatPossible()> by:
283         format isn't possible, if Writer fly frame is locked resp. col-locked.
284 
285         @author OD
286     */
287     virtual bool IsFormatPossible() const;
288     static void GetAnchoredObjects( std::list<SwAnchoredObject*>&, const SwFmt& rFmt );
289 
290     // overwriting "SwFrmFmt *SwLayoutFrm::GetFmt" to provide the correct derived return type.
291     // (This is in order to skip on the otherwise necessary casting of the result to
292     // 'SwFlyFrmFmt *' after calls to this function. The casting is now done in this function.)
293     virtual const SwFlyFrmFmt *GetFmt() const;
294     virtual       SwFlyFrmFmt *GetFmt();
295 };
296 #endif
297