[Libreoffice-commits] .: 3 commits - sc/inc sc/qa sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Sep 23 11:08:38 PDT 2012


 sc/inc/colorscale.hxx                  |    8 +-
 sc/inc/conditio.hxx                    |    6 -
 sc/qa/unit/data/ods/colorScale.ods     |binary
 sc/qa/unit/data/xlsx/colorScale.xlsx   |binary
 sc/qa/unit/subsequent_filters-test.cxx |  119 ++++++++++++++++++++++++++-------
 sc/source/core/data/colorscale.cxx     |   54 +++++++++++++-
 sc/source/core/data/conditio.cxx       |    4 -
 7 files changed, 156 insertions(+), 35 deletions(-)

New commits:
commit 0222ce3cc6bdf4f6927139347ef5506a869eb977
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Sep 23 20:06:18 2012 +0200

    add color scale import test for xlsx
    
    Change-Id: I8877d285be21ea4cd010cb532de593b3f5ab5975

diff --git a/sc/qa/unit/data/xlsx/colorScale.xlsx b/sc/qa/unit/data/xlsx/colorScale.xlsx
new file mode 100644
index 0000000..33234ee
Binary files /dev/null and b/sc/qa/unit/data/xlsx/colorScale.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 6a2267a..8670345 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -142,6 +142,7 @@ public:
     void testDataValidityODS();
 
     void testColorScaleODS();
+    void testColorScaleXLSX();
     void testDataBarODS();
     void testNewCondFormat();
 
@@ -194,6 +195,7 @@ public:
     CPPUNIT_TEST(testControlImport);
 
     CPPUNIT_TEST(testColorScaleODS);
+    CPPUNIT_TEST(testColorScaleXLSX);
     CPPUNIT_TEST(testDataBarODS);
     CPPUNIT_TEST(testNewCondFormat);
 
@@ -1568,6 +1570,26 @@ void ScFiltersTest::testColorScaleODS()
     testColorScale_Impl(pDoc, aBuffer.makeStringAndClear());
 }
 
+void ScFiltersTest::testColorScaleXLSX()
+{
+    const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("colorScale."));
+    rtl::OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 );
+    rtl::OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ;
+    rtl::OUString aFileName;
+    createFileURL(aFileNameBase, aFileExtension, aFileName);
+    rtl::OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8);
+    std::cout << aFileFormats[XLSX].pName << " Test" << std::endl;
+    ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[XLSX].nFormatType);
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load colorScale.xlsx", xDocSh.Is());
+
+    ScDocument* pDoc = xDocSh->GetDocument();
+
+    rtl::OUStringBuffer aBuffer(getSrcRootPath());
+    aBuffer.append(m_aBaseString).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/reference/")));
+    testColorScale_Impl(pDoc, aBuffer.makeStringAndClear());
+}
+
 void ScFiltersTest::testDataBarODS()
 {
 
commit cb3ab592fd462bdd877178c6f0f0b7638938f0ce
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Sep 23 19:57:11 2012 +0200

    improve the color Scale test
    
    Change-Id: I6004874b83adbc602dcad83192cf68607bee5a96

diff --git a/sc/qa/unit/data/ods/colorScale.ods b/sc/qa/unit/data/ods/colorScale.ods
index 1c3fe6e..1e1f457 100644
Binary files a/sc/qa/unit/data/ods/colorScale.ods and b/sc/qa/unit/data/ods/colorScale.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index d48c455..6a2267a 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -141,9 +141,9 @@ public:
     void testRepeatedColumnsODS();
     void testDataValidityODS();
 
-    void testColorScale();
-    void testDataBar();
-    void testCondFormat();
+    void testColorScaleODS();
+    void testDataBarODS();
+    void testNewCondFormat();
 
     //change this test file only in excel and not in calc
     void testSharedFormulaXLSX();
@@ -193,9 +193,9 @@ public:
     CPPUNIT_TEST(testCellValueXLSX);
     CPPUNIT_TEST(testControlImport);
 
-    CPPUNIT_TEST(testColorScale);
-    CPPUNIT_TEST(testDataBar);
-    CPPUNIT_TEST(testCondFormat);
+    CPPUNIT_TEST(testColorScaleODS);
+    CPPUNIT_TEST(testDataBarODS);
+    CPPUNIT_TEST(testNewCondFormat);
 
     CPPUNIT_TEST(testNumberFormatHTML);
     CPPUNIT_TEST(testNumberFormatCSV);
@@ -1485,7 +1485,70 @@ void ScFiltersTest::testPivotTableBasicODS()
     xDocSh->DoClose();
 }
 
