[Libreoffice-commits] .: 5 commits - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Nov 4 16:28:08 PST 2012


 sc/source/filter/excel/xecontent.cxx   |   65 ++++++++++++++++++++++++++-------
 sc/source/filter/excel/xestream.cxx    |    2 -
 sc/source/filter/excel/xestyle.cxx     |    2 -
 sc/source/filter/inc/xecontent.hxx     |    2 -
 sc/source/filter/xml/xmlcondformat.cxx |   32 ++++++++++++++++
 sc/source/filter/xml/xmlexprt.cxx      |   20 ++++++++++
 6 files changed, 107 insertions(+), 16 deletions(-)

New commits:
commit c2e91c7d8cb027f3f8f06130e3d6552a0c6750ab
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 5 01:24:45 2012 +0100

    fix several bugs around cond format export to ooxml
    
    Change-Id: I4d9c8ea0cc778f5620136548324054b625938887

diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index ffca41e..557538e 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -824,7 +824,7 @@ const char* GetOperatorString(ScConditionMode eMode, bool& bFrmla2)
             break;
         case SC_COND_NONE:
         default:
-            pRet = "";
+            pRet = "equal";
             break;
     }
     return pRet;
@@ -852,6 +852,14 @@ const char* GetTypeString(ScConditionMode eMode)
             return "containsErrors";
         case SC_COND_NOERROR:
             return "notContainsErrors";
+        case SC_COND_BEGINS_WITH:
+            return "beginsWith";
+        case SC_COND_ENDS_WITH:
+            return "endsWith";
+        case SC_COND_CONTAINS_TEXT:
+            return "containsText";
+        case SC_COND_NOT_CONTAINS_TEXT:
+            return "notContainsText";
         default:
             return "cellIs";
     }
@@ -873,6 +881,22 @@ bool IsTopBottomRule(ScConditionMode eMode)
     return false;
 }
 
+bool IsTextRule(ScConditionMode eMode)
+{
+    switch(eMode)
+    {
+        case SC_COND_BEGINS_WITH:
+        case SC_COND_ENDS_WITH:
+        case SC_COND_CONTAINS_TEXT:
+        case SC_COND_NOT_CONTAINS_TEXT:
+            return true;
+        default:
+            break;
+    }
+
+    return false;
+}
+
 }
 
 void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
@@ -884,13 +908,23 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
         || eOperation == SC_COND_BOTTOM_PERCENT;
     sal_Int32 nPercent = eOperation == SC_COND_TOP_PERCENT ||
         eOperation == SC_COND_BOTTOM_PERCENT;
-    rtl::OString aRank;
+    rtl::OString aRank("0");
     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));
     }
+    rtl::OString aText;
+    if(IsTextRule(eOperation))
+    {
+        // we need to write the text without quotes
+        // we have to actually get the string from
+        // the token array for that
+        ScTokenArray* pTokenArray = mrFormatEntry.CreateTokenArry(0);
+        if(pTokenArray->GetLen())
+            aText = XclXmlUtils::ToOString(pTokenArray->First()->GetString());
+    }
 
     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
     rWorksheet->startElement( XML_cfRule,
@@ -901,16 +935,20 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
             XML_bottom, OString::valueOf( nBottom ).getStr(),
             XML_percent, OString::valueOf( nPercent ).getStr(),
             XML_rank, aRank.getStr(),
+            XML_text, aText.getStr(),
             XML_dxfId, OString::valueOf( GetDxfs().GetDxfId( mrFormatEntry.GetStyle() ) ).getStr(),
             FSEND );
-    rWorksheet->startElement( XML_formula, FSEND );
-    rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 0 ) ));
-    rWorksheet->endElement( XML_formula );
-    if (bFmla2)
+    if(!IsTextRule(eOperation) && !IsTopBottomRule(eOperation))
     {
         rWorksheet->startElement( XML_formula, FSEND );
-        rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 1 ) ));
+        rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 0 ) ));
         rWorksheet->endElement( XML_formula );
+        if (bFmla2)
+        {
+            rWorksheet->startElement( XML_formula, FSEND );
+            rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), mrFormatEntry.GetValidSrcPos(), mrFormatEntry.CreateTokenArry( 1 ) ));
+            rWorksheet->endElement( XML_formula );
+        }
     }
     // OOXTODO: XML_extLst
     rWorksheet->endElement( XML_cfRule );
@@ -1025,7 +1063,7 @@ void XclExpColScaleCol::SaveXml( XclExpXmlStream& rStrm )
 
 // ----------------------------------------------------------------------------
 
-XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, XclExtLstRef xExtLst ) :
+XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, XclExtLstRef xExtLst, sal_Int32& rIndex ) :
     XclExpRecord( EXC_ID_CONDFMT ),
     XclExpRoot( rRoot )
 {
@@ -1037,13 +1075,13 @@ XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat
             if( const ScFormatEntry* pFormatEntry = rCondFormat.GetEntry( nIndex ) )
             {
                 if(pFormatEntry->GetType() == condformat::CONDITION)
-                    maCFList.AppendNewRecord( new XclExpCF( GetRoot(), static_cast<const ScCondFormatEntry&>(*pFormatEntry), nIndex ) );
+                    maCFList.AppendNewRecord( new XclExpCF( GetRoot(), static_cast<const ScCondFormatEntry&>(*pFormatEntry), ++rIndex ) );
                 else if(pFormatEntry->GetType() == condformat::COLORSCALE)
-                    maCFList.AppendNewRecord( new XclExpColorScale( GetRoot(), static_cast<const ScColorScaleFormat&>(*pFormatEntry), nIndex ) );
+                    maCFList.AppendNewRecord( new XclExpColorScale( GetRoot(), static_cast<const ScColorScaleFormat&>(*pFormatEntry), ++rIndex ) );
                 else if(pFormatEntry->GetType() == condformat::DATABAR)
-                    maCFList.AppendNewRecord( new XclExpDataBar( GetRoot(), static_cast<const ScDataBarFormat&>(*pFormatEntry), nIndex, xExtLst ) );
+                    maCFList.AppendNewRecord( new XclExpDataBar( GetRoot(), static_cast<const ScDataBarFormat&>(*pFormatEntry), ++rIndex, xExtLst ) );
                 else if(pFormatEntry->GetType() == condformat::ICONSET)
-                    maCFList.AppendNewRecord( new XclExpIconSet( GetRoot(), static_cast<const ScIconSetFormat&>(*pFormatEntry), nIndex ) );
+                    maCFList.AppendNewRecord( new XclExpIconSet( GetRoot(), static_cast<const ScIconSetFormat&>(*pFormatEntry), ++rIndex ) );
             }
         aScRanges.Format( msSeqRef, SCA_VALID, NULL, formula::FormulaGrammar::CONV_XL_A1 );
     }
@@ -1293,10 +1331,11 @@ XclExpCondFormatBuffer::XclExpCondFormatBuffer( const XclExpRoot& rRoot, XclExtL
 {
     if( const ScConditionalFormatList* pCondFmtList = GetDoc().GetCondFormList(GetCurrScTab()) )
     {
+        sal_Int32 nIndex = 0;
         for( ScConditionalFormatList::const_iterator itr = pCondFmtList->begin();
                         itr != pCondFmtList->end(); ++itr)
         {
-            XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), *itr, xExtLst ) );
+            XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), *itr, xExtLst, nIndex ));
             if( xCondfmtRec->IsValid() )
                 maCondfmtList.AppendRecord( xCondfmtRec );
         }
diff --git a/sc/source/filter/inc/xecontent.hxx b/sc/source/filter/inc/xecontent.hxx
index b245336..7e94df9 100644
--- a/sc/source/filter/inc/xecontent.hxx
+++ b/sc/source/filter/inc/xecontent.hxx
@@ -224,7 +224,7 @@ class ScConditionalFormat;
 class XclExpCondfmt : public XclExpRecord, protected XclExpRoot
 {
 public:
-    explicit            XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, XclExtLstRef xExtLst );
+    explicit            XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat, XclExtLstRef xExtLst, sal_Int32& rIndex );
     virtual             ~XclExpCondfmt();
 
     /** Returns true, if this conditional format contains at least one cell range and CF record. */
commit 0f96fa7b59c48f5f00d5987265a7a73091472b24
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 5 01:20:06 2012 +0100

    implement new cond format import from odf
    
    Change-Id: Ib1d80a25c29c1172d8d453d6f6b17ec081c8fef1

diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index 806cb87..788d5b3 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -433,6 +433,38 @@ void GetConditionData(const rtl::OUString& rValue, ScConditionMode& eMode, rtl::
         rExpr1 = ScXMLConditionHelper::getExpression( pStart, pEnd, ')');
         eMode = SC_COND_DIRECT;
     }
