summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-03-27 12:06:25 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-03-27 15:00:07 +0200
commit6d05579c7fceb0f3ce83abe25bdfe62b26c29671 (patch)
tree4a82c2c20f36c68dee1cd4c6ee1a7225e513d127 /filter
parentd0f1a431eab9a7a503bf6487732eeaec0e881053 (diff)
msfilter: extract duplicated WriteHex() from HTML/RTF filter
The RtfAttributeOutput one is a superset of the HTML one, so use that. Change-Id: I3e342113a7ba26946320f43a164e457d6cbb6946 Reviewed-on: https://gerrit.libreoffice.org/51937 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/msfilter/rtfutil.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/filter/source/msfilter/rtfutil.cxx b/filter/source/msfilter/rtfutil.cxx
index 8ac044032163..2cad73a20a97 100644
--- a/filter/source/msfilter/rtfutil.cxx
+++ b/filter/source/msfilter/rtfutil.cxx
@@ -204,6 +204,38 @@ int AsHex(char ch)
return ret;
}
+OString WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, SvStream* pStream, sal_uInt32 nLimit)
+{
+ OStringBuffer aRet;
+
+ sal_uInt32 nBreak = 0;
+ for (sal_uInt32 i = 0; i < nSize; i++)
+ {
+ OString sNo = OString::number(pData[i], 16);
+ if (sNo.getLength() < 2)
+ {
+ if (pStream)
+ pStream->WriteChar('0');
+ else
+ aRet.append('0');
+ }
+ if (pStream)
+ pStream->WriteCharPtr(sNo.getStr());
+ else
+ aRet.append(sNo);
+ if (++nBreak == nLimit)
+ {
+ if (pStream)
+ pStream->WriteCharPtr(SAL_NEWLINE_STRING);
+ else
+ aRet.append(SAL_NEWLINE_STRING);
+ nBreak = 0;
+ }
+ }
+
+ return aRet.makeStringAndClear();
+}
+
bool ExtractOLE2FromObjdata(const OString& rObjdata, SvStream& rOle2)
{
SvMemoryStream aStream;