1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: anchoreddrawobject.hxx,v $
10 * $Revision: 1.15.214.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _ANCHOREDDRAWOBJECT_HXX
31 #define _ANCHOREDDRAWOBJECT_HXX
33 #include <anchoredobject.hxx>
34 #include <tools/gen.hxx>
36 /** class for the positioning of drawing objects
38 OD 2004-03-25 #i26791#
42 class SW_DLLPUBLIC SwAnchoredDrawObject
: public SwAnchoredObject
45 // boolean, indicating that the object position has been invalidated
46 // and that a positioning has to be performed.
49 // rectangle, keeping the last object rectangle after the postioning
50 // --> OD 2004-09-29 #i34748# - change <maLastObjRect> to a pointer
51 Rectangle
* mpLastObjRect
;
53 // boolean, indicating that anchored drawing object hasn't been attached
54 // to a anchor frame yet. Once, it is attached to a anchor frame the
55 // boolean changes its state.
56 bool mbNotYetAttachedToAnchorFrame
;
58 // --> OD 2004-08-09 #i28749# - boolean, indicating that anchored
59 // drawing object hasn't been positioned yet. Once, it's positioned the
60 // boolean changes its state.
61 bool mbNotYetPositioned
;
63 // --> OD 2006-03-17 #i62875#
64 // boolean, indicating that after change of layout direction the
65 // anchored drawing object has to be captured on the page, if it exceeds
66 // the left or right page margin.
67 // Needed for compatibility option <DoNotCaptureDrawObjsOnPage>
68 bool mbCaptureAfterLayoutDirChange
;
71 /** method for the intrinsic positioning of a at-paragraph|at-character
72 anchored drawing object
74 OD 2004-08-12 #i32795# - helper method for method <MakeObjPos>
78 void _MakeObjPosAnchoredAtPara();
80 /** method for the intrinsic positioning of a at-page|at-frame anchored
83 OD 2004-08-12 #i32795# - helper method for method <MakeObjPos>
87 void _MakeObjPosAnchoredAtLayout();
89 /** method to set positioning attributes (not for as-character anchored)
91 OD 2004-10-20 #i35798#
92 During load the positioning attributes aren't set.
93 Thus, the positioning attributes are set by the current object geometry.
94 This method is also used for the conversion for drawing objects
95 (not anchored as-character) imported from OpenOffice.org file format
96 once and directly before the first positioning.
100 void _SetPositioningAttr();
102 /** method to set internal anchor position of <SdrObject> instance
103 of the drawing object
105 For drawing objects the internal anchor position of the <SdrObject>
106 instance has to be set.
107 Note: This adjustment is not be done for as-character anchored
108 drawing object - the positioning code takes care of this.
109 OD 2004-07-29 #i31698# - API for drawing objects in Writer has
110 been adjusted. Thus, this method will only set the internal anchor
111 position of the <SdrObject> instance to the anchor position given
116 void _SetDrawObjAnchor();
118 /** method to invalidate the given page frame
120 OD 2004-07-02 #i28701#
124 void _InvalidatePage( SwPageFrm
* _pPageFrm
);
127 virtual void ObjectAttachedToAnchorFrame();
129 /** method to assure that anchored object is registered at the correct
132 OD 2004-07-02 #i28701#
136 virtual void RegisterAtCorrectPage();
138 // --> OD 2006-08-10 #i68520#
139 virtual bool _SetObjTop( const SwTwips _nTop
);
140 virtual bool _SetObjLeft( const SwTwips _nLeft
);
143 // --> OD 2006-10-05 #i70122#
144 virtual const SwRect
GetObjBoundRect() const;
149 SwAnchoredDrawObject();
150 virtual ~SwAnchoredDrawObject();
152 // declaration of pure virtual methods of base class <SwAnchoredObject>
153 virtual void MakeObjPos();
154 virtual void InvalidateObjPos();
155 inline bool IsValidPos() const
160 // accessors to the format
161 virtual SwFrmFmt
& GetFrmFmt();
162 virtual const SwFrmFmt
& GetFrmFmt() const;
164 // accessors to the object area and its position
165 virtual const SwRect
GetObjRect() const;
166 // --> OD 2004-09-29 #i34748# - change return type to a pointer.
167 // Return value can be NULL.
168 const Rectangle
* GetLastObjRect() const;
170 // --> OD 2004-09-29 #i34748# - change method
171 void SetLastObjRect( const Rectangle
& _rNewObjRect
);
174 /** adjust positioning and alignment attributes for new anchor frame
177 Set horizontal and vertical position/alignment to manual position
178 relative to anchor frame area using the anchor position of the
179 new anchor frame and the current absolute drawing object position.
180 Note: For correct Undo/Redo method should only be called inside a
182 OD 2004-08-24 #i33313# - add second optional parameter <_pNewObjRect>
186 @param <_pNewAnchorFrm>
187 input parameter - new anchor frame for the anchored object.
189 @param <_pNewObjRect>
190 optional input parameter - proposed new object rectangle. If not
191 provided the current object rectangle is taken.
193 void AdjustPositioningAttr( const SwFrm
* _pNewAnchorFrm
,
194 const SwRect
* _pNewObjRect
= 0L );
196 /** method to notify background of drawing object
198 OD 2004-06-30 #i28701#
202 virtual void NotifyBackground( SwPageFrm
* _pPageFrm
,
203 const SwRect
& _rRect
,
204 PrepareHint _eHint
);
206 // --> OD 2005-08-16 #i53320#
207 inline bool NotYetPositioned() const
209 return mbNotYetPositioned
;
213 // --> OD 2006-03-17 #i62875#
214 // change of layout direction needs to be tracked
215 // for setting <mbCaptureAfterLayoutDirChange>.
216 virtual void UpdateLayoutDir();
218 // --> OD 2006-03-17 #i62875#
219 bool IsOutsidePage() const;
223 void ValidateThis() { mbValidPos
= true; }