summaryrefslogtreecommitdiff
path: root/l10ntools/source/helper.cxx
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-03-31 20:11:57 +0200
committerZolnai Tamás <zolnaitamas2000@gmail.com>2013-03-31 20:25:13 +0200
commitce51bf1a6ef36bbd1eea751add342cae6f1004d2 (patch)
treefedd6cb9efdd0a90306316bda580ace87b78b0b4 /l10ntools/source/helper.cxx
parent6ea8d4a55c3693d75da32af7e9a40a79bac99fa7 (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.cxx59
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("&lt;");
break;
-
case '>':
sReturn.append("&gt;");
break;
-
case '"':
sReturn.append("&quot;");
break;
-
case '&':
if (rString.match("&amp;", i))
sReturn.append('&');
else
sReturn.append("&amp;");
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("&amp;", i)) {
+ sReturn.append('&');
+ i += RTL_CONSTASCII_LENGTH("&amp;");
+ } else if (rString.match("&lt;", i)) {
+ sReturn.append('<');
+ i += RTL_CONSTASCII_LENGTH("&lt;");
+ } else if (rString.match("&gt;", i)) {
+ sReturn.append('>');
+ i += RTL_CONSTASCII_LENGTH("&gt;");
+ } else if (rString.match("&quot;", i)) {
+ sReturn.append('"');
+ i += RTL_CONSTASCII_LENGTH("&quot;");
+ } else if (rString.match("&apos;", i)) {
+ sReturn.append('\'');
+ i += RTL_CONSTASCII_LENGTH("&apos;");
+ } else {
+ sReturn.append(rString[i]);
+ ++i;
}
}
return sReturn.makeStringAndClear();