Update ooo320-m1
[ooovba.git] / sw / source / core / text / txtfly.hxx
blob6849cefb9586a0bd7cf69d0896f863ab3e2db72d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtfly.hxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _TXTFLY_HXX
31 #define _TXTFLY_HXX
32 #include <svtools/svarray.hxx>
34 #include "swtypes.hxx"
35 #include "swrect.hxx"
37 class OutputDevice;
38 class SwCntntFrm;
39 class SwPageFrm;
40 class SwTxtFly;
41 class SdrObject;
42 class SwTxtPaintInfo;
43 class SwFmt;
44 class TextRanger;
45 class Color;
46 // --> OD 2004-10-06 #i26945#
47 class SwAnchoredObject;
48 // <--
50 // --> OD 2006-08-15 #i68520# - refactoring
51 //typedef MSHORT _FlyCntnt;
52 #include <fmtsrndenum.hxx>
53 // <--
55 // --> OD 2006-08-15 #i68520#
56 //SV_DECL_PTRARR( SwFlyList, SdrObject*, 10, 10 )
57 #include <vector>
58 typedef std::vector< SwAnchoredObject* > SwAnchoredObjList;
59 // <--
61 /*************************************************************************
62 * class SwFlyIter
63 *************************************************************************/
64 enum PAGESIDE { LEFT_SIDE, RIGHT_SIDE, DONTKNOW_SIDE };
66 /*************************************************************************
67 * class SwContourCache
68 *************************************************************************/
70 class SwDrawTextInfo;
71 // Contour-Cache, globale Variable, in txtinit.cxx initialisiert/zerstoert
72 // und in txtfly.cxx benutzt bei Konturumfluss
73 class SwContourCache;
74 extern SwContourCache *pContourCache;
75 class SwTxtFrm;
77 #define POLY_CNT 20
78 #define POLY_MIN 5
79 #define POLY_MAX 4000
81 class SwContourCache
83 friend void ClrContourCache();
84 const SdrObject *pSdrObj[ POLY_CNT ];
85 TextRanger *pTextRanger[ POLY_CNT ];
86 long nPntCnt;
87 MSHORT nObjCnt;
88 const SwRect ContourRect( const SwFmt* pFmt, const SdrObject* pObj,
89 const SwTxtFrm* pFrm, const SwRect &rLine, const long nXPos,
90 const sal_Bool bRight );
92 public:
93 SwContourCache();
94 ~SwContourCache();
95 const SdrObject* GetObject( MSHORT nPos ){ return pSdrObj[ nPos ]; }
96 MSHORT GetCount() const { return nObjCnt; }
97 void ClrObject( MSHORT nPos );
98 // --> OD 2006-08-15 #i68520#
99 static const SwRect CalcBoundRect( const SwAnchoredObject* pAnchoredObj,
100 const SwRect &rLine,
101 const SwTxtFrm* pFrm,
102 const long nXPos,
103 const sal_Bool bRight );
104 // <--
105 #ifndef PRODUCT
106 void ShowContour( OutputDevice* pOut, const SdrObject* pObj,
107 const Color& rClosedColor, const Color& rOpenColor );
108 #endif
111 /*************************************************************************
112 * class SwTxtFly
113 *************************************************************************/
115 class SwTxtFly
117 const SwPageFrm *pPage;
118 // --> OD 2006-08-15 #i68520#
119 const SwAnchoredObject* mpCurrAnchoredObj;
120 // <--
122 const SwTxtFrm *pCurrFrm;
124 const SwCntntFrm *pMaster;
125 // --> OD 2006-08-15 #i68520#
126 SwAnchoredObjList* mpAnchoredObjList;
127 // <--
129 long nMinBottom;
130 long nNextTop; // Hier wird die Oberkante des "naechsten" Rahmens gespeichert
131 ULONG nIndex;
132 sal_Bool bOn : 1;
133 sal_Bool bLeftSide : 1;
134 sal_Bool bTopRule: 1;
135 sal_Bool mbIgnoreCurrentFrame: 1;
136 sal_Bool mbIgnoreContour: 1;
137 // --> OD 2004-12-17 #118809# - boolean, indicating if objects in page
138 // header|footer are considered for text frames not in page header|footer.
139 sal_Bool mbIgnoreObjsInHeaderFooter: 1;
140 // <--
141 SwRect _GetFrm( const SwRect &rPortion, sal_Bool bTop ) const;
142 // --> OD 2006-08-15 #i68520#
143 SwAnchoredObjList* InitAnchoredObjList();
144 inline SwAnchoredObjList* GetAnchoredObjList() const
146 return mpAnchoredObjList
147 ? mpAnchoredObjList
148 : const_cast<SwTxtFly*>(this)->InitAnchoredObjList();
150 // iterates over the anchored object list <mpAnchoredObjList>
151 sal_Bool ForEach( const SwRect &rRect, SwRect* pRect, sal_Bool bAvoid ) const;
152 SwSurround _GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const;
153 void CalcRightMargin( SwRect &rFly,
154 SwAnchoredObjList::size_type nPos,
155 const SwRect &rLine ) const;
156 void CalcLeftMargin( SwRect &rFly,
157 SwAnchoredObjList::size_type nPos,
158 const SwRect &rLine ) const;
159 SwAnchoredObjList::size_type GetPos( const SwAnchoredObject* pAnchoredObj ) const;
160 // <--
161 // --> OD 2004-10-06 #i26945# - change first parameter:
162 // Now it's the <SwAnchoredObject> instance of the floating screen object
163 sal_Bool GetTop( const SwAnchoredObject* _pAnchoredObj,
164 const sal_Bool bInFtn,
165 const sal_Bool bInFooterOrHeader );
166 // <--
167 SwTwips CalcMinBottom() const;
168 const SwCntntFrm* _GetMaster();
170 public:
171 inline SwTxtFly()
173 mbIgnoreCurrentFrame = sal_False;
174 mbIgnoreCurrentFrame = sal_False;
175 // --> OD 2004-12-17 #118809#
176 mbIgnoreObjsInHeaderFooter = sal_False;
177 // <--
178 // --> OD 2006-08-15 #i68520#
179 mpCurrAnchoredObj = 0;
180 mpAnchoredObjList = 0;
181 // <--
182 pMaster = 0;
184 inline SwTxtFly( const SwTxtFrm *pFrm )
185 { CtorInitTxtFly( pFrm ); }
187 SwTxtFly( const SwTxtFly& rTxtFly );
188 // --> OD 2006-08-15 #i68520#
189 inline ~SwTxtFly() { delete mpAnchoredObjList; }
190 // <--
191 void CtorInitTxtFly( const SwTxtFrm *pFrm );
192 void SetTopRule(){ bTopRule = sal_False; }
194 inline SwRect GetFrm( const SwRect &rPortion, sal_Bool bTop = sal_True ) const;
195 inline sal_Bool IsOn() const { return bOn; }
196 inline sal_Bool Relax( const SwRect &rRect );
197 inline sal_Bool Relax();
198 inline SwTwips GetMinBottom() const
199 // --> OD 2006-08-15 #i68520#
200 { return mpAnchoredObjList ? nMinBottom : CalcMinBottom(); }
201 // <--
202 inline const SwCntntFrm* GetMaster() const
203 { return pMaster ? pMaster : ((SwTxtFly*)this)->_GetMaster(); }
204 inline long GetNextTop() const { return nNextTop; }
205 // Diese temporaere Variable darf auch in const-Methoden manipuliert werden
206 inline void SetNextTop( long nNew ) const
207 { ((SwTxtFly*)this)->nNextTop = nNew; }
209 // --> OD 2006-08-15 #i68520#
210 // determines the demanded rectangle for an anchored object,
211 // considering its surround for text wrapping.
212 SwRect AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
213 const SwRect& rRect ) const;
214 // <--
216 // Die Drawmethoden stellen sicher, dass ueberlappende Frames
217 // (ausser bei transparenten Frames) nicht uebergepinselt werden.
218 sal_Bool DrawTextOpaque( SwDrawTextInfo &rInf );
220 void DrawFlyRect( OutputDevice* pOut, const SwRect &rRect,
221 const SwTxtPaintInfo &rInf, sal_Bool bNoGraphic = sal_False );
223 // Liefert zurueck, ob die Zeile von einem Frame ueberlappt wird.
224 sal_Bool IsAnyFrm( const SwRect &rLine ) const;
225 sal_Bool IsAnyFrm() const;
226 //Das Rechteck kann leer sein, es gilt dann der Frm.
227 sal_Bool IsAnyObj( const SwRect& ) const;
229 void SetIgnoreCurrentFrame( sal_Bool bNew ) { mbIgnoreCurrentFrame = bNew; }
230 void SetIgnoreContour( sal_Bool bNew ) { mbIgnoreContour = bNew; }
231 // --> OD 2004-12-17 #118809#
232 inline void SetIgnoreObjsInHeaderFooter( const sal_Bool _bNew )
234 mbIgnoreObjsInHeaderFooter = _bNew;
236 // <--
238 #ifndef PRODUCT
239 void ShowContour( OutputDevice* pOut );
240 #endif
243 // Wenn in das rRect (meist die aktuelle Zeile) kein freifliegender
244 // Frame ragt, dann schalten wir uns ab.
245 // rRect ist dokumentglobal !
246 inline sal_Bool SwTxtFly::Relax( const SwRect &rRect )
248 return 0 != (bOn = bOn && IsAnyFrm( rRect ));
251 inline sal_Bool SwTxtFly::Relax()
253 return 0 != (bOn = bOn && IsAnyFrm());
256 inline SwRect SwTxtFly::GetFrm( const SwRect &rRect, sal_Bool bTop ) const
258 return bOn ? _GetFrm( rRect, bTop ) : SwRect();
262 #endif