[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Jul 11 09:30:31 UTC 2018
sw/qa/extras/htmlexport/data/reqif-p.xhtml | 1 +
sw/qa/extras/htmlexport/htmlexport.cxx | 4 ++++
sw/source/filter/html/wrthtml.cxx | 18 +++++++++++++++---
3 files changed, 20 insertions(+), 3 deletions(-)
New commits:
commit bbcab55e7e1b8e062c066dae841ff1318ef4c42a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jul 10 13:54:54 2018 +0200
sw HTML export: fix bookmark output in XHTML mode
Missing XML namespace, wrong attribute name, missing escaping for the
bookmark name.
Change-Id: I639c147574e059083646b4c33ede9d478d6c0c38
Reviewed-on: https://gerrit.libreoffice.org/57230
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins
(cherry picked from commit 967eb080ac91e3b59fb244dc6d6106a264d0fbf1)
diff --git a/sw/qa/extras/htmlexport/data/reqif-p.xhtml b/sw/qa/extras/htmlexport/data/reqif-p.xhtml
index fa69342d00a6..304857d9a9f8 100644
--- a/sw/qa/extras/htmlexport/data/reqif-p.xhtml
+++ b/sw/qa/extras/htmlexport/data/reqif-p.xhtml
@@ -5,3 +5,4 @@
<reqif-xhtml:strong>s</reqif-xhtml:strong>
<reqif-xhtml:strike>s</reqif-xhtml:strike>
<reqif-xhtml:font color="#ce181e">s</reqif-xhtml:font>
+<reqif-xhtml:a name="Bookmark 1"></reqif-xhtml:a>
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index bf46da807fa6..161d1fc098e5 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -372,6 +372,10 @@ DECLARE_HTMLEXPORT_TEST(testReqIfParagraph, "reqif-p.xhtml")
// This was "<font>" instead of CSS + namespace prefix was missing.
CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:span style=\"color: #ce181e\"") != -1);
+
+ // This was '<a name="Bookmark 1"': missing namespace prefix, wrong
+ // attribute name, wrong attribute value.
+ CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:a id=\"Bookmark_1\"></reqif-xhtml:a>") != -1);
}
DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOleData, "reqif-ole-data.xhtml")
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index ab71a1a96b22..20b96a248045 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -1120,9 +1120,21 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
void SwHTMLWriter::OutAnchor( const OUString& rName )
{
OStringBuffer sOut;
- sOut.append("<" OOO_STRING_SVTOOLS_HTML_anchor " " OOO_STRING_SVTOOLS_HTML_O_name "=\"");
- Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
- HTMLOutFuncs::Out_String( Strm(), rName, m_eDestEnc, &m_aNonConvertableCharacters ).WriteCharPtr( "\">" );
+ sOut.append("<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor " ");
+ if (!mbXHTML)
+ {
+ sOut.append(OOO_STRING_SVTOOLS_HTML_O_name "=\"");
+ Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
+ HTMLOutFuncs::Out_String( Strm(), rName, m_eDestEnc, &m_aNonConvertableCharacters ).WriteCharPtr( "\">" );
+ }
+ else
+ {
+ // XHTML wants 'id' instead of 'name', also the value can't contain
+ // spaces.
+ sOut.append(OOO_STRING_SVTOOLS_HTML_O_id "=\"");
+ Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
+ HTMLOutFuncs::Out_String( Strm(), rName.replace(' ', '_'), m_eDestEnc, &m_aNonConvertableCharacters ).WriteCharPtr( "\">" );
+ }
HTMLOutFuncs::Out_AsciiTag( Strm(), GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor, false );
}
More information about the Libreoffice-commits
mailing list