diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-03-10 16:29:48 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-03-10 20:10:16 +0100 |
commit | 8f48f91009caa86d896f247059874242ed18bf39 (patch) | |
tree | ace1b39f63ca0f0228cb7fbc8c8b2c46728e3e7c /xmloff/qa/unit/text.cxx | |
parent | 6e8ae79176be1c34cadc833c8e521be19455fade (diff) |
ODT export: omit unreferenced <text:list xml:id="...">
This attribute is needed when a numbering is built using multiple,
independent <text:list> elements. In that case the markup to connect
these are either:
<text:list text:style-name="L1">
</text:list>
...
<text:list text:continue-numbering="true" text:style-name="L1">
</text:list>
In case there is no other list in-between, or:
<text:list xml:id="..." text:style-name="L1">
</text:list>
...
<text:list text:continue-list="..." text:style-name="L1">
</text:list>
In case there are other lists in-between.
This means that at least in case all the text nodes of the numbering are
after each other, then the random value in xml:id="..." is never
referenced, so it can be omitted.
This helps deterministic ODF output when the input is HTML, where there
are never text:continue-list="..." attributes that would refer to these
xml:id="..." attributes.
Change-Id: Ice69422a12d4229879f89f3a4a24ed926c6d43af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131322
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'xmloff/qa/unit/text.cxx')
-rw-r--r-- | xmloff/qa/unit/text.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index 1d239e2e0c09..71772edb3585 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -245,6 +245,30 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testContinueNumberingWord) CPPUNIT_ASSERT_EQUAL(OUString("2."), aActual); } +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testListId) +{ + // Given a document with a simple list (no continue-list="..." attribute): + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "list-id.fodt"; + getComponent() = loadFromDesktop(aURL); + + // When storing that document as ODF: + uno::Reference<frame::XStorable> xStorable(getComponent(), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aStoreProps = comphelper::InitPropertySequence({ + { "FilterName", uno::makeAny(OUString("writer8")) }, + }); + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + xStorable->storeToURL(aTempFile.GetURL(), aStoreProps); + + // Then make sure that unreferenced xml:id="..." attributes are not written: + std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, "content.xml"); + xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + // Without the accompanying fix in place, this failed with: + // - XPath '//text:list' unexpected 'id' attribute + // i.e. xml:id="..." was written unconditionally, even when no other list needed it. + assertXPathNoAttribute(pXmlDoc, "//text:list", "id"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |