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
155public:
157private:
158
163 bool ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const;
164
179 css::text::WrapTextMode GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const;
180
185 void CalcRightMargin( SwRect &rFly,
186 SwAnchoredObjList::size_type nPos,
187 const SwRect &rLine ) const;
188
193 void CalcLeftMargin( SwRect &rFly,
194 SwAnchoredObjList::size_type nPos,
195 const SwRect &rLine ) const;
196
200 SwAnchoredObjList::size_type GetPos( const SwAnchoredObject* pAnchoredObj ) const;
201
202 bool GetTop( const SwAnchoredObject* _pAnchoredObj,
203 const bool bInFootnote,
204 const bool bInFooterOrHeader );
205
206 SwTwips CalcMinBottom() const;
207
208 const SwTextFrame* GetMaster_();
209
210public:
211
212 SwTextFly();
213 SwTextFly( const SwTextFrame *pFrame );
214 SwTextFly( const SwTextFly& rTextFly );
215 ~SwTextFly();
216
217 void CtorInitTextFly( const SwTextFrame *pFrame );
218
219 void SetTopRule();
220
221 SwRect GetFrame( const SwRect &rPortion ) const;
222 bool IsOn() const;
223
230 bool Relax( const SwRect &rRect );
231 bool Relax();
232
233 SwTwips GetMinBottom() const;
234
236 SwTwips GetMaxBottom(const SwBreakPortion& rPortion, const SwTextFormatInfo& rInfo) const;
237
238 const SwTextFrame* GetMaster() const;
239
240 // This temporary variable needs to be manipulated in const methods
241 tools::Long GetNextTop() const;
242 void SetNextTop( tools::Long nNew ) const;
243
253 SwRect AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
254 const SwRect& rRect ) const;
255
266 void DrawTextOpaque( SwDrawTextInfo &rInf );
267
276 void DrawFlyRect( OutputDevice* pOut, const SwRect &rRect );
277
284 bool IsAnyFrame( const SwRect &rLine ) const;
285
290 bool IsAnyFrame() const;
291
301 bool IsAnyObj( const SwRect& rRect ) const;
302
303 void SetIgnoreCurrentFrame( bool bNew );
304 void SetIgnoreContour( bool bNew );
305
306 void SetIgnoreObjsInHeaderFooter( const bool bNew );
307
308 SwRect GetFrameArea() const;
309};
310
312{
313 return mpAnchoredObjList
314 ? mpAnchoredObjList.get()
315 : const_cast<SwTextFly*>(this)->InitAnchoredObjList();
316}
317
319{
320 m_bTopRule = false;
321}
322
323inline bool SwTextFly::IsOn() const
324{
325 return m_bOn;
326}
327
328inline bool SwTextFly::Relax( const SwRect &rRect )
329{
330 if (m_bOn)
331 {
332 m_bOn = IsAnyFrame( rRect );
333 }
334 return m_bOn;
335}
336
337inline bool SwTextFly::Relax()
338{
339 if (m_bOn)
340 {
341 m_bOn = IsAnyFrame();
342 }
343 return m_bOn;
344}
345
347{
349}
350
352{
353 return m_pMaster ? m_pMaster : const_cast<SwTextFly*>(this)->GetMaster_();
354}
355
357{
358 return m_nNextTop;
359}
360
361inline void SwTextFly::SetNextTop( tools::Long nNew ) const
362{
363 const_cast<SwTextFly*>(this)->m_nNextTop = nNew;
364}
365
366inline SwRect SwTextFly::GetFrame( const SwRect &rRect ) const
367{
368 return m_bOn ? GetFrame_( rRect ) : SwRect();
369}
370
371inline void SwTextFly::SetIgnoreCurrentFrame( bool bNew )
372{
374}
375
376inline void SwTextFly::SetIgnoreContour( bool bNew )
377{
378 mbIgnoreContour = bNew;
379}
380
381inline void SwTextFly::SetIgnoreObjsInHeaderFooter( const bool bNew )
382{
384}
385
386/* 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:59
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:1173
SwTextFly()
Definition: txtfly.cxx:309
SwTwips GetMinBottom() const
Definition: txtfly.hxx:346
void SetNextTop(tools::Long nNew) const
Definition: txtfly.hxx:361
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:1163
void SetIgnoreObjsInHeaderFooter(const bool bNew)
Definition: txtfly.hxx:381
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:318
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:1326
SwTwips GetMaxBottom(const SwBreakPortion &rPortion, const SwTextFormatInfo &rInfo) const
Gets the maximum of the fly frame bottoms.
Definition: txtfly.cxx:1004
void SetIgnoreContour(bool bNew)
Definition: txtfly.hxx:376
void SetIgnoreCurrentFrame(bool bNew)
Definition: txtfly.hxx:371
tools::Long m_nMinBottom
Definition: txtfly.hxx:129
bool m_bTopRule
Definition: txtfly.hxx:134
SwAnchoredObjList * InitAnchoredObjList()
Definition: txtfly.cxx:843
const SwTextFrame * GetMaster() const
Definition: txtfly.hxx:351
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:1062
bool Relax()
Definition: txtfly.hxx:337
SwRect GetFrameArea() const
Definition: txtfly.cxx:826
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:1391
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:366
SwTwips CalcMinBottom() const
Definition: txtfly.cxx:970
const SwTextFrame * m_pCurrFrame
Definition: txtfly.hxx:125
const SwTextFrame * m_pMaster
Definition: txtfly.hxx:126
bool IsOn() const
Definition: txtfly.hxx:323
bool mbIgnoreCurrentFrame
Definition: txtfly.hxx:135
SwAnchoredObjList * GetAnchoredObjList() const
Definition: txtfly.hxx:311
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:1262
tools::Long GetNextTop() const
Definition: txtfly.hxx:356
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: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