1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <rtl/strbuf.hxx>
23 #include <rtl/ustring.hxx>
24 #include <tools/stream.hxx>
25 #include <w1class.hxx>
29 static const sal_Char
* pUnknown
= "?";
35 Ww1SingleSprm
* Ww1Sprm::aTab
[ 256 ];
36 Ww1SingleSprm
* Ww1Sprm::pSingleSprm
= 0;
40 /////////////////////////////////////////////////////////////////// Fib
41 Ww1Fib::Ww1Fib( SvStream
& _rStream
)
44 bOK
= 0 == rStream
.Seek(0) &&
45 rStream
.Read( &aFib
, sizeof( aFib
)) == sizeof( aFib
);
48 ///////////////////////////////////////////////////////////// PlainText
50 Ww1PlainText::Ww1PlainText(Ww1Fib
& rWwFib
, sal_uLong nFilePos
, sal_uLong nCountBytes
)
51 : rFib(rWwFib
), ulFilePos(nFilePos
), ulCountBytes(nCountBytes
),
56 sal_Unicode
Ww1PlainText::operator [] ( sal_uLong ulOffset
)
58 OSL_ENSURE( ulOffset
<Count(), "Ww1PlainText" );
61 if( rFib
.GetStream().Seek( ulFilePos
+ ulOffset
) == ulFilePos
+ulOffset
&&
62 rFib
.GetStream().Read( &cRead
, sizeof( cRead
) ) == sizeof( cRead
) )
64 cRet
= OUString(&cRead
, 1, RTL_TEXTENCODING_MS_1252
).toChar();
71 String
Ww1PlainText::GetText( sal_uLong ulOffset
, sal_uLong nLen
) const
73 OSL_ENSURE(ulOffset
+nLen
<Count(), "Ww1PlainText");
75 sal_Size nPos
= ulFilePos
+ulOffset
;
77 bool bSeekOk
= rFib
.GetStream().Seek(nPos
) == nPos
;
79 read_uInt8s_ToOUString(rFib
.GetStream(), nLen
, RTL_TEXTENCODING_MS_1252
) :
83 ///////////////////////////////////////////////////////////////// Style
85 : pPapx(0), pParent(0), stcBase(0), stcNext(0), bUsed(false)
94 void Ww1Style::SetDefaults(sal_uInt8 stc
)
104 sal_uInt16
Ww1Style::ReadName( sal_uInt8
*&p
, sal_uInt16
& rnCountBytes
, sal_uInt16 stc
)
106 sal_uInt8 nCountBytes
= SVBT8ToByte(p
);
109 if( !nCountBytes
) // default
111 static const sal_Char
* const names
[] =
114 "W1 Annotation reference", //223
115 "W1 Annotation text", //224
116 "W1 Table of contents 8", //225
117 "W1 Table of contents 7", //226
118 "W1 Table of contents 6", //227
119 "W1 Table of contents 5", //228
120 "W1 Table of contents 4", //229
121 "W1 Table of contents 3", //230
122 "W1 Table of contents 2", //231
123 "W1 Table of contents 1", //232
131 "W1 Line number", //240
132 "W1 Index heading", //241
135 "W1 Footnote reference", //244
136 "W1 Footnote text", //245
137 "W1 Heading 9", //246
138 "W1 Heading 8", //247
139 "W1 Heading 7", //248
140 "W1 Heading 6", //249
141 "W1 Heading 5", //250
142 "W1 Heading 4", //251
143 "W1 Heading 3", //252
144 "W1 Heading 2", //253
145 "W1 Heading 1", //254
146 "W1 Normal indent" //255
149 const sal_Char
* pStr
;
153 else if (nSize
- 222 >= SAL_N_ELEMENTS(names
))
156 pStr
= names
[nSize
-222];
157 SetName(String(pStr
, RTL_TEXTENCODING_MS_1252
));
159 else if( 255 > nCountBytes
) // unused
161 SetName( String( (sal_Char
*)p
, nCountBytes
, RTL_TEXTENCODING_MS_1252
));
163 OSL_ENSURE(rnCountBytes
>=nCountBytes
, "Ww1Style");
164 rnCountBytes
= rnCountBytes
- nCountBytes
;
169 sal_uInt16
Ww1Style::ReadChpx( sal_uInt8
*&p
, sal_uInt16
& rnCountBytes
)
171 sal_uInt16 nCountBytes
= SVBT8ToByte(p
);
174 if (nCountBytes
!= 255 // unused
175 && nCountBytes
!= 0) // default
177 if (nCountBytes
> sizeof(aChpx
))
178 nCountBytes
= sizeof(aChpx
);
179 memcpy( &aChpx
, p
, nCountBytes
);
181 OSL_ENSURE(rnCountBytes
>=nCountBytes
, "Ww1Style");
182 rnCountBytes
= rnCountBytes
- nCountBytes
;
187 sal_uInt16
Ww1Style::ReadPapx(sal_uInt8
*&p
, sal_uInt16
& rnCountBytes
)
189 sal_uInt16 nCountBytes
= SVBT8ToByte(p
);
192 if (nCountBytes
!= 255)
194 pPapx
= new Ww1SprmPapx(p
, nCountBytes
);
196 OSL_ENSURE(rnCountBytes
>=nCountBytes
, "Ww1Style");
197 rnCountBytes
= rnCountBytes
- nCountBytes
;
200 pPapx
= new Ww1SprmPapx(p
, 0);
204 sal_uInt16
Ww1Style::ReadEstcp(sal_uInt8
*&p
, sal_uInt16
& rnCountBytes
)
206 stcNext
= SVBT8ToByte(p
);
209 stcBase
= SVBT8ToByte(p
);
211 OSL_ENSURE(rnCountBytes
>0, "Ww1Style");
216 //////////////////////////////////////////////////////////// StyleSheet
217 Ww1StyleSheet::Ww1StyleSheet(Ww1Fib
& _rFib
)
222 sal_uInt16 cbStshf
= rFib
.GetFIB().cbStshfGet();
223 OSL_ENSURE(cbStshf
>=17, "Ww1StyleSheet");
224 for (sal_uInt16 stc
=0;stc
<Count();stc
++)
226 aStyles
[stc
].SetParent(this);
227 aStyles
[stc
].SetDefaults((sal_uInt8
)stc
);
229 sal_uInt8
* del
= NULL
;
230 if (rFib
.GetStream().Seek(rFib
.GetFIB().fcStshfGet())
231 == (sal_uLong
)rFib
.GetFIB().fcStshfGet()
232 && (del
= new sal_uInt8
[cbStshf
]) != NULL
233 && rFib
.GetStream().Read(del
, cbStshf
) == (sal_uLong
)cbStshf
)
236 cstcStd
= SVBT16ToShort(p
);
238 cbStshf
-= sizeof(SVBT16
);
239 ReadNames(p
, cbStshf
);
240 ReadChpx(p
, cbStshf
);
241 ReadPapx(p
, cbStshf
);
242 ReadEstcp(p
, cbStshf
);
243 OSL_ENSURE(cbStshf
==0, "Ww1StyleSheet");
249 sal_uInt16
Ww1StyleSheet::ReadNames( sal_uInt8
*& p
, sal_uInt16
& rnCountBytes
)
251 sal_uInt16 nCountBytes
= SVBT16ToShort(p
);
253 OSL_ENSURE(rnCountBytes
>=nCountBytes
, "Ww1StyleSheet");
254 rnCountBytes
= rnCountBytes
- nCountBytes
;
255 nCountBytes
= nCountBytes
- sizeof(SVBT16
);
257 while (nCountBytes
> 0)
259 sal_uInt16 stc
= (stcp
- cstcStd
) & 255;
260 aStyles
[stc
].ReadName(p
, nCountBytes
, stc
);
263 OSL_ENSURE(nCountBytes
==0, "Ww1StyleSheet");
267 sal_uInt16
Ww1StyleSheet::ReadChpx(sal_uInt8
*& p
, sal_uInt16
& rnCountBytes
)
269 sal_uInt16 nCountBytes
= SVBT16ToShort(p
);
271 OSL_ENSURE(rnCountBytes
>=nCountBytes
, "Ww1StyleSheet");
272 rnCountBytes
= rnCountBytes
- nCountBytes
;
273 nCountBytes
= nCountBytes
- sizeof(SVBT16
);
275 while (nCountBytes
> 0)
277 sal_uInt16 stc
= (stcp
- cstcStd
) & 255;
278 aStyles
[stc
].ReadChpx(p
, nCountBytes
);
281 OSL_ENSURE(nCountBytes
== 0, "Ww1StyleSheet");
285 sal_uInt16
Ww1StyleSheet::ReadPapx(sal_uInt8
*& p
, sal_uInt16
& rnCountBytes
)
287 sal_uInt16 nCountBytes
= SVBT16ToShort(p
);
289 OSL_ENSURE(rnCountBytes
>=nCountBytes
, "Ww1StyleSheet");
290 rnCountBytes
= rnCountBytes
- nCountBytes
;
291 nCountBytes
= nCountBytes
- sizeof(SVBT16
);
293 while (nCountBytes
> 0)
295 sal_uInt16 stc
= (stcp
- cstcStd
) & 255;
296 aStyles
[stc
].ReadPapx(p
, nCountBytes
);
299 OSL_ENSURE(nCountBytes
== 0, "Ww1StyleSheet");
303 sal_uInt16
Ww1StyleSheet::ReadEstcp(sal_uInt8
*& p
, sal_uInt16
& rnCountBytes
)
305 sal_uInt16 iMac
= SVBT16ToShort(p
);
307 OSL_ENSURE(rnCountBytes
>=sizeof(SVBT16
), "Ww1StyleSheet");
308 rnCountBytes
-= sizeof(SVBT16
);
309 for (sal_uInt16 stcp
=0;stcp
<iMac
;stcp
++)
311 sal_uInt16 stc
= (stcp
- cstcStd
) & 255;
312 aStyles
[stc
].ReadEstcp(p
, rnCountBytes
);
314 OSL_ENSURE(rnCountBytes
==0, "Ww1StyleSheet");
318 ///////////////////////////////////////////////////////////////// Fonts
320 Ww1Fonts::Ww1Fonts(Ww1Fib
& rInFib
, sal_uLong nFieldFlgs
)
321 : pFontA(0), rFib(rInFib
), nFieldFlags(nFieldFlgs
), nMax(0), bOK(false)
323 if(rFib
.GetFIB().cbSttbfffnGet() > 2 ) // ueberhaupt fonts?
326 OSL_ENSURE(rFib
.GetFIB().cbSttbfffnGet() > sizeof(nCountBytes
), "Ww1Fonts");
327 if (rFib
.GetStream().Seek(rFib
.GetFIB().fcSttbfffnGet())
328 == (sal_uLong
)rFib
.GetFIB().fcSttbfffnGet())
329 if (rFib
.GetStream().Read(nCountBytes
, sizeof(nCountBytes
))
330 == sizeof(nCountBytes
)) // Laenge steht hier nochmal
332 OSL_ENSURE(SVBT16ToShort(nCountBytes
)
333 == rFib
.GetFIB().cbSttbfffnGet(), "redundant-size missmatch");
334 // hoffentlich sind sie immer gleich
335 W1_FFN
* pA
= (W1_FFN
*)new char[rFib
.GetFIB().cbSttbfffnGet()
336 - sizeof(nCountBytes
)]; // Alloziere Font-Array
338 if (rFib
.GetStream().Read(pA
, rFib
.GetFIB().cbSttbfffnGet()
339 - sizeof(nCountBytes
)) == (sal_uLong
)rFib
.GetFIB().cbSttbfffnGet()
340 - sizeof(nCountBytes
)) // lese alle Fonts
343 long nLeft
= rFib
.GetFIB().cbSttbfffnGet()
344 - sizeof(nCountBytes
); // Zaehle, wieviele Fonts enthalten
349 nNextSiz
= p
->cbFfnM1Get() + 1;
354 if(nLeft
< 1) // naechste Laenge muss gelesen werden koennen
356 p
= (W1_FFN
*)(((char*)p
) + nNextSiz
);
360 pFontA
= new W1_FFN
*[nMax
]; // alloziere Index-Array
362 pFontA
[0] = pA
; // fuelle Index-Array
364 for(i
=1, p
=pA
; i
<nMax
; i
++)
366 p
= (W1_FFN
*)(((char*)p
) + p
->cbFfnM1Get() + 1);
371 pFontA
= 0; // Keine Eintraege -> kein Array
377 W1_FFN
* Ww1Fonts::GetFFN(sal_uInt16 nNum
)
386 /////////////////////////////////////////////////////////////////// DOP
387 Ww1Dop::Ww1Dop(Ww1Fib
& _rFib
)
391 memset(&aDop
, 0, sizeof(aDop
)); // set defaults
392 if(rFib
.GetFIB().cbDopGet() >= sizeof(aDop
))
393 nRead
= sizeof(aDop
);
395 nRead
= rFib
.GetFIB().cbDopGet();
396 bOK
= rFib
.GetStream().Seek(rFib
.GetFIB().fcDopGet()) ==
397 (sal_uLong
)rFib
.GetFIB().fcDopGet() &&
398 rFib
.GetStream().Read(&aDop
, nRead
) == (sal_uLong
)nRead
;
401 /////////////////////////////////////////////////////////////// Picture
402 Ww1Picture::Ww1Picture(SvStream
& rStream
, sal_uLong ulFilePos
)
403 : bOK(false), pPic(0)
405 ulFilePos
&= 0xffffff; //~ ww1: warum auch immer - im highbyte steht eine 5?!?!
407 if (rStream
.Seek(ulFilePos
) == (sal_uLong
)ulFilePos
)
408 if (rStream
.Read(&lcb
, sizeof(lcb
)) == (sal_uLong
)sizeof(lcb
))
409 if (sizeof(int)>=4 || SVBT32ToUInt32(lcb
) < 0x8000) //~ mdt: 64K & 16bit
410 if ((pPic
= (W1_PIC
*)(new sal_uInt8
[SVBT32ToUInt32(lcb
)])) != NULL
)
411 if (rStream
.Seek(ulFilePos
) == (sal_uLong
)ulFilePos
)
412 if (rStream
.Read(pPic
, SVBT32ToUInt32(lcb
)) == (sal_uLong
)SVBT32ToUInt32(lcb
))
414 OSL_ENSURE(pPic
->cbHeaderGet()==sizeof(*pPic
)-sizeof(pPic
->rgb
), "Ww1Picture");
419 ////////////////////////////////////////////////////////////////// Sprm
420 Ww1Sprm::Ww1Sprm(sal_uInt8
* x
, sal_uInt16 _nCountBytes
)
422 nCountBytes(_nCountBytes
),
427 if (nCountBytes
== 0)
430 if ((p
= new sal_uInt8
[nCountBytes
]) != NULL
)
432 memcpy(p
, x
, nCountBytes
);
438 Ww1Sprm::Ww1Sprm(SvStream
& rStream
, sal_uLong ulFilePos
)
447 if (rStream
.Seek(ulFilePos
) == (sal_uLong
)ulFilePos
)
448 if (rStream
.Read(&x
, sizeof(x
)) == (sal_uLong
)sizeof(x
))
449 if ((nCountBytes
= SVBT8ToByte(x
)) == 255
451 || (p
= new sal_uInt8
[nCountBytes
]) != NULL
)
452 if (nCountBytes
== 255
454 || rStream
.Read(p
, nCountBytes
) == (sal_uLong
)nCountBytes
)
465 sal_uInt16
Ww1SingleSprm::Size(sal_uInt8
* /*pSprm*/)
470 Ww1SingleSprm::~Ww1SingleSprm()
474 sal_uInt16
Ww1SingleSprmTab::Size(sal_uInt8
* pSprm
) // Doc 24/25, Fastsave-Sprm
476 OSL_ENSURE(nCountBytes
==0, "Ww1SingleSprmTab");
477 sal_uInt16 nRet
= sizeof(SVBT8
);
478 sal_uInt16 nSize
= SVBT8ToByte(pSprm
);
483 sal_uInt16 nDel
= SVBT8ToByte(pSprm
+1) * 4;
484 sal_uInt16 nIns
= SVBT8ToByte(pSprm
+ 3 + nDel
) * 3;
487 OSL_ENSURE(nRet
<= 354, "Ww1SingleSprmTab");
493 sal_uInt16
Ww1SingleSprmByteSized::Size(sal_uInt8
* pSprm
)
496 nRet
= SVBT8ToByte(pSprm
);
497 nRet
+= sizeof(SVBT8
); // var. l. byte-size
498 nRet
= nRet
+ nCountBytes
;
502 sal_uInt16
Ww1SingleSprmWordSized::Size(sal_uInt8
* pSprm
)
505 nRet
= SVBT16ToShort(pSprm
);
506 nRet
+= sizeof(SVBT16
); // var. l. word-size
507 nRet
= nRet
+ nCountBytes
;
511 static sal_uInt8 nLast
= 0;
512 static sal_uInt8 nCurrent
= 0;
513 sal_uInt16
Ww1Sprm::GetSize(sal_uInt8 nId
, sal_uInt8
* pSprm
)
516 nL
= GetTab(nId
).Size(pSprm
);
522 sal_Bool
Ww1Sprm::Fill(sal_uInt16 index
, sal_uInt8
& nId
, sal_uInt16
& nL
, sal_uInt8
*& pSprm
)
524 OSL_ENSURE(index
< Count(), "Ww1Sprm");
525 pSprm
= p
+ pArr
[index
];
526 nId
= SVBT8ToByte(pSprm
);
528 nL
= GetTab(nId
).Size(pSprm
);
532 sal_Bool
Ww1Sprm::ReCalc()
534 sal_Bool bRet
= sal_True
;
538 if (nCountBytes
!= 255) // not unused?
540 sal_uInt16 cbsik
= nCountBytes
;
544 sal_uInt16 iLen
= GetSizeBrutto(psik
);
545 OSL_ENSURE(iLen
<=cbsik
, "Ww1Sprm");
547 cbsik
= 0; // ignore the rest: we are wrong...
551 cbsik
= cbsik
- iLen
;
556 && (pArr
= new sal_uInt16
[count
]) != NULL
)
559 sal_uInt16 offset
= 0;
560 sal_uInt16 current
= 0;
562 while (current
<count
)
564 pArr
[current
++] = offset
;
565 sal_uInt16 iLen
= GetSizeBrutto(psik
);
570 cbsik
= cbsik
- iLen
;
571 offset
= offset
+ iLen
;
581 void Ww1Sprm::DeinitTab()
583 for (size_t i
=0; i
< SAL_N_ELEMENTS(aTab
); ++i
)
585 memset(aTab
, 0, SAL_N_ELEMENTS(aTab
));
589 void Ww1Sprm::InitTab()
591 memset(aTab
, 0, SAL_N_ELEMENTS(aTab
));
592 pSingleSprm
= new Ww1SingleSprm( 0, DUMPNAME(pUnknown
));
594 aTab
[ 2] = new Ww1SingleSprmByte(DUMPNAME("sprmPStc")); // 2 pap.istd (style code)
595 aTab
[ 3] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmPIstdPermute")); // 3 pap.istd permutation
596 aTab
[ 4] = new Ww1SingleSprmByte(DUMPNAME("sprmPIncLevel")); // 4 pap.istddifference
597 aTab
[ 5] = new Ww1SingleSprmPJc(DUMPNAME("sprmPJc")); // 5 pap.jc (justification)
598 aTab
[ 6] = new Ww1SingleSprmBool(DUMPNAME("sprmPFSideBySide")); // 6 pap.fSideBySide
599 aTab
[ 7] = new Ww1SingleSprmPFKeep(DUMPNAME("sprmPFKeep")); // 7 pap.fKeep
600 aTab
[ 8] = new Ww1SingleSprmPFKeepFollow(DUMPNAME("sprmPFKeepFollow")); // 8 pap.fKeepFollow
601 aTab
[ 9] = new Ww1SingleSprmPPageBreakBefore(DUMPNAME("sprmPPageBreakBefore")); // 9 pap.fPageBreakBefore
602 aTab
[ 10] = new Ww1SingleSprmByte(DUMPNAME("sprmPBrcl")); // 10 pap.brcl
603 aTab
[ 11] = new Ww1SingleSprmByte(DUMPNAME("sprmPBrcp")); // 11 pap.brcp
604 aTab
[ 12] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmPAnld")); // 12 pap.anld (ANLD structure)
605 aTab
[ 13] = new Ww1SingleSprmByte(DUMPNAME("sprmPNLvlAnm")); // 13 pap.nLvlAnm nn
606 aTab
[ 14] = new Ww1SingleSprmBool(DUMPNAME("sprmPFNoLineNumb")); // 14 ap.fNoLnn
607 aTab
[ 15] = new Ww1SingleSprmPChgTabsPapx(DUMPNAME("sprmPChgTabsPapx")); // 15 pap.itbdMac, ...
608 aTab
[ 16] = new Ww1SingleSprmPDxaRight(DUMPNAME("sprmPDxaRight")); // 16 pap.dxaRight
609 aTab
[ 17] = new Ww1SingleSprmPDxaLeft(DUMPNAME("sprmPDxaLeft")); // 17 pap.dxaLeft
610 aTab
[ 18] = new Ww1SingleSprmWord(DUMPNAME("sprmPNest")); // 18 pap.dxaNest
611 aTab
[ 19] = new Ww1SingleSprmPDxaLeft1(DUMPNAME("sprmPDxaLeft1")); // 19 pap.dxaLeft1
612 aTab
[ 20] = new Ww1SingleSprmPDyaLine(DUMPNAME("sprmPDyaLine")); // 20 pap.lspd an LSPD
613 aTab
[ 21] = new Ww1SingleSprmPDyaBefore(DUMPNAME("sprmPDyaBefore")); // 21 pap.dyaBefore
614 aTab
[ 22] = new Ww1SingleSprmPDyaAfter(DUMPNAME("sprmPDyaAfter")); // 22 pap.dyaAfter
615 aTab
[ 23] = new Ww1SingleSprmTab(0, DUMPNAME(pUnknown
)); // 23 pap.itbdMac, pap.rgdxaTab
616 aTab
[ 24] = new Ww1SingleSprmPFInTable(DUMPNAME("sprmPFInTable")); // 24 pap.fInTable
617 aTab
[ 25] = new Ww1SingleSprmPTtp(DUMPNAME("sprmPTtp")); // 25 pap.fTtp
618 aTab
[ 26] = new Ww1SingleSprmPDxaAbs(DUMPNAME("sprmPDxaAbs")); // 26 pap.dxaAbs
619 aTab
[ 27] = new Ww1SingleSprmPDyaAbs(DUMPNAME("sprmPDyaAbs")); // 27 pap.dyaAbs
620 aTab
[ 28] = new Ww1SingleSprmPDxaWidth(DUMPNAME("sprmPDxaWidth")); // 28 pap.dxaWidth
621 aTab
[ 29] = new Ww1SingleSprmPpc(DUMPNAME("sprmPPc")); // 29 pap.pcHorz, pap.pcVert
622 aTab
[ 30] = new Ww1SingleSprmPBrc10(BRC_TOP
, DUMPNAME("sprmPBrcTop10")); // 30 pap.brcTop BRC10
623 aTab
[ 31] = new Ww1SingleSprmPBrc10(BRC_LEFT
, DUMPNAME("sprmPBrcLeft10")); // 31 pap.brcLeft BRC10
624 aTab
[ 32] = new Ww1SingleSprmPBrc10(BRC_BOTTOM
, DUMPNAME("sprmPBrcBottom10")); // 32 pap.brcBottom BRC10
625 aTab
[ 33] = new Ww1SingleSprmPBrc10(BRC_RIGHT
, DUMPNAME("sprmPBrcRight10")); // 33 pap.brcRight BRC10
626 aTab
[ 34] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBetween10")); // 34 pap.brcBetween BRC10
627 aTab
[ 35] = new Ww1SingleSprmPBrc10(BRC_LEFT
, DUMPNAME("sprmPBrcBar10")); // 35 pap.brcBar BRC10
628 aTab
[ 36] = new Ww1SingleSprmPFromText(DUMPNAME("sprmPFromText10")); // 36 pap.dxaFromText dxa
629 aTab
[ 37] = new Ww1SingleSprmByte(DUMPNAME("sprmPWr")); // 37 pap.wr wr
630 aTab
[ 38] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcTop")); // 38 pap.brcTop BRC
631 aTab
[ 39] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcLeft")); // 39 pap.brcLeft BRC
632 aTab
[ 40] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBottom")); // 40 pap.brcBottom BRC
633 aTab
[ 41] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcRight")); // 41 pap.brcRight BRC
634 aTab
[ 42] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBetween")); // 42 pap.brcBetween BRC
635 aTab
[ 43] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBar")); // 43 pap.brcBar BRC word
636 aTab
[ 44] = new Ww1SingleSprmBool(DUMPNAME("sprmPFNoAutoHyph")); // 44 pap.fNoAutoHyph
637 aTab
[ 45] = new Ww1SingleSprmWord(DUMPNAME("sprmPWHeightAbs")); // 45 pap.wHeightAbs w
638 aTab
[ 46] = new Ww1SingleSprmWord(DUMPNAME("sprmPDcs")); // 46 pap.dcs DCS
639 aTab
[ 47] = new Ww1SingleSprmWord(DUMPNAME("sprmPShd")); // 47 pap.shd SHD
640 aTab
[ 48] = new Ww1SingleSprmWord(DUMPNAME("sprmPDyaFromText")); // 48 pap.dyaFromText dya
641 aTab
[ 49] = new Ww1SingleSprmWord(DUMPNAME("sprmPDxaFromText")); // 49 pap.dxaFromText dxa
642 aTab
[ 50] = new Ww1SingleSprmBool(DUMPNAME("sprmPFLocked")); // 50 pap.fLocked 0 or 1 byte
643 aTab
[ 51] = new Ww1SingleSprmBool(DUMPNAME("sprmPFWidowControl")); // 51 pap.fWidowControl 0 or 1 byte
645 aTab
[ 57] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmCDefault")); // 57 whole CHP (see below) none variable length
646 aTab
[ 58] = new Ww1SingleSprm(0, DUMPNAME("sprmCPlain")); // 58 whole CHP (see below) none 0
648 aTab
[ 60] = new Ww1SingleSprm4State(DUMPNAME("sprmCFBold")); // 60 chp.fBold 0,1, 128, or 129 (see below) byte
649 aTab
[ 61] = new Ww1SingleSprm4State(DUMPNAME("sprmCFItalic")); // 61 chp.fItalic 0,1, 128, or 129 (see below) byte
650 aTab
[ 62] = new Ww1SingleSprm4State(DUMPNAME("sprmCFStrike")); // 62 chp.fStrike 0,1, 128, or 129 (see below) byte
651 aTab
[ 63] = new Ww1SingleSprm4State(DUMPNAME("sprmCFOutline")); // 63 chp.fOutline 0,1, 128, or 129 (see below) byte
652 aTab
[ 64] = new Ww1SingleSprm4State(DUMPNAME("sprmCFShadow")); // 64 chp.fShadow 0,1, 128, or 129 (see below) byte
653 aTab
[ 65] = new Ww1SingleSprm4State(DUMPNAME("sprmCFSmallCaps")); // 65 chp.fSmallCaps 0,1, 128, or 129 (see below) byte
654 aTab
[ 66] = new Ww1SingleSprm4State(DUMPNAME("sprmCFCaps")); // 66 chp.fCaps 0,1, 128, or 129 (see below) byte
655 aTab
[ 67] = new Ww1SingleSprm4State(DUMPNAME("sprmCFVanish")); // 67 chp.fVanish 0,1, 128, or 129 (see below) byte
656 aTab
[ 68] = new Ww1SingleSprmWord(DUMPNAME("sprmCFtc")); // 68 chp.ftc ftc word
657 aTab
[ 69] = new Ww1SingleSprmByte(DUMPNAME("sprmCKul")); // 69 chp.kul kul byte
658 aTab
[ 70] = new Ww1SingleSprm(3, DUMPNAME("sprmCSizePos")); // 70 chp.hps, chp.hpsPos (see below) 3 bytes
659 aTab
[ 71] = new Ww1SingleSprmWord(DUMPNAME("sprmCDxaSpace")); // 71 chp.dxaSpace dxa word
660 aTab
[ 72] = new Ww1SingleSprmWord(DUMPNAME("//")); // 72 //
661 aTab
[ 73] = new Ww1SingleSprmByte(DUMPNAME("sprmCIco")); // 73 chp.ico ico byte
662 aTab
[ 74] = new Ww1SingleSprmByte(DUMPNAME("sprmCHps")); // 74 chp.hps hps !byte!
663 aTab
[ 75] = new Ww1SingleSprmByte(DUMPNAME("sprmCHpsInc")); // 75 chp.hps (see below) byte
664 aTab
[ 76] = new Ww1SingleSprmWord(DUMPNAME("sprmCHpsPos")); // 76 chp.hpsPos hps !word!
665 aTab
[ 77] = new Ww1SingleSprmByte(DUMPNAME("sprmCHpsPosAdj")); // 77 chp.hpsPos hps (see below) byte
666 aTab
[ 78] = new Ww1SingleSprmByteSized(0, DUMPNAME(pUnknown
)); // 78 ?chp.fBold, chp.fItalic, chp.fSmallCaps, ...
668 aTab
[ 94] = new Ww1SingleSprmByte(DUMPNAME("sprmPicBrcl")); // 94 pic.brcl brcl (see PIC structure definition) byte
669 aTab
[ 95] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmPicScale")); // 95 pic.mx, pic.my, pic.dxaCropleft,
671 aTab
[117] = new Ww1SingleSprmByte(DUMPNAME("sprmSBkc")); // 117 sep.bkc bkc byte
672 aTab
[118] = new Ww1SingleSprmBool(DUMPNAME("sprmSFTitlePage")); // 118 sep.fTitlePage 0 or 1 byte
673 aTab
[119] = new Ww1SingleSprmSColumns(DUMPNAME("sprmSCcolumns")); // 119 sep.ccolM1 # of cols - 1 word
674 aTab
[120] = new Ww1SingleSprmWord(DUMPNAME("sprmSDxaColumns")); // 120 sep.dxaColumns dxa word
676 aTab
[122] = new Ww1SingleSprmByte(DUMPNAME("sprmSNfcPgn")); // 122 sep.nfcPgn nfc byte
678 aTab
[125] = new Ww1SingleSprmBool(DUMPNAME("sprmSFPgnRestart")); // 125 sep.fPgnRestart 0 or 1 byte
679 aTab
[126] = new Ww1SingleSprmBool(DUMPNAME("sprmSFEndnote")); // 126 sep.fEndnote 0 or 1 byte
680 aTab
[127] = new Ww1SingleSprmByte(DUMPNAME("sprmSLnc")); // 127 sep.lnc lnc byte
681 aTab
[128] = new Ww1SingleSprmSGprfIhdt(DUMPNAME("sprmSGprfIhdt")); // 128 sep.grpfIhdt grpfihdt (see Headers and Footers topic) byte
682 aTab
[129] = new Ww1SingleSprmWord(DUMPNAME("sprmSNLnnMod")); // 129 sep.nLnnMod non-neg int. word
683 aTab
[130] = new Ww1SingleSprmWord(DUMPNAME("sprmSDxaLnn")); // 130 sep.dxaLnn dxa word
684 aTab
[131] = new Ww1SingleSprmWord(DUMPNAME("sprmSDyaHdrTop")); // 131 sep.dyaHdrTop dya word
685 aTab
[132] = new Ww1SingleSprmWord(DUMPNAME("sprmSDyaHdrBottom")); // 132 sep.dyaHdrBottom dya word
686 aTab
[133] = new Ww1SingleSprmBool(DUMPNAME("sprmSLBetween")); // 133 sep.fLBetween 0 or 1 byte
687 aTab
[134] = new Ww1SingleSprmByte(DUMPNAME("sprmSVjc")); // 134 sep.vjc vjc byte
688 aTab
[135] = new Ww1SingleSprmWord(DUMPNAME("sprmSLnnMin")); // 135 sep.lnnMin lnn word
689 aTab
[136] = new Ww1SingleSprmWord(DUMPNAME("sprmSPgnStart")); // 136 sep.pgnStart pgn word
691 aTab
[146] = new Ww1SingleSprmWord(DUMPNAME("sprmTJc")); // 146 tap.jc jc word (low order byte is significant)
692 aTab
[147] = new Ww1SingleSprmWord(DUMPNAME("sprmTDxaLeft")); // 147 tap.rgdxaCenter (see below) dxa word
693 aTab
[148] = new Ww1SingleSprmWord(DUMPNAME("sprmTDxaGapHalf")); // 148 tap.dxaGapHalf, tap.rgdxaCenter (see below) dxa word
695 aTab
[152] = new Ww1SingleSprmTDefTable10(DUMPNAME("sprmTDefTable10")); // 152 tap.rgdxaCenter, tap.rgtc complex (see below) variable length
696 aTab
[153] = new Ww1SingleSprmWord(DUMPNAME("sprmTDyaRowHeight")); // 153 tap.dyaRowHeight dya word
698 aTab
[158] = new Ww1SingleSprm(4, DUMPNAME("sprmTInsert")); // 158 tap.rgdxaCenter,tap.rgtc complex (see below) 4 bytes
699 aTab
[159] = new Ww1SingleSprmWord(DUMPNAME("sprmTDelete")); // 159 tap.rgdxaCenter, tap.rgtc complex (see below) word
700 aTab
[160] = new Ww1SingleSprm(4, DUMPNAME("sprmTDxaCol")); // 160 tap.rgdxaCenter complex (see below) 4 bytes
701 aTab
[161] = new Ww1SingleSprmWord(DUMPNAME("sprmTMerge")); // 161 tap.fFirstMerged, tap.fMerged complex (see below) word
702 aTab
[162] = new Ww1SingleSprmWord(DUMPNAME("sprmTSplit")); // 162 tap.fFirstMerged, tap.fMerged complex (see below) word
703 aTab
[163] = new Ww1SingleSprm(5, DUMPNAME("sprmTSetBrc10")); // 163 tap.rgtc[].rgbrc complex (see below) 5 bytes
706 ////////////////////////////////////////////////////////////// SprmPapx
707 Ww1SprmPapx::Ww1SprmPapx(sal_uInt8
* pByte
, sal_uInt16 nSize
) :
708 Ww1Sprm(Sprm(pByte
, nSize
), SprmSize(pByte
, nSize
))
710 memset(&aPapx
, 0, sizeof(aPapx
));
711 memcpy(&aPapx
, pByte
, nSize
<sizeof(aPapx
)?nSize
:sizeof(aPapx
));
714 sal_uInt16
Ww1SprmPapx::SprmSize(sal_uInt8
*, sal_uInt16 nSize
)
717 if (nSize
>= sizeof(W1_PAPX
))
718 nRet
= nSize
- ( sizeof(W1_PAPX
) - 1 ); // im W1_PAPX ist das
719 // 1. SprmByte enthalten
723 sal_uInt8
* Ww1SprmPapx::Sprm(sal_uInt8
* pByte
, sal_uInt16 nSize
)
725 sal_uInt8
* pRet
= NULL
;
726 if (nSize
>= sizeof(W1_PAPX
))
727 pRet
= ((W1_PAPX
*)(pByte
))->grpprlGet();
731 /////////////////////////////////////////////////////////////////// Plc
732 Ww1Plc::Ww1Plc(Ww1Fib
& rInFib
, sal_uLong ulFilePos
, sal_uInt16 nInCountBytes
,
733 sal_uInt16 nInItemSize
)
734 : p(0), nCountBytes(nInCountBytes
), iMac(0), nItemSize(nInItemSize
),
735 bOK(false), rFib(rInFib
)
741 if (rFib
.GetStream().Seek(ulFilePos
) == (sal_uLong
)ulFilePos
)
743 if ((p
= new sal_uInt8
[nCountBytes
]) != NULL
)
745 if (rFib
.GetStream().Read(p
, nCountBytes
) == (sal_uLong
)nCountBytes
)
748 iMac
= (nCountBytes
-
749 sizeof(SVBT32
)) / (sizeof(SVBT32
) + nItemSize
);
750 OSL_ENSURE(iMac
* ((sal_uInt16
)sizeof(sal_uLong
) + nItemSize
) +
751 (sal_uInt16
)sizeof(SVBT32
) == nCountBytes
, "Ww1Plc");
763 void Ww1Plc::Seek(sal_uLong ulSeek
, sal_uInt16
& nIndex
)
766 for (;nIndex
<= iMac
&& Where(nIndex
) < ulSeek
;nIndex
++)
770 sal_uLong
Ww1Plc::Where(sal_uInt16 nIndex
)
772 sal_uLong ulRet
= 0xffffffff;
773 OSL_ENSURE(nIndex
<= iMac
, "index out of bounds");
774 if (iMac
&& nIndex
<= iMac
)
775 ulRet
= SVBT32ToUInt32(p
+ sizeof(SVBT32
) * nIndex
);
779 sal_uInt8
* Ww1Plc::GetData(sal_uInt16 nIndex
)
781 sal_uInt8
* pRet
= NULL
;
782 OSL_ENSURE(nIndex
< iMac
, "index out of bounds");
784 pRet
= p
+ (iMac
+ 1) * sizeof(SVBT32
) +
785 nIndex
* nItemSize
; // Pointer auf Inhalts-Array
789 ///////////////////////////////////////////////////////////// PlcBookmarks
790 // class Ww1StringList liest im Ctor eine Anzahl von P-Strings aus dem Stream
791 // in den Speicher und patcht sie zu C-Strings um.
792 // Die Anzahl wird in nMax zurueckgeliefert.
793 // im Index 0 stehen alle Strings nacheinander, ab Index 1 werden
794 // die einzelnen Strings referenziert.
795 Ww1StringList::Ww1StringList( SvStream
& rSt
, sal_uLong nFc
, sal_uInt16 nCb
)
798 if( nCb
> 2 ) // ueberhaupt Eintraege ?
801 OSL_ENSURE(nCb
> sizeof(nCountBytes
), "Ww1StringList");
802 if (rSt
.Seek(nFc
) == (sal_uLong
)nFc
)
803 if (rSt
.Read(nCountBytes
, sizeof(nCountBytes
))
804 == sizeof(nCountBytes
)) // Laenge steht hier nochmal
806 OSL_ENSURE(SVBT16ToShort(nCountBytes
)
807 == nCb
, "redundant-size missmatch");
808 // hoffentlich sind sie immer gleich
809 sal_Char
* pA
= new sal_Char
[nCb
- sizeof(nCountBytes
) + 1];
810 // Alloziere PString-Array
812 if (rSt
.Read(pA
, nCb
- sizeof(nCountBytes
))
813 == (sal_uLong
)nCb
- sizeof(nCountBytes
)) // lese alle
815 // Zaehle, wieviele Fonts enthalten
816 long nLeft
= nCb
- sizeof(nCountBytes
);
826 if(nLeft
< 1) // naechste Laenge muss gelesen werden koennen
832 pIdxA
= new sal_Char
*[nMax
+1]; // alloziere Index-Array
833 pIdxA
[0] = pA
; // Index 0 : alles
834 // ab Index 1 C-Strings
835 pIdxA
[1] = pA
+ 1; // fuelle Index-Array
841 p
+= nL
+ 1; // Neues Laengen-Byte
842 nL
= *p
; // merke Laenge
843 *p
= '\0'; // mach C-String draus
846 pIdxA
[i
] = p
+ 1; // Ptr auf C-String
851 pIdxA
= 0; // Keine Eintraege -> kein Array
855 const String
Ww1StringList::GetStr( sal_uInt16 nNum
) const
859 sRet
= String( pIdxA
[ nNum
+1 ], RTL_TEXTENCODING_MS_1252
);
863 Ww1Bookmarks::Ww1Bookmarks(Ww1Fib
& rInFib
)
864 : aNames(rInFib
), rFib(rInFib
), nIsEnd(0)
866 pPos
[0] = new Ww1PlcBookmarkPos(rFib
, rFib
.GetFIB().fcPlcfbkfGet(),
867 rFib
.GetFIB().cbPlcfbkfGet(), sal_False
);
869 pPos
[1] = new Ww1PlcBookmarkPos(rFib
, rFib
.GetFIB().fcPlcfbklGet(),
870 rFib
.GetFIB().cbPlcfbklGet(), sal_True
);
872 bOK
= !aNames
.GetError() && !pPos
[0]->GetError() && !pPos
[1]->GetError();
875 // Der Operator ++ hat eine Tuecke: Wenn 2 Bookmarks aneinandergrenzen, dann
876 // sollte erst das Ende des ersten und dann der Anfang des 2. erreicht werden.
877 // Liegen jedoch 2 Bookmarks der Laenge 0 aufeinander, *muss* von jedem Bookmark
878 // erst der Anfang und dann das Ende gefunden werden.
882 // ist noch nicht geloest, dabei muesste ich in den Anfangs- und Endindices
883 // vor- und zurueckspringen, wobei ein weiterer Index oder ein Bitfeld
884 // oder etwas aehnliches zum Merken der bereits abgearbeiteten Bookmarks
886 void Ww1Bookmarks::operator++()
892 sal_uLong l0
= pPos
[0]->Where(nPlcIdx
[0]);
893 sal_uLong l1
= pPos
[1]->Where(nPlcIdx
[1]);
899 nIsEnd
= ( nIsEnd
) ? 0 : 1;
903 long Ww1Bookmarks::GetHandle() const
910 const sal_uInt8
* p
= pPos
[0]->GetData( nPlcIdx
[0] );
912 return SVBT16ToShort( p
);
917 long Ww1Bookmarks::Len() const
921 OSL_ENSURE( sal_False
, "Falscher Aufruf (1) von Ww1Bookmarks::Len()" );
924 sal_uInt16 nEndIdx
= SVBT16ToShort(pPos
[0]->GetData(nPlcIdx
[0]));
925 return pPos
[1]->Where(nEndIdx
) - pPos
[0]->Where(nPlcIdx
[0]);
928 const String
Ww1Bookmarks::GetName() const
931 return OUString("???");
932 return aNames
.GetStr( nPlcIdx
[0] );
935 /////////////////////////////////////////////////////////////////// Fkp
936 Ww1Fkp::Ww1Fkp(SvStream
& rStream
, sal_uLong ulFilePos
, sal_uInt16 _nItemSize
) :
937 nItemSize(_nItemSize
),
940 if (rStream
.Seek(ulFilePos
) == (sal_uLong
)ulFilePos
)
941 if (rStream
.Read(aFkp
, sizeof(aFkp
)) == sizeof(aFkp
))
945 sal_uLong
Ww1Fkp::Where(sal_uInt16 nIndex
)
947 sal_uLong lRet
= 0xffffffff;
948 OSL_ENSURE(nIndex
<=Count(), "index out of bounds");
950 lRet
= SVBT32ToUInt32(aFkp
+nIndex
*sizeof(SVBT32
));
954 sal_uInt8
* Ww1Fkp::GetData(sal_uInt16 nIndex
)
956 sal_uInt8
* pRet
= NULL
;
957 OSL_ENSURE(nIndex
<=Count(), "index out of bounds");
959 pRet
= aFkp
+ (Count()+1) * sizeof(SVBT32
) +
960 nIndex
* nItemSize
; // beginn der strukturen
964 //////////////////////////////////////////////////////////////// FkpPap
965 sal_Bool
Ww1FkpPap::Fill(sal_uInt16 nIndex
, sal_uInt8
*& p
, sal_uInt16
& rnCountBytes
)
967 OSL_ENSURE( nIndex
< Count(), "Ww1FkpPap::Fill() Index out of Range" );
968 sal_uInt16 nOffset
= SVBT8ToByte(GetData(nIndex
)) * 2;
971 OSL_ENSURE(nOffset
>(sal_uInt16
)(Count()*sizeof(SVBT32
)), "calc error");
972 rnCountBytes
= SVBT8ToByte(aFkp
+nOffset
) * 2;
973 nOffset
+= sizeof(SVBT8
);
974 if( nOffset
+ rnCountBytes
< 511 ) // SH: Assert schlug 1 zu frueh zu
975 rnCountBytes
++; // SH: Ich weiss nicht genau,
976 // ob das letzte Byte des PAPX
977 // genutzt wird, aber so vergessen
978 // wir keins und sind trotzdem
979 // auf der sicheren Seite
980 OSL_ENSURE(nOffset
+rnCountBytes
<= 511, "calc error");
991 //////////////////////////////////////////////////////////////// FkpChp
992 sal_Bool
Ww1FkpChp::Fill(sal_uInt16 nIndex
, W1_CHP
& aChp
)
994 OSL_ENSURE( nIndex
< Count(), "Ww1FkpChp::Fill() Index out of Range" );
995 memset(&aChp
, 0, sizeof(aChp
)); // Default, da verkuerzt gespeichert
996 sal_uInt16 nOffset
= GetData(nIndex
)[0] * 2;
999 OSL_ENSURE(nOffset
>(sal_uInt16
)(Count()*sizeof(SVBT32
)), "calc error");
1000 sal_uInt16 nCountBytes
= aFkp
[nOffset
];
1001 nOffset
+= sizeof(SVBT8
);
1002 OSL_ENSURE(nCountBytes
<= 511-nOffset
, "calc error");
1003 OSL_ENSURE(nCountBytes
<= sizeof(aChp
), "calc error");
1004 memcpy(&aChp
, aFkp
+nOffset
, nCountBytes
);
1009 ///////////////////////////////////////////////////////////////// Assoc
1010 Ww1Assoc::Ww1Assoc(Ww1Fib
& _rFib
)
1011 : rFib(_rFib
), pBuffer(NULL
), bOK(sal_False
)
1013 sal_uInt16 cb
= rFib
.GetFIB().cbSttbfAssocGet();
1016 for ( i
= 0; i
< MaxFields
; i
++ )
1018 if ((pBuffer
= new sal_Char
[cb
]) != NULL
1019 && rFib
.GetStream().Seek(rFib
.GetFIB().fcSttbfAssocGet()) ==
1020 rFib
.GetFIB().fcSttbfAssocGet()
1021 && rFib
.GetStream().Read(pBuffer
, cb
) == cb
)
1024 OSL_ENSURE( cb
== SVBT16ToShort( *(SVBT16
*)pBuffer
), "size missmatch");
1025 for (i
=0,j
=sizeof(SVBT16
);j
<cb
&& i
<Criteria1
;i
++)
1027 pStrTbl
[i
] = pBuffer
+j
;
1028 j
+= (*pBuffer
+ j
) + 1;
1034 String
Ww1Assoc::GetStr(sal_uInt16 code
)
1037 OSL_ENSURE(code
<MaxFields
, "out of range");
1038 if (pStrTbl
[code
] != NULL
)
1039 for( sal_uInt16 i
=0;i
<pStrTbl
[code
][0];i
++ )
1040 sRet
.append(pStrTbl
[code
][i
+1]);
1041 return OStringToOUString(sRet
.makeStringAndClear(),
1042 RTL_TEXTENCODING_MS_1252
);
1045 /////////////////////////////////////////////////////////////////// Pap
1046 Ww1Pap::Ww1Pap(Ww1Fib
& _rFib
)
1047 : Ww1PlcPap(_rFib
), nPlcIndex(0), nPushedPlcIndex(0xffff), nFkpIndex(0),
1048 nPushedFkpIndex(0xffff), ulOffset(0), pPap(0)
1052 void Ww1Pap::Seek(sal_uLong ulSeek
)
1054 while (ulSeek
> Where())
1058 // SH: Where hat einen Parameter mitbekommen, der sagt, ob bei Neuanlegen eines
1059 // Fkps der zugehoerige Index auf 0 gesetzt werden soll
1060 // ( darf fuer Push/Pop nicht passieren )
1061 // Ein eleganterer Weg faellt mir auf die Schnelle nicht ein
1062 sal_uLong
Ww1Pap::Where( sal_Bool bSetIndex
)
1064 sal_uLong ulRet
= 0xffffffff;
1066 if (nPlcIndex
< Count())
1068 pPap
= new Ww1FkpPap(rFib
.GetStream(),
1069 SVBT16ToShort(GetData(nPlcIndex
)) << 9);
1074 if (nFkpIndex
<= pPap
->Count())
1075 ulRet
= pPap
->Where(nFkpIndex
) - rFib
.GetFIB().fcMinGet();
1079 void Ww1Pap::operator++()
1082 if (++nFkpIndex
> pPap
->Count())
1090 // SH: FindSprm sucht in grpprl nach Sprm nId
1091 // Rueckgabe: Pointer oder 0
1092 sal_Bool
Ww1Pap::FindSprm(sal_uInt16 nId
, sal_uInt8
* pStart
, sal_uInt8
* pEnd
)
1094 Ww1Sprm
aSprm( pStart
, static_cast< sal_uInt16
>(pEnd
-pStart
) );
1095 sal_uInt16 nC
= aSprm
.Count();
1100 for( i
= 0; i
< nC
; i
++ ){
1101 aSprm
.Fill( i
, nI
, nLen
, pData
);
1108 sal_Bool
Ww1Pap::HasId0(sal_uInt16 nId
)
1110 sal_Bool bRet
= sal_False
;
1114 OSL_ENSURE( sal_False
, "Ww1Pap::HasId():: kann kein pPap erzeugen" );
1120 if( pPap
->Fill(nFkpIndex
, pByte
, n
) ){
1121 sal_uInt8
* p2
= ((W1_PAPX
*)(pByte
))->grpprlGet(); // SH: Offset fehlte
1122 bRet
= FindSprm( nId
, p2
, pByte
+ n
);
1127 sal_Bool
Ww1Pap::HasId(sal_uInt16 nId
)
1129 sal_uInt16 nPushedPlcIndex2
= nPlcIndex
;
1130 sal_uInt16 nPushedFkpIndex2
= nFkpIndex
;
1131 sal_Bool bRet
= HasId0( nId
);
1132 if (nPlcIndex
!= nPushedPlcIndex2
)
1137 nPlcIndex
= nPushedPlcIndex2
;
1138 nFkpIndex
= nPushedFkpIndex2
;
1143 /////////////////////////////////////////////////////////////////// Chp
1144 Ww1Chp::Ww1Chp(Ww1Fib
& _rFib
)
1145 : Ww1PlcChp(_rFib
), nPlcIndex(0), nPushedPlcIndex(0xffff), nFkpIndex(0),
1146 nPushedFkpIndex(0xffff), ulOffset(0), pChp(0)
1150 void Ww1Chp::Seek(sal_uLong ulSeek
)
1152 while (ulSeek
> Where())
1156 // SH: Where hat einen Parameter mitbekommen, der sagt, ob bei Neuanlegen eines
1157 // Fkps der zugehoerige Index auf 0 gesetzt werden soll
1158 // ( darf fuer Push/Pop nicht passieren )
1159 // Ein eleganterer Weg faellt mir auf die Schnelle nicht ein
1160 sal_uLong
Ww1Chp::Where( sal_Bool bSetIndex
)
1162 sal_uLong ulRet
= 0xffffffff;
1164 if (nPlcIndex
< Count())
1166 pChp
= new Ww1FkpChp(rFib
.GetStream(),
1167 SVBT16ToShort(GetData(nPlcIndex
)) << 9);
1172 if (nFkpIndex
<= pChp
->Count())
1173 ulRet
= pChp
->Where(nFkpIndex
) -
1174 rFib
.GetFIB().fcMinGet() - ulOffset
;
1178 void Ww1Chp::operator++()
1181 if (++nFkpIndex
> pChp
->Count())
1189 ////////////////////////////////////////////////////////////// Manager
1190 Ww1Manager::Ww1Manager(SvStream
& rStrm
, sal_uLong nFieldFlgs
)
1191 : bOK(sal_False
), bInTtp(false), bInStyle(false), bStopAll(false), aFib(rStrm
),
1192 aDop(aFib
), aFonts(aFib
, nFieldFlgs
), aDoc(aFib
), pDoc(&aDoc
),
1193 ulDocSeek(0), pSeek(&ulDocSeek
), aFld(aFib
), pFld(&aFld
), aChp(aFib
),
1194 aPap(aFib
), aFtn(aFib
), aBooks(aFib
),
1195 aSep(aFib
, aDop
.GetDOP().grpfIhdtGet())
1197 bOK
= !aFib
.GetError()
1198 && !aFib
.GetFIB().fComplexGet()
1205 && !aBooks
.GetError();
1208 sal_Bool
Ww1Manager::HasInTable()
1210 return aPap
.HasId(24); // Ww1SingleSprmPFInTable
1213 sal_Bool
Ww1Manager::HasTtp()
1215 return aPap
.HasId(25); // Ww1SingleSprmPTtp
1218 sal_Bool
Ww1Manager::HasPPc()
1220 return aPap
.HasId(29); // Ww1SingleSprmPPc
1223 sal_Bool
Ww1Manager::HasPDxaAbs()
1225 return aPap
.HasId(26); // Ww1SingleSprmPDxaAbs
1228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */