summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tools/stream.hxx20
-rw-r--r--sw/source/filter/ww8/ww8par.cxx66
-rw-r--r--sw/source/filter/ww8/ww8par.hxx3
3 files changed, 33 insertions, 56 deletions
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index ef7091e98eba..f78e8afc5e7f 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -498,30 +498,42 @@ TOOLS_DLLPUBLIC OUString read_zeroTerminated_uInt8s_ToOUString(SvStream& rStrm,
/// Attempt to read a pascal-style length (of type prefix) prefixed sequence of
/// 8bit units to an OString, returned OString's length is number of units
/// successfully read.
+inline OString read_uInt32_lenPrefixed_uInt8s_ToOString(SvStream& rStrm)
+{
+ sal_uInt32 nUnits = 0;
+ rStrm.ReadUInt32(nUnits);
+ return read_uInt8s_ToOString(rStrm, nUnits);
+}
inline OString read_uInt16_lenPrefixed_uInt8s_ToOString(SvStream& rStrm)
{
sal_uInt16 nUnits = 0;
- rStrm.ReadUInt16( nUnits );
+ rStrm.ReadUInt16(nUnits);
return read_uInt8s_ToOString(rStrm, nUnits);
}
inline OString read_uInt8_lenPrefixed_uInt8s_ToOString(SvStream& rStrm)
{
sal_uInt8 nUnits = 0;
- rStrm.ReadUChar( nUnits );
+ rStrm.ReadUChar(nUnits);
return read_uInt8s_ToOString(rStrm, nUnits);
}
/// Attempt to read a pascal-style length (of type prefix) prefixed sequence of
/// 8bit units to an OUString
+inline OUString read_uInt32_lenPrefixed_uInt8s_ToOUString(SvStream& rStrm,
+ rtl_TextEncoding eEnc)
+{
+ return OStringToOUString(read_uInt32_lenPrefixed_uInt8s_ToOString(rStrm), eEnc);
+}
+
inline OUString read_uInt16_lenPrefixed_uInt8s_ToOUString(SvStream& rStrm,
- rtl_TextEncoding eEnc)
+ rtl_TextEncoding eEnc)
{
return OStringToOUString(read_uInt16_lenPrefixed_uInt8s_ToOString(rStrm), eEnc);
}
inline OUString read_uInt8_lenPrefixed_uInt8s_ToOUString(SvStream& rStrm,
- rtl_TextEncoding eEnc)
+ rtl_TextEncoding eEnc)
{
return OStringToOUString(read_uInt8_lenPrefixed_uInt8s_ToOString(rStrm), eEnc);
}
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 553ba5e58bd3..831082c032a3 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -203,53 +203,19 @@ void lclGetAbsPath(OUString& rPath, sal_uInt16 nLevel, SwDocShell* pDocShell)
}
}
-void lclIgnoreString32( SvMemoryStream& rStrm, bool b16Bit )
-{
- sal_uInt32 nChars(0);
- rStrm.ReadUInt32( nChars );
- if( b16Bit )
- nChars *= 2;
- rStrm.SeekRel( nChars );
-}
-
-OUString SwWW8ImplReader::ReadRawUniString(SvMemoryStream& rStrm, sal_uInt16 nChars, bool b16Bit)
+namespace
{
- OUStringBuffer aBuf(nChars);
- if( b16Bit )
+ void lclIgnoreString32(SvStream& rStrm, bool b16Bit)
{
- sal_uInt16 nReadChar;
- for( sal_uInt16 i = 0; i < nChars; ++i)
- {
- rStrm.ReadUInt16( nReadChar );
- aBuf.append(static_cast< sal_Unicode >( nReadChar ));
- }
+ sal_uInt32 nChars(0);
+ rStrm.ReadUInt32(nChars);
+ if (b16Bit)
+ nChars *= 2;
+ rStrm.SeekRel(nChars);
}
- else
- {
- sal_uInt8 nReadChar;
- for( sal_uInt16 i = 0; i < nChars; ++i)
- {
- rStrm.ReadUChar( nReadChar ) ;
- aBuf.append(static_cast< sal_Unicode >( nReadChar ));
- }
- }
- return aBuf.makeStringAndClear();
-}
-
-OUString lclGetString32(SvMemoryStream& rStrm, sal_uInt32 nChars, bool b16Bit)
-{
- sal_uInt16 nReadChars = ulimit_cast< sal_uInt16 >( nChars );
- return SwWW8ImplReader::ReadRawUniString( rStrm, nReadChars, b16Bit );
-}
-
-OUString lclGetString32(SvMemoryStream& rStrm, bool b16Bit)
-{
- sal_uInt32 nValue(0);
- rStrm.ReadUInt32( nValue );
- return lclGetString32(rStrm, nValue, b16Bit);
}
-void SwWW8ImplReader::ReadEmbeddedData( SvMemoryStream& rStrm, SwDocShell* pDocShell, struct HyperLinksTable& hlStr)
+void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell* pDocShell, struct HyperLinksTable& hlStr)
{
// (0x01B8) HLINK
// const sal_uInt16 WW8_ID_HLINK = 0x01B8;
@@ -288,13 +254,13 @@ void SwWW8ImplReader::ReadEmbeddedData( SvMemoryStream& rStrm, SwDocShell* pDocS
// target frame
if( ::get_flag( nFlags, WW8_HLINK_FRAME ) )
{
- hlStr.tarFrame = lclGetString32(rStrm, true);
+ hlStr.tarFrame = read_uInt32_lenPrefixed_uInt16s_ToOUString(rStrm);
}
// UNC path
if( ::get_flag( nFlags, WW8_HLINK_UNC ) )
{
- xLongName.reset( new OUString(lclGetString32(rStrm, true)) );
+ xLongName.reset(new OUString(read_uInt32_lenPrefixed_uInt16s_ToOUString(rStrm)));
lclGetAbsPath( *xLongName, 0 , pDocShell);
}
// file link or URL
@@ -305,7 +271,7 @@ void SwWW8ImplReader::ReadEmbeddedData( SvMemoryStream& rStrm, SwDocShell* pDocS
if( (memcmp(aGuid, aGuidFileMoniker, 16) == 0) )
{
rStrm.ReadUInt16( nLevel );
- xShortName.reset( new OUString(lclGetString32(rStrm, false )) );
+ xShortName.reset(new OUString(read_uInt32_lenPrefixed_uInt8s_ToOUString(rStrm, GetCharSetFromLanguage())));
rStrm.SeekRel( 24 );
sal_uInt32 nStrLen(0);
@@ -316,7 +282,7 @@ void SwWW8ImplReader::ReadEmbeddedData( SvMemoryStream& rStrm, SwDocShell* pDocS
rStrm.ReadUInt32( nStrLen );
nStrLen /= 2;
rStrm.SeekRel( 2 );
- xLongName.reset( new OUString(lclGetString32( rStrm, nStrLen, true )) );
+ xLongName.reset(new OUString(read_uInt32_lenPrefixed_uInt16s_ToOUString(rStrm)));
lclGetAbsPath( *xLongName, nLevel, pDocShell);
}
else
@@ -327,7 +293,7 @@ void SwWW8ImplReader::ReadEmbeddedData( SvMemoryStream& rStrm, SwDocShell* pDocS
sal_uInt32 nStrLen(0);
rStrm.ReadUInt32( nStrLen );
nStrLen /= 2;
- xLongName.reset( new OUString(lclGetString32( rStrm, nStrLen, true )) );
+ xLongName.reset(new OUString(read_uInt32_lenPrefixed_uInt16s_ToOUString(rStrm)));
if( !::get_flag( nFlags, WW8_HLINK_ABS ) )
lclGetAbsPath( *xLongName, 0 ,pDocShell);
}
@@ -340,7 +306,7 @@ void SwWW8ImplReader::ReadEmbeddedData( SvMemoryStream& rStrm, SwDocShell* pDocS
// text mark
if( ::get_flag( nFlags, WW8_HLINK_MARK ) )
{
- xTextMark.reset( new OUString(lclGetString32( rStrm, true )) );
+ xTextMark.reset(new OUString(read_uInt32_lenPrefixed_uInt16s_ToOUString(rStrm)));
}
if( !xLongName.get() && xShortName.get() )
@@ -1139,9 +1105,9 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
if( bRet )
aMemStream.ReadUInt16( nRawRecId ).ReadUInt16( nRawRecSize );
SwDocShell* pDocShell = rReader.m_pDocShell;
- if(pDocShell)
+ if (pDocShell)
{
- SwWW8ImplReader::ReadEmbeddedData( aMemStream, pDocShell, hlStr);
+ rReader.ReadEmbeddedData(aMemStream, pDocShell, hlStr);
}
}
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 12c55d3fc24c..95481dc9622b 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1876,8 +1876,7 @@ public: // really private, but can only be done public
rtl_TextEncoding GetCJKCharSetFromLanguage();
void PostProcessAttrs();
- static void ReadEmbeddedData(SvMemoryStream& rStrm, SwDocShell* pDocShell, struct HyperLinksTable& hlStr);
- static OUString ReadRawUniString(SvMemoryStream& rStrm, sal_uInt16 nChars, bool b16Bit);
+ void ReadEmbeddedData(SvStream& rStrm, SwDocShell* pDocShell, struct HyperLinksTable& hlStr);
};
bool CanUseRemoteLink(const OUString &rGrfName);