11#include <rtl/strbuf.hxx>
13#include <osl/diagnose.h>
15#include <rtl/character.hxx>
27 const OString& rClassName)
30 OString aAnsiUserType;
32 if (rClassName ==
"PBrush")
34 aAnsiUserType =
"Bitmap Image";
35 aName =
SvGlobalName(0x0003000A, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0x46);
39 if (!rClassName.isEmpty() && rClassName !=
"Package")
41 SAL_WARN(
"filter.ms",
"WrapOle1InOle2: unexpected class name: '" << rClassName <<
"'");
43 aAnsiUserType =
"OLE Package";
44 aName =
SvGlobalName(0x0003000C, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0x46);
46 pStorage->SetClass(aName, SotClipboardFormatId::NONE,
"");
51 pCompObj->WriteUInt32(0xfffe0001);
53 pCompObj->WriteUInt32(0x00000a03);
55 pCompObj->WriteUInt32(0xffffffff);
56 pCompObj->WriteUInt32(0x0003000c);
57 pCompObj->WriteUInt32(0x00000000);
58 pCompObj->WriteUInt32(0x000000c0);
59 pCompObj->WriteUInt32(0x46000000);
62 pCompObj->WriteUInt32(aAnsiUserType.getLength() + 1);
63 pCompObj->WriteOString(aAnsiUserType);
64 pCompObj->WriteChar(0);
66 pCompObj->WriteUInt32(0x00000000);
68 pCompObj->WriteUInt32(rClassName.getLength() + 1);
69 pCompObj->WriteOString(rClassName);
70 pCompObj->WriteChar(0);
72 pCompObj->WriteUInt32(0x71B239F4);
74 pCompObj->WriteUInt32(0x00000000);
76 pCompObj->WriteUInt32(0x00000000);
78 pCompObj->WriteUInt32(0x00000000);
85 pOleNative->WriteUInt32(nOle1Size);
86 pOleNative->WriteStream(rOle1, nOle1Size);
100 char aNToABuf[] =
"0000000000000000";
102 OSL_ENSURE(nLen <
sizeof(aNToABuf),
"nLen is too big");
103 if (nLen >=
sizeof(aNToABuf))
104 nLen = (
sizeof(aNToABuf) - 1);
107 char* pStr = aNToABuf + (
sizeof(aNToABuf) - 1);
110 *(--pStr) =
static_cast<char>(nHex & 0xf) + 48;
135 const char* pStr =
nullptr;
150 aBuf.append(
static_cast<char>(c));
165 if (c >=
' ' && c <=
'~')
166 aBuf.append(
static_cast<char>(c));
169 OUString sBuf(&c, 1);
172 *pSuccess &= sBuf.convertToString(&sConverted, eDestEnc,
173 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
174 | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR);
176 sBuf.convertToString(&sConverted, eDestEnc, OUSTRING_TO_OSTRING_CVTFLAGS);
177 const sal_Int32 nLen = sConverted.getLength();
179 if (pUCMode && bUnicode)
181 if (*pUCMode != nLen)
183 aBuf.append(
"\\uc" + OString::number(nLen));
188 aBuf.append(
"\\u" + OString::number(
static_cast<sal_Int32
>(c)));
191 for (sal_Int32 nI = 0; nI < nLen; ++nI)
193 aBuf.append(
"\\'" +
OutHex(sConverted[nI], 2));
210 return aBuf.makeStringAndClear();
213OString
OutString(std::u16string_view rStr, rtl_TextEncoding eDestEnc,
bool bUnicode)
217 for (
size_t n = 0;
n < rStr.size(); ++
n)
218 aBuf.append(
OutChar(rStr[
n], &nUCMode, eDestEnc,
nullptr, bUnicode));
225 return aBuf.makeStringAndClear();
229static bool TryOutString(std::u16string_view rStr, rtl_TextEncoding eDestEnc)
232 for (
size_t n = 0;
n < rStr.size(); ++
n)
235 OutChar(rStr[
n], &nUCMode, eDestEnc, &bRet);
242OString
OutStringUpr(std::string_view pToken, std::u16string_view rStr, rtl_TextEncoding eDestEnc)
245 return OString::Concat(
"{") + pToken +
" " +
OutString(rStr, eDestEnc) +
"}";
256 if (rtl::isAsciiDigit(
static_cast<unsigned char>(
ch)))
260 if (
ch >=
'a' &&
ch <=
'f')
262 else if (
ch >=
'A' &&
ch <=
'F')
275 sal_uInt32 nBreak = 0;
276 for (sal_uInt32
i = 0;
i < nSize;
i++)
278 OString sNo = OString::number(
pData[
i], 16);
279 if (sNo.getLength() < 2)
290 if (++nBreak == nLimit)
300 return aRet.makeStringAndClear();
310 for (
int i = 0;
i < rObjdata.getLength(); ++
i)
312 char ch = rObjdata[
i];
313 if (
ch != 0x0d &&
ch != 0x0a)
360 const sal_uInt8 aOle2Signature[8] = { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 };
363 if (std::memcmp(aSignature, aOle2Signature,
SAL_N_ELEMENTS(aSignature)) == 0)
371 WrapOle1InOle2(aStream, nData, aStorage, aClassName);
381 if (rpGraphicAry && (rSize > 0x22))
383 if ((rpGraphicAry[0] == 0xd7) && (rpGraphicAry[1] == 0xcd) && (rpGraphicAry[2] == 0xc6)
384 && (rpGraphicAry[3] == 0x9a))
SvStream & WriteOString(std::string_view rStr)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & WriteChar(char nChar)
std::size_t ReadBytes(void *pData, std::size_t nSize)
sal_uInt64 SeekRel(sal_Int64 nPos)
SvStream & WriteStream(SvStream &rStream)
#define SAL_NEWLINE_STRING
#define SAL_WARN(area, stream)
#define SAL_N_ELEMENTS(arr)
std::unique_ptr< sal_Int32[]> pData
OString OutStringUpr(std::string_view pToken, std::u16string_view rStr, rtl_TextEncoding eDestEnc)
Handles correct unicode and legacy export of a string, when a '{' \upr '{' keyword ansi_text '}{*' \u...
OString OutChar(sal_Unicode c, int *pUCMode, rtl_TextEncoding eDestEnc, bool *pSuccess, bool bUnicode)
Handles correct unicode and legacy export of a single character.
OString OutString(std::u16string_view rStr, rtl_TextEncoding eDestEnc, bool bUnicode)
Handles correct unicode and legacy export of a string.
bool StripMetafileHeader(const sal_uInt8 *&rpGraphicAry, sal_uInt64 &rSize)
Strips the header of a WMF file.
OString OutHex(sal_uLong nHex, sal_uInt8 nLen)
Outputs a single character in hex form.
bool ExtractOLE2FromObjdata(const OString &rObjdata, SvStream &rOle2)
Extract OLE2 data from an \objdata hex dump.
OString WriteHex(const sal_uInt8 *pData, sal_uInt32 nSize, SvStream *pStream, sal_uInt32 nLimit)
Writes binary data as a hex dump.
int AsHex(char ch)
Get the numeric value of a single character, representing a hex value.
static bool TryOutString(std::u16string_view rStr, rtl_TextEncoding eDestEnc)
Checks if lossless conversion of the string to eDestEnc is possible or not.
#define OOO_STRING_SVTOOLS_RTF_UC
#define OOO_STRING_SVTOOLS_RTF_LINE
#define OOO_STRING_SVTOOLS_RTF_IGNORE
#define OOO_STRING_SVTOOLS_RTF_UD
#define OOO_STRING_SVTOOLS_RTF_UPR
#define OOO_STRING_SVTOOLS_RTF_TAB
TOOLS_DLLPUBLIC OString read_uInt8s_ToOString(SvStream &rStrm, std::size_t nUnits)