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_INC_ANCHOREDDRAWOBJECT_HXX
20 #define INCLUDED_SW_INC_ANCHOREDDRAWOBJECT_HXX
22 #include <anchoredobject.hxx>
26 /** class for the positioning of drawing objects
30 class SW_DLLPUBLIC SwAnchoredDrawObject
: public SwAnchoredObject
33 // boolean, indicating that the object position has been invalidated
34 // and that a positioning has to be performed.
37 // rectangle, keeping the last object rectangle after the positioning
38 Rectangle
* mpLastObjRect
;
40 // boolean, indicating that anchored drawing object hasn't been attached
41 // to a anchor frame yet. Once, it is attached to a anchor frame the
42 // boolean changes its state.
43 bool mbNotYetAttachedToAnchorFrame
;
45 // boolean, indicating that anchored
46 // drawing object hasn't been positioned yet. Once, it's positioned the
47 // boolean changes its state.
48 bool mbNotYetPositioned
;
50 // boolean, indicating that after change of layout direction the
51 // anchored drawing object has to be captured on the page, if it exceeds
52 // the left or right page margin.
53 // Needed for compatibility option <DoNotCaptureDrawObjsOnPage>
54 bool mbCaptureAfterLayoutDirChange
;
56 /** method for the intrinsic positioning of a at-paragraph|at-character
57 anchored drawing object
59 helper method for method <MakeObjPos>
63 void _MakeObjPosAnchoredAtPara();
65 /** method for the intrinsic positioning of a at-page|at-frame anchored
68 helper method for method <MakeObjPos>
72 void _MakeObjPosAnchoredAtLayout();
74 /** method to set positioning attributes (not for as-character anchored)
76 During load the positioning attributes aren't set.
77 Thus, the positioning attributes are set by the current object geometry.
78 This method is also used for the conversion for drawing objects
79 (not anchored as-character) imported from OpenOffice.org file format
80 once and directly before the first positioning.
84 void _SetPositioningAttr();
86 /** method to set internal anchor position of <SdrObject> instance
89 For drawing objects the internal anchor position of the <SdrObject>
90 instance has to be set.
91 Note: This adjustment is not be done for as-character anchored
92 drawing object - the positioning code takes care of this.
93 #i31698# - API for drawing objects in Writer has
94 been adjusted. Thus, this method will only set the internal anchor
95 position of the <SdrObject> instance to the anchor position given
100 void _SetDrawObjAnchor();
102 /** method to invalidate the given page frame
106 void _InvalidatePage( SwPageFrm
* _pPageFrm
);
109 virtual void ObjectAttachedToAnchorFrame() SAL_OVERRIDE
;
111 /** method to assure that anchored object is registered at the correct
116 virtual void RegisterAtCorrectPage() SAL_OVERRIDE
;
118 virtual bool _SetObjTop( const SwTwips _nTop
) SAL_OVERRIDE
;
119 virtual bool _SetObjLeft( const SwTwips _nLeft
) SAL_OVERRIDE
;
121 virtual const SwRect
GetObjBoundRect() const SAL_OVERRIDE
;
126 SwAnchoredDrawObject();
127 virtual ~SwAnchoredDrawObject();
129 // declaration of pure virtual methods of base class <SwAnchoredObject>
130 virtual void MakeObjPos() SAL_OVERRIDE
;
131 virtual void InvalidateObjPos() SAL_OVERRIDE
;
132 inline bool IsValidPos() const
137 // accessors to the format
138 virtual SwFrameFormat
& GetFrameFormat() SAL_OVERRIDE
;
139 virtual const SwFrameFormat
& GetFrameFormat() const SAL_OVERRIDE
;
141 // accessors to the object area and its position
142 virtual const SwRect
GetObjRect() const SAL_OVERRIDE
;
143 // Return value can be NULL.
144 const Rectangle
* GetLastObjRect() const { return mpLastObjRect
;}
146 void SetLastObjRect( const Rectangle
& _rNewObjRect
);
148 /** adjust positioning and alignment attributes for new anchor frame
150 Set horizontal and vertical position/alignment to manual position
151 relative to anchor frame area using the anchor position of the
152 new anchor frame and the current absolute drawing object position.
153 Note: For correct Undo/Redo method should only be called inside a
158 @param <_pNewAnchorFrm>
159 input parameter - new anchor frame for the anchored object.
161 @param <_pNewObjRect>
162 optional input parameter - proposed new object rectangle. If not
163 provided the current object rectangle is taken.
165 void AdjustPositioningAttr( const SwFrm
* _pNewAnchorFrm
,
166 const SwRect
* _pNewObjRect
= 0L );
168 /** method to notify background of drawing object
172 virtual void NotifyBackground( SwPageFrm
* _pPageFrm
,
173 const SwRect
& _rRect
,
174 PrepareHint _eHint
) SAL_OVERRIDE
;
176 inline bool NotYetPositioned() const
178 return mbNotYetPositioned
;
181 // change of layout direction needs to be tracked
182 // for setting <mbCaptureAfterLayoutDirChange>.
183 virtual void UpdateLayoutDir() SAL_OVERRIDE
;
184 bool IsOutsidePage() const;
187 void ValidateThis() { mbValidPos
= true; }
189 /** The element name to show in the XML dump.
191 virtual const char* getElementName( ) const SAL_OVERRIDE
{ return "SwAnchoredDrawObject"; }
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */