sc/qa/unit/data/ods/databar.ods |binary sc/qa/unit/data/xlsx/databar.xlsx |binary sc/qa/unit/subsequent_filters-test.cxx | 173 ++++++++++++--------------------- sc/source/core/data/colorscale.cxx | 7 + sc/source/filter/excel/xeextlst.cxx | 9 + sc/source/ui/formdlg/formula.cxx | 8 - 6 files changed, 80 insertions(+), 117 deletions(-)
New commits: commit 33b0684dd721c4ee5c24d2c9b3b77974db882046 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 22 06:58:27 2013 +0100 update the test files Change-Id: I0285e9d6739e7f2a9882fd19f03524482128e2d2 diff --git a/sc/qa/unit/data/ods/databar.ods b/sc/qa/unit/data/ods/databar.ods index 404f7a2..b3cb964 100644 Binary files a/sc/qa/unit/data/ods/databar.ods and b/sc/qa/unit/data/ods/databar.ods differ diff --git a/sc/qa/unit/data/xlsx/databar.xlsx b/sc/qa/unit/data/xlsx/databar.xlsx index c099f57..bf43cd6 100644 Binary files a/sc/qa/unit/data/xlsx/databar.xlsx and b/sc/qa/unit/data/xlsx/databar.xlsx differ commit b22b7d0c675304c3c7e6b49e7e10563a2dc737c5 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 22 06:58:02 2013 +0100 we need to copy the formula cell as well Change-Id: If73ca17414a1aac1ce9efe5a56b0b1f499014fa0 diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index e4183e7..16a8575 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -59,6 +59,11 @@ ScColorScaleEntry::ScColorScaleEntry(const ScColorScaleEntry& rEntry): mpCell(), meType(rEntry.meType) { + if(rEntry.mpCell) + { + mpCell.reset(static_cast<ScFormulaCell*>(rEntry.mpCell->Clone(*rEntry.mpCell->GetDocument(), SC_CLONECELL_NOMAKEABS_EXTERNAL))); + mpCell->StartListeningTo( mpCell->GetDocument() ); + } } ScColorScaleEntry::ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry& rEntry): @@ -76,6 +81,8 @@ ScColorScaleEntry::ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry& ScColorScaleEntry::~ScColorScaleEntry() { + if(mpCell) + mpCell->EndListeningTo(mpCell->GetDocument()); } void ScColorScaleEntry::SetFormula( const rtl::OUString& rFormula, ScDocument* pDoc, const ScAddress& rAddr, formula::FormulaGrammar::Grammar eGrammar ) commit 9263095cf6beb43b46a4feda359d84c66fdfd811 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 22 06:15:07 2013 +0100 add import test for data bars Change-Id: Ida98e51a7f9970c7d4c845f5a6ac1566cbed9e3a diff --git a/sc/qa/unit/data/ods/databar.ods b/sc/qa/unit/data/ods/databar.ods new file mode 100644 index 0000000..404f7a2 Binary files /dev/null and b/sc/qa/unit/data/ods/databar.ods differ diff --git a/sc/qa/unit/data/xlsx/databar.xlsx b/sc/qa/unit/data/xlsx/databar.xlsx new file mode 100644 index 0000000..c099f57 Binary files /dev/null and b/sc/qa/unit/data/xlsx/databar.xlsx differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index b2133db..2206f42 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -58,6 +58,7 @@ #include "stlsheet.hxx" #include "docfunc.hxx" #include "markdata.hxx" +#include "colorscale.hxx" #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/XControlShape.hpp> @@ -122,6 +123,7 @@ public: void testDataValidityODS(); void testDataBarODS(); + void testDataBarXLSX(); void testNewCondFormatXLSX(); //change this test file only in excel and not in calc @@ -181,6 +183,7 @@ public: CPPUNIT_TEST(testChartImportODS); CPPUNIT_TEST(testDataBarODS); + CPPUNIT_TEST(testDataBarXLSX); CPPUNIT_TEST(testNewCondFormatXLSX); CPPUNIT_TEST(testNumberFormatHTML); @@ -1724,8 +1727,85 @@ void ScFiltersTest::testRichTextContentODS() xDocSh->DoClose(); } +namespace { + +struct FindCondFormatByEnclosingRange +{ + FindCondFormatByEnclosingRange(const ScRange& rRange): + mrRange(rRange) {} + + bool operator()(const ScConditionalFormat& rFormat) + { + if(rFormat.GetRange().Combine() == mrRange) + return true; + + return false; + } + +private: + const ScRange& mrRange; +}; + +struct DataBarData +{ + ScRange aRange; + ScColorScaleEntryType eLowerLimitType; + ScColorScaleEntryType eUpperLimitType; + databar::ScAxisPostion eAxisPosition; +}; + +DataBarData aData[] = { + { ScRange(1,2,0,1,5,0), COLORSCALE_AUTO, COLORSCALE_AUTO, databar::AUTOMATIC }, + { ScRange(3,2,0,3,5,0), COLORSCALE_MIN, COLORSCALE_MAX, databar::AUTOMATIC }, + { ScRange(5,2,0,5,5,0), COLORSCALE_PERCENTILE, COLORSCALE_PERCENT, databar::AUTOMATIC }, + { ScRange(7,2,0,7,5,0), COLORSCALE_VALUE, COLORSCALE_FORMULA, databar::AUTOMATIC }, + { ScRange(1,9,0,1,12,0), COLORSCALE_AUTO, COLORSCALE_AUTO, databar::MIDDLE } +}; + +void testDataBar_Impl(ScDocument* pDoc) +{ + ScConditionalFormatList* pList = pDoc->GetCondFormList(0); + CPPUNIT_ASSERT(pList); + + for(size_t i = 0; i < SAL_N_ELEMENTS(aData); ++i) + { + ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), + pList->end(), FindCondFormatByEnclosingRange(aData[i].aRange)); + CPPUNIT_ASSERT(itr != pList->end()); + CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); + + const ScFormatEntry* pFormatEntry = itr->GetEntry(0); + CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::DATABAR); + const ScDataBarFormat* pDataBar = static_cast<const ScDataBarFormat*>(pFormatEntry); + CPPUNIT_ASSERT(pDataBar); + const ScDataBarFormatData* pDataBarData = pDataBar->GetDataBarData(); + CPPUNIT_ASSERT_EQUAL(aData[i].eLowerLimitType, pDataBarData->mpLowerLimit->GetType()); + CPPUNIT_ASSERT_EQUAL(aData[i].eUpperLimitType, pDataBarData->mpUpperLimit->GetType()); + + CPPUNIT_ASSERT_EQUAL(aData[i].eAxisPosition, pDataBarData->meAxisPosition); + } +} + +} + void ScFiltersTest::testDataBarODS() { + ScDocShellRef xDocSh = loadDoc("databar.", ODS); + CPPUNIT_ASSERT(xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + testDataBar_Impl(pDoc); +} + +void ScFiltersTest::testDataBarXLSX() +{ + ScDocShellRef xDocSh = loadDoc("databar.", XLSX); + CPPUNIT_ASSERT(xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + testDataBar_Impl(pDoc); } void ScFiltersTest::testNewCondFormatXLSX() commit b979429f1a16fb0558b9eb51f9ac7a51fecfcc2e Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 22 04:57:52 2013 +0100 prevent crash if formula is empty Change-Id: Ib7bb245fa0c59c9a56441d4c45584b40193b0a32 diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx index cf1963c..a02a101 100644 --- a/sc/source/filter/excel/xeextlst.cxx +++ b/sc/source/filter/excel/xeextlst.cxx @@ -58,8 +58,13 @@ XclExpExtCfvo::XclExpExtCfvo( const XclExpRoot& rRoot, const ScColorScaleEntry& { if( rEntry.GetType() == COLORSCALE_FORMULA ) { - rtl::OUString aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), rSrcPos, - rEntry.GetFormula()->Clone(), GetRoot().GetOpCodeMap() ); + const ScTokenArray* pArr = rEntry.GetFormula(); + rtl::OUString aFormula; + if(pArr) + { + aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), rSrcPos, + pArr->Clone(), GetRoot().GetOpCodeMap() ); + } maValue = rtl::OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 ); } else commit 86ff8ec2a6da2e7eb50694c1f8242c9e9b713920 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 22 04:41:34 2013 +0100 let us use ScBootstrapFixture::loadDoc here Change-Id: Ia5d29da921e53b8443541e5f69e2bbc7fd99edfa diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 72a5dc3..b2133db 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -1730,18 +1730,7 @@ void ScFiltersTest::testDataBarODS() void ScFiltersTest::testNewCondFormatXLSX() { - const OUString aFileNameBase("new_cond_format_test."); - OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); - OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ; - OUString aFileName; - createFileURL(aFileNameBase, aFileExtension, aFileName); - OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8); - std::cout << aFileFormats[XLSX].pName << " Test" << std::endl; - - unsigned int nFormatType = aFileFormats[XLSX].nFormatType; - unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; - ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, aFilterName, OUString(), aFilterType, - nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); + ScDocShellRef xDocSh = ScBootstrapFixture::loadDoc( "new_cond_format_test.", XLSX ); CPPUNIT_ASSERT_MESSAGE("Failed to load new_cond_format_test.xlsx", xDocSh.Is()); @@ -1757,18 +1746,7 @@ void ScFiltersTest::testNewCondFormatXLSX() void ScFiltersTest::testFormulaDependency() { - const OUString aFileNameBase("dependencyTree."); - OUString aFileExtension(aFileFormats[ODS].pName, strlen(aFileFormats[ODS].pName), RTL_TEXTENCODING_UTF8 ); - OUString aFilterName(aFileFormats[ODS].pFilterName, strlen(aFileFormats[ODS].pFilterName), RTL_TEXTENCODING_UTF8) ; - OUString aFileName; - createFileURL(aFileNameBase, aFileExtension, aFileName); - OUString aFilterType(aFileFormats[ODS].pTypeName, strlen(aFileFormats[ODS].pTypeName), RTL_TEXTENCODING_UTF8); - std::cout << aFileFormats[ODS].pName << " Test" << std::endl; - - unsigned int nFormatType = aFileFormats[ODS].nFormatType; - unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; - ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, aFilterName, OUString(), aFilterType, - nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); + ScDocShellRef xDocSh = ScBootstrapFixture::loadDoc( "dependencyTree.", ODS ); ScDocument* pDoc = xDocSh->GetDocument(); commit 0d8db7a49354de97977d1cfcea534fbcdc250078 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 22 04:35:33 2013 +0100 make method name consistent Change-Id: I5fd08be86c68b788510d04ff6df6c3938c43e625 diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 69764cc..72a5dc3 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -122,7 +122,7 @@ public: void testDataValidityODS(); void testDataBarODS(); - void testNewCondFormat(); + void testNewCondFormatXLSX(); //change this test file only in excel and not in calc void testSharedFormulaXLSX(); @@ -181,7 +181,7 @@ public: CPPUNIT_TEST(testChartImportODS); CPPUNIT_TEST(testDataBarODS); - CPPUNIT_TEST(testNewCondFormat); + CPPUNIT_TEST(testNewCondFormatXLSX); CPPUNIT_TEST(testNumberFormatHTML); CPPUNIT_TEST(testNumberFormatCSV); @@ -1728,7 +1728,7 @@ void ScFiltersTest::testDataBarODS() { } -void ScFiltersTest::testNewCondFormat() +void ScFiltersTest::testNewCondFormatXLSX() { const OUString aFileNameBase("new_cond_format_test."); OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); commit a9c75e5b908d2c3f16608756aea55d7ff7bdd39a Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Mar 22 04:34:29 2013 +0100 remove disabled tests Change-Id: I56490efc131cb25baa279b6f8204cf8f5d3af8c4 diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index d7cf013..69764cc 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -121,8 +121,6 @@ public: void testRepeatedColumnsODS(); void testDataValidityODS(); - void testColorScaleODS(); - void testColorScaleXLSX(); void testDataBarODS(); void testNewCondFormat(); @@ -182,8 +180,6 @@ public: CPPUNIT_TEST(testControlImport); CPPUNIT_TEST(testChartImportODS); - //CPPUNIT_TEST(testColorScaleODS); - //CPPUNIT_TEST(testColorScaleXLSX); CPPUNIT_TEST(testDataBarODS); CPPUNIT_TEST(testNewCondFormat); @@ -1728,105 +1724,6 @@ void ScFiltersTest::testRichTextContentODS() xDocSh->DoClose(); } -namespace { - -void testColorScaleFormat_Impl(const OUString& rFilePath, const ScConditionalFormat* pFormat) -{ - OUStringBuffer aBuf; - CPPUNIT_ASSERT(pFormat); - pFormat->dumpInfo(aBuf); - OUString aString = aBuf.makeStringAndClear(); - std::string aStdString; - loadFile(rFilePath, aStdString); - OUString aRefString = OUString::createFromAscii(aStdString.c_str()); - CPPUNIT_ASSERT_EQUAL(aRefString, aString); -} - -void testColorScale_Impl(ScDocument* pDoc, const OUString& aBaseString) -{ - // first color scale - { - const ScConditionalFormat* pFormat = pDoc->GetCondFormat(1,1,0); - OUString aFilePath = aBaseString + OUString("colorScale_1.txt"); - testColorScaleFormat_Impl(aFilePath, pFormat); - } - - // second cond format - { - const ScConditionalFormat* pFormat = pDoc->GetCondFormat(4,1,0); - OUString aFilePath = aBaseString + OUString("colorScale_2.txt"); - testColorScaleFormat_Impl(aFilePath, pFormat); - } - - // third cond format - { - const ScConditionalFormat* pFormat = pDoc->GetCondFormat(7,1,0); - OUString aFilePath = aBaseString + OUString("colorScale_3.txt"); - testColorScaleFormat_Impl(aFilePath, pFormat); - } - - // forth cond format - { - const ScConditionalFormat* pFormat = pDoc->GetCondFormat(10,1,0); - OUString aFilePath = aBaseString + OUString("colorScale_4.txt"); - testColorScaleFormat_Impl(aFilePath, pFormat); - } -} - -} - -void ScFiltersTest::testColorScaleODS() -{ - const OUString aFileNameBase("colorScale."); - OUString aFileExtension(aFileFormats[ODS].pName, strlen(aFileFormats[ODS].pName), RTL_TEXTENCODING_UTF8 ); - OUString aFilterName(aFileFormats[ODS].pFilterName, strlen(aFileFormats[ODS].pFilterName), RTL_TEXTENCODING_UTF8) ; - OUString aFileName; - createFileURL(aFileNameBase, aFileExtension, aFileName); - OUString aFilterType(aFileFormats[ODS].pTypeName, strlen(aFileFormats[ODS].pTypeName), RTL_TEXTENCODING_UTF8); - std::cout << aFileFormats[ODS].pName << " Test" << std::endl; - - unsigned int nFormatType = aFileFormats[ODS].nFormatType; - unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; - ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, aFilterName, OUString(), aFilterType, - nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); - - CPPUNIT_ASSERT_MESSAGE("Failed to load colorScale.ods", xDocSh.Is()); - - ScDocument* pDoc = xDocSh->GetDocument(); - - OUStringBuffer aBuffer(getSrcRootPath()); - aBuffer.append(m_aBaseString).append(OUString("/reference/")); - testColorScale_Impl(pDoc, aBuffer.makeStringAndClear()); - - xDocSh->DoClose(); -} - -void ScFiltersTest::testColorScaleXLSX() -{ - const OUString aFileNameBase("colorScale."); - OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 ); - OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ; - OUString aFileName; - createFileURL(aFileNameBase, aFileExtension, aFileName); - OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8); - std::cout << aFileFormats[XLSX].pName << " Test" << std::endl; - - unsigned int nFormatType = aFileFormats[XLSX].nFormatType; - unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; - ScDocShellRef xDocSh = ScBootstrapFixture::load(aFileName, aFilterName, OUString(), aFilterType, - nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); - - CPPUNIT_ASSERT_MESSAGE("Failed to load colorScale.xlsx", xDocSh.Is()); - - ScDocument* pDoc = xDocSh->GetDocument(); - - OUStringBuffer aBuffer(getSrcRootPath()); - aBuffer.append(m_aBaseString).append(OUString("/reference/")); - testColorScale_Impl(pDoc, aBuffer.makeStringAndClear()); - - xDocSh->DoClose(); -} - void ScFiltersTest::testDataBarODS() { } commit 7e5928b1def2ac5705e014e344d6564aea8baa8f Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Mar 19 02:18:28 2013 +0100 this return value is always true Change-Id: I90314f334e8b318d615e18fb0689297a8e4cfea7 diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index 752a656..6e4b846 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -316,8 +316,6 @@ sal_Bool ScFormulaDlg::Close() // -------------------------------------------------------------------------- bool ScFormulaDlg::calculateValue( const String& rStrExp, String& rStrResult ) { - sal_Bool bResult = sal_True; - boost::scoped_ptr<ScFormulaCell> pFCell( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) ); // HACK! um bei ColRowNames kein #REF! zu bekommen, @@ -378,7 +376,7 @@ bool ScFormulaDlg::calculateValue( const String& rStrExp, String& rStrResult ) CheckMatrix(); } - return bResult; + return true; } commit f1a64e9d570752a1d3baa9cc1c59b121ff2de29f Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Mar 19 02:16:38 2013 +0100 replace auto_ptr with boost::scoped_ptr Change-Id: I0775e436774308ce7a93b991f7806a429f1480ea diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index 10dbb17..752a656 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -318,9 +318,7 @@ bool ScFormulaDlg::calculateValue( const String& rStrExp, String& rStrResult ) { sal_Bool bResult = sal_True; - SAL_WNODEPRECATED_DECLARATIONS_PUSH - ::std::auto_ptr<ScFormulaCell> pFCell( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) ); - SAL_WNODEPRECATED_DECLARATIONS_POP + boost::scoped_ptr<ScFormulaCell> pFCell( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) ); // HACK! um bei ColRowNames kein #REF! zu bekommen, // wenn ein Name eigentlich als Bereich in die Gesamt-Formel _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits