[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jan 13 19:57:09 UTC 2020
sw/qa/extras/htmlexport/data/reqif-chinese.odt |binary
sw/qa/extras/htmlexport/htmlexport.cxx | 22 ++++++++++++++++++++++
sw/source/filter/html/htmlatr.cxx | 10 +++++-----
sw/source/filter/html/htmlbas.cxx | 4 ++--
sw/source/filter/html/htmlfldw.cxx | 5 ++---
sw/source/filter/html/htmlflywriter.cxx | 2 +-
sw/source/filter/html/htmlforw.cxx | 6 +++---
sw/source/filter/html/htmlftn.cxx | 4 ++--
sw/source/filter/html/wrthtml.cxx | 4 ++--
sw/source/filter/html/wrthtml.hxx | 2 +-
10 files changed, 40 insertions(+), 19 deletions(-)
New commits:
commit 186ef501a305d452da1f36aa51106dba181dc324
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jan 13 17:07:34 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Jan 13 20:56:34 2020 +0100
sw reqif-xhtml export: fix non-well-formed output on Chinese text
And also search for the '"<" OOO_something' pattern, and fix up all
cases where we forgot to call GetNamespace() when opening an element.
Change-Id: I015e807c1ad0f96c7c4aaa97f7f61ae134cf3754
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86701
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/sw/qa/extras/htmlexport/data/reqif-chinese.odt b/sw/qa/extras/htmlexport/data/reqif-chinese.odt
new file mode 100644
index 000000000000..b99c57caee10
Binary files /dev/null and b/sw/qa/extras/htmlexport/data/reqif-chinese.odt differ
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index c2ef9bc7961b..0bf573039813 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -761,6 +761,28 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testRTFOLEMimeType)
aType);
}
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testChinese)
+{
+ // Load a document with Chinese text in it.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "reqif-chinese.odt";
+ mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument", {});
+
+ // Export it.
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aStoreProperties = {
+ comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")),
+ comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")),
+ };
+ xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties);
+ SvMemoryStream aStream;
+ HtmlExportTest::wrapFragment(maTempFile, aStream);
+ xmlDocPtr pDoc = parseXmlStream(&aStream);
+
+ // Without the accompanying fix in place, this test would have failed as the output was not
+ // well-formed.
+ CPPUNIT_ASSERT(pDoc);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 7c1258ae90bd..8b501b0e894f 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -781,7 +781,7 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
// The align=... attribute does behave strange in netscape
// if there are controls in a paragraph, because the control and
// all text behind the control does not recognize this attribute.
- OString sOut = "<" OOO_STRING_SVTOOLS_HTML_division;
+ OString sOut = "<" + rHWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division;
rWrt.Strm().WriteOString( sOut );
rHWrt.m_bTextAttr = false;
@@ -2648,7 +2648,7 @@ static Writer& OutHTML_SvxColor( Writer& rWrt, const SfxPoolItem& rHt )
}
else
{
- OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font " "
+ OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font " "
OOO_STRING_SVTOOLS_HTML_O_color "=";
rWrt.Strm().WriteOString( sOut );
HTMLOutFuncs::Out_Color( rWrt.Strm(), aColor ).WriteChar( '>' );
@@ -2708,7 +2708,7 @@ static Writer& OutHTML_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
}
else
{
- OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font " "
+ OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font " "
OOO_STRING_SVTOOLS_HTML_O_face "=\"";
rWrt.Strm().WriteOString( sOut );
HTMLOutFuncs::Out_String( rWrt.Strm(), aNames, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters )
@@ -2748,7 +2748,7 @@ static Writer& OutHTML_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
}
else
{
- OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font;
+ OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font;
sal_uInt32 nHeight = static_cast<const SvxFontHeightItem&>(rHt).GetHeight();
sal_uInt16 nSize = rHTMLWrt.GetHTMLFontSize( nHeight );
@@ -2788,7 +2788,7 @@ static Writer& OutHTML_SvxLanguage( Writer& rWrt, const SfxPoolItem& rHt )
if( rHTMLWrt.m_bTagOn )
{
- OString sOut = "<" OOO_STRING_SVTOOLS_HTML_span;
+ OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span;
rWrt.Strm().WriteOString( sOut );
rHTMLWrt.OutLanguage( static_cast<const SvxLanguageItem &>(rHt).GetLanguage() );
rWrt.Strm().WriteChar( '>' );
diff --git a/sw/source/filter/html/htmlbas.cxx b/sw/source/filter/html/htmlbas.cxx
index 4e3a2d40b1ea..d42f6f90a872 100644
--- a/sw/source/filter/html/htmlbas.cxx
+++ b/sw/source/filter/html/htmlbas.cxx
@@ -245,7 +245,7 @@ void SwHTMLParser::InsertBasicDocEvent( const OUString& aEvent, const OUString&
pDocSh );
}
-void SwHTMLWriter::OutBasic()
+void SwHTMLWriter::OutBasic(SwHTMLWriter & rHTMLWrt)
{
#if HAVE_FEATURE_SCRIPTING
if( !m_bCfgStarBasic )
@@ -274,7 +274,7 @@ void SwHTMLWriter::OutBasic()
bFirst = false;
OutNewLine();
OString sOut =
- "<" OOO_STRING_SVTOOLS_HTML_meta
+ "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_meta
" " OOO_STRING_SVTOOLS_HTML_O_httpequiv
"=\""
OOO_STRING_SVTOOLS_HTML_META_content_script_type
diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx
index 33014b6dddef..ee67b6f08374 100644
--- a/sw/source/filter/html/htmlfldw.cxx
+++ b/sw/source/filter/html/htmlfldw.cxx
@@ -442,6 +442,7 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
{
+ SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const SwFormatField & rField = static_cast<const SwFormatField&>(rHt);
const SwField* pField = rField.GetField();
const SwFieldType* pFieldTyp = pField->GetTyp();
@@ -509,7 +510,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
OUString sComment(convertLineEnd(rComment, GetSystemLineEnd()));
// TODO: ???
OString sOut =
- "<" OOO_STRING_SVTOOLS_HTML_comment
+ "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_comment
" " +
OUStringToOString(sComment, static_cast<SwHTMLWriter&>(rWrt).m_eDestEnc) +
" -->";
@@ -518,7 +519,6 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
}
else if( SwFieldIds::Script == pFieldTyp->Which() )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
if( rHTMLWrt.m_bLFPossible )
rHTMLWrt.OutNewLine( true );
@@ -544,7 +544,6 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
OSL_ENSURE( pTextField, "Where is the txt fld?" );
if( pTextField )
{
- SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// ReqIF-XHTML doesn't allow specifying a background color.
bool bFieldShadings = SwViewOption::IsFieldShadings() && !rHTMLWrt.mbReqIF;
if (bFieldShadings)
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index 93c948f76013..424b902a644c 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -1657,7 +1657,7 @@ static Writer& OutHTML_FrameFormatAsSpacer( Writer& rWrt, const SwFrameFormat& r
rHTMLWrt.OutNewLine( true );
OString sOut =
- "<" OOO_STRING_SVTOOLS_HTML_spacer " "
+ "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_spacer " "
OOO_STRING_SVTOOLS_HTML_O_type "=\""
OOO_STRING_SVTOOLS_HTML_SPTYPE_block "\"";
rWrt.Strm().WriteOString( sOut );
diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx
index 4b00a5b57705..4431234b8015 100644
--- a/sw/source/filter/html/htmlforw.cxx
+++ b/sw/source/filter/html/htmlforw.cxx
@@ -444,7 +444,7 @@ void SwHTMLWriter::OutForm( bool bOn,
// the new form is opened
if( m_bLFPossible )
OutNewLine();
- OString sOut = "<" OOO_STRING_SVTOOLS_HTML_form;
+ OString sOut = "<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_form;
uno::Reference< beans::XPropertySet > xFormPropSet( rFormComps, uno::UNO_QUERY );
@@ -573,7 +573,7 @@ void SwHTMLWriter::OutHiddenControls(
{
if( m_bLFPossible )
OutNewLine( true );
- OString sOut = "<" OOO_STRING_SVTOOLS_HTML_input " "
+ OString sOut = "<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_input " "
OOO_STRING_SVTOOLS_HTML_O_type "=\""
OOO_STRING_SVTOOLS_HTML_IT_hidden "\"";
@@ -1200,7 +1200,7 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
nSel++;
rHTMLWrt.OutNewLine(); // every Option gets its own line
- sOut = "<" OOO_STRING_SVTOOLS_HTML_option;
+ sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_option;
if( !sVal.isEmpty() || bEmptyVal )
{
sOut += " " OOO_STRING_SVTOOLS_HTML_O_value "=\"";
diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx
index a55b3801cc01..1d628ef49c88 100644
--- a/sw/source/filter/html/htmlftn.cxx
+++ b/sw/source/filter/html/htmlftn.cxx
@@ -327,7 +327,7 @@ void SwHTMLWriter::OutFootEndNotes()
if( m_bLFPossible )
OutNewLine();
OString sOut =
- "<" OOO_STRING_SVTOOLS_HTML_division
+ "<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_division
" " OOO_STRING_SVTOOLS_HTML_O_id "=\"";
Strm().WriteOString( sOut );
HTMLOutFuncs::Out_String( Strm(), sFootnoteName, m_eDestEnc, &m_aNonConvertableCharacters );
@@ -504,7 +504,7 @@ static void lcl_html_outFootEndNoteInfo( Writer& rWrt, OUString const *pParts,
rHTMLWrt.OutNewLine();
OString sOut =
- "<" OOO_STRING_SVTOOLS_HTML_meta " "
+ "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_meta " "
OOO_STRING_SVTOOLS_HTML_O_name "=\"" + rtl::OStringView(pName) +
"\" " OOO_STRING_SVTOOLS_HTML_O_content "=\"";
rWrt.Strm().WriteOString( sOut );
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 91dc026ba61a..0aae69b16f93 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -418,7 +418,7 @@ ErrCode SwHTMLWriter::WriteStream()
&m_aNonConvertableCharacters );
aStartTags =
- "<" OOO_STRING_SVTOOLS_HTML_division
+ "<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_division
" " OOO_STRING_SVTOOLS_HTML_O_id
"=\"" + aName + "\">" +
aStartTags;
@@ -1053,7 +1053,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
// and now ... the BASIC and JavaScript!
if( m_pDoc->GetDocShell() ) // only with DocShell BASIC is possible
- OutBasic();
+ OutBasic(*this);
DecIndentLevel(); // indent content of <HEAD>
OutNewLine();
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 27304b8705da..0f773901aa33 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -445,7 +445,7 @@ public:
void OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote, const OUString& rNum,
sal_uInt16 nScript );
- void OutBasic();
+ void OutBasic(SwHTMLWriter& rHTMLWrt);
void OutAndSetDefList( sal_uInt16 nNewLvl );
More information about the Libreoffice-commits
mailing list