summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-05-10 20:39:12 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-05-12 08:50:02 +0200
commitc2cfeed369a2b0f6d91d1093d3876357277411c9 (patch)
tree2f56b19c7b38d3aeb4dd38eeeecea388723273c9
parentb69db38a38b09e158e8d46d8b717db85860ca874 (diff)
tdf#155238: Reimplement how ListAutoFormat is stored to ODF
This reimplements commits 6249858a8972aef077e0249bd93cfe8f01bce4d6 (sw: ODT import/export of DOCX's paragraph marker formatting, 2022-12-19) and 209dce614c43f63f63f5b42a746665c0ec1cbfe3 (sw: fix ODT import of paragraph marker formatting, 2022-12-20). Instead of using an empty trailing span for the ListAutoFormat data, introduce a new loext:marker-style-name attribute for text:p element, referencing a text autostyle. The problems with the previous implementation were that (1) it was impossible (or very difficult) to disambiguate several empty trailing spans, in case it was needed; and (2) this was incompatible change, with other ODF implementations treating the trailing span normally. I couldn't manage to incorporate the attribute to paragraph autostyle, because of problems referencing different autostyles one from another, so put it directly to the paragraph attributes. Change-Id: I33473147f1f774c24cbbc57bf0c4f3a1d83ce5bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151645 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151681 Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--include/xmloff/txtimp.hxx2
-rw-r--r--include/xmloff/xmltoken.hxx1
-rw-r--r--schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng9
-rw-r--r--sw/qa/extras/odfexport/data/ParagraphMarkerMarkup.fodt22
-rw-r--r--sw/qa/extras/odfexport/odfexport2.cxx10
-rw-r--r--sw/qa/extras/odfimport/data/emptyParagraphLoosesFontHeight.fodt21
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx21
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport2.cxx3
-rw-r--r--sw/source/core/unocore/unoobj.cxx71
-rw-r--r--sw/source/core/unocore/unoparagraph.cxx15
-rw-r--r--sw/source/core/unocore/unoportenum.cxx5
-rw-r--r--xmloff/inc/xmlprop.hxx1
-rw-r--r--xmloff/source/core/xmltoken.cxx1
-rw-r--r--xmloff/source/text/txtimp.cxx9
-rw-r--r--xmloff/source/text/txtparae.cxx32
-rw-r--r--xmloff/source/text/txtparai.cxx22
-rw-r--r--xmloff/source/text/txtparai.hxx1
-rw-r--r--xmloff/source/text/txtprmap.cxx2
-rw-r--r--xmloff/source/token/tokens.txt1
19 files changed, 181 insertions, 68 deletions
diff --git a/include/xmloff/txtimp.hxx b/include/xmloff/txtimp.hxx
index cc617393e1b4..218db6fa7acd 100644
--- a/include/xmloff/txtimp.hxx
+++ b/include/xmloff/txtimp.hxx
@@ -223,6 +223,8 @@ public:
const OUString& rName ) const;
XMLPropStyleContext* FindPageMaster(
const OUString& rName ) const;
+ XMLPropStyleContext* FindAutoCharStyle(const OUString& rName) const;
+
XMLPropStyleContext* FindDrawingPage(OUString const& rName) const;
const css::uno::Reference< css::container::XNameContainer> & GetParaStyles() const;
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index bd650daea6e7..ef7d48df8489 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -1208,6 +1208,7 @@ namespace xmloff::token {
XML_LINKED_CELL,
XML_LINK_TO_SOURCE_DATA,
XML_LIST,
+ XML_MARKER_STYLE_NAME,
XML_LIST_BLOCK,
XML_LIST_HEADER,
XML_LIST_INFO,
diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
index f2e54ddc9c18..d6fd19eba3ec 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -3322,4 +3322,13 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:optional>
</rng:define>
+ <!-- TODO no proposal -->
+ <rng:define name="paragraph-attrs" combine="interleave">
+ <rng:optional>
+ <rng:attribute name="loext:marker-style-name">
+ <rng:ref name="styleNameRef"/>
+ </rng:attribute>
+ </rng:optional>
+ </rng:define>
+
</rng:grammar>
diff --git a/sw/qa/extras/odfexport/data/ParagraphMarkerMarkup.fodt b/sw/qa/extras/odfexport/data/ParagraphMarkerMarkup.fodt
new file mode 100644
index 000000000000..c3a21261da26
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/ParagraphMarkerMarkup.fodt
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+ <style:style style:name="Standard" style:family="paragraph" style:class="text">
+ <style:text-properties fo:font-size="11pt"/>
+ </style:style>
+ </office:styles>
+ <office:automatic-styles>
+ <style:style style:name="T1" style:family="text">
+ <style:text-properties fo:font-size="8pt"/>
+ </style:style>
+ <style:style style:name="T2" style:family="text">
+ <style:text-properties fo:font-size="9pt" fo:color="#ff0000"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:text>
+ <text:p text:style-name="Standard" loext:marker-style-name="T2"><text:span text:style-name="T1">text</text:span></text:p>
+ </office:text>
+ </office:body>
+</office:document> \ No newline at end of file
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx
index f065b28d5308..8dff88773630 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -833,6 +833,16 @@ DECLARE_ODFEXPORT_TEST(testSectionColumnSeparator, "section-columns-separator.fo
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xColumns, "SeparatorLineIsOn"));
}
+CPPUNIT_TEST_FIXTURE(Test, testParagraphMarkerMarkupRoundtrip)
+{
+ loadAndReload("ParagraphMarkerMarkup.fodt");
+ // Test that the markup stays at save-and-reload
+ xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
+ assertXPath(pXmlDoc, "/office:document-content/office:body/office:text/text:p", "marker-style-name", "T2");
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='T2']/style:text-properties", "font-size", "9pt");
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='T2']/style:text-properties", "color", "#ff0000");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/odfimport/data/emptyParagraphLoosesFontHeight.fodt b/sw/qa/extras/odfimport/data/emptyParagraphLoosesFontHeight.fodt
new file mode 100644
index 000000000000..7843d7e00f5f
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/emptyParagraphLoosesFontHeight.fodt
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+ <style:style style:name="Standard" style:family="paragraph" style:class="text">
+ <style:text-properties fo:font-size="11pt"/>
+ </style:style>
+ </office:styles>
+ <office:automatic-styles>
+ <style:style style:name="T1" style:family="text">
+ <style:text-properties fo:font-size="8pt"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:text>
+ <text:p text:style-name="Standard"><text:span text:style-name="T1">value1</text:span><text:span text:style-name="T1"/></text:p>
+ <text:p text:style-name="Standard"><text:span text:style-name="T1"></text:span><text:span text:style-name="T1"/></text:p>
+ <text:p text:style-name="Standard"><text:span text:style-name="T1">value2</text:span><text:span text:style-name="T1"/></text:p>
+ </office:text>
+ </office:body>
+</office:document> \ No newline at end of file
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 4e87edc309dc..e38f1629bf23 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1381,5 +1381,26 @@ CPPUNIT_TEST_FIXTURE(Test, testForcepoint108)
mxComponent = mxDesktop->loadComponentFromURL(createFileURL(u"forcepoint108.fodt"), "_default", 0, {});
}
+CPPUNIT_TEST_FIXTURE(Test, testEmptyTrailingSpans)
+{
+ createSwDoc("emptyParagraphLoosesFontHeight.fodt");
+
+ CPPUNIT_ASSERT_EQUAL(3, getParagraphs());
+
+ auto xPara2 = getParagraph(2);
+ CPPUNIT_ASSERT_EQUAL(float(11), getProperty<float>(xPara2, "CharHeight"));
+ auto xRun = getRun(xPara2, 1);
+ CPPUNIT_ASSERT_EQUAL(float(8), getProperty<float>(xRun, "CharHeight"));
+ // Both empty spans merge -> no more runs
+ CPPUNIT_ASSERT_THROW(getRun(xPara2, 2), css::container::NoSuchElementException);
+
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+ auto height1 = getXPath(pXmlDoc, "/root/page/body/txt[1]/infos/bounds", "height").toInt32();
+ auto height2 = getXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds", "height").toInt32();
+ CPPUNIT_ASSERT_EQUAL(height1, height2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(184, height2, 1); // allow a bit of room for rounding just in case
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index 5b47a78aa7e6..550246983796 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -841,8 +841,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo64238_b, "fdo64238_b.docx")
xRunEnum->nextElement();
numOfRuns++;
}
- // "This is the ", "ODD", " [", "LEFT", "] header" and the colored paragraph marker
- CPPUNIT_ASSERT_EQUAL(sal_Int32(6), numOfRuns);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(5), numOfRuns);
}
DECLARE_OOXMLEXPORT_TEST(testFdo56679, "fdo56679.docx")
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 51ef4da39402..4315d173796d 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -230,57 +230,6 @@ lcl_setAutoStyle(IStyleAccess & rStyleAccess, const uno::Any & rValue,
rSet.Put(aFormat);
};
-/// Tries to map rValue to RES_PARATR_LIST_AUTOFMT on the current paragraph, returns true on
-/// success.
-static bool lcl_setListAutoStyle(SwPaM& rPam, const uno::Any& rValue, SfxItemSet& rItemSet)
-{
- // See if this is an empty range at the end of a paragraph.
- if (rPam.Start()->GetNodeIndex() != rPam.End()->GetNodeIndex())
- {
- return false;
- }
-
- if (rPam.Start()->GetContentIndex() != rPam.End()->GetContentIndex())
- {
- return false;
- }
-
- SwTextNode* pTextNode = rPam.GetPointNode().GetTextNode();
- if (!pTextNode)
- {
- return false;
- }
-
- if (rPam.Start()->GetContentIndex() != pTextNode->Len())
- {
- return false;
- }
-
- // Look up the style content based on the name.
- OUString sStyle;
- if (!(rValue >>= sStyle))
- {
- return false;
- }
-
- IStyleAccess& rStyleAccess = rPam.GetDoc().GetIStyleAccess();
- std::shared_ptr<SfxItemSet> pStyle
- = rStyleAccess.getByName(sStyle, IStyleAccess::AUTO_STYLE_CHAR);
- if (!pStyle)
- {
- return false;
- }
-
- // Set the style on the text node.
- SwFormatAutoFormat aItem(RES_PARATR_LIST_AUTOFMT);
- aItem.SetStyleHandle(pStyle);
- pTextNode->SetAttr(aItem);
- // Clear the style from the hints array. Without clearing, it would contain some style which
- // happened to be there previously.
- rItemSet.ClearItem(RES_TXTATR_AUTOFMT);
- return true;
-}
-
void
SwUnoCursorHelper::SetTextFormatColl(const uno::Any & rAny, SwPaM & rPaM)
{
@@ -499,11 +448,6 @@ SwUnoCursorHelper::SetCursorPropertyValue(
lcl_setCharStyle(rPam.GetDoc(), rValue, rItemSet);
break;
case RES_TXTATR_AUTOFMT:
- if (lcl_setListAutoStyle(rPam, rValue, rItemSet))
- {
- break;
- }
-
lcl_setAutoStyle(rPam.GetDoc().GetIStyleAccess(),
rValue, rItemSet, false);
break;
@@ -567,8 +511,8 @@ SwUnoCursorHelper::SetCursorPropertyValue(
}
else if (FN_UNO_PARA_NUM_AUTO_FORMAT == rEntry.nWID)
{
- uno::Sequence<beans::NamedValue> props;
- if (rValue >>= props)
+ std::shared_ptr<SfxItemSet> pAutoStyle;
+ if (uno::Sequence<beans::NamedValue> props; rValue >>= props)
{
// TODO create own map for this, it contains UNO_NAME_DISPLAY_NAME? or make property readable so ODF export can map it to a automatic style?
SfxItemPropertySet const& rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE));
@@ -603,8 +547,15 @@ SwUnoCursorHelper::SetCursorPropertyValue(
IStyleAccess& rStyleAccess = rPam.GetDoc().GetIStyleAccess();
// Add it to the autostyle pool, needed by the ODT export.
- const std::shared_ptr<SfxItemSet> pAutoStyle
- = rStyleAccess.getAutomaticStyle(items, IStyleAccess::AUTO_STYLE_CHAR);
+ pAutoStyle = rStyleAccess.getAutomaticStyle(items, IStyleAccess::AUTO_STYLE_CHAR);
+ }
+ else if (OUString styleName; rValue >>= styleName)
+ {
+ IStyleAccess& rStyleAccess = rPam.GetDoc().GetIStyleAccess();
+ pAutoStyle = rStyleAccess.getByName(styleName, IStyleAccess::AUTO_STYLE_CHAR);
+ }
+ if (pAutoStyle)
+ {
SwFormatAutoFormat item(RES_PARATR_LIST_AUTOFMT);
// note: paragraph auto styles have ParaStyleName property for the parent style; character auto styles currently do not because there's a separate hint, but for this it would be a good way to add it in order to export it as style:parent-style-name, see XMLTextParagraphExport::Add()
item.SetStyleHandle(pAutoStyle);
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index a41f11ef873c..c3d35d47075c 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -26,6 +26,7 @@
#include <comphelper/diagnose_ex.hxx>
#include <cmdid.h>
+#include <fmtautofmt.hxx>
#include <unomid.h>
#include <unoparaframeenum.hxx>
#include <unotext.hxx>
@@ -539,6 +540,20 @@ uno::Sequence< uno::Any > SwXParagraph::Impl::GetPropertyValues_Impl(
const SwAttrSet& rAttrSet( rTextNode.GetSwAttrSet() );
for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
{
+ if (pPropertyNames[nProp] == "ParaMarkerAutoStyleSpan")
+ {
+ // A hack to tunnel the fake text span to ODF export
+ // see XMLTextParagraphExport::exportParagraph
+ if (rTextNode.GetAttr(RES_PARATR_LIST_AUTOFMT).GetStyleHandle())
+ {
+ SwUnoCursor aEndCursor(*aPam.GetMark());
+ css::uno::Reference<css::beans::XPropertySet> xFakeSpan(
+ new SwXTextPortion(&aEndCursor, {}, PORTION_LIST_AUTOFMT));
+ pValues[nProp] <<= xFakeSpan;
+ }
+ continue;
+ }
+
SfxItemPropertyMapEntry const*const pEntry =
rMap.getByName( pPropertyNames[nProp] );
if (!pEntry)
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index fc0239370eaa..3b439d454336 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -1513,11 +1513,6 @@ static void lcl_CreatePortions(
// text portion because there may be a hyperlink attribute
xRef = new SwXTextPortion(pUnoCursor, i_xParentText, PORTION_TEXT);
}
- else if (bAtEnd && !xRef.is() && pTextNode->GetSwAttrSet().HasItem(RES_PARATR_LIST_AUTOFMT))
- {
- // We have explicit paragraph marker formatting, export it.
- xRef = new SwXTextPortion(pUnoCursor, i_xParentText, PORTION_LIST_AUTOFMT);
- }
else if (bAtEnd && !xRef.is() && pHints)
{
// See if there is an empty autofmt at the paragraph end. If so, export it, since that
diff --git a/xmloff/inc/xmlprop.hxx b/xmloff/inc/xmlprop.hxx
index 4325a00d82b5..868f619a7246 100644
--- a/xmloff/inc/xmlprop.hxx
+++ b/xmloff/inc/xmlprop.hxx
@@ -432,6 +432,7 @@ inline constexpr OUStringLiteral PROP_LineTransparence = u"LineTransparence";
inline constexpr OUStringLiteral PROP_LineWidth = u"LineWidth";
inline constexpr OUStringLiteral PROP_Lines = u"Lines";
inline constexpr OUStringLiteral PROP_LinkNumberFormatToSource = u"LinkNumberFormatToSource";
+inline constexpr OUStringLiteral PROP_ListAutoFormat = u"ListAutoFormat";
inline constexpr OUStringLiteral PROP_Logarithmic = u"Logarithmic";
inline constexpr OUStringLiteral PROP_MajorOrigin = u"MajorOrigin";
inline constexpr OUStringLiteral PROP_MarkPosition = u"MarkPosition";
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 1dc56ced1114..93d23f0a044b 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -1221,6 +1221,7 @@ namespace xmloff::token {
TOKEN( "linked-cell", XML_LINKED_CELL ),
TOKEN( "link-to-source-data", XML_LINK_TO_SOURCE_DATA ),
TOKEN( "list", XML_LIST ),
+ TOKEN( "marker-style-name", XML_MARKER_STYLE_NAME ),
TOKEN( "list-block", XML_LIST_BLOCK ),
TOKEN( "list-header", XML_LIST_HEADER ),
TOKEN( "list-info", XML_LIST_INFO ),
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index 87fd2b91283a..e0df349b63e4 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -2031,6 +2031,15 @@ XMLPropStyleContext* XMLTextImportHelper::FindPageMaster(
return pStyle;
}
+XMLPropStyleContext* XMLTextImportHelper::FindAutoCharStyle(const OUString& rName) const
+{
+ if (!m_xImpl->m_xAutoStyles)
+ return nullptr;
+ auto pStyle
+ = m_xImpl->m_xAutoStyles->FindStyleChildContext(XmlStyleFamily::TEXT_TEXT, rName, true);
+ return dynamic_cast<XMLPropStyleContext*>(const_cast<SvXMLStyleContext*>(pStyle));
+}
+
XMLPropStyleContext * XMLTextImportHelper::FindDrawingPage(OUString const& rName) const
{
if (!m_xImpl->m_xAutoStyles.is())
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 482a1fa71897..ee074c0b412d 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/UnknownPropertyException.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextSectionsSupplier.hpp>
@@ -2187,6 +2188,37 @@ void XMLTextParagraphExport::exportParagraph(
}
}
}
+
+ if (GetExport().getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
+ {
+ try
+ {
+ // ParaMarkerAutoStyleSpan is a hidden property, just to pass the autostyle here
+ // See SwXParagraph::Impl::GetPropertyValues_Impl
+ css::uno::Any aVal = xPropSet->getPropertyValue("ParaMarkerAutoStyleSpan");
+ if (css::uno::Reference<css::beans::XPropertySet> xFakeSpan{ aVal, css::uno::UNO_QUERY })
+ {
+ if (bAutoStyles)
+ {
+ Add(XmlStyleFamily::TEXT_TEXT, xFakeSpan);
+ }
+ else
+ {
+ bool bIsUICharStyle, bHasAutoStyle;
+ OUString sStyle = FindTextStyle(xFakeSpan, bIsUICharStyle, bHasAutoStyle);
+ if (!sStyle.isEmpty())
+ {
+ GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_MARKER_STYLE_NAME,
+ sStyle);
+ }
+ }
+ }
+ }
+ catch (const css::beans::UnknownPropertyException&)
+ {
+ // No problem
+ }
+ }
}
Reference < XEnumerationAccess > xEA( rTextContent, UNO_QUERY );
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 5fffc202612a..1a0801646943 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -41,6 +41,7 @@
#include <sax/tools/converter.hxx>
+#include <xmloff/prstylei.hxx>
#include <xmloff/xmlictxt.hxx>
#include <xmloff/xmlimp.hxx>
#include <xmloff/xmltoken.hxx>
@@ -1675,6 +1676,10 @@ XMLParaContext::XMLParaContext(
nStartValue = sal::static_int_cast< sal_Int16 >(aIter.toInt32());
}
break;
+ case XML_ELEMENT(LO_EXT, XML_MARKER_STYLE_NAME):
+ if (auto pStyle = rImport.GetTextImport()->FindAutoCharStyle(aIter.toString()))
+ m_aMarkerStyleName = pStyle->GetAutoName();
+ break;
default:
XMLOFF_WARN_UNKNOWN("xmloff", aIter);
}
@@ -1720,6 +1725,21 @@ void XMLParaContext::endFastElement(sal_Int32 )
// insert a paragraph break
xTxtImport->InsertControlCharacter( ControlCharacter::APPEND_PARAGRAPH );
+ if (!m_aMarkerStyleName.isEmpty())
+ {
+ if (css::uno::Reference<css::beans::XPropertySet> xPropSet{ xStart, css::uno::UNO_QUERY })
+ {
+ try
+ {
+ xPropSet->setPropertyValue("ListAutoFormat", css::uno::Any(m_aMarkerStyleName));
+ }
+ catch (const css::beans::UnknownPropertyException&)
+ {
+ // no problem
+ }
+ }
+ }
+
// create a cursor that select the whole last paragraph
Reference < XTextCursor > xAttrCursor;
try {
@@ -1832,7 +1852,7 @@ void XMLParaContext::endFastElement(sal_Int32 )
{
bool bSetNoFormatAttr = false;
uno::Reference<beans::XPropertySet> xCursorProps(xAttrCursor, uno::UNO_QUERY);
- if (m_xHints->GetHints().size() > 1)
+ if (m_xHints->GetHints().size() > 1 || !m_aMarkerStyleName.isEmpty())
{
// We have multiple hints, then make try to ask the cursor to not upgrade our character
// attributes to paragraph-level formatting, which would lead to incorrect rendering.
diff --git a/xmloff/source/text/txtparai.hxx b/xmloff/source/text/txtparai.hxx
index 66c64181c4ba..4cf406027a2b 100644
--- a/xmloff/source/text/txtparai.hxx
+++ b/xmloff/source/text/txtparai.hxx
@@ -42,6 +42,7 @@ class XMLParaContext : public SvXMLImportContext
OUString m_sProperty;
OUString m_sContent;
OUString m_sDatatype;
+ OUString m_aMarkerStyleName;
bool m_bHaveAbout;
sal_Int8 nOutlineLevel;
std::unique_ptr<XMLHints_Impl> m_xHints;
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index 820506c8ea8a..b961a2c60944 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -463,6 +463,8 @@ XMLPropertyMapEntry const aXMLParaPropMap[] =
MP_ED( PROP_FontIndependentLineSpacing, STYLE, FONT_INDEPENDENT_LINE_SPACING, XML_TYPE_BOOL, 0 ),
+ MAP_EXT( PROP_ListAutoFormat, XML_NAMESPACE_LO_EXT, XML_MARKER_STYLE_NAME, XML_TYPE_STYLENAME|XML_TYPE_PROP_PARAGRAPH, 0 ),
+
M_END()
};
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 5fef52535c63..27fc8621e638 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -1121,6 +1121,7 @@ lines-used
linked-cell
link-to-source-data
list
+marker-style-name
list-block
list-header
list-info