diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-06 15:08:45 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-07 09:02:45 +0000 |
commit | 9b77f8142bf665a47c3a179e3fe3f82623a99f8a (patch) | |
tree | 6aee5ab0ec475499fa20f0485bdcb16853b5a79f /sw | |
parent | 60aac84fc83ca6d527d06cf4ce031d7ef5ffee48 (diff) |
ditch ReadRawUniString
This thing is defined by MS-OSHARED, there FWIW, the 8 bit encoding is "ANSI",
which is somewhat useless, use the same GetCharSetFromLanguage() attempt we use
elsewhere when that problem arises
Change-Id: I6d8efdbec0daf7f3439283f2be0473b6fad1fb17
Reviewed-on: https://gerrit.libreoffice.org/36214
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 66 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.hxx | 3 |
2 files changed, 17 insertions, 52 deletions
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); |