1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _OBJECTFORMATTER_HXX 24 #define _OBJECTFORMATTER_HXX 25 26 #include <sal/types.h> 27 28 class SwFrm; 29 // --> OD 2004-10-08 #i26945# 30 class SwTxtFrm; 31 // <-- 32 class SwLayoutFrm; 33 class SwPageFrm; 34 class SwAnchoredObject; 35 class SwLayAction; 36 // --> OD 2004-10-04 #i26945# 37 class SwPageNumAndTypeOfAnchors; 38 // <-- 39 40 // ----------------------------------------------------------------------------- 41 // OD 2004-06-25 #i28701# 42 // Format floating screen objects, which are anchored at the given anchor frame 43 // and registered at the given page frame. 44 // ----------------------------------------------------------------------------- 45 class SwObjectFormatter 46 { 47 private: 48 // page frame, at which the floating screen objects are registered. 49 const SwPageFrm& mrPageFrm; 50 51 // boolean, indicating that only as-character anchored objects have to 52 // be formatted. 53 bool mbFormatOnlyAsCharAnchored; 54 55 // value of document compatibility option 'Consider wrapping style on 56 // object positioning' 57 const bool mbConsiderWrapOnObjPos; 58 59 // layout action calling the format of the floating screen objects 60 SwLayAction* mpLayAction; 61 62 // data structure to collect page number of object's 'anchor' 63 // --> OD 2004-10-04 #i26945# 64 SwPageNumAndTypeOfAnchors* mpPgNumAndTypeOfAnchors; 65 // <-- 66 67 /** helper method for method <_FormatObj(..)> - performs the intrinsic 68 format of the layout of the given layout frame and all its lower 69 layout frames. 70 71 OD 2004-06-28 #i28701# 72 IMPORTANT NOTE: 73 Method corresponds to methods <SwLayAction::FormatLayoutFly(..)> and 74 <SwLayAction::FormatLayout(..)>. Thus, its code for the formatting have 75 to be synchronised. 76 77 @author OD 78 */ 79 void _FormatLayout( SwLayoutFrm& _rLayoutFrm ); 80 81 /** helper method for method <_FormatObj(..)> - performs the intrinsic 82 format of the content of the given floating screen object. 83 84 OD 2004-06-28 #i28701# 85 86 @author OD 87 */ 88 void _FormatObjCntnt( SwAnchoredObject& _rAnchoredObj ); 89 90 protected: 91 SwObjectFormatter( const SwPageFrm& _rPageFrm, 92 SwLayAction* _pLayAction = 0L, 93 const bool _bCollectPgNumOfAnchors = false ); 94 95 static SwObjectFormatter* CreateObjFormatter( SwFrm& _rAnchorFrm, 96 const SwPageFrm& _rPageFrm, 97 SwLayAction* _pLayAction ); 98 99 virtual SwFrm& GetAnchorFrm() = 0; 100 GetPageFrm() const101 inline const SwPageFrm& GetPageFrm() const 102 { 103 return mrPageFrm; 104 } 105 ConsiderWrapOnObjPos() const106 inline bool ConsiderWrapOnObjPos() const 107 { 108 return mbConsiderWrapOnObjPos; 109 } 110 GetLayAction()111 inline SwLayAction* GetLayAction() 112 { 113 return mpLayAction; 114 } 115 116 /** method to restrict the format of floating screen objects to 117 as-character anchored ones 118 119 @author OD 120 */ SetFormatOnlyAsCharAnchored()121 inline void SetFormatOnlyAsCharAnchored() 122 { 123 mbFormatOnlyAsCharAnchored = true; 124 } 125 FormatOnlyAsCharAnchored() const126 inline bool FormatOnlyAsCharAnchored() const 127 { 128 return mbFormatOnlyAsCharAnchored; 129 } 130 131 /** performs the intrinsic format of a given floating screen object and its content. 132 133 OD 2004-06-28 #i28701# 134 135 @author OD 136 */ 137 void _FormatObj( SwAnchoredObject& _rAnchoredObj ); 138 139 /** invokes the intrinsic format method for all floating screen objects, 140 anchored at anchor frame on the given page frame 141 142 OD 2004-06-28 #i28701# 143 OD 2004-10-08 #i26945# - for format of floating screen objects for 144 follow text frames, the 'master' text frame is passed to the method. 145 Thus, the objects, whose anchor character is inside the follow text 146 frame can be formatted. 147 148 @author OD 149 150 @param _pMasterTxtFrm 151 input parameter - pointer to 'master' text frame. default value: NULL 152 */ 153 bool _FormatObjsAtFrm( SwTxtFrm* _pMasterTxtFrm = 0L ); 154 155 /** accessor to collected anchored object 156 157 OD 2004-07-05 #i28701# 158 159 @author OD 160 */ 161 SwAnchoredObject* GetCollectedObj( const sal_uInt32 _nIndex ); 162 163 /** accessor to 'anchor' page number of collected anchored object 164 165 OD 2004-07-05 #i28701# 166 167 @author OD 168 */ 169 sal_uInt32 GetPgNumOfCollected( const sal_uInt32 _nIndex ); 170 171 /** accessor to 'anchor' type of collected anchored object 172 173 OD 2004-10-04 #i26945# 174 175 @author OD 176 */ 177 bool IsCollectedAnchoredAtMaster( const sal_uInt32 _nIndex ); 178 179 /** accessor to total number of collected anchored objects 180 181 OD 2004-07-05 #i28701# 182 183 @author OD 184 */ 185 sal_uInt32 CountOfCollected(); 186 187 public: 188 virtual ~SwObjectFormatter(); 189 190 /** intrinsic method to format a certain floating screen object 191 192 OD 2005-01-10 #i40147# - add parameter <_bCheckForMovedFwd> 193 194 @author OD 195 196 @param _rAnchoredObj 197 input parameter - anchored object, which have to be formatted. 198 199 @param _bCheckForMovedFwd 200 input parameter - boolean indicating, that after a successful 201 format of the anchored object the anchor frame has to be checked, 202 if it would moved forward due to the positioning of the anchored object. 203 default value: false 204 value only considered, if wrapping style influence has to be 205 considered for the positioning of the anchored object. 206 */ 207 virtual bool DoFormatObj( SwAnchoredObject& _rAnchoredObj, 208 const bool _bCheckForMovedFwd = false ) = 0; 209 210 /** intrinsic method to format all floating screen objects 211 212 @author OD 213 */ 214 virtual bool DoFormatObjs() = 0; 215 216 /** method to format all floating screen objects at the given anchor frame 217 218 @author OD 219 */ 220 static bool FormatObjsAtFrm( SwFrm& _rAnchorFrm, 221 const SwPageFrm& _rPageFrm, 222 SwLayAction* _pLayAction = 0L ); 223 224 /** method to format a given floating screen object 225 226 @author OD 227 */ 228 static bool FormatObj( SwAnchoredObject& _rAnchoredObj, 229 SwFrm* _pAnchorFrm = 0L, 230 const SwPageFrm* _pPageFrm = 0L, 231 SwLayAction* _pLayAction = 0L ); 232 }; 233 234 #endif 235