[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 24 09:07:26 UTC 2020


 sw/qa/extras/htmlexport/htmlexport.cxx |   29 +++++++++++++++++++++++++++++
 sw/source/filter/html/htmlatr.cxx      |    6 ++++++
 sw/source/filter/html/wrthtml.cxx      |    5 +++++
 3 files changed, 40 insertions(+)

New commits:
commit c16f0ca65acf5282a788a6032a3ef1deda70328e
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Apr 23 17:55:34 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Apr 24 09:30:03 2020 +0200

    sw html export: fix handling of paragraph alignment in XHTML mode
    
    The problem was that the <p align="..."> markup was used, while XHTML
    prefers the <p style="text-align: ..."> markup. Note that
    OutHTML_SvxAdjust() is a special case: other paragraph-level pool items
    would just call the equivalent of OutCSS1_SvxAdjust().
    
    Fix the problem by bringing the paragraph alignment case close to e.g.
    SvxULSpace handling, which is the m_bNoAlign == true case.
    
    On top of this the reqif-xhtml output is then valid out of the box,
    since IgnorePropertyForReqIF() already filters out not allowed CSS
    properties.
    
    (cherry picked from commit 9d38360e2ed06b2083d56b637f009411d41f36eb)
    
    Conflicts:
            sw/source/filter/html/htmlatr.cxx
            sw/source/filter/html/wrthtml.cxx
    
    Change-Id: I5fb4314bec172affcd03b1c49b986406a93c2b12

diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 7d707888dea5..92375cbe2c81 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -19,6 +19,7 @@
 #include <rtl/byteseq.hxx>
 #include <com/sun/star/frame/XDispatchHelper.hpp>
 #include <com/sun/star/frame/DispatchHelper.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
 
 #include <swmodule.hxx>
 #include <swdll.hxx>
@@ -880,6 +881,34 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifFontNameSize)
     assertXPath(pDoc, "//reqif-xhtml:span", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifParagraphAlignment)
+{
+    // Create a document with an explicitly aligned paragraph.
+    loadURL("private:factory/swriter", nullptr);
+    uno::Reference<beans::XPropertySet> xParagraph(getParagraph(1), uno::UNO_QUERY);
+    xParagraph->setPropertyValue(
+        "ParaAdjust", uno::makeAny(static_cast<sal_Int16>(style::ParagraphAdjust_RIGHT)));
+
+    // 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);
+
+    // Make sure the output is well-formed.
+    CPPUNIT_ASSERT(pDoc);
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected:
+    // - Actual  : right
+    // i.e. the <reqif-xhtml:p align="..."> markup was used, which is invalid.
+    assertXPathNoAttribute(pDoc, "//reqif-xhtml:p", "align");
+}
+
 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 f34d978e9806..ffadbfff3636 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -436,6 +436,12 @@ void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
     bool bNoEndTag = false;         // don't output an end tag
 
     rHWrt.m_bNoAlign = false;       // no ALIGN=... possible
+
+    if (rHWrt.mbXHTML)
+    {
+        rHWrt.m_bNoAlign = true;
+    }
+
     bool bNoStyle = false;          // no STYLE=... possible
     sal_uInt8 nBulletGrfLvl = 255;  // The bullet graphic we want to output
 
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 492eced82a07..513e3489f3f9 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -216,6 +216,11 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
         }
     }
 
+    if (mbXHTML)
+    {
+        m_bNoAlign = true;
+    }
+
     comphelper::SequenceAsHashMap aStoreMap(rMedium.GetArgs());
     auto it = aStoreMap.find("RTFOLEMimeType");
     if (it == aStoreMap.end())


More information about the Libreoffice-commits mailing list