diff options
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.hxx | 6 | ||||
-rw-r--r-- | tools/inc/tools/stream.hxx | 11 | ||||
-rw-r--r-- | vcl/source/gdi/metaact.cxx | 50 |
4 files changed, 20 insertions, 54 deletions
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 57e42db1f0f0..aadaa68e6593 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -1910,13 +1910,6 @@ Err: return false; } -String read_uInt16_PascalString(SvStream& rStrm) -{ - sal_uInt16 nLen(0); - rStrm >> nLen; - return read_uInt16s_ToOUString(rStrm, nLen); -} - String read_uInt8_BeltAndBracesString(SvStream& rStrm, rtl_TextEncoding eEnc) { rtl::OUString aRet = read_lenPrefixed_uInt8s_ToOUString<sal_uInt8>(rStrm, eEnc); diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index d4012d486fdb..b3a85ed71545 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -139,7 +139,11 @@ inline String read_uInt8_PascalString(SvStream& rStrm, rtl_TextEncoding eEnc) { return read_lenPrefixed_uInt8s_ToOUString<sal_uInt8>(rStrm, eEnc); } -String read_uInt16_PascalString(SvStream& rStrm); + +inline String read_uInt16_PascalString(SvStream& rStrm) +{ + return read_lenPrefixed_uInt16s_ToOUString<sal_uInt16>(rStrm); +} //Belt and Braces strings, i.e. Pascal-style strings followed by //null termination, Spolsky calls them "fucked strings" FWIW diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx index 78f84fc2f7ba..0e1c6f77e21c 100644 --- a/tools/inc/tools/stream.hxx +++ b/tools/inc/tools/stream.hxx @@ -504,6 +504,17 @@ TOOLS_DLLPUBLIC inline rtl::OUString read_uInt8s_ToOUString(SvStream& rStrm, TOOLS_DLLPUBLIC rtl::OUString read_uInt16s_ToOUString(SvStream& rStrm, sal_Size nUnits); +//Attempt to read a pascal-style length (of type prefix) prefixed sequence of +//16bit units to an OUString, returned rtl::OString's length is number of units +//successfully read. +template<typename prefix> +rtl::OUString read_lenPrefixed_uInt16s_ToOUString(SvStream& rStrm) +{ + prefix nUnits = 0; + rStrm >> nUnits; + return read_uInt16s_ToOUString(rStrm, nUnits); +} + //Attempt to read 8bit units to an OString until a zero terminator is //encountered, returned rtl::OString's length is number of units *definitely* //successfully read, check SvStream::good() to see if null terminator was diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 12113b7ec014..2d0c94c479ec 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -1283,18 +1283,7 @@ void MetaTextAction::Read( SvStream& rIStm, ImplMetaReadData* pData ) rIStm >> mnLen; if ( aCompat.GetVersion() >= 2 ) // Version 2 - { - sal_uInt16 nLen(0); - rIStm >> nLen; - rtl::OUStringBuffer aBuffer(nLen); - while ( nLen-- ) - { - sal_uInt16 nChar; - rIStm >> nChar; - aBuffer.append(nChar); - } - maStr = aBuffer.makeStringAndClear(); - } + maStr = read_lenPrefixed_uInt16s_ToOUString<sal_uInt16>(rIStm); } // ======================================================================== @@ -1480,16 +1469,7 @@ void MetaTextArrayAction::Read( SvStream& rIStm, ImplMetaReadData* pData ) if ( aCompat.GetVersion() >= 2 ) // Version 2 { - sal_uInt16 nLen(0); - rIStm >> nLen; - rtl::OUStringBuffer aBuffer(nLen); - while ( nLen-- ) - { - sal_uInt16 nChar; - rIStm >> nChar; - aBuffer.append(nChar); - } - maStr = aBuffer.makeStringAndClear(); + maStr = read_lenPrefixed_uInt16s_ToOUString<sal_uInt16>(rIStm); if ( mnIndex + mnLen > maStr.getLength() ) { @@ -1591,18 +1571,7 @@ void MetaStretchTextAction::Read( SvStream& rIStm, ImplMetaReadData* pData ) rIStm >> mnLen; if ( aCompat.GetVersion() >= 2 ) // Version 2 - { - sal_uInt16 nLen(0); - rIStm >> nLen; - rtl::OUStringBuffer aBuffer(nLen); - while ( nLen-- ) - { - sal_uInt16 nChar; - rIStm >> nChar; - aBuffer.append(nChar); - } - maStr = aBuffer.makeStringAndClear(); - } + maStr = read_lenPrefixed_uInt16s_ToOUString<sal_uInt16>(rIStm); } // ======================================================================== @@ -1687,18 +1656,7 @@ void MetaTextRectAction::Read( SvStream& rIStm, ImplMetaReadData* pData ) rIStm >> mnStyle; if ( aCompat.GetVersion() >= 2 ) // Version 2 - { - sal_uInt16 nLen(0); - rIStm >> nLen; - rtl::OUStringBuffer aBuffer(nLen); - while ( nLen-- ) - { - sal_uInt16 nChar; - rIStm >> nChar; - aBuffer.append(nChar); - } - maStr = aBuffer.makeStringAndClear(); - } + maStr = read_lenPrefixed_uInt16s_ToOUString<sal_uInt16>(rIStm); } // ======================================================================== |