diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-02-15 10:00:33 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-07-07 17:04:47 +0200 |
commit | 533b2385022843274a619a788e2a1594ae9090fd (patch) | |
tree | 741b4d0a197424311f43e8bb2717cd6beb12912e /sw | |
parent | 31850ef3505bc15a75c9a9a50ed04f970670b244 (diff) |
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.
(cherry picked from commit 22d09d65c0e61cac1fa27af6a04a23e16f97c907)
Conflicts:
sw/source/filter/html/wrthtml.cxx
Change-Id: Ib7cdbb082e93b9ff105afe72f295994733b4525a
(cherry picked from commit 97fee18693461e5b0272f2826860269483ca547e)
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/html/wrthtml.cxx | 118 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.hxx | 2 |
2 files changed, 95 insertions, 25 deletions
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index 2f83734aee37..e5ac25005de0 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -194,49 +194,117 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium) const OUString sFilterOptions = static_cast<const SfxStringItem*>(pItem)->GetValue(); SetupFilterOptions(sFilterOptions); - comphelper::SequenceAsHashMap aStoreMap(rMedium.GetArgs()); - auto it = aStoreMap.find("RTFOLEMimeType"); - if (it == aStoreMap.end()) - { - return; - } - - it->second >>= m_aRTFOLEMimeType; + SetupFilterFromPropertyValues(rMedium.GetArgs()); } void SwHTMLWriter::SetupFilterOptions(const OUString& rFilterOptions) { - if (rFilterOptions == "SkipImages") + comphelper::SequenceAsHashMap aStoreMap; + if (rFilterOptions.indexOf("SkipImages") >= 0) { - mbSkipImages = true; + aStoreMap["SkipImages"] <<= true; } - else if (rFilterOptions == "SkipHeaderFooter") + else if (rFilterOptions.indexOf("SkipHeaderFooter") >= 0) { - mbSkipHeaderFooter = true; + aStoreMap["SkipHeaderFooter"] <<= true; } - else if (rFilterOptions == "EmbedImages") + else if (rFilterOptions.indexOf("EmbedImages") >= 0) { - mbEmbedImages = true; + aStoreMap["EmbedImages"] <<= true; } - const uno::Sequence<OUString> aOptionSeq = comphelper::string::convertCommaSeparated(rFilterOptions); + // 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); const OUString aXhtmlNsKey("xhtmlns="); for (const auto& rOption : aOptionSeq) { if (rOption == "XHTML") - mbXHTML = true; + { + aStoreMap["XHTML"] <<= true; + } else if (rOption.startsWith(aXhtmlNsKey)) { - 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; + 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()) + { + it->second >>= m_aRTFOLEMimeType; + } + + it = aStoreMap.find("SkipImages"); + if (it != aStoreMap.end()) + { + bool bVal{}; + it->second >>= bVal; + mbSkipImages = bVal; + } + + it = aStoreMap.find("SkipHeaderFooter"); + if (it != aStoreMap.end()) + { + bool bVal{}; + it->second >>= bVal; + mbSkipHeaderFooter = bVal; + } + + it = aStoreMap.find("EmbedImages"); + if (it != aStoreMap.end()) + { + bool bVal{}; + it->second >>= bVal; + mbEmbedImages = bVal; + } + + it = aStoreMap.find("NoLineLimit"); + if (it != aStoreMap.end()) + { + bool bVal{}; + it->second >>= bVal; + if (bVal) + { + m_nWhishLineLen = -1; + } + } + + it = aStoreMap.find("XHTML"); + if (it != aStoreMap.end()) + { + 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") + { + 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 ef5226f95674..0774efc41da1 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -288,6 +288,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 |