[Libreoffice-commits] .: Branch 'feature/killsdf' - l10ntools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 13 12:53:38 PST 2012
l10ntools/source/helper.hxx | 46 +++++++++++++++++++++++++++++++++++++++++
l10ntools/source/helpmerge.cxx | 2 -
l10ntools/source/xrmmerge.cxx | 4 +--
3 files changed, 49 insertions(+), 3 deletions(-)
New commits:
commit 6cfa7552eebf69daab1ed3acc2a9954d52f00aad
Author: Andras Timar <atimar at suse.com>
Date: Tue Nov 13 21:55:18 2012 +0100
fix XML tag check in help and readme translations
Change-Id: I88a3ad382df41da96fcab38c3c06d5871228e082
diff --git a/l10ntools/source/helper.hxx b/l10ntools/source/helper.hxx
index 1e28aa6..1d268dd 100644
--- a/l10ntools/source/helper.hxx
+++ b/l10ntools/source/helper.hxx
@@ -39,6 +39,7 @@
#include "rtl/string.hxx"
#include "rtl/ustring.hxx"
+#include "rtl/strbuf.hxx"
#include "sal/types.h"
namespace helper {
@@ -102,6 +103,50 @@ inline sal_Int32 indexOfAnyAsciiL(
return -1;
}
+rtl::OString QuotHTML(const rtl::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;
+
+ case '<':
+ sReturn.append("<");
+ break;
+
+ case '>':
+ sReturn.append(">");
+ break;
+
+ case '"':
+ sReturn.append(""");
+ break;
+
+ case '&':
+ if (rString.matchL(RTL_CONSTASCII_STRINGPARAM("&"), i))
+ sReturn.append('&');
+ else
+ sReturn.append(RTL_CONSTASCII_STRINGPARAM("&"));
+ break;
+ }
+ }
+ return sReturn.makeStringAndClear();
+}
+
inline bool isWellFormedXML( OString const & text )
{
xmlDocPtr doc;
@@ -120,6 +165,7 @@ inline bool isWellFormedXML( OString const & text )
return result;
}
+
template< typename T > inline T abbreviate(
T const & text, sal_Int32 start, sal_Int32 length)
{
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index aab255f..8764935 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -380,7 +380,7 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const rtl::OString& sCur ,
nPreSpaces++;
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sCur , true );
OUString sNewdata;
- if (helper::isWellFormedXML(sNewText))
+ if (helper::isWellFormedXML(helper::QuotHTML(sNewText)))
{
sNewdata = sSourceText.copy(0,nPreSpaces) +
rtl::OStringToOUString(sNewText, RTL_TEXTENCODING_UTF8);
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index b4868f5..5b562ea 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -609,7 +609,6 @@ void XRMResMerge::WorkOnText(
sContent, STRING_TYP_TEXT, sLang )) &&
( sContent != "-" ) && !sContent.isEmpty() &&
helper::isWellFormedXML( sContent ))
-
{
rText = sContent;
ConvertStringToXMLFormat( rText );
@@ -645,7 +644,8 @@ void XRMResMerge::EndOfText(
if (!sCur.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")) &&
( pEntrys->GetText(
sContent, STRING_TYP_TEXT, sCur, sal_True )) &&
- ( sContent != "-" ) && !sContent.isEmpty())
+ ( sContent != "-" ) && !sContent.isEmpty() &&
+ helper::isWellFormedXML( sContent ))
{
rtl::OString sText( sContent );
rtl::OString sAdditionalLine( "\n " );
More information about the Libreoffice-commits
mailing list