1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ww8scan.cxx,v $
10 * $Revision: 1.142.12.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
34 #include "ww8scan.hxx"
39 #include <string.h> // memset()
40 #include <rtl/tencinfo.h>
44 #define ERR_SWG_READ_ERROR 1234
45 #define ASSERT( a, b )
48 #include <swerror.h> // ERR_WW6_...
49 #include <swtypes.hxx> // DELETEZ
52 #include <tools/debug.hxx>
53 #include <i18npool/lang.h>
54 #include <vcl/svapp.hxx> // Application #i90932#
58 #define ASSERT_RET_ON_FAIL( aCon, aError, aRet ) \
59 ASSERT(aCon, aError); \
66 # define IMPLCONSTSTRINGARRAY(X) const char a##X[] = "" #X ""
67 IMPLCONSTSTRINGARRAY(ObjectPool
);
68 IMPLCONSTSTRINGARRAY(1Table
);
69 IMPLCONSTSTRINGARRAY(0Table
);
70 IMPLCONSTSTRINGARRAY(Data
);
71 IMPLCONSTSTRINGARRAY(CheckBox
);
72 IMPLCONSTSTRINGARRAY(ListBox
);
73 IMPLCONSTSTRINGARRAY(TextBox
);
74 IMPLCONSTSTRINGARRAY(TextField
);
75 IMPLCONSTSTRINGARRAY(MSMacroCmds
);
78 template<class C
> bool wwString
<C
>::TestBeltAndBraces(const SvStream
& rStrm
)
81 sal_uInt32 nOldPos
= rStrm
.Tell();
82 SvStream
&rMutableStrm
= const_cast<SvStream
&>(rStrm
);
83 sal_uInt32 nLen
= rMutableStrm
.Seek(STREAM_SEEK_TO_END
);
84 rMutableStrm
.Seek(nOldPos
);
86 rMutableStrm
>> nBelt
;
88 if (nOldPos
+ sizeof(C
) + nBelt
+ sizeof(C
) <= nLen
&&
89 !rStrm
.GetError() && !rStrm
.IsEof())
91 rMutableStrm
.SeekRel(nBelt
);
92 if (!rStrm
.GetError())
95 rMutableStrm
>> cBraces
;
96 if (!rMutableStrm
.GetError() && cBraces
== 0)
100 rMutableStrm
.Seek(nOldPos
);
104 inline bool operator==(const SprmInfo
&rFirst
, const SprmInfo
&rSecond
)
106 return (rFirst
.nId
== rSecond
.nId
);
109 const wwSprmSearcher
*wwSprmParser::GetWW2SprmSearcher()
113 static const SprmInfo aSprms
[] =
115 { 0, 0, L_FIX
}, // "Default-sprm", wird uebersprungen
116 { 2, 1, L_FIX
}, // "sprmPIstd", pap.istd (style code)
117 { 3, 0, L_VAR
}, // "sprmPIstdPermute pap.istd permutation
118 { 4, 1, L_FIX
}, // "sprmPIncLv1" pap.istddifference
119 { 5, 1, L_FIX
}, // "sprmPJc" pap.jc (justification)
120 { 6, 1, L_FIX
}, // "sprmPFSideBySide" pap.fSideBySide
121 { 7, 1, L_FIX
}, // "sprmPFKeep" pap.fKeep
122 { 8, 1, L_FIX
}, // "sprmPFKeepFollow " pap.fKeepFollow
123 { 9, 1, L_FIX
}, // "sprmPPageBreakBefore" pap.fPageBreakBefore
124 { 10, 1, L_FIX
}, // "sprmPBrcl" pap.brcl
125 { 11, 1, L_FIX
}, // "sprmPBrcp" pap.brcp
126 { 12, 1, L_FIX
}, // "sprmPNfcSeqNumb" pap.nfcSeqNumb
127 { 13, 1, L_FIX
}, // "sprmPNoSeqNumb" pap.nnSeqNumb
128 { 14, 1, L_FIX
}, // "sprmPFNoLineNumb" pap.fNoLnn
129 { 15, 0, L_VAR
}, // "?sprmPChgTabsPapx" pap.itbdMac, ...
130 { 16, 2, L_FIX
}, // "sprmPDxaRight" pap.dxaRight
131 { 17, 2, L_FIX
}, // "sprmPDxaLeft" pap.dxaLeft
132 { 18, 2, L_FIX
}, // "sprmPNest" pap.dxaLeft
133 { 19, 2, L_FIX
}, // "sprmPDxaLeft1" pap.dxaLeft1
134 { 20, 2, L_FIX
}, // "sprmPDyaLine" pap.lspd an LSPD
135 { 21, 2, L_FIX
}, // "sprmPDyaBefore" pap.dyaBefore
136 { 22, 2, L_FIX
}, // "sprmPDyaAfter" pap.dyaAfter
137 { 23, 0, L_VAR
}, // "?sprmPChgTabs" pap.itbdMac, pap.rgdxaTab, ...
138 { 24, 1, L_FIX
}, // "sprmPFInTable" pap.fInTable
139 { 25, 1, L_FIX
}, // "sprmPTtp" pap.fTtp
140 { 26, 2, L_FIX
}, // "sprmPDxaAbs" pap.dxaAbs
141 { 27, 2, L_FIX
}, // "sprmPDyaAbs" pap.dyaAbs
142 { 28, 2, L_FIX
}, // "sprmPDxaWidth" pap.dxaWidth
143 { 29, 1, L_FIX
}, // "sprmPPc" pap.pcHorz, pap.pcVert
144 { 30, 2, L_FIX
}, // "sprmPBrcTop10" pap.brcTop BRC10
145 { 31, 2, L_FIX
}, // "sprmPBrcLeft10" pap.brcLeft BRC10
146 { 32, 2, L_FIX
}, // "sprmPBrcBottom10" pap.brcBottom BRC10
147 { 33, 2, L_FIX
}, // "sprmPBrcRight10" pap.brcRight BRC10
148 { 34, 2, L_FIX
}, // "sprmPBrcBetween10" pap.brcBetween BRC10
149 { 35, 2, L_FIX
}, // "sprmPBrcBar10" pap.brcBar BRC10
150 { 36, 2, L_FIX
}, // "sprmPFromText10" pap.dxaFromText dxa
151 { 37, 1, L_FIX
}, // "sprmPWr" pap.wr wr
152 { 38, 2, L_FIX
}, // "sprmPBrcTop" pap.brcTop BRC
153 { 39, 2, L_FIX
}, // "sprmPBrcLeft" pap.brcLeft BRC
154 { 40, 2, L_FIX
}, // "sprmPBrcBottom" pap.brcBottom BRC
155 { 41, 2, L_FIX
}, // "sprmPBrcRight" pap.brcRight BRC
156 { 42, 2, L_FIX
}, // "sprmPBrcBetween" pap.brcBetween BRC
157 { 43, 2, L_FIX
}, // "sprmPBrcBar" pap.brcBar BRC word
158 { 44, 1, L_FIX
}, // "sprmPFNoAutoHyph" pap.fNoAutoHyph
159 { 45, 2, L_FIX
}, // "sprmPWHeightAbs" pap.wHeightAbs w
160 { 46, 2, L_FIX
}, // "sprmPDcs" pap.dcs DCS
161 { 47, 2, L_FIX
}, // "sprmPShd" pap.shd SHD
162 { 48, 2, L_FIX
}, // "sprmPDyaFromText" pap.dyaFromText dya
163 { 49, 2, L_FIX
}, // "sprmPDxaFromText" pap.dxaFromText dxa
164 { 50, 1, L_FIX
}, // "sprmPFBiDi" pap.fBiDi 0 or 1 byte
165 { 51, 1, L_FIX
}, // "sprmPFWidowControl" pap.fWidowControl 0 or 1 byte
166 { 52, 0, L_FIX
}, // "?sprmPRuler 52"
167 { 53, 1, L_FIX
}, // "sprmCFStrikeRM" chp.fRMarkDel 1 or 0 bit
168 { 54, 1, L_FIX
}, // "sprmCFRMark" chp.fRMark 1 or 0 bit
169 { 55, 1, L_FIX
}, // "sprmCFFldVanish" chp.fFldVanish 1 or 0 bit
170 { 57, 0, L_VAR
}, // "sprmCDefault" whole CHP
171 { 58, 0, L_FIX
}, // "sprmCPlain" whole CHP
172 { 60, 1, L_FIX
}, // "sprmCFBold" chp.fBold 0,1, 128, or 129
173 { 61, 1, L_FIX
}, // "sprmCFItalic" chp.fItalic 0,1, 128, or 129
174 { 62, 1, L_FIX
}, // "sprmCFStrike" chp.fStrike 0,1, 128, or 129
175 { 63, 1, L_FIX
}, // "sprmCFOutline" chp.fOutline 0,1, 128, or 129
176 { 64, 1, L_FIX
}, // "sprmCFShadow" chp.fShadow 0,1, 128, or 129
177 { 65, 1, L_FIX
}, // "sprmCFSmallCaps" chp.fSmallCaps 0,1, 128, or 129
178 { 66, 1, L_FIX
}, // "sprmCFCaps" chp.fCaps 0,1, 128, or 129
179 { 67, 1, L_FIX
}, // "sprmCFVanish" chp.fVanish 0,1, 128, or 129
180 { 68, 2, L_FIX
}, // "sprmCFtc" chp.ftc ftc word
181 { 69, 1, L_FIX
}, // "sprmCKul" chp.kul kul byte
182 { 70, 3, L_FIX
}, // "sprmCSizePos" chp.hps, chp.hpsPos
183 { 71, 2, L_FIX
}, // "sprmCDxaSpace" chp.dxaSpace dxa
184 { 72, 2, L_FIX
}, // "sprmCLid" chp.lid LID
185 { 73, 1, L_FIX
}, // "sprmCIco" chp.ico ico byte
186 { 74, 1, L_FIX
}, // "sprmCHps" chp.hps hps !word!
187 { 75, 1, L_FIX
}, // "sprmCHpsInc" chp.hps
188 { 76, 1, L_FIX
}, // "sprmCHpsPos" chp.hpsPos hps !word!
189 { 77, 1, L_FIX
}, // "sprmCHpsPosAdj" chp.hpsPos hps
190 { 78, 0, L_VAR
}, // "?sprmCMajority" chp.fBold, chp.fItalic, ...
191 { 80, 1, L_FIX
}, // "sprmCFBoldBi" chp.fBoldBi
192 { 81, 1, L_FIX
}, // "sprmCFItalicBi" chp.fItalicBi
193 { 82, 2, L_FIX
}, // "sprmCFtcBi" chp.ftcBi
194 { 83, 2, L_FIX
}, // "sprmClidBi" chp.lidBi
195 { 84, 1, L_FIX
}, // "sprmCIcoBi" chp.icoBi
196 { 85, 1, L_FIX
}, // "sprmCHpsBi" chp.hpsBi
197 { 86, 1, L_FIX
}, // "sprmCFBiDi" chp.fBiDi
198 { 87, 1, L_FIX
}, // "sprmCFDiacColor" chp.fDiacUSico
199 { 94, 1, L_FIX
}, // "sprmPicBrcl" pic.brcl brcl (see PIC definition)
200 { 95,12, L_VAR
}, // "sprmPicScale" pic.mx, pic.my, pic.dxaCropleft,
201 { 96, 2, L_FIX
}, // "sprmPicBrcTop" pic.brcTop BRC word
202 { 97, 2, L_FIX
}, // "sprmPicBrcLeft" pic.brcLeft BRC word
203 { 98, 2, L_FIX
}, // "sprmPicBrcBottom" pic.brcBottom BRC word
204 { 99, 2, L_FIX
}, // "sprmPicBrcRight" pic.brcRight BRC word
205 {112, 1, L_FIX
}, // "sprmSFRTLGutter", set to one if gutter is on
206 {114, 1, L_FIX
}, // "sprmSFBiDi" ;;;
207 {115, 2, L_FIX
}, // "sprmSDmBinFirst" sep.dmBinFirst word
208 {116, 2, L_FIX
}, // "sprmSDmBinOther" sep.dmBinOther word
209 {117, 1, L_FIX
}, // "sprmSBkc" sep.bkc bkc byte
210 {118, 1, L_FIX
}, // "sprmSFTitlePage" sep.fTitlePage 0 or 1 byte
211 {119, 2, L_FIX
}, // "sprmSCcolumns" sep.ccolM1 # of cols - 1 word
212 {120, 2, L_FIX
}, // "sprmSDxaColumns" sep.dxaColumns dxa word
213 {121, 1, L_FIX
}, // "sprmSFAutoPgn" sep.fAutoPgn obsolete byte
214 {122, 1, L_FIX
}, // "sprmSNfcPgn" sep.nfcPgn nfc byte
215 {123, 2, L_FIX
}, // "sprmSDyaPgn" sep.dyaPgn dya short
216 {124, 2, L_FIX
}, // "sprmSDxaPgn" sep.dxaPgn dya short
217 {125, 1, L_FIX
}, // "sprmSFPgnRestart" sep.fPgnRestart 0 or 1 byte
218 {126, 1, L_FIX
}, // "sprmSFEndnote" sep.fEndnote 0 or 1 byte
219 {127, 1, L_FIX
}, // "sprmSLnc" sep.lnc lnc byte
220 {128, 1, L_FIX
}, // "sprmSGprfIhdt" sep.grpfIhdt grpfihdt
221 {129, 2, L_FIX
}, // "sprmSNLnnMod" sep.nLnnMod non-neg int. word
222 {130, 2, L_FIX
}, // "sprmSDxaLnn" sep.dxaLnn dxa word
223 {131, 2, L_FIX
}, // "sprmSDyaHdrTop" sep.dyaHdrTop dya word
224 {132, 2, L_FIX
}, // "sprmSDyaHdrBottom" sep.dyaHdrBottom dya word
225 {133, 1, L_FIX
}, // "sprmSLBetween" sep.fLBetween 0 or 1 byte
226 {134, 1, L_FIX
}, // "sprmSVjc" sep.vjc vjc byte
227 {135, 2, L_FIX
}, // "sprmSLnnMin" sep.lnnMin lnn word
228 {136, 2, L_FIX
}, // "sprmSPgnStart" sep.pgnStart pgn word
229 {137, 1, L_FIX
}, // "sprmSBOrientation" sep.dmOrientPage dm byte
230 {138, 1, L_FIX
}, // "sprmSFFacingCol" ;;;
231 {139, 2, L_FIX
}, // "sprmSXaPage" sep.xaPage xa word
232 {140, 2, L_FIX
}, // "sprmSYaPage" sep.yaPage ya word
233 {141, 2, L_FIX
}, // "sprmSDxaLeft" sep.dxaLeft dxa word
234 {142, 2, L_FIX
}, // "sprmSDxaRight" sep.dxaRight dxa word
235 {143, 2, L_FIX
}, // "sprmSDyaTop" sep.dyaTop dya word
236 {144, 2, L_FIX
}, // "sprmSDyaBottom" sep.dyaBottom dya word
237 {145, 2, L_FIX
}, // "sprmSDzaGutter" sep.dzaGutter dza word
238 {146, 2, L_FIX
}, // "sprmTJc" tap.jc jc (low order byte is significant)
239 {147, 2, L_FIX
}, // "sprmTDxaLeft" tap.rgdxaCenter dxa word
240 {148, 2, L_FIX
}, // "sprmTDxaGapHalf" tap.dxaGapHalf, tap.rgdxaCenter
241 {149, 1, L_FIX
}, // "sprmTFBiDi" ;;;
242 {152, 0, L_VAR
}, // "sprmTDefTable10" tap.rgdxaCenter, tap.rgtc complex
243 {153, 2, L_FIX
}, // "sprmTDyaRowHeight" tap.dyaRowHeight dya word
244 {154, 0, L_VAR2
},// "sprmTDefTable" tap.rgtc complex
245 {155, 1, L_VAR
}, // "sprmTDefTableShd" tap.rgshd complex
246 {157, 5, L_FIX
}, // "sprmTSetBrc" tap.rgtc[].rgbrc complex 5 bytes
247 {158, 4, L_FIX
}, // "sprmTInsert" tap.rgdxaCenter,tap.rgtc complex
248 {159, 2, L_FIX
}, // "sprmTDelete" tap.rgdxaCenter, tap.rgtc complex
249 {160, 4, L_FIX
}, // "sprmTDxaCol" tap.rgdxaCenter complex
250 {161, 2, L_FIX
}, // "sprmTMerge" tap.fFirstMerged, tap.fMerged complex
251 {162, 2, L_FIX
}, // "sprmTSplit" tap.fFirstMerged, tap.fMerged complex
252 {163, 5, L_FIX
}, // "sprmTSetBrc10" tap.rgtc[].rgbrc complex 5 bytes
253 {164, 4, L_FIX
}, // "sprmTSetShd", tap.rgshd complex 4 bytes
256 static wwSprmSearcher
aSprmSrch(aSprms
, sizeof(aSprms
) / sizeof(aSprms
[0]));
261 const wwSprmSearcher
*wwSprmParser::GetWW6SprmSearcher()
265 static const SprmInfo aSprms
[] =
267 { 0, 0, L_FIX
}, // "Default-sprm", wird uebersprungen
268 { 2, 2, L_FIX
}, // "sprmPIstd", pap.istd (style code)
269 { 3, 3, L_VAR
}, // "sprmPIstdPermute pap.istd permutation
270 { 4, 1, L_FIX
}, // "sprmPIncLv1" pap.istddifference
271 { 5, 1, L_FIX
}, // "sprmPJc" pap.jc (justification)
272 { 6, 1, L_FIX
}, // "sprmPFSideBySide" pap.fSideBySide
273 { 7, 1, L_FIX
}, // "sprmPFKeep" pap.fKeep
274 { 8, 1, L_FIX
}, // "sprmPFKeepFollow " pap.fKeepFollow
275 { 9, 1, L_FIX
}, // "sprmPPageBreakBefore" pap.fPageBreakBefore
276 { 10, 1, L_FIX
}, // "sprmPBrcl" pap.brcl
277 { 11, 1, L_FIX
}, // "sprmPBrcp" pap.brcp
278 { 12, 0, L_VAR
}, // "sprmPAnld" pap.anld (ANLD structure)
279 { 13, 1, L_FIX
}, // "sprmPNLvlAnm" pap.nLvlAnm nn
280 { 14, 1, L_FIX
}, // "sprmPFNoLineNumb" pap.fNoLnn
281 { 15, 0, L_VAR
}, // "?sprmPChgTabsPapx" pap.itbdMac, ...
282 { 16, 2, L_FIX
}, // "sprmPDxaRight" pap.dxaRight
283 { 17, 2, L_FIX
}, // "sprmPDxaLeft" pap.dxaLeft
284 { 18, 2, L_FIX
}, // "sprmPNest" pap.dxaLeft
285 { 19, 2, L_FIX
}, // "sprmPDxaLeft1" pap.dxaLeft1
286 { 20, 4, L_FIX
}, // "sprmPDyaLine" pap.lspd an LSPD
287 { 21, 2, L_FIX
}, // "sprmPDyaBefore" pap.dyaBefore
288 { 22, 2, L_FIX
}, // "sprmPDyaAfter" pap.dyaAfter
289 { 23, 0, L_VAR
}, // "?sprmPChgTabs" pap.itbdMac, pap.rgdxaTab, ...
290 { 24, 1, L_FIX
}, // "sprmPFInTable" pap.fInTable
291 { 25, 1, L_FIX
}, // "sprmPTtp" pap.fTtp
292 { 26, 2, L_FIX
}, // "sprmPDxaAbs" pap.dxaAbs
293 { 27, 2, L_FIX
}, // "sprmPDyaAbs" pap.dyaAbs
294 { 28, 2, L_FIX
}, // "sprmPDxaWidth" pap.dxaWidth
295 { 29, 1, L_FIX
}, // "sprmPPc" pap.pcHorz, pap.pcVert
296 { 30, 2, L_FIX
}, // "sprmPBrcTop10" pap.brcTop BRC10
297 { 31, 2, L_FIX
}, // "sprmPBrcLeft10" pap.brcLeft BRC10
298 { 32, 2, L_FIX
}, // "sprmPBrcBottom10" pap.brcBottom BRC10
299 { 33, 2, L_FIX
}, // "sprmPBrcRight10" pap.brcRight BRC10
300 { 34, 2, L_FIX
}, // "sprmPBrcBetween10" pap.brcBetween BRC10
301 { 35, 2, L_FIX
}, // "sprmPBrcBar10" pap.brcBar BRC10
302 { 36, 2, L_FIX
}, // "sprmPFromText10" pap.dxaFromText dxa
303 { 37, 1, L_FIX
}, // "sprmPWr" pap.wr wr
304 { 38, 2, L_FIX
}, // "sprmPBrcTop" pap.brcTop BRC
305 { 39, 2, L_FIX
}, // "sprmPBrcLeft" pap.brcLeft BRC
306 { 40, 2, L_FIX
}, // "sprmPBrcBottom" pap.brcBottom BRC
307 { 41, 2, L_FIX
}, // "sprmPBrcRight" pap.brcRight BRC
308 { 42, 2, L_FIX
}, // "sprmPBrcBetween" pap.brcBetween BRC
309 { 43, 2, L_FIX
}, // "sprmPBrcBar" pap.brcBar BRC word
310 { 44, 1, L_FIX
}, // "sprmPFNoAutoHyph" pap.fNoAutoHyph
311 { 45, 2, L_FIX
}, // "sprmPWHeightAbs" pap.wHeightAbs w
312 { 46, 2, L_FIX
}, // "sprmPDcs" pap.dcs DCS
313 { 47, 2, L_FIX
}, // "sprmPShd" pap.shd SHD
314 { 48, 2, L_FIX
}, // "sprmPDyaFromText" pap.dyaFromText dya
315 { 49, 2, L_FIX
}, // "sprmPDxaFromText" pap.dxaFromText dxa
316 { 50, 1, L_FIX
}, // "sprmPFLocked" pap.fLocked 0 or 1 byte
317 { 51, 1, L_FIX
}, // "sprmPFWidowControl" pap.fWidowControl 0 or 1 byte
318 { 52, 0, L_FIX
}, // "?sprmPRuler 52"
319 { 64, 0, L_VAR
}, // rtl property ?
320 { 65, 1, L_FIX
}, // "sprmCFStrikeRM" chp.fRMarkDel 1 or 0 bit
321 { 66, 1, L_FIX
}, // "sprmCFRMark" chp.fRMark 1 or 0 bit
322 { 67, 1, L_FIX
}, // "sprmCFFldVanish" chp.fFldVanish 1 or 0 bit
323 { 68, 0, L_VAR
}, // "sprmCPicLocation" chp.fcPic and chp.fSpec
324 { 69, 2, L_FIX
}, // "sprmCIbstRMark" chp.ibstRMark index into sttbRMark
325 { 70, 4, L_FIX
}, // "sprmCDttmRMark" chp.dttm DTTM long
326 { 71, 1, L_FIX
}, // "sprmCFData" chp.fData 1 or 0 bit
327 { 72, 2, L_FIX
}, // "sprmCRMReason" chp.idslRMReason an index to a table
328 { 73, 3, L_FIX
}, // "sprmCChse" chp.fChsDiff and chp.chse
329 { 74, 0, L_VAR
}, // "sprmCSymbol" chp.fSpec, chp.chSym and chp.ftcSym
330 { 75, 1, L_FIX
}, // "sprmCFOle2" chp.fOle2 1 or 0 bit
331 { 77, 0, L_VAR
}, // unknown
332 { 79, 0, L_VAR
}, // unknown
333 { 80, 2, L_FIX
}, // "sprmCIstd" chp.istd istd, see stylesheet definition
334 { 81, 0, L_VAR
}, // "sprmCIstdPermute" chp.istd permutation vector
335 { 82, 0, L_VAR
}, // "sprmCDefault" whole CHP
336 { 83, 0, L_FIX
}, // "sprmCPlain" whole CHP
337 { 85, 1, L_FIX
}, // "sprmCFBold" chp.fBold 0,1, 128, or 129
338 { 86, 1, L_FIX
}, // "sprmCFItalic" chp.fItalic 0,1, 128, or 129
339 { 87, 1, L_FIX
}, // "sprmCFStrike" chp.fStrike 0,1, 128, or 129
340 { 88, 1, L_FIX
}, // "sprmCFOutline" chp.fOutline 0,1, 128, or 129
341 { 89, 1, L_FIX
}, // "sprmCFShadow" chp.fShadow 0,1, 128, or 129
342 { 90, 1, L_FIX
}, // "sprmCFSmallCaps" chp.fSmallCaps 0,1, 128, or 129
343 { 91, 1, L_FIX
}, // "sprmCFCaps" chp.fCaps 0,1, 128, or 129
344 { 92, 1, L_FIX
}, // "sprmCFVanish" chp.fVanish 0,1, 128, or 129
345 { 93, 2, L_FIX
}, // "sprmCFtc" chp.ftc ftc word
346 { 94, 1, L_FIX
}, // "sprmCKul" chp.kul kul byte
347 { 95, 3, L_FIX
}, // "sprmCSizePos" chp.hps, chp.hpsPos
348 { 96, 2, L_FIX
}, // "sprmCDxaSpace" chp.dxaSpace dxa
349 { 97, 2, L_FIX
}, // "sprmCLid" chp.lid LID
350 { 98, 1, L_FIX
}, // "sprmCIco" chp.ico ico byte
351 { 99, 2, L_FIX
}, // "sprmCHps" chp.hps hps !word!
352 {100, 1, L_FIX
}, // "sprmCHpsInc" chp.hps
353 {101, 2, L_FIX
}, // "sprmCHpsPos" chp.hpsPos hps !word!
354 {102, 1, L_FIX
}, // "sprmCHpsPosAdj" chp.hpsPos hps
355 {103, 0, L_VAR
}, // "?sprmCMajority" chp.fBold, chp.fItalic, ...
356 {104, 1, L_FIX
}, // "sprmCIss" chp.iss iss
357 {105, 0, L_VAR
}, // "sprmCHpsNew50" chp.hps hps variable width
358 {106, 0, L_VAR
}, // "sprmCHpsInc1" chp.hps complex
359 {107, 2, L_FIX
}, // "sprmCHpsKern" chp.hpsKern hps
360 {108, 0, L_VAR
}, // "sprmCMajority50" chp.fBold, chp.fItalic, ...
361 {109, 2, L_FIX
}, // "sprmCHpsMul" chp.hps percentage to grow hps
362 {110, 2, L_FIX
}, // "sprmCCondHyhen" chp.ysri ysri
363 {111, 2, L_FIX
}, // rtl bold
364 {112, 2, L_FIX
}, // rtl italic
365 {113, 0, L_VAR
}, // rtl property ?
366 {115, 0, L_VAR
}, // rtl property ?
367 {116, 0, L_VAR
}, // unknown
368 {117, 1, L_FIX
}, // "sprmCFSpec" chp.fSpec 1 or 0 bit
369 {118, 1, L_FIX
}, // "sprmCFObj" chp.fObj 1 or 0 bit
370 {119, 1, L_FIX
}, // "sprmPicBrcl" pic.brcl brcl (see PIC definition)
371 {120,12, L_VAR
}, // "sprmPicScale" pic.mx, pic.my, pic.dxaCropleft,
372 {121, 2, L_FIX
}, // "sprmPicBrcTop" pic.brcTop BRC word
373 {122, 2, L_FIX
}, // "sprmPicBrcLeft" pic.brcLeft BRC word
374 {123, 2, L_FIX
}, // "sprmPicBrcBottom" pic.brcBottom BRC word
375 {124, 2, L_FIX
}, // "sprmPicBrcRight" pic.brcRight BRC word
376 {131, 1, L_FIX
}, // "sprmSScnsPgn" sep.cnsPgn cns byte
377 {132, 1, L_FIX
}, // "sprmSiHeadingPgn" sep.iHeadingPgn
378 {133, 0, L_VAR
}, // "sprmSOlstAnm" sep.olstAnm OLST variable length
379 {136, 3, L_FIX
}, // "sprmSDxaColWidth" sep.rgdxaColWidthSpacing complex
380 {137, 3, L_FIX
}, // "sprmSDxaColSpacing" sep.rgdxaColWidthSpacing
381 {138, 1, L_FIX
}, // "sprmSFEvenlySpaced" sep.fEvenlySpaced 1 or 0
382 {139, 1, L_FIX
}, // "sprmSFProtected" sep.fUnlocked 1 or 0 byte
383 {140, 2, L_FIX
}, // "sprmSDmBinFirst" sep.dmBinFirst word
384 {141, 2, L_FIX
}, // "sprmSDmBinOther" sep.dmBinOther word
385 {142, 1, L_FIX
}, // "sprmSBkc" sep.bkc bkc byte
386 {143, 1, L_FIX
}, // "sprmSFTitlePage" sep.fTitlePage 0 or 1 byte
387 {144, 2, L_FIX
}, // "sprmSCcolumns" sep.ccolM1 # of cols - 1 word
388 {145, 2, L_FIX
}, // "sprmSDxaColumns" sep.dxaColumns dxa word
389 {146, 1, L_FIX
}, // "sprmSFAutoPgn" sep.fAutoPgn obsolete byte
390 {147, 1, L_FIX
}, // "sprmSNfcPgn" sep.nfcPgn nfc byte
391 {148, 2, L_FIX
}, // "sprmSDyaPgn" sep.dyaPgn dya short
392 {149, 2, L_FIX
}, // "sprmSDxaPgn" sep.dxaPgn dya short
393 {150, 1, L_FIX
}, // "sprmSFPgnRestart" sep.fPgnRestart 0 or 1 byte
394 {151, 1, L_FIX
}, // "sprmSFEndnote" sep.fEndnote 0 or 1 byte
395 {152, 1, L_FIX
}, // "sprmSLnc" sep.lnc lnc byte
396 {153, 1, L_FIX
}, // "sprmSGprfIhdt" sep.grpfIhdt grpfihdt
397 {154, 2, L_FIX
}, // "sprmSNLnnMod" sep.nLnnMod non-neg int. word
398 {155, 2, L_FIX
}, // "sprmSDxaLnn" sep.dxaLnn dxa word
399 {156, 2, L_FIX
}, // "sprmSDyaHdrTop" sep.dyaHdrTop dya word
400 {157, 2, L_FIX
}, // "sprmSDyaHdrBottom" sep.dyaHdrBottom dya word
401 {158, 1, L_FIX
}, // "sprmSLBetween" sep.fLBetween 0 or 1 byte
402 {159, 1, L_FIX
}, // "sprmSVjc" sep.vjc vjc byte
403 {160, 2, L_FIX
}, // "sprmSLnnMin" sep.lnnMin lnn word
404 {161, 2, L_FIX
}, // "sprmSPgnStart" sep.pgnStart pgn word
405 {162, 1, L_FIX
}, // "sprmSBOrientation" sep.dmOrientPage dm byte
406 {163, 0, L_FIX
}, // "?SprmSBCustomize 163"
407 {164, 2, L_FIX
}, // "sprmSXaPage" sep.xaPage xa word
408 {165, 2, L_FIX
}, // "sprmSYaPage" sep.yaPage ya word
409 {166, 2, L_FIX
}, // "sprmSDxaLeft" sep.dxaLeft dxa word
410 {167, 2, L_FIX
}, // "sprmSDxaRight" sep.dxaRight dxa word
411 {168, 2, L_FIX
}, // "sprmSDyaTop" sep.dyaTop dya word
412 {169, 2, L_FIX
}, // "sprmSDyaBottom" sep.dyaBottom dya word
413 {170, 2, L_FIX
}, // "sprmSDzaGutter" sep.dzaGutter dza word
414 {171, 2, L_FIX
}, // "sprmSDMPaperReq" sep.dmPaperReq dm word
415 {179, 0, L_VAR
}, // rtl property ?
416 {181, 0, L_VAR
}, // rtl property ?
417 {182, 2, L_FIX
}, // "sprmTJc" tap.jc jc (low order byte is significant)
418 {183, 2, L_FIX
}, // "sprmTDxaLeft" tap.rgdxaCenter dxa word
419 {184, 2, L_FIX
}, // "sprmTDxaGapHalf" tap.dxaGapHalf, tap.rgdxaCenter
420 {185, 1, L_FIX
}, // "sprmTFCantSplit" tap.fCantSplit 1 or 0 byte
421 {186, 1, L_FIX
}, // "sprmTTableHeader" tap.fTableHeader 1 or 0 byte
422 {187,12, L_FIX
}, // "sprmTTableBorders" tap.rgbrcTable complex 12 bytes
423 {188, 0, L_VAR
}, // "sprmTDefTable10" tap.rgdxaCenter, tap.rgtc complex
424 {189, 2, L_FIX
}, // "sprmTDyaRowHeight" tap.dyaRowHeight dya word
425 {190, 0, L_VAR2
},// "sprmTDefTable" tap.rgtc complex
426 {191, 1, L_VAR
}, // "sprmTDefTableShd" tap.rgshd complex
427 {192, 4, L_FIX
}, // "sprmTTlp" tap.tlp TLP 4 bytes
428 {193, 5, L_FIX
}, // "sprmTSetBrc" tap.rgtc[].rgbrc complex 5 bytes
429 {194, 4, L_FIX
}, // "sprmTInsert" tap.rgdxaCenter,tap.rgtc complex
430 {195, 2, L_FIX
}, // "sprmTDelete" tap.rgdxaCenter, tap.rgtc complex
431 {196, 4, L_FIX
}, // "sprmTDxaCol" tap.rgdxaCenter complex
432 {197, 2, L_FIX
}, // "sprmTMerge" tap.fFirstMerged, tap.fMerged complex
433 {198, 2, L_FIX
}, // "sprmTSplit" tap.fFirstMerged, tap.fMerged complex
434 {199, 5, L_FIX
}, // "sprmTSetBrc10" tap.rgtc[].rgbrc complex 5 bytes
435 {200, 4, L_FIX
}, // "sprmTSetShd", tap.rgshd complex 4 bytes
436 {207, 0, L_VAR
} // rtl property ?
439 static wwSprmSearcher
aSprmSrch(aSprms
, sizeof(aSprms
) / sizeof(aSprms
[0]));
443 const wwSprmSearcher
*wwSprmParser::GetWW8SprmSearcher()
447 static const SprmInfo aSprms
[] =
449 { 0, 0, L_FIX
}, // "Default-sprm"/ wird uebersprungen
450 {0x4600, 2, L_FIX
}, // "sprmPIstd" pap.istd;istd (style code);short;
451 {0xC601, 0, L_VAR
}, // "sprmPIstdPermute" pap.istd;permutation vector
452 {0x2602, 1, L_FIX
}, // "sprmPIncLvl" pap.istd, pap.lvl;difference
453 // between istd of base PAP and istd of PAP to be
455 {0x2403, 1, L_FIX
}, // "sprmPJc" pap.jc;jc (justification);byte;
456 {0x2404, 1, L_FIX
}, // "sprmPFSideBySide" pap.fSideBySide;0 or 1;byte;
457 {0x2405, 1, L_FIX
}, // "sprmPFKeep" pap.fKeep;0 or 1;byte;
458 {0x2406, 1, L_FIX
}, // "sprmPFKeepFollow" pap.fKeepFollow;0 or 1;byte;
459 {0x2407, 1, L_FIX
}, // "sprmPFPageBreakBefore" pap.fPageBreakBefore;
461 {0x2408, 1, L_FIX
}, // "sprmPBrcl" pap.brcl;brcl;byte;
462 {0x2409, 1, L_FIX
}, // "sprmPBrcp" pap.brcp;brcp;byte;
463 {0x260A, 1, L_FIX
}, // "sprmPIlvl" pap.ilvl;ilvl;byte;
464 {0x460B, 2, L_FIX
}, // "sprmPIlfo" pap.ilfo;ilfo (list index) ;short;
465 {0x240C, 1, L_FIX
}, // "sprmPFNoLineNumb" pap.fNoLnn;0 or 1;byte;
466 {0xC60D, 0, L_VAR
}, // "sprmPChgTabsPapx" pap.itbdMac, pap.rgdxaTab,
468 {0x840E, 2, L_FIX
}, // "sprmPDxaRight" pap.dxaRight;dxa;word;
469 {0x840F, 2, L_FIX
}, // "sprmPDxaLeft" pap.dxaLeft;dxa;word;
470 {0x4610, 2, L_FIX
}, // "sprmPNest" pap.dxaLeft;dxa
471 {0x8411, 2, L_FIX
}, // "sprmPDxaLeft1" pap.dxaLeft1;dxa;word;
472 {0x6412, 4, L_FIX
}, // "sprmPDyaLine" pap.lspd;an LSPD, a long word
473 // structure consisting of a short of dyaLine
474 // followed by a short of fMultLinespace
475 {0xA413, 2, L_FIX
}, // "sprmPDyaBefore" pap.dyaBefore;dya;word;
476 {0xA414, 2, L_FIX
}, // "sprmPDyaAfter" pap.dyaAfter;dya;word;
477 {0xC615, 0, L_VAR
}, // "sprmPChgTabs" pap.itbdMac, pap.rgdxaTab,
479 {0x2416, 1, L_FIX
}, // "sprmPFInTable" pap.fInTable;0 or 1;byte;
480 {0x2417, 1, L_FIX
}, // "sprmPFTtp" pap.fTtp;0 or 1;byte;
481 {0x8418, 2, L_FIX
}, // "sprmPDxaAbs" pap.dxaAbs;dxa;word;
482 {0x8419, 2, L_FIX
}, // "sprmPDyaAbs" pap.dyaAbs;dya;word;
483 {0x841A, 2, L_FIX
}, // "sprmPDxaWidth" pap.dxaWidth;dxa;word;
484 {0x261B, 1, L_FIX
}, // "sprmPPc" pap.pcHorz, pap.pcVert;complex
485 {0x461C, 2, L_FIX
}, // "sprmPBrcTop10" pap.brcTop;BRC10;word;
486 {0x461D, 2, L_FIX
}, // "sprmPBrcLeft10" pap.brcLeft;BRC10;word;
487 {0x461E, 2, L_FIX
}, // "sprmPBrcBottom10" pap.brcBottom;BRC10;word;
488 {0x461F, 2, L_FIX
}, // "sprmPBrcRight10" pap.brcRight;BRC10;word;
489 {0x4620, 2, L_FIX
}, // "sprmPBrcBetween10" pap.brcBetween;BRC10;word;
490 {0x4621, 2, L_FIX
}, // "sprmPBrcBar10" pap.brcBar;BRC10;word;
491 {0x4622, 2, L_FIX
}, // "sprmPDxaFromText10" pap.dxaFromText;dxa;word;
492 {0x2423, 1, L_FIX
}, // "sprmPWr" pap.wr;wr
493 {0x6424, 4, L_FIX
}, // "sprmPBrcTop" pap.brcTop;BRC;long;
494 {0x6425, 4, L_FIX
}, // "sprmPBrcLeft" pap.brcLeft;BRC;long;
495 {0x6426, 4, L_FIX
}, // "sprmPBrcBottom" pap.brcBottom;BRC;long;
496 {0x6427, 4, L_FIX
}, // "sprmPBrcRight" pap.brcRight;BRC;long;
497 {0x6428, 4, L_FIX
}, // "sprmPBrcBetween" pap.brcBetween;BRC;long;
498 {0x6629, 4, L_FIX
}, // "sprmPBrcBar" pap.brcBar;BRC;long;
499 {0x242A, 1, L_FIX
}, // "sprmPFNoAutoHyph" pap.fNoAutoHyph;0 or 1;byte;
500 {0x442B, 2, L_FIX
}, // "sprmPWHeightAbs" pap.wHeightAbs;w;word;
501 {0x442C, 2, L_FIX
}, // "sprmPDcs" pap.dcs;DCS;short;
502 {0x442D, 2, L_FIX
}, // "sprmPShd" pap.shd;SHD;word;
503 {0x842E, 2, L_FIX
}, // "sprmPDyaFromText" pap.dyaFromText;dya;word;
504 {0x842F, 2, L_FIX
}, // "sprmPDxaFromText" pap.dxaFromText;dxa;word;
505 {0x2430, 1, L_FIX
}, // "sprmPFLocked" pap.fLocked;0 or 1;byte;
506 {0x2431, 1, L_FIX
}, // "sprmPFWidowControl" pap.fWidowControl;0 or 1
507 {0xC632, 0, L_VAR
}, // "sprmPRuler" ;;variable length;
508 {0x2433, 1, L_FIX
}, // "sprmPFKinsoku" pap.fKinsoku;0 or 1;byte;
509 {0x2434, 1, L_FIX
}, // "sprmPFWordWrap" pap.fWordWrap;0 or 1;byte;
510 {0x2435, 1, L_FIX
}, // "sprmPFOverflowPunct" pap.fOverflowPunct;0 or 1
511 {0x2436, 1, L_FIX
}, // "sprmPFTopLinePunct" pap.fTopLinePunct;0 or 1
512 {0x2437, 1, L_FIX
}, // "sprmPFAutoSpaceDE" pap.fAutoSpaceDE;0 or 1
513 {0x2438, 1, L_FIX
}, // "sprmPFAutoSpaceDN" pap.fAutoSpaceDN;0 or 1
514 {0x4439, 2, L_FIX
}, // "sprmPWAlignFont" pap.wAlignFont;iFa
515 {0x443A, 2, L_FIX
}, // "sprmPFrameTextFlow" pap.fVertical pap.fBackward
516 // pap.fRotateFont;complex
517 {0x243B, 1, L_FIX
}, // "sprmPISnapBaseLine" obsolete: not applicable in
518 // Word97 and later versions;
519 {0xC63E, 0, L_VAR
}, // "sprmPAnld" pap.anld;;variable length;
520 {0xC63F, 0, L_VAR
}, // "sprmPPropRMark" pap.fPropRMark;complex
521 {0x2640, 1, L_FIX
}, // "sprmPOutLvl" pap.lvl;has no effect if pap.istd
523 {0x2441, 1, L_FIX
}, // "sprmPFBiDi" ;;byte;
524 {0x2443, 1, L_FIX
}, // "sprmPFNumRMIns" pap.fNumRMIns;1 or 0;bit;
525 {0x2444, 1, L_FIX
}, // "sprmPCrLf" ;;byte;
526 {0xC645, 0, L_VAR
}, // "sprmPNumRM" pap.numrm;;variable length;
527 {0x6645, 4, L_FIX
}, // "sprmPHugePapx" fc in the data stream to locate
529 {0x6646, 4, L_FIX
}, // "sprmPHugePapx" fc in the data stream to locate
531 {0x2447, 1, L_FIX
}, // "sprmPFUsePgsuSettings" pap.fUsePgsuSettings;
533 {0x2448, 1, L_FIX
}, // "sprmPFAdjustRight" pap.fAdjustRight;1 or 0;byte;
534 {0x0800, 1, L_FIX
}, // "sprmCFRMarkDel" chp.fRMarkDel;1 or 0;bit;
535 {0x0801, 1, L_FIX
}, // "sprmCFRMark" chp.fRMark;1 or 0;bit;
536 {0x0802, 1, L_FIX
}, // "sprmCFFldVanish" chp.fFldVanish;1 or 0;bit;
537 {0x6A03, 4, L_FIX
}, // "sprmCPicLocation" chp.fcPic and chp.fSpec;
538 {0x4804, 2, L_FIX
}, // "sprmCIbstRMark" chp.ibstRMark;index into
540 {0x6805, 4, L_FIX
}, // "sprmCDttmRMark" chp.dttmRMark;DTTM;long;
541 {0x0806, 1, L_FIX
}, // "sprmCFData" chp.fData;1 or 0;bit;
542 {0x4807, 2, L_FIX
}, // "sprmCIdslRMark" chp.idslRMReason;an index to a
543 // table of strings defined in Word 6.0
544 // executables;short;
545 {0xEA08, 1, L_FIX
}, // "sprmCChs" chp.fChsDiff and chp.chse;
546 {0x6A09, 4, L_FIX
}, // "sprmCSymbol" chp.fSpec, chp.xchSym and
548 {0x080A, 1, L_FIX
}, // "sprmCFOle2" chp.fOle2;1 or 0;bit;
549 {0x480B, 0, L_FIX
}, // "sprmCIdCharType" obsolete: not applicable in
550 // Word97 and later versions;;;
551 {0x2A0C, 1, L_FIX
}, // "sprmCHighlight" chp.fHighlight,
552 // chp.icoHighlight;ico (fHighlight is set to 1 iff
554 {0x680E, 4, L_FIX
}, // "sprmCObjLocation" chp.fcObj;FC;long;
555 {0x2A10, 0, L_FIX
}, // "sprmCFFtcAsciSymb" ;;;
556 {0x4A30, 2, L_FIX
}, // "sprmCIstd" chp.istd;istd, see stylesheet def
557 {0xCA31, 0, L_VAR
}, // "sprmCIstdPermute" chp.istd;permutation vector
558 {0x2A32, 0, L_VAR
}, // "sprmCDefault" whole CHP;none;variable length;
559 {0x2A33, 0, L_FIX
}, // "sprmCPlain" whole CHP;none;0;
560 {0x2A34, 1, L_FIX
}, // "sprmCKcd" ;;;
561 {0x0835, 1, L_FIX
}, // "sprmCFBold" chp.fBold;0,1, 128, or 129
562 {0x0836, 1, L_FIX
}, // "sprmCFItalic" chp.fItalic;0,1, 128, or 129
563 {0x0837, 1, L_FIX
}, // "sprmCFStrike" chp.fStrike;0,1, 128, or 129
564 {0x0838, 1, L_FIX
}, // "sprmCFOutline" chp.fOutline;0,1, 128, or 129
565 {0x0839, 1, L_FIX
}, // "sprmCFShadow" chp.fShadow;0,1, 128, or 129
566 {0x083A, 1, L_FIX
}, // "sprmCFSmallCaps" chp.fSmallCaps;0,1, 128, or 129
567 {0x083B, 1, L_FIX
}, // "sprmCFCaps" chp.fCaps;0,1, 128, or 129
568 {0x083C, 1, L_FIX
}, // "sprmCFVanish" chp.fVanish;0,1, 128, or 129
569 {0x4A3D, 2, L_FIX
}, // "sprmCFtcDefault" ;ftc, only used internally
570 {0x2A3E, 1, L_FIX
}, // "sprmCKul" chp.kul;kul;byte;
571 {0xEA3F, 3, L_FIX
}, // "sprmCSizePos" chp.hps, chp.hpsPos;3 bytes;
572 {0x8840, 2, L_FIX
}, // "sprmCDxaSpace" chp.dxaSpace;dxa;word;
573 {0x4A41, 2, L_FIX
}, // "sprmCLid" ;only used internally never stored
574 {0x2A42, 1, L_FIX
}, // "sprmCIco" chp.ico;ico;byte;
575 {0x4A43, 2, L_FIX
}, // "sprmCHps" chp.hps;hps
576 {0x2A44, 1, L_FIX
}, // "sprmCHpsInc" chp.hps;
577 {0x4845, 2, L_FIX
}, // "sprmCHpsPos" chp.hpsPos;hps;short; (doc wrong)
578 {0x2A46, 1, L_FIX
}, // "sprmCHpsPosAdj" chp.hpsPos;hps
579 {0xCA47, 0, L_VAR
}, // "sprmCMajority" chp.fBold, chp.fItalic,
580 // chp.fSmallCaps, chp.fVanish, chp.fStrike,
581 // chp.fCaps, chp.rgftc, chp.hps, chp.hpsPos,
582 // chp.kul, chp.dxaSpace, chp.ico,
583 // chp.rglid;complex;variable length, length byte
584 // plus size of following grpprl;
585 {0x2A48, 1, L_FIX
}, // "sprmCIss" chp.iss;iss;byte;
586 {0xCA49, 0, L_VAR
}, // "sprmCHpsNew50" chp.hps;hps;variable width
587 {0xCA4A, 0, L_VAR
}, // "sprmCHpsInc1" chp.hps;complex
588 {0x484B, 2, L_FIX
}, // "sprmCHpsKern" chp.hpsKern;hps;short;
589 {0xCA4C, 2, L_FIX
}, // "sprmCMajority50" chp.fBold, chp.fItalic,
590 // chp.fSmallCaps, chp.fVanish, chp.fStrike,
591 // chp.fCaps, chp.ftc, chp.hps, chp.hpsPos, chp.kul,
592 // chp.dxaSpace, chp.ico,;complex
593 {0x4A4D, 2, L_FIX
}, // "sprmCHpsMul" chp.hps;percentage to grow hps
594 {0x484E, 2, L_FIX
}, // "sprmCYsri" chp.ysri;ysri;short;
595 {0x4A4F, 2, L_FIX
}, // "sprmCRgFtc0" chp.rgftc[0];ftc for ASCII text
596 {0x4A50, 2, L_FIX
}, // "sprmCRgFtc1" chp.rgftc[1];ftc for Far East text
597 {0x4A51, 2, L_FIX
}, // "sprmCRgFtc2" chp.rgftc[2];ftc for non-FE text
598 {0x4852, 2, L_FIX
}, // "sprmCCharScale"
599 {0x2A53, 1, L_FIX
}, // "sprmCFDStrike" chp.fDStrike;;byte;
600 {0x0854, 1, L_FIX
}, // "sprmCFImprint" chp.fImprint;1 or 0;bit;
601 {0x0855, 1, L_FIX
}, // "sprmCFSpec" chp.fSpec ;1 or 0;bit;
602 {0x0856, 1, L_FIX
}, // "sprmCFObj" chp.fObj;1 or 0;bit;
603 {0xCA57, 0, L_VAR
}, // "sprmCPropRMark" chp.fPropRMark,
604 // chp.ibstPropRMark, chp.dttmPropRMark;Complex
605 {0x0858, 1, L_FIX
}, // "sprmCFEmboss" chp.fEmboss;1 or 0;bit;
606 {0x2859, 1, L_FIX
}, // "sprmCSfxText" chp.sfxtText;text animation;byte;
607 {0x085A, 1, L_FIX
}, // "sprmCFBiDi" ;;;
608 {0x085B, 1, L_FIX
}, // "sprmCFDiacColor" ;;;
609 {0x085C, 1, L_FIX
}, // "sprmCFBoldBi" ;;;
610 {0x085D, 1, L_FIX
}, // "sprmCFItalicBi" ;;;
612 {0x485F, 2, L_FIX
}, // "sprmCLidBi" ;;;
613 {0x4A60, 1, L_FIX
}, // "sprmCIcoBi" ;;;
614 {0x4A61, 2, L_FIX
}, // "sprmCHpsBi" ;;;
615 {0xCA62, 0, L_VAR
}, // "sprmCDispFldRMark" chp.fDispFldRMark,
616 // chp.ibstDispFldRMark, chp.dttmDispFldRMark ;
617 {0x4863, 2, L_FIX
}, // "sprmCIbstRMarkDel" chp.ibstRMarkDel;index into
619 {0x6864, 4, L_FIX
}, // "sprmCDttmRMarkDel" chp.dttmRMarkDel;DTTM;long;
620 {0x6865, 4, L_FIX
}, // "sprmCBrc" chp.brc;BRC;long;
621 {0x4866, 2, L_FIX
}, // "sprmCShd" chp.shd;SHD;short;
622 {0x4867, 2, L_FIX
}, // "sprmCIdslRMarkDel" chp.idslRMReasonDel;an index
623 // to a table of strings defined in Word 6.0
624 // executables;short;
625 {0x0868, 1, L_FIX
}, // "sprmCFUsePgsuSettings"
626 // chp.fUsePgsuSettings;1 or 0
627 {0x486B, 2, L_FIX
}, // "sprmCCpg" ;;word;
628 {0x486D, 2, L_FIX
}, // "sprmCRgLid0" chp.rglid[0];LID: for non-FE text
629 {0x486E, 2, L_FIX
}, // "sprmCRgLid1" chp.rglid[1];LID: for Far East text
630 {0x286F, 1, L_FIX
}, // "sprmCIdctHint" chp.idctHint;IDCT:
631 {0x2E00, 1, L_FIX
}, // "sprmPicBrcl" pic.brcl;brcl (see PIC definition)
632 {0xCE01, 0, L_VAR
}, // "sprmPicScale" pic.mx, pic.my, pic.dxaCropleft,
633 // pic.dyaCropTop pic.dxaCropRight,
634 // pic.dyaCropBottom;Complex
635 {0x6C02, 4, L_FIX
}, // "sprmPicBrcTop" pic.brcTop;BRC;long;
636 {0x6C03, 4, L_FIX
}, // "sprmPicBrcLeft" pic.brcLeft;BRC;long;
637 {0x6C04, 4, L_FIX
}, // "sprmPicBrcBottom" pic.brcBottom;BRC;long;
638 {0x6C05, 4, L_FIX
}, // "sprmPicBrcRight" pic.brcRight;BRC;long;
639 {0x3000, 1, L_FIX
}, // "sprmScnsPgn" sep.cnsPgn;cns;byte;
640 {0x3001, 1, L_FIX
}, // "sprmSiHeadingPgn" sep.iHeadingPgn;heading number
642 {0xD202, 0, L_VAR
}, // "sprmSOlstAnm" sep.olstAnm;OLST;variable length;
643 {0xF203, 3, L_FIX
}, // "sprmSDxaColWidth" sep.rgdxaColWidthSpacing;
644 {0xF204, 3, L_FIX
}, // "sprmSDxaColSpacing" sep.rgdxaColWidthSpacing;
646 {0x3005, 1, L_FIX
}, // "sprmSFEvenlySpaced" sep.fEvenlySpaced;1 or 0
647 {0x3006, 1, L_FIX
}, // "sprmSFProtected" sep.fUnlocked;1 or 0;byte;
648 {0x5007, 2, L_FIX
}, // "sprmSDmBinFirst" sep.dmBinFirst;;word;
649 {0x5008, 2, L_FIX
}, // "sprmSDmBinOther" sep.dmBinOther;;word;
650 {0x3009, 1, L_FIX
}, // "sprmSBkc" sep.bkc;bkc;byte;
651 {0x300A, 1, L_FIX
}, // "sprmSFTitlePage" sep.fTitlePage;0 or 1;byte;
652 {0x500B, 2, L_FIX
}, // "sprmSCcolumns" sep.ccolM1;# of cols - 1;word;
653 {0x900C, 2, L_FIX
}, // "sprmSDxaColumns" sep.dxaColumns;dxa;word;
654 {0x300D, 1, L_FIX
}, // "sprmSFAutoPgn" sep.fAutoPgn;obsolete;byte;
655 {0x300E, 1, L_FIX
}, // "sprmSNfcPgn" sep.nfcPgn;nfc;byte;
656 {0xB00F, 2, L_FIX
}, // "sprmSDyaPgn" sep.dyaPgn;dya;short;
657 {0xB010, 2, L_FIX
}, // "sprmSDxaPgn" sep.dxaPgn;dya;short;
658 {0x3011, 1, L_FIX
}, // "sprmSFPgnRestart" sep.fPgnRestart;0 or 1;byte;
659 {0x3012, 1, L_FIX
}, // "sprmSFEndnote" sep.fEndnote;0 or 1;byte;
660 {0x3013, 1, L_FIX
}, // "sprmSLnc" sep.lnc;lnc;byte;
661 {0x3014, 1, L_FIX
}, // "sprmSGprfIhdt" sep.grpfIhdt;grpfihdt
662 {0x5015, 2, L_FIX
}, // "sprmSNLnnMod" sep.nLnnMod;non-neg int.;word;
663 {0x9016, 2, L_FIX
}, // "sprmSDxaLnn" sep.dxaLnn;dxa;word;
664 {0xB017, 2, L_FIX
}, // "sprmSDyaHdrTop" sep.dyaHdrTop;dya;word;
665 {0xB018, 2, L_FIX
}, // "sprmSDyaHdrBottom" sep.dyaHdrBottom;dya;word;
666 {0x3019, 1, L_FIX
}, // "sprmSLBetween" sep.fLBetween;0 or 1;byte;
667 {0x301A, 1, L_FIX
}, // "sprmSVjc" sep.vjc;vjc;byte;
668 {0x501B, 2, L_FIX
}, // "sprmSLnnMin" sep.lnnMin;lnn;word;
669 {0x501C, 2, L_FIX
}, // "sprmSPgnStart" sep.pgnStart;pgn;word;
670 {0x301D, 1, L_FIX
}, // "sprmSBOrientation" sep.dmOrientPage;dm;byte;
671 {0x301E, 1, L_FIX
}, // "sprmSBCustomize" ;;;
672 {0xB01F, 2, L_FIX
}, // "sprmSXaPage" sep.xaPage;xa;word;
673 {0xB020, 2, L_FIX
}, // "sprmSYaPage" sep.yaPage;ya;word;
674 {0xB021, 2, L_FIX
}, // "sprmSDxaLeft" sep.dxaLeft;dxa;word;
675 {0xB022, 2, L_FIX
}, // "sprmSDxaRight" sep.dxaRight;dxa;word;
676 {0x9023, 2, L_FIX
}, // "sprmSDyaTop" sep.dyaTop;dya;word;
677 {0x9024, 2, L_FIX
}, // "sprmSDyaBottom" sep.dyaBottom;dya;word;
678 {0xB025, 2, L_FIX
}, // "sprmSDzaGutter" sep.dzaGutter;dza;word;
679 {0x5026, 2, L_FIX
}, // "sprmSDmPaperReq" sep.dmPaperReq;dm;word;
680 {0xD227, 0, L_VAR
}, // "sprmSPropRMark" sep.fPropRMark,
681 // sep.ibstPropRMark, sep.dttmPropRMark ;complex
682 {0x3228, 1, L_FIX
}, // "sprmSFBiDi" ;;;
683 {0x3229, 1, L_FIX
}, // "sprmSFFacingCol" ;;;
684 {0x322A, 1, L_FIX
}, // "sprmSFRTLGutter", set to one if gutter is on
686 {0x702B, 4, L_FIX
}, // "sprmSBrcTop" sep.brcTop;BRC;long;
687 {0x702C, 4, L_FIX
}, // "sprmSBrcLeft" sep.brcLeft;BRC;long;
688 {0x702D, 4, L_FIX
}, // "sprmSBrcBottom" sep.brcBottom;BRC;long;
689 {0x702E, 4, L_FIX
}, // "sprmSBrcRight" sep.brcRight;BRC;long;
690 {0x522F, 2, L_FIX
}, // "sprmSPgbProp" sep.pgbProp;;word;
691 {0x7030, 4, L_FIX
}, // "sprmSDxtCharSpace" sep.dxtCharSpace;dxt;long;
692 {0x9031, 2, L_FIX
}, // "sprmSDyaLinePitch"
693 // sep.dyaLinePitch;dya; WRONG:long; RIGHT:short; !
694 {0x5032, 2, L_FIX
}, // "sprmSClm" ;;;
695 {0x5033, 2, L_FIX
}, // "sprmSTextFlow" sep.wTextFlow;complex
696 {0x5400, 2, L_FIX
}, // "sprmTJc" tap.jc;jc;word (low order byte is
698 {0x9601, 2, L_FIX
}, // "sprmTDxaLeft" tap.rgdxaCenter
699 {0x9602, 2, L_FIX
}, // "sprmTDxaGapHalf" tap.dxaGapHalf,
701 {0x3403, 1, L_FIX
}, // "sprmTFCantSplit" tap.fCantSplit;1 or 0;byte;
702 {0x3404, 1, L_FIX
}, // "sprmTTableHeader" tap.fTableHeader;1 or 0;byte;
703 {0x3466, 1, L_FIX
}, // "sprmTFCantSplit90" tap.fCantSplit90;1 or 0;byte;
704 {0xD605, 0, L_VAR
}, // "sprmTTableBorders" tap.rgbrcTable;complex
705 {0xD606, 0, L_VAR
}, // "sprmTDefTable10" tap.rgdxaCenter,
707 {0x9407, 2, L_FIX
}, // "sprmTDyaRowHeight" tap.dyaRowHeight;dya;word;
708 {0xD608, 0, L_VAR
}, // "sprmTDefTable" tap.rgtc;complex
709 {0xD609, 0, L_VAR
}, // "sprmTDefTableShd" tap.rgshd;complex
710 {0x740A, 4, L_FIX
}, // "sprmTTlp" tap.tlp;TLP;4 bytes;
711 {0x560B, 2, L_FIX
}, // "sprmTFBiDi" ;;;
712 {0x740C, 1, L_FIX
}, // "sprmTHTMLProps" ;;;
713 {0xD620, 0, L_VAR
}, // "sprmTSetBrc" tap.rgtc[].rgbrc;complex
714 {0x7621, 4, L_FIX
}, // "sprmTInsert" tap.rgdxaCenter, tap.rgtc;complex
715 {0x5622, 2, L_FIX
}, // "sprmTDelete" tap.rgdxaCenter, tap.rgtc;complex
716 {0x7623, 4, L_FIX
}, // "sprmTDxaCol" tap.rgdxaCenter;complex
717 {0x5624, 0, L_VAR
}, // "sprmTMerge" tap.fFirstMerged, tap.fMerged;
718 {0x5625, 0, L_VAR
}, // "sprmTSplit" tap.fFirstMerged, tap.fMerged;
719 {0xD626, 0, L_VAR
}, // "sprmTSetBrc10" tap.rgtc[].rgbrc;complex
720 {0x7627, 0, L_VAR
}, // "sprmTSetShd" tap.rgshd;complex
721 {0x7628, 0, L_VAR
}, // "sprmTSetShdOdd" tap.rgshd;complex
722 {0x7629, 4, L_FIX
}, // "sprmTTextFlow" tap.rgtc[].fVerticaltap,
723 // rgtc[].fBackwardtap, rgtc[].fRotateFont;0 or 10
725 {0xD62A, 1, L_FIX
}, // "sprmTDiagLine" ;;;
726 {0xD62B, 0, L_VAR
}, // "sprmTVertMerge" tap.rgtc[].vertMerge
727 {0xD62C, 0, L_VAR
}, // "sprmTVertAlign" tap.rgtc[].vertAlign
728 {0xCA78, 0, L_VAR
}, // undocumented "sprmCDoubleLine ?"
729 {0x6649, 4, L_FIX
}, // undocumented
730 {0xF614, 3, L_FIX
}, // undocumented
731 {0xD612, 0, L_VAR
}, // undocumented, new background colours.
732 {0xD613, 0, L_VAR
}, // undocumented
733 {0xD61A, 0, L_VAR
}, // undocumented
734 {0xD61B, 0, L_VAR
}, // undocumented
735 {0xD61C, 0, L_VAR
}, // undocumented
736 {0xD61D, 0, L_VAR
}, // undocumented
737 {0xD632, 0, L_VAR
}, // undocumented
738 {0xD634, 0, L_VAR
}, // undocumented
739 {0xD238, 0, L_VAR
}, // undocumented sep
740 {0xC64E, 0, L_VAR
}, // undocumented
741 {0xC64F, 0, L_VAR
}, // undocumented
742 {0xC650, 0, L_VAR
}, // undocumented
743 {0xC651, 0, L_VAR
}, // undocumented
744 {0xF661, 3, L_FIX
}, // undocumented
745 {0x4873, 2, L_FIX
}, // undocumented
746 {0x4874, 2, L_FIX
}, // undocumented
747 {0x6463, 4, L_FIX
}, // undocumented
748 {0x2461, 1, L_FIX
}, // undoc, must be asian version of "sprmPJc"
749 {0x845D, 2, L_FIX
}, // undoc, must be asian version of "sprmPDxaRight"
750 {0x845E, 2, L_FIX
}, // undoc, must be asian version of "sprmPDxaLeft"
751 {0x8460, 2, L_FIX
}, // undoc, must be asian version of "sprmPDxaLeft1"
752 {0x3615, 1, L_FIX
}, // undocumented
753 {0x360D, 1, L_FIX
}, // undocumented
754 {0x703A, 4, L_FIX
}, // undocumented, sep, perhaps related to textgrids ?
755 {0x303B, 1, L_FIX
}, // undocumented, sep
756 {0x244B, 1, L_FIX
}, // undocumented, subtable "sprmPFInTable" equiv ?
757 {0x244C, 1, L_FIX
}, // undocumented, subtable "sprmPFTtp" equiv ?
758 {0x940E, 2, L_FIX
}, // undocumented
759 {0x940F, 2, L_FIX
}, // undocumented
760 {0x9410, 2, L_FIX
}, // undocumented
761 {0x6815, 4, L_FIX
}, // undocumented
762 {0x6816, 4, L_FIX
}, // undocumented
763 {0x6870, 4, L_FIX
}, // undocumented, text colour
764 {0xC64D, 0, L_VAR
}, // undocumented, para back colour
765 {0x6467, 4, L_FIX
}, // undocumented
766 {0x646B, 4, L_FIX
}, // undocumented
767 {0xF617, 3, L_FIX
}, // undocumented
768 {0xD660, 0, L_VAR
}, // undocumented, something to do with colour.
769 {0xD670, 0, L_VAR
}, // undocumented, something to do with colour.
770 {0xCA71, 0, L_VAR
}, // undocumented, text backcolour
771 {0x303C, 1, L_FIX
}, // undocumented, sep
772 {0x245B, 1, L_FIX
}, // undocumented, para autobefore
773 {0x245C, 1, L_FIX
}, // undocumented, para autoafter
774 // undocumented, don't add space between para of the same style
778 static wwSprmSearcher
aSprmSrch(aSprms
, sizeof(aSprms
) / sizeof(aSprms
[0]));
782 wwSprmParser::wwSprmParser(ww::WordVersion eVersion
) : meVersion(eVersion
)
784 ASSERT((meVersion
>= ww::eWW2
&& meVersion
<= ww::eWW8
),
785 "Impossible value for version");
787 mnDelta
= (ww::IsSevenMinus(meVersion
)) ? 0 : 1;
789 if (meVersion
<= ww::eWW2
)
790 mpKnownSprms
= GetWW2SprmSearcher();
791 else if (meVersion
< ww::eWW8
)
792 mpKnownSprms
= GetWW6SprmSearcher();
794 mpKnownSprms
= GetWW8SprmSearcher();
797 SprmInfo
wwSprmParser::GetSprmInfo(sal_uInt16 nId
) const
800 SprmInfo aSrch
={0,0,0};
802 const SprmInfo
* pFound
= mpKnownSprms
->search(aSrch
);
805 ASSERT(ww::IsEightPlus(meVersion
),
806 "Unknown ww7- sprm, dangerous, report to development");
810 //All the unknown ww7 sprms appear to be variable (which makes sense)
813 if (ww::IsEightPlus(meVersion
)) //We can recover perfectly in this case
850 inline BYTE
Get_Byte( BYTE
*& p
)
852 BYTE n
= SVBT8ToByte( *(SVBT8
*)p
);
857 inline USHORT
Get_UShort( BYTE
*& p
)
859 USHORT n
= SVBT16ToShort( *(SVBT16
*)p
);
864 inline short Get_Short( BYTE
*& p
)
866 return Get_UShort(p
);
869 inline ULONG
Get_ULong( BYTE
*& p
)
871 ULONG n
= SVBT32ToUInt32( *(SVBT32
*)p
);
876 inline long Get_Long( BYTE
*& p
)
881 WW8SprmIter::WW8SprmIter(const BYTE
* pSprms_
, long nLen_
,
882 const wwSprmParser
&rParser
)
883 : mrSprmParser(rParser
), pSprms( pSprms_
), nRemLen( nLen_
)
888 void WW8SprmIter::SetSprms(const BYTE
* pSprms_
, long nLen_
)
895 const BYTE
* WW8SprmIter::operator ++( int )
906 void WW8SprmIter::UpdateMyMembers()
908 if (pSprms
&& nRemLen
> (mrSprmParser
.getVersion()?1:0)) //see #125180#
910 nAktId
= mrSprmParser
.GetSprmId(pSprms
);
911 pAktParams
= pSprms
+ mrSprmParser
.DistanceToData(nAktId
);
912 nAktSize
= mrSprmParser
.GetSprmSize(nAktId
, pSprms
);
923 const BYTE
* WW8SprmIter::FindSprm(USHORT nId
)
927 if( GetAktId() == nId
)
928 return GetAktParams(); // SPRM found!
932 return 0; // SPRM _not_ found
935 //-----------------------------------------
937 //-----------------------------------------
938 // WW8PLCFx_PCDAttrs halten sich an WW8PLCF_Pcd fest und besitzen deshalb keine
939 // eigenen Iteratoren. Alle sich auf Iteratoren beziehenden Methoden
940 // sind deshalb Dummies.
942 WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs(ww::WordVersion eVersion
,
943 WW8PLCFx_PCD
* pPLCFx_PCD
, const WW8ScannerBase
* pBase
)
944 : WW8PLCFx(eVersion
, true), pPcdI(pPLCFx_PCD
->GetPLCFIter()),
945 pPcd(pPLCFx_PCD
), pGrpprls(pBase
->pPieceGrpprls
),
946 nGrpprls(pBase
->nPieceGrpprls
)
950 ULONG
WW8PLCFx_PCDAttrs::GetIdx() const
955 void WW8PLCFx_PCDAttrs::SetIdx( ULONG
)
959 bool WW8PLCFx_PCDAttrs::SeekPos(WW8_CP
)
964 WW8PLCFx
& WW8PLCFx_PCDAttrs::operator ++( int )
969 WW8_CP
WW8PLCFx_PCDAttrs::Where()
971 return ( pPcd
) ? pPcd
->Where() : WW8_CP_MAX
;
974 void WW8PLCFx_PCDAttrs::GetSprms(WW8PLCFxDesc
* p
)
978 p
->bRealLineEnd
= false;
979 if ( !pPcdI
|| !pPcdI
->Get(p
->nStartPos
, p
->nEndPos
, pData
) )
981 // PLCF fully processed
982 p
->nStartPos
= p
->nEndPos
= WW8_CP_MAX
;
988 UINT16 nPrm
= SVBT16ToShort( ( (WW8_PCD
*)pData
)->prm
);
992 UINT16 nSprmIdx
= nPrm
>> 1;
994 if( nSprmIdx
>= nGrpprls
)
997 p
->nStartPos
= p
->nEndPos
= WW8_CP_MAX
;
1002 const BYTE
* pSprms
= pGrpprls
[ nSprmIdx
];
1004 p
->nSprmsLen
= SVBT16ToShort( pSprms
); // Length
1006 p
->pMemPos
= pSprms
; // Position
1010 // PRM Variante 1: Sprm wird direkt in Member-Var abgelegt
1012 Dies sind die Attr, die in der Piece-Table stehen, statt im Text !
1015 if (IsSevenMinus(GetFIBVersion()))
1017 aShortSprm
[0] = (BYTE
)( ( nPrm
& 0xfe) >> 1 );
1018 aShortSprm
[1] = (BYTE
)( nPrm
>> 8 );
1019 p
->nSprmsLen
= ( nPrm
) ? 2 : 0; // Laenge
1021 // store Postion of internal mini storage in Data Pointer
1022 p
->pMemPos
= aShortSprm
;
1028 BYTE nSprmListIdx
= (BYTE
)((nPrm
& 0xfe) >> 1);
1031 // process Sprm Id Matching as explained in MS Doku
1033 // ''Property Modifier(variant 1) (PRM)''
1034 // see file: s62f39.htm
1036 // Since isprm is 7 bits, rgsprmPrm can hold 0x80 entries.
1037 static const USHORT aSprmId
[0x80] =
1039 // sprmNoop, sprmNoop, sprmNoop, sprmNoop
1040 0x0000,0x0000,0x0000,0x0000,
1041 // sprmPIncLvl, sprmPJc, sprmPFSideBySide, sprmPFKeep
1042 0x2402,0x2403,0x2404,0x2405,
1043 // sprmPFKeepFollow, sprmPFPageBreakBefore, sprmPBrcl,
1045 0x2406,0x2407,0x2408,0x2409,
1046 // sprmPIlvl, sprmNoop, sprmPFNoLineNumb, sprmNoop
1047 0x260A,0x0000,0x240C,0x0000,
1048 // sprmNoop, sprmNoop, sprmNoop, sprmNoop
1049 0x0000,0x0000,0x0000,0x0000,
1050 // sprmNoop, sprmNoop, sprmNoop, sprmNoop
1051 0x0000,0x0000,0x0000,0x0000,
1052 // sprmPFInTable, sprmPFTtp, sprmNoop, sprmNoop
1053 0x2416,0x2417,0x0000,0x0000,
1054 // sprmNoop, sprmPPc, sprmNoop, sprmNoop
1055 0x0000,0x261B,0x0000,0x0000,
1056 // sprmNoop, sprmNoop, sprmNoop, sprmNoop
1057 0x0000,0x0000,0x0000,0x0000,
1058 // sprmNoop, sprmPWr, sprmNoop, sprmNoop
1059 0x0000,0x2423,0x0000,0x0000,
1060 // sprmNoop, sprmNoop, sprmNoop, sprmNoop
1061 0x0000,0x0000,0x0000,0x0000,
1062 // sprmPFNoAutoHyph, sprmNoop, sprmNoop, sprmNoop
1063 0x242A,0x0000,0x0000,0x0000,
1064 // sprmNoop, sprmNoop, sprmPFLocked, sprmPFWidowControl
1065 0x0000,0x0000,0x2430,0x2431,
1066 // sprmNoop, sprmPFKinsoku, sprmPFWordWrap,
1067 // sprmPFOverflowPunct
1068 0x0000,0x2433,0x2434,0x2435,
1069 // sprmPFTopLinePunct, sprmPFAutoSpaceDE,
1070 // sprmPFAutoSpaceDN, sprmNoop
1071 0x2436,0x2437,0x2438,0x0000,
1072 // sprmNoop, sprmPISnapBaseLine, sprmNoop, sprmNoop
1073 0x0000,0x243B,0x000,0x0000,
1074 // sprmNoop, sprmCFStrikeRM, sprmCFRMark, sprmCFFldVanish
1075 0x0000,0x0800,0x0801,0x0802,
1076 // sprmNoop, sprmNoop, sprmNoop, sprmCFData
1077 0x0000,0x0000,0x0000,0x0806,
1078 // sprmNoop, sprmNoop, sprmNoop, sprmCFOle2
1079 0x0000,0x0000,0x0000,0x080A,
1080 // sprmNoop, sprmCHighlight, sprmCFEmboss, sprmCSfxText
1081 0x0000,0x2A0C,0x0858,0x2859,
1082 // sprmNoop, sprmNoop, sprmNoop, sprmCPlain
1083 0x0000,0x0000,0x0000,0x2A33,
1084 // sprmNoop, sprmCFBold, sprmCFItalic, sprmCFStrike
1085 0x0000,0x0835,0x0836,0x0837,
1086 // sprmCFOutline, sprmCFShadow, sprmCFSmallCaps, sprmCFCaps,
1087 0x0838,0x0839,0x083a,0x083b,
1088 // sprmCFVanish, sprmNoop, sprmCKul, sprmNoop,
1089 0x083C,0x0000,0x2A3E,0x0000,
1090 // sprmNoop, sprmNoop, sprmCIco, sprmNoop,
1091 0x0000,0x0000,0x2A42,0x0000,
1092 // sprmCHpsInc, sprmNoop, sprmCHpsPosAdj, sprmNoop,
1093 0x2A44,0x0000,0x2A46,0x0000,
1094 // sprmCIss, sprmNoop, sprmNoop, sprmNoop,
1095 0x2A48,0x0000,0x0000,0x0000,
1096 // sprmNoop, sprmNoop, sprmNoop, sprmNoop,
1097 0x0000,0x0000,0x0000,0x0000,
1098 // sprmNoop, sprmNoop, sprmNoop, sprmCFDStrike,
1099 0x0000,0x0000,0x0000,0x2A53,
1100 // sprmCFImprint, sprmCFSpec, sprmCFObj, sprmPicBrcl,
1101 0x0854,0x0855,0x0856,0x2E00,
1102 // sprmPOutLvl, sprmPFBiDi, sprmNoop, sprmNoop,
1103 0x2640,0x2441,0x0000,0x0000,
1104 // sprmNoop, sprmNoop, sprmPPnbrRMarkNot
1105 0x0000,0x0000,0x0000,0x0000
1108 // find real Sprm Id:
1109 USHORT nSprmId
= aSprmId
[ nSprmListIdx
];
1113 // move Sprm Id and Sprm Param to internal mini storage:
1114 aShortSprm
[0] = (BYTE
)( ( nSprmId
& 0x00ff) );
1115 aShortSprm
[1] = (BYTE
)( ( nSprmId
& 0xff00) >> 8 );
1116 aShortSprm
[2] = (BYTE
)( nPrm
>> 8 );
1118 // store Sprm Length in member:
1119 p
->nSprmsLen
= ( nPrm
) ? 3 : 0;
1121 // store Postion of internal mini storage in Data Pointer
1122 p
->pMemPos
= aShortSprm
;
1129 //------------------------------------------------------------------------
1131 WW8PLCFx_PCD::WW8PLCFx_PCD(ww::WordVersion eVersion
, WW8PLCFpcd
* pPLCFpcd
,
1132 WW8_CP nStartCp
, bool bVer67P
)
1133 : WW8PLCFx(eVersion
, false), nClipStart(-1)
1135 // eigenen Iterator konstruieren
1136 pPcdI
= new WW8PLCFpcd_Iter(*pPLCFpcd
, nStartCp
);
1140 WW8PLCFx_PCD::~WW8PLCFx_PCD()
1142 // pPcd-Dtor which in called from WW8ScannerBase
1146 ULONG
WW8PLCFx_PCD::GetIMax() const
1148 return pPcdI
? pPcdI
->GetIMax() : 0;
1151 ULONG
WW8PLCFx_PCD::GetIdx() const
1153 return pPcdI
? pPcdI
->GetIdx() : 0;
1156 void WW8PLCFx_PCD::SetIdx( ULONG nIdx
)
1159 pPcdI
->SetIdx( nIdx
);
1162 bool WW8PLCFx_PCD::SeekPos(WW8_CP nCpPos
)
1164 return pPcdI
? pPcdI
->SeekPos( nCpPos
) : false;
1167 WW8_CP
WW8PLCFx_PCD::Where()
1169 return pPcdI
? pPcdI
->Where() : WW8_CP_MAX
;
1172 long WW8PLCFx_PCD::GetNoSprms( WW8_CP
& rStart
, WW8_CP
& rEnd
, sal_Int32
& rLen
)
1177 if ( !pPcdI
|| !pPcdI
->Get(rStart
, rEnd
, pData
) )
1179 rStart
= rEnd
= WW8_CP_MAX
;
1182 return pPcdI
->GetIdx();
1185 WW8PLCFx
& WW8PLCFx_PCD::operator ++( int )
1190 ASSERT( !this, "pPcdI fehlt");
1195 WW8_FC
WW8PLCFx_PCD::AktPieceStartCp2Fc( WW8_CP nCp
)
1197 WW8_CP nCpStart
, nCpEnd
;
1200 if ( !pPcdI
->Get(nCpStart
, nCpEnd
, pData
) )
1202 ASSERT( !this, "AktPieceStartCp2Fc() with false Cp found (1)" );
1206 ASSERT( nCp
>= nCpStart
&& nCp
< nCpEnd
,
1207 "AktPieceCp2Fc() with false Cp found (2)" );
1209 if( nCp
< nCpStart
)
1214 bool bIsUnicode
= false;
1215 WW8_FC nFC
= SVBT32ToUInt32( ((WW8_PCD
*)pData
)->fc
);
1217 nFC
= WW8PLCFx_PCD::TransformPieceAddress( nFC
, bIsUnicode
);
1219 return nFC
+ (nCp
- nCpStart
) * (bIsUnicode
? 2 : 1);
1223 void WW8PLCFx_PCD::AktPieceFc2Cp( WW8_CP
& rStartPos
, WW8_CP
& rEndPos
,
1224 const WW8ScannerBase
*pSBase
)
1226 //No point going anywhere with this
1227 if ((rStartPos
== WW8_CP_MAX
) && (rEndPos
== WW8_CP_MAX
))
1230 rStartPos
= pSBase
->WW8Fc2Cp( rStartPos
);
1231 rEndPos
= pSBase
->WW8Fc2Cp( rEndPos
);
1234 WW8_CP
WW8PLCFx_PCD::AktPieceStartFc2Cp( WW8_FC nStartPos
)
1236 WW8_CP nCpStart
, nCpEnd
;
1238 if ( !pPcdI
->Get( nCpStart
, nCpEnd
, pData
) )
1240 ASSERT( !this, "AktPieceStartFc2Cp() - Fehler" );
1243 bool bIsUnicode
= false;
1244 INT32 nFcStart
= SVBT32ToUInt32( ((WW8_PCD
*)pData
)->fc
);
1246 nFcStart
= WW8PLCFx_PCD::TransformPieceAddress( nFcStart
, bIsUnicode
);
1248 INT32 nUnicodeFactor
= bIsUnicode
? 2 : 1;
1250 if( nStartPos
< nFcStart
)
1251 nStartPos
= nFcStart
;
1253 if( nStartPos
>= nFcStart
+ (nCpEnd
- nCpStart
) * nUnicodeFactor
)
1254 nStartPos
= nFcStart
+ (nCpEnd
- nCpStart
- 1) * nUnicodeFactor
;
1256 return nCpStart
+ (nStartPos
- nFcStart
) / nUnicodeFactor
;
1259 //-----------------------------------------
1260 // Hilfsroutinen fuer alle
1261 //-----------------------------------------
1263 short WW8_BRC::DetermineBorderProperties(bool bVer67
, short *pSpace
,
1264 BYTE
*pCol
, short *pIdx
) const
1267 Word does not factor the width of the border into the width/height
1268 stored in the information for graphic/table/object widths, so we need
1269 to figure out this extra width here and utilize the returned size in
1272 short nMSTotalWidth
;
1277 UINT16 aBrc1
= SVBT16ToShort(aBits1
);
1278 nCol
= static_cast< BYTE
>((aBrc1
>> 6) & 0x1f); // aBor.ico
1279 nSpace
= (aBrc1
& 0xF800) >> 11;
1281 nMSTotalWidth
= aBrc1
& 0x07;
1282 nIdx
= (aBrc1
& 0x18) >> 3;
1283 //Dashed/Dotted unsets double/thick
1284 if (nMSTotalWidth
> 5)
1289 nMSTotalWidth
= nMSTotalWidth
* nIdx
* 15;
1294 nCol
= aBits2
[0]; // aBor.ico
1295 nSpace
= aBits2
[1] & 0x1F; //space between line and object
1297 //Specification in 8ths of a point, 1 Point = 20 Twips, so by 2.5
1298 nMSTotalWidth
= aBits1
[ 0 ] * 20 / 8;
1300 //Figure out the real size of the border according to word
1303 //Note that codes over 25 are undocumented, and I can't create
1304 //these 4 here in the wild.
1310 DBG_WARNING("Can't create these from the menus, please report");
1316 case 23: //Only 3pt in the menus, but honours the size setting.
1320 double line is three times the width of an ordinary line,
1321 except for the smallest 1/4 point size which appears to have
1322 exactly the same total border width as a 1/2 point size
1323 ordinary line, i.e. twice the nominal line width
1325 nMSTotalWidth
= (nMSTotalWidth
== 5) ?
1326 nMSTotalWidth
*2 : nMSTotalWidth
*3;
1330 triple line is five times the width of an ordinary line,
1331 except that the smallest 1/4 point size appears to have
1332 exactly the same total border width as a 3/4 point size
1333 ordinary line, i.e. three times the nominal line width. The
1334 second smallest 1/2 point size appears to have exactly the
1335 total border width as a 2 1/4 border, i.e 4.5 times the size.
1337 if (nMSTotalWidth
== 5)
1339 else if (nMSTotalWidth
== 10)
1340 nMSTotalWidth
= nMSTotalWidth
*9/2;
1347 small gap thin thick and thick thin appears to have a 3/4
1348 point line, a 3/4 point gap and a thick line of the specified
1351 nMSTotalWidth
= nMSTotalWidth
+ 15*2;
1355 thin thick thin appears to have two outside 3/4 point lines,
1356 two 3/4 point gaps and a thick line of the specified width
1358 nMSTotalWidth
= nMSTotalWidth
+ 15*4;
1363 medium gap thin thick and thick thin appears to have a line
1364 50% of the thick line, and an equal sized gap and then the
1365 thick line of the specified width. But it appears to only
1366 use one of the existing predefined widths for the thin line,
1367 so the closest smallest existing border to the halved thick
1370 switch (nMSTotalWidth
)
1372 case 45: //2 1/4, closest to half is 1
1373 nMSTotalWidth
+= 20 + (nMSTotalWidth
-1)/2;
1379 case 15: //3/4, closest to half is 1/4
1380 nMSTotalWidth
+= 5 + (nMSTotalWidth
-1)/2;
1389 medium gap thin thick thin appears to have a line
1390 50% of the thick line, and an equal sized gap and then the
1391 thick line of the specified width. But it appears to only
1392 use one of the existing predefined widths for the thin
1393 line, so the closest smallest existing border to the halved
1394 thick line is used. Though some fudging at smaller sizes is
1397 switch (nMSTotalWidth
)
1399 case 45: //2 1/4, closest to half is 1
1400 nMSTotalWidth
+= nMSTotalWidth
+ 20 * 2;
1404 nMSTotalWidth
+= nMSTotalWidth
+ 7 * 2;
1408 nMSTotalWidth
+= 5 + 4;
1418 large gap thin thick and thick thin appears to have a thick
1419 line of 1 1/2 pt and a narrow of 3/4 point, with a distance
1420 between the two of the explicitly set line width
1422 nMSTotalWidth
+=15+30;
1426 large gap thin thick thin appears to have a thick line of 1
1427 1/2 pt and two narrows of 3/4 point, with a distance between
1428 the two of the explicitly set line width, though the narrowest
1429 line appears to behave as if it was even smaller
1431 if (nMSTotalWidth
== 5)
1433 nMSTotalWidth
= nMSTotalWidth
*2 + 15*2 + 30;
1437 wave, the dimensions appear to be created by the drawing of
1438 the wave, so we have only two possibilites in the menus, 3/4
1439 point is equal to solid 3 point. This calculation seems to
1440 match well to results.
1446 double wave, the dimensions appear to be created by the
1447 drawing of the wave, so we have only one possibilites in the
1448 menus, that of 3/4 point is equal to solid 3 point. This
1449 calculation seems to match well to results.
1451 nMSTotalWidth
+= 45*2;
1456 emboss and engrave consist of a three lines, the central is of
1457 the explicit point width, the other two (of equal size to each
1458 other are the shadows and are either 3/4 pt of 1 1/2 depending
1459 on if the central line is greater of less than 2 1/4 pt
1461 if (nMSTotalWidth
<= 45)
1462 nMSTotalWidth
+= 2*15;
1464 nMSTotalWidth
+= 2*30;
1472 *pSpace
= nSpace
*20;
1475 return nMSTotalWidth
;
1478 WW8_CP
WW8ScannerBase::WW8Fc2Cp( WW8_FC nFcPos
) const
1480 WW8_CP nFallBackCpEnd
= WW8_CP_MAX
;
1481 if( nFcPos
== WW8_FC_MAX
)
1482 return nFallBackCpEnd
;
1484 bool bIsUnicode
= false;
1485 if( pPieceIter
) // Complex File ?
1487 ULONG nOldPos
= pPieceIter
->GetIdx();
1489 for (pPieceIter
->SetIdx(0);
1490 pPieceIter
->GetIdx() < pPieceIter
->GetIMax();(*pPieceIter
)++)
1492 WW8_CP nCpStart
, nCpEnd
;
1494 if( !pPieceIter
->Get( nCpStart
, nCpEnd
, pData
) )
1495 { // ausserhalb PLCFfpcd ?
1496 ASSERT( !this, "PLCFpcd-WW8Fc2Cp() ging schief" );
1499 INT32 nFcStart
= SVBT32ToUInt32( ((WW8_PCD
*)pData
)->fc
);
1500 if( 8 <= pWw8Fib
->nVersion
)
1502 nFcStart
= WW8PLCFx_PCD::TransformPieceAddress( nFcStart
,
1507 if (pWw8Fib
->fExtChar
)
1510 INT32 nLen
= (nCpEnd
- nCpStart
) * (bIsUnicode
? 2 : 1);
1513 If this cp is inside this piece, or its the last piece and we are
1514 on the very last cp of that piece
1516 if (nFcPos
>= nFcStart
)
1520 nCpStart
+ ((nFcPos
- nFcStart
) / (bIsUnicode
? 2 : 1));
1521 if (nFcPos
< nFcStart
+ nLen
)
1523 pPieceIter
->SetIdx( nOldPos
);
1526 else if (nFcPos
== nFcStart
+ nLen
)
1528 //Keep this cp as its on a piece boundary because we might
1529 //need it if tests fail
1530 nFallBackCpEnd
= nTempCp
;
1535 pPieceIter
->SetIdx( nOldPos
); // not found
1537 If it was not found, then this is because it has fallen between two
1538 stools, i.e. either it is the last cp/fc of the last piece, or it is
1539 the last cp/fc of a disjoint piece.
1541 return nFallBackCpEnd
;
1544 if (pWw8Fib
->fExtChar
)
1546 return ((nFcPos
- pWw8Fib
->fcMin
) / (bIsUnicode
? 2 : 1));
1549 WW8_FC
WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos
, bool* pIsUnicode
,
1550 WW8_CP
* pNextPieceCp
, bool* pTestFlag
) const
1554 if( WW8_CP_MAX
== nCpPos
)
1559 pIsUnicode
= &bIsUnicode
;
1564 *pNextPieceCp
= WW8_CP_MAX
;
1566 if( !pPieceIter
->SeekPos( nCpPos
) )
1571 ASSERT( !this, "Falscher CP an WW8Cp2Fc() uebergeben" );
1575 WW8_CP nCpStart
, nCpEnd
;
1577 if( !pPieceIter
->Get( nCpStart
, nCpEnd
, pData
) )
1582 ASSERT( !this, "PLCFfpcd-Get ging schief" );
1587 *pNextPieceCp
= nCpEnd
;
1589 WW8_FC nRet
= SVBT32ToUInt32( ((WW8_PCD
*)pData
)->fc
);
1590 if (8 > pWw8Fib
->nVersion
)
1591 if (pWw8Fib
->fExtChar
)
1594 *pIsUnicode
= false;
1596 nRet
= WW8PLCFx_PCD::TransformPieceAddress( nRet
, *pIsUnicode
);
1599 nRet
+= (nCpPos
- nCpStart
) * (*pIsUnicode
? 2 : 1);
1605 if (pWw8Fib
->fExtChar
)
1608 *pIsUnicode
= false;
1609 return pWw8Fib
->fcMin
+ nCpPos
* (*pIsUnicode
? 2 : 1);
1612 //-----------------------------------------
1613 // class WW8ScannerBase
1614 //-----------------------------------------
1616 WW8PLCFpcd
* WW8ScannerBase::OpenPieceTable( SvStream
* pStr
, const WW8Fib
* pWwF
)
1618 if ( ((8 > pWw8Fib
->nVersion
) && !pWwF
->fComplex
) || !pWwF
->lcbClx
)
1621 WW8_FC nClxPos
= pWwF
->fcClx
;
1622 INT32 nClxLen
= pWwF
->lcbClx
;
1623 INT32 nLeft
= nClxLen
;
1627 pStr
->Seek( nClxPos
);
1628 while( 1 ) // Zaehle Zahl der Grpprls
1632 if( 2 == clxt
) // PLCFfpcd ?
1633 break; // PLCFfpcd gefunden
1634 if( 1 == clxt
) // clxtGrpprl ?
1640 return 0; // schiefgegangen
1641 pStr
->SeekRel( nLen
); // ueberlies grpprl
1643 pStr
->Seek( nClxPos
);
1645 pPieceGrpprls
= new BYTE
*[nGrpprl
+ 1];
1646 memset( pPieceGrpprls
, 0, ( nGrpprl
+ 1 ) * sizeof(BYTE
*) );
1647 nPieceGrpprls
= nGrpprl
;
1648 INT16 nAktGrpprl
= 0; // lies Grpprls ein
1653 if( 2 == clxt
) // PLCFfpcd ?
1654 break; // PLCFfpcd gefunden
1659 return 0; // schiefgegangen
1660 if( 1 == clxt
) // clxtGrpprl ?
1662 BYTE
* p
= new BYTE
[nLen
+2]; // alloziere
1663 ShortToSVBT16(nLen
, p
); // trage Laenge ein
1664 pStr
->Read( p
+2, nLen
); // lies grpprl
1665 pPieceGrpprls
[nAktGrpprl
++] = p
; // trage in Array ein
1668 pStr
->SeekRel( nLen
); // ueberlies nicht-Grpprl
1670 // lies Piece Table PLCF ein
1671 sal_Int32 nPLCFfLen
;
1672 if (pWwF
->GetFIBVersion() <= ww::eWW2
)
1674 sal_Int16 nWordTwoLen
;
1675 *pStr
>> nWordTwoLen
;
1676 nPLCFfLen
= nWordTwoLen
;
1680 ASSERT( 65536 > nPLCFfLen
, "PLCFfpcd ueber 64 k" );
1681 return new WW8PLCFpcd( pStr
, pStr
->Tell(), nPLCFfLen
, 8 );
1684 void WW8ScannerBase::DeletePieceTable()
1688 for( BYTE
** p
= pPieceGrpprls
; *p
; p
++ )
1690 delete[] pPieceGrpprls
;
1695 WW8ScannerBase::WW8ScannerBase( SvStream
* pSt
, SvStream
* pTblSt
,
1696 SvStream
* pDataSt
, const WW8Fib
* pWwFib
)
1697 : pWw8Fib(pWwFib
), pMainFdoa(0), pHdFtFdoa(0), pMainTxbx(0),
1698 pMainTxbxBkd(0), pHdFtTxbx(0), pHdFtTxbxBkd(0), pMagicTables(0),
1699 pSubdocs(0), pExtendedAtrds(0), pPieceGrpprls(0)
1701 pPiecePLCF
= OpenPieceTable( pTblSt
, pWw8Fib
); // Complex
1704 pPieceIter
= new WW8PLCFpcd_Iter( *pPiecePLCF
);
1705 pPLCFx_PCD
= new WW8PLCFx_PCD(pWwFib
->GetFIBVersion(), pPiecePLCF
, 0,
1706 IsSevenMinus(pWw8Fib
->GetFIBVersion()));
1707 pPLCFx_PCDAttrs
= new WW8PLCFx_PCDAttrs(pWwFib
->GetFIBVersion(),
1714 pPLCFx_PCDAttrs
= 0;
1717 // pChpPLCF and pPapPLCF may NOT be created before pPLCFx_PCD !!
1718 pChpPLCF
= new WW8PLCFx_Cp_FKP( pSt
, pTblSt
, pDataSt
, *this, CHP
); // CHPX
1719 pPapPLCF
= new WW8PLCFx_Cp_FKP( pSt
, pTblSt
, pDataSt
, *this, PAP
); // PAPX
1721 pSepPLCF
= new WW8PLCFx_SEPX( pSt
, pTblSt
, *pWwFib
, 0 ); // SEPX
1724 pFtnPLCF
= new WW8PLCFx_SubDoc( pTblSt
, pWwFib
->GetFIBVersion(), 0,
1725 pWwFib
->fcPlcffndRef
, pWwFib
->lcbPlcffndRef
, pWwFib
->fcPlcffndTxt
,
1726 pWwFib
->lcbPlcffndTxt
, 2 );
1728 pEdnPLCF
= new WW8PLCFx_SubDoc( pTblSt
, pWwFib
->GetFIBVersion(), 0,
1729 pWwFib
->fcPlcfendRef
, pWwFib
->lcbPlcfendRef
, pWwFib
->fcPlcfendTxt
,
1730 pWwFib
->lcbPlcfendTxt
, 2 );
1732 pAndPLCF
= new WW8PLCFx_SubDoc( pTblSt
, pWwFib
->GetFIBVersion(), 0,
1733 pWwFib
->fcPlcfandRef
, pWwFib
->lcbPlcfandRef
, pWwFib
->fcPlcfandTxt
,
1734 pWwFib
->lcbPlcfandTxt
, IsSevenMinus(pWwFib
->GetFIBVersion()) ? 20 : 30);
1737 pFldPLCF
= new WW8PLCFx_FLD(pTblSt
, *pWwFib
, MAN_MAINTEXT
);
1738 // Fields Header / Footer
1739 pFldHdFtPLCF
= new WW8PLCFx_FLD(pTblSt
, *pWwFib
, MAN_HDFT
);
1741 pFldFtnPLCF
= new WW8PLCFx_FLD(pTblSt
, *pWwFib
, MAN_FTN
);
1743 pFldEdnPLCF
= new WW8PLCFx_FLD(pTblSt
, *pWwFib
, MAN_EDN
);
1744 // Fields Anmerkungen
1745 pFldAndPLCF
= new WW8PLCFx_FLD(pTblSt
, *pWwFib
, MAN_AND
);
1746 // Fields in Textboxes in Main Text
1747 pFldTxbxPLCF
= new WW8PLCFx_FLD(pTblSt
, *pWwFib
, MAN_TXBX
);
1748 // Fields in Textboxes in Header / Footer
1749 pFldTxbxHdFtPLCF
= new WW8PLCFx_FLD(pTblSt
,*pWwFib
,MAN_TXBX_HDFT
);
1751 // Note: 6 stands for "6 OR 7", 7 stands for "ONLY 7"
1752 switch( pWw8Fib
->nVersion
)
1756 if( pWwFib
->fcPlcfdoaMom
&& pWwFib
->lcbPlcfdoaMom
)
1758 pMainFdoa
= new WW8PLCFspecial( pTblSt
, pWwFib
->fcPlcfdoaMom
,
1759 pWwFib
->lcbPlcfdoaMom
, 6 );
1761 if( pWwFib
->fcPlcfdoaHdr
&& pWwFib
->lcbPlcfdoaHdr
)
1763 pHdFtFdoa
= new WW8PLCFspecial( pTblSt
, pWwFib
->fcPlcfdoaHdr
,
1764 pWwFib
->lcbPlcfdoaHdr
, 6 );
1768 if( pWwFib
->fcPlcfspaMom
&& pWwFib
->lcbPlcfspaMom
)
1770 pMainFdoa
= new WW8PLCFspecial( pTblSt
, pWwFib
->fcPlcfspaMom
,
1771 pWwFib
->lcbPlcfspaMom
, 26 );
1773 if( pWwFib
->fcPlcfspaHdr
&& pWwFib
->lcbPlcfspaHdr
)
1775 pHdFtFdoa
= new WW8PLCFspecial( pTblSt
, pWwFib
->fcPlcfspaHdr
,
1776 pWwFib
->lcbPlcfspaHdr
, 26 );
1778 // PLCF fuer TextBox-Break-Deskriptoren im Maintext
1779 if( pWwFib
->fcPlcftxbxBkd
&& pWwFib
->lcbPlcftxbxBkd
)
1781 pMainTxbxBkd
= new WW8PLCFspecial( pTblSt
,
1782 pWwFib
->fcPlcftxbxBkd
, pWwFib
->lcbPlcftxbxBkd
, 0);
1784 // PLCF fuer TextBox-Break-Deskriptoren im Header-/Footer-Bereich
1785 if( pWwFib
->fcPlcfHdrtxbxBkd
&& pWwFib
->lcbPlcfHdrtxbxBkd
)
1787 pHdFtTxbxBkd
= new WW8PLCFspecial( pTblSt
,
1788 pWwFib
->fcPlcfHdrtxbxBkd
, pWwFib
->lcbPlcfHdrtxbxBkd
, 0);
1790 // Sub table cp positions
1791 if (pWwFib
->fcPlcfTch
&& pWwFib
->lcbPlcfTch
)
1793 pMagicTables
= new WW8PLCFspecial( pTblSt
,
1794 pWwFib
->fcPlcfTch
, pWwFib
->lcbPlcfTch
, 4);
1796 // Sub document cp positions
1797 if (pWwFib
->fcPlcfwkb
&& pWwFib
->lcbPlcfwkb
)
1799 pSubdocs
= new WW8PLCFspecial( pTblSt
,
1800 pWwFib
->fcPlcfwkb
, pWwFib
->lcbPlcfwkb
, 12);
1803 if (pWwFib
->fcAtrdExtra
&& pWwFib
->lcbAtrdExtra
)
1805 pExtendedAtrds
= new BYTE
[pWwFib
->lcbAtrdExtra
];
1806 long nOldPos
= pTblSt
->Tell();
1807 pTblSt
->Seek(pWwFib
->fcAtrdExtra
);
1808 pTblSt
->Read(pExtendedAtrds
, pWwFib
->lcbAtrdExtra
);
1809 pTblSt
->Seek(nOldPos
);
1814 ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
1818 // PLCF fuer TextBox-Stories im Maintext
1819 long nLenTxBxS
= (8 > pWw8Fib
->nVersion
) ? 0 : 22;
1820 if( pWwFib
->fcPlcftxbxTxt
&& pWwFib
->lcbPlcftxbxTxt
)
1822 pMainTxbx
= new WW8PLCFspecial( pTblSt
, pWwFib
->fcPlcftxbxTxt
,
1823 pWwFib
->lcbPlcftxbxTxt
, nLenTxBxS
);
1826 // PLCF fuer TextBox-Stories im Header-/Footer-Bereich
1827 if( pWwFib
->fcPlcfHdrtxbxTxt
&& pWwFib
->lcbPlcfHdrtxbxTxt
)
1829 pHdFtTxbx
= new WW8PLCFspecial( pTblSt
, pWwFib
->fcPlcfHdrtxbxTxt
,
1830 pWwFib
->lcbPlcfHdrtxbxTxt
, nLenTxBxS
);
1833 pBook
= new WW8PLCFx_Book(pTblSt
, *pWwFib
);
1836 WW8ScannerBase::~WW8ScannerBase()
1839 delete pPLCFx_PCDAttrs
;
1847 delete pFldHdFtPLCF
;
1849 delete pFldTxbxPLCF
;
1850 delete pFldTxbxHdFtPLCF
;
1857 // vergessene Schaeflein
1861 delete pMainTxbxBkd
;
1863 delete pHdFtTxbxBkd
;
1864 delete pMagicTables
;
1866 delete [] pExtendedAtrds
;
1869 //-----------------------------------------
1871 //-----------------------------------------
1872 static bool WW8SkipField(WW8PLCFspecial
& rPLCF
)
1877 if (!rPLCF
.Get(nP
, pData
)) // Ende des PLCFspecial ?
1882 if((((BYTE
*)pData
)[0] & 0x1f ) != 0x13 ) // Kein Anfang ?
1883 return true; // Bei Fehler nicht abbrechen
1885 if( !rPLCF
.Get( nP
, pData
) )
1889 while((((BYTE
*)pData
)[0] & 0x1f ) == 0x13 )
1891 // immer noch neue (nested) Anfaenge ?
1892 WW8SkipField( rPLCF
); // nested Field im Beschreibungsteil
1893 if( !rPLCF
.Get( nP
, pData
) )
1897 if((((BYTE
*)pData
)[0] & 0x1f ) == 0x14 )
1900 // Field Separator ?
1903 if( !rPLCF
.Get( nP
, pData
) )
1906 while ((((BYTE
*)pData
)[0] & 0x1f ) == 0x13)
1908 // immer noch neue (nested) Anfaenge ?
1909 WW8SkipField( rPLCF
); // nested Field im Resultatteil
1910 if( !rPLCF
.Get( nP
, pData
) )
1919 static bool WW8GetFieldPara(WW8PLCFspecial
& rPLCF
, WW8FieldDesc
& rF
)
1922 ULONG nOldIdx
= rPLCF
.GetIdx();
1924 rF
.nLen
= rF
.nId
= rF
.nOpt
= rF
.bCodeNest
= rF
.bResNest
= 0;
1926 if( !rPLCF
.Get( rF
.nSCode
, pData
) ) // Ende des PLCFspecial ?
1931 if((((BYTE
*)pData
)[0] & 0x1f ) != 0x13 ) // Kein Anfang ?
1934 rF
.nId
= ((BYTE
*)pData
)[1];
1936 if( !rPLCF
.Get( rF
.nLCode
, pData
) )
1939 rF
.nSRes
= rF
.nLCode
; // Default
1940 rF
.nSCode
++; // ohne Marken
1941 rF
.nLCode
-= rF
.nSCode
; // Pos zu Laenge
1943 while((((BYTE
*)pData
)[0] & 0x1f ) == 0x13 )
1945 // immer noch neue (nested) Anfaenge ?
1946 WW8SkipField( rPLCF
); // nested Field im Beschreibungsteil
1947 rF
.bCodeNest
= true;
1948 if( !rPLCF
.Get( rF
.nSRes
, pData
) )
1952 if((((BYTE
*)pData
)[0] & 0x1f ) == 0x14 ){ // Field Separator ?
1955 if( !rPLCF
.Get( rF
.nLRes
, pData
) )
1958 while((((BYTE
*)pData
)[0] & 0x1f ) == 0x13 )
1960 // immer noch neue (nested) Anfaenge ?
1961 WW8SkipField( rPLCF
); // nested Field im Resultatteil
1963 if( !rPLCF
.Get( rF
.nLRes
, pData
) )
1966 rF
.nLen
= rF
.nLRes
- rF
.nSCode
+ 2; // nLRes ist noch die Endposition
1967 rF
.nLRes
-= rF
.nSRes
; // nun: nLRes = Laenge
1968 rF
.nSRes
++; // Endpos encl. Marken
1972 rF
.nLRes
= 0; // Kein Result vorhanden
1973 rF
.nLen
= rF
.nSRes
- rF
.nSCode
+ 2; // Gesamtlaenge
1977 if((((BYTE
*)pData
)[0] & 0x1f ) == 0x15 )
1980 // INDEX-Fld hat Bit7 gesetzt!?!
1981 rF
.nOpt
= ((BYTE
*)pData
)[1]; // Ja -> Flags uebernehmen
1983 rF
.nId
= 0; // Nein -> Feld ungueltig
1986 rPLCF
.SetIdx( nOldIdx
);
1989 rPLCF
.SetIdx( nOldIdx
);
1994 //-----------------------------------------
1997 // WW8ReadPString liest einen Pascal-String ein und gibt ihn zurueck. Der
1998 // Pascal- String hat am Ende ein \0, der aber im Laengenbyte nicht
1999 // mitgezaehlt wird. Der Speicher fuer den Pascalstring wird alloziert.
2000 String
WW8ReadPString(SvStream
& rStrm
, rtl_TextEncoding eEnc
,
2001 bool bAtEndSeekRel1
)
2003 ByteString aByteStr
;
2009 // Alloc methode automatically sets Zero at the end
2010 sal_Char
* pByteData
= aByteStr
.AllocBuffer( b
);
2012 ULONG nWasRead
= rStrm
.Read( pByteData
, b
);
2014 aByteStr
.ReleaseBufferAccess(static_cast<xub_StrLen
>(nWasRead
));
2017 if( bAtEndSeekRel1
)
2018 rStrm
.SeekRel( 1 ); // ueberspringe das Null-Byte am Ende.
2021 return String( aByteStr
, eEnc
);
2024 String
WW8Read_xstz(SvStream
& rStrm
, USHORT nChars
, bool bAtEndSeekRel1
)
2036 // Alloc methode automatically sets Zero at the end
2037 sal_Unicode
* pData
= aStr
.AllocBuffer( b
);
2039 ULONG nWasRead
= rStrm
.Read( (sal_Char
*)pData
, b
* 2 );
2040 if( nWasRead
!= static_cast<ULONG
>(b
*2) )
2042 b
= static_cast<UINT16
>(nWasRead
/ 2);
2043 aStr
.ReleaseBufferAccess( b
);
2044 pData
= aStr
.GetBufferAccess();
2047 #ifdef OSL_BIGENDIAN
2050 for( n
= 0, pWork
= pData
; n
< b
; ++n
, ++pWork
)
2051 *pWork
= SWAPSHORT( *pWork
);
2052 #endif // ifdef OSL_BIGENDIAN
2055 if( bAtEndSeekRel1
)
2056 rStrm
.SeekRel( 2 ); // ueberspringe das Null-Character am Ende.
2061 ULONG
SafeReadString(ByteString
&rStr
,USHORT nLen
,SvStream
&rStrm
)
2066 nWasRead
= rStrm
.Read( rStr
.AllocBuffer( nLen
), nLen
);
2067 if( nWasRead
!= nLen
)
2068 rStr
.ReleaseBufferAccess(static_cast<xub_StrLen
>(nWasRead
));
2073 xub_StrLen
WW8ScannerBase::WW8ReadString( SvStream
& rStrm
, String
& rStr
,
2074 WW8_CP nAktStartCp
, long nTotalLen
, rtl_TextEncoding eEnc
) const
2076 // Klartext einlesen, der sich ueber mehrere Pieces erstrecken kann
2079 long nTotalRead
= 0;
2080 WW8_CP nBehindTextCp
= nAktStartCp
+ nTotalLen
;
2081 WW8_CP nNextPieceCp
= nBehindTextCp
; // Initialisierung wichtig fuer Ver6
2084 bool bIsUnicode
, bPosOk
;
2085 WW8_FC fcAct
= WW8Cp2Fc(nAktStartCp
,&bIsUnicode
,&nNextPieceCp
,&bPosOk
);
2087 // vermutlich uebers Dateiende hinaus gezielt, macht nix!
2091 rStrm
.Seek( fcAct
);
2093 long nLen
= ( (nNextPieceCp
< nBehindTextCp
) ? nNextPieceCp
2094 : nBehindTextCp
) - nAktStartCp
;
2099 if( nLen
> USHRT_MAX
- 1 )
2100 nLen
= USHRT_MAX
- 1;
2103 rStr
.Append(WW8Read_xstz(rStrm
, (USHORT
)nLen
, false));
2106 // Alloc method automatically sets Zero at the end
2107 ByteString aByteStr
;
2108 SafeReadString(aByteStr
,(USHORT
)nLen
,rStrm
);
2109 rStr
+= String( aByteStr
, eEnc
);
2112 nAktStartCp
+= nLen
;
2113 if ( nTotalRead
!= rStr
.Len() )
2116 while( nTotalRead
< nTotalLen
);
2121 //-----------------------------------------
2123 //-----------------------------------------
2125 // Bei nStartPos < 0 wird das erste Element des PLCFs genommen
2126 WW8PLCFspecial::WW8PLCFspecial(SvStream
* pSt
, long nFilePos
, long nPLCF
,
2127 long nStruct
, long nStartPos
, bool bNoEnd
)
2128 : nIdx(0), nStru(nStruct
)
2130 nIMax
= ( nPLCF
- 4 ) / ( 4 + nStruct
);
2131 // Pointer auf Pos- u. Struct-Array
2132 pPLCF_PosArray
= new INT32
[ ( nPLCF
+ 3 ) / 4 ];
2134 long nOldPos
= pSt
->Tell();
2136 pSt
->Seek( nFilePos
);
2137 pSt
->Read( pPLCF_PosArray
, nPLCF
);
2138 #ifdef OSL_BIGENDIAN
2139 for( nIdx
= 0; nIdx
<= nIMax
; nIdx
++ )
2140 pPLCF_PosArray
[nIdx
] = SWAPLONG( pPLCF_PosArray
[nIdx
] );
2142 #endif // OSL_BIGENDIAN
2145 if( nStruct
) // Pointer auf Inhalts-Array
2146 pPLCF_Contents
= (BYTE
*)&pPLCF_PosArray
[nIMax
+ 1];
2148 pPLCF_Contents
= 0; // kein Inhalt
2149 if( nStartPos
>= 0 )
2150 SeekPos( nStartPos
);
2152 pSt
->Seek( nOldPos
);
2155 // WW8PLCFspecial::SeekPos() stellt den WW8PLCFspecial auf die Stelle nPos, wobei auch noch der
2156 // Eintrag benutzt wird, der vor nPos beginnt und bis hinter nPos reicht.
2157 // geeignet fuer normale Attribute. Allerdings wird der Attributanfang nicht
2158 // auf die Position nPos korrigiert.
2159 bool WW8PLCFspecial::SeekPos(long nP
)
2161 if( nP
< pPLCF_PosArray
[0] )
2164 return false; // Not found: nP unterhalb kleinstem Eintrag
2167 // Search from beginning?
2168 if( (1 > nIdx
) || (nP
< pPLCF_PosArray
[ nIdx
-1 ]) )
2171 long nI
= nIdx
? nIdx
: 1;
2174 for(int n
= (1==nIdx
? 1 : 2); n
; --n
)
2176 for( ; nI
<=nEnd
; ++nI
)
2177 { // Suchen mit um 1 erhoehtem Index
2178 if( nP
< pPLCF_PosArray
[nI
] )
2179 { // Position gefunden
2180 nIdx
= nI
- 1; // nI - 1 ist der richtige Index
2181 return true; // ... und fertig
2187 nIdx
= nIMax
; // Nicht gefunden, groesser als alle Eintraege
2191 // WW8PLCFspecial::SeekPosExact() wie SeekPos(), aber es wird sichergestellt,
2192 // dass kein Attribut angeschnitten wird, d.h. das naechste gelieferte
2193 // Attribut beginnt auf oder hinter nPos. Wird benutzt fuer Felder +
2195 bool WW8PLCFspecial::SeekPosExact(long nP
)
2197 if( nP
< pPLCF_PosArray
[0] )
2200 return false; // Not found: nP unterhalb kleinstem Eintrag
2202 // Search from beginning?
2203 if( nP
<=pPLCF_PosArray
[nIdx
] )
2206 long nI
= nIdx
? nIdx
-1 : 0;
2209 for(int n
= (0==nIdx
? 1 : 2); n
; --n
)
2211 for( ; nI
< nEnd
; ++nI
)
2213 if( nP
<=pPLCF_PosArray
[nI
] )
2214 { // Position gefunden
2215 nIdx
= nI
; // nI ist der richtige Index
2216 return true; // ... und fertig
2222 nIdx
= nIMax
; // Not found, groesser als alle Eintraege
2226 bool WW8PLCFspecial::Get(WW8_CP
& rPos
, void*& rpValue
) const
2228 return GetData( nIdx
, rPos
, rpValue
);
2231 bool WW8PLCFspecial::GetData(long nInIdx
, WW8_CP
& rPos
, void*& rpValue
) const
2233 if ( nInIdx
>= nIMax
)
2238 rPos
= pPLCF_PosArray
[nInIdx
];
2239 rpValue
= pPLCF_Contents
? (void*)&pPLCF_Contents
[nInIdx
* nStru
] : 0;
2243 //-----------------------------------------
2244 // WW8PLCF z.B. fuer SEPX
2245 //-----------------------------------------
2247 // Ctor fuer *andere* als Fkps
2248 // Bei nStartPos < 0 wird das erste Element des PLCFs genommen
2249 WW8PLCF::WW8PLCF( SvStream
* pSt
, WW8_FC nFilePos
, INT32 nPLCF
, int nStruct
,
2250 WW8_CP nStartPos
) : pPLCF_PosArray(0), nIdx(0), nStru(nStruct
)
2252 ASSERT( nPLCF
, "WW8PLCF: nPLCF ist Null!" );
2254 nIMax
= ( nPLCF
- 4 ) / ( 4 + nStruct
);
2256 ReadPLCF( pSt
, nFilePos
, nPLCF
);
2258 if( nStartPos
>= 0 )
2259 SeekPos( nStartPos
);
2262 // Ctor *nur* fuer Fkps
2263 // Die letzten 2 Parameter sind fuer PLCF.Chpx und PLCF.Papx noetig. ist ncpN
2264 // != 0, dann wird ein unvollstaendiger PLCF vervollstaendigt. Das ist bei
2265 // WW6 bei Resourcenmangel und bei WordPad (W95) immer noetig. Bei nStartPos
2266 // < 0 wird das erste Element des PLCFs genommen
2267 WW8PLCF::WW8PLCF( SvStream
* pSt
, WW8_FC nFilePos
, INT32 nPLCF
, int nStruct
,
2268 WW8_CP nStartPos
, INT32 nPN
, INT32 ncpN
) : pPLCF_PosArray(0), nIdx(0),
2271 nIMax
= ( nPLCF
- 4 ) / ( 4 + nStruct
);
2274 ReadPLCF( pSt
, nFilePos
, nPLCF
);
2276 GeneratePLCF( pSt
, nPN
, ncpN
);
2278 if( nStartPos
>= 0 )
2279 SeekPos( nStartPos
);
2282 void WW8PLCF::ReadPLCF( SvStream
* pSt
, WW8_FC nFilePos
, INT32 nPLCF
)
2284 // Pointer auf Pos-Array
2285 pPLCF_PosArray
= new WW8_CP
[ ( nPLCF
+ 3 ) / 4 ];
2287 sal_Size nOldPos
= pSt
->Tell();
2289 pSt
->Seek( nFilePos
);
2290 pSt
->Read( pPLCF_PosArray
, nPLCF
);
2291 #ifdef OSL_BIGENDIAN
2292 for( nIdx
= 0; nIdx
<= nIMax
; nIdx
++ )
2293 pPLCF_PosArray
[nIdx
] = SWAPLONG( pPLCF_PosArray
[nIdx
] );
2295 #endif // OSL_BIGENDIAN
2296 // Pointer auf Inhalts-Array
2297 pPLCF_Contents
= (BYTE
*)&pPLCF_PosArray
[nIMax
+ 1];
2299 pSt
->Seek( nOldPos
);
2302 void WW8PLCF::GeneratePLCF( SvStream
* pSt
, INT32 nPN
, INT32 ncpN
)
2304 ASSERT( nIMax
< ncpN
, "Pcl.Fkp: Warum ist PLCF zu gross ?" );
2306 bool failure
= false;
2309 if ((nIMax
< 1) || (nIMax
> (WW8_CP_MAX
- 4)/6) || ((nPN
+ ncpN
) > USHRT_MAX
))
2314 size_t nSiz
= 6 * nIMax
+ 4;
2315 size_t nElems
= ( nSiz
+ 3 ) / 4;
2316 pPLCF_PosArray
= new INT32
[ nElems
]; // Pointer auf Pos-Array
2318 for (INT32 i
= 0; i
< ncpN
&& !pSt
->GetError(); ++i
)
2320 // Baue FC-Eintraege
2321 pSt
->Seek( ( nPN
+ i
) << 9 ); // erster FC-Eintrag jedes Fkp
2324 pPLCF_PosArray
[i
] = nFc
;
2327 failure
= pSt
->GetError();
2332 sal_Size nLastFkpPos
= ( ( nPN
+ nIMax
- 1 ) << 9 );
2333 pSt
->Seek( nLastFkpPos
+ 511 ); // Anz. Fkp-Eintraege des letzten Fkp
2337 pSt
->Seek( nLastFkpPos
+ nb
* 4 ); // letzer FC-Eintrag des letzten Fkp
2341 pPLCF_PosArray
[nIMax
] = nFc
; // Ende des letzten Fkp
2343 failure
= pSt
->GetError();
2348 // Pointer auf Inhalts-Array
2349 pPLCF_Contents
= (BYTE
*)&pPLCF_PosArray
[nIMax
+ 1];
2350 BYTE
* p
= pPLCF_Contents
;
2352 for (INT32 i
= 0; i
< ncpN
; ++i
) // Baue PNs
2354 ShortToSVBT16(static_cast<sal_uInt16
>(nPN
+ i
), p
);
2359 ASSERT( !failure
, "Document has corrupt PLCF, ignoring it" );
2364 delete[] pPLCF_PosArray
;
2365 pPLCF_PosArray
= new INT32
[2];
2366 pPLCF_PosArray
[0] = pPLCF_PosArray
[1] = WW8_CP_MAX
;
2367 pPLCF_Contents
= (BYTE
*)&pPLCF_PosArray
[nIMax
+ 1];
2371 bool WW8PLCF::SeekPos(WW8_CP nPos
)
2375 if( nP
< pPLCF_PosArray
[0] )
2378 // Nicht gefunden: nPos unterhalb kleinstem Eintrag
2382 // Search from beginning?
2383 if( (1 > nIdx
) || (nP
< pPLCF_PosArray
[ nIdx
-1 ]) )
2386 INT32 nI
= nIdx
? nIdx
: 1;
2389 for(int n
= (1==nIdx
? 1 : 2); n
; --n
)
2391 for( ; nI
<=nEnd
; ++nI
) // Suchen mit um 1 erhoehtem Index
2393 if( nP
< pPLCF_PosArray
[nI
] ) // Position gefunden
2395 nIdx
= nI
- 1; // nI - 1 ist der richtige Index
2396 return true; // ... und fertig
2403 nIdx
= nIMax
; // Nicht gefunden, groesser als alle Eintraege
2407 bool WW8PLCF::Get(WW8_CP
& rStart
, WW8_CP
& rEnd
, void*& rpValue
) const
2409 if ( nIdx
>= nIMax
)
2411 rStart
= rEnd
= WW8_CP_MAX
;
2414 rStart
= pPLCF_PosArray
[ nIdx
];
2415 rEnd
= pPLCF_PosArray
[ nIdx
+ 1 ];
2416 rpValue
= (void*)&pPLCF_Contents
[nIdx
* nStru
];
2420 WW8_CP
WW8PLCF::Where() const
2422 if ( nIdx
>= nIMax
)
2425 return pPLCF_PosArray
[nIdx
];
2428 //-----------------------------------------
2430 //-----------------------------------------
2432 WW8PLCFpcd::WW8PLCFpcd( SvStream
* pSt
, long nFilePos
, long nPLCF
, long nStruct
)
2435 nIMax
= ( nPLCF
- 4 ) / ( 4 + nStruct
);
2436 pPLCF_PosArray
= new INT32
[ ( nPLCF
+ 3 ) / 4 ]; // Pointer auf Pos-Array
2438 long nOldPos
= pSt
->Tell();
2440 pSt
->Seek( nFilePos
);
2441 pSt
->Read( pPLCF_PosArray
, nPLCF
);
2442 #ifdef OSL_BIGENDIAN
2443 for( long nI
= 0; nI
<= nIMax
; nI
++ )
2444 pPLCF_PosArray
[nI
] = SWAPLONG( pPLCF_PosArray
[nI
] );
2445 #endif // OSL_BIGENDIAN
2447 // Pointer auf Inhalts-Array
2448 pPLCF_Contents
= (BYTE
*)&pPLCF_PosArray
[nIMax
+ 1];
2450 pSt
->Seek( nOldPos
);
2453 // Bei nStartPos < 0 wird das erste Element des PLCFs genommen
2454 WW8PLCFpcd_Iter::WW8PLCFpcd_Iter( WW8PLCFpcd
& rPLCFpcd
, long nStartPos
)
2455 :rPLCF( rPLCFpcd
), nIdx( 0 )
2457 if( nStartPos
>= 0 )
2458 SeekPos( nStartPos
);
2461 bool WW8PLCFpcd_Iter::SeekPos(long nPos
)
2465 if( nP
< rPLCF
.pPLCF_PosArray
[0] )
2468 return false; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
2470 // Search from beginning?
2471 if( (1 > nIdx
) || (nP
< rPLCF
.pPLCF_PosArray
[ nIdx
-1 ]) )
2474 long nI
= nIdx
? nIdx
: 1;
2475 long nEnd
= rPLCF
.nIMax
;
2477 for(int n
= (1==nIdx
? 1 : 2); n
; --n
)
2479 for( ; nI
<=nEnd
; ++nI
)
2480 { // Suchen mit um 1 erhoehtem Index
2481 if( nP
< rPLCF
.pPLCF_PosArray
[nI
] )
2482 { // Position gefunden
2483 nIdx
= nI
- 1; // nI - 1 ist der richtige Index
2484 return true; // ... und fertig
2490 nIdx
= rPLCF
.nIMax
; // Nicht gefunden, groesser als alle Eintraege
2494 bool WW8PLCFpcd_Iter::Get(WW8_CP
& rStart
, WW8_CP
& rEnd
, void*& rpValue
) const
2496 if( nIdx
>= rPLCF
.nIMax
)
2498 rStart
= rEnd
= WW8_CP_MAX
;
2501 rStart
= rPLCF
.pPLCF_PosArray
[nIdx
];
2502 rEnd
= rPLCF
.pPLCF_PosArray
[nIdx
+ 1];
2503 rpValue
= (void*)&rPLCF
.pPLCF_Contents
[nIdx
* rPLCF
.nStru
];
2507 INT32
WW8PLCFpcd_Iter::Where() const
2509 if ( nIdx
>= rPLCF
.nIMax
)
2510 return SAL_MAX_INT32
;
2512 return rPLCF
.pPLCF_PosArray
[nIdx
];
2515 //-----------------------------------------
2516 bool WW8PLCFx_Fc_FKP::WW8Fkp::Entry::operator<
2517 (const WW8PLCFx_Fc_FKP::WW8Fkp::Entry
& rSecond
) const
2519 return (mnFC
< rSecond
.mnFC
);
2522 bool IsReplaceAllSprm(USHORT nSpId
)
2524 return (0x6645 == nSpId
|| 0x6646 == nSpId
);
2527 bool IsExpandableSprm(USHORT nSpId
)
2529 return 0x646B == nSpId
;
2532 WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(ww::WordVersion eVersion
, SvStream
* pSt
,
2533 SvStream
* pDataSt
, long _nFilePos
, long nItemSiz
, ePLCFT ePl
,
2535 : nItemSize(nItemSiz
), nFilePos(_nFilePos
), mnIdx(0), ePLCF(ePl
),
2536 maSprmParser(eVersion
)
2538 long nOldPos
= pSt
->Tell();
2540 pSt
->Seek(nFilePos
);
2541 pSt
->Read(maRawData
, 512);
2542 mnIMax
= maRawData
[511];
2544 sal_uInt8
*pStart
= maRawData
;
2545 // Pointer to Offset-Location in maRawData
2546 sal_uInt8
* pOfs
= maRawData
+ (mnIMax
+ 1) * 4;
2548 for (mnIdx
= 0; mnIdx
< mnIMax
; ++mnIdx
)
2550 unsigned int nOfs
= (*(pOfs
+ mnIdx
* nItemSize
)) * 2;
2551 Entry
aEntry(Get_Long(pStart
));
2558 aEntry
.mnLen
= maRawData
[nOfs
];
2559 aEntry
.mpData
= maRawData
+ nOfs
+ 1;
2561 if (aEntry
.mnLen
&& eVersion
== ww::eWW2
)
2563 Word2CHPX aChpx
= ReadWord2Chpx(*pSt
, nFilePos
+ nOfs
+ 1, static_cast< sal_uInt8
>(aEntry
.mnLen
));
2564 std::vector
<BYTE
> aSprms
= ChpxToSprms(aChpx
);
2565 aEntry
.mnLen
= static_cast< sal_uInt16
>(aSprms
.size());
2568 aEntry
.mpData
= new sal_uInt8
[aEntry
.mnLen
];
2569 memcpy(aEntry
.mpData
, &(aSprms
[0]), aEntry
.mnLen
);
2570 aEntry
.mbMustDelete
= true;
2577 sal_uInt8 nDelta
= 0;
2579 aEntry
.mnLen
= maRawData
[nOfs
];
2580 if (IsEightPlus(eVersion
) && !aEntry
.mnLen
)
2582 aEntry
.mnLen
= maRawData
[nOfs
+1];
2588 //stylecode, std/istd
2589 if (eVersion
== ww::eWW2
)
2591 aEntry
.mnIStd
= *(maRawData
+nOfs
+1+nDelta
);
2592 aEntry
.mnLen
--; //style code
2593 aEntry
.mnLen
-=6; //PHE
2594 //skipi stc, len byte + 6 byte PHE
2595 aEntry
.mpData
= maRawData
+ nOfs
+ 8;
2599 aEntry
.mnIStd
= SVBT16ToShort(maRawData
+nOfs
+1+nDelta
);
2600 aEntry
.mnLen
-=2; //istd
2601 //skip istd, len byte + optional extra len byte
2602 aEntry
.mpData
= maRawData
+ nOfs
+ 3 + nDelta
;
2605 USHORT nSpId
= aEntry
.mnLen
? maSprmParser
.GetSprmId(aEntry
.mpData
) : 0;
2608 If we replace then we throw away the old data, if we
2609 are expanding, then we tack the old data onto the end
2612 bool bExpand
= IsExpandableSprm(nSpId
);
2613 if (IsReplaceAllSprm(nSpId
) || bExpand
)
2615 sal_uInt16 nOrigLen
= bExpand
? aEntry
.mnLen
: 0;
2616 sal_uInt8
*pOrigData
= bExpand
? aEntry
.mpData
: 0;
2618 UINT32 nCurr
= pDataSt
->Tell();
2620 UINT32 nPos
= SVBT32ToUInt32(aEntry
.mpData
+ 2);
2621 pDataSt
->Seek(nPos
);
2622 *pDataSt
>> aEntry
.mnLen
;
2624 new sal_uInt8
[aEntry
.mnLen
+ nOrigLen
];
2625 aEntry
.mbMustDelete
= true;
2626 pDataSt
->Read(aEntry
.mpData
, aEntry
.mnLen
);
2628 pDataSt
->Seek( nCurr
);
2632 memcpy(aEntry
.mpData
+ aEntry
.mnLen
,
2633 pOrigData
, nOrigLen
);
2634 aEntry
.mnLen
= aEntry
.mnLen
+ nOrigLen
;
2640 ASSERT(false, "sweet god, what have you done!");
2645 maEntries
.push_back(aEntry
);
2648 //one more FC than grrpl entries
2649 maEntries
.push_back(Entry(Get_Long(pStart
)));
2651 //#104773#, we expect them sorted, but it appears possible
2652 //for them to arive unsorted
2653 std::sort(maEntries
.begin(), maEntries
.end());
2663 WW8PLCFx_Fc_FKP::WW8Fkp::Entry::Entry(const Entry
&rEntry
)
2664 : mnFC(rEntry
.mnFC
), mnLen(rEntry
.mnLen
), mnIStd(rEntry
.mnIStd
),
2665 mbMustDelete(rEntry
.mbMustDelete
)
2669 mpData
= new sal_uInt8
[mnLen
];
2670 memcpy(mpData
, rEntry
.mpData
, mnLen
);
2673 mpData
= rEntry
.mpData
;
2676 WW8PLCFx_Fc_FKP::WW8Fkp::Entry
&
2677 WW8PLCFx_Fc_FKP::WW8Fkp::Entry::operator=(const Entry
&rEntry
)
2683 mnLen
= rEntry
.mnLen
;
2684 mnIStd
= rEntry
.mnIStd
;
2685 mbMustDelete
= rEntry
.mbMustDelete
;
2689 mpData
= new sal_uInt8
[mnLen
];
2690 memcpy(mpData
, rEntry
.mpData
, mnLen
);
2693 mpData
= rEntry
.mpData
;
2697 WW8PLCFx_Fc_FKP::WW8Fkp::Entry::~Entry()
2703 void WW8PLCFx_Fc_FKP::WW8Fkp::Reset(WW8_FC nFc
)
2710 bool WW8PLCFx_Fc_FKP::WW8Fkp::SeekPos(WW8_FC nFc
)
2712 if (nFc
< maEntries
[0].mnFC
)
2715 return false; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
2718 // Search from beginning?
2719 if ((1 > mnIdx
) || (nFc
< maEntries
[mnIdx
-1].mnFC
))
2722 sal_uInt8 nI
= mnIdx
? mnIdx
: 1;
2723 sal_uInt8 nEnd
= mnIMax
;
2725 for(sal_uInt8 n
= (1==mnIdx
? 1 : 2); n
; --n
)
2727 for( ; nI
<=nEnd
; ++nI
)
2728 { // Suchen mit um 1 erhoehtem Index
2729 if (nFc
< maEntries
[nI
].mnFC
)
2730 { // Position gefunden
2731 mnIdx
= nI
- 1; // nI - 1 ist der richtige Index
2732 return true; // ... und fertig
2738 mnIdx
= mnIMax
; // Nicht gefunden, groesser als alle Eintraege
2742 BYTE
* WW8PLCFx_Fc_FKP::WW8Fkp::Get(WW8_FC
& rStart
, WW8_FC
& rEnd
, sal_Int32
& rLen
)
2747 if (mnIdx
>= mnIMax
)
2749 rStart
= WW8_FC_MAX
;
2753 rStart
= maEntries
[mnIdx
].mnFC
;
2754 rEnd
= maEntries
[mnIdx
+ 1].mnFC
;
2756 BYTE
* pSprms
= GetLenAndIStdAndSprms( rLen
);
2760 bool WW8PLCFx_Fc_FKP::WW8Fkp::SetIdx(sal_uInt8 nI
)
2770 BYTE
* WW8PLCFx_Fc_FKP::WW8Fkp::GetLenAndIStdAndSprms(sal_Int32
& rLen
) const
2772 rLen
= maEntries
[mnIdx
].mnLen
;
2773 return maEntries
[mnIdx
].mpData
;
2776 const BYTE
* WW8PLCFx_Fc_FKP::WW8Fkp::HasSprm( USHORT nId
)
2778 if (mnIdx
>= mnIMax
)
2782 BYTE
* pSprms
= GetLenAndIStdAndSprms( nLen
);
2784 WW8SprmIter
aIter(pSprms
, nLen
, maSprmParser
);
2785 return aIter
.FindSprm(nId
);
2788 bool WW8PLCFx_Fc_FKP::WW8Fkp::HasSprm(USHORT nId
,
2789 std::vector
<const BYTE
*> &rResult
)
2791 if (mnIdx
>= mnIMax
)
2795 BYTE
* pSprms
= GetLenAndIStdAndSprms( nLen
);
2797 WW8SprmIter
aIter(pSprms
, nLen
, maSprmParser
);
2799 while(aIter
.GetSprms())
2801 if (aIter
.GetAktId() == nId
)
2802 rResult
.push_back(aIter
.GetAktParams());
2805 return !rResult
.empty();
2808 //-----------------------------------------
2809 void WW8PLCFx::GetSprms( WW8PLCFxDesc
* p
)
2811 ASSERT( !this, "Falsches GetSprms gerufen" );
2812 p
->nStartPos
= p
->nEndPos
= WW8_CP_MAX
;
2815 p
->bRealLineEnd
= false;
2819 long WW8PLCFx::GetNoSprms( WW8_CP
& rStart
, WW8_CP
& rEnd
, sal_Int32
& rLen
)
2821 ASSERT( !this, "Falsches GetNoSprms gerufen" );
2822 rStart
= rEnd
= WW8_CP_MAX
;
2827 // ...Idx2: Default: ignorieren
2828 ULONG
WW8PLCFx::GetIdx2() const
2833 void WW8PLCFx::SetIdx2(ULONG
)
2838 public std::unary_function
<const WW8PLCFx_Fc_FKP::WW8Fkp
*, bool>
2843 SamePos(long nPo
) : mnPo(nPo
) {};
2844 bool operator()(const WW8PLCFx_Fc_FKP::WW8Fkp
*pFkp
)
2845 {return mnPo
== pFkp
->GetFilePos();}
2848 //-----------------------------------------
2849 bool WW8PLCFx_Fc_FKP::NewFkp()
2851 WW8_CP nPLCFStart
, nPLCFEnd
;
2854 static const int WW8FkpSizeTabVer2
[ PLCF_END
] =
2856 1, 1, 0 /*, 0, 0, 0*/
2858 static const int WW8FkpSizeTabVer6
[ PLCF_END
] =
2860 1, 7, 0 /*, 0, 0, 0*/
2862 static const int WW8FkpSizeTabVer8
[ PLCF_END
] =
2864 1, 13, 0 /*, 0, 0, 0*/
2866 const int* pFkpSizeTab
;
2868 switch (GetFIBVersion())
2871 pFkpSizeTab
= WW8FkpSizeTabVer2
;
2875 pFkpSizeTab
= WW8FkpSizeTabVer6
;
2878 pFkpSizeTab
= WW8FkpSizeTabVer8
;
2882 ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
2886 if (!pPLCF
->Get( nPLCFStart
, nPLCFEnd
, pPage
))
2889 return false; // PLCF fertig abgearbeitet
2892 long nPo
= SVBT16ToShort( (BYTE
*)pPage
);
2893 nPo
<<= 9; // shift als LONG
2895 long nAktFkpFilePos
= pFkp
? pFkp
->GetFilePos() : -1;
2896 if (nAktFkpFilePos
== nPo
)
2897 pFkp
->Reset(GetStartFc()); // #79464# //
2901 std::find_if(maFkpCache
.begin(), maFkpCache
.end(), SamePos(nPo
));
2902 if (aIter
!= maFkpCache
.end())
2905 pFkp
->Reset(GetStartFc());
2907 else if (0 != (pFkp
= new WW8Fkp(GetFIBVersion(), pFKPStrm
, pDataStrm
, nPo
,
2908 pFkpSizeTab
[ ePLCF
], ePLCF
, GetStartFc())))
2910 maFkpCache
.push_back(pFkp
);
2912 if (maFkpCache
.size() > eMaxCache
)
2914 delete maFkpCache
.front();
2915 maFkpCache
.pop_front();
2920 SetStartFc( -1 ); // Nur das erste Mal
2924 WW8PLCFx_Fc_FKP::WW8PLCFx_Fc_FKP(SvStream
* pSt
, SvStream
* pTblSt
,
2925 SvStream
* pDataSt
, const WW8Fib
& rFib
, ePLCFT ePl
, WW8_FC nStartFcL
)
2926 : WW8PLCFx(rFib
.GetFIBVersion(), true), pFKPStrm(pSt
), pDataStrm(pDataSt
),
2927 pFkp(0), ePLCF(ePl
), pPCDAttrs(0)
2929 SetStartFc(nStartFcL
);
2930 long nLenStruct
= (8 > rFib
.nVersion
) ? 2 : 4;
2933 pPLCF
= new WW8PLCF(pTblSt
, rFib
.fcPlcfbteChpx
, rFib
.lcbPlcfbteChpx
,
2934 nLenStruct
, GetStartFc(), rFib
.pnChpFirst
, rFib
.cpnBteChp
);
2938 pPLCF
= new WW8PLCF(pTblSt
, rFib
.fcPlcfbtePapx
, rFib
.lcbPlcfbtePapx
,
2939 nLenStruct
, GetStartFc(), rFib
.pnPapFirst
, rFib
.cpnBtePap
);
2943 WW8PLCFx_Fc_FKP::~WW8PLCFx_Fc_FKP()
2945 myiter aEnd
= maFkpCache
.end();
2946 for (myiter aIter
= maFkpCache
.begin(); aIter
!= aEnd
; ++aIter
)
2952 ULONG
WW8PLCFx_Fc_FKP::GetIdx() const
2954 ULONG u
= pPLCF
->GetIdx() << 8;
2956 u
|= pFkp
->GetIdx();
2960 void WW8PLCFx_Fc_FKP::SetIdx( ULONG nIdx
)
2962 if( !( nIdx
& 0xffffff00L
) )
2964 pPLCF
->SetIdx( nIdx
>> 8 );
2968 { //Es gab einen Fkp
2969 //Lese PLCF um 1 Pos zurueck, um die Adresse des Fkp wiederzubekommen
2970 pPLCF
->SetIdx( ( nIdx
>> 8 ) - 1 );
2971 if (NewFkp()) // und lese Fkp wieder ein
2973 sal_uInt8 nFkpIdx
= static_cast<sal_uInt8
>(nIdx
& 0xff);
2974 pFkp
->SetIdx(nFkpIdx
); // Dann stelle Fkp-Pos wieder ein
2979 bool WW8PLCFx_Fc_FKP::SeekPos(WW8_FC nFcPos
)
2981 // StartPos for next Where()
2982 SetStartFc( nFcPos
);
2984 // find StartPos for next pPLCF->Get()
2985 bool bRet
= pPLCF
->SeekPos(nFcPos
);
2987 // make FKP invalid?
2988 WW8_CP nPLCFStart
, nPLCFEnd
;
2990 if( pFkp
&& pPLCF
->Get( nPLCFStart
, nPLCFEnd
, pPage
) )
2992 long nPo
= SVBT16ToShort( (BYTE
*)pPage
);
2993 nPo
<<= 9; // shift als LONG
2994 if (nPo
!= pFkp
->GetFilePos())
2997 pFkp
->SeekPos( nFcPos
);
3002 WW8_FC
WW8PLCFx_Fc_FKP::Where()
3009 WW8_FC nP
= pFkp
->Where();
3010 if( nP
!= WW8_FC_MAX
)
3013 pFkp
= 0; // FKP beendet -> hole neuen
3014 return Where(); // am einfachsten rekursiv
3017 BYTE
* WW8PLCFx_Fc_FKP::GetSprmsAndPos(WW8_FC
& rStart
, WW8_FC
& rEnd
, sal_Int32
& rLen
)
3019 rLen
= 0; // Default
3020 rStart
= rEnd
= WW8_FC_MAX
;
3022 if( !pFkp
) // Fkp not there ?
3028 BYTE
* pPos
= pFkp
->Get( rStart
, rEnd
, rLen
);
3029 if( rStart
== WW8_FC_MAX
) //Not found
3034 WW8PLCFx
& WW8PLCFx_Fc_FKP::operator ++( int )
3043 if( pFkp
->Where() == WW8_FC_MAX
)
3049 USHORT
WW8PLCFx_Fc_FKP::GetIstd() const
3051 return pFkp
? pFkp
->GetIstd() : 0xFFFF;
3054 void WW8PLCFx_Fc_FKP::GetPCDSprms( WW8PLCFxDesc
& rDesc
)
3057 rDesc
.nSprmsLen
= 0;
3063 "+Problem: GetPCDSprms: NewFkp necessay (not possible!)" );
3067 pPCDAttrs
->GetSprms(&rDesc
);
3071 const BYTE
* WW8PLCFx_Fc_FKP::HasSprm( USHORT nId
)
3073 // const waere schoener, aber dafuer muesste NewFkp() ersetzt werden oder
3077 DBG_WARNING( "+Motz: HasSprm: NewFkp noetig ( kein const moeglich )" );
3078 // Passiert bei BugDoc 31722
3083 const BYTE
* pRes
= pFkp
->HasSprm( nId
);
3088 GetPCDSprms( aDesc
);
3092 WW8SprmIter
aIter(aDesc
.pMemPos
, aDesc
.nSprmsLen
,
3093 pFkp
->GetSprmParser());
3094 pRes
= aIter
.FindSprm(nId
);
3101 bool WW8PLCFx_Fc_FKP::HasSprm(USHORT nId
, std::vector
<const BYTE
*> &rResult
)
3103 // const waere schoener, aber dafuer muesste NewFkp() ersetzt werden oder
3107 DBG_WARNING( "+Motz: HasSprm: NewFkp noetig ( kein const moeglich )" );
3108 // Passiert bei BugDoc 31722
3113 pFkp
->HasSprm(nId
, rResult
);
3116 GetPCDSprms( aDesc
);
3120 WW8SprmIter
aIter(aDesc
.pMemPos
, aDesc
.nSprmsLen
,
3121 pFkp
->GetSprmParser());
3122 while(aIter
.GetSprms())
3124 if (aIter
.GetAktId() == nId
)
3125 rResult
.push_back(aIter
.GetAktParams());
3129 return !rResult
.empty();
3132 //-----------------------------------------
3134 WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream
* pSt
, SvStream
* pTblSt
,
3135 SvStream
* pDataSt
, const WW8ScannerBase
& rBase
, ePLCFT ePl
)
3136 : WW8PLCFx_Fc_FKP(pSt
, pTblSt
, pDataSt
, *rBase
.pWw8Fib
, ePl
,
3137 rBase
.WW8Cp2Fc(0)), rSBase(rBase
), nAttrStart(-1), nAttrEnd(-1),
3139 bComplex( (7 < rBase
.pWw8Fib
->nVersion
) || (0 != rBase
.pWw8Fib
->fComplex
) )
3141 ResetAttrStartEnd();
3143 pPcd
= rSBase
.pPiecePLCF
? new WW8PLCFx_PCD(GetFIBVersion(),
3144 rBase
.pPiecePLCF
, 0, IsSevenMinus(GetFIBVersion())) : 0;
3147 Make a copy of the piece attributes for so that the calls to HasSprm on a
3148 Fc_FKP will be able to take into account the current piece attributes,
3149 despite the fact that such attributes can only be found through a cp based
3154 pPCDAttrs
= rSBase
.pPLCFx_PCDAttrs
? new WW8PLCFx_PCDAttrs(
3155 rSBase
.pWw8Fib
->GetFIBVersion(), pPcd
, &rSBase
) : 0;
3158 pPieceIter
= rSBase
.pPieceIter
;
3161 WW8PLCFx_Cp_FKP::~WW8PLCFx_Cp_FKP()
3166 void WW8PLCFx_Cp_FKP::ResetAttrStartEnd()
3173 ULONG
WW8PLCFx_Cp_FKP::GetPCDIMax() const
3175 return pPcd
? pPcd
->GetIMax() : 0;
3178 ULONG
WW8PLCFx_Cp_FKP::GetPCDIdx() const
3180 return pPcd
? pPcd
->GetIdx() : 0;
3183 void WW8PLCFx_Cp_FKP::SetPCDIdx( ULONG nIdx
)
3186 pPcd
->SetIdx( nIdx
);
3189 bool WW8PLCFx_Cp_FKP::SeekPos(WW8_CP nCpPos
)
3191 if( pPcd
) // Complex
3193 if( !pPcd
->SeekPos( nCpPos
) ) // Piece setzen
3195 if (pPCDAttrs
&& !pPCDAttrs
->GetIter()->SeekPos(nCpPos
))
3197 return WW8PLCFx_Fc_FKP::SeekPos(pPcd
->AktPieceStartCp2Fc(nCpPos
));
3199 // KEINE Piece-Table !!!
3200 return WW8PLCFx_Fc_FKP::SeekPos( rSBase
.WW8Cp2Fc(nCpPos
) );
3203 WW8_CP
WW8PLCFx_Cp_FKP::Where()
3205 WW8_FC nFc
= WW8PLCFx_Fc_FKP::Where();
3207 return pPcd
->AktPieceStartFc2Cp( nFc
); // Piece ermitteln
3208 return rSBase
.WW8Fc2Cp( nFc
); // KEINE Piece-Table !!!
3211 void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc
* p
)
3213 WW8_CP nOrigCp
= p
->nStartPos
;
3215 if (!GetDirty()) //Normal case
3217 p
->pMemPos
= WW8PLCFx_Fc_FKP::GetSprmsAndPos(p
->nStartPos
, p
->nEndPos
,
3224 For the odd case where we have a location in a fastsaved file which
3225 does not have an entry in the FKP, perhaps its para end is in the next
3226 piece, or perhaps the cp just doesn't exist at all in this document.
3227 AdvSprm doesn't know so it sets the PLCF as dirty and we figure out
3228 in this method what the situation is
3230 It doesn't exist then the piece iterator will not be able to find it.
3231 Otherwise our cool fastsave algorithm can be brought to bear on the
3234 ULONG nOldPos
= pPieceIter
->GetIdx();
3235 bool bOk
= pPieceIter
->SeekPos(nOrigCp
);
3236 pPieceIter
->SetIdx( nOldPos
);
3241 if( pPcd
) // Piece-Table vorhanden !!!
3243 // Init ( noch kein ++ gerufen )
3244 if( (nAttrStart
> nAttrEnd
) || (nAttrStart
== -1) )
3246 p
->bRealLineEnd
= (ePLCF
== PAP
);
3248 if ( ((ePLCF
== PAP
) || (ePLCF
== CHP
)) && (nOrigCp
!= WW8_CP_MAX
) )
3250 bool bIsUnicode
=false;
3252 To find the end of a paragraph for a character in a
3253 complex format file.
3255 It is necessary to know the piece that contains the
3256 character and the FC assigned to the character.
3259 //We set the piece iterator to the piece that contains the
3260 //character, now we have the correct piece for this character
3261 ULONG nOldPos
= pPieceIter
->GetIdx();
3262 p
->nStartPos
= nOrigCp
;
3263 pPieceIter
->SeekPos( p
->nStartPos
);
3265 //This is the FC assigned to the character, but we already
3266 //have the result of the next stage, so we can skip this step
3267 //WW8_FC nStartFc = rSBase.WW8Cp2Fc(p->nStartPos, &bIsUnicode);
3270 Using the FC of the character, first search the FKP that
3271 describes the character to find the smallest FC in the rgfc
3272 that is larger than the character FC.
3274 //But the search has already been done, the next largest FC is
3276 WW8_FC nOldEndPos
= p
->nEndPos
;
3279 If the FC found in the FKP is less than or equal to the limit
3280 FC of the piece, the end of the paragraph that contains the
3281 character is at the FKP FC minus 1.
3283 WW8_CP nCpStart
, nCpEnd
;
3285 pPieceIter
->Get(nCpStart
, nCpEnd
, pData
);
3287 WW8_FC nLimitFC
= SVBT32ToUInt32( ((WW8_PCD
*)pData
)->fc
);
3288 WW8_FC nBeginLimitFC
= nLimitFC
;
3289 if (IsEightPlus(GetFIBVersion()))
3292 WW8PLCFx_PCD::TransformPieceAddress(nLimitFC
,
3296 nLimitFC
= nBeginLimitFC
+
3297 (nCpEnd
- nCpStart
) * (bIsUnicode
? 2 : 1);
3299 if (nOldEndPos
<= nLimitFC
)
3301 p
->nEndPos
= nCpEnd
-
3302 (nLimitFC
-nOldEndPos
) / (bIsUnicode
? 2 : 1);
3307 p
->nEndPos
= nCpEnd
;
3311 If the FKP FC that was found was greater than the FC
3312 of the end of the piece, scan piece by piece toward
3313 the end of the document until a piece is found that
3314 contains a paragraph end mark.
3318 It's possible to check if a piece contains a paragraph
3319 mark by using the FC of the beginning of the piece to
3320 search in the FKPs for the smallest FC in the FKP rgfc
3321 that is greater than the FC of the beginning of the
3322 piece. If the FC found is less than or equal to the
3323 limit FC of the piece, then the character that ends
3324 the paragraph is the character immediately before the
3330 for (;pPieceIter
->GetIdx() < pPieceIter
->GetIMax();
3333 if( !pPieceIter
->Get( nCpStart
, nCpEnd
, pData
) )
3335 ASSERT( !this, "piece iter broken!" );
3339 INT32 nFcStart
=SVBT32ToUInt32(((WW8_PCD
*)pData
)->fc
);
3341 if (IsEightPlus(GetFIBVersion()))
3344 WW8PLCFx_PCD::TransformPieceAddress(
3345 nFcStart
,bIsUnicode
);
3348 nLimitFC
= nFcStart
+ (nCpEnd
- nCpStart
) *
3349 (bIsUnicode
? 2 : 1);
3351 //if it doesn't exist, skip it
3352 if (!SeekPos(nCpStart
))
3355 WW8_FC nOne
,nSmallest
;
3356 p
->pMemPos
= WW8PLCFx_Fc_FKP::GetSprmsAndPos(nOne
,
3357 nSmallest
, p
->nSprmsLen
);
3359 if (nSmallest
<= nLimitFC
)
3361 p
->nEndPos
= nCpEnd
-
3362 (nLimitFC
-nSmallest
) / (bIsUnicode
? 2 : 1);
3368 pPieceIter
->SetIdx( nOldPos
);
3371 pPcd
->AktPieceFc2Cp( p
->nStartPos
, p
->nEndPos
,&rSBase
);
3375 p
->nStartPos
= nAttrStart
;
3376 p
->nEndPos
= nAttrEnd
;
3377 p
->bRealLineEnd
= bLineEnd
;
3380 else // KEINE Piece-Table !!!
3382 p
->nStartPos
= rSBase
.WW8Fc2Cp( p
->nStartPos
);
3383 p
->nEndPos
= rSBase
.WW8Fc2Cp( p
->nEndPos
);
3384 p
->bRealLineEnd
= ePLCF
== PAP
;
3388 WW8PLCFx
& WW8PLCFx_Cp_FKP::operator ++( int )
3390 WW8PLCFx_Fc_FKP::operator ++( 0 );
3392 if ( !bComplex
|| !pPcd
)
3395 if( GetPCDIdx() >= GetPCDIMax() ) // End of PLCF
3397 nAttrStart
= nAttrEnd
= WW8_CP_MAX
;
3401 sal_Int32 nFkpLen
; // Fkp-Eintrag
3402 // Fkp-Eintrag holen
3403 WW8PLCFx_Fc_FKP::GetSprmsAndPos(nAttrStart
, nAttrEnd
, nFkpLen
);
3405 pPcd
->AktPieceFc2Cp( nAttrStart
, nAttrEnd
, &rSBase
);
3406 bLineEnd
= (ePLCF
== PAP
);
3410 //-----------------------------------------
3411 //-----------------------------------------
3413 WW8PLCFx_SEPX::WW8PLCFx_SEPX(SvStream
* pSt
, SvStream
* pTblSt
,
3414 const WW8Fib
& rFib
, WW8_CP nStartCp
)
3415 : WW8PLCFx(rFib
.GetFIBVersion(), true), maSprmParser(rFib
.GetFIBVersion()),
3416 pStrm(pSt
), nArrMax(256), nSprmSiz(0)
3418 pPLCF
= rFib
.lcbPlcfsed
3419 ? new WW8PLCF(pTblSt
, rFib
.fcPlcfsed
, rFib
.lcbPlcfsed
,
3420 GetFIBVersion() <= ww::eWW2
? 6 : 12, nStartCp
)
3423 pSprms
= new BYTE
[nArrMax
]; // maximum length
3426 WW8PLCFx_SEPX::~WW8PLCFx_SEPX()
3432 ULONG
WW8PLCFx_SEPX::GetIdx() const
3434 return pPLCF
? pPLCF
->GetIdx() : 0;
3437 void WW8PLCFx_SEPX::SetIdx( ULONG nIdx
)
3439 if( pPLCF
) pPLCF
->SetIdx( nIdx
);
3442 bool WW8PLCFx_SEPX::SeekPos(WW8_CP nCpPos
)
3444 return pPLCF
? pPLCF
->SeekPos( nCpPos
) : 0;
3447 WW8_CP
WW8PLCFx_SEPX::Where()
3449 return pPLCF
? pPLCF
->Where() : 0;
3452 void WW8PLCFx_SEPX::GetSprms(WW8PLCFxDesc
* p
)
3454 if( !pPLCF
) return;
3458 p
->bRealLineEnd
= false;
3459 if (!pPLCF
->Get( p
->nStartPos
, p
->nEndPos
, pData
))
3461 p
->nStartPos
= p
->nEndPos
= WW8_CP_MAX
; // PLCF fertig abgearbeitet
3467 sal_uInt32 nPo
= SVBT32ToUInt32( (BYTE
*)pData
+2 );
3468 if (nPo
== 0xFFFFFFFF)
3470 p
->nStartPos
= p
->nEndPos
= WW8_CP_MAX
; // Sepx empty
3479 if (GetFIBVersion() <= ww::eWW2
) // eWW6 ?, docs say yes, but...
3488 if( nSprmSiz
> nArrMax
)
3491 nArrMax
= nSprmSiz
; // Hole mehr Speicher
3492 pSprms
= new BYTE
[nArrMax
];
3494 pStrm
->Read( pSprms
, nSprmSiz
); // read Sprms
3496 p
->nSprmsLen
= nSprmSiz
;
3497 p
->pMemPos
= pSprms
; // return Position
3502 WW8PLCFx
& WW8PLCFx_SEPX::operator ++( int )
3509 const BYTE
* WW8PLCFx_SEPX::HasSprm( USHORT nId
) const
3511 return HasSprm( nId
, pSprms
, nSprmSiz
);
3514 const BYTE
* WW8PLCFx_SEPX::HasSprm( USHORT nId
, const BYTE
* pOtherSprms
,
3515 long nOtherSprmSiz
) const
3517 const BYTE
*pRet
= 0;
3520 WW8SprmIter
aIter(pOtherSprms
, nOtherSprmSiz
, maSprmParser
);
3521 pRet
= aIter
.FindSprm(nId
);
3526 bool WW8PLCFx_SEPX::Find4Sprms(USHORT nId1
,USHORT nId2
,USHORT nId3
,USHORT nId4
,
3527 BYTE
*& p1
, BYTE
*& p2
, BYTE
*& p3
, BYTE
*& p4
) const
3532 bool bFound
= false;
3540 while (i
+ maSprmParser
.MinSprmLen() <= nSprmSiz
)
3543 USHORT nAktId
= maSprmParser
.GetSprmId(pSp
);
3545 if( nAktId
== nId1
)
3546 p1
= pSp
+ maSprmParser
.DistanceToData(nId1
);
3547 else if( nAktId
== nId2
)
3548 p2
= pSp
+ maSprmParser
.DistanceToData(nId2
);
3549 else if( nAktId
== nId3
)
3550 p3
= pSp
+ maSprmParser
.DistanceToData(nId3
);
3551 else if( nAktId
== nId4
)
3552 p4
= pSp
+ maSprmParser
.DistanceToData(nId4
);
3556 // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
3557 USHORT x
= maSprmParser
.GetSprmSize(nAktId
, pSp
);
3564 const BYTE
* WW8PLCFx_SEPX::HasSprm( USHORT nId
, BYTE n2nd
) const
3572 while (i
+ maSprmParser
.MinSprmLen() <= nSprmSiz
)
3575 USHORT nAktId
= maSprmParser
.GetSprmId(pSp
);
3578 BYTE
*pRet
= pSp
+ maSprmParser
.DistanceToData(nId
);
3582 // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
3583 USHORT x
= maSprmParser
.GetSprmSize(nAktId
, pSp
);
3588 return 0; // Sprm nicht gefunden
3591 //-----------------------------------------
3592 WW8PLCFx_SubDoc::WW8PLCFx_SubDoc(SvStream
* pSt
, ww::WordVersion eVersion
,
3593 WW8_CP nStartCp
, long nFcRef
, long nLenRef
, long nFcTxt
, long nLenTxt
,
3595 : WW8PLCFx(eVersion
, true), pRef(0), pTxt(0)
3597 if( nLenRef
&& nLenTxt
)
3599 pRef
= new WW8PLCF( pSt
, nFcRef
, nLenRef
, nStruct
, nStartCp
);
3600 pTxt
= new WW8PLCF( pSt
, nFcTxt
, nLenTxt
, 0, nStartCp
);
3604 WW8PLCFx_SubDoc::~WW8PLCFx_SubDoc()
3610 ULONG
WW8PLCFx_SubDoc::GetIdx() const
3612 // Wahrscheinlich pTxt... nicht noetig
3614 return ( pRef
->GetIdx() << 16 | pTxt
->GetIdx() );
3618 void WW8PLCFx_SubDoc::SetIdx( ULONG nIdx
)
3622 pRef
->SetIdx( nIdx
>> 16 );
3623 // Wahrscheinlich pTxt... nicht noetig
3624 pTxt
->SetIdx( nIdx
& 0xFFFF );
3628 bool WW8PLCFx_SubDoc::SeekPos( WW8_CP nCpPos
)
3630 return ( pRef
) ? pRef
->SeekPos( nCpPos
) : false;
3633 WW8_CP
WW8PLCFx_SubDoc::Where()
3635 return ( pRef
) ? pRef
->Where() : WW8_CP_MAX
;
3638 void WW8PLCFx_SubDoc::GetSprms(WW8PLCFxDesc
* p
)
3640 p
->nStartPos
= p
->nEndPos
= WW8_CP_MAX
;
3643 p
->bRealLineEnd
= false;
3648 ULONG nNr
= pRef
->GetIdx();
3652 if (!pRef
->Get(p
->nStartPos
, nFoo
, pData
))
3654 p
->nEndPos
= p
->nStartPos
= WW8_CP_MAX
;
3658 p
->nEndPos
= p
->nStartPos
+ 1;
3665 if (!pTxt
->Get(p
->nCp2OrIdx
, p
->nSprmsLen
, pData
))
3667 p
->nEndPos
= p
->nStartPos
= WW8_CP_MAX
;
3672 p
->nSprmsLen
-= p
->nCp2OrIdx
;
3675 WW8PLCFx
& WW8PLCFx_SubDoc::operator ++( int )
3685 //-----------------------------------------
3687 //-----------------------------------------
3689 WW8PLCFx_FLD::WW8PLCFx_FLD( SvStream
* pSt
, const WW8Fib
& rMyFib
, short nType
)
3690 : WW8PLCFx(rMyFib
.GetFIBVersion(), true), pPLCF(0), rFib(rMyFib
)
3697 nFc
= rFib
.fcPlcffldHdr
;
3698 nLen
= rFib
.lcbPlcffldHdr
;
3701 nFc
= rFib
.fcPlcffldFtn
;
3702 nLen
= rFib
.lcbPlcffldFtn
;
3705 nFc
= rFib
.fcPlcffldEdn
;
3706 nLen
= rFib
.lcbPlcffldEdn
;
3709 nFc
= rFib
.fcPlcffldAtn
;
3710 nLen
= rFib
.lcbPlcffldAtn
;
3713 nFc
= rFib
.fcPlcffldTxbx
;
3714 nLen
= rFib
.lcbPlcffldTxbx
;
3717 nFc
= rFib
.fcPlcffldHdrTxbx
;
3718 nLen
= rFib
.lcbPlcffldHdrTxbx
;
3721 nFc
= rFib
.fcPlcffldMom
;
3722 nLen
= rFib
.lcbPlcffldMom
;
3727 pPLCF
= new WW8PLCFspecial( pSt
, nFc
, nLen
, 2 );
3730 WW8PLCFx_FLD::~WW8PLCFx_FLD()
3735 ULONG
WW8PLCFx_FLD::GetIdx() const
3737 return pPLCF
? pPLCF
->GetIdx() : 0;
3740 void WW8PLCFx_FLD::SetIdx( ULONG nIdx
)
3743 pPLCF
->SetIdx( nIdx
);
3746 bool WW8PLCFx_FLD::SeekPos(WW8_CP nCpPos
)
3748 return pPLCF
? pPLCF
->SeekPosExact( nCpPos
) : false;
3751 WW8_CP
WW8PLCFx_FLD::Where()
3753 return pPLCF
? pPLCF
->Where() : WW8_CP_MAX
;
3756 bool WW8PLCFx_FLD::StartPosIsFieldStart()
3761 (!pPLCF
|| !pPLCF
->Get(nTest
, pData
) ||
3762 ((((BYTE
*)pData
)[0] & 0x1f) != 0x13))
3768 bool WW8PLCFx_FLD::EndPosIsFieldEnd()
3774 long n
= pPLCF
->GetIdx();
3780 if ( pPLCF
->Get(nTest
, pData
) && ((((BYTE
*)pData
)[0] & 0x1f) == 0x15) )
3789 void WW8PLCFx_FLD::GetSprms(WW8PLCFxDesc
* p
)
3791 p
->nStartPos
= p
->nEndPos
= WW8_CP_MAX
;
3794 p
->bRealLineEnd
= false;
3798 p
->nStartPos
= WW8_CP_MAX
; // Es gibt keine Felder
3802 long n
= pPLCF
->GetIdx();
3806 if (!pPLCF
->Get(nP
, pData
)) // Ende des PLCFspecial ?
3808 p
->nStartPos
= WW8_CP_MAX
; // PLCF fertig abgearbeitet
3815 if (!pPLCF
->Get(nP
, pData
)) // Ende des PLCFspecial ?
3817 p
->nStartPos
= WW8_CP_MAX
; // PLCF fertig abgearbeitet
3825 p
->nCp2OrIdx
= pPLCF
->GetIdx();
3828 WW8PLCFx
& WW8PLCFx_FLD::operator ++( int )
3834 bool WW8PLCFx_FLD::GetPara(long nIdx
, WW8FieldDesc
& rF
)
3836 ASSERT( pPLCF
, "Aufruf ohne Feld PLCFspecial" );
3840 long n
= pPLCF
->GetIdx();
3841 pPLCF
->SetIdx(nIdx
);
3843 bool bOk
= WW8GetFieldPara(*pPLCF
, rF
);
3849 //-----------------------------------------
3850 // class WW8PLCF_Book
3851 //-----------------------------------------
3853 /* to be optimized like this: */
3854 void WW8ReadSTTBF(bool bVer8
, SvStream
& rStrm
, UINT32 nStart
, INT32 nLen
,
3855 USHORT nExtraLen
, rtl_TextEncoding eCS
, std::vector
<String
> &rArray
,
3856 std::vector
<ww::bytes
>* pExtraArray
, ::std::vector
<String
>* pValueArray
)
3858 if(nLen
==0) // Handle Empty STTBF
3861 ULONG nOldPos
= rStrm
.Tell();
3862 rStrm
.Seek( nStart
);
3865 rStrm
>> nLen2
; // bVer67: total length of structure
3866 // bVer8 : count of strings
3871 bool bUnicode
= (0xFFFF == nLen2
);
3879 for( USHORT i
=0; i
< nStrings
; i
++ )
3882 rArray
.push_back(WW8Read_xstz(rStrm
, 0, false));
3888 SafeReadString(aTmp
,nBChar
,rStrm
);
3889 rArray
.push_back(String(aTmp
, eCS
));
3892 // Skip the extra data
3897 ww::bytes extraData
;
3899 for(int j
= 0; j
< nExtraLen
; ++j
)
3902 extraData
.push_back(iTmp
);
3904 pExtraArray
->push_back(extraData
);
3907 rStrm
.SeekRel( nExtraLen
);
3910 // #129053# read the value of the document variables, if requested.
3913 for( USHORT i
=0; i
< nStrings
; i
++ )
3916 pValueArray
->push_back(WW8Read_xstz(rStrm
, 0, false));
3922 SafeReadString(aTmp
,nBChar
,rStrm
);
3923 pValueArray
->push_back(String(aTmp
, eCS
));
3933 ASSERT( nLen2
== nLen
, "Fib length and read length are different" );
3934 if (nLen
> USHRT_MAX
)
3938 nLen2
= static_cast<UINT16
>(nLen
);
3941 for( nLen2
-= 2; nRead
< nLen2
; )
3943 rStrm
>> nBChar
; ++nRead
;
3947 nRead
+= SafeReadString(aTmp
,nBChar
,rStrm
);
3948 rArray
.push_back(String(aTmp
, eCS
));
3951 rArray
.push_back(aEmptyStr
);
3953 // #89125# Skip the extra data (for bVer67 versions this must come
3954 // from external knowledge)
3959 ww::bytes extraData
;
3960 for(int i
=0;i
< nExtraLen
;i
++)
3964 extraData
.push_back(iTmp
);
3966 pExtraArray
->push_back(extraData
);
3969 rStrm
.SeekRel( nExtraLen
);
3974 rStrm
.Seek( nOldPos
);
3977 WW8PLCFx_Book::WW8PLCFx_Book(SvStream
* pTblSt
, const WW8Fib
& rFib
)
3978 : WW8PLCFx(rFib
.GetFIBVersion(), false), pStatus(0), nIsEnd(0), nBookmarkId(1)
3980 if( !rFib
.fcPlcfbkf
|| !rFib
.lcbPlcfbkf
|| !rFib
.fcPlcfbkl
||
3981 !rFib
.lcbPlcfbkl
|| !rFib
.fcSttbfbkmk
|| !rFib
.lcbSttbfbkmk
)
3983 pBook
[0] = pBook
[1] = 0;
3988 pBook
[0] = new WW8PLCFspecial(pTblSt
,rFib
.fcPlcfbkf
,rFib
.lcbPlcfbkf
,4);
3990 pBook
[1] = new WW8PLCFspecial( pTblSt
, rFib
.fcPlcfbkl
, rFib
.lcbPlcfbkl
,
3993 rtl_TextEncoding eStructChrSet
= WW8Fib::GetFIBCharset(rFib
.chseTables
);
3995 WW8ReadSTTBF( (7 < rFib
.nVersion
), *pTblSt
, rFib
.fcSttbfbkmk
,
3996 rFib
.lcbSttbfbkmk
, 0, eStructChrSet
, aBookNames
);
3998 nIMax
= aBookNames
.size();
4000 if( pBook
[0]->GetIMax() < nIMax
) // Count of Bookmarks
4001 nIMax
= pBook
[0]->GetIMax();
4002 if( pBook
[1]->GetIMax() < nIMax
)
4003 nIMax
= pBook
[1]->GetIMax();
4004 pStatus
= new eBookStatus
[ nIMax
];
4005 memset( pStatus
, 0, nIMax
* sizeof( eBookStatus
) );
4009 WW8PLCFx_Book::~WW8PLCFx_Book()
4016 ULONG
WW8PLCFx_Book::GetIdx() const
4018 return nIMax
? pBook
[0]->GetIdx() : 0;
4021 void WW8PLCFx_Book::SetIdx( ULONG nI
)
4024 pBook
[0]->SetIdx( nI
);
4027 ULONG
WW8PLCFx_Book::GetIdx2() const
4029 return nIMax
? ( pBook
[1]->GetIdx() | ( ( nIsEnd
) ? 0x80000000 : 0 ) ) : 0;
4032 void WW8PLCFx_Book::SetIdx2( ULONG nI
)
4036 pBook
[1]->SetIdx( nI
& 0x7fffffff );
4037 nIsEnd
= (USHORT
)( ( nI
>> 31 ) & 1 ); // 0 oder 1
4041 bool WW8PLCFx_Book::SeekPos(WW8_CP nCpPos
)
4046 bool bOk
= pBook
[0]->SeekPosExact( nCpPos
);
4047 bOk
&= pBook
[1]->SeekPosExact( nCpPos
);
4053 WW8_CP
WW8PLCFx_Book::Where()
4055 return pBook
[nIsEnd
]->Where();
4058 long WW8PLCFx_Book::GetNoSprms( WW8_CP
& rStart
, WW8_CP
& rEnd
, sal_Int32
& rLen
)
4064 if (!pBook
[0] || !pBook
[1] || !nIMax
|| (pBook
[nIsEnd
]->GetIdx()) >= nIMax
)
4066 rStart
= rEnd
= WW8_CP_MAX
;
4070 pBook
[nIsEnd
]->Get( rStart
, pData
); // Pos. abfragen
4072 return pBook
[nIsEnd
]->GetIdx();
4075 // Der Operator ++ hat eine Tuecke: Wenn 2 Bookmarks aneinandergrenzen, dann
4076 // sollte erst das Ende des ersten und dann der Anfang des 2. erreicht werden.
4077 // Liegen jedoch 2 Bookmarks der Laenge 0 aufeinander, *muss* von jedem Bookmark
4078 // erst der Anfang und dann das Ende gefunden werden.
4082 // ist noch nicht geloest, dabei muesste ich in den Anfangs- und Endindices
4083 // vor- und zurueckspringen, wobei ein weiterer Index oder ein Bitfeld
4084 // oder etwas aehnliches zum Merken der bereits abgearbeiteten Bookmarks
4086 WW8PLCFx
& WW8PLCFx_Book::operator ++( int )
4088 if( pBook
[0] && pBook
[1] && nIMax
)
4092 ULONG l0
= pBook
[0]->Where();
4093 ULONG l1
= pBook
[1]->Where();
4099 nIsEnd
= ( nIsEnd
) ? 0 : 1;
4104 long WW8PLCFx_Book::GetLen() const
4108 ASSERT( !this, "Falscher Aufruf (1) von PLCF_Book::GetLen()" );
4113 if( !pBook
[0]->Get( nStartPos
, p
) )
4115 ASSERT( !this, "Falscher Aufruf (2) von PLCF_Book::GetLen()" );
4118 USHORT nEndIdx
= SVBT16ToShort( *((SVBT16
*)p
) );
4119 long nNum
= pBook
[1]->GetPos( nEndIdx
);
4124 void WW8PLCFx_Book::SetStatus(USHORT nIndex
, eBookStatus eStat
)
4126 ASSERT(nIndex
< nIMax
, "set status of non existing bookmark!");
4127 pStatus
[nIndex
] = (eBookStatus
)( pStatus
[nIndex
] | eStat
);
4130 eBookStatus
WW8PLCFx_Book::GetStatus() const
4134 long nEndIdx
= GetHandle();
4135 return ( nEndIdx
< nIMax
) ? pStatus
[nEndIdx
] : BOOK_NORMAL
;
4138 long WW8PLCFx_Book::GetHandle() const
4140 if( !pBook
[0] || !pBook
[1] )
4144 return pBook
[1]->GetIdx();
4147 if (const void* p
= pBook
[0]->GetData(pBook
[0]->GetIdx()))
4148 return SVBT16ToShort( *((SVBT16
*)p
) );
4154 String
WW8PLCFx_Book::GetBookmark(long nStart
,long nEnd
, USHORT
&nIndex
)
4156 bool bFound
= false;
4158 if( pBook
[0] && pBook
[1] )
4160 WW8_CP nStartAkt
, nEndAkt
;
4166 if( pBook
[0]->GetData( i
, nStartAkt
, p
) && p
)
4167 nEndIdx
= SVBT16ToShort( *((SVBT16
*)p
) );
4170 ASSERT( !this, "Bookmark-EndIdx nicht lesbar" );
4174 nEndAkt
= pBook
[1]->GetPos( nEndIdx
);
4176 if ((nStartAkt
>= nStart
) && (nEndAkt
<= nEnd
))
4184 while (i
< pBook
[0]->GetIMax());
4186 return bFound
? aBookNames
[i
] : aEmptyStr
;
4189 String
WW8PLCFx_Book::GetUniqueBookmarkName(String
&suggestedName
)
4191 String aRet
=(suggestedName
.Len()==0?String::CreateFromAscii("Unnamed"):suggestedName
);
4193 while(i
<aBookNames
.size()) {
4194 String
&s
=aBookNames
[i
];
4195 if (aRet
.CompareTo(s
)==0) {
4198 while(p
>0 && aRet
.GetChar(static_cast<USHORT
>(p
))>='0' && aRet
.GetChar(static_cast<USHORT
>(p
))<='9')
4200 aRet
=String(aRet
, 0, static_cast<USHORT
>(p
+1));
4201 aRet
+= String::CreateFromInt32( nBookmarkId
++ );
4202 i
=0; // start search from beginning
4210 bool WW8PLCFx_Book::MapName(String
& rName
)
4212 if( !pBook
[0] || !pBook
[1] )
4215 bool bFound
= false;
4217 WW8_CP nStartAkt
, nEndAkt
;
4223 if( pBook
[0]->GetData( i
, nStartAkt
, p
) && p
)
4224 nEndIdx
= SVBT16ToShort( *((SVBT16
*)p
) );
4227 ASSERT( !this, "Bookmark-EndIdx nicht lesbar" );
4230 nEndAkt
= pBook
[1]->GetPos( nEndIdx
);
4231 if (COMPARE_EQUAL
== rName
.CompareIgnoreCaseToAscii(aBookNames
[i
]))
4233 rName
= aBookNames
[i
];
4238 while (!bFound
&& i
< pBook
[0]->GetIMax());
4242 const String
* WW8PLCFx_Book::GetName() const
4244 const String
*pRet
= 0;
4245 if (!nIsEnd
&& (pBook
[0]->GetIdx() < nIMax
))
4246 pRet
= &(aBookNames
[pBook
[0]->GetIdx()]);
4250 //-----------------------------------------
4252 //-----------------------------------------
4256 // Am Ende eines Absatzes reichen bei WW6 die Attribute bis hinter das <CR>.
4257 // Das wird fuer die Verwendung mit dem SW um 1 Zeichen zurueckgesetzt, wenn
4258 // dadurch kein AErger zu erwarten ist.
4259 void WW8PLCFMan::AdjustEnds( WW8PLCFxDesc
& rDesc
)
4261 //Store old end position for supercool new property finder that uses
4262 //cp instead of fc's as nature intended
4263 rDesc
.nOrigEndPos
= rDesc
.nEndPos
;
4264 rDesc
.nOrigStartPos
= rDesc
.nStartPos
;
4267 Normally given ^XXX{para end}^ we don't actually insert a para end
4268 character into the document, so we clip the para end property one to the
4269 left to make the para properties end when the paragraph text does. In a
4270 drawing textbox we actually do insert a para end character, so we don't
4271 clip it. Making the para end properties end after the para end char.
4273 if (GetDoingDrawTextBox())
4276 if ( (&rDesc
== pPap
) && rDesc
.bRealLineEnd
)
4278 if ( pPap
->nEndPos
!= WW8_CP_MAX
) // Para adjust
4280 nLineEnd
= pPap
->nEndPos
;// nLineEnd zeigt *hinter* das <CR>
4281 pPap
->nEndPos
--; // Absatzende um 1 Zeichen verkuerzen
4283 // gibt es bereits ein CharAttr-Ende das auf das jetzige
4284 // Absatzende zeigt ? ... dann auch um 1 Zeichen verkuerzen
4285 if (pChp
->nEndPos
== nLineEnd
)
4288 // gibt es bereits ein Sep-Ende, das auf das jetzige Absatzende
4289 // zeigt ? ... dann auch um 1 Zeichen verkuerzen
4290 if( pSep
->nEndPos
== nLineEnd
)
4294 else if ( (&rDesc
== pChp
) || (&rDesc
== pSep
) )
4296 // Char Adjust oder Sep Adjust Wenn Ende Char-Attr == Absatzende ...
4297 if( (rDesc
.nEndPos
== nLineEnd
) && (rDesc
.nEndPos
> rDesc
.nStartPos
) )
4298 rDesc
.nEndPos
--; // ... dann um 1 Zeichen verkuerzen
4302 void WW8PLCFxDesc::ReduceByOffset()
4304 ASSERT((WW8_CP_MAX
== nStartPos
) || (nStartPos
<= nEndPos
),
4305 "Attr-Anfang und -Ende ueber Kreuz" );
4307 if( nStartPos
!= WW8_CP_MAX
)
4311 Force the property change to happen at the beginning of this
4312 subdocument, same as in GetNewNoSprms, except that the target type is
4313 attributes attached to a piece that might span subdocument boundaries
4315 if (nCpOfs
> nStartPos
)
4318 nStartPos
-= nCpOfs
;
4320 if( nEndPos
!= WW8_CP_MAX
)
4322 ASSERT(nCpOfs
<= nEndPos
,
4323 "oh oh, so much for the subdocument piece theory");
4328 void WW8PLCFMan::GetNewSprms( WW8PLCFxDesc
& rDesc
)
4330 rDesc
.pPLCFx
->GetSprms(&rDesc
);
4331 rDesc
.ReduceByOffset();
4333 rDesc
.bFirstSprm
= true;
4334 AdjustEnds( rDesc
);
4335 rDesc
.nOrigSprmsLen
= rDesc
.nSprmsLen
;
4338 void WW8PLCFMan::GetNewNoSprms( WW8PLCFxDesc
& rDesc
)
4340 rDesc
.nCp2OrIdx
= rDesc
.pPLCFx
->GetNoSprms(rDesc
.nStartPos
, rDesc
.nEndPos
,
4343 ASSERT((WW8_CP_MAX
== rDesc
.nStartPos
) || (rDesc
.nStartPos
<= rDesc
.nEndPos
),
4344 "Attr-Anfang und -Ende ueber Kreuz" );
4346 rDesc
.ReduceByOffset();
4348 rDesc
.bFirstSprm
= true;
4349 rDesc
.nOrigSprmsLen
= rDesc
.nSprmsLen
;
4352 USHORT
WW8PLCFMan::GetId(const WW8PLCFxDesc
* p
) const
4364 else if (p
->nSprmsLen
> 0)
4365 nId
= maSprmParser
.GetSprmId(p
->pMemPos
);
4367 nId
= 0; // Id = 0 for empty attributes
4372 WW8PLCFMan::WW8PLCFMan(WW8ScannerBase
* pBase
, ManTypes nType
, long nStartCp
,
4373 bool bDoingDrawTextBox
)
4374 : maSprmParser(pBase
->pWw8Fib
->GetFIBVersion()),
4375 mbDoingDrawTextBox(bDoingDrawTextBox
)
4377 pWwFib
= pBase
->pWw8Fib
;
4379 nLastWhereIdxCp
= 0;
4380 memset( aD
, 0, sizeof( aD
) );
4381 nLineEnd
= WW8_CP_MAX
;
4385 if( MAN_MAINTEXT
== nType
)
4387 // Suchreihenfolge der Attribute
4388 nPLCF
= MAN_ANZ_PLCF
;
4395 pPcd
= ( pBase
->pPLCFx_PCD
) ? &aD
[4] : 0;
4396 //pPcdA index == pPcd index + 1
4397 pPcdA
= ( pBase
->pPLCFx_PCDAttrs
) ? &aD
[5] : 0;
4402 pSep
->pPLCFx
= pBase
->pSepPLCF
;
4403 pFtn
->pPLCFx
= pBase
->pFtnPLCF
;
4404 pEdn
->pPLCFx
= pBase
->pEdnPLCF
;
4405 pBkm
->pPLCFx
= pBase
->pBook
;
4406 pAnd
->pPLCFx
= pBase
->pAndPLCF
;
4411 // Suchreihenfolge der Attribute
4414 pBkm
= ( pBase
->pBook
) ? &aD
[1] : 0;
4416 pPcd
= ( pBase
->pPLCFx_PCD
) ? &aD
[2] : 0;
4417 //pPcdA index == pPcd index + 1
4418 pPcdA
= ( pBase
->pPLCFx_PCDAttrs
) ? &aD
[3] : 0;
4422 pSep
= &aD
[6]; // Dummy
4424 pAnd
= pFtn
= pEdn
= 0; // unbenutzt bei SpezText
4427 pChp
->pPLCFx
= pBase
->pChpPLCF
;
4428 pPap
->pPLCFx
= pBase
->pPapPLCF
;
4430 pPcd
->pPLCFx
= pBase
->pPLCFx_PCD
;
4432 pPcdA
->pPLCFx
= pBase
->pPLCFx_PCDAttrs
;
4434 pBkm
->pPLCFx
= pBase
->pBook
;
4436 pMagicTables
= pBase
->pMagicTables
;
4437 pSubdocs
= pBase
->pSubdocs
;
4438 pExtendedAtrds
= pBase
->pExtendedAtrds
;
4440 switch( nType
) // Feld-Initialisierung
4443 pFld
->pPLCFx
= pBase
->pFldHdFtPLCF
;
4444 pFdoa
= pBase
->pHdFtFdoa
;
4445 pTxbx
= pBase
->pHdFtTxbx
;
4446 pTxbxBkd
= pBase
->pHdFtTxbxBkd
;
4449 pFld
->pPLCFx
= pBase
->pFldFtnPLCF
;
4450 pFdoa
= pTxbx
= pTxbxBkd
= 0;
4453 pFld
->pPLCFx
= pBase
->pFldEdnPLCF
;
4454 pFdoa
= pTxbx
= pTxbxBkd
= 0;
4457 pFld
->pPLCFx
= pBase
->pFldAndPLCF
;
4458 pFdoa
= pTxbx
= pTxbxBkd
= 0;
4461 pFld
->pPLCFx
= pBase
->pFldTxbxPLCF
;
4462 pTxbx
= pBase
->pMainTxbx
;
4463 pTxbxBkd
= pBase
->pMainTxbxBkd
;
4467 pFld
->pPLCFx
= pBase
->pFldTxbxHdFtPLCF
;
4468 pTxbx
= pBase
->pHdFtTxbx
;
4469 pTxbxBkd
= pBase
->pHdFtTxbxBkd
;
4473 pFld
->pPLCFx
= pBase
->pFldPLCF
;
4474 pFdoa
= pBase
->pMainFdoa
;
4475 pTxbx
= pBase
->pMainTxbx
;
4476 pTxbxBkd
= pBase
->pMainTxbxBkd
;
4480 nCpO
= pWwFib
->GetBaseCp(nType
);
4482 if( nStartCp
|| nCpO
)
4483 SeekPos( nStartCp
); // PLCFe auf Text-StartPos einstellen
4485 // initialisieren der Member-Vars Low-Level
4486 GetChpPLCF()->ResetAttrStartEnd();
4487 GetPapPLCF()->ResetAttrStartEnd();
4488 for( i
=0; i
< nPLCF
; i
++)
4490 WW8PLCFxDesc
* p
= &aD
[i
];
4494 For subdocuments we modify the cp of properties to be relative to
4495 the beginning of subdocuments, we should also do the same for
4496 piecetable changes, and piecetable properties, otherwise a piece
4497 change that happens in a subdocument is lost.
4499 p
->nCpOfs
= ( p
== pChp
|| p
== pPap
|| p
== pBkm
|| p
== pPcd
||
4500 p
== pPcdA
) ? nCpO
: 0;
4503 p
->bFirstSprm
= false;
4506 if ((p
== pChp
) || (p
== pPap
))
4507 p
->nStartPos
= p
->nEndPos
= nStartCp
;
4509 p
->nStartPos
= p
->nEndPos
= WW8_CP_MAX
;
4512 // initialisieren der Member-Vars High-Level
4513 for( i
=0; i
<nPLCF
; i
++){
4514 WW8PLCFxDesc
* p
= &aD
[i
];
4518 p
->nStartPos
= p
->nEndPos
= WW8_CP_MAX
;
4522 if( p
->pPLCFx
->IsSprm() )
4524 // Vorsicht: nEndPos muss bereits
4525 p
->pIdStk
= new std::stack
<USHORT
>;
4526 if ((p
== pChp
) || (p
== pPap
))
4528 WW8_CP nTemp
= p
->nEndPos
+p
->nCpOfs
;
4531 p
->nStartPos
= nTemp
;
4532 if (!(*p
->pPLCFx
).SeekPos(p
->nStartPos
))
4533 p
->nEndPos
= p
->nStartPos
= WW8_CP_MAX
;
4538 GetNewSprms( *p
); // bei allen PLCFen initialisiert sein
4540 else if( p
->pPLCFx
)
4541 GetNewNoSprms( *p
);
4545 WW8PLCFMan::~WW8PLCFMan()
4547 for( USHORT i
=0; i
<nPLCF
; i
++)
4548 delete aD
[i
].pIdStk
;
4551 // 0. welche Attr.-Klasse,
4552 // 1. ob ein Attr.-Start ist,
4553 // 2. CP, wo ist naechste Attr.-Aenderung
4554 USHORT
WW8PLCFMan::WhereIdx(bool* pbStart
, long* pPos
) const
4556 ASSERT(nPLCF
,"What the hell");
4557 long nNext
= LONG_MAX
; // SuchReihenfolge:
4558 USHORT nNextIdx
= nPLCF
;// first ending found ( CHP, PAP, ( SEP ) ),
4559 bool bStart
= true; // dann Anfaenge finden ( ( SEP ), PAP, CHP )
4561 const WW8PLCFxDesc
* pD
;
4562 for (i
=0; i
< nPLCF
; i
++)
4567 if( (pD
->nEndPos
< nNext
) && (pD
->nStartPos
== WW8_CP_MAX
) )
4569 // sonst ist Anfang = Ende
4570 nNext
= pD
->nEndPos
;
4576 for (i
=nPLCF
; i
> 0; i
--)
4581 if( pD
->nStartPos
< nNext
)
4583 nNext
= pD
->nStartPos
;
4596 // gibt die CP-Pos der naechsten Attribut-Aenderung zurueck
4597 WW8_CP
WW8PLCFMan::Where() const
4604 void WW8PLCFMan::SeekPos( long nNewCp
)
4606 pChp
->pPLCFx
->SeekPos( nNewCp
+ nCpO
); // Attribute neu
4607 pPap
->pPLCFx
->SeekPos( nNewCp
+ nCpO
); // aufsetzen
4608 pFld
->pPLCFx
->SeekPos( nNewCp
);
4610 pPcd
->pPLCFx
->SeekPos( nNewCp
+ nCpO
);
4612 pBkm
->pPLCFx
->SeekPos( nNewCp
+ nCpO
);
4615 void WW8PLCFMan::SaveAllPLCFx( WW8PLCFxSaveAll
& rSave
) const
4619 pPcd
->Save( rSave
.aS
[n
++] );
4621 pPcdA
->Save( rSave
.aS
[n
++] );
4623 for(i
=0; i
<nPLCF
; ++i
)
4624 if( pPcd
!= &aD
[i
] && pPcdA
!= &aD
[i
] )
4625 aD
[i
].Save( rSave
.aS
[n
++] );
4628 void WW8PLCFMan::RestoreAllPLCFx( const WW8PLCFxSaveAll
& rSave
)
4632 pPcd
->Restore( rSave
.aS
[n
++] );
4634 pPcdA
->Restore( rSave
.aS
[n
++] );
4636 for(i
=0; i
<nPLCF
; ++i
)
4637 if( pPcd
!= &aD
[i
] && pPcdA
!= &aD
[i
] )
4638 aD
[i
].Restore( rSave
.aS
[n
++] );
4641 void WW8PLCFMan::GetSprmStart( short nIdx
, WW8PLCFManResult
* pRes
) const
4643 memset( pRes
, 0, sizeof( WW8PLCFManResult
) );
4649 const WW8PLCFxDesc
* p
= &aD
[nIdx
];
4651 // first Sprm in a Group
4655 pRes
->nFlags
|= MAN_MASK_NEW_PAP
;
4656 else if( p
== pSep
)
4657 pRes
->nFlags
|= MAN_MASK_NEW_SEP
;
4659 pRes
->pMemPos
= p
->pMemPos
;
4660 pRes
->nSprmId
= GetId(p
);
4661 pRes
->nCp2OrIdx
= p
->nCp2OrIdx
;
4662 if ((p
== pFtn
) || (p
== pEdn
) || (p
== pAnd
))
4663 pRes
->nMemLen
= p
->nSprmsLen
;
4664 else if (p
->nSprmsLen
) //Normal
4666 // Length of actual sprm
4667 pRes
->nMemLen
= maSprmParser
.GetSprmSize(pRes
->nSprmId
, pRes
->pMemPos
);
4671 void WW8PLCFMan::GetSprmEnd( short nIdx
, WW8PLCFManResult
* pRes
) const
4673 memset( pRes
, 0, sizeof( WW8PLCFManResult
) );
4675 const WW8PLCFxDesc
* p
= &aD
[nIdx
];
4677 if (!(p
->pIdStk
->empty()))
4678 pRes
->nSprmId
= p
->pIdStk
->top(); // get end position
4681 ASSERT( !this, "No Id on the Stack" );
4686 void WW8PLCFMan::GetNoSprmStart( short nIdx
, WW8PLCFManResult
* pRes
) const
4688 const WW8PLCFxDesc
* p
= &aD
[nIdx
];
4690 pRes
->nCpPos
= p
->nStartPos
;
4691 pRes
->nMemLen
= p
->nSprmsLen
;
4692 pRes
->nCp2OrIdx
= p
->nCp2OrIdx
;
4695 pRes
->nSprmId
= eFLD
;
4696 else if( p
== pFtn
)
4697 pRes
->nSprmId
= eFTN
;
4698 else if( p
== pEdn
)
4699 pRes
->nSprmId
= eEDN
;
4700 else if( p
== pBkm
)
4701 pRes
->nSprmId
= eBKN
;
4702 else if( p
== pAnd
)
4703 pRes
->nSprmId
= eAND
;
4704 else if( p
== pPcd
)
4706 //We slave the piece table attributes to the piece table, the piece
4707 //table attribute iterator contains the sprms for this piece.
4708 GetSprmStart( nIdx
+1, pRes
);
4711 pRes
->nSprmId
= 0; // default: not found
4714 void WW8PLCFMan::GetNoSprmEnd( short nIdx
, WW8PLCFManResult
* pRes
) const
4716 pRes
->nMemLen
= -1; // Ende-Kennzeichen
4718 if( &aD
[nIdx
] == pBkm
)
4719 pRes
->nSprmId
= eBKN
;
4720 else if( &aD
[nIdx
] == pPcd
)
4722 //We slave the piece table attributes to the piece table, the piece
4723 //table attribute iterator contains the sprms for this piece.
4724 GetSprmEnd( nIdx
+1, pRes
);
4730 bool WW8PLCFMan::TransferOpenSprms(std::stack
<USHORT
> &rStack
)
4732 for (int i
= 0; i
< nPLCF
; ++i
)
4734 WW8PLCFxDesc
* p
= &aD
[i
];
4735 if (!p
|| !p
->pIdStk
)
4737 while (!p
->pIdStk
->empty())
4739 rStack
.push(p
->pIdStk
->top());
4743 return rStack
.empty();
4746 void WW8PLCFMan::AdvSprm(short nIdx
, bool bStart
)
4748 WW8PLCFxDesc
* p
= &aD
[nIdx
]; // Sprm-Klasse(!) ermitteln
4750 p
->bFirstSprm
= false;
4753 USHORT nLastId
= GetId(p
);
4754 p
->pIdStk
->push(nLastId
); // merke Id fuer Attribut-Ende
4758 Pruefe, ob noch Sprm(s) abzuarbeiten sind
4762 // Length of last sprm
4763 USHORT nSprmL
= maSprmParser
.GetSprmSize(nLastId
, p
->pMemPos
);
4765 // Gesamtlaenge Sprms um SprmLaenge verringern
4766 p
->nSprmsLen
-= nSprmL
;
4768 // Pos des evtl. naechsten Sprm
4769 if (p
->nSprmsLen
< maSprmParser
.MinSprmLen())
4771 // sicherheitshalber auf Null setzen, da Enden folgen!
4776 p
->pMemPos
+= nSprmL
;
4781 if (p
->nSprmsLen
< maSprmParser
.MinSprmLen())
4782 p
->nStartPos
= WW8_CP_MAX
; // es folgen Enden
4786 if (!(p
->pIdStk
->empty()))
4788 if (p
->pIdStk
->empty())
4790 if ( (p
== pChp
) || (p
== pPap
) )
4794 p
->nStartPos
= p
->nOrigEndPos
+p
->nCpOfs
;
4798 On failed seek we have run out of sprms, probably. But if its
4799 a fastsaved file (has pPcd) then we may be just in a sprm free
4800 gap between pieces that have them, so set dirty flag in sprm
4801 finder to consider than.
4803 if (!(*p
->pPLCFx
).SeekPos(p
->nStartPos
))
4805 p
->nEndPos
= WW8_CP_MAX
;
4806 p
->pPLCFx
->SetDirty(true);
4808 if (!p
->pPLCFx
->GetDirty() || pPcd
)
4810 p
->pPLCFx
->SetDirty(false);
4814 To get the character and paragraph properties you first get
4815 the pap and chp and then apply the fastsaved pPcd properties
4816 to the range. If a pap or chp starts inside the pPcd range
4817 then we must bring the current pPcd range to a halt so as to
4818 end those sprms, then the pap/chp will be processed, and then
4819 we must force a restart of the pPcd on that pap/chp starting
4820 boundary. Doing that effectively means that the pPcd sprms will
4821 be applied to the new range. Not doing it means that the pPcd
4822 sprms will only be applied to the first pap/chp set of
4823 properties contained in the pap/chp range.
4825 So we bring the pPcd to a halt on this location here, by
4826 settings its end to the current start, then store the starting
4827 position of the current range to clipstart. The pPcd sprms
4828 will end as normal (albeit earlier than originally expected),
4829 and the existance of a clipstart will force the pPcd iterater
4830 to reread the current set of sprms instead of advancing to its
4831 next set. Then the clipstart will be set as the starting
4832 position which will force them to be applied directly after
4835 if (pPcd
&& ((p
->nStartPos
> pPcd
->nStartPos
) ||
4836 (pPcd
->nStartPos
== WW8_CP_MAX
)) &&
4837 (pPcd
->nEndPos
!= p
->nStartPos
))
4839 pPcd
->nEndPos
= p
->nStartPos
;
4840 ((WW8PLCFx_PCD
*)(pPcd
->pPLCFx
))->SetClipStart(
4847 (*p
->pPLCFx
)++; // next Group of Sprms
4848 p
->pMemPos
= 0; // !!!
4852 ASSERT( p
->nStartPos
<= p
->nEndPos
, "Attribut ueber Kreuz" );
4857 void WW8PLCFMan::AdvNoSprm(short nIdx
, bool bStart
)
4860 For the case of a piece table we slave the piece table attribute iterator
4861 to the piece table and access it through that only. They are two seperate
4862 structures, but act together as one logical one. The attributes only go
4863 to the next entry when the piece changes
4865 WW8PLCFxDesc
* p
= &aD
[nIdx
];
4869 AdvSprm(nIdx
+1,bStart
);
4871 p
->nStartPos
= aD
[nIdx
+1].nStartPos
;
4874 if (aD
[nIdx
+1].pIdStk
->empty())
4876 WW8PLCFx_PCD
*pTemp
= (WW8PLCFx_PCD
*)(pPcd
->pPLCFx
);
4879 As per normal, go on to the next set of properties, i.e. we
4880 have traversed over to the next piece. With a clipstart set
4881 we are being told to reread the current piece sprms so as to
4882 reapply them to a new chp or pap range.
4884 if (pTemp
->GetClipStart() == -1)
4888 GetNewSprms( aD
[nIdx
+1] );
4889 GetNewNoSprms( *p
);
4890 if (pTemp
->GetClipStart() != -1)
4893 #i2325#, now we will force our starting position to the
4894 clipping start so as to force the application of these
4895 sprms after the current pap/chp sprms so as to apply the
4896 fastsave sprms to the current range.
4898 p
->nStartPos
= pTemp
->GetClipStart();
4899 pTemp
->SetClipStart(-1);
4905 { // NoSprm ohne Ende
4907 p
->pMemPos
= 0; // MemPos ungueltig
4909 GetNewNoSprms( *p
);
4913 WW8PLCFMan
& WW8PLCFMan::operator ++(int)
4916 USHORT nIdx
= WhereIdx(&bStart
);
4919 WW8PLCFxDesc
* p
= &aD
[nIdx
];
4921 p
->bFirstSprm
= true; // Default
4923 if( p
->pPLCFx
->IsSprm() )
4924 AdvSprm( nIdx
, bStart
);
4926 AdvNoSprm( nIdx
, bStart
);
4931 // Rueckgabe true fuer Anfang eines Attributes oder Fehler,
4932 // false fuer Ende d. Attr
4933 // Restliche Rueckgabewerte werden in der vom Aufrufer zu stellenden Struktur
4934 // WW8PclxManResults geliefert.
4935 bool WW8PLCFMan::Get(WW8PLCFManResult
* pRes
) const
4937 memset( pRes
, 0, sizeof( WW8PLCFManResult
) );
4939 USHORT nIdx
= WhereIdx(&bStart
);
4943 ASSERT( !this, "Position not found" );
4947 if( aD
[nIdx
].pPLCFx
->IsSprm() )
4951 GetSprmStart( nIdx
, pRes
);
4956 GetSprmEnd( nIdx
, pRes
);
4964 GetNoSprmStart( nIdx
, pRes
);
4969 GetNoSprmEnd( nIdx
, pRes
);
4975 USHORT
WW8PLCFMan::GetColl() const
4978 return pPap
->pPLCFx
->GetIstd();
4981 ASSERT( !this, "GetColl ohne PLCF_Pap" );
4986 WW8PLCFx_FLD
* WW8PLCFMan::GetFld() const
4988 return (WW8PLCFx_FLD
*)pFld
->pPLCFx
;
4991 const BYTE
* WW8PLCFMan::HasParaSprm( USHORT nId
) const
4993 return ((WW8PLCFx_Cp_FKP
*)pPap
->pPLCFx
)->HasSprm( nId
);
4996 const BYTE
* WW8PLCFMan::HasCharSprm( USHORT nId
) const
4998 return ((WW8PLCFx_Cp_FKP
*)pChp
->pPLCFx
)->HasSprm( nId
);
5001 bool WW8PLCFMan::HasCharSprm(USHORT nId
,
5002 std::vector
<const BYTE
*> &rResult
) const
5004 return ((WW8PLCFx_Cp_FKP
*)pChp
->pPLCFx
)->HasSprm(nId
, rResult
);
5009 void WW8PLCFx::Save( WW8PLCFxSave1
& rSave
) const
5011 rSave
.nPLCFxPos
= GetIdx();
5012 rSave
.nPLCFxPos2
= GetIdx2();
5013 rSave
.nPLCFxMemOfs
= 0;
5014 rSave
.nStartFC
= GetStartFc();
5017 void WW8PLCFx::Restore( const WW8PLCFxSave1
& rSave
)
5019 SetIdx( rSave
.nPLCFxPos
);
5020 SetIdx2( rSave
.nPLCFxPos2
);
5021 SetStartFc( rSave
.nStartFC
);
5024 ULONG
WW8PLCFx_Cp_FKP::GetIdx2() const
5029 void WW8PLCFx_Cp_FKP::SetIdx2( ULONG nIdx
)
5034 void WW8PLCFx_Cp_FKP::Save( WW8PLCFxSave1
& rSave
) const
5036 WW8PLCFx::Save( rSave
);
5038 rSave
.nAttrStart
= nAttrStart
;
5039 rSave
.nAttrEnd
= nAttrEnd
;
5040 rSave
.bLineEnd
= bLineEnd
;
5043 void WW8PLCFx_Cp_FKP::Restore( const WW8PLCFxSave1
& rSave
)
5045 WW8PLCFx::Restore( rSave
);
5047 nAttrStart
= rSave
.nAttrStart
;
5048 nAttrEnd
= rSave
.nAttrEnd
;
5049 bLineEnd
= rSave
.bLineEnd
;
5052 void WW8PLCFxDesc::Save( WW8PLCFxSave1
& rSave
) const
5056 pPLCFx
->Save( rSave
);
5057 if( pPLCFx
->IsSprm() )
5060 aD
.nStartPos
= nOrigStartPos
+nCpOfs
;
5061 aD
.nCpOfs
= rSave
.nCpOfs
= nCpOfs
;
5062 if (!(pPLCFx
->SeekPos(aD
.nStartPos
)))
5064 aD
.nEndPos
= WW8_CP_MAX
;
5065 pPLCFx
->SetDirty(true);
5067 pPLCFx
->GetSprms(&aD
);
5068 pPLCFx
->SetDirty(false);
5069 aD
.ReduceByOffset();
5070 rSave
.nStartCp
= aD
.nStartPos
;
5071 rSave
.nPLCFxMemOfs
= nOrigSprmsLen
- nSprmsLen
;
5076 void WW8PLCFxDesc::Restore( const WW8PLCFxSave1
& rSave
)
5080 pPLCFx
->Restore( rSave
);
5081 if( pPLCFx
->IsSprm() )
5084 aD
.nStartPos
= rSave
.nStartCp
+rSave
.nCpOfs
;
5085 nCpOfs
= aD
.nCpOfs
= rSave
.nCpOfs
;
5086 if (!(pPLCFx
->SeekPos(aD
.nStartPos
)))
5088 aD
.nEndPos
= WW8_CP_MAX
;
5089 pPLCFx
->SetDirty(true);
5091 pPLCFx
->GetSprms(&aD
);
5092 pPLCFx
->SetDirty(false);
5093 aD
.ReduceByOffset();
5094 pMemPos
= aD
.pMemPos
+ rSave
.nPLCFxMemOfs
;
5099 //-----------------------------------------
5103 sal_uInt32
Readcb(SvStream
& rSt
, ww::WordVersion eVer
)
5105 if (eVer
<= ww::eWW2
)
5120 WW8_CP
WW8Fib::GetBaseCp(ManTypes nType
) const
5133 nOffset
= ccpText
+ ccpFtn
;
5136 * A subdocument of this kind probably exists in some defunct version
5137 * of MSWord, but now ccpMcr is always 0
5141 nOffset
= ccpText
+ ccpFtn
+ ccpHdr
;
5145 nOffset
= ccpText
+ ccpFtn
+ ccpHdr
+ ccpMcr
;
5148 nOffset
= ccpText
+ ccpFtn
+ ccpHdr
+ ccpMcr
+ ccpAtn
;
5151 nOffset
= ccpText
+ ccpFtn
+ ccpHdr
+ ccpMcr
+ ccpAtn
+ ccpEdn
;
5154 nOffset
= ccpText
+ ccpFtn
+ ccpHdr
+ ccpMcr
+ ccpAtn
+ ccpEdn
+
5161 ww::WordVersion
WW8Fib::GetFIBVersion() const
5163 ww::WordVersion eVer
= ww::eWW8
;
5164 if (wIdent
== 0xa5db)
5184 WW8Fib::WW8Fib(SvStream
& rSt
, BYTE nWantedVersion
, UINT32 nOffset
)
5187 memset(this, 0, sizeof(*this));
5190 BYTE aVer8Bits1
; // nur ab WinWord 8 benutzt
5191 rSt
.Seek( nOffset
);
5193 Wunsch-Nr vermerken, File-Versionsnummer ermitteln
5194 und gegen Wunsch-Nr. checken !
5196 nVersion
= nWantedVersion
;
5200 if( 0 != rSt
.GetError() )
5204 // note: 6 stands for "6 OR 7", 7 stands for "ONLY 7"
5208 nFibMin
= 0x0065; // von 101 WinWord 6.0
5210 // und 103 WinWord 6.0 fuer Macintosh
5212 nFibMax
= 0x0069; // bis 105 WinWord 95
5215 nFibMin
= 0x0069; // von 105 WinWord 95
5216 nFibMax
= 0x0069; // bis 105 WinWord 95
5219 nFibMin
= 0x006A; // von 106 WinWord 97
5220 nFibMax
= 0x00c1; // bis 193 WinWord 97 (?)
5223 nFibMin
= 0; // Programm-Fehler!
5226 ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
5229 if ( (nFib
< nFibMin
) || (nFib
> nFibMax
) )
5231 nFibError
= ERR_SWG_READ_ERROR
; // Error melden
5232 return; // und hopp raus!
5236 ww::WordVersion eVer
= GetFIBVersion();
5238 // Hilfs-Varis fuer Ver67:
5239 INT16 pnChpFirst_Ver67
=0;
5240 INT16 pnPapFirst_Ver67
=0;
5241 INT16 cpnBteChp_Ver67
=0;
5242 INT16 cpnBtePap_Ver67
=0;
5244 // und auf gehts: FIB einlesen
5253 rSt
>> aVer8Bits1
; // unter Ver67 nur leeres Reservefeld
5254 // Inhalt von aVer8Bits1
5257 // BYTE fEmptySpecial :1;
5258 // BYTE fLoadOverridePage :1;
5259 // BYTE fFuturesavedUndo :1;
5260 // BYTE fWord97Saved :1;
5267 // Einschub fuer WW8 *****************************************************
5268 if (IsEightPlus(eVer
))
5272 // Marke: "rgsw" Beginning of the array of shorts
5273 rSt
>> wMagicCreated
;
5274 rSt
>> wMagicRevised
;
5275 rSt
>> wMagicCreatedPrivate
;
5276 rSt
>> wMagicRevisedPrivate
;
5277 rSt
.SeekRel( 9 * sizeof( INT16
) );
5280 // dies sind die 9 unused Felder:
5281 && (bVer67 || WW8ReadINT16( rSt, pnFbpChpFirst_W6 )) // 1
5282 && (bVer67 || WW8ReadINT16( rSt, pnChpFirst_W6 )) // 2
5283 && (bVer67 || WW8ReadINT16( rSt, cpnBteChp_W6 )) // 3
5284 && (bVer67 || WW8ReadINT16( rSt, pnFbpPapFirst_W6 )) // 4
5285 && (bVer67 || WW8ReadINT16( rSt, pnPapFirst_W6 )) // 5
5286 && (bVer67 || WW8ReadINT16( rSt, cpnBtePap_W6 )) // 6
5287 && (bVer67 || WW8ReadINT16( rSt, pnFbpLvcFirst_W6 )) // 7
5288 && (bVer67 || WW8ReadINT16( rSt, pnLvcFirst_W6 )) // 8
5289 && (bVer67 || WW8ReadINT16( rSt, cpnBteLvc_W6 )) // 9
5295 // Ende des Einschubs fuer WW8 *******************************************
5297 // Marke: "rglw" Beginning of the array of longs
5300 // 2 Longs uebergehen, da unwichtiger Quatsch
5301 rSt
.SeekRel( 2 * sizeof( INT32
) );
5303 // weitere 2 Longs nur bei Ver67 ueberspringen
5304 if (IsSevenMinus(eVer
))
5305 rSt
.SeekRel( 2 * sizeof( INT32
) );
5316 // weiteres Long nur bei Ver67 ueberspringen
5317 if (IsSevenMinus(eVer
))
5318 rSt
.SeekRel( 1 * sizeof( INT32
) );
5321 // Einschub fuer WW8 *****************************************************
5322 rSt
>> pnFbpChpFirst
;
5325 rSt
>> pnFbpPapFirst
;
5328 rSt
>> pnFbpLvcFirst
;
5331 rSt
>> fcIslandFirst
;
5336 // Ende des Einschubs fuer WW8 *******************************************
5338 // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
5340 lcbStshfOrig
= Readcb(rSt
, eVer
);
5342 lcbStshf
= Readcb(rSt
, eVer
);
5343 rSt
>> fcPlcffndRef
;
5344 lcbPlcffndRef
= Readcb(rSt
, eVer
);
5345 rSt
>> fcPlcffndTxt
;
5346 lcbPlcffndTxt
= Readcb(rSt
, eVer
);
5347 rSt
>> fcPlcfandRef
;
5348 lcbPlcfandRef
= Readcb(rSt
, eVer
);
5349 rSt
>> fcPlcfandTxt
;
5350 lcbPlcfandTxt
= Readcb(rSt
, eVer
);
5352 lcbPlcfsed
= Readcb(rSt
, eVer
);
5354 lcbPlcfpad
= Readcb(rSt
, eVer
);
5356 lcbPlcfphe
= Readcb(rSt
, eVer
);
5358 lcbSttbfglsy
= Readcb(rSt
, eVer
);
5360 lcbPlcfglsy
= Readcb(rSt
, eVer
);
5362 lcbPlcfhdd
= Readcb(rSt
, eVer
);
5363 rSt
>> fcPlcfbteChpx
;
5364 lcbPlcfbteChpx
= Readcb(rSt
, eVer
);
5365 rSt
>> fcPlcfbtePapx
;
5366 lcbPlcfbtePapx
= Readcb(rSt
, eVer
);
5368 lcbPlcfsea
= Readcb(rSt
, eVer
);
5370 lcbSttbfffn
= Readcb(rSt
, eVer
);
5371 rSt
>> fcPlcffldMom
;
5372 lcbPlcffldMom
= Readcb(rSt
, eVer
);
5373 rSt
>> fcPlcffldHdr
;
5374 lcbPlcffldHdr
= Readcb(rSt
, eVer
);
5375 rSt
>> fcPlcffldFtn
;
5376 lcbPlcffldFtn
= Readcb(rSt
, eVer
);
5377 rSt
>> fcPlcffldAtn
;
5378 lcbPlcffldAtn
= Readcb(rSt
, eVer
);
5379 rSt
>> fcPlcffldMcr
;
5380 lcbPlcffldMcr
= Readcb(rSt
, eVer
);
5382 lcbSttbfbkmk
= Readcb(rSt
, eVer
);
5384 lcbPlcfbkf
= Readcb(rSt
, eVer
);
5386 lcbPlcfbkl
= Readcb(rSt
, eVer
);
5388 lcbCmds
= Readcb(rSt
, eVer
);
5390 lcbPlcfmcr
= Readcb(rSt
, eVer
);
5392 lcbSttbfmcr
= Readcb(rSt
, eVer
);
5394 lcbPrDrvr
= Readcb(rSt
, eVer
);
5396 lcbPrEnvPort
= Readcb(rSt
, eVer
);
5398 lcbPrEnvLand
= Readcb(rSt
, eVer
);
5400 lcbWss
= Readcb(rSt
, eVer
);
5402 lcbDop
= Readcb(rSt
, eVer
);
5403 rSt
>> fcSttbfAssoc
;
5404 lcbSttbfAssoc
= Readcb(rSt
, eVer
);
5406 lcbClx
= Readcb(rSt
, eVer
);
5407 rSt
>> fcPlcfpgdFtn
;
5408 lcbPlcfpgdFtn
= Readcb(rSt
, eVer
);
5409 rSt
>> fcAutosaveSource
;
5410 lcbAutosaveSource
= Readcb(rSt
, eVer
);
5411 rSt
>> fcGrpStAtnOwners
;
5412 lcbGrpStAtnOwners
= Readcb(rSt
, eVer
);
5413 rSt
>> fcSttbfAtnbkmk
;
5414 lcbSttbfAtnbkmk
= Readcb(rSt
, eVer
);
5416 // weiteres short nur bei Ver67 ueberspringen
5417 if (IsSevenMinus(eVer
))
5419 rSt
.SeekRel( 1*sizeof( INT16
) );
5421 // folgende 4 Shorts existieren nur bei Ver67;
5422 rSt
>> pnChpFirst_Ver67
;
5423 rSt
>> pnPapFirst_Ver67
;
5424 rSt
>> cpnBteChp_Ver67
;
5425 rSt
>> cpnBtePap_Ver67
;
5428 if (eVer
> ww::eWW2
)
5430 rSt
>> fcPlcfdoaMom
;
5431 rSt
>> lcbPlcfdoaMom
;
5432 rSt
>> fcPlcfdoaHdr
;
5433 rSt
>> lcbPlcfdoaHdr
;
5434 rSt
>> fcPlcfspaMom
;
5435 rSt
>> lcbPlcfspaMom
;
5436 rSt
>> fcPlcfspaHdr
;
5437 rSt
>> lcbPlcfspaHdr
;
5439 rSt
>> fcPlcfAtnbkf
;
5440 rSt
>> lcbPlcfAtnbkf
;
5441 rSt
>> fcPlcfAtnbkl
;
5442 rSt
>> lcbPlcfAtnbkl
;
5445 rSt
>> fcFormFldSttbf
;
5446 rSt
>> lcbFormFldSttbf
;
5447 rSt
>> fcPlcfendRef
;
5448 rSt
>> lcbPlcfendRef
;
5449 rSt
>> fcPlcfendTxt
;
5450 rSt
>> lcbPlcfendTxt
;
5451 rSt
>> fcPlcffldEdn
;
5452 rSt
>> lcbPlcffldEdn
;
5453 rSt
>> fcPlcfpgdEdn
;
5454 rSt
>> lcbPlcfpgdEdn
;
5457 rSt
>> fcSttbfRMark
;
5458 rSt
>> lcbSttbfRMark
;
5459 rSt
>> fcSttbfCaption
;
5460 rSt
>> lcbSttbfCaption
;
5461 rSt
>> fcSttbAutoCaption
;
5462 rSt
>> lcbSttbAutoCaption
;
5467 rSt
>> fcPlcftxbxTxt
;
5468 rSt
>> lcbPlcftxbxTxt
;
5469 rSt
>> fcPlcffldTxbx
;
5470 rSt
>> lcbPlcffldTxbx
;
5471 rSt
>> fcPlcfHdrtxbxTxt
;
5472 rSt
>> lcbPlcfHdrtxbxTxt
;
5473 rSt
>> fcPlcffldHdrTxbx
;
5474 rSt
>> lcbPlcffldHdrTxbx
;
5478 rSt
>> lcbSttbttmbd
;
5481 if( 0 == rSt
.GetError() )
5484 fDot
= aBits1
& 0x01 ;
5485 fGlsy
= ( aBits1
& 0x02 ) >> 1;
5486 fComplex
= ( aBits1
& 0x04 ) >> 2;
5487 fHasPic
= ( aBits1
& 0x08 ) >> 3;
5488 cQuickSaves
= ( aBits1
& 0xf0 ) >> 4;
5489 fEncrypted
= aBits2
& 0x01 ;
5490 fWhichTblStm
= ( aBits2
& 0x02 ) >> 1;
5491 // dummy = ( aBits2 & 0x0e ) >> 1;
5492 fExtChar
= ( aBits2
& 0x10 ) >> 4;
5493 // dummy = ( aBits2 & 0x20 ) >> 5;
5494 fFarEast
= ( aBits2
& 0x40 ) >> 6; // #i90932#
5495 // dummy = ( aBits2 & 0x80 ) >> 7;
5498 ggfs. Ziel-Varaiblen, aus xxx_Ver67 fuellen
5501 if (IsSevenMinus(eVer
))
5503 pnChpFirst
= pnChpFirst_Ver67
;
5504 pnPapFirst
= pnPapFirst_Ver67
;
5505 cpnBteChp
= cpnBteChp_Ver67
;
5506 cpnBtePap
= cpnBtePap_Ver67
;
5508 else if (IsEightPlus(eVer
))
5510 fMac
= aVer8Bits1
& 0x01 ;
5511 fEmptySpecial
= ( aVer8Bits1
& 0x02 ) >> 1;
5512 fLoadOverridePage
= ( aVer8Bits1
& 0x04 ) >> 2;
5513 fFuturesavedUndo
= ( aVer8Bits1
& 0x08 ) >> 3;
5514 fWord97Saved
= ( aVer8Bits1
& 0x10 ) >> 4;
5515 fWord2000Saved
= ( aVer8Bits1
& 0x20 ) >> 5;
5519 ermittle die Werte fuer PLCF LST und PLF LFO
5520 und PLCF fuer TextBox-Break-Deskriptoren
5522 long nOldPos
= rSt
.Tell();
5531 rSt
>> fcPlcftxbxBkd
;
5532 rSt
>> lcbPlcftxbxBkd
;
5533 rSt
>> fcPlcfHdrtxbxBkd
;
5534 rSt
>> lcbPlcfHdrtxbxBkd
;
5535 if( 0 != rSt
.GetError() )
5537 nFibError
= ERR_SWG_READ_ERROR
;
5540 rSt
.Seek( 0x372 ); // fcSttbListNames
5541 rSt
>> fcSttbListNames
;
5542 rSt
>> lcbSttbListNames
;
5546 rSt
.Seek( 0x382 ); // MagicTables
5553 rSt
.Seek( 0x41A ); // new ATRD
5555 rSt
>> lcbAtrdExtra
;
5558 if( 0 != rSt
.GetError() )
5559 nFibError
= ERR_SWG_READ_ERROR
;
5561 rSt
.Seek( 0x5bc ); // Actual nFib introduced in Word 2003
5564 rSt
.Seek( nOldPos
);
5569 nFibError
= ERR_SWG_READ_ERROR
; // Error melden
5574 WW8Fib::WW8Fib(BYTE nVer
)
5576 memset(this, 0, sizeof(*this));
5586 csw
= 0x0e; // muss das sein ???
5587 cfclcb
= 0x88; // -""-
5589 pnFbpChpFirst
= pnFbpPapFirst
= pnFbpLvcFirst
= 0x000fffff;
5591 fWord97Saved
= fWord2000Saved
= true;
5593 // diese Flags muessen nicht gesetzt werden; koennen aber.
5594 // wMagicCreated = wMagicRevised = 0x6a62;
5595 // wMagicCreatedPrivate = wMagicRevisedPrivate = 0xb3b2;
5598 wMagicCreated
= 0x6143;
5599 wMagicRevised
= 0x6C6F;
5600 wMagicCreatedPrivate
= 0x6E61;
5601 wMagicRevisedPrivate
= 0x3038;
5607 nFib
= nFibBack
= 0x65;
5612 lid
= 0x409; // LANGUAGE_ENGLISH_US
5614 LanguageType nLang
= Application::GetSettings().GetLanguage();
5617 case LANGUAGE_CHINESE
:
5618 case LANGUAGE_CHINESE_SIMPLIFIED
:
5619 case LANGUAGE_CHINESE_HONGKONG
:
5620 case LANGUAGE_CHINESE_SINGAPORE
:
5621 case LANGUAGE_CHINESE_MACAU
:
5622 case LANGUAGE_CHINESE_TRADITIONAL
:
5623 case LANGUAGE_KOREAN
:
5624 case LANGUAGE_KOREAN_JOHAB
:
5625 case LANGUAGE_JAPANESE
:
5637 bool WW8Fib::WriteHeader(SvStream
& rStrm
)
5639 bool bVer8
= 8 == nVersion
;
5641 size_t nUnencryptedHdr
= bVer8
? 0x44 : 0x24;
5642 BYTE
*pDataPtr
= new BYTE
[ nUnencryptedHdr
];
5643 BYTE
*pData
= pDataPtr
;
5644 memset( pData
, 0, nUnencryptedHdr
);
5646 ULONG nPos
= rStrm
.Tell();
5647 cbMac
= rStrm
.Seek( STREAM_SEEK_TO_END
);
5650 Set_UInt16( pData
, wIdent
);
5651 Set_UInt16( pData
, nFib
);
5652 Set_UInt16( pData
, nProduct
);
5653 Set_UInt16( pData
, lid
);
5654 Set_UInt16( pData
, pnNext
);
5657 if( fDot
) nBits16
|= 0x0001;
5658 if( fGlsy
) nBits16
|= 0x0002;
5659 if( fComplex
) nBits16
|= 0x0004;
5660 if( fHasPic
) nBits16
|= 0x0008;
5661 nBits16
|= (0xf0 & ( cQuickSaves
<< 4 ));
5662 if( fEncrypted
) nBits16
|= 0x0100;
5663 if( fWhichTblStm
) nBits16
|= 0x0200;
5664 if( fExtChar
) nBits16
|= 0x1000;
5665 if( fFarEast
) nBits16
|= 0x4000; // #i90932#
5666 if( fObfuscated
) nBits16
|= 0x8000;
5667 Set_UInt16( pData
, nBits16
);
5669 Set_UInt16( pData
, nFibBack
);
5670 Set_UInt16( pData
, nHash
);
5671 Set_UInt16( pData
, nKey
);
5672 Set_UInt8( pData
, envr
);
5677 if( fMac
) nBits8
|= 0x0001;
5678 if( fEmptySpecial
) nBits8
|= 0x0002;
5679 if( fLoadOverridePage
) nBits8
|= 0x0004;
5680 if( fFuturesavedUndo
) nBits8
|= 0x0008;
5681 if( fWord97Saved
) nBits8
|= 0x0010;
5682 if( fWord2000Saved
) nBits8
|= 0x0020;
5684 // unter Ver67 these are only reserved
5685 Set_UInt8( pData
, nBits8
);
5687 Set_UInt16( pData
, chse
);
5688 Set_UInt16( pData
, chseTables
);
5689 Set_UInt32( pData
, fcMin
);
5690 Set_UInt32( pData
, fcMac
);
5692 // Einschub fuer WW8 *****************************************************
5694 // Marke: "rgsw" Beginning of the array of shorts
5697 Set_UInt16( pData
, csw
);
5698 Set_UInt16( pData
, wMagicCreated
);
5699 Set_UInt16( pData
, wMagicRevised
);
5700 Set_UInt16( pData
, wMagicCreatedPrivate
);
5701 Set_UInt16( pData
, wMagicRevisedPrivate
);
5702 pData
+= 9 * sizeof( INT16
);
5703 Set_UInt16( pData
, lidFE
);
5704 Set_UInt16( pData
, clw
);
5707 // Ende des Einschubs fuer WW8 *******************************************
5709 // Marke: "rglw" Beginning of the array of longs
5710 Set_UInt32( pData
, cbMac
);
5712 rStrm
.Write( pDataPtr
, nUnencryptedHdr
);
5714 return 0 == rStrm
.GetError();
5717 bool WW8Fib::Write(SvStream
& rStrm
)
5719 bool bVer8
= 8 == nVersion
;
5721 WriteHeader( rStrm
);
5723 size_t nUnencryptedHdr
= bVer8
? 0x44 : 0x24;
5725 BYTE
*pDataPtr
= new BYTE
[ fcMin
- nUnencryptedHdr
];
5726 BYTE
*pData
= pDataPtr
;
5727 memset( pData
, 0, fcMin
- nUnencryptedHdr
);
5729 ULONG nPos
= rStrm
.Tell();
5730 cbMac
= rStrm
.Seek( STREAM_SEEK_TO_END
);
5733 // 2 Longs uebergehen, da unwichtiger Quatsch
5734 pData
+= 2 * sizeof( INT32
);
5736 // weitere 2 Longs nur bei Ver67 ueberspringen
5738 pData
+= 2 * sizeof( INT32
);
5740 Set_UInt32( pData
, ccpText
);
5741 Set_UInt32( pData
, ccpFtn
);
5742 Set_UInt32( pData
, ccpHdr
);
5743 Set_UInt32( pData
, ccpMcr
);
5744 Set_UInt32( pData
, ccpAtn
);
5745 Set_UInt32( pData
, ccpEdn
);
5746 Set_UInt32( pData
, ccpTxbx
);
5747 Set_UInt32( pData
, ccpHdrTxbx
);
5749 // weiteres Long nur bei Ver67 ueberspringen
5751 pData
+= 1 * sizeof( INT32
);
5753 // Einschub fuer WW8 *****************************************************
5756 Set_UInt32( pData
, pnFbpChpFirst
);
5757 Set_UInt32( pData
, pnChpFirst
);
5758 Set_UInt32( pData
, cpnBteChp
);
5759 Set_UInt32( pData
, pnFbpPapFirst
);
5760 Set_UInt32( pData
, pnPapFirst
);
5761 Set_UInt32( pData
, cpnBtePap
);
5762 Set_UInt32( pData
, pnFbpLvcFirst
);
5763 Set_UInt32( pData
, pnLvcFirst
);
5764 Set_UInt32( pData
, cpnBteLvc
);
5765 Set_UInt32( pData
, fcIslandFirst
);
5766 Set_UInt32( pData
, fcIslandLim
);
5767 Set_UInt16( pData
, cfclcb
);
5769 // Ende des Einschubs fuer WW8 *******************************************
5771 // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
5772 Set_UInt32( pData
, fcStshfOrig
);
5773 Set_UInt32( pData
, lcbStshfOrig
);
5774 Set_UInt32( pData
, fcStshf
);
5775 Set_UInt32( pData
, lcbStshf
);
5776 Set_UInt32( pData
, fcPlcffndRef
);
5777 Set_UInt32( pData
, lcbPlcffndRef
);
5778 Set_UInt32( pData
, fcPlcffndTxt
);
5779 Set_UInt32( pData
, lcbPlcffndTxt
);
5780 Set_UInt32( pData
, fcPlcfandRef
);
5781 Set_UInt32( pData
, lcbPlcfandRef
);
5782 Set_UInt32( pData
, fcPlcfandTxt
);
5783 Set_UInt32( pData
, lcbPlcfandTxt
);
5784 Set_UInt32( pData
, fcPlcfsed
);
5785 Set_UInt32( pData
, lcbPlcfsed
);
5786 Set_UInt32( pData
, fcPlcfpad
);
5787 Set_UInt32( pData
, lcbPlcfpad
);
5788 Set_UInt32( pData
, fcPlcfphe
);
5789 Set_UInt32( pData
, lcbPlcfphe
);
5790 Set_UInt32( pData
, fcSttbfglsy
);
5791 Set_UInt32( pData
, lcbSttbfglsy
);
5792 Set_UInt32( pData
, fcPlcfglsy
);
5793 Set_UInt32( pData
, lcbPlcfglsy
);
5794 Set_UInt32( pData
, fcPlcfhdd
);
5795 Set_UInt32( pData
, lcbPlcfhdd
);
5796 Set_UInt32( pData
, fcPlcfbteChpx
);
5797 Set_UInt32( pData
, lcbPlcfbteChpx
);
5798 Set_UInt32( pData
, fcPlcfbtePapx
);
5799 Set_UInt32( pData
, lcbPlcfbtePapx
);
5800 Set_UInt32( pData
, fcPlcfsea
);
5801 Set_UInt32( pData
, lcbPlcfsea
);
5802 Set_UInt32( pData
, fcSttbfffn
);
5803 Set_UInt32( pData
, lcbSttbfffn
);
5804 Set_UInt32( pData
, fcPlcffldMom
);
5805 Set_UInt32( pData
, lcbPlcffldMom
);
5806 Set_UInt32( pData
, fcPlcffldHdr
);
5807 Set_UInt32( pData
, lcbPlcffldHdr
);
5808 Set_UInt32( pData
, fcPlcffldFtn
);
5809 Set_UInt32( pData
, lcbPlcffldFtn
);
5810 Set_UInt32( pData
, fcPlcffldAtn
);
5811 Set_UInt32( pData
, lcbPlcffldAtn
);
5812 Set_UInt32( pData
, fcPlcffldMcr
);
5813 Set_UInt32( pData
, lcbPlcffldMcr
);
5814 Set_UInt32( pData
, fcSttbfbkmk
);
5815 Set_UInt32( pData
, lcbSttbfbkmk
);
5816 Set_UInt32( pData
, fcPlcfbkf
);
5817 Set_UInt32( pData
, lcbPlcfbkf
);
5818 Set_UInt32( pData
, fcPlcfbkl
);
5819 Set_UInt32( pData
, lcbPlcfbkl
);
5820 Set_UInt32( pData
, fcCmds
);
5821 Set_UInt32( pData
, lcbCmds
);
5822 Set_UInt32( pData
, fcPlcfmcr
);
5823 Set_UInt32( pData
, lcbPlcfmcr
);
5824 Set_UInt32( pData
, fcSttbfmcr
);
5825 Set_UInt32( pData
, lcbSttbfmcr
);
5826 Set_UInt32( pData
, fcPrDrvr
);
5827 Set_UInt32( pData
, lcbPrDrvr
);
5828 Set_UInt32( pData
, fcPrEnvPort
);
5829 Set_UInt32( pData
, lcbPrEnvPort
);
5830 Set_UInt32( pData
, fcPrEnvLand
);
5831 Set_UInt32( pData
, lcbPrEnvLand
);
5832 Set_UInt32( pData
, fcWss
);
5833 Set_UInt32( pData
, lcbWss
);
5834 Set_UInt32( pData
, fcDop
);
5835 Set_UInt32( pData
, lcbDop
);
5836 Set_UInt32( pData
, fcSttbfAssoc
);
5837 Set_UInt32( pData
, lcbSttbfAssoc
);
5838 Set_UInt32( pData
, fcClx
);
5839 Set_UInt32( pData
, lcbClx
);
5840 Set_UInt32( pData
, fcPlcfpgdFtn
);
5841 Set_UInt32( pData
, lcbPlcfpgdFtn
);
5842 Set_UInt32( pData
, fcAutosaveSource
);
5843 Set_UInt32( pData
, lcbAutosaveSource
);
5844 Set_UInt32( pData
, fcGrpStAtnOwners
);
5845 Set_UInt32( pData
, lcbGrpStAtnOwners
);
5846 Set_UInt32( pData
, fcSttbfAtnbkmk
);
5847 Set_UInt32( pData
, lcbSttbfAtnbkmk
);
5849 // weiteres short nur bei Ver67 ueberspringen
5852 pData
+= 1*sizeof( INT16
);
5853 Set_UInt16( pData
, (UINT16
)pnChpFirst
);
5854 Set_UInt16( pData
, (UINT16
)pnPapFirst
);
5855 Set_UInt16( pData
, (UINT16
)cpnBteChp
);
5856 Set_UInt16( pData
, (UINT16
)cpnBtePap
);
5859 Set_UInt32( pData
, fcPlcfdoaMom
); // nur bei Ver67, in Ver8 unused
5860 Set_UInt32( pData
, lcbPlcfdoaMom
); // nur bei Ver67, in Ver8 unused
5861 Set_UInt32( pData
, fcPlcfdoaHdr
); // nur bei Ver67, in Ver8 unused
5862 Set_UInt32( pData
, lcbPlcfdoaHdr
); // nur bei Ver67, in Ver8 unused
5864 Set_UInt32( pData
, fcPlcfspaMom
); // in Ver67 leere Reserve
5865 Set_UInt32( pData
, lcbPlcfspaMom
); // in Ver67 leere Reserve
5866 Set_UInt32( pData
, fcPlcfspaHdr
); // in Ver67 leere Reserve
5867 Set_UInt32( pData
, lcbPlcfspaHdr
); // in Ver67 leere Reserve
5869 Set_UInt32( pData
, fcPlcfAtnbkf
);
5870 Set_UInt32( pData
, lcbPlcfAtnbkf
);
5871 Set_UInt32( pData
, fcPlcfAtnbkl
);
5872 Set_UInt32( pData
, lcbPlcfAtnbkl
);
5873 Set_UInt32( pData
, fcPms
);
5874 Set_UInt32( pData
, lcbPMS
);
5875 Set_UInt32( pData
, fcFormFldSttbf
);
5876 Set_UInt32( pData
, lcbFormFldSttbf
);
5877 Set_UInt32( pData
, fcPlcfendRef
);
5878 Set_UInt32( pData
, lcbPlcfendRef
);
5879 Set_UInt32( pData
, fcPlcfendTxt
);
5880 Set_UInt32( pData
, lcbPlcfendTxt
);
5881 Set_UInt32( pData
, fcPlcffldEdn
);
5882 Set_UInt32( pData
, lcbPlcffldEdn
);
5883 Set_UInt32( pData
, fcPlcfpgdEdn
);
5884 Set_UInt32( pData
, lcbPlcfpgdEdn
);
5885 Set_UInt32( pData
, fcDggInfo
); // in Ver67 leere Reserve
5886 Set_UInt32( pData
, lcbDggInfo
); // in Ver67 leere Reserve
5887 Set_UInt32( pData
, fcSttbfRMark
);
5888 Set_UInt32( pData
, lcbSttbfRMark
);
5889 Set_UInt32( pData
, fcSttbfCaption
);
5890 Set_UInt32( pData
, lcbSttbfCaption
);
5891 Set_UInt32( pData
, fcSttbAutoCaption
);
5892 Set_UInt32( pData
, lcbSttbAutoCaption
);
5893 Set_UInt32( pData
, fcPlcfwkb
);
5894 Set_UInt32( pData
, lcbPlcfwkb
);
5895 Set_UInt32( pData
, fcPlcfspl
); // in Ver67 leere Reserve
5896 Set_UInt32( pData
, lcbPlcfspl
); // in Ver67 leere Reserve
5897 Set_UInt32( pData
, fcPlcftxbxTxt
);
5898 Set_UInt32( pData
, lcbPlcftxbxTxt
);
5899 Set_UInt32( pData
, fcPlcffldTxbx
);
5900 Set_UInt32( pData
, lcbPlcffldTxbx
);
5901 Set_UInt32( pData
, fcPlcfHdrtxbxTxt
);
5902 Set_UInt32( pData
, lcbPlcfHdrtxbxTxt
);
5903 Set_UInt32( pData
, fcPlcffldHdrTxbx
);
5904 Set_UInt32( pData
, lcbPlcffldHdrTxbx
);
5908 pData
+= 0x2da - 0x27a; // Pos + Offset (fcPlcfLst - fcStwUser)
5909 Set_UInt32( pData
, fcSttbFnm
);
5910 Set_UInt32( pData
, lcbSttbFnm
);
5911 Set_UInt32( pData
, fcPlcfLst
);
5912 Set_UInt32( pData
, lcbPlcfLst
);
5913 Set_UInt32( pData
, fcPlfLfo
);
5914 Set_UInt32( pData
, lcbPlfLfo
);
5915 Set_UInt32( pData
, fcPlcftxbxBkd
);
5916 Set_UInt32( pData
, lcbPlcftxbxBkd
);
5917 Set_UInt32( pData
, fcPlcfHdrtxbxBkd
);
5918 Set_UInt32( pData
, lcbPlcfHdrtxbxBkd
);
5920 pData
+= 0x372 - 0x302; // Pos + Offset (fcSttbListNames - fcDocUndo)
5921 Set_UInt32( pData
, fcSttbListNames
);
5922 Set_UInt32( pData
, lcbSttbListNames
);
5924 pData
+= 0x382 - 0x37A;
5925 Set_UInt32( pData
, fcPlcfTch
);
5926 Set_UInt32( pData
, lcbPlcfTch
);
5928 pData
+= 0x3FA - 0x38A;
5929 Set_UInt16( pData
, (UINT16
)0x0002);
5930 Set_UInt16( pData
, (UINT16
)0x00D9);
5932 pData
+= 0x41A - 0x3FE;
5933 Set_UInt32( pData
, fcAtrdExtra
);
5934 Set_UInt32( pData
, lcbAtrdExtra
);
5936 pData
+= 0x4DA - 0x422;
5937 Set_UInt32( pData
, fcHplxsdr
);
5938 Set_UInt32( pData
, 0);
5941 rStrm
.Write( pDataPtr
, fcMin
- nUnencryptedHdr
);
5943 return 0 == rStrm
.GetError();
5946 rtl_TextEncoding
WW8Fib::GetFIBCharset(UINT16 chs
)
5948 ASSERT(chs
<= 0x100, "overflowed winword charset set");
5949 rtl_TextEncoding eCharSet
=
5951 ? RTL_TEXTENCODING_APPLE_ROMAN
5952 : rtl_getTextEncodingFromWindowsCharset( static_cast<BYTE
>(chs
) );
5956 WW8Style::WW8Style(SvStream
& rStream
, WW8Fib
& rFibPara
)
5957 : rFib(rFibPara
), rSt(rStream
), cstd(0), cbSTDBaseInFile(0),
5958 stiMaxWhenSaved(0), istdMaxFixedWhenSaved(0), nVerBuiltInNamesWhenSaved(0),
5959 ftcStandardChpStsh(0), ftcStandardChpCJKStsh(0), ftcStandardChpCTLStsh(0)
5961 nStyleStart
= rFib
.fcStshf
;
5962 nStyleLen
= rFib
.lcbStshf
;
5964 rSt
.Seek(nStyleStart
);
5966 USHORT cbStshi
= 0; // 2 bytes size of the following STSHI structure
5968 if (rFib
.GetFIBVersion() <= ww::eWW2
)
5973 else if (rFib
.nFib
< 67) // old Version ? (need to find this again to fix)
5974 cbStshi
= 4; // -> Laengenfeld fehlt
5975 else // neue Version:
5976 // lies die Laenge der in der Datei gespeicherten Struktur
5979 UINT16 nRead
= cbStshi
;
5984 if( 2 > nRead
) break;
5987 if( 4 > nRead
) break;
5988 rSt
>> cbSTDBaseInFile
;
5990 if( 6 > nRead
) break;
5992 fStdStylenamesWritten
= a16Bit
& 0x0001;
5994 if( 8 > nRead
) break;
5995 rSt
>> stiMaxWhenSaved
;
5997 if( 10 > nRead
) break;
5998 rSt
>> istdMaxFixedWhenSaved
;
6000 if( 12 > nRead
) break;
6001 rSt
>> nVerBuiltInNamesWhenSaved
;
6003 if( 14 > nRead
) break;
6004 rSt
>> ftcStandardChpStsh
;
6006 if( 16 > nRead
) break;
6007 rSt
>> ftcStandardChpCJKStsh
;
6009 if ( 18 > nRead
) break;
6010 rSt
>> ftcStandardChpCTLStsh
;
6012 // ggfs. den Rest ueberlesen
6014 rSt
.SeekRel( nRead
-18 );
6016 while( !this ); // Trick: obiger Block wird genau einmal durchlaufen
6017 // und kann vorzeitig per "break" verlassen werden.
6019 if( 0 != rSt
.GetError() )
6021 // wie denn nun den Error melden?
6025 // Read1STDFixed() liest ein Style ein. Wenn der Style vollstaendig vorhanden
6026 // ist, d.h. kein leerer Slot, dann wird Speicher alloziert und ein Pointer auf
6027 // die ( evtl. mit Nullen aufgefuellten ) STD geliefert. Ist es ein leerer
6028 // Slot, dann wird ein Nullpointer zurueckgeliefert.
6029 WW8_STD
* WW8Style::Read1STDFixed( short& rSkip
, short* pcbStd
)
6034 rSt
>> cbStd
; // lies Laenge
6036 UINT16 nRead
= cbSTDBaseInFile
;
6037 if( cbStd
>= cbSTDBaseInFile
)
6039 // Fixed part vollst. vorhanden
6041 // read fixed part of STD
6043 memset( pStd
, 0, sizeof( *pStd
) );
6049 if( 2 > nRead
) break;
6051 pStd
->sti
= a16Bit
& 0x0fff ;
6052 pStd
->fScratch
= 0 != ( a16Bit
& 0x1000 );
6053 pStd
->fInvalHeight
= 0 != ( a16Bit
& 0x2000 );
6054 pStd
->fHasUpe
= 0 != ( a16Bit
& 0x4000 );
6055 pStd
->fMassCopy
= 0 != ( a16Bit
& 0x8000 );
6057 if( 4 > nRead
) break;
6059 pStd
->sgc
= a16Bit
& 0x000f ;
6060 pStd
->istdBase
= ( a16Bit
& 0xfff0 ) >> 4;
6062 if( 6 > nRead
) break;
6064 pStd
->cupx
= a16Bit
& 0x000f ;
6065 pStd
->istdNext
= ( a16Bit
& 0xfff0 ) >> 4;
6067 if( 8 > nRead
) break;
6068 rSt
>> pStd
->bchUpe
;
6070 // ab Ver8 sollten diese beiden Felder dazukommen:
6071 if(10 > nRead
) break;
6073 pStd
->fAutoRedef
= a16Bit
& 0x0001 ;
6074 pStd
->fHidden
= ( a16Bit
& 0x0002 ) >> 2;
6076 // man kann nie wissen: vorsichtshalber ueberlesen
6077 // wir eventuelle Fuellsel, die noch zum BASE-Part gehoeren...
6079 rSt
.SeekRel( nRead
-10 );
6081 while( !this ); // Trick: obiger Block wird genau einmal durchlaufen
6082 // und kann vorzeitig per "break" verlassen werden.
6084 if( (0 != rSt
.GetError()) || !nRead
)
6085 DELETEZ( pStd
); // per NULL den Error melden
6087 rSkip
= cbStd
- cbSTDBaseInFile
;
6090 { // Fixed part zu kurz
6092 rSt
.SeekRel( cbStd
); // ueberlies Reste
6100 WW8_STD
* WW8Style::Read1Style( short& rSkip
, String
* pString
, short* pcbStd
)
6102 // Attention: MacWord-Documents have their Stylenames
6103 // always in ANSI, even if eStructCharSet == CHARSET_MAC !!
6105 WW8_STD
* pStd
= Read1STDFixed( rSkip
, pcbStd
); // lese STD
6107 // String gewuenscht ?
6112 switch( rFib
.nVersion
)
6116 // lies Pascal-String
6117 *pString
= WW8ReadPString( rSt
, RTL_TEXTENCODING_MS_1252
);
6118 // leading len and trailing zero --> 2
6119 rSkip
-= 2+ pString
->Len();
6122 // handle Unicode-String with leading length short and
6124 if (ww8String::TestBeltAndBraces(rSt
))
6126 *pString
= WW8Read_xstz(rSt
, 0, true);
6127 rSkip
-= (pString
->Len() + 2) * 2;
6133 This is supposed to be impossible, its just supposed
6134 to be 16 bit count followed by the string and ending
6135 in a 0 short. But "Lotus SmartSuite Product: Word Pro"
6136 is creating invalid style names in ww7- format. So we
6137 use the belt and braces of the ms strings to see if
6138 they are not corrupt. If they are then we try them as
6141 *pString
= WW8ReadPString(rSt
,RTL_TEXTENCODING_MS_1252
);
6142 // leading len and trailing zero --> 2
6143 rSkip
-= 2+ pString
->Len();
6147 ASSERT(!this, "Es wurde vergessen, nVersion zu kodieren!");
6152 *pString
= aEmptyStr
; // Kann keinen Namen liefern
6158 //-----------------------------------------
6161 struct WW8_FFN_Ver6
: public WW8_FFN_BASE
6164 sal_Char szFfn
[65]; // 0x6 bzw. 0x40 ab Ver8 zero terminated string that
6165 // records name of font.
6166 // Maximal size of szFfn is 65 characters.
6167 // Vorsicht: Dieses Array kann auch kleiner sein!!!
6168 // Possibly followed by a second sz which records the
6169 // name of an alternate font to use if the first named
6170 // font does not exist on this system.
6172 struct WW8_FFN_Ver8
: public WW8_FFN_BASE
6174 // ab Ver8 sind folgende beiden Felder eingeschoben,
6175 // werden von uns ignoriert.
6176 sal_Char panose
[ 10 ]; // 0x6 PANOSE
6177 sal_Char fs
[ 24 ]; // 0x10 FONTSIGNATURE
6179 // ab Ver8 als Unicode
6180 UINT16 szFfn
[65]; // 0x6 bzw. 0x40 ab Ver8 zero terminated string that
6181 // records name of font.
6182 // Maximal size of szFfn is 65 characters.
6183 // Vorsicht: Dieses Array kann auch kleiner sein!!!
6184 // Possibly followed by a second sz which records the
6185 // name of an alternate font to use if the first named
6186 // font does not exist on this system.
6189 // #i43762# check font name for illegal characters
6190 void lcl_checkFontname( String
& sString
)
6192 // for efficiency, we'd like to use String methods as far as possible.
6194 // 1) convert all invalid chars to \u0001
6195 // 2) then erase all \u0001 chars (if any were found), and
6196 // 3) erase leading/trailing ';', in case a font name was
6197 // completely removed
6199 // convert all invalid chars to \u0001
6200 sal_Unicode
* pBuffer
= sString
.GetBufferAccess();
6201 xub_StrLen nLen
= sString
.Len();
6202 bool bFound
= false;
6203 for( xub_StrLen n
= 0; n
< nLen
; n
++ )
6205 if( pBuffer
[n
] < sal_Unicode( 0x20 ) )
6207 pBuffer
[n
] = sal_Unicode( 1 );
6211 sString
.ReleaseBufferAccess();
6213 // if anything was found, remove \u0001 + leading/trailing ';'
6216 sString
.EraseAllChars( sal_Unicode( 1 ) );
6217 sString
.EraseLeadingAndTrailingChars( sal_Unicode( ';' ) );
6221 WW8Fonts::WW8Fonts( SvStream
& rSt
, WW8Fib
& rFib
)
6222 : pFontA(0), nMax(0)
6224 // Attention: MacWord-Documents have their Fontnames
6225 // always in ANSI, even if eStructCharSet == CHARSET_MAC !!
6226 if( rFib
.lcbSttbfffn
<= 2 )
6228 ASSERT( !this, "Fonttabelle kaputt! (rFib.lcbSttbfffn < 2)" );
6234 rSt
.Seek( rFib
.fcSttbfffn
);
6236 // allocate Font Array
6237 BYTE
* pA
= new BYTE
[ rFib
.lcbSttbfffn
- 2 ];
6238 WW8_FFN
* p
= (WW8_FFN
*)pA
;
6240 ww::WordVersion eVersion
= rFib
.GetFIBVersion();
6242 if( eVersion
>= ww::eWW8
)
6244 // bVer8: read the count of strings in nMax
6248 // Ver8: skip undefined uint16
6249 // Ver67: skip the herein stored total byte of structure
6250 // - we already got that information in rFib.lcbSttbfffn
6253 // read all font information
6254 rSt
.Read( pA
, rFib
.lcbSttbfffn
- 2 );
6256 if( eVersion
< ww::eWW8
)
6258 // try to figure out how many fonts are defined here
6260 long nLeft
= rFib
.lcbSttbfffn
- 2;
6265 nNextSiz
= p
->cbFfnM1
+ 1;
6266 if( nNextSiz
> nLeft
)
6270 if( nLeft
< 1 ) // can we read the given ammount of bytes ?
6272 // increase p by nNextSiz Bytes
6273 p
= (WW8_FFN
*)( ( (BYTE
*)p
) + nNextSiz
);
6279 // allocate Index Array
6280 pFontA
= new WW8_FFN
[ nMax
];
6283 if( eVersion
<= ww::eWW2
)
6285 WW8_FFN_BASE
* pVer2
= (WW8_FFN_BASE
*)pA
;
6286 for(USHORT i
=0; i
<nMax
; ++i
, ++p
)
6288 p
->cbFfnM1
= pVer2
->cbFfnM1
;
6294 p
->wWeight
= ( *(((BYTE
*)pVer2
) + 1) );
6295 p
->chs
= ( *(((BYTE
*)pVer2
) + 2) );
6297 #i8726# 7- seems to encode the name in the same encoding as
6298 the font, e.g load the doc in 97 and save to see the unicode
6299 ver of the asian fontnames in that example to confirm.
6301 rtl_TextEncoding eEnc
= WW8Fib::GetFIBCharset(p
->chs
);
6302 if ((eEnc
== RTL_TEXTENCODING_SYMBOL
) || (eEnc
== RTL_TEXTENCODING_DONTKNOW
))
6303 eEnc
= RTL_TEXTENCODING_MS_1252
;
6305 p
->sFontname
= String ( (((const sal_Char
*)pVer2
) + 1 + 2), eEnc
);
6306 pVer2
= (WW8_FFN_BASE
*)( ((BYTE
*)pVer2
) + pVer2
->cbFfnM1
+ 1 );
6309 else if( eVersion
< ww::eWW8
)
6311 WW8_FFN_Ver6
* pVer6
= (WW8_FFN_Ver6
*)pA
;
6313 for(USHORT i
=0; i
<nMax
; ++i
, ++p
)
6315 p
->cbFfnM1
= pVer6
->cbFfnM1
;
6316 c2
= *(((BYTE
*)pVer6
) + 1);
6319 p
->fTrueType
= (c2
& 0x04) >> 2;
6320 // ein Reserve-Bit ueberspringen
6321 p
->ff
= (c2
& 0x70) >> 4;
6323 p
->wWeight
= SVBT16ToShort( *(SVBT16
*)&pVer6
->wWeight
);
6324 p
->chs
= pVer6
->chs
;
6325 p
->ibszAlt
= pVer6
->ibszAlt
;
6327 #i8726# 7- seems to encode the name in the same encoding as
6328 the font, e.g load the doc in 97 and save to see the unicode
6329 ver of the asian fontnames in that example to confirm.
6331 rtl_TextEncoding eEnc
= WW8Fib::GetFIBCharset(p
->chs
);
6332 if ((eEnc
== RTL_TEXTENCODING_SYMBOL
) || (eEnc
== RTL_TEXTENCODING_DONTKNOW
))
6333 eEnc
= RTL_TEXTENCODING_MS_1252
;
6334 p
->sFontname
= String(pVer6
->szFfn
, eEnc
);
6337 p
->sFontname
.Append(';');
6338 p
->sFontname
+= String(pVer6
->szFfn
+p
->ibszAlt
, eEnc
);
6342 //#i18369# if its a symbol font set Symbol as fallback
6344 RTL_TEXTENCODING_SYMBOL
== WW8Fib::GetFIBCharset(p
->chs
)
6345 && !p
->sFontname
.EqualsAscii("Symbol")
6348 p
->sFontname
.APPEND_CONST_ASC(";Symbol");
6351 pVer6
= (WW8_FFN_Ver6
*)( ((BYTE
*)pVer6
) + pVer6
->cbFfnM1
+ 1 );
6356 WW8_FFN_Ver8
* pVer8
= (WW8_FFN_Ver8
*)pA
;
6358 for(USHORT i
=0; i
<nMax
; ++i
, ++p
)
6360 p
->cbFfnM1
= pVer8
->cbFfnM1
;
6361 c2
= *(((BYTE
*)pVer8
) + 1);
6364 p
->fTrueType
= (c2
& 0x04) >> 2;
6365 // ein Reserve-Bit ueberspringen
6366 p
->ff
= (c2
& 0x70) >> 4;
6368 p
->wWeight
= SVBT16ToShort( *(SVBT16
*)&pVer8
->wWeight
);
6369 p
->chs
= pVer8
->chs
;
6370 p
->ibszAlt
= pVer8
->ibszAlt
;
6372 #ifdef __WW8_NEEDS_COPY
6375 for( UINT16
* pTmp
= pVer8
->szFfn
;
6376 nLen
< pVer8
->cbFfnM1
+ 1 ; ++pTmp
, nLen
+=2 )
6378 *pTmp
= SVBT16ToShort( *(SVBT16
*)pTmp
);
6381 #endif // defined __WW8_NEEDS_COPY
6383 p
->sFontname
= pVer8
->szFfn
;
6386 p
->sFontname
.Append(';');
6387 p
->sFontname
.Append(pVer8
->szFfn
+p
->ibszAlt
);
6390 // #i43762# check font name for illegal characters
6391 lcl_checkFontname( p
->sFontname
);
6393 // Zeiger auf Ursprungsarray einen Font nach hinten setzen
6394 pVer8
= (WW8_FFN_Ver8
*)( ((BYTE
*)pVer8
) + pVer8
->cbFfnM1
+ 1 );
6401 const WW8_FFN
* WW8Fonts::GetFont( USHORT nNum
) const
6403 if( !pFontA
|| nNum
>= nMax
)
6406 return &pFontA
[ nNum
];
6411 //-----------------------------------------
6414 // Suche zu einem Header / Footer den Index in der WW-Liste von Headern / Footern
6416 // Pferdefuesse bei WinWord6 und -7:
6417 // 1) Am Anfang des Einlesens muss WWPLCF_HdFt mit Fib und Dop konstruiert werden
6418 // 2) Der Haupttext muss sequentiell ueber alle Sections gelesen werden
6419 // 3) Fuer jedes vorkommende Header / Footer - Attribut des Haupttextes
6420 // ( Darf pro Section maximal eins sein ) muss UpdateIndex() genau einmal
6421 // mit dem Parameter des Attributes gerufen werden. Dieser Aufruf muss *nach*
6422 // dem letzten Aufruf von GetTextPos() passieren.
6423 // 4) GetTextPos() darf mit genau einem der obenstehen WW_... aufgerufen werden
6424 // ( nicht verodern ! )
6425 // -> dann liefert GetTextPos() vielleicht auch ein richtiges Ergebnis
6427 WW8PLCF_HdFt::WW8PLCF_HdFt( SvStream
* pSt
, WW8Fib
& rFib
, WW8Dop
& rDop
)
6428 : aPLCF( pSt
, rFib
.fcPlcfhdd
, rFib
.lcbPlcfhdd
, 0 )
6433 cmc 23/02/2000: This dop.grpfIhdt has a bit set for each special
6434 footnote *and endnote!!* seperator,continuation seperator, and
6435 continuation notice entry, the documentation does not mention the
6436 endnote seperators, the documentation also gets the index numbers
6437 backwards when specifiying which bits to test. The bottom six bits
6438 of this value must be tested and skipped over. Each section's
6439 grpfIhdt is then tested for the existence of the appropiate headers
6440 and footers, at the end of each section the nIdxOffset must be updated
6441 to point to the beginning of the next section's group of headers and
6442 footers in this PLCF, UpdateIndex does that task.
6444 for( BYTE nI
= 0x1; nI
<= 0x20; nI
<<= 1 )
6445 if( nI
& rDop
.grpfIhdt
) // Bit gesetzt ?
6448 nTextOfs
= rFib
.ccpText
+ rFib
.ccpFtn
; // Groesse des Haupttextes
6449 // und der Fussnoten
6452 bool WW8PLCF_HdFt::GetTextPos(BYTE grpfIhdt
, BYTE nWhich
, WW8_CP
& rStart
,
6456 short nIdx
= nIdxOffset
;
6462 nIdx
++; // uninteresting Header / Footer
6463 nI
<<= 1; // text next bit
6465 return false; // not found
6467 // nIdx ist HdFt-Index
6471 aPLCF
.SetIdx( nIdx
); // Lookup suitable CP
6472 aPLCF
.Get( rStart
, nEnd
, pData
);
6473 rLen
= nEnd
- rStart
;
6479 bool WW8PLCF_HdFt::GetTextPosExact(short nIdx
, WW8_CP
& rStart
, long& rLen
)
6484 aPLCF
.SetIdx( nIdx
); // Lookup suitable CP
6485 aPLCF
.Get( rStart
, nEnd
, pData
);
6486 rLen
= nEnd
- rStart
;
6490 void WW8PLCF_HdFt::UpdateIndex( BYTE grpfIhdt
)
6492 // Caution: Description is not correct
6493 for( BYTE nI
= 0x01; nI
<= 0x20; nI
<<= 1 )
6498 //-----------------------------------------
6500 //-----------------------------------------
6502 WW8Dop::WW8Dop(SvStream
& rSt
, INT16 nFib
, INT32 nPos
, sal_uInt32 nSize
) : bUseThaiLineBreakingRules(false)
6504 memset( &nDataStart
, 0, (&nDataEnd
- &nDataStart
) );
6505 fDontUseHTMLAutoSpacing
= true; //default
6506 fAcetateShowAtn
= true; //default
6507 const sal_uInt32 nMaxDopSize
= 0x268;
6508 BYTE
* pDataPtr
= new BYTE
[ nMaxDopSize
];
6509 BYTE
* pData
= pDataPtr
;
6511 sal_uInt32 nRead
= nMaxDopSize
< nSize
? nMaxDopSize
: nSize
;
6513 if (2 > nSize
|| nRead
!= rSt
.Read(pData
, nRead
))
6514 nDopError
= ERR_SWG_READ_ERROR
; // Error melden
6517 if (nMaxDopSize
> nRead
)
6518 memset( pData
+ nRead
, 0, nMaxDopSize
- nRead
);
6520 // dann mal die Daten auswerten
6525 a16Bit
= Get_UShort( pData
); // 0 0x00
6526 fFacingPages
= 0 != ( a16Bit
& 0x0001 ) ;
6527 fWidowControl
= 0 != ( a16Bit
& 0x0002 ) ;
6528 fPMHMainDoc
= 0 != ( a16Bit
& 0x0004 ) ;
6529 grfSuppression
= ( a16Bit
& 0x0018 ) >> 3;
6530 fpc
= ( a16Bit
& 0x0060 ) >> 5;
6531 grpfIhdt
= ( a16Bit
& 0xff00 ) >> 8;
6533 a16Bit
= Get_UShort( pData
); // 2 0x02
6534 rncFtn
= a16Bit
& 0x0003 ;
6535 nFtn
= ( a16Bit
& ~0x0003 ) >> 2 ;
6537 a8Bit
= Get_Byte( pData
); // 4 0x04
6538 fOutlineDirtySave
= 0 != ( a8Bit
& 0x01 );
6540 a8Bit
= Get_Byte( pData
); // 5 0x05
6541 fOnlyMacPics
= 0 != ( a8Bit
& 0x01 );
6542 fOnlyWinPics
= 0 != ( a8Bit
& 0x02 );
6543 fLabelDoc
= 0 != ( a8Bit
& 0x04 );
6544 fHyphCapitals
= 0 != ( a8Bit
& 0x08 );
6545 fAutoHyphen
= 0 != ( a8Bit
& 0x10 );
6546 fFormNoFields
= 0 != ( a8Bit
& 0x20 );
6547 fLinkStyles
= 0 != ( a8Bit
& 0x40 );
6548 fRevMarking
= 0 != ( a8Bit
& 0x80 );
6550 a8Bit
= Get_Byte( pData
); // 6 0x06
6551 fBackup
= 0 != ( a8Bit
& 0x01 );
6552 fExactCWords
= 0 != ( a8Bit
& 0x02 );
6553 fPagHidden
= 0 != ( a8Bit
& 0x04 );
6554 fPagResults
= 0 != ( a8Bit
& 0x08 );
6555 fLockAtn
= 0 != ( a8Bit
& 0x10 );
6556 fMirrorMargins
= 0 != ( a8Bit
& 0x20 );
6557 fReadOnlyRecommended
= 0 != ( a8Bit
& 0x40 );
6558 fDfltTrueType
= 0 != ( a8Bit
& 0x80 );
6560 a8Bit
= Get_Byte( pData
); // 7 0x07
6561 fPagSuppressTopSpacing
= 0 != ( a8Bit
& 0x01 );
6562 fProtEnabled
= 0 != ( a8Bit
& 0x02 );
6563 fDispFormFldSel
= 0 != ( a8Bit
& 0x04 );
6564 fRMView
= 0 != ( a8Bit
& 0x08 );
6565 fRMPrint
= 0 != ( a8Bit
& 0x10 );
6566 fWriteReservation
= 0 != ( a8Bit
& 0x20 );
6567 fLockRev
= 0 != ( a8Bit
& 0x40 );
6568 fEmbedFonts
= 0 != ( a8Bit
& 0x80 );
6571 a8Bit
= Get_Byte( pData
); // 8 0x08
6572 copts_fNoTabForInd
= 0 != ( a8Bit
& 0x01 );
6573 copts_fNoSpaceRaiseLower
= 0 != ( a8Bit
& 0x02 );
6574 copts_fSupressSpbfAfterPgBrk
= 0 != ( a8Bit
& 0x04 );
6575 copts_fWrapTrailSpaces
= 0 != ( a8Bit
& 0x08 );
6576 copts_fMapPrintTextColor
= 0 != ( a8Bit
& 0x10 );
6577 copts_fNoColumnBalance
= 0 != ( a8Bit
& 0x20 );
6578 copts_fConvMailMergeEsc
= 0 != ( a8Bit
& 0x40 );
6579 copts_fSupressTopSpacing
= 0 != ( a8Bit
& 0x80 );
6581 a8Bit
= Get_Byte( pData
); // 9 0x09
6582 copts_fOrigWordTableRules
= 0 != ( a8Bit
& 0x01 );
6583 copts_fTransparentMetafiles
= 0 != ( a8Bit
& 0x02 );
6584 copts_fShowBreaksInFrames
= 0 != ( a8Bit
& 0x04 );
6585 copts_fSwapBordersFacingPgs
= 0 != ( a8Bit
& 0x08 );
6586 copts_fExpShRtn
= 0 != ( a8Bit
& 0x20 ); // #i56856#
6588 dxaTab
= Get_Short( pData
); // 10 0x0a
6589 wSpare
= Get_UShort( pData
); // 12 0x0c
6590 dxaHotZ
= Get_UShort( pData
); // 14 0x0e
6591 cConsecHypLim
= Get_UShort( pData
); // 16 0x10
6592 wSpare2
= Get_UShort( pData
); // 18 0x12
6593 dttmCreated
= Get_Long( pData
); // 20 0x14
6594 dttmRevised
= Get_Long( pData
); // 24 0x18
6595 dttmLastPrint
= Get_Long( pData
); // 28 0x1c
6596 nRevision
= Get_Short( pData
); // 32 0x20
6597 tmEdited
= Get_Long( pData
); // 34 0x22
6598 cWords
= Get_Long( pData
); // 38 0x26
6599 cCh
= Get_Long( pData
); // 42 0x2a
6600 cPg
= Get_Short( pData
); // 46 0x2e
6601 cParas
= Get_Long( pData
); // 48 0x30
6603 a16Bit
= Get_UShort( pData
); // 52 0x34
6604 rncEdn
= a16Bit
& 0x0003 ;
6605 nEdn
= ( a16Bit
& ~0x0003 ) >> 2;
6607 a16Bit
= Get_UShort( pData
); // 54 0x36
6608 epc
= a16Bit
& 0x0003 ;
6609 nfcFtnRef
= ( a16Bit
& 0x003c ) >> 2;
6610 nfcEdnRef
= ( a16Bit
& 0x03c0 ) >> 6;
6611 fPrintFormData
= 0 != ( a16Bit
& 0x0400 );
6612 fSaveFormData
= 0 != ( a16Bit
& 0x0800 );
6613 fShadeFormData
= 0 != ( a16Bit
& 0x1000 );
6614 fWCFtnEdn
= 0 != ( a16Bit
& 0x8000 );
6616 cLines
= Get_Long( pData
); // 56 0x38
6617 cWordsFtnEnd
= Get_Long( pData
); // 60 0x3c
6618 cChFtnEdn
= Get_Long( pData
); // 64 0x40
6619 cPgFtnEdn
= Get_Short( pData
); // 68 0x44
6620 cParasFtnEdn
= Get_Long( pData
); // 70 0x46
6621 cLinesFtnEdn
= Get_Long( pData
); // 74 0x4a
6622 lKeyProtDoc
= Get_Long( pData
); // 78 0x4e
6624 a16Bit
= Get_UShort( pData
); // 82 0x52
6625 wvkSaved
= a16Bit
& 0x0007 ;
6626 wScaleSaved
= ( a16Bit
& 0x0ff8 ) >> 3 ;
6627 zkSaved
= ( a16Bit
& 0x3000 ) >> 12;
6628 fRotateFontW6
= ( a16Bit
& 0x4000 ) >> 14;
6629 iGutterPos
= ( a16Bit
& 0x8000 ) >> 15;
6631 bei nFib >= 103 gehts weiter:
6633 if (nFib
>= 103) // Word 6/32bit, 95, 97, 2000, 2002, 2003, 2007
6635 a32Bit
= Get_ULong( pData
); // 84 0x54
6636 SetCompatabilityOptions(a32Bit
);
6639 //#i22436#, for all WW7- documents
6640 if (nFib
<= 104) // Word 95
6641 fUsePrinterMetrics
= 1;
6644 bei nFib > 105 gehts weiter:
6646 if (nFib
> 105) // Word 97, 2000, 2002, 2003, 2007
6648 adt
= Get_Short( pData
); // 88 0x58
6650 doptypography
.ReadFromMem(pData
); // 90 0x5a
6652 memcpy( &dogrid
, pData
, sizeof( WW8_DOGRID
)); // 400 0x190
6653 pData
+= sizeof( WW8_DOGRID
);
6655 a16Bit
= Get_UShort( pData
); // 410 0x19a
6656 // die untersten 9 Bit sind uninteressant
6657 fHtmlDoc
= ( a16Bit
& 0x0200 ) >> 9 ;
6658 fSnapBorder
= ( a16Bit
& 0x0800 ) >> 11 ;
6659 fIncludeHeader
= ( a16Bit
& 0x1000 ) >> 12 ;
6660 fIncludeFooter
= ( a16Bit
& 0x2000 ) >> 13 ;
6661 fForcePageSizePag
= ( a16Bit
& 0x4000 ) >> 14 ;
6662 fMinFontSizePag
= ( a16Bit
& 0x8000 ) >> 15 ;
6664 a16Bit
= Get_UShort( pData
); // 412 0x19c
6665 fHaveVersions
= 0 != ( a16Bit
& 0x0001 );
6666 fAutoVersion
= 0 != ( a16Bit
& 0x0002 );
6668 pData
+= 12; // 414 0x19e
6670 cChWS
= Get_Long( pData
); // 426 0x1aa
6671 cChWSFtnEdn
= Get_Long( pData
); // 430 0x1ae
6672 grfDocEvents
= Get_Long( pData
); // 434 0x1b2
6674 pData
+= 4+30+8; // 438 0x1b6; 442 0x1ba; 472 0x1d8; 476 0x1dc
6676 cDBC
= Get_Long( pData
); // 480 0x1e0
6677 cDBCFtnEdn
= Get_Long( pData
); // 484 0x1e4
6679 pData
+= 1 * sizeof( INT32
); // 488 0x1e8
6681 nfcFtnRef
= Get_Short( pData
); // 492 0x1ec
6682 nfcEdnRef
= Get_Short( pData
); // 494 0x1ee
6683 hpsZoonFontPag
= Get_Short( pData
); // 496 0x1f0
6684 dywDispPag
= Get_Short( pData
); // 498 0x1f2
6688 //500 -> 508, Appear to be repeated here in 2000+
6689 pData
+= 8; // 500 0x1f4
6690 a32Bit
= Get_Long( pData
); // 508 0x1fc
6691 SetCompatabilityOptions(a32Bit
);
6692 a32Bit
= Get_Long( pData
); // 512 0x200
6695 // fDontUseHTMLAutoSpacing = (a32Bit & 0x4) >> 2;
6696 SetCompatabilityOptions2(a32Bit
);
6701 a16Bit
= Get_UShort( pData
);
6702 fDoNotEmbedSystemFont
= ( a16Bit
& 0x0001 );
6703 fWordCompat
= ( a16Bit
& 0x0002 ) >> 1;
6704 fLiveRecover
= ( a16Bit
& 0x0004 ) >> 2;
6705 fEmbedFactoids
= ( a16Bit
& 0x0008 ) >> 3;
6706 fFactoidXML
= ( a16Bit
& 0x00010 ) >> 4;
6707 fFactoidAllDone
= ( a16Bit
& 0x0020 ) >> 5;
6708 fFolioPrint
= ( a16Bit
& 0x0040 ) >> 6;
6709 fReverseFolio
= ( a16Bit
& 0x0080 ) >> 7;
6710 iTextLineEnding
= ( a16Bit
& 0x0700 ) >> 8;
6711 fHideFcc
= ( a16Bit
& 0x0800 ) >> 11;
6712 fAcetateShowMarkup
= ( a16Bit
& 0x1000 ) >> 12;
6713 fAcetateShowAtn
= ( a16Bit
& 0x2000 ) >> 13;
6714 fAcetateShowInsDel
= ( a16Bit
& 0x4000 ) >> 14;
6715 fAcetateShowProps
= ( a16Bit
& 0x8000 ) >> 15;
6720 a16Bit
= Get_Short(pData
);
6721 fUseBackGroundInAllmodes
= (a16Bit
& 0x0080) >> 7;
6728 WW8Dop::WW8Dop() : bUseThaiLineBreakingRules(false)
6730 // first set everything to a default of 0
6731 memset( &nDataStart
, 0, (&nDataEnd
- &nDataStart
) );
6736 fOutlineDirtySave
= 1;
6744 Writer acts like this all the time at the moment, ideally we need an
6745 option for these two as well to import word docs that are not like
6749 fUsePrinterMetrics
= 1;
6771 cChWSFtnEdn
= /**!!**/ 0;
6774 cDBCFtnEdn
= /**!!**/ 0;
6776 fAcetateShowAtn
= true;
6779 void WW8Dop::SetCompatabilityOptions(UINT32 a32Bit
)
6781 fNoTabForInd
= ( a32Bit
& 0x00000001 ) ;
6782 fNoSpaceRaiseLower
= ( a32Bit
& 0x00000002 ) >> 1 ;
6783 fSupressSpbfAfterPageBreak
= ( a32Bit
& 0x00000004 ) >> 2 ;
6784 fWrapTrailSpaces
= ( a32Bit
& 0x00000008 ) >> 3 ;
6785 fMapPrintTextColor
= ( a32Bit
& 0x00000010 ) >> 4 ;
6786 fNoColumnBalance
= ( a32Bit
& 0x00000020 ) >> 5 ;
6787 fConvMailMergeEsc
= ( a32Bit
& 0x00000040 ) >> 6 ;
6788 fSupressTopSpacing
= ( a32Bit
& 0x00000080 ) >> 7 ;
6789 fOrigWordTableRules
= ( a32Bit
& 0x00000100 ) >> 8 ;
6790 fTransparentMetafiles
= ( a32Bit
& 0x00000200 ) >> 9 ;
6791 fShowBreaksInFrames
= ( a32Bit
& 0x00000400 ) >> 10 ;
6792 fSwapBordersFacingPgs
= ( a32Bit
& 0x00000800 ) >> 11 ;
6793 fCompatabilityOptions_Unknown1_13
= ( a32Bit
& 0x00001000 ) >> 12 ;
6794 fExpShRtn
= ( a32Bit
& 0x00002000 ) >> 13 ; // #i56856#
6795 fCompatabilityOptions_Unknown1_15
= ( a32Bit
& 0x00004000 ) >> 14 ;
6796 fCompatabilityOptions_Unknown1_16
= ( a32Bit
& 0x00008000 ) >> 15 ;
6797 fSuppressTopSpacingMac5
= ( a32Bit
& 0x00010000 ) >> 16 ;
6798 fTruncDxaExpand
= ( a32Bit
& 0x00020000 ) >> 17 ;
6799 fPrintBodyBeforeHdr
= ( a32Bit
& 0x00040000 ) >> 18 ;
6800 fNoLeading
= ( a32Bit
& 0x00080000 ) >> 19 ;
6801 fCompatabilityOptions_Unknown1_21
= ( a32Bit
& 0x00100000 ) >> 20 ;
6802 fMWSmallCaps
= ( a32Bit
& 0x00200000 ) >> 21 ;
6803 fCompatabilityOptions_Unknown1_23
= ( a32Bit
& 0x00400000 ) >> 22 ;
6804 fCompatabilityOptions_Unknown1_24
= ( a32Bit
& 0x00800800 ) >> 23 ;
6805 fCompatabilityOptions_Unknown1_25
= ( a32Bit
& 0x01000000 ) >> 24 ;
6806 fCompatabilityOptions_Unknown1_26
= ( a32Bit
& 0x02000000 ) >> 25 ;
6807 fCompatabilityOptions_Unknown1_27
= ( a32Bit
& 0x04000000 ) >> 26 ;
6808 fCompatabilityOptions_Unknown1_28
= ( a32Bit
& 0x08000000 ) >> 27 ;
6809 fCompatabilityOptions_Unknown1_29
= ( a32Bit
& 0x10000000 ) >> 28 ;
6810 fCompatabilityOptions_Unknown1_30
= ( a32Bit
& 0x20000000 ) >> 29 ;
6811 fCompatabilityOptions_Unknown1_31
= ( a32Bit
& 0x40000000 ) >> 30 ;
6813 fUsePrinterMetrics
= ( a32Bit
& 0x80000000 ) >> 31 ;
6816 UINT32
WW8Dop::GetCompatabilityOptions() const
6819 if (fNoTabForInd
) a32Bit
|= 0x00000001;
6820 if (fNoSpaceRaiseLower
) a32Bit
|= 0x00000002;
6821 if (fSupressSpbfAfterPageBreak
) a32Bit
|= 0x00000004;
6822 if (fWrapTrailSpaces
) a32Bit
|= 0x00000008;
6823 if (fMapPrintTextColor
) a32Bit
|= 0x00000010;
6824 if (fNoColumnBalance
) a32Bit
|= 0x00000020;
6825 if (fConvMailMergeEsc
) a32Bit
|= 0x00000040;
6826 if (fSupressTopSpacing
) a32Bit
|= 0x00000080;
6827 if (fOrigWordTableRules
) a32Bit
|= 0x00000100;
6828 if (fTransparentMetafiles
) a32Bit
|= 0x00000200;
6829 if (fShowBreaksInFrames
) a32Bit
|= 0x00000400;
6830 if (fSwapBordersFacingPgs
) a32Bit
|= 0x00000800;
6831 if (fCompatabilityOptions_Unknown1_13
) a32Bit
|= 0x00001000;
6832 if (fExpShRtn
) a32Bit
|= 0x00002000; // #i56856#
6833 if (fCompatabilityOptions_Unknown1_15
) a32Bit
|= 0x00004000;
6834 if (fCompatabilityOptions_Unknown1_16
) a32Bit
|= 0x00008000;
6835 if (fSuppressTopSpacingMac5
) a32Bit
|= 0x00010000;
6836 if (fTruncDxaExpand
) a32Bit
|= 0x00020000;
6837 if (fPrintBodyBeforeHdr
) a32Bit
|= 0x00040000;
6838 if (fNoLeading
) a32Bit
|= 0x00080000;
6839 if (fCompatabilityOptions_Unknown1_21
) a32Bit
|= 0x00100000;
6840 if (fMWSmallCaps
) a32Bit
|= 0x00200000;
6841 if (fCompatabilityOptions_Unknown1_23
) a32Bit
|= 0x00400000;
6842 if (fCompatabilityOptions_Unknown1_24
) a32Bit
|= 0x00800000;
6843 if (fCompatabilityOptions_Unknown1_25
) a32Bit
|= 0x01000000;
6844 if (fCompatabilityOptions_Unknown1_26
) a32Bit
|= 0x02000000;
6845 if (fCompatabilityOptions_Unknown1_27
) a32Bit
|= 0x04000000;
6846 if (fCompatabilityOptions_Unknown1_28
) a32Bit
|= 0x08000000;
6847 if (fCompatabilityOptions_Unknown1_29
) a32Bit
|= 0x10000000;
6848 if (fCompatabilityOptions_Unknown1_30
) a32Bit
|= 0x20000000;
6849 if (fCompatabilityOptions_Unknown1_31
) a32Bit
|= 0x40000000;
6850 if (fUsePrinterMetrics
) a32Bit
|= 0x80000000;
6855 void WW8Dop::SetCompatabilityOptions2(UINT32 a32Bit
)
6857 fCompatabilityOptions_Unknown2_1
= ( a32Bit
& 0x00000001 );
6858 fCompatabilityOptions_Unknown2_2
= ( a32Bit
& 0x00000002 ) >> 1 ;
6859 fDontUseHTMLAutoSpacing
= ( a32Bit
& 0x00000004 ) >> 2 ;
6860 fCompatabilityOptions_Unknown2_4
= ( a32Bit
& 0x00000008 ) >> 3 ;
6861 fCompatabilityOptions_Unknown2_5
= ( a32Bit
& 0x00000010 ) >> 4 ;
6862 fCompatabilityOptions_Unknown2_6
= ( a32Bit
& 0x00000020 ) >> 5 ;
6863 fCompatabilityOptions_Unknown2_7
= ( a32Bit
& 0x00000040 ) >> 6 ;
6864 fCompatabilityOptions_Unknown2_8
= ( a32Bit
& 0x00000080 ) >> 7 ;
6865 fCompatabilityOptions_Unknown2_9
= ( a32Bit
& 0x00000100 ) >> 8 ;
6866 fCompatabilityOptions_Unknown2_10
= ( a32Bit
& 0x00000200 ) >> 9 ;
6867 fCompatabilityOptions_Unknown2_11
= ( a32Bit
& 0x00000400 ) >> 10 ;
6868 fCompatabilityOptions_Unknown2_12
= ( a32Bit
& 0x00000800 ) >> 11 ;
6869 fCompatabilityOptions_Unknown2_13
= ( a32Bit
& 0x00001000 ) >> 12 ;
6870 fCompatabilityOptions_Unknown2_14
= ( a32Bit
& 0x00002000 ) >> 13 ;
6871 fCompatabilityOptions_Unknown2_15
= ( a32Bit
& 0x00004000 ) >> 14 ;
6872 fCompatabilityOptions_Unknown2_16
= ( a32Bit
& 0x00008000 ) >> 15 ;
6873 fCompatabilityOptions_Unknown2_17
= ( a32Bit
& 0x00010000 ) >> 16 ;
6874 fCompatabilityOptions_Unknown2_18
= ( a32Bit
& 0x00020000 ) >> 17 ;
6875 fCompatabilityOptions_Unknown2_19
= ( a32Bit
& 0x00040000 ) >> 18 ;
6876 fCompatabilityOptions_Unknown2_20
= ( a32Bit
& 0x00080000 ) >> 19 ;
6877 fCompatabilityOptions_Unknown2_21
= ( a32Bit
& 0x00100000 ) >> 20 ;
6878 fCompatabilityOptions_Unknown2_22
= ( a32Bit
& 0x00200000 ) >> 21 ;
6879 fCompatabilityOptions_Unknown2_23
= ( a32Bit
& 0x00400000 ) >> 22 ;
6880 fCompatabilityOptions_Unknown2_24
= ( a32Bit
& 0x00800800 ) >> 23 ;
6881 fCompatabilityOptions_Unknown2_25
= ( a32Bit
& 0x01000800 ) >> 24 ;
6882 fCompatabilityOptions_Unknown2_26
= ( a32Bit
& 0x02000800 ) >> 25 ;
6883 fCompatabilityOptions_Unknown2_27
= ( a32Bit
& 0x04000800 ) >> 26 ;
6884 fCompatabilityOptions_Unknown2_28
= ( a32Bit
& 0x08000800 ) >> 27 ;
6885 fCompatabilityOptions_Unknown2_29
= ( a32Bit
& 0x10000800 ) >> 28 ;
6886 fCompatabilityOptions_Unknown2_30
= ( a32Bit
& 0x20000800 ) >> 29 ;
6887 fCompatabilityOptions_Unknown2_31
= ( a32Bit
& 0x40000800 ) >> 30 ;
6888 fCompatabilityOptions_Unknown2_32
= ( a32Bit
& 0x80000000 ) >> 31 ;
6891 UINT32
WW8Dop::GetCompatabilityOptions2() const
6894 if (fCompatabilityOptions_Unknown2_1
) a32Bit
|= 0x00000001;
6895 if (fCompatabilityOptions_Unknown2_2
) a32Bit
|= 0x00000002;
6896 if (fDontUseHTMLAutoSpacing
) a32Bit
|= 0x00000004;
6897 if (fCompatabilityOptions_Unknown2_4
) a32Bit
|= 0x00000008;
6898 if (fCompatabilityOptions_Unknown2_5
) a32Bit
|= 0x00000010;
6899 if (fCompatabilityOptions_Unknown2_6
) a32Bit
|= 0x00000020;
6900 if (fCompatabilityOptions_Unknown2_7
) a32Bit
|= 0x00000040;
6901 if (fCompatabilityOptions_Unknown2_8
) a32Bit
|= 0x00000080;
6902 if (fCompatabilityOptions_Unknown2_9
) a32Bit
|= 0x00000100;
6903 if (fCompatabilityOptions_Unknown2_10
) a32Bit
|= 0x00000200;
6904 if (fCompatabilityOptions_Unknown2_11
) a32Bit
|= 0x00000400;
6905 if (fCompatabilityOptions_Unknown2_12
) a32Bit
|= 0x00000800;
6906 if (fCompatabilityOptions_Unknown2_13
) a32Bit
|= 0x00001000;
6907 //#i42909# set thai "line breaking rules" compatibility option
6908 // pflin, wonder whether bUseThaiLineBreakingRules is correct
6909 // when importing word document.
6910 if (bUseThaiLineBreakingRules
) a32Bit
|= 0x00002000;
6911 else if (fCompatabilityOptions_Unknown2_14
) a32Bit
|= 0x00002000;
6912 if (fCompatabilityOptions_Unknown2_15
) a32Bit
|= 0x00004000;
6913 if (fCompatabilityOptions_Unknown2_16
) a32Bit
|= 0x00008000;
6914 if (fCompatabilityOptions_Unknown2_17
) a32Bit
|= 0x00010000;
6915 if (fCompatabilityOptions_Unknown2_18
) a32Bit
|= 0x00020000;
6916 if (fCompatabilityOptions_Unknown2_19
) a32Bit
|= 0x00040000;
6917 if (fCompatabilityOptions_Unknown2_20
) a32Bit
|= 0x00080000;
6918 if (fCompatabilityOptions_Unknown2_21
) a32Bit
|= 0x00100000;
6919 if (fCompatabilityOptions_Unknown2_22
) a32Bit
|= 0x00200000;
6920 if (fCompatabilityOptions_Unknown2_23
) a32Bit
|= 0x00400000;
6921 if (fCompatabilityOptions_Unknown2_24
) a32Bit
|= 0x00800000;
6922 if (fCompatabilityOptions_Unknown2_25
) a32Bit
|= 0x01000000;
6923 if (fCompatabilityOptions_Unknown2_26
) a32Bit
|= 0x02000000;
6924 if (fCompatabilityOptions_Unknown2_27
) a32Bit
|= 0x04000000;
6925 if (fCompatabilityOptions_Unknown2_28
) a32Bit
|= 0x08000000;
6926 if (fCompatabilityOptions_Unknown2_29
) a32Bit
|= 0x10000000;
6927 if (fCompatabilityOptions_Unknown2_30
) a32Bit
|= 0x20000000;
6928 if (fCompatabilityOptions_Unknown2_31
) a32Bit
|= 0x40000000;
6929 if (fCompatabilityOptions_Unknown2_32
) a32Bit
|= 0x80000000;
6933 bool WW8Dop::Write(SvStream
& rStrm
, WW8Fib
& rFib
) const
6935 const int nMaxDopLen
= 610;
6936 sal_uInt32 nLen
= 8 == rFib
.nVersion
? nMaxDopLen
: 84;
6937 rFib
.fcDop
= rStrm
.Tell();
6940 BYTE aData
[ nMaxDopLen
];
6941 memset( aData
, 0, nMaxDopLen
);
6942 BYTE
* pData
= aData
;
6944 // dann mal die Daten auswerten
6948 a16Bit
= 0; // 0 0x00
6955 a16Bit
|= ( 0x0018 & (grfSuppression
<< 3));
6956 a16Bit
|= ( 0x0060 & (fpc
<< 5));
6957 a16Bit
|= ( 0xff00 & (grpfIhdt
<< 8));
6958 Set_UInt16( pData
, a16Bit
);
6960 a16Bit
= 0; // 2 0x02
6961 a16Bit
|= ( 0x0003 & rncFtn
);
6962 a16Bit
|= ( ~0x0003 & (nFtn
<< 2));
6963 Set_UInt16( pData
, a16Bit
);
6965 a8Bit
= 0; // 4 0x04
6966 if( fOutlineDirtySave
) a8Bit
|= 0x01;
6967 Set_UInt8( pData
, a8Bit
);
6969 a8Bit
= 0; // 5 0x05
6970 if( fOnlyMacPics
) a8Bit
|= 0x01;
6971 if( fOnlyWinPics
) a8Bit
|= 0x02;
6972 if( fLabelDoc
) a8Bit
|= 0x04;
6973 if( fHyphCapitals
) a8Bit
|= 0x08;
6974 if( fAutoHyphen
) a8Bit
|= 0x10;
6975 if( fFormNoFields
) a8Bit
|= 0x20;
6976 if( fLinkStyles
) a8Bit
|= 0x40;
6977 if( fRevMarking
) a8Bit
|= 0x80;
6978 Set_UInt8( pData
, a8Bit
);
6980 a8Bit
= 0; // 6 0x06
6981 if( fBackup
) a8Bit
|= 0x01;
6982 if( fExactCWords
) a8Bit
|= 0x02;
6983 if( fPagHidden
) a8Bit
|= 0x04;
6984 if( fPagResults
) a8Bit
|= 0x08;
6985 if( fLockAtn
) a8Bit
|= 0x10;
6986 if( fMirrorMargins
) a8Bit
|= 0x20;
6987 if( fReadOnlyRecommended
) a8Bit
|= 0x40;
6988 if( fDfltTrueType
) a8Bit
|= 0x80;
6989 Set_UInt8( pData
, a8Bit
);
6991 a8Bit
= 0; // 7 0x07
6992 if( fPagSuppressTopSpacing
) a8Bit
|= 0x01;
6993 if( fProtEnabled
) a8Bit
|= 0x02;
6994 if( fDispFormFldSel
) a8Bit
|= 0x04;
6995 if( fRMView
) a8Bit
|= 0x08;
6996 if( fRMPrint
) a8Bit
|= 0x10;
6997 if( fWriteReservation
) a8Bit
|= 0x20;
6998 if( fLockRev
) a8Bit
|= 0x40;
6999 if( fEmbedFonts
) a8Bit
|= 0x80;
7000 Set_UInt8( pData
, a8Bit
);
7003 a8Bit
= 0; // 8 0x08
7004 if( copts_fNoTabForInd
) a8Bit
|= 0x01;
7005 if( copts_fNoSpaceRaiseLower
) a8Bit
|= 0x02;
7006 if( copts_fSupressSpbfAfterPgBrk
) a8Bit
|= 0x04;
7007 if( copts_fWrapTrailSpaces
) a8Bit
|= 0x08;
7008 if( copts_fMapPrintTextColor
) a8Bit
|= 0x10;
7009 if( copts_fNoColumnBalance
) a8Bit
|= 0x20;
7010 if( copts_fConvMailMergeEsc
) a8Bit
|= 0x40;
7011 if( copts_fSupressTopSpacing
) a8Bit
|= 0x80;
7012 Set_UInt8( pData
, a8Bit
);
7014 a8Bit
= 0; // 9 0x09
7015 if( copts_fOrigWordTableRules
) a8Bit
|= 0x01;
7016 if( copts_fTransparentMetafiles
) a8Bit
|= 0x02;
7017 if( copts_fShowBreaksInFrames
) a8Bit
|= 0x04;
7018 if( copts_fSwapBordersFacingPgs
) a8Bit
|= 0x08;
7019 if( copts_fExpShRtn
) a8Bit
|= 0x20; // #i56856#
7020 Set_UInt8( pData
, a8Bit
);
7022 Set_UInt16( pData
, dxaTab
); // 10 0x0a
7023 Set_UInt16( pData
, wSpare
); // 12 0x0c
7024 Set_UInt16( pData
, dxaHotZ
); // 14 0x0e
7025 Set_UInt16( pData
, cConsecHypLim
); // 16 0x10
7026 Set_UInt16( pData
, wSpare2
); // 18 0x12
7027 Set_UInt32( pData
, dttmCreated
); // 20 0x14
7028 Set_UInt32( pData
, dttmRevised
); // 24 0x18
7029 Set_UInt32( pData
, dttmLastPrint
); // 28 0x1c
7030 Set_UInt16( pData
, nRevision
); // 32 0x20
7031 Set_UInt32( pData
, tmEdited
); // 34 0x22
7032 Set_UInt32( pData
, cWords
); // 38 0x26
7033 Set_UInt32( pData
, cCh
); // 42 0x2a
7034 Set_UInt16( pData
, cPg
); // 46 0x2e
7035 Set_UInt32( pData
, cParas
); // 48 0x30
7037 a16Bit
= 0; // 52 0x34
7038 a16Bit
|= ( 0x0003 & rncEdn
);
7039 a16Bit
|= (~0x0003 & ( nEdn
<< 2));
7040 Set_UInt16( pData
, a16Bit
);
7042 a16Bit
= 0; // 54 0x36
7043 a16Bit
|= (0x0003 & epc
);
7044 a16Bit
|= (0x003c & (nfcFtnRef
<< 2));
7045 a16Bit
|= (0x03c0 & (nfcEdnRef
<< 6));
7046 if( fPrintFormData
) a16Bit
|= 0x0400;
7047 if( fSaveFormData
) a16Bit
|= 0x0800;
7048 if( fShadeFormData
) a16Bit
|= 0x1000;
7049 if( fWCFtnEdn
) a16Bit
|= 0x8000;
7050 Set_UInt16( pData
, a16Bit
);
7052 Set_UInt32( pData
, cLines
); // 56 0x38
7053 Set_UInt32( pData
, cWordsFtnEnd
); // 60 0x3c
7054 Set_UInt32( pData
, cChFtnEdn
); // 64 0x40
7055 Set_UInt16( pData
, cPgFtnEdn
); // 68 0x44
7056 Set_UInt32( pData
, cParasFtnEdn
); // 70 0x46
7057 Set_UInt32( pData
, cLinesFtnEdn
); // 74 0x4a
7058 Set_UInt32( pData
, lKeyProtDoc
); // 78 0x4e
7060 a16Bit
= 0; // 82 0x52
7063 a16Bit
|= (0x0ff8 & (wScaleSaved
<< 3));
7064 a16Bit
|= (0x3000 & (zkSaved
<< 12));
7065 Set_UInt16( pData
, a16Bit
);
7067 if( 8 == rFib
.nVersion
)
7069 Set_UInt32(pData
, GetCompatabilityOptions()); // 84 0x54
7071 Set_UInt16( pData
, adt
); // 88 0x58
7073 doptypography
.WriteToMem(pData
); // 400 0x190
7075 memcpy( pData
, &dogrid
, sizeof( WW8_DOGRID
));
7076 pData
+= sizeof( WW8_DOGRID
);
7078 a16Bit
= 0x12; // lvl auf 9 setzen // 410 0x19a
7079 if( fHtmlDoc
) a16Bit
|= 0x0200;
7080 if( fSnapBorder
) a16Bit
|= 0x0800;
7081 if( fIncludeHeader
) a16Bit
|= 0x1000;
7082 if( fIncludeFooter
) a16Bit
|= 0x2000;
7083 if( fForcePageSizePag
) a16Bit
|= 0x4000;
7084 if( fMinFontSizePag
) a16Bit
|= 0x8000;
7085 Set_UInt16( pData
, a16Bit
);
7087 a16Bit
= 0; // 412 0x19c
7088 if( fHaveVersions
) a16Bit
|= 0x0001;
7089 if( fAutoVersion
) a16Bit
|= 0x0002;
7090 Set_UInt16( pData
, a16Bit
);
7092 pData
+= 12; // 414 0x19e
7094 Set_UInt32( pData
, cChWS
); // 426 0x1aa
7095 Set_UInt32( pData
, cChWSFtnEdn
); // 430 0x1ae
7096 Set_UInt32( pData
, grfDocEvents
); // 434 0x1b2
7098 pData
+= 4+30+8; // 438 0x1b6; 442 0x1ba; 472 0x1d8; 476 0x1dc
7100 Set_UInt32( pData
, cDBC
); // 480 0x1e0
7101 Set_UInt32( pData
, cDBCFtnEdn
); // 484 0x1e4
7103 pData
+= 1 * sizeof( INT32
); // 488 0x1e8
7105 Set_UInt16( pData
, nfcFtnRef
); // 492 0x1ec
7106 Set_UInt16( pData
, nfcEdnRef
); // 494 0x1ee
7107 Set_UInt16( pData
, hpsZoonFontPag
); // 496 0x1f0
7108 Set_UInt16( pData
, dywDispPag
); // 498 0x1f2
7110 //500 -> 508, Appear to be repeated here in 2000+
7112 Set_UInt32(pData
, GetCompatabilityOptions());
7113 Set_UInt32(pData
, GetCompatabilityOptions2());
7117 if (fAcetateShowMarkup
)
7119 //Word XP at least requires fAcetateShowMarkup to honour fAcetateShowAtn
7120 if (fAcetateShowAtn
)
7125 Set_UInt16(pData
, a16Bit
);
7129 Set_UInt16(pData
, a16Bit
);
7131 rStrm
.Write( aData
, nLen
);
7132 return 0 == rStrm
.GetError();
7135 void WW8DopTypography::ReadFromMem(BYTE
*&pData
)
7137 USHORT a16Bit
= Get_UShort(pData
);
7138 fKerningPunct
= (a16Bit
& 0x0001);
7139 iJustification
= (a16Bit
& 0x0006) >> 1;
7140 iLevelOfKinsoku
= (a16Bit
& 0x0018) >> 3;
7141 f2on1
= (a16Bit
& 0x0020) >> 5;
7142 reserved1
= (a16Bit
& 0x03C0) >> 6;
7143 reserved2
= (a16Bit
& 0xFC00) >> 10;
7145 cchFollowingPunct
= Get_Short(pData
);
7146 cchLeadingPunct
= Get_Short(pData
);
7149 for (i
=0; i
< nMaxFollowing
; ++i
)
7150 rgxchFPunct
[i
] = Get_Short(pData
);
7151 for (i
=0; i
< nMaxLeading
; ++i
)
7152 rgxchLPunct
[i
] = Get_Short(pData
);
7154 rgxchFPunct
[cchFollowingPunct
]=0;
7155 rgxchLPunct
[cchLeadingPunct
]=0;
7158 void WW8DopTypography::WriteToMem(BYTE
*&pData
) const
7160 USHORT a16Bit
= fKerningPunct
;
7161 a16Bit
|= (iJustification
<< 1) & 0x0006;
7162 a16Bit
|= (iLevelOfKinsoku
<< 3) & 0x0018;
7163 a16Bit
|= (f2on1
<< 5) & 0x002;
7164 a16Bit
|= (reserved1
<< 6) & 0x03C0;
7165 a16Bit
|= (reserved2
<< 10) & 0xFC00;
7166 Set_UInt16(pData
,a16Bit
);
7168 Set_UInt16(pData
,cchFollowingPunct
);
7169 Set_UInt16(pData
,cchLeadingPunct
);
7172 for (i
=0; i
< nMaxFollowing
; ++i
)
7173 Set_UInt16(pData
,rgxchFPunct
[i
]);
7174 for (i
=0; i
< nMaxLeading
; ++i
)
7175 Set_UInt16(pData
,rgxchLPunct
[i
]);
7178 USHORT
WW8DopTypography::GetConvertedLang() const
7181 //I have assumed peoples republic/taiwan == simplified/traditional
7183 //This isn't a documented issue, so we might have it all wrong,
7184 //i.e. i.e. whats with the powers of two ?
7188 One example of 3 for reserved1 which was really Japanese, perhaps last bit
7189 is for some other use ?, or redundant. If more examples trigger the assert
7190 we might be able to figure it out.
7192 switch(reserved1
& 0xE)
7195 nLang
= LANGUAGE_JAPANESE
;
7197 case 4: //Chinese (Peoples Republic)
7198 nLang
= LANGUAGE_CHINESE_SIMPLIFIED
;
7201 nLang
= LANGUAGE_KOREAN
;
7203 case 8: //Chinese (Taiwan)
7204 nLang
= LANGUAGE_CHINESE_TRADITIONAL
;
7207 ASSERT(!this, "Unknown MS Asian Typography language, report");
7208 nLang
= LANGUAGE_CHINESE
;
7211 //And here we have the possibility that it says 2, but its really
7212 //a bug and only japanese level 2 has been selected after a custom
7213 //version was chosen on last save!
7214 nLang
= LANGUAGE_JAPANESE
;
7220 //-----------------------------------------
7222 //-----------------------------------------
7223 USHORT
wwSprmParser::GetSprmTailLen(sal_uInt16 nId
, const sal_uInt8
* pSprm
)
7226 SprmInfo aSprm
= GetSprmInfo(nId
);
7227 USHORT nL
= 0; // number of Bytes to read
7234 if( pSprm
[1 + mnDelta
] != 255 )
7235 nL
= static_cast< USHORT
>(pSprm
[1 + mnDelta
] + aSprm
.nLen
);
7238 BYTE nDel
= pSprm
[2 + mnDelta
];
7239 BYTE nIns
= pSprm
[3 + mnDelta
+ 4 * nDel
];
7241 nL
= 2 + 4 * nDel
+ 3 * nIns
;
7245 nL
= SVBT16ToShort( &pSprm
[1 + mnDelta
] );
7248 switch (aSprm
.nVari
)
7251 nL
= aSprm
.nLen
; // Excl. Token
7254 // Variable 1-Byte Length?
7255 // Excl. Token + Var-Lengthbyte
7256 nL
= static_cast< USHORT
>(pSprm
[1 + mnDelta
] + aSprm
.nLen
);
7259 // Variable 2-Byte Length?
7260 // Excl. Token + Var-Lengthbyte
7261 nL
= static_cast< USHORT
>(SVBT16ToShort( &pSprm
[1 + mnDelta
] ) + aSprm
.nLen
- 1);
7264 ASSERT(!this, "Unknown sprm varient");
7272 // one or two bytes at the beginning at the sprm id
7273 USHORT
wwSprmParser::GetSprmId(const sal_uInt8
* pSp
) const
7275 ASSERT_RET_ON_FAIL(pSp
, "Why GetSprmId with pSp of 0", 0);
7279 if (ww::IsSevenMinus(meVersion
))
7287 nId
= SVBT16ToShort(pSp
);
7295 // with tokens and length byte
7296 USHORT
wwSprmParser::GetSprmSize(sal_uInt16 nId
, const sal_uInt8
* pSprm
) const
7298 return GetSprmTailLen(nId
, pSprm
) + 1 + mnDelta
+ SprmDataOfs(nId
);
7301 BYTE
wwSprmParser::SprmDataOfs(USHORT nId
) const
7303 return GetSprmInfo(nId
).nVari
;
7306 USHORT
wwSprmParser::DistanceToData(USHORT nId
) const
7308 return 1 + mnDelta
+ SprmDataOfs(nId
);
7312 bkc(2), fTitlePage(0), fAutoPgn(0), nfcPgn(0), fUnlocked(0), cnsPgn(0),
7313 fPgnRestart(0), fEndNote(1), lnc(0), grpfIhdt(0), nLnnMod(0), dxaLnn(0),
7314 dxaPgn(720), dyaPgn(720), fLBetween(0), vjc(0), dmBinFirst(0),
7315 dmBinOther(0), dmPaperReq(0), fPropRMark(0), ibstPropRMark(0),
7316 dttmPropRMark(0), dxtCharSpace(0), dyaLinePitch(0), clm(0), reserved1(0),
7317 dmOrientPage(0), iHeadingPgn(0), pgnStart(1), lnnMin(0), wTextFlow(0),
7318 reserved2(0), pgbApplyTo(0), pgbPageDepth(0), pgbOffsetFrom(0),
7319 xaPage(lLetterWidth
), yaPage(lLetterHeight
), xaPageNUp(lLetterWidth
), yaPageNUp(lLetterHeight
),
7320 dxaLeft(1800), dxaRight(1800), dyaTop(1440), dyaBottom(1440), dzaGutter(0),
7321 dyaHdrTop(720), dyaHdrBottom(720), ccolM1(0), fEvenlySpaced(1),
7322 reserved3(0), fBiDi(0), fFacingCol(0), fRTLGutter(0), fRTLAlignment(0),
7323 dxaColumns(720), dxaColumnWidth(0), dmOrientFirst(0), fLayout(0),
7326 memset(rgdxaColumnWidthSpacing
, 0, sizeof(rgdxaColumnWidthSpacing
));
7329 /* vi:set tabstop=4 shiftwidth=4 expandtab: */