Files
odfstudio/xmloff
Miklos Vajna 1c5f8e7caf cool#11320 xmloff: warn, but not fail when can't export a numbering style
It's not clear how to reproduce this problem, but when it happens, an
ODT file can't be saved because of an unhandled exception while
producing styles.xml.

Digging deeper, a container::NoSuchElementException is thrown in
XStyleFamily::getByName(), and when that happens the backtrace is:
	#0  (anonymous namespace)::XStyleFamily::getByName (this=0x28fb8740, rName=...)
	    at sw/source/core/unocore/unostyle.cxx:1031
	#1  0x000075ae461d5d8c in (anonymous namespace)::XStyleFamily::getByIndex (this=0x28fb8740, nIndex=0)
	    at sw/source/core/unocore/unostyle.cxx:1027
	#2  0x000075ae541c4d77 in XMLTextListAutoStylePool::XMLTextListAutoStylePool (this=0x75ae243c1318, rExp=...)
	    at include/com/sun/star/uno/Reference.h:384
I.e. the XMLTextListAutoStylePool gets the NumberingStyles style family,
nStyles is 15, we try to get each numbering style by index, but already
the first fails, because 0 gets turned into a 'Keine Liste' (no list)
name, but getting that internally by name then fails.

Fix the direct problem by catching container::NoSuchElementException in
the XMLTextListAutoStylePool_Impl ctor, not expoting a list style is
better than not being able to save the document at all.

Almost certainly this is an effect of a problem earlier, but this should
improve things till reproducer steps are found for that problem.

Change-Id: Ia9fbe8db9dfe5f90f2583111c3d59b98a914798d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183445
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2025-03-28 12:38:38 +01:00
..
…
2025-03-25 11:44:48 +01:00
…
…
…

ODF Import and Export Filter Logic

The main library "xo" contains the basic ODF import/export filter implementation for most applications. The document is accessed via its UNO API, which has the advantage that the same import/export code can be used for text in all applications (from/to Writer/EditEngine). The filter consumes/produces via SAX UNO API interface (implemented in "sax"). Various bits of the ODF filters are also implemented in applications, for example [git:sw/source/filter/xml].

There is a central list of all element or attribute names in [git:include/xmloff/xmltoken.hxx]. The main class of the import filter is SvXMLImport, and of the export filter SvXMLExport.

The Import filter maintains a stack of contexts for each element being read. There are many classes specific to particular elements, derived from SvXMLImportContext.

Note that for export several different versions of ODF are supported, with the default being the latest ODF version with "extensions", which means it may contain elements and attributes that are only in drafts of the specification or are not yet submitted for specification. Documents produced in the other (non-extended) ODF modes are supposed to be strictly conforming to the respective specification, i.e., only markup defined by the ODF specification is allowed.

There is another library "xof" built from the source/transform directory, which is the filter for the OpenOffice.org XML format. This legacy format is a predecessor of ODF and was the default in OpenOffice.org 1.x versions, which did not support ODF. This filter works as a SAX transformation from/to ODF, i.e., when importing a document the transform library reads the SAX events from the file and generates SAX events that are then consumed by the ODF import filter.

OpenOffice.org XML File Format

There is some stuff in the "dtd" directory which is most likely related to the OpenOffice.org XML format but is possibly outdated and obsolete.

Add New XML Tokens

When adding a new XML token, you need to add its entry in the following three files:

  • [git:include/xmloff/xmltoken.hxx]
  • [git:xmloff/source/core/xmltoken.cxx]
  • [git:xmloff/source/token/tokens.txt]