[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 17 09:15:55 UTC 2020


 sw/qa/extras/htmlexport/htmlexport.cxx |   44 +++++++++++++++++++++++++++++++++
 sw/source/filter/html/htmlfldw.cxx     |    2 -
 2 files changed, 45 insertions(+), 1 deletion(-)

New commits:
commit a73483817faac173b2b9d4e970d2a05bfedc6798
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Jan 17 09:16:21 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jan 17 10:15:23 2020 +0100

    sw reqif-xhtml export: fix not needed namespace for comments
    
    In general, all "foo" elements should be started as "<reqif-xhtml:foo"
    in the reqif case, but not for comments, which stay as "<!--".
    
    Change-Id: I841c0d8e448f670b9b42cb915154e6264f7f150a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86952
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 0bf573039813..b87d1bde173a 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -14,6 +14,8 @@
 #include <com/sun/star/embed/ElementModes.hpp>
 #include <com/sun/star/io/XActiveDataStreamer.hpp>
 #include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/frame/XDispatchHelper.hpp>
+#include <com/sun/star/frame/DispatchHelper.hpp>
 
 #include <swmodule.hxx>
 #include <swdll.hxx>
@@ -23,6 +25,7 @@
 #include <tools/urlobj.hxx>
 #include <svtools/rtfkeywd.hxx>
 #include <comphelper/propertyvalue.hxx>
+#include <comphelper/propertysequence.hxx>
 
 class HtmlExportTest : public SwModelTestBase, public HtmlTestTools
 {
@@ -783,6 +786,47 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testChinese)
     CPPUNIT_ASSERT(pDoc);
 }
 
+static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rPropertyValues)
+{
+    uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController();
+    CPPUNIT_ASSERT(xController.is());
+    uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xFrame.is());
+
+    uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
+    uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext));
+    CPPUNIT_ASSERT(xDispatchHelper.is());
+
+    xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues);
+}
+
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifComment)
+{
+    // Create a document with a comment in it.
+    loadURL("private:factory/swriter", nullptr);
+    uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence(
+    {
+        {"Text", uno::makeAny(OUString("some text"))},
+        {"Author", uno::makeAny(OUString("me"))},
+    });
+    lcl_dispatchCommand(mxComponent, ".uno:InsertAnnotation", aPropertyValues);
+
+    // 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/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx
index ee67b6f08374..67d79cc28c04 100644
--- a/sw/source/filter/html/htmlfldw.cxx
+++ b/sw/source/filter/html/htmlfldw.cxx
@@ -510,7 +510,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
             OUString sComment(convertLineEnd(rComment, GetSystemLineEnd()));
             // TODO: ???
             OString sOut =
-                "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_comment
+                "<" OOO_STRING_SVTOOLS_HTML_comment
                 " " +
                 OUStringToOString(sComment, static_cast<SwHTMLWriter&>(rWrt).m_eDestEnc) +
                 " -->";


More information about the Libreoffice-commits mailing list