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 24 #ifndef _WW8PAR2_HXX 25 #define _WW8PAR2_HXX 26 27 #ifndef SWTYPES_HXX 28 #include <swtypes.hxx> // enum RndStdIds 29 #endif 30 #include <fmtfsize.hxx> 31 #include <fmtornt.hxx> 32 #include <fmtsrnd.hxx> 33 #include <editeng/lrspitem.hxx> 34 35 #ifndef WW8SCAN_HXX 36 #include "ww8scan.hxx" // class WW8Style 37 #endif 38 #ifndef WW8PAR_HXX 39 #include "ww8par.hxx" // WW8_BRC5 40 #endif 41 42 class WW8RStyle; 43 44 class WW8DupProperties 45 { 46 public: 47 WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStk); 48 void Insert(const SwPosition &rPos); 49 private: 50 //No copying 51 WW8DupProperties(const WW8DupProperties&); 52 WW8DupProperties& operator=(const WW8DupProperties&); 53 SwWW8FltControlStack* pCtrlStck; 54 SfxItemSet aChrSet,aParSet; 55 }; 56 57 struct WW8FlyPara 58 { // WinWord-Attribute 59 // Achtung: *Nicht* umsortieren, da Teile mit 60 // memcmp verglichen werden 61 bool bVer67; 62 sal_Int16 nSp26, nSp27; // rohe Position 63 sal_Int16 nSp45, nSp28; // Breite / Hoehe 64 sal_Int16 nLeMgn, nRiMgn, nUpMgn, nLoMgn; // Raender 65 sal_uInt8 nSp29; // rohe Bindung + Alignment 66 sal_uInt8 nSp37; // Wrap-Mode ( 1 / 2; 0 = no Apo ? ) 67 WW8_BRC5 brc; // Umrandung Top, Left, Bottom, Right, Between 68 bool bBorderLines; // Umrandungslinien 69 bool bGrafApo; // true: Dieser Rahmen dient allein dazu, die 70 // enthaltene Grafik anders als zeichengebunden 71 // zu positionieren 72 bool mbVertSet; // true if vertical positioning has been set 73 sal_uInt8 nOrigSp29; 74 75 WW8FlyPara(bool bIsVer67, const WW8FlyPara* pSrc = 0); 76 bool operator==(const WW8FlyPara& rSrc) const; 77 void Read(const sal_uInt8* pSprm29, WW8PLCFx_Cp_FKP* pPap); 78 void ReadFull(const sal_uInt8* pSprm29, SwWW8ImplReader* pIo); 79 void Read(const sal_uInt8* pSprm29, WW8RStyle* pStyle); 80 void ApplyTabPos(const WW8_TablePos *pTabPos); 81 bool IsEmpty() const; 82 }; 83 84 struct WW8SwFlyPara 85 { 86 SwFlyFrmFmt* pFlyFmt; 87 88 // 1. Teil: daraus abgeleitete Sw-Attribute 89 sal_Int16 nXPos, nYPos; // Position 90 sal_Int16 nLeMgn, nRiMgn; // Raender 91 sal_Int16 nUpMgn, nLoMgn; // Raender 92 sal_Int16 nWidth, nHeight; // Groesse 93 sal_Int16 nNettoWidth; 94 95 SwFrmSize eHeightFix; // Hoehe Fix oder Min 96 RndStdIds eAnchor; // Bindung 97 short eHRel; // Seite oder Seitenrand 98 short eVRel; // Seite oder Seitenrand 99 sal_Int16 eVAlign; // Oben, unten, mittig 100 sal_Int16 eHAlign; // links, rechts, mittig 101 SwSurround eSurround; // Wrap-Mode 102 103 sal_uInt8 nXBind, nYBind; // relativ zu was gebunden 104 105 // 2.Teil: sich waehrend des Einlesens ergebende AEnderungen 106 long nNewNettoWidth; 107 SwPosition* pMainTextPos; // um nach Apo in Haupttext zurueckzukehren 108 sal_uInt16 nLineSpace; // LineSpace in tw fuer Graf-Apos 109 bool bAutoWidth; 110 bool bToggelPos; 111 112 // --> OD 2007-07-03 #148498# 113 // add parameter <nWWPgTop> - WW8's page top margin 114 WW8SwFlyPara( SwPaM& rPaM, 115 SwWW8ImplReader& rIo, 116 WW8FlyPara& rWW, 117 const sal_uInt32 nWWPgTop, 118 const sal_uInt32 nPgLeft, 119 const sal_uInt32 nPgWidth, 120 const sal_Int32 nIniFlyDx, 121 const sal_Int32 nIniFlyDy ); 122 123 void BoxUpWidth( long nWidth ); 124 SwWW8FltAnchorStack *pOldAnchorStck; 125 }; 126 127 class SwWW8StyInf 128 { 129 String sWWStyleName; 130 sal_uInt16 nWWStyleId; 131 132 133 public: 134 rtl_TextEncoding eLTRFontSrcCharSet; // rtl_TextEncoding fuer den Font 135 rtl_TextEncoding eRTLFontSrcCharSet; // rtl_TextEncoding fuer den Font 136 rtl_TextEncoding eCJKFontSrcCharSet; // rtl_TextEncoding fuer den Font 137 SwFmt* pFmt; 138 WW8FlyPara* pWWFly; 139 SwNumRule* pOutlineNumrule; 140 long nFilePos; 141 sal_uInt16 nBase; 142 sal_uInt16 nFollow; 143 sal_uInt16 nLFOIndex; 144 sal_uInt8 nListLevel; 145 146 // WW8 outline level is zero-based: 147 // 0: outline level 1 148 // 1: outline level 2 149 // ... 150 // 8: outline level 9 151 // 9: body text 152 sal_uInt8 mnWW8OutlineLevel; 153 154 sal_uInt16 n81Flags; // Fuer Bold, Italic, ... 155 sal_uInt16 n81BiDiFlags; // Fuer Bold, Italic, ... 156 SvxLRSpaceItem maWordLR; 157 bool bValid; // leer oder Valid 158 bool bImported; // fuers rekursive Importieren 159 bool bColl; // true-> pFmt ist SwTxtFmtColl 160 bool bImportSkipped; // nur true bei !bNewDoc && vorh. Style 161 bool bHasStyNumRule; // true-> Benannter NumRule in Style 162 bool bHasBrokenWW6List; // true-> WW8+ style has a WW7- list 163 bool bListReleventIndentSet; //true if this style's indent has 164 //been explicitly set, it's set to the value 165 //of pFmt->GetItemState(RES_LR_SPACE, false) 166 //if it was possible to get the ItemState 167 //for L of the LR space independently 168 bool bParaAutoBefore; // For Auto spacing before a paragraph 169 bool bParaAutoAfter; // For Auto Spacing after a paragraph 170 SwWW8StyInf()171 SwWW8StyInf() : 172 sWWStyleName( aEmptyStr ), 173 nWWStyleId( 0 ), 174 eLTRFontSrcCharSet(0), 175 eRTLFontSrcCharSet(0), 176 eCJKFontSrcCharSet(0), 177 pFmt( 0 ), 178 pWWFly( 0 ), 179 pOutlineNumrule( 0 ), 180 nFilePos( 0 ), 181 nBase( 0 ), 182 nFollow( 0 ), 183 nLFOIndex( USHRT_MAX ), 184 nListLevel(WW8ListManager::nMaxLevel), 185 mnWW8OutlineLevel( MAXLEVEL ), 186 n81Flags( 0 ), 187 n81BiDiFlags(0), 188 maWordLR( RES_LR_SPACE ), 189 bValid(false), 190 bImported(false), 191 bColl(false), 192 bImportSkipped(false), 193 bHasStyNumRule(false), 194 bHasBrokenWW6List(false), 195 bListReleventIndentSet(false), 196 bParaAutoBefore(false), 197 bParaAutoAfter(false) 198 199 {} 200 ~SwWW8StyInf()201 ~SwWW8StyInf() 202 { 203 delete pWWFly; 204 } 205 SetOrgWWIdent(const String & rName,const sal_uInt16 nId)206 void SetOrgWWIdent( const String& rName, const sal_uInt16 nId ) 207 { 208 sWWStyleName = rName; 209 nWWStyleId = nId; 210 211 // apply default WW8 outline level to WW8 Built-in Heading styles 212 if ( IsWW8BuiltInHeadingStyle() ) 213 { 214 mnWW8OutlineLevel = nWWStyleId - 1; 215 } 216 } 217 GetOrgWWName() const218 const String& GetOrgWWName() const 219 { 220 return sWWStyleName; 221 } 222 HasWW8OutlineLevel() const223 bool HasWW8OutlineLevel() const 224 { 225 return ( pFmt != NULL && (MAXLEVEL > mnWW8OutlineLevel) ); 226 } 227 IsOutlineNumbered() const228 bool IsOutlineNumbered() const 229 { 230 return pOutlineNumrule != NULL && HasWW8OutlineLevel(); 231 } 232 GetOutlineNumrule() const233 const SwNumRule* GetOutlineNumrule() const 234 { 235 return pOutlineNumrule; 236 } 237 238 CharSet GetCharSet() const; 239 CharSet GetCJKCharSet() const; 240 GetWWStyleId() const241 inline sal_uInt16 GetWWStyleId() const 242 { 243 return nWWStyleId; 244 } 245 IsWW8BuiltInHeadingStyle()246 inline bool IsWW8BuiltInHeadingStyle() 247 { 248 return GetWWStyleId() >= 1 && GetWWStyleId() <= 9; 249 } 250 IsWW8BuiltInDefaultStyle()251 inline bool IsWW8BuiltInDefaultStyle() 252 { 253 return GetWWStyleId() == 0; 254 } 255 WW8OutlineLevelToOutlinelevel(const sal_uInt8 nWW8OutlineLevel)256 static sal_uInt8 WW8OutlineLevelToOutlinelevel( const sal_uInt8 nWW8OutlineLevel ) 257 { 258 if ( nWW8OutlineLevel < MAXLEVEL ) 259 { 260 if ( nWW8OutlineLevel == 9 ) 261 { 262 return 0; // no outline level --> body text 263 } 264 else 265 { 266 return nWW8OutlineLevel + 1; // outline level 1..9 267 } 268 } 269 270 return 0; 271 } 272 }; 273 274 class WW8RStyle: public WW8Style 275 { 276 friend class SwWW8ImplReader; 277 wwSprmParser maSprmParser; 278 SwWW8ImplReader* pIo; // Parser-Klasse 279 SvStream* pStStrm; // Input-File 280 281 SwNumRule* pStyRule; // Bullets und Aufzaehlungen in Styles 282 283 sal_uInt8* pParaSprms; // alle ParaSprms des UPX falls UPX.Papx 284 sal_uInt16 nSprmsLen; // Laenge davon 285 286 sal_uInt8 nWwNumLevel; // fuer Bullets und Aufzaehlungen in Styles 287 288 bool bTxtColChanged; 289 bool bFontChanged; // For Simulating Default-Font 290 bool bCJKFontChanged; // For Simulating Default-CJK Font 291 bool bCTLFontChanged; // For Simulating Default-CTL Font 292 bool bFSizeChanged; // For Simulating Default-FontSize 293 bool bFCTLSizeChanged; // For Simulating Default-CTL FontSize 294 bool bWidowsChanged; // For Simulating Default-Widows / Orphans 295 296 void ImportSprms(sal_Size nPosFc, short nLen, bool bPap); 297 void ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap); 298 void ImportGrupx(short nLen, bool bPara, bool bOdd); 299 short ImportUPX(short nLen, bool bPAP, bool bOdd); 300 301 void Set1StyleDefaults(); 302 void Import1Style(sal_uInt16 nNr); 303 void RecursiveReg(sal_uInt16 nNr); 304 305 void ImportStyles(); 306 307 void ImportNewFormatStyles(); 308 void ScanStyles(); 309 void ImportOldFormatStyles(); 310 311 bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle); 312 void PostStyle(SwWW8StyInf &rSI, bool bOldNoImp); 313 314 //No copying 315 WW8RStyle(const WW8RStyle&); 316 WW8RStyle& operator=(const WW8RStyle&); 317 public: 318 WW8RStyle( WW8Fib& rFib, SwWW8ImplReader* pI ); 319 void Import(); 320 void PostProcessStyles(); 321 const sal_uInt8* HasParaSprm( sal_uInt16 nId ) const; 322 }; 323 324 class WW8FlySet: public SfxItemSet 325 { 326 private: 327 //No copying 328 const WW8FlySet& operator=(const WW8FlySet&); 329 void Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM); 330 public: 331 WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW, 332 const WW8SwFlyPara* pFS, bool bGraf); 333 WW8FlySet(SwWW8ImplReader& rReader, const SwPaM* pPaM, const WW8_PIC& rPic, 334 long nWidth, long nHeight); 335 }; 336 337 enum WW8LvlType {WW8_None, WW8_Outline, WW8_Numbering, WW8_Sequence, WW8_Pause}; 338 339 WW8LvlType GetNumType(sal_uInt8 nWwLevelNo); 340 #endif 341 342 /* vi:set tabstop=4 shiftwidth=4 expandtab: */ 343