-void ScFiltersTest::testColorScale()
+namespace {
+
+void testColorScale_Impl(ScDocument* pDoc, const rtl::OUString& aBaseString)
+{
+    // first color scale
+    {
+        rtl::OUStringBuffer aBuf;
+        const ScConditionalFormat* pFormat = pDoc->GetCondFormat(1,1,0);
+        CPPUNIT_ASSERT(pFormat);
+        pFormat->dumpInfo(aBuf);
+        rtl::OUString aString = aBuf.makeStringAndClear();
+        rtl::OUString aFilePath = aBaseString + rtl::OUString("colorScale_1.txt");
+        std::string aStdString;
+        loadFile(aFilePath, aStdString);
+        rtl::OUString aRefString = rtl::OUString::createFromAscii(aStdString.c_str());
+        CPPUNIT_ASSERT_EQUAL(aRefString, aString);
+    }
+
+    // second cond format
+    {
+        rtl::OUStringBuffer aBuf;
+        const ScConditionalFormat* pFormat = pDoc->GetCondFormat(4,1,0);
+        CPPUNIT_ASSERT(pFormat);
+        pFormat->dumpInfo(aBuf);
+        rtl::OUString aString = aBuf.makeStringAndClear();
+        rtl::OUString aFilePath = aBaseString + rtl::OUString("colorScale_2.txt");
+        std::string aStdString;
+        loadFile(aFilePath, aStdString);
+        rtl::OUString aRefString = rtl::OUString::createFromAscii(aStdString.c_str());
+        CPPUNIT_ASSERT_EQUAL(aRefString, aString);
+    }
+
+    // third cond format
+    {
+        rtl::OUStringBuffer aBuf;
+        const ScConditionalFormat* pFormat = pDoc->GetCondFormat(7,1,0);
+        CPPUNIT_ASSERT(pFormat);
+        pFormat->dumpInfo(aBuf);
+        rtl::OUString aString = aBuf.makeStringAndClear();
+        rtl::OUString aFilePath = aBaseString + rtl::OUString("colorScale_3.txt");
+        std::string aStdString;
+        loadFile(aFilePath, aStdString);
+        rtl::OUString aRefString = rtl::OUString::createFromAscii(aStdString.c_str());
+        CPPUNIT_ASSERT_EQUAL(aRefString, aString);
+    }
+
+    // forth cond format
+    {
+        rtl::OUStringBuffer aBuf;
+        const ScConditionalFormat* pFormat = pDoc->GetCondFormat(10,1,0);
+        CPPUNIT_ASSERT(pFormat);
+        pFormat->dumpInfo(aBuf);
+        rtl::OUString aString = aBuf.makeStringAndClear();
+        rtl::OUString aFilePath = aBaseString + rtl::OUString("colorScale_4.txt");
+        std::string aStdString;
+        loadFile(aFilePath, aStdString);
+        rtl::OUString aRefString = rtl::OUString::createFromAscii(aStdString.c_str());
+        CPPUNIT_ASSERT_EQUAL(aRefString, aString);
+    }
+}
+
+}
+
+void ScFiltersTest::testColorScaleODS()
 {
     const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("colorScale."));
     rtl::OUString aFileExtension(aFileFormats[ODS].pName, strlen(aFileFormats[ODS].pName), RTL_TEXTENCODING_UTF8 );
@@ -1500,27 +1563,17 @@ void ScFiltersTest::testColorScale()
 
     ScDocument* pDoc = xDocSh->GetDocument();
 