+    else if(rValue.indexOf("top-elements") == 0)
+    {
+        const sal_Unicode* pStr = rValue.getStr();
+        const sal_Unicode* pStart = pStr + 13;
+        const sal_Unicode* pEnd = pStr + rValue.getLength();
+        rExpr1 = ScXMLConditionHelper::getExpression( pStart, pEnd, ')');
+        eMode = SC_COND_TOP10;
+    }
+    else if(rValue.indexOf("bottom-elements") == 0)
+    {
+        const sal_Unicode* pStr = rValue.getStr();
+        const sal_Unicode* pStart = pStr + 16;
+        const sal_Unicode* pEnd = pStr + rValue.getLength();
+        rExpr1 = ScXMLConditionHelper::getExpression( pStart, pEnd, ')');
+        eMode = SC_COND_BOTTOM10;
+    }
+    else if(rValue.indexOf("top-percent") == 0)
+    {
+        const sal_Unicode* pStr = rValue.getStr();
+        const sal_Unicode* pStart = pStr + 11;
+        const sal_Unicode* pEnd = pStr + rValue.getLength();
+        rExpr1 = ScXMLConditionHelper::getExpression( pStart, pEnd, ')');
+        eMode = SC_COND_TOP_PERCENT;
+    }
+    else if(rValue.indexOf("bottom-percent") == 0)
+    {
+        const sal_Unicode* pStr = rValue.getStr();
+        const sal_Unicode* pStart = pStr + 15;
+        const sal_Unicode* pEnd = pStr + rValue.getLength();
+        rExpr1 = ScXMLConditionHelper::getExpression( pStart, pEnd, ')');
+        eMode = SC_COND_BOTTOM_PERCENT;
+    }
     else if(rValue.indexOf("is-error") == 0)
     {
         eMode = SC_COND_ERROR;
commit c412b2196343bdd13f4ab59314805a3b92b32071
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 5 01:16:54 2012 +0100

    add export for new cond formats to odf
    
    still missing:
    above average
    below average
    
    Change-Id: I32d4de1d5de3e61d05d75065952dca90bd81370a

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 58cdaa4..0249852 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3908,6 +3908,26 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
                                 aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 aCond.append(')');
                                 break;
+                            case SC_COND_TOP10:
+                                aCond.append("top-elements(");
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(")");
+                                break;
+                            case SC_COND_BOTTOM10:
+                                aCond.append("bottom-elements(");
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(")");
+                                break;
+                            case SC_COND_TOP_PERCENT:
+                                aCond.append("top-percent(");
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(")");
+                                break;
+                            case SC_COND_BOTTOM_PERCENT:
+                                aCond.append("bottom-percent(");
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(")");
+                                break;
                             case SC_COND_ERROR:
                                 aCond.append("is-error");
                                 break;
commit a5f449fe9c26a56271c68d70839348fc0047878c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 5 01:03:36 2012 +0100

    export dxfs at the correct place
    
    Change-Id: I2ab31904169adad4f173d4655d0511855de77464

diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 339dd10..d99c9fd 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -3059,8 +3059,8 @@ void XclExpXmlStyleSheet::SaveXml( XclExpXmlStream& rStrm )
     CreateRecord( EXC_ID_FORMATLIST )->SaveXml( rStrm );
     CreateRecord( EXC_ID_FONTLIST )->SaveXml( rStrm );
     CreateRecord( EXC_ID_XFLIST )->SaveXml( rStrm );
-    CreateRecord( EXC_ID_PALETTE )->SaveXml( rStrm );
     CreateRecord( EXC_ID_DXFS )->SaveXml( rStrm );
+    CreateRecord( EXC_ID_PALETTE )->SaveXml( rStrm );
 
     aStyleSheet->endElement( XML_styleSheet );
 
commit a59d4707bd9eaa4c5aae0195220ff45ad11ec5c9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 5 01:01:24 2012 +0100

    fix ooxml color export
    
    Change-Id: I4b94883f594e13e9923bdd05593447a152fa8b0a

diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 5a9d19a..31bcafa 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -756,7 +756,7 @@ rtl::OUString XclXmlUtils::GetStreamName( const char* sStreamDir, const char* sS
 OString XclXmlUtils::ToOString( const Color& rColor )
 {
     char buf[9];
-    sprintf( buf, "%.2X%.2X%.2X%.2X", rColor.GetTransparency(), rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue() );
+    sprintf( buf, "%.2X%.2X%.2X%.2X", 0xFF-rColor.GetTransparency(), rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue() );
     buf[8] = '\0';
     return OString( buf );
 }


More information about the Libreoffice-commits mailing list