Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _ANCHOREDDRAWOBJECT_HXX
20 : #define _ANCHOREDDRAWOBJECT_HXX
21 :
22 : #include <anchoredobject.hxx>
23 : #include <tools/gen.hxx>
24 :
25 : /** class for the positioning of drawing objects
26 :
27 : @author OD
28 : */
29 : class SW_DLLPUBLIC SwAnchoredDrawObject : public SwAnchoredObject
30 : {
31 : private:
32 : // boolean, indicating that the object position has been invalidated
33 : // and that a positioning has to be performed.
34 : bool mbValidPos;
35 :
36 : // rectangle, keeping the last object rectangle after the postioning
37 : Rectangle* mpLastObjRect;
38 :
39 : // boolean, indicating that anchored drawing object hasn't been attached
40 : // to a anchor frame yet. Once, it is attached to a anchor frame the
41 : // boolean changes its state.
42 : bool mbNotYetAttachedToAnchorFrame;
43 :
44 : // boolean, indicating that anchored
45 : // drawing object hasn't been positioned yet. Once, it's positioned the
46 : // boolean changes its state.
47 : bool mbNotYetPositioned;
48 :
49 : // boolean, indicating that after change of layout direction the
50 : // anchored drawing object has to be captured on the page, if it exceeds
51 : // the left or right page margin.
52 : // Needed for compatibility option <DoNotCaptureDrawObjsOnPage>
53 : bool mbCaptureAfterLayoutDirChange;
54 :
55 : /** method for the intrinsic positioning of a at-paragraph|at-character
56 : anchored drawing object
57 :
58 : helper method for method <MakeObjPos>
59 :
60 : @author OD
61 : */
62 : void _MakeObjPosAnchoredAtPara();
63 :
64 : /** method for the intrinsic positioning of a at-page|at-frame anchored
65 : drawing object
66 :
67 : helper method for method <MakeObjPos>
68 :
69 : @author OD
70 : */
71 : void _MakeObjPosAnchoredAtLayout();
72 :
73 : /** method to set positioning attributes (not for as-character anchored)
74 :
75 : During load the positioning attributes aren't set.
76 : Thus, the positioning attributes are set by the current object geometry.
77 : This method is also used for the conversion for drawing objects
78 : (not anchored as-character) imported from OpenOffice.org file format
79 : once and directly before the first positioning.
80 :
81 : @author OD
82 : */
83 : void _SetPositioningAttr();
84 :
85 : /** method to set internal anchor position of <SdrObject> instance
86 : of the drawing object
87 :
88 : For drawing objects the internal anchor position of the <SdrObject>
89 : instance has to be set.
90 : Note: This adjustment is not be done for as-character anchored
91 : drawing object - the positioning code takes care of this.
92 : #i31698# - API for drawing objects in Writer has
93 : been adjusted. Thus, this method will only set the internal anchor
94 : position of the <SdrObject> instance to the anchor position given
95 : by its anchor frame.
96 :
97 : @author OD
98 : */
99 : void _SetDrawObjAnchor();
100 :
101 : /** method to invalidate the given page frame
102 :
103 : @author OD
104 : */
105 : void _InvalidatePage( SwPageFrm* _pPageFrm );
106 :
107 : protected:
108 : virtual void ObjectAttachedToAnchorFrame();
109 :
110 : /** method to assure that anchored object is registered at the correct
111 : page frame
112 :
113 : @author OD
114 : */
115 : virtual void RegisterAtCorrectPage();
116 :
117 : virtual bool _SetObjTop( const SwTwips _nTop);
118 : virtual bool _SetObjLeft( const SwTwips _nLeft);
119 :
120 : virtual const SwRect GetObjBoundRect() const;
121 :
122 : public:
123 : TYPEINFO();
124 :
125 : SwAnchoredDrawObject();
126 : virtual ~SwAnchoredDrawObject();
127 :
128 : // declaration of pure virtual methods of base class <SwAnchoredObject>
129 : virtual void MakeObjPos();
130 : virtual void InvalidateObjPos();
131 0 : inline bool IsValidPos() const
132 : {
133 0 : return mbValidPos;
134 : }
135 :
136 : // accessors to the format
137 : virtual SwFrmFmt& GetFrmFmt();
138 : virtual const SwFrmFmt& GetFrmFmt() const;
139 :
140 : // accessors to the object area and its position
141 : virtual const SwRect GetObjRect() const;
142 : // Return value can be NULL.
143 : const Rectangle* GetLastObjRect() const;
144 :
145 : void SetLastObjRect( const Rectangle& _rNewObjRect );
146 :
147 : /** adjust positioning and alignment attributes for new anchor frame
148 :
149 : Set horizontal and vertical position/alignment to manual position
150 : relative to anchor frame area using the anchor position of the
151 : new anchor frame and the current absolute drawing object position.
152 : Note: For correct Undo/Redo method should only be called inside a
153 : Undo-/Redo-action.
154 :
155 : @author OD
156 :
157 : @param <_pNewAnchorFrm>
158 : input parameter - new anchor frame for the anchored object.
159 :
160 : @param <_pNewObjRect>
161 : optional input parameter - proposed new object rectangle. If not
162 : provided the current object rectangle is taken.
163 : */
164 : void AdjustPositioningAttr( const SwFrm* _pNewAnchorFrm,
165 : const SwRect* _pNewObjRect = 0L );
166 :
167 : /** method to notify background of drawing object
168 :
169 : @author OD
170 : */
171 : virtual void NotifyBackground( SwPageFrm* _pPageFrm,
172 : const SwRect& _rRect,
173 : PrepareHint _eHint );
174 :
175 255 : inline bool NotYetPositioned() const
176 : {
177 255 : return mbNotYetPositioned;
178 : }
179 :
180 : // change of layout direction needs to be tracked
181 : // for setting <mbCaptureAfterLayoutDirChange>.
182 : virtual void UpdateLayoutDir();
183 : bool IsOutsidePage() const;
184 :
185 : // new Loop control
186 0 : void ValidateThis() { mbValidPos = true; }
187 :
188 : /** The element name to show in the XML dump.
189 : */
190 1 : virtual const char* getElementName( ) { return "SwAnchoredDrawObject"; }
191 : };
192 :
193 : #endif
194 :
195 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|