-    const ScPatternAttr* pPattern = pDoc->GetPattern(1,1,0);
-    sal_uLong nIndex = static_cast<const SfxUInt32Item&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetValue();
-    CPPUNIT_ASSERT(nIndex);
-    ScConditionalFormatList* pCondFormatList = pDoc->GetCondFormList(0);
-    const ScConditionalFormat* pFormat = pCondFormatList->GetFormat(nIndex);
-    CPPUNIT_ASSERT(pFormat);
-    pFormat->dumpInfo();
-
-    pPattern = pDoc->GetPattern(1,5,0);
-    nIndex = static_cast<const SfxUInt32Item&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetValue();
-    CPPUNIT_ASSERT(nIndex);
-    pFormat = pCondFormatList->GetFormat(nIndex);
-    CPPUNIT_ASSERT(pFormat);
+    rtl::OUStringBuffer aBuffer(getSrcRootPath());
+    aBuffer.append(m_aBaseString).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/reference/")));
+    testColorScale_Impl(pDoc, aBuffer.makeStringAndClear());
 }
 
-void ScFiltersTest::testDataBar()
+void ScFiltersTest::testDataBarODS()
 {
 
 }
 
-void ScFiltersTest::testCondFormat()
+void ScFiltersTest::testNewCondFormat()
 {
 
 }
commit b3d5de767c6dbd30ded0881da9de8ae9638abb54
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Sep 23 19:51:02 2012 +0200

    improve the dump code for cond formats
    
    Change-Id: Icefaa4777f64ca934928ae2ad95496000df364e9

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index db13e92..df3e17a 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -86,6 +86,10 @@ public:
 
     ScColorScaleEntryType GetType() const;
     void SetType( ScColorScaleEntryType eType );
+
+#if DUMP_FORMAT_INFO
+    void dumpInfo(rtl::OUStringBuffer& rBuf) const;
+#endif
 };
 
 namespace databar
@@ -228,7 +232,7 @@ public:
     size_t size() const;
 
 #if DUMP_FORMAT_INFO
-    virtual void dumpInfo() const;
+    virtual void dumpInfo(rtl::OUStringBuffer& rBuf) const;
 #endif
 };
 
@@ -252,7 +256,7 @@ public:
     virtual condformat::ScFormatEntryType GetType() const;
 
 #if DUMP_FORMAT_INFO
-    virtual void dumpInfo() const;
+    virtual void dumpInfo(rtl::OUStringBuffer& rBuf) const;
 #endif
 private:
     double getMin(double nMin, double nMax) const;
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index b4f686e..7b1cf17 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -114,7 +114,7 @@ public:
     bool operator==( const ScFormatEntry& ) const;
 
 #if DUMP_FORMAT_INFO
-    virtual void dumpInfo() const = 0;
+    virtual void dumpInfo(rtl::OUStringBuffer& rBuf) const = 0;
 #endif
 protected:
     ScDocument* mpDoc;
@@ -213,7 +213,7 @@ public:
     static ScConditionMode GetModeFromApi(sal_Int32 nOperator);
 
 #if DUMP_FORMAT_INFO
-    virtual void dumpInfo() const {}
+    virtual void dumpInfo(rtl::OUStringBuffer& ) const {}
 #endif
 
 protected:
@@ -319,7 +319,7 @@ public:
     bool            MarkUsedExternalReferences() const;
 
 #if DUMP_FORMAT_INFO
-    void dumpInfo() const;
+    void dumpInfo(rtl::OUStringBuffer& rBuf) const;
 #endif
 
     //  sorted (via PTRARR) by Index
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 1303e01..4ca1bc7 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -147,6 +147,44 @@ void ScColorScaleEntry::SetColor(const Color& rColor)
     maColor = rColor;
 }
 
