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