docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / sw / source / core / inc / flyfrm.hxx
blobf599fa86b888824443566712706023e0c44d0e74
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&); // 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 );
91 void UpdateAttrForFormatChange( SwFormat* pOldFormat, SwFormat* pNewFormat, SwFlyFrameInvFlags & );
93 using SwLayoutFrame::CalcRel;
95 protected:
96 // Predecessor/Successor for chaining with text flow
97 SwFlyFrame *m_pPrevLink, *m_pNextLink;
98 static const SwFormatAnchor* GetAnchorFromPoolItem(const SfxPoolItem& rItem);
99 static const SwFormatAnchor* GetAnchorFromPoolItem(const SwAttrSetChg& rItem);
101 private:
102 // It must be possible to block Content-bound flys so that they will be not
103 // formatted; in this case MakeAll() returns immediately. This is necessary
104 // for page changes during formatting. In addition, it is needed during
105 // the constructor call of the root object since otherwise the anchor will
106 // be formatted before the root is anchored correctly to a shell and
107 // because too much would be formatted as a result.
108 bool m_bLocked :1;
109 // true if the background of NotifyDTor needs to be notified at the end
110 // of a MakeAll() call.
111 bool m_bNotifyBack :1;
113 protected:
114 // Pos, PrtArea or SSize have been invalidated - they will be evaluated
115 // again immediately because they have to be valid _at all time_.
116 // The invalidation is tracked here so that LayAction knows about it and
117 // can handle it properly. Exceptions prove the rule.
118 bool m_bInvalid :1;
120 // true if the proposed height of an attribute is a minimal height
121 // (this means that the frame can grow higher if needed)
122 bool m_bMinHeight :1;
123 // true if the fly frame could not format position/size based on its
124 // attributes, e.g. because there was not enough space.
125 bool m_bHeightClipped :1;
126 bool m_bWidthClipped :1;
127 // If true then call only the format after adjusting the width (CheckClip);
128 // but the width will not be re-evaluated based on the attributes.
129 bool m_bFormatHeightOnly :1;
131 bool m_bInCnt :1; ///< RndStdIds::FLY_AS_CHAR, anchored as character
132 bool m_bAtCnt :1; ///< RndStdIds::FLY_AT_PARA, anchored at paragraph
133 ///< or RndStdIds::FLY_AT_CHAR
134 bool m_bLayout :1; ///< RndStdIds::FLY_AT_PAGE, RndStdIds::FLY_AT_FLY, at page or at frame
135 bool m_bAutoPosition :1; ///< RndStdIds::FLY_AT_CHAR, anchored at character
136 bool m_bDeleted :1; ///< Anchored to a tracked deletion
137 size_t m_nAuthor; ///< Redline author index for colored crossing out
139 friend class SwNoTextFrame; // is allowed to call NotifyBackground
141 Point m_aContentPos; // content area's position relatively to Frame
142 bool m_bValidContentPos;
144 virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
145 void MakePrtArea( const SwBorderAttrs &rAttrs );
146 void MakeContentPos( const SwBorderAttrs &rAttrs );
148 void Lock() { m_bLocked = true; }
149 void Unlock() { m_bLocked = false; }
151 Size CalcRel( const SwFormatFrameSize &rSz ) const;
153 SwFlyFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor, bool bFollow = false );
155 virtual void DestroyImpl() override;
156 virtual ~SwFlyFrame() override;
158 /** method to assure that anchored object is registered at the correct
159 page frame
161 virtual void RegisterAtCorrectPage() override;
163 virtual bool SetObjTop_( const SwTwips _nTop ) override;
164 virtual bool SetObjLeft_( const SwTwips _nLeft ) override;
166 virtual SwRect GetObjBoundRect() const override;
167 virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override;
169 virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( ) override;
171 SwTwips CalcContentHeight(const SwBorderAttrs *pAttrs, const SwTwips nMinHeight, const SwTwips nUL);
173 public:
174 // #i26791#
175 virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&, PaintFrameMode mode = PAINT_ALL ) const override;
176 virtual Size ChgSize( const Size& aNewSize ) override;
177 virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
178 SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
180 virtual void CheckDirection( bool bVert ) override;
181 virtual void Cut() override;
182 #ifdef DBG_UTIL
183 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
184 #endif
186 bool IsResizeValid(const SwBorderAttrs *pAttrs, Size aTargetSize);
187 SwTwips Shrink_( SwTwips, bool bTst );
188 SwTwips Grow_(SwTwips, SwResizeLimitReason&, bool bTst);
189 void Invalidate_( SwPageFrame const *pPage = nullptr );
191 bool FrameSizeChg( const SwFormatFrameSize & );
193 SwFlyFrame *GetPrevLink() const { return m_pPrevLink; }
194 SwFlyFrame *GetNextLink() const { return m_pNextLink; }
196 static void ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow );
197 static void UnchainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow );
199 SwFlyFrame *FindChainNeighbour( SwFrameFormat const &rFormat, SwFrame *pAnch = nullptr );
201 /// Is this fly allowed to split across pages? (Disabled by default.)
202 bool IsFlySplitAllowed() const;
204 // #i26791#
205 const SwVirtFlyDrawObj* GetVirtDrawObj() const;
206 SwVirtFlyDrawObj *GetVirtDrawObj();
207 void NotifyDrawObj();
209 void ChgRelPos( const Point &rAbsPos );
210 bool IsInvalid() const { return m_bInvalid; }
211 void Invalidate() const { const_cast<SwFlyFrame*>(this)->m_bInvalid = true; }
212 void Validate() const { const_cast<SwFlyFrame*>(this)->m_bInvalid = false; }
214 bool IsMinHeight() const { return m_bMinHeight; }
215 bool IsLocked() const { return m_bLocked; }
216 bool IsAutoPos() const { return m_bAutoPosition; }
217 bool IsFlyInContentFrame() const { return m_bInCnt; }
218 bool IsFlyFreeFrame() const { return m_bAtCnt || m_bLayout; }
219 bool IsFlyLayFrame() const { return m_bLayout; }
220 bool IsFlyAtContentFrame() const { return m_bAtCnt; }
221 bool IsDeleted() const { return m_bDeleted; }
222 void SetDeleted(bool bDeleted) { m_bDeleted = bDeleted; }
223 void SetAuthor( size_t nAuthor ) { m_nAuthor = nAuthor; }
224 size_t GetAuthor() const { return m_nAuthor; }
226 bool IsNotifyBack() const { return m_bNotifyBack; }
227 void SetNotifyBack() { m_bNotifyBack = true; }
228 void ResetNotifyBack() { m_bNotifyBack = false; }
230 bool IsClipped() const { return m_bHeightClipped || m_bWidthClipped; }
231 bool IsHeightClipped() const { return m_bHeightClipped; }
233 bool IsLowerOf( const SwLayoutFrame* pUpper ) const;
234 bool IsUpperOf( const SwFlyFrame& _rLower ) const
236 return _rLower.IsLowerOf( this );
239 SwFrame *FindLastLower();
241 // #i13147# - add parameter <_bForPaint> to avoid load of
242 // the graphic during paint. Default value: false
243 bool GetContour( tools::PolyPolygon& rContour,
244 const bool _bForPaint = false ) const;
246 // Paint on this shell (consider Preview, print flag, etc. recursively)?
247 static bool IsPaint(SdrObject *pObj, const SwViewShell& rSh);
249 /** SwFlyFrame::IsBackgroundTransparent
251 determines if background of fly frame has to be drawn transparently
253 definition found in /core/layout/paintfrm.cxx
255 @return true, if background color is transparent or an existing background
256 graphic is transparent.
258 bool IsBackgroundTransparent() const;
260 void Chain( SwFrame* _pAnchor );
261 void Unchain();
262 void InsertCnt();
263 void DeleteCnt();
264 void InsertColumns();
266 // #i26791# - pure virtual methods of base class <SwAnchoredObject>
267 virtual void MakeObjPos() override;
268 virtual void InvalidateObjPos() override;
269 virtual void RegisterAtPage(SwPageFrame&) override;
271 virtual SwFrameFormat* GetFrameFormat() override;
272 virtual const SwFrameFormat* GetFrameFormat() const override;
274 virtual SwRect GetObjRect() const override;
276 /** method to determine if a format on the Writer fly frame is possible
278 #i28701#
279 refine 'IsFormatPossible'-conditions of method
280 <SwAnchoredObject::IsFormatPossible()> by:
281 format isn't possible, if Writer fly frame is locked resp. col-locked.
283 virtual bool IsFormatPossible() const override;
284 static void GetAnchoredObjects( std::vector<SwAnchoredObject*>&, const SwFormat& rFormat );
286 // overwriting "SwFrameFormat *SwLayoutFrame::GetFormat" to provide the correct derived return type.
287 // (This is in order to skip on the otherwise necessary casting of the result to
288 // 'SwFlyFrameFormat *' after calls to this function. The casting is now done in this function.)
289 virtual const SwFlyFrameFormat *GetFormat() const override;
290 SW_DLLPUBLIC virtual SwFlyFrameFormat *GetFormat() override;
292 virtual void dumpAsXml(xmlTextWriterPtr writer = nullptr) const override;
294 virtual void Calc(vcl::RenderContext* pRenderContext) const override;
296 const Point& ContentPos() const { return m_aContentPos; }
297 Point& ContentPos() { return m_aContentPos; }
299 void InvalidateContentPos();
301 void SelectionHasChanged(SwFEShell* pShell);
302 SW_DLLPUBLIC bool IsShowUnfloatButton(SwWrtShell* pWrtSh) const;
304 // For testing only (see uiwriter)
305 SW_DLLPUBLIC void ActiveUnfloatButton(SwWrtShell* pWrtSh);
307 virtual const SwFlyFrame* DynCastFlyFrame() const override;
308 virtual SwFlyFrame* DynCastFlyFrame() override;
310 SW_DLLPUBLIC SwFlyAtContentFrame* DynCastFlyAtContentFrame();
312 private:
313 void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const;
314 void PaintDecorators() const;
317 #endif
319 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */