xref: /AOO41X/main/sw/source/core/inc/objectformatter.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 #ifndef _OBJECTFORMATTER_HXX
28 #define _OBJECTFORMATTER_HXX
29 
30 #include <sal/types.h>
31 
32 class SwFrm;
33 // --> OD 2004-10-08 #i26945#
34 class SwTxtFrm;
35 // <--
36 class SwLayoutFrm;
37 class SwPageFrm;
38 class SwAnchoredObject;
39 class SwLayAction;
40 // --> OD 2004-10-04 #i26945#
41 class SwPageNumAndTypeOfAnchors;
42 // <--
43 
44 // -----------------------------------------------------------------------------
45 // OD 2004-06-25 #i28701#
46 // Format floating screen objects, which are anchored at the given anchor frame
47 // and registered at the given page frame.
48 // -----------------------------------------------------------------------------
49 class SwObjectFormatter
50 {
51     private:
52         // page frame, at which the floating screen objects are registered.
53         const SwPageFrm& mrPageFrm;
54 
55         // boolean, indicating that only as-character anchored objects have to
56         // be formatted.
57         bool mbFormatOnlyAsCharAnchored;
58 
59         // value of document compatibility option 'Consider wrapping style on
60         // object positioning'
61         const bool mbConsiderWrapOnObjPos;
62 
63         // layout action calling the format of the floating screen objects
64         SwLayAction* mpLayAction;
65 
66         // data structure to collect page number of object's 'anchor'
67         // --> OD 2004-10-04 #i26945#
68         SwPageNumAndTypeOfAnchors* mpPgNumAndTypeOfAnchors;
69         // <--
70 
71         /** helper method for method <_FormatObj(..)> - performs the intrinsic
72             format of the layout of the given layout frame and all its lower
73             layout frames.
74 
75             OD 2004-06-28 #i28701#
76             IMPORTANT NOTE:
77             Method corresponds to methods <SwLayAction::FormatLayoutFly(..)> and
78             <SwLayAction::FormatLayout(..)>. Thus, its code for the formatting have
79             to be synchronised.
80 
81             @author OD
82         */
83         void _FormatLayout( SwLayoutFrm& _rLayoutFrm );
84 
85         /** helper method for method <_FormatObj(..)> - performs the intrinsic
86             format of the content of the given floating screen object.
87 
88             OD 2004-06-28 #i28701#
89 
90             @author OD
91         */
92         void _FormatObjCntnt( SwAnchoredObject& _rAnchoredObj );
93 
94     protected:
95         SwObjectFormatter( const SwPageFrm& _rPageFrm,
96                            SwLayAction* _pLayAction = 0L,
97                            const bool _bCollectPgNumOfAnchors = false );
98 
99         static SwObjectFormatter* CreateObjFormatter( SwFrm& _rAnchorFrm,
100                                                       const SwPageFrm& _rPageFrm,
101                                                       SwLayAction* _pLayAction );
102 
103         virtual SwFrm& GetAnchorFrm() = 0;
104 
105         inline const SwPageFrm& GetPageFrm() const
106         {
107             return mrPageFrm;
108         }
109 
110         inline bool ConsiderWrapOnObjPos() const
111         {
112             return mbConsiderWrapOnObjPos;
113         }
114 
115         inline SwLayAction* GetLayAction()
116         {
117             return mpLayAction;
118         }
119 
120         /** method to restrict the format of floating screen objects to
121             as-character anchored ones
122 
123             @author OD
124         */
125         inline void SetFormatOnlyAsCharAnchored()
126         {
127             mbFormatOnlyAsCharAnchored = true;
128         }
129 
130         inline bool FormatOnlyAsCharAnchored() const
131         {
132             return mbFormatOnlyAsCharAnchored;
133         }
134 
135         /** performs the intrinsic format of a given floating screen object and its content.
136 
137             OD 2004-06-28 #i28701#
138 
139             @author OD
140         */
141         void _FormatObj( SwAnchoredObject& _rAnchoredObj );
142 
143         /** invokes the intrinsic format method for all floating screen objects,
144             anchored at anchor frame on the given page frame
145 
146             OD 2004-06-28 #i28701#
147             OD 2004-10-08 #i26945# - for format of floating screen objects for
148             follow text frames, the 'master' text frame is passed to the method.
149             Thus, the objects, whose anchor character is inside the follow text
150             frame can be formatted.
151 
152             @author OD
153 
154             @param _pMasterTxtFrm
155             input parameter - pointer to 'master' text frame. default value: NULL
156         */
157         bool _FormatObjsAtFrm( SwTxtFrm* _pMasterTxtFrm = 0L );
158 
159         /** accessor to collected anchored object
160 
161             OD 2004-07-05 #i28701#
162 
163             @author OD
164         */
165         SwAnchoredObject* GetCollectedObj( const sal_uInt32 _nIndex );
166 
167         /** accessor to 'anchor' page number of collected anchored object
168 
169             OD 2004-07-05 #i28701#
170 
171             @author OD
172         */
173         sal_uInt32 GetPgNumOfCollected( const sal_uInt32 _nIndex );
174 
175         /** accessor to 'anchor' type of collected anchored object
176 
177             OD 2004-10-04 #i26945#
178 
179             @author OD
180         */
181         bool IsCollectedAnchoredAtMaster( const sal_uInt32 _nIndex );
182 
183         /** accessor to total number of collected anchored objects
184 
185             OD 2004-07-05 #i28701#
186 
187             @author OD
188         */
189         sal_uInt32 CountOfCollected();
190 
191     public:
192         virtual ~SwObjectFormatter();
193 
194         /** intrinsic method to format a certain floating screen object
195 
196             OD 2005-01-10 #i40147# - add parameter <_bCheckForMovedFwd>
197 
198             @author OD
199 
200             @param _rAnchoredObj
201             input parameter - anchored object, which have to be formatted.
202 
203             @param _bCheckForMovedFwd
204             input parameter - boolean indicating, that after a successful
205             format of the anchored object the anchor frame has to be checked,
206             if it would moved forward due to the positioning of the anchored object.
207             default value: false
208             value only considered, if wrapping style influence has to be
209             considered for the positioning of the anchored object.
210         */
211         virtual bool DoFormatObj( SwAnchoredObject& _rAnchoredObj,
212                                   const bool _bCheckForMovedFwd = false ) = 0;
213 
214         /** intrinsic method to format all floating screen objects
215 
216             @author OD
217         */
218         virtual bool DoFormatObjs() = 0;
219 
220         /** method to format all floating screen objects at the given anchor frame
221 
222             @author OD
223         */
224         static bool FormatObjsAtFrm( SwFrm& _rAnchorFrm,
225                                      const SwPageFrm& _rPageFrm,
226                                      SwLayAction* _pLayAction = 0L );
227 
228         /** method to format a given floating screen object
229 
230             @author OD
231         */
232         static bool FormatObj( SwAnchoredObject& _rAnchoredObj,
233                                SwFrm* _pAnchorFrm = 0L,
234                                const SwPageFrm* _pPageFrm = 0L,
235                                SwLayAction* _pLayAction = 0L );
236 };
237 
238 #endif
239