Revert "reduce symbol visibility in sw"
[LibreOffice.git] / sw / source / core / inc / flyfrm.hxx
blob821be741fc704edf6d38fcdeeaa4a486a5f97f94
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_FLYFRM_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_FLYFRM_HXX
23 #include "layfrm.hxx"
24 #include <vector>
25 #include <frmfmt.hxx>
26 #include <anchoredobject.hxx>
27 #include <swdllapi.h>
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 class SwFlyAtContentFrame;
44 /** search an anchor for paragraph bound frames starting from pOldAnch
46 needed for dragging of objects bound to a paragraph for showing an anchor
47 indicator as well as for changing the anchor.
49 implemented in layout/flycnt.cxx
51 const SwContentFrame *FindAnchor( const SwFrame *pOldAnch, const Point &rNew,
52 const bool bBody = false );
54 /** calculate rectangle in that the object can be moved or rather be resized */
55 bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, bool bMove = true );
57 enum class SwFlyFrameInvFlags : sal_uInt8
59 NONE = 0x00,
60 InvalidatePos = 0x01,
61 InvalidateSize = 0x02,
62 InvalidatePrt = 0x04,
63 SetNotifyBack = 0x08,
64 SetCompletePaint = 0x10,
65 InvalidateBrowseWidth = 0x20,
66 ClearContourCache = 0x40,
67 UpdateObjInSortedList = 0x80,
70 namespace o3tl {
71 template<> struct typed_flags<SwFlyFrameInvFlags> : is_typed_flags<SwFlyFrameInvFlags, 0x00ff> {};
75 /** general base class for all free-flowing frames
77 #i26791# - inherit also from <SwAnchoredFlyFrame>
79 class SAL_DLLPUBLIC_RTTI SwFlyFrame : public SwLayoutFrame, public SwAnchoredObject
81 // is allowed to lock, implemented in frmtool.cxx
82 friend void AppendObj(SwFrame *const pFrame, SwPageFrame *const pPage, SwFrameFormat *const pFormat, const SwFormatAnchor & rAnch);
83 friend void Notify( SwFlyFrame *, SwPageFrame *pOld, const SwRect &rOld,
84 const SwRect* pOldPrt );
86 void InitDrawObj(SwFrame const&); // these to methods are called in the
87 void FinitDrawObj(); // constructors
89 void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, SwFlyFrameInvFlags &,
90 SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
92 using SwLayoutFrame::CalcRel;
94 protected:
95 // Predecessor/Successor for chaining with text flow
96 SwFlyFrame *m_pPrevLink, *m_pNextLink;
97 static const SwFormatAnchor* GetAnchorFromPoolItem(const SfxPoolItem& rItem);
99 private:
100 // It must be possible to block Content-bound flys so that they will be not
101 // formatted; in this case MakeAll() returns immediately. This is necessary
102 // for page changes during formatting. In addition, it is needed during
103 // the constructor call of the root object since otherwise the anchor will
104 // be formatted before the root is anchored correctly to a shell and
105 // because too much would be formatted as a result.
106 bool m_bLocked :1;
107 // true if the background of NotifyDTor needs to be notified at the end
108 // of a MakeAll() call.
109 bool m_bNotifyBack :1;
111 protected:
112 // Pos, PrtArea or SSize have been invalidated - they will be evaluated
113 // again immediately because they have to be valid _at all time_.
114 // The invalidation is tracked here so that LayAction knows about it and
115 // can handle it properly. Exceptions prove the rule.
116 bool m_bInvalid :1;
118 // true if the proposed height of an attribute is a minimal height
119 // (this means that the frame can grow higher if needed)
120 bool m_bMinHeight :1;
121 // true if the fly frame could not format position/size based on its
122 // attributes, e.g. because there was not enough space.
123 bool m_bHeightClipped :1;
124 bool m_bWidthClipped :1;
125 // If true then call only the format after adjusting the width (CheckClip);
126 // but the width will not be re-evaluated based on the attributes.
127 bool m_bFormatHeightOnly :1;
129 bool m_bInCnt :1; ///< RndStdIds::FLY_AS_CHAR, anchored as character
130 bool m_bAtCnt :1; ///< RndStdIds::FLY_AT_PARA, anchored at paragraph
131 ///< or RndStdIds::FLY_AT_CHAR
132 bool m_bLayout :1; ///< RndStdIds::FLY_AT_PAGE, RndStdIds::FLY_AT_FLY, at page or at frame
133 bool m_bAutoPosition :1; ///< RndStdIds::FLY_AT_CHAR, anchored at character
134 bool m_bDeleted :1; ///< Anchored to a tracked deletion
135 size_t m_nAuthor; ///< Redline author index for colored crossing out
137 friend class SwNoTextFrame; // is allowed to call NotifyBackground
139 Point m_aContentPos; // content area's position relatively to Frame
140 bool m_bValidContentPos;
142 virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
143 void MakePrtArea( const SwBorderAttrs &rAttrs );
144 void MakeContentPos( const SwBorderAttrs &rAttrs );
146 void Lock() { m_bLocked = true; }
147 void Unlock() { m_bLocked = false; }
149 Size CalcRel( const SwFormatFrameSize &rSz ) const;
151 SwFlyFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor, bool bFollow = false );
153 virtual void DestroyImpl() override;
154 virtual ~SwFlyFrame() override;
156 /** method to assure that anchored object is registered at the correct
157 page frame
159 virtual void RegisterAtCorrectPage() override;
161 virtual bool SetObjTop_( const SwTwips _nTop ) override;
162 virtual bool SetObjLeft_( const SwTwips _nLeft ) override;
164 virtual SwRect GetObjBoundRect() const override;
165 virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override;
167 virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( ) override;
169 SwTwips CalcContentHeight(const SwBorderAttrs *pAttrs, const SwTwips nMinHeight, const SwTwips nUL);
171 public:
172 // #i26791#
173 virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const& ) const override;
174 virtual Size ChgSize( const Size& aNewSize ) override;
175 virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
176 SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
178 virtual void CheckDirection( bool bVert ) override;
179 virtual void Cut() override;
180 #ifdef DBG_UTIL
181 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
182 #endif
184 SwTwips Shrink_( SwTwips, bool bTst );
185 SwTwips Grow_ ( SwTwips, bool bTst );
186 void Invalidate_( SwPageFrame const *pPage = nullptr );
188 bool FrameSizeChg( const SwFormatFrameSize & );
190 SwFlyFrame *GetPrevLink() const { return m_pPrevLink; }
191 SwFlyFrame *GetNextLink() const { return m_pNextLink; }
193 static void ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow );
194 static void UnchainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow );
196 SwFlyFrame *FindChainNeighbour( SwFrameFormat const &rFormat, SwFrame *pAnch = nullptr );
198 /// Is this fly allowed to split across pages? (Disabled by default.)
199 bool IsFlySplitAllowed() const;
201 // #i26791#
202 const SwVirtFlyDrawObj* GetVirtDrawObj() const;
203 SwVirtFlyDrawObj *GetVirtDrawObj();
204 void NotifyDrawObj();
206 void ChgRelPos( const Point &rAbsPos );
207 bool IsInvalid() const { return m_bInvalid; }
208 void Invalidate() const { const_cast<SwFlyFrame*>(this)->m_bInvalid = true; }
209 void Validate() const { const_cast<SwFlyFrame*>(this)->m_bInvalid = false; }
211 bool IsMinHeight() const { return m_bMinHeight; }
212 bool IsLocked() const { return m_bLocked; }
213 bool IsAutoPos() const { return m_bAutoPosition; }
214 bool IsFlyInContentFrame() const { return m_bInCnt; }
215 bool IsFlyFreeFrame() const { return m_bAtCnt || m_bLayout; }
216 bool IsFlyLayFrame() const { return m_bLayout; }
217 bool IsFlyAtContentFrame() const { return m_bAtCnt; }
218 bool IsDeleted() const { return m_bDeleted; }
219 void SetDeleted(bool bDeleted) { m_bDeleted = bDeleted; }
220 void SetAuthor( size_t nAuthor ) { m_nAuthor = nAuthor; }
221 size_t GetAuthor() const { return m_nAuthor; }
223 bool IsNotifyBack() const { return m_bNotifyBack; }
224 void SetNotifyBack() { m_bNotifyBack = true; }
225 void ResetNotifyBack() { m_bNotifyBack = false; }
227 bool IsClipped() const { return m_bHeightClipped || m_bWidthClipped; }
228 bool IsHeightClipped() const { return m_bHeightClipped; }
230 bool IsLowerOf( const SwLayoutFrame* pUpper ) const;
231 bool IsUpperOf( const SwFlyFrame& _rLower ) const
233 return _rLower.IsLowerOf( this );
236 SwFrame *FindLastLower();
238 // #i13147# - add parameter <_bForPaint> to avoid load of
239 // the graphic during paint. Default value: false
240 bool GetContour( tools::PolyPolygon& rContour,
241 const bool _bForPaint = false ) const;
243 // Paint on this shell (consider Preview, print flag, etc. recursively)?
244 static bool IsPaint( SdrObject *pObj, const SwViewShell *pSh );
246 /** SwFlyFrame::IsBackgroundTransparent
248 determines if background of fly frame has to be drawn transparently
250 definition found in /core/layout/paintfrm.cxx
252 @return true, if background color is transparent or an existing background
253 graphic is transparent.
255 bool IsBackgroundTransparent() const;
257 void Chain( SwFrame* _pAnchor );
258 void Unchain();
259 void InsertCnt();
260 void DeleteCnt();
261 void InsertColumns();
263 // #i26791# - pure virtual methods of base class <SwAnchoredObject>
264 virtual void MakeObjPos() override;
265 virtual void InvalidateObjPos() override;
266 virtual void RegisterAtPage(SwPageFrame&) override;
268 virtual SwFrameFormat* GetFrameFormat() override;
269 virtual const SwFrameFormat* GetFrameFormat() const override;
271 virtual SwRect GetObjRect() const override;
273 /** method to determine if a format on the Writer fly frame is possible
275 #i28701#
276 refine 'IsFormatPossible'-conditions of method
277 <SwAnchoredObject::IsFormatPossible()> by:
278 format isn't possible, if Writer fly frame is locked resp. col-locked.
280 virtual bool IsFormatPossible() const override;
281 static void GetAnchoredObjects( std::vector<SwAnchoredObject*>&, const SwFormat& rFormat );
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 SW_DLLPUBLIC virtual SwFlyFrameFormat *GetFormat() override;
289 virtual void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override;
291 virtual void Calc(vcl::RenderContext* pRenderContext) const override;
293 const Point& ContentPos() const { return m_aContentPos; }
294 Point& ContentPos() { return m_aContentPos; }
296 void InvalidateContentPos();
298 void SelectionHasChanged(SwFEShell* pShell);
299 SW_DLLPUBLIC bool IsShowUnfloatButton(SwWrtShell* pWrtSh) const;
301 // For testing only (see uiwriter)
302 SW_DLLPUBLIC void ActiveUnfloatButton(SwWrtShell* pWrtSh);
304 virtual const SwFlyFrame* DynCastFlyFrame() const override;
305 virtual SwFlyFrame* DynCastFlyFrame() override;
307 SW_DLLPUBLIC SwFlyAtContentFrame* DynCastFlyAtContentFrame();
309 private:
310 void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const;
311 void PaintDecorators() const;
313 #endif
315 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */