[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - sc/inc sc/qa sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Fri Jul 26 08:50:20 PDT 2013
sc/inc/document.hxx | 2
sc/qa/unit/data/ods/fdo62729.ods |binary
sc/qa/unit/data/xls/inline-array.xls |binary
sc/qa/unit/subsequent_export-test.cxx | 83 ++++++++++++++++++++++++++++++++++
sc/source/filter/xml/xmlexprt.cxx | 1
5 files changed, 85 insertions(+), 1 deletion(-)
New commits:
commit 5300d19c19e3ee5cb8f55cf3f104d4b046041c1c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Jul 26 11:50:30 2013 -0400
Add export test for exporting inline arrays to xls format.
Change-Id: I8f6e32adcbd33362f20eca3ce329633bf9fbf039
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 09f0874..39334ee 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -566,7 +566,7 @@ public:
SCCOL nEndCol, SCROW nEndRow,
const ScMarkData& rMark ) const;
- bool GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );
+ SC_DLLPUBLIC bool GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );
bool IsEmbedded() const;
void GetEmbedded( ScRange& rRange ) const;
diff --git a/sc/qa/unit/data/xls/inline-array.xls b/sc/qa/unit/data/xls/inline-array.xls
new file mode 100644
index 0000000..64574f8
Binary files /dev/null and b/sc/qa/unit/data/xls/inline-array.xls differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 600bc5a..ad7a514 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -26,6 +26,7 @@
#include "scitems.hxx"
#include "document.hxx"
#include "cellform.hxx"
+#include "formulacell.hxx"
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -51,6 +52,8 @@ public:
void testMiscRowHeightExport();
void testNamedRangeBugfdo62729();
+ void testInlineArrayXLS();
+
CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test);
#if !defined(MACOSX) && !defined(DRAGONFLY)
@@ -62,6 +65,7 @@ public:
CPPUNIT_TEST(testColorScaleExportXLSX);
CPPUNIT_TEST(testMiscRowHeightExport);
CPPUNIT_TEST(testNamedRangeBugfdo62729);
+ CPPUNIT_TEST(testInlineArrayXLS);
CPPUNIT_TEST_SUITE_END();
private:
@@ -319,6 +323,55 @@ void ScExportTest::testNamedRangeBugfdo62729()
xDocSh->DoClose();
}
+namespace {
+
+void checkMatrixRange(ScDocument& rDoc, const ScRange& rRange)
+{
+ ScRange aMatRange;
+ ScAddress aMatOrigin;
+ for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
+ {
+ for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow)
+ {
+ ScAddress aPos(nCol, nRow, rRange.aStart.Tab());
+ bool bIsMatrix = rDoc.GetMatrixFormulaRange(aPos, aMatRange);
+ CPPUNIT_ASSERT_MESSAGE("Matrix expected, but not found.", bIsMatrix);
+ CPPUNIT_ASSERT_MESSAGE("Wrong matrix range.", rRange == aMatRange);
+ const ScFormulaCell* pCell = rDoc.GetFormulaCell(aPos);
+ CPPUNIT_ASSERT_MESSAGE("This must be a formula cell.", pCell);
+
+ bIsMatrix = pCell->GetMatrixOrigin(aMatOrigin);
+ CPPUNIT_ASSERT_MESSAGE("Not a part of matrix formula.", bIsMatrix);
+ CPPUNIT_ASSERT_MESSAGE("Wrong matrix origin.", aMatOrigin == aMatRange.aStart);
+ }
+ }
+}
+
+}
+
+void ScExportTest::testInlineArrayXLS()
+{
+ ScDocShellRef xShell = loadDoc("inline-array.", XLS);
+ CPPUNIT_ASSERT(xShell.Is());
+
+ ScDocShellRef xDocSh = saveAndReload(xShell, XLS);
+ CPPUNIT_ASSERT(xDocSh.Is());
+
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+
+ // B2:C3 contains a matrix.
+ checkMatrixRange(*pDoc, ScRange(1,1,0,2,2,0));
+
+ // B5:D6 contains a matrix.
+ checkMatrixRange(*pDoc, ScRange(1,4,0,3,5,0));
+
+ // B8:C10 as well.
+ checkMatrixRange(*pDoc, ScRange(1,7,0,2,9,0));
+
+ xDocSh->DoClose();
+}
+
ScExportTest::ScExportTest()
: ScBootstrapFixture("/sc/qa/unit/data")
{
commit b7df19862d6fbf4d05950540bd49885813312ec7
Author: Noel Power <noel.power at suse.com>
Date: Fri Jul 26 13:13:37 2013 +0100
unit test for fdo#62729
Change-Id: Ib9be75459aa49b8bab968dedae9e0760ccef9a26
diff --git a/sc/qa/unit/data/ods/fdo62729.ods b/sc/qa/unit/data/ods/fdo62729.ods
new file mode 100644
index 0000000..00b5079
Binary files /dev/null and b/sc/qa/unit/data/ods/fdo62729.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 05b0c35..600bc5a 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -49,6 +49,7 @@ public:
void testDataBarExportODS();
void testDataBarExportXLSX();
void testMiscRowHeightExport();
+ void testNamedRangeBugfdo62729();
CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test);
@@ -60,6 +61,7 @@ public:
CPPUNIT_TEST(testColorScaleExportODS);
CPPUNIT_TEST(testColorScaleExportXLSX);
CPPUNIT_TEST(testMiscRowHeightExport);
+ CPPUNIT_TEST(testNamedRangeBugfdo62729);
CPPUNIT_TEST_SUITE_END();
private:
@@ -289,6 +291,34 @@ void ScExportTest::testMiscRowHeightExport()
miscRowHeightsTest( aTestValues, SAL_N_ELEMENTS(aTestValues) );
}
+
+void ScExportTest::testNamedRangeBugfdo62729()
+{
+ ScDocShellRef xShell = loadDoc("fdo62729.", ODS);
+ CPPUNIT_ASSERT(xShell.Is());
+ ScDocument* pDoc = xShell->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+
+ ScRangeName* pNames = pDoc->GetRangeName();
+ //should be just a single named range
+ CPPUNIT_ASSERT(pNames->size() == 1 );
+ pDoc->DeleteTab(0);
+ //should be still a single named range
+ CPPUNIT_ASSERT(pNames->size() == 1 );
+ ScDocShellRef xDocSh = saveAndReload(xShell, ODS);
+ xShell->DoClose();
+
+ CPPUNIT_ASSERT(xDocSh.Is());
+ pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+
+ pNames = pDoc->GetRangeName();
+ //after reload should still have a named range
+ CPPUNIT_ASSERT(pNames->size() == 1 );
+
+ xDocSh->DoClose();
+}
+
ScExportTest::ScExportTest()
: ScBootstrapFixture("/sc/qa/unit/data")
{
commit d3e0730e56e1369397bb3c9e77053cfd170d6260
Author: Noel Power <noel.power at suse.com>
Date: Fri Jul 26 11:25:51 2013 +0100
fix for fdo#62729 reference pos can point to non existing table
there is an existing function ( called at least from uno names api also )
that updates the tab pos, calling that seems to fix this problem
Change-Id: I6f6f31895eda9c338eeabd3f3285bf2c9eb23b7e
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 1943238..23fd580 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3727,6 +3727,7 @@ void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName)
AddAttribute(sAttrName, it->second->GetName());
OUString sBaseCellAddress;
+ it->second->ValidateTabRefs();
ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, it->second->GetPos(), pDoc,
FormulaGrammar::CONV_OOO, ' ', false, SCA_ABS_3D);
AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, sBaseCellAddress);
More information about the Libreoffice-commits
mailing list