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
This commit is contained in:
parent
a66c2f5511
commit
6cf1f3c09c
3 changed files with 39 additions and 17 deletions
BIN
xmloff/qa/unit/data/content-control-dropdown.docx
Normal file
BIN
xmloff/qa/unit/data/content-control-dropdown.docx
Normal file
Binary file not shown.
|
@ -862,6 +862,25 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPlainTextContentControlImport)
|
||||||
CPPUNIT_ASSERT(bPlainText);
|
CPPUNIT_ASSERT(bPlainText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
|
|
@ -4022,27 +4022,30 @@ void XMLTextParagraphExport::ExportContentControl(
|
||||||
SvXMLElementExport aElem(GetExport(), bExport, XML_NAMESPACE_LO_EXT, XML_CONTENT_CONTROL, false,
|
SvXMLElementExport aElem(GetExport(), bExport, XML_NAMESPACE_LO_EXT, XML_CONTENT_CONTROL, false,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
// Export list items of dropdowns.
|
if (bExport)
|
||||||
uno::Sequence<beans::PropertyValues> aListItems;
|
|
||||||
xPropertySet->getPropertyValue("ListItems") >>= aListItems;
|
|
||||||
for (const auto& rListItem : aListItems)
|
|
||||||
{
|
{
|
||||||
comphelper::SequenceAsHashMap aMap(rListItem);
|
// Export list items of dropdowns.
|
||||||
auto it = aMap.find("DisplayText");
|
uno::Sequence<beans::PropertyValues> aListItems;
|
||||||
OUString aValue;
|
xPropertySet->getPropertyValue("ListItems") >>= aListItems;
|
||||||
if (it != aMap.end() && (it->second >>= aValue) && !aValue.isEmpty())
|
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");
|
it = aMap.find("Value");
|
||||||
if (it != aMap.end() && (it->second >>= aValue))
|
if (it != aMap.end() && (it->second >>= aValue))
|
||||||
{
|
{
|
||||||
GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_VALUE, aValue);
|
GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_VALUE, aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
SvXMLElementExport aItem(GetExport(), bExport, XML_NAMESPACE_LO_EXT, XML_LIST_ITEM, false,
|
SvXMLElementExport aItem(GetExport(), bExport, XML_NAMESPACE_LO_EXT, XML_LIST_ITEM, false,
|
||||||
false);
|
false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recurse to export content.
|
// Recurse to export content.
|
||||||
|
|
Loading…
Reference in a new issue