diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-07-15 23:52:01 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-07-18 12:22:55 +0100 |
commit | b7aae6df48abf695bbf9068fc6639f9f78aa3ff2 (patch) | |
tree | 28bd313cb6e6212f030e7fcb1d2fb230bab6710e | |
parent | a2dc470f1bd045028b020c9a743d881165491aff (diff) |
if the offset doesn't exist, don't bother
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 182 |
1 files changed, 93 insertions, 89 deletions
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 60e1bcda86..09608bd54d 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -3853,122 +3853,126 @@ void 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) { - if(nLen==0) // Handle Empty STTBF + if (nLen==0) // Handle Empty STTBF return; - sal_uLong nOldPos = rStrm.Tell(); - rStrm.Seek( nStart ); - - sal_uInt16 nLen2; - rStrm >> nLen2; // bVer67: total length of structure - // bVer8 : count of strings - - if( bVer8 ) + sal_Size nOldPos = rStrm.Tell(); + if (checkSeek(rStrm, nStart)) { - sal_uInt16 nStrings; - bool bUnicode = (0xFFFF == nLen2); - if( bUnicode ) - rStrm >> nStrings; - else - nStrings = nLen2; - - rStrm >> nExtraLen; + sal_uInt16 nLen2(0); + rStrm >> nLen2; // bVer67: total length of structure + // bVer8 : count of strings - for( sal_uInt16 i=0; i < nStrings; i++ ) + if( bVer8 ) { - if( bUnicode ) - rArray.push_back(WW8Read_xstz(rStrm, 0, false)); + sal_uInt16 nStrings(0); + bool bUnicode = (0xFFFF == nLen2); + if (bUnicode) + rStrm >> nStrings; else - { - sal_uInt8 nBChar; - rStrm >> nBChar; - ByteString aTmp; - SafeReadString(aTmp,nBChar,rStrm); - rArray.push_back(String(aTmp, eCS)); - } + nStrings = nLen2; + + rStrm >> nExtraLen; - // Skip the extra data - if( nExtraLen ) + for (sal_uInt16 i=0; i < nStrings; ++i) { - if (pExtraArray) + if (bUnicode) + rArray.push_back(WW8Read_xstz(rStrm, 0, false)); + else + { + sal_uInt8 nBChar(0); + rStrm >> nBChar; + ByteString aTmp; + SafeReadString(aTmp,nBChar,rStrm); + rArray.push_back(String(aTmp, eCS)); + } + + // Skip the extra data + if (nExtraLen) { - ww::bytes extraData; - sal_uInt8 iTmp; - for(int j = 0; j < nExtraLen; ++j) + if (pExtraArray) { - rStrm >> iTmp; - extraData.push_back(iTmp); + ww::bytes extraData; + for (sal_uInt16 j = 0; j < nExtraLen; ++j) + { + sal_uInt8 iTmp(0); + rStrm >> iTmp; + extraData.push_back(iTmp); + } + pExtraArray->push_back(extraData); } - pExtraArray->push_back(extraData); + else + rStrm.SeekRel( nExtraLen ); } - else - rStrm.SeekRel( nExtraLen ); } - } - // read the value of the document variables, if requested. - if (pValueArray) - { - for( sal_uInt16 i=0; i < nStrings; i++ ) + // read the value of the document variables, if requested. + if (pValueArray) + { + for (sal_uInt16 i=0; i < nStrings; ++i) { - if( bUnicode ) - pValueArray->push_back(WW8Read_xstz(rStrm, 0, false)); - else - { - sal_uInt8 nBChar; - rStrm >> nBChar; - ByteString aTmp; - SafeReadString(aTmp,nBChar,rStrm); - pValueArray->push_back(String(aTmp, eCS)); - } + if( bUnicode ) + pValueArray->push_back(WW8Read_xstz(rStrm, 0, false)); + else + { + sal_uInt8 nBChar(0); + rStrm >> nBChar; + ByteString aTmp; + SafeReadString(aTmp,nBChar,rStrm); + pValueArray->push_back(String(aTmp, eCS)); + } } + } } - } - else - { - sal_uInt8 nBChar; - if( nLen2 != nLen ) - { - OSL_ENSURE( nLen2 == nLen, "Fib length and read length are different" ); - if (nLen > USHRT_MAX) - nLen = USHRT_MAX; - else if (nLen < 2 ) - nLen = 2; - nLen2 = static_cast<sal_uInt16>(nLen); - } - sal_uLong nRead = 0; - for( nLen2 -= 2; nRead < nLen2; ) + else { - rStrm >> nBChar; ++nRead; - if (nBChar) + if( nLen2 != nLen ) { - ByteString aTmp; - nRead += SafeReadString(aTmp,nBChar,rStrm); - rArray.push_back(String(aTmp, eCS)); + OSL_ENSURE(nLen2 == nLen, + "Fib length and read length are different"); + if (nLen > USHRT_MAX) + nLen = USHRT_MAX; + else if (nLen < 2 ) + nLen = 2; + nLen2 = static_cast<sal_uInt16>(nLen); } - else - rArray.push_back(aEmptyStr); - - // Skip the extra data (for bVer67 versions this must come from external knowledge) - if (nExtraLen) + sal_uLong nRead = 0; + for( nLen2 -= 2; nRead < nLen2; ) { - if (pExtraArray) + sal_uInt8 nBChar(0); + rStrm >> nBChar; + ++nRead; + if (nBChar) { - ww::bytes extraData; - for(int i =0;i < nExtraLen;i++) + ByteString aTmp; + nRead += SafeReadString(aTmp,nBChar,rStrm); + rArray.push_back(String(aTmp, eCS)); + } + else + rArray.push_back(aEmptyStr); + + // Skip the extra data (for bVer67 versions this must come from + // external knowledge) + if (nExtraLen) + { + if (pExtraArray) { - sal_uInt8 iTmp; - rStrm >> iTmp; - extraData.push_back(iTmp); + ww::bytes extraData; + for (sal_uInt16 i=0;i < nExtraLen;++i) + { + sal_uInt8 iTmp(0); + rStrm >> iTmp; + extraData.push_back(iTmp); + } + pExtraArray->push_back(extraData); } - pExtraArray->push_back(extraData); + else + rStrm.SeekRel( nExtraLen ); + nRead+=nExtraLen; } - else - rStrm.SeekRel( nExtraLen ); - nRead+=nExtraLen; } } } - rStrm.Seek( nOldPos ); + rStrm.Seek(nOldPos); } WW8PLCFx_Book::WW8PLCFx_Book(SvStream* pTblSt, const WW8Fib& rFib) |