summaryrefslogtreecommitdiff
path: root/l10ntools/source/po.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/po.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/po.cxx')
-rwxr-xr-xl10ntools/source/po.cxx82
1 files changed, 2 insertions, 80 deletions
diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx
index 36e6ebb6f2ce..bbfe0633bab6 100755
--- a/l10ntools/source/po.cxx
+++ b/l10ntools/source/po.cxx
@@ -17,15 +17,12 @@
#include <string>
#include <boost/crc.hpp>
-#include <unicode/regex.h>
#include "po.hxx"
#define POESCAPED OString("\\n\\t\\r\\\\\\\"")
#define POUNESCAPED OString("\n\t\r\\\"")
-using namespace U_ICU_NAMESPACE;
-
/** Container of po entry
Provide all file operations related to LibreOffice specific
@@ -282,92 +279,17 @@ namespace
const OString& rText,const bool bHelpText = false )
{
if ( bHelpText )
- return lcl_UnEscapeText(rText,"\\<\\>\\\"\\\\","<>\"\\");
+ return rText;
else
return lcl_UnEscapeText(rText,"\\n\\t\\r","\n\t\r");
}
- //Find all special tag in a string using a regular expression
- static void lcl_FindAllTag(
- const OString& rText,std::vector<OString>& o_vFoundTags )
- {
-
- UErrorCode nIcuErr = U_ZERO_ERROR;
- static const sal_uInt32 nSearchFlags =
- UREGEX_DOTALL | UREGEX_CASE_INSENSITIVE;
- OUString sLocaleText( OStringToOUString(rText,RTL_TEXTENCODING_UTF8) );
- static const OUString sPattern(
- "<[/]\?\?[a-z_-]+?(?:| +[a-z]+?=\".*?\") *[/]\?\?>");
- static const UnicodeString sSearchPat(
- reinterpret_cast<const UChar*>(sPattern.getStr()),
- sPattern.getLength() );
- UnicodeString sSource(
- reinterpret_cast<const UChar*>(
- sLocaleText.getStr()), sLocaleText.getLength() );
-
- RegexMatcher aRegexMatcher( sSearchPat, nSearchFlags, nIcuErr );
- aRegexMatcher.reset( sSource );
- int64_t nStartPos = 0;
- while( aRegexMatcher.find(nStartPos, nIcuErr) &&
- nIcuErr == U_ZERO_ERROR )
- {
- UnicodeString sMatch =
- aRegexMatcher.group(nIcuErr);
- o_vFoundTags.push_back(
- OUStringToOString(
- OUString(
- reinterpret_cast<const sal_Unicode*>(
- sMatch.getBuffer()),sMatch.length()),
- RTL_TEXTENCODING_UTF8));
- nStartPos = aRegexMatcher.start(nIcuErr)+1;
- }
- }
-
- //Escape special tags
- static OString lcl_EscapeTags( const OString& rText )
- {
- typedef std::vector<OString> StrVec_t;
- static const OString vInitializer[] = {
- "ahelp", "link", "item", "emph", "defaultinline",
- "switchinline", "caseinline", "variable",
- "bookmark_value", "image", "embedvar", "alt" };
- static const StrVec_t vTagsForEscape( vInitializer,
- vInitializer + sizeof(vInitializer) / sizeof(vInitializer[0]) );
- StrVec_t vFoundTags;
- lcl_FindAllTag(rText,vFoundTags);
- OString sResult = rText;
- for(StrVec_t::const_iterator pFound = vFoundTags.begin();
- pFound != vFoundTags.end(); ++pFound)
- {
- bool bEscapeThis = false;
- for(StrVec_t::const_iterator pEscape = vTagsForEscape.begin();
- pEscape != vTagsForEscape.end(); ++pEscape)
- {
- if (pFound->startsWith("<" + *pEscape) ||
- *pFound == "</" + *pEscape + ">")
- {
- bEscapeThis = true;
- break;
- }
- }
- if( bEscapeThis || *pFound=="<br/>" ||
- *pFound =="<help-id-missing/>")
- {
- OString sToReplace = "\\<" +
- pFound->copy(1,pFound->getLength()-2).
- replaceAll("\"","\\\"") + "\\>";
- sResult = sResult.replaceAll(*pFound, sToReplace);
- }
- }
- return sResult;
- }
-
//Escape to get merge string
static OString lcl_EscapeMergeText(
const OString& rText,const bool bHelpText = false )
{
if ( bHelpText )
- return lcl_EscapeTags(rText.replaceAll("\\","\\\\"));
+ return rText;
else
return lcl_EscapeText(rText,"\n\t\r","\\n\\t\\r");
}