[Libreoffice-commits] .: 4 commits - sc/qa sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Nov 3 11:08:44 PDT 2012


 sc/qa/unit/data/contentCSV/new_cond_format_test.csv |   22 ++++++++++++
 sc/qa/unit/data/xlsx/new_cond_format_test.xlsx      |binary
 sc/qa/unit/helper/csv_handler.hxx                   |    3 +
 sc/qa/unit/subsequent_filters-test.cxx              |   28 ++++++++++++++++
 sc/source/filter/excel/xecontent.cxx                |   34 ++++++++++++++++++++
 sc/source/ui/condformat/condformatdlgentry.cxx      |    5 ++
 6 files changed, 92 insertions(+)

New commits:
commit 4e1f89f08bd9712edeb0a0770193cb21633c054c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Nov 3 19:00:58 2012 +0100

    hide the second edit field for all necessary cond formats
    
    Change-Id: I56c5ba7829540d0c619adb8ff68eacc736ff92ff

diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 77f51d0..1f4a1f0 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -158,6 +158,7 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
         StyleSelectHdl(NULL);
         ScConditionMode eMode = pFormatEntry->GetOperation();
         maEdVal1.SetText(pFormatEntry->GetExpression(maPos, 0));
+        maEdVal2.Hide();
         switch(eMode)
         {
             case SC_COND_EQUAL:
@@ -179,10 +180,12 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
                 maLbCondType.SelectEntryPos(5);
                 break;
             case SC_COND_BETWEEN:
+                maEdVal2.Show();
                 maEdVal2.SetText(pFormatEntry->GetExpression(maPos, 1));
                 maLbCondType.SelectEntryPos(6);
                 break;
             case SC_COND_NOTBETWEEN:
+                maEdVal2.Show();
                 maEdVal2.SetText(pFormatEntry->GetExpression(maPos, 1));
                 maLbCondType.SelectEntryPos(7);
                 break;
@@ -209,9 +212,11 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
                 maLbCondType.SelectEntryPos(13);
                 break;
             case SC_COND_ABOVE_AVERAGE:
+                maEdVal1.Hide();
                 maLbCondType.SelectEntryPos(14);
                 break;
             case SC_COND_BELOW_AVERAGE:
+                maEdVal1.Hide();
                 maLbCondType.SelectEntryPos(15);
                 break;
             case SC_COND_NONE:
commit 338c7073e45df2463dfe1e85babe34bc10017a1c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Nov 3 19:00:34 2012 +0100

    improve cond format export to ooxml
    
    Change-Id: Ie89d5595c528b546b5de870421bf7d27a928c739

diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index e278a09..9672dc4 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -853,16 +853,50 @@ const char* GetTypeString(ScConditionMode eMode)
     }
 }
 
