1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #ifndef INCLUDED_FILTER_MSFILTER_RTFUTIL_HXX
11 #define INCLUDED_FILTER_MSFILTER_RTFUTIL_HXX
13 #include <filter/msfilter/msfilterdllapi.h>
14 #include <rtl/string.hxx>
15 #include <rtl/ustring.hxx>
16 #include <rtl/textenc.h>
17 #include <sal/types.h>
18 #include <tools/solar.h>
20 // RTF values are often multiplied by 2^16
21 #define RTF_MULTIPLIER 65536
25 namespace msfilter::rtfutil
27 /// Outputs a single character in hex form.
28 MSFILTER_DLLPUBLIC OString
OutHex(sal_uLong nHex
, sal_uInt8 nLen
);
30 /// Handles correct unicode and legacy export of a single character.
31 MSFILTER_DLLPUBLIC OString
OutChar(sal_Unicode c
, int* pUCMode
, rtl_TextEncoding eDestEnc
,
32 bool* pSuccess
, bool bUnicode
= true);
35 * Handles correct unicode and legacy export of a string.
37 * @param rStr the string to export
38 * @param eDestEnc the legacy encoding to use
39 * @param bUnicode if unicode output is wanted as well, or just legacy
41 MSFILTER_DLLPUBLIC OString
OutString(std::u16string_view rStr
, rtl_TextEncoding eDestEnc
,
42 bool bUnicode
= true);
45 * Handles correct unicode and legacy export of a string, when a
46 * '{' \upr '{' keyword ansi_text '}{\*' \ud '{' keyword Unicode_text '}}}'
47 * construct should be used.
49 * @param pToken the keyword
50 * @param rStr the text to export
51 * @param eDestEnc the legacy encoding to use
53 MSFILTER_DLLPUBLIC OString
OutStringUpr(std::string_view pToken
, std::u16string_view rStr
,
54 rtl_TextEncoding eDestEnc
);
57 * Get the numeric value of a single character, representing a hex value.
59 * @return -1 on failure
61 MSFILTER_DLLPUBLIC
int AsHex(char ch
);
63 /// Writes binary data as a hex dump.
64 MSFILTER_DLLPUBLIC OString
WriteHex(const sal_uInt8
* pData
, sal_uInt32 nSize
,
65 SvStream
* pStream
= nullptr, sal_uInt32 nLimit
= 64);
68 * Extract OLE2 data from an \objdata hex dump.
70 MSFILTER_DLLPUBLIC
bool ExtractOLE2FromObjdata(const OString
& rObjdata
, SvStream
& rOle2
);
72 /// Strips the header of a WMF file.
73 MSFILTER_DLLPUBLIC
bool StripMetafileHeader(const sal_uInt8
*& rpGraphicAry
, sal_uInt64
& rSize
);
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */