1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef _ANCHOREDDRAWOBJECT_HXX
28 #define _ANCHOREDDRAWOBJECT_HXX
30 #include <anchoredobject.hxx>
31 #include <tools/gen.hxx>
33 /** class for the positioning of drawing objects
35 OD 2004-03-25 #i26791#
39 class SW_DLLPUBLIC SwAnchoredDrawObject
: public SwAnchoredObject
42 // boolean, indicating that the object position has been invalidated
43 // and that a positioning has to be performed.
46 // rectangle, keeping the last object rectangle after the postioning
47 // --> OD 2004-09-29 #i34748# - change <maLastObjRect> to a pointer
48 Rectangle
* mpLastObjRect
;
50 // boolean, indicating that anchored drawing object hasn't been attached
51 // to a anchor frame yet. Once, it is attached to a anchor frame the
52 // boolean changes its state.
53 bool mbNotYetAttachedToAnchorFrame
;
55 // --> OD 2004-08-09 #i28749# - boolean, indicating that anchored
56 // drawing object hasn't been positioned yet. Once, it's positioned the
57 // boolean changes its state.
58 bool mbNotYetPositioned
;
60 // --> OD 2006-03-17 #i62875#
61 // boolean, indicating that after change of layout direction the
62 // anchored drawing object has to be captured on the page, if it exceeds
63 // the left or right page margin.
64 // Needed for compatibility option <DoNotCaptureDrawObjsOnPage>
65 bool mbCaptureAfterLayoutDirChange
;
68 /** method for the intrinsic positioning of a at-paragraph|at-character
69 anchored drawing object
71 OD 2004-08-12 #i32795# - helper method for method <MakeObjPos>
75 void _MakeObjPosAnchoredAtPara();
77 /** method for the intrinsic positioning of a at-page|at-frame anchored
80 OD 2004-08-12 #i32795# - helper method for method <MakeObjPos>
84 void _MakeObjPosAnchoredAtLayout();
86 /** method to set positioning attributes (not for as-character anchored)
88 OD 2004-10-20 #i35798#
89 During load the positioning attributes aren't set.
90 Thus, the positioning attributes are set by the current object geometry.
91 This method is also used for the conversion for drawing objects
92 (not anchored as-character) imported from OpenOffice.org file format
93 once and directly before the first positioning.
97 void _SetPositioningAttr();
99 /** method to set internal anchor position of <SdrObject> instance
100 of the drawing object
102 For drawing objects the internal anchor position of the <SdrObject>
103 instance has to be set.
104 Note: This adjustment is not be done for as-character anchored
105 drawing object - the positioning code takes care of this.
106 OD 2004-07-29 #i31698# - API for drawing objects in Writer has
107 been adjusted. Thus, this method will only set the internal anchor
108 position of the <SdrObject> instance to the anchor position given
113 void _SetDrawObjAnchor();
115 /** method to invalidate the given page frame
117 OD 2004-07-02 #i28701#
121 void _InvalidatePage( SwPageFrm
* _pPageFrm
);
124 virtual void ObjectAttachedToAnchorFrame();
126 /** method to assure that anchored object is registered at the correct
129 OD 2004-07-02 #i28701#
133 virtual void RegisterAtCorrectPage();
135 // --> OD 2006-08-10 #i68520#
136 virtual bool _SetObjTop( const SwTwips _nTop
);
137 virtual bool _SetObjLeft( const SwTwips _nLeft
);
140 // --> OD 2006-10-05 #i70122#
141 virtual const SwRect
GetObjBoundRect() const;
146 SwAnchoredDrawObject();
147 virtual ~SwAnchoredDrawObject();
149 // declaration of pure virtual methods of base class <SwAnchoredObject>
150 virtual void MakeObjPos();
151 virtual void InvalidateObjPos();
152 inline bool IsValidPos() const
157 // accessors to the format
158 virtual SwFrmFmt
& GetFrmFmt();
159 virtual const SwFrmFmt
& GetFrmFmt() const;
161 // accessors to the object area and its position
162 virtual const SwRect
GetObjRect() const;
163 // --> OD 2004-09-29 #i34748# - change return type to a pointer.
164 // Return value can be NULL.
165 const Rectangle
* GetLastObjRect() const;
167 // --> OD 2004-09-29 #i34748# - change method
168 void SetLastObjRect( const Rectangle
& _rNewObjRect
);
171 /** adjust positioning and alignment attributes for new anchor frame
174 Set horizontal and vertical position/alignment to manual position
175 relative to anchor frame area using the anchor position of the
176 new anchor frame and the current absolute drawing object position.
177 Note: For correct Undo/Redo method should only be called inside a
179 OD 2004-08-24 #i33313# - add second optional parameter <_pNewObjRect>
183 @param <_pNewAnchorFrm>
184 input parameter - new anchor frame for the anchored object.
186 @param <_pNewObjRect>
187 optional input parameter - proposed new object rectangle. If not
188 provided the current object rectangle is taken.
190 void AdjustPositioningAttr( const SwFrm
* _pNewAnchorFrm
,
191 const SwRect
* _pNewObjRect
= 0L );
193 /** method to notify background of drawing object
195 OD 2004-06-30 #i28701#
199 virtual void NotifyBackground( SwPageFrm
* _pPageFrm
,
200 const SwRect
& _rRect
,
201 PrepareHint _eHint
);
203 // --> OD 2005-08-16 #i53320#
204 inline bool NotYetPositioned() const
206 return mbNotYetPositioned
;
210 // --> OD 2006-03-17 #i62875#
211 // change of layout direction needs to be tracked
212 // for setting <mbCaptureAfterLayoutDirChange>.
213 virtual void UpdateLayoutDir();
215 // --> OD 2006-03-17 #i62875#
216 bool IsOutsidePage() const;
220 void ValidateThis() { mbValidPos
= true; }