sc/source/filter/excel/excdoc.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
New commits: commit fa4a651e5b2b4094dee3b15cc25622b89fe7a04c Author: Bayram Çiçek <bayram.ci...@collabora.com> AuthorDate: Thu Aug 21 13:11:44 2025 +0300 Commit: Bayram Çiçek <bayram.ci...@collabora.com> CommitDate: Thu Aug 21 18:04:00 2025 +0200 tdf#167689: Calc: check if XML declaration exists when exporting xl/xmlMaps.xml follow-up for https://gerrit.libreoffice.org/c/core/+/189044 (657f0112b550a28a61aca874e301d98dade57e1d) Signed-off-by: Bayram Çiçek <bayram.ci...@collabora.com> Change-Id: Iac5e94774632d74f1b99a32aaa56514396b10792 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189994 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index 675ec95beea3..73f6d01eafd8 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -1293,8 +1293,11 @@ void ExcDocument::WriteXml( XclExpXmlStream& rStrm ) /* we should remove <?xml version="1.0" encoding="UTF-8"?> XML declaration from the string as rStrm.PushStream() already adds it. */ - sal_uInt32 nXmlDeclarationLocation = sXmlMapsContent.find(">"); - sXmlMapsContent = sXmlMapsContent.substr(nXmlDeclarationLocation + 1); + const std::size_t nXmlDeclarationLocation = sXmlMapsContent.find("?>"); + + // but there may not be an XML declaration, we should also check that. + if (nXmlDeclarationLocation != std::string::npos) + sXmlMapsContent = sXmlMapsContent.substr(nXmlDeclarationLocation + 2); // write contents into xl/xmlMaps.xml rStrm.GetCurrentStream()->write(sXmlMapsContent);