dev/null |binary sc/qa/unit/data/xls/shared-formula/relative-refs1.xls |binary sc/qa/unit/data/xls/shared-formula/relative-refs2.xls |binary sc/qa/unit/subsequent_filters-test.cxx | 61 ++++++++++++++---- sc/source/filter/excel/excform8.cxx | 11 ++- sc/source/filter/excel/impop.cxx | 12 +-- 6 files changed, 64 insertions(+), 20 deletions(-)
New commits: commit 11109ded381e0cc4f44f7837af995c8c82b3df09 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Dec 30 01:17:29 2014 +0100 add test for fdo#84556 Change-Id: I9b3af4f66513fff437facd17c0758ee92ac5744d diff --git a/sc/qa/unit/data/xls/shared-formula/relative-refs.xls b/sc/qa/unit/data/xls/shared-formula/relative-refs1.xls similarity index 100% rename from sc/qa/unit/data/xls/shared-formula/relative-refs.xls rename to sc/qa/unit/data/xls/shared-formula/relative-refs1.xls diff --git a/sc/qa/unit/data/xls/shared-formula/relative-refs2.xls b/sc/qa/unit/data/xls/shared-formula/relative-refs2.xls new file mode 100644 index 0000000..56ff822 Binary files /dev/null and b/sc/qa/unit/data/xls/shared-formula/relative-refs2.xls differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 529486d..703f905 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -2583,23 +2583,58 @@ void ScFiltersTest::testSharedFormulaXLSB() void ScFiltersTest::testSharedFormulaXLS() { - ScDocShellRef xDocSh = loadDoc("shared-formula/relative-refs.", XLS); - CPPUNIT_ASSERT(xDocSh.Is()); - ScDocument& rDoc = xDocSh->GetDocument(); - rDoc.CalcAll(); + { + // fdo#80091 + ScDocShellRef xDocSh = loadDoc("shared-formula/relative-refs1.", XLS); + CPPUNIT_ASSERT(xDocSh.Is()); + ScDocument& rDoc = xDocSh->GetDocument(); + rDoc.CalcAll(); - // A1:A30 should be all formulas, and they should belong to the same group. - const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0,1,0)); - CPPUNIT_ASSERT(pFC); - CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), pFC->GetSharedTopRow()); - CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(29), pFC->GetSharedLength()); + // A1:A30 should be all formulas, and they should belong to the same group. + const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0,1,0)); + CPPUNIT_ASSERT(pFC); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), pFC->GetSharedTopRow()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(29), pFC->GetSharedLength()); - for(SCROW nRow = 0; nRow < 30; ++nRow) - { - ASSERT_DOUBLES_EQUAL(double(nRow+1), rDoc.GetValue(0, nRow, 0)); + for(SCROW nRow = 0; nRow < 30; ++nRow) + { + ASSERT_DOUBLES_EQUAL(double(nRow+1), rDoc.GetValue(0, nRow, 0)); + } + + xDocSh->DoClose(); } - xDocSh->DoClose(); + { + // fdo#84556 and some related tests + ScDocShellRef xDocSh = loadDoc("shared-formula/relative-refs2.", XLS); + CPPUNIT_ASSERT(xDocSh.Is()); + ScDocument& rDoc = xDocSh->GetDocument(); + rDoc.CalcAll(); + + { + const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(2,1,0)); + CPPUNIT_ASSERT(pFC); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), pFC->GetSharedTopRow()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), pFC->GetSharedLength()); + + OUString aFormula; + rDoc.GetFormula(2, 1, 0, aFormula); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B9:D9)"), aFormula); + } + + { + const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(4,8,0)); + CPPUNIT_ASSERT(pFC); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(8), pFC->GetSharedTopRow()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), pFC->GetSharedLength()); + + OUString aFormula; + rDoc.GetFormula(4, 8, 0, aFormula); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(G9:EY9)"), aFormula); + } + + xDocSh->DoClose(); + } } void ScFiltersTest::testExternalRefCacheXLSX() commit b010e6724fa5cd519daafd3abf57f0a3257025bb Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Dec 30 01:16:53 2014 +0100 relative refs wrap around in xls, fdo#84556 Change-Id: If84d468d4bd55ed55ccd517d0b078d283a1a9c38 diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx index 042d79b..ff4bd6c 100644 --- a/sc/source/filter/excel/excform8.cxx +++ b/sc/source/filter/excel/excform8.cxx @@ -1464,7 +1464,16 @@ void ExcelToSc8::ExcRelToScRel8( sal_uInt16 nRow, sal_uInt16 nC, ScSingleRefData { // C O L if( bColRel ) - rSRD.SetRelCol(static_cast<SCCOL>(static_cast<sal_Int8>(nC))); + { + SCCOL nRelCol = static_cast<sal_Int8>(nC); + sal_Int16 nDiff = aEingPos.Col() + nRelCol; + if ( nDiff < 0) + { + // relative column references wrap around + nRelCol = static_cast<sal_Int16>(256 + (int)nRelCol); + } + rSRD.SetRelCol(static_cast<SCCOL>(nRelCol)); + } else rSRD.SetAbsCol(static_cast<SCCOL>(nCol)); diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index b000fa0..0629bca 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -842,17 +842,17 @@ void ImportExcel::Shrfmla( void ) const ScTokenArray* pErgebnis; - pFormConv->Reset(); - pFormConv->Convert( pErgebnis, maStrm, nLenExpr, true, FT_SharedFormula ); - - OSL_ENSURE( pErgebnis, "+ImportExcel::Shrfmla(): ScTokenArray is NULL!" ); - // The shared range in this record is erroneous more than half the time. - // Don't ever rely on it. + // Don't ever rely on it. Use the one from the formula cell above. SCCOL nCol1 = mpLastFormula->mnCol; SCROW nRow1 = mpLastFormula->mnRow; ScAddress aPos(nCol1, nRow1, GetCurrScTab()); + pFormConv->Reset(aPos); + pFormConv->Convert( pErgebnis, maStrm, nLenExpr, true, FT_SharedFormula ); + + OSL_ENSURE( pErgebnis, "+ImportExcel::Shrfmla(): ScTokenArray is NULL!" ); + pExcRoot->pShrfmlaBuff->Store(aPos, *pErgebnis); // Create formula cell for the last formula record. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits