diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-11-22 09:20:23 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-11-22 11:24:24 +0100 |
commit | fd6150915253e382a7e9f674fe23a72a9a801761 (patch) | |
tree | aa76c8e0cd09eaa2cafbf7897fe48eb42a0886ec /filter | |
parent | 9ffa900cb4d0381587162e3deb9d910965b69d58 (diff) |
RTF filter: drop now redundant astyle.options
I (tried to) keep the RTF filter style consistent locally with astyle in
the past, but now that's redundant when we have an enforcing
clang-format mechanism in place. So drop the astyle config and switch to
clang-format in the RTF filter case.
To minimize backport pain, do this shortly before the libreoffice-6-0
branch-off.
Change-Id: I708dbeb0b5ad2afacc90029ee5abba9495f4601f
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/msfilter/rtfutil.cxx | 129 |
1 files changed, 66 insertions, 63 deletions
diff --git a/filter/source/msfilter/rtfutil.cxx b/filter/source/msfilter/rtfutil.cxx index ad1e9d13fbfa..279fe123e5b5 100644 --- a/filter/source/msfilter/rtfutil.cxx +++ b/filter/source/msfilter/rtfutil.cxx @@ -16,17 +16,16 @@ namespace msfilter { namespace rtfutil { - OString OutHex(sal_uLong nHex, sal_uInt8 nLen) { sal_Char aNToABuf[] = "0000000000000000"; OSL_ENSURE(nLen < sizeof(aNToABuf), "nLen is too big"); if (nLen >= sizeof(aNToABuf)) - nLen = (sizeof(aNToABuf)-1); + nLen = (sizeof(aNToABuf) - 1); // Set pointer to the buffer end - sal_Char* pStr = aNToABuf + (sizeof(aNToABuf)-1); + sal_Char* pStr = aNToABuf + (sizeof(aNToABuf) - 1); for (sal_uInt8 n = 0; n < nLen; ++n) { *(--pStr) = (sal_Char)(nHex & 0xf) + 48; @@ -48,7 +47,8 @@ OString OutHex(sal_uLong nHex, sal_uInt8 nLen) // However the "Mathematics" section has an example that shows the code point // U+1D44E being encoded as UTF-16 surrogate pair "\u-10187?\u-9138?", so // sal_Unicode actually works fine here. -OString OutChar(sal_Unicode c, int* pUCMode, rtl_TextEncoding eDestEnc, bool* pSuccess, bool bUnicode) +OString OutChar(sal_Unicode c, int* pUCMode, rtl_TextEncoding eDestEnc, bool* pSuccess, + bool bUnicode) { if (pSuccess) *pSuccess = true; @@ -57,76 +57,78 @@ OString OutChar(sal_Unicode c, int* pUCMode, rtl_TextEncoding eDestEnc, bool* pS // 0x0b instead of \n, etc because of the replacements in SwWW8AttrIter::GetSnippet() switch (c) { - case 0x0b: - // hard line break - pStr = OOO_STRING_SVTOOLS_RTF_LINE; - break; - case '\t': - pStr = OOO_STRING_SVTOOLS_RTF_TAB; - break; - case '\\': - case '}': - case '{': - aBuf.append('\\'); - aBuf.append((sal_Char)c); - break; - case 0xa0: - // non-breaking space - pStr = "\\~"; - break; - case 0x1e: - // non-breaking hyphen - pStr = "\\_"; - break; - case 0x1f: - // optional hyphen - pStr = "\\-"; - break; - default: - if (c >= ' ' && c <= '~') + case 0x0b: + // hard line break + pStr = OOO_STRING_SVTOOLS_RTF_LINE; + break; + case '\t': + pStr = OOO_STRING_SVTOOLS_RTF_TAB; + break; + case '\\': + case '}': + case '{': + aBuf.append('\\'); aBuf.append((sal_Char)c); - else - { - OUString sBuf(&c, 1); - OString sConverted; - if (pSuccess) - *pSuccess &= sBuf.convertToString(&sConverted, eDestEnc, RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR); + break; + case 0xa0: + // non-breaking space + pStr = "\\~"; + break; + case 0x1e: + // non-breaking hyphen + pStr = "\\_"; + break; + case 0x1f: + // optional hyphen + pStr = "\\-"; + break; + default: + if (c >= ' ' && c <= '~') + aBuf.append((sal_Char)c); else - sBuf.convertToString(&sConverted, eDestEnc, OUSTRING_TO_OSTRING_CVTFLAGS); - const sal_Int32 nLen = sConverted.getLength(); - - if (pUCMode && bUnicode) { - if (*pUCMode != nLen) + OUString sBuf(&c, 1); + OString sConverted; + if (pSuccess) + *pSuccess &= sBuf.convertToString(&sConverted, eDestEnc, + RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR + | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR); + else + sBuf.convertToString(&sConverted, eDestEnc, OUSTRING_TO_OSTRING_CVTFLAGS); + const sal_Int32 nLen = sConverted.getLength(); + + if (pUCMode && bUnicode) { - aBuf.append("\\uc"); - aBuf.append((sal_Int32)nLen); - // #i47831# add an additional whitespace, so that "document whitespaces" are not ignored. - aBuf.append(' '); - *pUCMode = nLen; + if (*pUCMode != nLen) + { + aBuf.append("\\uc"); + aBuf.append((sal_Int32)nLen); + // #i47831# add an additional whitespace, so that "document whitespaces" are not ignored. + aBuf.append(' '); + *pUCMode = nLen; + } + aBuf.append("\\u"); + aBuf.append((sal_Int32)c); } - aBuf.append("\\u"); - aBuf.append((sal_Int32)c); - } - for (sal_Int32 nI = 0; nI < nLen; ++nI) - { - aBuf.append("\\'"); - aBuf.append(OutHex(sConverted[nI], 2)); + for (sal_Int32 nI = 0; nI < nLen; ++nI) + { + aBuf.append("\\'"); + aBuf.append(OutHex(sConverted[nI], 2)); + } } - } } if (pStr) { aBuf.append(pStr); switch (c) { - case 0xa0: - case 0x1e: - case 0x1f: - break; - default: - aBuf.append(' '); + case 0xa0: + case 0x1e: + case 0x1f: + break; + default: + aBuf.append(' '); } } return aBuf.makeStringAndClear(); @@ -143,7 +145,8 @@ OString OutString(const OUString& rStr, rtl_TextEncoding eDestEnc, bool bUnicode { aBuf.append(OOO_STRING_SVTOOLS_RTF_UC); aBuf.append((sal_Int32)1); - aBuf.append(" "); // #i47831# add an additional whitespace, so that "document whitespaces" are not ignored.; + aBuf.append( + " "); // #i47831# add an additional whitespace, so that "document whitespaces" are not ignored.; } return aBuf.makeStringAndClear(); } @@ -171,7 +174,7 @@ OString OutStringUpr(const sal_Char* pToken, const OUString& rStr, rtl_TextEncod aRet.append("{" OOO_STRING_SVTOOLS_RTF_UPR "{"); aRet.append(pToken); aRet.append(" "); - aRet.append(OutString(rStr, eDestEnc, /*bUnicode =*/ false)); + aRet.append(OutString(rStr, eDestEnc, /*bUnicode =*/false)); aRet.append("}{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_UD "{"); aRet.append(pToken); aRet.append(" "); |