summaryrefslogtreecommitdiff
path: root/l10ntools/source/helper.cxx
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-04-13 05:43:53 +0200
committerZolnai Tamás <zolnaitamas2000@gmail.com>2013-04-13 05:44:02 +0200
commitd885a85a48a4706934e170b7a6671e5e029089a0 (patch)
tree03d6dd088d97ce10a5bed62c565078df8d6a264c /l10ntools/source/helper.cxx
parentedc3bfd558f3065a5444ad3f5c456da9546d16c4 (diff)
Make l10ntools executables escape clear
Steps of escaping process: 1. Executables unescape the string for export(if necessary) 2. Po class work with unescaped string 3. Escape strings to PO format and write out 4. Read from PO and unescape strings 5. Executables make own transformation on string and merge Use general functions for escaping (helper) Delete unneeded escaping methods(xrmmerge, merge) Delete some unused method from PoEntry class Change-Id: I7f9414581aae9e6de7d1573862a32cdbd68c9545
Diffstat (limited to 'l10ntools/source/helper.cxx')
-rw-r--r--l10ntools/source/helper.cxx43
1 files changed, 43 insertions, 0 deletions
diff --git a/l10ntools/source/helper.cxx b/l10ntools/source/helper.cxx
index 69163d0e38ae..6c3a04559078 100644
--- a/l10ntools/source/helper.cxx
+++ b/l10ntools/source/helper.cxx
@@ -11,6 +11,49 @@
namespace helper {
+OString escapeAll(
+ const OString& rText, const OString& rUnEscaped, const OString& rEscaped )
+{
+ assert( rEscaped.getLength() == 2*rUnEscaped.getLength() );
+ OStringBuffer sReturn;
+ for ( sal_Int32 nIndex = 0; nIndex < rText.getLength(); ++nIndex )
+ {
+ sal_Int32 nUnEscapedOne = rUnEscaped.indexOf(rText[nIndex]);
+ if( nUnEscapedOne != -1 )
+ {
+ sReturn.append(rEscaped.copy(nUnEscapedOne*2,2));
+ }
+ else
+ sReturn.append(rText[nIndex]);
+ }
+ return sReturn.makeStringAndClear();
+}
+
+
+OString unEscapeAll(
+ const OString& rText, const OString& rEscaped, const OString& rUnEscaped)
+{
+ assert( rEscaped.getLength() == 2*rUnEscaped.getLength() );
+ OStringBuffer sReturn;
+ const sal_Int32 nLength = rText.getLength();
+ for ( sal_Int32 nIndex = 0; nIndex < nLength; ++nIndex )
+ {
+ if( rText[nIndex] == '\\' && nIndex+1 < nLength )
+ {
+ sal_Int32 nEscapedOne = rEscaped.indexOf(rText.copy(nIndex,2));
+ if( nEscapedOne != -1 )
+ {
+ sReturn.append(rUnEscaped[nEscapedOne/2]);
+ ++nIndex;
+ }
+ }
+ else
+ sReturn.append(rText[nIndex]);
+ }
+ return sReturn.makeStringAndClear();
+}
+
+
OString QuotHTML(const OString &rString)
{
OStringBuffer sReturn;