1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*1d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*1d2dbeb0SAndrew Rist * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*1d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist *
11*1d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist *
13*1d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the
17*1d2dbeb0SAndrew Rist * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist * under the License.
19*1d2dbeb0SAndrew Rist *
20*1d2dbeb0SAndrew Rist *************************************************************/
21*1d2dbeb0SAndrew Rist
22*1d2dbeb0SAndrew Rist
23cdf0e10cSrcweir #ifndef _TXTFLY_HXX
24cdf0e10cSrcweir #define _TXTFLY_HXX
25cdf0e10cSrcweir #include <svl/svarray.hxx>
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "swtypes.hxx"
28cdf0e10cSrcweir #include "swrect.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir class OutputDevice;
31cdf0e10cSrcweir class SwCntntFrm;
32cdf0e10cSrcweir class SwPageFrm;
33cdf0e10cSrcweir class SwTxtFly;
34cdf0e10cSrcweir class SdrObject;
35cdf0e10cSrcweir class SwTxtPaintInfo;
36cdf0e10cSrcweir class SwFmt;
37cdf0e10cSrcweir class TextRanger;
38cdf0e10cSrcweir class Color;
39cdf0e10cSrcweir // --> OD 2004-10-06 #i26945#
40cdf0e10cSrcweir class SwAnchoredObject;
41cdf0e10cSrcweir // <--
42cdf0e10cSrcweir
43cdf0e10cSrcweir // --> OD 2006-08-15 #i68520# - refactoring
44cdf0e10cSrcweir //typedef MSHORT _FlyCntnt;
45cdf0e10cSrcweir #include <fmtsrndenum.hxx>
46cdf0e10cSrcweir // <--
47cdf0e10cSrcweir
48cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
49cdf0e10cSrcweir //SV_DECL_PTRARR( SwFlyList, SdrObject*, 10, 10 )
50cdf0e10cSrcweir #include <vector>
51cdf0e10cSrcweir typedef std::vector< SwAnchoredObject* > SwAnchoredObjList;
52cdf0e10cSrcweir // <--
53cdf0e10cSrcweir
54cdf0e10cSrcweir /*************************************************************************
55cdf0e10cSrcweir * class SwFlyIter
56cdf0e10cSrcweir *************************************************************************/
57cdf0e10cSrcweir enum PAGESIDE { LEFT_SIDE, RIGHT_SIDE, DONTKNOW_SIDE };
58cdf0e10cSrcweir
59cdf0e10cSrcweir /*************************************************************************
60cdf0e10cSrcweir * class SwContourCache
61cdf0e10cSrcweir *************************************************************************/
62cdf0e10cSrcweir
63cdf0e10cSrcweir class SwDrawTextInfo;
64cdf0e10cSrcweir // Contour-Cache, globale Variable, in txtinit.cxx initialisiert/zerstoert
65cdf0e10cSrcweir // und in txtfly.cxx benutzt bei Konturumfluss
66cdf0e10cSrcweir class SwContourCache;
67cdf0e10cSrcweir extern SwContourCache *pContourCache;
68cdf0e10cSrcweir class SwTxtFrm;
69cdf0e10cSrcweir
70cdf0e10cSrcweir #define POLY_CNT 20
71cdf0e10cSrcweir #define POLY_MIN 5
72cdf0e10cSrcweir #define POLY_MAX 4000
73cdf0e10cSrcweir
74cdf0e10cSrcweir class SwContourCache
75cdf0e10cSrcweir {
76cdf0e10cSrcweir friend void ClrContourCache();
77cdf0e10cSrcweir const SdrObject *pSdrObj[ POLY_CNT ];
78cdf0e10cSrcweir TextRanger *pTextRanger[ POLY_CNT ];
79cdf0e10cSrcweir long nPntCnt;
80cdf0e10cSrcweir MSHORT nObjCnt;
81cdf0e10cSrcweir const SwRect ContourRect( const SwFmt* pFmt, const SdrObject* pObj,
82cdf0e10cSrcweir const SwTxtFrm* pFrm, const SwRect &rLine, const long nXPos,
83cdf0e10cSrcweir const sal_Bool bRight );
84cdf0e10cSrcweir
85cdf0e10cSrcweir public:
86cdf0e10cSrcweir SwContourCache();
87cdf0e10cSrcweir ~SwContourCache();
GetObject(MSHORT nPos)88cdf0e10cSrcweir const SdrObject* GetObject( MSHORT nPos ){ return pSdrObj[ nPos ]; }
GetCount() const89cdf0e10cSrcweir MSHORT GetCount() const { return nObjCnt; }
90cdf0e10cSrcweir void ClrObject( MSHORT nPos );
91cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
92cdf0e10cSrcweir static const SwRect CalcBoundRect( const SwAnchoredObject* pAnchoredObj,
93cdf0e10cSrcweir const SwRect &rLine,
94cdf0e10cSrcweir const SwTxtFrm* pFrm,
95cdf0e10cSrcweir const long nXPos,
96cdf0e10cSrcweir const sal_Bool bRight );
97cdf0e10cSrcweir // <--
98cdf0e10cSrcweir #ifdef DBG_UTIL
99cdf0e10cSrcweir void ShowContour( OutputDevice* pOut, const SdrObject* pObj,
100cdf0e10cSrcweir const Color& rClosedColor, const Color& rOpenColor );
101cdf0e10cSrcweir #endif
102cdf0e10cSrcweir };
103cdf0e10cSrcweir
104cdf0e10cSrcweir /*************************************************************************
105cdf0e10cSrcweir * class SwTxtFly
106cdf0e10cSrcweir *************************************************************************/
107cdf0e10cSrcweir
108cdf0e10cSrcweir class SwTxtFly
109cdf0e10cSrcweir {
110cdf0e10cSrcweir const SwPageFrm *pPage;
111cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
112cdf0e10cSrcweir const SwAnchoredObject* mpCurrAnchoredObj;
113cdf0e10cSrcweir // <--
114cdf0e10cSrcweir
115cdf0e10cSrcweir const SwTxtFrm *pCurrFrm;
116cdf0e10cSrcweir
117cdf0e10cSrcweir const SwCntntFrm *pMaster;
118cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
119cdf0e10cSrcweir SwAnchoredObjList* mpAnchoredObjList;
120cdf0e10cSrcweir // <--
121cdf0e10cSrcweir
122cdf0e10cSrcweir long nMinBottom;
123cdf0e10cSrcweir long nNextTop; // Hier wird die Oberkante des "naechsten" Rahmens gespeichert
124cdf0e10cSrcweir sal_uLong nIndex;
125cdf0e10cSrcweir sal_Bool bOn : 1;
126cdf0e10cSrcweir sal_Bool bLeftSide : 1;
127cdf0e10cSrcweir sal_Bool bTopRule: 1;
128cdf0e10cSrcweir sal_Bool mbIgnoreCurrentFrame: 1;
129cdf0e10cSrcweir sal_Bool mbIgnoreContour: 1;
130cdf0e10cSrcweir // --> OD 2004-12-17 #118809# - boolean, indicating if objects in page
131cdf0e10cSrcweir // header|footer are considered for text frames not in page header|footer.
132cdf0e10cSrcweir sal_Bool mbIgnoreObjsInHeaderFooter: 1;
133cdf0e10cSrcweir // <--
134cdf0e10cSrcweir SwRect _GetFrm( const SwRect &rPortion, sal_Bool bTop ) const;
135cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
136cdf0e10cSrcweir SwAnchoredObjList* InitAnchoredObjList();
GetAnchoredObjList() const137cdf0e10cSrcweir inline SwAnchoredObjList* GetAnchoredObjList() const
138cdf0e10cSrcweir {
139cdf0e10cSrcweir return mpAnchoredObjList
140cdf0e10cSrcweir ? mpAnchoredObjList
141cdf0e10cSrcweir : const_cast<SwTxtFly*>(this)->InitAnchoredObjList();
142cdf0e10cSrcweir }
143cdf0e10cSrcweir // iterates over the anchored object list <mpAnchoredObjList>
144cdf0e10cSrcweir sal_Bool ForEach( const SwRect &rRect, SwRect* pRect, sal_Bool bAvoid ) const;
145cdf0e10cSrcweir SwSurround _GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const;
146cdf0e10cSrcweir void CalcRightMargin( SwRect &rFly,
147cdf0e10cSrcweir SwAnchoredObjList::size_type nPos,
148cdf0e10cSrcweir const SwRect &rLine ) const;
149cdf0e10cSrcweir void CalcLeftMargin( SwRect &rFly,
150cdf0e10cSrcweir SwAnchoredObjList::size_type nPos,
151cdf0e10cSrcweir const SwRect &rLine ) const;
152cdf0e10cSrcweir SwAnchoredObjList::size_type GetPos( const SwAnchoredObject* pAnchoredObj ) const;
153cdf0e10cSrcweir // <--
154cdf0e10cSrcweir // --> OD 2004-10-06 #i26945# - change first parameter:
155cdf0e10cSrcweir // Now it's the <SwAnchoredObject> instance of the floating screen object
156cdf0e10cSrcweir sal_Bool GetTop( const SwAnchoredObject* _pAnchoredObj,
157cdf0e10cSrcweir const sal_Bool bInFtn,
158cdf0e10cSrcweir const sal_Bool bInFooterOrHeader );
159cdf0e10cSrcweir // <--
160cdf0e10cSrcweir SwTwips CalcMinBottom() const;
161cdf0e10cSrcweir const SwCntntFrm* _GetMaster();
162cdf0e10cSrcweir
163cdf0e10cSrcweir public:
SwTxtFly()164cdf0e10cSrcweir inline SwTxtFly()
165cdf0e10cSrcweir {
166cdf0e10cSrcweir mbIgnoreCurrentFrame = sal_False;
167cdf0e10cSrcweir mbIgnoreCurrentFrame = sal_False;
168cdf0e10cSrcweir // --> OD 2004-12-17 #118809#
169cdf0e10cSrcweir mbIgnoreObjsInHeaderFooter = sal_False;
170cdf0e10cSrcweir // <--
171cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
172cdf0e10cSrcweir mpCurrAnchoredObj = 0;
173cdf0e10cSrcweir mpAnchoredObjList = 0;
174cdf0e10cSrcweir // <--
175cdf0e10cSrcweir pMaster = 0;
176cdf0e10cSrcweir }
SwTxtFly(const SwTxtFrm * pFrm)177cdf0e10cSrcweir inline SwTxtFly( const SwTxtFrm *pFrm )
178cdf0e10cSrcweir { CtorInitTxtFly( pFrm ); }
179cdf0e10cSrcweir
180cdf0e10cSrcweir SwTxtFly( const SwTxtFly& rTxtFly );
181cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
~SwTxtFly()182cdf0e10cSrcweir inline ~SwTxtFly() { delete mpAnchoredObjList; }
183cdf0e10cSrcweir // <--
184cdf0e10cSrcweir void CtorInitTxtFly( const SwTxtFrm *pFrm );
SetTopRule()185cdf0e10cSrcweir void SetTopRule(){ bTopRule = sal_False; }
186cdf0e10cSrcweir
187cdf0e10cSrcweir inline SwRect GetFrm( const SwRect &rPortion, sal_Bool bTop = sal_True ) const;
IsOn() const188cdf0e10cSrcweir inline sal_Bool IsOn() const { return bOn; }
189cdf0e10cSrcweir inline sal_Bool Relax( const SwRect &rRect );
190cdf0e10cSrcweir inline sal_Bool Relax();
GetMinBottom() const191cdf0e10cSrcweir inline SwTwips GetMinBottom() const
192cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
193cdf0e10cSrcweir { return mpAnchoredObjList ? nMinBottom : CalcMinBottom(); }
194cdf0e10cSrcweir // <--
GetMaster() const195cdf0e10cSrcweir inline const SwCntntFrm* GetMaster() const
196cdf0e10cSrcweir { return pMaster ? pMaster : ((SwTxtFly*)this)->_GetMaster(); }
GetNextTop() const197cdf0e10cSrcweir inline long GetNextTop() const { return nNextTop; }
198cdf0e10cSrcweir // Diese temporaere Variable darf auch in const-Methoden manipuliert werden
SetNextTop(long nNew) const199cdf0e10cSrcweir inline void SetNextTop( long nNew ) const
200cdf0e10cSrcweir { ((SwTxtFly*)this)->nNextTop = nNew; }
201cdf0e10cSrcweir
202cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
203cdf0e10cSrcweir // determines the demanded rectangle for an anchored object,
204cdf0e10cSrcweir // considering its surround for text wrapping.
205cdf0e10cSrcweir SwRect AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
206cdf0e10cSrcweir const SwRect& rRect ) const;
207cdf0e10cSrcweir // <--
208cdf0e10cSrcweir
209cdf0e10cSrcweir // Die Drawmethoden stellen sicher, dass ueberlappende Frames
210cdf0e10cSrcweir // (ausser bei transparenten Frames) nicht uebergepinselt werden.
211cdf0e10cSrcweir sal_Bool DrawTextOpaque( SwDrawTextInfo &rInf );
212cdf0e10cSrcweir
213cdf0e10cSrcweir void DrawFlyRect( OutputDevice* pOut, const SwRect &rRect,
214cdf0e10cSrcweir const SwTxtPaintInfo &rInf, sal_Bool bNoGraphic = sal_False );
215cdf0e10cSrcweir
216cdf0e10cSrcweir // Liefert zurueck, ob die Zeile von einem Frame ueberlappt wird.
217cdf0e10cSrcweir sal_Bool IsAnyFrm( const SwRect &rLine ) const;
218cdf0e10cSrcweir sal_Bool IsAnyFrm() const;
219cdf0e10cSrcweir //Das Rechteck kann leer sein, es gilt dann der Frm.
220cdf0e10cSrcweir sal_Bool IsAnyObj( const SwRect& ) const;
221cdf0e10cSrcweir
SetIgnoreCurrentFrame(sal_Bool bNew)222cdf0e10cSrcweir void SetIgnoreCurrentFrame( sal_Bool bNew ) { mbIgnoreCurrentFrame = bNew; }
SetIgnoreContour(sal_Bool bNew)223cdf0e10cSrcweir void SetIgnoreContour( sal_Bool bNew ) { mbIgnoreContour = bNew; }
224cdf0e10cSrcweir // --> OD 2004-12-17 #118809#
SetIgnoreObjsInHeaderFooter(const sal_Bool _bNew)225cdf0e10cSrcweir inline void SetIgnoreObjsInHeaderFooter( const sal_Bool _bNew )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir mbIgnoreObjsInHeaderFooter = _bNew;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir // <--
230cdf0e10cSrcweir
231cdf0e10cSrcweir #ifdef DBG_UTIL
232cdf0e10cSrcweir void ShowContour( OutputDevice* pOut );
233cdf0e10cSrcweir #endif
234cdf0e10cSrcweir };
235cdf0e10cSrcweir
236cdf0e10cSrcweir // Wenn in das rRect (meist die aktuelle Zeile) kein freifliegender
237cdf0e10cSrcweir // Frame ragt, dann schalten wir uns ab.
238cdf0e10cSrcweir // rRect ist dokumentglobal !
Relax(const SwRect & rRect)239cdf0e10cSrcweir inline sal_Bool SwTxtFly::Relax( const SwRect &rRect )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir return 0 != (bOn = bOn && IsAnyFrm( rRect ));
242cdf0e10cSrcweir }
243cdf0e10cSrcweir
Relax()244cdf0e10cSrcweir inline sal_Bool SwTxtFly::Relax()
245cdf0e10cSrcweir {
246cdf0e10cSrcweir return 0 != (bOn = bOn && IsAnyFrm());
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
GetFrm(const SwRect & rRect,sal_Bool bTop) const249cdf0e10cSrcweir inline SwRect SwTxtFly::GetFrm( const SwRect &rRect, sal_Bool bTop ) const
250cdf0e10cSrcweir {
251cdf0e10cSrcweir return bOn ? _GetFrm( rRect, bTop ) : SwRect();
252cdf0e10cSrcweir }
253cdf0e10cSrcweir
254cdf0e10cSrcweir
255cdf0e10cSrcweir #endif
256