summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2024-04-18 17:30:06 -0400
committerMiklos Vajna <vmiklos@collabora.com>2024-04-23 08:40:49 +0200
commita29d91ac403f1ed431ca95b8b9c290bd354c3ae7 (patch)
tree14436c55ba9236eace6c9deac5ae5ef5ca997148
parentFix XAccessibleSelection::getSelectedAccessibleChild doc (diff)
downloadcore-a29d91ac403f1ed431ca95b8b9c290bd354c3ae7.tar.gz
core-a29d91ac403f1ed431ca95b8b9c290bd354c3ae7.zip
xlsx export: never export short-hand version of range address
If all the columns are in focus, LO was exporting A10:XFD11 as 10:11. Amazingly, we can't read that. Seriously? Doesn't Microsoft ever export in shorthand? I thought it would be helpful to find any instances where LO is exporting shorthand, to verify that we really do break import of round-tripped files. I made a brief attempt at fixing the import, but it will require lots of changes and break lots of assumptions. Obviously it can't be a hugely common problem because I didn't find any bug reports about it... I abandoned my attempt because it is too prone to disaster. Change-Id: If59c316d0af466e5cf71ecc459bdf57bb2cd5144 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166269 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sc/qa/unit/data/xlsx/protectedRange.xlsxbin0 -> 8828 bytes
-rw-r--r--sc/qa/unit/subsequent_export_test2.cxx11
-rw-r--r--sc/source/core/tool/rangelst.cxx4
-rw-r--r--sc/source/filter/excel/xestream.cxx3
4 files changed, 17 insertions, 1 deletions
diff --git a/sc/qa/unit/data/xlsx/protectedRange.xlsx b/sc/qa/unit/data/xlsx/protectedRange.xlsx
new file mode 100644
index 000000000000..a185ac3598d0
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/protectedRange.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx
index 9f281928c732..c0b17e11aeb8 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -1263,6 +1263,17 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf126024XLSX)
"External");
}
+CPPUNIT_TEST_FIXTURE(ScExportTest2, testProtectedRange)
+{
+ createScDoc("xlsx/protectedRange.xlsx");
+ save("Calc Office Open XML");
+
+ xmlDocUniquePtr pDoc = parseExport("xl/worksheets/sheet1.xml");
+ CPPUNIT_ASSERT(pDoc);
+ // entire row was being exported as shorthand 'B:B' which LO couldn't read back
+ assertXPath(pDoc, "//x:protectedRanges/x:protectedRange"_ostr, "sqref"_ostr, "B1:B1048576");
+}
+
CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf91332)
{
createScDoc("xlsx/tdf91332.xlsx");
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index f84c92c7a7ae..998187b42996 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -133,6 +133,10 @@ void ScRangeList::Format( OUString& rStr, ScRefFlags nFlags, const ScDocument& r
formula::FormulaGrammar::AddressConvention eConv,
sal_Unicode cDelimiter, bool bFullAddressNotation ) const
{
+ // LO's AddressConverter::parseOoxAddress2d cannot import a short-hand address,
+ // so definitely do not export that way.
+ assert(eConv != FormulaGrammar::CONV_XL_OOX || bFullAddressNotation);
+
if (!cDelimiter)
cDelimiter = ScCompiler::GetNativeSymbolChar(ocSep);
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 32cecf352de3..c93cf6f5f34d 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -748,7 +748,8 @@ OString XclXmlUtils::ToOString( const ScDocument& rDoc, const ScRange& rRange, b
OString XclXmlUtils::ToOString( const ScDocument& rDoc, const ScRangeList& rRangeList )
{
OUString s;
- rRangeList.Format(s, ScRefFlags::VALID, rDoc, FormulaGrammar::CONV_XL_OOX, ' ');
+ rRangeList.Format(s, ScRefFlags::VALID, rDoc, FormulaGrammar::CONV_XL_OOX, ' ',
+ /*FullAddressNotation=*/true);
return s.toUtf8();
}