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