+#if DUMP_FORMAT_INFO
+
+void ScColorScaleEntry::dumpInfo(rtl::OUStringBuffer& rBuf) const
+{
+    rBuf.append("Color Scale Entry\n");
+    rBuf.append("Type: ");
+    switch(meType)
+    {
+        case COLORSCALE_VALUE:
+            rBuf.append( "Value\n" );
+            break;
+        case COLORSCALE_MIN:
+            rBuf.append( "Min\n" );
+            break;
+        case COLORSCALE_MAX:
+            rBuf.append( "Max\n" );
+            break;
+        case COLORSCALE_PERCENT:
+            rBuf.append( "Percent\n" );
+            break;
+        case COLORSCALE_PERCENTILE:
+            rBuf.append( "Percentile\n" );
+            break;
+        case COLORSCALE_FORMULA:
+            rBuf.append( "Formual\n" );
+            break;
+        default:
+            rBuf.append( "Unsupported Type\n" );
+    }
+    rBuf.append( "Color: " ).append( (int)maColor.GetRed() ).append( "," ).append( (int)maColor.GetGreen() ).append( "," ).append( (int)maColor.GetBlue() ).append( "\n" );
+    if(meType == COLORSCALE_FORMULA)
+        rBuf.append( "Formula: " ).append( GetFormula( formula::FormulaGrammar::GRAM_DEFAULT ) ).append("\n");
+    else if( meType != COLORSCALE_MIN && meType != COLORSCALE_MAX )
+        rBuf.append( "Value: " ).append( mnVal ).append( "\n" );
+}
+
+#endif
+
 ScColorFormat::ScColorFormat(ScDocument* pDoc):
     ScFormatEntry(pDoc)
 {
@@ -491,9 +529,14 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
 }
 
 #if DUMP_FORMAT_INFO
-void ScColorScaleFormat::dumpInfo() const
+void ScColorScaleFormat::dumpInfo(rtl::OUStringBuffer& rBuf) const
 {
-    std::cout << "Color Scale" << std::endl;
+    rBuf.append("Color Scale with ").append(static_cast<sal_Int32>(size())).append(" entries\n");
+    for(const_iterator itr = begin(); itr != end(); ++itr)
+    {
+        itr->dumpInfo(rBuf);
+    }
+
     const ScRangeList& rRange = GetRange();
     size_t n = rRange.size();
     for(size_t i = 0; i < n; ++i)
@@ -505,9 +548,8 @@ void ScColorScaleFormat::dumpInfo() const
             for( SCROW nRow = pRange->aStart.Row(), nEndRow = pRange->aEnd.Row(); nRow <= nEndRow; ++nRow)
             {
                 boost::scoped_ptr<Color> pColor( GetColor(ScAddress(nCol, nRow, nTab)) );
-                std::cout << nCol << "," << nRow << "," << nTab << ",";
-                std::cout << ((int)pColor->GetRed()) << "," << ((int)pColor->GetGreen()) << "," << ((int)pColor->GetBlue());
-                std::cout << std::endl;
+                rBuf.append(nCol).append(",").append(nRow).append(",").append(nTab).append(",");
+                rBuf.append(((int)pColor->GetRed())).append(",").append(((int)pColor->GetGreen())).append(",").append(((int)pColor->GetBlue())).append("\n");
             }
         }
     }
@@ -852,7 +894,7 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
 }
 
 #if DUMP_FORMAT_INFO
-void ScDataBarFormat::dumpInfo() const
+void ScDataBarFormat::dumpInfo(rtl::OUStringBuffer& rBuf) const
 {
     const ScRangeList& rRange = GetRange();
     size_t n = rRange.size();
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 7f0c2d9..c8e2dbc 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1457,11 +1457,11 @@ ScCondFormatData ScConditionalFormat::GetData( ScBaseCell* pCell, const ScAddres
 
 
 #if DUMP_FORMAT_INFO
-void ScConditionalFormat::dumpInfo() const
+void ScConditionalFormat::dumpInfo(rtl::OUStringBuffer& rBuf) const
 {
     for(CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
     {
-        itr->dumpInfo();
+        itr->dumpInfo(rBuf);
     }
 }
 #endif


More information about the Libreoffice-commits mailing list