sw/source/filter/html/wrthtml.cxx |  120 +++++++++++++++++++++++++++++---------
 sw/source/filter/html/wrthtml.hxx |    2 
 2 files changed, 94 insertions(+), 28 deletions(-)

New commits:
commit 22d09d65c0e61cac1fa27af6a04a23e16f97c907
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Feb 15 10:00:33 2022 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Feb 15 11:49:23 2022 +0100

    sw HTML export: extract a SetupFilterFromPropertyValues()
    
    From the two SetupFilterOptions() overloads, which meant that some
    options were only possible to set from FilterOptions, and others were
    only possible to set via UNO property values.
    
    Change-Id: Ib7cdbb082e93b9ff105afe72f295994733b4525a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129955
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/filter/html/wrthtml.cxx 
b/sw/source/filter/html/wrthtml.cxx
index 2808da051611..af92e3d46330 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -194,7 +194,53 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
     const OUString sFilterOptions = static_cast<const 
SfxStringItem*>(pItem)->GetValue();
     SetupFilterOptions(sFilterOptions);
 
-    comphelper::SequenceAsHashMap aStoreMap(rMedium.GetArgs());
+    SetupFilterFromPropertyValues(rMedium.GetArgs());
+}
+
+void SwHTMLWriter::SetupFilterOptions(const OUString& rFilterOptions)
+{
+    comphelper::SequenceAsHashMap aStoreMap;
+    if (rFilterOptions.indexOf("SkipImages") >= 0)
+    {
+        aStoreMap["SkipImages"] <<= true;
+    }
+    else if (rFilterOptions.indexOf("SkipHeaderFooter") >= 0)
+    {
+        aStoreMap["SkipHeaderFooter"] <<= true;
+    }
+    else if (rFilterOptions.indexOf("EmbedImages") >= 0)
+    {
+        aStoreMap["EmbedImages"] <<= true;
+    }
+
+    // this option can be "on" together with any of above
+    if (rFilterOptions.indexOf("NoLineLimit") >= 0)
+    {
+        aStoreMap["NoLineLimit"] <<= true;
+    }
+
+    const uno::Sequence<OUString> aOptionSeq
+        = comphelper::string::convertCommaSeparated(rFilterOptions);
+    static const OUStringLiteral aXhtmlNsKey(u"xhtmlns=");
+    for (const auto& rOption : aOptionSeq)
+    {
+        if (rOption == "XHTML")
+        {
+            aStoreMap["XHTML"] <<= true;
+        }
+        else if (rOption.startsWith(aXhtmlNsKey))
+        {
+            aStoreMap["XhtmlNs"] <<= rOption.copy(aXhtmlNsKey.getLength());
+        }
+    }
+
+    SetupFilterFromPropertyValues(aStoreMap.getAsConstPropertyValueList());
+}
+
+void SwHTMLWriter::SetupFilterFromPropertyValues(
+    const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues)
+{
+    comphelper::SequenceAsHashMap aStoreMap(rPropertyValues);
     auto it = aStoreMap.find("RTFOLEMimeType");
     if (it != aStoreMap.end())
     {
@@ -214,47 +260,65 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
         it->second >>= nVal;
         m_nShapeDPI.emplace(nVal);
     }
-}
 
-void SwHTMLWriter::SetupFilterOptions(const OUString& rFilterOptions)
-{
-    if (rFilterOptions.indexOf("SkipImages") >= 0)
+    it = aStoreMap.find("SkipImages");
+    if (it != aStoreMap.end())
     {
-        mbSkipImages = true;
+        bool bVal{};
+        it->second >>= bVal;
+        mbSkipImages = bVal;
     }
-    else if (rFilterOptions.indexOf("SkipHeaderFooter") >= 0)
+
+    it = aStoreMap.find("SkipHeaderFooter");
+    if (it != aStoreMap.end())
     {
-        mbSkipHeaderFooter = true;
+        bool bVal{};
+        it->second >>= bVal;
+        mbSkipHeaderFooter = bVal;
     }
-    else if (rFilterOptions.indexOf("EmbedImages") >= 0)
+
+    it = aStoreMap.find("EmbedImages");
+    if (it != aStoreMap.end())
     {
-        mbEmbedImages = true;
+        bool bVal{};
+        it->second >>= bVal;
+        mbEmbedImages = bVal;
     }
 
-    // this option can be "on" together with any of above
-    if (rFilterOptions.indexOf("NoLineLimit") >= 0)
+    it = aStoreMap.find("NoLineLimit");
+    if (it != aStoreMap.end())
     {
-        m_nWishLineLen = -1;
+        bool bVal{};
+        it->second >>= bVal;
+        if (bVal)
+        {
+            m_nWishLineLen = -1;
+        }
     }
 
-    const uno::Sequence<OUString> aOptionSeq = 
comphelper::string::convertCommaSeparated(rFilterOptions);
-    static const OUStringLiteral aXhtmlNsKey(u"xhtmlns=");
-    for (const auto& rOption : aOptionSeq)
+    it = aStoreMap.find("XHTML");
+    if (it != aStoreMap.end())
     {
-        if (rOption == "XHTML")
-            mbXHTML = true;
-        else if (rOption.startsWith(aXhtmlNsKey))
+        bool bVal{};
+        it->second >>= bVal;
+        mbXHTML = bVal;
+    }
+
+    it = aStoreMap.find("XhtmlNs");
+    if (it != aStoreMap.end())
+    {
+        OUString aVal;
+        it->second >>= aVal;
+
+        maNamespace = aVal.toUtf8();
+        if (maNamespace == "reqif-xhtml")
         {
-            maNamespace = rOption.copy(aXhtmlNsKey.getLength()).toUtf8();
-            if (maNamespace == "reqif-xhtml")
-            {
-                mbReqIF = true;
-                // XHTML is always just a fragment inside ReqIF.
-                mbSkipHeaderFooter = true;
-            }
-            // XHTML namespace implies XHTML.
-            mbXHTML = true;
+            mbReqIF = true;
+            // XHTML is always just a fragment inside ReqIF.
+            mbSkipHeaderFooter = true;
         }
+        // XHTML namespace implies XHTML.
+        mbXHTML = true;
     }
 }
 
diff --git a/sw/source/filter/html/wrthtml.hxx 
b/sw/source/filter/html/wrthtml.hxx
index bf6806b1ae95..c5cd5dbe0780 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -276,6 +276,8 @@ class SW_DLLPUBLIC SwHTMLWriter : public Writer
 protected:
     ErrCode WriteStream() override;
     void SetupFilterOptions(SfxMedium& rMedium) override;
+    void SetupFilterFromPropertyValues(
+        const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues);
 
 public:
     std::vector<OUString> m_aImgMapNames;   // written image maps

Reply via email to