1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
27cdf0e10cSrcweir #include "ww8scan.hxx"
28cdf0e10cSrcweir
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <functional>
31cdf0e10cSrcweir #include <algorithm>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <string.h> // memset()
34cdf0e10cSrcweir #include <rtl/tencinfo.h>
35cdf0e10cSrcweir
36cdf0e10cSrcweir #ifdef DUMP
37cdf0e10cSrcweir
38cdf0e10cSrcweir #define ERR_SWG_READ_ERROR 1234
39cdf0e10cSrcweir #define ASSERT( a, b )
40cdf0e10cSrcweir
41cdf0e10cSrcweir #else // dump
42cdf0e10cSrcweir #include <swerror.h> // ERR_WW6_...
43cdf0e10cSrcweir #include <swtypes.hxx> // DELETEZ
44cdf0e10cSrcweir
45cdf0e10cSrcweir #endif // dump
46cdf0e10cSrcweir #include <tools/debug.hxx>
47cdf0e10cSrcweir #include <i18npool/lang.h>
48cdf0e10cSrcweir #include <vcl/svapp.hxx> // Application #i90932#
49cdf0e10cSrcweir
50cdf0e10cSrcweir #include <stdio.h>
51cdf0e10cSrcweir
52cdf0e10cSrcweir #define ASSERT_RET_ON_FAIL( aCon, aError, aRet ) \
53cdf0e10cSrcweir ASSERT(aCon, aError); \
54cdf0e10cSrcweir if (!(aCon)) \
55cdf0e10cSrcweir return aRet;
56cdf0e10cSrcweir
57cdf0e10cSrcweir //-begin
58cdf0e10cSrcweir namespace SL
59cdf0e10cSrcweir {
60cdf0e10cSrcweir # define IMPLCONSTSTRINGARRAY(X) const char a##X[] = "" #X ""
61cdf0e10cSrcweir IMPLCONSTSTRINGARRAY(ObjectPool);
62cdf0e10cSrcweir IMPLCONSTSTRINGARRAY(1Table);
63cdf0e10cSrcweir IMPLCONSTSTRINGARRAY(0Table);
64cdf0e10cSrcweir IMPLCONSTSTRINGARRAY(Data);
65cdf0e10cSrcweir IMPLCONSTSTRINGARRAY(CheckBox);
66cdf0e10cSrcweir IMPLCONSTSTRINGARRAY(ListBox);
67cdf0e10cSrcweir IMPLCONSTSTRINGARRAY(TextBox);
68cdf0e10cSrcweir IMPLCONSTSTRINGARRAY(TextField);
69cdf0e10cSrcweir IMPLCONSTSTRINGARRAY(MSMacroCmds);
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
TestBeltAndBraces(const SvStream & rStrm)72cdf0e10cSrcweir template<class C> bool wwString<C>::TestBeltAndBraces(const SvStream& rStrm)
73cdf0e10cSrcweir {
74cdf0e10cSrcweir bool bRet = false;
75cdf0e10cSrcweir sal_uInt32 nOldPos = rStrm.Tell();
76cdf0e10cSrcweir SvStream &rMutableStrm = const_cast<SvStream &>(rStrm);
77cdf0e10cSrcweir sal_uInt32 nLen = rMutableStrm.Seek(STREAM_SEEK_TO_END);
78cdf0e10cSrcweir rMutableStrm.Seek(nOldPos);
79cdf0e10cSrcweir C nBelt;
80cdf0e10cSrcweir rMutableStrm >> nBelt;
81cdf0e10cSrcweir nBelt *= sizeof(C);
82cdf0e10cSrcweir if (nOldPos + sizeof(C) + nBelt + sizeof(C) <= nLen &&
83cdf0e10cSrcweir !rStrm.GetError() && !rStrm.IsEof())
84cdf0e10cSrcweir {
85cdf0e10cSrcweir rMutableStrm.SeekRel(nBelt);
86cdf0e10cSrcweir if (!rStrm.GetError())
87cdf0e10cSrcweir {
88cdf0e10cSrcweir C cBraces;
89cdf0e10cSrcweir rMutableStrm >> cBraces;
90cdf0e10cSrcweir if (!rMutableStrm.GetError() && cBraces == 0)
91cdf0e10cSrcweir bRet = true;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir }
94cdf0e10cSrcweir rMutableStrm.Seek(nOldPos);
95cdf0e10cSrcweir return bRet;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
operator ==(const SprmInfo & rFirst,const SprmInfo & rSecond)98cdf0e10cSrcweir inline bool operator==(const SprmInfo &rFirst, const SprmInfo &rSecond)
99cdf0e10cSrcweir {
100cdf0e10cSrcweir return (rFirst.nId == rSecond.nId);
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
GetWW2SprmSearcher()103cdf0e10cSrcweir const wwSprmSearcher *wwSprmParser::GetWW2SprmSearcher()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir //double lock me
106cdf0e10cSrcweir // WW7- Sprms
107cdf0e10cSrcweir static const SprmInfo aSprms[] =
108cdf0e10cSrcweir {
109cdf0e10cSrcweir { 0, 0, L_FIX}, // "Default-sprm", wird uebersprungen
110cdf0e10cSrcweir { 2, 1, L_FIX}, // "sprmPIstd", pap.istd (style code)
111cdf0e10cSrcweir { 3, 0, L_VAR}, // "sprmPIstdPermute pap.istd permutation
112cdf0e10cSrcweir { 4, 1, L_FIX}, // "sprmPIncLv1" pap.istddifference
113cdf0e10cSrcweir { 5, 1, L_FIX}, // "sprmPJc" pap.jc (justification)
114cdf0e10cSrcweir { 6, 1, L_FIX}, // "sprmPFSideBySide" pap.fSideBySide
115cdf0e10cSrcweir { 7, 1, L_FIX}, // "sprmPFKeep" pap.fKeep
116cdf0e10cSrcweir { 8, 1, L_FIX}, // "sprmPFKeepFollow " pap.fKeepFollow
117cdf0e10cSrcweir { 9, 1, L_FIX}, // "sprmPPageBreakBefore" pap.fPageBreakBefore
118cdf0e10cSrcweir { 10, 1, L_FIX}, // "sprmPBrcl" pap.brcl
119cdf0e10cSrcweir { 11, 1, L_FIX}, // "sprmPBrcp" pap.brcp
120cdf0e10cSrcweir { 12, 1, L_FIX}, // "sprmPNfcSeqNumb" pap.nfcSeqNumb
121cdf0e10cSrcweir { 13, 1, L_FIX}, // "sprmPNoSeqNumb" pap.nnSeqNumb
122cdf0e10cSrcweir { 14, 1, L_FIX}, // "sprmPFNoLineNumb" pap.fNoLnn
123cdf0e10cSrcweir { 15, 0, L_VAR}, // "?sprmPChgTabsPapx" pap.itbdMac, ...
124cdf0e10cSrcweir { 16, 2, L_FIX}, // "sprmPDxaRight" pap.dxaRight
125cdf0e10cSrcweir { 17, 2, L_FIX}, // "sprmPDxaLeft" pap.dxaLeft
126cdf0e10cSrcweir { 18, 2, L_FIX}, // "sprmPNest" pap.dxaLeft
127cdf0e10cSrcweir { 19, 2, L_FIX}, // "sprmPDxaLeft1" pap.dxaLeft1
128cdf0e10cSrcweir { 20, 2, L_FIX}, // "sprmPDyaLine" pap.lspd an LSPD
129cdf0e10cSrcweir { 21, 2, L_FIX}, // "sprmPDyaBefore" pap.dyaBefore
130cdf0e10cSrcweir { 22, 2, L_FIX}, // "sprmPDyaAfter" pap.dyaAfter
131cdf0e10cSrcweir { 23, 0, L_VAR}, // "?sprmPChgTabs" pap.itbdMac, pap.rgdxaTab, ...
132cdf0e10cSrcweir { 24, 1, L_FIX}, // "sprmPFInTable" pap.fInTable
133cdf0e10cSrcweir { 25, 1, L_FIX}, // "sprmPTtp" pap.fTtp
134cdf0e10cSrcweir { 26, 2, L_FIX}, // "sprmPDxaAbs" pap.dxaAbs
135cdf0e10cSrcweir { 27, 2, L_FIX}, // "sprmPDyaAbs" pap.dyaAbs
136cdf0e10cSrcweir { 28, 2, L_FIX}, // "sprmPDxaWidth" pap.dxaWidth
137cdf0e10cSrcweir { 29, 1, L_FIX}, // "sprmPPc" pap.pcHorz, pap.pcVert
138cdf0e10cSrcweir { 30, 2, L_FIX}, // "sprmPBrcTop10" pap.brcTop BRC10
139cdf0e10cSrcweir { 31, 2, L_FIX}, // "sprmPBrcLeft10" pap.brcLeft BRC10
140cdf0e10cSrcweir { 32, 2, L_FIX}, // "sprmPBrcBottom10" pap.brcBottom BRC10
141cdf0e10cSrcweir { 33, 2, L_FIX}, // "sprmPBrcRight10" pap.brcRight BRC10
142cdf0e10cSrcweir { 34, 2, L_FIX}, // "sprmPBrcBetween10" pap.brcBetween BRC10
143cdf0e10cSrcweir { 35, 2, L_FIX}, // "sprmPBrcBar10" pap.brcBar BRC10
144cdf0e10cSrcweir { 36, 2, L_FIX}, // "sprmPFromText10" pap.dxaFromText dxa
145cdf0e10cSrcweir { 37, 1, L_FIX}, // "sprmPWr" pap.wr wr
146cdf0e10cSrcweir { 38, 2, L_FIX}, // "sprmPBrcTop" pap.brcTop BRC
147cdf0e10cSrcweir { 39, 2, L_FIX}, // "sprmPBrcLeft" pap.brcLeft BRC
148cdf0e10cSrcweir { 40, 2, L_FIX}, // "sprmPBrcBottom" pap.brcBottom BRC
149cdf0e10cSrcweir { 41, 2, L_FIX}, // "sprmPBrcRight" pap.brcRight BRC
150cdf0e10cSrcweir { 42, 2, L_FIX}, // "sprmPBrcBetween" pap.brcBetween BRC
151cdf0e10cSrcweir { 43, 2, L_FIX}, // "sprmPBrcBar" pap.brcBar BRC word
152cdf0e10cSrcweir { 44, 1, L_FIX}, // "sprmPFNoAutoHyph" pap.fNoAutoHyph
153cdf0e10cSrcweir { 45, 2, L_FIX}, // "sprmPWHeightAbs" pap.wHeightAbs w
154cdf0e10cSrcweir { 46, 2, L_FIX}, // "sprmPDcs" pap.dcs DCS
155cdf0e10cSrcweir { 47, 2, L_FIX}, // "sprmPShd" pap.shd SHD
156cdf0e10cSrcweir { 48, 2, L_FIX}, // "sprmPDyaFromText" pap.dyaFromText dya
157cdf0e10cSrcweir { 49, 2, L_FIX}, // "sprmPDxaFromText" pap.dxaFromText dxa
158cdf0e10cSrcweir { 50, 1, L_FIX}, // "sprmPFBiDi" pap.fBiDi 0 or 1 byte
159cdf0e10cSrcweir { 51, 1, L_FIX}, // "sprmPFWidowControl" pap.fWidowControl 0 or 1 byte
160cdf0e10cSrcweir { 52, 0, L_FIX}, // "?sprmPRuler 52"
161cdf0e10cSrcweir { 53, 1, L_FIX}, // "sprmCFStrikeRM" chp.fRMarkDel 1 or 0 bit
162cdf0e10cSrcweir { 54, 1, L_FIX}, // "sprmCFRMark" chp.fRMark 1 or 0 bit
163cdf0e10cSrcweir { 55, 1, L_FIX}, // "sprmCFFldVanish" chp.fFldVanish 1 or 0 bit
164cdf0e10cSrcweir { 57, 0, L_VAR}, // "sprmCDefault" whole CHP
165cdf0e10cSrcweir { 58, 0, L_FIX}, // "sprmCPlain" whole CHP
166cdf0e10cSrcweir { 60, 1, L_FIX}, // "sprmCFBold" chp.fBold 0,1, 128, or 129
167cdf0e10cSrcweir { 61, 1, L_FIX}, // "sprmCFItalic" chp.fItalic 0,1, 128, or 129
168cdf0e10cSrcweir { 62, 1, L_FIX}, // "sprmCFStrike" chp.fStrike 0,1, 128, or 129
169cdf0e10cSrcweir { 63, 1, L_FIX}, // "sprmCFOutline" chp.fOutline 0,1, 128, or 129
170cdf0e10cSrcweir { 64, 1, L_FIX}, // "sprmCFShadow" chp.fShadow 0,1, 128, or 129
171cdf0e10cSrcweir { 65, 1, L_FIX}, // "sprmCFSmallCaps" chp.fSmallCaps 0,1, 128, or 129
172cdf0e10cSrcweir { 66, 1, L_FIX}, // "sprmCFCaps" chp.fCaps 0,1, 128, or 129
173cdf0e10cSrcweir { 67, 1, L_FIX}, // "sprmCFVanish" chp.fVanish 0,1, 128, or 129
174cdf0e10cSrcweir { 68, 2, L_FIX}, // "sprmCFtc" chp.ftc ftc word
175cdf0e10cSrcweir { 69, 1, L_FIX}, // "sprmCKul" chp.kul kul byte
176cdf0e10cSrcweir { 70, 3, L_FIX}, // "sprmCSizePos" chp.hps, chp.hpsPos
177cdf0e10cSrcweir { 71, 2, L_FIX}, // "sprmCDxaSpace" chp.dxaSpace dxa
178cdf0e10cSrcweir { 72, 2, L_FIX}, // "sprmCLid" chp.lid LID
179cdf0e10cSrcweir { 73, 1, L_FIX}, // "sprmCIco" chp.ico ico byte
180cdf0e10cSrcweir { 74, 1, L_FIX}, // "sprmCHps" chp.hps hps !word!
181cdf0e10cSrcweir { 75, 1, L_FIX}, // "sprmCHpsInc" chp.hps
182cdf0e10cSrcweir { 76, 1, L_FIX}, // "sprmCHpsPos" chp.hpsPos hps !word!
183cdf0e10cSrcweir { 77, 1, L_FIX}, // "sprmCHpsPosAdj" chp.hpsPos hps
184cdf0e10cSrcweir { 78, 0, L_VAR}, // "?sprmCMajority" chp.fBold, chp.fItalic, ...
185cdf0e10cSrcweir { 80, 1, L_FIX}, // "sprmCFBoldBi" chp.fBoldBi
186cdf0e10cSrcweir { 81, 1, L_FIX}, // "sprmCFItalicBi" chp.fItalicBi
187cdf0e10cSrcweir { 82, 2, L_FIX}, // "sprmCFtcBi" chp.ftcBi
188cdf0e10cSrcweir { 83, 2, L_FIX}, // "sprmClidBi" chp.lidBi
189cdf0e10cSrcweir { 84, 1, L_FIX}, // "sprmCIcoBi" chp.icoBi
190cdf0e10cSrcweir { 85, 1, L_FIX}, // "sprmCHpsBi" chp.hpsBi
191cdf0e10cSrcweir { 86, 1, L_FIX}, // "sprmCFBiDi" chp.fBiDi
192cdf0e10cSrcweir { 87, 1, L_FIX}, // "sprmCFDiacColor" chp.fDiacUSico
193cdf0e10cSrcweir { 94, 1, L_FIX}, // "sprmPicBrcl" pic.brcl brcl (see PIC definition)
194cdf0e10cSrcweir { 95,12, L_VAR}, // "sprmPicScale" pic.mx, pic.my, pic.dxaCropleft,
195cdf0e10cSrcweir { 96, 2, L_FIX}, // "sprmPicBrcTop" pic.brcTop BRC word
196cdf0e10cSrcweir { 97, 2, L_FIX}, // "sprmPicBrcLeft" pic.brcLeft BRC word
197cdf0e10cSrcweir { 98, 2, L_FIX}, // "sprmPicBrcBottom" pic.brcBottom BRC word
198cdf0e10cSrcweir { 99, 2, L_FIX}, // "sprmPicBrcRight" pic.brcRight BRC word
199cdf0e10cSrcweir {112, 1, L_FIX}, // "sprmSFRTLGutter", set to one if gutter is on
200cdf0e10cSrcweir {114, 1, L_FIX}, // "sprmSFBiDi" ;;;
201cdf0e10cSrcweir {115, 2, L_FIX}, // "sprmSDmBinFirst" sep.dmBinFirst word
202cdf0e10cSrcweir {116, 2, L_FIX}, // "sprmSDmBinOther" sep.dmBinOther word
203cdf0e10cSrcweir {117, 1, L_FIX}, // "sprmSBkc" sep.bkc bkc byte
204cdf0e10cSrcweir {118, 1, L_FIX}, // "sprmSFTitlePage" sep.fTitlePage 0 or 1 byte
205cdf0e10cSrcweir {119, 2, L_FIX}, // "sprmSCcolumns" sep.ccolM1 # of cols - 1 word
206cdf0e10cSrcweir {120, 2, L_FIX}, // "sprmSDxaColumns" sep.dxaColumns dxa word
207cdf0e10cSrcweir {121, 1, L_FIX}, // "sprmSFAutoPgn" sep.fAutoPgn obsolete byte
208cdf0e10cSrcweir {122, 1, L_FIX}, // "sprmSNfcPgn" sep.nfcPgn nfc byte
209cdf0e10cSrcweir {123, 2, L_FIX}, // "sprmSDyaPgn" sep.dyaPgn dya short
210cdf0e10cSrcweir {124, 2, L_FIX}, // "sprmSDxaPgn" sep.dxaPgn dya short
211cdf0e10cSrcweir {125, 1, L_FIX}, // "sprmSFPgnRestart" sep.fPgnRestart 0 or 1 byte
212cdf0e10cSrcweir {126, 1, L_FIX}, // "sprmSFEndnote" sep.fEndnote 0 or 1 byte
213cdf0e10cSrcweir {127, 1, L_FIX}, // "sprmSLnc" sep.lnc lnc byte
214cdf0e10cSrcweir {128, 1, L_FIX}, // "sprmSGprfIhdt" sep.grpfIhdt grpfihdt
215cdf0e10cSrcweir {129, 2, L_FIX}, // "sprmSNLnnMod" sep.nLnnMod non-neg int. word
216cdf0e10cSrcweir {130, 2, L_FIX}, // "sprmSDxaLnn" sep.dxaLnn dxa word
217cdf0e10cSrcweir {131, 2, L_FIX}, // "sprmSDyaHdrTop" sep.dyaHdrTop dya word
218cdf0e10cSrcweir {132, 2, L_FIX}, // "sprmSDyaHdrBottom" sep.dyaHdrBottom dya word
219cdf0e10cSrcweir {133, 1, L_FIX}, // "sprmSLBetween" sep.fLBetween 0 or 1 byte
220cdf0e10cSrcweir {134, 1, L_FIX}, // "sprmSVjc" sep.vjc vjc byte
221cdf0e10cSrcweir {135, 2, L_FIX}, // "sprmSLnnMin" sep.lnnMin lnn word
222cdf0e10cSrcweir {136, 2, L_FIX}, // "sprmSPgnStart" sep.pgnStart pgn word
223cdf0e10cSrcweir {137, 1, L_FIX}, // "sprmSBOrientation" sep.dmOrientPage dm byte
224cdf0e10cSrcweir {138, 1, L_FIX}, // "sprmSFFacingCol" ;;;
225cdf0e10cSrcweir {139, 2, L_FIX}, // "sprmSXaPage" sep.xaPage xa word
226cdf0e10cSrcweir {140, 2, L_FIX}, // "sprmSYaPage" sep.yaPage ya word
227cdf0e10cSrcweir {141, 2, L_FIX}, // "sprmSDxaLeft" sep.dxaLeft dxa word
228cdf0e10cSrcweir {142, 2, L_FIX}, // "sprmSDxaRight" sep.dxaRight dxa word
229cdf0e10cSrcweir {143, 2, L_FIX}, // "sprmSDyaTop" sep.dyaTop dya word
230cdf0e10cSrcweir {144, 2, L_FIX}, // "sprmSDyaBottom" sep.dyaBottom dya word
231cdf0e10cSrcweir {145, 2, L_FIX}, // "sprmSDzaGutter" sep.dzaGutter dza word
232cdf0e10cSrcweir {146, 2, L_FIX}, // "sprmTJc" tap.jc jc (low order byte is significant)
233cdf0e10cSrcweir {147, 2, L_FIX}, // "sprmTDxaLeft" tap.rgdxaCenter dxa word
234cdf0e10cSrcweir {148, 2, L_FIX}, // "sprmTDxaGapHalf" tap.dxaGapHalf, tap.rgdxaCenter
235cdf0e10cSrcweir {149, 1, L_FIX}, // "sprmTFBiDi" ;;;
236cdf0e10cSrcweir {152, 0, L_VAR}, // "sprmTDefTable10" tap.rgdxaCenter, tap.rgtc complex
237cdf0e10cSrcweir {153, 2, L_FIX}, // "sprmTDyaRowHeight" tap.dyaRowHeight dya word
238cdf0e10cSrcweir {154, 0, L_VAR2},// "sprmTDefTable" tap.rgtc complex
239cdf0e10cSrcweir {155, 1, L_VAR}, // "sprmTDefTableShd" tap.rgshd complex
240cdf0e10cSrcweir {157, 5, L_FIX}, // "sprmTSetBrc" tap.rgtc[].rgbrc complex 5 bytes
241cdf0e10cSrcweir {158, 4, L_FIX}, // "sprmTInsert" tap.rgdxaCenter,tap.rgtc complex
242cdf0e10cSrcweir {159, 2, L_FIX}, // "sprmTDelete" tap.rgdxaCenter, tap.rgtc complex
243cdf0e10cSrcweir {160, 4, L_FIX}, // "sprmTDxaCol" tap.rgdxaCenter complex
244cdf0e10cSrcweir {161, 2, L_FIX}, // "sprmTMerge" tap.fFirstMerged, tap.fMerged complex
245cdf0e10cSrcweir {162, 2, L_FIX}, // "sprmTSplit" tap.fFirstMerged, tap.fMerged complex
246cdf0e10cSrcweir {163, 5, L_FIX}, // "sprmTSetBrc10" tap.rgtc[].rgbrc complex 5 bytes
247cdf0e10cSrcweir {164, 4, L_FIX}, // "sprmTSetShd", tap.rgshd complex 4 bytes
248cdf0e10cSrcweir };
249cdf0e10cSrcweir
250cdf0e10cSrcweir static wwSprmSearcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0]));
251cdf0e10cSrcweir return &aSprmSrch;
252cdf0e10cSrcweir };
253cdf0e10cSrcweir
254cdf0e10cSrcweir
GetWW6SprmSearcher()255cdf0e10cSrcweir const wwSprmSearcher *wwSprmParser::GetWW6SprmSearcher()
256cdf0e10cSrcweir {
257cdf0e10cSrcweir //double lock me
258cdf0e10cSrcweir // WW7- Sprms
259cdf0e10cSrcweir static const SprmInfo aSprms[] =
260cdf0e10cSrcweir {
261cdf0e10cSrcweir { 0, 0, L_FIX}, // "Default-sprm", wird uebersprungen
262cdf0e10cSrcweir { 2, 2, L_FIX}, // "sprmPIstd", pap.istd (style code)
263cdf0e10cSrcweir { 3, 3, L_VAR}, // "sprmPIstdPermute pap.istd permutation
264cdf0e10cSrcweir { 4, 1, L_FIX}, // "sprmPIncLv1" pap.istddifference
265cdf0e10cSrcweir { 5, 1, L_FIX}, // "sprmPJc" pap.jc (justification)
266cdf0e10cSrcweir { 6, 1, L_FIX}, // "sprmPFSideBySide" pap.fSideBySide
267cdf0e10cSrcweir { 7, 1, L_FIX}, // "sprmPFKeep" pap.fKeep
268cdf0e10cSrcweir { 8, 1, L_FIX}, // "sprmPFKeepFollow " pap.fKeepFollow
269cdf0e10cSrcweir { 9, 1, L_FIX}, // "sprmPPageBreakBefore" pap.fPageBreakBefore
270cdf0e10cSrcweir { 10, 1, L_FIX}, // "sprmPBrcl" pap.brcl
271cdf0e10cSrcweir { 11, 1, L_FIX}, // "sprmPBrcp" pap.brcp
272cdf0e10cSrcweir { 12, 0, L_VAR}, // "sprmPAnld" pap.anld (ANLD structure)
273cdf0e10cSrcweir { 13, 1, L_FIX}, // "sprmPNLvlAnm" pap.nLvlAnm nn
274cdf0e10cSrcweir { 14, 1, L_FIX}, // "sprmPFNoLineNumb" pap.fNoLnn
275cdf0e10cSrcweir { 15, 0, L_VAR}, // "?sprmPChgTabsPapx" pap.itbdMac, ...
276cdf0e10cSrcweir { 16, 2, L_FIX}, // "sprmPDxaRight" pap.dxaRight
277cdf0e10cSrcweir { 17, 2, L_FIX}, // "sprmPDxaLeft" pap.dxaLeft
278cdf0e10cSrcweir { 18, 2, L_FIX}, // "sprmPNest" pap.dxaLeft
279cdf0e10cSrcweir { 19, 2, L_FIX}, // "sprmPDxaLeft1" pap.dxaLeft1
280cdf0e10cSrcweir { 20, 4, L_FIX}, // "sprmPDyaLine" pap.lspd an LSPD
281cdf0e10cSrcweir { 21, 2, L_FIX}, // "sprmPDyaBefore" pap.dyaBefore
282cdf0e10cSrcweir { 22, 2, L_FIX}, // "sprmPDyaAfter" pap.dyaAfter
283cdf0e10cSrcweir { 23, 0, L_VAR}, // "?sprmPChgTabs" pap.itbdMac, pap.rgdxaTab, ...
284cdf0e10cSrcweir { 24, 1, L_FIX}, // "sprmPFInTable" pap.fInTable
285cdf0e10cSrcweir { 25, 1, L_FIX}, // "sprmPTtp" pap.fTtp
286cdf0e10cSrcweir { 26, 2, L_FIX}, // "sprmPDxaAbs" pap.dxaAbs
287cdf0e10cSrcweir { 27, 2, L_FIX}, // "sprmPDyaAbs" pap.dyaAbs
288cdf0e10cSrcweir { 28, 2, L_FIX}, // "sprmPDxaWidth" pap.dxaWidth
289cdf0e10cSrcweir { 29, 1, L_FIX}, // "sprmPPc" pap.pcHorz, pap.pcVert
290cdf0e10cSrcweir { 30, 2, L_FIX}, // "sprmPBrcTop10" pap.brcTop BRC10
291cdf0e10cSrcweir { 31, 2, L_FIX}, // "sprmPBrcLeft10" pap.brcLeft BRC10
292cdf0e10cSrcweir { 32, 2, L_FIX}, // "sprmPBrcBottom10" pap.brcBottom BRC10
293cdf0e10cSrcweir { 33, 2, L_FIX}, // "sprmPBrcRight10" pap.brcRight BRC10
294cdf0e10cSrcweir { 34, 2, L_FIX}, // "sprmPBrcBetween10" pap.brcBetween BRC10
295cdf0e10cSrcweir { 35, 2, L_FIX}, // "sprmPBrcBar10" pap.brcBar BRC10
296cdf0e10cSrcweir { 36, 2, L_FIX}, // "sprmPFromText10" pap.dxaFromText dxa
297cdf0e10cSrcweir { 37, 1, L_FIX}, // "sprmPWr" pap.wr wr
298cdf0e10cSrcweir { 38, 2, L_FIX}, // "sprmPBrcTop" pap.brcTop BRC
299cdf0e10cSrcweir { 39, 2, L_FIX}, // "sprmPBrcLeft" pap.brcLeft BRC
300cdf0e10cSrcweir { 40, 2, L_FIX}, // "sprmPBrcBottom" pap.brcBottom BRC
301cdf0e10cSrcweir { 41, 2, L_FIX}, // "sprmPBrcRight" pap.brcRight BRC
302cdf0e10cSrcweir { 42, 2, L_FIX}, // "sprmPBrcBetween" pap.brcBetween BRC
303cdf0e10cSrcweir { 43, 2, L_FIX}, // "sprmPBrcBar" pap.brcBar BRC word
304cdf0e10cSrcweir { 44, 1, L_FIX}, // "sprmPFNoAutoHyph" pap.fNoAutoHyph
305cdf0e10cSrcweir { 45, 2, L_FIX}, // "sprmPWHeightAbs" pap.wHeightAbs w
306cdf0e10cSrcweir { 46, 2, L_FIX}, // "sprmPDcs" pap.dcs DCS
307cdf0e10cSrcweir { 47, 2, L_FIX}, // "sprmPShd" pap.shd SHD
308cdf0e10cSrcweir { 48, 2, L_FIX}, // "sprmPDyaFromText" pap.dyaFromText dya
309cdf0e10cSrcweir { 49, 2, L_FIX}, // "sprmPDxaFromText" pap.dxaFromText dxa
310cdf0e10cSrcweir { 50, 1, L_FIX}, // "sprmPFLocked" pap.fLocked 0 or 1 byte
311cdf0e10cSrcweir { 51, 1, L_FIX}, // "sprmPFWidowControl" pap.fWidowControl 0 or 1 byte
312cdf0e10cSrcweir { 52, 0, L_FIX}, // "?sprmPRuler 52"
313cdf0e10cSrcweir { 64, 0, L_VAR}, // rtl property ?
314cdf0e10cSrcweir { 65, 1, L_FIX}, // "sprmCFStrikeRM" chp.fRMarkDel 1 or 0 bit
315cdf0e10cSrcweir { 66, 1, L_FIX}, // "sprmCFRMark" chp.fRMark 1 or 0 bit
316cdf0e10cSrcweir { 67, 1, L_FIX}, // "sprmCFFldVanish" chp.fFldVanish 1 or 0 bit
317cdf0e10cSrcweir { 68, 0, L_VAR}, // "sprmCPicLocation" chp.fcPic and chp.fSpec
318cdf0e10cSrcweir { 69, 2, L_FIX}, // "sprmCIbstRMark" chp.ibstRMark index into sttbRMark
319cdf0e10cSrcweir { 70, 4, L_FIX}, // "sprmCDttmRMark" chp.dttm DTTM long
320cdf0e10cSrcweir { 71, 1, L_FIX}, // "sprmCFData" chp.fData 1 or 0 bit
321cdf0e10cSrcweir { 72, 2, L_FIX}, // "sprmCRMReason" chp.idslRMReason an index to a table
322cdf0e10cSrcweir { 73, 3, L_FIX}, // "sprmCChse" chp.fChsDiff and chp.chse
323cdf0e10cSrcweir { 74, 0, L_VAR}, // "sprmCSymbol" chp.fSpec, chp.chSym and chp.ftcSym
324cdf0e10cSrcweir { 75, 1, L_FIX}, // "sprmCFOle2" chp.fOle2 1 or 0 bit
325cdf0e10cSrcweir { 77, 0, L_VAR}, // unknown
326cdf0e10cSrcweir { 79, 0, L_VAR}, // unknown
327cdf0e10cSrcweir { 80, 2, L_FIX}, // "sprmCIstd" chp.istd istd, see stylesheet definition
328cdf0e10cSrcweir { 81, 0, L_VAR}, // "sprmCIstdPermute" chp.istd permutation vector
329cdf0e10cSrcweir { 82, 0, L_VAR}, // "sprmCDefault" whole CHP
330cdf0e10cSrcweir { 83, 0, L_FIX}, // "sprmCPlain" whole CHP
331cdf0e10cSrcweir { 85, 1, L_FIX}, // "sprmCFBold" chp.fBold 0,1, 128, or 129
332cdf0e10cSrcweir { 86, 1, L_FIX}, // "sprmCFItalic" chp.fItalic 0,1, 128, or 129
333cdf0e10cSrcweir { 87, 1, L_FIX}, // "sprmCFStrike" chp.fStrike 0,1, 128, or 129
334cdf0e10cSrcweir { 88, 1, L_FIX}, // "sprmCFOutline" chp.fOutline 0,1, 128, or 129
335cdf0e10cSrcweir { 89, 1, L_FIX}, // "sprmCFShadow" chp.fShadow 0,1, 128, or 129
336cdf0e10cSrcweir { 90, 1, L_FIX}, // "sprmCFSmallCaps" chp.fSmallCaps 0,1, 128, or 129
337cdf0e10cSrcweir { 91, 1, L_FIX}, // "sprmCFCaps" chp.fCaps 0,1, 128, or 129
338cdf0e10cSrcweir { 92, 1, L_FIX}, // "sprmCFVanish" chp.fVanish 0,1, 128, or 129
339cdf0e10cSrcweir { 93, 2, L_FIX}, // "sprmCFtc" chp.ftc ftc word
340cdf0e10cSrcweir { 94, 1, L_FIX}, // "sprmCKul" chp.kul kul byte
341cdf0e10cSrcweir { 95, 3, L_FIX}, // "sprmCSizePos" chp.hps, chp.hpsPos
342cdf0e10cSrcweir { 96, 2, L_FIX}, // "sprmCDxaSpace" chp.dxaSpace dxa
343cdf0e10cSrcweir { 97, 2, L_FIX}, // "sprmCLid" chp.lid LID
344cdf0e10cSrcweir { 98, 1, L_FIX}, // "sprmCIco" chp.ico ico byte
345cdf0e10cSrcweir { 99, 2, L_FIX}, // "sprmCHps" chp.hps hps !word!
346cdf0e10cSrcweir {100, 1, L_FIX}, // "sprmCHpsInc" chp.hps
347cdf0e10cSrcweir {101, 2, L_FIX}, // "sprmCHpsPos" chp.hpsPos hps !word!
348cdf0e10cSrcweir {102, 1, L_FIX}, // "sprmCHpsPosAdj" chp.hpsPos hps
349cdf0e10cSrcweir {103, 0, L_VAR}, // "?sprmCMajority" chp.fBold, chp.fItalic, ...
350cdf0e10cSrcweir {104, 1, L_FIX}, // "sprmCIss" chp.iss iss
351cdf0e10cSrcweir {105, 0, L_VAR}, // "sprmCHpsNew50" chp.hps hps variable width
352cdf0e10cSrcweir {106, 0, L_VAR}, // "sprmCHpsInc1" chp.hps complex
353cdf0e10cSrcweir {107, 2, L_FIX}, // "sprmCHpsKern" chp.hpsKern hps
354cdf0e10cSrcweir {108, 0, L_VAR}, // "sprmCMajority50" chp.fBold, chp.fItalic, ...
355cdf0e10cSrcweir {109, 2, L_FIX}, // "sprmCHpsMul" chp.hps percentage to grow hps
356cdf0e10cSrcweir {110, 2, L_FIX}, // "sprmCCondHyhen" chp.ysri ysri
357cdf0e10cSrcweir {111, 2, L_FIX}, // rtl bold
358cdf0e10cSrcweir {112, 2, L_FIX}, // rtl italic
359cdf0e10cSrcweir {113, 0, L_VAR}, // rtl property ?
360cdf0e10cSrcweir {115, 0, L_VAR}, // rtl property ?
361cdf0e10cSrcweir {116, 0, L_VAR}, // unknown
362cdf0e10cSrcweir {117, 1, L_FIX}, // "sprmCFSpec" chp.fSpec 1 or 0 bit
363cdf0e10cSrcweir {118, 1, L_FIX}, // "sprmCFObj" chp.fObj 1 or 0 bit
364cdf0e10cSrcweir {119, 1, L_FIX}, // "sprmPicBrcl" pic.brcl brcl (see PIC definition)
365cdf0e10cSrcweir {120,12, L_VAR}, // "sprmPicScale" pic.mx, pic.my, pic.dxaCropleft,
366cdf0e10cSrcweir {121, 2, L_FIX}, // "sprmPicBrcTop" pic.brcTop BRC word
367cdf0e10cSrcweir {122, 2, L_FIX}, // "sprmPicBrcLeft" pic.brcLeft BRC word
368cdf0e10cSrcweir {123, 2, L_FIX}, // "sprmPicBrcBottom" pic.brcBottom BRC word
369cdf0e10cSrcweir {124, 2, L_FIX}, // "sprmPicBrcRight" pic.brcRight BRC word
370cdf0e10cSrcweir {131, 1, L_FIX}, // "sprmSScnsPgn" sep.cnsPgn cns byte
371cdf0e10cSrcweir {132, 1, L_FIX}, // "sprmSiHeadingPgn" sep.iHeadingPgn
372cdf0e10cSrcweir {133, 0, L_VAR}, // "sprmSOlstAnm" sep.olstAnm OLST variable length
373cdf0e10cSrcweir {136, 3, L_FIX}, // "sprmSDxaColWidth" sep.rgdxaColWidthSpacing complex
374cdf0e10cSrcweir {137, 3, L_FIX}, // "sprmSDxaColSpacing" sep.rgdxaColWidthSpacing
375cdf0e10cSrcweir {138, 1, L_FIX}, // "sprmSFEvenlySpaced" sep.fEvenlySpaced 1 or 0
376cdf0e10cSrcweir {139, 1, L_FIX}, // "sprmSFProtected" sep.fUnlocked 1 or 0 byte
377cdf0e10cSrcweir {140, 2, L_FIX}, // "sprmSDmBinFirst" sep.dmBinFirst word
378cdf0e10cSrcweir {141, 2, L_FIX}, // "sprmSDmBinOther" sep.dmBinOther word
379cdf0e10cSrcweir {142, 1, L_FIX}, // "sprmSBkc" sep.bkc bkc byte
380cdf0e10cSrcweir {143, 1, L_FIX}, // "sprmSFTitlePage" sep.fTitlePage 0 or 1 byte
381cdf0e10cSrcweir {144, 2, L_FIX}, // "sprmSCcolumns" sep.ccolM1 # of cols - 1 word
382cdf0e10cSrcweir {145, 2, L_FIX}, // "sprmSDxaColumns" sep.dxaColumns dxa word
383cdf0e10cSrcweir {146, 1, L_FIX}, // "sprmSFAutoPgn" sep.fAutoPgn obsolete byte
384cdf0e10cSrcweir {147, 1, L_FIX}, // "sprmSNfcPgn" sep.nfcPgn nfc byte
385cdf0e10cSrcweir {148, 2, L_FIX}, // "sprmSDyaPgn" sep.dyaPgn dya short
386cdf0e10cSrcweir {149, 2, L_FIX}, // "sprmSDxaPgn" sep.dxaPgn dya short
387cdf0e10cSrcweir {150, 1, L_FIX}, // "sprmSFPgnRestart" sep.fPgnRestart 0 or 1 byte
388cdf0e10cSrcweir {151, 1, L_FIX}, // "sprmSFEndnote" sep.fEndnote 0 or 1 byte
389cdf0e10cSrcweir {152, 1, L_FIX}, // "sprmSLnc" sep.lnc lnc byte
390cdf0e10cSrcweir {153, 1, L_FIX}, // "sprmSGprfIhdt" sep.grpfIhdt grpfihdt
391cdf0e10cSrcweir {154, 2, L_FIX}, // "sprmSNLnnMod" sep.nLnnMod non-neg int. word
392cdf0e10cSrcweir {155, 2, L_FIX}, // "sprmSDxaLnn" sep.dxaLnn dxa word
393cdf0e10cSrcweir {156, 2, L_FIX}, // "sprmSDyaHdrTop" sep.dyaHdrTop dya word
394cdf0e10cSrcweir {157, 2, L_FIX}, // "sprmSDyaHdrBottom" sep.dyaHdrBottom dya word
395cdf0e10cSrcweir {158, 1, L_FIX}, // "sprmSLBetween" sep.fLBetween 0 or 1 byte
396cdf0e10cSrcweir {159, 1, L_FIX}, // "sprmSVjc" sep.vjc vjc byte
397cdf0e10cSrcweir {160, 2, L_FIX}, // "sprmSLnnMin" sep.lnnMin lnn word
398cdf0e10cSrcweir {161, 2, L_FIX}, // "sprmSPgnStart" sep.pgnStart pgn word
399cdf0e10cSrcweir {162, 1, L_FIX}, // "sprmSBOrientation" sep.dmOrientPage dm byte
400cdf0e10cSrcweir {163, 0, L_FIX}, // "?SprmSBCustomize 163"
401cdf0e10cSrcweir {164, 2, L_FIX}, // "sprmSXaPage" sep.xaPage xa word
402cdf0e10cSrcweir {165, 2, L_FIX}, // "sprmSYaPage" sep.yaPage ya word
403cdf0e10cSrcweir {166, 2, L_FIX}, // "sprmSDxaLeft" sep.dxaLeft dxa word
404cdf0e10cSrcweir {167, 2, L_FIX}, // "sprmSDxaRight" sep.dxaRight dxa word
405cdf0e10cSrcweir {168, 2, L_FIX}, // "sprmSDyaTop" sep.dyaTop dya word
406cdf0e10cSrcweir {169, 2, L_FIX}, // "sprmSDyaBottom" sep.dyaBottom dya word
407cdf0e10cSrcweir {170, 2, L_FIX}, // "sprmSDzaGutter" sep.dzaGutter dza word
408cdf0e10cSrcweir {171, 2, L_FIX}, // "sprmSDMPaperReq" sep.dmPaperReq dm word
409cdf0e10cSrcweir {179, 0, L_VAR}, // rtl property ?
410cdf0e10cSrcweir {181, 0, L_VAR}, // rtl property ?
411cdf0e10cSrcweir {182, 2, L_FIX}, // "sprmTJc" tap.jc jc (low order byte is significant)
412cdf0e10cSrcweir {183, 2, L_FIX}, // "sprmTDxaLeft" tap.rgdxaCenter dxa word
413cdf0e10cSrcweir {184, 2, L_FIX}, // "sprmTDxaGapHalf" tap.dxaGapHalf, tap.rgdxaCenter
414cdf0e10cSrcweir {185, 1, L_FIX}, // "sprmTFCantSplit" tap.fCantSplit 1 or 0 byte
415cdf0e10cSrcweir {186, 1, L_FIX}, // "sprmTTableHeader" tap.fTableHeader 1 or 0 byte
416cdf0e10cSrcweir {187,12, L_FIX}, // "sprmTTableBorders" tap.rgbrcTable complex 12 bytes
417cdf0e10cSrcweir {188, 0, L_VAR}, // "sprmTDefTable10" tap.rgdxaCenter, tap.rgtc complex
418cdf0e10cSrcweir {189, 2, L_FIX}, // "sprmTDyaRowHeight" tap.dyaRowHeight dya word
419cdf0e10cSrcweir {190, 0, L_VAR2},// "sprmTDefTable" tap.rgtc complex
420cdf0e10cSrcweir {191, 1, L_VAR}, // "sprmTDefTableShd" tap.rgshd complex
421cdf0e10cSrcweir {192, 4, L_FIX}, // "sprmTTlp" tap.tlp TLP 4 bytes
422cdf0e10cSrcweir {193, 5, L_FIX}, // "sprmTSetBrc" tap.rgtc[].rgbrc complex 5 bytes
423cdf0e10cSrcweir {194, 4, L_FIX}, // "sprmTInsert" tap.rgdxaCenter,tap.rgtc complex
424cdf0e10cSrcweir {195, 2, L_FIX}, // "sprmTDelete" tap.rgdxaCenter, tap.rgtc complex
425cdf0e10cSrcweir {196, 4, L_FIX}, // "sprmTDxaCol" tap.rgdxaCenter complex
426cdf0e10cSrcweir {197, 2, L_FIX}, // "sprmTMerge" tap.fFirstMerged, tap.fMerged complex
427cdf0e10cSrcweir {198, 2, L_FIX}, // "sprmTSplit" tap.fFirstMerged, tap.fMerged complex
428cdf0e10cSrcweir {199, 5, L_FIX}, // "sprmTSetBrc10" tap.rgtc[].rgbrc complex 5 bytes
429cdf0e10cSrcweir {200, 4, L_FIX}, // "sprmTSetShd", tap.rgshd complex 4 bytes
430cdf0e10cSrcweir {207, 0, L_VAR} // rtl property ?
431cdf0e10cSrcweir };
432cdf0e10cSrcweir
433cdf0e10cSrcweir static wwSprmSearcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0]));
434cdf0e10cSrcweir return &aSprmSrch;
435cdf0e10cSrcweir };
436cdf0e10cSrcweir
GetWW8SprmSearcher()437cdf0e10cSrcweir const wwSprmSearcher *wwSprmParser::GetWW8SprmSearcher()
438cdf0e10cSrcweir {
439cdf0e10cSrcweir //double lock me
440cdf0e10cSrcweir //WW8+ Sprms
441cdf0e10cSrcweir static const SprmInfo aSprms[] =
442cdf0e10cSrcweir {
443cdf0e10cSrcweir { 0, 0, L_FIX}, // "Default-sprm"/ wird uebersprungen
444cdf0e10cSrcweir {0x4600, 2, L_FIX}, // "sprmPIstd" pap.istd;istd (style code);short;
445cdf0e10cSrcweir {0xC601, 0, L_VAR}, // "sprmPIstdPermute" pap.istd;permutation vector
446cdf0e10cSrcweir {0x2602, 1, L_FIX}, // "sprmPIncLvl" pap.istd, pap.lvl;difference
447cdf0e10cSrcweir // between istd of base PAP and istd of PAP to be
448cdf0e10cSrcweir // produced
449cdf0e10cSrcweir {0x2403, 1, L_FIX}, // "sprmPJc" pap.jc;jc (justification);byte;
450cdf0e10cSrcweir {0x2404, 1, L_FIX}, // "sprmPFSideBySide" pap.fSideBySide;0 or 1;byte;
451cdf0e10cSrcweir {0x2405, 1, L_FIX}, // "sprmPFKeep" pap.fKeep;0 or 1;byte;
452cdf0e10cSrcweir {0x2406, 1, L_FIX}, // "sprmPFKeepFollow" pap.fKeepFollow;0 or 1;byte;
453cdf0e10cSrcweir {0x2407, 1, L_FIX}, // "sprmPFPageBreakBefore" pap.fPageBreakBefore;
454cdf0e10cSrcweir // 0 or 1
455cdf0e10cSrcweir {0x2408, 1, L_FIX}, // "sprmPBrcl" pap.brcl;brcl;byte;
456cdf0e10cSrcweir {0x2409, 1, L_FIX}, // "sprmPBrcp" pap.brcp;brcp;byte;
457cdf0e10cSrcweir {0x260A, 1, L_FIX}, // "sprmPIlvl" pap.ilvl;ilvl;byte;
458cdf0e10cSrcweir {0x460B, 2, L_FIX}, // "sprmPIlfo" pap.ilfo;ilfo (list index) ;short;
459cdf0e10cSrcweir {0x240C, 1, L_FIX}, // "sprmPFNoLineNumb" pap.fNoLnn;0 or 1;byte;
460cdf0e10cSrcweir {0xC60D, 0, L_VAR}, // "sprmPChgTabsPapx" pap.itbdMac, pap.rgdxaTab,
461cdf0e10cSrcweir // pap.rgtbd;complex
462cdf0e10cSrcweir {0x840E, 2, L_FIX}, // "sprmPDxaRight" pap.dxaRight;dxa;word;
463cdf0e10cSrcweir {0x840F, 2, L_FIX}, // "sprmPDxaLeft" pap.dxaLeft;dxa;word;
464cdf0e10cSrcweir {0x4610, 2, L_FIX}, // "sprmPNest" pap.dxaLeft;dxa
465cdf0e10cSrcweir {0x8411, 2, L_FIX}, // "sprmPDxaLeft1" pap.dxaLeft1;dxa;word;
466cdf0e10cSrcweir {0x6412, 4, L_FIX}, // "sprmPDyaLine" pap.lspd;an LSPD, a long word
467cdf0e10cSrcweir // structure consisting of a short of dyaLine
468cdf0e10cSrcweir // followed by a short of fMultLinespace
469cdf0e10cSrcweir {0xA413, 2, L_FIX}, // "sprmPDyaBefore" pap.dyaBefore;dya;word;
470cdf0e10cSrcweir {0xA414, 2, L_FIX}, // "sprmPDyaAfter" pap.dyaAfter;dya;word;
471cdf0e10cSrcweir {0xC615, 0, L_VAR}, // "sprmPChgTabs" pap.itbdMac, pap.rgdxaTab,
472cdf0e10cSrcweir // pap.rgtbd;complex
473cdf0e10cSrcweir {0x2416, 1, L_FIX}, // "sprmPFInTable" pap.fInTable;0 or 1;byte;
474cdf0e10cSrcweir {0x2417, 1, L_FIX}, // "sprmPFTtp" pap.fTtp;0 or 1;byte;
475cdf0e10cSrcweir {0x8418, 2, L_FIX}, // "sprmPDxaAbs" pap.dxaAbs;dxa;word;
476cdf0e10cSrcweir {0x8419, 2, L_FIX}, // "sprmPDyaAbs" pap.dyaAbs;dya;word;
477cdf0e10cSrcweir {0x841A, 2, L_FIX}, // "sprmPDxaWidth" pap.dxaWidth;dxa;word;
478cdf0e10cSrcweir {0x261B, 1, L_FIX}, // "sprmPPc" pap.pcHorz, pap.pcVert;complex
479cdf0e10cSrcweir {0x461C, 2, L_FIX}, // "sprmPBrcTop10" pap.brcTop;BRC10;word;
480cdf0e10cSrcweir {0x461D, 2, L_FIX}, // "sprmPBrcLeft10" pap.brcLeft;BRC10;word;
481cdf0e10cSrcweir {0x461E, 2, L_FIX}, // "sprmPBrcBottom10" pap.brcBottom;BRC10;word;
482cdf0e10cSrcweir {0x461F, 2, L_FIX}, // "sprmPBrcRight10" pap.brcRight;BRC10;word;
483cdf0e10cSrcweir {0x4620, 2, L_FIX}, // "sprmPBrcBetween10" pap.brcBetween;BRC10;word;
484cdf0e10cSrcweir {0x4621, 2, L_FIX}, // "sprmPBrcBar10" pap.brcBar;BRC10;word;
485cdf0e10cSrcweir {0x4622, 2, L_FIX}, // "sprmPDxaFromText10" pap.dxaFromText;dxa;word;
486cdf0e10cSrcweir {0x2423, 1, L_FIX}, // "sprmPWr" pap.wr;wr
487cdf0e10cSrcweir {0x6424, 4, L_FIX}, // "sprmPBrcTop" pap.brcTop;BRC;long;
488cdf0e10cSrcweir {0x6425, 4, L_FIX}, // "sprmPBrcLeft" pap.brcLeft;BRC;long;
489cdf0e10cSrcweir {0x6426, 4, L_FIX}, // "sprmPBrcBottom" pap.brcBottom;BRC;long;
490cdf0e10cSrcweir {0x6427, 4, L_FIX}, // "sprmPBrcRight" pap.brcRight;BRC;long;
491cdf0e10cSrcweir {0x6428, 4, L_FIX}, // "sprmPBrcBetween" pap.brcBetween;BRC;long;
492cdf0e10cSrcweir {0x6629, 4, L_FIX}, // "sprmPBrcBar" pap.brcBar;BRC;long;
493cdf0e10cSrcweir {0x242A, 1, L_FIX}, // "sprmPFNoAutoHyph" pap.fNoAutoHyph;0 or 1;byte;
494cdf0e10cSrcweir {0x442B, 2, L_FIX}, // "sprmPWHeightAbs" pap.wHeightAbs;w;word;
495cdf0e10cSrcweir {0x442C, 2, L_FIX}, // "sprmPDcs" pap.dcs;DCS;short;
496cdf0e10cSrcweir {0x442D, 2, L_FIX}, // "sprmPShd" pap.shd;SHD;word;
497cdf0e10cSrcweir {0x842E, 2, L_FIX}, // "sprmPDyaFromText" pap.dyaFromText;dya;word;
498cdf0e10cSrcweir {0x842F, 2, L_FIX}, // "sprmPDxaFromText" pap.dxaFromText;dxa;word;
499cdf0e10cSrcweir {0x2430, 1, L_FIX}, // "sprmPFLocked" pap.fLocked;0 or 1;byte;
500cdf0e10cSrcweir {0x2431, 1, L_FIX}, // "sprmPFWidowControl" pap.fWidowControl;0 or 1
501cdf0e10cSrcweir {0xC632, 0, L_VAR}, // "sprmPRuler" ;;variable length;
502cdf0e10cSrcweir {0x2433, 1, L_FIX}, // "sprmPFKinsoku" pap.fKinsoku;0 or 1;byte;
503cdf0e10cSrcweir {0x2434, 1, L_FIX}, // "sprmPFWordWrap" pap.fWordWrap;0 or 1;byte;
504cdf0e10cSrcweir {0x2435, 1, L_FIX}, // "sprmPFOverflowPunct" pap.fOverflowPunct;0 or 1
505cdf0e10cSrcweir {0x2436, 1, L_FIX}, // "sprmPFTopLinePunct" pap.fTopLinePunct;0 or 1
506cdf0e10cSrcweir {0x2437, 1, L_FIX}, // "sprmPFAutoSpaceDE" pap.fAutoSpaceDE;0 or 1
507cdf0e10cSrcweir {0x2438, 1, L_FIX}, // "sprmPFAutoSpaceDN" pap.fAutoSpaceDN;0 or 1
508cdf0e10cSrcweir {0x4439, 2, L_FIX}, // "sprmPWAlignFont" pap.wAlignFont;iFa
509cdf0e10cSrcweir {0x443A, 2, L_FIX}, // "sprmPFrameTextFlow" pap.fVertical pap.fBackward
510cdf0e10cSrcweir // pap.fRotateFont;complex
511cdf0e10cSrcweir {0x243B, 1, L_FIX}, // "sprmPISnapBaseLine" obsolete: not applicable in
512cdf0e10cSrcweir // Word97 and later versions;
513cdf0e10cSrcweir {0xC63E, 0, L_VAR}, // "sprmPAnld" pap.anld;;variable length;
514cdf0e10cSrcweir {0xC63F, 0, L_VAR}, // "sprmPPropRMark" pap.fPropRMark;complex
515cdf0e10cSrcweir {0x2640, 1, L_FIX}, // "sprmPOutLvl" pap.lvl;has no effect if pap.istd
516cdf0e10cSrcweir // is < 1 or is > 9
517cdf0e10cSrcweir {0x2441, 1, L_FIX}, // "sprmPFBiDi" ;;byte;
518cdf0e10cSrcweir {0x2443, 1, L_FIX}, // "sprmPFNumRMIns" pap.fNumRMIns;1 or 0;bit;
519cdf0e10cSrcweir {0x2444, 1, L_FIX}, // "sprmPCrLf" ;;byte;
520cdf0e10cSrcweir {0xC645, 0, L_VAR}, // "sprmPNumRM" pap.numrm;;variable length;
521cdf0e10cSrcweir {0x6645, 4, L_FIX}, // "sprmPHugePapx" fc in the data stream to locate
522cdf0e10cSrcweir // the huge grpprl
523cdf0e10cSrcweir {0x6646, 4, L_FIX}, // "sprmPHugePapx" fc in the data stream to locate
524cdf0e10cSrcweir // the huge grpprl
525cdf0e10cSrcweir {0x2447, 1, L_FIX}, // "sprmPFUsePgsuSettings" pap.fUsePgsuSettings;
526cdf0e10cSrcweir // 1 or 0
527cdf0e10cSrcweir {0x2448, 1, L_FIX}, // "sprmPFAdjustRight" pap.fAdjustRight;1 or 0;byte;
528cdf0e10cSrcweir {0x0800, 1, L_FIX}, // "sprmCFRMarkDel" chp.fRMarkDel;1 or 0;bit;
529cdf0e10cSrcweir {0x0801, 1, L_FIX}, // "sprmCFRMark" chp.fRMark;1 or 0;bit;
530cdf0e10cSrcweir {0x0802, 1, L_FIX}, // "sprmCFFldVanish" chp.fFldVanish;1 or 0;bit;
531cdf0e10cSrcweir {0x6A03, 4, L_FIX}, // "sprmCPicLocation" chp.fcPic and chp.fSpec;
532cdf0e10cSrcweir {0x4804, 2, L_FIX}, // "sprmCIbstRMark" chp.ibstRMark;index into
533cdf0e10cSrcweir // sttbRMark
534cdf0e10cSrcweir {0x6805, 4, L_FIX}, // "sprmCDttmRMark" chp.dttmRMark;DTTM;long;
535cdf0e10cSrcweir {0x0806, 1, L_FIX}, // "sprmCFData" chp.fData;1 or 0;bit;
536cdf0e10cSrcweir {0x4807, 2, L_FIX}, // "sprmCIdslRMark" chp.idslRMReason;an index to a
537cdf0e10cSrcweir // table of strings defined in Word 6.0
538cdf0e10cSrcweir // executables;short;
539cdf0e10cSrcweir {0xEA08, 1, L_FIX}, // "sprmCChs" chp.fChsDiff and chp.chse;
540cdf0e10cSrcweir {0x6A09, 4, L_FIX}, // "sprmCSymbol" chp.fSpec, chp.xchSym and
541cdf0e10cSrcweir // chp.ftcSym
542cdf0e10cSrcweir {0x080A, 1, L_FIX}, // "sprmCFOle2" chp.fOle2;1 or 0;bit;
543cdf0e10cSrcweir {0x480B, 0, L_FIX}, // "sprmCIdCharType" obsolete: not applicable in
544cdf0e10cSrcweir // Word97 and later versions;;;
545cdf0e10cSrcweir {0x2A0C, 1, L_FIX}, // "sprmCHighlight" chp.fHighlight,
546cdf0e10cSrcweir // chp.icoHighlight;ico (fHighlight is set to 1 iff
547cdf0e10cSrcweir // ico is not 0)
548cdf0e10cSrcweir {0x680E, 4, L_FIX}, // "sprmCObjLocation" chp.fcObj;FC;long;
549cdf0e10cSrcweir {0x2A10, 0, L_FIX}, // "sprmCFFtcAsciSymb" ;;;
550cdf0e10cSrcweir {0x4A30, 2, L_FIX}, // "sprmCIstd" chp.istd;istd, see stylesheet def
551cdf0e10cSrcweir {0xCA31, 0, L_VAR}, // "sprmCIstdPermute" chp.istd;permutation vector
552cdf0e10cSrcweir {0x2A32, 0, L_VAR}, // "sprmCDefault" whole CHP;none;variable length;
553cdf0e10cSrcweir {0x2A33, 0, L_FIX}, // "sprmCPlain" whole CHP;none;0;
554cdf0e10cSrcweir {0x2A34, 1, L_FIX}, // "sprmCKcd" ;;;
555cdf0e10cSrcweir {0x0835, 1, L_FIX}, // "sprmCFBold" chp.fBold;0,1, 128, or 129
556cdf0e10cSrcweir {0x0836, 1, L_FIX}, // "sprmCFItalic" chp.fItalic;0,1, 128, or 129
557cdf0e10cSrcweir {0x0837, 1, L_FIX}, // "sprmCFStrike" chp.fStrike;0,1, 128, or 129
558cdf0e10cSrcweir {0x0838, 1, L_FIX}, // "sprmCFOutline" chp.fOutline;0,1, 128, or 129
559cdf0e10cSrcweir {0x0839, 1, L_FIX}, // "sprmCFShadow" chp.fShadow;0,1, 128, or 129
560cdf0e10cSrcweir {0x083A, 1, L_FIX}, // "sprmCFSmallCaps" chp.fSmallCaps;0,1, 128, or 129
561cdf0e10cSrcweir {0x083B, 1, L_FIX}, // "sprmCFCaps" chp.fCaps;0,1, 128, or 129
562cdf0e10cSrcweir {0x083C, 1, L_FIX}, // "sprmCFVanish" chp.fVanish;0,1, 128, or 129
563cdf0e10cSrcweir {0x4A3D, 2, L_FIX}, // "sprmCFtcDefault" ;ftc, only used internally
564cdf0e10cSrcweir {0x2A3E, 1, L_FIX}, // "sprmCKul" chp.kul;kul;byte;
565cdf0e10cSrcweir {0xEA3F, 3, L_FIX}, // "sprmCSizePos" chp.hps, chp.hpsPos;3 bytes;
566cdf0e10cSrcweir {0x8840, 2, L_FIX}, // "sprmCDxaSpace" chp.dxaSpace;dxa;word;
567cdf0e10cSrcweir {0x4A41, 2, L_FIX}, // "sprmCLid" ;only used internally never stored
568cdf0e10cSrcweir {0x2A42, 1, L_FIX}, // "sprmCIco" chp.ico;ico;byte;
569cdf0e10cSrcweir {0x4A43, 2, L_FIX}, // "sprmCHps" chp.hps;hps
570cdf0e10cSrcweir {0x2A44, 1, L_FIX}, // "sprmCHpsInc" chp.hps;
571cdf0e10cSrcweir {0x4845, 2, L_FIX}, // "sprmCHpsPos" chp.hpsPos;hps;short; (doc wrong)
572cdf0e10cSrcweir {0x2A46, 1, L_FIX}, // "sprmCHpsPosAdj" chp.hpsPos;hps
573cdf0e10cSrcweir {0xCA47, 0, L_VAR}, // "sprmCMajority" chp.fBold, chp.fItalic,
574cdf0e10cSrcweir // chp.fSmallCaps, chp.fVanish, chp.fStrike,
575cdf0e10cSrcweir // chp.fCaps, chp.rgftc, chp.hps, chp.hpsPos,
576cdf0e10cSrcweir // chp.kul, chp.dxaSpace, chp.ico,
577cdf0e10cSrcweir // chp.rglid;complex;variable length, length byte
578cdf0e10cSrcweir // plus size of following grpprl;
579cdf0e10cSrcweir {0x2A48, 1, L_FIX}, // "sprmCIss" chp.iss;iss;byte;
580cdf0e10cSrcweir {0xCA49, 0, L_VAR}, // "sprmCHpsNew50" chp.hps;hps;variable width
581cdf0e10cSrcweir {0xCA4A, 0, L_VAR}, // "sprmCHpsInc1" chp.hps;complex
582cdf0e10cSrcweir {0x484B, 2, L_FIX}, // "sprmCHpsKern" chp.hpsKern;hps;short;
583cdf0e10cSrcweir {0xCA4C, 2, L_FIX}, // "sprmCMajority50" chp.fBold, chp.fItalic,
584cdf0e10cSrcweir // chp.fSmallCaps, chp.fVanish, chp.fStrike,
585cdf0e10cSrcweir // chp.fCaps, chp.ftc, chp.hps, chp.hpsPos, chp.kul,
586cdf0e10cSrcweir // chp.dxaSpace, chp.ico,;complex
587cdf0e10cSrcweir {0x4A4D, 2, L_FIX}, // "sprmCHpsMul" chp.hps;percentage to grow hps
588cdf0e10cSrcweir {0x484E, 2, L_FIX}, // "sprmCYsri" chp.ysri;ysri;short;
589cdf0e10cSrcweir {0x4A4F, 2, L_FIX}, // "sprmCRgFtc0" chp.rgftc[0];ftc for ASCII text
590cdf0e10cSrcweir {0x4A50, 2, L_FIX}, // "sprmCRgFtc1" chp.rgftc[1];ftc for Far East text
591cdf0e10cSrcweir {0x4A51, 2, L_FIX}, // "sprmCRgFtc2" chp.rgftc[2];ftc for non-FE text
592cdf0e10cSrcweir {0x4852, 2, L_FIX}, // "sprmCCharScale"
593cdf0e10cSrcweir {0x2A53, 1, L_FIX}, // "sprmCFDStrike" chp.fDStrike;;byte;
594cdf0e10cSrcweir {0x0854, 1, L_FIX}, // "sprmCFImprint" chp.fImprint;1 or 0;bit;
595cdf0e10cSrcweir {0x0855, 1, L_FIX}, // "sprmCFSpec" chp.fSpec ;1 or 0;bit;
596cdf0e10cSrcweir {0x0856, 1, L_FIX}, // "sprmCFObj" chp.fObj;1 or 0;bit;
597cdf0e10cSrcweir {0xCA57, 0, L_VAR}, // "sprmCPropRMark" chp.fPropRMark,
598cdf0e10cSrcweir // chp.ibstPropRMark, chp.dttmPropRMark;Complex
599cdf0e10cSrcweir {0x0858, 1, L_FIX}, // "sprmCFEmboss" chp.fEmboss;1 or 0;bit;
600cdf0e10cSrcweir {0x2859, 1, L_FIX}, // "sprmCSfxText" chp.sfxtText;text animation;byte;
601cdf0e10cSrcweir {0x085A, 1, L_FIX}, // "sprmCFBiDi" ;;;
602cdf0e10cSrcweir {0x085B, 1, L_FIX}, // "sprmCFDiacColor" ;;;
603cdf0e10cSrcweir {0x085C, 1, L_FIX}, // "sprmCFBoldBi" ;;;
604cdf0e10cSrcweir {0x085D, 1, L_FIX}, // "sprmCFItalicBi" ;;;
605cdf0e10cSrcweir {0x4A5E, 2, L_FIX},
606cdf0e10cSrcweir {0x485F, 2, L_FIX}, // "sprmCLidBi" ;;;
607cdf0e10cSrcweir {0x4A60, 1, L_FIX}, // "sprmCIcoBi" ;;;
608cdf0e10cSrcweir {0x4A61, 2, L_FIX}, // "sprmCHpsBi" ;;;
609cdf0e10cSrcweir {0xCA62, 0, L_VAR}, // "sprmCDispFldRMark" chp.fDispFldRMark,
610cdf0e10cSrcweir // chp.ibstDispFldRMark, chp.dttmDispFldRMark ;
611cdf0e10cSrcweir {0x4863, 2, L_FIX}, // "sprmCIbstRMarkDel" chp.ibstRMarkDel;index into
612cdf0e10cSrcweir // sttbRMark;short;
613cdf0e10cSrcweir {0x6864, 4, L_FIX}, // "sprmCDttmRMarkDel" chp.dttmRMarkDel;DTTM;long;
614cdf0e10cSrcweir {0x6865, 4, L_FIX}, // "sprmCBrc" chp.brc;BRC;long;
615cdf0e10cSrcweir {0x4866, 2, L_FIX}, // "sprmCShd" chp.shd;SHD;short;
616cdf0e10cSrcweir {0x4867, 2, L_FIX}, // "sprmCIdslRMarkDel" chp.idslRMReasonDel;an index
617cdf0e10cSrcweir // to a table of strings defined in Word 6.0
618cdf0e10cSrcweir // executables;short;
619cdf0e10cSrcweir {0x0868, 1, L_FIX}, // "sprmCFUsePgsuSettings"
620cdf0e10cSrcweir // chp.fUsePgsuSettings;1 or 0
621cdf0e10cSrcweir {0x486B, 2, L_FIX}, // "sprmCCpg" ;;word;
622cdf0e10cSrcweir {0x486D, 2, L_FIX}, // "sprmCRgLid0" chp.rglid[0];LID: for non-FE text
623cdf0e10cSrcweir {0x486E, 2, L_FIX}, // "sprmCRgLid1" chp.rglid[1];LID: for Far East text
624cdf0e10cSrcweir {0x286F, 1, L_FIX}, // "sprmCIdctHint" chp.idctHint;IDCT:
625cdf0e10cSrcweir {0x2E00, 1, L_FIX}, // "sprmPicBrcl" pic.brcl;brcl (see PIC definition)
626cdf0e10cSrcweir {0xCE01, 0, L_VAR}, // "sprmPicScale" pic.mx, pic.my, pic.dxaCropleft,
627cdf0e10cSrcweir // pic.dyaCropTop pic.dxaCropRight,
628cdf0e10cSrcweir // pic.dyaCropBottom;Complex
629cdf0e10cSrcweir {0x6C02, 4, L_FIX}, // "sprmPicBrcTop" pic.brcTop;BRC;long;
630cdf0e10cSrcweir {0x6C03, 4, L_FIX}, // "sprmPicBrcLeft" pic.brcLeft;BRC;long;
631cdf0e10cSrcweir {0x6C04, 4, L_FIX}, // "sprmPicBrcBottom" pic.brcBottom;BRC;long;
632cdf0e10cSrcweir {0x6C05, 4, L_FIX}, // "sprmPicBrcRight" pic.brcRight;BRC;long;
633cdf0e10cSrcweir {0x3000, 1, L_FIX}, // "sprmScnsPgn" sep.cnsPgn;cns;byte;
634cdf0e10cSrcweir {0x3001, 1, L_FIX}, // "sprmSiHeadingPgn" sep.iHeadingPgn;heading number
635cdf0e10cSrcweir // level;byte;
636cdf0e10cSrcweir {0xD202, 0, L_VAR}, // "sprmSOlstAnm" sep.olstAnm;OLST;variable length;
637cdf0e10cSrcweir {0xF203, 3, L_FIX}, // "sprmSDxaColWidth" sep.rgdxaColWidthSpacing;
638cdf0e10cSrcweir {0xF204, 3, L_FIX}, // "sprmSDxaColSpacing" sep.rgdxaColWidthSpacing;
639cdf0e10cSrcweir // complex
640cdf0e10cSrcweir {0x3005, 1, L_FIX}, // "sprmSFEvenlySpaced" sep.fEvenlySpaced;1 or 0
641cdf0e10cSrcweir {0x3006, 1, L_FIX}, // "sprmSFProtected" sep.fUnlocked;1 or 0;byte;
642cdf0e10cSrcweir {0x5007, 2, L_FIX}, // "sprmSDmBinFirst" sep.dmBinFirst;;word;
643cdf0e10cSrcweir {0x5008, 2, L_FIX}, // "sprmSDmBinOther" sep.dmBinOther;;word;
644cdf0e10cSrcweir {0x3009, 1, L_FIX}, // "sprmSBkc" sep.bkc;bkc;byte;
645cdf0e10cSrcweir {0x300A, 1, L_FIX}, // "sprmSFTitlePage" sep.fTitlePage;0 or 1;byte;
646cdf0e10cSrcweir {0x500B, 2, L_FIX}, // "sprmSCcolumns" sep.ccolM1;# of cols - 1;word;
647cdf0e10cSrcweir {0x900C, 2, L_FIX}, // "sprmSDxaColumns" sep.dxaColumns;dxa;word;
648cdf0e10cSrcweir {0x300D, 1, L_FIX}, // "sprmSFAutoPgn" sep.fAutoPgn;obsolete;byte;
649cdf0e10cSrcweir {0x300E, 1, L_FIX}, // "sprmSNfcPgn" sep.nfcPgn;nfc;byte;
650cdf0e10cSrcweir {0xB00F, 2, L_FIX}, // "sprmSDyaPgn" sep.dyaPgn;dya;short;
651cdf0e10cSrcweir {0xB010, 2, L_FIX}, // "sprmSDxaPgn" sep.dxaPgn;dya;short;
652cdf0e10cSrcweir {0x3011, 1, L_FIX}, // "sprmSFPgnRestart" sep.fPgnRestart;0 or 1;byte;
653cdf0e10cSrcweir {0x3012, 1, L_FIX}, // "sprmSFEndnote" sep.fEndnote;0 or 1;byte;
654cdf0e10cSrcweir {0x3013, 1, L_FIX}, // "sprmSLnc" sep.lnc;lnc;byte;
655cdf0e10cSrcweir {0x3014, 1, L_FIX}, // "sprmSGprfIhdt" sep.grpfIhdt;grpfihdt
656cdf0e10cSrcweir {0x5015, 2, L_FIX}, // "sprmSNLnnMod" sep.nLnnMod;non-neg int.;word;
657cdf0e10cSrcweir {0x9016, 2, L_FIX}, // "sprmSDxaLnn" sep.dxaLnn;dxa;word;
658cdf0e10cSrcweir {0xB017, 2, L_FIX}, // "sprmSDyaHdrTop" sep.dyaHdrTop;dya;word;
659cdf0e10cSrcweir {0xB018, 2, L_FIX}, // "sprmSDyaHdrBottom" sep.dyaHdrBottom;dya;word;
660cdf0e10cSrcweir {0x3019, 1, L_FIX}, // "sprmSLBetween" sep.fLBetween;0 or 1;byte;
661cdf0e10cSrcweir {0x301A, 1, L_FIX}, // "sprmSVjc" sep.vjc;vjc;byte;
662cdf0e10cSrcweir {0x501B, 2, L_FIX}, // "sprmSLnnMin" sep.lnnMin;lnn;word;
663cdf0e10cSrcweir {0x501C, 2, L_FIX}, // "sprmSPgnStart" sep.pgnStart;pgn;word;
664cdf0e10cSrcweir {0x301D, 1, L_FIX}, // "sprmSBOrientation" sep.dmOrientPage;dm;byte;
665cdf0e10cSrcweir {0x301E, 1, L_FIX}, // "sprmSBCustomize" ;;;
666cdf0e10cSrcweir {0xB01F, 2, L_FIX}, // "sprmSXaPage" sep.xaPage;xa;word;
667cdf0e10cSrcweir {0xB020, 2, L_FIX}, // "sprmSYaPage" sep.yaPage;ya;word;
668cdf0e10cSrcweir {0xB021, 2, L_FIX}, // "sprmSDxaLeft" sep.dxaLeft;dxa;word;
669cdf0e10cSrcweir {0xB022, 2, L_FIX}, // "sprmSDxaRight" sep.dxaRight;dxa;word;
670cdf0e10cSrcweir {0x9023, 2, L_FIX}, // "sprmSDyaTop" sep.dyaTop;dya;word;
671cdf0e10cSrcweir {0x9024, 2, L_FIX}, // "sprmSDyaBottom" sep.dyaBottom;dya;word;
672cdf0e10cSrcweir {0xB025, 2, L_FIX}, // "sprmSDzaGutter" sep.dzaGutter;dza;word;
673cdf0e10cSrcweir {0x5026, 2, L_FIX}, // "sprmSDmPaperReq" sep.dmPaperReq;dm;word;
674cdf0e10cSrcweir {0xD227, 0, L_VAR}, // "sprmSPropRMark" sep.fPropRMark,
675cdf0e10cSrcweir // sep.ibstPropRMark, sep.dttmPropRMark ;complex
676cdf0e10cSrcweir {0x3228, 1, L_FIX}, // "sprmSFBiDi" ;;;
677cdf0e10cSrcweir {0x3229, 1, L_FIX}, // "sprmSFFacingCol" ;;;
678cdf0e10cSrcweir {0x322A, 1, L_FIX}, // "sprmSFRTLGutter", set to one if gutter is on
679cdf0e10cSrcweir // right
680cdf0e10cSrcweir {0x702B, 4, L_FIX}, // "sprmSBrcTop" sep.brcTop;BRC;long;
681cdf0e10cSrcweir {0x702C, 4, L_FIX}, // "sprmSBrcLeft" sep.brcLeft;BRC;long;
682cdf0e10cSrcweir {0x702D, 4, L_FIX}, // "sprmSBrcBottom" sep.brcBottom;BRC;long;
683cdf0e10cSrcweir {0x702E, 4, L_FIX}, // "sprmSBrcRight" sep.brcRight;BRC;long;
684cdf0e10cSrcweir {0x522F, 2, L_FIX}, // "sprmSPgbProp" sep.pgbProp;;word;
685cdf0e10cSrcweir {0x7030, 4, L_FIX}, // "sprmSDxtCharSpace" sep.dxtCharSpace;dxt;long;
686cdf0e10cSrcweir {0x9031, 2, L_FIX}, // "sprmSDyaLinePitch"
687cdf0e10cSrcweir // sep.dyaLinePitch;dya; WRONG:long; RIGHT:short; !
688cdf0e10cSrcweir {0x5032, 2, L_FIX}, // "sprmSClm" ;;;
689cdf0e10cSrcweir {0x5033, 2, L_FIX}, // "sprmSTextFlow" sep.wTextFlow;complex
690cdf0e10cSrcweir {0x5400, 2, L_FIX}, // "sprmTJc" tap.jc;jc;word (low order byte is
691cdf0e10cSrcweir // significant);
692cdf0e10cSrcweir {0x9601, 2, L_FIX}, // "sprmTDxaLeft" tap.rgdxaCenter
693cdf0e10cSrcweir {0x9602, 2, L_FIX}, // "sprmTDxaGapHalf" tap.dxaGapHalf,
694cdf0e10cSrcweir // tap.rgdxaCenter
695cdf0e10cSrcweir {0x3403, 1, L_FIX}, // "sprmTFCantSplit" tap.fCantSplit;1 or 0;byte;
696cdf0e10cSrcweir {0x3404, 1, L_FIX}, // "sprmTTableHeader" tap.fTableHeader;1 or 0;byte;
697cdf0e10cSrcweir {0x3466, 1, L_FIX}, // "sprmTFCantSplit90" tap.fCantSplit90;1 or 0;byte;
698cdf0e10cSrcweir {0xD605, 0, L_VAR}, // "sprmTTableBorders" tap.rgbrcTable;complex
699cdf0e10cSrcweir {0xD606, 0, L_VAR}, // "sprmTDefTable10" tap.rgdxaCenter,
700cdf0e10cSrcweir // tap.rgtc;complex
701cdf0e10cSrcweir {0x9407, 2, L_FIX}, // "sprmTDyaRowHeight" tap.dyaRowHeight;dya;word;
702cdf0e10cSrcweir {0xD608, 0, L_VAR}, // "sprmTDefTable" tap.rgtc;complex
703cdf0e10cSrcweir {0xD609, 0, L_VAR}, // "sprmTDefTableShd" tap.rgshd;complex
704cdf0e10cSrcweir {0x740A, 4, L_FIX}, // "sprmTTlp" tap.tlp;TLP;4 bytes;
705cdf0e10cSrcweir {0x560B, 2, L_FIX}, // "sprmTFBiDi" ;;;
706cdf0e10cSrcweir {0x740C, 1, L_FIX}, // "sprmTHTMLProps" ;;;
707cdf0e10cSrcweir {0xD620, 0, L_VAR}, // "sprmTSetBrc" tap.rgtc[].rgbrc;complex
708cdf0e10cSrcweir {0x7621, 4, L_FIX}, // "sprmTInsert" tap.rgdxaCenter, tap.rgtc;complex
709cdf0e10cSrcweir {0x5622, 2, L_FIX}, // "sprmTDelete" tap.rgdxaCenter, tap.rgtc;complex
710cdf0e10cSrcweir {0x7623, 4, L_FIX}, // "sprmTDxaCol" tap.rgdxaCenter;complex
711cdf0e10cSrcweir {0x5624, 0, L_VAR}, // "sprmTMerge" tap.fFirstMerged, tap.fMerged;
712cdf0e10cSrcweir {0x5625, 0, L_VAR}, // "sprmTSplit" tap.fFirstMerged, tap.fMerged;
713cdf0e10cSrcweir {0xD626, 0, L_VAR}, // "sprmTSetBrc10" tap.rgtc[].rgbrc;complex
714cdf0e10cSrcweir {0x7627, 0, L_VAR}, // "sprmTSetShd" tap.rgshd;complex
715cdf0e10cSrcweir {0x7628, 0, L_VAR}, // "sprmTSetShdOdd" tap.rgshd;complex
716cdf0e10cSrcweir {0x7629, 4, L_FIX}, // "sprmTTextFlow" tap.rgtc[].fVerticaltap,
717cdf0e10cSrcweir // rgtc[].fBackwardtap, rgtc[].fRotateFont;0 or 10
718cdf0e10cSrcweir // or 10 or 1;word;
719cdf0e10cSrcweir {0xD62A, 1, L_FIX}, // "sprmTDiagLine" ;;;
720cdf0e10cSrcweir {0xD62B, 0, L_VAR}, // "sprmTVertMerge" tap.rgtc[].vertMerge
721cdf0e10cSrcweir {0xD62C, 0, L_VAR}, // "sprmTVertAlign" tap.rgtc[].vertAlign
722cdf0e10cSrcweir {0xCA78, 0, L_VAR}, // undocumented "sprmCDoubleLine ?"
723cdf0e10cSrcweir {0x6649, 4, L_FIX}, // undocumented
724cdf0e10cSrcweir {0xF614, 3, L_FIX}, // undocumented
725cdf0e10cSrcweir {0xD612, 0, L_VAR}, // undocumented, new background colours.
726cdf0e10cSrcweir {0xD613, 0, L_VAR}, // undocumented
727cdf0e10cSrcweir {0xD61A, 0, L_VAR}, // undocumented
728cdf0e10cSrcweir {0xD61B, 0, L_VAR}, // undocumented
729cdf0e10cSrcweir {0xD61C, 0, L_VAR}, // undocumented
730cdf0e10cSrcweir {0xD61D, 0, L_VAR}, // undocumented
731cdf0e10cSrcweir {0xD632, 0, L_VAR}, // undocumented
732cdf0e10cSrcweir {0xD634, 0, L_VAR}, // undocumented
733cdf0e10cSrcweir {0xD238, 0, L_VAR}, // undocumented sep
734cdf0e10cSrcweir {0xC64E, 0, L_VAR}, // undocumented
735cdf0e10cSrcweir {0xC64F, 0, L_VAR}, // undocumented
736cdf0e10cSrcweir {0xC650, 0, L_VAR}, // undocumented
737cdf0e10cSrcweir {0xC651, 0, L_VAR}, // undocumented
738cdf0e10cSrcweir {0xF661, 3, L_FIX}, // undocumented
739cdf0e10cSrcweir {0x4873, 2, L_FIX}, // undocumented
740cdf0e10cSrcweir {0x4874, 2, L_FIX}, // undocumented
741cdf0e10cSrcweir {0x6463, 4, L_FIX}, // undocumented
742cdf0e10cSrcweir {0x2461, 1, L_FIX}, // undoc, must be asian version of "sprmPJc"
743cdf0e10cSrcweir {0x845D, 2, L_FIX}, // undoc, must be asian version of "sprmPDxaRight"
744cdf0e10cSrcweir {0x845E, 2, L_FIX}, // undoc, must be asian version of "sprmPDxaLeft"
745cdf0e10cSrcweir {0x8460, 2, L_FIX}, // undoc, must be asian version of "sprmPDxaLeft1"
746cdf0e10cSrcweir {0x3615, 1, L_FIX}, // undocumented
747cdf0e10cSrcweir {0x360D, 1, L_FIX}, // undocumented
748cdf0e10cSrcweir {0x703A, 4, L_FIX}, // undocumented, sep, perhaps related to textgrids ?
749cdf0e10cSrcweir {0x303B, 1, L_FIX}, // undocumented, sep
750cdf0e10cSrcweir {0x244B, 1, L_FIX}, // undocumented, subtable "sprmPFInTable" equiv ?
751cdf0e10cSrcweir {0x244C, 1, L_FIX}, // undocumented, subtable "sprmPFTtp" equiv ?
752cdf0e10cSrcweir {0x940E, 2, L_FIX}, // undocumented
753cdf0e10cSrcweir {0x940F, 2, L_FIX}, // undocumented
754cdf0e10cSrcweir {0x9410, 2, L_FIX}, // undocumented
755cdf0e10cSrcweir {0x6815, 4, L_FIX}, // undocumented
756cdf0e10cSrcweir {0x6816, 4, L_FIX}, // undocumented
757cdf0e10cSrcweir {0x6870, 4, L_FIX}, // undocumented, text colour
758cdf0e10cSrcweir {0xC64D, 0, L_VAR}, // undocumented, para back colour
759cdf0e10cSrcweir {0x6467, 4, L_FIX}, // undocumented
760cdf0e10cSrcweir {0x646B, 4, L_FIX}, // undocumented
761cdf0e10cSrcweir {0xF617, 3, L_FIX}, // undocumented
762cdf0e10cSrcweir {0xD660, 0, L_VAR}, // undocumented, something to do with colour.
763cdf0e10cSrcweir {0xD670, 0, L_VAR}, // undocumented, something to do with colour.
764cdf0e10cSrcweir {0xCA71, 0, L_VAR}, // undocumented, text backcolour
765cdf0e10cSrcweir {0x303C, 1, L_FIX}, // undocumented, sep
766cdf0e10cSrcweir {0x245B, 1, L_FIX}, // undocumented, para autobefore
767cdf0e10cSrcweir {0x245C, 1, L_FIX}, // undocumented, para autoafter
768cdf0e10cSrcweir // undocumented, don't add space between para of the same style
769cdf0e10cSrcweir {0x246D, 1, L_FIX}
770cdf0e10cSrcweir };
771cdf0e10cSrcweir
772cdf0e10cSrcweir static wwSprmSearcher aSprmSrch(aSprms, sizeof(aSprms) / sizeof(aSprms[0]));
773cdf0e10cSrcweir return &aSprmSrch;
774cdf0e10cSrcweir };
775cdf0e10cSrcweir
wwSprmParser(ww::WordVersion eVersion)776cdf0e10cSrcweir wwSprmParser::wwSprmParser(ww::WordVersion eVersion) : meVersion(eVersion)
777cdf0e10cSrcweir {
778cdf0e10cSrcweir ASSERT((meVersion >= ww::eWW2 && meVersion <= ww::eWW8),
779cdf0e10cSrcweir "Impossible value for version");
780cdf0e10cSrcweir
781cdf0e10cSrcweir mnDelta = (ww::IsSevenMinus(meVersion)) ? 0 : 1;
782cdf0e10cSrcweir
783cdf0e10cSrcweir if (meVersion <= ww::eWW2)
784cdf0e10cSrcweir mpKnownSprms = GetWW2SprmSearcher();
785cdf0e10cSrcweir else if (meVersion < ww::eWW8)
786cdf0e10cSrcweir mpKnownSprms = GetWW6SprmSearcher();
787cdf0e10cSrcweir else
788cdf0e10cSrcweir mpKnownSprms = GetWW8SprmSearcher();
789cdf0e10cSrcweir }
790cdf0e10cSrcweir
GetSprmInfo(sal_uInt16 nId) const791cdf0e10cSrcweir SprmInfo wwSprmParser::GetSprmInfo(sal_uInt16 nId) const
792cdf0e10cSrcweir {
793cdf0e10cSrcweir // Find sprm
794cdf0e10cSrcweir SprmInfo aSrch={0,0,0};
795cdf0e10cSrcweir aSrch.nId = nId;
796cdf0e10cSrcweir const SprmInfo* pFound = mpKnownSprms->search(aSrch);
797cdf0e10cSrcweir if (pFound == 0)
798cdf0e10cSrcweir {
799cdf0e10cSrcweir ASSERT(ww::IsEightPlus(meVersion),
800cdf0e10cSrcweir "Unknown ww7- sprm, dangerous, report to development");
801cdf0e10cSrcweir
802cdf0e10cSrcweir aSrch.nId = 0;
803cdf0e10cSrcweir aSrch.nLen = 0;
804cdf0e10cSrcweir //All the unknown ww7 sprms appear to be variable (which makes sense)
805cdf0e10cSrcweir aSrch.nVari = L_VAR;
806cdf0e10cSrcweir
807cdf0e10cSrcweir if (ww::IsEightPlus(meVersion)) //We can recover perfectly in this case
808cdf0e10cSrcweir {
809cdf0e10cSrcweir aSrch.nVari = L_FIX;
810cdf0e10cSrcweir switch (nId >> 13)
811cdf0e10cSrcweir {
812cdf0e10cSrcweir case 0:
813cdf0e10cSrcweir case 1:
814cdf0e10cSrcweir aSrch.nLen = 1;
815cdf0e10cSrcweir break;
816cdf0e10cSrcweir case 2:
817cdf0e10cSrcweir aSrch.nLen = 2;
818cdf0e10cSrcweir break;
819cdf0e10cSrcweir case 3:
820cdf0e10cSrcweir aSrch.nLen = 4;
821cdf0e10cSrcweir break;
822cdf0e10cSrcweir case 4:
823cdf0e10cSrcweir case 5:
824cdf0e10cSrcweir aSrch.nLen = 2;
825cdf0e10cSrcweir break;
826cdf0e10cSrcweir case 6:
827cdf0e10cSrcweir aSrch.nLen = 0;
828cdf0e10cSrcweir aSrch.nVari = L_VAR;
829cdf0e10cSrcweir break;
830cdf0e10cSrcweir case 7:
831cdf0e10cSrcweir default:
832cdf0e10cSrcweir aSrch.nLen = 3;
833cdf0e10cSrcweir break;
834cdf0e10cSrcweir }
835cdf0e10cSrcweir }
836cdf0e10cSrcweir
837cdf0e10cSrcweir pFound = &aSrch;
838cdf0e10cSrcweir }
839cdf0e10cSrcweir return *pFound;
840cdf0e10cSrcweir }
841cdf0e10cSrcweir
842cdf0e10cSrcweir //-end
843cdf0e10cSrcweir
Get_Byte(sal_uInt8 * & p)844cdf0e10cSrcweir inline sal_uInt8 Get_Byte( sal_uInt8 *& p )
845cdf0e10cSrcweir {
846cdf0e10cSrcweir sal_uInt8 n = SVBT8ToByte( *(SVBT8*)p );
847cdf0e10cSrcweir p += 1;
848cdf0e10cSrcweir return n;
849cdf0e10cSrcweir }
850cdf0e10cSrcweir
Get_UShort(sal_uInt8 * & p)851cdf0e10cSrcweir inline sal_uInt16 Get_UShort( sal_uInt8 *& p )
852cdf0e10cSrcweir {
853cdf0e10cSrcweir sal_uInt16 n = SVBT16ToShort( *(SVBT16*)p );
854cdf0e10cSrcweir p += 2;
855cdf0e10cSrcweir return n;
856cdf0e10cSrcweir }
857cdf0e10cSrcweir
Get_Short(sal_uInt8 * & p)858cdf0e10cSrcweir inline short Get_Short( sal_uInt8 *& p )
859cdf0e10cSrcweir {
860cdf0e10cSrcweir return Get_UShort(p);
861cdf0e10cSrcweir }
862cdf0e10cSrcweir
Get_ULong(sal_uInt8 * & p)863cdf0e10cSrcweir inline sal_uLong Get_ULong( sal_uInt8 *& p )
864cdf0e10cSrcweir {
865cdf0e10cSrcweir sal_uLong n = SVBT32ToUInt32( *(SVBT32*)p );
866cdf0e10cSrcweir p += 4;
867cdf0e10cSrcweir return n;
868cdf0e10cSrcweir }
869cdf0e10cSrcweir
Get_Long(sal_uInt8 * & p)870cdf0e10cSrcweir inline long Get_Long( sal_uInt8 *& p )
871cdf0e10cSrcweir {
872cdf0e10cSrcweir return Get_ULong(p);
873cdf0e10cSrcweir }
874cdf0e10cSrcweir
WW8SprmIter(const sal_uInt8 * pSprms_,long nLen_,const wwSprmParser & rParser)875cdf0e10cSrcweir WW8SprmIter::WW8SprmIter(const sal_uInt8* pSprms_, long nLen_,
876cdf0e10cSrcweir const wwSprmParser &rParser)
877cdf0e10cSrcweir : mrSprmParser(rParser), pSprms( pSprms_), nRemLen( nLen_)
878cdf0e10cSrcweir {
879cdf0e10cSrcweir UpdateMyMembers();
880cdf0e10cSrcweir }
881cdf0e10cSrcweir
SetSprms(const sal_uInt8 * pSprms_,long nLen_)882cdf0e10cSrcweir void WW8SprmIter::SetSprms(const sal_uInt8* pSprms_, long nLen_)
883cdf0e10cSrcweir {
884cdf0e10cSrcweir pSprms = pSprms_;
885cdf0e10cSrcweir nRemLen = nLen_;
886cdf0e10cSrcweir UpdateMyMembers();
887cdf0e10cSrcweir }
888cdf0e10cSrcweir
operator ++(int)889cdf0e10cSrcweir const sal_uInt8* WW8SprmIter::operator ++( int )
890cdf0e10cSrcweir {
891cdf0e10cSrcweir if (nRemLen > 0 )
892cdf0e10cSrcweir {
893cdf0e10cSrcweir if( nRemLen >= nAktSize )
894cdf0e10cSrcweir {
895cdf0e10cSrcweir pSprms += nAktSize;
896cdf0e10cSrcweir nRemLen -= nAktSize;
897cdf0e10cSrcweir UpdateMyMembers();
898cdf0e10cSrcweir }
899cdf0e10cSrcweir else
900cdf0e10cSrcweir {
901cdf0e10cSrcweir throw( ::std::exception() );
902cdf0e10cSrcweir }
903cdf0e10cSrcweir }
904cdf0e10cSrcweir return pSprms;
905cdf0e10cSrcweir }
906cdf0e10cSrcweir
UpdateMyMembers()907cdf0e10cSrcweir void WW8SprmIter::UpdateMyMembers()
908cdf0e10cSrcweir {
909cdf0e10cSrcweir if (pSprms && nRemLen > (mrSprmParser.getVersion()?1:0)) //see #125180#
910cdf0e10cSrcweir {
911cdf0e10cSrcweir nAktId = mrSprmParser.GetSprmId(pSprms);
912cdf0e10cSrcweir pAktParams = pSprms + mrSprmParser.DistanceToData(nAktId);
913cdf0e10cSrcweir nAktSize = mrSprmParser.GetSprmSize(nAktId, pSprms);
914cdf0e10cSrcweir }
915cdf0e10cSrcweir else
916cdf0e10cSrcweir {
917cdf0e10cSrcweir nAktId = 0;
918cdf0e10cSrcweir pAktParams = 0;
919cdf0e10cSrcweir nAktSize = 0;
920cdf0e10cSrcweir nRemLen = 0;
921cdf0e10cSrcweir }
922cdf0e10cSrcweir }
923cdf0e10cSrcweir
FindSprm(sal_uInt16 nId)924cdf0e10cSrcweir const sal_uInt8* WW8SprmIter::FindSprm(sal_uInt16 nId)
925cdf0e10cSrcweir {
926cdf0e10cSrcweir while(GetSprms())
927cdf0e10cSrcweir {
928cdf0e10cSrcweir if( GetAktId() == nId )
929cdf0e10cSrcweir return GetAktParams(); // SPRM found!
930cdf0e10cSrcweir operator ++(0);
931cdf0e10cSrcweir }
932cdf0e10cSrcweir
933cdf0e10cSrcweir return 0; // SPRM _not_ found
934cdf0e10cSrcweir }
935cdf0e10cSrcweir
9362726b7b2SOliver-Rainer Wittmann namespace {
IsPLCFPosArrayValid(const sal_Int32 * pPLCFPosArray,const sal_Int32 nMaxIndex)9372726b7b2SOliver-Rainer Wittmann bool IsPLCFPosArrayValid(
9382726b7b2SOliver-Rainer Wittmann const sal_Int32* pPLCFPosArray,
9392726b7b2SOliver-Rainer Wittmann const sal_Int32 nMaxIndex )
9402726b7b2SOliver-Rainer Wittmann {
9412726b7b2SOliver-Rainer Wittmann bool bIsValid = true;
9422726b7b2SOliver-Rainer Wittmann
9437447c561SOliver-Rainer Wittmann //WW8_CP nValue = 0;
9442726b7b2SOliver-Rainer Wittmann for ( sal_Int32 i = 0; i <= nMaxIndex; ++i )
9452726b7b2SOliver-Rainer Wittmann {
9467447c561SOliver-Rainer Wittmann if ( pPLCFPosArray[i] < 0
9471077d09aSOliver-Rainer Wittmann && !( i == nMaxIndex-1 && pPLCFPosArray[i] == -63488 ) // pPLCFPosArray[nMaxIndex-1]==-63488 (0xffff0800) seems to be allowed
9481077d09aSOliver-Rainer Wittmann && !( i == nMaxIndex-1 && pPLCFPosArray[i] == -65536 ) // pPLCFPosArray[nMaxIndex-1]==-65536 (0xffff0000) seems to be allowed
9491077d09aSOliver-Rainer Wittmann && !( i == nMaxIndex-1 && pPLCFPosArray[i] == -61440 ) ) // pPLCFPosArray[nMaxIndex-1]==-61440 (0xffff112c) seems to be allowed
9502726b7b2SOliver-Rainer Wittmann {
9512726b7b2SOliver-Rainer Wittmann bIsValid = false;
9522726b7b2SOliver-Rainer Wittmann break;
9532726b7b2SOliver-Rainer Wittmann }
9547447c561SOliver-Rainer Wittmann //nValue = pPLCFPosArray[i];
9552726b7b2SOliver-Rainer Wittmann }
9562726b7b2SOliver-Rainer Wittmann
9572726b7b2SOliver-Rainer Wittmann return bIsValid;
9582726b7b2SOliver-Rainer Wittmann }
9592726b7b2SOliver-Rainer Wittmann }
9602726b7b2SOliver-Rainer Wittmann
961cdf0e10cSrcweir //-----------------------------------------
962cdf0e10cSrcweir // temporaerer Test
963cdf0e10cSrcweir //-----------------------------------------
964cdf0e10cSrcweir // WW8PLCFx_PCDAttrs halten sich an WW8PLCF_Pcd fest und besitzen deshalb keine
965cdf0e10cSrcweir // eigenen Iteratoren. Alle sich auf Iteratoren beziehenden Methoden
966cdf0e10cSrcweir // sind deshalb Dummies.
967cdf0e10cSrcweir
WW8PLCFx_PCDAttrs(ww::WordVersion eVersion,WW8PLCFx_PCD * pPLCFx_PCD,const WW8ScannerBase * pBase)968cdf0e10cSrcweir WW8PLCFx_PCDAttrs::WW8PLCFx_PCDAttrs(ww::WordVersion eVersion,
969cdf0e10cSrcweir WW8PLCFx_PCD* pPLCFx_PCD, const WW8ScannerBase* pBase)
970cdf0e10cSrcweir : WW8PLCFx(eVersion, true), pPcdI(pPLCFx_PCD->GetPLCFIter()),
971cdf0e10cSrcweir pPcd(pPLCFx_PCD), pGrpprls(pBase->pPieceGrpprls),
972cdf0e10cSrcweir nGrpprls(pBase->nPieceGrpprls)
973cdf0e10cSrcweir {
974cdf0e10cSrcweir }
975cdf0e10cSrcweir
GetIdx() const976cdf0e10cSrcweir sal_uLong WW8PLCFx_PCDAttrs::GetIdx() const
977cdf0e10cSrcweir {
978cdf0e10cSrcweir return 0;
979cdf0e10cSrcweir }
980cdf0e10cSrcweir
SetIdx(sal_uLong)981cdf0e10cSrcweir void WW8PLCFx_PCDAttrs::SetIdx( sal_uLong )
982cdf0e10cSrcweir {
983cdf0e10cSrcweir }
984cdf0e10cSrcweir
SeekPos(WW8_CP)985cdf0e10cSrcweir bool WW8PLCFx_PCDAttrs::SeekPos(WW8_CP )
986cdf0e10cSrcweir {
987cdf0e10cSrcweir return true;
988cdf0e10cSrcweir }
989cdf0e10cSrcweir
operator ++(int)990cdf0e10cSrcweir WW8PLCFx& WW8PLCFx_PCDAttrs::operator ++( int )
991cdf0e10cSrcweir {
992cdf0e10cSrcweir return *this;
993cdf0e10cSrcweir }
994cdf0e10cSrcweir
Where()995cdf0e10cSrcweir WW8_CP WW8PLCFx_PCDAttrs::Where()
996cdf0e10cSrcweir {
997cdf0e10cSrcweir return ( pPcd ) ? pPcd->Where() : WW8_CP_MAX;
998cdf0e10cSrcweir }
999cdf0e10cSrcweir
GetSprms(WW8PLCFxDesc * p)1000cdf0e10cSrcweir void WW8PLCFx_PCDAttrs::GetSprms(WW8PLCFxDesc* p)
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir void* pData;
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir p->bRealLineEnd = false;
1005cdf0e10cSrcweir if ( !pPcdI || !pPcdI->Get(p->nStartPos, p->nEndPos, pData) )
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir // PLCF fully processed
1008cdf0e10cSrcweir p->nStartPos = p->nEndPos = WW8_CP_MAX;
1009cdf0e10cSrcweir p->pMemPos = 0;
1010cdf0e10cSrcweir p->nSprmsLen = 0;
1011cdf0e10cSrcweir return;
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir
1014cdf0e10cSrcweir sal_uInt16 nPrm = SVBT16ToShort( ( (WW8_PCD*)pData )->prm );
1015cdf0e10cSrcweir if ( nPrm & 1 )
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir // PRM Variant 2
1018cdf0e10cSrcweir sal_uInt16 nSprmIdx = nPrm >> 1;
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir if( nSprmIdx >= nGrpprls )
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir // Invalid Index
1023cdf0e10cSrcweir p->nStartPos = p->nEndPos = WW8_CP_MAX;
1024cdf0e10cSrcweir p->pMemPos = 0;
1025cdf0e10cSrcweir p->nSprmsLen = 0;
1026cdf0e10cSrcweir return;
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir const sal_uInt8* pSprms = pGrpprls[ nSprmIdx ];
1029cdf0e10cSrcweir
1030cdf0e10cSrcweir p->nSprmsLen = SVBT16ToShort( pSprms ); // Length
1031cdf0e10cSrcweir pSprms += 2;
1032cdf0e10cSrcweir p->pMemPos = pSprms; // Position
1033cdf0e10cSrcweir }
1034cdf0e10cSrcweir else
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir // PRM Variante 1: Sprm wird direkt in Member-Var abgelegt
1037cdf0e10cSrcweir /*
1038cdf0e10cSrcweir Dies sind die Attr, die in der Piece-Table stehen, statt im Text !
1039cdf0e10cSrcweir */
1040cdf0e10cSrcweir
1041cdf0e10cSrcweir if (IsSevenMinus(GetFIBVersion()))
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir aShortSprm[0] = (sal_uInt8)( ( nPrm & 0xfe) >> 1 );
1044cdf0e10cSrcweir aShortSprm[1] = (sal_uInt8)( nPrm >> 8 );
1045cdf0e10cSrcweir p->nSprmsLen = ( nPrm ) ? 2 : 0; // Laenge
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir // store Postion of internal mini storage in Data Pointer
1048cdf0e10cSrcweir p->pMemPos = aShortSprm;
1049cdf0e10cSrcweir }
1050cdf0e10cSrcweir else
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir p->pMemPos = 0;
1053cdf0e10cSrcweir p->nSprmsLen = 0;
1054cdf0e10cSrcweir sal_uInt8 nSprmListIdx = (sal_uInt8)((nPrm & 0xfe) >> 1);
1055cdf0e10cSrcweir if( nSprmListIdx )
1056cdf0e10cSrcweir {
1057cdf0e10cSrcweir // process Sprm Id Matching as explained in MS Doku
1058cdf0e10cSrcweir //
1059cdf0e10cSrcweir // ''Property Modifier(variant 1) (PRM)''
1060cdf0e10cSrcweir // see file: s62f39.htm
1061cdf0e10cSrcweir //
1062cdf0e10cSrcweir // Since isprm is 7 bits, rgsprmPrm can hold 0x80 entries.
1063cdf0e10cSrcweir static const sal_uInt16 aSprmId[0x80] =
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmNoop, sprmNoop
1066cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x0000,
1067cdf0e10cSrcweir // sprmPIncLvl, sprmPJc, sprmPFSideBySide, sprmPFKeep
1068cdf0e10cSrcweir 0x2402,0x2403,0x2404,0x2405,
1069cdf0e10cSrcweir // sprmPFKeepFollow, sprmPFPageBreakBefore, sprmPBrcl,
1070cdf0e10cSrcweir // sprmPBrcp
1071cdf0e10cSrcweir 0x2406,0x2407,0x2408,0x2409,
1072cdf0e10cSrcweir // sprmPIlvl, sprmNoop, sprmPFNoLineNumb, sprmNoop
1073cdf0e10cSrcweir 0x260A,0x0000,0x240C,0x0000,
1074cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmNoop, sprmNoop
1075cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x0000,
1076cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmNoop, sprmNoop
1077cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x0000,
1078cdf0e10cSrcweir // sprmPFInTable, sprmPFTtp, sprmNoop, sprmNoop
1079cdf0e10cSrcweir 0x2416,0x2417,0x0000,0x0000,
1080cdf0e10cSrcweir // sprmNoop, sprmPPc, sprmNoop, sprmNoop
1081cdf0e10cSrcweir 0x0000,0x261B,0x0000,0x0000,
1082cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmNoop, sprmNoop
1083cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x0000,
1084cdf0e10cSrcweir // sprmNoop, sprmPWr, sprmNoop, sprmNoop
1085cdf0e10cSrcweir 0x0000,0x2423,0x0000,0x0000,
1086cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmNoop, sprmNoop
1087cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x0000,
1088cdf0e10cSrcweir // sprmPFNoAutoHyph, sprmNoop, sprmNoop, sprmNoop
1089cdf0e10cSrcweir 0x242A,0x0000,0x0000,0x0000,
1090cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmPFLocked, sprmPFWidowControl
1091cdf0e10cSrcweir 0x0000,0x0000,0x2430,0x2431,
1092cdf0e10cSrcweir // sprmNoop, sprmPFKinsoku, sprmPFWordWrap,
1093cdf0e10cSrcweir // sprmPFOverflowPunct
1094cdf0e10cSrcweir 0x0000,0x2433,0x2434,0x2435,
1095cdf0e10cSrcweir // sprmPFTopLinePunct, sprmPFAutoSpaceDE,
1096cdf0e10cSrcweir // sprmPFAutoSpaceDN, sprmNoop
1097cdf0e10cSrcweir 0x2436,0x2437,0x2438,0x0000,
1098cdf0e10cSrcweir // sprmNoop, sprmPISnapBaseLine, sprmNoop, sprmNoop
1099cdf0e10cSrcweir 0x0000,0x243B,0x000,0x0000,
1100cdf0e10cSrcweir // sprmNoop, sprmCFStrikeRM, sprmCFRMark, sprmCFFldVanish
1101cdf0e10cSrcweir 0x0000,0x0800,0x0801,0x0802,
1102cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmNoop, sprmCFData
1103cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x0806,
1104cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmNoop, sprmCFOle2
1105cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x080A,
1106cdf0e10cSrcweir // sprmNoop, sprmCHighlight, sprmCFEmboss, sprmCSfxText
1107cdf0e10cSrcweir 0x0000,0x2A0C,0x0858,0x2859,
1108cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmNoop, sprmCPlain
1109cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x2A33,
1110cdf0e10cSrcweir // sprmNoop, sprmCFBold, sprmCFItalic, sprmCFStrike
1111cdf0e10cSrcweir 0x0000,0x0835,0x0836,0x0837,
1112cdf0e10cSrcweir // sprmCFOutline, sprmCFShadow, sprmCFSmallCaps, sprmCFCaps,
1113cdf0e10cSrcweir 0x0838,0x0839,0x083a,0x083b,
1114cdf0e10cSrcweir // sprmCFVanish, sprmNoop, sprmCKul, sprmNoop,
1115cdf0e10cSrcweir 0x083C,0x0000,0x2A3E,0x0000,
1116cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmCIco, sprmNoop,
1117cdf0e10cSrcweir 0x0000,0x0000,0x2A42,0x0000,
1118cdf0e10cSrcweir // sprmCHpsInc, sprmNoop, sprmCHpsPosAdj, sprmNoop,
1119cdf0e10cSrcweir 0x2A44,0x0000,0x2A46,0x0000,
1120cdf0e10cSrcweir // sprmCIss, sprmNoop, sprmNoop, sprmNoop,
1121cdf0e10cSrcweir 0x2A48,0x0000,0x0000,0x0000,
1122cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmNoop, sprmNoop,
1123cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x0000,
1124cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmNoop, sprmCFDStrike,
1125cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x2A53,
1126cdf0e10cSrcweir // sprmCFImprint, sprmCFSpec, sprmCFObj, sprmPicBrcl,
1127cdf0e10cSrcweir 0x0854,0x0855,0x0856,0x2E00,
1128cdf0e10cSrcweir // sprmPOutLvl, sprmPFBiDi, sprmNoop, sprmNoop,
1129cdf0e10cSrcweir 0x2640,0x2441,0x0000,0x0000,
1130cdf0e10cSrcweir // sprmNoop, sprmNoop, sprmPPnbrRMarkNot
1131cdf0e10cSrcweir 0x0000,0x0000,0x0000,0x0000
1132cdf0e10cSrcweir };
1133cdf0e10cSrcweir
1134cdf0e10cSrcweir // find real Sprm Id:
1135cdf0e10cSrcweir sal_uInt16 nSprmId = aSprmId[ nSprmListIdx ];
1136cdf0e10cSrcweir
1137cdf0e10cSrcweir if( nSprmId )
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir // move Sprm Id and Sprm Param to internal mini storage:
1140cdf0e10cSrcweir aShortSprm[0] = (sal_uInt8)( ( nSprmId & 0x00ff) );
1141cdf0e10cSrcweir aShortSprm[1] = (sal_uInt8)( ( nSprmId & 0xff00) >> 8 );
1142cdf0e10cSrcweir aShortSprm[2] = (sal_uInt8)( nPrm >> 8 );
1143cdf0e10cSrcweir
1144cdf0e10cSrcweir // store Sprm Length in member:
1145cdf0e10cSrcweir p->nSprmsLen = ( nPrm ) ? 3 : 0;
1146cdf0e10cSrcweir
1147cdf0e10cSrcweir // store Postion of internal mini storage in Data Pointer
1148cdf0e10cSrcweir p->pMemPos = aShortSprm;
1149cdf0e10cSrcweir }
1150cdf0e10cSrcweir }
1151cdf0e10cSrcweir }
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir }
1154cdf0e10cSrcweir
1155cdf0e10cSrcweir //------------------------------------------------------------------------
1156cdf0e10cSrcweir
WW8PLCFx_PCD(ww::WordVersion eVersion,WW8PLCFpcd * pPLCFpcd,WW8_CP nStartCp,bool bVer67P)1157cdf0e10cSrcweir WW8PLCFx_PCD::WW8PLCFx_PCD(ww::WordVersion eVersion, WW8PLCFpcd* pPLCFpcd,
1158cdf0e10cSrcweir WW8_CP nStartCp, bool bVer67P)
1159cdf0e10cSrcweir : WW8PLCFx(eVersion, false), nClipStart(-1)
1160cdf0e10cSrcweir {
1161cdf0e10cSrcweir // eigenen Iterator konstruieren
1162cdf0e10cSrcweir pPcdI = new WW8PLCFpcd_Iter(*pPLCFpcd, nStartCp);
1163cdf0e10cSrcweir bVer67= bVer67P;
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir
~WW8PLCFx_PCD()1166cdf0e10cSrcweir WW8PLCFx_PCD::~WW8PLCFx_PCD()
1167cdf0e10cSrcweir {
1168cdf0e10cSrcweir // pPcd-Dtor which in called from WW8ScannerBase
1169cdf0e10cSrcweir delete pPcdI;
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir
GetIMax() const1172cdf0e10cSrcweir sal_uLong WW8PLCFx_PCD::GetIMax() const
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir return pPcdI ? pPcdI->GetIMax() : 0;
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir
GetIdx() const1177cdf0e10cSrcweir sal_uLong WW8PLCFx_PCD::GetIdx() const
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir return pPcdI ? pPcdI->GetIdx() : 0;
1180cdf0e10cSrcweir }
1181cdf0e10cSrcweir
SetIdx(sal_uLong nIdx)1182cdf0e10cSrcweir void WW8PLCFx_PCD::SetIdx( sal_uLong nIdx )
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir if (pPcdI)
1185cdf0e10cSrcweir pPcdI->SetIdx( nIdx );
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir
SeekPos(WW8_CP nCpPos)1188cdf0e10cSrcweir bool WW8PLCFx_PCD::SeekPos(WW8_CP nCpPos)
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir return pPcdI ? pPcdI->SeekPos( nCpPos ) : false;
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir
Where()1193cdf0e10cSrcweir WW8_CP WW8PLCFx_PCD::Where()
1194cdf0e10cSrcweir {
1195cdf0e10cSrcweir return pPcdI ? pPcdI->Where() : WW8_CP_MAX;
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir
GetNoSprms(WW8_CP & rStart,WW8_CP & rEnd,sal_Int32 & rLen)1198cdf0e10cSrcweir long WW8PLCFx_PCD::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32& rLen )
1199cdf0e10cSrcweir {
1200cdf0e10cSrcweir void* pData;
1201cdf0e10cSrcweir rLen = 0;
1202cdf0e10cSrcweir
1203cdf0e10cSrcweir if ( !pPcdI || !pPcdI->Get(rStart, rEnd, pData) )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir rStart = rEnd = WW8_CP_MAX;
1206cdf0e10cSrcweir return -1;
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir return pPcdI->GetIdx();
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir
operator ++(int)1211cdf0e10cSrcweir WW8PLCFx& WW8PLCFx_PCD::operator ++( int )
1212cdf0e10cSrcweir {
1213cdf0e10cSrcweir if (pPcdI)
1214cdf0e10cSrcweir (*pPcdI)++;
1215cdf0e10cSrcweir else {
1216cdf0e10cSrcweir ASSERT( !this, "pPcdI fehlt");
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir return *this;
1219cdf0e10cSrcweir }
1220cdf0e10cSrcweir
AktPieceStartCp2Fc(WW8_CP nCp)1221cdf0e10cSrcweir WW8_FC WW8PLCFx_PCD::AktPieceStartCp2Fc( WW8_CP nCp )
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir WW8_CP nCpStart, nCpEnd;
1224cdf0e10cSrcweir void* pData;
1225cdf0e10cSrcweir
1226cdf0e10cSrcweir if ( !pPcdI->Get(nCpStart, nCpEnd, pData) )
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir ASSERT( !this, "AktPieceStartCp2Fc() with false Cp found (1)" );
1229cdf0e10cSrcweir return WW8_FC_MAX;
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir ASSERT( nCp >= nCpStart && nCp < nCpEnd,
1233cdf0e10cSrcweir "AktPieceCp2Fc() with false Cp found (2)" );
1234cdf0e10cSrcweir
1235cdf0e10cSrcweir if( nCp < nCpStart )
1236cdf0e10cSrcweir nCp = nCpStart;
1237cdf0e10cSrcweir if( nCp >= nCpEnd )
1238cdf0e10cSrcweir nCp = nCpEnd - 1;
1239cdf0e10cSrcweir
1240cdf0e10cSrcweir bool bIsUnicode = false;
1241cdf0e10cSrcweir WW8_FC nFC = SVBT32ToUInt32( ((WW8_PCD*)pData)->fc );
1242cdf0e10cSrcweir if( !bVer67 )
1243cdf0e10cSrcweir nFC = WW8PLCFx_PCD::TransformPieceAddress( nFC, bIsUnicode );
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir return nFC + (nCp - nCpStart) * (bIsUnicode ? 2 : 1);
1246cdf0e10cSrcweir }
1247cdf0e10cSrcweir
1248cdf0e10cSrcweir
AktPieceFc2Cp(WW8_CP & rStartPos,WW8_CP & rEndPos,const WW8ScannerBase * pSBase)1249cdf0e10cSrcweir void WW8PLCFx_PCD::AktPieceFc2Cp( WW8_CP& rStartPos, WW8_CP& rEndPos,
1250cdf0e10cSrcweir const WW8ScannerBase *pSBase )
1251cdf0e10cSrcweir {
1252cdf0e10cSrcweir //No point going anywhere with this
1253cdf0e10cSrcweir if ((rStartPos == WW8_CP_MAX) && (rEndPos == WW8_CP_MAX))
1254cdf0e10cSrcweir return;
1255cdf0e10cSrcweir
1256cdf0e10cSrcweir rStartPos = pSBase->WW8Fc2Cp( rStartPos );
1257cdf0e10cSrcweir rEndPos = pSBase->WW8Fc2Cp( rEndPos );
1258cdf0e10cSrcweir }
1259cdf0e10cSrcweir
AktPieceStartFc2Cp(WW8_FC nStartPos)1260cdf0e10cSrcweir WW8_CP WW8PLCFx_PCD::AktPieceStartFc2Cp( WW8_FC nStartPos )
1261cdf0e10cSrcweir {
1262cdf0e10cSrcweir WW8_CP nCpStart, nCpEnd;
1263cdf0e10cSrcweir void* pData;
1264cdf0e10cSrcweir if ( !pPcdI->Get( nCpStart, nCpEnd, pData ) )
1265cdf0e10cSrcweir {
1266cdf0e10cSrcweir ASSERT( !this, "AktPieceStartFc2Cp() - Fehler" );
1267cdf0e10cSrcweir return WW8_CP_MAX;
1268cdf0e10cSrcweir }
1269cdf0e10cSrcweir bool bIsUnicode = false;
1270cdf0e10cSrcweir sal_Int32 nFcStart = SVBT32ToUInt32( ((WW8_PCD*)pData)->fc );
1271cdf0e10cSrcweir if( !bVer67 )
1272cdf0e10cSrcweir nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart, bIsUnicode );
1273cdf0e10cSrcweir
1274cdf0e10cSrcweir sal_Int32 nUnicodeFactor = bIsUnicode ? 2 : 1;
1275cdf0e10cSrcweir
1276cdf0e10cSrcweir if( nStartPos < nFcStart )
1277cdf0e10cSrcweir nStartPos = nFcStart;
1278cdf0e10cSrcweir
1279cdf0e10cSrcweir if( nStartPos >= nFcStart + (nCpEnd - nCpStart) * nUnicodeFactor )
1280cdf0e10cSrcweir nStartPos = nFcStart + (nCpEnd - nCpStart - 1) * nUnicodeFactor;
1281cdf0e10cSrcweir
1282cdf0e10cSrcweir return nCpStart + (nStartPos - nFcStart) / nUnicodeFactor;
1283cdf0e10cSrcweir }
1284cdf0e10cSrcweir
1285cdf0e10cSrcweir //-----------------------------------------
1286cdf0e10cSrcweir // Hilfsroutinen fuer alle
1287cdf0e10cSrcweir //-----------------------------------------
1288cdf0e10cSrcweir
DetermineBorderProperties(bool bVer67,short * pSpace,sal_uInt8 * pCol,short * pIdx) const1289cdf0e10cSrcweir short WW8_BRC::DetermineBorderProperties(bool bVer67, short *pSpace,
1290cdf0e10cSrcweir sal_uInt8 *pCol, short *pIdx) const
1291cdf0e10cSrcweir {
1292cdf0e10cSrcweir /*
1293cdf0e10cSrcweir Word does not factor the width of the border into the width/height
1294cdf0e10cSrcweir stored in the information for graphic/table/object widths, so we need
1295cdf0e10cSrcweir to figure out this extra width here and utilize the returned size in
1296cdf0e10cSrcweir our calculations
1297cdf0e10cSrcweir */
1298cdf0e10cSrcweir short nMSTotalWidth;
1299cdf0e10cSrcweir sal_uInt8 nCol;
1300cdf0e10cSrcweir short nIdx,nSpace;
1301cdf0e10cSrcweir if( bVer67 )
1302cdf0e10cSrcweir {
1303cdf0e10cSrcweir sal_uInt16 aBrc1 = SVBT16ToShort(aBits1);
1304cdf0e10cSrcweir nCol = static_cast< sal_uInt8 >((aBrc1 >> 6) & 0x1f); // aBor.ico
1305cdf0e10cSrcweir nSpace = (aBrc1 & 0xF800) >> 11;
1306cdf0e10cSrcweir
1307cdf0e10cSrcweir nMSTotalWidth = aBrc1 & 0x07;
1308cdf0e10cSrcweir nIdx = (aBrc1 & 0x18) >> 3;
1309cdf0e10cSrcweir //Dashed/Dotted unsets double/thick
1310cdf0e10cSrcweir if (nMSTotalWidth > 5)
1311cdf0e10cSrcweir {
1312cdf0e10cSrcweir nMSTotalWidth=1;
1313cdf0e10cSrcweir nIdx = 1;
1314cdf0e10cSrcweir }
1315cdf0e10cSrcweir nMSTotalWidth = nMSTotalWidth * nIdx * 15;
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir else
1318cdf0e10cSrcweir {
1319cdf0e10cSrcweir nIdx = aBits1[1];
1320cdf0e10cSrcweir nCol = aBits2[0]; // aBor.ico
1321cdf0e10cSrcweir nSpace = aBits2[1] & 0x1F; //space between line and object
1322cdf0e10cSrcweir
1323cdf0e10cSrcweir //Specification in 8ths of a point, 1 Point = 20 Twips, so by 2.5
1324cdf0e10cSrcweir nMSTotalWidth = aBits1[ 0 ] * 20 / 8;
1325cdf0e10cSrcweir
1326cdf0e10cSrcweir //Figure out the real size of the border according to word
1327cdf0e10cSrcweir switch (nIdx)
1328cdf0e10cSrcweir {
1329cdf0e10cSrcweir //Note that codes over 25 are undocumented, and I can't create
1330cdf0e10cSrcweir //these 4 here in the wild.
1331cdf0e10cSrcweir default:
1332cdf0e10cSrcweir case 2:
1333cdf0e10cSrcweir case 4:
1334cdf0e10cSrcweir case 5:
1335cdf0e10cSrcweir case 22:
1336cdf0e10cSrcweir DBG_WARNING("Can't create these from the menus, please report");
1337cdf0e10cSrcweir case 1:
1338cdf0e10cSrcweir case 6:
1339cdf0e10cSrcweir case 7:
1340cdf0e10cSrcweir case 8:
1341cdf0e10cSrcweir case 9:
1342cdf0e10cSrcweir case 23: //Only 3pt in the menus, but honours the size setting.
1343cdf0e10cSrcweir break;
1344cdf0e10cSrcweir case 3:
1345cdf0e10cSrcweir /*
1346cdf0e10cSrcweir double line is three times the width of an ordinary line,
1347cdf0e10cSrcweir except for the smallest 1/4 point size which appears to have
1348cdf0e10cSrcweir exactly the same total border width as a 1/2 point size
1349cdf0e10cSrcweir ordinary line, i.e. twice the nominal line width
1350cdf0e10cSrcweir */
1351cdf0e10cSrcweir nMSTotalWidth = (nMSTotalWidth == 5) ?
1352cdf0e10cSrcweir nMSTotalWidth*2 : nMSTotalWidth*3;
1353cdf0e10cSrcweir break;
1354cdf0e10cSrcweir case 10:
1355cdf0e10cSrcweir /*
1356cdf0e10cSrcweir triple line is five times the width of an ordinary line,
1357cdf0e10cSrcweir except that the smallest 1/4 point size appears to have
1358cdf0e10cSrcweir exactly the same total border width as a 3/4 point size
1359cdf0e10cSrcweir ordinary line, i.e. three times the nominal line width. The
1360cdf0e10cSrcweir second smallest 1/2 point size appears to have exactly the
1361cdf0e10cSrcweir total border width as a 2 1/4 border, i.e 4.5 times the size.
1362cdf0e10cSrcweir */
1363cdf0e10cSrcweir if (nMSTotalWidth == 5)
1364cdf0e10cSrcweir nMSTotalWidth*=3;
1365cdf0e10cSrcweir else if (nMSTotalWidth == 10)
1366cdf0e10cSrcweir nMSTotalWidth = nMSTotalWidth*9/2;
1367cdf0e10cSrcweir else
1368cdf0e10cSrcweir nMSTotalWidth*=5;
1369cdf0e10cSrcweir break;
1370cdf0e10cSrcweir case 11:
1371cdf0e10cSrcweir case 12:
1372cdf0e10cSrcweir /*
1373cdf0e10cSrcweir small gap thin thick and thick thin appears to have a 3/4
1374cdf0e10cSrcweir point line, a 3/4 point gap and a thick line of the specified
1375cdf0e10cSrcweir width
1376cdf0e10cSrcweir */
1377cdf0e10cSrcweir nMSTotalWidth = nMSTotalWidth + 15*2;
1378cdf0e10cSrcweir break;
1379cdf0e10cSrcweir case 13:
1380cdf0e10cSrcweir /*
1381cdf0e10cSrcweir thin thick thin appears to have two outside 3/4 point lines,
1382cdf0e10cSrcweir two 3/4 point gaps and a thick line of the specified width
1383cdf0e10cSrcweir */
1384cdf0e10cSrcweir nMSTotalWidth = nMSTotalWidth + 15*4;
1385cdf0e10cSrcweir break;
1386cdf0e10cSrcweir case 14:
1387cdf0e10cSrcweir case 15:
1388cdf0e10cSrcweir /*
1389cdf0e10cSrcweir medium gap thin thick and thick thin appears to have a line
1390cdf0e10cSrcweir 50% of the thick line, and an equal sized gap and then the
1391cdf0e10cSrcweir thick line of the specified width. But it appears to only
1392cdf0e10cSrcweir use one of the existing predefined widths for the thin line,
1393cdf0e10cSrcweir so the closest smallest existing border to the halved thick
1394cdf0e10cSrcweir line is used.
1395cdf0e10cSrcweir */
1396cdf0e10cSrcweir switch (nMSTotalWidth)
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir case 45: //2 1/4, closest to half is 1
1399cdf0e10cSrcweir nMSTotalWidth += 20 + (nMSTotalWidth-1)/2;
1400cdf0e10cSrcweir break;
1401cdf0e10cSrcweir case 5:
1402cdf0e10cSrcweir case 10:
1403cdf0e10cSrcweir nMSTotalWidth += 5;
1404cdf0e10cSrcweir break;
1405cdf0e10cSrcweir case 15: //3/4, closest to half is 1/4
1406cdf0e10cSrcweir nMSTotalWidth += 5 + (nMSTotalWidth-1)/2;
1407cdf0e10cSrcweir break;
1408cdf0e10cSrcweir default:
1409cdf0e10cSrcweir nMSTotalWidth*=2;
1410cdf0e10cSrcweir break;
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir break;
1413cdf0e10cSrcweir case 16:
1414cdf0e10cSrcweir /*
1415cdf0e10cSrcweir medium gap thin thick thin appears to have a line
1416cdf0e10cSrcweir 50% of the thick line, and an equal sized gap and then the
1417cdf0e10cSrcweir thick line of the specified width. But it appears to only
1418cdf0e10cSrcweir use one of the existing predefined widths for the thin
1419cdf0e10cSrcweir line, so the closest smallest existing border to the halved
1420cdf0e10cSrcweir thick line is used. Though some fudging at smaller sizes is
1421cdf0e10cSrcweir still required.
1422cdf0e10cSrcweir */
1423cdf0e10cSrcweir switch (nMSTotalWidth)
1424cdf0e10cSrcweir {
1425cdf0e10cSrcweir case 45: //2 1/4, closest to half is 1
1426cdf0e10cSrcweir nMSTotalWidth += nMSTotalWidth + 20 * 2;
1427cdf0e10cSrcweir break;
1428cdf0e10cSrcweir case 20:
1429cdf0e10cSrcweir case 15:
1430cdf0e10cSrcweir nMSTotalWidth += nMSTotalWidth + 7 * 2;
1431cdf0e10cSrcweir break;
1432cdf0e10cSrcweir case 10:
1433cdf0e10cSrcweir case 5:
1434cdf0e10cSrcweir nMSTotalWidth += 5 + 4;
1435cdf0e10cSrcweir break;
1436cdf0e10cSrcweir default:
1437cdf0e10cSrcweir nMSTotalWidth*=3;
1438cdf0e10cSrcweir break;
1439cdf0e10cSrcweir }
1440cdf0e10cSrcweir break;
1441cdf0e10cSrcweir case 17:
1442cdf0e10cSrcweir case 18:
1443cdf0e10cSrcweir /*
1444cdf0e10cSrcweir large gap thin thick and thick thin appears to have a thick
1445cdf0e10cSrcweir line of 1 1/2 pt and a narrow of 3/4 point, with a distance
1446cdf0e10cSrcweir between the two of the explicitly set line width
1447cdf0e10cSrcweir */
1448cdf0e10cSrcweir nMSTotalWidth+=15+30;
1449cdf0e10cSrcweir break;
1450cdf0e10cSrcweir case 19:
1451cdf0e10cSrcweir /*
1452cdf0e10cSrcweir large gap thin thick thin appears to have a thick line of 1
1453cdf0e10cSrcweir 1/2 pt and two narrows of 3/4 point, with a distance between
1454cdf0e10cSrcweir the two of the explicitly set line width, though the narrowest
1455cdf0e10cSrcweir line appears to behave as if it was even smaller
1456cdf0e10cSrcweir */
1457cdf0e10cSrcweir if (nMSTotalWidth == 5)
1458cdf0e10cSrcweir nMSTotalWidth = 3;
1459cdf0e10cSrcweir nMSTotalWidth = nMSTotalWidth*2 + 15*2 + 30;
1460cdf0e10cSrcweir break;
1461cdf0e10cSrcweir case 20:
1462cdf0e10cSrcweir /*
1463cdf0e10cSrcweir wave, the dimensions appear to be created by the drawing of
1464cdf0e10cSrcweir the wave, so we have only two possibilites in the menus, 3/4
1465cdf0e10cSrcweir point is equal to solid 3 point. This calculation seems to
1466cdf0e10cSrcweir match well to results.
1467cdf0e10cSrcweir */
1468cdf0e10cSrcweir nMSTotalWidth +=45;
1469cdf0e10cSrcweir break;
1470cdf0e10cSrcweir case 21:
1471cdf0e10cSrcweir /*
1472cdf0e10cSrcweir double wave, the dimensions appear to be created by the
1473cdf0e10cSrcweir drawing of the wave, so we have only one possibilites in the
1474cdf0e10cSrcweir menus, that of 3/4 point is equal to solid 3 point. This
1475cdf0e10cSrcweir calculation seems to match well to results.
1476cdf0e10cSrcweir */
1477cdf0e10cSrcweir nMSTotalWidth += 45*2;
1478cdf0e10cSrcweir break;
1479cdf0e10cSrcweir case 24:
1480cdf0e10cSrcweir case 25:
1481cdf0e10cSrcweir /*
1482cdf0e10cSrcweir emboss and engrave consist of a three lines, the central is of
1483cdf0e10cSrcweir the explicit point width, the other two (of equal size to each
1484cdf0e10cSrcweir other are the shadows and are either 3/4 pt of 1 1/2 depending
1485cdf0e10cSrcweir on if the central line is greater of less than 2 1/4 pt
1486cdf0e10cSrcweir */
1487cdf0e10cSrcweir if (nMSTotalWidth <= 45)
1488cdf0e10cSrcweir nMSTotalWidth += 2*15;
1489cdf0e10cSrcweir else
1490cdf0e10cSrcweir nMSTotalWidth += 2*30;
1491cdf0e10cSrcweir break;
1492cdf0e10cSrcweir }
1493cdf0e10cSrcweir }
1494cdf0e10cSrcweir
1495cdf0e10cSrcweir if (pIdx)
1496cdf0e10cSrcweir *pIdx = nIdx;
1497cdf0e10cSrcweir if (pSpace)
1498cdf0e10cSrcweir *pSpace = nSpace*20;
1499cdf0e10cSrcweir if (pCol)
1500cdf0e10cSrcweir *pCol = nCol;
1501cdf0e10cSrcweir return nMSTotalWidth;
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir
WW8Fc2Cp(WW8_FC nFcPos) const1504cdf0e10cSrcweir WW8_CP WW8ScannerBase::WW8Fc2Cp( WW8_FC nFcPos ) const
1505cdf0e10cSrcweir {
1506cdf0e10cSrcweir WW8_CP nFallBackCpEnd = WW8_CP_MAX;
1507cdf0e10cSrcweir if( nFcPos == WW8_FC_MAX )
1508cdf0e10cSrcweir return nFallBackCpEnd;
1509cdf0e10cSrcweir
1510cdf0e10cSrcweir bool bIsUnicode = false;
1511cdf0e10cSrcweir if( pPieceIter ) // Complex File ?
1512cdf0e10cSrcweir {
1513cdf0e10cSrcweir sal_uLong nOldPos = pPieceIter->GetIdx();
1514cdf0e10cSrcweir
1515cdf0e10cSrcweir for (pPieceIter->SetIdx(0);
1516cdf0e10cSrcweir pPieceIter->GetIdx() < pPieceIter->GetIMax();(*pPieceIter)++)
1517cdf0e10cSrcweir {
1518cdf0e10cSrcweir WW8_CP nCpStart, nCpEnd;
1519cdf0e10cSrcweir void* pData;
1520cdf0e10cSrcweir if( !pPieceIter->Get( nCpStart, nCpEnd, pData ) )
1521cdf0e10cSrcweir { // ausserhalb PLCFfpcd ?
1522cdf0e10cSrcweir ASSERT( !this, "PLCFpcd-WW8Fc2Cp() ging schief" );
1523cdf0e10cSrcweir break;
1524cdf0e10cSrcweir }
1525cdf0e10cSrcweir sal_Int32 nFcStart = SVBT32ToUInt32( ((WW8_PCD*)pData)->fc );
1526cdf0e10cSrcweir if( 8 <= pWw8Fib->nVersion )
1527cdf0e10cSrcweir {
1528cdf0e10cSrcweir nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart,
1529cdf0e10cSrcweir bIsUnicode );
1530cdf0e10cSrcweir }
1531cdf0e10cSrcweir else
1532cdf0e10cSrcweir {
1533cdf0e10cSrcweir if (pWw8Fib->fExtChar)
1534cdf0e10cSrcweir bIsUnicode=true;
1535cdf0e10cSrcweir }
1536cdf0e10cSrcweir sal_Int32 nLen = (nCpEnd - nCpStart) * (bIsUnicode ? 2 : 1);
1537cdf0e10cSrcweir
1538cdf0e10cSrcweir /*
1539cdf0e10cSrcweir If this cp is inside this piece, or its the last piece and we are
1540cdf0e10cSrcweir on the very last cp of that piece
1541cdf0e10cSrcweir */
1542cdf0e10cSrcweir if (nFcPos >= nFcStart)
1543cdf0e10cSrcweir {
1544cdf0e10cSrcweir // found
1545cdf0e10cSrcweir WW8_CP nTempCp =
1546cdf0e10cSrcweir nCpStart + ((nFcPos - nFcStart) / (bIsUnicode ? 2 : 1));
1547cdf0e10cSrcweir if (nFcPos < nFcStart + nLen)
1548cdf0e10cSrcweir {
1549cdf0e10cSrcweir pPieceIter->SetIdx( nOldPos );
1550cdf0e10cSrcweir return nTempCp;
1551cdf0e10cSrcweir }
1552cdf0e10cSrcweir else if (nFcPos == nFcStart + nLen)
1553cdf0e10cSrcweir {
1554cdf0e10cSrcweir //Keep this cp as its on a piece boundary because we might
1555cdf0e10cSrcweir //need it if tests fail
1556cdf0e10cSrcweir nFallBackCpEnd = nTempCp;
1557cdf0e10cSrcweir }
1558cdf0e10cSrcweir }
1559cdf0e10cSrcweir }
1560cdf0e10cSrcweir // not found
1561cdf0e10cSrcweir pPieceIter->SetIdx( nOldPos ); // not found
1562cdf0e10cSrcweir /*
1563cdf0e10cSrcweir If it was not found, then this is because it has fallen between two
1564cdf0e10cSrcweir stools, i.e. either it is the last cp/fc of the last piece, or it is
1565cdf0e10cSrcweir the last cp/fc of a disjoint piece.
1566cdf0e10cSrcweir */
1567cdf0e10cSrcweir return nFallBackCpEnd;
1568cdf0e10cSrcweir }
1569cdf0e10cSrcweir // No complex file
1570cdf0e10cSrcweir if (pWw8Fib->fExtChar)
1571cdf0e10cSrcweir bIsUnicode=true;
1572cdf0e10cSrcweir return ((nFcPos - pWw8Fib->fcMin) / (bIsUnicode ? 2 : 1));
1573cdf0e10cSrcweir }
1574cdf0e10cSrcweir
WW8Cp2Fc(WW8_CP nCpPos,bool * pIsUnicode,WW8_CP * pNextPieceCp,bool * pTestFlag) const1575cdf0e10cSrcweir WW8_FC WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode,
1576cdf0e10cSrcweir WW8_CP* pNextPieceCp, bool* pTestFlag) const
1577cdf0e10cSrcweir {
1578cdf0e10cSrcweir if( pTestFlag )
1579cdf0e10cSrcweir *pTestFlag = true;
1580cdf0e10cSrcweir if( WW8_CP_MAX == nCpPos )
1581cdf0e10cSrcweir return WW8_CP_MAX;
1582cdf0e10cSrcweir
1583cdf0e10cSrcweir bool bIsUnicode;
1584cdf0e10cSrcweir if( !pIsUnicode )
1585cdf0e10cSrcweir pIsUnicode = &bIsUnicode;
1586cdf0e10cSrcweir
1587cdf0e10cSrcweir if( pPieceIter )
1588cdf0e10cSrcweir { // Complex File
1589cdf0e10cSrcweir if( pNextPieceCp )
1590cdf0e10cSrcweir *pNextPieceCp = WW8_CP_MAX;
1591cdf0e10cSrcweir
1592cdf0e10cSrcweir if( !pPieceIter->SeekPos( nCpPos ) )
1593cdf0e10cSrcweir {
1594cdf0e10cSrcweir if( pTestFlag )
1595cdf0e10cSrcweir *pTestFlag = false;
1596cdf0e10cSrcweir else {
1597cdf0e10cSrcweir ASSERT( !this, "Falscher CP an WW8Cp2Fc() uebergeben" );
1598cdf0e10cSrcweir }
1599cdf0e10cSrcweir return WW8_FC_MAX;
1600cdf0e10cSrcweir }
1601cdf0e10cSrcweir WW8_CP nCpStart, nCpEnd;
1602cdf0e10cSrcweir void* pData;
1603cdf0e10cSrcweir if( !pPieceIter->Get( nCpStart, nCpEnd, pData ) )
1604cdf0e10cSrcweir {
1605cdf0e10cSrcweir if( pTestFlag )
1606cdf0e10cSrcweir *pTestFlag = false;
1607cdf0e10cSrcweir else {
1608cdf0e10cSrcweir ASSERT( !this, "PLCFfpcd-Get ging schief" );
1609cdf0e10cSrcweir }
1610cdf0e10cSrcweir return WW8_FC_MAX;
1611cdf0e10cSrcweir }
1612cdf0e10cSrcweir if( pNextPieceCp )
1613cdf0e10cSrcweir *pNextPieceCp = nCpEnd;
1614cdf0e10cSrcweir
1615cdf0e10cSrcweir WW8_FC nRet = SVBT32ToUInt32( ((WW8_PCD*)pData)->fc );
1616cdf0e10cSrcweir if (8 > pWw8Fib->nVersion)
1617cdf0e10cSrcweir if (pWw8Fib->fExtChar)
1618cdf0e10cSrcweir *pIsUnicode=true;
1619cdf0e10cSrcweir else
1620cdf0e10cSrcweir *pIsUnicode = false;
1621cdf0e10cSrcweir else
1622cdf0e10cSrcweir nRet = WW8PLCFx_PCD::TransformPieceAddress( nRet, *pIsUnicode );
1623cdf0e10cSrcweir
1624cdf0e10cSrcweir
1625cdf0e10cSrcweir nRet += (nCpPos - nCpStart) * (*pIsUnicode ? 2 : 1);
1626cdf0e10cSrcweir
1627cdf0e10cSrcweir return nRet;
1628cdf0e10cSrcweir }
1629cdf0e10cSrcweir
1630cdf0e10cSrcweir // No complex file
1631cdf0e10cSrcweir if (pWw8Fib->fExtChar)
1632cdf0e10cSrcweir *pIsUnicode = true;
1633cdf0e10cSrcweir else
1634cdf0e10cSrcweir *pIsUnicode = false;
1635cdf0e10cSrcweir return pWw8Fib->fcMin + nCpPos * (*pIsUnicode ? 2 : 1);
1636cdf0e10cSrcweir }
1637cdf0e10cSrcweir
1638cdf0e10cSrcweir //-----------------------------------------
1639cdf0e10cSrcweir // class WW8ScannerBase
1640cdf0e10cSrcweir //-----------------------------------------
1641cdf0e10cSrcweir
OpenPieceTable(SvStream * pStr,const WW8Fib * pWwF)1642cdf0e10cSrcweir WW8PLCFpcd* WW8ScannerBase::OpenPieceTable( SvStream* pStr, const WW8Fib* pWwF )
1643cdf0e10cSrcweir {
1644cdf0e10cSrcweir if ( ((8 > pWw8Fib->nVersion) && !pWwF->fComplex) || !pWwF->lcbClx )
1645cdf0e10cSrcweir return 0;
1646cdf0e10cSrcweir
1647cdf0e10cSrcweir WW8_FC nClxPos = pWwF->fcClx;
1648cdf0e10cSrcweir sal_Int32 nClxLen = pWwF->lcbClx;
1649cdf0e10cSrcweir sal_Int32 nLeft = nClxLen;
1650cdf0e10cSrcweir sal_Int16 nGrpprl = 0;
1651cdf0e10cSrcweir sal_uInt8 clxt;
1652cdf0e10cSrcweir
1653cdf0e10cSrcweir pStr->Seek( nClxPos );
165456e2a4eaSAndrea Pescetti while( nGrpprl < SAL_MAX_INT16 ) // Zaehle Zahl der Grpprls
1655cdf0e10cSrcweir {
1656cdf0e10cSrcweir *pStr >> clxt;
1657cdf0e10cSrcweir nLeft--;
1658cdf0e10cSrcweir if( 2 == clxt ) // PLCFfpcd ?
1659cdf0e10cSrcweir break; // PLCFfpcd gefunden
1660cdf0e10cSrcweir if( 1 == clxt ) // clxtGrpprl ?
1661cdf0e10cSrcweir nGrpprl++;
1662cdf0e10cSrcweir sal_uInt16 nLen;
1663cdf0e10cSrcweir *pStr >> nLen;
1664cdf0e10cSrcweir nLeft -= 2 + nLen;
1665cdf0e10cSrcweir if( nLeft < 0 )
1666cdf0e10cSrcweir return 0; // schiefgegangen
1667cdf0e10cSrcweir pStr->SeekRel( nLen ); // ueberlies grpprl
1668cdf0e10cSrcweir }
166956e2a4eaSAndrea Pescetti if ( nGrpprl == SAL_MAX_INT16 )
167056e2a4eaSAndrea Pescetti return 0;
1671cdf0e10cSrcweir pStr->Seek( nClxPos );
1672cdf0e10cSrcweir nLeft = nClxLen;
1673cdf0e10cSrcweir pPieceGrpprls = new sal_uInt8*[nGrpprl + 1];
1674cdf0e10cSrcweir memset( pPieceGrpprls, 0, ( nGrpprl + 1 ) * sizeof(sal_uInt8 *) );
1675cdf0e10cSrcweir nPieceGrpprls = nGrpprl;
1676cdf0e10cSrcweir sal_Int16 nAktGrpprl = 0; // lies Grpprls ein
1677cdf0e10cSrcweir while( 1 )
1678cdf0e10cSrcweir {
1679cdf0e10cSrcweir *pStr >> clxt;
1680cdf0e10cSrcweir nLeft--;
1681cdf0e10cSrcweir if( 2 == clxt) // PLCFfpcd ?
1682cdf0e10cSrcweir break; // PLCFfpcd gefunden
1683cdf0e10cSrcweir sal_uInt16 nLen;
1684cdf0e10cSrcweir *pStr >> nLen;
1685cdf0e10cSrcweir nLeft -= 2 + nLen;
1686cdf0e10cSrcweir if( nLeft < 0 )
1687cdf0e10cSrcweir return 0; // schiefgegangen
1688cdf0e10cSrcweir if( 1 == clxt ) // clxtGrpprl ?
1689cdf0e10cSrcweir {
1690cdf0e10cSrcweir sal_uInt8* p = new sal_uInt8[nLen+2]; // alloziere
1691cdf0e10cSrcweir ShortToSVBT16(nLen, p); // trage Laenge ein
1692cdf0e10cSrcweir pStr->Read( p+2, nLen ); // lies grpprl
1693cdf0e10cSrcweir pPieceGrpprls[nAktGrpprl++] = p; // trage in Array ein
1694cdf0e10cSrcweir }
1695cdf0e10cSrcweir else
1696cdf0e10cSrcweir pStr->SeekRel( nLen ); // ueberlies nicht-Grpprl
1697cdf0e10cSrcweir }
1698cdf0e10cSrcweir // lies Piece Table PLCF ein
1699cdf0e10cSrcweir sal_Int32 nPLCFfLen;
1700cdf0e10cSrcweir if (pWwF->GetFIBVersion() <= ww::eWW2)
1701cdf0e10cSrcweir {
1702cdf0e10cSrcweir sal_Int16 nWordTwoLen;
1703cdf0e10cSrcweir *pStr >> nWordTwoLen;
1704cdf0e10cSrcweir nPLCFfLen = nWordTwoLen;
1705cdf0e10cSrcweir }
1706cdf0e10cSrcweir else
1707cdf0e10cSrcweir *pStr >> nPLCFfLen;
1708cdf0e10cSrcweir ASSERT( 65536 > nPLCFfLen, "PLCFfpcd ueber 64 k" );
1709cdf0e10cSrcweir return new WW8PLCFpcd( pStr, pStr->Tell(), nPLCFfLen, 8 );
1710cdf0e10cSrcweir }
1711cdf0e10cSrcweir
DeletePieceTable()1712cdf0e10cSrcweir void WW8ScannerBase::DeletePieceTable()
1713cdf0e10cSrcweir {
1714cdf0e10cSrcweir if( pPieceGrpprls )
1715cdf0e10cSrcweir {
1716cdf0e10cSrcweir for( sal_uInt8** p = pPieceGrpprls; *p; p++ )
1717cdf0e10cSrcweir delete[] (*p);
1718cdf0e10cSrcweir delete[] pPieceGrpprls;
1719cdf0e10cSrcweir pPieceGrpprls = 0;
1720cdf0e10cSrcweir }
1721cdf0e10cSrcweir }
1722cdf0e10cSrcweir
WW8ScannerBase(SvStream * pSt,SvStream * pTblSt,SvStream * pDataSt,const WW8Fib * pWwFib)1723cdf0e10cSrcweir WW8ScannerBase::WW8ScannerBase( SvStream* pSt, SvStream* pTblSt,
1724cdf0e10cSrcweir SvStream* pDataSt, const WW8Fib* pWwFib )
17252726b7b2SOliver-Rainer Wittmann : pWw8Fib(pWwFib)
17262726b7b2SOliver-Rainer Wittmann , pChpPLCF( 0 )
17272726b7b2SOliver-Rainer Wittmann , pPapPLCF( 0 )
17282726b7b2SOliver-Rainer Wittmann , pSepPLCF( 0 )
17292726b7b2SOliver-Rainer Wittmann , pFtnPLCF( 0 )
17302726b7b2SOliver-Rainer Wittmann , pEdnPLCF( 0 )
17312726b7b2SOliver-Rainer Wittmann , pAndPLCF( 0 )
17322726b7b2SOliver-Rainer Wittmann , pFldPLCF( 0 )
17332726b7b2SOliver-Rainer Wittmann , pFldHdFtPLCF( 0 )
17342726b7b2SOliver-Rainer Wittmann , pFldTxbxPLCF( 0 )
17352726b7b2SOliver-Rainer Wittmann , pFldTxbxHdFtPLCF( 0 )
17362726b7b2SOliver-Rainer Wittmann , pFldFtnPLCF( 0 )
17372726b7b2SOliver-Rainer Wittmann , pFldEdnPLCF( 0 )
17382726b7b2SOliver-Rainer Wittmann , pFldAndPLCF( 0 )
17392726b7b2SOliver-Rainer Wittmann , pMainFdoa(0)
17402726b7b2SOliver-Rainer Wittmann , pHdFtFdoa(0)
17412726b7b2SOliver-Rainer Wittmann , pMainTxbx(0)
17422726b7b2SOliver-Rainer Wittmann , pMainTxbxBkd(0)
17432726b7b2SOliver-Rainer Wittmann , pHdFtTxbx(0)
17442726b7b2SOliver-Rainer Wittmann , pHdFtTxbxBkd(0)
17452726b7b2SOliver-Rainer Wittmann , pMagicTables(0)
17462726b7b2SOliver-Rainer Wittmann , pSubdocs(0)
17472726b7b2SOliver-Rainer Wittmann , pExtendedAtrds(0)
17482726b7b2SOliver-Rainer Wittmann , pBook( 0 )
17492726b7b2SOliver-Rainer Wittmann , pPiecePLCF( 0 )
17502726b7b2SOliver-Rainer Wittmann , pPieceIter( 0 )
17512726b7b2SOliver-Rainer Wittmann , pPLCFx_PCD( 0 )
17522726b7b2SOliver-Rainer Wittmann , pPLCFx_PCDAttrs( 0 )
17532726b7b2SOliver-Rainer Wittmann , pPieceGrpprls(0)
17542726b7b2SOliver-Rainer Wittmann , nPieceGrpprls( 0 )
1755cdf0e10cSrcweir {
1756cdf0e10cSrcweir pPiecePLCF = OpenPieceTable( pTblSt, pWw8Fib ); // Complex
1757cdf0e10cSrcweir if( pPiecePLCF )
1758cdf0e10cSrcweir {
1759cdf0e10cSrcweir pPieceIter = new WW8PLCFpcd_Iter( *pPiecePLCF );
1760cdf0e10cSrcweir pPLCFx_PCD = new WW8PLCFx_PCD(pWwFib->GetFIBVersion(), pPiecePLCF, 0,
1761cdf0e10cSrcweir IsSevenMinus(pWw8Fib->GetFIBVersion()));
1762cdf0e10cSrcweir pPLCFx_PCDAttrs = new WW8PLCFx_PCDAttrs(pWwFib->GetFIBVersion(),
1763cdf0e10cSrcweir pPLCFx_PCD, this);
1764cdf0e10cSrcweir }
1765cdf0e10cSrcweir else
1766cdf0e10cSrcweir {
1767cdf0e10cSrcweir pPieceIter = 0;
1768cdf0e10cSrcweir pPLCFx_PCD = 0;
1769cdf0e10cSrcweir pPLCFx_PCDAttrs = 0;
1770cdf0e10cSrcweir }
1771cdf0e10cSrcweir
1772cdf0e10cSrcweir // pChpPLCF and pPapPLCF may NOT be created before pPLCFx_PCD !!
1773cdf0e10cSrcweir pChpPLCF = new WW8PLCFx_Cp_FKP( pSt, pTblSt, pDataSt, *this, CHP ); // CHPX
1774cdf0e10cSrcweir pPapPLCF = new WW8PLCFx_Cp_FKP( pSt, pTblSt, pDataSt, *this, PAP ); // PAPX
1775cdf0e10cSrcweir
1776cdf0e10cSrcweir pSepPLCF = new WW8PLCFx_SEPX( pSt, pTblSt, *pWwFib, 0 ); // SEPX
1777cdf0e10cSrcweir
1778cdf0e10cSrcweir // Footnotes
1779cdf0e10cSrcweir pFtnPLCF = new WW8PLCFx_SubDoc( pTblSt, pWwFib->GetFIBVersion(), 0,
1780cdf0e10cSrcweir pWwFib->fcPlcffndRef, pWwFib->lcbPlcffndRef, pWwFib->fcPlcffndTxt,
1781cdf0e10cSrcweir pWwFib->lcbPlcffndTxt, 2 );
1782cdf0e10cSrcweir // Endnotes
1783cdf0e10cSrcweir pEdnPLCF = new WW8PLCFx_SubDoc( pTblSt, pWwFib->GetFIBVersion(), 0,
1784cdf0e10cSrcweir pWwFib->fcPlcfendRef, pWwFib->lcbPlcfendRef, pWwFib->fcPlcfendTxt,
1785cdf0e10cSrcweir pWwFib->lcbPlcfendTxt, 2 );
1786cdf0e10cSrcweir // Anmerkungen
1787cdf0e10cSrcweir pAndPLCF = new WW8PLCFx_SubDoc( pTblSt, pWwFib->GetFIBVersion(), 0,
1788cdf0e10cSrcweir pWwFib->fcPlcfandRef, pWwFib->lcbPlcfandRef, pWwFib->fcPlcfandTxt,
1789cdf0e10cSrcweir pWwFib->lcbPlcfandTxt, IsSevenMinus(pWwFib->GetFIBVersion()) ? 20 : 30);
1790cdf0e10cSrcweir
1791cdf0e10cSrcweir // Fields Main Text
1792cdf0e10cSrcweir pFldPLCF = new WW8PLCFx_FLD(pTblSt, *pWwFib, MAN_MAINTEXT);
1793cdf0e10cSrcweir // Fields Header / Footer
1794cdf0e10cSrcweir pFldHdFtPLCF= new WW8PLCFx_FLD(pTblSt, *pWwFib, MAN_HDFT);
1795cdf0e10cSrcweir // Fields Footnote
1796cdf0e10cSrcweir pFldFtnPLCF = new WW8PLCFx_FLD(pTblSt, *pWwFib, MAN_FTN);
1797cdf0e10cSrcweir // Fields Endnote
1798cdf0e10cSrcweir pFldEdnPLCF = new WW8PLCFx_FLD(pTblSt, *pWwFib, MAN_EDN);
1799cdf0e10cSrcweir // Fields Anmerkungen
1800cdf0e10cSrcweir pFldAndPLCF = new WW8PLCFx_FLD(pTblSt, *pWwFib, MAN_AND);
1801cdf0e10cSrcweir // Fields in Textboxes in Main Text
1802cdf0e10cSrcweir pFldTxbxPLCF= new WW8PLCFx_FLD(pTblSt, *pWwFib, MAN_TXBX);
1803cdf0e10cSrcweir // Fields in Textboxes in Header / Footer
1804cdf0e10cSrcweir pFldTxbxHdFtPLCF = new WW8PLCFx_FLD(pTblSt,*pWwFib,MAN_TXBX_HDFT);
1805cdf0e10cSrcweir
1806cdf0e10cSrcweir // Note: 6 stands for "6 OR 7", 7 stands for "ONLY 7"
1807cdf0e10cSrcweir switch( pWw8Fib->nVersion )
1808cdf0e10cSrcweir {
1809cdf0e10cSrcweir case 6:
1810cdf0e10cSrcweir case 7:
1811cdf0e10cSrcweir if( pWwFib->fcPlcfdoaMom && pWwFib->lcbPlcfdoaMom )
1812cdf0e10cSrcweir {
1813cdf0e10cSrcweir pMainFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfdoaMom,
1814cdf0e10cSrcweir pWwFib->lcbPlcfdoaMom, 6 );
1815cdf0e10cSrcweir }
1816cdf0e10cSrcweir if( pWwFib->fcPlcfdoaHdr && pWwFib->lcbPlcfdoaHdr )
1817cdf0e10cSrcweir {
1818cdf0e10cSrcweir pHdFtFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfdoaHdr,
1819cdf0e10cSrcweir pWwFib->lcbPlcfdoaHdr, 6 );
1820cdf0e10cSrcweir }
1821cdf0e10cSrcweir break;
1822cdf0e10cSrcweir case 8:
1823cdf0e10cSrcweir if( pWwFib->fcPlcfspaMom && pWwFib->lcbPlcfspaMom )
1824cdf0e10cSrcweir {
1825cdf0e10cSrcweir pMainFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfspaMom,
1826cdf0e10cSrcweir pWwFib->lcbPlcfspaMom, 26 );
1827cdf0e10cSrcweir }
1828cdf0e10cSrcweir if( pWwFib->fcPlcfspaHdr && pWwFib->lcbPlcfspaHdr )
1829cdf0e10cSrcweir {
1830cdf0e10cSrcweir pHdFtFdoa = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfspaHdr,
1831cdf0e10cSrcweir pWwFib->lcbPlcfspaHdr, 26 );
1832cdf0e10cSrcweir }
1833cdf0e10cSrcweir // PLCF fuer TextBox-Break-Deskriptoren im Maintext
1834cdf0e10cSrcweir if( pWwFib->fcPlcftxbxBkd && pWwFib->lcbPlcftxbxBkd )
1835cdf0e10cSrcweir {
1836cdf0e10cSrcweir pMainTxbxBkd = new WW8PLCFspecial( pTblSt,
1837cdf0e10cSrcweir pWwFib->fcPlcftxbxBkd, pWwFib->lcbPlcftxbxBkd, 0);
1838cdf0e10cSrcweir }
1839cdf0e10cSrcweir // PLCF fuer TextBox-Break-Deskriptoren im Header-/Footer-Bereich
1840cdf0e10cSrcweir if( pWwFib->fcPlcfHdrtxbxBkd && pWwFib->lcbPlcfHdrtxbxBkd )
1841cdf0e10cSrcweir {
1842cdf0e10cSrcweir pHdFtTxbxBkd = new WW8PLCFspecial( pTblSt,
1843cdf0e10cSrcweir pWwFib->fcPlcfHdrtxbxBkd, pWwFib->lcbPlcfHdrtxbxBkd, 0);
1844cdf0e10cSrcweir }
1845cdf0e10cSrcweir // Sub table cp positions
1846cdf0e10cSrcweir if (pWwFib->fcPlcfTch && pWwFib->lcbPlcfTch)
1847cdf0e10cSrcweir {
1848cdf0e10cSrcweir pMagicTables = new WW8PLCFspecial( pTblSt,
1849cdf0e10cSrcweir pWwFib->fcPlcfTch, pWwFib->lcbPlcfTch, 4);
1850cdf0e10cSrcweir }
1851cdf0e10cSrcweir // Sub document cp positions
1852cdf0e10cSrcweir if (pWwFib->fcPlcfwkb && pWwFib->lcbPlcfwkb)
1853cdf0e10cSrcweir {
1854cdf0e10cSrcweir pSubdocs = new WW8PLCFspecial( pTblSt,
1855cdf0e10cSrcweir pWwFib->fcPlcfwkb, pWwFib->lcbPlcfwkb, 12);
1856cdf0e10cSrcweir }
18572726b7b2SOliver-Rainer Wittmann // Extended ATRD
1858cdf0e10cSrcweir if (pWwFib->fcAtrdExtra && pWwFib->lcbAtrdExtra)
1859cdf0e10cSrcweir {
1860cdf0e10cSrcweir pExtendedAtrds = new sal_uInt8[pWwFib->lcbAtrdExtra];
18612726b7b2SOliver-Rainer Wittmann long nOldPos = pTblSt->Tell();
18622726b7b2SOliver-Rainer Wittmann pTblSt->Seek(pWwFib->fcAtrdExtra);
18632726b7b2SOliver-Rainer Wittmann pTblSt->Read(pExtendedAtrds, pWwFib->lcbAtrdExtra);
18642726b7b2SOliver-Rainer Wittmann pTblSt->Seek(nOldPos);
1865cdf0e10cSrcweir }
1866cdf0e10cSrcweir
1867cdf0e10cSrcweir break;
1868cdf0e10cSrcweir default:
1869cdf0e10cSrcweir ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
1870cdf0e10cSrcweir break;
1871cdf0e10cSrcweir }
1872cdf0e10cSrcweir
1873cdf0e10cSrcweir // PLCF fuer TextBox-Stories im Maintext
1874cdf0e10cSrcweir long nLenTxBxS = (8 > pWw8Fib->nVersion) ? 0 : 22;
1875cdf0e10cSrcweir if( pWwFib->fcPlcftxbxTxt && pWwFib->lcbPlcftxbxTxt )
1876cdf0e10cSrcweir {
1877cdf0e10cSrcweir pMainTxbx = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcftxbxTxt,
1878cdf0e10cSrcweir pWwFib->lcbPlcftxbxTxt, nLenTxBxS );
1879cdf0e10cSrcweir }
1880cdf0e10cSrcweir
1881cdf0e10cSrcweir // PLCF fuer TextBox-Stories im Header-/Footer-Bereich
1882cdf0e10cSrcweir if( pWwFib->fcPlcfHdrtxbxTxt && pWwFib->lcbPlcfHdrtxbxTxt )
1883cdf0e10cSrcweir {
1884cdf0e10cSrcweir pHdFtTxbx = new WW8PLCFspecial( pTblSt, pWwFib->fcPlcfHdrtxbxTxt,
1885cdf0e10cSrcweir pWwFib->lcbPlcfHdrtxbxTxt, nLenTxBxS );
1886cdf0e10cSrcweir }
1887cdf0e10cSrcweir
1888cdf0e10cSrcweir pBook = new WW8PLCFx_Book(pTblSt, *pWwFib);
1889cdf0e10cSrcweir }
1890cdf0e10cSrcweir
IsValid()18912726b7b2SOliver-Rainer Wittmann bool WW8ScannerBase::IsValid()
18922726b7b2SOliver-Rainer Wittmann {
18932726b7b2SOliver-Rainer Wittmann return ( pPiecePLCF == 0 || pPiecePLCF->IsValid() )
18942726b7b2SOliver-Rainer Wittmann && pChpPLCF->HasValidPLCF()
18952726b7b2SOliver-Rainer Wittmann && pPapPLCF->HasValidPLCF()
18962726b7b2SOliver-Rainer Wittmann && pSepPLCF->HasValidPLCF()
18972726b7b2SOliver-Rainer Wittmann && pFtnPLCF->HasValidPLCF()
18982726b7b2SOliver-Rainer Wittmann && pEdnPLCF->HasValidPLCF()
18992726b7b2SOliver-Rainer Wittmann && pAndPLCF->HasValidPLCF()
19002726b7b2SOliver-Rainer Wittmann && pFldPLCF->HasValidPLCF()
19012726b7b2SOliver-Rainer Wittmann && pFldHdFtPLCF->HasValidPLCF()
19022726b7b2SOliver-Rainer Wittmann && pFldFtnPLCF->HasValidPLCF()
19032726b7b2SOliver-Rainer Wittmann && pFldEdnPLCF->HasValidPLCF()
19042726b7b2SOliver-Rainer Wittmann && pFldAndPLCF->HasValidPLCF()
19052726b7b2SOliver-Rainer Wittmann && pFldTxbxPLCF->HasValidPLCF()
19062726b7b2SOliver-Rainer Wittmann && pFldTxbxHdFtPLCF->HasValidPLCF()
19072726b7b2SOliver-Rainer Wittmann && ( pMainFdoa == 0 || pMainFdoa->IsValid() )
19082726b7b2SOliver-Rainer Wittmann && ( pHdFtFdoa == 0 || pHdFtFdoa->IsValid() )
19092726b7b2SOliver-Rainer Wittmann && ( pMainTxbxBkd == 0 || pMainTxbxBkd->IsValid() )
19102726b7b2SOliver-Rainer Wittmann && ( pHdFtTxbxBkd == 0 || pHdFtTxbxBkd->IsValid() )
19112726b7b2SOliver-Rainer Wittmann && ( pMagicTables == 0 || pMagicTables->IsValid() )
19122726b7b2SOliver-Rainer Wittmann && ( pSubdocs == 0 || pSubdocs->IsValid() )
19132726b7b2SOliver-Rainer Wittmann && ( pHdFtTxbx == 0 || pHdFtTxbx->IsValid() )
19142726b7b2SOliver-Rainer Wittmann && pBook->HasValidPLCF();
19152726b7b2SOliver-Rainer Wittmann }
19162726b7b2SOliver-Rainer Wittmann
~WW8ScannerBase()1917cdf0e10cSrcweir WW8ScannerBase::~WW8ScannerBase()
1918cdf0e10cSrcweir {
1919cdf0e10cSrcweir DeletePieceTable();
1920cdf0e10cSrcweir delete pPLCFx_PCDAttrs;
1921cdf0e10cSrcweir delete pPLCFx_PCD;
1922cdf0e10cSrcweir delete pPieceIter;
1923cdf0e10cSrcweir delete pPiecePLCF;
1924cdf0e10cSrcweir delete pBook;
1925cdf0e10cSrcweir delete pFldEdnPLCF;
1926cdf0e10cSrcweir delete pFldFtnPLCF;
1927cdf0e10cSrcweir delete pFldAndPLCF;
1928cdf0e10cSrcweir delete pFldHdFtPLCF;
1929cdf0e10cSrcweir delete pFldPLCF;
1930cdf0e10cSrcweir delete pFldTxbxPLCF;
1931cdf0e10cSrcweir delete pFldTxbxHdFtPLCF;
1932cdf0e10cSrcweir delete pEdnPLCF;
1933cdf0e10cSrcweir delete pFtnPLCF;
1934cdf0e10cSrcweir delete pAndPLCF;
1935cdf0e10cSrcweir delete pSepPLCF;
1936cdf0e10cSrcweir delete pPapPLCF;
1937cdf0e10cSrcweir delete pChpPLCF;
1938cdf0e10cSrcweir // vergessene Schaeflein
1939cdf0e10cSrcweir delete pMainFdoa;
1940cdf0e10cSrcweir delete pHdFtFdoa;
1941cdf0e10cSrcweir delete pMainTxbx;
1942cdf0e10cSrcweir delete pMainTxbxBkd;
1943cdf0e10cSrcweir delete pHdFtTxbx;
1944cdf0e10cSrcweir delete pHdFtTxbxBkd;
1945cdf0e10cSrcweir delete pMagicTables;
1946cdf0e10cSrcweir delete pSubdocs;
1947cdf0e10cSrcweir delete [] pExtendedAtrds;
1948cdf0e10cSrcweir }
1949cdf0e10cSrcweir
1950cdf0e10cSrcweir //-----------------------------------------
1951cdf0e10cSrcweir // Fields
1952cdf0e10cSrcweir //-----------------------------------------
WW8SkipField(WW8PLCFspecial & rPLCF)1953cdf0e10cSrcweir static bool WW8SkipField(WW8PLCFspecial& rPLCF)
1954cdf0e10cSrcweir {
1955cdf0e10cSrcweir void* pData;
1956cdf0e10cSrcweir WW8_CP nP;
1957cdf0e10cSrcweir
1958cdf0e10cSrcweir if (!rPLCF.Get(nP, pData)) // Ende des PLCFspecial ?
1959cdf0e10cSrcweir return false;
1960cdf0e10cSrcweir
1961cdf0e10cSrcweir rPLCF++;
1962cdf0e10cSrcweir
1963cdf0e10cSrcweir if((((sal_uInt8*)pData)[0] & 0x1f ) != 0x13 ) // Kein Anfang ?
1964cdf0e10cSrcweir return true; // Bei Fehler nicht abbrechen
1965cdf0e10cSrcweir
1966cdf0e10cSrcweir if( !rPLCF.Get( nP, pData ) )
1967cdf0e10cSrcweir return false;
1968cdf0e10cSrcweir
1969cdf0e10cSrcweir
1970cdf0e10cSrcweir while((((sal_uInt8*)pData)[0] & 0x1f ) == 0x13 )
1971cdf0e10cSrcweir {
1972cdf0e10cSrcweir // immer noch neue (nested) Anfaenge ?
1973cdf0e10cSrcweir WW8SkipField( rPLCF ); // nested Field im Beschreibungsteil
1974cdf0e10cSrcweir if( !rPLCF.Get( nP, pData ) )
1975cdf0e10cSrcweir return false;
1976cdf0e10cSrcweir }
1977cdf0e10cSrcweir
1978cdf0e10cSrcweir if((((sal_uInt8*)pData)[0] & 0x1f ) == 0x14 )
1979cdf0e10cSrcweir {
1980cdf0e10cSrcweir
1981cdf0e10cSrcweir // Field Separator ?
1982cdf0e10cSrcweir rPLCF++;
1983cdf0e10cSrcweir
1984cdf0e10cSrcweir if( !rPLCF.Get( nP, pData ) )
1985cdf0e10cSrcweir return false;
1986cdf0e10cSrcweir
1987cdf0e10cSrcweir while ((((sal_uInt8*)pData)[0] & 0x1f ) == 0x13)
1988cdf0e10cSrcweir {
1989cdf0e10cSrcweir // immer noch neue (nested) Anfaenge ?
1990cdf0e10cSrcweir WW8SkipField( rPLCF ); // nested Field im Resultatteil
1991cdf0e10cSrcweir if( !rPLCF.Get( nP, pData ) )
1992cdf0e10cSrcweir return false;
1993cdf0e10cSrcweir }
1994cdf0e10cSrcweir }
1995cdf0e10cSrcweir rPLCF++;
1996cdf0e10cSrcweir
1997cdf0e10cSrcweir return true;
1998cdf0e10cSrcweir }
1999cdf0e10cSrcweir
WW8GetFieldPara(WW8PLCFspecial & rPLCF,WW8FieldDesc & rF)2000cdf0e10cSrcweir static bool WW8GetFieldPara(WW8PLCFspecial& rPLCF, WW8FieldDesc& rF)
2001cdf0e10cSrcweir {
2002cdf0e10cSrcweir void* pData;
2003cdf0e10cSrcweir sal_uLong nOldIdx = rPLCF.GetIdx();
2004cdf0e10cSrcweir
2005cdf0e10cSrcweir rF.nLen = rF.nId = rF.nOpt = rF.bCodeNest = rF.bResNest = 0;
2006cdf0e10cSrcweir
2007cdf0e10cSrcweir if( !rPLCF.Get( rF.nSCode, pData ) ) // Ende des PLCFspecial ?
2008cdf0e10cSrcweir goto Err;
2009cdf0e10cSrcweir
2010cdf0e10cSrcweir rPLCF++;
2011cdf0e10cSrcweir
2012cdf0e10cSrcweir if((((sal_uInt8*)pData)[0] & 0x1f ) != 0x13 ) // Kein Anfang ?
2013cdf0e10cSrcweir goto Err;
2014cdf0e10cSrcweir
2015cdf0e10cSrcweir rF.nId = ((sal_uInt8*)pData)[1];
2016cdf0e10cSrcweir
2017cdf0e10cSrcweir if( !rPLCF.Get( rF.nLCode, pData ) )
2018cdf0e10cSrcweir goto Err;
2019cdf0e10cSrcweir
2020cdf0e10cSrcweir rF.nSRes = rF.nLCode; // Default
2021cdf0e10cSrcweir rF.nSCode++; // ohne Marken
2022cdf0e10cSrcweir rF.nLCode -= rF.nSCode; // Pos zu Laenge
2023cdf0e10cSrcweir
2024cdf0e10cSrcweir while((((sal_uInt8*)pData)[0] & 0x1f ) == 0x13 )
2025cdf0e10cSrcweir {
2026cdf0e10cSrcweir // immer noch neue (nested) Anfaenge ?
2027cdf0e10cSrcweir WW8SkipField( rPLCF ); // nested Field im Beschreibungsteil
2028cdf0e10cSrcweir rF.bCodeNest = true;
2029cdf0e10cSrcweir if( !rPLCF.Get( rF.nSRes, pData ) )
2030cdf0e10cSrcweir goto Err;
2031cdf0e10cSrcweir }
2032cdf0e10cSrcweir
2033cdf0e10cSrcweir if((((sal_uInt8*)pData)[0] & 0x1f ) == 0x14 ){ // Field Separator ?
2034cdf0e10cSrcweir rPLCF++;
2035cdf0e10cSrcweir
2036cdf0e10cSrcweir if( !rPLCF.Get( rF.nLRes, pData ) )
2037cdf0e10cSrcweir goto Err;
2038cdf0e10cSrcweir
2039cdf0e10cSrcweir while((((sal_uInt8*)pData)[0] & 0x1f ) == 0x13 )
2040cdf0e10cSrcweir {
2041cdf0e10cSrcweir // immer noch neue (nested) Anfaenge ?
2042cdf0e10cSrcweir WW8SkipField( rPLCF ); // nested Field im Resultatteil
2043cdf0e10cSrcweir rF.bResNest = true;
2044cdf0e10cSrcweir if( !rPLCF.Get( rF.nLRes, pData ) )
2045cdf0e10cSrcweir goto Err;
2046cdf0e10cSrcweir }
2047cdf0e10cSrcweir rF.nLen = rF.nLRes - rF.nSCode + 2; // nLRes ist noch die Endposition
2048cdf0e10cSrcweir rF.nLRes -= rF.nSRes; // nun: nLRes = Laenge
2049cdf0e10cSrcweir rF.nSRes++; // Endpos encl. Marken
2050cdf0e10cSrcweir rF.nLRes--;
2051cdf0e10cSrcweir
2052cdf0e10cSrcweir }else{
2053cdf0e10cSrcweir rF.nLRes = 0; // Kein Result vorhanden
2054cdf0e10cSrcweir rF.nLen = rF.nSRes - rF.nSCode + 2; // Gesamtlaenge
2055cdf0e10cSrcweir }
2056cdf0e10cSrcweir
2057cdf0e10cSrcweir rPLCF++;
2058cdf0e10cSrcweir if((((sal_uInt8*)pData)[0] & 0x1f ) == 0x15 )
2059cdf0e10cSrcweir {
2060cdf0e10cSrcweir // Field Ende ?
2061cdf0e10cSrcweir // INDEX-Fld hat Bit7 gesetzt!?!
2062cdf0e10cSrcweir rF.nOpt = ((sal_uInt8*)pData)[1]; // Ja -> Flags uebernehmen
2063cdf0e10cSrcweir }else{
2064cdf0e10cSrcweir rF.nId = 0; // Nein -> Feld ungueltig
2065cdf0e10cSrcweir }
2066cdf0e10cSrcweir
2067cdf0e10cSrcweir rPLCF.SetIdx( nOldIdx );
2068cdf0e10cSrcweir return true;
2069cdf0e10cSrcweir Err:
2070cdf0e10cSrcweir rPLCF.SetIdx( nOldIdx );
2071cdf0e10cSrcweir return false;
2072cdf0e10cSrcweir }
2073cdf0e10cSrcweir
2074cdf0e10cSrcweir
2075cdf0e10cSrcweir //-----------------------------------------
2076cdf0e10cSrcweir
2077cdf0e10cSrcweir
2078cdf0e10cSrcweir // WW8ReadPString liest einen Pascal-String ein und gibt ihn zurueck. Der
2079cdf0e10cSrcweir // Pascal- String hat am Ende ein \0, der aber im Laengenbyte nicht
2080cdf0e10cSrcweir // mitgezaehlt wird. Der Speicher fuer den Pascalstring wird alloziert.
WW8ReadPString(SvStream & rStrm,rtl_TextEncoding eEnc,bool bAtEndSeekRel1)2081cdf0e10cSrcweir String WW8ReadPString(SvStream& rStrm, rtl_TextEncoding eEnc,
2082cdf0e10cSrcweir bool bAtEndSeekRel1)
2083cdf0e10cSrcweir {
2084cdf0e10cSrcweir ByteString aByteStr;
2085cdf0e10cSrcweir sal_uInt8 b;
2086cdf0e10cSrcweir rStrm >> b;
2087cdf0e10cSrcweir
2088cdf0e10cSrcweir if (b)
2089cdf0e10cSrcweir {
2090cdf0e10cSrcweir // Alloc methode automatically sets Zero at the end
2091cdf0e10cSrcweir sal_Char* pByteData = aByteStr.AllocBuffer( b );
2092cdf0e10cSrcweir
2093cdf0e10cSrcweir sal_uLong nWasRead = rStrm.Read( pByteData, b );
2094cdf0e10cSrcweir if( nWasRead != b )
2095cdf0e10cSrcweir aByteStr.ReleaseBufferAccess(static_cast<xub_StrLen>(nWasRead));
2096cdf0e10cSrcweir }
2097cdf0e10cSrcweir
2098cdf0e10cSrcweir if( bAtEndSeekRel1 )
2099cdf0e10cSrcweir rStrm.SeekRel( 1 ); // ueberspringe das Null-Byte am Ende.
2100cdf0e10cSrcweir
2101cdf0e10cSrcweir
2102cdf0e10cSrcweir return String( aByteStr, eEnc );
2103cdf0e10cSrcweir }
2104cdf0e10cSrcweir
WW8Read_xstz(SvStream & rStrm,sal_uInt16 nChars,bool bAtEndSeekRel1)2105cdf0e10cSrcweir String WW8Read_xstz(SvStream& rStrm, sal_uInt16 nChars, bool bAtEndSeekRel1)
2106cdf0e10cSrcweir {
2107cdf0e10cSrcweir sal_uInt16 b;
2108cdf0e10cSrcweir
2109cdf0e10cSrcweir if( nChars )
2110cdf0e10cSrcweir b = nChars;
2111cdf0e10cSrcweir else
2112cdf0e10cSrcweir rStrm >> b;
2113cdf0e10cSrcweir
2114cdf0e10cSrcweir String aStr;
2115cdf0e10cSrcweir if (b)
2116cdf0e10cSrcweir {
2117cdf0e10cSrcweir // Alloc methode automatically sets Zero at the end
2118cdf0e10cSrcweir sal_Unicode* pData = aStr.AllocBuffer( b );
2119cdf0e10cSrcweir
2120cdf0e10cSrcweir sal_uLong nWasRead = rStrm.Read( (sal_Char*)pData, b * 2 );
2121cdf0e10cSrcweir if( nWasRead != static_cast<sal_uLong>(b*2) )
2122cdf0e10cSrcweir {
2123cdf0e10cSrcweir b = static_cast<sal_uInt16>(nWasRead / 2);
2124cdf0e10cSrcweir aStr.ReleaseBufferAccess( b );
2125cdf0e10cSrcweir pData = aStr.GetBufferAccess();
2126cdf0e10cSrcweir }
2127cdf0e10cSrcweir
2128cdf0e10cSrcweir #ifdef OSL_BIGENDIAN
2129cdf0e10cSrcweir sal_uLong n;
2130cdf0e10cSrcweir sal_Unicode *pWork;
2131cdf0e10cSrcweir for( n = 0, pWork = pData; n < b; ++n, ++pWork )
2132cdf0e10cSrcweir *pWork = SWAPSHORT( *pWork );
2133cdf0e10cSrcweir #endif // ifdef OSL_BIGENDIAN
2134cdf0e10cSrcweir }
2135cdf0e10cSrcweir
2136cdf0e10cSrcweir if( bAtEndSeekRel1 )
2137cdf0e10cSrcweir rStrm.SeekRel( 2 ); // ueberspringe das Null-Character am Ende.
2138cdf0e10cSrcweir
2139cdf0e10cSrcweir return aStr;
2140cdf0e10cSrcweir }
2141cdf0e10cSrcweir
SafeReadString(ByteString & rStr,sal_uInt16 nLen,SvStream & rStrm)2142cdf0e10cSrcweir sal_uLong SafeReadString(ByteString &rStr,sal_uInt16 nLen,SvStream &rStrm)
2143cdf0e10cSrcweir {
2144cdf0e10cSrcweir sal_uLong nWasRead=0;
2145cdf0e10cSrcweir if (nLen)
2146cdf0e10cSrcweir {
2147cdf0e10cSrcweir nWasRead = rStrm.Read( rStr.AllocBuffer( nLen ), nLen);
2148cdf0e10cSrcweir if( nWasRead != nLen )
2149cdf0e10cSrcweir rStr.ReleaseBufferAccess(static_cast<xub_StrLen>(nWasRead));
2150cdf0e10cSrcweir }
2151cdf0e10cSrcweir return nWasRead;
2152cdf0e10cSrcweir }
2153cdf0e10cSrcweir
WW8ReadString(SvStream & rStrm,String & rStr,WW8_CP nAktStartCp,long nTotalLen,rtl_TextEncoding eEnc) const2154cdf0e10cSrcweir xub_StrLen WW8ScannerBase::WW8ReadString( SvStream& rStrm, String& rStr,
2155cdf0e10cSrcweir WW8_CP nAktStartCp, long nTotalLen, rtl_TextEncoding eEnc ) const
2156cdf0e10cSrcweir {
2157cdf0e10cSrcweir // Klartext einlesen, der sich ueber mehrere Pieces erstrecken kann
2158cdf0e10cSrcweir rStr.Erase();
2159cdf0e10cSrcweir
2160cdf0e10cSrcweir long nTotalRead = 0;
2161cdf0e10cSrcweir WW8_CP nBehindTextCp = nAktStartCp + nTotalLen;
2162cdf0e10cSrcweir WW8_CP nNextPieceCp = nBehindTextCp; // Initialisierung wichtig fuer Ver6
2163cdf0e10cSrcweir do
2164cdf0e10cSrcweir {
2165cdf0e10cSrcweir bool bIsUnicode, bPosOk;
2166cdf0e10cSrcweir WW8_FC fcAct = WW8Cp2Fc(nAktStartCp,&bIsUnicode,&nNextPieceCp,&bPosOk);
2167cdf0e10cSrcweir
2168cdf0e10cSrcweir // vermutlich uebers Dateiende hinaus gezielt, macht nix!
2169cdf0e10cSrcweir if( !bPosOk )
2170cdf0e10cSrcweir break;
2171cdf0e10cSrcweir
2172cdf0e10cSrcweir rStrm.Seek( fcAct );
2173cdf0e10cSrcweir
2174cdf0e10cSrcweir long nLen = ( (nNextPieceCp < nBehindTextCp) ? nNextPieceCp
2175cdf0e10cSrcweir : nBehindTextCp ) - nAktStartCp;
2176cdf0e10cSrcweir
2177cdf0e10cSrcweir if( 0 >= nLen )
2178cdf0e10cSrcweir break;
2179cdf0e10cSrcweir
2180cdf0e10cSrcweir if( nLen > USHRT_MAX - 1 )
2181cdf0e10cSrcweir nLen = USHRT_MAX - 1;
2182cdf0e10cSrcweir
2183cdf0e10cSrcweir if( bIsUnicode )
2184cdf0e10cSrcweir rStr.Append(WW8Read_xstz(rStrm, (sal_uInt16)nLen, false));
2185cdf0e10cSrcweir else
2186cdf0e10cSrcweir {
2187cdf0e10cSrcweir // Alloc method automatically sets Zero at the end
2188cdf0e10cSrcweir ByteString aByteStr;
2189cdf0e10cSrcweir SafeReadString(aByteStr,(sal_uInt16)nLen,rStrm);
2190cdf0e10cSrcweir rStr += String( aByteStr, eEnc );
2191cdf0e10cSrcweir }
2192cdf0e10cSrcweir nTotalRead += nLen;
2193cdf0e10cSrcweir nAktStartCp += nLen;
2194cdf0e10cSrcweir if ( nTotalRead != rStr.Len() )
2195cdf0e10cSrcweir break;
2196cdf0e10cSrcweir }
2197cdf0e10cSrcweir while( nTotalRead < nTotalLen );
2198cdf0e10cSrcweir
2199cdf0e10cSrcweir return rStr.Len();
2200cdf0e10cSrcweir }
2201cdf0e10cSrcweir
2202cdf0e10cSrcweir //-----------------------------------------
2203cdf0e10cSrcweir // WW8PLCFspecial
2204cdf0e10cSrcweir //-----------------------------------------
2205cdf0e10cSrcweir
2206cdf0e10cSrcweir // Bei nStartPos < 0 wird das erste Element des PLCFs genommen
WW8PLCFspecial(SvStream * pSt,long nFilePos,long nPLCF,long nStruct,long nStartPos)2207cdf0e10cSrcweir WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, long nFilePos, long nPLCF,
2208cdf0e10cSrcweir long nStruct, long nStartPos)
2209cdf0e10cSrcweir : nIdx(0), nStru(nStruct)
2210cdf0e10cSrcweir {
2211cdf0e10cSrcweir nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
2212cdf0e10cSrcweir // Pointer auf Pos- u. Struct-Array
2213cdf0e10cSrcweir pPLCF_PosArray = new sal_Int32[ ( nPLCF + 3 ) / 4 ];
2214cdf0e10cSrcweir
2215cdf0e10cSrcweir long nOldPos = pSt->Tell();
2216cdf0e10cSrcweir
2217cdf0e10cSrcweir pSt->Seek( nFilePos );
2218cdf0e10cSrcweir pSt->Read( pPLCF_PosArray, nPLCF );
2219cdf0e10cSrcweir #ifdef OSL_BIGENDIAN
2220cdf0e10cSrcweir for( nIdx = 0; nIdx <= nIMax; nIdx++ )
2221cdf0e10cSrcweir pPLCF_PosArray[nIdx] = SWAPLONG( pPLCF_PosArray[nIdx] );
2222cdf0e10cSrcweir nIdx = 0;
2223cdf0e10cSrcweir #endif // OSL_BIGENDIAN
2224cdf0e10cSrcweir if( nStruct ) // Pointer auf Inhalts-Array
2225cdf0e10cSrcweir pPLCF_Contents = (sal_uInt8*)&pPLCF_PosArray[nIMax + 1];
2226cdf0e10cSrcweir else
2227cdf0e10cSrcweir pPLCF_Contents = 0; // kein Inhalt
2228cdf0e10cSrcweir if( nStartPos >= 0 )
2229cdf0e10cSrcweir SeekPos( nStartPos );
2230cdf0e10cSrcweir
2231cdf0e10cSrcweir pSt->Seek( nOldPos );
2232cdf0e10cSrcweir }
2233cdf0e10cSrcweir
IsValid()22342726b7b2SOliver-Rainer Wittmann bool WW8PLCFspecial::IsValid()
22352726b7b2SOliver-Rainer Wittmann {
22362726b7b2SOliver-Rainer Wittmann return IsPLCFPosArrayValid( pPLCF_PosArray, nIMax );
22372726b7b2SOliver-Rainer Wittmann }
22382726b7b2SOliver-Rainer Wittmann
2239cdf0e10cSrcweir // WW8PLCFspecial::SeekPos() stellt den WW8PLCFspecial auf die Stelle nPos, wobei auch noch der
2240cdf0e10cSrcweir // Eintrag benutzt wird, der vor nPos beginnt und bis hinter nPos reicht.
2241cdf0e10cSrcweir // geeignet fuer normale Attribute. Allerdings wird der Attributanfang nicht
2242cdf0e10cSrcweir // auf die Position nPos korrigiert.
SeekPos(long nP)2243cdf0e10cSrcweir bool WW8PLCFspecial::SeekPos(long nP)
2244cdf0e10cSrcweir {
2245cdf0e10cSrcweir if( nP < pPLCF_PosArray[0] )
2246cdf0e10cSrcweir {
2247cdf0e10cSrcweir nIdx = 0;
2248cdf0e10cSrcweir return false; // Not found: nP unterhalb kleinstem Eintrag
2249cdf0e10cSrcweir }
2250cdf0e10cSrcweir
2251cdf0e10cSrcweir // Search from beginning?
2252cdf0e10cSrcweir if( (1 > nIdx) || (nP < pPLCF_PosArray[ nIdx-1 ]) )
2253cdf0e10cSrcweir nIdx = 1;
2254cdf0e10cSrcweir
2255cdf0e10cSrcweir long nI = nIdx ? nIdx : 1;
2256cdf0e10cSrcweir long nEnd = nIMax;
2257cdf0e10cSrcweir
2258cdf0e10cSrcweir for(int n = (1==nIdx ? 1 : 2); n; --n )
2259cdf0e10cSrcweir {
2260cdf0e10cSrcweir for( ; nI <=nEnd; ++nI)
2261cdf0e10cSrcweir { // Suchen mit um 1 erhoehtem Index
2262cdf0e10cSrcweir if( nP < pPLCF_PosArray[nI] )
2263cdf0e10cSrcweir { // Position gefunden
2264cdf0e10cSrcweir nIdx = nI - 1; // nI - 1 ist der richtige Index
2265cdf0e10cSrcweir return true; // ... und fertig
2266cdf0e10cSrcweir }
2267cdf0e10cSrcweir }
2268cdf0e10cSrcweir nI = 1;
2269cdf0e10cSrcweir nEnd = nIdx-1;
2270cdf0e10cSrcweir }
2271cdf0e10cSrcweir nIdx = nIMax; // Nicht gefunden, groesser als alle Eintraege
2272cdf0e10cSrcweir return false;
2273cdf0e10cSrcweir }
2274cdf0e10cSrcweir
2275cdf0e10cSrcweir // WW8PLCFspecial::SeekPosExact() wie SeekPos(), aber es wird sichergestellt,
2276cdf0e10cSrcweir // dass kein Attribut angeschnitten wird, d.h. das naechste gelieferte
2277cdf0e10cSrcweir // Attribut beginnt auf oder hinter nPos. Wird benutzt fuer Felder +
2278cdf0e10cSrcweir // Bookmarks.
SeekPosExact(long nP)2279cdf0e10cSrcweir bool WW8PLCFspecial::SeekPosExact(long nP)
2280cdf0e10cSrcweir {
2281cdf0e10cSrcweir if( nP < pPLCF_PosArray[0] )
2282cdf0e10cSrcweir {
2283cdf0e10cSrcweir nIdx = 0;
2284cdf0e10cSrcweir return false; // Not found: nP unterhalb kleinstem Eintrag
2285cdf0e10cSrcweir }
2286cdf0e10cSrcweir // Search from beginning?
2287cdf0e10cSrcweir if( nP <=pPLCF_PosArray[nIdx] )
2288cdf0e10cSrcweir nIdx = 0;
2289cdf0e10cSrcweir
2290cdf0e10cSrcweir long nI = nIdx ? nIdx-1 : 0;
2291cdf0e10cSrcweir long nEnd = nIMax;
2292cdf0e10cSrcweir
2293cdf0e10cSrcweir for(int n = (0==nIdx ? 1 : 2); n; --n )
2294cdf0e10cSrcweir {
2295cdf0e10cSrcweir for( ; nI < nEnd; ++nI)
2296cdf0e10cSrcweir {
2297cdf0e10cSrcweir if( nP <=pPLCF_PosArray[nI] )
2298cdf0e10cSrcweir { // Position gefunden
2299cdf0e10cSrcweir nIdx = nI; // nI ist der richtige Index
2300cdf0e10cSrcweir return true; // ... und fertig
2301cdf0e10cSrcweir }
2302cdf0e10cSrcweir }
2303cdf0e10cSrcweir nI = 0;
2304cdf0e10cSrcweir nEnd = nIdx;
2305cdf0e10cSrcweir }
2306cdf0e10cSrcweir nIdx = nIMax; // Not found, groesser als alle Eintraege
2307cdf0e10cSrcweir return false;
2308cdf0e10cSrcweir }
2309cdf0e10cSrcweir
Get(WW8_CP & rPos,void * & rpValue) const2310cdf0e10cSrcweir bool WW8PLCFspecial::Get(WW8_CP& rPos, void*& rpValue) const
2311cdf0e10cSrcweir {
2312cdf0e10cSrcweir return GetData( nIdx, rPos, rpValue );
2313cdf0e10cSrcweir }
2314cdf0e10cSrcweir
GetData(long nInIdx,WW8_CP & rPos,void * & rpValue) const2315cdf0e10cSrcweir bool WW8PLCFspecial::GetData(long nInIdx, WW8_CP& rPos, void*& rpValue) const
2316cdf0e10cSrcweir {
2317cdf0e10cSrcweir if ( nInIdx >= nIMax )
2318cdf0e10cSrcweir {
2319cdf0e10cSrcweir rPos = WW8_CP_MAX;
2320cdf0e10cSrcweir return false;
2321cdf0e10cSrcweir }
2322cdf0e10cSrcweir rPos = pPLCF_PosArray[nInIdx];
2323cdf0e10cSrcweir rpValue = pPLCF_Contents ? (void*)&pPLCF_Contents[nInIdx * nStru] : 0;
2324cdf0e10cSrcweir return true;
2325cdf0e10cSrcweir }
2326cdf0e10cSrcweir
2327cdf0e10cSrcweir //-----------------------------------------
2328cdf0e10cSrcweir // WW8PLCF z.B. fuer SEPX
2329cdf0e10cSrcweir //-----------------------------------------
2330cdf0e10cSrcweir
2331cdf0e10cSrcweir // Ctor fuer *andere* als Fkps
2332cdf0e10cSrcweir // Bei nStartPos < 0 wird das erste Element des PLCFs genommen
WW8PLCF(SvStream * pSt,WW8_FC nFilePos,sal_Int32 nPLCF,int nStruct,WW8_CP nStartPos)23332726b7b2SOliver-Rainer Wittmann WW8PLCF::WW8PLCF(
23342726b7b2SOliver-Rainer Wittmann SvStream* pSt,
23352726b7b2SOliver-Rainer Wittmann WW8_FC nFilePos,
23362726b7b2SOliver-Rainer Wittmann sal_Int32 nPLCF,
23372726b7b2SOliver-Rainer Wittmann int nStruct,
23382726b7b2SOliver-Rainer Wittmann WW8_CP nStartPos )
23392726b7b2SOliver-Rainer Wittmann : pPLCF_PosArray( 0 )
23402726b7b2SOliver-Rainer Wittmann , pPLCF_Contents( 0 )
23412726b7b2SOliver-Rainer Wittmann , nIMax( 0 )
23422726b7b2SOliver-Rainer Wittmann , nIdx( 0 )
23432726b7b2SOliver-Rainer Wittmann , nStru( nStruct )
2344cdf0e10cSrcweir {
2345cdf0e10cSrcweir ASSERT( nPLCF, "WW8PLCF: nPLCF ist Null!" );
2346cdf0e10cSrcweir
2347cdf0e10cSrcweir nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
2348cdf0e10cSrcweir
2349cdf0e10cSrcweir ReadPLCF( pSt, nFilePos, nPLCF );
2350cdf0e10cSrcweir
2351cdf0e10cSrcweir if( nStartPos >= 0 )
2352cdf0e10cSrcweir SeekPos( nStartPos );
2353cdf0e10cSrcweir }
2354cdf0e10cSrcweir
2355cdf0e10cSrcweir // Ctor *nur* fuer Fkps
2356cdf0e10cSrcweir // Die letzten 2 Parameter sind fuer PLCF.Chpx und PLCF.Papx noetig. ist ncpN
2357cdf0e10cSrcweir // != 0, dann wird ein unvollstaendiger PLCF vervollstaendigt. Das ist bei
2358cdf0e10cSrcweir // WW6 bei Resourcenmangel und bei WordPad (W95) immer noetig. Bei nStartPos
2359cdf0e10cSrcweir // < 0 wird das erste Element des PLCFs genommen
WW8PLCF(SvStream * pSt,WW8_FC nFilePos,sal_Int32 nPLCF,int nStruct,WW8_CP nStartPos,sal_Int32 nPN,sal_Int32 ncpN)2360cdf0e10cSrcweir WW8PLCF::WW8PLCF( SvStream* pSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
2361cdf0e10cSrcweir WW8_CP nStartPos, sal_Int32 nPN, sal_Int32 ncpN ) : pPLCF_PosArray(0), nIdx(0),
2362cdf0e10cSrcweir nStru(nStruct)
2363cdf0e10cSrcweir {
2364cdf0e10cSrcweir nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
2365cdf0e10cSrcweir
2366cdf0e10cSrcweir if( nIMax >= ncpN )
2367cdf0e10cSrcweir ReadPLCF( pSt, nFilePos, nPLCF );
2368cdf0e10cSrcweir else
2369cdf0e10cSrcweir GeneratePLCF( pSt, nPN, ncpN );
2370cdf0e10cSrcweir
2371cdf0e10cSrcweir if( nStartPos >= 0 )
2372cdf0e10cSrcweir SeekPos( nStartPos );
2373cdf0e10cSrcweir }
2374cdf0e10cSrcweir
IsValid()23752726b7b2SOliver-Rainer Wittmann bool WW8PLCF::IsValid()
23762726b7b2SOliver-Rainer Wittmann {
23772726b7b2SOliver-Rainer Wittmann return pPLCF_PosArray == 0
23782726b7b2SOliver-Rainer Wittmann || IsPLCFPosArrayValid( pPLCF_PosArray, nIMax );
23792726b7b2SOliver-Rainer Wittmann }
23802726b7b2SOliver-Rainer Wittmann
ReadPLCF(SvStream * pSt,WW8_FC nFilePos,sal_Int32 nPLCF)2381cdf0e10cSrcweir void WW8PLCF::ReadPLCF( SvStream* pSt, WW8_FC nFilePos, sal_Int32 nPLCF )
2382cdf0e10cSrcweir {
2383cdf0e10cSrcweir bool failure = false;
2384cdf0e10cSrcweir
2385cdf0e10cSrcweir // Pointer auf Pos-Array
2386cdf0e10cSrcweir pPLCF_PosArray = new WW8_CP[ ( nPLCF + 3 ) / 4 ];
2387cdf0e10cSrcweir
2388cdf0e10cSrcweir sal_Size nOldPos = pSt->Tell();
2389cdf0e10cSrcweir
2390cdf0e10cSrcweir pSt->Seek( nFilePos );
2391cdf0e10cSrcweir failure = pSt->GetError();
2392cdf0e10cSrcweir
2393cdf0e10cSrcweir if (!failure)
2394cdf0e10cSrcweir {
2395cdf0e10cSrcweir pSt->Read( pPLCF_PosArray, nPLCF );
2396cdf0e10cSrcweir failure = pSt->GetError();
2397cdf0e10cSrcweir }
2398cdf0e10cSrcweir
2399cdf0e10cSrcweir if (!failure)
2400cdf0e10cSrcweir {
2401cdf0e10cSrcweir #ifdef OSL_BIGENDIAN
2402cdf0e10cSrcweir for( nIdx = 0; nIdx <= nIMax; nIdx++ )
2403cdf0e10cSrcweir pPLCF_PosArray[nIdx] = SWAPLONG( pPLCF_PosArray[nIdx] );
2404cdf0e10cSrcweir nIdx = 0;
2405cdf0e10cSrcweir #endif // OSL_BIGENDIAN
2406cdf0e10cSrcweir // Pointer auf Inhalts-Array
2407cdf0e10cSrcweir pPLCF_Contents = (sal_uInt8*)&pPLCF_PosArray[nIMax + 1];
2408cdf0e10cSrcweir }
2409cdf0e10cSrcweir
2410cdf0e10cSrcweir pSt->Seek( nOldPos );
2411cdf0e10cSrcweir
2412cdf0e10cSrcweir ASSERT( !failure, "Document has corrupt PLCF, ignoring it" );
2413cdf0e10cSrcweir
2414cdf0e10cSrcweir if (failure)
2415cdf0e10cSrcweir MakeFailedPLCF();
2416cdf0e10cSrcweir }
2417cdf0e10cSrcweir
MakeFailedPLCF()2418cdf0e10cSrcweir void WW8PLCF::MakeFailedPLCF()
2419cdf0e10cSrcweir {
2420cdf0e10cSrcweir nIMax = 0;
2421cdf0e10cSrcweir delete[] pPLCF_PosArray;
2422cdf0e10cSrcweir pPLCF_PosArray = new sal_Int32[2];
2423cdf0e10cSrcweir pPLCF_PosArray[0] = pPLCF_PosArray[1] = WW8_CP_MAX;
2424cdf0e10cSrcweir pPLCF_Contents = (sal_uInt8*)&pPLCF_PosArray[nIMax + 1];
2425cdf0e10cSrcweir }
2426cdf0e10cSrcweir
GeneratePLCF(SvStream * pSt,sal_Int32 nPN,sal_Int32 ncpN)2427cdf0e10cSrcweir void WW8PLCF::GeneratePLCF( SvStream* pSt, sal_Int32 nPN, sal_Int32 ncpN )
2428cdf0e10cSrcweir {
2429cdf0e10cSrcweir ASSERT( nIMax < ncpN, "Pcl.Fkp: Warum ist PLCF zu gross ?" );
2430cdf0e10cSrcweir
2431cdf0e10cSrcweir bool failure = false;
2432cdf0e10cSrcweir nIMax = ncpN;
2433cdf0e10cSrcweir
2434cdf0e10cSrcweir if ((nIMax < 1) || (nIMax > (WW8_CP_MAX - 4)/6) || ((nPN + ncpN) > USHRT_MAX))
2435cdf0e10cSrcweir failure = true;
2436cdf0e10cSrcweir
2437cdf0e10cSrcweir if (!failure)
2438cdf0e10cSrcweir {
2439cdf0e10cSrcweir size_t nSiz = 6 * nIMax + 4;
2440cdf0e10cSrcweir size_t nElems = ( nSiz + 3 ) / 4;
2441cdf0e10cSrcweir pPLCF_PosArray = new sal_Int32[ nElems ]; // Pointer auf Pos-Array
2442cdf0e10cSrcweir
2443cdf0e10cSrcweir for (sal_Int32 i = 0; i < ncpN && !pSt->GetError(); ++i)
2444cdf0e10cSrcweir {
2445cdf0e10cSrcweir // Baue FC-Eintraege
2446cdf0e10cSrcweir pSt->Seek( ( nPN + i ) << 9 ); // erster FC-Eintrag jedes Fkp
2447cdf0e10cSrcweir WW8_CP nFc;
2448cdf0e10cSrcweir *pSt >> nFc;
2449cdf0e10cSrcweir pPLCF_PosArray[i] = nFc;
2450cdf0e10cSrcweir }
2451cdf0e10cSrcweir
2452cdf0e10cSrcweir failure = pSt->GetError();
2453cdf0e10cSrcweir }
2454cdf0e10cSrcweir
2455cdf0e10cSrcweir if (!failure)
2456cdf0e10cSrcweir {
2457cdf0e10cSrcweir sal_Size nLastFkpPos = ( ( nPN + nIMax - 1 ) << 9 );
2458cdf0e10cSrcweir pSt->Seek( nLastFkpPos + 511 ); // Anz. Fkp-Eintraege des letzten Fkp
2459cdf0e10cSrcweir
2460cdf0e10cSrcweir sal_uInt8 nb;
2461cdf0e10cSrcweir *pSt >> nb;
2462cdf0e10cSrcweir pSt->Seek( nLastFkpPos + nb * 4 ); // letzer FC-Eintrag des letzten Fkp
2463cdf0e10cSrcweir
2464cdf0e10cSrcweir WW8_CP nFc;
2465cdf0e10cSrcweir *pSt >> nFc;
2466cdf0e10cSrcweir pPLCF_PosArray[nIMax] = nFc; // Ende des letzten Fkp
2467cdf0e10cSrcweir
2468cdf0e10cSrcweir failure = pSt->GetError();
2469cdf0e10cSrcweir }
2470cdf0e10cSrcweir
2471cdf0e10cSrcweir if (!failure)
2472cdf0e10cSrcweir {
2473cdf0e10cSrcweir // Pointer auf Inhalts-Array
2474cdf0e10cSrcweir pPLCF_Contents = (sal_uInt8*)&pPLCF_PosArray[nIMax + 1];
2475cdf0e10cSrcweir sal_uInt8* p = pPLCF_Contents;
2476cdf0e10cSrcweir
2477cdf0e10cSrcweir for (sal_Int32 i = 0; i < ncpN; ++i) // Baue PNs
2478cdf0e10cSrcweir {
2479cdf0e10cSrcweir ShortToSVBT16(static_cast<sal_uInt16>(nPN + i), p);
2480cdf0e10cSrcweir p+=2;
2481cdf0e10cSrcweir }
2482cdf0e10cSrcweir }
2483cdf0e10cSrcweir
2484cdf0e10cSrcweir ASSERT( !failure, "Document has corrupt PLCF, ignoring it" );
2485cdf0e10cSrcweir
2486cdf0e10cSrcweir if (failure)
2487cdf0e10cSrcweir MakeFailedPLCF();
2488cdf0e10cSrcweir }
2489cdf0e10cSrcweir
SeekPos(WW8_CP nPos)2490cdf0e10cSrcweir bool WW8PLCF::SeekPos(WW8_CP nPos)
2491cdf0e10cSrcweir {
2492cdf0e10cSrcweir WW8_CP nP = nPos;
2493cdf0e10cSrcweir
2494cdf0e10cSrcweir if( nP < pPLCF_PosArray[0] )
2495cdf0e10cSrcweir {
2496cdf0e10cSrcweir nIdx = 0;
2497cdf0e10cSrcweir // Nicht gefunden: nPos unterhalb kleinstem Eintrag
2498cdf0e10cSrcweir return false;
2499cdf0e10cSrcweir }
2500cdf0e10cSrcweir
2501cdf0e10cSrcweir // Search from beginning?
2502cdf0e10cSrcweir if( (1 > nIdx) || (nP < pPLCF_PosArray[ nIdx-1 ]) )
2503cdf0e10cSrcweir nIdx = 1;
2504cdf0e10cSrcweir
2505cdf0e10cSrcweir sal_Int32 nI = nIdx ? nIdx : 1;
2506cdf0e10cSrcweir sal_Int32 nEnd = nIMax;
2507cdf0e10cSrcweir
2508cdf0e10cSrcweir for(int n = (1==nIdx ? 1 : 2); n; --n )
2509cdf0e10cSrcweir {
2510cdf0e10cSrcweir for( ; nI <=nEnd; ++nI) // Suchen mit um 1 erhoehtem Index
2511cdf0e10cSrcweir {
2512cdf0e10cSrcweir if( nP < pPLCF_PosArray[nI] ) // Position gefunden
2513cdf0e10cSrcweir {
2514cdf0e10cSrcweir nIdx = nI - 1; // nI - 1 ist der richtige Index
2515cdf0e10cSrcweir return true; // ... und fertig
2516cdf0e10cSrcweir }
2517cdf0e10cSrcweir }
2518cdf0e10cSrcweir nI = 1;
2519cdf0e10cSrcweir nEnd = nIdx-1;
2520cdf0e10cSrcweir }
2521cdf0e10cSrcweir
2522cdf0e10cSrcweir nIdx = nIMax; // Nicht gefunden, groesser als alle Eintraege
2523cdf0e10cSrcweir return false;
2524cdf0e10cSrcweir }
2525cdf0e10cSrcweir
Get(WW8_CP & rStart,WW8_CP & rEnd,void * & rpValue) const2526cdf0e10cSrcweir bool WW8PLCF::Get(WW8_CP& rStart, WW8_CP& rEnd, void*& rpValue) const
2527cdf0e10cSrcweir {
2528cdf0e10cSrcweir if ( nIdx >= nIMax )
2529cdf0e10cSrcweir {
2530cdf0e10cSrcweir rStart = rEnd = WW8_CP_MAX;
2531cdf0e10cSrcweir return false;
2532cdf0e10cSrcweir }
2533cdf0e10cSrcweir rStart = pPLCF_PosArray[ nIdx ];
2534cdf0e10cSrcweir rEnd = pPLCF_PosArray[ nIdx + 1 ];
2535cdf0e10cSrcweir rpValue = (void*)&pPLCF_Contents[nIdx * nStru];
2536cdf0e10cSrcweir return true;
2537cdf0e10cSrcweir }
2538cdf0e10cSrcweir
Where() const2539cdf0e10cSrcweir WW8_CP WW8PLCF::Where() const
2540cdf0e10cSrcweir {
2541cdf0e10cSrcweir if ( nIdx >= nIMax )
2542cdf0e10cSrcweir return WW8_CP_MAX;
2543cdf0e10cSrcweir
2544cdf0e10cSrcweir return pPLCF_PosArray[nIdx];
2545cdf0e10cSrcweir }
2546cdf0e10cSrcweir
2547cdf0e10cSrcweir //-----------------------------------------
2548cdf0e10cSrcweir // WW8PLCFpcd
2549cdf0e10cSrcweir //-----------------------------------------
2550cdf0e10cSrcweir
WW8PLCFpcd(SvStream * pSt,long nFilePos,long nPLCF,long nStruct)2551cdf0e10cSrcweir WW8PLCFpcd::WW8PLCFpcd( SvStream* pSt, long nFilePos, long nPLCF, long nStruct )
2552cdf0e10cSrcweir :nStru( nStruct )
2553cdf0e10cSrcweir {
2554cdf0e10cSrcweir nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
2555cdf0e10cSrcweir pPLCF_PosArray = new sal_Int32[ ( nPLCF + 3 ) / 4 ]; // Pointer auf Pos-Array
2556cdf0e10cSrcweir
2557cdf0e10cSrcweir long nOldPos = pSt->Tell();
2558cdf0e10cSrcweir
2559cdf0e10cSrcweir pSt->Seek( nFilePos );
2560cdf0e10cSrcweir pSt->Read( pPLCF_PosArray, nPLCF );
2561cdf0e10cSrcweir #ifdef OSL_BIGENDIAN
2562cdf0e10cSrcweir for( long nI = 0; nI <= nIMax; nI++ )
2563cdf0e10cSrcweir pPLCF_PosArray[nI] = SWAPLONG( pPLCF_PosArray[nI] );
2564cdf0e10cSrcweir #endif // OSL_BIGENDIAN
2565cdf0e10cSrcweir
2566cdf0e10cSrcweir // Pointer auf Inhalts-Array
2567cdf0e10cSrcweir pPLCF_Contents = (sal_uInt8*)&pPLCF_PosArray[nIMax + 1];
2568cdf0e10cSrcweir
2569cdf0e10cSrcweir pSt->Seek( nOldPos );
2570cdf0e10cSrcweir }
2571cdf0e10cSrcweir
IsValid()25722726b7b2SOliver-Rainer Wittmann bool WW8PLCFpcd::IsValid()
25732726b7b2SOliver-Rainer Wittmann {
25742726b7b2SOliver-Rainer Wittmann return IsPLCFPosArrayValid( pPLCF_PosArray, nIMax );
25752726b7b2SOliver-Rainer Wittmann }
25762726b7b2SOliver-Rainer Wittmann
2577cdf0e10cSrcweir // Bei nStartPos < 0 wird das erste Element des PLCFs genommen
WW8PLCFpcd_Iter(WW8PLCFpcd & rPLCFpcd,long nStartPos)2578cdf0e10cSrcweir WW8PLCFpcd_Iter::WW8PLCFpcd_Iter( WW8PLCFpcd& rPLCFpcd, long nStartPos )
2579cdf0e10cSrcweir :rPLCF( rPLCFpcd ), nIdx( 0 )
2580cdf0e10cSrcweir {
2581cdf0e10cSrcweir if( nStartPos >= 0 )
2582cdf0e10cSrcweir SeekPos( nStartPos );
2583cdf0e10cSrcweir }
2584cdf0e10cSrcweir
SeekPos(long nPos)2585cdf0e10cSrcweir bool WW8PLCFpcd_Iter::SeekPos(long nPos)
2586cdf0e10cSrcweir {
2587cdf0e10cSrcweir long nP = nPos;
2588cdf0e10cSrcweir
2589cdf0e10cSrcweir if( nP < rPLCF.pPLCF_PosArray[0] )
2590cdf0e10cSrcweir {
2591cdf0e10cSrcweir nIdx = 0;
2592cdf0e10cSrcweir return false; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
2593cdf0e10cSrcweir }
2594cdf0e10cSrcweir // Search from beginning?
2595cdf0e10cSrcweir if( (1 > nIdx) || (nP < rPLCF.pPLCF_PosArray[ nIdx-1 ]) )
2596cdf0e10cSrcweir nIdx = 1;
2597cdf0e10cSrcweir
2598cdf0e10cSrcweir long nI = nIdx ? nIdx : 1;
2599cdf0e10cSrcweir long nEnd = rPLCF.nIMax;
2600cdf0e10cSrcweir
2601cdf0e10cSrcweir for(int n = (1==nIdx ? 1 : 2); n; --n )
2602cdf0e10cSrcweir {
2603cdf0e10cSrcweir for( ; nI <=nEnd; ++nI)
2604cdf0e10cSrcweir { // Suchen mit um 1 erhoehtem Index
2605cdf0e10cSrcweir if( nP < rPLCF.pPLCF_PosArray[nI] )
2606cdf0e10cSrcweir { // Position gefunden
2607cdf0e10cSrcweir nIdx = nI - 1; // nI - 1 ist der richtige Index
2608cdf0e10cSrcweir return true; // ... und fertig
2609cdf0e10cSrcweir }
2610cdf0e10cSrcweir }
2611cdf0e10cSrcweir nI = 1;
2612cdf0e10cSrcweir nEnd = nIdx-1;
2613cdf0e10cSrcweir }
2614cdf0e10cSrcweir nIdx = rPLCF.nIMax; // Nicht gefunden, groesser als alle Eintraege
2615cdf0e10cSrcweir return false;
2616cdf0e10cSrcweir }
2617cdf0e10cSrcweir
Get(WW8_CP & rStart,WW8_CP & rEnd,void * & rpValue) const2618cdf0e10cSrcweir bool WW8PLCFpcd_Iter::Get(WW8_CP& rStart, WW8_CP& rEnd, void*& rpValue) const
2619cdf0e10cSrcweir {
2620cdf0e10cSrcweir if( nIdx >= rPLCF.nIMax )
2621cdf0e10cSrcweir {
2622cdf0e10cSrcweir rStart = rEnd = WW8_CP_MAX;
2623cdf0e10cSrcweir return false;
2624cdf0e10cSrcweir }
2625cdf0e10cSrcweir rStart = rPLCF.pPLCF_PosArray[nIdx];
2626cdf0e10cSrcweir rEnd = rPLCF.pPLCF_PosArray[nIdx + 1];
2627cdf0e10cSrcweir rpValue = (void*)&rPLCF.pPLCF_Contents[nIdx * rPLCF.nStru];
2628cdf0e10cSrcweir return true;
2629cdf0e10cSrcweir }
2630cdf0e10cSrcweir
Where() const2631cdf0e10cSrcweir sal_Int32 WW8PLCFpcd_Iter::Where() const
2632cdf0e10cSrcweir {
2633cdf0e10cSrcweir if ( nIdx >= rPLCF.nIMax )
2634cdf0e10cSrcweir return SAL_MAX_INT32;
2635cdf0e10cSrcweir
2636cdf0e10cSrcweir return rPLCF.pPLCF_PosArray[nIdx];
2637cdf0e10cSrcweir }
2638cdf0e10cSrcweir
2639cdf0e10cSrcweir //-----------------------------------------
operator <(const WW8PLCFx_Fc_FKP::WW8Fkp::Entry & rSecond) const2640cdf0e10cSrcweir bool WW8PLCFx_Fc_FKP::WW8Fkp::Entry::operator<
2641cdf0e10cSrcweir (const WW8PLCFx_Fc_FKP::WW8Fkp::Entry& rSecond) const
2642cdf0e10cSrcweir {
2643cdf0e10cSrcweir return (mnFC < rSecond.mnFC);
2644cdf0e10cSrcweir }
2645cdf0e10cSrcweir
IsReplaceAllSprm(sal_uInt16 nSpId)2646cdf0e10cSrcweir bool IsReplaceAllSprm(sal_uInt16 nSpId)
2647cdf0e10cSrcweir {
2648cdf0e10cSrcweir return (0x6645 == nSpId || 0x6646 == nSpId);
2649cdf0e10cSrcweir }
2650cdf0e10cSrcweir
IsExpandableSprm(sal_uInt16 nSpId)2651cdf0e10cSrcweir bool IsExpandableSprm(sal_uInt16 nSpId)
2652cdf0e10cSrcweir {
2653cdf0e10cSrcweir return 0x646B == nSpId;
2654cdf0e10cSrcweir }
2655cdf0e10cSrcweir
WW8Fkp(ww::WordVersion eVersion,SvStream * pSt,SvStream * pDataSt,long _nFilePos,long nItemSiz,ePLCFT ePl,WW8_FC nStartFc)2656cdf0e10cSrcweir WW8PLCFx_Fc_FKP::WW8Fkp::WW8Fkp(ww::WordVersion eVersion, SvStream* pSt,
2657cdf0e10cSrcweir SvStream* pDataSt, long _nFilePos, long nItemSiz, ePLCFT ePl,
2658cdf0e10cSrcweir WW8_FC nStartFc)
2659cdf0e10cSrcweir : nItemSize(nItemSiz), nFilePos(_nFilePos), mnIdx(0), ePLCF(ePl),
2660cdf0e10cSrcweir maSprmParser(eVersion)
2661cdf0e10cSrcweir {
2662cdf0e10cSrcweir long nOldPos = pSt->Tell();
2663cdf0e10cSrcweir
2664cdf0e10cSrcweir pSt->Seek(nFilePos);
2665cdf0e10cSrcweir pSt->Read(maRawData, 512);
2666cdf0e10cSrcweir mnIMax = maRawData[511];
2667cdf0e10cSrcweir
2668cdf0e10cSrcweir sal_uInt8 *pStart = maRawData;
2669cdf0e10cSrcweir // Pointer to Offset-Location in maRawData
2670cdf0e10cSrcweir sal_uInt8* pOfs = maRawData + (mnIMax + 1) * 4;
2671cdf0e10cSrcweir
2672cdf0e10cSrcweir for (mnIdx = 0; mnIdx < mnIMax; ++mnIdx)
2673cdf0e10cSrcweir {
2674cdf0e10cSrcweir unsigned int nOfs = (*(pOfs + mnIdx * nItemSize)) * 2;
2675cdf0e10cSrcweir Entry aEntry(Get_Long(pStart));
2676cdf0e10cSrcweir
2677cdf0e10cSrcweir if (nOfs)
2678cdf0e10cSrcweir {
2679cdf0e10cSrcweir switch (ePLCF)
2680cdf0e10cSrcweir {
2681cdf0e10cSrcweir case CHP:
2682cdf0e10cSrcweir aEntry.mnLen = maRawData[nOfs];
2683cdf0e10cSrcweir aEntry.mpData = maRawData + nOfs + 1;
2684cdf0e10cSrcweir
2685cdf0e10cSrcweir if (aEntry.mnLen && eVersion == ww::eWW2)
2686cdf0e10cSrcweir {
2687cdf0e10cSrcweir Word2CHPX aChpx = ReadWord2Chpx(*pSt, nFilePos + nOfs + 1, static_cast< sal_uInt8 >(aEntry.mnLen));
2688cdf0e10cSrcweir std::vector<sal_uInt8> aSprms = ChpxToSprms(aChpx);
2689cdf0e10cSrcweir aEntry.mnLen = static_cast< sal_uInt16 >(aSprms.size());
2690cdf0e10cSrcweir if (aEntry.mnLen)
2691cdf0e10cSrcweir {
2692cdf0e10cSrcweir aEntry.mpData = new sal_uInt8[aEntry.mnLen];
2693cdf0e10cSrcweir memcpy(aEntry.mpData, &(aSprms[0]), aEntry.mnLen);
2694cdf0e10cSrcweir aEntry.mbMustDelete = true;
2695cdf0e10cSrcweir }
2696cdf0e10cSrcweir }
2697cdf0e10cSrcweir
2698cdf0e10cSrcweir break;
2699cdf0e10cSrcweir case PAP:
2700cdf0e10cSrcweir {
2701cdf0e10cSrcweir sal_uInt8 nDelta = 0;
2702cdf0e10cSrcweir
2703cdf0e10cSrcweir aEntry.mnLen = maRawData[nOfs];
2704cdf0e10cSrcweir if (IsEightPlus(eVersion) && !aEntry.mnLen)
2705cdf0e10cSrcweir {
2706cdf0e10cSrcweir aEntry.mnLen = maRawData[nOfs+1];
2707cdf0e10cSrcweir nDelta++;
2708cdf0e10cSrcweir }
2709cdf0e10cSrcweir
2710cdf0e10cSrcweir aEntry.mnLen *= 2;
2711cdf0e10cSrcweir
2712cdf0e10cSrcweir //stylecode, std/istd
2713cdf0e10cSrcweir if (eVersion == ww::eWW2)
2714cdf0e10cSrcweir {
2715cdf0e10cSrcweir aEntry.mnIStd = *(maRawData+nOfs+1+nDelta);
2716cdf0e10cSrcweir aEntry.mnLen--; //style code
2717cdf0e10cSrcweir aEntry.mnLen-=6; //PHE
2718cdf0e10cSrcweir //skipi stc, len byte + 6 byte PHE
2719cdf0e10cSrcweir aEntry.mpData = maRawData + nOfs + 8;
2720cdf0e10cSrcweir }
2721cdf0e10cSrcweir else
2722cdf0e10cSrcweir {
2723cdf0e10cSrcweir aEntry.mnIStd = SVBT16ToShort(maRawData+nOfs+1+nDelta);
2724cdf0e10cSrcweir aEntry.mnLen-=2; //istd
2725cdf0e10cSrcweir //skip istd, len byte + optional extra len byte
2726cdf0e10cSrcweir aEntry.mpData = maRawData + nOfs + 3 + nDelta;
2727cdf0e10cSrcweir }
2728cdf0e10cSrcweir
2729cdf0e10cSrcweir sal_uInt16 nSpId = aEntry.mnLen ? maSprmParser.GetSprmId(aEntry.mpData) : 0;
2730cdf0e10cSrcweir
2731cdf0e10cSrcweir /*
2732cdf0e10cSrcweir If we replace then we throw away the old data, if we
2733cdf0e10cSrcweir are expanding, then we tack the old data onto the end
2734cdf0e10cSrcweir of the new data
2735cdf0e10cSrcweir */
2736cdf0e10cSrcweir bool bExpand = IsExpandableSprm(nSpId);
2737cdf0e10cSrcweir if (IsReplaceAllSprm(nSpId) || bExpand)
2738cdf0e10cSrcweir {
2739cdf0e10cSrcweir sal_uInt16 nOrigLen = bExpand ? aEntry.mnLen : 0;
2740cdf0e10cSrcweir sal_uInt8 *pOrigData = bExpand ? aEntry.mpData : 0;
2741cdf0e10cSrcweir
2742cdf0e10cSrcweir sal_uInt32 nCurr = pDataSt->Tell();
2743cdf0e10cSrcweir
2744cdf0e10cSrcweir sal_uInt32 nPos = SVBT32ToUInt32(aEntry.mpData + 2);
2745cdf0e10cSrcweir pDataSt->Seek(nPos);
2746cdf0e10cSrcweir *pDataSt >> aEntry.mnLen;
2747cdf0e10cSrcweir aEntry.mpData =
2748cdf0e10cSrcweir new sal_uInt8[aEntry.mnLen + nOrigLen];
2749cdf0e10cSrcweir aEntry.mbMustDelete = true;
2750cdf0e10cSrcweir pDataSt->Read(aEntry.mpData, aEntry.mnLen);
2751cdf0e10cSrcweir
2752cdf0e10cSrcweir pDataSt->Seek( nCurr );
2753cdf0e10cSrcweir
2754cdf0e10cSrcweir if (pOrigData)
2755cdf0e10cSrcweir {
2756cdf0e10cSrcweir memcpy(aEntry.mpData + aEntry.mnLen,
2757cdf0e10cSrcweir pOrigData, nOrigLen);
2758cdf0e10cSrcweir aEntry.mnLen = aEntry.mnLen + nOrigLen;
2759cdf0e10cSrcweir }
2760cdf0e10cSrcweir }
2761cdf0e10cSrcweir }
2762cdf0e10cSrcweir break;
2763cdf0e10cSrcweir default:
2764cdf0e10cSrcweir ASSERT(false, "sweet god, what have you done!");
2765cdf0e10cSrcweir break;
2766cdf0e10cSrcweir }
2767cdf0e10cSrcweir }
2768cdf0e10cSrcweir
2769cdf0e10cSrcweir maEntries.push_back(aEntry);
2770cdf0e10cSrcweir }
2771cdf0e10cSrcweir
2772cdf0e10cSrcweir //one more FC than grrpl entries
2773cdf0e10cSrcweir maEntries.push_back(Entry(Get_Long(pStart)));
2774cdf0e10cSrcweir
2775cdf0e10cSrcweir //#104773#, we expect them sorted, but it appears possible
2776cdf0e10cSrcweir //for them to arive unsorted
2777cdf0e10cSrcweir std::sort(maEntries.begin(), maEntries.end());
2778cdf0e10cSrcweir
2779cdf0e10cSrcweir mnIdx = 0;
2780cdf0e10cSrcweir
2781cdf0e10cSrcweir if (nStartFc >= 0)
2782cdf0e10cSrcweir SeekPos(nStartFc);
2783cdf0e10cSrcweir
2784cdf0e10cSrcweir pSt->Seek(nOldPos);
2785cdf0e10cSrcweir }
2786cdf0e10cSrcweir
Entry(const Entry & rEntry)2787cdf0e10cSrcweir WW8PLCFx_Fc_FKP::WW8Fkp::Entry::Entry(const Entry &rEntry)
2788cdf0e10cSrcweir : mnFC(rEntry.mnFC), mnLen(rEntry.mnLen), mnIStd(rEntry.mnIStd),
2789cdf0e10cSrcweir mbMustDelete(rEntry.mbMustDelete)
2790cdf0e10cSrcweir {
2791cdf0e10cSrcweir if (mbMustDelete)
2792cdf0e10cSrcweir {
2793cdf0e10cSrcweir mpData = new sal_uInt8[mnLen];
2794cdf0e10cSrcweir memcpy(mpData, rEntry.mpData, mnLen);
2795cdf0e10cSrcweir }
2796cdf0e10cSrcweir else
2797cdf0e10cSrcweir mpData = rEntry.mpData;
2798cdf0e10cSrcweir }
2799cdf0e10cSrcweir
2800cdf0e10cSrcweir WW8PLCFx_Fc_FKP::WW8Fkp::Entry&
operator =(const Entry & rEntry)2801cdf0e10cSrcweir WW8PLCFx_Fc_FKP::WW8Fkp::Entry::operator=(const Entry &rEntry)
2802cdf0e10cSrcweir {
2803cdf0e10cSrcweir if (mbMustDelete)
2804cdf0e10cSrcweir delete[] mpData;
2805cdf0e10cSrcweir
2806cdf0e10cSrcweir mnFC = rEntry.mnFC;
2807cdf0e10cSrcweir mnLen = rEntry.mnLen;
2808cdf0e10cSrcweir mnIStd = rEntry.mnIStd;
2809cdf0e10cSrcweir mbMustDelete = rEntry.mbMustDelete;
2810cdf0e10cSrcweir
2811cdf0e10cSrcweir if (mbMustDelete)
2812cdf0e10cSrcweir {
2813cdf0e10cSrcweir mpData = new sal_uInt8[mnLen];
2814cdf0e10cSrcweir memcpy(mpData, rEntry.mpData, mnLen);
2815cdf0e10cSrcweir }
2816cdf0e10cSrcweir else
2817cdf0e10cSrcweir mpData = rEntry.mpData;
2818cdf0e10cSrcweir return *this;
2819cdf0e10cSrcweir }
2820cdf0e10cSrcweir
~Entry()2821cdf0e10cSrcweir WW8PLCFx_Fc_FKP::WW8Fkp::Entry::~Entry()
2822cdf0e10cSrcweir {
2823cdf0e10cSrcweir if (mbMustDelete)
2824cdf0e10cSrcweir delete[] mpData;
2825cdf0e10cSrcweir }
2826cdf0e10cSrcweir
Reset(WW8_FC nFc)2827cdf0e10cSrcweir void WW8PLCFx_Fc_FKP::WW8Fkp::Reset(WW8_FC nFc)
2828cdf0e10cSrcweir {
2829cdf0e10cSrcweir SetIdx(0);
2830cdf0e10cSrcweir if (nFc >= 0)
2831cdf0e10cSrcweir SeekPos(nFc);
2832cdf0e10cSrcweir }
2833cdf0e10cSrcweir
SeekPos(WW8_FC nFc)2834cdf0e10cSrcweir bool WW8PLCFx_Fc_FKP::WW8Fkp::SeekPos(WW8_FC nFc)
2835cdf0e10cSrcweir {
2836cdf0e10cSrcweir if (nFc < maEntries[0].mnFC)
2837cdf0e10cSrcweir {
2838cdf0e10cSrcweir mnIdx = 0;
2839cdf0e10cSrcweir return false; // Nicht gefunden: nPos unterhalb kleinstem Eintrag
2840cdf0e10cSrcweir }
2841cdf0e10cSrcweir
2842cdf0e10cSrcweir // Search from beginning?
2843cdf0e10cSrcweir if ((1 > mnIdx) || (nFc < maEntries[mnIdx-1].mnFC))
2844cdf0e10cSrcweir mnIdx = 1;
2845cdf0e10cSrcweir
2846cdf0e10cSrcweir sal_uInt8 nI = mnIdx ? mnIdx : 1;
2847cdf0e10cSrcweir sal_uInt8 nEnd = mnIMax;
2848cdf0e10cSrcweir
2849cdf0e10cSrcweir for(sal_uInt8 n = (1==mnIdx ? 1 : 2); n; --n )
2850cdf0e10cSrcweir {
2851cdf0e10cSrcweir for( ; nI <=nEnd; ++nI)
2852cdf0e10cSrcweir { // Suchen mit um 1 erhoehtem Index
2853cdf0e10cSrcweir if (nFc < maEntries[nI].mnFC)
2854cdf0e10cSrcweir { // Position gefunden
2855cdf0e10cSrcweir mnIdx = nI - 1; // nI - 1 ist der richtige Index
2856cdf0e10cSrcweir return true; // ... und fertig
2857cdf0e10cSrcweir }
2858cdf0e10cSrcweir }
2859cdf0e10cSrcweir nI = 1;
2860cdf0e10cSrcweir nEnd = mnIdx-1;
2861cdf0e10cSrcweir }
2862cdf0e10cSrcweir mnIdx = mnIMax; // Nicht gefunden, groesser als alle Eintraege
2863cdf0e10cSrcweir return false;
2864cdf0e10cSrcweir }
2865cdf0e10cSrcweir
Get(WW8_FC & rStart,WW8_FC & rEnd,sal_Int32 & rLen) const2866cdf0e10cSrcweir sal_uInt8* WW8PLCFx_Fc_FKP::WW8Fkp::Get(WW8_FC& rStart, WW8_FC& rEnd, sal_Int32& rLen)
2867cdf0e10cSrcweir const
2868cdf0e10cSrcweir {
2869cdf0e10cSrcweir rLen = 0;
2870cdf0e10cSrcweir
2871cdf0e10cSrcweir if (mnIdx >= mnIMax)
2872cdf0e10cSrcweir {
2873cdf0e10cSrcweir rStart = WW8_FC_MAX;
2874cdf0e10cSrcweir return 0;
2875cdf0e10cSrcweir }
2876cdf0e10cSrcweir
2877cdf0e10cSrcweir rStart = maEntries[mnIdx].mnFC;
2878cdf0e10cSrcweir rEnd = maEntries[mnIdx + 1].mnFC;
2879cdf0e10cSrcweir
2880cdf0e10cSrcweir sal_uInt8* pSprms = GetLenAndIStdAndSprms( rLen );
2881cdf0e10cSrcweir return pSprms;
2882cdf0e10cSrcweir }
2883cdf0e10cSrcweir
SetIdx(sal_uInt8 nI)2884cdf0e10cSrcweir bool WW8PLCFx_Fc_FKP::WW8Fkp::SetIdx(sal_uInt8 nI)
2885cdf0e10cSrcweir {
2886cdf0e10cSrcweir if (nI < mnIMax)
2887cdf0e10cSrcweir {
2888cdf0e10cSrcweir mnIdx = nI;
2889cdf0e10cSrcweir return true;
2890cdf0e10cSrcweir }
2891cdf0e10cSrcweir return false;
2892cdf0e10cSrcweir }
2893cdf0e10cSrcweir
GetLenAndIStdAndSprms(sal_Int32 & rLen) const2894cdf0e10cSrcweir sal_uInt8* WW8PLCFx_Fc_FKP::WW8Fkp::GetLenAndIStdAndSprms(sal_Int32& rLen) const
2895cdf0e10cSrcweir {
2896cdf0e10cSrcweir rLen = maEntries[mnIdx].mnLen;
2897cdf0e10cSrcweir return maEntries[mnIdx].mpData;
2898cdf0e10cSrcweir }
2899cdf0e10cSrcweir
HasSprm(sal_uInt16 nId)2900cdf0e10cSrcweir const sal_uInt8* WW8PLCFx_Fc_FKP::WW8Fkp::HasSprm( sal_uInt16 nId )
2901cdf0e10cSrcweir {
2902cdf0e10cSrcweir if (mnIdx >= mnIMax)
2903cdf0e10cSrcweir return 0;
2904cdf0e10cSrcweir
2905cdf0e10cSrcweir sal_Int32 nLen;
2906cdf0e10cSrcweir sal_uInt8* pSprms = GetLenAndIStdAndSprms( nLen );
2907cdf0e10cSrcweir
2908cdf0e10cSrcweir WW8SprmIter aIter(pSprms, nLen, maSprmParser);
2909cdf0e10cSrcweir return aIter.FindSprm(nId);
2910cdf0e10cSrcweir }
2911cdf0e10cSrcweir
HasSprm(sal_uInt16 nId,std::vector<const sal_uInt8 * > & rResult)2912cdf0e10cSrcweir bool WW8PLCFx_Fc_FKP::WW8Fkp::HasSprm(sal_uInt16 nId,
2913cdf0e10cSrcweir std::vector<const sal_uInt8 *> &rResult)
2914cdf0e10cSrcweir {
2915cdf0e10cSrcweir if (mnIdx >= mnIMax)
2916cdf0e10cSrcweir return false;
2917cdf0e10cSrcweir
2918cdf0e10cSrcweir sal_Int32 nLen;
2919cdf0e10cSrcweir sal_uInt8* pSprms = GetLenAndIStdAndSprms( nLen );
2920cdf0e10cSrcweir
2921cdf0e10cSrcweir WW8SprmIter aIter(pSprms, nLen, maSprmParser);
2922cdf0e10cSrcweir
2923cdf0e10cSrcweir while(aIter.GetSprms())
2924cdf0e10cSrcweir {
2925cdf0e10cSrcweir if (aIter.GetAktId() == nId)
2926cdf0e10cSrcweir rResult.push_back(aIter.GetAktParams());
2927cdf0e10cSrcweir aIter++;
2928cdf0e10cSrcweir };
2929cdf0e10cSrcweir return !rResult.empty();
2930cdf0e10cSrcweir }
2931cdf0e10cSrcweir
2932cdf0e10cSrcweir //-----------------------------------------
GetSprms(WW8PLCFxDesc * p)2933cdf0e10cSrcweir void WW8PLCFx::GetSprms( WW8PLCFxDesc* p )
2934cdf0e10cSrcweir {
2935cdf0e10cSrcweir ASSERT( !this, "Falsches GetSprms gerufen" );
2936cdf0e10cSrcweir p->nStartPos = p->nEndPos = WW8_CP_MAX;
2937cdf0e10cSrcweir p->pMemPos = 0;
2938cdf0e10cSrcweir p->nSprmsLen = 0;
2939cdf0e10cSrcweir p->bRealLineEnd = false;
2940cdf0e10cSrcweir return;
2941cdf0e10cSrcweir }
2942cdf0e10cSrcweir
GetNoSprms(WW8_CP & rStart,WW8_CP & rEnd,sal_Int32 & rLen)2943cdf0e10cSrcweir long WW8PLCFx::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32& rLen )
2944cdf0e10cSrcweir {
2945cdf0e10cSrcweir ASSERT( !this, "Falsches GetNoSprms gerufen" );
2946cdf0e10cSrcweir rStart = rEnd = WW8_CP_MAX;
2947cdf0e10cSrcweir rLen = 0;
2948cdf0e10cSrcweir return 0;
2949cdf0e10cSrcweir }
2950cdf0e10cSrcweir
2951cdf0e10cSrcweir // ...Idx2: Default: ignorieren
GetIdx2() const2952cdf0e10cSrcweir sal_uLong WW8PLCFx::GetIdx2() const
2953cdf0e10cSrcweir {
2954cdf0e10cSrcweir return 0;
2955cdf0e10cSrcweir }
2956cdf0e10cSrcweir
SetIdx2(sal_uLong)2957cdf0e10cSrcweir void WW8PLCFx::SetIdx2(sal_uLong )
2958cdf0e10cSrcweir {
2959cdf0e10cSrcweir }
2960cdf0e10cSrcweir
2961cdf0e10cSrcweir class SamePos :
2962cdf0e10cSrcweir public std::unary_function<const WW8PLCFx_Fc_FKP::WW8Fkp *, bool>
2963cdf0e10cSrcweir {
2964cdf0e10cSrcweir private:
2965cdf0e10cSrcweir long mnPo;
2966cdf0e10cSrcweir public:
SamePos(long nPo)2967cdf0e10cSrcweir SamePos(long nPo) : mnPo(nPo) {};
operator ()(const WW8PLCFx_Fc_FKP::WW8Fkp * pFkp)2968cdf0e10cSrcweir bool operator()(const WW8PLCFx_Fc_FKP::WW8Fkp *pFkp)
2969cdf0e10cSrcweir {return mnPo == pFkp->GetFilePos();}
2970cdf0e10cSrcweir };
2971cdf0e10cSrcweir
2972cdf0e10cSrcweir //-----------------------------------------
NewFkp()2973cdf0e10cSrcweir bool WW8PLCFx_Fc_FKP::NewFkp()
2974cdf0e10cSrcweir {
2975cdf0e10cSrcweir WW8_CP nPLCFStart, nPLCFEnd;
2976cdf0e10cSrcweir void* pPage;
2977cdf0e10cSrcweir
2978cdf0e10cSrcweir static const int WW8FkpSizeTabVer2[ PLCF_END ] =
2979cdf0e10cSrcweir {
2980cdf0e10cSrcweir 1, 1, 0 /*, 0, 0, 0*/
2981cdf0e10cSrcweir };
2982cdf0e10cSrcweir static const int WW8FkpSizeTabVer6[ PLCF_END ] =
2983cdf0e10cSrcweir {
2984cdf0e10cSrcweir 1, 7, 0 /*, 0, 0, 0*/
2985cdf0e10cSrcweir };
2986cdf0e10cSrcweir static const int WW8FkpSizeTabVer8[ PLCF_END ] =
2987cdf0e10cSrcweir {
2988cdf0e10cSrcweir 1, 13, 0 /*, 0, 0, 0*/
2989cdf0e10cSrcweir };
2990cdf0e10cSrcweir const int* pFkpSizeTab;
2991cdf0e10cSrcweir
2992cdf0e10cSrcweir switch (GetFIBVersion())
2993cdf0e10cSrcweir {
2994cdf0e10cSrcweir case ww::eWW2:
2995cdf0e10cSrcweir pFkpSizeTab = WW8FkpSizeTabVer2;
2996cdf0e10cSrcweir break;
2997cdf0e10cSrcweir case ww::eWW6:
2998cdf0e10cSrcweir case ww::eWW7:
2999cdf0e10cSrcweir pFkpSizeTab = WW8FkpSizeTabVer6;
3000cdf0e10cSrcweir break;
3001cdf0e10cSrcweir case ww::eWW8:
3002cdf0e10cSrcweir pFkpSizeTab = WW8FkpSizeTabVer8;
3003cdf0e10cSrcweir break;
3004cdf0e10cSrcweir default:
3005cdf0e10cSrcweir // Programm-Fehler!
3006cdf0e10cSrcweir ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
3007cdf0e10cSrcweir return false;
3008cdf0e10cSrcweir }
3009cdf0e10cSrcweir
3010cdf0e10cSrcweir if (!pPLCF->Get( nPLCFStart, nPLCFEnd, pPage ))
3011cdf0e10cSrcweir {
3012cdf0e10cSrcweir pFkp = 0;
3013cdf0e10cSrcweir return false; // PLCF fertig abgearbeitet
3014cdf0e10cSrcweir }
3015cdf0e10cSrcweir (*pPLCF)++;
3016cdf0e10cSrcweir long nPo = SVBT16ToShort( (sal_uInt8 *)pPage );
3017cdf0e10cSrcweir nPo <<= 9; // shift als LONG
3018cdf0e10cSrcweir
3019cdf0e10cSrcweir long nAktFkpFilePos = pFkp ? pFkp->GetFilePos() : -1;
3020cdf0e10cSrcweir if (nAktFkpFilePos == nPo)
3021cdf0e10cSrcweir pFkp->Reset(GetStartFc()); // #79464# //
3022cdf0e10cSrcweir else
3023cdf0e10cSrcweir {
3024cdf0e10cSrcweir myiter aIter =
3025cdf0e10cSrcweir std::find_if(maFkpCache.begin(), maFkpCache.end(), SamePos(nPo));
3026cdf0e10cSrcweir if (aIter != maFkpCache.end())
3027cdf0e10cSrcweir {
3028cdf0e10cSrcweir pFkp = *aIter;
3029cdf0e10cSrcweir pFkp->Reset(GetStartFc());
3030cdf0e10cSrcweir }
3031cdf0e10cSrcweir else if (0 != (pFkp = new WW8Fkp(GetFIBVersion(), pFKPStrm, pDataStrm, nPo,
3032cdf0e10cSrcweir pFkpSizeTab[ ePLCF ], ePLCF, GetStartFc())))
3033cdf0e10cSrcweir {
3034cdf0e10cSrcweir maFkpCache.push_back(pFkp);
3035cdf0e10cSrcweir
3036cdf0e10cSrcweir if (maFkpCache.size() > eMaxCache)
3037cdf0e10cSrcweir {
3038cdf0e10cSrcweir delete maFkpCache.front();
3039cdf0e10cSrcweir maFkpCache.pop_front();
3040cdf0e10cSrcweir }
3041cdf0e10cSrcweir }
3042cdf0e10cSrcweir }
3043cdf0e10cSrcweir
3044cdf0e10cSrcweir SetStartFc( -1 ); // Nur das erste Mal
3045cdf0e10cSrcweir return true;
3046cdf0e10cSrcweir }
3047cdf0e10cSrcweir
WW8PLCFx_Fc_FKP(SvStream * pSt,SvStream * pTblSt,SvStream * pDataSt,const WW8Fib & rFib,ePLCFT ePl,WW8_FC nStartFcL)3048cdf0e10cSrcweir WW8PLCFx_Fc_FKP::WW8PLCFx_Fc_FKP(SvStream* pSt, SvStream* pTblSt,
3049cdf0e10cSrcweir SvStream* pDataSt, const WW8Fib& rFib, ePLCFT ePl, WW8_FC nStartFcL)
3050cdf0e10cSrcweir : WW8PLCFx(rFib.GetFIBVersion(), true), pFKPStrm(pSt), pDataStrm(pDataSt),
3051cdf0e10cSrcweir pFkp(0), ePLCF(ePl), pPCDAttrs(0)
3052cdf0e10cSrcweir {
3053cdf0e10cSrcweir SetStartFc(nStartFcL);
3054cdf0e10cSrcweir long nLenStruct = (8 > rFib.nVersion) ? 2 : 4;
3055cdf0e10cSrcweir if (ePl == CHP)
3056cdf0e10cSrcweir {
3057cdf0e10cSrcweir pPLCF = new WW8PLCF(pTblSt, rFib.fcPlcfbteChpx, rFib.lcbPlcfbteChpx,
3058cdf0e10cSrcweir nLenStruct, GetStartFc(), rFib.pnChpFirst, rFib.cpnBteChp);
3059cdf0e10cSrcweir }
3060cdf0e10cSrcweir else
3061cdf0e10cSrcweir {
3062cdf0e10cSrcweir pPLCF = new WW8PLCF(pTblSt, rFib.fcPlcfbtePapx, rFib.lcbPlcfbtePapx,
3063cdf0e10cSrcweir nLenStruct, GetStartFc(), rFib.pnPapFirst, rFib.cpnBtePap);
3064cdf0e10cSrcweir }
3065cdf0e10cSrcweir }
3066cdf0e10cSrcweir
~WW8PLCFx_Fc_FKP()3067cdf0e10cSrcweir WW8PLCFx_Fc_FKP::~WW8PLCFx_Fc_FKP()
3068cdf0e10cSrcweir {
3069cdf0e10cSrcweir myiter aEnd = maFkpCache.end();
3070cdf0e10cSrcweir for (myiter aIter = maFkpCache.begin(); aIter != aEnd; ++aIter)
3071cdf0e10cSrcweir delete *aIter;
3072cdf0e10cSrcweir delete pPLCF;
3073cdf0e10cSrcweir delete pPCDAttrs;
3074cdf0e10cSrcweir }
3075cdf0e10cSrcweir
HasValidPLCF()30762726b7b2SOliver-Rainer Wittmann bool WW8PLCFx_Fc_FKP::HasValidPLCF()
30772726b7b2SOliver-Rainer Wittmann {
30782726b7b2SOliver-Rainer Wittmann return pPLCF == 0 || pPLCF->IsValid();
30792726b7b2SOliver-Rainer Wittmann }
30802726b7b2SOliver-Rainer Wittmann
GetIdx() const3081cdf0e10cSrcweir sal_uLong WW8PLCFx_Fc_FKP::GetIdx() const
3082cdf0e10cSrcweir {
3083cdf0e10cSrcweir sal_uLong u = pPLCF->GetIdx() << 8;
3084cdf0e10cSrcweir if (pFkp)
3085cdf0e10cSrcweir u |= pFkp->GetIdx();
3086cdf0e10cSrcweir return u;
3087cdf0e10cSrcweir }
3088cdf0e10cSrcweir
SetIdx(sal_uLong nIdx)3089cdf0e10cSrcweir void WW8PLCFx_Fc_FKP::SetIdx( sal_uLong nIdx )
3090cdf0e10cSrcweir {
3091cdf0e10cSrcweir if( !( nIdx & 0xffffff00L ) )
3092cdf0e10cSrcweir {
3093cdf0e10cSrcweir pPLCF->SetIdx( nIdx >> 8 );
3094cdf0e10cSrcweir pFkp = 0;
3095cdf0e10cSrcweir }
3096cdf0e10cSrcweir else
3097cdf0e10cSrcweir { //Es gab einen Fkp
3098cdf0e10cSrcweir //Lese PLCF um 1 Pos zurueck, um die Adresse des Fkp wiederzubekommen
3099cdf0e10cSrcweir pPLCF->SetIdx( ( nIdx >> 8 ) - 1 );
3100cdf0e10cSrcweir if (NewFkp()) // und lese Fkp wieder ein
3101cdf0e10cSrcweir {
3102cdf0e10cSrcweir sal_uInt8 nFkpIdx = static_cast<sal_uInt8>(nIdx & 0xff);
3103cdf0e10cSrcweir pFkp->SetIdx(nFkpIdx); // Dann stelle Fkp-Pos wieder ein
3104cdf0e10cSrcweir }
3105cdf0e10cSrcweir }
3106cdf0e10cSrcweir }
3107cdf0e10cSrcweir
SeekPos(WW8_FC nFcPos)3108cdf0e10cSrcweir bool WW8PLCFx_Fc_FKP::SeekPos(WW8_FC nFcPos)
3109cdf0e10cSrcweir {
3110cdf0e10cSrcweir // StartPos for next Where()
3111cdf0e10cSrcweir SetStartFc( nFcPos );
3112cdf0e10cSrcweir
3113cdf0e10cSrcweir // find StartPos for next pPLCF->Get()
3114cdf0e10cSrcweir bool bRet = pPLCF->SeekPos(nFcPos);
3115cdf0e10cSrcweir
3116cdf0e10cSrcweir // make FKP invalid?
3117cdf0e10cSrcweir WW8_CP nPLCFStart, nPLCFEnd;
3118cdf0e10cSrcweir void* pPage;
3119cdf0e10cSrcweir if( pFkp && pPLCF->Get( nPLCFStart, nPLCFEnd, pPage ) )
3120cdf0e10cSrcweir {
3121cdf0e10cSrcweir long nPo = SVBT16ToShort( (sal_uInt8 *)pPage );
3122cdf0e10cSrcweir nPo <<= 9; // shift als LONG
3123cdf0e10cSrcweir if (nPo != pFkp->GetFilePos())
3124cdf0e10cSrcweir pFkp = 0;
3125cdf0e10cSrcweir else
3126cdf0e10cSrcweir pFkp->SeekPos( nFcPos );
3127cdf0e10cSrcweir }
3128cdf0e10cSrcweir return bRet;
3129cdf0e10cSrcweir }
3130cdf0e10cSrcweir
Where()3131cdf0e10cSrcweir WW8_FC WW8PLCFx_Fc_FKP::Where()
3132cdf0e10cSrcweir {
3133cdf0e10cSrcweir if( !pFkp )
3134cdf0e10cSrcweir {
3135cdf0e10cSrcweir if( !NewFkp() )
3136cdf0e10cSrcweir return WW8_FC_MAX;
3137cdf0e10cSrcweir }
3138cdf0e10cSrcweir WW8_FC nP = pFkp->Where();
3139cdf0e10cSrcweir if( nP != WW8_FC_MAX )
3140cdf0e10cSrcweir return nP;
3141cdf0e10cSrcweir
3142cdf0e10cSrcweir pFkp = 0; // FKP beendet -> hole neuen
3143cdf0e10cSrcweir return Where(); // am einfachsten rekursiv
3144cdf0e10cSrcweir }
3145cdf0e10cSrcweir
GetSprmsAndPos(WW8_FC & rStart,WW8_FC & rEnd,sal_Int32 & rLen)3146cdf0e10cSrcweir sal_uInt8* WW8PLCFx_Fc_FKP::GetSprmsAndPos(WW8_FC& rStart, WW8_FC& rEnd, sal_Int32& rLen)
3147cdf0e10cSrcweir {
3148cdf0e10cSrcweir rLen = 0; // Default
3149cdf0e10cSrcweir rStart = rEnd = WW8_FC_MAX;
3150cdf0e10cSrcweir
3151cdf0e10cSrcweir if( !pFkp ) // Fkp not there ?
3152cdf0e10cSrcweir {
3153cdf0e10cSrcweir if( !NewFkp() )
3154cdf0e10cSrcweir return 0;
3155cdf0e10cSrcweir }
3156cdf0e10cSrcweir
3157cdf0e10cSrcweir sal_uInt8* pPos = pFkp->Get( rStart, rEnd, rLen );
3158cdf0e10cSrcweir if( rStart == WW8_FC_MAX ) //Not found
3159cdf0e10cSrcweir return 0;
3160cdf0e10cSrcweir return pPos;
3161cdf0e10cSrcweir }
3162cdf0e10cSrcweir
operator ++(int)3163cdf0e10cSrcweir WW8PLCFx& WW8PLCFx_Fc_FKP::operator ++( int )
3164cdf0e10cSrcweir {
3165cdf0e10cSrcweir if( !pFkp )
3166cdf0e10cSrcweir {
3167cdf0e10cSrcweir if( !NewFkp() )
3168cdf0e10cSrcweir return *this;
3169cdf0e10cSrcweir }
3170cdf0e10cSrcweir
3171cdf0e10cSrcweir (*pFkp)++;
3172cdf0e10cSrcweir if( pFkp->Where() == WW8_FC_MAX )
3173cdf0e10cSrcweir NewFkp();
3174cdf0e10cSrcweir
3175cdf0e10cSrcweir return *this;
3176cdf0e10cSrcweir }
3177cdf0e10cSrcweir
GetIstd() const3178cdf0e10cSrcweir sal_uInt16 WW8PLCFx_Fc_FKP::GetIstd() const
3179cdf0e10cSrcweir {
3180cdf0e10cSrcweir return pFkp ? pFkp->GetIstd() : 0xFFFF;
3181cdf0e10cSrcweir }
3182cdf0e10cSrcweir
GetPCDSprms(WW8PLCFxDesc & rDesc)3183cdf0e10cSrcweir void WW8PLCFx_Fc_FKP::GetPCDSprms( WW8PLCFxDesc& rDesc )
3184cdf0e10cSrcweir {
3185cdf0e10cSrcweir rDesc.pMemPos = 0;
3186cdf0e10cSrcweir rDesc.nSprmsLen = 0;
3187cdf0e10cSrcweir if( pPCDAttrs )
3188cdf0e10cSrcweir {
3189cdf0e10cSrcweir if( !pFkp )
3190cdf0e10cSrcweir {
3191cdf0e10cSrcweir DBG_WARNING(
3192cdf0e10cSrcweir "+Problem: GetPCDSprms: NewFkp necessay (not possible!)" );
3193cdf0e10cSrcweir if( !NewFkp() )
3194cdf0e10cSrcweir return;
3195cdf0e10cSrcweir }
3196cdf0e10cSrcweir pPCDAttrs->GetSprms(&rDesc);
3197cdf0e10cSrcweir }
3198cdf0e10cSrcweir }
3199cdf0e10cSrcweir
HasSprm(sal_uInt16 nId)3200cdf0e10cSrcweir const sal_uInt8* WW8PLCFx_Fc_FKP::HasSprm( sal_uInt16 nId )
3201cdf0e10cSrcweir {
3202cdf0e10cSrcweir // const waere schoener, aber dafuer muesste NewFkp() ersetzt werden oder
3203cdf0e10cSrcweir // wegfallen
3204cdf0e10cSrcweir if( !pFkp )
3205cdf0e10cSrcweir {
3206cdf0e10cSrcweir DBG_WARNING( "+Motz: HasSprm: NewFkp noetig ( kein const moeglich )" );
3207cdf0e10cSrcweir // Passiert bei BugDoc 31722
3208cdf0e10cSrcweir if( !NewFkp() )
3209cdf0e10cSrcweir return 0;
3210cdf0e10cSrcweir }
3211cdf0e10cSrcweir
3212cdf0e10cSrcweir const sal_uInt8* pRes = pFkp->HasSprm( nId );
3213cdf0e10cSrcweir
3214cdf0e10cSrcweir if( !pRes )
3215cdf0e10cSrcweir {
3216cdf0e10cSrcweir WW8PLCFxDesc aDesc;
3217cdf0e10cSrcweir GetPCDSprms( aDesc );
3218cdf0e10cSrcweir
3219cdf0e10cSrcweir if (aDesc.pMemPos)
3220cdf0e10cSrcweir {
3221cdf0e10cSrcweir WW8SprmIter aIter(aDesc.pMemPos, aDesc.nSprmsLen,
3222cdf0e10cSrcweir pFkp->GetSprmParser());
3223cdf0e10cSrcweir pRes = aIter.FindSprm(nId);
3224cdf0e10cSrcweir }
3225cdf0e10cSrcweir }
3226cdf0e10cSrcweir
3227cdf0e10cSrcweir return pRes;
3228cdf0e10cSrcweir }
3229cdf0e10cSrcweir
HasSprm(sal_uInt16 nId,std::vector<const sal_uInt8 * > & rResult)3230cdf0e10cSrcweir bool WW8PLCFx_Fc_FKP::HasSprm(sal_uInt16 nId, std::vector<const sal_uInt8 *> &rResult)
3231cdf0e10cSrcweir {
3232cdf0e10cSrcweir // const waere schoener, aber dafuer muesste NewFkp() ersetzt werden oder
3233cdf0e10cSrcweir // wegfallen
3234cdf0e10cSrcweir if (!pFkp)
3235cdf0e10cSrcweir {
3236cdf0e10cSrcweir DBG_WARNING( "+Motz: HasSprm: NewFkp noetig ( kein const moeglich )" );
3237cdf0e10cSrcweir // Passiert bei BugDoc 31722
3238cdf0e10cSrcweir if( !NewFkp() )
3239cdf0e10cSrcweir return 0;
3240cdf0e10cSrcweir }
3241cdf0e10cSrcweir
3242cdf0e10cSrcweir pFkp->HasSprm(nId, rResult);
3243cdf0e10cSrcweir
3244cdf0e10cSrcweir WW8PLCFxDesc aDesc;
3245cdf0e10cSrcweir GetPCDSprms( aDesc );
3246cdf0e10cSrcweir
3247cdf0e10cSrcweir if (aDesc.pMemPos)
3248cdf0e10cSrcweir {
3249cdf0e10cSrcweir WW8SprmIter aIter(aDesc.pMemPos, aDesc.nSprmsLen,
3250cdf0e10cSrcweir pFkp->GetSprmParser());
3251cdf0e10cSrcweir while(aIter.GetSprms())
3252cdf0e10cSrcweir {
3253cdf0e10cSrcweir if (aIter.GetAktId() == nId)
3254cdf0e10cSrcweir rResult.push_back(aIter.GetAktParams());
3255cdf0e10cSrcweir aIter++;
3256cdf0e10cSrcweir };
3257cdf0e10cSrcweir }
3258cdf0e10cSrcweir return !rResult.empty();
3259cdf0e10cSrcweir }
3260cdf0e10cSrcweir
3261cdf0e10cSrcweir //-----------------------------------------
3262cdf0e10cSrcweir
WW8PLCFx_Cp_FKP(SvStream * pSt,SvStream * pTblSt,SvStream * pDataSt,const WW8ScannerBase & rBase,ePLCFT ePl)3263cdf0e10cSrcweir WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTblSt,
3264cdf0e10cSrcweir SvStream* pDataSt, const WW8ScannerBase& rBase, ePLCFT ePl )
3265cdf0e10cSrcweir : WW8PLCFx_Fc_FKP(pSt, pTblSt, pDataSt, *rBase.pWw8Fib, ePl,
3266cdf0e10cSrcweir rBase.WW8Cp2Fc(0)), rSBase(rBase), nAttrStart(-1), nAttrEnd(-1),
3267cdf0e10cSrcweir bLineEnd(false),
3268cdf0e10cSrcweir bComplex( (7 < rBase.pWw8Fib->nVersion) || (0 != rBase.pWw8Fib->fComplex) )
3269cdf0e10cSrcweir {
3270cdf0e10cSrcweir ResetAttrStartEnd();
3271cdf0e10cSrcweir
3272cdf0e10cSrcweir pPcd = rSBase.pPiecePLCF ? new WW8PLCFx_PCD(GetFIBVersion(),
3273cdf0e10cSrcweir rBase.pPiecePLCF, 0, IsSevenMinus(GetFIBVersion())) : 0;
3274cdf0e10cSrcweir
3275cdf0e10cSrcweir /*
3276cdf0e10cSrcweir Make a copy of the piece attributes for so that the calls to HasSprm on a
3277cdf0e10cSrcweir Fc_FKP will be able to take into account the current piece attributes,
3278cdf0e10cSrcweir despite the fact that such attributes can only be found through a cp based
3279cdf0e10cSrcweir mechanism.
3280cdf0e10cSrcweir */
3281cdf0e10cSrcweir if (pPcd)
3282cdf0e10cSrcweir {
3283cdf0e10cSrcweir pPCDAttrs = rSBase.pPLCFx_PCDAttrs ? new WW8PLCFx_PCDAttrs(
3284cdf0e10cSrcweir rSBase.pWw8Fib->GetFIBVersion(), pPcd, &rSBase) : 0;
3285cdf0e10cSrcweir }
3286cdf0e10cSrcweir
3287cdf0e10cSrcweir pPieceIter = rSBase.pPieceIter;
3288cdf0e10cSrcweir }
3289cdf0e10cSrcweir
~WW8PLCFx_Cp_FKP()3290cdf0e10cSrcweir WW8PLCFx_Cp_FKP::~WW8PLCFx_Cp_FKP()
3291cdf0e10cSrcweir {
3292cdf0e10cSrcweir delete pPcd;
3293cdf0e10cSrcweir }
3294cdf0e10cSrcweir
ResetAttrStartEnd()3295cdf0e10cSrcweir void WW8PLCFx_Cp_FKP::ResetAttrStartEnd()
3296cdf0e10cSrcweir {
3297cdf0e10cSrcweir nAttrStart = -1;
3298cdf0e10cSrcweir nAttrEnd = -1;
3299cdf0e10cSrcweir bLineEnd = false;
3300cdf0e10cSrcweir }
3301cdf0e10cSrcweir
GetPCDIMax() const3302cdf0e10cSrcweir sal_uLong WW8PLCFx_Cp_FKP::GetPCDIMax() const
3303cdf0e10cSrcweir {
3304cdf0e10cSrcweir return pPcd ? pPcd->GetIMax() : 0;
3305cdf0e10cSrcweir }
3306cdf0e10cSrcweir
GetPCDIdx() const3307cdf0e10cSrcweir sal_uLong WW8PLCFx_Cp_FKP::GetPCDIdx() const
3308cdf0e10cSrcweir {
3309cdf0e10cSrcweir return pPcd ? pPcd->GetIdx() : 0;
3310cdf0e10cSrcweir }
3311cdf0e10cSrcweir
SetPCDIdx(sal_uLong nIdx)3312cdf0e10cSrcweir void WW8PLCFx_Cp_FKP::SetPCDIdx( sal_uLong nIdx )
3313cdf0e10cSrcweir {
3314cdf0e10cSrcweir if( pPcd )
3315cdf0e10cSrcweir pPcd->SetIdx( nIdx );
3316cdf0e10cSrcweir }
3317cdf0e10cSrcweir
SeekPos(WW8_CP nCpPos)3318cdf0e10cSrcweir bool WW8PLCFx_Cp_FKP::SeekPos(WW8_CP nCpPos)
3319cdf0e10cSrcweir {
3320cdf0e10cSrcweir if( pPcd ) // Complex
3321cdf0e10cSrcweir {
3322cdf0e10cSrcweir if( !pPcd->SeekPos( nCpPos ) ) // Piece setzen
3323cdf0e10cSrcweir return false;
3324cdf0e10cSrcweir if (pPCDAttrs && !pPCDAttrs->GetIter()->SeekPos(nCpPos))
3325cdf0e10cSrcweir return false;
3326cdf0e10cSrcweir return WW8PLCFx_Fc_FKP::SeekPos(pPcd->AktPieceStartCp2Fc(nCpPos));
3327cdf0e10cSrcweir }
3328cdf0e10cSrcweir // KEINE Piece-Table !!!
3329cdf0e10cSrcweir return WW8PLCFx_Fc_FKP::SeekPos( rSBase.WW8Cp2Fc(nCpPos) );
3330cdf0e10cSrcweir }
3331cdf0e10cSrcweir
Where()3332cdf0e10cSrcweir WW8_CP WW8PLCFx_Cp_FKP::Where()
3333cdf0e10cSrcweir {
3334cdf0e10cSrcweir WW8_FC nFc = WW8PLCFx_Fc_FKP::Where();
3335cdf0e10cSrcweir if( pPcd )
3336cdf0e10cSrcweir return pPcd->AktPieceStartFc2Cp( nFc ); // Piece ermitteln
3337cdf0e10cSrcweir return rSBase.WW8Fc2Cp( nFc ); // KEINE Piece-Table !!!
3338cdf0e10cSrcweir }
3339cdf0e10cSrcweir
GetSprms(WW8PLCFxDesc * p)3340cdf0e10cSrcweir void WW8PLCFx_Cp_FKP::GetSprms(WW8PLCFxDesc* p)
3341cdf0e10cSrcweir {
3342cdf0e10cSrcweir WW8_CP nOrigCp = p->nStartPos;
3343cdf0e10cSrcweir
3344cdf0e10cSrcweir if (!GetDirty()) //Normal case
3345cdf0e10cSrcweir {
3346cdf0e10cSrcweir p->pMemPos = WW8PLCFx_Fc_FKP::GetSprmsAndPos(p->nStartPos, p->nEndPos,
3347cdf0e10cSrcweir p->nSprmsLen);
3348cdf0e10cSrcweir }
3349cdf0e10cSrcweir else
3350cdf0e10cSrcweir {
3351cdf0e10cSrcweir /*
3352cdf0e10cSrcweir #93702#
3353cdf0e10cSrcweir For the odd case where we have a location in a fastsaved file which
3354cdf0e10cSrcweir does not have an entry in the FKP, perhaps its para end is in the next
3355cdf0e10cSrcweir piece, or perhaps the cp just doesn't exist at all in this document.
3356cdf0e10cSrcweir AdvSprm doesn't know so it sets the PLCF as dirty and we figure out
3357cdf0e10cSrcweir in this method what the situation is
3358cdf0e10cSrcweir
3359cdf0e10cSrcweir It doesn't exist then the piece iterator will not be able to find it.
3360cdf0e10cSrcweir Otherwise our cool fastsave algorithm can be brought to bear on the
3361cdf0e10cSrcweir problem.
3362cdf0e10cSrcweir */
3363cdf0e10cSrcweir if( !pPieceIter )
3364cdf0e10cSrcweir return;
3365cdf0e10cSrcweir sal_uLong nOldPos = pPieceIter->GetIdx();
3366cdf0e10cSrcweir bool bOk = pPieceIter->SeekPos(nOrigCp);
3367cdf0e10cSrcweir pPieceIter->SetIdx( nOldPos );
3368cdf0e10cSrcweir if (!bOk)
3369cdf0e10cSrcweir return;
3370cdf0e10cSrcweir }
3371cdf0e10cSrcweir
3372cdf0e10cSrcweir if( pPcd ) // Piece-Table vorhanden !!!
3373cdf0e10cSrcweir {
3374cdf0e10cSrcweir // Init ( noch kein ++ gerufen )
3375cdf0e10cSrcweir if( (nAttrStart > nAttrEnd) || (nAttrStart == -1) )
3376cdf0e10cSrcweir {
3377cdf0e10cSrcweir p->bRealLineEnd = (ePLCF == PAP);
3378cdf0e10cSrcweir
3379cdf0e10cSrcweir if ( ((ePLCF == PAP ) || (ePLCF == CHP)) && (nOrigCp != WW8_CP_MAX) )
3380cdf0e10cSrcweir {
3381cdf0e10cSrcweir bool bIsUnicode=false;
3382cdf0e10cSrcweir /*
3383cdf0e10cSrcweir To find the end of a paragraph for a character in a
3384cdf0e10cSrcweir complex format file.
3385cdf0e10cSrcweir
3386cdf0e10cSrcweir It is necessary to know the piece that contains the
3387cdf0e10cSrcweir character and the FC assigned to the character.
3388cdf0e10cSrcweir */
3389cdf0e10cSrcweir
3390cdf0e10cSrcweir //We set the piece iterator to the piece that contains the
3391cdf0e10cSrcweir //character, now we have the correct piece for this character
3392cdf0e10cSrcweir sal_uLong nOldPos = pPieceIter->GetIdx();
3393cdf0e10cSrcweir p->nStartPos = nOrigCp;
3394cdf0e10cSrcweir pPieceIter->SeekPos( p->nStartPos);
3395cdf0e10cSrcweir
3396cdf0e10cSrcweir //This is the FC assigned to the character, but we already
3397cdf0e10cSrcweir //have the result of the next stage, so we can skip this step
3398cdf0e10cSrcweir //WW8_FC nStartFc = rSBase.WW8Cp2Fc(p->nStartPos, &bIsUnicode);
3399cdf0e10cSrcweir
3400cdf0e10cSrcweir /*
3401cdf0e10cSrcweir Using the FC of the character, first search the FKP that
3402cdf0e10cSrcweir describes the character to find the smallest FC in the rgfc
3403cdf0e10cSrcweir that is larger than the character FC.
3404cdf0e10cSrcweir */
3405cdf0e10cSrcweir //But the search has already been done, the next largest FC is
3406cdf0e10cSrcweir //p->nEndPos.
3407cdf0e10cSrcweir WW8_FC nOldEndPos = p->nEndPos;
3408cdf0e10cSrcweir
3409cdf0e10cSrcweir /*
3410cdf0e10cSrcweir If the FC found in the FKP is less than or equal to the limit
3411cdf0e10cSrcweir FC of the piece, the end of the paragraph that contains the
3412cdf0e10cSrcweir character is at the FKP FC minus 1.
3413cdf0e10cSrcweir */
3414cdf0e10cSrcweir WW8_CP nCpStart, nCpEnd;
3415cdf0e10cSrcweir void* pData=NULL;
3416cdf0e10cSrcweir pPieceIter->Get(nCpStart, nCpEnd, pData);
3417cdf0e10cSrcweir
3418cdf0e10cSrcweir WW8_FC nLimitFC = SVBT32ToUInt32( ((WW8_PCD*)pData)->fc );
3419cdf0e10cSrcweir WW8_FC nBeginLimitFC = nLimitFC;
3420cdf0e10cSrcweir if (IsEightPlus(GetFIBVersion()))
3421cdf0e10cSrcweir {
3422cdf0e10cSrcweir nBeginLimitFC =
3423cdf0e10cSrcweir WW8PLCFx_PCD::TransformPieceAddress(nLimitFC,
3424cdf0e10cSrcweir bIsUnicode);
3425cdf0e10cSrcweir }
3426cdf0e10cSrcweir
3427cdf0e10cSrcweir nLimitFC = nBeginLimitFC +
3428cdf0e10cSrcweir (nCpEnd - nCpStart) * (bIsUnicode ? 2 : 1);
3429cdf0e10cSrcweir
3430cdf0e10cSrcweir if (nOldEndPos <= nLimitFC)
3431cdf0e10cSrcweir {
3432cdf0e10cSrcweir p->nEndPos = nCpEnd -
3433cdf0e10cSrcweir (nLimitFC-nOldEndPos) / (bIsUnicode ? 2 : 1);
3434cdf0e10cSrcweir }
3435cdf0e10cSrcweir else
3436cdf0e10cSrcweir {
3437cdf0e10cSrcweir if (ePLCF == CHP)
3438cdf0e10cSrcweir p->nEndPos = nCpEnd;
3439cdf0e10cSrcweir else
3440cdf0e10cSrcweir {
3441cdf0e10cSrcweir /*
3442cdf0e10cSrcweir If the FKP FC that was found was greater than the FC
3443cdf0e10cSrcweir of the end of the piece, scan piece by piece toward
3444cdf0e10cSrcweir the end of the document until a piece is found that
3445cdf0e10cSrcweir contains a paragraph end mark.
3446cdf0e10cSrcweir */
3447cdf0e10cSrcweir
3448cdf0e10cSrcweir /*
3449cdf0e10cSrcweir It's possible to check if a piece contains a paragraph
3450cdf0e10cSrcweir mark by using the FC of the beginning of the piece to
3451cdf0e10cSrcweir search in the FKPs for the smallest FC in the FKP rgfc
3452cdf0e10cSrcweir that is greater than the FC of the beginning of the
3453cdf0e10cSrcweir piece. If the FC found is less than or equal to the
3454cdf0e10cSrcweir limit FC of the piece, then the character that ends
3455cdf0e10cSrcweir the paragraph is the character immediately before the
3456cdf0e10cSrcweir FKP fc
3457cdf0e10cSrcweir */
3458cdf0e10cSrcweir
3459cdf0e10cSrcweir (*pPieceIter)++;
3460cdf0e10cSrcweir
3461cdf0e10cSrcweir for (;pPieceIter->GetIdx() < pPieceIter->GetIMax();
3462cdf0e10cSrcweir (*pPieceIter)++)
3463cdf0e10cSrcweir {
3464cdf0e10cSrcweir if( !pPieceIter->Get( nCpStart, nCpEnd, pData ) )
3465cdf0e10cSrcweir {
3466cdf0e10cSrcweir ASSERT( !this, "piece iter broken!" );
3467cdf0e10cSrcweir break;
3468cdf0e10cSrcweir }
3469cdf0e10cSrcweir bIsUnicode = false;
3470cdf0e10cSrcweir sal_Int32 nFcStart=SVBT32ToUInt32(((WW8_PCD*)pData)->fc);
3471cdf0e10cSrcweir
3472cdf0e10cSrcweir if (IsEightPlus(GetFIBVersion()))
3473cdf0e10cSrcweir {
3474cdf0e10cSrcweir nFcStart =
3475cdf0e10cSrcweir WW8PLCFx_PCD::TransformPieceAddress(
3476cdf0e10cSrcweir nFcStart,bIsUnicode );
3477cdf0e10cSrcweir }
3478cdf0e10cSrcweir
3479cdf0e10cSrcweir nLimitFC = nFcStart + (nCpEnd - nCpStart) *
3480cdf0e10cSrcweir (bIsUnicode ? 2 : 1);
3481cdf0e10cSrcweir
3482cdf0e10cSrcweir //if it doesn't exist, skip it
3483cdf0e10cSrcweir if (!SeekPos(nCpStart))
3484cdf0e10cSrcweir continue;
3485cdf0e10cSrcweir
3486cdf0e10cSrcweir WW8_FC nOne,nSmallest;
3487cdf0e10cSrcweir p->pMemPos = WW8PLCFx_Fc_FKP::GetSprmsAndPos(nOne,
3488cdf0e10cSrcweir nSmallest, p->nSprmsLen);
3489cdf0e10cSrcweir
3490cdf0e10cSrcweir if (nSmallest <= nLimitFC)
3491cdf0e10cSrcweir {
3492cdf0e10cSrcweir p->nEndPos = nCpEnd -
3493cdf0e10cSrcweir (nLimitFC-nSmallest) / (bIsUnicode ? 2 : 1);
3494cdf0e10cSrcweir break;
3495cdf0e10cSrcweir }
3496cdf0e10cSrcweir }
3497cdf0e10cSrcweir }
3498cdf0e10cSrcweir }
3499cdf0e10cSrcweir pPieceIter->SetIdx( nOldPos );
3500cdf0e10cSrcweir }
3501cdf0e10cSrcweir else
3502cdf0e10cSrcweir pPcd->AktPieceFc2Cp( p->nStartPos, p->nEndPos,&rSBase );
3503cdf0e10cSrcweir }
3504cdf0e10cSrcweir else
3505cdf0e10cSrcweir {
3506cdf0e10cSrcweir p->nStartPos = nAttrStart;
3507cdf0e10cSrcweir p->nEndPos = nAttrEnd;
3508cdf0e10cSrcweir p->bRealLineEnd = bLineEnd;
3509cdf0e10cSrcweir }
3510cdf0e10cSrcweir }
3511cdf0e10cSrcweir else // KEINE Piece-Table !!!
3512cdf0e10cSrcweir {
3513cdf0e10cSrcweir p->nStartPos = rSBase.WW8Fc2Cp( p->nStartPos );
3514cdf0e10cSrcweir p->nEndPos = rSBase.WW8Fc2Cp( p->nEndPos );
3515cdf0e10cSrcweir p->bRealLineEnd = ePLCF == PAP;
3516cdf0e10cSrcweir }
3517cdf0e10cSrcweir }
3518cdf0e10cSrcweir
operator ++(int)3519cdf0e10cSrcweir WW8PLCFx& WW8PLCFx_Cp_FKP::operator ++( int )
3520cdf0e10cSrcweir {
3521cdf0e10cSrcweir WW8PLCFx_Fc_FKP::operator ++( 0 );
3522cdf0e10cSrcweir // !pPcd: Notbremse
3523cdf0e10cSrcweir if ( !bComplex || !pPcd )
3524cdf0e10cSrcweir return *this;
3525cdf0e10cSrcweir
3526cdf0e10cSrcweir if( GetPCDIdx() >= GetPCDIMax() ) // End of PLCF
3527cdf0e10cSrcweir {
3528cdf0e10cSrcweir nAttrStart = nAttrEnd = WW8_CP_MAX;
3529cdf0e10cSrcweir return *this;
3530cdf0e10cSrcweir }
3531cdf0e10cSrcweir
3532cdf0e10cSrcweir sal_Int32 nFkpLen; // Fkp-Eintrag
3533cdf0e10cSrcweir // Fkp-Eintrag holen
3534cdf0e10cSrcweir WW8PLCFx_Fc_FKP::GetSprmsAndPos(nAttrStart, nAttrEnd, nFkpLen);
3535cdf0e10cSrcweir
3536cdf0e10cSrcweir pPcd->AktPieceFc2Cp( nAttrStart, nAttrEnd, &rSBase );
3537cdf0e10cSrcweir bLineEnd = (ePLCF == PAP);
3538cdf0e10cSrcweir return *this;
3539cdf0e10cSrcweir }
3540cdf0e10cSrcweir
3541cdf0e10cSrcweir //-----------------------------------------
3542cdf0e10cSrcweir //-----------------------------------------
3543cdf0e10cSrcweir
WW8PLCFx_SEPX(SvStream * pSt,SvStream * pTblSt,const WW8Fib & rFib,WW8_CP nStartCp)35442726b7b2SOliver-Rainer Wittmann WW8PLCFx_SEPX::WW8PLCFx_SEPX(
35452726b7b2SOliver-Rainer Wittmann SvStream* pSt,
35462726b7b2SOliver-Rainer Wittmann SvStream* pTblSt,
35472726b7b2SOliver-Rainer Wittmann const WW8Fib& rFib,
35482726b7b2SOliver-Rainer Wittmann WW8_CP nStartCp)
35492726b7b2SOliver-Rainer Wittmann : WW8PLCFx(rFib.GetFIBVersion(), true)
35502726b7b2SOliver-Rainer Wittmann , maSprmParser(rFib.GetFIBVersion())
35512726b7b2SOliver-Rainer Wittmann , pStrm(pSt)
35522726b7b2SOliver-Rainer Wittmann , nArrMax(256)
35532726b7b2SOliver-Rainer Wittmann , nSprmSiz(0)
3554cdf0e10cSrcweir {
3555cdf0e10cSrcweir pPLCF = rFib.lcbPlcfsed
3556cdf0e10cSrcweir ? new WW8PLCF(pTblSt, rFib.fcPlcfsed, rFib.lcbPlcfsed,
3557cdf0e10cSrcweir GetFIBVersion() <= ww::eWW2 ? 6 : 12, nStartCp)
3558cdf0e10cSrcweir : 0;
3559cdf0e10cSrcweir
3560cdf0e10cSrcweir pSprms = new sal_uInt8[nArrMax]; // maximum length
3561cdf0e10cSrcweir }
3562cdf0e10cSrcweir
~WW8PLCFx_SEPX()3563cdf0e10cSrcweir WW8PLCFx_SEPX::~WW8PLCFx_SEPX()
3564cdf0e10cSrcweir {
3565cdf0e10cSrcweir delete pPLCF;
3566cdf0e10cSrcweir delete[] pSprms;
3567cdf0e10cSrcweir }
3568cdf0e10cSrcweir
HasValidPLCF()35692726b7b2SOliver-Rainer Wittmann bool WW8PLCFx_SEPX::HasValidPLCF()
35702726b7b2SOliver-Rainer Wittmann {
35712726b7b2SOliver-Rainer Wittmann return pPLCF == 0 || pPLCF->IsValid();
35722726b7b2SOliver-Rainer Wittmann }
35732726b7b2SOliver-Rainer Wittmann
GetIdx() const3574cdf0e10cSrcweir sal_uLong WW8PLCFx_SEPX::GetIdx() const
3575cdf0e10cSrcweir {
3576cdf0e10cSrcweir return pPLCF ? pPLCF->GetIdx() : 0;
3577cdf0e10cSrcweir }
3578cdf0e10cSrcweir
SetIdx(sal_uLong nIdx)3579cdf0e10cSrcweir void WW8PLCFx_SEPX::SetIdx( sal_uLong nIdx )
3580cdf0e10cSrcweir {
3581cdf0e10cSrcweir if( pPLCF ) pPLCF->SetIdx( nIdx );
3582cdf0e10cSrcweir }
3583cdf0e10cSrcweir
SeekPos(WW8_CP nCpPos)3584cdf0e10cSrcweir bool WW8PLCFx_SEPX::SeekPos(WW8_CP nCpPos)
3585cdf0e10cSrcweir {
3586cdf0e10cSrcweir return pPLCF ? pPLCF->SeekPos( nCpPos ) : 0;
3587cdf0e10cSrcweir }
3588cdf0e10cSrcweir
Where()3589cdf0e10cSrcweir WW8_CP WW8PLCFx_SEPX::Where()
3590cdf0e10cSrcweir {
3591cdf0e10cSrcweir return pPLCF ? pPLCF->Where() : 0;
3592cdf0e10cSrcweir }
3593cdf0e10cSrcweir
GetSprms(WW8PLCFxDesc * p)3594cdf0e10cSrcweir void WW8PLCFx_SEPX::GetSprms(WW8PLCFxDesc* p)
3595cdf0e10cSrcweir {
3596cdf0e10cSrcweir if( !pPLCF ) return;
3597cdf0e10cSrcweir
3598cdf0e10cSrcweir void* pData;
3599cdf0e10cSrcweir
3600cdf0e10cSrcweir p->bRealLineEnd = false;
3601cdf0e10cSrcweir if (!pPLCF->Get( p->nStartPos, p->nEndPos, pData ))
3602cdf0e10cSrcweir {
3603cdf0e10cSrcweir p->nStartPos = p->nEndPos = WW8_CP_MAX; // PLCF fertig abgearbeitet
3604cdf0e10cSrcweir p->pMemPos = 0;
3605cdf0e10cSrcweir p->nSprmsLen = 0;
3606cdf0e10cSrcweir }
3607cdf0e10cSrcweir else
3608cdf0e10cSrcweir {
3609cdf0e10cSrcweir sal_uInt32 nPo = SVBT32ToUInt32( (sal_uInt8*)pData+2 );
3610cdf0e10cSrcweir if (nPo == 0xFFFFFFFF)
3611cdf0e10cSrcweir {
3612cdf0e10cSrcweir p->nStartPos = p->nEndPos = WW8_CP_MAX; // Sepx empty
3613cdf0e10cSrcweir p->pMemPos = 0;
3614cdf0e10cSrcweir p->nSprmsLen = 0;
3615cdf0e10cSrcweir }
3616cdf0e10cSrcweir else
3617cdf0e10cSrcweir {
3618cdf0e10cSrcweir pStrm->Seek( nPo );
3619cdf0e10cSrcweir
3620cdf0e10cSrcweir // read len
3621cdf0e10cSrcweir if (GetFIBVersion() <= ww::eWW2) // eWW6 ?, docs say yes, but...
3622cdf0e10cSrcweir {
3623cdf0e10cSrcweir sal_uInt8 nSiz(0);
3624cdf0e10cSrcweir *pStrm >> nSiz;
3625cdf0e10cSrcweir nSprmSiz = nSiz;
3626cdf0e10cSrcweir }
3627cdf0e10cSrcweir else
3628cdf0e10cSrcweir *pStrm >> nSprmSiz;
3629cdf0e10cSrcweir
3630cdf0e10cSrcweir if( nSprmSiz > nArrMax )
3631cdf0e10cSrcweir { // passt nicht
3632cdf0e10cSrcweir delete[] pSprms;
3633cdf0e10cSrcweir nArrMax = nSprmSiz; // Hole mehr Speicher
3634cdf0e10cSrcweir pSprms = new sal_uInt8[nArrMax];
3635cdf0e10cSrcweir }
3636cdf0e10cSrcweir pStrm->Read( pSprms, nSprmSiz ); // read Sprms
3637cdf0e10cSrcweir
3638cdf0e10cSrcweir p->nSprmsLen = nSprmSiz;
3639cdf0e10cSrcweir p->pMemPos = pSprms; // return Position
3640cdf0e10cSrcweir }
3641cdf0e10cSrcweir }
3642cdf0e10cSrcweir }
3643cdf0e10cSrcweir
operator ++(int)3644cdf0e10cSrcweir WW8PLCFx& WW8PLCFx_SEPX::operator ++( int )
3645cdf0e10cSrcweir {
3646cdf0e10cSrcweir if( pPLCF )
3647cdf0e10cSrcweir (*pPLCF)++;
3648cdf0e10cSrcweir return *this;
3649cdf0e10cSrcweir }
3650cdf0e10cSrcweir
HasSprm(sal_uInt16 nId) const3651cdf0e10cSrcweir const sal_uInt8* WW8PLCFx_SEPX::HasSprm( sal_uInt16 nId ) const
3652cdf0e10cSrcweir {
3653cdf0e10cSrcweir return HasSprm( nId, pSprms, nSprmSiz);
3654cdf0e10cSrcweir }
3655cdf0e10cSrcweir
HasSprm(sal_uInt16 nId,const sal_uInt8 * pOtherSprms,long nOtherSprmSiz) const3656cdf0e10cSrcweir const sal_uInt8* WW8PLCFx_SEPX::HasSprm( sal_uInt16 nId, const sal_uInt8* pOtherSprms,
3657cdf0e10cSrcweir long nOtherSprmSiz ) const
3658cdf0e10cSrcweir {
3659cdf0e10cSrcweir const sal_uInt8 *pRet = 0;
3660cdf0e10cSrcweir if (pPLCF)
3661cdf0e10cSrcweir {
3662cdf0e10cSrcweir WW8SprmIter aIter(pOtherSprms, nOtherSprmSiz, maSprmParser);
3663cdf0e10cSrcweir pRet = aIter.FindSprm(nId);
3664cdf0e10cSrcweir }
3665cdf0e10cSrcweir return pRet;
3666cdf0e10cSrcweir }
3667cdf0e10cSrcweir
Find4Sprms(sal_uInt16 nId1,sal_uInt16 nId2,sal_uInt16 nId3,sal_uInt16 nId4,sal_uInt8 * & p1,sal_uInt8 * & p2,sal_uInt8 * & p3,sal_uInt8 * & p4) const3668cdf0e10cSrcweir bool WW8PLCFx_SEPX::Find4Sprms(sal_uInt16 nId1,sal_uInt16 nId2,sal_uInt16 nId3,sal_uInt16 nId4,
3669cdf0e10cSrcweir sal_uInt8*& p1, sal_uInt8*& p2, sal_uInt8*& p3, sal_uInt8*& p4) const
3670cdf0e10cSrcweir {
3671cdf0e10cSrcweir if( !pPLCF )
3672cdf0e10cSrcweir return 0;
3673cdf0e10cSrcweir
3674cdf0e10cSrcweir bool bFound = false;
3675cdf0e10cSrcweir p1 = 0;
3676cdf0e10cSrcweir p2 = 0;
3677cdf0e10cSrcweir p3 = 0;
3678cdf0e10cSrcweir p4 = 0;
3679cdf0e10cSrcweir
3680cdf0e10cSrcweir sal_uInt8* pSp = pSprms;
3681cdf0e10cSrcweir sal_uInt16 i=0;
3682cdf0e10cSrcweir while (i + maSprmParser.MinSprmLen() <= nSprmSiz)
3683cdf0e10cSrcweir {
3684cdf0e10cSrcweir // Sprm gefunden?
3685cdf0e10cSrcweir sal_uInt16 nAktId = maSprmParser.GetSprmId(pSp);
3686cdf0e10cSrcweir bool bOk = true;
3687cdf0e10cSrcweir if( nAktId == nId1 )
3688cdf0e10cSrcweir p1 = pSp + maSprmParser.DistanceToData(nId1);
3689cdf0e10cSrcweir else if( nAktId == nId2 )
3690cdf0e10cSrcweir p2 = pSp + maSprmParser.DistanceToData(nId2);
3691cdf0e10cSrcweir else if( nAktId == nId3 )
3692cdf0e10cSrcweir p3 = pSp + maSprmParser.DistanceToData(nId3);
3693cdf0e10cSrcweir else if( nAktId == nId4 )
3694cdf0e10cSrcweir p4 = pSp + maSprmParser.DistanceToData(nId4);
3695cdf0e10cSrcweir else
3696cdf0e10cSrcweir bOk = false;
3697cdf0e10cSrcweir bFound |= bOk;
3698cdf0e10cSrcweir // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
3699cdf0e10cSrcweir sal_uInt16 x = maSprmParser.GetSprmSize(nAktId, pSp);
3700cdf0e10cSrcweir i = i + x;
3701cdf0e10cSrcweir pSp += x;
3702cdf0e10cSrcweir }
3703cdf0e10cSrcweir return bFound;
3704cdf0e10cSrcweir }
3705cdf0e10cSrcweir
HasSprm(sal_uInt16 nId,sal_uInt8 n2nd) const3706cdf0e10cSrcweir const sal_uInt8* WW8PLCFx_SEPX::HasSprm( sal_uInt16 nId, sal_uInt8 n2nd ) const
3707cdf0e10cSrcweir {
3708cdf0e10cSrcweir if( !pPLCF )
3709cdf0e10cSrcweir return 0;
3710cdf0e10cSrcweir
3711cdf0e10cSrcweir sal_uInt8* pSp = pSprms;
3712cdf0e10cSrcweir
3713cdf0e10cSrcweir sal_uInt16 i=0;
3714cdf0e10cSrcweir while (i + maSprmParser.MinSprmLen() <= nSprmSiz)
3715cdf0e10cSrcweir {
3716cdf0e10cSrcweir // Sprm gefunden?
3717cdf0e10cSrcweir sal_uInt16 nAktId = maSprmParser.GetSprmId(pSp);
3718cdf0e10cSrcweir if (nAktId == nId)
3719cdf0e10cSrcweir {
3720cdf0e10cSrcweir sal_uInt8 *pRet = pSp + maSprmParser.DistanceToData(nId);
3721cdf0e10cSrcweir if (*pRet == n2nd)
3722cdf0e10cSrcweir return pRet;
3723cdf0e10cSrcweir }
3724cdf0e10cSrcweir // erhoehe Zeiger, so dass er auf naechsten Sprm zeigt
3725cdf0e10cSrcweir sal_uInt16 x = maSprmParser.GetSprmSize(nAktId, pSp);
3726cdf0e10cSrcweir i = i + x;
3727cdf0e10cSrcweir pSp += x;
3728cdf0e10cSrcweir }
3729cdf0e10cSrcweir
3730cdf0e10cSrcweir return 0; // Sprm nicht gefunden
3731cdf0e10cSrcweir }
3732cdf0e10cSrcweir
3733cdf0e10cSrcweir //-----------------------------------------
WW8PLCFx_SubDoc(SvStream * pSt,ww::WordVersion eVersion,WW8_CP nStartCp,long nFcRef,long nLenRef,long nFcTxt,long nLenTxt,long nStruct)37342726b7b2SOliver-Rainer Wittmann WW8PLCFx_SubDoc::WW8PLCFx_SubDoc(
37352726b7b2SOliver-Rainer Wittmann SvStream* pSt,
37362726b7b2SOliver-Rainer Wittmann ww::WordVersion eVersion,
37372726b7b2SOliver-Rainer Wittmann WW8_CP nStartCp,
37382726b7b2SOliver-Rainer Wittmann long nFcRef,
37392726b7b2SOliver-Rainer Wittmann long nLenRef,
37402726b7b2SOliver-Rainer Wittmann long nFcTxt,
37412726b7b2SOliver-Rainer Wittmann long nLenTxt,
3742cdf0e10cSrcweir long nStruct)
37432726b7b2SOliver-Rainer Wittmann : WW8PLCFx(eVersion, true)
37442726b7b2SOliver-Rainer Wittmann , pRef(0)
37452726b7b2SOliver-Rainer Wittmann , pTxt(0)
3746cdf0e10cSrcweir {
3747cdf0e10cSrcweir if( nLenRef && nLenTxt )
3748cdf0e10cSrcweir {
3749cdf0e10cSrcweir pRef = new WW8PLCF( pSt, nFcRef, nLenRef, nStruct, nStartCp );
3750cdf0e10cSrcweir pTxt = new WW8PLCF( pSt, nFcTxt, nLenTxt, 0, nStartCp );
3751cdf0e10cSrcweir }
3752cdf0e10cSrcweir }
3753cdf0e10cSrcweir
~WW8PLCFx_SubDoc()3754cdf0e10cSrcweir WW8PLCFx_SubDoc::~WW8PLCFx_SubDoc()
3755cdf0e10cSrcweir {
3756cdf0e10cSrcweir delete pRef;
3757cdf0e10cSrcweir delete pTxt;
3758cdf0e10cSrcweir }
3759cdf0e10cSrcweir
HasValidPLCF()37602726b7b2SOliver-Rainer Wittmann bool WW8PLCFx_SubDoc::HasValidPLCF()
37612726b7b2SOliver-Rainer Wittmann {
37622726b7b2SOliver-Rainer Wittmann return ( pRef == 0 || pRef->IsValid() )
37632726b7b2SOliver-Rainer Wittmann && ( pTxt == 0 || pTxt->IsValid() );
37642726b7b2SOliver-Rainer Wittmann }
37652726b7b2SOliver-Rainer Wittmann
GetIdx() const3766cdf0e10cSrcweir sal_uLong WW8PLCFx_SubDoc::GetIdx() const
3767cdf0e10cSrcweir {
3768cdf0e10cSrcweir // Wahrscheinlich pTxt... nicht noetig
3769cdf0e10cSrcweir if( pRef )
3770cdf0e10cSrcweir return ( pRef->GetIdx() << 16 | pTxt->GetIdx() );
3771cdf0e10cSrcweir return 0;
3772cdf0e10cSrcweir }
3773cdf0e10cSrcweir
SetIdx(sal_uLong nIdx)3774cdf0e10cSrcweir void WW8PLCFx_SubDoc::SetIdx( sal_uLong nIdx )
3775cdf0e10cSrcweir {
3776cdf0e10cSrcweir if( pRef )
3777cdf0e10cSrcweir {
3778cdf0e10cSrcweir pRef->SetIdx( nIdx >> 16 );
3779cdf0e10cSrcweir // Wahrscheinlich pTxt... nicht noetig
3780cdf0e10cSrcweir pTxt->SetIdx( nIdx & 0xFFFF );
3781cdf0e10cSrcweir }
3782cdf0e10cSrcweir }
3783cdf0e10cSrcweir
SeekPos(WW8_CP nCpPos)3784cdf0e10cSrcweir bool WW8PLCFx_SubDoc::SeekPos( WW8_CP nCpPos )
3785cdf0e10cSrcweir {
3786cdf0e10cSrcweir return ( pRef ) ? pRef->SeekPos( nCpPos ) : false;
3787cdf0e10cSrcweir }
3788cdf0e10cSrcweir
Where()3789cdf0e10cSrcweir WW8_CP WW8PLCFx_SubDoc::Where()
3790cdf0e10cSrcweir {
3791cdf0e10cSrcweir return ( pRef ) ? pRef->Where() : WW8_CP_MAX;
3792cdf0e10cSrcweir }
3793cdf0e10cSrcweir
GetSprms(WW8PLCFxDesc * p)3794cdf0e10cSrcweir void WW8PLCFx_SubDoc::GetSprms(WW8PLCFxDesc* p)
3795cdf0e10cSrcweir {
3796cdf0e10cSrcweir p->nStartPos = p->nEndPos = WW8_CP_MAX;
3797cdf0e10cSrcweir p->pMemPos = 0;
3798cdf0e10cSrcweir p->nSprmsLen = 0;
3799cdf0e10cSrcweir p->bRealLineEnd = false;
3800cdf0e10cSrcweir
3801cdf0e10cSrcweir if (!pRef)
3802cdf0e10cSrcweir return;
3803cdf0e10cSrcweir
3804cdf0e10cSrcweir sal_uLong nNr = pRef->GetIdx();
3805cdf0e10cSrcweir
3806cdf0e10cSrcweir void *pData;
3807cdf0e10cSrcweir WW8_CP nFoo;
3808cdf0e10cSrcweir if (!pRef->Get(p->nStartPos, nFoo, pData))
3809cdf0e10cSrcweir {
3810cdf0e10cSrcweir p->nEndPos = p->nStartPos = WW8_CP_MAX;
3811cdf0e10cSrcweir return;
3812cdf0e10cSrcweir }
3813cdf0e10cSrcweir
3814cdf0e10cSrcweir p->nEndPos = p->nStartPos + 1;
3815cdf0e10cSrcweir
3816cdf0e10cSrcweir if (!pTxt)
3817cdf0e10cSrcweir return;
3818cdf0e10cSrcweir
3819cdf0e10cSrcweir pTxt->SetIdx(nNr);
3820cdf0e10cSrcweir
3821cdf0e10cSrcweir if (!pTxt->Get(p->nCp2OrIdx, p->nSprmsLen, pData))
3822cdf0e10cSrcweir {
3823cdf0e10cSrcweir p->nEndPos = p->nStartPos = WW8_CP_MAX;
3824cdf0e10cSrcweir p->nSprmsLen = 0;
3825cdf0e10cSrcweir return;
3826cdf0e10cSrcweir }
3827cdf0e10cSrcweir
3828cdf0e10cSrcweir p->nSprmsLen -= p->nCp2OrIdx;
3829cdf0e10cSrcweir }
3830cdf0e10cSrcweir
operator ++(int)3831cdf0e10cSrcweir WW8PLCFx& WW8PLCFx_SubDoc::operator ++( int )
3832cdf0e10cSrcweir {
3833cdf0e10cSrcweir if( pRef && pTxt )
3834cdf0e10cSrcweir {
3835cdf0e10cSrcweir (*pRef)++;
3836cdf0e10cSrcweir (*pTxt)++;
3837cdf0e10cSrcweir }
3838cdf0e10cSrcweir return *this;
3839cdf0e10cSrcweir }
3840cdf0e10cSrcweir
3841cdf0e10cSrcweir //-----------------------------------------
3842cdf0e10cSrcweir // Felder
3843cdf0e10cSrcweir //-----------------------------------------
3844cdf0e10cSrcweir
WW8PLCFx_FLD(SvStream * pSt,const WW8Fib & rMyFib,short nType)3845cdf0e10cSrcweir WW8PLCFx_FLD::WW8PLCFx_FLD( SvStream* pSt, const WW8Fib& rMyFib, short nType)
3846cdf0e10cSrcweir : WW8PLCFx(rMyFib.GetFIBVersion(), true), pPLCF(0), rFib(rMyFib)
3847cdf0e10cSrcweir {
3848cdf0e10cSrcweir long nFc, nLen;
3849cdf0e10cSrcweir
3850cdf0e10cSrcweir switch( nType )
3851cdf0e10cSrcweir {
3852cdf0e10cSrcweir case MAN_HDFT:
3853cdf0e10cSrcweir nFc = rFib.fcPlcffldHdr;
3854cdf0e10cSrcweir nLen = rFib.lcbPlcffldHdr;
3855cdf0e10cSrcweir break;
3856cdf0e10cSrcweir case MAN_FTN:
3857cdf0e10cSrcweir nFc = rFib.fcPlcffldFtn;
3858cdf0e10cSrcweir nLen = rFib.lcbPlcffldFtn;
3859cdf0e10cSrcweir break;
3860cdf0e10cSrcweir case MAN_EDN:
3861cdf0e10cSrcweir nFc = rFib.fcPlcffldEdn;
3862cdf0e10cSrcweir nLen = rFib.lcbPlcffldEdn;
3863cdf0e10cSrcweir break;
3864cdf0e10cSrcweir case MAN_AND:
3865cdf0e10cSrcweir nFc = rFib.fcPlcffldAtn;
3866cdf0e10cSrcweir nLen = rFib.lcbPlcffldAtn;
3867cdf0e10cSrcweir break;
3868cdf0e10cSrcweir case MAN_TXBX:
3869cdf0e10cSrcweir nFc = rFib.fcPlcffldTxbx;
3870cdf0e10cSrcweir nLen = rFib.lcbPlcffldTxbx;
3871cdf0e10cSrcweir break;
3872cdf0e10cSrcweir case MAN_TXBX_HDFT:
3873cdf0e10cSrcweir nFc = rFib.fcPlcffldHdrTxbx;
3874cdf0e10cSrcweir nLen = rFib.lcbPlcffldHdrTxbx;
3875cdf0e10cSrcweir break;
3876cdf0e10cSrcweir default:
3877cdf0e10cSrcweir nFc = rFib.fcPlcffldMom;
3878cdf0e10cSrcweir nLen = rFib.lcbPlcffldMom;
3879cdf0e10cSrcweir break;
3880cdf0e10cSrcweir }
3881cdf0e10cSrcweir
3882cdf0e10cSrcweir if( nLen )
3883cdf0e10cSrcweir pPLCF = new WW8PLCFspecial( pSt, nFc, nLen, 2 );
3884cdf0e10cSrcweir }
3885cdf0e10cSrcweir
~WW8PLCFx_FLD()3886cdf0e10cSrcweir WW8PLCFx_FLD::~WW8PLCFx_FLD()
3887cdf0e10cSrcweir {
3888cdf0e10cSrcweir delete pPLCF;
3889cdf0e10cSrcweir }
3890cdf0e10cSrcweir
HasValidPLCF()38912726b7b2SOliver-Rainer Wittmann bool WW8PLCFx_FLD::HasValidPLCF()
38922726b7b2SOliver-Rainer Wittmann {
38932726b7b2SOliver-Rainer Wittmann return pPLCF == 0 || pPLCF->IsValid();
38942726b7b2SOliver-Rainer Wittmann }
38952726b7b2SOliver-Rainer Wittmann
GetIdx() const3896cdf0e10cSrcweir sal_uLong WW8PLCFx_FLD::GetIdx() const
3897cdf0e10cSrcweir {
3898cdf0e10cSrcweir return pPLCF ? pPLCF->GetIdx() : 0;
3899cdf0e10cSrcweir }
3900cdf0e10cSrcweir
SetIdx(sal_uLong nIdx)3901cdf0e10cSrcweir void WW8PLCFx_FLD::SetIdx( sal_uLong nIdx )
3902cdf0e10cSrcweir {
3903cdf0e10cSrcweir if( pPLCF )
3904cdf0e10cSrcweir pPLCF->SetIdx( nIdx );
3905cdf0e10cSrcweir }
3906cdf0e10cSrcweir
SeekPos(WW8_CP nCpPos)3907cdf0e10cSrcweir bool WW8PLCFx_FLD::SeekPos(WW8_CP nCpPos)
3908cdf0e10cSrcweir {
3909cdf0e10cSrcweir return pPLCF ? pPLCF->SeekPosExact( nCpPos ) : false;
3910cdf0e10cSrcweir }
3911cdf0e10cSrcweir
Where()3912cdf0e10cSrcweir WW8_CP WW8PLCFx_FLD::Where()
3913cdf0e10cSrcweir {
3914cdf0e10cSrcweir return pPLCF ? pPLCF->Where() : WW8_CP_MAX;
3915cdf0e10cSrcweir }
3916cdf0e10cSrcweir
StartPosIsFieldStart()3917cdf0e10cSrcweir bool WW8PLCFx_FLD::StartPosIsFieldStart()
3918cdf0e10cSrcweir {
3919cdf0e10cSrcweir void* pData;
3920cdf0e10cSrcweir sal_Int32 nTest;
3921cdf0e10cSrcweir if (
3922cdf0e10cSrcweir (!pPLCF || !pPLCF->Get(nTest, pData) ||
3923cdf0e10cSrcweir ((((sal_uInt8*)pData)[0] & 0x1f) != 0x13))
3924cdf0e10cSrcweir )
3925cdf0e10cSrcweir return false;
3926cdf0e10cSrcweir return true;
3927cdf0e10cSrcweir }
3928cdf0e10cSrcweir
EndPosIsFieldEnd(WW8_CP & nCP)3929f66c5aafSOliver-Rainer Wittmann bool WW8PLCFx_FLD::EndPosIsFieldEnd(WW8_CP& nCP)
3930cdf0e10cSrcweir {
3931cdf0e10cSrcweir bool bRet = false;
3932cdf0e10cSrcweir
3933cdf0e10cSrcweir if (pPLCF)
3934cdf0e10cSrcweir {
3935cdf0e10cSrcweir long n = pPLCF->GetIdx();
3936cdf0e10cSrcweir
3937cdf0e10cSrcweir (*pPLCF)++;
3938cdf0e10cSrcweir
3939cdf0e10cSrcweir void* pData;
3940cdf0e10cSrcweir sal_Int32 nTest;
3941cdf0e10cSrcweir if ( pPLCF->Get(nTest, pData) && ((((sal_uInt8*)pData)[0] & 0x1f) == 0x15) )
3942f66c5aafSOliver-Rainer Wittmann {
3943f66c5aafSOliver-Rainer Wittmann nCP = nTest;
3944cdf0e10cSrcweir bRet = true;
3945f66c5aafSOliver-Rainer Wittmann }
3946cdf0e10cSrcweir
3947cdf0e10cSrcweir pPLCF->SetIdx(n);
3948cdf0e10cSrcweir }
3949cdf0e10cSrcweir
3950cdf0e10cSrcweir return bRet;
3951cdf0e10cSrcweir }
3952cdf0e10cSrcweir
GetSprms(WW8PLCFxDesc * p)3953cdf0e10cSrcweir void WW8PLCFx_FLD::GetSprms(WW8PLCFxDesc* p)
3954cdf0e10cSrcweir {
3955cdf0e10cSrcweir p->nStartPos = p->nEndPos = WW8_CP_MAX;
3956cdf0e10cSrcweir p->pMemPos = 0;
3957cdf0e10cSrcweir p->nSprmsLen = 0;
3958cdf0e10cSrcweir p->bRealLineEnd = false;
3959cdf0e10cSrcweir
3960cdf0e10cSrcweir if (!pPLCF)
3961cdf0e10cSrcweir {
3962cdf0e10cSrcweir p->nStartPos = WW8_CP_MAX; // Es gibt keine Felder
3963cdf0e10cSrcweir return;
3964cdf0e10cSrcweir }
3965cdf0e10cSrcweir
3966cdf0e10cSrcweir long n = pPLCF->GetIdx();
3967cdf0e10cSrcweir
3968cdf0e10cSrcweir sal_Int32 nP;
3969cdf0e10cSrcweir void *pData;
3970cdf0e10cSrcweir if (!pPLCF->Get(nP, pData)) // Ende des PLCFspecial ?
3971cdf0e10cSrcweir {
3972cdf0e10cSrcweir p->nStartPos = WW8_CP_MAX; // PLCF fertig abgearbeitet
3973cdf0e10cSrcweir return;
3974cdf0e10cSrcweir }
3975cdf0e10cSrcweir
3976cdf0e10cSrcweir p->nStartPos = nP;
3977cdf0e10cSrcweir
3978cdf0e10cSrcweir (*pPLCF)++;
3979cdf0e10cSrcweir if (!pPLCF->Get(nP, pData)) // Ende des PLCFspecial ?
3980cdf0e10cSrcweir {
3981cdf0e10cSrcweir p->nStartPos = WW8_CP_MAX; // PLCF fertig abgearbeitet
3982cdf0e10cSrcweir return;
3983cdf0e10cSrcweir }
3984cdf0e10cSrcweir
3985cdf0e10cSrcweir p->nEndPos = nP;
3986cdf0e10cSrcweir
3987cdf0e10cSrcweir pPLCF->SetIdx(n);
3988cdf0e10cSrcweir
3989cdf0e10cSrcweir p->nCp2OrIdx = pPLCF->GetIdx();
3990cdf0e10cSrcweir }
3991cdf0e10cSrcweir
operator ++(int)3992cdf0e10cSrcweir WW8PLCFx& WW8PLCFx_FLD::operator ++( int )
3993cdf0e10cSrcweir {
3994cdf0e10cSrcweir (*pPLCF)++;
3995cdf0e10cSrcweir return *this;
3996cdf0e10cSrcweir }
3997cdf0e10cSrcweir
GetPara(long nIdx,WW8FieldDesc & rF)3998cdf0e10cSrcweir bool WW8PLCFx_FLD::GetPara(long nIdx, WW8FieldDesc& rF)
3999cdf0e10cSrcweir {
4000cdf0e10cSrcweir ASSERT( pPLCF, "Aufruf ohne Feld PLCFspecial" );
4001cdf0e10cSrcweir if( !pPLCF )
4002cdf0e10cSrcweir return false;
4003cdf0e10cSrcweir
4004cdf0e10cSrcweir long n = pPLCF->GetIdx();
4005cdf0e10cSrcweir pPLCF->SetIdx(nIdx);
4006cdf0e10cSrcweir
4007cdf0e10cSrcweir bool bOk = WW8GetFieldPara(*pPLCF, rF);
4008cdf0e10cSrcweir
4009cdf0e10cSrcweir pPLCF->SetIdx(n);
4010cdf0e10cSrcweir return bOk;
4011cdf0e10cSrcweir }
4012cdf0e10cSrcweir
4013cdf0e10cSrcweir //-----------------------------------------
4014cdf0e10cSrcweir // class WW8PLCF_Book
4015cdf0e10cSrcweir //-----------------------------------------
4016cdf0e10cSrcweir
4017cdf0e10cSrcweir /* to be optimized like this: */
WW8ReadSTTBF(bool bVer8,SvStream & rStrm,sal_uInt32 nStart,sal_Int32 nLen,sal_uInt16 nExtraLen,rtl_TextEncoding eCS,std::vector<String> & rArray,std::vector<ww::bytes> * pExtraArray,::std::vector<String> * pValueArray)4018cdf0e10cSrcweir void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen,
4019cdf0e10cSrcweir sal_uInt16 nExtraLen, rtl_TextEncoding eCS, std::vector<String> &rArray,
4020cdf0e10cSrcweir std::vector<ww::bytes>* pExtraArray, ::std::vector<String>* pValueArray)
4021cdf0e10cSrcweir {
4022cdf0e10cSrcweir if(nLen==0) // Handle Empty STTBF
4023cdf0e10cSrcweir return;
4024cdf0e10cSrcweir
4025cdf0e10cSrcweir sal_uLong nOldPos = rStrm.Tell();
4026cdf0e10cSrcweir rStrm.Seek( nStart );
4027cdf0e10cSrcweir
4028cdf0e10cSrcweir sal_uInt16 nLen2;
4029cdf0e10cSrcweir rStrm >> nLen2; // bVer67: total length of structure
4030cdf0e10cSrcweir // bVer8 : count of strings
4031cdf0e10cSrcweir
4032cdf0e10cSrcweir if( bVer8 )
4033cdf0e10cSrcweir {
4034cdf0e10cSrcweir sal_uInt16 nStrings;
4035cdf0e10cSrcweir bool bUnicode = (0xFFFF == nLen2);
4036cdf0e10cSrcweir if( bUnicode )
4037cdf0e10cSrcweir rStrm >> nStrings;
4038cdf0e10cSrcweir else
4039cdf0e10cSrcweir nStrings = nLen2;
4040cdf0e10cSrcweir
4041cdf0e10cSrcweir rStrm >> nExtraLen;
4042cdf0e10cSrcweir
4043cdf0e10cSrcweir for( sal_uInt16 i=0; i < nStrings; i++ )
4044cdf0e10cSrcweir {
4045cdf0e10cSrcweir if( bUnicode )
4046cdf0e10cSrcweir rArray.push_back(WW8Read_xstz(rStrm, 0, false));
4047cdf0e10cSrcweir else
4048cdf0e10cSrcweir {
4049cdf0e10cSrcweir sal_uInt8 nBChar;
4050cdf0e10cSrcweir rStrm >> nBChar;
4051cdf0e10cSrcweir ByteString aTmp;
4052cdf0e10cSrcweir SafeReadString(aTmp,nBChar,rStrm);
4053cdf0e10cSrcweir rArray.push_back(String(aTmp, eCS));
4054cdf0e10cSrcweir }
4055cdf0e10cSrcweir
4056cdf0e10cSrcweir // Skip the extra data
4057cdf0e10cSrcweir if( nExtraLen )
4058cdf0e10cSrcweir {
4059cdf0e10cSrcweir if (pExtraArray)
4060cdf0e10cSrcweir {
4061cdf0e10cSrcweir ww::bytes extraData;
4062cdf0e10cSrcweir sal_uInt8 iTmp;
4063cdf0e10cSrcweir for(int j = 0; j < nExtraLen; ++j)
4064cdf0e10cSrcweir {
4065cdf0e10cSrcweir rStrm >> iTmp;
4066cdf0e10cSrcweir extraData.push_back(iTmp);
4067cdf0e10cSrcweir }
4068cdf0e10cSrcweir pExtraArray->push_back(extraData);
4069cdf0e10cSrcweir }
4070cdf0e10cSrcweir else
4071cdf0e10cSrcweir rStrm.SeekRel( nExtraLen );
4072cdf0e10cSrcweir }
4073cdf0e10cSrcweir }
4074cdf0e10cSrcweir // #129053# read the value of the document variables, if requested.
4075cdf0e10cSrcweir if (pValueArray)
4076cdf0e10cSrcweir {
4077cdf0e10cSrcweir for( sal_uInt16 i=0; i < nStrings; i++ )
4078cdf0e10cSrcweir {
4079cdf0e10cSrcweir if( bUnicode )
4080cdf0e10cSrcweir pValueArray->push_back(WW8Read_xstz(rStrm, 0, false));
4081cdf0e10cSrcweir else
4082cdf0e10cSrcweir {
4083cdf0e10cSrcweir sal_uInt8 nBChar;
4084cdf0e10cSrcweir rStrm >> nBChar;
4085cdf0e10cSrcweir ByteString aTmp;
4086cdf0e10cSrcweir SafeReadString(aTmp,nBChar,rStrm);
4087cdf0e10cSrcweir pValueArray->push_back(String(aTmp, eCS));
4088cdf0e10cSrcweir }
4089cdf0e10cSrcweir }
4090cdf0e10cSrcweir }
4091cdf0e10cSrcweir }
4092cdf0e10cSrcweir else
4093cdf0e10cSrcweir {
4094cdf0e10cSrcweir sal_uInt8 nBChar;
4095cdf0e10cSrcweir if( nLen2 != nLen )
4096cdf0e10cSrcweir {
4097cdf0e10cSrcweir ASSERT( nLen2 == nLen, "Fib length and read length are different" );
4098cdf0e10cSrcweir if (nLen > USHRT_MAX)
4099cdf0e10cSrcweir nLen = USHRT_MAX;
4100cdf0e10cSrcweir else if (nLen < 2 )
4101cdf0e10cSrcweir nLen = 2;
4102cdf0e10cSrcweir nLen2 = static_cast<sal_uInt16>(nLen);
4103cdf0e10cSrcweir }
4104cdf0e10cSrcweir sal_uLong nRead = 0;
4105cdf0e10cSrcweir for( nLen2 -= 2; nRead < nLen2; )
4106cdf0e10cSrcweir {
4107cdf0e10cSrcweir rStrm >> nBChar; ++nRead;
4108cdf0e10cSrcweir if (nBChar)
4109cdf0e10cSrcweir {
4110cdf0e10cSrcweir ByteString aTmp;
4111cdf0e10cSrcweir nRead += SafeReadString(aTmp,nBChar,rStrm);
4112cdf0e10cSrcweir rArray.push_back(String(aTmp, eCS));
4113cdf0e10cSrcweir }
4114cdf0e10cSrcweir else
4115cdf0e10cSrcweir rArray.push_back(aEmptyStr);
4116cdf0e10cSrcweir
4117cdf0e10cSrcweir // #89125# Skip the extra data (for bVer67 versions this must come
4118cdf0e10cSrcweir // from external knowledge)
4119cdf0e10cSrcweir if (nExtraLen)
4120cdf0e10cSrcweir {
4121cdf0e10cSrcweir if (pExtraArray)
4122cdf0e10cSrcweir {
4123cdf0e10cSrcweir ww::bytes extraData;
4124cdf0e10cSrcweir for(int i =0;i < nExtraLen;i++)
4125cdf0e10cSrcweir {
4126cdf0e10cSrcweir sal_uInt8 iTmp;
4127cdf0e10cSrcweir rStrm >> iTmp;
4128cdf0e10cSrcweir extraData.push_back(iTmp);
4129cdf0e10cSrcweir }
4130cdf0e10cSrcweir pExtraArray->push_back(extraData);
4131cdf0e10cSrcweir }
4132cdf0e10cSrcweir else
4133cdf0e10cSrcweir rStrm.SeekRel( nExtraLen );
4134cdf0e10cSrcweir nRead+=nExtraLen;
4135cdf0e10cSrcweir }
4136cdf0e10cSrcweir }
4137cdf0e10cSrcweir }
4138cdf0e10cSrcweir rStrm.Seek( nOldPos );
4139cdf0e10cSrcweir }
4140cdf0e10cSrcweir
WW8PLCFx_Book(SvStream * pTblSt,const WW8Fib & rFib)4141cdf0e10cSrcweir WW8PLCFx_Book::WW8PLCFx_Book(SvStream* pTblSt, const WW8Fib& rFib)
4142cdf0e10cSrcweir : WW8PLCFx(rFib.GetFIBVersion(), false), pStatus(0), nIsEnd(0), nBookmarkId(1)
4143cdf0e10cSrcweir {
4144cdf0e10cSrcweir if( !rFib.fcPlcfbkf || !rFib.lcbPlcfbkf || !rFib.fcPlcfbkl ||
4145cdf0e10cSrcweir !rFib.lcbPlcfbkl || !rFib.fcSttbfbkmk || !rFib.lcbSttbfbkmk )
4146cdf0e10cSrcweir {
4147cdf0e10cSrcweir pBook[0] = pBook[1] = 0;
4148cdf0e10cSrcweir nIMax = 0;
4149cdf0e10cSrcweir }
4150cdf0e10cSrcweir else
4151cdf0e10cSrcweir {
4152cdf0e10cSrcweir pBook[0] = new WW8PLCFspecial(pTblSt,rFib.fcPlcfbkf,rFib.lcbPlcfbkf,4);
4153cdf0e10cSrcweir
4154cdf0e10cSrcweir pBook[1] = new WW8PLCFspecial(pTblSt,rFib.fcPlcfbkl,rFib.lcbPlcfbkl,0);
4155cdf0e10cSrcweir
4156cdf0e10cSrcweir rtl_TextEncoding eStructChrSet = WW8Fib::GetFIBCharset(rFib.chseTables);
4157cdf0e10cSrcweir
4158cdf0e10cSrcweir WW8ReadSTTBF( (7 < rFib.nVersion), *pTblSt, rFib.fcSttbfbkmk,
4159cdf0e10cSrcweir rFib.lcbSttbfbkmk, 0, eStructChrSet, aBookNames );
4160cdf0e10cSrcweir
4161cdf0e10cSrcweir nIMax = aBookNames.size();
4162cdf0e10cSrcweir
4163cdf0e10cSrcweir if( pBook[0]->GetIMax() < nIMax ) // Count of Bookmarks
4164cdf0e10cSrcweir nIMax = pBook[0]->GetIMax();
4165cdf0e10cSrcweir pStatus = new eBookStatus[ nIMax ];
4166cdf0e10cSrcweir memset( pStatus, 0, nIMax * sizeof( eBookStatus ) );
4167cdf0e10cSrcweir }
4168cdf0e10cSrcweir }
4169cdf0e10cSrcweir
~WW8PLCFx_Book()4170cdf0e10cSrcweir WW8PLCFx_Book::~WW8PLCFx_Book()
4171cdf0e10cSrcweir {
4172cdf0e10cSrcweir delete[] pStatus;
4173cdf0e10cSrcweir delete pBook[1];
4174cdf0e10cSrcweir delete pBook[0];
4175cdf0e10cSrcweir }
4176cdf0e10cSrcweir
HasValidPLCF()41772726b7b2SOliver-Rainer Wittmann bool WW8PLCFx_Book::HasValidPLCF()
41782726b7b2SOliver-Rainer Wittmann {
41792726b7b2SOliver-Rainer Wittmann return ( pBook[0] == 0 || pBook[0]->IsValid() )
41802726b7b2SOliver-Rainer Wittmann && ( pBook[1] == 0 || pBook[1]->IsValid() );
41812726b7b2SOliver-Rainer Wittmann }
41822726b7b2SOliver-Rainer Wittmann
GetIdx() const4183cdf0e10cSrcweir sal_uLong WW8PLCFx_Book::GetIdx() const
4184cdf0e10cSrcweir {
4185cdf0e10cSrcweir return nIMax ? pBook[0]->GetIdx() : 0;
4186cdf0e10cSrcweir }
4187cdf0e10cSrcweir
SetIdx(sal_uLong nI)4188cdf0e10cSrcweir void WW8PLCFx_Book::SetIdx( sal_uLong nI )
4189cdf0e10cSrcweir {
4190cdf0e10cSrcweir if( nIMax )
4191cdf0e10cSrcweir pBook[0]->SetIdx( nI );
4192cdf0e10cSrcweir }
4193cdf0e10cSrcweir
GetIdx2() const4194cdf0e10cSrcweir sal_uLong WW8PLCFx_Book::GetIdx2() const
4195cdf0e10cSrcweir {
4196cdf0e10cSrcweir return nIMax ? ( pBook[1]->GetIdx() | ( ( nIsEnd ) ? 0x80000000 : 0 ) ) : 0;
4197cdf0e10cSrcweir }
4198cdf0e10cSrcweir
SetIdx2(sal_uLong nI)4199cdf0e10cSrcweir void WW8PLCFx_Book::SetIdx2( sal_uLong nI )
4200cdf0e10cSrcweir {
4201cdf0e10cSrcweir if( nIMax )
4202cdf0e10cSrcweir {
4203cdf0e10cSrcweir pBook[1]->SetIdx( nI & 0x7fffffff );
4204cdf0e10cSrcweir nIsEnd = (sal_uInt16)( ( nI >> 31 ) & 1 ); // 0 oder 1
4205cdf0e10cSrcweir }
4206cdf0e10cSrcweir }
4207cdf0e10cSrcweir
SeekPos(WW8_CP nCpPos)4208cdf0e10cSrcweir bool WW8PLCFx_Book::SeekPos(WW8_CP nCpPos)
4209cdf0e10cSrcweir {
4210cdf0e10cSrcweir if( !pBook[0] )
4211cdf0e10cSrcweir return false;
4212cdf0e10cSrcweir
4213cdf0e10cSrcweir bool bOk = pBook[0]->SeekPosExact( nCpPos );
4214cdf0e10cSrcweir bOk &= pBook[1]->SeekPosExact( nCpPos );
4215cdf0e10cSrcweir nIsEnd = 0;
4216cdf0e10cSrcweir
4217cdf0e10cSrcweir return bOk;
4218cdf0e10cSrcweir }
4219cdf0e10cSrcweir
Where()4220cdf0e10cSrcweir WW8_CP WW8PLCFx_Book::Where()
4221cdf0e10cSrcweir {
4222cdf0e10cSrcweir return pBook[nIsEnd]->Where();
4223cdf0e10cSrcweir }
4224cdf0e10cSrcweir
GetNoSprms(WW8_CP & rStart,WW8_CP & rEnd,sal_Int32 & rLen)4225cdf0e10cSrcweir long WW8PLCFx_Book::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32& rLen )
4226cdf0e10cSrcweir {
4227cdf0e10cSrcweir void* pData;
4228cdf0e10cSrcweir rEnd = WW8_CP_MAX;
4229cdf0e10cSrcweir rLen = 0;
4230cdf0e10cSrcweir
4231cdf0e10cSrcweir if (!pBook[0] || !pBook[1] || !nIMax || (pBook[nIsEnd]->GetIdx()) >= nIMax)
4232cdf0e10cSrcweir {
4233cdf0e10cSrcweir rStart = rEnd = WW8_CP_MAX;
4234cdf0e10cSrcweir return -1;
4235cdf0e10cSrcweir }
4236cdf0e10cSrcweir
4237cdf0e10cSrcweir pBook[nIsEnd]->Get( rStart, pData ); // Pos. abfragen
4238cdf0e10cSrcweir
4239cdf0e10cSrcweir return pBook[nIsEnd]->GetIdx();
4240cdf0e10cSrcweir }
4241cdf0e10cSrcweir
4242cdf0e10cSrcweir // Der Operator ++ hat eine Tuecke: Wenn 2 Bookmarks aneinandergrenzen, dann
4243cdf0e10cSrcweir // sollte erst das Ende des ersten und dann der Anfang des 2. erreicht werden.
4244cdf0e10cSrcweir // Liegen jedoch 2 Bookmarks der Laenge 0 aufeinander, *muss* von jedem Bookmark
4245cdf0e10cSrcweir // erst der Anfang und dann das Ende gefunden werden.
4246cdf0e10cSrcweir // Der Fall: ][
4247cdf0e10cSrcweir // [...]
4248cdf0e10cSrcweir // ][
4249cdf0e10cSrcweir // ist noch nicht geloest, dabei muesste ich in den Anfangs- und Endindices
4250cdf0e10cSrcweir // vor- und zurueckspringen, wobei ein weiterer Index oder ein Bitfeld
4251cdf0e10cSrcweir // oder etwas aehnliches zum Merken der bereits abgearbeiteten Bookmarks
4252cdf0e10cSrcweir // noetig wird.
operator ++(int)4253cdf0e10cSrcweir WW8PLCFx& WW8PLCFx_Book::operator ++( int )
4254cdf0e10cSrcweir {
4255cdf0e10cSrcweir if( pBook[0] && pBook[1] && nIMax )
4256cdf0e10cSrcweir {
4257cdf0e10cSrcweir (*pBook[nIsEnd])++;
4258cdf0e10cSrcweir
4259cdf0e10cSrcweir sal_uLong l0 = pBook[0]->Where();
4260cdf0e10cSrcweir sal_uLong l1 = pBook[1]->Where();
4261cdf0e10cSrcweir if( l0 < l1 )
4262cdf0e10cSrcweir nIsEnd = 0;
4263cdf0e10cSrcweir else if( l1 < l0 )
4264cdf0e10cSrcweir nIsEnd = 1;
4265cdf0e10cSrcweir else
4266f66c5aafSOliver-Rainer Wittmann {
4267f66c5aafSOliver-Rainer Wittmann const void * p = pBook[0]->GetData(pBook[0]->GetIdx());
4268f66c5aafSOliver-Rainer Wittmann long nPairFor = (p == NULL)? 0L : SVBT16ToShort(*((SVBT16*) p));
4269f66c5aafSOliver-Rainer Wittmann if (nPairFor == pBook[1]->GetIdx())
4270f66c5aafSOliver-Rainer Wittmann nIsEnd = 0;
4271f66c5aafSOliver-Rainer Wittmann else
4272f66c5aafSOliver-Rainer Wittmann nIsEnd = ( nIsEnd ) ? 0 : 1;
4273f66c5aafSOliver-Rainer Wittmann }
4274cdf0e10cSrcweir }
4275cdf0e10cSrcweir return *this;
4276cdf0e10cSrcweir }
4277cdf0e10cSrcweir
GetLen() const4278cdf0e10cSrcweir long WW8PLCFx_Book::GetLen() const
4279cdf0e10cSrcweir {
4280cdf0e10cSrcweir if( nIsEnd )
4281cdf0e10cSrcweir {
4282cdf0e10cSrcweir ASSERT( !this, "Falscher Aufruf (1) von PLCF_Book::GetLen()" );
4283cdf0e10cSrcweir return 0;
4284cdf0e10cSrcweir }
4285cdf0e10cSrcweir void * p;
4286cdf0e10cSrcweir WW8_CP nStartPos;
4287cdf0e10cSrcweir if( !pBook[0]->Get( nStartPos, p ) )
4288cdf0e10cSrcweir {
4289cdf0e10cSrcweir ASSERT( !this, "Falscher Aufruf (2) von PLCF_Book::GetLen()" );
4290cdf0e10cSrcweir return 0;
4291cdf0e10cSrcweir }
4292cdf0e10cSrcweir sal_uInt16 nEndIdx = SVBT16ToShort( *((SVBT16*)p) );
4293cdf0e10cSrcweir long nNum = pBook[1]->GetPos( nEndIdx );
4294cdf0e10cSrcweir nNum -= nStartPos;
4295cdf0e10cSrcweir return nNum;
4296cdf0e10cSrcweir }
4297cdf0e10cSrcweir
SetStatus(sal_uInt16 nIndex,eBookStatus eStat)4298cdf0e10cSrcweir void WW8PLCFx_Book::SetStatus(sal_uInt16 nIndex, eBookStatus eStat )
4299cdf0e10cSrcweir {
4300cdf0e10cSrcweir ASSERT(nIndex < nIMax, "set status of non existing bookmark!");
4301bbdbb408SAndrea Pescetti if ( nIndex < nIMax )
4302bbdbb408SAndrea Pescetti pStatus[nIndex] = (eBookStatus)( pStatus[nIndex] | eStat );
4303cdf0e10cSrcweir }
4304cdf0e10cSrcweir
GetStatus() const4305cdf0e10cSrcweir eBookStatus WW8PLCFx_Book::GetStatus() const
4306cdf0e10cSrcweir {
4307cdf0e10cSrcweir if( !pStatus )
4308cdf0e10cSrcweir return BOOK_NORMAL;
4309cdf0e10cSrcweir long nEndIdx = GetHandle();
4310cdf0e10cSrcweir return ( nEndIdx < nIMax ) ? pStatus[nEndIdx] : BOOK_NORMAL;
4311cdf0e10cSrcweir }
4312cdf0e10cSrcweir
GetHandle() const4313cdf0e10cSrcweir long WW8PLCFx_Book::GetHandle() const
4314cdf0e10cSrcweir {
4315cdf0e10cSrcweir if( !pBook[0] || !pBook[1] )
4316cdf0e10cSrcweir return LONG_MAX;
4317cdf0e10cSrcweir
4318cdf0e10cSrcweir if( nIsEnd )
4319cdf0e10cSrcweir return pBook[1]->GetIdx();
4320cdf0e10cSrcweir else
4321cdf0e10cSrcweir {
4322cdf0e10cSrcweir if (const void* p = pBook[0]->GetData(pBook[0]->GetIdx()))
4323cdf0e10cSrcweir return SVBT16ToShort( *((SVBT16*)p) );
4324cdf0e10cSrcweir else
4325cdf0e10cSrcweir return LONG_MAX;
4326cdf0e10cSrcweir }
4327cdf0e10cSrcweir }
4328cdf0e10cSrcweir
GetBookmark(long nStart,long nEnd,sal_uInt16 & nIndex)4329cdf0e10cSrcweir String WW8PLCFx_Book::GetBookmark(long nStart,long nEnd, sal_uInt16 &nIndex)
4330cdf0e10cSrcweir {
4331cdf0e10cSrcweir bool bFound = false;
4332cdf0e10cSrcweir sal_uInt16 i = 0;
4333cdf0e10cSrcweir if( pBook[0] && pBook[1] )
4334cdf0e10cSrcweir {
4335cdf0e10cSrcweir WW8_CP nStartAkt, nEndAkt;
4336cdf0e10cSrcweir do
4337cdf0e10cSrcweir {
4338cdf0e10cSrcweir void* p;
4339cdf0e10cSrcweir sal_uInt16 nEndIdx;
4340cdf0e10cSrcweir
4341cdf0e10cSrcweir if( pBook[0]->GetData( i, nStartAkt, p ) && p )
4342cdf0e10cSrcweir nEndIdx = SVBT16ToShort( *((SVBT16*)p) );
4343cdf0e10cSrcweir else
4344cdf0e10cSrcweir {
4345cdf0e10cSrcweir ASSERT( !this, "Bookmark-EndIdx nicht lesbar" );
4346cdf0e10cSrcweir nEndIdx = i;
4347cdf0e10cSrcweir }
4348cdf0e10cSrcweir
4349cdf0e10cSrcweir nEndAkt = pBook[1]->GetPos( nEndIdx );
4350cdf0e10cSrcweir
4351cdf0e10cSrcweir if ((nStartAkt >= nStart) && (nEndAkt <= nEnd))
4352cdf0e10cSrcweir {
4353cdf0e10cSrcweir nIndex = i;
4354cdf0e10cSrcweir bFound=true;
4355cdf0e10cSrcweir break;
4356cdf0e10cSrcweir }
4357cdf0e10cSrcweir ++i;
4358cdf0e10cSrcweir }
4359cdf0e10cSrcweir while (i < pBook[0]->GetIMax());
4360cdf0e10cSrcweir }
4361cdf0e10cSrcweir return bFound ? aBookNames[i] : aEmptyStr;
4362cdf0e10cSrcweir }
4363cdf0e10cSrcweir
GetUniqueBookmarkName(String & suggestedName)4364cdf0e10cSrcweir String WW8PLCFx_Book::GetUniqueBookmarkName(String &suggestedName)
4365cdf0e10cSrcweir {
4366cdf0e10cSrcweir String aRet=(suggestedName.Len()==0?String::CreateFromAscii("Unnamed"):suggestedName);
4367cdf0e10cSrcweir unsigned int i=0;
4368cdf0e10cSrcweir while(i<aBookNames.size()) {
4369cdf0e10cSrcweir String &s=aBookNames[i];
4370cdf0e10cSrcweir if (aRet.CompareTo(s)==0) {
4371cdf0e10cSrcweir int len=aRet.Len();
4372cdf0e10cSrcweir int p=len-1;
4373cdf0e10cSrcweir while(p>0 && aRet.GetChar(static_cast<sal_uInt16>(p))>='0' && aRet.GetChar(static_cast<sal_uInt16>(p))<='9')
4374cdf0e10cSrcweir p--;
4375cdf0e10cSrcweir aRet=String(aRet, 0, static_cast<sal_uInt16>(p+1));
4376cdf0e10cSrcweir aRet += String::CreateFromInt32( nBookmarkId++ );
4377cdf0e10cSrcweir i=0; // start search from beginning
4378cdf0e10cSrcweir } else {
4379cdf0e10cSrcweir i++;
4380cdf0e10cSrcweir }
4381cdf0e10cSrcweir }
4382cdf0e10cSrcweir return aRet;
4383cdf0e10cSrcweir }
4384cdf0e10cSrcweir
MapName(String & rName)4385cdf0e10cSrcweir bool WW8PLCFx_Book::MapName(String& rName)
4386cdf0e10cSrcweir {
4387cdf0e10cSrcweir if( !pBook[0] || !pBook[1] )
4388cdf0e10cSrcweir return false;
4389cdf0e10cSrcweir
4390cdf0e10cSrcweir bool bFound = false;
4391cdf0e10cSrcweir sal_uInt16 i = 0;
4392cdf0e10cSrcweir WW8_CP nStartAkt, nEndAkt;
4393cdf0e10cSrcweir do
4394cdf0e10cSrcweir {
4395cdf0e10cSrcweir void* p;
4396cdf0e10cSrcweir sal_uInt16 nEndIdx;
4397cdf0e10cSrcweir
4398cdf0e10cSrcweir if( pBook[0]->GetData( i, nStartAkt, p ) && p )
4399cdf0e10cSrcweir nEndIdx = SVBT16ToShort( *((SVBT16*)p) );
4400cdf0e10cSrcweir else
4401cdf0e10cSrcweir {
4402cdf0e10cSrcweir ASSERT( !this, "Bookmark-EndIdx nicht lesbar" );
4403cdf0e10cSrcweir nEndIdx = i;
4404cdf0e10cSrcweir }
4405cdf0e10cSrcweir nEndAkt = pBook[1]->GetPos( nEndIdx );
4406cdf0e10cSrcweir if (COMPARE_EQUAL == rName.CompareIgnoreCaseToAscii(aBookNames[i]))
4407cdf0e10cSrcweir {
4408cdf0e10cSrcweir rName = aBookNames[i];
4409cdf0e10cSrcweir bFound = true;
4410cdf0e10cSrcweir }
4411cdf0e10cSrcweir ++i;
4412cdf0e10cSrcweir }
4413cdf0e10cSrcweir while (!bFound && i < pBook[0]->GetIMax());
4414cdf0e10cSrcweir return bFound;
4415cdf0e10cSrcweir }
4416cdf0e10cSrcweir
GetName() const4417cdf0e10cSrcweir const String* WW8PLCFx_Book::GetName() const
4418cdf0e10cSrcweir {
4419cdf0e10cSrcweir const String *pRet = 0;
4420cdf0e10cSrcweir if (!nIsEnd && (pBook[0]->GetIdx() < nIMax))
4421cdf0e10cSrcweir pRet = &(aBookNames[pBook[0]->GetIdx()]);
4422cdf0e10cSrcweir return pRet;
4423cdf0e10cSrcweir }
4424cdf0e10cSrcweir
4425cdf0e10cSrcweir //-----------------------------------------
4426cdf0e10cSrcweir // WW8PLCFMan
4427cdf0e10cSrcweir //-----------------------------------------
4428cdf0e10cSrcweir
4429cdf0e10cSrcweir #ifndef DUMP
4430cdf0e10cSrcweir
4431cdf0e10cSrcweir // Am Ende eines Absatzes reichen bei WW6 die Attribute bis hinter das <CR>.
4432cdf0e10cSrcweir // Das wird fuer die Verwendung mit dem SW um 1 Zeichen zurueckgesetzt, wenn
4433cdf0e10cSrcweir // dadurch kein AErger zu erwarten ist.
AdjustEnds(WW8PLCFxDesc & rDesc)4434cdf0e10cSrcweir void WW8PLCFMan::AdjustEnds( WW8PLCFxDesc& rDesc )
4435cdf0e10cSrcweir {
4436cdf0e10cSrcweir //Store old end position for supercool new property finder that uses
4437cdf0e10cSrcweir //cp instead of fc's as nature intended
4438cdf0e10cSrcweir rDesc.nOrigEndPos = rDesc.nEndPos;
4439cdf0e10cSrcweir rDesc.nOrigStartPos = rDesc.nStartPos;
4440cdf0e10cSrcweir
4441cdf0e10cSrcweir /*
4442cdf0e10cSrcweir Normally given ^XXX{para end}^ we don't actually insert a para end
4443cdf0e10cSrcweir character into the document, so we clip the para end property one to the
4444cdf0e10cSrcweir left to make the para properties end when the paragraph text does. In a
4445cdf0e10cSrcweir drawing textbox we actually do insert a para end character, so we don't
4446cdf0e10cSrcweir clip it. Making the para end properties end after the para end char.
4447cdf0e10cSrcweir */
4448cdf0e10cSrcweir if (GetDoingDrawTextBox())
4449cdf0e10cSrcweir return;
4450cdf0e10cSrcweir
4451cdf0e10cSrcweir if ( (&rDesc == pPap) && rDesc.bRealLineEnd )
4452cdf0e10cSrcweir {
4453cdf0e10cSrcweir if ( pPap->nEndPos != WW8_CP_MAX ) // Para adjust
4454cdf0e10cSrcweir {
4455cdf0e10cSrcweir nLineEnd = pPap->nEndPos;// nLineEnd zeigt *hinter* das <CR>
4456cdf0e10cSrcweir pPap->nEndPos--; // Absatzende um 1 Zeichen verkuerzen
4457cdf0e10cSrcweir
4458cdf0e10cSrcweir // gibt es bereits ein CharAttr-Ende das auf das jetzige
4459cdf0e10cSrcweir // Absatzende zeigt ? ... dann auch um 1 Zeichen verkuerzen
4460cdf0e10cSrcweir if (pChp->nEndPos == nLineEnd)
4461cdf0e10cSrcweir pChp->nEndPos--;
4462cdf0e10cSrcweir
4463cdf0e10cSrcweir // gibt es bereits ein Sep-Ende, das auf das jetzige Absatzende
4464cdf0e10cSrcweir // zeigt ? ... dann auch um 1 Zeichen verkuerzen
4465cdf0e10cSrcweir if( pSep->nEndPos == nLineEnd )
4466cdf0e10cSrcweir pSep->nEndPos--;
4467cdf0e10cSrcweir }
4468cdf0e10cSrcweir }
4469cdf0e10cSrcweir else if ( (&rDesc == pChp) || (&rDesc == pSep) )
4470cdf0e10cSrcweir {
4471cdf0e10cSrcweir // Char Adjust oder Sep Adjust Wenn Ende Char-Attr == Absatzende ...
4472cdf0e10cSrcweir if( (rDesc.nEndPos == nLineEnd) && (rDesc.nEndPos > rDesc.nStartPos) )
4473cdf0e10cSrcweir rDesc.nEndPos--; // ... dann um 1 Zeichen verkuerzen
4474cdf0e10cSrcweir }
4475cdf0e10cSrcweir }
4476cdf0e10cSrcweir
ReduceByOffset()4477cdf0e10cSrcweir void WW8PLCFxDesc::ReduceByOffset()
4478cdf0e10cSrcweir {
4479cdf0e10cSrcweir ASSERT((WW8_CP_MAX == nStartPos) || (nStartPos <= nEndPos),
4480cdf0e10cSrcweir "Attr-Anfang und -Ende ueber Kreuz" );
4481cdf0e10cSrcweir
4482cdf0e10cSrcweir if( nStartPos != WW8_CP_MAX )
4483cdf0e10cSrcweir {
4484cdf0e10cSrcweir /*
4485cdf0e10cSrcweir ##516##,##517##
4486cdf0e10cSrcweir Force the property change to happen at the beginning of this
4487cdf0e10cSrcweir subdocument, same as in GetNewNoSprms, except that the target type is
4488cdf0e10cSrcweir attributes attached to a piece that might span subdocument boundaries
4489cdf0e10cSrcweir */
4490cdf0e10cSrcweir if (nCpOfs > nStartPos)
4491cdf0e10cSrcweir nStartPos = 0;
4492cdf0e10cSrcweir else
4493cdf0e10cSrcweir nStartPos -= nCpOfs;
4494cdf0e10cSrcweir }
4495cdf0e10cSrcweir if( nEndPos != WW8_CP_MAX )
4496cdf0e10cSrcweir {
4497cdf0e10cSrcweir ASSERT(nCpOfs <= nEndPos,
4498cdf0e10cSrcweir "oh oh, so much for the subdocument piece theory");
4499cdf0e10cSrcweir nEndPos -= nCpOfs;
4500cdf0e10cSrcweir }
4501cdf0e10cSrcweir }
4502cdf0e10cSrcweir
GetNewSprms(WW8PLCFxDesc & rDesc)4503cdf0e10cSrcweir void WW8PLCFMan::GetNewSprms( WW8PLCFxDesc& rDesc )
4504cdf0e10cSrcweir {
4505cdf0e10cSrcweir rDesc.pPLCFx->GetSprms(&rDesc);
4506cdf0e10cSrcweir rDesc.ReduceByOffset();
4507cdf0e10cSrcweir
4508cdf0e10cSrcweir rDesc.bFirstSprm = true;
4509cdf0e10cSrcweir AdjustEnds( rDesc );
4510cdf0e10cSrcweir rDesc.nOrigSprmsLen = rDesc.nSprmsLen;
4511cdf0e10cSrcweir }
4512cdf0e10cSrcweir
GetNewNoSprms(WW8PLCFxDesc & rDesc)4513cdf0e10cSrcweir void WW8PLCFMan::GetNewNoSprms( WW8PLCFxDesc& rDesc )
4514cdf0e10cSrcweir {
4515cdf0e10cSrcweir rDesc.nCp2OrIdx = rDesc.pPLCFx->GetNoSprms(rDesc.nStartPos, rDesc.nEndPos,
4516cdf0e10cSrcweir rDesc.nSprmsLen);
4517cdf0e10cSrcweir
4518cdf0e10cSrcweir ASSERT((WW8_CP_MAX == rDesc.nStartPos) || (rDesc.nStartPos <= rDesc.nEndPos),
4519cdf0e10cSrcweir "Attr-Anfang und -Ende ueber Kreuz" );
4520cdf0e10cSrcweir
4521cdf0e10cSrcweir rDesc.ReduceByOffset();
4522cdf0e10cSrcweir
4523cdf0e10cSrcweir rDesc.bFirstSprm = true;
4524cdf0e10cSrcweir rDesc.nOrigSprmsLen = rDesc.nSprmsLen;
4525cdf0e10cSrcweir }
4526cdf0e10cSrcweir
GetId(const WW8PLCFxDesc * p) const4527cdf0e10cSrcweir sal_uInt16 WW8PLCFMan::GetId(const WW8PLCFxDesc* p) const
4528cdf0e10cSrcweir {
4529cdf0e10cSrcweir sal_uInt16 nId;
4530cdf0e10cSrcweir
4531cdf0e10cSrcweir if (p == pFld)
4532cdf0e10cSrcweir nId = eFLD;
4533cdf0e10cSrcweir else if (p == pFtn)
4534cdf0e10cSrcweir nId = eFTN;
4535cdf0e10cSrcweir else if (p == pEdn)
4536cdf0e10cSrcweir nId = eEDN;
4537cdf0e10cSrcweir else if (p == pAnd)
4538cdf0e10cSrcweir nId = eAND;
4539cdf0e10cSrcweir else if (p->nSprmsLen > 0)
4540cdf0e10cSrcweir nId = maSprmParser.GetSprmId(p->pMemPos);
4541cdf0e10cSrcweir else
4542cdf0e10cSrcweir nId = 0; // Id = 0 for empty attributes
4543cdf0e10cSrcweir
4544cdf0e10cSrcweir return nId;
4545cdf0e10cSrcweir }
4546cdf0e10cSrcweir
WW8PLCFMan(WW8ScannerBase * pBase,ManTypes nType,long nStartCp,bool bDoingDrawTextBox)4547cdf0e10cSrcweir WW8PLCFMan::WW8PLCFMan(WW8ScannerBase* pBase, ManTypes nType, long nStartCp,
4548cdf0e10cSrcweir bool bDoingDrawTextBox)
4549cdf0e10cSrcweir : maSprmParser(pBase->pWw8Fib->GetFIBVersion()),
4550cdf0e10cSrcweir mbDoingDrawTextBox(bDoingDrawTextBox)
4551cdf0e10cSrcweir {
4552cdf0e10cSrcweir pWwFib = pBase->pWw8Fib;
4553cdf0e10cSrcweir
4554cdf0e10cSrcweir nLastWhereIdxCp = 0;
4555cdf0e10cSrcweir memset( aD, 0, sizeof( aD ) );
4556cdf0e10cSrcweir nLineEnd = WW8_CP_MAX;
4557cdf0e10cSrcweir nManType = nType;
4558cdf0e10cSrcweir sal_uInt16 i;
4559cdf0e10cSrcweir
4560cdf0e10cSrcweir if( MAN_MAINTEXT == nType )
4561cdf0e10cSrcweir {
4562cdf0e10cSrcweir // Suchreihenfolge der Attribute
4563cdf0e10cSrcweir nPLCF = MAN_ANZ_PLCF;
4564cdf0e10cSrcweir pFld = &aD[0];
4565cdf0e10cSrcweir pBkm = &aD[1];
4566cdf0e10cSrcweir pEdn = &aD[2];
4567cdf0e10cSrcweir pFtn = &aD[3];
4568cdf0e10cSrcweir pAnd = &aD[4];
4569cdf0e10cSrcweir
4570cdf0e10cSrcweir pPcd = ( pBase->pPLCFx_PCD ) ? &aD[5] : 0;
4571cdf0e10cSrcweir //pPcdA index == pPcd index + 1
4572cdf0e10cSrcweir pPcdA = ( pBase->pPLCFx_PCDAttrs ) ? &aD[6] : 0;
4573cdf0e10cSrcweir
4574cdf0e10cSrcweir pChp = &aD[7];
4575cdf0e10cSrcweir pPap = &aD[8];
4576cdf0e10cSrcweir pSep = &aD[9];
4577cdf0e10cSrcweir
4578cdf0e10cSrcweir pSep->pPLCFx = pBase->pSepPLCF;
4579cdf0e10cSrcweir pFtn->pPLCFx = pBase->pFtnPLCF;
4580cdf0e10cSrcweir pEdn->pPLCFx = pBase->pEdnPLCF;
4581cdf0e10cSrcweir pBkm->pPLCFx = pBase->pBook;
4582cdf0e10cSrcweir pAnd->pPLCFx = pBase->pAndPLCF;
4583cdf0e10cSrcweir
4584cdf0e10cSrcweir }
4585cdf0e10cSrcweir else
4586cdf0e10cSrcweir {
4587cdf0e10cSrcweir // Suchreihenfolge der Attribute
4588cdf0e10cSrcweir nPLCF = 7;
4589cdf0e10cSrcweir pFld = &aD[0];
4590cdf0e10cSrcweir pBkm = ( pBase->pBook ) ? &aD[1] : 0;
4591cdf0e10cSrcweir
4592cdf0e10cSrcweir pPcd = ( pBase->pPLCFx_PCD ) ? &aD[2] : 0;
4593cdf0e10cSrcweir //pPcdA index == pPcd index + 1
4594cdf0e10cSrcweir pPcdA= ( pBase->pPLCFx_PCDAttrs ) ? &aD[3] : 0;
4595cdf0e10cSrcweir
4596cdf0e10cSrcweir pChp = &aD[4];
4597cdf0e10cSrcweir pPap = &aD[5];
4598cdf0e10cSrcweir pSep = &aD[6]; // Dummy
4599cdf0e10cSrcweir
4600cdf0e10cSrcweir pAnd = pFtn = pEdn = 0; // unbenutzt bei SpezText
4601cdf0e10cSrcweir }
4602cdf0e10cSrcweir
4603cdf0e10cSrcweir pChp->pPLCFx = pBase->pChpPLCF;
4604cdf0e10cSrcweir pPap->pPLCFx = pBase->pPapPLCF;
4605cdf0e10cSrcweir if( pPcd )
4606cdf0e10cSrcweir pPcd->pPLCFx = pBase->pPLCFx_PCD;
4607cdf0e10cSrcweir if( pPcdA )
4608cdf0e10cSrcweir pPcdA->pPLCFx= pBase->pPLCFx_PCDAttrs;
4609cdf0e10cSrcweir if( pBkm )
4610cdf0e10cSrcweir pBkm->pPLCFx = pBase->pBook;
4611cdf0e10cSrcweir
4612cdf0e10cSrcweir pMagicTables = pBase->pMagicTables;
4613cdf0e10cSrcweir pSubdocs = pBase->pSubdocs;
4614cdf0e10cSrcweir pExtendedAtrds = pBase->pExtendedAtrds;
4615cdf0e10cSrcweir
4616cdf0e10cSrcweir switch( nType ) // Feld-Initialisierung
4617cdf0e10cSrcweir {
4618cdf0e10cSrcweir case MAN_HDFT:
4619cdf0e10cSrcweir pFld->pPLCFx = pBase->pFldHdFtPLCF;
4620cdf0e10cSrcweir pFdoa = pBase->pHdFtFdoa;
4621cdf0e10cSrcweir pTxbx = pBase->pHdFtTxbx;
4622cdf0e10cSrcweir pTxbxBkd = pBase->pHdFtTxbxBkd;
4623cdf0e10cSrcweir break;
4624cdf0e10cSrcweir case MAN_FTN:
4625cdf0e10cSrcweir pFld->pPLCFx = pBase->pFldFtnPLCF;
4626cdf0e10cSrcweir pFdoa = pTxbx = pTxbxBkd = 0;
4627cdf0e10cSrcweir break;
4628cdf0e10cSrcweir case MAN_EDN:
4629cdf0e10cSrcweir pFld->pPLCFx = pBase->pFldEdnPLCF;
4630cdf0e10cSrcweir pFdoa = pTxbx = pTxbxBkd = 0;
4631cdf0e10cSrcweir break;
4632cdf0e10cSrcweir case MAN_AND:
4633cdf0e10cSrcweir pFld->pPLCFx = pBase->pFldAndPLCF;
4634cdf0e10cSrcweir pFdoa = pTxbx = pTxbxBkd = 0;
4635cdf0e10cSrcweir break;
4636cdf0e10cSrcweir case MAN_TXBX:
4637cdf0e10cSrcweir pFld->pPLCFx = pBase->pFldTxbxPLCF;
4638cdf0e10cSrcweir pTxbx = pBase->pMainTxbx;
4639cdf0e10cSrcweir pTxbxBkd = pBase->pMainTxbxBkd;
4640cdf0e10cSrcweir pFdoa = 0;
4641cdf0e10cSrcweir break;
4642cdf0e10cSrcweir case MAN_TXBX_HDFT:
4643cdf0e10cSrcweir pFld->pPLCFx = pBase->pFldTxbxHdFtPLCF;
4644cdf0e10cSrcweir pTxbx = pBase->pHdFtTxbx;
4645cdf0e10cSrcweir pTxbxBkd = pBase->pHdFtTxbxBkd;
4646cdf0e10cSrcweir pFdoa = 0;
4647cdf0e10cSrcweir break;
4648cdf0e10cSrcweir default:
4649cdf0e10cSrcweir pFld->pPLCFx = pBase->pFldPLCF;
4650cdf0e10cSrcweir pFdoa = pBase->pMainFdoa;
4651cdf0e10cSrcweir pTxbx = pBase->pMainTxbx;
4652cdf0e10cSrcweir pTxbxBkd = pBase->pMainTxbxBkd;
4653cdf0e10cSrcweir break;
4654cdf0e10cSrcweir }
4655cdf0e10cSrcweir
4656cdf0e10cSrcweir nCpO = pWwFib->GetBaseCp(nType);
4657cdf0e10cSrcweir
4658cdf0e10cSrcweir if( nStartCp || nCpO )
4659cdf0e10cSrcweir SeekPos( nStartCp ); // PLCFe auf Text-StartPos einstellen
4660cdf0e10cSrcweir
4661cdf0e10cSrcweir // initialisieren der Member-Vars Low-Level
4662cdf0e10cSrcweir GetChpPLCF()->ResetAttrStartEnd();
4663cdf0e10cSrcweir GetPapPLCF()->ResetAttrStartEnd();
4664cdf0e10cSrcweir for( i=0; i < nPLCF; i++)
4665cdf0e10cSrcweir {
4666cdf0e10cSrcweir WW8PLCFxDesc* p = &aD[i];
4667cdf0e10cSrcweir
4668cdf0e10cSrcweir /*
4669cdf0e10cSrcweir ##516##,##517##
4670cdf0e10cSrcweir For subdocuments we modify the cp of properties to be relative to
4671cdf0e10cSrcweir the beginning of subdocuments, we should also do the same for
4672cdf0e10cSrcweir piecetable changes, and piecetable properties, otherwise a piece
4673cdf0e10cSrcweir change that happens in a subdocument is lost.
4674cdf0e10cSrcweir */
4675cdf0e10cSrcweir p->nCpOfs = ( p == pChp || p == pPap || p == pBkm || p == pPcd ||
4676cdf0e10cSrcweir p == pPcdA ) ? nCpO : 0;
4677cdf0e10cSrcweir
4678cdf0e10cSrcweir p->nCp2OrIdx = 0;
4679cdf0e10cSrcweir p->bFirstSprm = false;
4680cdf0e10cSrcweir p->pIdStk = 0;
4681cdf0e10cSrcweir
4682cdf0e10cSrcweir if ((p == pChp) || (p == pPap))
4683cdf0e10cSrcweir p->nStartPos = p->nEndPos = nStartCp;
4684cdf0e10cSrcweir else
4685cdf0e10cSrcweir p->nStartPos = p->nEndPos = WW8_CP_MAX;
4686cdf0e10cSrcweir }
4687cdf0e10cSrcweir
4688cdf0e10cSrcweir // initialisieren der Member-Vars High-Level
4689cdf0e10cSrcweir for( i=0; i<nPLCF; i++){
4690cdf0e10cSrcweir WW8PLCFxDesc* p = &aD[i];
4691cdf0e10cSrcweir
4692cdf0e10cSrcweir if( !p->pPLCFx )
4693cdf0e10cSrcweir {
4694cdf0e10cSrcweir p->nStartPos = p->nEndPos = WW8_CP_MAX;
4695cdf0e10cSrcweir continue;
4696cdf0e10cSrcweir }
4697cdf0e10cSrcweir
4698cdf0e10cSrcweir if( p->pPLCFx->IsSprm() )
4699cdf0e10cSrcweir {
4700cdf0e10cSrcweir // Vorsicht: nEndPos muss bereits
4701cdf0e10cSrcweir p->pIdStk = new std::stack<sal_uInt16>;
4702cdf0e10cSrcweir if ((p == pChp) || (p == pPap))
4703cdf0e10cSrcweir {
4704cdf0e10cSrcweir WW8_CP nTemp = p->nEndPos+p->nCpOfs;
4705cdf0e10cSrcweir p->pMemPos = 0;
4706cdf0e10cSrcweir p->nSprmsLen = 0;
4707cdf0e10cSrcweir p->nStartPos = nTemp;
4708cdf0e10cSrcweir if (!(*p->pPLCFx).SeekPos(p->nStartPos))
4709cdf0e10cSrcweir p->nEndPos = p->nStartPos = WW8_CP_MAX;
4710cdf0e10cSrcweir else
4711cdf0e10cSrcweir GetNewSprms( *p );
4712cdf0e10cSrcweir }
4713cdf0e10cSrcweir else
4714cdf0e10cSrcweir GetNewSprms( *p ); // bei allen PLCFen initialisiert sein
4715cdf0e10cSrcweir }
4716cdf0e10cSrcweir else if( p->pPLCFx )
4717cdf0e10cSrcweir GetNewNoSprms( *p );
4718cdf0e10cSrcweir }
4719cdf0e10cSrcweir }
4720cdf0e10cSrcweir
~WW8PLCFMan()4721cdf0e10cSrcweir WW8PLCFMan::~WW8PLCFMan()
4722cdf0e10cSrcweir {
4723cdf0e10cSrcweir for( sal_uInt16 i=0; i<nPLCF; i++)
4724cdf0e10cSrcweir delete aD[i].pIdStk;
4725cdf0e10cSrcweir }
4726cdf0e10cSrcweir
4727cdf0e10cSrcweir // 0. welche Attr.-Klasse,
4728cdf0e10cSrcweir // 1. ob ein Attr.-Start ist,
4729cdf0e10cSrcweir // 2. CP, wo ist naechste Attr.-Aenderung
WhereIdx(bool * pbStart,long * pPos) const4730cdf0e10cSrcweir sal_uInt16 WW8PLCFMan::WhereIdx(bool* pbStart, long* pPos) const
4731cdf0e10cSrcweir {
4732cdf0e10cSrcweir ASSERT(nPLCF,"What the hell");
4733cdf0e10cSrcweir long nNext = LONG_MAX; // SuchReihenfolge:
4734cdf0e10cSrcweir sal_uInt16 nNextIdx = nPLCF;// first ending found ( CHP, PAP, ( SEP ) ),
4735cdf0e10cSrcweir bool bStart = true; // dann Anfaenge finden ( ( SEP ), PAP, CHP )
4736cdf0e10cSrcweir sal_uInt16 i;
4737cdf0e10cSrcweir const WW8PLCFxDesc* pD;
4738cdf0e10cSrcweir for (i=0; i < nPLCF; i++)
4739cdf0e10cSrcweir {
4740cdf0e10cSrcweir pD = &aD[i];
4741cdf0e10cSrcweir if (pD != pPcdA)
4742cdf0e10cSrcweir {
4743cdf0e10cSrcweir if( (pD->nEndPos < nNext) && (pD->nStartPos == WW8_CP_MAX) )
4744cdf0e10cSrcweir {
4745cdf0e10cSrcweir // sonst ist Anfang = Ende
4746cdf0e10cSrcweir nNext = pD->nEndPos;
4747cdf0e10cSrcweir nNextIdx = i;
4748cdf0e10cSrcweir bStart = false;
4749cdf0e10cSrcweir }
4750cdf0e10cSrcweir }
4751cdf0e10cSrcweir }
4752cdf0e10cSrcweir for (i=nPLCF; i > 0; i--)
4753cdf0e10cSrcweir {
4754cdf0e10cSrcweir pD = &aD[i-1];
4755cdf0e10cSrcweir if (pD != pPcdA)
4756cdf0e10cSrcweir {
4757cdf0e10cSrcweir if( pD->nStartPos < nNext )
4758cdf0e10cSrcweir {
4759cdf0e10cSrcweir nNext = pD->nStartPos;
4760cdf0e10cSrcweir nNextIdx = i-1;
4761cdf0e10cSrcweir bStart = true;
4762cdf0e10cSrcweir }
4763cdf0e10cSrcweir }
4764cdf0e10cSrcweir }
4765cdf0e10cSrcweir if( pPos )
4766cdf0e10cSrcweir *pPos = nNext;
4767cdf0e10cSrcweir if( pbStart )
4768cdf0e10cSrcweir *pbStart = bStart;
4769cdf0e10cSrcweir return nNextIdx;
4770cdf0e10cSrcweir }
4771cdf0e10cSrcweir
4772cdf0e10cSrcweir // gibt die CP-Pos der naechsten Attribut-Aenderung zurueck
Where() const4773cdf0e10cSrcweir WW8_CP WW8PLCFMan::Where() const
4774cdf0e10cSrcweir {
4775cdf0e10cSrcweir long l;
4776cdf0e10cSrcweir WhereIdx(0, &l);
4777cdf0e10cSrcweir return l;
4778cdf0e10cSrcweir }
4779cdf0e10cSrcweir
SeekPos(long nNewCp)4780cdf0e10cSrcweir void WW8PLCFMan::SeekPos( long nNewCp )
4781cdf0e10cSrcweir {
4782cdf0e10cSrcweir pChp->pPLCFx->SeekPos( nNewCp + nCpO ); // Attribute neu
4783cdf0e10cSrcweir pPap->pPLCFx->SeekPos( nNewCp + nCpO ); // aufsetzen
4784cdf0e10cSrcweir pFld->pPLCFx->SeekPos( nNewCp );
4785cdf0e10cSrcweir if( pPcd )
4786cdf0e10cSrcweir pPcd->pPLCFx->SeekPos( nNewCp + nCpO );
4787cdf0e10cSrcweir if( pBkm )
4788cdf0e10cSrcweir pBkm->pPLCFx->SeekPos( nNewCp + nCpO );
4789cdf0e10cSrcweir }
4790cdf0e10cSrcweir
SaveAllPLCFx(WW8PLCFxSaveAll & rSave) const4791cdf0e10cSrcweir void WW8PLCFMan::SaveAllPLCFx( WW8PLCFxSaveAll& rSave ) const
4792cdf0e10cSrcweir {
4793cdf0e10cSrcweir sal_uInt16 i, n=0;
4794cdf0e10cSrcweir if( pPcd )
4795cdf0e10cSrcweir pPcd->Save( rSave.aS[n++] );
4796cdf0e10cSrcweir if( pPcdA )
4797cdf0e10cSrcweir pPcdA->Save( rSave.aS[n++] );
4798cdf0e10cSrcweir
4799cdf0e10cSrcweir for(i=0; i<nPLCF; ++i)
4800cdf0e10cSrcweir if( pPcd != &aD[i] && pPcdA != &aD[i] )
4801cdf0e10cSrcweir aD[i].Save( rSave.aS[n++] );
4802cdf0e10cSrcweir }
4803cdf0e10cSrcweir
RestoreAllPLCFx(const WW8PLCFxSaveAll & rSave)4804cdf0e10cSrcweir void WW8PLCFMan::RestoreAllPLCFx( const WW8PLCFxSaveAll& rSave )
4805cdf0e10cSrcweir {
4806cdf0e10cSrcweir sal_uInt16 i, n=0;
4807cdf0e10cSrcweir if( pPcd )
4808cdf0e10cSrcweir pPcd->Restore( rSave.aS[n++] );
4809cdf0e10cSrcweir if( pPcdA )
4810cdf0e10cSrcweir pPcdA->Restore( rSave.aS[n++] );
4811cdf0e10cSrcweir
4812cdf0e10cSrcweir for(i=0; i<nPLCF; ++i)
4813cdf0e10cSrcweir if( pPcd != &aD[i] && pPcdA != &aD[i] )
4814cdf0e10cSrcweir aD[i].Restore( rSave.aS[n++] );
4815cdf0e10cSrcweir }
4816cdf0e10cSrcweir
GetSprmStart(short nIdx,WW8PLCFManResult * pRes) const4817cdf0e10cSrcweir void WW8PLCFMan::GetSprmStart( short nIdx, WW8PLCFManResult* pRes ) const
4818cdf0e10cSrcweir {
4819cdf0e10cSrcweir memset( pRes, 0, sizeof( WW8PLCFManResult ) );
4820cdf0e10cSrcweir
4821cdf0e10cSrcweir // Pruefen !!!
4822cdf0e10cSrcweir
4823cdf0e10cSrcweir pRes->nMemLen = 0;
4824cdf0e10cSrcweir
4825cdf0e10cSrcweir const WW8PLCFxDesc* p = &aD[nIdx];
4826cdf0e10cSrcweir
4827cdf0e10cSrcweir // first Sprm in a Group
4828cdf0e10cSrcweir if( p->bFirstSprm )
4829cdf0e10cSrcweir {
4830cdf0e10cSrcweir if( p == pPap )
4831cdf0e10cSrcweir pRes->nFlags |= MAN_MASK_NEW_PAP;
4832cdf0e10cSrcweir else if( p == pSep )
4833cdf0e10cSrcweir pRes->nFlags |= MAN_MASK_NEW_SEP;
4834cdf0e10cSrcweir }
4835cdf0e10cSrcweir pRes->pMemPos = p->pMemPos;
4836cdf0e10cSrcweir pRes->nSprmId = GetId(p);
4837cdf0e10cSrcweir pRes->nCp2OrIdx = p->nCp2OrIdx;
4838cdf0e10cSrcweir if ((p == pFtn) || (p == pEdn) || (p == pAnd))
4839cdf0e10cSrcweir pRes->nMemLen = p->nSprmsLen;
4840cdf0e10cSrcweir else if (p->nSprmsLen) //Normal
4841cdf0e10cSrcweir {
4842cdf0e10cSrcweir // Length of actual sprm
4843cdf0e10cSrcweir pRes->nMemLen = maSprmParser.GetSprmSize(pRes->nSprmId, pRes->pMemPos);
4844cdf0e10cSrcweir }
4845cdf0e10cSrcweir }
4846cdf0e10cSrcweir
GetSprmEnd(short nIdx,WW8PLCFManResult * pRes) const4847cdf0e10cSrcweir void WW8PLCFMan::GetSprmEnd( short nIdx, WW8PLCFManResult* pRes ) const
4848cdf0e10cSrcweir {
4849cdf0e10cSrcweir memset( pRes, 0, sizeof( WW8PLCFManResult ) );
4850cdf0e10cSrcweir
4851cdf0e10cSrcweir const WW8PLCFxDesc* p = &aD[nIdx];
4852cdf0e10cSrcweir
4853cdf0e10cSrcweir if (!(p->pIdStk->empty()))
4854cdf0e10cSrcweir pRes->nSprmId = p->pIdStk->top(); // get end position
4855cdf0e10cSrcweir else
4856cdf0e10cSrcweir {
4857cdf0e10cSrcweir ASSERT( !this, "No Id on the Stack" );
4858cdf0e10cSrcweir pRes->nSprmId = 0;
4859cdf0e10cSrcweir }
4860cdf0e10cSrcweir }
4861cdf0e10cSrcweir
GetNoSprmStart(short nIdx,WW8PLCFManResult * pRes) const4862cdf0e10cSrcweir void WW8PLCFMan::GetNoSprmStart( short nIdx, WW8PLCFManResult* pRes ) const
4863cdf0e10cSrcweir {
4864cdf0e10cSrcweir const WW8PLCFxDesc* p = &aD[nIdx];
4865cdf0e10cSrcweir
4866cdf0e10cSrcweir pRes->nCpPos = p->nStartPos;
4867cdf0e10cSrcweir pRes->nMemLen = p->nSprmsLen;
4868cdf0e10cSrcweir pRes->nCp2OrIdx = p->nCp2OrIdx;
4869cdf0e10cSrcweir
4870cdf0e10cSrcweir if( p == pFld )
4871cdf0e10cSrcweir pRes->nSprmId = eFLD;
4872cdf0e10cSrcweir else if( p == pFtn )
4873cdf0e10cSrcweir pRes->nSprmId = eFTN;
4874cdf0e10cSrcweir else if( p == pEdn )
4875cdf0e10cSrcweir pRes->nSprmId = eEDN;
4876cdf0e10cSrcweir else if( p == pBkm )
4877cdf0e10cSrcweir pRes->nSprmId = eBKN;
4878cdf0e10cSrcweir else if( p == pAnd )
4879cdf0e10cSrcweir pRes->nSprmId = eAND;
4880cdf0e10cSrcweir else if( p == pPcd )
4881cdf0e10cSrcweir {
4882cdf0e10cSrcweir //We slave the piece table attributes to the piece table, the piece
4883cdf0e10cSrcweir //table attribute iterator contains the sprms for this piece.
4884cdf0e10cSrcweir GetSprmStart( nIdx+1, pRes );
4885cdf0e10cSrcweir }
4886cdf0e10cSrcweir else
4887cdf0e10cSrcweir pRes->nSprmId = 0; // default: not found
4888cdf0e10cSrcweir }
4889cdf0e10cSrcweir
GetNoSprmEnd(short nIdx,WW8PLCFManResult * pRes) const4890cdf0e10cSrcweir void WW8PLCFMan::GetNoSprmEnd( short nIdx, WW8PLCFManResult* pRes ) const
4891cdf0e10cSrcweir {
4892cdf0e10cSrcweir pRes->nMemLen = -1; // Ende-Kennzeichen
4893cdf0e10cSrcweir
4894cdf0e10cSrcweir if( &aD[nIdx] == pBkm )
4895cdf0e10cSrcweir pRes->nSprmId = eBKN;
4896cdf0e10cSrcweir else if( &aD[nIdx] == pPcd )
4897cdf0e10cSrcweir {
4898cdf0e10cSrcweir //We slave the piece table attributes to the piece table, the piece
4899cdf0e10cSrcweir //table attribute iterator contains the sprms for this piece.
4900cdf0e10cSrcweir GetSprmEnd( nIdx+1, pRes );
4901cdf0e10cSrcweir }
4902cdf0e10cSrcweir else
4903cdf0e10cSrcweir pRes->nSprmId = 0;
4904cdf0e10cSrcweir }
4905cdf0e10cSrcweir
TransferOpenSprms(std::stack<sal_uInt16> & rStack)4906cdf0e10cSrcweir bool WW8PLCFMan::TransferOpenSprms(std::stack<sal_uInt16> &rStack)
4907cdf0e10cSrcweir {
4908cdf0e10cSrcweir for (int i = 0; i < nPLCF; ++i)
4909cdf0e10cSrcweir {
4910cdf0e10cSrcweir WW8PLCFxDesc* p = &aD[i];
4911cdf0e10cSrcweir if (!p || !p->pIdStk)
4912cdf0e10cSrcweir continue;
4913cdf0e10cSrcweir while (!p->pIdStk->empty())
4914cdf0e10cSrcweir {
4915cdf0e10cSrcweir rStack.push(p->pIdStk->top());
4916cdf0e10cSrcweir p->pIdStk->pop();
4917cdf0e10cSrcweir }
4918cdf0e10cSrcweir }
4919cdf0e10cSrcweir return rStack.empty();
4920cdf0e10cSrcweir }
4921cdf0e10cSrcweir
AdvSprm(short nIdx,bool bStart)4922cdf0e10cSrcweir void WW8PLCFMan::AdvSprm(short nIdx, bool bStart)
4923cdf0e10cSrcweir {
4924cdf0e10cSrcweir WW8PLCFxDesc* p = &aD[nIdx]; // Sprm-Klasse(!) ermitteln
4925cdf0e10cSrcweir
4926cdf0e10cSrcweir p->bFirstSprm = false;
4927cdf0e10cSrcweir if( bStart )
4928cdf0e10cSrcweir {
4929cdf0e10cSrcweir sal_uInt16 nLastId = GetId(p);
4930cdf0e10cSrcweir p->pIdStk->push(nLastId); // merke Id fuer Attribut-Ende
4931cdf0e10cSrcweir
4932cdf0e10cSrcweir if( p->nSprmsLen )
4933cdf0e10cSrcweir { /*
4934cdf0e10cSrcweir Pruefe, ob noch Sprm(s) abzuarbeiten sind
4935cdf0e10cSrcweir */
4936cdf0e10cSrcweir if( p->pMemPos )
4937cdf0e10cSrcweir {
4938cdf0e10cSrcweir // Length of last sprm
4939cdf0e10cSrcweir sal_uInt16 nSprmL = maSprmParser.GetSprmSize(nLastId, p->pMemPos);
4940cdf0e10cSrcweir
4941cdf0e10cSrcweir // Gesamtlaenge Sprms um SprmLaenge verringern
4942cdf0e10cSrcweir p->nSprmsLen -= nSprmL;
4943cdf0e10cSrcweir
4944cdf0e10cSrcweir // Pos des evtl. naechsten Sprm
4945cdf0e10cSrcweir if (p->nSprmsLen < maSprmParser.MinSprmLen())
4946cdf0e10cSrcweir {
4947cdf0e10cSrcweir // sicherheitshalber auf Null setzen, da Enden folgen!
4948cdf0e10cSrcweir p->pMemPos = 0;
4949cdf0e10cSrcweir p->nSprmsLen = 0;
4950cdf0e10cSrcweir }
4951cdf0e10cSrcweir else
4952cdf0e10cSrcweir p->pMemPos += nSprmL;
4953cdf0e10cSrcweir }
4954cdf0e10cSrcweir else
4955cdf0e10cSrcweir p->nSprmsLen = 0;
4956cdf0e10cSrcweir }
4957cdf0e10cSrcweir if (p->nSprmsLen < maSprmParser.MinSprmLen())
4958cdf0e10cSrcweir p->nStartPos = WW8_CP_MAX; // es folgen Enden
4959cdf0e10cSrcweir }
4960cdf0e10cSrcweir else
4961cdf0e10cSrcweir {
4962cdf0e10cSrcweir if (!(p->pIdStk->empty()))
4963cdf0e10cSrcweir p->pIdStk->pop();
4964cdf0e10cSrcweir if (p->pIdStk->empty())
4965cdf0e10cSrcweir {
4966cdf0e10cSrcweir if ( (p == pChp) || (p == pPap) )
4967cdf0e10cSrcweir {
4968cdf0e10cSrcweir p->pMemPos = 0;
4969cdf0e10cSrcweir p->nSprmsLen = 0;
4970cdf0e10cSrcweir p->nStartPos = p->nOrigEndPos+p->nCpOfs;
4971cdf0e10cSrcweir
4972cdf0e10cSrcweir /*
4973cdf0e10cSrcweir #93702#
4974cdf0e10cSrcweir On failed seek we have run out of sprms, probably. But if its
4975cdf0e10cSrcweir a fastsaved file (has pPcd) then we may be just in a sprm free
4976cdf0e10cSrcweir gap between pieces that have them, so set dirty flag in sprm
4977cdf0e10cSrcweir finder to consider than.
4978cdf0e10cSrcweir */
4979cdf0e10cSrcweir if (!(*p->pPLCFx).SeekPos(p->nStartPos))
4980cdf0e10cSrcweir {
4981cdf0e10cSrcweir p->nEndPos = WW8_CP_MAX;
4982cdf0e10cSrcweir p->pPLCFx->SetDirty(true);
4983cdf0e10cSrcweir }
4984cdf0e10cSrcweir if (!p->pPLCFx->GetDirty() || pPcd)
4985cdf0e10cSrcweir GetNewSprms( *p );
4986cdf0e10cSrcweir p->pPLCFx->SetDirty(false);
4987cdf0e10cSrcweir
4988cdf0e10cSrcweir /*
4989cdf0e10cSrcweir #i2325#
4990cdf0e10cSrcweir To get the character and paragraph properties you first get
4991cdf0e10cSrcweir the pap and chp and then apply the fastsaved pPcd properties
4992cdf0e10cSrcweir to the range. If a pap or chp starts inside the pPcd range
4993cdf0e10cSrcweir then we must bring the current pPcd range to a halt so as to
4994cdf0e10cSrcweir end those sprms, then the pap/chp will be processed, and then
4995cdf0e10cSrcweir we must force a restart of the pPcd on that pap/chp starting
4996cdf0e10cSrcweir boundary. Doing that effectively means that the pPcd sprms will
4997cdf0e10cSrcweir be applied to the new range. Not doing it means that the pPcd
4998cdf0e10cSrcweir sprms will only be applied to the first pap/chp set of
4999cdf0e10cSrcweir properties contained in the pap/chp range.
5000cdf0e10cSrcweir
5001cdf0e10cSrcweir So we bring the pPcd to a halt on this location here, by
5002cdf0e10cSrcweir settings its end to the current start, then store the starting
5003cdf0e10cSrcweir position of the current range to clipstart. The pPcd sprms
5004cdf0e10cSrcweir will end as normal (albeit earlier than originally expected),
5005cdf0e10cSrcweir and the existance of a clipstart will force the pPcd iterater
5006cdf0e10cSrcweir to reread the current set of sprms instead of advancing to its
5007cdf0e10cSrcweir next set. Then the clipstart will be set as the starting
5008cdf0e10cSrcweir position which will force them to be applied directly after
5009cdf0e10cSrcweir the pap and chps.
5010cdf0e10cSrcweir */
5011cdf0e10cSrcweir if (pPcd && ((p->nStartPos > pPcd->nStartPos) ||
5012cdf0e10cSrcweir (pPcd->nStartPos == WW8_CP_MAX)) &&
5013cdf0e10cSrcweir (pPcd->nEndPos != p->nStartPos))
5014cdf0e10cSrcweir {
5015cdf0e10cSrcweir pPcd->nEndPos = p->nStartPos;
5016cdf0e10cSrcweir ((WW8PLCFx_PCD *)(pPcd->pPLCFx))->SetClipStart(
5017cdf0e10cSrcweir p->nStartPos);
5018cdf0e10cSrcweir }
5019cdf0e10cSrcweir
5020cdf0e10cSrcweir }
5021cdf0e10cSrcweir else
5022cdf0e10cSrcweir {
5023cdf0e10cSrcweir (*p->pPLCFx)++; // next Group of Sprms
5024cdf0e10cSrcweir p->pMemPos = 0; // !!!
5025cdf0e10cSrcweir p->nSprmsLen = 0;
5026cdf0e10cSrcweir GetNewSprms( *p );
5027cdf0e10cSrcweir }
5028cdf0e10cSrcweir ASSERT( p->nStartPos <= p->nEndPos, "Attribut ueber Kreuz" );
5029cdf0e10cSrcweir }
5030cdf0e10cSrcweir }
5031cdf0e10cSrcweir }
5032cdf0e10cSrcweir
AdvNoSprm(short nIdx,bool bStart)5033cdf0e10cSrcweir void WW8PLCFMan::AdvNoSprm(short nIdx, bool bStart)
5034cdf0e10cSrcweir {
5035cdf0e10cSrcweir /*
5036cdf0e10cSrcweir For the case of a piece table we slave the piece table attribute iterator
5037cdf0e10cSrcweir to the piece table and access it through that only. They are two seperate
5038cdf0e10cSrcweir structures, but act together as one logical one. The attributes only go
5039cdf0e10cSrcweir to the next entry when the piece changes
5040cdf0e10cSrcweir */
5041cdf0e10cSrcweir WW8PLCFxDesc* p = &aD[nIdx];
5042cdf0e10cSrcweir
5043cdf0e10cSrcweir if( p == pPcd )
5044cdf0e10cSrcweir {
5045cdf0e10cSrcweir AdvSprm(nIdx+1,bStart);
5046cdf0e10cSrcweir if( bStart )
5047cdf0e10cSrcweir p->nStartPos = aD[nIdx+1].nStartPos;
5048cdf0e10cSrcweir else
5049cdf0e10cSrcweir {
5050cdf0e10cSrcweir if (aD[nIdx+1].pIdStk->empty())
5051cdf0e10cSrcweir {
5052cdf0e10cSrcweir WW8PLCFx_PCD *pTemp = (WW8PLCFx_PCD*)(pPcd->pPLCFx);
5053cdf0e10cSrcweir /*
5054cdf0e10cSrcweir #i2325#
5055cdf0e10cSrcweir As per normal, go on to the next set of properties, i.e. we
5056cdf0e10cSrcweir have traversed over to the next piece. With a clipstart set
5057cdf0e10cSrcweir we are being told to reread the current piece sprms so as to
5058cdf0e10cSrcweir reapply them to a new chp or pap range.
5059cdf0e10cSrcweir */
5060cdf0e10cSrcweir if (pTemp->GetClipStart() == -1)
5061cdf0e10cSrcweir (*p->pPLCFx)++;
5062cdf0e10cSrcweir p->pMemPos = 0;
5063cdf0e10cSrcweir p->nSprmsLen = 0;
5064cdf0e10cSrcweir GetNewSprms( aD[nIdx+1] );
5065cdf0e10cSrcweir GetNewNoSprms( *p );
5066cdf0e10cSrcweir if (pTemp->GetClipStart() != -1)
5067cdf0e10cSrcweir {
5068cdf0e10cSrcweir /*
5069cdf0e10cSrcweir #i2325#, now we will force our starting position to the
5070cdf0e10cSrcweir clipping start so as to force the application of these
5071cdf0e10cSrcweir sprms after the current pap/chp sprms so as to apply the
5072cdf0e10cSrcweir fastsave sprms to the current range.
5073cdf0e10cSrcweir */
5074cdf0e10cSrcweir p->nStartPos = pTemp->GetClipStart();
5075cdf0e10cSrcweir pTemp->SetClipStart(-1);
5076cdf0e10cSrcweir }
5077cdf0e10cSrcweir }
5078cdf0e10cSrcweir }
5079cdf0e10cSrcweir }
5080cdf0e10cSrcweir else
5081cdf0e10cSrcweir { // NoSprm ohne Ende
5082cdf0e10cSrcweir (*p->pPLCFx)++;
5083cdf0e10cSrcweir p->pMemPos = 0; // MemPos ungueltig
5084cdf0e10cSrcweir p->nSprmsLen = 0;
5085cdf0e10cSrcweir GetNewNoSprms( *p );
5086cdf0e10cSrcweir }
5087cdf0e10cSrcweir }
5088cdf0e10cSrcweir
operator ++(int)5089cdf0e10cSrcweir WW8PLCFMan& WW8PLCFMan::operator ++(int)
5090cdf0e10cSrcweir {
5091cdf0e10cSrcweir bool bStart;
5092cdf0e10cSrcweir sal_uInt16 nIdx = WhereIdx(&bStart);
5093cdf0e10cSrcweir if (nIdx < nPLCF)
5094cdf0e10cSrcweir {
5095cdf0e10cSrcweir WW8PLCFxDesc* p = &aD[nIdx];
5096cdf0e10cSrcweir
5097cdf0e10cSrcweir p->bFirstSprm = true; // Default
5098cdf0e10cSrcweir
5099cdf0e10cSrcweir if( p->pPLCFx->IsSprm() )
5100cdf0e10cSrcweir AdvSprm( nIdx, bStart );
5101cdf0e10cSrcweir else // NoSprm
5102cdf0e10cSrcweir AdvNoSprm( nIdx, bStart );
5103cdf0e10cSrcweir }
5104cdf0e10cSrcweir return *this;
5105cdf0e10cSrcweir }
5106cdf0e10cSrcweir
5107cdf0e10cSrcweir // Rueckgabe true fuer Anfang eines Attributes oder Fehler,
5108cdf0e10cSrcweir // false fuer Ende d. Attr
5109cdf0e10cSrcweir // Restliche Rueckgabewerte werden in der vom Aufrufer zu stellenden Struktur
5110cdf0e10cSrcweir // WW8PclxManResults geliefert.
Get(WW8PLCFManResult * pRes) const5111cdf0e10cSrcweir bool WW8PLCFMan::Get(WW8PLCFManResult* pRes) const
5112cdf0e10cSrcweir {
5113cdf0e10cSrcweir memset( pRes, 0, sizeof( WW8PLCFManResult ) );
5114cdf0e10cSrcweir bool bStart;
5115cdf0e10cSrcweir sal_uInt16 nIdx = WhereIdx(&bStart);
5116cdf0e10cSrcweir
5117cdf0e10cSrcweir if( nIdx >= nPLCF )
5118cdf0e10cSrcweir {
5119cdf0e10cSrcweir ASSERT( !this, "Position not found" );
5120cdf0e10cSrcweir return true;
5121cdf0e10cSrcweir }
5122cdf0e10cSrcweir
5123cdf0e10cSrcweir if( aD[nIdx].pPLCFx->IsSprm() )
5124cdf0e10cSrcweir {
5125cdf0e10cSrcweir if( bStart )
5126cdf0e10cSrcweir {
5127cdf0e10cSrcweir GetSprmStart( nIdx, pRes );
5128cdf0e10cSrcweir return true;
5129cdf0e10cSrcweir }
5130cdf0e10cSrcweir else
5131cdf0e10cSrcweir {
5132cdf0e10cSrcweir GetSprmEnd( nIdx, pRes );
5133cdf0e10cSrcweir return false;
5134cdf0e10cSrcweir }
5135cdf0e10cSrcweir }
5136cdf0e10cSrcweir else
5137cdf0e10cSrcweir {
5138cdf0e10cSrcweir if( bStart )
5139cdf0e10cSrcweir {
5140cdf0e10cSrcweir GetNoSprmStart( nIdx, pRes );
5141cdf0e10cSrcweir return true;
5142cdf0e10cSrcweir }
5143cdf0e10cSrcweir else
5144cdf0e10cSrcweir {
5145cdf0e10cSrcweir GetNoSprmEnd( nIdx, pRes );
5146cdf0e10cSrcweir return false;
5147cdf0e10cSrcweir }
5148cdf0e10cSrcweir }
5149cdf0e10cSrcweir }
5150cdf0e10cSrcweir
GetColl() const5151cdf0e10cSrcweir sal_uInt16 WW8PLCFMan::GetColl() const
5152cdf0e10cSrcweir {
5153cdf0e10cSrcweir if( pPap->pPLCFx )
5154cdf0e10cSrcweir return pPap->pPLCFx->GetIstd();
5155cdf0e10cSrcweir else
5156cdf0e10cSrcweir {
5157cdf0e10cSrcweir ASSERT( !this, "GetColl ohne PLCF_Pap" );
5158cdf0e10cSrcweir return 0;
5159cdf0e10cSrcweir }
5160cdf0e10cSrcweir }
5161cdf0e10cSrcweir
GetFld() const5162cdf0e10cSrcweir WW8PLCFx_FLD* WW8PLCFMan::GetFld() const
5163cdf0e10cSrcweir {
5164cdf0e10cSrcweir return (WW8PLCFx_FLD*)pFld->pPLCFx;
5165cdf0e10cSrcweir }
5166cdf0e10cSrcweir
HasParaSprm(sal_uInt16 nId) const5167cdf0e10cSrcweir const sal_uInt8* WW8PLCFMan::HasParaSprm( sal_uInt16 nId ) const
5168cdf0e10cSrcweir {
5169cdf0e10cSrcweir return ((WW8PLCFx_Cp_FKP*)pPap->pPLCFx)->HasSprm( nId );
5170cdf0e10cSrcweir }
5171cdf0e10cSrcweir
HasCharSprm(sal_uInt16 nId) const5172cdf0e10cSrcweir const sal_uInt8* WW8PLCFMan::HasCharSprm( sal_uInt16 nId ) const
5173cdf0e10cSrcweir {
5174cdf0e10cSrcweir return ((WW8PLCFx_Cp_FKP*)pChp->pPLCFx)->HasSprm( nId );
5175cdf0e10cSrcweir }
5176cdf0e10cSrcweir
HasCharSprm(sal_uInt16 nId,std::vector<const sal_uInt8 * > & rResult) const5177cdf0e10cSrcweir bool WW8PLCFMan::HasCharSprm(sal_uInt16 nId,
5178cdf0e10cSrcweir std::vector<const sal_uInt8 *> &rResult) const
5179cdf0e10cSrcweir {
5180cdf0e10cSrcweir return ((WW8PLCFx_Cp_FKP*)pChp->pPLCFx)->HasSprm(nId, rResult);
5181cdf0e10cSrcweir }
5182cdf0e10cSrcweir
5183cdf0e10cSrcweir #endif // !DUMP
5184cdf0e10cSrcweir
Save(WW8PLCFxSave1 & rSave) const5185cdf0e10cSrcweir void WW8PLCFx::Save( WW8PLCFxSave1& rSave ) const
5186cdf0e10cSrcweir {
5187cdf0e10cSrcweir rSave.nPLCFxPos = GetIdx();
5188cdf0e10cSrcweir rSave.nPLCFxPos2 = GetIdx2();
5189cdf0e10cSrcweir rSave.nPLCFxMemOfs = 0;
5190cdf0e10cSrcweir rSave.nStartFC = GetStartFc();
5191cdf0e10cSrcweir }
5192cdf0e10cSrcweir
Restore(const WW8PLCFxSave1 & rSave)5193cdf0e10cSrcweir void WW8PLCFx::Restore( const WW8PLCFxSave1& rSave )
5194cdf0e10cSrcweir {
5195cdf0e10cSrcweir SetIdx( rSave.nPLCFxPos );
5196cdf0e10cSrcweir SetIdx2( rSave.nPLCFxPos2 );
5197cdf0e10cSrcweir SetStartFc( rSave.nStartFC );
5198cdf0e10cSrcweir }
5199cdf0e10cSrcweir
GetIdx2() const5200cdf0e10cSrcweir sal_uLong WW8PLCFx_Cp_FKP::GetIdx2() const
5201cdf0e10cSrcweir {
5202cdf0e10cSrcweir return GetPCDIdx();
5203cdf0e10cSrcweir }
5204cdf0e10cSrcweir
SetIdx2(sal_uLong nIdx)5205cdf0e10cSrcweir void WW8PLCFx_Cp_FKP::SetIdx2( sal_uLong nIdx )
5206cdf0e10cSrcweir {
5207cdf0e10cSrcweir SetPCDIdx( nIdx );
5208cdf0e10cSrcweir }
5209cdf0e10cSrcweir
Save(WW8PLCFxSave1 & rSave) const5210cdf0e10cSrcweir void WW8PLCFx_Cp_FKP::Save( WW8PLCFxSave1& rSave ) const
5211cdf0e10cSrcweir {
5212cdf0e10cSrcweir WW8PLCFx::Save( rSave );
5213cdf0e10cSrcweir
5214cdf0e10cSrcweir rSave.nAttrStart = nAttrStart;
5215cdf0e10cSrcweir rSave.nAttrEnd = nAttrEnd;
5216cdf0e10cSrcweir rSave.bLineEnd = bLineEnd;
5217cdf0e10cSrcweir }
5218cdf0e10cSrcweir
Restore(const WW8PLCFxSave1 & rSave)5219cdf0e10cSrcweir void WW8PLCFx_Cp_FKP::Restore( const WW8PLCFxSave1& rSave )
5220cdf0e10cSrcweir {
5221cdf0e10cSrcweir WW8PLCFx::Restore( rSave );
5222cdf0e10cSrcweir
5223cdf0e10cSrcweir nAttrStart = rSave.nAttrStart;
5224cdf0e10cSrcweir nAttrEnd = rSave.nAttrEnd;
5225cdf0e10cSrcweir bLineEnd = rSave.bLineEnd;
5226cdf0e10cSrcweir }
5227cdf0e10cSrcweir
Save(WW8PLCFxSave1 & rSave) const5228cdf0e10cSrcweir void WW8PLCFxDesc::Save( WW8PLCFxSave1& rSave ) const
5229cdf0e10cSrcweir {
5230cdf0e10cSrcweir if( pPLCFx )
5231cdf0e10cSrcweir {
5232cdf0e10cSrcweir pPLCFx->Save( rSave );
5233cdf0e10cSrcweir if( pPLCFx->IsSprm() )
5234cdf0e10cSrcweir {
5235cdf0e10cSrcweir WW8PLCFxDesc aD;
5236cdf0e10cSrcweir aD.nStartPos = nOrigStartPos+nCpOfs;
5237cdf0e10cSrcweir aD.nCpOfs = rSave.nCpOfs = nCpOfs;
5238cdf0e10cSrcweir if (!(pPLCFx->SeekPos(aD.nStartPos)))
5239cdf0e10cSrcweir {
5240cdf0e10cSrcweir aD.nEndPos = WW8_CP_MAX;
5241cdf0e10cSrcweir pPLCFx->SetDirty(true);
5242cdf0e10cSrcweir }
5243cdf0e10cSrcweir pPLCFx->GetSprms(&aD);
5244cdf0e10cSrcweir pPLCFx->SetDirty(false);
5245cdf0e10cSrcweir aD.ReduceByOffset();
5246cdf0e10cSrcweir rSave.nStartCp = aD.nStartPos;
5247cdf0e10cSrcweir rSave.nPLCFxMemOfs = nOrigSprmsLen - nSprmsLen;
5248cdf0e10cSrcweir }
5249cdf0e10cSrcweir }
5250cdf0e10cSrcweir }
5251cdf0e10cSrcweir
Restore(const WW8PLCFxSave1 & rSave)5252cdf0e10cSrcweir void WW8PLCFxDesc::Restore( const WW8PLCFxSave1& rSave )
5253cdf0e10cSrcweir {
5254cdf0e10cSrcweir if( pPLCFx )
5255cdf0e10cSrcweir {
5256cdf0e10cSrcweir pPLCFx->Restore( rSave );
5257cdf0e10cSrcweir if( pPLCFx->IsSprm() )
5258cdf0e10cSrcweir {
5259cdf0e10cSrcweir WW8PLCFxDesc aD;
5260cdf0e10cSrcweir aD.nStartPos = rSave.nStartCp+rSave.nCpOfs;
5261cdf0e10cSrcweir nCpOfs = aD.nCpOfs = rSave.nCpOfs;
5262cdf0e10cSrcweir if (!(pPLCFx->SeekPos(aD.nStartPos)))
5263cdf0e10cSrcweir {
5264cdf0e10cSrcweir aD.nEndPos = WW8_CP_MAX;
5265cdf0e10cSrcweir pPLCFx->SetDirty(true);
5266cdf0e10cSrcweir }
5267cdf0e10cSrcweir pPLCFx->GetSprms(&aD);
5268cdf0e10cSrcweir pPLCFx->SetDirty(false);
5269cdf0e10cSrcweir aD.ReduceByOffset();
5270cdf0e10cSrcweir pMemPos = aD.pMemPos + rSave.nPLCFxMemOfs;
5271cdf0e10cSrcweir }
5272cdf0e10cSrcweir }
5273cdf0e10cSrcweir }
5274cdf0e10cSrcweir
5275cdf0e10cSrcweir //-----------------------------------------
5276cdf0e10cSrcweir
5277cdf0e10cSrcweir namespace
5278cdf0e10cSrcweir {
Readcb(SvStream & rSt,ww::WordVersion eVer)5279cdf0e10cSrcweir sal_uInt32 Readcb(SvStream& rSt, ww::WordVersion eVer)
5280cdf0e10cSrcweir {
5281cdf0e10cSrcweir if (eVer <= ww::eWW2)
5282cdf0e10cSrcweir {
5283cdf0e10cSrcweir sal_uInt16 nShort;
5284cdf0e10cSrcweir rSt >> nShort;
5285cdf0e10cSrcweir return nShort;
5286cdf0e10cSrcweir }
5287cdf0e10cSrcweir else
5288cdf0e10cSrcweir {
5289cdf0e10cSrcweir sal_uInt32 nLong;
5290cdf0e10cSrcweir rSt >> nLong;
5291cdf0e10cSrcweir return nLong;
5292cdf0e10cSrcweir }
5293cdf0e10cSrcweir }
5294cdf0e10cSrcweir }
5295cdf0e10cSrcweir
GetBaseCp(ManTypes nType) const5296cdf0e10cSrcweir WW8_CP WW8Fib::GetBaseCp(ManTypes nType) const
5297cdf0e10cSrcweir {
5298cdf0e10cSrcweir WW8_CP nOffset = 0;
5299cdf0e10cSrcweir
5300cdf0e10cSrcweir switch( nType )
5301cdf0e10cSrcweir {
5302cdf0e10cSrcweir default:
5303cdf0e10cSrcweir case MAN_MAINTEXT:
5304cdf0e10cSrcweir break;
5305cdf0e10cSrcweir case MAN_FTN:
5306cdf0e10cSrcweir nOffset = ccpText;
5307cdf0e10cSrcweir break;
5308cdf0e10cSrcweir case MAN_HDFT:
5309cdf0e10cSrcweir nOffset = ccpText + ccpFtn;
5310cdf0e10cSrcweir break;
5311cdf0e10cSrcweir /*
5312cdf0e10cSrcweir * A subdocument of this kind probably exists in some defunct version
5313cdf0e10cSrcweir * of MSWord, but now ccpMcr is always 0
5314cdf0e10cSrcweir */
5315cdf0e10cSrcweir #if 0
5316cdf0e10cSrcweir case MAN_MACRO:
5317cdf0e10cSrcweir nOffset = ccpText + ccpFtn + ccpHdr;
5318cdf0e10cSrcweir break;
5319cdf0e10cSrcweir #endif
5320cdf0e10cSrcweir case MAN_AND:
5321cdf0e10cSrcweir nOffset = ccpText + ccpFtn + ccpHdr + ccpMcr;
5322cdf0e10cSrcweir break;
5323cdf0e10cSrcweir case MAN_EDN:
5324cdf0e10cSrcweir nOffset = ccpText + ccpFtn + ccpHdr + ccpMcr + ccpAtn;
5325cdf0e10cSrcweir break;
5326cdf0e10cSrcweir case MAN_TXBX:
5327cdf0e10cSrcweir nOffset = ccpText + ccpFtn + ccpHdr + ccpMcr + ccpAtn + ccpEdn;
5328cdf0e10cSrcweir break;
5329cdf0e10cSrcweir case MAN_TXBX_HDFT:
5330cdf0e10cSrcweir nOffset = ccpText + ccpFtn + ccpHdr + ccpMcr + ccpAtn + ccpEdn +
5331cdf0e10cSrcweir ccpTxbx;
5332cdf0e10cSrcweir break;
5333cdf0e10cSrcweir }
5334cdf0e10cSrcweir return nOffset;
5335cdf0e10cSrcweir }
5336cdf0e10cSrcweir
GetFIBVersion() const5337cdf0e10cSrcweir ww::WordVersion WW8Fib::GetFIBVersion() const
5338cdf0e10cSrcweir {
5339cdf0e10cSrcweir ww::WordVersion eVer = ww::eWW8;
5340cdf0e10cSrcweir if (wIdent == 0xa5db)
5341cdf0e10cSrcweir eVer = ww::eWW2;
5342cdf0e10cSrcweir else
5343cdf0e10cSrcweir {
5344cdf0e10cSrcweir switch (nVersion)
5345cdf0e10cSrcweir {
5346cdf0e10cSrcweir case 6:
5347cdf0e10cSrcweir eVer = ww::eWW6;
5348cdf0e10cSrcweir break;
5349cdf0e10cSrcweir case 7:
5350cdf0e10cSrcweir eVer = ww::eWW7;
5351cdf0e10cSrcweir break;
5352cdf0e10cSrcweir case 8:
5353cdf0e10cSrcweir eVer = ww::eWW8;
5354cdf0e10cSrcweir break;
5355cdf0e10cSrcweir }
5356cdf0e10cSrcweir }
5357cdf0e10cSrcweir return eVer;
5358cdf0e10cSrcweir }
5359cdf0e10cSrcweir
WW8Fib(SvStream & rSt,sal_uInt8 nWantedVersion,sal_uInt32 nOffset)5360cdf0e10cSrcweir WW8Fib::WW8Fib(SvStream& rSt, sal_uInt8 nWantedVersion, sal_uInt32 nOffset)
5361cdf0e10cSrcweir : nFibError( 0 )
5362cdf0e10cSrcweir {
5363cdf0e10cSrcweir memset(this, 0, sizeof(*this));
5364cdf0e10cSrcweir sal_uInt8 aBits1;
5365cdf0e10cSrcweir sal_uInt8 aBits2;
5366cdf0e10cSrcweir sal_uInt8 aVer8Bits1; // nur ab WinWord 8 benutzt
5367cdf0e10cSrcweir rSt.Seek( nOffset );
5368cdf0e10cSrcweir /*
5369cdf0e10cSrcweir Wunsch-Nr vermerken, File-Versionsnummer ermitteln
5370cdf0e10cSrcweir und gegen Wunsch-Nr. checken !
5371cdf0e10cSrcweir */
5372cdf0e10cSrcweir nVersion = nWantedVersion;
5373cdf0e10cSrcweir rSt >> wIdent;
5374cdf0e10cSrcweir rSt >> nFib;
5375cdf0e10cSrcweir rSt >> nProduct;
5376cdf0e10cSrcweir if( 0 != rSt.GetError() )
5377cdf0e10cSrcweir {
5378cdf0e10cSrcweir sal_Int16 nFibMin;
5379cdf0e10cSrcweir sal_Int16 nFibMax;
5380cdf0e10cSrcweir // note: 6 stands for "6 OR 7", 7 stands for "ONLY 7"
5381cdf0e10cSrcweir switch( nVersion )
5382cdf0e10cSrcweir {
5383cdf0e10cSrcweir case 6:
5384cdf0e10cSrcweir nFibMin = 0x0065; // von 101 WinWord 6.0
5385cdf0e10cSrcweir // 102 "
5386cdf0e10cSrcweir // und 103 WinWord 6.0 fuer Macintosh
5387cdf0e10cSrcweir // 104 "
5388cdf0e10cSrcweir nFibMax = 0x0069; // bis 105 WinWord 95
5389cdf0e10cSrcweir break;
5390cdf0e10cSrcweir case 7:
5391cdf0e10cSrcweir nFibMin = 0x0069; // von 105 WinWord 95
5392cdf0e10cSrcweir nFibMax = 0x0069; // bis 105 WinWord 95
5393cdf0e10cSrcweir break;
5394cdf0e10cSrcweir case 8:
5395cdf0e10cSrcweir nFibMin = 0x006A; // von 106 WinWord 97
5396cdf0e10cSrcweir nFibMax = 0x00c1; // bis 193 WinWord 97 (?)
5397cdf0e10cSrcweir break;
5398cdf0e10cSrcweir default:
5399cdf0e10cSrcweir nFibMin = 0; // Programm-Fehler!
5400cdf0e10cSrcweir nFibMax = 0;
5401cdf0e10cSrcweir nFib = 1;
5402cdf0e10cSrcweir ASSERT( !this, "Es wurde vergessen, nVersion zu kodieren!" );
5403cdf0e10cSrcweir break;
5404cdf0e10cSrcweir }
5405cdf0e10cSrcweir if ( (nFib < nFibMin) || (nFib > nFibMax) )
5406cdf0e10cSrcweir {
5407cdf0e10cSrcweir nFibError = ERR_SWG_READ_ERROR; // Error melden
5408cdf0e10cSrcweir return; // und hopp raus!
5409cdf0e10cSrcweir }
5410cdf0e10cSrcweir }
5411cdf0e10cSrcweir
5412cdf0e10cSrcweir ww::WordVersion eVer = GetFIBVersion();
5413cdf0e10cSrcweir
5414cdf0e10cSrcweir // Hilfs-Varis fuer Ver67:
5415cdf0e10cSrcweir sal_Int16 pnChpFirst_Ver67=0;
5416cdf0e10cSrcweir sal_Int16 pnPapFirst_Ver67=0;
5417cdf0e10cSrcweir sal_Int16 cpnBteChp_Ver67=0;
5418cdf0e10cSrcweir sal_Int16 cpnBtePap_Ver67=0;
5419cdf0e10cSrcweir
5420cdf0e10cSrcweir // und auf gehts: FIB einlesen
5421cdf0e10cSrcweir rSt >> lid;
5422cdf0e10cSrcweir rSt >> pnNext;
5423cdf0e10cSrcweir rSt >> aBits1;
5424cdf0e10cSrcweir rSt >> aBits2;
5425cdf0e10cSrcweir rSt >> nFibBack;
5426cdf0e10cSrcweir rSt >> nHash;
5427cdf0e10cSrcweir rSt >> nKey;
5428cdf0e10cSrcweir rSt >> envr;
5429cdf0e10cSrcweir rSt >> aVer8Bits1; // unter Ver67 nur leeres Reservefeld
5430cdf0e10cSrcweir // Inhalt von aVer8Bits1
5431cdf0e10cSrcweir //
5432cdf0e10cSrcweir // sal_uInt8 fMac :1;
5433cdf0e10cSrcweir // sal_uInt8 fEmptySpecial :1;
5434cdf0e10cSrcweir // sal_uInt8 fLoadOverridePage :1;
5435cdf0e10cSrcweir // sal_uInt8 fFuturesavedUndo :1;
5436cdf0e10cSrcweir // sal_uInt8 fWord97Saved :1;
5437cdf0e10cSrcweir // sal_uInt8 :3;
5438cdf0e10cSrcweir rSt >> chse;
5439cdf0e10cSrcweir rSt >> chseTables;
5440cdf0e10cSrcweir rSt >> fcMin;
5441cdf0e10cSrcweir rSt >> fcMac;
5442cdf0e10cSrcweir
5443cdf0e10cSrcweir // Einschub fuer WW8 *****************************************************
5444cdf0e10cSrcweir if (IsEightPlus(eVer))
5445cdf0e10cSrcweir {
5446cdf0e10cSrcweir rSt >> csw;
5447cdf0e10cSrcweir
5448cdf0e10cSrcweir // Marke: "rgsw" Beginning of the array of shorts
5449cdf0e10cSrcweir rSt >> wMagicCreated;
5450cdf0e10cSrcweir rSt >> wMagicRevised;
5451cdf0e10cSrcweir rSt >> wMagicCreatedPrivate;
5452cdf0e10cSrcweir rSt >> wMagicRevisedPrivate;
5453cdf0e10cSrcweir rSt.SeekRel( 9 * sizeof( sal_Int16 ) );
5454cdf0e10cSrcweir
5455cdf0e10cSrcweir /*
5456cdf0e10cSrcweir // dies sind die 9 unused Felder:
5457cdf0e10cSrcweir && (bVer67 || WW8ReadINT16( rSt, pnFbpChpFirst_W6 )) // 1
5458cdf0e10cSrcweir && (bVer67 || WW8ReadINT16( rSt, pnChpFirst_W6 )) // 2
5459cdf0e10cSrcweir && (bVer67 || WW8ReadINT16( rSt, cpnBteChp_W6 )) // 3
5460cdf0e10cSrcweir && (bVer67 || WW8ReadINT16( rSt, pnFbpPapFirst_W6 )) // 4
5461cdf0e10cSrcweir && (bVer67 || WW8ReadINT16( rSt, pnPapFirst_W6 )) // 5
5462cdf0e10cSrcweir && (bVer67 || WW8ReadINT16( rSt, cpnBtePap_W6 )) // 6
5463cdf0e10cSrcweir && (bVer67 || WW8ReadINT16( rSt, pnFbpLvcFirst_W6 )) // 7
5464cdf0e10cSrcweir && (bVer67 || WW8ReadINT16( rSt, pnLvcFirst_W6 )) // 8
5465cdf0e10cSrcweir && (bVer67 || WW8ReadINT16( rSt, cpnBteLvc_W6 )) // 9
5466cdf0e10cSrcweir */
5467cdf0e10cSrcweir rSt >> lidFE;
5468cdf0e10cSrcweir rSt >> clw;
5469cdf0e10cSrcweir }
5470cdf0e10cSrcweir
5471cdf0e10cSrcweir // Ende des Einschubs fuer WW8 *******************************************
5472cdf0e10cSrcweir
5473cdf0e10cSrcweir // Marke: "rglw" Beginning of the array of longs
5474cdf0e10cSrcweir rSt >> cbMac;
5475cdf0e10cSrcweir
5476cdf0e10cSrcweir // 2 Longs uebergehen, da unwichtiger Quatsch
5477cdf0e10cSrcweir rSt.SeekRel( 2 * sizeof( sal_Int32) );
5478cdf0e10cSrcweir
5479cdf0e10cSrcweir // weitere 2 Longs nur bei Ver67 ueberspringen
5480cdf0e10cSrcweir if (IsSevenMinus(eVer))
5481cdf0e10cSrcweir rSt.SeekRel( 2 * sizeof( sal_Int32) );
5482cdf0e10cSrcweir
5483cdf0e10cSrcweir rSt >> ccpText;
5484cdf0e10cSrcweir rSt >> ccpFtn;
5485cdf0e10cSrcweir rSt >> ccpHdr;
5486cdf0e10cSrcweir rSt >> ccpMcr;
5487cdf0e10cSrcweir rSt >> ccpAtn;
5488cdf0e10cSrcweir rSt >> ccpEdn;
5489cdf0e10cSrcweir rSt >> ccpTxbx;
5490cdf0e10cSrcweir rSt >> ccpHdrTxbx;
5491cdf0e10cSrcweir
5492cdf0e10cSrcweir // weiteres Long nur bei Ver67 ueberspringen
5493cdf0e10cSrcweir if (IsSevenMinus(eVer))
5494cdf0e10cSrcweir rSt.SeekRel( 1 * sizeof( sal_Int32) );
5495cdf0e10cSrcweir else
5496cdf0e10cSrcweir {
5497cdf0e10cSrcweir // Einschub fuer WW8 *****************************************************
5498cdf0e10cSrcweir rSt >> pnFbpChpFirst;
5499cdf0e10cSrcweir rSt >> pnChpFirst;
5500cdf0e10cSrcweir rSt >> cpnBteChp;
5501cdf0e10cSrcweir rSt >> pnFbpPapFirst;
5502cdf0e10cSrcweir rSt >> pnPapFirst;
5503cdf0e10cSrcweir rSt >> cpnBtePap;
5504cdf0e10cSrcweir rSt >> pnFbpLvcFirst;
5505cdf0e10cSrcweir rSt >> pnLvcFirst;
5506cdf0e10cSrcweir rSt >> cpnBteLvc;
5507cdf0e10cSrcweir rSt >> fcIslandFirst;
5508cdf0e10cSrcweir rSt >> fcIslandLim;
5509cdf0e10cSrcweir rSt >> cfclcb;
5510cdf0e10cSrcweir }
5511cdf0e10cSrcweir
5512cdf0e10cSrcweir // Ende des Einschubs fuer WW8 *******************************************
5513cdf0e10cSrcweir
5514cdf0e10cSrcweir // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
5515cdf0e10cSrcweir rSt >> fcStshfOrig;
5516cdf0e10cSrcweir lcbStshfOrig = Readcb(rSt, eVer);
5517cdf0e10cSrcweir rSt >> fcStshf;
5518cdf0e10cSrcweir lcbStshf = Readcb(rSt, eVer);
5519cdf0e10cSrcweir rSt >> fcPlcffndRef;
5520cdf0e10cSrcweir lcbPlcffndRef = Readcb(rSt, eVer);
5521cdf0e10cSrcweir rSt >> fcPlcffndTxt;
5522cdf0e10cSrcweir lcbPlcffndTxt = Readcb(rSt, eVer);
5523cdf0e10cSrcweir rSt >> fcPlcfandRef;
5524cdf0e10cSrcweir lcbPlcfandRef = Readcb(rSt, eVer);
5525cdf0e10cSrcweir rSt >> fcPlcfandTxt;
5526cdf0e10cSrcweir lcbPlcfandTxt = Readcb(rSt, eVer);
5527cdf0e10cSrcweir rSt >> fcPlcfsed;
5528cdf0e10cSrcweir lcbPlcfsed = Readcb(rSt, eVer);
5529cdf0e10cSrcweir rSt >> fcPlcfpad;
5530cdf0e10cSrcweir lcbPlcfpad = Readcb(rSt, eVer);
5531cdf0e10cSrcweir rSt >> fcPlcfphe;
5532cdf0e10cSrcweir lcbPlcfphe = Readcb(rSt, eVer);
5533cdf0e10cSrcweir rSt >> fcSttbfglsy;
5534cdf0e10cSrcweir lcbSttbfglsy = Readcb(rSt, eVer);
5535cdf0e10cSrcweir rSt >> fcPlcfglsy;
5536cdf0e10cSrcweir lcbPlcfglsy = Readcb(rSt, eVer);
5537cdf0e10cSrcweir rSt >> fcPlcfhdd;
5538cdf0e10cSrcweir lcbPlcfhdd = Readcb(rSt, eVer);
5539cdf0e10cSrcweir rSt >> fcPlcfbteChpx;
5540cdf0e10cSrcweir lcbPlcfbteChpx = Readcb(rSt, eVer);
5541cdf0e10cSrcweir rSt >> fcPlcfbtePapx;
5542cdf0e10cSrcweir lcbPlcfbtePapx = Readcb(rSt, eVer);
5543cdf0e10cSrcweir rSt >> fcPlcfsea;
5544cdf0e10cSrcweir lcbPlcfsea = Readcb(rSt, eVer);
5545cdf0e10cSrcweir rSt >> fcSttbfffn;
5546cdf0e10cSrcweir lcbSttbfffn = Readcb(rSt, eVer);
5547cdf0e10cSrcweir rSt >> fcPlcffldMom;
5548cdf0e10cSrcweir lcbPlcffldMom = Readcb(rSt, eVer);
5549cdf0e10cSrcweir rSt >> fcPlcffldHdr;
5550cdf0e10cSrcweir lcbPlcffldHdr = Readcb(rSt, eVer);
5551cdf0e10cSrcweir rSt >> fcPlcffldFtn;
5552cdf0e10cSrcweir lcbPlcffldFtn = Readcb(rSt, eVer);
5553cdf0e10cSrcweir rSt >> fcPlcffldAtn;
5554cdf0e10cSrcweir lcbPlcffldAtn = Readcb(rSt, eVer);
5555cdf0e10cSrcweir rSt >> fcPlcffldMcr;
5556cdf0e10cSrcweir lcbPlcffldMcr = Readcb(rSt, eVer);
5557cdf0e10cSrcweir rSt >> fcSttbfbkmk;
5558cdf0e10cSrcweir lcbSttbfbkmk = Readcb(rSt, eVer);
5559cdf0e10cSrcweir rSt >> fcPlcfbkf;
5560cdf0e10cSrcweir lcbPlcfbkf = Readcb(rSt, eVer);
5561cdf0e10cSrcweir rSt >> fcPlcfbkl;
5562cdf0e10cSrcweir lcbPlcfbkl = Readcb(rSt, eVer);
5563cdf0e10cSrcweir rSt >> fcCmds;
5564cdf0e10cSrcweir lcbCmds = Readcb(rSt, eVer);
5565cdf0e10cSrcweir rSt >> fcPlcfmcr;
5566cdf0e10cSrcweir lcbPlcfmcr = Readcb(rSt, eVer);
5567cdf0e10cSrcweir rSt >> fcSttbfmcr;
5568cdf0e10cSrcweir lcbSttbfmcr = Readcb(rSt, eVer);
5569cdf0e10cSrcweir rSt >> fcPrDrvr;
5570cdf0e10cSrcweir lcbPrDrvr = Readcb(rSt, eVer);
5571cdf0e10cSrcweir rSt >> fcPrEnvPort;
5572cdf0e10cSrcweir lcbPrEnvPort = Readcb(rSt, eVer);
5573cdf0e10cSrcweir rSt >> fcPrEnvLand;
5574cdf0e10cSrcweir lcbPrEnvLand = Readcb(rSt, eVer);
5575cdf0e10cSrcweir rSt >> fcWss;
5576cdf0e10cSrcweir lcbWss = Readcb(rSt, eVer);
5577cdf0e10cSrcweir rSt >> fcDop;
5578cdf0e10cSrcweir lcbDop = Readcb(rSt, eVer);
5579cdf0e10cSrcweir rSt >> fcSttbfAssoc;
5580cdf0e10cSrcweir lcbSttbfAssoc = Readcb(rSt, eVer);
5581cdf0e10cSrcweir rSt >> fcClx;
5582cdf0e10cSrcweir lcbClx = Readcb(rSt, eVer);
5583cdf0e10cSrcweir rSt >> fcPlcfpgdFtn;
5584cdf0e10cSrcweir lcbPlcfpgdFtn = Readcb(rSt, eVer);
5585cdf0e10cSrcweir rSt >> fcAutosaveSource;
5586cdf0e10cSrcweir lcbAutosaveSource = Readcb(rSt, eVer);
5587cdf0e10cSrcweir rSt >> fcGrpStAtnOwners;
5588cdf0e10cSrcweir lcbGrpStAtnOwners = Readcb(rSt, eVer);
5589cdf0e10cSrcweir rSt >> fcSttbfAtnbkmk;
5590cdf0e10cSrcweir lcbSttbfAtnbkmk = Readcb(rSt, eVer);
5591cdf0e10cSrcweir
5592cdf0e10cSrcweir // weiteres short nur bei Ver67 ueberspringen
5593cdf0e10cSrcweir if (IsSevenMinus(eVer))
5594cdf0e10cSrcweir {
5595cdf0e10cSrcweir rSt.SeekRel( 1*sizeof( sal_Int16) );
5596cdf0e10cSrcweir
5597cdf0e10cSrcweir // folgende 4 Shorts existieren nur bei Ver67;
5598cdf0e10cSrcweir rSt >> pnChpFirst_Ver67;
5599cdf0e10cSrcweir rSt >> pnPapFirst_Ver67;
5600cdf0e10cSrcweir rSt >> cpnBteChp_Ver67;
5601cdf0e10cSrcweir rSt >> cpnBtePap_Ver67;
5602cdf0e10cSrcweir }
5603cdf0e10cSrcweir
5604cdf0e10cSrcweir if (eVer > ww::eWW2)
5605cdf0e10cSrcweir {
5606cdf0e10cSrcweir rSt >> fcPlcfdoaMom;
5607cdf0e10cSrcweir rSt >> lcbPlcfdoaMom;
5608cdf0e10cSrcweir rSt >> fcPlcfdoaHdr;
5609cdf0e10cSrcweir rSt >> lcbPlcfdoaHdr;
5610cdf0e10cSrcweir rSt >> fcPlcfspaMom;
5611cdf0e10cSrcweir rSt >> lcbPlcfspaMom;
5612cdf0e10cSrcweir rSt >> fcPlcfspaHdr;
5613cdf0e10cSrcweir rSt >> lcbPlcfspaHdr;
5614cdf0e10cSrcweir
5615cdf0e10cSrcweir rSt >> fcPlcfAtnbkf;
5616cdf0e10cSrcweir rSt >> lcbPlcfAtnbkf;
5617cdf0e10cSrcweir rSt >> fcPlcfAtnbkl;
5618cdf0e10cSrcweir rSt >> lcbPlcfAtnbkl;
5619cdf0e10cSrcweir rSt >> fcPms;
5620cdf0e10cSrcweir rSt >> lcbPMS;
5621cdf0e10cSrcweir rSt >> fcFormFldSttbf;
5622cdf0e10cSrcweir rSt >> lcbFormFldSttbf;
5623cdf0e10cSrcweir rSt >> fcPlcfendRef;
5624cdf0e10cSrcweir rSt >> lcbPlcfendRef;
5625cdf0e10cSrcweir rSt >> fcPlcfendTxt;
5626cdf0e10cSrcweir rSt >> lcbPlcfendTxt;
5627cdf0e10cSrcweir rSt >> fcPlcffldEdn;
5628cdf0e10cSrcweir rSt >> lcbPlcffldEdn;
5629cdf0e10cSrcweir rSt >> fcPlcfpgdEdn;
5630cdf0e10cSrcweir rSt >> lcbPlcfpgdEdn;
5631cdf0e10cSrcweir rSt >> fcDggInfo;
5632cdf0e10cSrcweir rSt >> lcbDggInfo;
5633cdf0e10cSrcweir rSt >> fcSttbfRMark;
5634cdf0e10cSrcweir rSt >> lcbSttbfRMark;
5635cdf0e10cSrcweir rSt >> fcSttbfCaption;
5636cdf0e10cSrcweir rSt >> lcbSttbfCaption;
5637cdf0e10cSrcweir rSt >> fcSttbAutoCaption;
5638cdf0e10cSrcweir rSt >> lcbSttbAutoCaption;
5639cdf0e10cSrcweir rSt >> fcPlcfwkb;
5640cdf0e10cSrcweir rSt >> lcbPlcfwkb;
5641cdf0e10cSrcweir rSt >> fcPlcfspl;
5642cdf0e10cSrcweir rSt >> lcbPlcfspl;
5643cdf0e10cSrcweir rSt >> fcPlcftxbxTxt;
5644cdf0e10cSrcweir rSt >> lcbPlcftxbxTxt;
5645cdf0e10cSrcweir rSt >> fcPlcffldTxbx;
5646cdf0e10cSrcweir rSt >> lcbPlcffldTxbx;
5647cdf0e10cSrcweir rSt >> fcPlcfHdrtxbxTxt;
5648cdf0e10cSrcweir rSt >> lcbPlcfHdrtxbxTxt;
5649cdf0e10cSrcweir rSt >> fcPlcffldHdrTxbx;
5650cdf0e10cSrcweir rSt >> lcbPlcffldHdrTxbx;
5651cdf0e10cSrcweir rSt >> fcStwUser;
5652cdf0e10cSrcweir rSt >> lcbStwUser;
5653cdf0e10cSrcweir rSt >> fcSttbttmbd;
5654cdf0e10cSrcweir rSt >> lcbSttbttmbd;
5655cdf0e10cSrcweir }
5656cdf0e10cSrcweir
5657cdf0e10cSrcweir if( 0 == rSt.GetError() )
5658cdf0e10cSrcweir {
5659cdf0e10cSrcweir // Bit-Flags setzen
5660cdf0e10cSrcweir fDot = aBits1 & 0x01 ;
5661cdf0e10cSrcweir fGlsy = ( aBits1 & 0x02 ) >> 1;
5662cdf0e10cSrcweir fComplex = ( aBits1 & 0x04 ) >> 2;
5663cdf0e10cSrcweir fHasPic = ( aBits1 & 0x08 ) >> 3;
5664cdf0e10cSrcweir cQuickSaves = ( aBits1 & 0xf0 ) >> 4;
5665cdf0e10cSrcweir fEncrypted = aBits2 & 0x01 ;
5666cdf0e10cSrcweir fWhichTblStm= ( aBits2 & 0x02 ) >> 1;
5667cdf0e10cSrcweir fReadOnlyRecommended = (aBits2 & 0x4) >> 2;
5668cdf0e10cSrcweir fWriteReservation = (aBits2 & 0x8) >> 3;
5669cdf0e10cSrcweir fExtChar = ( aBits2 & 0x10 ) >> 4;
5670cdf0e10cSrcweir // dummy = ( aBits2 & 0x20 ) >> 5;
5671cdf0e10cSrcweir fFarEast = ( aBits2 & 0x40 ) >> 6; // #i90932#
5672cdf0e10cSrcweir // dummy = ( aBits2 & 0x80 ) >> 7;
5673cdf0e10cSrcweir
5674cdf0e10cSrcweir /*
5675cdf0e10cSrcweir ggfs. Ziel-Varaiblen, aus xxx_Ver67 fuellen
5676cdf0e10cSrcweir oder Flags setzen
5677cdf0e10cSrcweir */
5678cdf0e10cSrcweir if (IsSevenMinus(eVer))
5679cdf0e10cSrcweir {
5680cdf0e10cSrcweir pnChpFirst = pnChpFirst_Ver67;
5681cdf0e10cSrcweir pnPapFirst = pnPapFirst_Ver67;
5682cdf0e10cSrcweir cpnBteChp = cpnBteChp_Ver67;
5683cdf0e10cSrcweir cpnBtePap = cpnBtePap_Ver67;
5684cdf0e10cSrcweir }
5685cdf0e10cSrcweir else if (IsEightPlus(eVer))
5686cdf0e10cSrcweir {
5687cdf0e10cSrcweir fMac = aVer8Bits1 & 0x01 ;
5688cdf0e10cSrcweir fEmptySpecial = ( aVer8Bits1 & 0x02 ) >> 1;
5689cdf0e10cSrcweir fLoadOverridePage = ( aVer8Bits1 & 0x04 ) >> 2;
5690cdf0e10cSrcweir fFuturesavedUndo = ( aVer8Bits1 & 0x08 ) >> 3;
5691cdf0e10cSrcweir fWord97Saved = ( aVer8Bits1 & 0x10 ) >> 4;
5692cdf0e10cSrcweir fWord2000Saved = ( aVer8Bits1 & 0x20 ) >> 5;
5693cdf0e10cSrcweir
5694cdf0e10cSrcweir /*
5695cdf0e10cSrcweir speziell fuer WW8:
5696cdf0e10cSrcweir ermittle die Werte fuer PLCF LST und PLF LFO
5697cdf0e10cSrcweir und PLCF fuer TextBox-Break-Deskriptoren
5698cdf0e10cSrcweir */
5699cdf0e10cSrcweir long nOldPos = rSt.Tell();
5700cdf0e10cSrcweir
5701cdf0e10cSrcweir rSt.Seek( 0x02da );
5702cdf0e10cSrcweir rSt >> fcSttbFnm;
5703cdf0e10cSrcweir rSt >> lcbSttbFnm;
5704cdf0e10cSrcweir rSt >> fcPlcfLst;
5705cdf0e10cSrcweir rSt >> lcbPlcfLst;
5706cdf0e10cSrcweir rSt >> fcPlfLfo;
5707cdf0e10cSrcweir rSt >> lcbPlfLfo;
5708cdf0e10cSrcweir rSt >> fcPlcftxbxBkd;
5709cdf0e10cSrcweir rSt >> lcbPlcftxbxBkd;
5710cdf0e10cSrcweir rSt >> fcPlcfHdrtxbxBkd;
5711cdf0e10cSrcweir rSt >> lcbPlcfHdrtxbxBkd;
5712cdf0e10cSrcweir if( 0 != rSt.GetError() )
5713cdf0e10cSrcweir {
5714cdf0e10cSrcweir nFibError = ERR_SWG_READ_ERROR;
5715cdf0e10cSrcweir }
5716cdf0e10cSrcweir
5717cdf0e10cSrcweir rSt.Seek( 0x372 ); // fcSttbListNames
5718cdf0e10cSrcweir rSt >> fcSttbListNames;
5719cdf0e10cSrcweir rSt >> lcbSttbListNames;
5720cdf0e10cSrcweir
5721cdf0e10cSrcweir if (cfclcb > 93)
5722cdf0e10cSrcweir {
5723cdf0e10cSrcweir rSt.Seek( 0x382 ); // MagicTables
5724cdf0e10cSrcweir rSt >> fcPlcfTch;
5725cdf0e10cSrcweir rSt >> lcbPlcfTch;
5726cdf0e10cSrcweir }
5727cdf0e10cSrcweir
5728cdf0e10cSrcweir if (cfclcb > 113)
5729cdf0e10cSrcweir {
5730cdf0e10cSrcweir rSt.Seek( 0x41A ); // new ATRD
5731cdf0e10cSrcweir rSt >> fcAtrdExtra;
5732cdf0e10cSrcweir rSt >> lcbAtrdExtra;
5733cdf0e10cSrcweir }
5734cdf0e10cSrcweir
5735cdf0e10cSrcweir if( 0 != rSt.GetError() )
5736cdf0e10cSrcweir nFibError = ERR_SWG_READ_ERROR;
5737cdf0e10cSrcweir
5738cdf0e10cSrcweir rSt.Seek( 0x5bc ); // Actual nFib introduced in Word 2003
5739cdf0e10cSrcweir rSt >> nFib_actual;
5740cdf0e10cSrcweir
5741cdf0e10cSrcweir rSt.Seek( nOldPos );
5742cdf0e10cSrcweir }
5743cdf0e10cSrcweir }
5744cdf0e10cSrcweir else
5745cdf0e10cSrcweir {
5746cdf0e10cSrcweir nFibError = ERR_SWG_READ_ERROR; // Error melden
5747cdf0e10cSrcweir }
5748cdf0e10cSrcweir }
5749cdf0e10cSrcweir
5750cdf0e10cSrcweir
WW8Fib(sal_uInt8 nVer)5751cdf0e10cSrcweir WW8Fib::WW8Fib(sal_uInt8 nVer)
5752cdf0e10cSrcweir {
5753cdf0e10cSrcweir memset(this, 0, sizeof(*this));
5754cdf0e10cSrcweir nVersion = nVer;
5755cdf0e10cSrcweir if (8 == nVer)
5756cdf0e10cSrcweir {
5757cdf0e10cSrcweir fcMin = 0x800;
5758cdf0e10cSrcweir wIdent = 0xa5ec;
5759cdf0e10cSrcweir nFib = 0x0101;
5760cdf0e10cSrcweir nFibBack = 0xbf;
5761cdf0e10cSrcweir nProduct = 0x204D;
5762cdf0e10cSrcweir
5763cdf0e10cSrcweir csw = 0x0e; // muss das sein ???
5764cdf0e10cSrcweir cfclcb = 0x88; // -""-
5765cdf0e10cSrcweir clw = 0x16; // -""-
5766cdf0e10cSrcweir pnFbpChpFirst = pnFbpPapFirst = pnFbpLvcFirst = 0x000fffff;
5767cdf0e10cSrcweir fExtChar = true;
5768cdf0e10cSrcweir fWord97Saved = fWord2000Saved = true;
5769cdf0e10cSrcweir
5770cdf0e10cSrcweir // diese Flags muessen nicht gesetzt werden; koennen aber.
5771cdf0e10cSrcweir // wMagicCreated = wMagicRevised = 0x6a62;
5772cdf0e10cSrcweir // wMagicCreatedPrivate = wMagicRevisedPrivate = 0xb3b2;
5773cdf0e10cSrcweir //
5774cdf0e10cSrcweir
5775cdf0e10cSrcweir wMagicCreated = 0x6143;
5776cdf0e10cSrcweir wMagicRevised = 0x6C6F;
5777cdf0e10cSrcweir wMagicCreatedPrivate = 0x6E61;
5778cdf0e10cSrcweir wMagicRevisedPrivate = 0x3038;
5779cdf0e10cSrcweir }
5780cdf0e10cSrcweir else
5781cdf0e10cSrcweir {
5782cdf0e10cSrcweir fcMin = 0x300;
5783cdf0e10cSrcweir wIdent = 0xa5dc;
5784cdf0e10cSrcweir nFib = nFibBack = 0x65;
5785cdf0e10cSrcweir nProduct = 0xc02d;
5786cdf0e10cSrcweir }
5787cdf0e10cSrcweir
5788cdf0e10cSrcweir // --> #i90932#
5789cdf0e10cSrcweir lid = 0x409; // LANGUAGE_ENGLISH_US
5790cdf0e10cSrcweir
5791cdf0e10cSrcweir LanguageType nLang = Application::GetSettings().GetLanguage();
5792cdf0e10cSrcweir switch( nLang )
5793cdf0e10cSrcweir {
5794cdf0e10cSrcweir case LANGUAGE_CHINESE:
5795cdf0e10cSrcweir case LANGUAGE_CHINESE_SIMPLIFIED:
5796cdf0e10cSrcweir case LANGUAGE_CHINESE_HONGKONG:
5797cdf0e10cSrcweir case LANGUAGE_CHINESE_SINGAPORE:
5798cdf0e10cSrcweir case LANGUAGE_CHINESE_MACAU:
5799cdf0e10cSrcweir case LANGUAGE_CHINESE_TRADITIONAL:
5800cdf0e10cSrcweir case LANGUAGE_KOREAN:
5801cdf0e10cSrcweir case LANGUAGE_KOREAN_JOHAB:
5802cdf0e10cSrcweir case LANGUAGE_JAPANESE:
5803cdf0e10cSrcweir lidFE = nLang;
5804cdf0e10cSrcweir fFarEast = true;
5805cdf0e10cSrcweir break;
5806cdf0e10cSrcweir default:
5807cdf0e10cSrcweir lidFE = lid;
5808cdf0e10cSrcweir fFarEast = false;
5809cdf0e10cSrcweir break;
5810cdf0e10cSrcweir };
5811cdf0e10cSrcweir // <-- #i90932#
5812cdf0e10cSrcweir }
5813cdf0e10cSrcweir
WriteHeader(SvStream & rStrm)5814cdf0e10cSrcweir bool WW8Fib::WriteHeader(SvStream& rStrm)
5815cdf0e10cSrcweir {
5816cdf0e10cSrcweir bool bVer8 = 8 == nVersion;
5817cdf0e10cSrcweir
5818cdf0e10cSrcweir size_t nUnencryptedHdr = bVer8 ? 0x44 : 0x24;
5819cdf0e10cSrcweir sal_uInt8 *pDataPtr = new sal_uInt8[ nUnencryptedHdr ];
5820cdf0e10cSrcweir sal_uInt8 *pData = pDataPtr;
5821cdf0e10cSrcweir memset( pData, 0, nUnencryptedHdr );
5822cdf0e10cSrcweir
5823cdf0e10cSrcweir sal_uLong nPos = rStrm.Tell();
5824cdf0e10cSrcweir cbMac = rStrm.Seek( STREAM_SEEK_TO_END );
5825cdf0e10cSrcweir rStrm.Seek( nPos );
5826cdf0e10cSrcweir
5827cdf0e10cSrcweir Set_UInt16( pData, wIdent );
5828cdf0e10cSrcweir Set_UInt16( pData, nFib );
5829cdf0e10cSrcweir Set_UInt16( pData, nProduct );
5830cdf0e10cSrcweir Set_UInt16( pData, lid );
5831cdf0e10cSrcweir Set_UInt16( pData, pnNext );
5832cdf0e10cSrcweir
5833cdf0e10cSrcweir sal_uInt16 nBits16 = 0;
5834cdf0e10cSrcweir if( fDot ) nBits16 |= 0x0001;
5835cdf0e10cSrcweir if( fGlsy) nBits16 |= 0x0002;
5836cdf0e10cSrcweir if( fComplex ) nBits16 |= 0x0004;
5837cdf0e10cSrcweir if( fHasPic ) nBits16 |= 0x0008;
5838cdf0e10cSrcweir nBits16 |= (0xf0 & ( cQuickSaves << 4 ));
5839cdf0e10cSrcweir if( fEncrypted ) nBits16 |= 0x0100;
5840cdf0e10cSrcweir if( fWhichTblStm ) nBits16 |= 0x0200;
5841cdf0e10cSrcweir
5842cdf0e10cSrcweir if (fReadOnlyRecommended)
5843cdf0e10cSrcweir nBits16 |= 0x0400;
5844cdf0e10cSrcweir if (fWriteReservation)
5845cdf0e10cSrcweir nBits16 |= 0x0800;
5846cdf0e10cSrcweir
5847cdf0e10cSrcweir if( fExtChar ) nBits16 |= 0x1000;
5848cdf0e10cSrcweir if( fFarEast ) nBits16 |= 0x4000; // #i90932#
5849cdf0e10cSrcweir if( fObfuscated ) nBits16 |= 0x8000;
5850cdf0e10cSrcweir Set_UInt16( pData, nBits16 );
5851cdf0e10cSrcweir
5852cdf0e10cSrcweir Set_UInt16( pData, nFibBack );
5853cdf0e10cSrcweir Set_UInt16( pData, nHash );
5854cdf0e10cSrcweir Set_UInt16( pData, nKey );
5855cdf0e10cSrcweir Set_UInt8( pData, envr );
5856cdf0e10cSrcweir
5857cdf0e10cSrcweir sal_uInt8 nBits8 = 0;
5858cdf0e10cSrcweir if( bVer8 )
5859cdf0e10cSrcweir {
5860cdf0e10cSrcweir if( fMac ) nBits8 |= 0x0001;
5861cdf0e10cSrcweir if( fEmptySpecial ) nBits8 |= 0x0002;
5862cdf0e10cSrcweir if( fLoadOverridePage ) nBits8 |= 0x0004;
5863cdf0e10cSrcweir if( fFuturesavedUndo ) nBits8 |= 0x0008;
5864cdf0e10cSrcweir if( fWord97Saved ) nBits8 |= 0x0010;
5865cdf0e10cSrcweir if( fWord2000Saved ) nBits8 |= 0x0020;
5866cdf0e10cSrcweir }
5867cdf0e10cSrcweir // unter Ver67 these are only reserved
5868cdf0e10cSrcweir Set_UInt8( pData, nBits8 );
5869cdf0e10cSrcweir
5870cdf0e10cSrcweir Set_UInt16( pData, chse );
5871cdf0e10cSrcweir Set_UInt16( pData, chseTables );
5872cdf0e10cSrcweir Set_UInt32( pData, fcMin );
5873cdf0e10cSrcweir Set_UInt32( pData, fcMac );
5874cdf0e10cSrcweir
5875cdf0e10cSrcweir // Einschub fuer WW8 *****************************************************
5876cdf0e10cSrcweir
5877cdf0e10cSrcweir // Marke: "rgsw" Beginning of the array of shorts
5878cdf0e10cSrcweir if( bVer8 )
5879cdf0e10cSrcweir {
5880cdf0e10cSrcweir Set_UInt16( pData, csw );
5881cdf0e10cSrcweir Set_UInt16( pData, wMagicCreated );
5882cdf0e10cSrcweir Set_UInt16( pData, wMagicRevised );
5883cdf0e10cSrcweir Set_UInt16( pData, wMagicCreatedPrivate );
5884cdf0e10cSrcweir Set_UInt16( pData, wMagicRevisedPrivate );
5885cdf0e10cSrcweir pData += 9 * sizeof( sal_Int16 );
5886cdf0e10cSrcweir Set_UInt16( pData, lidFE );
5887cdf0e10cSrcweir Set_UInt16( pData, clw );
5888cdf0e10cSrcweir }
5889cdf0e10cSrcweir
5890cdf0e10cSrcweir // Ende des Einschubs fuer WW8 *******************************************
5891cdf0e10cSrcweir
5892cdf0e10cSrcweir // Marke: "rglw" Beginning of the array of longs
5893cdf0e10cSrcweir Set_UInt32( pData, cbMac );
5894cdf0e10cSrcweir
5895cdf0e10cSrcweir rStrm.Write( pDataPtr, nUnencryptedHdr );
5896cdf0e10cSrcweir delete[] pDataPtr;
5897cdf0e10cSrcweir return 0 == rStrm.GetError();
5898cdf0e10cSrcweir }
5899cdf0e10cSrcweir
Write(SvStream & rStrm)5900cdf0e10cSrcweir bool WW8Fib::Write(SvStream& rStrm)
5901cdf0e10cSrcweir {
5902cdf0e10cSrcweir bool bVer8 = 8 == nVersion;
5903cdf0e10cSrcweir
5904cdf0e10cSrcweir WriteHeader( rStrm );
5905cdf0e10cSrcweir
5906cdf0e10cSrcweir size_t nUnencryptedHdr = bVer8 ? 0x44 : 0x24;
5907cdf0e10cSrcweir
5908cdf0e10cSrcweir sal_uInt8 *pDataPtr = new sal_uInt8[ fcMin - nUnencryptedHdr ];
5909cdf0e10cSrcweir sal_uInt8 *pData = pDataPtr;
5910cdf0e10cSrcweir memset( pData, 0, fcMin - nUnencryptedHdr );
5911cdf0e10cSrcweir
5912cdf0e10cSrcweir sal_uLong nPos = rStrm.Tell();
5913cdf0e10cSrcweir cbMac = rStrm.Seek( STREAM_SEEK_TO_END );
5914cdf0e10cSrcweir rStrm.Seek( nPos );
5915cdf0e10cSrcweir
5916cdf0e10cSrcweir // 2 Longs uebergehen, da unwichtiger Quatsch
5917cdf0e10cSrcweir pData += 2 * sizeof( sal_Int32);
5918cdf0e10cSrcweir
5919cdf0e10cSrcweir // weitere 2 Longs nur bei Ver67 ueberspringen
5920cdf0e10cSrcweir if( !bVer8 )
5921cdf0e10cSrcweir pData += 2 * sizeof( sal_Int32);
5922cdf0e10cSrcweir
5923cdf0e10cSrcweir Set_UInt32( pData, ccpText );
5924cdf0e10cSrcweir Set_UInt32( pData, ccpFtn );
5925cdf0e10cSrcweir Set_UInt32( pData, ccpHdr );
5926cdf0e10cSrcweir Set_UInt32( pData, ccpMcr );
5927cdf0e10cSrcweir Set_UInt32( pData, ccpAtn );
5928cdf0e10cSrcweir Set_UInt32( pData, ccpEdn );
5929cdf0e10cSrcweir Set_UInt32( pData, ccpTxbx );
5930cdf0e10cSrcweir Set_UInt32( pData, ccpHdrTxbx );
5931cdf0e10cSrcweir
5932cdf0e10cSrcweir // weiteres Long nur bei Ver67 ueberspringen
5933cdf0e10cSrcweir if( !bVer8 )
5934cdf0e10cSrcweir pData += 1 * sizeof( sal_Int32);
5935cdf0e10cSrcweir
5936cdf0e10cSrcweir // Einschub fuer WW8 *****************************************************
5937cdf0e10cSrcweir if( bVer8 )
5938cdf0e10cSrcweir {
5939cdf0e10cSrcweir Set_UInt32( pData, pnFbpChpFirst );
5940cdf0e10cSrcweir Set_UInt32( pData, pnChpFirst );
5941cdf0e10cSrcweir Set_UInt32( pData, cpnBteChp );
5942cdf0e10cSrcweir Set_UInt32( pData, pnFbpPapFirst );
5943cdf0e10cSrcweir Set_UInt32( pData, pnPapFirst );
5944cdf0e10cSrcweir Set_UInt32( pData, cpnBtePap );
5945cdf0e10cSrcweir Set_UInt32( pData, pnFbpLvcFirst );
5946cdf0e10cSrcweir Set_UInt32( pData, pnLvcFirst );
5947cdf0e10cSrcweir Set_UInt32( pData, cpnBteLvc );
5948cdf0e10cSrcweir Set_UInt32( pData, fcIslandFirst );
5949cdf0e10cSrcweir Set_UInt32( pData, fcIslandLim );
5950cdf0e10cSrcweir Set_UInt16( pData, cfclcb );
5951cdf0e10cSrcweir }
5952cdf0e10cSrcweir // Ende des Einschubs fuer WW8 *******************************************
5953cdf0e10cSrcweir
5954cdf0e10cSrcweir // Marke: "rgfclcb" Beginning of array of FC/LCB pairs.
5955cdf0e10cSrcweir Set_UInt32( pData, fcStshfOrig );
5956cdf0e10cSrcweir Set_UInt32( pData, lcbStshfOrig );
5957cdf0e10cSrcweir Set_UInt32( pData, fcStshf );
5958cdf0e10cSrcweir Set_UInt32( pData, lcbStshf );
5959cdf0e10cSrcweir Set_UInt32( pData, fcPlcffndRef );
5960cdf0e10cSrcweir Set_UInt32( pData, lcbPlcffndRef );
5961cdf0e10cSrcweir Set_UInt32( pData, fcPlcffndTxt );
5962cdf0e10cSrcweir Set_UInt32( pData, lcbPlcffndTxt );
5963cdf0e10cSrcweir Set_UInt32( pData, fcPlcfandRef );
5964cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfandRef );
5965cdf0e10cSrcweir Set_UInt32( pData, fcPlcfandTxt );
5966cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfandTxt );
5967cdf0e10cSrcweir Set_UInt32( pData, fcPlcfsed );
5968cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfsed );
5969cdf0e10cSrcweir Set_UInt32( pData, fcPlcfpad );
5970cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfpad );
5971cdf0e10cSrcweir Set_UInt32( pData, fcPlcfphe );
5972cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfphe );
5973cdf0e10cSrcweir Set_UInt32( pData, fcSttbfglsy );
5974cdf0e10cSrcweir Set_UInt32( pData, lcbSttbfglsy );
5975cdf0e10cSrcweir Set_UInt32( pData, fcPlcfglsy );
5976cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfglsy );
5977cdf0e10cSrcweir Set_UInt32( pData, fcPlcfhdd );
5978cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfhdd );
5979cdf0e10cSrcweir Set_UInt32( pData, fcPlcfbteChpx );
5980cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfbteChpx );
5981cdf0e10cSrcweir Set_UInt32( pData, fcPlcfbtePapx );
5982cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfbtePapx );
5983cdf0e10cSrcweir Set_UInt32( pData, fcPlcfsea );
5984cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfsea );
5985cdf0e10cSrcweir Set_UInt32( pData, fcSttbfffn );
5986cdf0e10cSrcweir Set_UInt32( pData, lcbSttbfffn );
5987cdf0e10cSrcweir Set_UInt32( pData, fcPlcffldMom );
5988cdf0e10cSrcweir Set_UInt32( pData, lcbPlcffldMom );
5989cdf0e10cSrcweir Set_UInt32( pData, fcPlcffldHdr );
5990cdf0e10cSrcweir Set_UInt32( pData, lcbPlcffldHdr );
5991cdf0e10cSrcweir Set_UInt32( pData, fcPlcffldFtn );
5992cdf0e10cSrcweir Set_UInt32( pData, lcbPlcffldFtn );
5993cdf0e10cSrcweir Set_UInt32( pData, fcPlcffldAtn );
5994cdf0e10cSrcweir Set_UInt32( pData, lcbPlcffldAtn );
5995cdf0e10cSrcweir Set_UInt32( pData, fcPlcffldMcr );
5996cdf0e10cSrcweir Set_UInt32( pData, lcbPlcffldMcr );
5997cdf0e10cSrcweir Set_UInt32( pData, fcSttbfbkmk );
5998cdf0e10cSrcweir Set_UInt32( pData, lcbSttbfbkmk );
5999cdf0e10cSrcweir Set_UInt32( pData, fcPlcfbkf );
6000cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfbkf );
6001cdf0e10cSrcweir Set_UInt32( pData, fcPlcfbkl );
6002cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfbkl );
6003cdf0e10cSrcweir Set_UInt32( pData, fcCmds );
6004cdf0e10cSrcweir Set_UInt32( pData, lcbCmds );
6005cdf0e10cSrcweir Set_UInt32( pData, fcPlcfmcr );
6006cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfmcr );
6007cdf0e10cSrcweir Set_UInt32( pData, fcSttbfmcr );
6008cdf0e10cSrcweir Set_UInt32( pData, lcbSttbfmcr );
6009cdf0e10cSrcweir Set_UInt32( pData, fcPrDrvr );
6010cdf0e10cSrcweir Set_UInt32( pData, lcbPrDrvr );
6011cdf0e10cSrcweir Set_UInt32( pData, fcPrEnvPort );
6012cdf0e10cSrcweir Set_UInt32( pData, lcbPrEnvPort );
6013cdf0e10cSrcweir Set_UInt32( pData, fcPrEnvLand );
6014cdf0e10cSrcweir Set_UInt32( pData, lcbPrEnvLand );
6015cdf0e10cSrcweir Set_UInt32( pData, fcWss );
6016cdf0e10cSrcweir Set_UInt32( pData, lcbWss );
6017cdf0e10cSrcweir Set_UInt32( pData, fcDop );
6018cdf0e10cSrcweir Set_UInt32( pData, lcbDop );
6019cdf0e10cSrcweir Set_UInt32( pData, fcSttbfAssoc );
6020cdf0e10cSrcweir Set_UInt32( pData, lcbSttbfAssoc );
6021cdf0e10cSrcweir Set_UInt32( pData, fcClx );
6022cdf0e10cSrcweir Set_UInt32( pData, lcbClx );
6023cdf0e10cSrcweir Set_UInt32( pData, fcPlcfpgdFtn );
6024cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfpgdFtn );
6025cdf0e10cSrcweir Set_UInt32( pData, fcAutosaveSource );
6026cdf0e10cSrcweir Set_UInt32( pData, lcbAutosaveSource );
6027cdf0e10cSrcweir Set_UInt32( pData, fcGrpStAtnOwners );
6028cdf0e10cSrcweir Set_UInt32( pData, lcbGrpStAtnOwners );
6029cdf0e10cSrcweir Set_UInt32( pData, fcSttbfAtnbkmk );
6030cdf0e10cSrcweir Set_UInt32( pData, lcbSttbfAtnbkmk );
6031cdf0e10cSrcweir
6032cdf0e10cSrcweir // weiteres short nur bei Ver67 ueberspringen
6033cdf0e10cSrcweir if( !bVer8 )
6034cdf0e10cSrcweir {
6035cdf0e10cSrcweir pData += 1*sizeof( sal_Int16);
6036cdf0e10cSrcweir Set_UInt16( pData, (sal_uInt16)pnChpFirst );
6037cdf0e10cSrcweir Set_UInt16( pData, (sal_uInt16)pnPapFirst );
6038cdf0e10cSrcweir Set_UInt16( pData, (sal_uInt16)cpnBteChp );
6039cdf0e10cSrcweir Set_UInt16( pData, (sal_uInt16)cpnBtePap );
6040cdf0e10cSrcweir }
6041cdf0e10cSrcweir
6042cdf0e10cSrcweir Set_UInt32( pData, fcPlcfdoaMom ); // nur bei Ver67, in Ver8 unused
6043cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfdoaMom ); // nur bei Ver67, in Ver8 unused
6044cdf0e10cSrcweir Set_UInt32( pData, fcPlcfdoaHdr ); // nur bei Ver67, in Ver8 unused
6045cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfdoaHdr ); // nur bei Ver67, in Ver8 unused
6046cdf0e10cSrcweir
6047cdf0e10cSrcweir Set_UInt32( pData, fcPlcfspaMom ); // in Ver67 leere Reserve
6048cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfspaMom ); // in Ver67 leere Reserve
6049cdf0e10cSrcweir Set_UInt32( pData, fcPlcfspaHdr ); // in Ver67 leere Reserve
6050cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfspaHdr ); // in Ver67 leere Reserve
6051cdf0e10cSrcweir
6052cdf0e10cSrcweir Set_UInt32( pData, fcPlcfAtnbkf );
6053cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfAtnbkf );
6054cdf0e10cSrcweir Set_UInt32( pData, fcPlcfAtnbkl );
6055cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfAtnbkl );
6056cdf0e10cSrcweir Set_UInt32( pData, fcPms );
6057cdf0e10cSrcweir Set_UInt32( pData, lcbPMS );
6058cdf0e10cSrcweir Set_UInt32( pData, fcFormFldSttbf );
6059cdf0e10cSrcweir Set_UInt32( pData, lcbFormFldSttbf );
6060cdf0e10cSrcweir Set_UInt32( pData, fcPlcfendRef );
6061cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfendRef );
6062cdf0e10cSrcweir Set_UInt32( pData, fcPlcfendTxt );
6063cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfendTxt );
6064cdf0e10cSrcweir Set_UInt32( pData, fcPlcffldEdn );
6065cdf0e10cSrcweir Set_UInt32( pData, lcbPlcffldEdn );
6066cdf0e10cSrcweir Set_UInt32( pData, fcPlcfpgdEdn );
6067cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfpgdEdn );
6068cdf0e10cSrcweir Set_UInt32( pData, fcDggInfo ); // in Ver67 leere Reserve
6069cdf0e10cSrcweir Set_UInt32( pData, lcbDggInfo ); // in Ver67 leere Reserve
6070cdf0e10cSrcweir Set_UInt32( pData, fcSttbfRMark );
6071cdf0e10cSrcweir Set_UInt32( pData, lcbSttbfRMark );
6072cdf0e10cSrcweir Set_UInt32( pData, fcSttbfCaption );
6073cdf0e10cSrcweir Set_UInt32( pData, lcbSttbfCaption );
6074cdf0e10cSrcweir Set_UInt32( pData, fcSttbAutoCaption );
6075cdf0e10cSrcweir Set_UInt32( pData, lcbSttbAutoCaption );
6076cdf0e10cSrcweir Set_UInt32( pData, fcPlcfwkb );
6077cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfwkb );
6078cdf0e10cSrcweir Set_UInt32( pData, fcPlcfspl ); // in Ver67 leere Reserve
6079cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfspl ); // in Ver67 leere Reserve
6080cdf0e10cSrcweir Set_UInt32( pData, fcPlcftxbxTxt );
6081cdf0e10cSrcweir Set_UInt32( pData, lcbPlcftxbxTxt );
6082cdf0e10cSrcweir Set_UInt32( pData, fcPlcffldTxbx );
6083cdf0e10cSrcweir Set_UInt32( pData, lcbPlcffldTxbx );
6084cdf0e10cSrcweir Set_UInt32( pData, fcPlcfHdrtxbxTxt );
6085cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfHdrtxbxTxt );
6086cdf0e10cSrcweir Set_UInt32( pData, fcPlcffldHdrTxbx );
6087cdf0e10cSrcweir Set_UInt32( pData, lcbPlcffldHdrTxbx );
6088cdf0e10cSrcweir
6089cdf0e10cSrcweir if( bVer8 )
6090cdf0e10cSrcweir {
6091cdf0e10cSrcweir pData += 0x2da - 0x27a; // Pos + Offset (fcPlcfLst - fcStwUser)
6092cdf0e10cSrcweir Set_UInt32( pData, fcSttbFnm);
6093cdf0e10cSrcweir Set_UInt32( pData, lcbSttbFnm);
6094cdf0e10cSrcweir Set_UInt32( pData, fcPlcfLst );
6095cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfLst );
6096cdf0e10cSrcweir Set_UInt32( pData, fcPlfLfo );
6097cdf0e10cSrcweir Set_UInt32( pData, lcbPlfLfo );
6098cdf0e10cSrcweir Set_UInt32( pData, fcPlcftxbxBkd );
6099cdf0e10cSrcweir Set_UInt32( pData, lcbPlcftxbxBkd );
6100cdf0e10cSrcweir Set_UInt32( pData, fcPlcfHdrtxbxBkd );
6101cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfHdrtxbxBkd );
6102cdf0e10cSrcweir
6103cdf0e10cSrcweir pData += 0x372 - 0x302; // Pos + Offset (fcSttbListNames - fcDocUndo)
6104cdf0e10cSrcweir Set_UInt32( pData, fcSttbListNames );
6105cdf0e10cSrcweir Set_UInt32( pData, lcbSttbListNames );
6106cdf0e10cSrcweir
6107cdf0e10cSrcweir pData += 0x382 - 0x37A;
6108cdf0e10cSrcweir Set_UInt32( pData, fcPlcfTch );
6109cdf0e10cSrcweir Set_UInt32( pData, lcbPlcfTch );
6110cdf0e10cSrcweir
6111cdf0e10cSrcweir pData += 0x3FA - 0x38A;
6112cdf0e10cSrcweir Set_UInt16( pData, (sal_uInt16)0x0002);
6113cdf0e10cSrcweir Set_UInt16( pData, (sal_uInt16)0x00D9);
6114cdf0e10cSrcweir
6115cdf0e10cSrcweir pData += 0x41A - 0x3FE;
6116cdf0e10cSrcweir Set_UInt32( pData, fcAtrdExtra );
6117cdf0e10cSrcweir Set_UInt32( pData, lcbAtrdExtra );
6118cdf0e10cSrcweir
6119cdf0e10cSrcweir pData += 0x4DA - 0x422;
6120cdf0e10cSrcweir Set_UInt32( pData, fcHplxsdr );
6121cdf0e10cSrcweir Set_UInt32( pData, 0);
6122cdf0e10cSrcweir }
6123cdf0e10cSrcweir
6124cdf0e10cSrcweir rStrm.Write( pDataPtr, fcMin - nUnencryptedHdr );
6125cdf0e10cSrcweir delete[] pDataPtr;
6126cdf0e10cSrcweir return 0 == rStrm.GetError();
6127cdf0e10cSrcweir }
6128cdf0e10cSrcweir
GetFIBCharset(sal_uInt16 chs)6129cdf0e10cSrcweir rtl_TextEncoding WW8Fib::GetFIBCharset(sal_uInt16 chs)
6130cdf0e10cSrcweir {
6131cdf0e10cSrcweir ASSERT(chs <= 0x100, "overflowed winword charset set");
6132cdf0e10cSrcweir rtl_TextEncoding eCharSet =
6133cdf0e10cSrcweir (0x0100 == chs)
6134cdf0e10cSrcweir ? RTL_TEXTENCODING_APPLE_ROMAN
6135cdf0e10cSrcweir : rtl_getTextEncodingFromWindowsCharset( static_cast<sal_uInt8>(chs) );
6136cdf0e10cSrcweir return eCharSet;
6137cdf0e10cSrcweir }
6138cdf0e10cSrcweir
WW8Style(SvStream & rStream,WW8Fib & rFibPara)6139cdf0e10cSrcweir WW8Style::WW8Style(SvStream& rStream, WW8Fib& rFibPara)
6140cdf0e10cSrcweir : rFib(rFibPara), rSt(rStream), cstd(0), cbSTDBaseInFile(0),
6141cdf0e10cSrcweir stiMaxWhenSaved(0), istdMaxFixedWhenSaved(0), nVerBuiltInNamesWhenSaved(0),
6142fcb46e12SPedro Giffuni ftcAsci(0), ftcFE(0), ftcOther(0), ftcBi(0)
6143cdf0e10cSrcweir {
6144cdf0e10cSrcweir nStyleStart = rFib.fcStshf;
6145cdf0e10cSrcweir nStyleLen = rFib.lcbStshf;
6146cdf0e10cSrcweir
6147cdf0e10cSrcweir rSt.Seek(nStyleStart);
6148cdf0e10cSrcweir
6149cdf0e10cSrcweir sal_uInt16 cbStshi = 0; // 2 bytes size of the following STSHI structure
6150cdf0e10cSrcweir
6151cdf0e10cSrcweir if (rFib.GetFIBVersion() <= ww::eWW2)
6152cdf0e10cSrcweir {
6153cdf0e10cSrcweir cbStshi = 0;
6154cdf0e10cSrcweir cstd = 256;
6155cdf0e10cSrcweir }
6156cdf0e10cSrcweir else if (rFib.nFib < 67) // old Version ? (need to find this again to fix)
6157cdf0e10cSrcweir cbStshi = 4; // -> Laengenfeld fehlt
6158cdf0e10cSrcweir else // neue Version:
6159cdf0e10cSrcweir // lies die Laenge der in der Datei gespeicherten Struktur
6160cdf0e10cSrcweir rSt >> cbStshi;
6161cdf0e10cSrcweir
6162cdf0e10cSrcweir sal_uInt16 nRead = cbStshi;
6163cdf0e10cSrcweir do
6164cdf0e10cSrcweir {
6165cdf0e10cSrcweir sal_uInt16 a16Bit;
6166cdf0e10cSrcweir
6167cdf0e10cSrcweir if( 2 > nRead ) break;
6168cdf0e10cSrcweir rSt >> cstd;
6169cdf0e10cSrcweir
6170cdf0e10cSrcweir if( 4 > nRead ) break;
6171cdf0e10cSrcweir rSt >> cbSTDBaseInFile;
6172cdf0e10cSrcweir
6173cdf0e10cSrcweir if( 6 > nRead ) break;
6174cdf0e10cSrcweir rSt >> a16Bit;
6175cdf0e10cSrcweir fStdStylenamesWritten = a16Bit & 0x0001;
6176cdf0e10cSrcweir
6177cdf0e10cSrcweir if( 8 > nRead ) break;
6178cdf0e10cSrcweir rSt >> stiMaxWhenSaved;
6179cdf0e10cSrcweir
6180cdf0e10cSrcweir if( 10 > nRead ) break;
6181cdf0e10cSrcweir rSt >> istdMaxFixedWhenSaved;
6182cdf0e10cSrcweir
6183cdf0e10cSrcweir if( 12 > nRead ) break;
6184cdf0e10cSrcweir rSt >> nVerBuiltInNamesWhenSaved;
6185cdf0e10cSrcweir
6186cdf0e10cSrcweir if( 14 > nRead ) break;
6187fcb46e12SPedro Giffuni rSt >> ftcAsci;
6188cdf0e10cSrcweir
6189cdf0e10cSrcweir if( 16 > nRead ) break;
6190fcb46e12SPedro Giffuni rSt >> ftcFE;
6191cdf0e10cSrcweir
6192cdf0e10cSrcweir if ( 18 > nRead ) break;
6193fcb46e12SPedro Giffuni rSt >> ftcOther;
6194fcb46e12SPedro Giffuni
6195fcb46e12SPedro Giffuni ftcBi = ftcOther;
6196fcb46e12SPedro Giffuni
6197fcb46e12SPedro Giffuni if ( 20 > nRead ) break;
6198fcb46e12SPedro Giffuni rSt >> ftcBi;
6199cdf0e10cSrcweir
6200cdf0e10cSrcweir // ggfs. den Rest ueberlesen
6201fcb46e12SPedro Giffuni if( 20 < nRead )
6202fcb46e12SPedro Giffuni rSt.SeekRel( nRead-20 );
6203cdf0e10cSrcweir }
6204cdf0e10cSrcweir while( !this ); // Trick: obiger Block wird genau einmal durchlaufen
6205cdf0e10cSrcweir // und kann vorzeitig per "break" verlassen werden.
6206cdf0e10cSrcweir
6207cdf0e10cSrcweir if( 0 != rSt.GetError() )
6208cdf0e10cSrcweir {
6209cdf0e10cSrcweir // wie denn nun den Error melden?
6210cdf0e10cSrcweir }
6211cdf0e10cSrcweir }
6212cdf0e10cSrcweir
6213cdf0e10cSrcweir // Read1STDFixed() liest ein Style ein. Wenn der Style vollstaendig vorhanden
6214cdf0e10cSrcweir // ist, d.h. kein leerer Slot, dann wird Speicher alloziert und ein Pointer auf
6215cdf0e10cSrcweir // die ( evtl. mit Nullen aufgefuellten ) STD geliefert. Ist es ein leerer
6216cdf0e10cSrcweir // Slot, dann wird ein Nullpointer zurueckgeliefert.
Read1STDFixed(short & rSkip,short * pcbStd)6217cdf0e10cSrcweir WW8_STD* WW8Style::Read1STDFixed( short& rSkip, short* pcbStd )
6218cdf0e10cSrcweir {
6219cdf0e10cSrcweir WW8_STD* pStd = 0;
6220cdf0e10cSrcweir
6221cdf0e10cSrcweir sal_uInt16 cbStd;
6222cdf0e10cSrcweir rSt >> cbStd; // lies Laenge
6223cdf0e10cSrcweir
6224cdf0e10cSrcweir sal_uInt16 nRead = cbSTDBaseInFile;
6225cdf0e10cSrcweir if( cbStd >= cbSTDBaseInFile )
6226cdf0e10cSrcweir {
6227cdf0e10cSrcweir // Fixed part vollst. vorhanden
6228cdf0e10cSrcweir
6229cdf0e10cSrcweir // read fixed part of STD
6230cdf0e10cSrcweir pStd = new WW8_STD;
6231cdf0e10cSrcweir memset( pStd, 0, sizeof( *pStd ) );
6232cdf0e10cSrcweir
6233cdf0e10cSrcweir do
6234cdf0e10cSrcweir {
6235cdf0e10cSrcweir sal_uInt16 a16Bit;
6236cdf0e10cSrcweir
6237cdf0e10cSrcweir if( 2 > nRead ) break;
6238cdf0e10cSrcweir rSt >> a16Bit;
6239cdf0e10cSrcweir pStd->sti = a16Bit & 0x0fff ;
6240cdf0e10cSrcweir pStd->fScratch = 0 != ( a16Bit & 0x1000 );
6241cdf0e10cSrcweir pStd->fInvalHeight = 0 != ( a16Bit & 0x2000 );
6242cdf0e10cSrcweir pStd->fHasUpe = 0 != ( a16Bit & 0x4000 );
6243cdf0e10cSrcweir pStd->fMassCopy = 0 != ( a16Bit & 0x8000 );
6244cdf0e10cSrcweir
6245cdf0e10cSrcweir if( 4 > nRead ) break;
6246cdf0e10cSrcweir rSt >> a16Bit;
6247cdf0e10cSrcweir pStd->sgc = a16Bit & 0x000f ;
6248cdf0e10cSrcweir pStd->istdBase = ( a16Bit & 0xfff0 ) >> 4;
6249cdf0e10cSrcweir
6250cdf0e10cSrcweir if( 6 > nRead ) break;
6251cdf0e10cSrcweir rSt >> a16Bit;
6252cdf0e10cSrcweir pStd->cupx = a16Bit & 0x000f ;
6253cdf0e10cSrcweir pStd->istdNext = ( a16Bit & 0xfff0 ) >> 4;
6254cdf0e10cSrcweir
6255cdf0e10cSrcweir if( 8 > nRead ) break;
6256cdf0e10cSrcweir rSt >> pStd->bchUpe;
6257cdf0e10cSrcweir
6258cdf0e10cSrcweir // ab Ver8 sollten diese beiden Felder dazukommen:
6259cdf0e10cSrcweir if(10 > nRead ) break;
6260cdf0e10cSrcweir rSt >> a16Bit;
6261cdf0e10cSrcweir pStd->fAutoRedef = a16Bit & 0x0001 ;
626258ebf6bfSHerbert Dürr pStd->fHidden = ( a16Bit & 0x0002 ) >> 1;
6263cdf0e10cSrcweir
6264cdf0e10cSrcweir // man kann nie wissen: vorsichtshalber ueberlesen
6265cdf0e10cSrcweir // wir eventuelle Fuellsel, die noch zum BASE-Part gehoeren...
6266cdf0e10cSrcweir if( 10 < nRead )
6267cdf0e10cSrcweir rSt.SeekRel( nRead-10 );
6268cdf0e10cSrcweir }
6269cdf0e10cSrcweir while( !this ); // Trick: obiger Block wird genau einmal durchlaufen
6270cdf0e10cSrcweir // und kann vorzeitig per "break" verlassen werden.
6271cdf0e10cSrcweir
6272cdf0e10cSrcweir if( (0 != rSt.GetError()) || !nRead )
6273cdf0e10cSrcweir DELETEZ( pStd ); // per NULL den Error melden
6274cdf0e10cSrcweir
6275cdf0e10cSrcweir rSkip = cbStd - cbSTDBaseInFile;
6276cdf0e10cSrcweir }
6277cdf0e10cSrcweir else
6278cdf0e10cSrcweir { // Fixed part zu kurz
6279cdf0e10cSrcweir if( cbStd )
6280cdf0e10cSrcweir rSt.SeekRel( cbStd ); // ueberlies Reste
6281cdf0e10cSrcweir rSkip = 0;
6282cdf0e10cSrcweir }
6283cdf0e10cSrcweir if( pcbStd )
6284cdf0e10cSrcweir *pcbStd = cbStd;
6285cdf0e10cSrcweir return pStd;
6286cdf0e10cSrcweir }
6287cdf0e10cSrcweir
Read1Style(short & rSkip,String * pString,short * pcbStd)6288cdf0e10cSrcweir WW8_STD* WW8Style::Read1Style( short& rSkip, String* pString, short* pcbStd )
6289cdf0e10cSrcweir {
6290cdf0e10cSrcweir // Attention: MacWord-Documents have their Stylenames
6291cdf0e10cSrcweir // always in ANSI, even if eStructCharSet == CHARSET_MAC !!
6292cdf0e10cSrcweir
6293cdf0e10cSrcweir WW8_STD* pStd = Read1STDFixed( rSkip, pcbStd ); // lese STD
6294cdf0e10cSrcweir
6295cdf0e10cSrcweir // String gewuenscht ?
6296cdf0e10cSrcweir if( pString )
6297cdf0e10cSrcweir { // echter Style ?
6298cdf0e10cSrcweir if ( pStd )
6299cdf0e10cSrcweir {
6300cdf0e10cSrcweir switch( rFib.nVersion )
6301cdf0e10cSrcweir {
6302cdf0e10cSrcweir case 6:
6303cdf0e10cSrcweir case 7:
6304cdf0e10cSrcweir // lies Pascal-String
6305cdf0e10cSrcweir *pString = WW8ReadPString( rSt, RTL_TEXTENCODING_MS_1252 );
6306cdf0e10cSrcweir // leading len and trailing zero --> 2
6307cdf0e10cSrcweir rSkip -= 2+ pString->Len();
6308cdf0e10cSrcweir break;
6309cdf0e10cSrcweir case 8:
6310cdf0e10cSrcweir // handle Unicode-String with leading length short and
6311cdf0e10cSrcweir // trailing zero
6312cdf0e10cSrcweir if (ww8String::TestBeltAndBraces(rSt))
6313cdf0e10cSrcweir {
6314cdf0e10cSrcweir *pString = WW8Read_xstz(rSt, 0, true);
6315cdf0e10cSrcweir rSkip -= (pString->Len() + 2) * 2;
6316cdf0e10cSrcweir }
6317cdf0e10cSrcweir else
6318cdf0e10cSrcweir {
6319cdf0e10cSrcweir /*
6320cdf0e10cSrcweir #i8114#
6321cdf0e10cSrcweir This is supposed to be impossible, its just supposed
6322cdf0e10cSrcweir to be 16 bit count followed by the string and ending
6323cdf0e10cSrcweir in a 0 short. But "Lotus SmartSuite Product: Word Pro"
6324cdf0e10cSrcweir is creating invalid style names in ww7- format. So we
6325cdf0e10cSrcweir use the belt and braces of the ms strings to see if
6326cdf0e10cSrcweir they are not corrupt. If they are then we try them as
6327cdf0e10cSrcweir 8bit ones
6328cdf0e10cSrcweir */
6329cdf0e10cSrcweir *pString = WW8ReadPString(rSt,RTL_TEXTENCODING_MS_1252);
6330cdf0e10cSrcweir // leading len and trailing zero --> 2
6331cdf0e10cSrcweir rSkip -= 2+ pString->Len();
6332cdf0e10cSrcweir }
6333cdf0e10cSrcweir break;
6334cdf0e10cSrcweir default:
6335cdf0e10cSrcweir ASSERT(!this, "Es wurde vergessen, nVersion zu kodieren!");
6336cdf0e10cSrcweir break;
6337cdf0e10cSrcweir }
6338cdf0e10cSrcweir }
6339cdf0e10cSrcweir else
6340cdf0e10cSrcweir *pString = aEmptyStr; // Kann keinen Namen liefern
6341cdf0e10cSrcweir }
6342cdf0e10cSrcweir return pStd;
6343cdf0e10cSrcweir }
6344cdf0e10cSrcweir
6345cdf0e10cSrcweir
6346cdf0e10cSrcweir //-----------------------------------------
6347cdf0e10cSrcweir
6348cdf0e10cSrcweir
6349cdf0e10cSrcweir struct WW8_FFN_Ver6 : public WW8_FFN_BASE
6350cdf0e10cSrcweir {
6351cdf0e10cSrcweir // ab Ver6
6352cdf0e10cSrcweir sal_Char szFfn[65]; // 0x6 bzw. 0x40 ab Ver8 zero terminated string that
6353cdf0e10cSrcweir // records name of font.
6354cdf0e10cSrcweir // Maximal size of szFfn is 65 characters.
6355cdf0e10cSrcweir // Vorsicht: Dieses Array kann auch kleiner sein!!!
6356cdf0e10cSrcweir // Possibly followed by a second sz which records the
6357cdf0e10cSrcweir // name of an alternate font to use if the first named
6358cdf0e10cSrcweir // font does not exist on this system.
6359cdf0e10cSrcweir };
6360cdf0e10cSrcweir struct WW8_FFN_Ver8 : public WW8_FFN_BASE
6361cdf0e10cSrcweir {
6362cdf0e10cSrcweir // ab Ver8 sind folgende beiden Felder eingeschoben,
6363cdf0e10cSrcweir // werden von uns ignoriert.
6364cdf0e10cSrcweir sal_Char panose[ 10 ]; // 0x6 PANOSE
6365cdf0e10cSrcweir sal_Char fs[ 24 ]; // 0x10 FONTSIGNATURE
6366cdf0e10cSrcweir
6367cdf0e10cSrcweir // ab Ver8 als Unicode
6368cdf0e10cSrcweir sal_uInt16 szFfn[65]; // 0x6 bzw. 0x40 ab Ver8 zero terminated string that
6369cdf0e10cSrcweir // records name of font.
6370cdf0e10cSrcweir // Maximal size of szFfn is 65 characters.
6371cdf0e10cSrcweir // Vorsicht: Dieses Array kann auch kleiner sein!!!
6372cdf0e10cSrcweir // Possibly followed by a second sz which records the
6373cdf0e10cSrcweir // name of an alternate font to use if the first named
6374cdf0e10cSrcweir // font does not exist on this system.
6375cdf0e10cSrcweir };
6376cdf0e10cSrcweir
6377cdf0e10cSrcweir // #i43762# check font name for illegal characters
lcl_checkFontname(String & sString)6378cdf0e10cSrcweir void lcl_checkFontname( String& sString )
6379cdf0e10cSrcweir {
6380cdf0e10cSrcweir // for efficiency, we'd like to use String methods as far as possible.
6381cdf0e10cSrcweir // Hence, we will:
6382cdf0e10cSrcweir // 1) convert all invalid chars to \u0001
6383cdf0e10cSrcweir // 2) then erase all \u0001 chars (if any were found), and
6384cdf0e10cSrcweir // 3) erase leading/trailing ';', in case a font name was
6385cdf0e10cSrcweir // completely removed
6386cdf0e10cSrcweir
6387cdf0e10cSrcweir // convert all invalid chars to \u0001
6388cdf0e10cSrcweir sal_Unicode* pBuffer = sString.GetBufferAccess();
6389cdf0e10cSrcweir xub_StrLen nLen = sString.Len();
6390cdf0e10cSrcweir bool bFound = false;
6391cdf0e10cSrcweir for( xub_StrLen n = 0; n < nLen; n++ )
6392cdf0e10cSrcweir {
6393cdf0e10cSrcweir if( pBuffer[n] < sal_Unicode( 0x20 ) )
6394cdf0e10cSrcweir {
6395cdf0e10cSrcweir pBuffer[n] = sal_Unicode( 1 );
6396cdf0e10cSrcweir bFound = true;
6397cdf0e10cSrcweir }
6398cdf0e10cSrcweir }
6399cdf0e10cSrcweir sString.ReleaseBufferAccess();
6400cdf0e10cSrcweir
6401cdf0e10cSrcweir // if anything was found, remove \u0001 + leading/trailing ';'
6402cdf0e10cSrcweir if( bFound )
6403cdf0e10cSrcweir {
6404cdf0e10cSrcweir sString.EraseAllChars( sal_Unicode( 1 ) );
6405cdf0e10cSrcweir sString.EraseLeadingAndTrailingChars( sal_Unicode( ';' ) );
6406cdf0e10cSrcweir }
6407cdf0e10cSrcweir }
6408cdf0e10cSrcweir
WW8Fonts(SvStream & rSt,WW8Fib & rFib)6409cdf0e10cSrcweir WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
6410cdf0e10cSrcweir : pFontA(0), nMax(0)
6411cdf0e10cSrcweir {
6412cdf0e10cSrcweir // Attention: MacWord-Documents have their Fontnames
6413cdf0e10cSrcweir // always in ANSI, even if eStructCharSet == CHARSET_MAC !!
6414cdf0e10cSrcweir if( rFib.lcbSttbfffn <= 2 )
6415cdf0e10cSrcweir {
6416cdf0e10cSrcweir ASSERT( !this, "Fonttabelle kaputt! (rFib.lcbSttbfffn < 2)" );
6417cdf0e10cSrcweir pFontA = 0;
6418cdf0e10cSrcweir nMax = 0;
6419cdf0e10cSrcweir return;
6420cdf0e10cSrcweir }
6421cdf0e10cSrcweir
6422cdf0e10cSrcweir rSt.Seek( rFib.fcSttbfffn );
6423cdf0e10cSrcweir
6424cdf0e10cSrcweir sal_Int32 nFFn = rFib.lcbSttbfffn - 2;
6425cdf0e10cSrcweir
6426cdf0e10cSrcweir // allocate Font Array
6427cdf0e10cSrcweir sal_uInt8* pA = new sal_uInt8[ nFFn ];
6428cdf0e10cSrcweir memset(pA, 0, nFFn);
6429cdf0e10cSrcweir WW8_FFN* p = (WW8_FFN*)pA;
6430cdf0e10cSrcweir
6431cdf0e10cSrcweir ww::WordVersion eVersion = rFib.GetFIBVersion();
6432cdf0e10cSrcweir
6433cdf0e10cSrcweir if( eVersion >= ww::eWW8 )
6434cdf0e10cSrcweir {
6435cdf0e10cSrcweir // bVer8: read the count of strings in nMax
6436cdf0e10cSrcweir rSt >> nMax;
6437cdf0e10cSrcweir }
6438cdf0e10cSrcweir
6439cdf0e10cSrcweir // Ver8: skip undefined uint16
6440cdf0e10cSrcweir // Ver67: skip the herein stored total byte of structure
6441cdf0e10cSrcweir // - we already got that information in rFib.lcbSttbfffn
6442cdf0e10cSrcweir rSt.SeekRel( 2 );
6443cdf0e10cSrcweir
6444cdf0e10cSrcweir // read all font information
6445cdf0e10cSrcweir nFFn = rSt.Read( pA, nFFn );
6446cdf0e10cSrcweir
6447cdf0e10cSrcweir if( eVersion < ww::eWW8 )
6448cdf0e10cSrcweir {
6449cdf0e10cSrcweir // try to figure out how many fonts are defined here
6450cdf0e10cSrcweir nMax = 0;
6451cdf0e10cSrcweir long nLeft = nFFn;
6452cdf0e10cSrcweir for(;;)
6453cdf0e10cSrcweir {
6454cdf0e10cSrcweir short nNextSiz;
6455cdf0e10cSrcweir
6456cdf0e10cSrcweir nNextSiz = p->cbFfnM1 + 1;
6457cdf0e10cSrcweir if( nNextSiz > nLeft )
6458cdf0e10cSrcweir break;
6459cdf0e10cSrcweir nMax++;
6460cdf0e10cSrcweir nLeft -= nNextSiz;
6461cdf0e10cSrcweir if( nLeft < 1 ) // can we read the given ammount of bytes ?
6462cdf0e10cSrcweir break;
6463cdf0e10cSrcweir // increase p by nNextSiz Bytes
6464cdf0e10cSrcweir p = (WW8_FFN *)( ( (sal_uInt8*)p ) + nNextSiz );
6465cdf0e10cSrcweir }
6466cdf0e10cSrcweir }
6467cdf0e10cSrcweir
6468cdf0e10cSrcweir if( nMax )
6469cdf0e10cSrcweir {
6470*5f190fc3SJim Jagielski // Check size consistency
6471*5f190fc3SJim Jagielski if(nMax > nFFn)
6472*5f190fc3SJim Jagielski {
6473*5f190fc3SJim Jagielski throw std::out_of_range("WW8 beyond end of buffer");
6474*5f190fc3SJim Jagielski }
6475*5f190fc3SJim Jagielski
6476cdf0e10cSrcweir // allocate Index Array
6477cdf0e10cSrcweir pFontA = new WW8_FFN[ nMax ];
6478cdf0e10cSrcweir p = pFontA;
6479cdf0e10cSrcweir
6480cdf0e10cSrcweir if( eVersion <= ww::eWW2 )
6481cdf0e10cSrcweir {
6482cdf0e10cSrcweir WW8_FFN_BASE* pVer2 = (WW8_FFN_BASE*)pA;
6483cdf0e10cSrcweir for(sal_uInt16 i=0; i<nMax; ++i, ++p)
6484cdf0e10cSrcweir {
6485cdf0e10cSrcweir p->cbFfnM1 = pVer2->cbFfnM1;
6486cdf0e10cSrcweir
6487cdf0e10cSrcweir p->prg = 0;
6488cdf0e10cSrcweir p->fTrueType = 0;
6489cdf0e10cSrcweir p->ff = 0;
6490cdf0e10cSrcweir
6491cdf0e10cSrcweir p->wWeight = ( *(((sal_uInt8*)pVer2) + 1) );
6492cdf0e10cSrcweir p->chs = ( *(((sal_uInt8*)pVer2) + 2) );
6493cdf0e10cSrcweir /*
6494cdf0e10cSrcweir #i8726# 7- seems to encode the name in the same encoding as
6495cdf0e10cSrcweir the font, e.g load the doc in 97 and save to see the unicode
6496cdf0e10cSrcweir ver of the asian fontnames in that example to confirm.
6497cdf0e10cSrcweir */
6498cdf0e10cSrcweir rtl_TextEncoding eEnc = WW8Fib::GetFIBCharset(p->chs);
6499cdf0e10cSrcweir if ((eEnc == RTL_TEXTENCODING_SYMBOL) || (eEnc == RTL_TEXTENCODING_DONTKNOW))
6500cdf0e10cSrcweir eEnc = RTL_TEXTENCODING_MS_1252;
6501cdf0e10cSrcweir
6502cdf0e10cSrcweir p->sFontname = String ( (((const sal_Char*)pVer2) + 1 + 2), eEnc);
6503cdf0e10cSrcweir pVer2 = (WW8_FFN_BASE*)( ((sal_uInt8*)pVer2) + pVer2->cbFfnM1 + 1 );
6504cdf0e10cSrcweir }
6505cdf0e10cSrcweir }
6506cdf0e10cSrcweir else if( eVersion < ww::eWW8 )
6507cdf0e10cSrcweir {
6508cdf0e10cSrcweir WW8_FFN_Ver6* pVer6 = (WW8_FFN_Ver6*)pA;
6509cdf0e10cSrcweir sal_uInt8 c2;
6510cdf0e10cSrcweir for(sal_uInt16 i=0; i<nMax; ++i, ++p)
6511cdf0e10cSrcweir {
6512cdf0e10cSrcweir p->cbFfnM1 = pVer6->cbFfnM1;
6513cdf0e10cSrcweir c2 = *(((sal_uInt8*)pVer6) + 1);
6514cdf0e10cSrcweir
6515cdf0e10cSrcweir p->prg = c2 & 0x02;
6516cdf0e10cSrcweir p->fTrueType = (c2 & 0x04) >> 2;
6517cdf0e10cSrcweir // ein Reserve-Bit ueberspringen
6518cdf0e10cSrcweir p->ff = (c2 & 0x70) >> 4;
6519cdf0e10cSrcweir
6520cdf0e10cSrcweir p->wWeight = SVBT16ToShort( *(SVBT16*)&pVer6->wWeight );
6521cdf0e10cSrcweir p->chs = pVer6->chs;
6522cdf0e10cSrcweir p->ibszAlt = pVer6->ibszAlt;
6523cdf0e10cSrcweir /*
6524cdf0e10cSrcweir #i8726# 7- seems to encode the name in the same encoding as
6525cdf0e10cSrcweir the font, e.g load the doc in 97 and save to see the unicode
6526cdf0e10cSrcweir ver of the asian fontnames in that example to confirm.
6527cdf0e10cSrcweir */
6528cdf0e10cSrcweir rtl_TextEncoding eEnc = WW8Fib::GetFIBCharset(p->chs);
6529cdf0e10cSrcweir if ((eEnc == RTL_TEXTENCODING_SYMBOL) || (eEnc == RTL_TEXTENCODING_DONTKNOW))
6530cdf0e10cSrcweir eEnc = RTL_TEXTENCODING_MS_1252;
6531cdf0e10cSrcweir p->sFontname = String(pVer6->szFfn, eEnc);
6532cdf0e10cSrcweir if (p->ibszAlt)
6533cdf0e10cSrcweir {
6534cdf0e10cSrcweir p->sFontname.Append(';');
6535cdf0e10cSrcweir p->sFontname += String(pVer6->szFfn+p->ibszAlt, eEnc);
6536cdf0e10cSrcweir }
6537cdf0e10cSrcweir else
6538cdf0e10cSrcweir {
6539cdf0e10cSrcweir //#i18369# if its a symbol font set Symbol as fallback
6540cdf0e10cSrcweir if (
6541cdf0e10cSrcweir RTL_TEXTENCODING_SYMBOL == WW8Fib::GetFIBCharset(p->chs)
6542cdf0e10cSrcweir && !p->sFontname.EqualsAscii("Symbol")
6543cdf0e10cSrcweir )
6544cdf0e10cSrcweir {
6545cdf0e10cSrcweir p->sFontname.APPEND_CONST_ASC(";Symbol");
6546cdf0e10cSrcweir }
6547cdf0e10cSrcweir }
6548cdf0e10cSrcweir pVer6 = (WW8_FFN_Ver6*)( ((sal_uInt8*)pVer6) + pVer6->cbFfnM1 + 1 );
6549cdf0e10cSrcweir }
6550cdf0e10cSrcweir }
6551cdf0e10cSrcweir else
6552cdf0e10cSrcweir {
6553cdf0e10cSrcweir WW8_FFN_Ver8* pVer8 = (WW8_FFN_Ver8*)pA;
6554cdf0e10cSrcweir sal_uInt8 c2;
6555cdf0e10cSrcweir for(sal_uInt16 i=0; i<nMax; ++i, ++p)
6556cdf0e10cSrcweir {
6557cdf0e10cSrcweir p->cbFfnM1 = pVer8->cbFfnM1;
6558cdf0e10cSrcweir c2 = *(((sal_uInt8*)pVer8) + 1);
6559cdf0e10cSrcweir
6560cdf0e10cSrcweir p->prg = c2 & 0x02;
6561cdf0e10cSrcweir p->fTrueType = (c2 & 0x04) >> 2;
6562cdf0e10cSrcweir // ein Reserve-Bit ueberspringen
6563cdf0e10cSrcweir p->ff = (c2 & 0x70) >> 4;
6564cdf0e10cSrcweir
6565cdf0e10cSrcweir p->wWeight = SVBT16ToShort( *(SVBT16*)&pVer8->wWeight );
6566cdf0e10cSrcweir p->chs = pVer8->chs;
6567cdf0e10cSrcweir p->ibszAlt = pVer8->ibszAlt;
6568cdf0e10cSrcweir
6569cdf0e10cSrcweir #ifdef __WW8_NEEDS_COPY
6570cdf0e10cSrcweir {
6571cdf0e10cSrcweir sal_uInt8 nLen = 0x28;
6572cdf0e10cSrcweir sal_uInt8 nLength = sizeof( pVer8->szFfn ) / sizeof( SVBT16 );
6573cdf0e10cSrcweir nLength = std::min( nLength, sal_uInt8( pVer8->cbFfnM1+1 ) );
6574cdf0e10cSrcweir for( sal_uInt16* pTmp = pVer8->szFfn;
6575cdf0e10cSrcweir nLen < nLength; ++pTmp, nLen+=2 )
6576cdf0e10cSrcweir {
6577cdf0e10cSrcweir *pTmp = SVBT16ToShort( *(SVBT16*)pTmp );
6578cdf0e10cSrcweir }
6579cdf0e10cSrcweir }
6580cdf0e10cSrcweir #endif // defined __WW8_NEEDS_COPY
6581cdf0e10cSrcweir
6582cdf0e10cSrcweir p->sFontname = pVer8->szFfn;
6583cdf0e10cSrcweir if (p->ibszAlt)
6584cdf0e10cSrcweir {
6585cdf0e10cSrcweir p->sFontname.Append(';');
6586cdf0e10cSrcweir p->sFontname.Append(pVer8->szFfn+p->ibszAlt);
6587cdf0e10cSrcweir }
6588cdf0e10cSrcweir
6589cdf0e10cSrcweir // #i43762# check font name for illegal characters
6590cdf0e10cSrcweir lcl_checkFontname( p->sFontname );
6591cdf0e10cSrcweir
6592cdf0e10cSrcweir // Zeiger auf Ursprungsarray einen Font nach hinten setzen
6593cdf0e10cSrcweir pVer8 = (WW8_FFN_Ver8*)( ((sal_uInt8*)pVer8) + pVer8->cbFfnM1 + 1 );
6594ef23fd8cSJim Jagielski
6595cdf0e10cSrcweir }
6596cdf0e10cSrcweir }
6597cdf0e10cSrcweir }
6598cdf0e10cSrcweir delete[] pA;
6599cdf0e10cSrcweir }
6600cdf0e10cSrcweir
GetFont(sal_uInt16 nNum) const6601cdf0e10cSrcweir const WW8_FFN* WW8Fonts::GetFont( sal_uInt16 nNum ) const
6602cdf0e10cSrcweir {
6603cdf0e10cSrcweir if( !pFontA || nNum >= nMax )
6604cdf0e10cSrcweir return 0;
6605cdf0e10cSrcweir
6606cdf0e10cSrcweir return &pFontA[ nNum ];
6607cdf0e10cSrcweir }
6608cdf0e10cSrcweir
6609cdf0e10cSrcweir
6610cdf0e10cSrcweir
6611cdf0e10cSrcweir //-----------------------------------------
6612cdf0e10cSrcweir
6613cdf0e10cSrcweir
6614cdf0e10cSrcweir // Suche zu einem Header / Footer den Index in der WW-Liste von Headern / Footern
6615cdf0e10cSrcweir //
6616cdf0e10cSrcweir // Pferdefuesse bei WinWord6 und -7:
6617cdf0e10cSrcweir // 1) Am Anfang des Einlesens muss WWPLCF_HdFt mit Fib und Dop konstruiert werden
6618cdf0e10cSrcweir // 2) Der Haupttext muss sequentiell ueber alle Sections gelesen werden
6619cdf0e10cSrcweir // 3) Fuer jedes vorkommende Header / Footer - Attribut des Haupttextes
6620cdf0e10cSrcweir // ( Darf pro Section maximal eins sein ) muss UpdateIndex() genau einmal
6621cdf0e10cSrcweir // mit dem Parameter des Attributes gerufen werden. Dieser Aufruf muss *nach*
6622cdf0e10cSrcweir // dem letzten Aufruf von GetTextPos() passieren.
6623cdf0e10cSrcweir // 4) GetTextPos() darf mit genau einem der obenstehen WW_... aufgerufen werden
6624cdf0e10cSrcweir // ( nicht verodern ! )
6625cdf0e10cSrcweir // -> dann liefert GetTextPos() vielleicht auch ein richtiges Ergebnis
6626cdf0e10cSrcweir
WW8PLCF_HdFt(SvStream * pSt,WW8Fib & rFib,WW8Dop & rDop)6627cdf0e10cSrcweir WW8PLCF_HdFt::WW8PLCF_HdFt( SvStream* pSt, WW8Fib& rFib, WW8Dop& rDop )
6628cdf0e10cSrcweir : aPLCF( pSt, rFib.fcPlcfhdd , rFib.lcbPlcfhdd , 0 )
6629cdf0e10cSrcweir {
6630cdf0e10cSrcweir nIdxOffset = 0;
6631cdf0e10cSrcweir
6632cdf0e10cSrcweir /*
6633cdf0e10cSrcweir cmc 23/02/2000: This dop.grpfIhdt has a bit set for each special
6634cdf0e10cSrcweir footnote *and endnote!!* seperator,continuation seperator, and
6635cdf0e10cSrcweir continuation notice entry, the documentation does not mention the
6636cdf0e10cSrcweir endnote seperators, the documentation also gets the index numbers
6637cdf0e10cSrcweir backwards when specifiying which bits to test. The bottom six bits
6638cdf0e10cSrcweir of this value must be tested and skipped over. Each section's
6639cdf0e10cSrcweir grpfIhdt is then tested for the existence of the appropiate headers
6640cdf0e10cSrcweir and footers, at the end of each section the nIdxOffset must be updated
6641cdf0e10cSrcweir to point to the beginning of the next section's group of headers and
6642cdf0e10cSrcweir footers in this PLCF, UpdateIndex does that task.
6643cdf0e10cSrcweir */
6644cdf0e10cSrcweir for( sal_uInt8 nI = 0x1; nI <= 0x20; nI <<= 1 )
6645cdf0e10cSrcweir if( nI & rDop.grpfIhdt ) // Bit gesetzt ?
6646cdf0e10cSrcweir nIdxOffset++;
6647cdf0e10cSrcweir
6648cdf0e10cSrcweir nTextOfs = rFib.ccpText + rFib.ccpFtn; // Groesse des Haupttextes
6649cdf0e10cSrcweir // und der Fussnoten
6650cdf0e10cSrcweir }
6651cdf0e10cSrcweir
GetTextPos(sal_uInt8 grpfIhdt,sal_uInt8 nWhich,WW8_CP & rStart,long & rLen)6652cdf0e10cSrcweir bool WW8PLCF_HdFt::GetTextPos(sal_uInt8 grpfIhdt, sal_uInt8 nWhich, WW8_CP& rStart,
6653cdf0e10cSrcweir long& rLen)
6654cdf0e10cSrcweir {
6655cdf0e10cSrcweir sal_uInt8 nI = 0x01;
6656cdf0e10cSrcweir short nIdx = nIdxOffset;
6657cdf0e10cSrcweir while (true)
6658cdf0e10cSrcweir {
6659cdf0e10cSrcweir if( nI & nWhich )
6660cdf0e10cSrcweir break; // found
6661cdf0e10cSrcweir if( grpfIhdt & nI )
6662cdf0e10cSrcweir nIdx++; // uninteresting Header / Footer
6663cdf0e10cSrcweir nI <<= 1; // text next bit
6664cdf0e10cSrcweir if( nI > 0x20 )
6665cdf0e10cSrcweir return false; // not found
6666cdf0e10cSrcweir }
6667cdf0e10cSrcweir // nIdx ist HdFt-Index
6668cdf0e10cSrcweir WW8_CP nEnd;
6669cdf0e10cSrcweir void* pData;
6670cdf0e10cSrcweir
6671cdf0e10cSrcweir aPLCF.SetIdx( nIdx ); // Lookup suitable CP
6672cdf0e10cSrcweir aPLCF.Get( rStart, nEnd, pData );
6673cdf0e10cSrcweir rLen = nEnd - rStart;
6674cdf0e10cSrcweir aPLCF++;
6675cdf0e10cSrcweir
6676cdf0e10cSrcweir return true;
6677cdf0e10cSrcweir }
6678cdf0e10cSrcweir
GetTextPosExact(short nIdx,WW8_CP & rStart,long & rLen)6679cdf0e10cSrcweir bool WW8PLCF_HdFt::GetTextPosExact(short nIdx, WW8_CP& rStart, long& rLen)
6680cdf0e10cSrcweir {
6681cdf0e10cSrcweir WW8_CP nEnd;
6682cdf0e10cSrcweir void* pData;
6683cdf0e10cSrcweir
6684cdf0e10cSrcweir aPLCF.SetIdx( nIdx ); // Lookup suitable CP
6685cdf0e10cSrcweir aPLCF.Get( rStart, nEnd, pData );
6686cdf0e10cSrcweir rLen = nEnd - rStart;
6687cdf0e10cSrcweir return true;
6688cdf0e10cSrcweir }
6689cdf0e10cSrcweir
UpdateIndex(sal_uInt8 grpfIhdt)6690cdf0e10cSrcweir void WW8PLCF_HdFt::UpdateIndex( sal_uInt8 grpfIhdt )
6691cdf0e10cSrcweir {
6692cdf0e10cSrcweir // Caution: Description is not correct
6693cdf0e10cSrcweir for( sal_uInt8 nI = 0x01; nI <= 0x20; nI <<= 1 )
6694cdf0e10cSrcweir if( nI & grpfIhdt )
6695cdf0e10cSrcweir nIdxOffset++;
6696cdf0e10cSrcweir }
6697cdf0e10cSrcweir
6698cdf0e10cSrcweir //-----------------------------------------
6699cdf0e10cSrcweir // WW8Dop
6700cdf0e10cSrcweir //-----------------------------------------
6701cdf0e10cSrcweir
WW8Dop(SvStream & rSt,sal_Int16 nFib,sal_Int32 nPos,sal_uInt32 nSize)6702cdf0e10cSrcweir WW8Dop::WW8Dop(SvStream& rSt, sal_Int16 nFib, sal_Int32 nPos, sal_uInt32 nSize) : bUseThaiLineBreakingRules(false)
6703cdf0e10cSrcweir {
6704cdf0e10cSrcweir memset( &nDataStart, 0, (&nDataEnd - &nDataStart) );
6705cdf0e10cSrcweir fDontUseHTMLAutoSpacing = true; //default
6706cdf0e10cSrcweir fAcetateShowAtn = true; //default
6707cdf0e10cSrcweir const sal_uInt32 nMaxDopSize = 0x268;
6708cdf0e10cSrcweir sal_uInt8* pDataPtr = new sal_uInt8[ nMaxDopSize ];
6709cdf0e10cSrcweir sal_uInt8* pData = pDataPtr;
6710cdf0e10cSrcweir
6711cdf0e10cSrcweir sal_uInt32 nRead = nMaxDopSize < nSize ? nMaxDopSize : nSize;
6712cdf0e10cSrcweir rSt.Seek( nPos );
6713cdf0e10cSrcweir if (2 > nSize || nRead != rSt.Read(pData, nRead))
6714cdf0e10cSrcweir nDopError = ERR_SWG_READ_ERROR; // Error melden
6715cdf0e10cSrcweir else
6716cdf0e10cSrcweir {
6717cdf0e10cSrcweir if (nMaxDopSize > nRead)
6718cdf0e10cSrcweir memset( pData + nRead, 0, nMaxDopSize - nRead );
6719cdf0e10cSrcweir
6720cdf0e10cSrcweir // dann mal die Daten auswerten
6721cdf0e10cSrcweir sal_uInt32 a32Bit;
6722cdf0e10cSrcweir sal_uInt16 a16Bit;
6723cdf0e10cSrcweir sal_uInt8 a8Bit;
6724cdf0e10cSrcweir
6725cdf0e10cSrcweir a16Bit = Get_UShort( pData ); // 0 0x00
6726cdf0e10cSrcweir fFacingPages = 0 != ( a16Bit & 0x0001 ) ;
6727cdf0e10cSrcweir fWidowControl = 0 != ( a16Bit & 0x0002 ) ;
6728cdf0e10cSrcweir fPMHMainDoc = 0 != ( a16Bit & 0x0004 ) ;
6729cdf0e10cSrcweir grfSuppression = ( a16Bit & 0x0018 ) >> 3;
6730cdf0e10cSrcweir fpc = ( a16Bit & 0x0060 ) >> 5;
6731cdf0e10cSrcweir grpfIhdt = ( a16Bit & 0xff00 ) >> 8;
6732cdf0e10cSrcweir
6733cdf0e10cSrcweir a16Bit = Get_UShort( pData ); // 2 0x02
6734cdf0e10cSrcweir rncFtn = a16Bit & 0x0003 ;
6735cdf0e10cSrcweir nFtn = ( a16Bit & ~0x0003 ) >> 2 ;
6736cdf0e10cSrcweir
6737cdf0e10cSrcweir a8Bit = Get_Byte( pData ); // 4 0x04
6738cdf0e10cSrcweir fOutlineDirtySave = 0 != ( a8Bit & 0x01 );
6739cdf0e10cSrcweir
6740cdf0e10cSrcweir a8Bit = Get_Byte( pData ); // 5 0x05
6741cdf0e10cSrcweir fOnlyMacPics = 0 != ( a8Bit & 0x01 );
6742cdf0e10cSrcweir fOnlyWinPics = 0 != ( a8Bit & 0x02 );
6743cdf0e10cSrcweir fLabelDoc = 0 != ( a8Bit & 0x04 );
6744cdf0e10cSrcweir fHyphCapitals = 0 != ( a8Bit & 0x08 );
6745cdf0e10cSrcweir fAutoHyphen = 0 != ( a8Bit & 0x10 );
6746cdf0e10cSrcweir fFormNoFields = 0 != ( a8Bit & 0x20 );
6747cdf0e10cSrcweir fLinkStyles = 0 != ( a8Bit & 0x40 );
6748cdf0e10cSrcweir fRevMarking = 0 != ( a8Bit & 0x80 );
6749cdf0e10cSrcweir
6750cdf0e10cSrcweir a8Bit = Get_Byte( pData ); // 6 0x06
6751cdf0e10cSrcweir fBackup = 0 != ( a8Bit & 0x01 );
6752cdf0e10cSrcweir fExactCWords = 0 != ( a8Bit & 0x02 );
6753cdf0e10cSrcweir fPagHidden = 0 != ( a8Bit & 0x04 );
6754cdf0e10cSrcweir fPagResults = 0 != ( a8Bit & 0x08 );
6755cdf0e10cSrcweir fLockAtn = 0 != ( a8Bit & 0x10 );
6756cdf0e10cSrcweir fMirrorMargins = 0 != ( a8Bit & 0x20 );
6757cdf0e10cSrcweir fReadOnlyRecommended = 0 != ( a8Bit & 0x40 );
6758cdf0e10cSrcweir fDfltTrueType = 0 != ( a8Bit & 0x80 );
6759cdf0e10cSrcweir
6760cdf0e10cSrcweir a8Bit = Get_Byte( pData ); // 7 0x07
6761cdf0e10cSrcweir fPagSuppressTopSpacing = 0 != ( a8Bit & 0x01 );
6762cdf0e10cSrcweir fProtEnabled = 0 != ( a8Bit & 0x02 );
6763cdf0e10cSrcweir fDispFormFldSel = 0 != ( a8Bit & 0x04 );
6764cdf0e10cSrcweir fRMView = 0 != ( a8Bit & 0x08 );
6765cdf0e10cSrcweir fRMPrint = 0 != ( a8Bit & 0x10 );
6766cdf0e10cSrcweir fWriteReservation = 0 != ( a8Bit & 0x20 );
6767cdf0e10cSrcweir fLockRev = 0 != ( a8Bit & 0x40 );
6768cdf0e10cSrcweir fEmbedFonts = 0 != ( a8Bit & 0x80 );
6769cdf0e10cSrcweir
6770cdf0e10cSrcweir
6771cdf0e10cSrcweir a8Bit = Get_Byte( pData ); // 8 0x08
6772cdf0e10cSrcweir copts_fNoTabForInd = 0 != ( a8Bit & 0x01 );
6773cdf0e10cSrcweir copts_fNoSpaceRaiseLower = 0 != ( a8Bit & 0x02 );
6774cdf0e10cSrcweir copts_fSupressSpbfAfterPgBrk = 0 != ( a8Bit & 0x04 );
6775cdf0e10cSrcweir copts_fWrapTrailSpaces = 0 != ( a8Bit & 0x08 );
6776cdf0e10cSrcweir copts_fMapPrintTextColor = 0 != ( a8Bit & 0x10 );
6777cdf0e10cSrcweir copts_fNoColumnBalance = 0 != ( a8Bit & 0x20 );
6778cdf0e10cSrcweir copts_fConvMailMergeEsc = 0 != ( a8Bit & 0x40 );
6779cdf0e10cSrcweir copts_fSupressTopSpacing = 0 != ( a8Bit & 0x80 );
6780cdf0e10cSrcweir
6781cdf0e10cSrcweir a8Bit = Get_Byte( pData ); // 9 0x09
6782cdf0e10cSrcweir copts_fOrigWordTableRules = 0 != ( a8Bit & 0x01 );
6783cdf0e10cSrcweir copts_fTransparentMetafiles = 0 != ( a8Bit & 0x02 );
6784cdf0e10cSrcweir copts_fShowBreaksInFrames = 0 != ( a8Bit & 0x04 );
6785cdf0e10cSrcweir copts_fSwapBordersFacingPgs = 0 != ( a8Bit & 0x08 );
6786cdf0e10cSrcweir copts_fExpShRtn = 0 != ( a8Bit & 0x20 ); // #i56856#
6787cdf0e10cSrcweir
6788cdf0e10cSrcweir dxaTab = Get_Short( pData ); // 10 0x0a
6789cdf0e10cSrcweir wSpare = Get_UShort( pData ); // 12 0x0c
6790cdf0e10cSrcweir dxaHotZ = Get_UShort( pData ); // 14 0x0e
6791cdf0e10cSrcweir cConsecHypLim = Get_UShort( pData ); // 16 0x10
6792cdf0e10cSrcweir wSpare2 = Get_UShort( pData ); // 18 0x12
6793cdf0e10cSrcweir dttmCreated = Get_Long( pData ); // 20 0x14
6794cdf0e10cSrcweir dttmRevised = Get_Long( pData ); // 24 0x18
6795cdf0e10cSrcweir dttmLastPrint = Get_Long( pData ); // 28 0x1c
6796cdf0e10cSrcweir nRevision = Get_Short( pData ); // 32 0x20
6797cdf0e10cSrcweir tmEdited = Get_Long( pData ); // 34 0x22
6798cdf0e10cSrcweir cWords = Get_Long( pData ); // 38 0x26
6799cdf0e10cSrcweir cCh = Get_Long( pData ); // 42 0x2a
6800cdf0e10cSrcweir cPg = Get_Short( pData ); // 46 0x2e
6801cdf0e10cSrcweir cParas = Get_Long( pData ); // 48 0x30
6802cdf0e10cSrcweir
6803cdf0e10cSrcweir a16Bit = Get_UShort( pData ); // 52 0x34
6804cdf0e10cSrcweir rncEdn = a16Bit & 0x0003 ;
6805cdf0e10cSrcweir nEdn = ( a16Bit & ~0x0003 ) >> 2;
6806cdf0e10cSrcweir
6807cdf0e10cSrcweir a16Bit = Get_UShort( pData ); // 54 0x36
6808cdf0e10cSrcweir epc = a16Bit & 0x0003 ;
6809cdf0e10cSrcweir nfcFtnRef = ( a16Bit & 0x003c ) >> 2;
6810cdf0e10cSrcweir nfcEdnRef = ( a16Bit & 0x03c0 ) >> 6;
6811cdf0e10cSrcweir fPrintFormData = 0 != ( a16Bit & 0x0400 );
6812cdf0e10cSrcweir fSaveFormData = 0 != ( a16Bit & 0x0800 );
6813cdf0e10cSrcweir fShadeFormData = 0 != ( a16Bit & 0x1000 );
6814cdf0e10cSrcweir fWCFtnEdn = 0 != ( a16Bit & 0x8000 );
6815cdf0e10cSrcweir
6816cdf0e10cSrcweir cLines = Get_Long( pData ); // 56 0x38
6817cdf0e10cSrcweir cWordsFtnEnd = Get_Long( pData ); // 60 0x3c
6818cdf0e10cSrcweir cChFtnEdn = Get_Long( pData ); // 64 0x40
6819cdf0e10cSrcweir cPgFtnEdn = Get_Short( pData ); // 68 0x44
6820cdf0e10cSrcweir cParasFtnEdn = Get_Long( pData ); // 70 0x46
6821cdf0e10cSrcweir cLinesFtnEdn = Get_Long( pData ); // 74 0x4a
6822cdf0e10cSrcweir lKeyProtDoc = Get_Long( pData ); // 78 0x4e
6823cdf0e10cSrcweir
6824cdf0e10cSrcweir a16Bit = Get_UShort( pData ); // 82 0x52
6825cdf0e10cSrcweir wvkSaved = a16Bit & 0x0007 ;
6826cdf0e10cSrcweir wScaleSaved = ( a16Bit & 0x0ff8 ) >> 3 ;
6827cdf0e10cSrcweir zkSaved = ( a16Bit & 0x3000 ) >> 12;
6828cdf0e10cSrcweir fRotateFontW6 = ( a16Bit & 0x4000 ) >> 14;
6829cdf0e10cSrcweir iGutterPos = ( a16Bit & 0x8000 ) >> 15;
6830cdf0e10cSrcweir /*
6831cdf0e10cSrcweir bei nFib >= 103 gehts weiter:
6832cdf0e10cSrcweir */
6833cdf0e10cSrcweir if (nFib >= 103) // Word 6/32bit, 95, 97, 2000, 2002, 2003, 2007
6834cdf0e10cSrcweir {
6835cdf0e10cSrcweir a32Bit = Get_ULong( pData ); // 84 0x54
6836cdf0e10cSrcweir SetCompatabilityOptions(a32Bit);
6837cdf0e10cSrcweir }
6838cdf0e10cSrcweir
6839cdf0e10cSrcweir //#i22436#, for all WW7- documents
6840cdf0e10cSrcweir if (nFib <= 104) // Word 95
6841cdf0e10cSrcweir fUsePrinterMetrics = 1;
6842cdf0e10cSrcweir
6843cdf0e10cSrcweir /*
6844cdf0e10cSrcweir bei nFib > 105 gehts weiter:
6845cdf0e10cSrcweir */
6846cdf0e10cSrcweir if (nFib > 105) // Word 97, 2000, 2002, 2003, 2007
6847cdf0e10cSrcweir {
6848cdf0e10cSrcweir adt = Get_Short( pData ); // 88 0x58
6849cdf0e10cSrcweir
6850cdf0e10cSrcweir doptypography.ReadFromMem(pData); // 90 0x5a
6851cdf0e10cSrcweir
6852cdf0e10cSrcweir memcpy( &dogrid, pData, sizeof( WW8_DOGRID )); // 400 0x190
6853cdf0e10cSrcweir pData += sizeof( WW8_DOGRID );
6854cdf0e10cSrcweir
6855cdf0e10cSrcweir a16Bit = Get_UShort( pData ); // 410 0x19a
6856cdf0e10cSrcweir // die untersten 9 Bit sind uninteressant
6857cdf0e10cSrcweir fHtmlDoc = ( a16Bit & 0x0200 ) >> 9 ;
6858cdf0e10cSrcweir fSnapBorder = ( a16Bit & 0x0800 ) >> 11 ;
6859cdf0e10cSrcweir fIncludeHeader = ( a16Bit & 0x1000 ) >> 12 ;
6860cdf0e10cSrcweir fIncludeFooter = ( a16Bit & 0x2000 ) >> 13 ;
6861cdf0e10cSrcweir fForcePageSizePag = ( a16Bit & 0x4000 ) >> 14 ;
6862cdf0e10cSrcweir fMinFontSizePag = ( a16Bit & 0x8000 ) >> 15 ;
6863cdf0e10cSrcweir
6864cdf0e10cSrcweir a16Bit = Get_UShort( pData ); // 412 0x19c
6865cdf0e10cSrcweir fHaveVersions = 0 != ( a16Bit & 0x0001 );
6866cdf0e10cSrcweir fAutoVersion = 0 != ( a16Bit & 0x0002 );
6867cdf0e10cSrcweir
6868cdf0e10cSrcweir pData += 12; // 414 0x19e
6869cdf0e10cSrcweir
6870cdf0e10cSrcweir cChWS = Get_Long( pData ); // 426 0x1aa
6871cdf0e10cSrcweir cChWSFtnEdn = Get_Long( pData ); // 430 0x1ae
6872cdf0e10cSrcweir grfDocEvents = Get_Long( pData ); // 434 0x1b2
6873cdf0e10cSrcweir
6874cdf0e10cSrcweir pData += 4+30+8; // 438 0x1b6; 442 0x1ba; 472 0x1d8; 476 0x1dc
6875cdf0e10cSrcweir
6876cdf0e10cSrcweir cDBC = Get_Long( pData ); // 480 0x1e0
6877cdf0e10cSrcweir cDBCFtnEdn = Get_Long( pData ); // 484 0x1e4
6878cdf0e10cSrcweir
6879cdf0e10cSrcweir pData += 1 * sizeof( sal_Int32); // 488 0x1e8
6880cdf0e10cSrcweir
6881cdf0e10cSrcweir nfcFtnRef = Get_Short( pData ); // 492 0x1ec
6882cdf0e10cSrcweir nfcEdnRef = Get_Short( pData ); // 494 0x1ee
6883cdf0e10cSrcweir hpsZoonFontPag = Get_Short( pData ); // 496 0x1f0
6884cdf0e10cSrcweir dywDispPag = Get_Short( pData ); // 498 0x1f2
6885cdf0e10cSrcweir
6886cdf0e10cSrcweir if (nRead >= 516)
6887cdf0e10cSrcweir {
6888cdf0e10cSrcweir //500 -> 508, Appear to be repeated here in 2000+
6889cdf0e10cSrcweir pData += 8; // 500 0x1f4
6890cdf0e10cSrcweir a32Bit = Get_Long( pData ); // 508 0x1fc
6891cdf0e10cSrcweir SetCompatabilityOptions(a32Bit);
6892cdf0e10cSrcweir a32Bit = Get_Long( pData ); // 512 0x200
6893cdf0e10cSrcweir
6894cdf0e10cSrcweir // i#78591#
6895cdf0e10cSrcweir // fDontUseHTMLAutoSpacing = (a32Bit & 0x4) >> 2;
6896cdf0e10cSrcweir SetCompatabilityOptions2(a32Bit);
6897cdf0e10cSrcweir }
6898cdf0e10cSrcweir if (nRead >= 550)
6899cdf0e10cSrcweir {
6900cdf0e10cSrcweir pData += 32;
6901cdf0e10cSrcweir a16Bit = Get_UShort( pData );
6902cdf0e10cSrcweir fDoNotEmbedSystemFont = ( a16Bit & 0x0001 );
6903cdf0e10cSrcweir fWordCompat = ( a16Bit & 0x0002 ) >> 1;
6904cdf0e10cSrcweir fLiveRecover = ( a16Bit & 0x0004 ) >> 2;
6905cdf0e10cSrcweir fEmbedFactoids = ( a16Bit & 0x0008 ) >> 3;
6906cdf0e10cSrcweir fFactoidXML = ( a16Bit & 0x00010 ) >> 4;
6907cdf0e10cSrcweir fFactoidAllDone = ( a16Bit & 0x0020 ) >> 5;
6908cdf0e10cSrcweir fFolioPrint = ( a16Bit & 0x0040 ) >> 6;
6909cdf0e10cSrcweir fReverseFolio = ( a16Bit & 0x0080 ) >> 7;
6910cdf0e10cSrcweir iTextLineEnding = ( a16Bit & 0x0700 ) >> 8;
6911cdf0e10cSrcweir fHideFcc = ( a16Bit & 0x0800 ) >> 11;
6912cdf0e10cSrcweir fAcetateShowMarkup = ( a16Bit & 0x1000 ) >> 12;
6913cdf0e10cSrcweir fAcetateShowAtn = ( a16Bit & 0x2000 ) >> 13;
6914cdf0e10cSrcweir fAcetateShowInsDel = ( a16Bit & 0x4000 ) >> 14;
6915cdf0e10cSrcweir fAcetateShowProps = ( a16Bit & 0x8000 ) >> 15;
6916cdf0e10cSrcweir }
6917cdf0e10cSrcweir if (nRead >= 600)
6918cdf0e10cSrcweir {
6919cdf0e10cSrcweir pData += 48;
6920cdf0e10cSrcweir a16Bit = Get_Short(pData);
6921cdf0e10cSrcweir fUseBackGroundInAllmodes = (a16Bit & 0x0080) >> 7;
6922cdf0e10cSrcweir }
6923cdf0e10cSrcweir }
6924cdf0e10cSrcweir }
6925cdf0e10cSrcweir delete[] pDataPtr;
6926cdf0e10cSrcweir }
6927cdf0e10cSrcweir
WW8Dop()6928cdf0e10cSrcweir WW8Dop::WW8Dop() : bUseThaiLineBreakingRules(false)
6929cdf0e10cSrcweir {
6930cdf0e10cSrcweir // first set everything to a default of 0
6931cdf0e10cSrcweir memset( &nDataStart, 0, (&nDataEnd - &nDataStart) );
6932cdf0e10cSrcweir
6933cdf0e10cSrcweir fWidowControl = 1;
6934cdf0e10cSrcweir fpc = 1;
6935cdf0e10cSrcweir nFtn = 1;
6936cdf0e10cSrcweir fOutlineDirtySave = 1;
6937cdf0e10cSrcweir fHyphCapitals = 1;
6938cdf0e10cSrcweir fBackup = 1;
6939cdf0e10cSrcweir fPagHidden = 1;
6940cdf0e10cSrcweir fPagResults = 1;
6941cdf0e10cSrcweir fDfltTrueType = 1;
6942cdf0e10cSrcweir
6943cdf0e10cSrcweir /*
6944cdf0e10cSrcweir Writer acts like this all the time at the moment, ideally we need an
6945cdf0e10cSrcweir option for these two as well to import word docs that are not like
6946cdf0e10cSrcweir this by default
6947cdf0e10cSrcweir */
6948cdf0e10cSrcweir fNoLeading = 1;
6949cdf0e10cSrcweir fUsePrinterMetrics = 1;
6950cdf0e10cSrcweir
6951cdf0e10cSrcweir fRMView = 1;
6952cdf0e10cSrcweir fRMPrint = 1;
6953cdf0e10cSrcweir dxaTab = 0x2d0;
6954cdf0e10cSrcweir dxaHotZ = 0x168;
6955cdf0e10cSrcweir nRevision = 1;
6956cdf0e10cSrcweir nEdn = 1;
6957cdf0e10cSrcweir
6958cdf0e10cSrcweir epc = 3;
6959cdf0e10cSrcweir nfcEdnRef = 2;
6960cdf0e10cSrcweir fShadeFormData = 1;
6961cdf0e10cSrcweir
6962cdf0e10cSrcweir wvkSaved = 2;
6963cdf0e10cSrcweir wScaleSaved = 100;
6964cdf0e10cSrcweir zkSaved = 0;
6965cdf0e10cSrcweir
6966cdf0e10cSrcweir lvl = 9;
6967cdf0e10cSrcweir fIncludeHeader = 1;
6968cdf0e10cSrcweir fIncludeFooter = 1;
6969cdf0e10cSrcweir
6970cdf0e10cSrcweir cChWS = /**!!**/ 0;
6971cdf0e10cSrcweir cChWSFtnEdn = /**!!**/ 0;
6972cdf0e10cSrcweir
6973cdf0e10cSrcweir cDBC = /**!!**/ 0;
6974cdf0e10cSrcweir cDBCFtnEdn = /**!!**/ 0;
6975cdf0e10cSrcweir
6976cdf0e10cSrcweir fAcetateShowAtn = true;
6977cdf0e10cSrcweir }
6978cdf0e10cSrcweir
SetCompatabilityOptions(sal_uInt32 a32Bit)6979cdf0e10cSrcweir void WW8Dop::SetCompatabilityOptions(sal_uInt32 a32Bit)
6980cdf0e10cSrcweir {
6981cdf0e10cSrcweir fNoTabForInd = ( a32Bit & 0x00000001 ) ;
6982cdf0e10cSrcweir fNoSpaceRaiseLower = ( a32Bit & 0x00000002 ) >> 1 ;
6983cdf0e10cSrcweir fSupressSpbfAfterPageBreak = ( a32Bit & 0x00000004 ) >> 2 ;
6984cdf0e10cSrcweir fWrapTrailSpaces = ( a32Bit & 0x00000008 ) >> 3 ;
6985cdf0e10cSrcweir fMapPrintTextColor = ( a32Bit & 0x00000010 ) >> 4 ;
6986cdf0e10cSrcweir fNoColumnBalance = ( a32Bit & 0x00000020 ) >> 5 ;
6987cdf0e10cSrcweir fConvMailMergeEsc = ( a32Bit & 0x00000040 ) >> 6 ;
6988cdf0e10cSrcweir fSupressTopSpacing = ( a32Bit & 0x00000080 ) >> 7 ;
6989cdf0e10cSrcweir fOrigWordTableRules = ( a32Bit & 0x00000100 ) >> 8 ;
6990cdf0e10cSrcweir fTransparentMetafiles = ( a32Bit & 0x00000200 ) >> 9 ;
6991cdf0e10cSrcweir fShowBreaksInFrames = ( a32Bit & 0x00000400 ) >> 10 ;
6992cdf0e10cSrcweir fSwapBordersFacingPgs = ( a32Bit & 0x00000800 ) >> 11 ;
6993cdf0e10cSrcweir fCompatabilityOptions_Unknown1_13 = ( a32Bit & 0x00001000 ) >> 12 ;
6994cdf0e10cSrcweir fExpShRtn = ( a32Bit & 0x00002000 ) >> 13 ; // #i56856#
6995cdf0e10cSrcweir fCompatabilityOptions_Unknown1_15 = ( a32Bit & 0x00004000 ) >> 14 ;
6996cdf0e10cSrcweir fCompatabilityOptions_Unknown1_16 = ( a32Bit & 0x00008000 ) >> 15 ;
6997cdf0e10cSrcweir fSuppressTopSpacingMac5 = ( a32Bit & 0x00010000 ) >> 16 ;
6998cdf0e10cSrcweir fTruncDxaExpand = ( a32Bit & 0x00020000 ) >> 17 ;
6999cdf0e10cSrcweir fPrintBodyBeforeHdr = ( a32Bit & 0x00040000 ) >> 18 ;
7000cdf0e10cSrcweir fNoLeading = ( a32Bit & 0x00080000 ) >> 19 ;
7001cdf0e10cSrcweir fCompatabilityOptions_Unknown1_21 = ( a32Bit & 0x00100000 ) >> 20 ;
7002cdf0e10cSrcweir fMWSmallCaps = ( a32Bit & 0x00200000 ) >> 21 ;
7003cdf0e10cSrcweir fCompatabilityOptions_Unknown1_23 = ( a32Bit & 0x00400000 ) >> 22 ;
7004cdf0e10cSrcweir fCompatabilityOptions_Unknown1_24 = ( a32Bit & 0x00800800 ) >> 23 ;
7005cdf0e10cSrcweir fCompatabilityOptions_Unknown1_25 = ( a32Bit & 0x01000000 ) >> 24 ;
7006cdf0e10cSrcweir fCompatabilityOptions_Unknown1_26 = ( a32Bit & 0x02000000 ) >> 25 ;
7007cdf0e10cSrcweir fCompatabilityOptions_Unknown1_27 = ( a32Bit & 0x04000000 ) >> 26 ;
7008cdf0e10cSrcweir fCompatabilityOptions_Unknown1_28 = ( a32Bit & 0x08000000 ) >> 27 ;
7009cdf0e10cSrcweir fCompatabilityOptions_Unknown1_29 = ( a32Bit & 0x10000000 ) >> 28 ;
7010cdf0e10cSrcweir fCompatabilityOptions_Unknown1_30 = ( a32Bit & 0x20000000 ) >> 29 ;
7011cdf0e10cSrcweir fCompatabilityOptions_Unknown1_31 = ( a32Bit & 0x40000000 ) >> 30 ;
7012cdf0e10cSrcweir
7013cdf0e10cSrcweir fUsePrinterMetrics = ( a32Bit & 0x80000000 ) >> 31 ;
7014cdf0e10cSrcweir }
7015cdf0e10cSrcweir
GetCompatabilityOptions() const7016cdf0e10cSrcweir sal_uInt32 WW8Dop::GetCompatabilityOptions() const
7017cdf0e10cSrcweir {
7018cdf0e10cSrcweir sal_uInt32 a32Bit = 0;
7019cdf0e10cSrcweir if (fNoTabForInd) a32Bit |= 0x00000001;
7020cdf0e10cSrcweir if (fNoSpaceRaiseLower) a32Bit |= 0x00000002;
7021cdf0e10cSrcweir if (fSupressSpbfAfterPageBreak) a32Bit |= 0x00000004;
7022cdf0e10cSrcweir if (fWrapTrailSpaces) a32Bit |= 0x00000008;
7023cdf0e10cSrcweir if (fMapPrintTextColor) a32Bit |= 0x00000010;
7024cdf0e10cSrcweir if (fNoColumnBalance) a32Bit |= 0x00000020;
7025cdf0e10cSrcweir if (fConvMailMergeEsc) a32Bit |= 0x00000040;
7026cdf0e10cSrcweir if (fSupressTopSpacing) a32Bit |= 0x00000080;
7027cdf0e10cSrcweir if (fOrigWordTableRules) a32Bit |= 0x00000100;
7028cdf0e10cSrcweir if (fTransparentMetafiles) a32Bit |= 0x00000200;
7029cdf0e10cSrcweir if (fShowBreaksInFrames) a32Bit |= 0x00000400;
7030cdf0e10cSrcweir if (fSwapBordersFacingPgs) a32Bit |= 0x00000800;
7031cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_13) a32Bit |= 0x00001000;
7032cdf0e10cSrcweir if (fExpShRtn) a32Bit |= 0x00002000; // #i56856#
7033cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_15) a32Bit |= 0x00004000;
7034cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_16) a32Bit |= 0x00008000;
7035cdf0e10cSrcweir if (fSuppressTopSpacingMac5) a32Bit |= 0x00010000;
7036cdf0e10cSrcweir if (fTruncDxaExpand) a32Bit |= 0x00020000;
7037cdf0e10cSrcweir if (fPrintBodyBeforeHdr) a32Bit |= 0x00040000;
7038cdf0e10cSrcweir if (fNoLeading) a32Bit |= 0x00080000;
7039cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_21) a32Bit |= 0x00100000;
7040cdf0e10cSrcweir if (fMWSmallCaps) a32Bit |= 0x00200000;
7041cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_23) a32Bit |= 0x00400000;
7042cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_24) a32Bit |= 0x00800000;
7043cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_25) a32Bit |= 0x01000000;
7044cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_26) a32Bit |= 0x02000000;
7045cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_27) a32Bit |= 0x04000000;
7046cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_28) a32Bit |= 0x08000000;
7047cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_29) a32Bit |= 0x10000000;
7048cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_30) a32Bit |= 0x20000000;
7049cdf0e10cSrcweir if (fCompatabilityOptions_Unknown1_31) a32Bit |= 0x40000000;
7050cdf0e10cSrcweir if (fUsePrinterMetrics) a32Bit |= 0x80000000;
7051cdf0e10cSrcweir return a32Bit;
7052cdf0e10cSrcweir }
7053cdf0e10cSrcweir
7054cdf0e10cSrcweir // i#78591#
SetCompatabilityOptions2(sal_uInt32 a32Bit)7055cdf0e10cSrcweir void WW8Dop::SetCompatabilityOptions2(sal_uInt32 a32Bit)
7056cdf0e10cSrcweir {
7057cdf0e10cSrcweir fCompatabilityOptions_Unknown2_1 = ( a32Bit & 0x00000001 );
7058cdf0e10cSrcweir fCompatabilityOptions_Unknown2_2 = ( a32Bit & 0x00000002 ) >> 1 ;
7059cdf0e10cSrcweir fDontUseHTMLAutoSpacing = ( a32Bit & 0x00000004 ) >> 2 ;
7060cdf0e10cSrcweir fCompatabilityOptions_Unknown2_4 = ( a32Bit & 0x00000008 ) >> 3 ;
7061cdf0e10cSrcweir fCompatabilityOptions_Unknown2_5 = ( a32Bit & 0x00000010 ) >> 4 ;
7062cdf0e10cSrcweir fCompatabilityOptions_Unknown2_6 = ( a32Bit & 0x00000020 ) >> 5 ;
7063cdf0e10cSrcweir fCompatabilityOptions_Unknown2_7 = ( a32Bit & 0x00000040 ) >> 6 ;
7064cdf0e10cSrcweir fCompatabilityOptions_Unknown2_8 = ( a32Bit & 0x00000080 ) >> 7 ;
7065cdf0e10cSrcweir fCompatabilityOptions_Unknown2_9 = ( a32Bit & 0x00000100 ) >> 8 ;
7066cdf0e10cSrcweir fCompatabilityOptions_Unknown2_10 = ( a32Bit & 0x00000200 ) >> 9 ;
7067cdf0e10cSrcweir fCompatabilityOptions_Unknown2_11 = ( a32Bit & 0x00000400 ) >> 10 ;
7068cdf0e10cSrcweir fCompatabilityOptions_Unknown2_12 = ( a32Bit & 0x00000800 ) >> 11 ;
7069cdf0e10cSrcweir fCompatabilityOptions_Unknown2_13 = ( a32Bit & 0x00001000 ) >> 12 ;
7070cdf0e10cSrcweir fCompatabilityOptions_Unknown2_14 = ( a32Bit & 0x00002000 ) >> 13 ;
7071cdf0e10cSrcweir fCompatabilityOptions_Unknown2_15 = ( a32Bit & 0x00004000 ) >> 14 ;
7072cdf0e10cSrcweir fCompatabilityOptions_Unknown2_16 = ( a32Bit & 0x00008000 ) >> 15 ;
7073cdf0e10cSrcweir fCompatabilityOptions_Unknown2_17 = ( a32Bit & 0x00010000 ) >> 16 ;
7074cdf0e10cSrcweir fCompatabilityOptions_Unknown2_18 = ( a32Bit & 0x00020000 ) >> 17 ;
7075cdf0e10cSrcweir fCompatabilityOptions_Unknown2_19 = ( a32Bit & 0x00040000 ) >> 18 ;
7076cdf0e10cSrcweir fCompatabilityOptions_Unknown2_20 = ( a32Bit & 0x00080000 ) >> 19 ;
7077cdf0e10cSrcweir fCompatabilityOptions_Unknown2_21 = ( a32Bit & 0x00100000 ) >> 20 ;
7078cdf0e10cSrcweir fCompatabilityOptions_Unknown2_22 = ( a32Bit & 0x00200000 ) >> 21 ;
7079cdf0e10cSrcweir fCompatabilityOptions_Unknown2_23 = ( a32Bit & 0x00400000 ) >> 22 ;
7080cdf0e10cSrcweir fCompatabilityOptions_Unknown2_24 = ( a32Bit & 0x00800800 ) >> 23 ;
7081cdf0e10cSrcweir fCompatabilityOptions_Unknown2_25 = ( a32Bit & 0x01000800 ) >> 24 ;
7082cdf0e10cSrcweir fCompatabilityOptions_Unknown2_26 = ( a32Bit & 0x02000800 ) >> 25 ;
7083cdf0e10cSrcweir fCompatabilityOptions_Unknown2_27 = ( a32Bit & 0x04000800 ) >> 26 ;
7084cdf0e10cSrcweir fCompatabilityOptions_Unknown2_28 = ( a32Bit & 0x08000800 ) >> 27 ;
7085cdf0e10cSrcweir fCompatabilityOptions_Unknown2_29 = ( a32Bit & 0x10000800 ) >> 28 ;
7086cdf0e10cSrcweir fCompatabilityOptions_Unknown2_30 = ( a32Bit & 0x20000800 ) >> 29 ;
7087cdf0e10cSrcweir fCompatabilityOptions_Unknown2_31 = ( a32Bit & 0x40000800 ) >> 30 ;
7088cdf0e10cSrcweir fCompatabilityOptions_Unknown2_32 = ( a32Bit & 0x80000000 ) >> 31 ;
7089cdf0e10cSrcweir }
7090cdf0e10cSrcweir
GetCompatabilityOptions2() const7091cdf0e10cSrcweir sal_uInt32 WW8Dop::GetCompatabilityOptions2() const
7092cdf0e10cSrcweir {
7093cdf0e10cSrcweir sal_uInt32 a32Bit = 0;
7094cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_1) a32Bit |= 0x00000001;
7095cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_2) a32Bit |= 0x00000002;
7096cdf0e10cSrcweir if (fDontUseHTMLAutoSpacing) a32Bit |= 0x00000004;
7097cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_4) a32Bit |= 0x00000008;
7098cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_5) a32Bit |= 0x00000010;
7099cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_6) a32Bit |= 0x00000020;
7100cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_7) a32Bit |= 0x00000040;
7101cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_8) a32Bit |= 0x00000080;
7102cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_9) a32Bit |= 0x00000100;
7103cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_10) a32Bit |= 0x00000200;
7104cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_11) a32Bit |= 0x00000400;
7105cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_12) a32Bit |= 0x00000800;
7106cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_13) a32Bit |= 0x00001000;
7107cdf0e10cSrcweir //#i42909# set thai "line breaking rules" compatibility option
7108cdf0e10cSrcweir // pflin, wonder whether bUseThaiLineBreakingRules is correct
7109cdf0e10cSrcweir // when importing word document.
7110cdf0e10cSrcweir if (bUseThaiLineBreakingRules) a32Bit |= 0x00002000;
7111cdf0e10cSrcweir else if (fCompatabilityOptions_Unknown2_14) a32Bit |= 0x00002000;
7112cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_15) a32Bit |= 0x00004000;
7113cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_16) a32Bit |= 0x00008000;
7114cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_17) a32Bit |= 0x00010000;
7115cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_18) a32Bit |= 0x00020000;
7116cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_19) a32Bit |= 0x00040000;
7117cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_20) a32Bit |= 0x00080000;
7118cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_21) a32Bit |= 0x00100000;
7119cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_22) a32Bit |= 0x00200000;
7120cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_23) a32Bit |= 0x00400000;
7121cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_24) a32Bit |= 0x00800000;
7122cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_25) a32Bit |= 0x01000000;
7123cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_26) a32Bit |= 0x02000000;
7124cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_27) a32Bit |= 0x04000000;
7125cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_28) a32Bit |= 0x08000000;
7126cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_29) a32Bit |= 0x10000000;
7127cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_30) a32Bit |= 0x20000000;
7128cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_31) a32Bit |= 0x40000000;
7129cdf0e10cSrcweir if (fCompatabilityOptions_Unknown2_32) a32Bit |= 0x80000000;
7130cdf0e10cSrcweir return a32Bit;
7131cdf0e10cSrcweir }
7132cdf0e10cSrcweir
Write(SvStream & rStrm,WW8Fib & rFib) const7133cdf0e10cSrcweir bool WW8Dop::Write(SvStream& rStrm, WW8Fib& rFib) const
7134cdf0e10cSrcweir {
7135cdf0e10cSrcweir const int nMaxDopLen = 610;
7136cdf0e10cSrcweir sal_uInt32 nLen = 8 == rFib.nVersion ? nMaxDopLen : 84;
7137cdf0e10cSrcweir rFib.fcDop = rStrm.Tell();
7138cdf0e10cSrcweir rFib.lcbDop = nLen;
7139cdf0e10cSrcweir
7140cdf0e10cSrcweir sal_uInt8 aData[ nMaxDopLen ];
7141cdf0e10cSrcweir memset( aData, 0, nMaxDopLen );
7142cdf0e10cSrcweir sal_uInt8* pData = aData;
7143cdf0e10cSrcweir
7144cdf0e10cSrcweir // dann mal die Daten auswerten
7145cdf0e10cSrcweir sal_uInt16 a16Bit;
7146cdf0e10cSrcweir sal_uInt8 a8Bit;
7147cdf0e10cSrcweir
7148cdf0e10cSrcweir a16Bit = 0; // 0 0x00
7149cdf0e10cSrcweir if (fFacingPages)
7150cdf0e10cSrcweir a16Bit |= 0x0001;
7151cdf0e10cSrcweir if (fWidowControl)
7152cdf0e10cSrcweir a16Bit |= 0x0002;
7153cdf0e10cSrcweir if (fPMHMainDoc)
7154cdf0e10cSrcweir a16Bit |= 0x0004;
7155cdf0e10cSrcweir a16Bit |= ( 0x0018 & (grfSuppression << 3));
7156cdf0e10cSrcweir a16Bit |= ( 0x0060 & (fpc << 5));
7157cdf0e10cSrcweir a16Bit |= ( 0xff00 & (grpfIhdt << 8));
7158cdf0e10cSrcweir Set_UInt16( pData, a16Bit );
7159cdf0e10cSrcweir
7160cdf0e10cSrcweir a16Bit = 0; // 2 0x02
7161cdf0e10cSrcweir a16Bit |= ( 0x0003 & rncFtn );
7162cdf0e10cSrcweir a16Bit |= ( ~0x0003 & (nFtn << 2));
7163cdf0e10cSrcweir Set_UInt16( pData, a16Bit );
7164cdf0e10cSrcweir
7165cdf0e10cSrcweir a8Bit = 0; // 4 0x04
7166cdf0e10cSrcweir if( fOutlineDirtySave ) a8Bit |= 0x01;
7167cdf0e10cSrcweir Set_UInt8( pData, a8Bit );
7168cdf0e10cSrcweir
7169cdf0e10cSrcweir a8Bit = 0; // 5 0x05
7170cdf0e10cSrcweir if( fOnlyMacPics ) a8Bit |= 0x01;
7171cdf0e10cSrcweir if( fOnlyWinPics ) a8Bit |= 0x02;
7172cdf0e10cSrcweir if( fLabelDoc ) a8Bit |= 0x04;
7173cdf0e10cSrcweir if( fHyphCapitals ) a8Bit |= 0x08;
7174cdf0e10cSrcweir if( fAutoHyphen ) a8Bit |= 0x10;
7175cdf0e10cSrcweir if( fFormNoFields ) a8Bit |= 0x20;
7176cdf0e10cSrcweir if( fLinkStyles ) a8Bit |= 0x40;
7177cdf0e10cSrcweir if( fRevMarking ) a8Bit |= 0x80;
7178cdf0e10cSrcweir Set_UInt8( pData, a8Bit );
7179cdf0e10cSrcweir
7180cdf0e10cSrcweir a8Bit = 0; // 6 0x06
7181cdf0e10cSrcweir if( fBackup ) a8Bit |= 0x01;
7182cdf0e10cSrcweir if( fExactCWords ) a8Bit |= 0x02;
7183cdf0e10cSrcweir if( fPagHidden ) a8Bit |= 0x04;
7184cdf0e10cSrcweir if( fPagResults ) a8Bit |= 0x08;
7185cdf0e10cSrcweir if( fLockAtn ) a8Bit |= 0x10;
7186cdf0e10cSrcweir if( fMirrorMargins ) a8Bit |= 0x20;
7187cdf0e10cSrcweir if( fReadOnlyRecommended ) a8Bit |= 0x40;
7188cdf0e10cSrcweir if( fDfltTrueType ) a8Bit |= 0x80;
7189cdf0e10cSrcweir Set_UInt8( pData, a8Bit );
7190cdf0e10cSrcweir
7191cdf0e10cSrcweir a8Bit = 0; // 7 0x07
7192cdf0e10cSrcweir if( fPagSuppressTopSpacing ) a8Bit |= 0x01;
7193cdf0e10cSrcweir if( fProtEnabled ) a8Bit |= 0x02;
7194cdf0e10cSrcweir if( fDispFormFldSel ) a8Bit |= 0x04;
7195cdf0e10cSrcweir if( fRMView ) a8Bit |= 0x08;
7196cdf0e10cSrcweir if( fRMPrint ) a8Bit |= 0x10;
7197cdf0e10cSrcweir if( fWriteReservation ) a8Bit |= 0x20;
7198cdf0e10cSrcweir if( fLockRev ) a8Bit |= 0x40;
7199cdf0e10cSrcweir if( fEmbedFonts ) a8Bit |= 0x80;
7200cdf0e10cSrcweir Set_UInt8( pData, a8Bit );
7201cdf0e10cSrcweir
7202cdf0e10cSrcweir
7203cdf0e10cSrcweir a8Bit = 0; // 8 0x08
7204cdf0e10cSrcweir if( copts_fNoTabForInd ) a8Bit |= 0x01;
7205cdf0e10cSrcweir if( copts_fNoSpaceRaiseLower ) a8Bit |= 0x02;
7206cdf0e10cSrcweir if( copts_fSupressSpbfAfterPgBrk ) a8Bit |= 0x04;
7207cdf0e10cSrcweir if( copts_fWrapTrailSpaces ) a8Bit |= 0x08;
7208cdf0e10cSrcweir if( copts_fMapPrintTextColor ) a8Bit |= 0x10;
7209cdf0e10cSrcweir if( copts_fNoColumnBalance ) a8Bit |= 0x20;
7210cdf0e10cSrcweir if( copts_fConvMailMergeEsc ) a8Bit |= 0x40;
7211cdf0e10cSrcweir if( copts_fSupressTopSpacing ) a8Bit |= 0x80;
7212cdf0e10cSrcweir Set_UInt8( pData, a8Bit );
7213cdf0e10cSrcweir
7214cdf0e10cSrcweir a8Bit = 0; // 9 0x09
7215cdf0e10cSrcweir if( copts_fOrigWordTableRules ) a8Bit |= 0x01;
7216cdf0e10cSrcweir if( copts_fTransparentMetafiles ) a8Bit |= 0x02;
7217cdf0e10cSrcweir if( copts_fShowBreaksInFrames ) a8Bit |= 0x04;
7218cdf0e10cSrcweir if( copts_fSwapBordersFacingPgs ) a8Bit |= 0x08;
7219cdf0e10cSrcweir if( copts_fExpShRtn ) a8Bit |= 0x20; // #i56856#
7220cdf0e10cSrcweir Set_UInt8( pData, a8Bit );
7221cdf0e10cSrcweir
7222cdf0e10cSrcweir Set_UInt16( pData, dxaTab ); // 10 0x0a
7223cdf0e10cSrcweir Set_UInt16( pData, wSpare ); // 12 0x0c
7224cdf0e10cSrcweir Set_UInt16( pData, dxaHotZ ); // 14 0x0e
7225cdf0e10cSrcweir Set_UInt16( pData, cConsecHypLim ); // 16 0x10
7226cdf0e10cSrcweir Set_UInt16( pData, wSpare2 ); // 18 0x12
7227cdf0e10cSrcweir Set_UInt32( pData, dttmCreated ); // 20 0x14
7228cdf0e10cSrcweir Set_UInt32( pData, dttmRevised ); // 24 0x18
7229cdf0e10cSrcweir Set_UInt32( pData, dttmLastPrint ); // 28 0x1c
7230cdf0e10cSrcweir Set_UInt16( pData, nRevision ); // 32 0x20
7231cdf0e10cSrcweir Set_UInt32( pData, tmEdited ); // 34 0x22
7232cdf0e10cSrcweir Set_UInt32( pData, cWords ); // 38 0x26
7233cdf0e10cSrcweir Set_UInt32( pData, cCh ); // 42 0x2a
7234cdf0e10cSrcweir Set_UInt16( pData, cPg ); // 46 0x2e
7235cdf0e10cSrcweir Set_UInt32( pData, cParas ); // 48 0x30
7236cdf0e10cSrcweir
7237cdf0e10cSrcweir a16Bit = 0; // 52 0x34
7238cdf0e10cSrcweir a16Bit |= ( 0x0003 & rncEdn );
7239cdf0e10cSrcweir a16Bit |= (~0x0003 & ( nEdn << 2));
7240cdf0e10cSrcweir Set_UInt16( pData, a16Bit );
7241cdf0e10cSrcweir
7242cdf0e10cSrcweir a16Bit = 0; // 54 0x36
7243cdf0e10cSrcweir a16Bit |= (0x0003 & epc );
7244cdf0e10cSrcweir a16Bit |= (0x003c & (nfcFtnRef << 2));
7245cdf0e10cSrcweir a16Bit |= (0x03c0 & (nfcEdnRef << 6));
7246cdf0e10cSrcweir if( fPrintFormData ) a16Bit |= 0x0400;
7247cdf0e10cSrcweir if( fSaveFormData ) a16Bit |= 0x0800;
7248cdf0e10cSrcweir if( fShadeFormData ) a16Bit |= 0x1000;
7249cdf0e10cSrcweir if( fWCFtnEdn ) a16Bit |= 0x8000;
7250cdf0e10cSrcweir Set_UInt16( pData, a16Bit );
7251cdf0e10cSrcweir
7252cdf0e10cSrcweir Set_UInt32( pData, cLines ); // 56 0x38
7253cdf0e10cSrcweir Set_UInt32( pData, cWordsFtnEnd ); // 60 0x3c
7254cdf0e10cSrcweir Set_UInt32( pData, cChFtnEdn ); // 64 0x40
7255cdf0e10cSrcweir Set_UInt16( pData, cPgFtnEdn ); // 68 0x44
7256cdf0e10cSrcweir Set_UInt32( pData, cParasFtnEdn ); // 70 0x46
7257cdf0e10cSrcweir Set_UInt32( pData, cLinesFtnEdn ); // 74 0x4a
7258cdf0e10cSrcweir Set_UInt32( pData, lKeyProtDoc ); // 78 0x4e
7259cdf0e10cSrcweir
7260cdf0e10cSrcweir a16Bit = 0; // 82 0x52
7261cdf0e10cSrcweir if (wvkSaved)
7262cdf0e10cSrcweir a16Bit |= 0x0007;
7263cdf0e10cSrcweir a16Bit |= (0x0ff8 & (wScaleSaved << 3));
7264cdf0e10cSrcweir a16Bit |= (0x3000 & (zkSaved << 12));
7265cdf0e10cSrcweir Set_UInt16( pData, a16Bit );
7266cdf0e10cSrcweir
7267cdf0e10cSrcweir if( 8 == rFib.nVersion )
7268cdf0e10cSrcweir {
7269cdf0e10cSrcweir Set_UInt32(pData, GetCompatabilityOptions()); // 84 0x54
7270cdf0e10cSrcweir
7271cdf0e10cSrcweir Set_UInt16( pData, adt ); // 88 0x58
7272cdf0e10cSrcweir
7273cdf0e10cSrcweir doptypography.WriteToMem(pData); // 400 0x190
7274cdf0e10cSrcweir
7275cdf0e10cSrcweir memcpy( pData, &dogrid, sizeof( WW8_DOGRID ));
7276cdf0e10cSrcweir pData += sizeof( WW8_DOGRID );
7277cdf0e10cSrcweir
7278cdf0e10cSrcweir a16Bit = 0x12; // lvl auf 9 setzen // 410 0x19a
7279cdf0e10cSrcweir if( fHtmlDoc ) a16Bit |= 0x0200;
7280cdf0e10cSrcweir if( fSnapBorder ) a16Bit |= 0x0800;
7281cdf0e10cSrcweir if( fIncludeHeader ) a16Bit |= 0x1000;
7282cdf0e10cSrcweir if( fIncludeFooter ) a16Bit |= 0x2000;
7283cdf0e10cSrcweir if( fForcePageSizePag ) a16Bit |= 0x4000;
7284cdf0e10cSrcweir if( fMinFontSizePag ) a16Bit |= 0x8000;
7285cdf0e10cSrcweir Set_UInt16( pData, a16Bit );
7286cdf0e10cSrcweir
7287cdf0e10cSrcweir a16Bit = 0; // 412 0x19c
7288cdf0e10cSrcweir if( fHaveVersions ) a16Bit |= 0x0001;
7289cdf0e10cSrcweir if( fAutoVersion ) a16Bit |= 0x0002;
7290cdf0e10cSrcweir Set_UInt16( pData, a16Bit );
7291cdf0e10cSrcweir
7292cdf0e10cSrcweir pData += 12; // 414 0x19e
7293cdf0e10cSrcweir
7294cdf0e10cSrcweir Set_UInt32( pData, cChWS ); // 426 0x1aa
7295cdf0e10cSrcweir Set_UInt32( pData, cChWSFtnEdn ); // 430 0x1ae
7296cdf0e10cSrcweir Set_UInt32( pData, grfDocEvents ); // 434 0x1b2
7297cdf0e10cSrcweir
7298cdf0e10cSrcweir pData += 4+30+8; // 438 0x1b6; 442 0x1ba; 472 0x1d8; 476 0x1dc
7299cdf0e10cSrcweir
7300cdf0e10cSrcweir Set_UInt32( pData, cDBC ); // 480 0x1e0
7301cdf0e10cSrcweir Set_UInt32( pData, cDBCFtnEdn ); // 484 0x1e4
7302cdf0e10cSrcweir
7303cdf0e10cSrcweir pData += 1 * sizeof( sal_Int32); // 488 0x1e8
7304cdf0e10cSrcweir
7305cdf0e10cSrcweir Set_UInt16( pData, nfcFtnRef ); // 492 0x1ec
7306cdf0e10cSrcweir Set_UInt16( pData, nfcEdnRef ); // 494 0x1ee
7307cdf0e10cSrcweir Set_UInt16( pData, hpsZoonFontPag ); // 496 0x1f0
7308cdf0e10cSrcweir Set_UInt16( pData, dywDispPag ); // 498 0x1f2
7309cdf0e10cSrcweir
7310cdf0e10cSrcweir //500 -> 508, Appear to be repeated here in 2000+
7311cdf0e10cSrcweir pData += 8;
7312cdf0e10cSrcweir Set_UInt32(pData, GetCompatabilityOptions());
7313cdf0e10cSrcweir Set_UInt32(pData, GetCompatabilityOptions2());
7314cdf0e10cSrcweir pData += 32;
7315cdf0e10cSrcweir
7316cdf0e10cSrcweir a16Bit = 0;
7317cdf0e10cSrcweir if (fAcetateShowMarkup)
7318cdf0e10cSrcweir a16Bit |= 0x1000;
7319cdf0e10cSrcweir //Word XP at least requires fAcetateShowMarkup to honour fAcetateShowAtn
7320cdf0e10cSrcweir if (fAcetateShowAtn)
7321cdf0e10cSrcweir {
7322cdf0e10cSrcweir a16Bit |= 0x1000;
7323cdf0e10cSrcweir a16Bit |= 0x2000;
7324cdf0e10cSrcweir }
7325cdf0e10cSrcweir Set_UInt16(pData, a16Bit);
7326cdf0e10cSrcweir
7327cdf0e10cSrcweir pData += 48;
7328cdf0e10cSrcweir a16Bit = 0x0080;
7329cdf0e10cSrcweir Set_UInt16(pData, a16Bit);
7330cdf0e10cSrcweir }
7331cdf0e10cSrcweir rStrm.Write( aData, nLen );
7332cdf0e10cSrcweir return 0 == rStrm.GetError();
7333cdf0e10cSrcweir }
7334cdf0e10cSrcweir
ReadFromMem(sal_uInt8 * & pData)7335cdf0e10cSrcweir void WW8DopTypography::ReadFromMem(sal_uInt8 *&pData)
7336cdf0e10cSrcweir {
7337cdf0e10cSrcweir sal_uInt16 a16Bit = Get_UShort(pData);
7338cdf0e10cSrcweir fKerningPunct = (a16Bit & 0x0001);
7339cdf0e10cSrcweir iJustification = (a16Bit & 0x0006) >> 1;
7340cdf0e10cSrcweir iLevelOfKinsoku = (a16Bit & 0x0018) >> 3;
7341cdf0e10cSrcweir f2on1 = (a16Bit & 0x0020) >> 5;
7342cdf0e10cSrcweir reserved1 = (a16Bit & 0x03C0) >> 6;
7343cdf0e10cSrcweir reserved2 = (a16Bit & 0xFC00) >> 10;
7344cdf0e10cSrcweir
7345cdf0e10cSrcweir cchFollowingPunct = Get_Short(pData);
7346cdf0e10cSrcweir cchLeadingPunct = Get_Short(pData);
7347cdf0e10cSrcweir
7348cdf0e10cSrcweir sal_Int16 i;
7349cdf0e10cSrcweir for (i=0; i < nMaxFollowing; ++i)
7350cdf0e10cSrcweir rgxchFPunct[i] = Get_Short(pData);
7351cdf0e10cSrcweir for (i=0; i < nMaxLeading; ++i)
7352cdf0e10cSrcweir rgxchLPunct[i] = Get_Short(pData);
7353cdf0e10cSrcweir
7354cdf0e10cSrcweir if (cchFollowingPunct >= 0 && cchFollowingPunct < nMaxFollowing)
7355cdf0e10cSrcweir rgxchFPunct[cchFollowingPunct]=0;
7356cdf0e10cSrcweir else
7357cdf0e10cSrcweir rgxchFPunct[nMaxFollowing - 1]=0;
7358cdf0e10cSrcweir
7359cdf0e10cSrcweir if (cchLeadingPunct >= 0 && cchLeadingPunct < nMaxLeading)
7360cdf0e10cSrcweir rgxchLPunct[cchLeadingPunct]=0;
7361cdf0e10cSrcweir else
7362cdf0e10cSrcweir rgxchLPunct[nMaxLeading - 1]=0;
7363cdf0e10cSrcweir
7364cdf0e10cSrcweir }
7365cdf0e10cSrcweir
WriteToMem(sal_uInt8 * & pData) const7366cdf0e10cSrcweir void WW8DopTypography::WriteToMem(sal_uInt8 *&pData) const
7367cdf0e10cSrcweir {
7368cdf0e10cSrcweir sal_uInt16 a16Bit = fKerningPunct;
7369cdf0e10cSrcweir a16Bit |= (iJustification << 1) & 0x0006;
7370cdf0e10cSrcweir a16Bit |= (iLevelOfKinsoku << 3) & 0x0018;
7371cdf0e10cSrcweir a16Bit |= (f2on1 << 5) & 0x002;
7372cdf0e10cSrcweir a16Bit |= (reserved1 << 6) & 0x03C0;
7373cdf0e10cSrcweir a16Bit |= (reserved2 << 10) & 0xFC00;
7374cdf0e10cSrcweir Set_UInt16(pData,a16Bit);
7375cdf0e10cSrcweir
7376cdf0e10cSrcweir Set_UInt16(pData,cchFollowingPunct);
7377cdf0e10cSrcweir Set_UInt16(pData,cchLeadingPunct);
7378cdf0e10cSrcweir
7379cdf0e10cSrcweir sal_Int16 i;
7380cdf0e10cSrcweir for (i=0; i < nMaxFollowing; ++i)
7381cdf0e10cSrcweir Set_UInt16(pData,rgxchFPunct[i]);
7382cdf0e10cSrcweir for (i=0; i < nMaxLeading; ++i)
7383cdf0e10cSrcweir Set_UInt16(pData,rgxchLPunct[i]);
7384cdf0e10cSrcweir }
7385cdf0e10cSrcweir
GetConvertedLang() const7386cdf0e10cSrcweir sal_uInt16 WW8DopTypography::GetConvertedLang() const
7387cdf0e10cSrcweir {
7388cdf0e10cSrcweir sal_uInt16 nLang;
7389cdf0e10cSrcweir //I have assumed peoples republic/taiwan == simplified/traditional
7390cdf0e10cSrcweir
7391cdf0e10cSrcweir //This isn't a documented issue, so we might have it all wrong,
7392cdf0e10cSrcweir //i.e. i.e. whats with the powers of two ?
7393cdf0e10cSrcweir
7394cdf0e10cSrcweir /*
7395cdf0e10cSrcweir #84082#
7396cdf0e10cSrcweir One example of 3 for reserved1 which was really Japanese, perhaps last bit
7397cdf0e10cSrcweir is for some other use ?, or redundant. If more examples trigger the assert
7398cdf0e10cSrcweir we might be able to figure it out.
7399cdf0e10cSrcweir */
7400cdf0e10cSrcweir switch(reserved1 & 0xE)
7401cdf0e10cSrcweir {
7402cdf0e10cSrcweir case 2: //Japan
7403cdf0e10cSrcweir nLang = LANGUAGE_JAPANESE;
7404cdf0e10cSrcweir break;
7405cdf0e10cSrcweir case 4: //Chinese (Peoples Republic)
7406cdf0e10cSrcweir nLang = LANGUAGE_CHINESE_SIMPLIFIED;
7407cdf0e10cSrcweir break;
7408cdf0e10cSrcweir case 6: //Korean
7409cdf0e10cSrcweir nLang = LANGUAGE_KOREAN;
7410cdf0e10cSrcweir break;
7411cdf0e10cSrcweir case 8: //Chinese (Taiwan)
7412cdf0e10cSrcweir nLang = LANGUAGE_CHINESE_TRADITIONAL;
7413cdf0e10cSrcweir break;
7414cdf0e10cSrcweir default:
7415cdf0e10cSrcweir ASSERT(!this, "Unknown MS Asian Typography language, report");
7416cdf0e10cSrcweir nLang = LANGUAGE_CHINESE;
7417cdf0e10cSrcweir break;
7418cdf0e10cSrcweir case 0:
7419cdf0e10cSrcweir //And here we have the possibility that it says 2, but its really
7420cdf0e10cSrcweir //a bug and only japanese level 2 has been selected after a custom
7421cdf0e10cSrcweir //version was chosen on last save!
7422cdf0e10cSrcweir nLang = LANGUAGE_JAPANESE;
7423cdf0e10cSrcweir break;
7424cdf0e10cSrcweir }
7425cdf0e10cSrcweir return nLang;
7426cdf0e10cSrcweir }
7427cdf0e10cSrcweir
7428cdf0e10cSrcweir //-----------------------------------------
7429cdf0e10cSrcweir // Sprms
7430cdf0e10cSrcweir //-----------------------------------------
GetSprmTailLen(sal_uInt16 nId,const sal_uInt8 * pSprm) const7431cdf0e10cSrcweir sal_uInt16 wwSprmParser::GetSprmTailLen(sal_uInt16 nId, const sal_uInt8* pSprm)
7432cdf0e10cSrcweir const
7433cdf0e10cSrcweir {
7434cdf0e10cSrcweir SprmInfo aSprm = GetSprmInfo(nId);
7435cdf0e10cSrcweir sal_uInt16 nL = 0; // number of Bytes to read
7436cdf0e10cSrcweir
7437cdf0e10cSrcweir //sprmPChgTabs
7438cdf0e10cSrcweir switch( nId )
7439cdf0e10cSrcweir {
7440cdf0e10cSrcweir case 23:
7441cdf0e10cSrcweir case 0xC615:
7442cdf0e10cSrcweir if( pSprm[1 + mnDelta] != 255 )
7443cdf0e10cSrcweir nL = static_cast< sal_uInt16 >(pSprm[1 + mnDelta] + aSprm.nLen);
7444cdf0e10cSrcweir else
7445cdf0e10cSrcweir {
7446cdf0e10cSrcweir sal_uInt8 nDel = pSprm[2 + mnDelta];
7447cdf0e10cSrcweir sal_uInt8 nIns = pSprm[3 + mnDelta + 4 * nDel];
7448cdf0e10cSrcweir
7449cdf0e10cSrcweir nL = 2 + 4 * nDel + 3 * nIns;
7450cdf0e10cSrcweir }
7451cdf0e10cSrcweir break;
7452cdf0e10cSrcweir case 0xD608:
7453cdf0e10cSrcweir nL = SVBT16ToShort( &pSprm[1 + mnDelta] );
7454cdf0e10cSrcweir break;
7455cdf0e10cSrcweir default:
7456cdf0e10cSrcweir switch (aSprm.nVari)
7457cdf0e10cSrcweir {
7458cdf0e10cSrcweir case L_FIX:
7459cdf0e10cSrcweir nL = aSprm.nLen; // Excl. Token
7460cdf0e10cSrcweir break;
7461cdf0e10cSrcweir case L_VAR:
7462cdf0e10cSrcweir // Variable 1-Byte Length?
7463cdf0e10cSrcweir // Excl. Token + Var-Lengthbyte
7464cdf0e10cSrcweir nL = static_cast< sal_uInt16 >(pSprm[1 + mnDelta] + aSprm.nLen);
7465cdf0e10cSrcweir break;
7466cdf0e10cSrcweir case L_VAR2:
7467cdf0e10cSrcweir // Variable 2-Byte Length?
7468cdf0e10cSrcweir // Excl. Token + Var-Lengthbyte
7469cdf0e10cSrcweir nL = static_cast< sal_uInt16 >(SVBT16ToShort( &pSprm[1 + mnDelta] ) + aSprm.nLen - 1);
7470cdf0e10cSrcweir break;
7471cdf0e10cSrcweir default:
7472cdf0e10cSrcweir ASSERT(!this, "Unknown sprm varient");
7473cdf0e10cSrcweir break;
7474cdf0e10cSrcweir }
7475cdf0e10cSrcweir break;
7476cdf0e10cSrcweir }
7477cdf0e10cSrcweir return nL;
7478cdf0e10cSrcweir }
7479cdf0e10cSrcweir
7480cdf0e10cSrcweir // one or two bytes at the beginning at the sprm id
GetSprmId(const sal_uInt8 * pSp) const7481cdf0e10cSrcweir sal_uInt16 wwSprmParser::GetSprmId(const sal_uInt8* pSp) const
7482cdf0e10cSrcweir {
7483cdf0e10cSrcweir ASSERT_RET_ON_FAIL(pSp, "Why GetSprmId with pSp of 0", 0);
7484cdf0e10cSrcweir
7485cdf0e10cSrcweir sal_uInt16 nId = 0;
7486cdf0e10cSrcweir
7487cdf0e10cSrcweir if (ww::IsSevenMinus(meVersion))
7488cdf0e10cSrcweir {
7489cdf0e10cSrcweir nId = *pSp;
7490cdf0e10cSrcweir if (0x0100 < nId)
7491cdf0e10cSrcweir nId = 0;
7492cdf0e10cSrcweir }
7493cdf0e10cSrcweir else
7494cdf0e10cSrcweir {
7495cdf0e10cSrcweir nId = SVBT16ToShort(pSp);
7496cdf0e10cSrcweir if (0x0800 > nId)
7497cdf0e10cSrcweir nId = 0;
7498cdf0e10cSrcweir }
7499cdf0e10cSrcweir
7500cdf0e10cSrcweir return nId;
7501cdf0e10cSrcweir }
7502cdf0e10cSrcweir
7503cdf0e10cSrcweir // with tokens and length byte
GetSprmSize(sal_uInt16 nId,const sal_uInt8 * pSprm) const7504cdf0e10cSrcweir sal_uInt16 wwSprmParser::GetSprmSize(sal_uInt16 nId, const sal_uInt8* pSprm) const
7505cdf0e10cSrcweir {
7506cdf0e10cSrcweir return GetSprmTailLen(nId, pSprm) + 1 + mnDelta + SprmDataOfs(nId);
7507cdf0e10cSrcweir }
7508cdf0e10cSrcweir
SprmDataOfs(sal_uInt16 nId) const7509cdf0e10cSrcweir sal_uInt8 wwSprmParser::SprmDataOfs(sal_uInt16 nId) const
7510cdf0e10cSrcweir {
7511cdf0e10cSrcweir return GetSprmInfo(nId).nVari;
7512cdf0e10cSrcweir }
7513cdf0e10cSrcweir
DistanceToData(sal_uInt16 nId) const7514cdf0e10cSrcweir sal_uInt16 wwSprmParser::DistanceToData(sal_uInt16 nId) const
7515cdf0e10cSrcweir {
7516cdf0e10cSrcweir return 1 + mnDelta + SprmDataOfs(nId);
7517cdf0e10cSrcweir }
7518cdf0e10cSrcweir
SEPr()7519cdf0e10cSrcweir SEPr::SEPr() :
7520cdf0e10cSrcweir bkc(2), fTitlePage(0), fAutoPgn(0), nfcPgn(0), fUnlocked(0), cnsPgn(0),
7521cdf0e10cSrcweir fPgnRestart(0), fEndNote(1), lnc(0), grpfIhdt(0), nLnnMod(0), dxaLnn(0),
7522cdf0e10cSrcweir dxaPgn(720), dyaPgn(720), fLBetween(0), vjc(0), dmBinFirst(0),
7523cdf0e10cSrcweir dmBinOther(0), dmPaperReq(0), fPropRMark(0), ibstPropRMark(0),
7524cdf0e10cSrcweir dttmPropRMark(0), dxtCharSpace(0), dyaLinePitch(0), clm(0), reserved1(0),
7525cdf0e10cSrcweir dmOrientPage(0), iHeadingPgn(0), pgnStart(1), lnnMin(0), wTextFlow(0),
7526cdf0e10cSrcweir reserved2(0), pgbApplyTo(0), pgbPageDepth(0), pgbOffsetFrom(0),
7527cdf0e10cSrcweir xaPage(lLetterWidth), yaPage(lLetterHeight), xaPageNUp(lLetterWidth), yaPageNUp(lLetterHeight),
7528cdf0e10cSrcweir dxaLeft(1800), dxaRight(1800), dyaTop(1440), dyaBottom(1440), dzaGutter(0),
7529cdf0e10cSrcweir dyaHdrTop(720), dyaHdrBottom(720), ccolM1(0), fEvenlySpaced(1),
7530cdf0e10cSrcweir reserved3(0), fBiDi(0), fFacingCol(0), fRTLGutter(0), fRTLAlignment(0),
7531cdf0e10cSrcweir dxaColumns(720), dxaColumnWidth(0), dmOrientFirst(0), fLayout(0),
7532cdf0e10cSrcweir reserved4(0)
7533cdf0e10cSrcweir {
7534cdf0e10cSrcweir memset(rgdxaColumnWidthSpacing, 0, sizeof(rgdxaColumnWidthSpacing));
7535cdf0e10cSrcweir }
7536cdf0e10cSrcweir
7537cdf0e10cSrcweir /* vi:set tabstop=4 shiftwidth=4 expandtab: */
7538