LibreOffice Module sw (master)  1
anchoredobject.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_INC_ANCHOREDOBJECT_HXX
20 #define INCLUDED_SW_INC_ANCHOREDOBJECT_HXX
21 
22 #include "swtypes.hxx"
23 #include "swrect.hxx"
24 #include <libxml/xmlwriter.h>
25 
26 struct SwPosition;
27 class SdrObject;
28 class SwFrame;
29 class SwLayoutFrame;
30 class SwTextFrame;
31 
32 class SwPageFrame;
33 
34 class SwFrameFormat;
35 class SwFormatAnchor;
36 enum class RndStdIds;
37 
45 {
46  private:
47  // drawing object representing the anchored object in the drawing layer
49  // frame the object is anchored at
51  // #i28701 - page frame the object is registered at
52  // note: no page frame for as-character anchored objects
54  // current relative position (relative to anchor position of anchor frame)
56 
57  // for to-character anchored objects:
58  // Last known anchor character rectangle.
59  // Used to decide, if invalidation has to been performed, if anchor position
60  // has changed, and used to position object.
62 
63  // for to-character anchored objects:
64  // Last known top of line, in which the anchor character is in.
65  // Used to decide, if invalidation has to been performed, if anchor position
66  // has changed, and used to position object.
68 
69  // for to-paragraph and to-character anchored objects:
70  // Layout frame vertical position is orient at - typically it's the upper
71  // of the anchor frame, but it could also by the upper of a follow or
72  // a following layout frame in the text flow.
74 
75  // i#i28701 boolean, indicating that the object
76  // positioning algorithm is in progress.
78 
79  // Booleans needed for the layout process.
80  // Values only of relevance for to-paragraph and to-character anchored
81  // floating screen object, for whose the 'straight-forward positioning
82  // process are applied
83  // Otherwise value of <mbConsiderForTextWrap> is treated as <true>,
84  // value of <mbPositionLocked> is treated as <false> and
85  // value of <mbRestartLayoutProcess> is treated as <false>.
86  // i#35911 - add boolean <mbClearEnvironment>
87  // Indicates that due to its position and wrapping style its layout
88  // environment is cleared - all content is moved forward.
89  // Treated as <false>, if not the 'straight-forward positioning process"
90  // is applied.
93  // boolean needed to keep position of
94  // anchored object locked due to special object positioning for sections.
96 
99 
100  // i#i3317 - boolean, indicating that temporarily
101  // the wrapping style influence of the anchored object has to be
102  // considered during its positioning.
103  // This boolean is used, if compatibility option 'Consider wrapping style
104  // influence on object positioning' is OFF and a positioning loop is
105  // detected in method <SwFlyAtContentFrame::MakeAll()> or method
106  // <SwAnchoredDrawObject::MakeObjPosAnchoredAtPara()>.
107  // The boolean is reset to <false>, when the layout process for a
108  // page frame starts.
110 
114 
120  void SetPositioningInProgress( const bool _bPosInProgress )
121  {
122  mbPositioningInProgress = _bPosInProgress;
123  }
124 
140  void CheckCharRect( const SwFormatAnchor& _rAnch,
141  const SwTextFrame& _rAnchorCharFrame );
142 
157  void CheckTopOfLine( const SwFormatAnchor& _rAnch,
158  const SwTextFrame& _rAnchorCharFrame );
159 
160  // method <sw_HideObj(..)> sets needed data structure values for the
161  // object positioning
162  friend bool sw_HideObj( const SwTextFrame& _rFrame,
163  const RndStdIds _eAnchorType,
164  SwPosition const& rAnchorPos,
165  SwAnchoredObject* _pAnchoredObj );
166  protected:
168 
169  void SetVertPosOrientFrame( const SwLayoutFrame& _rVertPosOrientFrame );
170 
174  virtual void RegisterAtCorrectPage() = 0;
175 
177  virtual void ObjectAttachedToAnchorFrame();
178 
182  bool ConsiderObjWrapInfluenceOfOtherObjs() const;
183 
187  void SetTmpConsiderWrapInfluenceOfOtherObjs();
188 
189  virtual bool SetObjTop_( const SwTwips _nTop) = 0;
190  virtual bool SetObjLeft_( const SwTwips _nLeft) = 0;
191 
192  virtual SwRect GetObjBoundRect() const = 0;
193  public:
194 
195  virtual ~SwAnchoredObject();
196 
197  // accessors to member <mpDrawObj>
198  void SetDrawObj( SdrObject& _rDrawObj );
199  const SdrObject* GetDrawObj() const { return mpDrawObj; }
200  SdrObject* DrawObj() { return mpDrawObj; }
201 
202  // accessors to member <mpAnchorFrame>
203  const SwFrame* GetAnchorFrame() const { return mpAnchorFrame; }
204  SwFrame* AnchorFrame() { return mpAnchorFrame; }
205  void ChgAnchorFrame( SwFrame* _pNewAnchorFrame );
213  SwFrame* GetAnchorFrameContainingAnchPos();
214 
215  SwPageFrame* GetPageFrame() { return mpPageFrame; }
216  const SwPageFrame* GetPageFrame() const { return mpPageFrame; }
217  void SetPageFrame( SwPageFrame* _pNewPageFrame );
218 
234  SwPageFrame* FindPageFrameOfAnchor();
235 
243  SwTextFrame* FindAnchorCharFrame();
244 
245  // accessors to data of position calculation:
246  // frame vertical position is orient at
248  {
249  return mpVertPosOrientFrame;
250  }
251  // method to clear member <mpVertPosOrientFrame>
252  void ClearVertPosOrientFrame();
253 
265  void CheckCharRectAndTopOfLine( const bool _bCheckForParaPorInf );
266 
267  // accessors to member <maLastCharRect>
268  const SwRect& GetLastCharRect() const { return maLastCharRect;}
269  SwTwips GetRelCharX( const SwFrame* pFrame ) const;
270  SwTwips GetRelCharY( const SwFrame* pFrame ) const;
271  void AddLastCharY( long nDiff );
272  void ResetLastCharRectHeight();
273 
274  // accessor to member <nmLastTopOfLine>
275  SwTwips GetLastTopOfLine() const { return mnLastTopOfLine;}
276  void AddLastTopOfLineY( SwTwips _nDiff );
277 
279  void ClearCharRectAndTopOfLine();
280 
284  virtual void MakeObjPos() = 0;
285 
288  {
289  return mbPositioningInProgress;
290  }
291 
293  bool InvalidationOfPosAllowed() const;
294 
296  virtual void InvalidateObjPos() = 0;
297 
302  void InvalidateObjPosForConsiderWrapInfluence();
303 
305  virtual void NotifyBackground( SwPageFrame* _pPageFrame,
306  const SwRect& _rRect,
307  PrepareHint _eHint ) = 0;
308 
309  // accessors to the current relative position (relative to anchor
310  // position of anchor frame)
311  const Point& GetCurrRelPos() const { return maRelPos;}
312  void SetCurrRelPos( Point _aRelPos );
313 
314  // accessors to the format
315  virtual SwFrameFormat& GetFrameFormat() = 0;
316  virtual const SwFrameFormat& GetFrameFormat() const = 0;
317 
318  // accessors to the object area and its position
319  virtual SwRect GetObjRect() const = 0;
320 
321  void SetObjTop( const SwTwips _nTop);
322  void SetObjLeft( const SwTwips _nLeft);
323 
330  virtual void UpdateLayoutDir();
331 
333  const SwRect& GetObjRectWithSpaces() const;
334 
336  {
337  mbObjRectWithSpacesValid = false;
338  }
339 
346  bool ConsiderObjWrapInfluenceOnObjPos() const;
347 
348  // accessors to booleans for layout process
349  bool ConsiderForTextWrap() const;
350  void SetConsiderForTextWrap( const bool _bConsiderForTextWrap );
351  bool PositionLocked() const;
353  {
354  mbPositionLocked = true;
355  }
357  {
358  if ( !mbKeepPositionLockedForSection )
359  {
360  mbPositionLocked = false;
361  }
362  }
363 
364  void SetKeepPosLocked( const bool _bKeepPosLocked )
365  {
366  mbKeepPositionLockedForSection = _bKeepPosLocked;
367  }
368 
369  bool RestartLayoutProcess() const;
370  void SetRestartLayoutProcess( const bool _bRestartLayoutProcess );
371  // accessors for <mbClearedEnvironment>
372  bool ClearedEnvironment() const;
373  void SetClearedEnvironment( const bool _bClearedEnvironment );
374 
375  // reset booleans for layout process
377  {
378  mbPositioningInProgress = false;
379  mbConsiderForTextWrap = false;
380  mbPositionLocked = false;
381  mbKeepPositionLockedForSection = false;
382  mbRestartLayoutProcess = false;
383  mbClearedEnvironment = false;
384  mbTmpConsiderWrapInfluence = false;
385  }
386 
390  bool HasClearedEnvironment() const;
391 
402  void UpdateObjInSortedList();
403 
409  virtual bool IsFormatPossible() const;
410 
411  // accessors to member <mbTmpConsiderWrapInfluence>
412  void SetTmpConsiderWrapInfluence( const bool _bTmpConsiderWrapInfluence );
413  bool IsTmpConsiderWrapInfluence() const { return mbTmpConsiderWrapInfluence;}
414  void ClearTmpConsiderWrapInfluence();
415 
424  bool OverlapsPrevColumn() const;
425 
433  Point GetRelPosToAnchorFrame() const;
434 
454  Point GetRelPosToPageFrame( const bool _bFollowTextFlow,
455  bool& _obRelToTableCell ) const;
456 
464  Point GetRelPosToChar() const;
465 
473  Point GetRelPosToLine() const;
474 
478  virtual void dumpAsXml( xmlTextWriterPtr pWriter ) const;
479 
481  virtual const char* getElementName( ) const { return "SwAnchoredObject"; }
482 };
483 
486 {
487  private:
489  // boolean indicating old state
490  // of anchored object regarding positioning in progress in order to
491  // consider nested usage of class <SwObjPositioningInProgress>
493 
494  public:
498 };
499 
500 #endif
501 
502 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:295
const SwRect & GetLastCharRect() const
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
Marks a position in the document model.
Definition: pam.hxx:35
const SwLayoutFrame * mpVertPosOrientFrame
SdrObject * mpDrawObj
long SwTwips
Definition: swtypes.hxx:49
const SwPageFrame * GetPageFrame() const
Helper class for notify that positioning of an anchored object is in progress.
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
wrapper class for the positioning of Writer fly frames and drawing objects
SdrObject * DrawObj()
SwAnchoredObject * mpAnchoredObj
SwFrame * AnchorFrame()
struct _xmlTextWriter * xmlTextWriterPtr
SwObjPositioningInProgress(SdrObject &_rSdrObj)
virtual const char * getElementName() const
The element name to show in the XML dump.
Style of a layout element.
Definition: frmfmt.hxx:57
PrepareHint
Definition: swtypes.hxx:204
const SdrObject * GetDrawObj() const
FlyAnchors.
Definition: fmtanchr.hxx:34
bool IsTmpConsiderWrapInfluence() const
SwPageFrame * mpPageFrame
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
A page of the document layout.
Definition: pagefrm.hxx:40
const SwLayoutFrame * GetVertPosOrientFrame() const
bool mbKeepPositionLockedForSection
const Point & GetCurrRelPos() const
void SetPositioningInProgress(const bool _bPosInProgress)
SwPageFrame * GetPageFrame()
SwTwips GetLastTopOfLine() const
void InvalidateObjRectWithSpaces() const
bool sw_HideObj(const SwTextFrame &_rFrame, const RndStdIds _eAnchorType, SwPosition const &rAnchorPos, SwAnchoredObject *_pAnchoredObj)
as-character anchored graphics, which are used for a graphic bullet list.
Definition: txtfrm.cxx:1483
RndStdIds
const SwFrame * GetAnchorFrame() const
void ResetLayoutProcessBools()
bool IsPositioningInProgress() const
is positioning of anchored object in progress
void SetKeepPosLocked(const bool _bKeepPosLocked)
SwFrame * mpAnchorFrame