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
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.get(); }
201 SdrObject* DrawObj() { return mpDrawObj.get(); }
202 void ClearDrawObj() { mpDrawObj.clear(); }
203
204 // accessors to member <mpAnchorFrame>
205 const SwFrame* GetAnchorFrame() const { return mpAnchorFrame; }
207 void ChgAnchorFrame( SwFrame* _pNewAnchorFrame );
215 SwFrame* GetAnchorFrameContainingAnchPos();
216
217 SwPageFrame* GetPageFrame() { return mpPageFrame; }
218 const SwPageFrame* GetPageFrame() const { return mpPageFrame; }
219 void SetPageFrame( SwPageFrame* _pNewPageFrame );
220
236 SwPageFrame* FindPageFrameOfAnchor();
237
245 SwTextFrame* FindAnchorCharFrame();
246
247 // accessors to data of position calculation:
248 // frame vertical position is orient at
250 {
251 return mpVertPosOrientFrame;
252 }
253 // method to clear member <mpVertPosOrientFrame>
254 void ClearVertPosOrientFrame();
255
267 void CheckCharRectAndTopOfLine( const bool _bCheckForParaPorInf );
268
269 // accessors to member <maLastCharRect>
270 const SwRect& GetLastCharRect() const { return maLastCharRect;}
271 SwTwips GetRelCharX( const SwFrame* pFrame ) const;
272 SwTwips GetRelCharY( const SwFrame* pFrame ) const;
273 void AddLastCharY( tools::Long nDiff );
274 void ResetLastCharRectHeight();
275
276 // accessor to member <nmLastTopOfLine>
277 SwTwips GetLastTopOfLine() const { return mnLastTopOfLine;}
278 void AddLastTopOfLineY( SwTwips _nDiff );
279
281 void ClearCharRectAndTopOfLine();
282
286 virtual void MakeObjPos() = 0;
287
290 {
291 return mbPositioningInProgress;
292 }
293
295 bool InvalidationOfPosAllowed() const;
296
298 virtual void InvalidateObjPos() = 0;
299
300 virtual void RegisterAtPage(SwPageFrame &) = 0;
301
306 void InvalidateObjPosForConsiderWrapInfluence();
307
309 virtual void NotifyBackground( SwPageFrame* _pPageFrame,
310 const SwRect& _rRect,
311 PrepareHint _eHint ) = 0;
312
313 // accessors to the current relative position (relative to anchor
314 // position of anchor frame)
315 const Point& GetCurrRelPos() const { return maRelPos;}
316 void SetCurrRelPos( Point _aRelPos );
317
318 // accessors to the format
320 virtual const SwFrameFormat& GetFrameFormat() const = 0;
321
322 // accessors to the object area and its position
323 virtual SwRect GetObjRect() const = 0;
324
325 void SetObjTop( const SwTwips _nTop);
326 void SetObjLeft( const SwTwips _nLeft);
327
334 virtual void UpdateLayoutDir();
335
337 const SwRect& GetObjRectWithSpaces() const;
338
340 {
341 mbObjRectWithSpacesValid = false;
342 }
343
350 bool ConsiderObjWrapInfluenceOnObjPos() const;
351
352 // accessors to booleans for layout process
353 bool ConsiderForTextWrap() const;
354 void SetConsiderForTextWrap( const bool _bConsiderForTextWrap );
355 bool PositionLocked() const;
357 {
358 mbPositionLocked = true;
359 }
361 {
362 if ( !mbKeepPositionLockedForSection )
363 {
364 mbPositionLocked = false;
365 }
366 }
367
368 void SetKeepPosLocked( const bool _bKeepPosLocked )
369 {
370 mbKeepPositionLockedForSection = _bKeepPosLocked;
371 }
372
373 bool RestartLayoutProcess() const;
374 void SetRestartLayoutProcess( const bool _bRestartLayoutProcess );
375 // accessors for <mbClearedEnvironment>
376 bool ClearedEnvironment() const;
377 void SetClearedEnvironment( const bool _bClearedEnvironment );
378
379 // reset booleans for layout process
381 {
382 mbPositioningInProgress = false;
383 mbConsiderForTextWrap = false;
384 mbPositionLocked = false;
385 mbKeepPositionLockedForSection = false;
386 mbRestartLayoutProcess = false;
387 mbClearedEnvironment = false;
388 mbTmpConsiderWrapInfluence = false;
389 }
390
394 bool HasClearedEnvironment() const;
395
407
413 virtual bool IsFormatPossible() const;
414
419 static bool IsDraggingOffPageAllowed(const SwFrameFormat*);
420
421 // accessors to member <mbTmpConsiderWrapInfluence>
422 void SetTmpConsiderWrapInfluence( const bool _bTmpConsiderWrapInfluence );
423 bool IsTmpConsiderWrapInfluence() const { return mbTmpConsiderWrapInfluence;}
424 void ClearTmpConsiderWrapInfluence();
425
434 bool OverlapsPrevColumn() const;
435
443 Point GetRelPosToAnchorFrame() const;
444
464 Point GetRelPosToPageFrame( const bool _bFollowTextFlow,
465 bool& _obRelToTableCell ) const;
466
474 Point GetRelPosToChar() const;
475
483 Point GetRelPosToLine() const;
484
488 virtual void dumpAsXml( xmlTextWriterPtr pWriter ) const;
489
491 virtual const char* getElementName( ) const { return "SwAnchoredObject"; }
492
493 virtual const SwFlyFrame* DynCastFlyFrame() const;
494 virtual SwFlyFrame* DynCastFlyFrame();
495};
496
499{
500 private:
502 // boolean indicating old state
503 // of anchored object regarding positioning in progress in order to
504 // consider nested usage of class <SwObjPositioningInProgress>
506
507 public:
511};
512
513#endif
514
515/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
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
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
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:62
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:58
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:165
long Long
Marks a position in the document model.
Definition: pam.hxx:37
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
RndStdIds
tools::Long SwTwips
Definition: swtypes.hxx:51
PrepareHint
Definition: swtypes.hxx:194
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:1486