tdf#144758: default value for 'table:orientation' attribute is 'row'
See [OpenDocument-v1.3-part3] section 19.690.3 <table:database-range>.
Regression after commit ed88b144ce24b9a733d4a9ab6614307c96537baa.
Also fixes relevant part of unit test first introduced in commit
6069ef7976c4455c1875afecf02c41c5731f6546, which was at that time
testing that IsSortColumns property returned false; then in commit
fc95d20500997a1a460be6f3553727299a5080eb, the correct value was
changed to true, reflecting the regression fixed here.
Change-Id: I6a12a0ad13405bc388efb7c2c3bbf31e89905620
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122955
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/sc/qa/unit/data/fods/tdf144758-dbdata-no-orientation.fods b/sc/qa/unit/data/fods/tdf144758-dbdata-no-orientation.fods
new file mode 100644
index 0000000..922fba5
--- /dev/null
+++ b/sc/qa/unit/data/fods/tdf144758-dbdata-no-orientation.fods
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.spreadsheet">
<office:body>
<office:spreadsheet>
<table:table table:name="Sheet1">
<table:table-column/>
<table:table-row>
<table:table-cell/>
</table:table-row>
</table:table>
<table:database-ranges>
<table:database-range table:name="__Anonymous_Sheet_DB__0" table:target-range-address="Sheet1.A1:Sheet1.A1" table:contains-header="false"/>
</table:database-ranges>
</office:spreadsheet>
</office:body>
</office:document>
\ No newline at end of file
diff --git a/sc/qa/unit/subsequent_filters_test.cxx b/sc/qa/unit/subsequent_filters_test.cxx
index 1bdfceb4..de4cea5 100644
--- a/sc/qa/unit/subsequent_filters_test.cxx
+++ b/sc/qa/unit/subsequent_filters_test.cxx
@@ -71,6 +71,7 @@
#include <detfunc.hxx>
#include <cellmergeoption.hxx>
#include <undoblk.hxx>
#include <sortparam.hxx>
#include <orcusfilters.hxx>
#include <filter.hxx>
@@ -217,6 +218,7 @@ public:
void testTdf129681();
void testTdf111974XLSM();
void testEscapedUnicodeXLSX();
void testTdf144758_DBDataDefaultOrientation();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testCondFormatOperatorsSameRangeXLSX);
@@ -320,6 +322,7 @@ public:
CPPUNIT_TEST(testTdf129681);
CPPUNIT_TEST(testTdf111974XLSM);
CPPUNIT_TEST(testEscapedUnicodeXLSX);
CPPUNIT_TEST(testTdf144758_DBDataDefaultOrientation);
CPPUNIT_TEST_SUITE_END();
@@ -3123,6 +3126,24 @@ void ScFiltersTest::testEscapedUnicodeXLSX()
xDocSh->DoClose();
}
void ScFiltersTest::testTdf144758_DBDataDefaultOrientation()
{
ScDocShellRef xDocSh = loadDoc(u"tdf144758-dbdata-no-orientation.", FORMAT_FODS);
CPPUNIT_ASSERT(xDocSh);
ScDocument& rDoc = xDocSh->GetDocument();
ScDBData* pAnonDBData = rDoc.GetAnonymousDBData(0);
CPPUNIT_ASSERT(pAnonDBData);
ScSortParam aSortParam;
pAnonDBData->GetSortParam(aSortParam);
// Without the fix, the default value for bByRow (in absence of 'table:orientation' attribute
// in 'table:database-range' element) was false
CPPUNIT_ASSERT(aSortParam.bByRow);
xDocSh->DoClose();
}
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "sc/qa/unit/data" )
{
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 820c424..9d59674 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -103,7 +103,7 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
bSubTotalsAscending(true),
bFilterConditionSourceRange(false),
bHasHeader(true),
bByRow(false),
bByRow(true),
meRangeType(ScDBCollection::GlobalNamed)
{
if( rAttrList.is() )
diff --git a/test/source/sheet/xdatabaserange.cxx b/test/source/sheet/xdatabaserange.cxx
index 2c45ba0..f1133ac 100644
--- a/test/source/sheet/xdatabaserange.cxx
+++ b/test/source/sheet/xdatabaserange.cxx
@@ -69,7 +69,7 @@ void XDatabaseRange::testGetSortDescriptor()
{
bool bIsSortColumns = true;
aProp.Value >>= bIsSortColumns;
CPPUNIT_ASSERT(bIsSortColumns);
CPPUNIT_ASSERT(!bIsSortColumns);
}
else if (aProp.Name == "ContainsHeader")
{