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 #ifndef INCLUDED_SW_SOURCE_CORE_INC_TXTFLY_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_TXTFLY_HXX
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 <memory>
28 #include <vector>
29 
30 class OutputDevice;
31 class SwPageFrame;
32 class SdrObject;
33 class SwFormat;
34 class SwAnchoredObject;
35 class SwTextFrame;
36 class SwDrawTextInfo;
38 
39 typedef std::vector< SwAnchoredObject* > SwAnchoredObjList;
40 
45 
46 #define POLY_CNT 20
47 #define POLY_MIN 5
48 #define POLY_MAX 4000
49 
50 void ClrContourCache( const SdrObject *pObj );
51 
53 {
54  friend void ClrContourCache();
55  struct CacheItem
56  {
58  std::unique_ptr<TextRanger> mxTextRanger;
59  };
60  std::vector<CacheItem> mvItems;
61  long nPntCnt;
62  SwRect ContourRect( const SwFormat* pFormat, const SdrObject* pObj,
63  const SwTextFrame* pFrame, const SwRect &rLine, const long nXPos,
64  const bool bRight );
65 
66 public:
69  const SdrObject* GetObject( sal_uInt16 nPos ) const{ return mvItems[ nPos ].mpSdrObj; }
70  sal_uInt16 GetCount() const { return mvItems.size(); }
71  void ClrObject( sal_uInt16 nPos );
72 
80  static SwRect CalcBoundRect( const SwAnchoredObject* pAnchoredObj,
81  const SwRect &rLine,
82  const SwTextFrame* pFrame,
83  const long nXPos,
84  const bool bRight );
85 };
86 
120 {
125  std::unique_ptr<SwAnchoredObjList> mpAnchoredObjList;
126 
128  long nNextTop;
130 
131  bool bOn : 1;
132  bool bTopRule: 1;
135 
140 
149  SwRect GetFrame_( const SwRect &rPortion ) const;
150 
152 
154 
159  bool ForEach( const SwRect &rRect, SwRect* pRect, bool bAvoid ) const;
160 
175  css::text::WrapTextMode GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const;
176 
181  void CalcRightMargin( SwRect &rFly,
182  SwAnchoredObjList::size_type nPos,
183  const SwRect &rLine ) const;
184 
189  void CalcLeftMargin( SwRect &rFly,
190  SwAnchoredObjList::size_type nPos,
191  const SwRect &rLine ) const;
192 
196  SwAnchoredObjList::size_type GetPos( const SwAnchoredObject* pAnchoredObj ) const;
197 
198  bool GetTop( const SwAnchoredObject* _pAnchoredObj,
199  const bool bInFootnote,
200  const bool bInFooterOrHeader );
201 
202  SwTwips CalcMinBottom() const;
203 
204  const SwTextFrame* GetMaster_();
205 
206 public:
207 
208  SwTextFly();
209  SwTextFly( const SwTextFrame *pFrame );
210  SwTextFly( const SwTextFly& rTextFly );
211  ~SwTextFly();
212 
213  void CtorInitTextFly( const SwTextFrame *pFrame );
214 
215  void SetTopRule();
216 
217  SwRect GetFrame( const SwRect &rPortion ) const;
218  bool IsOn() const;
219 
226  bool Relax( const SwRect &rRect );
227  bool Relax();
228 
229  SwTwips GetMinBottom() const;
230  const SwTextFrame* GetMaster() const;
231 
232  // This temporary variable needs to be manipulated in const methods
233  long GetNextTop() const;
234  void SetNextTop( long nNew ) const;
235 
245  SwRect AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
246  const SwRect& rRect ) const;
247 
258  void DrawTextOpaque( SwDrawTextInfo &rInf );
259 
268  void DrawFlyRect( OutputDevice* pOut, const SwRect &rRect );
269 
276  bool IsAnyFrame( const SwRect &rLine ) const;
277 
282  bool IsAnyFrame() const;
283 
293  bool IsAnyObj( const SwRect& rRect ) const;
294 
295  void SetIgnoreCurrentFrame( bool bNew );
296  void SetIgnoreContour( bool bNew );
297 
298  void SetIgnoreObjsInHeaderFooter( const bool bNew );
299 };
300 
302 {
303  return mpAnchoredObjList
304  ? mpAnchoredObjList.get()
305  : const_cast<SwTextFly*>(this)->InitAnchoredObjList();
306 }
307 
309 {
310  bTopRule = false;
311 }
312 
313 inline bool SwTextFly::IsOn() const
314 {
315  return bOn;
316 }
317 
318 inline bool SwTextFly::Relax( const SwRect &rRect )
319 {
320  if (bOn)
321  {
322  bOn = IsAnyFrame( rRect );
323  }
324  return bOn;
325 }
326 
327 inline bool SwTextFly::Relax()
328 {
329  if (bOn)
330  {
331  bOn = IsAnyFrame();
332  }
333  return bOn;
334 }
335 
337 {
339 }
340 
341 inline const SwTextFrame* SwTextFly::GetMaster() const
342 {
343  return m_pMaster ? m_pMaster : const_cast<SwTextFly*>(this)->GetMaster_();
344 }
345 
346 inline long SwTextFly::GetNextTop() const
347 {
348  return nNextTop;
349 }
350 
351 inline void SwTextFly::SetNextTop( long nNew ) const
352 {
353  const_cast<SwTextFly*>(this)->nNextTop = nNew;
354 }
355 
356 inline SwRect SwTextFly::GetFrame( const SwRect &rRect ) const
357 {
358  return bOn ? GetFrame_( rRect ) : SwRect();
359 }
360 
361 inline void SwTextFly::SetIgnoreCurrentFrame( bool bNew )
362 {
363  mbIgnoreCurrentFrame = bNew;
364 }
365 
366 inline void SwTextFly::SetIgnoreContour( bool bNew )
367 {
368  mbIgnoreContour = bNew;
369 }
370 
371 inline void SwTextFly::SetIgnoreObjsInHeaderFooter( const bool bNew )
372 {
374 }
375 
376 #endif
377 
378 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwAnchoredObjList * GetAnchoredObjList() const
Definition: txtfly.hxx:301
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
SwTwips GetMinBottom() const
Definition: txtfly.hxx:336
void SetIgnoreCurrentFrame(bool bNew)
Definition: txtfly.hxx:361
long nNextTop
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 to 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:139
bool bTopRule
Definition: txtfly.hxx:132
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:127
sal_uIntPtr sal_uLong
void DrawFlyRect(OutputDevice *pOut, const SwRect &rRect)
Two subtleties needs to be mentioned:
Definition: txtfly.cxx:568
The purpose of this class is to be the universal interface between formatting/text output and the pos...
Definition: txtfly.hxx:119
SwAnchoredObjList * InitAnchoredObjList()
Definition: txtfly.cxx:825
bool bOn
Definition: txtfly.hxx:131
long SwTwips
Definition: swtypes.hxx:49
SwContourCache * pContourCache
Contour-cache global variable, initialized/destroyed in txtinit.cxx and needed in txtfly...
Definition: txtinit.cxx:31
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwTwips CalcMinBottom() const
Definition: txtfly.cxx:957
const SwAnchoredObject * mpCurrAnchoredObj
Definition: txtfly.hxx:122
bool mbIgnoreCurrentFrame
Definition: txtfly.hxx:133
const SwTextFrame * m_pMaster
Definition: txtfly.hxx:124
const SwPageFrame * pPage
Definition: txtfly.hxx:121
SwRect GetFrame(const SwRect &rPortion) const
Definition: txtfly.hxx:356
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:1191
SwRect ContourRect(const SwFormat *pFormat, const SdrObject *pObj, const SwTextFrame *pFrame, const SwRect &rLine, const long nXPos, const bool bRight)
Definition: txtfly.cxx:202
sal_uLong m_nCurrFrameNodeIndex
Stores the upper edge of the "next" frame.
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:43
void SetIgnoreObjsInHeaderFooter(const bool bNew)
Definition: txtfly.hxx:371
std::vector< CacheItem > mvItems
Definition: txtfly.hxx:60
const SdrObject * mpSdrObj
Definition: txtfly.hxx:57
void SetIgnoreContour(bool bNew)
Definition: txtfly.hxx:366
long nPntCnt
Definition: txtfly.hxx:61
static SwRect CalcBoundRect(const SwAnchoredObject *pAnchoredObj, const SwRect &rLine, const SwTextFrame *pFrame, const long nXPos, const bool bRight)
Computes the rectangle that will cover the object in the given line.
Definition: txtfly.cxx:154
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:628
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:1255
const SdrObject * GetObject(sal_uInt16 nPos) const
Definition: txtfly.hxx:69
bool mbIgnoreContour
Definition: txtfly.hxx:134
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:1102
A page of the document layout.
Definition: pagefrm.hxx:40
sal_uInt16 GetCount() const
Definition: txtfly.hxx:70
bool Relax()
Definition: txtfly.hxx:327
std::vector< SwAnchoredObject * > SwAnchoredObjList
Definition: txtfly.hxx:37
void SetTopRule()
Definition: txtfly.hxx:308
SwTextFly()
Definition: txtfly.cxx:306
std::unique_ptr< TextRanger > mxTextRanger
Definition: txtfly.hxx:58
const SwTextFrame * m_pCurrFrame
Definition: txtfly.hxx:123
SwAnchoredObjList::size_type GetPos(const SwAnchoredObject *pAnchoredObj) const
Definition: txtfly.cxx:1092
std::unique_ptr< SwAnchoredObjList > mpAnchoredObjList
Definition: txtfly.hxx:125
const SwTextFrame * GetMaster() const
Definition: txtfly.hxx:341
friend void ClrContourCache()
Definition: txtfly.cxx:144
void ClrContourCache(const SdrObject *pObj)
Definition: txtfly.cxx:133
long GetNextTop() const
Definition: txtfly.hxx:346
~SwTextFly()
Definition: txtfly.cxx:349
bool ForEach(const SwRect &rRect, SwRect *pRect, bool bAvoid) const
Look for the first object which overlaps with the rectangle.
Definition: txtfly.cxx:991
css::text::WrapTextMode GetSurroundForTextWrap(const SwAnchoredObject *pAnchoredObj) const
Definition: txtfly.cxx:1320
void SetNextTop(long nNew) const
Definition: txtfly.hxx:351
bool IsOn() const
Definition: txtfly.hxx:313
void CtorInitTextFly(const SwTextFrame *pFrame)
Definition: txtfly.cxx:353
long nMinBottom
Definition: txtfly.hxx:127