diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-03-31 20:11:57 +0200 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-03-31 20:25:13 +0200 |
commit | ce51bf1a6ef36bbd1eea751add342cae6f1004d2 (patch) | |
tree | fedd6cb9efdd0a90306316bda580ace87b78b0b4 /l10ntools/source/helper.cxx | |
parent | 6ea8d4a55c3693d75da32af7e9a40a79bac99fa7 (diff) |
Make a bit cleaner transformation of help strings
*Not escape tags and double quots in tags,
but find tags(icu regexp) when merge and
use this infromation to make strings valid.
*Define a new Quot function for helpex,
which works with icu UnicodeCharacter.
*Move tag search to xmlparse.cxx and use icu
just in helpex.
*QuotHTML not unescape just replace xml charcters.
(unescaping is also useless in uimerge.cxx)
*Move UnQuotHTML() to helper.
(was used it in xmlparse.cxx and cfgmerge.cxx)
*Use UnQuotHTML() in uimerge.cxx too.
Change-Id: Ice8940ef69279709a1c5d84c6ae1b0d62a71ca76
Diffstat (limited to 'l10ntools/source/helper.cxx')
-rw-r--r-- | l10ntools/source/helper.cxx | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/l10ntools/source/helper.cxx b/l10ntools/source/helper.cxx index cbcf6d1572fb..08a256013bcd 100644 --- a/l10ntools/source/helper.cxx +++ b/l10ntools/source/helper.cxx @@ -11,45 +11,58 @@ namespace helper { -rtl::OString QuotHTML(const rtl::OString &rString) +OString QuotHTML(const OString &rString) { - rtl::OStringBuffer sReturn; - for (sal_Int32 i = 0; i < rString.getLength(); ++i) { - switch (rString[i]) { - case '\\': - if (i < rString.getLength()) { - switch (rString[i + 1]) { - case '"': - case '<': - case '>': - case '\\': - ++i; - break; - } - } - // fall through - default: - sReturn.append(rString[i]); - break; - + OStringBuffer sReturn; + for (sal_Int32 i = 0; i < rString.getLength(); ++i) + { + switch (rString[i]) + { case '<': sReturn.append("<"); break; - case '>': sReturn.append(">"); break; - case '"': sReturn.append("""); break; - case '&': if (rString.match("&", i)) sReturn.append('&'); else sReturn.append("&"); break; + default: + sReturn.append(rString[i]); + break; + } + } + return sReturn.makeStringAndClear(); +} + +OString UnQuotHTML( const OString& rString ) +{ + OStringBuffer sReturn; + for (sal_Int32 i = 0; i != rString.getLength();) { + if (rString.match("&", i)) { + sReturn.append('&'); + i += RTL_CONSTASCII_LENGTH("&"); + } else if (rString.match("<", i)) { + sReturn.append('<'); + i += RTL_CONSTASCII_LENGTH("<"); + } else if (rString.match(">", i)) { + sReturn.append('>'); + i += RTL_CONSTASCII_LENGTH(">"); + } else if (rString.match(""", i)) { + sReturn.append('"'); + i += RTL_CONSTASCII_LENGTH("""); + } else if (rString.match("'", i)) { + sReturn.append('\''); + i += RTL_CONSTASCII_LENGTH("'"); + } else { + sReturn.append(rString[i]); + ++i; } } return sReturn.makeStringAndClear(); |