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
122{
127 std::unique_ptr<SwAnchoredObjList> mpAnchoredObjList;
128
132
133 bool m_bOn : 1;
134 bool m_bTopRule: 1;
137
142
151 SwRect GetFrame_( const SwRect &rPortion ) const;
152
154
156
161 bool ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const;
162
177 css::text::WrapTextMode GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const;
178
183 void CalcRightMargin( SwRect &rFly,
184 SwAnchoredObjList::size_type nPos,
185 const SwRect &rLine ) const;
186
191 void CalcLeftMargin( SwRect &rFly,
192 SwAnchoredObjList::size_type nPos,
193 const SwRect &rLine ) const;
194
198 SwAnchoredObjList::size_type GetPos( const SwAnchoredObject* pAnchoredObj ) const;
199
200 bool GetTop( const SwAnchoredObject* _pAnchoredObj,
201 const bool bInFootnote,
202 const bool bInFooterOrHeader );
203
204 SwTwips CalcMinBottom() const;
205
206 const SwTextFrame* GetMaster_();
207
208public:
209
210 SwTextFly();
211 SwTextFly( const SwTextFrame *pFrame );
212 SwTextFly( const SwTextFly& rTextFly );
213 ~SwTextFly();
214
215 void CtorInitTextFly( const SwTextFrame *pFrame );
216
217 void SetTopRule();
218
219 SwRect GetFrame( const SwRect &rPortion ) const;
220 bool IsOn() const;
221
228 bool Relax( const SwRect &rRect );
229 bool Relax();
230
231 SwTwips GetMinBottom() const;
232
234 SwTwips GetMaxBottom(const SwBreakPortion& rPortion, const SwTextFormatInfo& rInfo) const;
235
236 const SwTextFrame* GetMaster() const;
237
238 // This temporary variable needs to be manipulated in const methods
239 tools::Long GetNextTop() const;
240 void SetNextTop( tools::Long nNew ) const;
241
251 SwRect AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
252 const SwRect& rRect ) const;
253
264 void DrawTextOpaque( SwDrawTextInfo &rInf );
265
274 void DrawFlyRect( OutputDevice* pOut, const SwRect &rRect );
275
282 bool IsAnyFrame( const SwRect &rLine ) const;
283
288 bool IsAnyFrame() const;
289
299 bool IsAnyObj( const SwRect& rRect ) const;
300
301 void SetIgnoreCurrentFrame( bool bNew );
302 void SetIgnoreContour( bool bNew );
303
304 void SetIgnoreObjsInHeaderFooter( const bool bNew );
305};
306
308{
309 return mpAnchoredObjList
310 ? mpAnchoredObjList.get()
311 : const_cast<SwTextFly*>(this)->InitAnchoredObjList();
312}
313
315{
316 m_bTopRule = false;
317}
318
319inline bool SwTextFly::IsOn() const
320{
321 return m_bOn;
322}
323
324inline bool SwTextFly::Relax( const SwRect &rRect )
325{
326 if (m_bOn)
327 {
328 m_bOn = IsAnyFrame( rRect );
329 }
330 return m_bOn;
331}
332
333inline bool SwTextFly::Relax()
334{
335 if (m_bOn)
336 {
337 m_bOn = IsAnyFrame();
338 }
339 return m_bOn;
340}
341
343{
345}
346
348{
349 return m_pMaster ? m_pMaster : const_cast<SwTextFly*>(this)->GetMaster_();
350}
351
353{
354 return m_nNextTop;
355}
356
357inline void SwTextFly::SetNextTop( tools::Long nNew ) const
358{
359 const_cast<SwTextFly*>(this)->m_nNextTop = nNew;
360}
361
362inline SwRect SwTextFly::GetFrame( const SwRect &rRect ) const
363{
364 return m_bOn ? GetFrame_( rRect ) : SwRect();
365}
366
367inline void SwTextFly::SetIgnoreCurrentFrame( bool bNew )
368{
370}
371
372inline void SwTextFly::SetIgnoreContour( bool bNew )
373{
374 mbIgnoreContour = bNew;
375}
376
377inline void SwTextFly::SetIgnoreObjsInHeaderFooter( const bool bNew )
378{
380}
381
382/* 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:58
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:122
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:1161
SwTextFly()
Definition: txtfly.cxx:309
SwTwips GetMinBottom() const
Definition: txtfly.hxx:342
void SetNextTop(tools::Long nNew) const
Definition: txtfly.hxx:357
std::unique_ptr< SwAnchoredObjList > mpAnchoredObjList
Definition: txtfly.hxx:127
bool mbIgnoreContour
Definition: txtfly.hxx:136
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:630
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:1151
void SetIgnoreObjsInHeaderFooter(const bool bNew)
Definition: txtfly.hxx:377
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:133
void SetTopRule()
Definition: txtfly.hxx:314
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:1314
SwTwips GetMaxBottom(const SwBreakPortion &rPortion, const SwTextFormatInfo &rInfo) const
Gets the maximum of the fly frame bottoms.
Definition: txtfly.cxx:999
void SetIgnoreContour(bool bNew)
Definition: txtfly.hxx:372
void SetIgnoreCurrentFrame(bool bNew)
Definition: txtfly.hxx:367
tools::Long m_nMinBottom
Definition: txtfly.hxx:129
bool m_bTopRule
Definition: txtfly.hxx:134
SwAnchoredObjList * InitAnchoredObjList()
Definition: txtfly.cxx:827
const SwTextFrame * GetMaster() const
Definition: txtfly.hxx:347
const SwTextFrame * GetMaster_()
Definition: txtfly.cxx:441
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:1050
bool Relax()
Definition: txtfly.hxx:333
const SwPageFrame * m_pPage
Definition: txtfly.hxx:123
void DrawFlyRect(OutputDevice *pOut, const SwRect &rRect)
Two subtleties needs to be mentioned:
Definition: txtfly.cxx:570
const SwAnchoredObject * mpCurrAnchoredObj
Definition: txtfly.hxx:124
css::text::WrapTextMode GetSurroundForTextWrap(const SwAnchoredObject *pAnchoredObj) const
Definition: txtfly.cxx:1379
bool mbIgnoreObjsInHeaderFooter
boolean, indicating if objects in page header|footer are considered for text frames not in page heade...
Definition: txtfly.hxx:141
SwRect GetFrame(const SwRect &rPortion) const
Definition: txtfly.hxx:362
SwTwips CalcMinBottom() const
Definition: txtfly.cxx:965
const SwTextFrame * m_pCurrFrame
Definition: txtfly.hxx:125
const SwTextFrame * m_pMaster
Definition: txtfly.hxx:126
bool IsOn() const
Definition: txtfly.hxx:319
bool mbIgnoreCurrentFrame
Definition: txtfly.hxx:135
SwAnchoredObjList * GetAnchoredObjList() const
Definition: txtfly.hxx:307
tools::Long m_nNextTop
Definition: txtfly.hxx:130
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:1250
tools::Long GetNextTop() const
Definition: txtfly.hxx:352
SwNodeOffset m_nCurrFrameNodeIndex
Stores the upper edge of the "next" frame.
Definition: txtfly.hxx:131
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:449
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:163
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