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: objectformatter.hxx,v $
10 * $Revision: 1.8.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 _OBJECTFORMATTER_HXX
31 #define _OBJECTFORMATTER_HXX
33 #include <sal/types.h>
36 // --> OD 2004-10-08 #i26945#
41 class SwAnchoredObject
;
43 // --> OD 2004-10-04 #i26945#
44 class SwPageNumAndTypeOfAnchors
;
47 // -----------------------------------------------------------------------------
48 // OD 2004-06-25 #i28701#
49 // Format floating screen objects, which are anchored at the given anchor frame
50 // and registered at the given page frame.
51 // -----------------------------------------------------------------------------
52 class SwObjectFormatter
55 // page frame, at which the floating screen objects are registered.
56 const SwPageFrm
& mrPageFrm
;
58 // boolean, indicating that only as-character anchored objects have to
60 bool mbFormatOnlyAsCharAnchored
;
62 // value of document compatibility option 'Consider wrapping style on
63 // object positioning'
64 const bool mbConsiderWrapOnObjPos
;
66 // layout action calling the format of the floating screen objects
67 SwLayAction
* mpLayAction
;
69 // data structure to collect page number of object's 'anchor'
70 // --> OD 2004-10-04 #i26945#
71 SwPageNumAndTypeOfAnchors
* mpPgNumAndTypeOfAnchors
;
74 /** helper method for method <_FormatObj(..)> - performs the intrinsic
75 format of the layout of the given layout frame and all its lower
78 OD 2004-06-28 #i28701#
80 Method corresponds to methods <SwLayAction::FormatLayoutFly(..)> and
81 <SwLayAction::FormatLayout(..)>. Thus, its code for the formatting have
86 void _FormatLayout( SwLayoutFrm
& _rLayoutFrm
);
88 /** helper method for method <_FormatObj(..)> - performs the intrinsic
89 format of the content of the given floating screen object.
91 OD 2004-06-28 #i28701#
95 void _FormatObjCntnt( SwAnchoredObject
& _rAnchoredObj
);
98 SwObjectFormatter( const SwPageFrm
& _rPageFrm
,
99 SwLayAction
* _pLayAction
= 0L,
100 const bool _bCollectPgNumOfAnchors
= false );
102 static SwObjectFormatter
* CreateObjFormatter( SwFrm
& _rAnchorFrm
,
103 const SwPageFrm
& _rPageFrm
,
104 SwLayAction
* _pLayAction
);
106 virtual SwFrm
& GetAnchorFrm() = 0;
108 inline const SwPageFrm
& GetPageFrm() const
113 inline bool ConsiderWrapOnObjPos() const
115 return mbConsiderWrapOnObjPos
;
118 inline SwLayAction
* GetLayAction()
123 /** method to restrict the format of floating screen objects to
124 as-character anchored ones
128 inline void SetFormatOnlyAsCharAnchored()
130 mbFormatOnlyAsCharAnchored
= true;
133 inline bool FormatOnlyAsCharAnchored() const
135 return mbFormatOnlyAsCharAnchored
;
138 /** performs the intrinsic format of a given floating screen object and its content.
140 OD 2004-06-28 #i28701#
144 void _FormatObj( SwAnchoredObject
& _rAnchoredObj
);
146 /** invokes the intrinsic format method for all floating screen objects,
147 anchored at anchor frame on the given page frame
149 OD 2004-06-28 #i28701#
150 OD 2004-10-08 #i26945# - for format of floating screen objects for
151 follow text frames, the 'master' text frame is passed to the method.
152 Thus, the objects, whose anchor character is inside the follow text
153 frame can be formatted.
157 @param _pMasterTxtFrm
158 input parameter - pointer to 'master' text frame. default value: NULL
160 bool _FormatObjsAtFrm( SwTxtFrm
* _pMasterTxtFrm
= 0L );
162 /** accessor to collected anchored object
164 OD 2004-07-05 #i28701#
168 SwAnchoredObject
* GetCollectedObj( const sal_uInt32 _nIndex
);
170 /** accessor to 'anchor' page number of collected anchored object
172 OD 2004-07-05 #i28701#
176 sal_uInt32
GetPgNumOfCollected( const sal_uInt32 _nIndex
);
178 /** accessor to 'anchor' type of collected anchored object
180 OD 2004-10-04 #i26945#
184 bool IsCollectedAnchoredAtMaster( const sal_uInt32 _nIndex
);
186 /** accessor to total number of collected anchored objects
188 OD 2004-07-05 #i28701#
192 sal_uInt32
CountOfCollected();
195 virtual ~SwObjectFormatter();
197 /** intrinsic method to format a certain floating screen object
199 OD 2005-01-10 #i40147# - add parameter <_bCheckForMovedFwd>
204 input parameter - anchored object, which have to be formatted.
206 @param _bCheckForMovedFwd
207 input parameter - boolean indicating, that after a successful
208 format of the anchored object the anchor frame has to be checked,
209 if it would moved forward due to the positioning of the anchored object.
211 value only considered, if wrapping style influence has to be
212 considered for the positioning of the anchored object.
214 virtual bool DoFormatObj( SwAnchoredObject
& _rAnchoredObj
,
215 const bool _bCheckForMovedFwd
= false ) = 0;
217 /** intrinsic method to format all floating screen objects
221 virtual bool DoFormatObjs() = 0;
223 /** method to format all floating screen objects at the given anchor frame
227 static bool FormatObjsAtFrm( SwFrm
& _rAnchorFrm
,
228 const SwPageFrm
& _rPageFrm
,
229 SwLayAction
* _pLayAction
= 0L );
231 /** method to format a given floating screen object
235 static bool FormatObj( SwAnchoredObject
& _rAnchoredObj
,
236 SwFrm
* _pAnchorFrm
= 0L,
237 const SwPageFrm
* _pPageFrm
= 0L,
238 SwLayAction
* _pLayAction
= 0L );