+bool IsTopBottomRule(ScConditionMode eMode)
+{
+    switch(eMode)
+    {
+        case SC_COND_TOP10:
+        case SC_COND_BOTTOM10:
+        case SC_COND_TOP_PERCENT:
+        case SC_COND_BOTTOM_PERCENT:
+            return true;
+        default:
+            break;
+    }
+
+    return false;
+}
+
 }
 
 void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
 {
     bool bFmla2 = false;
+    ScConditionMode eOperation = mrFormatEntry.GetOperation();
+    sal_Int32 nAboveAverage = eOperation == SC_COND_ABOVE_AVERAGE;
+    sal_Int32 nBottom = eOperation == SC_COND_BOTTOM10
+        || eOperation == SC_COND_BOTTOM_PERCENT;
+    sal_Int32 nPercent = eOperation == SC_COND_TOP_PERCENT ||
+        eOperation == SC_COND_BOTTOM_PERCENT;
+    rtl::OString aRank;
+    if(IsTopBottomRule(eOperation))
+    {
+        // position and formula grammar are not important
+        // we only store a number there
+        aRank = XclXmlUtils::ToOString(mrFormatEntry.GetExpression(ScAddress(0,0,0), 0));
+    }
+
     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
     rWorksheet->startElement( XML_cfRule,
             XML_type, GetTypeString( mrFormatEntry.GetOperation() ),
             XML_priority, OString::valueOf( mnPriority + 1 ).getStr(),
             XML_operator, GetOperatorString( mrFormatEntry.GetOperation(), bFmla2 ),
+            XML_aboveAverage, OString::valueOf( nAboveAverage ).getStr(),
+            XML_bottom, OString::valueOf( nBottom ).getStr(),
+            XML_percent, OString::valueOf( nPercent ).getStr(),
+            XML_rank, aRank.getStr(),
             XML_dxfId, OString::valueOf( GetDxfs().GetDxfId( mrFormatEntry.GetStyle() ) ).getStr(),
             FSEND );
     rWorksheet->startElement( XML_formula, FSEND );
commit 167ba3fee2f3f52420197d7791a3125787a93247
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Nov 3 18:59:32 2012 +0100

    add an import test for the new cond formats
    
    Change-Id: I2c25604df183ce27845f9e01bb27ab92fc8ffbec

diff --git a/sc/qa/unit/data/contentCSV/new_cond_format_test.csv b/sc/qa/unit/data/contentCSV/new_cond_format_test.csv
new file mode 100644
index 0000000..156f2a0
--- /dev/null
+++ b/sc/qa/unit/data/contentCSV/new_cond_format_test.csv
@@ -0,0 +1,22 @@
+,top n elements,,bottom n elements,,top n percent,,bottom n percent,,above average,,below average,,above equal average,,below equal average
+,1,,1.00,,1,,1.00,,1,,1.00,,2,,2.00
+,2,,2.00,,2,,2.00,,2,,2.00,,3,,3.00
+,3,,3.00,,3,,3.00,,3,,3.00,,4,,4.00
+,4,,4.00,,4,,4,,4,,4.00,,5,,5.00
+,5,,5,,5,,5,,5,,5.00,,6,,6.00
+,6,,6,,6,,6,,6,,6.00,,7,,7.00
+,7,,7,,7,,7,,7,,7.00,,11.00,,11
+,10,,10,,10,,10,,10.00,,10,,10.00,,10.00
+,11,,11,,11,,11,,11.00,,11,,11.00,,11
+,12,,12,,12,,12,,12.00,,12,,12.00,,12
+,13,,13,,13,,13,,13.00,,13,,13.00,,13
+,14,,14,,14,,14,,14.00,,14,,14.00,,14
+,15.00,,15,,15,,15,,15.00,,15,,15.00,,15
+,16.00,,16,,16,,16,,16.00,,16,,16.00,,16
+,17.00,,17,,17,,17,,17.00,,17,,17.00,,17
+,18.00,,18,,18.00,,18,,18.00,,18,,18.00,,18
+,19.00,,19,,19.00,,19,,19.00,,19,,19.00,,19
+,20.00,,20,,20.00,,20,,20.00,,20,,20.00,,20
+,1,,1.00,,1,,1.00,,1,,1.00,,2,,2.00
+,2,,2.00,,2,,2.00,,2,,2.00,,2,,2.00
+,3,,3.00,,3,,3.00,,3,,3.00,,3,,3.00
diff --git a/sc/qa/unit/data/xlsx/new_cond_format_test.xlsx b/sc/qa/unit/data/xlsx/new_cond_format_test.xlsx
new file mode 100644
index 0000000..f5a6977
Binary files /dev/null and b/sc/qa/unit/data/xlsx/new_cond_format_test.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 798ce07..4bed60f 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -1664,12 +1664,40 @@ void ScFiltersTest::testColorScaleXLSX()
 
 void ScFiltersTest::testDataBarODS()
 {
+}
+
+namespace {
+
+void testNewCondFormatData( const rtl::OUString& rFilePath, ScDocument* pDoc )
+{
+
+}
 
 }
 
 void ScFiltersTest::testNewCondFormat()
 {
+    const rtl::OUString aFileNameBase("new_cond_format_test.");
+    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;
 
+    unsigned int nFormatType = aFileFormats[XLSX].nFormatType;
+    unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0;
+    ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType,
+        nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT);
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load new_cond_format_test.xlsx", xDocSh.Is());
+
+    ScDocument* pDoc = xDocSh->GetDocument();
+
+    rtl::OUString aCSVFile("new_cond_format_test.");
+    rtl::OUString aCSVPath;
+    createCSVPath( aCSVFile, aCSVPath );
+    testCondFile(aCSVPath, pDoc, 0);
 }
 
 ScFiltersTest::ScFiltersTest()
commit 81fd504f0b39130770144ac73c39e7309a836731
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Nov 3 18:57:45 2012 +0100

    be more forgiving for empty cells in tests with csv files
    
    Change-Id: I69f66cc580da0aab79e7df15ad5201624ce0f9f2

diff --git a/sc/qa/unit/helper/csv_handler.hxx b/sc/qa/unit/helper/csv_handler.hxx
index 4d16576..8493f10 100644
--- a/sc/qa/unit/helper/csv_handler.hxx
+++ b/sc/qa/unit/helper/csv_handler.hxx
@@ -44,6 +44,9 @@ rtl::OUString getConditionalFormatString(ScDocument* pDoc, SCCOL nCol, SCROW nRo
     rtl::OUString aString;
     Color* pColor;
     ScBaseCell* pCell = pDoc->GetCell(ScAddress(nCol, nRow, nTab));
+    if(!pCell)
+        return aString;
+
     const SfxItemSet* pCondSet = pDoc->GetCondResult( nCol, nRow, nTab );
     const ScPatternAttr* pPattern = pDoc->GetPattern(nCol, nRow, nTab);
     SvNumberFormatter* pFormatter = pDoc->GetFormatTable();


More information about the Libreoffice-commits mailing list