summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-03-23 14:53:44 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-03-23 15:46:25 +0100
commit679a3b9314d56cad05b5ff2a2c2fa3d320f719bb (patch)
tree97a949dd4f9ba96b461bb34c4ab1aee16a3871d2 /sw
parent1ed1753be26325edf3660c9b9cbd76dc0e9d36ce (diff)
msfilter: extract copy&pasted RTF code from sw and writerfilter
Both the hexdump and the OLE1 reader can be shared. Change-Id: I97d72a8deeb9c79fc8e8c4a73c613213badfa744 Reviewed-on: https://gerrit.libreoffice.org/51783 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_uwriter.mk1
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/source/filter/html/htmlreqifreader.cxx66
3 files changed, 4 insertions, 64 deletions
diff --git a/sw/CppunitTest_sw_uwriter.mk b/sw/CppunitTest_sw_uwriter.mk
index ba31ae9d9a5a..9c305d3dcbb3 100644
--- a/sw/CppunitTest_sw_uwriter.mk
+++ b/sw/CppunitTest_sw_uwriter.mk
@@ -35,6 +35,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uwriter, \
i18nlangtag \
i18nutil \
lng \
+ msfilter \
oox \
sal \
salhelper \
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index f70ef0b76b27..78d62e03809e 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -59,6 +59,7 @@ $(eval $(call gb_Library_use_libraries,sw,\
i18nlangtag \
i18nutil \
lng \
+ msfilter \
sal \
salhelper \
sax \
diff --git a/sw/source/filter/html/htmlreqifreader.cxx b/sw/source/filter/html/htmlreqifreader.cxx
index 34199d8a613f..eef33d93b293 100644
--- a/sw/source/filter/html/htmlreqifreader.cxx
+++ b/sw/source/filter/html/htmlreqifreader.cxx
@@ -14,27 +14,10 @@
#include <svtools/parrtf.hxx>
#include <svtools/rtftoken.h>
#include <tools/stream.hxx>
+#include <filter/msfilter/rtfutil.hxx>
namespace
{
-int AsHex(char ch)
-{
- int ret = 0;
- if (rtl::isAsciiDigit(static_cast<unsigned char>(ch)))
- ret = ch - '0';
- else
- {
- if (ch >= 'a' && ch <= 'f')
- ret = ch - 'a';
- else if (ch >= 'A' && ch <= 'F')
- ret = ch - 'A';
- else
- return -1;
- ret += 10;
- }
- return ret;
-}
-
/// RTF parser that just extracts a single OLE2 object from a file.
class ReqIfRtfReader : public SvRTFParser
{
@@ -72,52 +55,7 @@ void ReqIfRtfReader::NextToken(int nToken)
bool ReqIfRtfReader::WriteObjectData(SvStream& rOLE)
{
- int b = 0, count = 2;
-
- SvMemoryStream aBuf;
- for (int i = 0; i < m_aHex.getLength(); ++i)
- {
- char ch = m_aHex[i];
- if (ch != 0x0d && ch != 0x0a)
- {
- b = b << 4;
- sal_Int8 parsed = AsHex(ch);
- if (parsed == -1)
- return false;
- b += parsed;
- count--;
- if (!count)
- {
- aBuf.WriteChar(b);
- count = 2;
- b = 0;
- }
- }
- }
-
- // Skip ObjectHeader, see [MS-OLEDS] 2.2.4.
- if (aBuf.Tell())
- {
- aBuf.Seek(0);
- sal_uInt32 nData;
- aBuf.ReadUInt32(nData); // OLEVersion
- aBuf.ReadUInt32(nData); // FormatID
- aBuf.ReadUInt32(nData); // ClassName
- aBuf.SeekRel(nData);
- aBuf.ReadUInt32(nData); // TopicName
- aBuf.SeekRel(nData);
- aBuf.ReadUInt32(nData); // ItemName
- aBuf.SeekRel(nData);
- aBuf.ReadUInt32(nData); // NativeDataSize
-
- if (nData)
- {
- rOLE.WriteStream(aBuf);
- rOLE.Seek(0);
- }
- }
-
- return true;
+ return msfilter::rtfutil::ExtractOLE2FromObjdata(m_aHex.makeStringAndClear(), rOLE);
}
}