xref: /aoo42x/main/sw/source/core/inc/frmtool.hxx (revision 56b35d86)
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
101d2dbeb0SAndrew Rist  *
111d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
121d2dbeb0SAndrew Rist  *
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.
191d2dbeb0SAndrew Rist  *
201d2dbeb0SAndrew Rist  *************************************************************/
211d2dbeb0SAndrew Rist 
221d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _FRMTOOL_HXX
24cdf0e10cSrcweir #define _FRMTOOL_HXX
25cdf0e10cSrcweir #include "swtypes.hxx"
26cdf0e10cSrcweir #include "layfrm.hxx"
27cdf0e10cSrcweir #include "frmatr.hxx"
28cdf0e10cSrcweir #include "swcache.hxx"
29cdf0e10cSrcweir // --> OD 2008-12-04 #i96772#
30cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
31cdf0e10cSrcweir // <--
32cdf0e10cSrcweir 
33cdf0e10cSrcweir class SwPageFrm;
34cdf0e10cSrcweir class SwFlyFrm;
35cdf0e10cSrcweir class SwCntntFrm;
36cdf0e10cSrcweir class SwRootFrm;
37cdf0e10cSrcweir class SwDoc;
38cdf0e10cSrcweir class SwAttrSet;
39cdf0e10cSrcweir class SdrObject;
40cdf0e10cSrcweir class BigInt;
41cdf0e10cSrcweir class SvxBrushItem;
42cdf0e10cSrcweir class SdrMarkList;
43cdf0e10cSrcweir class SwNodeIndex;
44cdf0e10cSrcweir class OutputDevice;
45cdf0e10cSrcweir class SwPageDesc;
46cdf0e10cSrcweir class SwTableBox;
47cdf0e10cSrcweir struct SwFindRowSpanCacheObj;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #if defined(MSC)
50cdf0e10cSrcweir #define MA_FASTCALL __fastcall
51cdf0e10cSrcweir #else
52cdf0e10cSrcweir #define MA_FASTCALL
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #define WEIT_WECH 		LONG_MAX - 20000		//Initale Position der Flys.
56cdf0e10cSrcweir #define BROWSE_HEIGHT   56700L * 10L               //10 Meter
57cdf0e10cSrcweir //#define BROWSE_HEIGHT   1440L * 45L     // 45 inch, maximum size for pdf files
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #define GRFNUM_NO 0
60cdf0e10cSrcweir #define GRFNUM_YES 1
61cdf0e10cSrcweir #define GRFNUM_REPLACE 2
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //Painten des Hintergrunds. Mit Brush oder Graphic.
64cdf0e10cSrcweir // OD 05.08.2002 #99657# - add 6th parameter to indicate that method should
65cdf0e10cSrcweir //     consider background transparency, saved in the color of the brush item
6664b14621SArmin Le Grand void MA_FASTCALL DrawGraphic(
6764b14621SArmin Le Grand     const SvxBrushItem *,
6864b14621SArmin Le Grand     OutputDevice *,
6964b14621SArmin Le Grand     const SwRect &rOrg,
7064b14621SArmin Le Grand     const SwRect &rOut,
7164b14621SArmin Le Grand     const sal_uInt8 nGrfNum = GRFNUM_NO,
7264b14621SArmin Le Grand     const sal_Bool bConsiderBackgroundTransparency = sal_False );
7364b14621SArmin Le Grand bool MA_FASTCALL DrawFillAttributes(
74*56b35d86SArmin Le Grand     const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes,
7564b14621SArmin Le Grand     const SwRect& rOriginalLayoutRect,
7664b14621SArmin Le Grand     const SwRect& rPaintRect,
7764b14621SArmin Le Grand     OutputDevice& rOut);
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // OD 24.01.2003 #106593# - method to align rectangle
80cdf0e10cSrcweir // Created declaration here to avoid <extern> declarations
81cdf0e10cSrcweir void MA_FASTCALL SwAlignRect( SwRect &rRect, ViewShell *pSh );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir // OD 24.01.2003 #106593# - method to align graphic rectangle
84cdf0e10cSrcweir // Created declaration here to avoid <extern> declarations
85cdf0e10cSrcweir void SwAlignGrfRect( SwRect *pGrfRect, const OutputDevice &rOut );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir //Fly besorgen, wenn keine List hineingereicht wird, wir die der aktuellen
88cdf0e10cSrcweir //Shell benutzt.
89cdf0e10cSrcweir //Implementierung in feshview.cxx
90cdf0e10cSrcweir SwFlyFrm *GetFlyFromMarked( const SdrMarkList *pLst, ViewShell *pSh );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir //Nicht gleich die math.lib anziehen.
93cdf0e10cSrcweir sal_uLong MA_FASTCALL SqRt( BigInt nX );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir SwFrm *SaveCntnt( SwLayoutFrm *pLay, SwFrm *pStart );
96cdf0e10cSrcweir void RestoreCntnt( SwFrm *pSav, SwLayoutFrm *pParent, SwFrm *pSibling, bool bGrow );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir //CntntNodes besorgen, CntntFrms erzeugen und in den LayFrm haengen.
99cdf0e10cSrcweir void MA_FASTCALL _InsertCnt( SwLayoutFrm *pLay, SwDoc *pDoc, sal_uLong nIndex,
100cdf0e10cSrcweir 				 sal_Bool bPages = sal_False, sal_uLong nEndIndex = 0,
101cdf0e10cSrcweir 				 SwFrm *pPrv = 0 );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir //Erzeugen der Frames fuer einen bestimmten Bereich, verwendet _InsertCnt
104cdf0e10cSrcweir void MakeFrms( SwDoc *pDoc, const SwNodeIndex &rSttIdx,
105cdf0e10cSrcweir 							const SwNodeIndex &rEndIdx );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //Um z.B. fuer Tabelleheadlines das Erzeugen der Flys in _InsertCnt zu unterbinden.
108cdf0e10cSrcweir extern sal_Bool bDontCreateObjects;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir //Fuer FlyCnts, siehe SwFlyAtCntFrm::MakeAll()
111cdf0e10cSrcweir extern sal_Bool bSetCompletePaintOnInvalidate;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir //Fuer Tabelleneinstellung per Tastatur.
114cdf0e10cSrcweir long MA_FASTCALL CalcRowRstHeight( SwLayoutFrm *pRow );
115cdf0e10cSrcweir long MA_FASTCALL CalcHeightWidthFlys( const SwFrm *pFrm ); 	//MA_FLY_HEIGHT
116cdf0e10cSrcweir 
117cdf0e10cSrcweir //Neue Seite einsetzen
118cdf0e10cSrcweir SwPageFrm * MA_FASTCALL InsertNewPage( SwPageDesc &rDesc, SwFrm *pUpper,
119cdf0e10cSrcweir 						  sal_Bool bOdd, sal_Bool bInsertEmpty, sal_Bool bFtn,
120cdf0e10cSrcweir 						  SwFrm *pSibling );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir //Flys bei der Seite anmelden.
123cdf0e10cSrcweir void RegistFlys( SwPageFrm*, const SwLayoutFrm* );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir //Benachrichtung des Fly Hintergrundes wenn Notwendig.
126cdf0e10cSrcweir void Notify( SwFlyFrm *pFly, SwPageFrm *pOld, const SwRect &rOld,
127cdf0e10cSrcweir              const SwRect* pOldRect = 0 );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir void Notify_Background( const SdrObject* pObj,
130cdf0e10cSrcweir                         SwPageFrm* pPage,
131cdf0e10cSrcweir                         const SwRect& rRect,
132cdf0e10cSrcweir                         const PrepareHint eHint,
133cdf0e10cSrcweir                         const sal_Bool bInva );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir const SwFrm* GetVirtualUpper( const SwFrm* pFrm, const Point& rPos );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir sal_Bool Is_Lower_Of( const SwFrm *pCurrFrm, const SdrObject* pObj );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir const SwFrm *FindKontext( const SwFrm *pFrm, sal_uInt16 nAdditionalKontextTyp );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir sal_Bool IsFrmInSameKontext( const SwFrm *pInnerFrm, const SwFrm *pFrm );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir const SwFrm * MA_FASTCALL FindPage( const SwRect &rRect, const SwFrm *pPage );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir // JP 07.05.98: wird von SwCntntNode::GetFrm und von SwFlyFrm::GetFrm
146cdf0e10cSrcweir //				gerufen
147cdf0e10cSrcweir SwFrm* GetFrmOfModify( const SwRootFrm* pLayout, SwModify const&, sal_uInt16 const nFrmType, const Point* = 0,
148cdf0e10cSrcweir 						const SwPosition *pPos = 0,
149cdf0e10cSrcweir 						const sal_Bool bCalcFrm = sal_False );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir //Sollen ExtraDaten (Reline-Strich, Zeilennummern) gepaintet werden?
152cdf0e10cSrcweir sal_Bool IsExtraData( const SwDoc *pDoc );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir // OD 14.03.2003 #i11760# - method declaration <CalcCntnt(..)>
155cdf0e10cSrcweir void CalcCntnt( SwLayoutFrm *pLay,
156cdf0e10cSrcweir                 bool bNoColl = false,
157cdf0e10cSrcweir                 bool bNoCalcFollow = false );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 
160cdf0e10cSrcweir //Die Notify-Klassen merken sich im CTor die aktuellen Groessen und fuehren
161cdf0e10cSrcweir //im DTor ggf. die notwendigen Benachrichtigungen durch.
162cdf0e10cSrcweir 
163cdf0e10cSrcweir class SwFrmNotify
164cdf0e10cSrcweir {
165cdf0e10cSrcweir protected:
166cdf0e10cSrcweir 	SwFrm *pFrm;
167cdf0e10cSrcweir 	const SwRect aFrm;
168cdf0e10cSrcweir 	const SwRect aPrt;
169cdf0e10cSrcweir     SwTwips mnFlyAnchorOfst;
170cdf0e10cSrcweir     SwTwips mnFlyAnchorOfstNoWrap;
171cdf0e10cSrcweir 	sal_Bool     bHadFollow;
172cdf0e10cSrcweir 	sal_Bool	 bInvaKeep;
173cdf0e10cSrcweir 	sal_Bool	 bValidSize;
174cdf0e10cSrcweir protected:
175cdf0e10cSrcweir     // --> OD 2005-07-29 #i49383#
176cdf0e10cSrcweir     bool mbFrmDeleted;
177cdf0e10cSrcweir     // <--
178cdf0e10cSrcweir 
179cdf0e10cSrcweir public:
180cdf0e10cSrcweir 	SwFrmNotify( SwFrm *pFrm );
181cdf0e10cSrcweir 	~SwFrmNotify();
182cdf0e10cSrcweir 
Frm() const183cdf0e10cSrcweir 	const SwRect &Frm() const { return aFrm; }
Prt() const184cdf0e10cSrcweir 	const SwRect &Prt() const { return aPrt; }
SetInvaKeep()185cdf0e10cSrcweir 	void SetInvaKeep() { bInvaKeep = sal_True; }
186cdf0e10cSrcweir     // --> OD 2005-07-29 #i49383#
FrmDeleted()187cdf0e10cSrcweir     void FrmDeleted()
188cdf0e10cSrcweir     {
189cdf0e10cSrcweir         mbFrmDeleted = true;
190cdf0e10cSrcweir     }
191cdf0e10cSrcweir     // <--
192cdf0e10cSrcweir };
193cdf0e10cSrcweir 
194cdf0e10cSrcweir class SwLayNotify : public SwFrmNotify
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     sal_Bool bLowersComplete;
197cdf0e10cSrcweir 
GetLay()198cdf0e10cSrcweir 	SwLayoutFrm *GetLay() { return (SwLayoutFrm*)pFrm; }
199cdf0e10cSrcweir public:
200cdf0e10cSrcweir 	SwLayNotify( SwLayoutFrm *pLayFrm );
201cdf0e10cSrcweir 	~SwLayNotify();
202cdf0e10cSrcweir 
SetLowersComplete(sal_Bool b)203cdf0e10cSrcweir     void SetLowersComplete( sal_Bool b ) { bLowersComplete = b; }
IsLowersComplete()204cdf0e10cSrcweir 	sal_Bool IsLowersComplete() 		 { return bLowersComplete; }
205cdf0e10cSrcweir };
206cdf0e10cSrcweir 
207cdf0e10cSrcweir class SwFlyNotify : public SwLayNotify
208cdf0e10cSrcweir {
209cdf0e10cSrcweir 	SwPageFrm *pOldPage;
210cdf0e10cSrcweir 	const SwRect aFrmAndSpace;
GetFly()211cdf0e10cSrcweir 	SwFlyFrm *GetFly() { return (SwFlyFrm*)pFrm; }
212cdf0e10cSrcweir public:
213cdf0e10cSrcweir 	SwFlyNotify( SwFlyFrm *pFlyFrm );
214cdf0e10cSrcweir 	~SwFlyNotify();
215cdf0e10cSrcweir 
GetOldPage() const216cdf0e10cSrcweir 	SwPageFrm *GetOldPage() const { return pOldPage; }
217cdf0e10cSrcweir };
218cdf0e10cSrcweir 
219cdf0e10cSrcweir class SwCntntNotify : public SwFrmNotify
220cdf0e10cSrcweir {
221cdf0e10cSrcweir private:
222cdf0e10cSrcweir     // OD 08.01.2004 #i11859#
223cdf0e10cSrcweir     bool    mbChkHeightOfLastLine;
224cdf0e10cSrcweir     SwTwips mnHeightOfLastLine;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     // OD 2004-02-26 #i25029#
227cdf0e10cSrcweir     bool        mbInvalidatePrevPrtArea;
228cdf0e10cSrcweir     bool        mbBordersJoinedWithPrev;
229cdf0e10cSrcweir 
GetCnt()230cdf0e10cSrcweir 	SwCntntFrm *GetCnt() { return (SwCntntFrm*)pFrm; }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir public:
233cdf0e10cSrcweir 	SwCntntNotify( SwCntntFrm *pCntFrm );
234cdf0e10cSrcweir 	~SwCntntNotify();
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     // OD 2004-02-26 #i25029#
SetInvalidatePrevPrtArea()237cdf0e10cSrcweir     void SetInvalidatePrevPrtArea()
238cdf0e10cSrcweir     {
239cdf0e10cSrcweir         mbInvalidatePrevPrtArea = true;
240cdf0e10cSrcweir     }
241cdf0e10cSrcweir 
SetBordersJoinedWithPrev()242cdf0e10cSrcweir     void SetBordersJoinedWithPrev()
243cdf0e10cSrcweir     {
244cdf0e10cSrcweir         mbBordersJoinedWithPrev = true;
245cdf0e10cSrcweir     }
246cdf0e10cSrcweir };
247cdf0e10cSrcweir 
248cdf0e10cSrcweir //SwBorderAttrs kapselt die Berechnung fuer die Randattribute inclusive
249cdf0e10cSrcweir //Umrandung. Die Attribute und die errechneten Werte werden gecached.
250cdf0e10cSrcweir //Neu: Die gesammte Klasse wird gecached.
251cdf0e10cSrcweir 
252cdf0e10cSrcweir //!!!Achtung: Wenn weitere Attribute gecached werden muss unbedingt die
253cdf0e10cSrcweir //Methode Modify::Modify mitgepflegt werden!!!
254cdf0e10cSrcweir 
255cdf0e10cSrcweir // OD 23.01.2003 #106895# - delete old method <SwBorderAttrs::CalcRight()> and
256cdf0e10cSrcweir // the stuff that belongs to it.
257cdf0e10cSrcweir class SwBorderAttrs : public SwCacheObj
258cdf0e10cSrcweir {
259cdf0e10cSrcweir 	const SwAttrSet		 &rAttrSet;
260cdf0e10cSrcweir 	const SvxULSpaceItem &rUL;
261cdf0e10cSrcweir     // --> OD 2008-12-04 #i96772#
262cdf0e10cSrcweir     SvxLRSpaceItem rLR;
263cdf0e10cSrcweir     // <--
264cdf0e10cSrcweir 	const SvxBoxItem	 &rBox;
265cdf0e10cSrcweir 	const SvxShadowItem  &rShadow;
266cdf0e10cSrcweir 	const Size			  aFrmSize;		//Die FrmSize
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 	sal_Bool bBorderDist	:1;				//Ist's ein Frm der auch ohne Linie
269cdf0e10cSrcweir 										//einen Abstand haben kann?
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 	//Mit den Folgenden Bools werden die gecache'ten Werte fuer UNgueltig
272cdf0e10cSrcweir 	//erklaert - bis sie einmal berechnet wurden.
273cdf0e10cSrcweir 	sal_Bool bTopLine		:1;
274cdf0e10cSrcweir 	sal_Bool bBottomLine	:1;
275cdf0e10cSrcweir 	sal_Bool bLeftLine		:1;
276cdf0e10cSrcweir 	sal_Bool bRightLine		:1;
277cdf0e10cSrcweir 	sal_Bool bTop			:1;
278cdf0e10cSrcweir 	sal_Bool bBottom		:1;
279cdf0e10cSrcweir 	sal_Bool bLine			:1;
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	sal_Bool bIsLine		:1;	//Umrandung an mind. einer Kante?
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	sal_Bool bCacheGetLine		  :1; //GetTopLine(), GetBottomLine() cachen?
284cdf0e10cSrcweir 	sal_Bool bCachedGetTopLine	  :1; //GetTopLine() gecached?
285cdf0e10cSrcweir     sal_Bool bCachedGetBottomLine :1; //GetBottomLine() gecached?
286cdf0e10cSrcweir     // OD 21.05.2003 #108789# - booleans indicating, if values <bJoinedWithPrev>
287cdf0e10cSrcweir     //          and <bJoinedWithNext> are cached and valid.
288cdf0e10cSrcweir     //          Caching depends on value of <bCacheGetLine>.
289cdf0e10cSrcweir     mutable sal_Bool bCachedJoinedWithPrev :1;
290cdf0e10cSrcweir     mutable sal_Bool bCachedJoinedWithNext :1;
291cdf0e10cSrcweir     // OD 21.05.2003 #108789# - booleans indicating, if borders are joined
292cdf0e10cSrcweir     //          with previous/next frame.
293cdf0e10cSrcweir     sal_Bool bJoinedWithPrev :1;
294cdf0e10cSrcweir     sal_Bool bJoinedWithNext :1;
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 	//Die gecache'ten Werte, undefiniert bis sie einmal berechnet wurden.
297cdf0e10cSrcweir 	sal_uInt16 nTopLine,
298cdf0e10cSrcweir 		   nBottomLine,
299cdf0e10cSrcweir 		   nLeftLine,
300cdf0e10cSrcweir 		   nRightLine,
301cdf0e10cSrcweir 		   nTop,
302cdf0e10cSrcweir 		   nBottom,
303cdf0e10cSrcweir 		   nGetTopLine,
304cdf0e10cSrcweir 		   nGetBottomLine;
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	//Nur die Lines + Shadow errechnen.
307cdf0e10cSrcweir 	void _CalcTopLine();
308cdf0e10cSrcweir 	void _CalcBottomLine();
309cdf0e10cSrcweir 	void _CalcLeftLine();
310cdf0e10cSrcweir 	void _CalcRightLine();
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 	//Lines + Shadow + Abstaende
313cdf0e10cSrcweir 	void _CalcTop();
314cdf0e10cSrcweir 	void _CalcBottom();
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 	void _IsLine();
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     // OD 2004-02-26 #i25029# - add optional 2nd parameter <_pPrevFrm>
319cdf0e10cSrcweir     // If set, its value is taken for testing, if borders/shadow have to joined
320cdf0e10cSrcweir     // with previous frame.
321cdf0e10cSrcweir     void _GetTopLine   ( const SwFrm& _rFrm,
322cdf0e10cSrcweir                          const SwFrm* _pPrevFrm = 0L );
323cdf0e10cSrcweir     void _GetBottomLine( const SwFrm& _rFrm );
324cdf0e10cSrcweir 
325cdf0e10cSrcweir     // OD 21.05.2003 #108789# - private methods to calculate cached values
326cdf0e10cSrcweir     // <bJoinedWithPrev> and <bJoinedWithNext>.
327cdf0e10cSrcweir     // OD 2004-02-26 #i25029# - add optional 2nd parameter <_pPrevFrm>
328cdf0e10cSrcweir     // If set, its value is taken for testing, if borders/shadow have to joined
329cdf0e10cSrcweir     // with previous frame.
330cdf0e10cSrcweir     void _CalcJoinedWithPrev( const SwFrm& _rFrm,
331cdf0e10cSrcweir                               const SwFrm* _pPrevFrm = 0L );
332cdf0e10cSrcweir     void _CalcJoinedWithNext( const SwFrm& _rFrm );
333cdf0e10cSrcweir 
334cdf0e10cSrcweir     // OD 21.05.2003 #108789# - internal helper method for methods
335cdf0e10cSrcweir     // <_CalcJoinedWithPrev> and <_CalcJoinedWithNext>.
336cdf0e10cSrcweir     sal_Bool _JoinWithCmp( const SwFrm& _rCallerFrm,
337cdf0e10cSrcweir                        const SwFrm& _rCmpFrm ) const;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 	 //Rechte und linke Linie sowie LRSpace gleich?
340cdf0e10cSrcweir     // OD 21.05.2003 #108789# - change name of 1st parameter - "rAttrs" -> "rCmpAttrs".
341cdf0e10cSrcweir     sal_Bool CmpLeftRight( const SwBorderAttrs &rCmpAttrs,
342cdf0e10cSrcweir                        const SwFrm *pCaller,
343cdf0e10cSrcweir 					   const SwFrm *pCmp ) const;
344cdf0e10cSrcweir 
345cdf0e10cSrcweir public:
346cdf0e10cSrcweir 	DECL_FIXEDMEMPOOL_NEWDEL(SwBorderAttrs)
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 	SwBorderAttrs( const SwModify *pOwner, const SwFrm *pConstructor );
349cdf0e10cSrcweir 	~SwBorderAttrs();
350cdf0e10cSrcweir 
GetAttrSet() const351cdf0e10cSrcweir 	inline const SwAttrSet		&GetAttrSet() const { return rAttrSet;	}
GetULSpace() const352cdf0e10cSrcweir 	inline const SvxULSpaceItem &GetULSpace() const { return rUL;		}
GetLRSpace() const353cdf0e10cSrcweir 	inline const SvxLRSpaceItem &GetLRSpace() const { return rLR;	  	}
GetBox() const354cdf0e10cSrcweir 	inline const SvxBoxItem 	&GetBox()	  const { return rBox;		}
GetShadow() const355cdf0e10cSrcweir 	inline const SvxShadowItem	&GetShadow()  const { return rShadow;	}
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 	inline sal_uInt16 CalcTopLine() const;
358cdf0e10cSrcweir 	inline sal_uInt16 CalcBottomLine() const;
359cdf0e10cSrcweir 	inline sal_uInt16 CalcLeftLine() const;
360cdf0e10cSrcweir 	inline sal_uInt16 CalcRightLine() const;
361cdf0e10cSrcweir 	inline sal_uInt16 CalcTop() const;
362cdf0e10cSrcweir 	inline sal_uInt16 CalcBottom() const;
363cdf0e10cSrcweir 		   long CalcLeft( const SwFrm *pCaller ) const;
364cdf0e10cSrcweir            long CalcRight( const SwFrm *pCaller ) const;
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 	inline sal_Bool IsLine() const;
367cdf0e10cSrcweir 
GetSize() const368cdf0e10cSrcweir 	inline const Size &GetSize()	 const { return aFrmSize; }
369cdf0e10cSrcweir 
IsBorderDist() const370cdf0e10cSrcweir 	inline sal_Bool IsBorderDist() const { return bBorderDist; }
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 	//Sollen obere bzw. untere Umrandung fuer den Frm ausgewertet werden?
373cdf0e10cSrcweir     // OD 2004-02-26 #i25029# - add optional 2nd parameter <_pPrevFrm>
374cdf0e10cSrcweir     // If set, its value is taken for testing, if borders/shadow have to joined
375cdf0e10cSrcweir     // with previous frame.
376cdf0e10cSrcweir     inline sal_uInt16 GetTopLine   ( const SwFrm& _rFrm,
377cdf0e10cSrcweir                                  const SwFrm* _pPrevFrm = 0L ) const;
378cdf0e10cSrcweir     inline sal_uInt16 GetBottomLine( const SwFrm& _rFrm ) const;
379cdf0e10cSrcweir 	inline void	  SetGetCacheLine( sal_Bool bNew ) const;
380cdf0e10cSrcweir     // OD 21.05.2003 #108789# - accessors for cached values <bJoinedWithPrev>
381cdf0e10cSrcweir     // and <bJoinedWithPrev>
382cdf0e10cSrcweir     // OD 2004-02-26 #i25029# - add optional 2nd parameter <_pPrevFrm>
383cdf0e10cSrcweir     // If set, its value is taken for testing, if borders/shadow have to joined
384cdf0e10cSrcweir     // with previous frame.
385cdf0e10cSrcweir     sal_Bool JoinedWithPrev( const SwFrm& _rFrm,
386cdf0e10cSrcweir                          const SwFrm* _pPrevFrm = 0L ) const;
387cdf0e10cSrcweir     sal_Bool JoinedWithNext( const SwFrm& _rFrm ) const;
388cdf0e10cSrcweir };
389cdf0e10cSrcweir 
390cdf0e10cSrcweir class SwBorderAttrAccess : public SwCacheAccess
391cdf0e10cSrcweir {
392cdf0e10cSrcweir 	const SwFrm *pConstructor;		//opt: Zur weitergabe an SwBorderAttrs
393cdf0e10cSrcweir protected:
394cdf0e10cSrcweir 	virtual SwCacheObj *NewObj();
395cdf0e10cSrcweir 
396cdf0e10cSrcweir public:
397cdf0e10cSrcweir 	SwBorderAttrAccess( SwCache &rCache, const SwFrm *pOwner );
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 	SwBorderAttrs *Get();
400cdf0e10cSrcweir };
401cdf0e10cSrcweir 
402cdf0e10cSrcweir //---------------------------------------------------------------------
403cdf0e10cSrcweir //Iterator fuer die DrawObjecte einer Seite. Die Objecte werden Nach ihrer
404cdf0e10cSrcweir //Z-Order iteriert.
405cdf0e10cSrcweir //Das iterieren ist nicht eben billig, denn fuer alle Operationen muss jeweils
406cdf0e10cSrcweir //ueber das gesamte SortArray iteriert werden.
407cdf0e10cSrcweir class SwOrderIter
408cdf0e10cSrcweir {
409cdf0e10cSrcweir 	const SwPageFrm *pPage;
410cdf0e10cSrcweir 	const SdrObject *pCurrent;
411cdf0e10cSrcweir 	const sal_Bool bFlysOnly;
412cdf0e10cSrcweir public:
413cdf0e10cSrcweir 	SwOrderIter( const SwPageFrm *pPage, sal_Bool bFlysOnly = sal_True );
414cdf0e10cSrcweir 
Current(const SdrObject * pNew)415cdf0e10cSrcweir 	void 			 Current( const SdrObject *pNew ) { pCurrent = pNew; }
Current() const416cdf0e10cSrcweir 	const SdrObject *Current()	  const { return pCurrent; }
operator ()() const417cdf0e10cSrcweir 	const SdrObject *operator()() const { return pCurrent; }
418cdf0e10cSrcweir 	const SdrObject *Top();
419cdf0e10cSrcweir 	const SdrObject *Bottom();
420cdf0e10cSrcweir 	const SdrObject *Next();
421cdf0e10cSrcweir 	const SdrObject *Prev();
422cdf0e10cSrcweir };
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 
425cdf0e10cSrcweir class StackHack
426cdf0e10cSrcweir {
427cdf0e10cSrcweir 	static sal_uInt8 nCnt;
428cdf0e10cSrcweir 	static sal_Bool bLocked;
429cdf0e10cSrcweir public:
StackHack()430cdf0e10cSrcweir 	StackHack()
431cdf0e10cSrcweir 	{
432cdf0e10cSrcweir 		if ( ++StackHack::nCnt > 50 )
433cdf0e10cSrcweir 			StackHack::bLocked = sal_True;
434cdf0e10cSrcweir 	}
~StackHack()435cdf0e10cSrcweir 	~StackHack()
436cdf0e10cSrcweir 	{
437cdf0e10cSrcweir         if ( --StackHack::nCnt < 5 )
438cdf0e10cSrcweir 			StackHack::bLocked = sal_False;
439cdf0e10cSrcweir 	}
440cdf0e10cSrcweir 
IsLocked()441cdf0e10cSrcweir 	static sal_Bool IsLocked()	{ return StackHack::bLocked; }
Count()442cdf0e10cSrcweir 	static sal_uInt8 Count()		{ return StackHack::nCnt; }
443cdf0e10cSrcweir };
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 
446cdf0e10cSrcweir //Sollen obere bzw. untere Umrandung fuer den Frm ausgewertet werden?
447cdf0e10cSrcweir // OD 2004-02-26 #i25029# - add optional 2nd parameter <_pPrevFrm>
448cdf0e10cSrcweir // If set, its value is taken for testing, if borders/shadow have to joined
449cdf0e10cSrcweir // with previous frame.
GetTopLine(const SwFrm & _rFrm,const SwFrm * _pPrevFrm) const450cdf0e10cSrcweir inline sal_uInt16 SwBorderAttrs::GetTopLine ( const SwFrm& _rFrm,
451cdf0e10cSrcweir                                           const SwFrm* _pPrevFrm ) const
452cdf0e10cSrcweir {
453cdf0e10cSrcweir     if ( !bCachedGetTopLine || _pPrevFrm )
454cdf0e10cSrcweir     {
455cdf0e10cSrcweir         const_cast<SwBorderAttrs*>(this)->_GetTopLine( _rFrm, _pPrevFrm );
456cdf0e10cSrcweir     }
457cdf0e10cSrcweir 	return nGetTopLine;
458cdf0e10cSrcweir }
GetBottomLine(const SwFrm & _rFrm) const459cdf0e10cSrcweir inline sal_uInt16 SwBorderAttrs::GetBottomLine( const SwFrm& _rFrm ) const
460cdf0e10cSrcweir {
461cdf0e10cSrcweir 	if ( !bCachedGetBottomLine )
462cdf0e10cSrcweir         const_cast<SwBorderAttrs*>(this)->_GetBottomLine( _rFrm );
463cdf0e10cSrcweir 	return nGetBottomLine;
464cdf0e10cSrcweir }
SetGetCacheLine(sal_Bool bNew) const465cdf0e10cSrcweir inline void	SwBorderAttrs::SetGetCacheLine( sal_Bool bNew ) const
466cdf0e10cSrcweir {
467cdf0e10cSrcweir 	((SwBorderAttrs*)this)->bCacheGetLine = bNew;
468cdf0e10cSrcweir 	((SwBorderAttrs*)this)->bCachedGetBottomLine =
469cdf0e10cSrcweir 	((SwBorderAttrs*)this)->bCachedGetTopLine = sal_False;
470cdf0e10cSrcweir     // OD 21.05.2003 #108789# - invalidate cache for values <bJoinedWithPrev>
471cdf0e10cSrcweir     // and <bJoinedWithNext>.
472cdf0e10cSrcweir     bCachedJoinedWithPrev = sal_False;
473cdf0e10cSrcweir     bCachedJoinedWithNext = sal_False;
474cdf0e10cSrcweir }
475cdf0e10cSrcweir 
CalcTopLine() const476cdf0e10cSrcweir inline sal_uInt16 SwBorderAttrs::CalcTopLine() const
477cdf0e10cSrcweir {
478cdf0e10cSrcweir 	if ( bTopLine )
479cdf0e10cSrcweir 		((SwBorderAttrs*)this)->_CalcTopLine();
480cdf0e10cSrcweir 	return nTopLine;
481cdf0e10cSrcweir }
CalcBottomLine() const482cdf0e10cSrcweir inline sal_uInt16 SwBorderAttrs::CalcBottomLine() const
483cdf0e10cSrcweir {
484cdf0e10cSrcweir 	if ( bBottomLine )
485cdf0e10cSrcweir 		((SwBorderAttrs*)this)->_CalcBottomLine();
486cdf0e10cSrcweir 	return nBottomLine;
487cdf0e10cSrcweir }
CalcLeftLine() const488cdf0e10cSrcweir inline sal_uInt16 SwBorderAttrs::CalcLeftLine() const
489cdf0e10cSrcweir {
490cdf0e10cSrcweir 	if ( bLeftLine )
491cdf0e10cSrcweir 		((SwBorderAttrs*)this)->_CalcLeftLine();
492cdf0e10cSrcweir 	return nLeftLine;
493cdf0e10cSrcweir }
CalcRightLine() const494cdf0e10cSrcweir inline sal_uInt16 SwBorderAttrs::CalcRightLine() const
495cdf0e10cSrcweir {
496cdf0e10cSrcweir 	if ( bRightLine )
497cdf0e10cSrcweir 		((SwBorderAttrs*)this)->_CalcRightLine();
498cdf0e10cSrcweir 	return nRightLine;
499cdf0e10cSrcweir }
CalcTop() const500cdf0e10cSrcweir inline sal_uInt16 SwBorderAttrs::CalcTop() const
501cdf0e10cSrcweir {
502cdf0e10cSrcweir 	if ( bTop )
503cdf0e10cSrcweir 		((SwBorderAttrs*)this)->_CalcTop();
504cdf0e10cSrcweir 	return nTop;
505cdf0e10cSrcweir }
CalcBottom() const506cdf0e10cSrcweir inline sal_uInt16 SwBorderAttrs::CalcBottom() const
507cdf0e10cSrcweir {
508cdf0e10cSrcweir 	if ( bBottom )
509cdf0e10cSrcweir 		((SwBorderAttrs*)this)->_CalcBottom();
510cdf0e10cSrcweir 	return nBottom;
511cdf0e10cSrcweir }
IsLine() const512cdf0e10cSrcweir inline sal_Bool SwBorderAttrs::IsLine() const
513cdf0e10cSrcweir {
514cdf0e10cSrcweir 	if ( bLine )
515cdf0e10cSrcweir 		((SwBorderAttrs*)this)->_IsLine();
516cdf0e10cSrcweir 	return bIsLine;
517cdf0e10cSrcweir }
518cdf0e10cSrcweir 
519cdf0e10cSrcweir /** method to determine the spacing values of a frame
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     OD 2004-03-10 #i28701#
522cdf0e10cSrcweir     Values only provided for flow frames (table, section or text frames)
523cdf0e10cSrcweir     Note: line spacing value is only determined for text frames
524cdf0e10cSrcweir     OD 2009-08-28 #i102458#
525cdf0e10cSrcweir     Add output parameter <obIsLineSpacingProportional>
526cdf0e10cSrcweir 
527cdf0e10cSrcweir     @param rFrm
528cdf0e10cSrcweir     input parameter - frame, for which the spacing values are determined.
529cdf0e10cSrcweir 
530cdf0e10cSrcweir     @param onPrevLowerSpacing
531cdf0e10cSrcweir     output parameter - lower spacing of the frame in SwTwips
532cdf0e10cSrcweir 
533cdf0e10cSrcweir     @param onPrevLineSpacing
534cdf0e10cSrcweir     output parameter - line spacing of the frame in SwTwips
535cdf0e10cSrcweir 
536cdf0e10cSrcweir     @param obIsLineSpacingProportional
537cdf0e10cSrcweir 
538cdf0e10cSrcweir     @author OD
539cdf0e10cSrcweir */
540cdf0e10cSrcweir void GetSpacingValuesOfFrm( const SwFrm& rFrm,
541cdf0e10cSrcweir                             SwTwips& onLowerSpacing,
542cdf0e10cSrcweir                             SwTwips& onLineSpacing,
543cdf0e10cSrcweir                             bool& obIsLineSpacingProportional );
544cdf0e10cSrcweir 
545cdf0e10cSrcweir /** method to get the content of the table cell
546cdf0e10cSrcweir 
547cdf0e10cSrcweir     Content from any nested tables will be omitted.
548cdf0e10cSrcweir     Note: line spacing value is only determined for text frames
549cdf0e10cSrcweir 
550cdf0e10cSrcweir     @param rCell_
551cdf0e10cSrcweir     input parameter - the cell which should be searched for content.
552cdf0e10cSrcweir 
553cdf0e10cSrcweir     return
554cdf0e10cSrcweir         pointer to the found content frame or 0
555cdf0e10cSrcweir */
556cdf0e10cSrcweir 
557cdf0e10cSrcweir const SwCntntFrm* GetCellCntnt( const SwLayoutFrm& rCell_ );
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 
560cdf0e10cSrcweir /** helper class to check if a frame has been deleted during an operation
561cdf0e10cSrcweir  *  !!!WARNING!!! This should only be used as a last and desperate means
562cdf0e10cSrcweir  *  to make the code robust.
563cdf0e10cSrcweir  */
564cdf0e10cSrcweir 
565cdf0e10cSrcweir class SwDeletionChecker
566cdf0e10cSrcweir {
567cdf0e10cSrcweir     private:
568cdf0e10cSrcweir 
569cdf0e10cSrcweir     const SwFrm* mpFrm;
570cdf0e10cSrcweir     const SwModify* mpRegIn;
571cdf0e10cSrcweir 
572cdf0e10cSrcweir     public:
573cdf0e10cSrcweir 
SwDeletionChecker(const SwFrm * pFrm)574cdf0e10cSrcweir     SwDeletionChecker( const SwFrm* pFrm )
575cdf0e10cSrcweir             : mpFrm( pFrm ),
576cdf0e10cSrcweir               mpRegIn( pFrm ? const_cast<SwFrm*>(pFrm)->GetRegisteredIn() : 0 )
577cdf0e10cSrcweir     {
578cdf0e10cSrcweir     }
579cdf0e10cSrcweir 
580cdf0e10cSrcweir     /**
581cdf0e10cSrcweir      *  return
582cdf0e10cSrcweir      *    true if mpFrm != 0 and mpFrm is not client of pRegIn
583cdf0e10cSrcweir      *    false otherwise
584cdf0e10cSrcweir      */
585cdf0e10cSrcweir     bool HasBeenDeleted();
586cdf0e10cSrcweir };
587cdf0e10cSrcweir 
588cdf0e10cSrcweir #endif  //_FRMTOOL_HXX
589