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 <svx/svdobj.hxx>
25#include <libxml/xmlwriter.h>
26
27struct SwPosition;
28class SwFrame;
29class SwLayoutFrame;
30class SwTextFrame;
31class SwFlyFrame;
32class SwPageFrame;
33
34class SwFrameFormat;
35class SwFormatAnchor;
36enum 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
112 bool mbForceNotifyNewBackground = false;
113
117
123 void SetPositioningInProgress( const bool _bPosInProgress )
124 {
125 mbPositioningInProgress = _bPosInProgress;
126 }
127
143 void CheckCharRect( const SwFormatAnchor& _rAnch,
144 const SwTextFrame& _rAnchorCharFrame );
145
160 void CheckTopOfLine( const SwFormatAnchor& _rAnch,
161 const SwTextFrame& _rAnchorCharFrame );
162
163 // method <sw_HideObj(..)> sets needed data structure values for the
164 // object positioning
165 friend bool sw_HideObj( const SwTextFrame& _rFrame,
166 const RndStdIds _eAnchorType,
167 SwFormatAnchor const& rFormatAnchor,
168 SwAnchoredObject* _pAnchoredObj );
169 protected:
171
172 void SetVertPosOrientFrame( const SwLayoutFrame& _rVertPosOrientFrame );
173
177 virtual void RegisterAtCorrectPage() = 0;
178
180 virtual void ObjectAttachedToAnchorFrame();
181
185 bool ConsiderObjWrapInfluenceOfOtherObjs() const;
186
190 void SetTmpConsiderWrapInfluenceOfOtherObjs();
191
192 virtual bool SetObjTop_( const SwTwips _nTop) = 0;
193 virtual bool SetObjLeft_( const SwTwips _nLeft) = 0;
194
195 virtual SwRect GetObjBoundRect() const = 0;
196 public:
197
198 virtual ~SwAnchoredObject();
199
200 // accessors to member <mpDrawObj>
201 void SetDrawObj( SdrObject& _rDrawObj );
202 const SdrObject* GetDrawObj() const { return mpDrawObj.get(); }
203 SdrObject* DrawObj() { return mpDrawObj.get(); }
204 void ClearDrawObj() { mpDrawObj.clear(); }
205
206 // accessors to member <mpAnchorFrame>
207 const SwFrame* GetAnchorFrame() const { return mpAnchorFrame; }
209 void ChgAnchorFrame( SwFrame* _pNewAnchorFrame );
217 SwFrame* GetAnchorFrameContainingAnchPos();
218
219 SwPageFrame* GetPageFrame() { return mpPageFrame; }
220 const SwPageFrame* GetPageFrame() const { return mpPageFrame; }
221 void SetPageFrame( SwPageFrame* _pNewPageFrame );
222
238 SwPageFrame* FindPageFrameOfAnchor();
239
247 SwTextFrame* FindAnchorCharFrame();
248
249 // accessors to data of position calculation:
250 // frame vertical position is orient at
252 {
253 return mpVertPosOrientFrame;
254 }
255 // method to clear member <mpVertPosOrientFrame>
256 void ClearVertPosOrientFrame();
257
269 void CheckCharRectAndTopOfLine( const bool _bCheckForParaPorInf );
270
271 // accessors to member <maLastCharRect>
272 const SwRect& GetLastCharRect() const { return maLastCharRect;}
273 SwTwips GetRelCharX( const SwFrame* pFrame ) const;
274 SwTwips GetRelCharY( const SwFrame* pFrame ) const;
275 void AddLastCharY( tools::Long nDiff );
276 void ResetLastCharRectHeight();
277
278 // accessor to member <nmLastTopOfLine>
279 SwTwips GetLastTopOfLine() const { return mnLastTopOfLine;}
280 void AddLastTopOfLineY( SwTwips _nDiff );
281
283 void ClearCharRectAndTopOfLine();
284
288 virtual void MakeObjPos() = 0;
289
292 {
293 return mbPositioningInProgress;
294 }
295
297 bool InvalidationOfPosAllowed() const;
298
300 virtual void InvalidateObjPos() = 0;
301
302 virtual void RegisterAtPage(SwPageFrame &) = 0;
303
308 void InvalidateObjPosForConsiderWrapInfluence();
309
311 virtual void NotifyBackground( SwPageFrame* _pPageFrame,
312 const SwRect& _rRect,
313 PrepareHint _eHint ) = 0;
314
315 // accessors to the current relative position (relative to anchor
316 // position of anchor frame)
317 const Point& GetCurrRelPos() const { return maRelPos;}
318 void SetCurrRelPos( Point _aRelPos );
319
320 // accessors to the format
322 virtual const SwFrameFormat& GetFrameFormat() const = 0;
323
324 // accessors to the object area and its position
325 virtual SwRect GetObjRect() const = 0;
326
327 void SetObjTop( const SwTwips _nTop);
328 void SetObjLeft( const SwTwips _nLeft);
329
336 virtual void UpdateLayoutDir();
337
339 const SwRect& GetObjRectWithSpaces() const;
340
342 {
343 mbObjRectWithSpacesValid = false;
344 }
345
352 bool ConsiderObjWrapInfluenceOnObjPos() const;
353
354 // accessors to booleans for layout process
355 bool ConsiderForTextWrap() const;
356 void SetConsiderForTextWrap( const bool _bConsiderForTextWrap );
357 bool PositionLocked() const;
359 {
360 mbPositionLocked = true;
361 }
363 {
364 if ( !mbKeepPositionLockedForSection )
365 {
366 mbPositionLocked = false;
367 }
368 }
369
370 void SetKeepPosLocked( const bool _bKeepPosLocked )
371 {
372 mbKeepPositionLockedForSection = _bKeepPosLocked;
373 }
374
375 bool RestartLayoutProcess() const;
376 void SetRestartLayoutProcess( const bool _bRestartLayoutProcess );
377 // accessors for <mbClearedEnvironment>
378 bool ClearedEnvironment() const;
379 void SetClearedEnvironment( const bool _bClearedEnvironment );
380
381 // reset booleans for layout process
383 {
384 mbPositioningInProgress = false;
385 mbConsiderForTextWrap = false;
386 mbPositionLocked = false;
387 mbKeepPositionLockedForSection = false;
388 mbRestartLayoutProcess = false;
389 mbClearedEnvironment = false;
390 mbTmpConsiderWrapInfluence = false;
391 }
392
396 bool HasClearedEnvironment() const;
397
409
415 virtual bool IsFormatPossible() const;
416
421 static bool IsDraggingOffPageAllowed(const SwFrameFormat*);
422
423 // accessors to member <mbTmpConsiderWrapInfluence>
424 void SetTmpConsiderWrapInfluence( const bool _bTmpConsiderWrapInfluence );
425 bool IsTmpConsiderWrapInfluence() const { return mbTmpConsiderWrapInfluence;}
426 void ClearTmpConsiderWrapInfluence();
427
428 bool IsForceNotifyNewBackground() { return mbForceNotifyNewBackground; }
429 void SetForceNotifyNewBackground(bool const b) { mbForceNotifyNewBackground = b; }
430
439 bool OverlapsPrevColumn() const;
440
448 Point GetRelPosToAnchorFrame() const;
449
469 Point GetRelPosToPageFrame( const bool _bFollowTextFlow,
470 bool& _obRelToTableCell ) const;
471
479 Point GetRelPosToChar() const;
480
488 Point GetRelPosToLine() const;
489
493 virtual void dumpAsXml( xmlTextWriterPtr pWriter = nullptr ) const;
494
496 virtual const char* getElementName( ) const { return "SwAnchoredObject"; }
497
498 virtual const SwFlyFrame* DynCastFlyFrame() const;
499 virtual SwFlyFrame* DynCastFlyFrame();
500};
501
504{
505 private:
507 // boolean indicating old state
508 // of anchored object regarding positioning in progress in order to
509 // consider nested usage of class <SwObjPositioningInProgress>
511
512 public:
516};
517
518#endif
519
520/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SwFrame * mpAnchorFrame
wrapper class for the positioning of Writer fly frames and drawing objects
const SwFrame * GetAnchorFrame() const
virtual void RegisterAtPage(SwPageFrame &)=0
virtual SwRect GetObjBoundRect() const =0
virtual void NotifyBackground(SwPageFrame *_pPageFrame, const SwRect &_rRect, PrepareHint _eHint)=0
method to trigger notification of 'background'
rtl::Reference< SdrObject > mpDrawObj
SwFrame * AnchorFrame()
const SwLayoutFrame * mpVertPosOrientFrame
virtual void RegisterAtCorrectPage()=0
method to assure that anchored object is registered at the correct page frame
void ResetLayoutProcessBools()
virtual bool SetObjLeft_(const SwTwips _nLeft)=0
const SwLayoutFrame * GetVertPosOrientFrame() const
virtual const char * getElementName() const
The element name to show in the XML dump.
bool mbKeepPositionLockedForSection
void SetForceNotifyNewBackground(bool const b)
const SwPageFrame * GetPageFrame() const
virtual SwFrameFormat & GetFrameFormat()=0
void SetKeepPosLocked(const bool _bKeepPosLocked)
virtual bool SetObjTop_(const SwTwips _nTop)=0
virtual void MakeObjPos()=0
method to determine position for the object and set the position at the object
SwPageFrame * GetPageFrame()
bool IsTmpConsiderWrapInfluence() const
const SwRect & GetLastCharRect() const
bool IsForceNotifyNewBackground()
SwTwips GetLastTopOfLine() const
virtual void InvalidateObjPos()=0
method to invalidate position of the anchored object
virtual const SwFrameFormat & GetFrameFormat() const =0
void InvalidateObjRectWithSpaces() const
SwPageFrame * mpPageFrame
const SdrObject * GetDrawObj() const
void SetPositioningInProgress(const bool _bPosInProgress)
virtual SwRect GetObjRect() const =0
SdrObject * DrawObj()
SwFrame * mpAnchorFrame
Frame the object is anchored at.
bool IsPositioningInProgress() const
is positioning of anchored object in progress
const Point & GetCurrRelPos() const
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
FlyAnchors.
Definition: fmtanchr.hxx:37
Style of a layout element.
Definition: frmfmt.hxx:72
Base class of the Writer layout elements.
Definition: frame.hxx:315
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
Definition: layfrm.hxx:36
Helper class for notify that positioning of an anchored object is in progress.
SwObjPositioningInProgress(SdrObject &_rSdrObj)
SwAnchoredObject * mpAnchoredObj
A page of the document layout.
Definition: pagefrm.hxx:60
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
struct _xmlTextWriter * xmlTextWriterPtr
long Long
Marks a position in the document model.
Definition: pam.hxx:38
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
RndStdIds
tools::Long SwTwips
Definition: swtypes.hxx:51
PrepareHint
Definition: swtypes.hxx:206
bool sw_HideObj(const SwTextFrame &_rFrame, const RndStdIds _eAnchorType, SwFormatAnchor const &rFormatAnchor, SwAnchoredObject *_pAnchoredObj)
as-character anchored graphics, which are used for a graphic bullet list.
Definition: txtfrm.cxx:1594