1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_FLYFRMS_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_FLYFRMS_HXX
22 #include <sal/config.h>
27 #include "flowfrm.hxx"
31 double getLocalFrameRotation_from_SwNoTextFrame(const SwNoTextFrame
& rNoTextFrame
);
33 // Base class for those Flys that can "move freely" or better that are not
35 class SW_DLLPUBLIC SwFlyFreeFrame
: public SwFlyFrame
38 // #i34753# - flag for at-page anchored Writer fly frames
39 // to prevent a positioning - call of method <MakeObjPos()> -, if Writer
40 // fly frame is already clipped during its format by the object formatter.
43 // #i37068# - flag to prevent move in method <CheckClip(..)>
44 bool mbNoMoveOnCheckClip
: 1;
46 SwRect maUnclippedFrame
;
48 // RotateFlyFrame3 add TransformableSwFrame
49 std::unique_ptr
< TransformableSwFrame
> mpTransformableSwFrame
;
51 void CheckClip( const SwFormatFrameSize
&rSz
); //'Emergency' Clipping.
53 /** determines, if direct environment of fly frame has 'auto' size
56 start with anchor frame and search for a header, footer, row or fly frame
57 stopping at page frame.
58 return <true>, if such a frame is found and it has 'auto' size.
59 otherwise <false> is returned.
61 @return boolean indicating, that direct environment has 'auto' size
63 bool HasEnvironmentAutoSize() const;
65 // RotateFlyFrame3 - Support for outer Frame of a SwGrfNode
66 // Only for local data extraction. To uniquely access information
67 // for local transformation, use getFrameArea(Print)Transformation
68 double getLocalFrameRotation() const;
71 // #i28701# - new friend class <SwFlyNotify> for access to
72 // method <NotifyBackground>
73 friend class SwFlyNotify
;
74 virtual void NotifyBackground( SwPageFrame
*pPage
,
75 const SwRect
& rRect
, PrepareHint eHint
) override
;
76 SwFlyFreeFrame( SwFlyFrameFormat
*, SwFrame
*, SwFrame
*pAnchor
, bool bFollow
= false );
78 virtual void DestroyImpl() override
;
79 virtual ~SwFlyFreeFrame() override
;
84 virtual void MakeAll(vcl::RenderContext
* pRenderContext
) override
;
86 // #i37068# - accessors for member <mbNoMoveOnCheckClip>
87 void SetNoMoveOnCheckClip( const bool _bNewNoMoveOnCheckClip
)
89 mbNoMoveOnCheckClip
= _bNewNoMoveOnCheckClip
;
91 bool IsNoMoveOnCheckClip() const
93 return mbNoMoveOnCheckClip
;
95 // #i34753# - accessors for member <mbNoMakePos>
96 void SetNoMakePos( const bool _bNoMakePos
)
98 if ( IsFlyLayFrame() )
100 mbNoMakePos
= _bNoMakePos
;
103 bool IsNoMakePos() const
105 if ( IsFlyLayFrame() )
115 const SwRect
& GetUnclippedFrame( ) const
117 if ( maUnclippedFrame
.HasArea( ) )
118 return maUnclippedFrame
;
120 return getFrameArea();
123 /** method to determine, if a format on the Writer fly frame is possible
126 refine 'IsFormatPossible'-conditions of method
127 <SwFlyFrame::IsFormatPossible()> by:
128 format isn't possible, if Writer fly frame isn't registered at a page frame
129 and its anchor frame isn't inside another Writer fly frame.
131 virtual bool IsFormatPossible() const override
;
133 // RotateFlyFrame3 - Support for Transformations
134 bool isTransformableSwFrame() const { return bool(mpTransformableSwFrame
); }
135 TransformableSwFrame
* getTransformableSwFrame() { return mpTransformableSwFrame
.get(); }
136 const TransformableSwFrame
* getTransformableSwFrame() const { return mpTransformableSwFrame
.get(); }
138 // RotateFlyFrame3 - Support for AutoContour
139 bool supportsAutoContour() const;
141 // RotateFlyFrame3 - Support for Transformations
142 virtual basegfx::B2DHomMatrix
getFrameAreaTransformation() const override
;
143 virtual basegfx::B2DHomMatrix
getFramePrintAreaTransformation() const override
;
145 // RotateFlyFrame3 - Support for Transformations
146 virtual void transform_translate(const Point
& rOffset
) override
;
149 /// Flys that are bound to layout frames (to-frame) and not to/as content
150 class SwFlyLayFrame final
: public SwFlyFreeFrame
155 SwFlyLayFrame( SwFlyFrameFormat
*, SwFrame
*, SwFrame
*pAnchor
);
157 virtual void RegisterAtPage(SwPageFrame
&) override
;
158 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
161 /// Flys that are anchored to content (at-para, at-char) but not in content (as-char).
162 class SW_DLLPUBLIC SwFlyAtContentFrame final
: public SwFlyFreeFrame
, public SwFlowFrame
164 virtual void MakeAll(vcl::RenderContext
* pRenderContext
) override
;
167 virtual bool InvalidationAllowed( const InvalidationType _nInvalid
) const override
;
169 /** method to assure that anchored object is registered at the correct
174 virtual void RegisterAtCorrectPage() override
;
175 virtual void RegisterAtPage(SwPageFrame
&) override
;
176 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
177 bool ShouldBwdMoved(SwLayoutFrame
* pNewUpper
, bool& rReformat
) override
;
182 SwFlyAtContentFrame( SwFlyFrameFormat
*, SwFrame
*, SwFrame
*pAnchor
, bool bFollow
= false );
183 SwFlyAtContentFrame(SwFlyAtContentFrame
& rPrecede
);
184 ~SwFlyAtContentFrame();
186 void SetAbsPos( const Point
&rNew
);
189 virtual void MakeObjPos() override
;
191 /** method to determine, if a format on the Writer fly frame is possible
194 refine 'IsFormatPossible'-conditions of method
195 <SwFlyFreeFrame::IsFormatPossible()> by:
196 format isn't possible, if method <MakeAll()> is already in progress.
198 virtual bool IsFormatPossible() const override
;
199 const SwFlyAtContentFrame
* GetFollow() const;
200 SwFlyAtContentFrame
* GetFollow();
201 const SwFlyAtContentFrame
* GetPrecede() const;
202 SwFlyAtContentFrame
* GetPrecede();
203 /// Like Cut(), except that follow chaining is maintained.
205 void dumpAsXmlAttributes(xmlTextWriterPtr pWriter
) const override
;
208 /// Flys that are anchored as a character in the content.
209 class SwFlyInContentFrame final
: public SwFlyFrame
211 Point m_aRef
; // relative to this point AbsPos is being calculated
213 virtual void DestroyImpl() override
;
214 virtual ~SwFlyInContentFrame() override
;
216 virtual void NotifyBackground(SwPageFrame
*pPage
, const SwRect
& rRect
, PrepareHint eHint
) override
;
217 virtual void MakeAll(vcl::RenderContext
* pRenderContext
) override
;
218 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
223 SwFlyInContentFrame( SwFlyFrameFormat
*, SwFrame
*, SwFrame
*pAnchor
);
225 virtual void Format( vcl::RenderContext
* pRenderContext
, const SwBorderAttrs
*pAttrs
= nullptr ) override
;
227 void SetRefPoint( const Point
& rPoint
, const Point
&rRelAttr
,
228 const Point
&rRelPos
);
229 const Point
&GetRefPoint() const { return m_aRef
; }
230 Point
const & GetRelPos() const;
232 // (26.11.93, see tabfrm.hxx, but might also be valid for others)
233 // For creation of a Fly after a FlyCnt was created _and_ inserted.
234 // Must be called by creator because can be pasted only after creation.
235 // Sometimes the page for registering the Flys is not visible until then
240 void AddRefOfst( tools::Long nOfst
) { m_aRef
.AdjustY( nOfst
); }
241 void AddRefOfst(Point
const& rOfst
) { m_aRef
+= rOfst
; }
244 virtual void MakeObjPos() override
;
246 // invalidate anchor frame on invalidation of the position, because the
247 // position is calculated during the format of the anchor frame
248 virtual void ActionOnInvalidation( const InvalidationType _nInvalid
) override
;
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */