office-gobmx/include/xmloff
Mike Kaganski 69ed893087 tdf#160253: fix list identifier export decision code
Commits 8f48f91009 (ODT export: omit
unreferenced <text:list xml:id="...">, 2022-03-10) and
82bbf63582  (tdf#155823: Improve the
check if the list id is not required, 2023-06-14) tried to improve
deterministic ODF output, by omitting the list identifiers in case
when those identifiers were unreferenced. The latter of these used
document model node numbers to check if other lists appeared after
the last occurrence of the list  that is continuing in the current
node. But it turned out, that this isn't robust. Consider this ODF:

  <text:list xml:id="list1" text:style-name="L1">
   <text:list-item>
    <text:p>a</text:p>
   </text:list-item>
  </text:list>
  <text:p>b<text:note text:id="ftn1" text:note-class="endnote"><text:note-citation>i</text:note-citation><text:note-body>
     <text:list text:style-name="L2">
      <text:list-item>
       <text:p>x</text:p>
      </text:list-item>
     </text:list></text:note-body></text:note></text:p>
  <text:list text:continue-list="list1" text:style-name="L1">
   <text:list-item>
    <text:p>c</text:p>
   </text:list-item>
  </text:list>

The paragraphs a, b, and c are all in the main document body,  and
have sequential document model node numbers  (say, 15, 16, 17). If
these numbers are checked,  there is no node between node 15 ("a")
and node 17 ("c") with a different list  (both 15 and 17 belong to
a list with style "L1" and identifier "list1", and node 16 doesn't
belong to any lists). That suggests that the list identifier isn't
needed in this case. Bug when the actual output of node 16 is done,
it includes a node from an endnote  ("x"),  which is located  in a
different place in the document model,  and has a node number like
7 (so not between 15 and 17). The paragraph "x" belongs to another
list with style  "L2", and is output to ODF between paragraphs "a"
and "c". Here, we must refer from paragraph "c" to the list of the
paragraph "a" using the list id, but this is not obvious when only
considering node numbers,  and requires the prior knowledge of the
actual order of appearance of lists in the ODF.

Unless we build a DOM,  this is only possible, if we do a two-pass
output, and collect the nodes order in the first pass.  The output
already does that in a "collect autostyles" pass. The problem here
is that the  "collect autostyles"  pass used an optimized function,
XMLTextParagraphExport::collectTextAutoStylesOptimized, introduced
in commit  8195d7061e  (INTEGRATION:
CWS swautomatic01 (1.126.4); FILE MERGED, 2006-12-01) for #i65476#
and which used style::XAutoStylesSupplier for optimization  to get
the autostyles.

This drops  XMLTextParagraphExport::collectTextAutoStylesOptimized,
and reverts to use of  collectTextAutoStyles,  which handles nodes
in the same order as when writing to ODF. There, we build a vector
of the node numbers sequence, used later to sort DocumentListNodes.

This uncovered an omission from the work on paragraph mark (commit
1a88efa8e0  tdf#155238:  Reimplement
how ListAutoFormat is stored to ODF, 2023-05-11).  Turns out, that
the code in SwTextFormatter::NewNumberPortion introduced in commit
cb0e1b52d6  (sw,  numbering  portion
format: consider full-para char formats as well,  2022-10-20)  was
left behind when re-implementing paragraph marks  to use dedicated
property;  empty trailing spans still affected  how the lists were
rendered,  and that allowed to overlook import defects,  where the
paragraph mark properties weren't properly set.

In ODF import (XMLParaContext::endFastElement),  for compatibility,
this treats empty trailing spans as defining paragraph mark  (when
the paragraph mark wasn't set explicitly).  This way, the trailing
spans get converted to the paragraph mark.

In WW8 import,  last cell paragraphs didn't call the code handling
the paragraph marks. This is also fixed now.

The changes result  in slightly different numbering  of autostyles
in the ODF.  It seems, that the new numbering more closely follows
the order of appearance of the autostyles in the output;  and some
cases of autostyles that were written,  but unreferenced,  are now
eliminated. The unit tests were updated accordingly.

I hope that the performance impact on the export time would not be
too large.

It is unclear why outline numbering  exports a list element at all.
Fixing that to not emit the list element is a separate task / TODO.

Change-Id: I5c99f8d48be77c4454ffac6ffa9f5babfe0d4909
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166572
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-04-24 11:37:27 +02:00
..
table
animationexport.hxx
animexp.hxx
autolayout.hxx
contextid.hxx
controlpropertyhdl.hxx
DashStyle.hxx
dllapi.h
DocumentSettingsContext.hxx
EnumPropertyHdl.hxx
families.hxx
formlayerexport.hxx
formlayerimport.hxx
GradientStyle.hxx
HatchStyle.hxx
i18nmap.hxx
ImageStyle.hxx
languagetagodf.hxx
maptype.hxx
MarkerStyle.hxx
NamedBoolPropertyHdl.hxx
namespacemap.hxx
numehelp.hxx
odffields.hxx
prhdlfac.hxx
ProgressBarHelper.hxx
prstylei.hxx
SchXMLExportHelper.hxx
SchXMLImportHelper.hxx
SchXMLSeriesHelper.hxx
SettingsExportHelper.hxx
settingsstore.hxx
shapeexport.hxx
shapeimport.hxx
SinglePropertySetInfoCache.hxx
styleexp.hxx
txtimp.hxx
txtimppr.hxx
txtparae.hxx tdf#160253: fix list identifier export decision code 2024-04-24 11:37:27 +02:00
txtprmap.hxx
txtstyli.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
unoatrcn.hxx
unointerfacetouniqueidentifiermapper.hxx
xformsexport.hxx
xformsimport.hxx
xmlaustp.hxx
XMLBase64ImportContext.hxx
XMLCharContext.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
xmlcnimp.hxx
XMLComplexColorContext.hxx
XMLComplexColorExport.hxx
XMLComplexColorHandler.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
XMLConstantsPropertyHandler.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
XMLDrawingPageStyleContext.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
XMLElementPropertyContext.hxx
xmlement.hxx
xmlerror.hxx
xmlevent.hxx
XMLEventExport.hxx
XMLEventsImportContext.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
xmlexp.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
xmlexppr.hxx
XMLFilterServiceNames.h
XMLFontAutoStylePool.hxx
XMLFontStylesContext.hxx
XMLGraphicsDefaultStyle.hxx
xmlictxt.hxx
xmlimp.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
xmlimppr.hxx
xmlmetae.hxx
xmlmetai.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
xmlnamespace.hxx
xmlnume.hxx
xmlnumfe.hxx
xmlnumfi.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
xmlnumi.hxx
XMLPageExport.hxx
xmlprcon.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
xmlprhdl.hxx
xmlprmap.hxx
xmlscripti.hxx
XMLSettingsExportContext.hxx
XMLShapeStyleContext.hxx
xmlstyle.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
XMLTextListAutoStylePool.hxx
XMLTextMasterPageContext.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
XMLTextMasterPageExport.hxx
XMLTextMasterStylesContext.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
XMLTextShapeImportHelper.hxx loplugin:finalmethods 2024-03-26 17:16:47 +01:00
XMLTextShapeStyleContext.hxx
XMLTextTableContext.hxx
xmltkmap.hxx
xmltoken.hxx tdf#132599 cui offapi sw xmloff: add hyphenation-keep-type 2024-04-11 10:20:41 +02:00
xmltypes.hxx tdf#132599 cui offapi sw xmloff: add hyphenation-keep-type 2024-04-11 10:20:41 +02:00
xmluconv.hxx