LibreOffice Module sw (master)  1
anchoreddrawobject.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_ANCHOREDDRAWOBJECT_HXX
20 #define INCLUDED_SW_INC_ANCHOREDDRAWOBJECT_HXX
21 
22 #include "anchoredobject.hxx"
23 #include <o3tl/optional.hxx>
24 
25 namespace tools { class Rectangle; }
26 
29 {
30  private:
31  // boolean, indicating that the object position has been invalidated
32  // and that a positioning has to be performed.
33  bool mbValidPos;
34 
35  // rectangle, keeping the last object rectangle after the positioning
36  o3tl::optional<tools::Rectangle> maLastObjRect;
37 
38  // boolean, indicating that anchored drawing object hasn't been attached
39  // to an anchor frame yet. Once, it is attached to an anchor frame the
40  // boolean changes its state.
42 
43  // boolean, indicating that anchored
44  // drawing object hasn't been positioned yet. Once, it's positioned the
45  // boolean changes its state.
47 
48  // boolean, indicating that after change of layout direction the
49  // anchored drawing object has to be captured on the page, if it exceeds
50  // the left or right page margin.
51  // Needed for compatibility option <DoNotCaptureDrawObjsOnPage>
53 
59 
65 
73  void SetPositioningAttr();
74 
86  void SetDrawObjAnchor();
87 
89  void InvalidatePage_( SwPageFrame* _pPageFrame );
90 
91  virtual void ObjectAttachedToAnchorFrame() override;
92 
96  virtual void RegisterAtCorrectPage() override;
97 
98  virtual bool SetObjTop_( const SwTwips _nTop) override;
99  virtual bool SetObjLeft_( const SwTwips _nLeft) override;
100 
101  virtual SwRect GetObjBoundRect() const override;
102 
103  public:
104 
106  virtual ~SwAnchoredDrawObject() override;
107 
108  // declaration of pure virtual methods of base class <SwAnchoredObject>
109  virtual void MakeObjPos() override;
110  virtual void InvalidateObjPos() override;
111  bool IsValidPos() const
112  {
113  return mbValidPos;
114  }
115 
116  // accessors to the format
117  virtual SwFrameFormat& GetFrameFormat() override;
118  virtual const SwFrameFormat& GetFrameFormat() const override;
119 
120  // accessors to the object area and its position
121  virtual SwRect GetObjRect() const override;
122 
123  o3tl::optional<tools::Rectangle> const & GetLastObjRect() const { return maLastObjRect;}
124  void SetLastObjRect( const tools::Rectangle& _rNewObjRect );
125 
141  void AdjustPositioningAttr( const SwFrame* _pNewAnchorFrame,
142  const SwRect* _pNewObjRect = nullptr );
143 
145  virtual void NotifyBackground( SwPageFrame* _pPageFrame,
146  const SwRect& _rRect,
147  PrepareHint _eHint ) override;
148 
149  bool NotYetPositioned() const
150  {
151  return mbNotYetPositioned;
152  }
153 
154  // change of layout direction needs to be tracked
155  // for setting <mbCaptureAfterLayoutDirChange>.
156  virtual void UpdateLayoutDir() override;
157  bool IsOutsidePage() const;
158 
159  // new Loop control
160  void ValidateThis() { mbValidPos = true; }
161 
163  virtual const char* getElementName( ) const override { return "SwAnchoredDrawObject"; }
164 };
165 
166 #endif
167 
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:295
class for the positioning of drawing objects
virtual void NotifyBackground(SwPageFrame *_pPageFrame, const SwRect &_rRect, PrepareHint _eHint) override
method to notify background of drawing object
o3tl::optional< tools::Rectangle > maLastObjRect
virtual const char * getElementName() const override
The element name to show in the XML dump.
void InvalidatePage_(SwPageFrame *_pPageFrame)
method to invalidate the given page frame
long SwTwips
Definition: swtypes.hxx:49
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
void MakeObjPosAnchoredAtLayout()
method for the intrinsic positioning of an at-page|at-frame anchored drawing object ...
virtual bool SetObjTop_(const SwTwips _nTop) override
wrapper class for the positioning of Writer fly frames and drawing objects
virtual void InvalidateObjPos() override
method to invalidate position of the anchored object
o3tl::optional< tools::Rectangle > const & GetLastObjRect() const
virtual void RegisterAtCorrectPage() override
method to assure that anchored object is registered at the correct page frame
virtual void ObjectAttachedToAnchorFrame() override
method to indicate, that anchored object is attached to an anchor frame
Style of a layout element.
Definition: frmfmt.hxx:57
PrepareHint
Definition: swtypes.hxx:204
virtual SwRect GetObjRect() const override
void SetDrawObjAnchor()
method to set internal anchor position of instance of the drawing object ...
void SetLastObjRect(const tools::Rectangle &_rNewObjRect)
A page of the document layout.
Definition: pagefrm.hxx:40
virtual ~SwAnchoredDrawObject() override
void MakeObjPosAnchoredAtPara()
method for the intrinsic positioning of an at-paragraph|at-character anchored drawing object ...
virtual SwFrameFormat & GetFrameFormat() override
virtual SwRect GetObjBoundRect() const override
void AdjustPositioningAttr(const SwFrame *_pNewAnchorFrame, const SwRect *_pNewObjRect=nullptr)
adjust positioning and alignment attributes for new anchor frame
virtual void MakeObjPos() override
method to determine position for the object and set the position at the object
virtual void UpdateLayoutDir() override
method update layout direction the layout direction, the anchored object is assigned to ...
void SetPositioningAttr()
method to set positioning attributes (not for as-character anchored)
virtual bool SetObjLeft_(const SwTwips _nLeft) override