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
29 /// Outputs a single character in hex form.
30 MSFILTER_DLLPUBLIC OString
OutHex(sal_uLong nHex
, sal_uInt8 nLen
);
32 /// Handles correct unicode and legacy export of a single character.
33 MSFILTER_DLLPUBLIC OString
OutChar(sal_Unicode c
, int* pUCMode
, rtl_TextEncoding eDestEnc
,
34 bool* pSuccess
, bool bUnicode
= true);
37 * Handles correct unicode and legacy export of a string.
39 * @param rStr the string to export
40 * @param eDestEnc the legacy encoding to use
41 * @param bUnicode if unicode output is wanted as well, or just legacy
43 MSFILTER_DLLPUBLIC OString
OutString(const OUString
& rStr
, rtl_TextEncoding eDestEnc
,
44 bool bUnicode
= true);
47 * Handles correct unicode and legacy export of a string, when a
48 * '{' \upr '{' keyword ansi_text '}{\*' \ud '{' keyword Unicode_text '}}}'
49 * construct should be used.
51 * @param pToken the keyword
52 * @param rStr the text to export
53 * @param eDestEnc the legacy encoding to use
55 MSFILTER_DLLPUBLIC OString
OutStringUpr(const sal_Char
* pToken
, const OUString
& rStr
,
56 rtl_TextEncoding eDestEnc
);
59 * Get the numeric value of a single character, representing a hex value.
61 * @return -1 on failure
63 MSFILTER_DLLPUBLIC
int AsHex(char ch
);
65 /// Writes binary data as a hex dump.
66 MSFILTER_DLLPUBLIC OString
WriteHex(const sal_uInt8
* pData
, sal_uInt32 nSize
,
67 SvStream
* pStream
= nullptr, sal_uInt32 nLimit
= 64);
70 * Extract OLE2 data from an \objdata hex dump.
72 MSFILTER_DLLPUBLIC
bool ExtractOLE2FromObjdata(const OString
& rObjdata
, SvStream
& rOle2
);
74 /// Strips the header of a WMF file.
75 MSFILTER_DLLPUBLIC
bool StripMetafileHeader(const sal_uInt8
*& rpGraphicAry
, sal_uInt64
& rSize
);
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */