[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Thu Mar 13 15:40:46 PDT 2014
sc/qa/unit/data/xlsx/row-index-1-based.xlsx |binary
sc/qa/unit/subsequent_filters-test.cxx | 39 ++++++++++++++++++++++++++++
sc/source/filter/inc/sheetdatacontext.hxx | 4 +-
sc/source/filter/oox/sheetdatacontext.cxx | 4 +-
4 files changed, 43 insertions(+), 4 deletions(-)
New commits:
commit ff56553e34dfed01b9226ce7a516dbeb6da32124
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Mar 13 18:01:21 2014 -0400
fdo#76032: This row index is 1-based whereas our own mnRow is 0-based.
Change-Id: I098d300532bef164bef0d40ebf62a6848bc19cb8
diff --git a/sc/source/filter/inc/sheetdatacontext.hxx b/sc/source/filter/inc/sheetdatacontext.hxx
index dba7a7e..e352cd0 100644
--- a/sc/source/filter/inc/sheetdatacontext.hxx
+++ b/sc/source/filter/inc/sheetdatacontext.hxx
@@ -129,8 +129,8 @@ private:
bool mbHasFormula; /// True = current cell has formula data (OOXML only).
bool mbValidRange; /// True = maFmlaData.maFormulaRef is valid (OOXML only).
- sal_Int32 mnRow;
- sal_Int32 mnCol;
+ sal_Int32 mnRow; /// row index (0-based)
+ sal_Int32 mnCol; /// column index (0-based)
};
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx
index 9628e78..4d2c57a 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -279,11 +279,11 @@ ContextHandlerRef SheetDataContext::onCreateRecordContext( sal_Int32 nRecId, Seq
void SheetDataContext::importRow( const AttributeList& rAttribs )
{
RowModel aModel;
- sal_Int32 nRow = rAttribs.getInteger( XML_r, -1 );
+ sal_Int32 nRow = rAttribs.getInteger( XML_r, -1 ); // 1-based row index
if(nRow != -1)
{
aModel.mnRow = nRow;
- mnRow = nRow;
+ mnRow = nRow-1; // to 0-based row index.
}
else
aModel.mnRow = ++mnRow;
commit a145e8859c5a878110ec1b346f244c51d1e5a80b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Mar 13 18:00:19 2014 -0400
fdo#76032: Write test for this.
Change-Id: Iec8d32a4e53d2d5d3cdc9767c2ede7654fe2bdd6
diff --git a/sc/qa/unit/data/xlsx/row-index-1-based.xlsx b/sc/qa/unit/data/xlsx/row-index-1-based.xlsx
new file mode 100644
index 0000000..1f60c3b
Binary files /dev/null and b/sc/qa/unit/data/xlsx/row-index-1-based.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index f22e1e2..66bfb94 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -127,6 +127,12 @@ public:
//change this test file only in excel and not in calc
void testCellValueXLSX();
+ /**
+ * Test importing of xlsx document that previously had its row index off
+ * by one. (fdo#76032)
+ */
+ void testRowIndex1BasedXLSX();
+
//misc tests unrelated to the import filters
void testPasswordNew();
void testPasswordOld();
@@ -195,6 +201,7 @@ public:
CPPUNIT_TEST(testDataTableMultiTableXLSX);
CPPUNIT_TEST(testBrokenQuotesCSV);
CPPUNIT_TEST(testCellValueXLSX);
+ CPPUNIT_TEST(testRowIndex1BasedXLSX);
CPPUNIT_TEST(testControlImport);
CPPUNIT_TEST(testChartImportODS);
@@ -1417,6 +1424,38 @@ void ScFiltersTest::testCellValueXLSX()
xDocSh->DoClose();
}
+void ScFiltersTest::testRowIndex1BasedXLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("row-index-1-based.", XLSX);
+ CPPUNIT_ASSERT(xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+
+ // A1
+ OUString aStr = pDoc->GetString(ScAddress(0,0,0));
+ CPPUNIT_ASSERT_EQUAL(OUString("Action Plan.Name"), aStr);
+
+ // B1
+ aStr = pDoc->GetString(ScAddress(1,0,0));
+ CPPUNIT_ASSERT_EQUAL(OUString("Action Plan.Description"), aStr);
+
+ // A2
+ aStr = pDoc->GetString(ScAddress(0,1,0));
+ CPPUNIT_ASSERT_EQUAL(OUString("Jerry"), aStr);
+
+ // B2 - multi-line text.
+ const EditTextObject* pText = pDoc->GetEditText(ScAddress(1,1,0));
+ CPPUNIT_ASSERT(pText);
+ CPPUNIT_ASSERT(pText->GetParagraphCount() == 3);
+ aStr = pText->GetText(0);
+ CPPUNIT_ASSERT_EQUAL(OUString("This is a longer Text."), aStr);
+ aStr = pText->GetText(1);
+ CPPUNIT_ASSERT_EQUAL(OUString("Second line."), aStr);
+ aStr = pText->GetText(2);
+ CPPUNIT_ASSERT_EQUAL(OUString("Third line."), aStr);
+
+ xDocSh->DoClose();
+}
+
void ScFiltersTest::testPassword_Impl(const OUString& aFileNameBase)
{
OUString aFileExtension(getFileFormats()[0].pName, strlen(getFileFormats()[0].pName), RTL_TEXTENCODING_UTF8 );
More information about the Libreoffice-commits
mailing list