Lines 815-821
Link Here
|
815 |
SprmInfo wwSprmParser::GetSprmInfo(sal_uInt16 nId) const |
815 |
SprmInfo wwSprmParser::GetSprmInfo(sal_uInt16 nId) const |
816 |
{ |
816 |
{ |
817 |
// Find sprm |
817 |
// Find sprm |
818 |
SprmInfo aSrch={0}; |
818 |
SprmInfo aSrch={0,0,0}; |
819 |
aSrch.nId = nId; |
819 |
aSrch.nId = nId; |
820 |
const SprmInfo* pFound = mpKnownSprms->search(aSrch); |
820 |
const SprmInfo* pFound = mpKnownSprms->search(aSrch); |
821 |
if (pFound == 0) |
821 |
if (pFound == 0) |
Lines 2234-2241
Link Here
|
2234 |
|
2234 |
|
2235 |
// Ctor fuer *andere* als Fkps |
2235 |
// Ctor fuer *andere* als Fkps |
2236 |
// Bei nStartPos < 0 wird das erste Element des PLCFs genommen |
2236 |
// Bei nStartPos < 0 wird das erste Element des PLCFs genommen |
2237 |
WW8PLCF::WW8PLCF( SvStream* pSt, long nFilePos, long nPLCF, long nStruct, |
2237 |
WW8PLCF::WW8PLCF( SvStream* pSt, WW8_FC nFilePos, INT32 nPLCF, int nStruct, |
2238 |
long nStartPos ) :nIdx( 0 ), nStru( nStruct ) |
2238 |
WW8_CP nStartPos ) : pPLCF_PosArray(0), nIdx(0), nStru(nStruct) |
2239 |
{ |
2239 |
{ |
2240 |
ASSERT( nPLCF, "WW8PLCF: nPLCF ist Null!" ); |
2240 |
ASSERT( nPLCF, "WW8PLCF: nPLCF ist Null!" ); |
2241 |
|
2241 |
|
Lines 2252-2263
Link Here
|
2252 |
// != 0, dann wird ein unvollstaendiger PLCF vervollstaendigt. Das ist bei |
2252 |
// != 0, dann wird ein unvollstaendiger PLCF vervollstaendigt. Das ist bei |
2253 |
// WW6 bei Resourcenmangel und bei WordPad (W95) immer noetig. Bei nStartPos |
2253 |
// WW6 bei Resourcenmangel und bei WordPad (W95) immer noetig. Bei nStartPos |
2254 |
// < 0 wird das erste Element des PLCFs genommen |
2254 |
// < 0 wird das erste Element des PLCFs genommen |
2255 |
WW8PLCF::WW8PLCF( SvStream* pSt, long nFilePos, long nPLCF, long nStruct, |
2255 |
WW8PLCF::WW8PLCF( SvStream* pSt, WW8_FC nFilePos, INT32 nPLCF, int nStruct, |
2256 |
long nStartPos, long nPN, long ncpN ) :nIdx( 0 ), nStru( nStruct ) |
2256 |
WW8_CP nStartPos, INT32 nPN, INT32 ncpN ) : pPLCF_PosArray(0), nIdx(0), |
|
|
2257 |
nStru(nStruct) |
2257 |
{ |
2258 |
{ |
2258 |
nIMax = ( nPLCF - 4 ) / ( 4 + nStruct ); |
2259 |
nIMax = ( nPLCF - 4 ) / ( 4 + nStruct ); |
2259 |
|
2260 |
|
2260 |
if( nIMax >= (long) ncpN ) |
2261 |
if( nIMax >= ncpN ) |
2261 |
ReadPLCF( pSt, nFilePos, nPLCF ); |
2262 |
ReadPLCF( pSt, nFilePos, nPLCF ); |
2262 |
else |
2263 |
else |
2263 |
GeneratePLCF( pSt, nPN, ncpN ); |
2264 |
GeneratePLCF( pSt, nPN, ncpN ); |
Lines 2266-2277
Link Here
|
2266 |
SeekPos( nStartPos ); |
2267 |
SeekPos( nStartPos ); |
2267 |
} |
2268 |
} |
2268 |
|
2269 |
|
2269 |
void WW8PLCF::ReadPLCF( SvStream* pSt, long nFilePos, long nPLCF ) |
2270 |
void WW8PLCF::ReadPLCF( SvStream* pSt, WW8_FC nFilePos, INT32 nPLCF ) |
2270 |
{ |
2271 |
{ |
2271 |
// Pointer auf Pos-Array |
2272 |
// Pointer auf Pos-Array |
2272 |
pPLCF_PosArray = new INT32[ ( nPLCF + 3 ) / 4 ]; |
2273 |
pPLCF_PosArray = new WW8_CP[ ( nPLCF + 3 ) / 4 ]; |
2273 |
|
2274 |
|
2274 |
long nOldPos = pSt->Tell(); |
2275 |
sal_Size nOldPos = pSt->Tell(); |
2275 |
|
2276 |
|
2276 |
pSt->Seek( nFilePos ); |
2277 |
pSt->Seek( nFilePos ); |
2277 |
pSt->Read( pPLCF_PosArray, nPLCF ); |
2278 |
pSt->Read( pPLCF_PosArray, nPLCF ); |
Lines 2286-2332
Link Here
|
2286 |
pSt->Seek( nOldPos ); |
2287 |
pSt->Seek( nOldPos ); |
2287 |
} |
2288 |
} |
2288 |
|
2289 |
|
2289 |
void WW8PLCF::GeneratePLCF( SvStream* pSt, long nPN, long ncpN ) |
2290 |
void WW8PLCF::GeneratePLCF( SvStream* pSt, INT32 nPN, INT32 ncpN ) |
2290 |
{ |
2291 |
{ |
2291 |
ASSERT(!this, "Not a bug, but I (cmc) want to see this .doc as an example"); |
2292 |
ASSERT( nIMax < ncpN, "Pcl.Fkp: Warum ist PLCF zu gross ?" ); |
2292 |
ASSERT( nIMax < (long)ncpN, "Pcl.Fkp: Warum ist PLCF zu gross ?" ); |
2293 |
|
|
|
2294 |
bool failure = false; |
2293 |
nIMax = ncpN; |
2295 |
nIMax = ncpN; |
2294 |
long nSiz = 6 * nIMax + 4; |
|
|
2295 |
pPLCF_PosArray = new INT32[ ( nSiz + 3 ) / 4 ]; // Pointer auf Pos-Array |
2296 |
memset( pPLCF_PosArray, 0, (size_t)nSiz ); |
2297 |
|
2296 |
|
2298 |
INT32 nFc; |
2297 |
if ((nIMax < 1) || (nIMax > (WW8_CP_MAX - 4)/6) || ((nPN + ncpN) > USHRT_MAX)) |
2299 |
USHORT i; |
2298 |
failure = true; |
|
|
2299 |
|
2300 |
if (!failure) |
2301 |
{ |
2302 |
size_t nSiz = 6 * nIMax + 4; |
2303 |
size_t nElems = ( nSiz + 3 ) / 4; |
2304 |
pPLCF_PosArray = new INT32[ nElems ]; // Pointer auf Pos-Array |
2305 |
|
2306 |
for (INT32 i = 0; i < ncpN && !pSt->GetError(); ++i) |
2307 |
{ |
2308 |
// Baue FC-Eintraege |
2309 |
pSt->Seek( ( nPN + i ) << 9 ); // erster FC-Eintrag jedes Fkp |
2310 |
WW8_CP nFc; |
2311 |
*pSt >> nFc; |
2312 |
pPLCF_PosArray[i] = nFc; |
2313 |
} |
2314 |
|
2315 |
failure = pSt->GetError(); |
2316 |
} |
2300 |
|
2317 |
|
2301 |
for (i = 0; i < ncpN; ++i) |
2318 |
if (!failure) |
2302 |
{ |
2319 |
{ |
2303 |
// Baue FC-Eintraege |
2320 |
sal_Size nLastFkpPos = ( ( nPN + nIMax - 1 ) << 9 ); |
2304 |
pSt->Seek( ( nPN + i ) << 9 ); // erster FC-Eintrag jedes Fkp |
2321 |
pSt->Seek( nLastFkpPos + 511 ); // Anz. Fkp-Eintraege des letzten Fkp |
|
|
2322 |
|
2323 |
BYTE nb; |
2324 |
*pSt >> nb; |
2325 |
pSt->Seek( nLastFkpPos + nb * 4 ); // letzer FC-Eintrag des letzten Fkp |
2326 |
|
2327 |
WW8_CP nFc; |
2305 |
*pSt >> nFc; |
2328 |
*pSt >> nFc; |
2306 |
pPLCF_PosArray[i] = nFc; |
2329 |
pPLCF_PosArray[nIMax] = nFc; // Ende des letzten Fkp |
|
|
2330 |
|
2331 |
failure = pSt->GetError(); |
2307 |
} |
2332 |
} |
2308 |
ULONG nLastFkpPos = ( ( nPN + nIMax - 1 ) << 9 ); |
|
|
2309 |
pSt->Seek( nLastFkpPos + 511 ); // Anz. Fkp-Eintraege des letzten Fkp |
2310 |
BYTE nb; |
2311 |
*pSt >> nb; |
2312 |
pSt->Seek( nLastFkpPos + nb * 4 ); // letzer FC-Eintrag des letzten Fkp |
2313 |
*pSt >> nFc; |
2314 |
pPLCF_PosArray[nIMax] = nFc; // Ende des letzten Fkp |
2315 |
|
2333 |
|
2316 |
// Pointer auf Inhalts-Array |
2334 |
if (!failure) |
2317 |
pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; |
2335 |
{ |
2318 |
BYTE* p = pPLCF_Contents; |
2336 |
// Pointer auf Inhalts-Array |
|
|
2337 |
pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; |
2338 |
BYTE* p = pPLCF_Contents; |
2339 |
|
2340 |
for (INT32 i = 0; i < ncpN; ++i) // Baue PNs |
2341 |
{ |
2342 |
ShortToSVBT16(static_cast<sal_uInt16>(nPN + i), p); |
2343 |
p+=2; |
2344 |
} |
2345 |
} |
2319 |
|
2346 |
|
2320 |
for (i = 0; i < ncpN; ++i) // Baue PNs |
2347 |
ASSERT( !failure, "Document has corrupt PLCF, ignoring it" ); |
|
|
2348 |
|
2349 |
if (failure) |
2321 |
{ |
2350 |
{ |
2322 |
ShortToSVBT16(static_cast<sal_uInt16>(nPN + i), p); |
2351 |
nIMax = 0; |
2323 |
p+=2; |
2352 |
delete[] pPLCF_PosArray; |
|
|
2353 |
pPLCF_PosArray = new INT32[2]; |
2354 |
pPLCF_PosArray[0] = pPLCF_PosArray[1] = WW8_CP_MAX; |
2355 |
pPLCF_Contents = (BYTE*)&pPLCF_PosArray[nIMax + 1]; |
2324 |
} |
2356 |
} |
2325 |
} |
2357 |
} |
2326 |
|
2358 |
|
2327 |
bool WW8PLCF::SeekPos(long nPos) |
2359 |
bool WW8PLCF::SeekPos(WW8_CP nPos) |
2328 |
{ |
2360 |
{ |
2329 |
long nP = nPos; |
2361 |
WW8_CP nP = nPos; |
2330 |
|
2362 |
|
2331 |
if( nP < pPLCF_PosArray[0] ) |
2363 |
if( nP < pPLCF_PosArray[0] ) |
2332 |
{ |
2364 |
{ |
Lines 2339-2346
Link Here
|
2339 |
if( (1 > nIdx) || (nP < pPLCF_PosArray[ nIdx-1 ]) ) |
2371 |
if( (1 > nIdx) || (nP < pPLCF_PosArray[ nIdx-1 ]) ) |
2340 |
nIdx = 1; |
2372 |
nIdx = 1; |
2341 |
|
2373 |
|
2342 |
long nI = nIdx ? nIdx : 1; |
2374 |
INT32 nI = nIdx ? nIdx : 1; |
2343 |
long nEnd = nIMax; |
2375 |
INT32 nEnd = nIMax; |
2344 |
|
2376 |
|
2345 |
for(int n = (1==nIdx ? 1 : 2); n; --n ) |
2377 |
for(int n = (1==nIdx ? 1 : 2); n; --n ) |
2346 |
{ |
2378 |
{ |
Lines 2373-2382
Link Here
|
2373 |
return true; |
2405 |
return true; |
2374 |
} |
2406 |
} |
2375 |
|
2407 |
|
2376 |
INT32 WW8PLCF::Where() const |
2408 |
WW8_CP WW8PLCF::Where() const |
2377 |
{ |
2409 |
{ |
2378 |
if ( nIdx >= nIMax ) |
2410 |
if ( nIdx >= nIMax ) |
2379 |
return SAL_MAX_INT32; |
2411 |
return WW8_CP_MAX; |
2380 |
|
2412 |
|
2381 |
return pPLCF_PosArray[nIdx]; |
2413 |
return pPLCF_PosArray[nIdx]; |
2382 |
} |
2414 |
} |
Lines 3842-3854
Link Here
|
3842 |
{ |
3874 |
{ |
3843 |
ww::bytes extraData; |
3875 |
ww::bytes extraData; |
3844 |
sal_uInt8 iTmp; |
3876 |
sal_uInt8 iTmp; |
3845 |
for(int i =0;i < nExtraLen;i++) |
3877 |
for(int j = 0; j < nExtraLen; ++j) |
3846 |
{ |
3878 |
{ |
3847 |
rStrm >> iTmp; |
3879 |
rStrm >> iTmp; |
3848 |
extraData.push_back(iTmp); |
3880 |
extraData.push_back(iTmp); |
3849 |
} |
3881 |
} |
3850 |
pExtraArray->push_back(extraData); |
3882 |
pExtraArray->push_back(extraData); |
3851 |
int kSize = extraData.size(); |
|
|
3852 |
} |
3883 |
} |
3853 |
else |
3884 |
else |
3854 |
rStrm.SeekRel( nExtraLen ); |
3885 |
rStrm.SeekRel( nExtraLen ); |