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 _OBJECTFORMATTER_HXX
20 : #define _OBJECTFORMATTER_HXX
21 :
22 : #include <sal/types.h>
23 :
24 : class SwFrm;
25 : // #i26945#
26 : class SwTxtFrm;
27 : class SwLayoutFrm;
28 : class SwPageFrm;
29 : class SwAnchoredObject;
30 : class SwLayAction;
31 : // OD 2004-10-04 #i26945#
32 : class SwPageNumAndTypeOfAnchors;
33 :
34 : // -----------------------------------------------------------------------------
35 : // #i28701#
36 : // Format floating screen objects, which are anchored at the given anchor frame
37 : // and registered at the given page frame.
38 : // -----------------------------------------------------------------------------
39 : class SwObjectFormatter
40 : {
41 : private:
42 : // page frame, at which the floating screen objects are registered.
43 : const SwPageFrm& mrPageFrm;
44 :
45 : // boolean, indicating that only as-character anchored objects have to
46 : // be formatted.
47 : bool mbFormatOnlyAsCharAnchored;
48 :
49 : // value of document compatibility option 'Consider wrapping style on
50 : // object positioning'
51 : const bool mbConsiderWrapOnObjPos;
52 :
53 : // layout action calling the format of the floating screen objects
54 : SwLayAction* mpLayAction;
55 :
56 : // data structure to collect page number of object's 'anchor'
57 : // #i26945#
58 : SwPageNumAndTypeOfAnchors* mpPgNumAndTypeOfAnchors;
59 :
60 : /** helper method for method <_FormatObj(..)> - performs the intrinsic
61 : format of the layout of the given layout frame and all its lower
62 : layout frames.
63 :
64 : #i28701#
65 : IMPORTANT NOTE:
66 : Method corresponds to methods <SwLayAction::FormatLayoutFly(..)> and
67 : <SwLayAction::FormatLayout(..)>. Thus, its code for the formatting have
68 : to be synchronised.
69 : */
70 : void _FormatLayout( SwLayoutFrm& _rLayoutFrm );
71 :
72 : /** helper method for method <_FormatObj(..)> - performs the intrinsic
73 : format of the content of the given floating screen object.
74 :
75 : #i28701#
76 : */
77 : void _FormatObjCntnt( SwAnchoredObject& _rAnchoredObj );
78 :
79 : protected:
80 : SwObjectFormatter( const SwPageFrm& _rPageFrm,
81 : SwLayAction* _pLayAction = 0L,
82 : const bool _bCollectPgNumOfAnchors = false );
83 :
84 : static SwObjectFormatter* CreateObjFormatter( SwFrm& _rAnchorFrm,
85 : const SwPageFrm& _rPageFrm,
86 : SwLayAction* _pLayAction );
87 :
88 : virtual SwFrm& GetAnchorFrm() = 0;
89 :
90 1 : inline const SwPageFrm& GetPageFrm() const
91 : {
92 1 : return mrPageFrm;
93 : }
94 :
95 194 : inline bool ConsiderWrapOnObjPos() const
96 : {
97 194 : return mbConsiderWrapOnObjPos;
98 : }
99 :
100 1397 : inline SwLayAction* GetLayAction()
101 : {
102 1397 : return mpLayAction;
103 : }
104 :
105 : /** method to restrict the format of floating screen objects to
106 : as-character anchored ones
107 : */
108 : inline void SetFormatOnlyAsCharAnchored()
109 : {
110 : mbFormatOnlyAsCharAnchored = true;
111 : }
112 :
113 834 : inline bool FormatOnlyAsCharAnchored() const
114 : {
115 834 : return mbFormatOnlyAsCharAnchored;
116 : }
117 :
118 : /** performs the intrinsic format of a given floating screen object and its content.
119 :
120 : #i28701#
121 : */
122 : void _FormatObj( SwAnchoredObject& _rAnchoredObj );
123 :
124 : /** invokes the intrinsic format method for all floating screen objects,
125 : anchored at anchor frame on the given page frame
126 :
127 : #i28701#
128 : #i26945# - for format of floating screen objects for
129 : follow text frames, the 'master' text frame is passed to the method.
130 : Thus, the objects, whose anchor character is inside the follow text
131 : frame can be formatted.
132 :
133 : @param _pMasterTxtFrm
134 : input parameter - pointer to 'master' text frame. default value: NULL
135 : */
136 : bool _FormatObjsAtFrm( SwTxtFrm* _pMasterTxtFrm = 0L );
137 :
138 : /** accessor to collected anchored object
139 :
140 : #i28701#
141 : */
142 : SwAnchoredObject* GetCollectedObj( const sal_uInt32 _nIndex );
143 :
144 : /** accessor to 'anchor' page number of collected anchored object
145 :
146 : #i28701#
147 : */
148 : sal_uInt32 GetPgNumOfCollected( const sal_uInt32 _nIndex );
149 :
150 : /** accessor to 'anchor' type of collected anchored object
151 :
152 : #i26945#
153 : */
154 : bool IsCollectedAnchoredAtMaster( const sal_uInt32 _nIndex );
155 :
156 : /** accessor to total number of collected anchored objects
157 :
158 : #i28701#
159 : */
160 : sal_uInt32 CountOfCollected();
161 :
162 : public:
163 : virtual ~SwObjectFormatter();
164 :
165 : /** intrinsic method to format a certain floating screen object
166 :
167 : #i40147# - add parameter <_bCheckForMovedFwd>
168 :
169 : @param _rAnchoredObj
170 : input parameter - anchored object, which have to be formatted.
171 :
172 : @param _bCheckForMovedFwd
173 : input parameter - boolean indicating, that after a successful
174 : format of the anchored object the anchor frame has to be checked,
175 : if it would moved forward due to the positioning of the anchored object.
176 : default value: false
177 : value only considered, if wrapping style influence has to be
178 : considered for the positioning of the anchored object.
179 : */
180 : virtual bool DoFormatObj( SwAnchoredObject& _rAnchoredObj,
181 : const bool _bCheckForMovedFwd = false ) = 0;
182 :
183 : /** intrinsic method to format all floating screen objects
184 : */
185 : virtual bool DoFormatObjs() = 0;
186 :
187 : /** method to format all floating screen objects at the given anchor frame
188 : */
189 : static bool FormatObjsAtFrm( SwFrm& _rAnchorFrm,
190 : const SwPageFrm& _rPageFrm,
191 : SwLayAction* _pLayAction = 0L );
192 :
193 : /** method to format a given floating screen object
194 : */
195 : static bool FormatObj( SwAnchoredObject& _rAnchoredObj,
196 : SwFrm* _pAnchorFrm = 0L,
197 : const SwPageFrm* _pPageFrm = 0L,
198 : SwLayAction* _pLayAction = 0L );
199 : };
200 :
201 : #endif
202 :
203 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|