nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / inc / flyfrm.hxx
blobf01c9262ec05948d77918e1ca03c3b75c5016a0e
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;
43 /** search an anchor for paragraph bound frames starting from pOldAnch
45 needed for dragging of objects bound to a paragraph for showing an anchor
46 indicator as well as for changing the anchor.
48 implemented in layout/flycnt.cxx
50 const SwContentFrame *FindAnchor( const SwFrame *pOldAnch, const Point &rNew,
51 const bool bBody = false );
53 /** calculate rectangle in that the object can be moved or rather be resized */
54 bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, bool bMove = true );
56 /** general base class for all free-flowing frames
58 #i26791# - inherit also from <SwAnchoredFlyFrame>
60 class SW_DLLPUBLIC SwFlyFrame : public SwLayoutFrame, public SwAnchoredObject
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 );
67 void InitDrawObj(SwFrame const&); // these to methods are called in the
68 void FinitDrawObj(); // constructors
70 void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
71 SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
73 using SwLayoutFrame::CalcRel;
75 protected:
76 // Predecessor/Successor for chaining with text flow
77 SwFlyFrame *m_pPrevLink, *m_pNextLink;
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;
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;
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;
109 bool m_bInCnt :1; ///< RndStdIds::FLY_AS_CHAR, anchored as character
110 bool m_bAtCnt :1; ///< RndStdIds::FLY_AT_PARA, anchored at paragraph
111 ///< or RndStdIds::FLY_AT_CHAR
112 bool m_bLayout :1; ///< RndStdIds::FLY_AT_PAGE, RndStdIds::FLY_AT_FLY, at page or at frame
113 bool m_bAutoPosition :1; ///< RndStdIds::FLY_AT_CHAR, anchored at character
115 friend class SwNoTextFrame; // is allowed to call NotifyBackground
117 Point m_aContentPos; // content area's position relatively to Frame
118 bool m_bValidContentPos;
120 virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
121 void MakePrtArea( const SwBorderAttrs &rAttrs );
122 void MakeContentPos( const SwBorderAttrs &rAttrs );
124 void Lock() { m_bLocked = true; }
125 void Unlock() { m_bLocked = false; }
127 Size CalcRel( const SwFormatFrameSize &rSz ) const;
129 SwFlyFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor );
131 virtual void DestroyImpl() override;
132 virtual ~SwFlyFrame() override;
134 /** method to assure that anchored object is registered at the correct
135 page frame
137 virtual void RegisterAtCorrectPage() override;
138 virtual void RegisterAtPage(SwPageFrame &) override;
140 virtual bool SetObjTop_( const SwTwips _nTop ) override;
141 virtual bool SetObjLeft_( const SwTwips _nLeft ) override;
143 virtual SwRect GetObjBoundRect() const override;
144 virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
145 virtual void SwClientNotify(const SwModify& rMod, const SfxHint& rHint) override;
147 virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( ) override;
149 SwTwips CalcContentHeight(const SwBorderAttrs *pAttrs, const SwTwips nMinHeight, const SwTwips nUL);
151 public:
152 // #i26791#
154 // get client information
155 virtual bool GetInfo( SfxPoolItem& ) const override;
156 virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&,
157 SwPrintData const*const pPrintData = nullptr ) const override;
158 virtual Size ChgSize( const Size& aNewSize ) override;
159 virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
160 SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
162 virtual void CheckDirection( bool bVert ) override;
163 virtual void Cut() override;
164 #ifdef DBG_UTIL
165 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
166 #endif
168 SwTwips Shrink_( SwTwips, bool bTst );
169 SwTwips Grow_ ( SwTwips, bool bTst );
170 void Invalidate_( SwPageFrame const *pPage = nullptr );
172 bool FrameSizeChg( const SwFormatFrameSize & );
174 SwFlyFrame *GetPrevLink() const { return m_pPrevLink; }
175 SwFlyFrame *GetNextLink() const { return m_pNextLink; }
177 static void ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow );
178 static void UnchainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow );
180 SwFlyFrame *FindChainNeighbour( SwFrameFormat const &rFormat, SwFrame *pAnch = nullptr );
182 // #i26791#
183 const SwVirtFlyDrawObj* GetVirtDrawObj() const;
184 SwVirtFlyDrawObj *GetVirtDrawObj();
185 void NotifyDrawObj();
187 void ChgRelPos( const Point &rAbsPos );
188 bool IsInvalid() const { return m_bInvalid; }
189 void Invalidate() const { const_cast<SwFlyFrame*>(this)->m_bInvalid = true; }
190 void Validate() const { const_cast<SwFlyFrame*>(this)->m_bInvalid = false; }
192 bool IsMinHeight() const { return m_bMinHeight; }
193 bool IsLocked() const { return m_bLocked; }
194 bool IsAutoPos() const { return m_bAutoPosition; }
195 bool IsFlyInContentFrame() const { return m_bInCnt; }
196 bool IsFlyFreeFrame() const { return m_bAtCnt || m_bLayout; }
197 bool IsFlyLayFrame() const { return m_bLayout; }
198 bool IsFlyAtContentFrame() const { return m_bAtCnt; }
200 bool IsNotifyBack() const { return m_bNotifyBack; }
201 void SetNotifyBack() { m_bNotifyBack = true; }
202 void ResetNotifyBack() { m_bNotifyBack = false; }
204 bool IsClipped() const { return m_bHeightClipped || m_bWidthClipped; }
205 bool IsHeightClipped() const { return m_bHeightClipped; }
207 bool IsLowerOf( const SwLayoutFrame* pUpper ) const;
208 bool IsUpperOf( const SwFlyFrame& _rLower ) const
210 return _rLower.IsLowerOf( this );
213 SwFrame *FindLastLower();
215 // #i13147# - add parameter <_bForPaint> to avoid load of
216 // the graphic during paint. Default value: false
217 bool GetContour( tools::PolyPolygon& rContour,
218 const bool _bForPaint = false ) const;
220 // Paint on this shell (consider Preview, print flag, etc. recursively)?
221 static bool IsPaint( SdrObject *pObj, const SwViewShell *pSh );
223 /** SwFlyFrame::IsBackgroundTransparent
225 determines if background of fly frame has to be drawn transparently
227 definition found in /core/layout/paintfrm.cxx
229 @return true, if background color is transparent or an existing background
230 graphic is transparent.
232 bool IsBackgroundTransparent() const;
234 void Chain( SwFrame* _pAnchor );
235 void Unchain();
236 void InsertCnt();
237 void DeleteCnt();
238 void InsertColumns();
240 // #i26791# - pure virtual methods of base class <SwAnchoredObject>
241 virtual void MakeObjPos() override;
242 virtual void InvalidateObjPos() override;
244 virtual SwFrameFormat& GetFrameFormat() override;
245 virtual const SwFrameFormat& GetFrameFormat() const override;
247 virtual SwRect GetObjRect() const override;
249 /** method to determine if a format on the Writer fly frame is possible
251 #i28701#
252 refine 'IsFormatPossible'-conditions of method
253 <SwAnchoredObject::IsFormatPossible()> by:
254 format isn't possible, if Writer fly frame is locked resp. col-locked.
256 virtual bool IsFormatPossible() const override;
257 static void GetAnchoredObjects( std::vector<SwAnchoredObject*>&, const SwFormat& rFormat );
259 // overwriting "SwFrameFormat *SwLayoutFrame::GetFormat" to provide the correct derived return type.
260 // (This is in order to skip on the otherwise necessary casting of the result to
261 // 'SwFlyFrameFormat *' after calls to this function. The casting is now done in this function.)
262 virtual const SwFlyFrameFormat *GetFormat() const override;
263 virtual SwFlyFrameFormat *GetFormat() override;
265 virtual void dumpAsXml( xmlTextWriterPtr writer ) const override { SwLayoutFrame::dumpAsXml( writer ); };
267 virtual void Calc(vcl::RenderContext* pRenderContext) const override;
269 const Point& ContentPos() const { return m_aContentPos; }
270 Point& ContentPos() { return m_aContentPos; }
272 void InvalidateContentPos();
274 void SelectionHasChanged(SwFEShell* pShell);
275 bool IsShowUnfloatButton(SwWrtShell* pWrtSh) const;
277 // For testing only (see uiwriter)
278 void ActiveUnfloatButton(SwWrtShell* pWrtSh);
280 private:
281 void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const;
282 void PaintDecorators() const;
284 #endif
286 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */