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
29class SwFormatAnchor;
30class SwPageFrame;
33class SwBorderAttrs;
35class SwAttrSetChg;
36namespace tools { class PolyPolygon; }
37class SwFormat;
38class SwViewShell;
39class SwFEShell;
40class SwWrtShell;
41
42
50const SwContentFrame *FindAnchor( const SwFrame *pOldAnch, const Point &rNew,
51 const bool bBody = false );
52
54bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, bool bMove = true );
55
57{
58 NONE = 0x00,
59 InvalidatePos = 0x01,
60 InvalidateSize = 0x02,
61 InvalidatePrt = 0x04,
62 SetNotifyBack = 0x08,
63 SetCompletePaint = 0x10,
65 ClearContourCache = 0x40,
67};
68
69namespace o3tl {
70 template<> struct typed_flags<SwFlyFrameInvFlags> : is_typed_flags<SwFlyFrameInvFlags, 0x00ff> {};
71}
72
73
79{
80 // is allowed to lock, implemented in frmtool.cxx
81 friend void AppendObj(SwFrame *const pFrame, SwPageFrame *const pPage, SwFrameFormat *const pFormat, const SwFormatAnchor & rAnch);
82 friend void Notify( SwFlyFrame *, SwPageFrame *pOld, const SwRect &rOld,
83 const SwRect* pOldPrt );
84
85 void InitDrawObj(SwFrame const&); // these to methods are called in the
86 void FinitDrawObj(); // constructors
87
88 void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, SwFlyFrameInvFlags &,
89 SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
90
92
93protected:
94 // Predecessor/Successor for chaining with text flow
95 SwFlyFrame *m_pPrevLink, *m_pNextLink;
96 static const SwFormatAnchor* GetAnchorFromPoolItem(const SfxPoolItem& rItem);
97
98private:
99 // It must be possible to block Content-bound flys so that they will be not
100 // formatted; in this case MakeAll() returns immediately. This is necessary
101 // for page changes during formatting. In addition, it is needed during
102 // the constructor call of the root object since otherwise the anchor will
103 // be formatted before the root is anchored correctly to a shell and
104 // because too much would be formatted as a result.
105 bool m_bLocked :1;
106 // true if the background of NotifyDTor needs to be notified at the end
107 // of a MakeAll() call.
109
110protected:
111 // Pos, PrtArea or SSize have been invalidated - they will be evaluated
112 // again immediately because they have to be valid _at all time_.
113 // The invalidation is tracked here so that LayAction knows about it and
114 // can handle it properly. Exceptions prove the rule.
115 bool m_bInvalid :1;
116
117 // true if the proposed height of an attribute is a minimal height
118 // (this means that the frame can grow higher if needed)
120 // true if the fly frame could not format position/size based on its
121 // attributes, e.g. because there was not enough space.
124 // If true then call only the format after adjusting the width (CheckClip);
125 // but the width will not be re-evaluated based on the attributes.
127
128 bool m_bInCnt :1;
129 bool m_bAtCnt :1;
131 bool m_bLayout :1;
133 bool m_bDeleted :1;
134 size_t m_nAuthor;
135
136 friend class SwNoTextFrame; // is allowed to call NotifyBackground
137
138 Point m_aContentPos; // content area's position relatively to Frame
140
141 virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
142 void MakePrtArea( const SwBorderAttrs &rAttrs );
143 void MakeContentPos( const SwBorderAttrs &rAttrs );
144
145 void Lock() { m_bLocked = true; }
146 void Unlock() { m_bLocked = false; }
147
148 Size CalcRel( const SwFormatFrameSize &rSz ) const;
149
151
152 virtual void DestroyImpl() override;
153 virtual ~SwFlyFrame() override;
154
158 virtual void RegisterAtCorrectPage() override;
159 virtual void RegisterAtPage(SwPageFrame &) override;
160
161 virtual bool SetObjTop_( const SwTwips _nTop ) override;
162 virtual bool SetObjLeft_( const SwTwips _nLeft ) override;
163
164 virtual SwRect GetObjBoundRect() const override;
165 virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override;
166
167 virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( ) override;
168
169 SwTwips CalcContentHeight(const SwBorderAttrs *pAttrs, const SwTwips nMinHeight, const SwTwips nUL);
170
171public:
172 // #i26791#
173
174 // get client information
175 virtual bool GetInfo( SfxPoolItem& ) const override;
176 virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&,
177 SwPrintData const*const pPrintData = nullptr ) const override;
178 virtual Size ChgSize( const Size& aNewSize ) override;
179 virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
180 SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
181
182 virtual void CheckDirection( bool bVert ) override;
183 virtual void Cut() override;
184#ifdef DBG_UTIL
185 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
186#endif
187
188 SwTwips Shrink_( SwTwips, bool bTst );
189 SwTwips Grow_ ( SwTwips, bool bTst );
190 void Invalidate_( SwPageFrame const *pPage = nullptr );
191
192 bool FrameSizeChg( const SwFormatFrameSize & );
193
194 SwFlyFrame *GetPrevLink() const { return m_pPrevLink; }
195 SwFlyFrame *GetNextLink() const { return m_pNextLink; }
196
197 static void ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow );
198 static void UnchainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow );
199
200 SwFlyFrame *FindChainNeighbour( SwFrameFormat const &rFormat, SwFrame *pAnch = nullptr );
201
202 // #i26791#
203 const SwVirtFlyDrawObj* GetVirtDrawObj() const;
204 SwVirtFlyDrawObj *GetVirtDrawObj();
205 void NotifyDrawObj();
206
207 void ChgRelPos( const Point &rAbsPos );
208 bool IsInvalid() const { return m_bInvalid; }
209 void Invalidate() const { const_cast<SwFlyFrame*>(this)->m_bInvalid = true; }
210 void Validate() const { const_cast<SwFlyFrame*>(this)->m_bInvalid = false; }
211
212 bool IsMinHeight() const { return m_bMinHeight; }
213 bool IsLocked() const { return m_bLocked; }
214 bool IsAutoPos() const { return m_bAutoPosition; }
215 bool IsFlyInContentFrame() const { return m_bInCnt; }
216 bool IsFlyFreeFrame() const { return m_bAtCnt || m_bLayout; }
217 bool IsFlyLayFrame() const { return m_bLayout; }
218 bool IsFlyAtContentFrame() const { return m_bAtCnt; }
219 bool IsDeleted() const { return m_bDeleted; }
220 void SetDeleted(bool bDeleted) { m_bDeleted = bDeleted; }
221 void SetAuthor( size_t nAuthor ) { m_nAuthor = nAuthor; }
222 size_t GetAuthor() const { return m_nAuthor; }
223
224 bool IsNotifyBack() const { return m_bNotifyBack; }
225 void SetNotifyBack() { m_bNotifyBack = true; }
226 void ResetNotifyBack() { m_bNotifyBack = false; }
227
228 bool IsClipped() const { return m_bHeightClipped || m_bWidthClipped; }
229 bool IsHeightClipped() const { return m_bHeightClipped; }
230
231 bool IsLowerOf( const SwLayoutFrame* pUpper ) const;
232 bool IsUpperOf( const SwFlyFrame& _rLower ) const
233 {
234 return _rLower.IsLowerOf( this );
235 }
236
237 SwFrame *FindLastLower();
238
239 // #i13147# - add parameter <_bForPaint> to avoid load of
240 // the graphic during paint. Default value: false
241 bool GetContour( tools::PolyPolygon& rContour,
242 const bool _bForPaint = false ) const;
243
244 // Paint on this shell (consider Preview, print flag, etc. recursively)?
245 static bool IsPaint( SdrObject *pObj, const SwViewShell *pSh );
246
256 bool IsBackgroundTransparent() const;
257
258 void Chain( SwFrame* _pAnchor );
259 void Unchain();
260 void InsertCnt();
261 void DeleteCnt();
262 void InsertColumns();
263
264 // #i26791# - pure virtual methods of base class <SwAnchoredObject>
265 virtual void MakeObjPos() override;
266 virtual void InvalidateObjPos() override;
267
268 virtual SwFrameFormat& GetFrameFormat() override;
269 virtual const SwFrameFormat& GetFrameFormat() const override;
270
271 virtual SwRect GetObjRect() const override;
272
280 virtual bool IsFormatPossible() const override;
281 static void GetAnchoredObjects( std::vector<SwAnchoredObject*>&, const SwFormat& rFormat );
282
283 // overwriting "SwFrameFormat *SwLayoutFrame::GetFormat" to provide the correct derived return type.
284 // (This is in order to skip on the otherwise necessary casting of the result to
285 // 'SwFlyFrameFormat *' after calls to this function. The casting is now done in this function.)
286 virtual const SwFlyFrameFormat *GetFormat() const override;
287 virtual SwFlyFrameFormat *GetFormat() override;
288
289 virtual void dumpAsXml( xmlTextWriterPtr writer ) const override { SwLayoutFrame::dumpAsXml( writer ); };
290
291 virtual void Calc(vcl::RenderContext* pRenderContext) const override;
292
293 const Point& ContentPos() const { return m_aContentPos; }
294 Point& ContentPos() { return m_aContentPos; }
295
296 void InvalidateContentPos();
297
298 void SelectionHasChanged(SwFEShell* pShell);
299 bool IsShowUnfloatButton(SwWrtShell* pWrtSh) const;
300
301 // For testing only (see uiwriter)
302 void ActiveUnfloatButton(SwWrtShell* pWrtSh);
303
304 virtual const SwFlyFrame* DynCastFlyFrame() const override;
305 virtual SwFlyFrame* DynCastFlyFrame() override;
306
307private:
308 void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const;
309 void PaintDecorators() const;
310};
311#endif
312
313/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
wrapper class for the positioning of Writer fly frames and drawing objects
virtual void RegisterAtPage(SwPageFrame &)=0
virtual SwRect GetObjBoundRect() const =0
virtual void RegisterAtCorrectPage()=0
method to assure that anchored object is registered at the correct page frame
virtual bool SetObjLeft_(const SwTwips _nLeft)=0
virtual SwFrameFormat & GetFrameFormat()=0
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
virtual void InvalidateObjPos()=0
method to invalidate position of the anchored object
virtual const SwFlyFrame * DynCastFlyFrame() const
virtual SwRect GetObjRect() const =0
virtual bool IsFormatPossible() const
method to determine, if a format on the anchored object is possible
virtual bool GetInfo(SfxPoolItem &) const
Definition: calbck.hxx:171
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
void MakePrtArea(const SwBorderAttrs &)
Definition: calcmove.cxx:1066
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
void Validate() const
Definition: flyfrm.hxx:210
SwFlyFrame * GetPrevLink() const
Definition: flyfrm.hxx:194
void ResetNotifyBack()
Definition: flyfrm.hxx:226
bool IsDeleted() const
Definition: flyfrm.hxx:219
bool IsFlyAtContentFrame() const
Definition: flyfrm.hxx:218
size_t m_nAuthor
Redline author index for colored crossing out.
Definition: flyfrm.hxx:134
size_t GetAuthor() const
Definition: flyfrm.hxx:222
void SetNotifyBack()
Definition: flyfrm.hxx:225
bool IsLowerOf(const SwLayoutFrame *pUpper) const
Definition: fly.cxx:2175
bool m_bNotifyBack
Definition: flyfrm.hxx:108
bool m_bLocked
Definition: flyfrm.hxx:105
bool IsMinHeight() const
Definition: flyfrm.hxx:212
void SetDeleted(bool bDeleted)
Definition: flyfrm.hxx:220
bool IsInvalid() const
Definition: flyfrm.hxx:208
SwFlyFrame * GetNextLink() const
Definition: flyfrm.hxx:195
bool m_bWidthClipped
Definition: flyfrm.hxx:123
bool IsLocked() const
Definition: flyfrm.hxx:213
bool m_bAtCnt
RndStdIds::FLY_AT_PARA, anchored at paragraph or RndStdIds::FLY_AT_CHAR.
Definition: flyfrm.hxx:129
void Lock()
Definition: flyfrm.hxx:145
bool IsFlyInContentFrame() const
Definition: flyfrm.hxx:215
void Invalidate() const
Definition: flyfrm.hxx:209
bool IsFlyLayFrame() const
Definition: flyfrm.hxx:217
bool m_bAutoPosition
RndStdIds::FLY_AT_CHAR, anchored at character.
Definition: flyfrm.hxx:132
bool m_bFormatHeightOnly
Definition: flyfrm.hxx:126
bool m_bDeleted
Anchored to a tracked deletion.
Definition: flyfrm.hxx:133
Point m_aContentPos
Definition: flyfrm.hxx:138
bool m_bMinHeight
Definition: flyfrm.hxx:119
void SetAuthor(size_t nAuthor)
Definition: flyfrm.hxx:221
bool m_bInCnt
RndStdIds::FLY_AS_CHAR, anchored as character.
Definition: flyfrm.hxx:128
void Unlock()
Definition: flyfrm.hxx:146
const Point & ContentPos() const
Definition: flyfrm.hxx:293
bool m_bValidContentPos
Definition: flyfrm.hxx:139
SwFlyFrame * m_pNextLink
Definition: flyfrm.hxx:95
bool m_bLayout
RndStdIds::FLY_AT_PAGE, RndStdIds::FLY_AT_FLY, at page or at frame.
Definition: flyfrm.hxx:131
bool IsFlyFreeFrame() const
Definition: flyfrm.hxx:216
bool m_bHeightClipped
Definition: flyfrm.hxx:122
bool IsUpperOf(const SwFlyFrame &_rLower) const
Definition: flyfrm.hxx:232
bool IsNotifyBack() const
Definition: flyfrm.hxx:224
virtual void dumpAsXml(xmlTextWriterPtr writer) const override
Dump a bunch of useful data to an XML representation to ease layout understanding,...
Definition: flyfrm.hxx:289
bool IsClipped() const
Definition: flyfrm.hxx:228
bool IsHeightClipped() const
Definition: flyfrm.hxx:229
Point & ContentPos()
Definition: flyfrm.hxx:294
bool IsAutoPos() const
Definition: flyfrm.hxx:214
bool m_bInvalid
Definition: flyfrm.hxx:115
FlyAnchors.
Definition: fmtanchr.hxx:37
Base class for various Writer styles.
Definition: format.hxx:47
Style of a layout element.
Definition: frmfmt.hxx:62
Base class of the Writer layout elements.
Definition: frame.hxx:315
virtual void dumpAsXml(xmlTextWriterPtr writer=nullptr) const
Definition: xmldump.cxx:308
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1798
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: wsfrm.cxx:480
virtual void CheckDirection(bool bVert)
Definition: wsfrm.cxx:396
virtual const IDocumentDrawModelAccess & getIDocumentDrawModelAccess()
Definition: wsfrm.cxx:326
virtual Size ChgSize(const Size &aNewSize)
Definition: wsfrm.cxx:737
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
Definition: layfrm.hxx:36
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
"Formats" the Frame; Frame and PrtArea.
Definition: wsfrm.cxx:3443
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Searches the ContentFrame owning the PrtArea containing the point.
Definition: trvlfrm.cxx:151
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:399
virtual void DestroyImpl() override
Definition: ssfrm.cxx:485
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr) override
Definition: wsfrm.cxx:1344
tools::Long CalcRel(const SwFormatFrameSize &rSz) const
Definition: wsfrm.cxx:3624
virtual void PaintSwFrame(vcl::RenderContext &rRenderContext, SwRect const &, SwPrintData const *const pPrintData=nullptr) const override
Definition: paintfrm.cxx:3493
virtual void Cut() override
Definition: wsfrm.cxx:1441
A page of the document layout.
Definition: pagefrm.hxx:58
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
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:1164
SwFlyFrameInvFlags
Definition: flyfrm.hxx:57
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:1069
void AppendObj(SwFrame *const pFrame, SwPageFrame *const pPage, SwFrameFormat *const pFormat, const SwFormatAnchor &rAnch)
Definition: frmtool.cxx:1034
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:3238
NONE
Marks a position in the document model.
Definition: pam.hxx:37
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
tools::Long SwTwips
Definition: swtypes.hxx:51
unsigned char sal_uInt8