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 class SwFlyFrame;
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
52  // #i28701 - page frame the object is registered at
53  // note: no page frame for as-character anchored objects
55  // current relative position (relative to anchor position of anchor frame)
57 
58  // for to-character anchored objects:
59  // Last known anchor character rectangle.
60  // Used to decide, if invalidation has to been performed, if anchor position
61  // has changed, and used to position object.
63 
64  // for to-character anchored objects:
65  // Last known top of line, in which the anchor character is in.
66  // Used to decide, if invalidation has to been performed, if anchor position
67  // has changed, and used to position object.
69 
70  // for to-paragraph and to-character anchored objects:
71  // Layout frame vertical position is orient at - typically it's the upper
72  // of the anchor frame, but it could also by the upper of a follow or
73  // a following layout frame in the text flow.
75 
76  // i#i28701 boolean, indicating that the object
77  // positioning algorithm is in progress.
79 
80  // Booleans needed for the layout process.
81  // Values only of relevance for to-paragraph and to-character anchored
82  // floating screen object, for whose the 'straight-forward positioning
83  // process are applied
84  // Otherwise value of <mbConsiderForTextWrap> is treated as <true>,
85  // value of <mbPositionLocked> is treated as <false> and
86  // value of <mbRestartLayoutProcess> is treated as <false>.
87  // i#35911 - add boolean <mbClearEnvironment>
88  // Indicates that due to its position and wrapping style its layout
89  // environment is cleared - all content is moved forward.
90  // Treated as <false>, if not the 'straight-forward positioning process"
91  // is applied.
94  // boolean needed to keep position of
95  // anchored object locked due to special object positioning for sections.
97 
100 
101  // i#i3317 - boolean, indicating that temporarily
102  // the wrapping style influence of the anchored object has to be
103  // considered during its positioning.
104  // This boolean is used, if compatibility option 'Consider wrapping style
105  // influence on object positioning' is OFF and a positioning loop is
106  // detected in method <SwFlyAtContentFrame::MakeAll()> or method
107  // <SwAnchoredDrawObject::MakeObjPosAnchoredAtPara()>.
108  // The boolean is reset to <false>, when the layout process for a
109  // page frame starts.
111 
115 
121  void SetPositioningInProgress( const bool _bPosInProgress )
122  {
123  mbPositioningInProgress = _bPosInProgress;
124  }
125 
141  void CheckCharRect( const SwFormatAnchor& _rAnch,
142  const SwTextFrame& _rAnchorCharFrame );
143 
158  void CheckTopOfLine( const SwFormatAnchor& _rAnch,
159  const SwTextFrame& _rAnchorCharFrame );
160 
161  // method <sw_HideObj(..)> sets needed data structure values for the
162  // object positioning
163  friend bool sw_HideObj( const SwTextFrame& _rFrame,
164  const RndStdIds _eAnchorType,
165  SwPosition const& rAnchorPos,
166  SwAnchoredObject* _pAnchoredObj );
167  protected:
169 
170  void SetVertPosOrientFrame( const SwLayoutFrame& _rVertPosOrientFrame );
171 
175  virtual void RegisterAtCorrectPage() = 0;
176 
178  virtual void ObjectAttachedToAnchorFrame();
179 
183  bool ConsiderObjWrapInfluenceOfOtherObjs() const;
184 
188  void SetTmpConsiderWrapInfluenceOfOtherObjs();
189 
190  virtual bool SetObjTop_( const SwTwips _nTop) = 0;
191  virtual bool SetObjLeft_( const SwTwips _nLeft) = 0;
192 
193  virtual SwRect GetObjBoundRect() const = 0;
194  public:
195 
196  virtual ~SwAnchoredObject();
197 
198  // accessors to member <mpDrawObj>
199  void SetDrawObj( SdrObject& _rDrawObj );
200  const SdrObject* GetDrawObj() const { return mpDrawObj; }
201  SdrObject* DrawObj() { return mpDrawObj; }
202 
203  // accessors to member <mpAnchorFrame>
204  const SwFrame* GetAnchorFrame() const { return mpAnchorFrame; }
206  void ChgAnchorFrame( SwFrame* _pNewAnchorFrame );
214  SwFrame* GetAnchorFrameContainingAnchPos();
215 
216  SwPageFrame* GetPageFrame() { return mpPageFrame; }
217  const SwPageFrame* GetPageFrame() const { return mpPageFrame; }
218  void SetPageFrame( SwPageFrame* _pNewPageFrame );
219 
235  SwPageFrame* FindPageFrameOfAnchor();
236 
244  SwTextFrame* FindAnchorCharFrame();
245 
246  // accessors to data of position calculation:
247  // frame vertical position is orient at
249  {
250  return mpVertPosOrientFrame;
251  }
252  // method to clear member <mpVertPosOrientFrame>
253  void ClearVertPosOrientFrame();
254 
266  void CheckCharRectAndTopOfLine( const bool _bCheckForParaPorInf );
267 
268  // accessors to member <maLastCharRect>
269  const SwRect& GetLastCharRect() const { return maLastCharRect;}
270  SwTwips GetRelCharX( const SwFrame* pFrame ) const;
271  SwTwips GetRelCharY( const SwFrame* pFrame ) const;
272  void AddLastCharY( tools::Long nDiff );
273  void ResetLastCharRectHeight();
274 
275  // accessor to member <nmLastTopOfLine>
276  SwTwips GetLastTopOfLine() const { return mnLastTopOfLine;}
277  void AddLastTopOfLineY( SwTwips _nDiff );
278 
280  void ClearCharRectAndTopOfLine();
281 
285  virtual void MakeObjPos() = 0;
286 
289  {
290  return mbPositioningInProgress;
291  }
292 
294  bool InvalidationOfPosAllowed() const;
295 
297  virtual void InvalidateObjPos() = 0;
298 
299  virtual void RegisterAtPage(SwPageFrame &) = 0;
300 
305  void InvalidateObjPosForConsiderWrapInfluence();
306 
308  virtual void NotifyBackground( SwPageFrame* _pPageFrame,
309  const SwRect& _rRect,
310  PrepareHint _eHint ) = 0;
311 
312  // accessors to the current relative position (relative to anchor
313  // position of anchor frame)
314  const Point& GetCurrRelPos() const { return maRelPos;}
315  void SetCurrRelPos( Point _aRelPos );
316 
317  // accessors to the format
318  virtual SwFrameFormat& GetFrameFormat() = 0;
319  virtual const SwFrameFormat& GetFrameFormat() const = 0;
320 
321  // accessors to the object area and its position
322  virtual SwRect GetObjRect() const = 0;
323 
324  void SetObjTop( const SwTwips _nTop);
325  void SetObjLeft( const SwTwips _nLeft);
326 
333  virtual void UpdateLayoutDir();
334 
336  const SwRect& GetObjRectWithSpaces() const;
337 
339  {
340  mbObjRectWithSpacesValid = false;
341  }
342 
349  bool ConsiderObjWrapInfluenceOnObjPos() const;
350 
351  // accessors to booleans for layout process
352  bool ConsiderForTextWrap() const;
353  void SetConsiderForTextWrap( const bool _bConsiderForTextWrap );
354  bool PositionLocked() const;
356  {
357  mbPositionLocked = true;
358  }
360  {
361  if ( !mbKeepPositionLockedForSection )
362  {
363  mbPositionLocked = false;
364  }
365  }
366 
367  void SetKeepPosLocked( const bool _bKeepPosLocked )
368  {
369  mbKeepPositionLockedForSection = _bKeepPosLocked;
370  }
371 
372  bool RestartLayoutProcess() const;
373  void SetRestartLayoutProcess( const bool _bRestartLayoutProcess );
374  // accessors for <mbClearedEnvironment>
375  bool ClearedEnvironment() const;
376  void SetClearedEnvironment( const bool _bClearedEnvironment );
377 
378  // reset booleans for layout process
380  {
381  mbPositioningInProgress = false;
382  mbConsiderForTextWrap = false;
383  mbPositionLocked = false;
384  mbKeepPositionLockedForSection = false;
385  mbRestartLayoutProcess = false;
386  mbClearedEnvironment = false;
387  mbTmpConsiderWrapInfluence = false;
388  }
389 
393  bool HasClearedEnvironment() const;
394 
405  void UpdateObjInSortedList();
406 
412  virtual bool IsFormatPossible() const;
413 
418  static bool IsDraggingOffPageAllowed(const SwFrameFormat*);
419 
420  // accessors to member <mbTmpConsiderWrapInfluence>
421  void SetTmpConsiderWrapInfluence( const bool _bTmpConsiderWrapInfluence );
422  bool IsTmpConsiderWrapInfluence() const { return mbTmpConsiderWrapInfluence;}
423  void ClearTmpConsiderWrapInfluence();
424 
433  bool OverlapsPrevColumn() const;
434 
442  Point GetRelPosToAnchorFrame() const;
443 
463  Point GetRelPosToPageFrame( const bool _bFollowTextFlow,
464  bool& _obRelToTableCell ) const;
465 
473  Point GetRelPosToChar() const;
474 
482  Point GetRelPosToLine() const;
483 
487  virtual void dumpAsXml( xmlTextWriterPtr pWriter ) const;
488 
490  virtual const char* getElementName( ) const { return "SwAnchoredObject"; }
491 
492  virtual const SwFlyFrame* DynCastFlyFrame() const;
493  virtual SwFlyFrame* DynCastFlyFrame();
494 };
495 
498 {
499  private:
501  // boolean indicating old state
502  // of anchored object regarding positioning in progress in order to
503  // consider nested usage of class <SwObjPositioningInProgress>
505 
506  public:
510 };
511 
512 #endif
513 
514 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:315
const SwRect & GetLastCharRect() const
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:159
Marks a position in the document model.
Definition: pam.hxx:36
const SwLayoutFrame * mpVertPosOrientFrame
long Long
SdrObject * mpDrawObj
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:59
PrepareHint
Definition: swtypes.hxx:194
const SdrObject * GetDrawObj() const
FlyAnchors.
Definition: fmtanchr.hxx:34
const SwFrame * mpAnchorFrame
bool IsTmpConsiderWrapInfluence() const
SwPageFrame * mpPageFrame
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
A page of the document layout.
Definition: pagefrm.hxx:57
tools::Long SwTwips
Definition: swtypes.hxx:52
const SwLayoutFrame * GetVertPosOrientFrame() const
bool mbKeepPositionLockedForSection
const Point & GetCurrRelPos() const
void SetPositioningInProgress(const bool _bPosInProgress)
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
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:1487
RndStdIds
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
const SwFrame * GetAnchorFrame() const
void ResetLayoutProcessBools()
bool IsPositioningInProgress() const
is positioning of anchored object in progress
void SetKeepPosLocked(const bool _bKeepPosLocked)
SwFrame * mpAnchorFrame
Frame the object is anchored at.