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 <tools/solar.h>
24 #include <swtypes.hxx>
25 #include <swrect.hxx>
26 #include <com/sun/star/text/WrapTextMode.hpp>
27 #include <nodeoffset.hxx>
28 #include <memory>
29 #include <vector>
30 
31 class OutputDevice;
32 class SwPageFrame;
33 class SdrObject;
34 class SwFormat;
35 class SwAnchoredObject;
36 class SwTextFrame;
37 class SwDrawTextInfo;
39 
40 typedef std::vector< SwAnchoredObject* > SwAnchoredObjList;
41 
46 
47 #define POLY_CNT 20
48 #define POLY_MIN 5
49 #define POLY_MAX 4000
50 
51 void ClrContourCache( const SdrObject *pObj );
52 
54 {
55  friend void ClrContourCache();
56  struct CacheItem
57  {
59  std::unique_ptr<TextRanger> mxTextRanger;
60  };
61  std::vector<CacheItem> mvItems;
63  SwRect ContourRect( const SwFormat* pFormat, const SdrObject* pObj,
64  const SwTextFrame* pFrame, const SwRect &rLine, const tools::Long nXPos,
65  const bool bRight );
66 
67 public:
70  const SdrObject* GetObject( sal_uInt16 nPos ) const{ return mvItems[ nPos ].mpSdrObj; }
71  sal_uInt16 GetCount() const { return mvItems.size(); }
72  void ClrObject( sal_uInt16 nPos );
73 
81  static SwRect CalcBoundRect( const SwAnchoredObject* pAnchoredObj,
82  const SwRect &rLine,
83  const SwTextFrame* pFrame,
84  const tools::Long nXPos,
85  const bool bRight );
86 };
87 
121 {
126  std::unique_ptr<SwAnchoredObjList> mpAnchoredObjList;
127 
131 
132  bool m_bOn : 1;
133  bool m_bTopRule: 1;
136 
141 
150  SwRect GetFrame_( const SwRect &rPortion ) const;
151 
153 
155 
160  bool ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const;
161 
176  css::text::WrapTextMode GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const;
177 
182  void CalcRightMargin( SwRect &rFly,
183  SwAnchoredObjList::size_type nPos,
184  const SwRect &rLine ) const;
185 
190  void CalcLeftMargin( SwRect &rFly,
191  SwAnchoredObjList::size_type nPos,
192  const SwRect &rLine ) const;
193 
197  SwAnchoredObjList::size_type GetPos( const SwAnchoredObject* pAnchoredObj ) const;
198 
199  bool GetTop( const SwAnchoredObject* _pAnchoredObj,
200  const bool bInFootnote,
201  const bool bInFooterOrHeader );
202 
203  SwTwips CalcMinBottom() const;
204 
205  const SwTextFrame* GetMaster_();
206 
207 public:
208 
209  SwTextFly();
210  SwTextFly( const SwTextFrame *pFrame );
211  SwTextFly( const SwTextFly& rTextFly );
212  ~SwTextFly();
213 
214  void CtorInitTextFly( const SwTextFrame *pFrame );
215 
216  void SetTopRule();
217 
218  SwRect GetFrame( const SwRect &rPortion ) const;
219  bool IsOn() const;
220 
227  bool Relax( const SwRect &rRect );
228  bool Relax();
229 
230  SwTwips GetMinBottom() const;
231  const SwTextFrame* GetMaster() const;
232 
233  // This temporary variable needs to be manipulated in const methods
234  tools::Long GetNextTop() const;
235  void SetNextTop( tools::Long nNew ) const;
236 
246  SwRect AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
247  const SwRect& rRect ) const;
248 
259  void DrawTextOpaque( SwDrawTextInfo &rInf );
260 
269  void DrawFlyRect( OutputDevice* pOut, const SwRect &rRect );
270 
277  bool IsAnyFrame( const SwRect &rLine ) const;
278 
283  bool IsAnyFrame() const;
284 
294  bool IsAnyObj( const SwRect& rRect ) const;
295 
296  void SetIgnoreCurrentFrame( bool bNew );
297  void SetIgnoreContour( bool bNew );
298 
299  void SetIgnoreObjsInHeaderFooter( const bool bNew );
300 };
301 
303 {
304  return mpAnchoredObjList
305  ? mpAnchoredObjList.get()
306  : const_cast<SwTextFly*>(this)->InitAnchoredObjList();
307 }
308 
310 {
311  m_bTopRule = false;
312 }
313 
314 inline bool SwTextFly::IsOn() const
315 {
316  return m_bOn;
317 }
318 
319 inline bool SwTextFly::Relax( const SwRect &rRect )
320 {
321  if (m_bOn)
322  {
323  m_bOn = IsAnyFrame( rRect );
324  }
325  return m_bOn;
326 }
327 
328 inline bool SwTextFly::Relax()
329 {
330  if (m_bOn)
331  {
332  m_bOn = IsAnyFrame();
333  }
334  return m_bOn;
335 }
336 
338 {
340 }
341 
342 inline const SwTextFrame* SwTextFly::GetMaster() const
343 {
344  return m_pMaster ? m_pMaster : const_cast<SwTextFly*>(this)->GetMaster_();
345 }
346 
348 {
349  return m_nNextTop;
350 }
351 
352 inline void SwTextFly::SetNextTop( tools::Long nNew ) const
353 {
354  const_cast<SwTextFly*>(this)->m_nNextTop = nNew;
355 }
356 
357 inline SwRect SwTextFly::GetFrame( const SwRect &rRect ) const
358 {
359  return m_bOn ? GetFrame_( rRect ) : SwRect();
360 }
361 
362 inline void SwTextFly::SetIgnoreCurrentFrame( bool bNew )
363 {
364  mbIgnoreCurrentFrame = bNew;
365 }
366 
367 inline void SwTextFly::SetIgnoreContour( bool bNew )
368 {
369  mbIgnoreContour = bNew;
370 }
371 
372 inline void SwTextFly::SetIgnoreObjsInHeaderFooter( const bool bNew )
373 {
375 }
376 
377 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwAnchoredObjList * GetAnchoredObjList() const
Definition: txtfly.hxx:302
void SetNextTop(tools::Long nNew) const
Definition: txtfly.hxx:352
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:159
SwTwips GetMinBottom() const
Definition: txtfly.hxx:337
void SetIgnoreCurrentFrame(bool bNew)
Definition: txtfly.hxx:362
tools::Long m_nMinBottom
Definition: txtfly.hxx:128
bool IsAnyFrame() const
Same as IsAnyFrame(const SwRect&), but uses the current frame print area.
Definition: txtfly.cxx:394
bool IsAnyObj(const SwRect &rRect) const
true when a frame or DrawObj must be taken in account.
Definition: txtfly.cxx:405
bool mbIgnoreObjsInHeaderFooter
boolean, indicating if objects in page header|footer are considered for text frames not in page heade...
Definition: txtfly.hxx:140
SwRect GetFrame_(const SwRect &rPortion) const
This method will be called during the LineIter formatting.
Definition: txtfly.cxx:376
const SwTextFrame * GetMaster_()
Definition: txtfly.cxx:438
void ClrObject(sal_uInt16 nPos)
Definition: txtfly.cxx:128
long Long
void DrawFlyRect(OutputDevice *pOut, const SwRect &rRect)
Two subtleties needs to be mentioned:
Definition: txtfly.cxx:567
The purpose of this class is to be the universal interface between formatting/text output and the pos...
Definition: txtfly.hxx:120
SwAnchoredObjList * InitAnchoredObjList()
Definition: txtfly.cxx:824
SwNodeOffset m_nCurrFrameNodeIndex
Stores the upper edge of the "next" frame.
Definition: txtfly.hxx:130
SwContourCache * pContourCache
Contour-cache global variable, initialized/destroyed in txtinit.cxx and needed in txtfly...
Definition: txtinit.cxx:30
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
tools::Long mnPointCount
Definition: txtfly.hxx:62
SwTwips CalcMinBottom() const
Definition: txtfly.cxx:962
const SwAnchoredObject * mpCurrAnchoredObj
Definition: txtfly.hxx:123
bool mbIgnoreCurrentFrame
Definition: txtfly.hxx:134
const SwTextFrame * m_pMaster
Definition: txtfly.hxx:125
SwRect GetFrame(const SwRect &rPortion) const
Definition: txtfly.hxx:357
wrapper class for the positioning of Writer fly frames and drawing objects
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:1196
tools::Long m_nNextTop
Definition: txtfly.hxx:129
void DrawTextOpaque(SwDrawTextInfo &rInf)
This method is called by DrawText().
Definition: txtfly.cxx:446
Base class for various Writer styles.
Definition: format.hxx:46
void SetIgnoreObjsInHeaderFooter(const bool bNew)
Definition: txtfly.hxx:372
std::vector< CacheItem > mvItems
Definition: txtfly.hxx:61
const SdrObject * mpSdrObj
Definition: txtfly.hxx:58
void SetIgnoreContour(bool bNew)
Definition: txtfly.hxx:367
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:155
bool GetTop(const SwAnchoredObject *_pAnchoredObj, const bool bInFootnote, const bool bInFooterOrHeader)
#i26945# - change first parameter Now it's the instance of the floating screen obj...
Definition: txtfly.cxx:627
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:1260
const SdrObject * GetObject(sal_uInt16 nPos) const
Definition: txtfly.hxx:70
bool mbIgnoreContour
Definition: txtfly.hxx:135
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:1107
A page of the document layout.
Definition: pagefrm.hxx:57
sal_uInt16 GetCount() const
Definition: txtfly.hxx:71
tools::Long GetNextTop() const
Definition: txtfly.hxx:347
tools::Long SwTwips
Definition: swtypes.hxx:52
bool m_bTopRule
Definition: txtfly.hxx:133
bool Relax()
Definition: txtfly.hxx:328
std::vector< SwAnchoredObject * > SwAnchoredObjList
Definition: txtfly.hxx:38
void SetTopRule()
Definition: txtfly.hxx:309
SwTextFly()
Definition: txtfly.cxx:306
std::unique_ptr< TextRanger > mxTextRanger
Definition: txtfly.hxx:59
bool m_bOn
Definition: txtfly.hxx:132
const SwTextFrame * m_pCurrFrame
Definition: txtfly.hxx:124
SwAnchoredObjList::size_type GetPos(const SwAnchoredObject *pAnchoredObj) const
Definition: txtfly.cxx:1097
std::unique_ptr< SwAnchoredObjList > mpAnchoredObjList
Definition: txtfly.hxx:126
const SwTextFrame * GetMaster() const
Definition: txtfly.hxx:342
friend void ClrContourCache()
Definition: txtfly.cxx:145
const SwPageFrame * m_pPage
Definition: txtfly.hxx:122
void ClrContourCache(const SdrObject *pObj)
Definition: txtfly.cxx:134
~SwTextFly()
Definition: txtfly.cxx:349
SwRect ContourRect(const SwFormat *pFormat, const SdrObject *pObj, const SwTextFrame *pFrame, const SwRect &rLine, const tools::Long nXPos, const bool bRight)
Definition: txtfly.cxx:203
bool ForEach(const SwRect &rRect, SwRect *pRect, bool bAvoid) const
Look for the first object which overlaps with the rectangle.
Definition: txtfly.cxx:996
css::text::WrapTextMode GetSurroundForTextWrap(const SwAnchoredObject *pAnchoredObj) const
Definition: txtfly.cxx:1325
bool IsOn() const
Definition: txtfly.hxx:314
void CtorInitTextFly(const SwTextFrame *pFrame)
Definition: txtfly.cxx:353