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