diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-09-22 10:01:26 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-09-22 12:29:15 +0200 |
commit | 01b1f57a90172a76faa1489b3b72250ee76169a6 (patch) | |
tree | 0f67e749f0ba0272aa314285bb52df3fa704f9d1 /sw | |
parent | 21d93d8d2ffd9c5d5cfe9064590b35e0727295c9 (diff) |
sw content controls, combo box: add DOCX filter
Map the ComboBox UNO property to:
<w:sdtPr>
<w:comboBox>
...
</w:comboBox>
</w:sdtPr>
and the opposite on import.
Change-Id: I50e0b961bca99f4ecca86d6784d2e6a13f469314
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140399
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/filter/ww8/ww8.cxx | 26 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 18 |
2 files changed, 42 insertions, 2 deletions
diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index 4f33e781d05d..ea8c4d9a9553 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -11,6 +11,10 @@ #include <com/sun/star/text/XTextDocument.hpp> +#include <docsh.hxx> +#include <formatcontentcontrol.hxx> +#include <wrtsh.hxx> + namespace { constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/filter/ww8/data/"; @@ -81,6 +85,28 @@ CPPUNIT_TEST_FIXTURE(Test, testPlainTextContentControlExport) // i.e. the plain text content control was turned into a rich text one on export. assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:text", 1); } + +CPPUNIT_TEST_FIXTURE(Test, testDocxComboBoxContentControlExport) +{ + // Given a document with a combo box content control around a text portion: + mxComponent = loadFromDesktop("private:factory/swriter"); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->InsertContentControl(SwContentControlType::COMBO_BOX); + + // When exporting to DOCX: + save("Office Open XML Text", maTempFile); + mbExported = true; + + // Then make sure the expected markup is used: + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // - XPath '//w:sdt/w:sdtPr/w:comboBox' number of nodes is incorrect + // i.e. the combo box content control was turned into a drop-down one on export. + assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:comboBox", 1); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index f8fc5429fb97..5833dd62dbca 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2393,14 +2393,28 @@ void DocxAttributeOutput::WriteContentControlStart() if (m_pContentControl->HasListItems()) { - m_pSerializer->startElementNS(XML_w, XML_dropDownList); + if (m_pContentControl->GetComboBox()) + { + m_pSerializer->startElementNS(XML_w, XML_comboBox); + } + else + { + m_pSerializer->startElementNS(XML_w, XML_dropDownList); + } for (const auto& rItem : m_pContentControl->GetListItems()) { m_pSerializer->singleElementNS(XML_w, XML_listItem, FSNS(XML_w, XML_displayText), rItem.m_aDisplayText, FSNS(XML_w, XML_value), rItem.m_aValue); } - m_pSerializer->endElementNS(XML_w, XML_dropDownList); + if (m_pContentControl->GetComboBox()) + { + m_pSerializer->endElementNS(XML_w, XML_comboBox); + } + else + { + m_pSerializer->endElementNS(XML_w, XML_dropDownList); + } } if (m_pContentControl->GetDate()) |