LibreOffice Module sw (master) 1
txtfly.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <editeng/txtrange.hxx>
23#include <swtypes.hxx>
24#include <swrect.hxx>
25#include <com/sun/star/text/WrapTextMode.hpp>
26#include <nodeoffset.hxx>
27#include <memory>
28#include <vector>
29
30class OutputDevice;
31class SwPageFrame;
32class SdrObject;
33class SwFormat;
35class SwTextFrame;
36class SwDrawTextInfo;
37class SwContourCache;
38class SwBreakPortion;
40
41typedef std::vector< SwAnchoredObject* > SwAnchoredObjList;
42
47
48#define POLY_CNT 20
49#define POLY_MIN 5
50#define POLY_MAX 4000
51
52void ClrContourCache( const SdrObject *pObj );
53
55{
56 friend void ClrContourCache();
57 struct CacheItem
58 {
60 std::unique_ptr<TextRanger> mxTextRanger;
61 };
62 std::vector<CacheItem> mvItems;
64 SwRect ContourRect( const SwFormat* pFormat, const SdrObject* pObj,
65 const SwTextFrame* pFrame, const SwRect &rLine, const tools::Long nXPos,
66 const bool bRight );
67
68public:
71 const SdrObject* GetObject( sal_uInt16 nPos ) const{ return mvItems[ nPos ].mpSdrObj; }
72 sal_uInt16 GetCount() const { return mvItems.size(); }
73 void ClrObject( sal_uInt16 nPos );
74
82 static SwRect CalcBoundRect( const SwAnchoredObject* pAnchoredObj,
83 const SwRect &rLine,
84 const SwTextFrame* pFrame,
85 const tools::Long nXPos,
86 const bool bRight );
87};
88
89// MS Word wraps on sides with even less space (value guessed).
90#define TEXT_MIN_SMALL 300
91
125{
130 std::unique_ptr<SwAnchoredObjList> mpAnchoredObjList;
131
135
136 bool m_bOn : 1;
137 bool m_bTopRule: 1;
140
145
154 SwRect GetFrame_( const SwRect &rPortion ) const;
155
157
158public:
160private:
161
166 bool ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const;
167
182 css::text::WrapTextMode GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const;
183
188 void CalcRightMargin( SwRect &rFly,
189 SwAnchoredObjList::size_type nPos,
190 const SwRect &rLine ) const;
191
196 void CalcLeftMargin( SwRect &rFly,
197 SwAnchoredObjList::size_type nPos,
198 const SwRect &rLine ) const;
199
203 SwAnchoredObjList::size_type GetPos( const SwAnchoredObject* pAnchoredObj ) const;
204
205 bool GetTop( const SwAnchoredObject* _pAnchoredObj,
206 const bool bInFootnote,
207 const bool bInFooterOrHeader );
208
209 SwTwips CalcMinBottom() const;
210
211 const SwTextFrame* GetMaster_();
212
213public:
214
215 SwTextFly();
216 SwTextFly( const SwTextFrame *pFrame );
217 SwTextFly( const SwTextFly& rTextFly );
218 ~SwTextFly();
219
220 void CtorInitTextFly( const SwTextFrame *pFrame );
221
222 void SetTopRule();
223
224 SwRect GetFrame( const SwRect &rPortion ) const;
225 bool IsOn() const;
226
233 bool Relax( const SwRect &rRect );
234 bool Relax();
235
236 SwTwips GetMinBottom() const;
237
239 SwTwips GetMaxBottom(const SwBreakPortion& rPortion, const SwTextFormatInfo& rInfo) const;
240
241 const SwTextFrame* GetMaster() const;
242
243 // This temporary variable needs to be manipulated in const methods
244 tools::Long GetNextTop() const;
245 void SetNextTop( tools::Long nNew ) const;
246
256 SwRect AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
257 const SwRect& rRect ) const;
258
269 void DrawTextOpaque( SwDrawTextInfo &rInf );
270
279 void DrawFlyRect( OutputDevice* pOut, const SwRect &rRect );
280
287 bool IsAnyFrame( const SwRect &rLine ) const;
288
293 bool IsAnyFrame() const;
294
304 bool IsAnyObj( const SwRect& rRect ) const;
305
306 void SetIgnoreCurrentFrame( bool bNew );
307 void SetIgnoreContour( bool bNew );
308
309 void SetIgnoreObjsInHeaderFooter( const bool bNew );
310
311 SwRect GetFrameArea() const;
312};
313
315{
316 return mpAnchoredObjList
317 ? mpAnchoredObjList.get()
318 : const_cast<SwTextFly*>(this)->InitAnchoredObjList();
319}
320
322{
323 m_bTopRule = false;
324}
325
326inline bool SwTextFly::IsOn() const
327{
328 return m_bOn;
329}
330
331inline bool SwTextFly::Relax( const SwRect &rRect )
332{
333 if (m_bOn)
334 {
335 m_bOn = IsAnyFrame( rRect );
336 }
337 return m_bOn;
338}
339
340inline bool SwTextFly::Relax()
341{
342 if (m_bOn)
343 {
344 m_bOn = IsAnyFrame();
345 }
346 return m_bOn;
347}
348
350{
352}
353
355{
356 return m_pMaster ? m_pMaster : const_cast<SwTextFly*>(this)->GetMaster_();
357}
358
360{
361 return m_nNextTop;
362}
363
364inline void SwTextFly::SetNextTop( tools::Long nNew ) const
365{
366 const_cast<SwTextFly*>(this)->m_nNextTop = nNew;
367}
368
369inline SwRect SwTextFly::GetFrame( const SwRect &rRect ) const
370{
371 return m_bOn ? GetFrame_( rRect ) : SwRect();
372}
373
374inline void SwTextFly::SetIgnoreCurrentFrame( bool bNew )
375{
377}
378
379inline void SwTextFly::SetIgnoreContour( bool bNew )
380{
381 mbIgnoreContour = bNew;
382}
383
384inline void SwTextFly::SetIgnoreObjsInHeaderFooter( const bool bNew )
385{
387}
388
389/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
wrapper class for the positioning of Writer fly frames and drawing objects
const SdrObject * GetObject(sal_uInt16 nPos) const
Definition: txtfly.hxx:71
tools::Long mnPointCount
Definition: txtfly.hxx:63
sal_uInt16 GetCount() const
Definition: txtfly.hxx:72
SwRect ContourRect(const SwFormat *pFormat, const SdrObject *pObj, const SwTextFrame *pFrame, const SwRect &rLine, const tools::Long nXPos, const bool bRight)
Definition: txtfly.cxx:206
static SwRect CalcBoundRect(const SwAnchoredObject *pAnchoredObj, const SwRect &rLine, const SwTextFrame *pFrame, const tools::Long nXPos, const bool bRight)
Computes the rectangle that will cover the object in the given line.
Definition: txtfly.cxx:158
friend void ClrContourCache()
Definition: txtfly.cxx:148
void ClrObject(sal_uInt16 nPos)
Definition: txtfly.cxx:131
std::vector< CacheItem > mvItems
Definition: txtfly.hxx:62
Base class for various Writer styles.
Definition: format.hxx:47
A page of the document layout.
Definition: pagefrm.hxx:60
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
The purpose of this class is to be the universal interface between formatting/text output and the pos...
Definition: txtfly.hxx:125
void CalcRightMargin(SwRect &rFly, SwAnchoredObjList::size_type nPos, const SwRect &rLine) const
The right margin is the right margin or it is determined by the next object standing on the line.
Definition: txtfly.cxx:1179
SwTextFly()
Definition: txtfly.cxx:309
SwTwips GetMinBottom() const
Definition: txtfly.hxx:349
void SetNextTop(tools::Long nNew) const
Definition: txtfly.hxx:364
std::unique_ptr< SwAnchoredObjList > mpAnchoredObjList
Definition: txtfly.hxx:130
bool mbIgnoreContour
Definition: txtfly.hxx:139
bool GetTop(const SwAnchoredObject *_pAnchoredObj, const bool bInFootnote, const bool bInFooterOrHeader)
#i26945# - change first parameter Now it's the <SwAnchoredObject> instance of the floating screen obj...
Definition: txtfly.cxx:636
bool IsAnyObj(const SwRect &rRect) const
true when a frame or DrawObj must be taken in account.
Definition: txtfly.cxx:408
SwAnchoredObjList::size_type GetPos(const SwAnchoredObject *pAnchoredObj) const
Definition: txtfly.cxx:1169
void SetIgnoreObjsInHeaderFooter(const bool bNew)
Definition: txtfly.hxx:384
SwRect GetFrame_(const SwRect &rPortion) const
This method will be called during the LineIter formatting.
Definition: txtfly.cxx:379
bool m_bOn
Definition: txtfly.hxx:136
void SetTopRule()
Definition: txtfly.hxx:321
SwRect AnchoredObjToRect(const SwAnchoredObject *pAnchoredObj, const SwRect &rRect) const
Determines the demanded rectangle for an anchored object, considering its surround for text wrapping.
Definition: txtfly.cxx:1332
SwTwips GetMaxBottom(const SwBreakPortion &rPortion, const SwTextFormatInfo &rInfo) const
Gets the maximum of the fly frame bottoms.
Definition: txtfly.cxx:1010
void SetIgnoreContour(bool bNew)
Definition: txtfly.hxx:379
void SetIgnoreCurrentFrame(bool bNew)
Definition: txtfly.hxx:374
tools::Long m_nMinBottom
Definition: txtfly.hxx:132
bool m_bTopRule
Definition: txtfly.hxx:137
SwAnchoredObjList * InitAnchoredObjList()
Definition: txtfly.cxx:849
const SwTextFrame * GetMaster() const
Definition: txtfly.hxx:354
const SwTextFrame * GetMaster_()
Definition: txtfly.cxx:447
bool IsAnyFrame() const
Same as IsAnyFrame(const SwRect&), but uses the current frame print area.
Definition: txtfly.cxx:397
bool ForEach(const SwRect &rRect, SwRect *pRect, bool bAvoid) const
Look for the first object which overlaps with the rectangle.
Definition: txtfly.cxx:1068
bool Relax()
Definition: txtfly.hxx:340
SwRect GetFrameArea() const
Definition: txtfly.cxx:832
const SwPageFrame * m_pPage
Definition: txtfly.hxx:126
void DrawFlyRect(OutputDevice *pOut, const SwRect &rRect)
Two subtleties needs to be mentioned:
Definition: txtfly.cxx:576
const SwAnchoredObject * mpCurrAnchoredObj
Definition: txtfly.hxx:127
css::text::WrapTextMode GetSurroundForTextWrap(const SwAnchoredObject *pAnchoredObj) const
Definition: txtfly.cxx:1394
bool mbIgnoreObjsInHeaderFooter
boolean, indicating if objects in page header|footer are considered for text frames not in page heade...
Definition: txtfly.hxx:144
SwRect GetFrame(const SwRect &rPortion) const
Definition: txtfly.hxx:369
SwTwips CalcMinBottom() const
Definition: txtfly.cxx:976
const SwTextFrame * m_pCurrFrame
Definition: txtfly.hxx:128
const SwTextFrame * m_pMaster
Definition: txtfly.hxx:129
bool IsOn() const
Definition: txtfly.hxx:326
bool mbIgnoreCurrentFrame
Definition: txtfly.hxx:138
SwAnchoredObjList * GetAnchoredObjList() const
Definition: txtfly.hxx:314
tools::Long m_nNextTop
Definition: txtfly.hxx:133
void CalcLeftMargin(SwRect &rFly, SwAnchoredObjList::size_type nPos, const SwRect &rLine) const
The left margin is the left margin of the current PrintArea or it is determined by the last FlyFrame,...
Definition: txtfly.cxx:1268
tools::Long GetNextTop() const
Definition: txtfly.hxx:359
SwNodeOffset m_nCurrFrameNodeIndex
Stores the upper edge of the "next" frame.
Definition: txtfly.hxx:134
void CtorInitTextFly(const SwTextFrame *pFrame)
Definition: txtfly.cxx:356
~SwTextFly()
Definition: txtfly.cxx:352
void DrawTextOpaque(SwDrawTextInfo &rInf)
This method is called by DrawText().
Definition: txtfly.cxx:455
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
sal_uInt16 nPos
long Long
std::unique_ptr< TextRanger > mxTextRanger
Definition: txtfly.hxx:60
const SdrObject * mpSdrObj
Definition: txtfly.hxx:59
tools::Long SwTwips
Definition: swtypes.hxx:51
void ClrContourCache(const SdrObject *pObj)
Definition: txtfly.cxx:137
std::vector< SwAnchoredObject * > SwAnchoredObjList
Definition: txtfly.hxx:39
SwContourCache * pContourCache
Contour-cache global variable, initialized/destroyed in txtinit.cxx and needed in txtfly....
Definition: txtinit.cxx:30