LibreOffice Module sw (master)  1
flyfrm.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 
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_FLYFRM_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_FLYFRM_HXX
22 
23 #include "layfrm.hxx"
24 #include <vector>
25 #include <frmfmt.hxx>
26 #include <anchoredobject.hxx>
27 #include <swdllapi.h>
28 
29 class SwFormatAnchor;
30 class SwPageFrame;
31 class SwFormatFrameSize;
32 struct SwCursorMoveState;
33 class SwBorderAttrs;
34 class SwVirtFlyDrawObj;
35 class SwAttrSetChg;
36 namespace tools { class PolyPolygon; }
37 class SwFormat;
38 class SwViewShell;
39 class SwFEShell;
40 class SwWrtShell;
41 
42 
50 const SwContentFrame *FindAnchor( const SwFrame *pOldAnch, const Point &rNew,
51  const bool bBody = false );
52 
54 bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, bool bMove = true );
55 
61 {
62  // is allowed to lock, implemented in frmtool.cxx
63  friend void AppendObj(SwFrame *const pFrame, SwPageFrame *const pPage, SwFrameFormat *const pFormat, const SwFormatAnchor & rAnch);
64  friend void Notify( SwFlyFrame *, SwPageFrame *pOld, const SwRect &rOld,
65  const SwRect* pOldPrt );
66 
67  void InitDrawObj(); // these to methods are called in the
68  void FinitDrawObj(); // constructors
69 
70  void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
71  SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
72 
74 
75 protected:
76  // Predecessor/Successor for chaining with text flow
77  SwFlyFrame *m_pPrevLink, *m_pNextLink;
78 
79 private:
80  // It must be possible to block Content-bound flys so that they will be not
81  // formatted; in this case MakeAll() returns immediately. This is necessary
82  // for page changes during formatting. In addition, it is needed during
83  // the constructor call of the root object since otherwise the anchor will
84  // be formatted before the root is anchored correctly to a shell and
85  // because too much would be formatted as a result.
86  bool m_bLocked :1;
87  // true if the background of NotifyDTor needs to be notified at the end
88  // of a MakeAll() call.
89  bool m_bNotifyBack :1;
90 
91 protected:
92  // Pos, PrtArea or SSize have been invalidated - they will be evaluated
93  // again immediately because they have to be valid _at all time_.
94  // The invalidation is tracked here so that LayAction knows about it and
95  // can handle it properly. Exceptions prove the rule.
96  bool m_bInvalid :1;
97 
98  // true if the proposed height of an attribute is a minimal height
99  // (this means that the frame can grow higher if needed)
100  bool m_bMinHeight :1;
101  // true if the fly frame could not format position/size based on its
102  // attributes, e.g. because there was not enough space.
103  bool m_bHeightClipped :1;
104  bool m_bWidthClipped :1;
105  // If true then call only the format after adjusting the width (CheckClip);
106  // but the width will not be re-evaluated based on the attributes.
107  bool m_bFormatHeightOnly :1;
108 
109  bool m_bInCnt :1;
110  bool m_bAtCnt :1;
111  bool m_bLayout :1;
113  bool m_bAutoPosition :1;
114 
115  friend class SwNoTextFrame; // is allowed to call NotifyBackground
116 
117  Point m_aContentPos; // content area's position relatively to Frame
119 
120  virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
121  void MakePrtArea( const SwBorderAttrs &rAttrs );
122  void MakeContentPos( const SwBorderAttrs &rAttrs );
123 
124  void Lock() { m_bLocked = true; }
125  void Unlock() { m_bLocked = false; }
126 
127  Size CalcRel( const SwFormatFrameSize &rSz ) const;
128 
129  SwFlyFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor );
130 
131  virtual void DestroyImpl() override;
132  virtual ~SwFlyFrame() override;
133 
137  virtual void RegisterAtCorrectPage() override;
138 
139  virtual bool SetObjTop_( const SwTwips _nTop ) override;
140  virtual bool SetObjLeft_( const SwTwips _nLeft ) override;
141 
142  virtual SwRect GetObjBoundRect() const override;
143  virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
144  virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override;
145 
146  virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( ) override;
147 
148  SwTwips CalcContentHeight(const SwBorderAttrs *pAttrs, const SwTwips nMinHeight, const SwTwips nUL);
149 
150 public:
151  // #i26791#
152 
153  // get client information
154  virtual bool GetInfo( SfxPoolItem& ) const override;
155  virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&,
156  SwPrintData const*const pPrintData = nullptr ) const override;
157  virtual Size ChgSize( const Size& aNewSize ) override;
158  virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
159  SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
160 
161  virtual void CheckDirection( bool bVert ) override;
162  virtual void Cut() override;
163 #ifdef DBG_UTIL
164  virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
165 #endif
166 
167  SwTwips Shrink_( SwTwips, bool bTst );
168  SwTwips Grow_ ( SwTwips, bool bTst );
169  void Invalidate_( SwPageFrame const *pPage = nullptr );
170 
171  bool FrameSizeChg( const SwFormatFrameSize & );
172 
173  SwFlyFrame *GetPrevLink() const { return m_pPrevLink; }
174  SwFlyFrame *GetNextLink() const { return m_pNextLink; }
175 
176  static void ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow );
177  static void UnchainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow );
178 
179  SwFlyFrame *FindChainNeighbour( SwFrameFormat const &rFormat, SwFrame *pAnch = nullptr );
180 
181  // #i26791#
182  const SwVirtFlyDrawObj* GetVirtDrawObj() const;
183  SwVirtFlyDrawObj *GetVirtDrawObj();
184  void NotifyDrawObj();
185 
186  void ChgRelPos( const Point &rAbsPos );
187  bool IsInvalid() const { return m_bInvalid; }
188  void Invalidate() const { const_cast<SwFlyFrame*>(this)->m_bInvalid = true; }
189  void Validate() const { const_cast<SwFlyFrame*>(this)->m_bInvalid = false; }
190 
191  bool IsMinHeight() const { return m_bMinHeight; }
192  bool IsLocked() const { return m_bLocked; }
193  bool IsAutoPos() const { return m_bAutoPosition; }
194  bool IsFlyInContentFrame() const { return m_bInCnt; }
195  bool IsFlyFreeFrame() const { return m_bAtCnt || m_bLayout; }
196  bool IsFlyLayFrame() const { return m_bLayout; }
197  bool IsFlyAtContentFrame() const { return m_bAtCnt; }
198 
199  bool IsNotifyBack() const { return m_bNotifyBack; }
200  void SetNotifyBack() { m_bNotifyBack = true; }
201  void ResetNotifyBack() { m_bNotifyBack = false; }
202 
203  bool IsClipped() const { return m_bHeightClipped || m_bWidthClipped; }
204  bool IsHeightClipped() const { return m_bHeightClipped; }
205 
206  bool IsLowerOf( const SwLayoutFrame* pUpper ) const;
207  bool IsUpperOf( const SwFlyFrame& _rLower ) const
208  {
209  return _rLower.IsLowerOf( this );
210  }
211 
212  SwFrame *FindLastLower();
213 
214  // #i13147# - add parameter <_bForPaint> to avoid load of
215  // the graphic during paint. Default value: false
216  bool GetContour( tools::PolyPolygon& rContour,
217  const bool _bForPaint = false ) const;
218 
219  // Paint on this shell (consider Preview, print flag, etc. recursively)?
220  static bool IsPaint( SdrObject *pObj, const SwViewShell *pSh );
221 
231  bool IsBackgroundTransparent() const;
232 
233  void Chain( SwFrame* _pAnchor );
234  void Unchain();
235  void InsertCnt();
236  void DeleteCnt();
237  void InsertColumns();
238 
239  // #i26791# - pure virtual methods of base class <SwAnchoredObject>
240  virtual void MakeObjPos() override;
241  virtual void InvalidateObjPos() override;
242 
243  virtual SwFrameFormat& GetFrameFormat() override;
244  virtual const SwFrameFormat& GetFrameFormat() const override;
245 
246  virtual SwRect GetObjRect() const override;
247 
255  virtual bool IsFormatPossible() const override;
256  static void GetAnchoredObjects( std::vector<SwAnchoredObject*>&, const SwFormat& rFormat );
257 
258  // overwriting "SwFrameFormat *SwLayoutFrame::GetFormat" to provide the correct derived return type.
259  // (This is in order to skip on the otherwise necessary casting of the result to
260  // 'SwFlyFrameFormat *' after calls to this function. The casting is now done in this function.)
261  virtual const SwFlyFrameFormat *GetFormat() const override;
262  virtual SwFlyFrameFormat *GetFormat() override;
263 
264  virtual void dumpAsXml( xmlTextWriterPtr writer ) const override { SwLayoutFrame::dumpAsXml( writer ); };
265 
266  virtual void Calc(vcl::RenderContext* pRenderContext) const override;
267 
268  const Point& ContentPos() const { return m_aContentPos; }
269  Point& ContentPos() { return m_aContentPos; }
270 
271  void InvalidateContentPos();
272 
273  void SelectionHasChanged(SwFEShell* pShell);
274  bool IsShowUnfloatButton(SwWrtShell* pWrtSh) const;
275 
276  // For testing only (see uiwriter)
277  void ActiveUnfloatButton(SwWrtShell* pWrtSh);
278 
279 private:
280  void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const;
281  void PaintDecorators() const;
282 };
283 #endif
284 
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void MakeObjPos()=0
method to determine position for the object and set the position at the object
Base class of the Writer layout elements.
Definition: frame.hxx:298
virtual SwRect GetObjRect() const =0
bool IsFlyLayFrame() const
Definition: flyfrm.hxx:196
void SetNotifyBack()
Definition: flyfrm.hxx:200
Marks a position in the document model.
Definition: pam.hxx:35
void MakePrtArea(const SwBorderAttrs &)
Definition: calcmove.cxx:1073
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3121
bool IsLowerOf(const SwLayoutFrame *pUpper) const
Definition: fly.cxx:2147
virtual bool SetObjTop_(const SwTwips _nTop)=0
Point & ContentPos()
Definition: flyfrm.hxx:269
void Unlock()
Definition: flyfrm.hxx:125
void Invalidate() const
Definition: flyfrm.hxx:188
virtual void dumpAsXml(xmlTextWriterPtr writer=nullptr) const
Definition: xmldump.cxx:257
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1787
bool CalcClipRect(const SdrObject *pSdrObj, SwRect &rRect, bool bMove=true)
calculate rectangle in that the object can be moved or rather be resized
Definition: flylay.cxx:1159
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
Calculate the Bitmap's site, if needed.
Definition: notxtfrm.cxx:656
SwFlyFrame * m_pPrevLink
Definition: flyfrm.hxx:77
virtual SwRect GetObjBoundRect() const =0
bool IsFlyAtContentFrame() const
Definition: flyfrm.hxx:197
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
wrapper class for the positioning of Writer fly frames and drawing objects
bool IsInvalid() const
Definition: flyfrm.hxx:187
const Point & ContentPos() const
Definition: flyfrm.hxx:268
SwFlyFrame * GetPrevLink() const
Definition: flyfrm.hxx:173
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:723
void Lock()
Definition: flyfrm.hxx:124
virtual bool GetModelPositionForViewPoint(SwPosition *pPos, Point &aPoint, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Definition: notxtfrm.cxx:703
bool IsUpperOf(const SwFlyFrame &_rLower) const
Definition: flyfrm.hxx:207
bool IsFlyInContentFrame() const
Definition: flyfrm.hxx:194
virtual bool SetObjLeft_(const SwTwips _nLeft)=0
virtual void dumpAsXml(xmlTextWriterPtr writer) const override
Dump a bunch of useful data to an XML representation to ease layout understanding, debugging and testing.
Definition: flyfrm.hxx:264
Base class for various Writer styles.
Definition: format.hxx:43
void AppendObj(SwFrame *const pFrame, SwPageFrame *const pPage, SwFrameFormat *const pFormat, const SwFormatAnchor &rAnch)
Definition: frmtool.cxx:978
struct _xmlTextWriter * xmlTextWriterPtr
bool IsMinHeight() const
Definition: flyfrm.hxx:191
Style of a layout element.
Definition: frmfmt.hxx:58
void Validate() const
Definition: flyfrm.hxx:189
FlyAnchors.
Definition: fmtanchr.hxx:34
virtual void PaintSwFrame(vcl::RenderContext &rRenderContext, SwRect const &, SwPrintData const *const pPrintData=nullptr) const override
Definition: notxtfrm.cxx:218
bool m_bValidContentPos
Definition: flyfrm.hxx:118
virtual void InvalidateObjPos()=0
method to invalidate position of the anchored object
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool IsNotifyBack() const
Definition: flyfrm.hxx:199
A page of the document layout.
Definition: pagefrm.hxx:41
tools::Long SwTwips
Definition: swtypes.hxx:49
virtual void CheckDirection(bool bVert)
Definition: wsfrm.cxx:391
virtual bool IsFormatPossible() const
method to determine, if a format on the anchored object is possible
tools::Long CalcRel(const SwFormatFrameSize &rSz) const
Definition: wsfrm.cxx:3557
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
virtual SwFrameFormat & GetFrameFormat()=0
bool IsLocked() const
Definition: flyfrm.hxx:192
unsigned char sal_uInt8
bool IsFlyFreeFrame() const
Definition: flyfrm.hxx:195
virtual const IDocumentDrawModelAccess & getIDocumentDrawModelAccess()
Definition: wsfrm.cxx:327
bool IsClipped() const
Definition: flyfrm.hxx:203
bool IsHeightClipped() const
Definition: flyfrm.hxx:204
SwFlyFrame * GetNextLink() const
Definition: flyfrm.hxx:174
Point m_aContentPos
Definition: flyfrm.hxx:117
virtual void RegisterAtCorrectPage()=0
method to assure that anchored object is registered at the correct page frame
virtual void Cut() override
Definition: wsfrm.cxx:1122
virtual bool GetInfo(SfxPoolItem &) const
Definition: calbck.hxx:170
const SwContentFrame * FindAnchor(const SwFrame *pOldAnch, const Point &rNew, const bool bBody=false)
search an anchor for paragraph bound frames starting from pOldAnch
Definition: flycnt.cxx:1034
virtual void DestroyImpl() override
Definition: notxtfrm.cxx:162
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
void ResetNotifyBack()
Definition: flyfrm.hxx:201
virtual void Modify(const SfxPoolItem *, const SfxPoolItem *) override
Definition: wsfrm.cxx:2325
bool IsAutoPos() const
Definition: flyfrm.hxx:193
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: notxtfrm.cxx:737
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:394