summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-07-26 08:50:03 +0200
committerCaolán McNamara <caolanm@redhat.com>2022-07-26 20:41:40 +0200
commit1583cbe00ccccca56663398001137870bc78b799 (patch)
treef2d16fdecafb25a56686c1b6f6b7ab2ffa01ae2e
parenta05e47d1679103cc3eb4a54258410fbfaf1e497c (diff)
crashtest: fix crash on ODT export of forum-mso-de-84211.docx
XMLTextParagraphExport::ExportContentControl() disables the export of the <loext:list-item> XML element in autostyle mode, then it should also disable the export of the matching attributes. Change-Id: Ia65fc8bd3398df0ab1b71973695c9bc8d10deaa4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137452 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137468 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--xmloff/qa/unit/data/content-control-dropdown.docxbin0 -> 65391 bytes
-rw-r--r--xmloff/qa/unit/text.cxx19
-rw-r--r--xmloff/source/text/txtparae.cxx37
3 files changed, 39 insertions, 17 deletions
diff --git a/xmloff/qa/unit/data/content-control-dropdown.docx b/xmloff/qa/unit/data/content-control-dropdown.docx
new file mode 100644
index 000000000000..1391c90f1a63
--- /dev/null
+++ b/xmloff/qa/unit/data/content-control-dropdown.docx
Binary files differ
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index 2aed79376fe0..d5c8f0b6e22a 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -796,6 +796,25 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDateContentControlImport)
CPPUNIT_ASSERT_EQUAL(OUString("2022-05-25T00:00:00Z"), aCurrentDate);
}
+CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlAutostyleExport)
+{
+ // Given a document with a dropdown content control, and formatting that forms an autostyle in
+ // ODT:
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "content-control-dropdown.docx";
+ getComponent() = loadFromDesktop(aURL);
+
+ // When saving that document to ODT, then make sure no assertion failure happens:
+ uno::Reference<frame::XStorable> xStorable(getComponent(), uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aStoreProps = comphelper::InitPropertySequence({
+ { "FilterName", uno::Any(OUString("writer8")) },
+ });
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ // Without the accompanying fix in place, this test would have failed, we had duplicated XML
+ // attributes.
+ xStorable->storeToURL(aTempFile.GetURL(), aStoreProps);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 13378e3902e2..cf1a84b1a326 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -4013,27 +4013,30 @@ void XMLTextParagraphExport::ExportContentControl(
SvXMLElementExport aElem(GetExport(), bExport, XML_NAMESPACE_LO_EXT, XML_CONTENT_CONTROL, false,
false);
- // Export list items of dropdowns.
- uno::Sequence<beans::PropertyValues> aListItems;
- xPropertySet->getPropertyValue("ListItems") >>= aListItems;
- for (const auto& rListItem : aListItems)
+ if (bExport)
{
- comphelper::SequenceAsHashMap aMap(rListItem);
- auto it = aMap.find("DisplayText");
- OUString aValue;
- if (it != aMap.end() && (it->second >>= aValue) && !aValue.isEmpty())
+ // Export list items of dropdowns.
+ uno::Sequence<beans::PropertyValues> aListItems;
+ xPropertySet->getPropertyValue("ListItems") >>= aListItems;
+ for (const auto& rListItem : aListItems)
{
- GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_DISPLAY_TEXT, aValue);
- }
+ comphelper::SequenceAsHashMap aMap(rListItem);
+ auto it = aMap.find("DisplayText");
+ OUString aValue;
+ if (it != aMap.end() && (it->second >>= aValue) && !aValue.isEmpty())
+ {
+ GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_DISPLAY_TEXT, aValue);
+ }
- it = aMap.find("Value");
- if (it != aMap.end() && (it->second >>= aValue))
- {
- GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_VALUE, aValue);
- }
+ it = aMap.find("Value");
+ if (it != aMap.end() && (it->second >>= aValue))
+ {
+ GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_VALUE, aValue);
+ }
- SvXMLElementExport aItem(GetExport(), bExport, XML_NAMESPACE_LO_EXT, XML_LIST_ITEM, false,
- false);
+ SvXMLElementExport aItem(GetExport(), bExport, XML_NAMESPACE_LO_EXT, XML_LIST_ITEM, false,
+ false);
+ }
}
// Recurse to export content.