summaryrefslogtreecommitdiff
path: root/xmloff/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-03-10 16:29:48 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-03-10 20:10:16 +0100
commit8f48f91009caa86d896f247059874242ed18bf39 (patch)
treeace1b39f63ca0f0228cb7fbc8c8b2c46728e3e7c /xmloff/source
parent6e8ae79176be1c34cadc833c8e521be19455fade (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/source')
-rw-r--r--xmloff/source/text/XMLTextNumRuleInfo.cxx11
-rw-r--r--xmloff/source/text/XMLTextNumRuleInfo.hxx4
-rw-r--r--xmloff/source/text/txtparae.cxx4
3 files changed, 16 insertions, 3 deletions
diff --git a/xmloff/source/text/XMLTextNumRuleInfo.cxx b/xmloff/source/text/XMLTextNumRuleInfo.cxx
index c6889abbbc9e..062b92879ee2 100644
--- a/xmloff/source/text/XMLTextNumRuleInfo.cxx
+++ b/xmloff/source/text/XMLTextNumRuleInfo.cxx
@@ -21,6 +21,7 @@
#include <osl/diagnose.h>
#include <sal/log.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/container/XIndexReplace.hpp>
#include <com/sun/star/style/NumberingType.hpp>
@@ -37,7 +38,8 @@ using namespace ::com::sun::star::style;
// Complete refactoring of the class and enhancement of the class for lists.
XMLTextNumRuleInfo::XMLTextNumRuleInfo()
- : mnListStartValue( -1 )
+ : mbListIdIsDefault(false)
+ , mnListStartValue( -1 )
, mnListLevel( 0 )
, mbIsNumbered( false )
, mbIsRestart( false )
@@ -59,6 +61,7 @@ void XMLTextNumRuleInfo::Set(
mbOutlineStyleAsNormalListStyle = bOutlineStyleAsNormalListStyle;
Reference< XPropertySet > xPropSet( xTextContent, UNO_QUERY );
+ Reference<XPropertyState> xPropState(xTextContent, UNO_QUERY);
Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
// check if this paragraph supports a numbering
@@ -135,6 +138,12 @@ void XMLTextNumRuleInfo::Set(
if( xPropSetInfo->hasPropertyByName( "ListId" ) )
{
xPropSet->getPropertyValue( "ListId" ) >>= msListId;
+
+ if (xPropState.is())
+ {
+ mbListIdIsDefault
+ = xPropState->getPropertyState("ListId") == PropertyState_DEFAULT_VALUE;
+ }
}
mbContinueingPreviousSubTree = false;
diff --git a/xmloff/source/text/XMLTextNumRuleInfo.hxx b/xmloff/source/text/XMLTextNumRuleInfo.hxx
index 53ad8e97f188..adb405411164 100644
--- a/xmloff/source/text/XMLTextNumRuleInfo.hxx
+++ b/xmloff/source/text/XMLTextNumRuleInfo.hxx
@@ -43,6 +43,8 @@ class XMLTextNumRuleInfo
// paragraph's list attributes
OUString msListId;
+ /// msListId won't be referenced by later lists.
+ bool mbListIdIsDefault;
sal_Int16 mnListStartValue;
sal_Int16 mnListLevel;
bool mbIsNumbered;
@@ -83,6 +85,8 @@ public:
return msListId;
}
+ bool IsListIdDefault() const { return mbListIdIsDefault; }
+
sal_Int16 GetLevel() const
{
return mnListLevel;
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 732c119cdb58..f8e46fb71844 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -932,7 +932,7 @@ void XMLTextParagraphExport::exportListChange(
{
if ( bExportODF &&
eODFDefaultVersion >= SvtSaveOptions::ODFSVER_012 &&
- !sListId.isEmpty() )
+ !sListId.isEmpty() && !rNextInfo.IsListIdDefault() )
{
/* Property text:id at element <text:list> has to be
replaced by property xml:id (#i92221#)
@@ -951,7 +951,7 @@ void XMLTextParagraphExport::exportListChange(
mpTextListsHelper->GenerateNewListId() );
if ( bExportODF &&
eODFDefaultVersion >= SvtSaveOptions::ODFSVER_012 &&
- !sListId.isEmpty() )
+ !sListId.isEmpty() && !rNextInfo.IsListIdDefault() )
{
/* Property text:id at element <text:list> has to be
replaced by property xml:id (#i92221#)