xmloff/source/text/XMLTextListAutoStylePool.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
New commits: commit 372fcff09b514172b6138d6b54d3d1d82ebec033 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Mar 27 15:11:11 2025 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Mar 28 08:36:30 2025 +0100 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/+/183427 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/xmloff/source/text/XMLTextListAutoStylePool.cxx b/xmloff/source/text/XMLTextListAutoStylePool.cxx index 8a4dae6f873e..f99f59d88645 100644 --- a/xmloff/source/text/XMLTextListAutoStylePool.cxx +++ b/xmloff/source/text/XMLTextListAutoStylePool.cxx @@ -172,7 +172,14 @@ XMLTextListAutoStylePool::XMLTextListAutoStylePool( SvXMLExport& rExp ) : for (sal_Int32 i = 0; i < nStyles; i++) { Reference<XStyle> xStyle; - xStyles->getByIndex(i) >>= xStyle; + try + { + xStyles->getByIndex(i) >>= xStyle; + } + catch (const container::NoSuchElementException&) + { + SAL_WARN("xmloff", "XMLTextListAutoStylePool_Impl ctor: can't export numbering style #" << i); + } RegisterName(xStyle->getName()); } }