diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index babb3319c364..8b32b9906372 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -77,26 +77,37 @@ namespace SL IMPLCONSTSTRINGARRAY(MSMacroCmds); } -template bool wwString::TestBeltAndBraces(SvStream& rStrm) +namespace { - bool bRet = false; - sal_uInt32 nOldPos = rStrm.Tell(); - C nBelt(0); - rStrm >> nBelt; - nBelt *= sizeof(C); - if (rStrm.good() && (rStrm.remainingSize() >= (nBelt + sizeof(C)))) + /** + winword strings are typically Belt and Braces strings preceeded with a + pascal style count, and ending with a c style 0 terminator. 16bit chars + and count for ww8+ and 8bit chars and count for ww7-. The count and 0 + can be checked for integrity to catch errors (e.g. lotus created + documents) where in error 8bit strings are used instead of 16bits + strings for style names. + */ + template bool TestBeltAndBraces(SvStream& rStrm) { - rStrm.SeekRel(nBelt); - if (rStrm.good()) + bool bRet = false; + sal_uInt32 nOldPos = rStrm.Tell(); + C nBelt(0); + rStrm >> nBelt; + nBelt *= sizeof(C); + if (rStrm.good() && (rStrm.remainingSize() >= (nBelt + sizeof(C)))) { - C cBraces(0); - rStrm >> cBraces; - if (rStrm.good() && cBraces == 0) - bRet = true; + rStrm.SeekRel(nBelt); + if (rStrm.good()) + { + C cBraces(0); + rStrm >> cBraces; + if (rStrm.good() && cBraces == 0) + bRet = true; + } } + rStrm.Seek(nOldPos); + return bRet; } - rStrm.Seek(nOldPos); - return bRet; } inline bool operator==(const SprmInfo &rFirst, const SprmInfo &rSecond) @@ -6146,7 +6157,7 @@ WW8_STD* WW8Style::Read1Style( short& rSkip, String* pString, short* pcbStd ) case 8: // handle Unicode-String with leading length short and // trailing zero - if (ww8String::TestBeltAndBraces(rSt)) + if (TestBeltAndBraces(rSt)) { *pString = read_LEuInt16_BeltAndBracesString(rSt); rSkip -= (pString->Len() + 2) * 2; diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index 7d732c81b4e7..a323b84bae6e 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -72,22 +72,6 @@ namespace SL DEFCONSTSTRINGARRAY(MSMacroCmds); } -/** - winword strings are typically Belt and Braces strings preceeded with a - pascal style count, and ending with a c style 0 terminator. 16bit chars - and count for ww8+ and 8bit chars and count for ww7-. The count and 0 - can be checked for integrity to catch errors (e.g. lotus created documents) - where in error 8bit strings are used instead of 16bits strings for style - names. -*/ -template class wwString -{ -public: - static bool TestBeltAndBraces(SvStream& rStrm); -}; - -typedef wwString ww8String; - struct SprmInfo { sal_uInt16 nId; ///< A ww8 sprm is hardcoded as 16bits @@ -98,9 +82,9 @@ struct SprmInfo struct SprmInfoHash { size_t operator()(const SprmInfo &a) const - { - return a.nId; - } + { + return a.nId; + } }; typedef ww::WrappedHash wwSprmSearcher;