sc/source/filter/excel/excrecds.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
New commits: commit 6c82e96e849c4a312feaa6cba21093c48a0d9d46 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Thu Apr 18 14:46:30 2024 -0400 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Apr 22 08:39:10 2024 +0200 xlsx export: fix corrupt file for Excel: protectedRange must have sqref Excel refuses to open a file if there is no sqref specified <protectedRanges> <protectedRange name="corruptFile"/> </protectedRanges> In this case, import failed to import sqref="10:131". I don't see much point in trying to create a unit test for this. (I assume protectedRange is simply round-tripped because I doubt LO has working support for protectedRanges.) commit 9cee6a45632623d3d7e5a574128940f96d8c926b Author: Eike Rathke on Thu Mar 20 10:16:50 2014 +0100 added ScEnhancedProtection to ScTableProtection Change-Id: I97ef1ee801898bdcace067d62890c4ce0e7cf1d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166265 Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Justin Luth <jl...@mail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166344 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 3db3d653073c..0dfba784f97c 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -478,6 +478,9 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) rWorksheet->startElement(XML_protectedRanges); for (const auto& rProt : rProts) { + if (!rProt.maRangeList.is()) + continue; // Excel refuses to open if sqref is missing from a protectedRange + SAL_WARN_IF( rProt.maSecurityDescriptorXML.isEmpty() && !rProt.maSecurityDescriptor.empty(), "sc.filter", "XclExpSheetProtection::SaveXml: losing BIFF security descriptor"); rWorksheet->singleElement( XML_protectedRange, @@ -492,7 +495,7 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) XML_hashValue, rProt.maPasswordHash.maHashValue.isEmpty() ? nullptr : rProt.maPasswordHash.maHashValue.toUtf8().getStr(), XML_saltValue, rProt.maPasswordHash.maSaltValue.isEmpty() ? nullptr : rProt.maPasswordHash.maSaltValue.toUtf8().getStr(), XML_spinCount, rProt.maPasswordHash.mnSpinCount ? OString::number( rProt.maPasswordHash.mnSpinCount).getStr() : nullptr, - XML_sqref, rProt.maRangeList.is() ? XclXmlUtils::ToOString( rStrm.GetRoot().GetDoc(), *rProt.maRangeList).getStr() : nullptr); + XML_sqref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), *rProt.maRangeList).getStr()); } rWorksheet->endElement( XML_protectedRanges); }