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

Muthu Subramanian sumuthu at kemper.freedesktop.org
Tue Feb 15 06:57:37 PST 2011


 sc/inc/fmtuno.hxx                |   15 +++-
 sc/source/ui/unoobj/cellsuno.cxx |    2 
 sc/source/ui/unoobj/fmtuno.cxx   |  118 ++++++++++++++++++++++++++++++++-------
 3 files changed, 111 insertions(+), 24 deletions(-)

New commits:
commit 22911947b85db5d18a30c601d390b7d2cb0cfd9d
Author: Muthu Subramanian K <sumuthu at novell.com>
Date:   Tue Feb 15 20:10:10 2011 +0530

    XLSX import of duplicate-conditional formatting.

diff --git a/sc/inc/fmtuno.hxx b/sc/inc/fmtuno.hxx
index cd4aaca..1fa57b3 100644
--- a/sc/inc/fmtuno.hxx
+++ b/sc/inc/fmtuno.hxx
@@ -36,6 +36,7 @@
 #include <svl/itemprop.hxx>
 #include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
 #include <com/sun/star/sheet/XSheetCondition.hpp>
+#include <com/sun/star/sheet/XSheetCondition2.hpp>
 #include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
@@ -48,7 +49,7 @@
 #include <cppuhelper/implbase3.hxx>
 #include <cppuhelper/implbase4.hxx>
 #include <cppuhelper/implbase5.hxx>
-
+#include <com/sun/star/sheet/ConditionOperator2.hpp>
 
 class ScDocument;
 class ScTableConditionalEntry;
@@ -153,7 +154,7 @@ public:
 
 
 class ScTableConditionalEntry : public cppu::WeakImplHelper3<
-                            com::sun::star::sheet::XSheetCondition,
+                            com::sun::star::sheet::XSheetCondition2,
                             com::sun::star::sheet::XSheetConditionalEntry,
                             com::sun::star::lang::XServiceInfo >
 {
@@ -172,8 +173,12 @@ public:
                             // XSheetCondition
     virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL getOperator()
                                 throw(::com::sun::star::uno::RuntimeException);
+    virtual sal_Int32 SAL_CALL getConditionOperator()
+                                throw(::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL	setOperator( ::com::sun::star::sheet::ConditionOperator nOperator )
                                 throw(::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL	setConditionOperator( sal_Int32 nOperator )
+                                throw(::com::sun::star::uno::RuntimeException);
     virtual ::rtl::OUString SAL_CALL getFormula1() throw(::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL	setFormula1( const ::rtl::OUString& aFormula1 )
                                 throw(::com::sun::star::uno::RuntimeException);
@@ -202,7 +207,7 @@ public:
 
 
 class ScTableValidationObj : public cppu::WeakImplHelper5<
-                            com::sun::star::sheet::XSheetCondition,
+                            com::sun::star::sheet::XSheetCondition2,
                             com::sun::star::sheet::XMultiFormulaTokens,
                             com::sun::star::beans::XPropertySet,
                             com::sun::star::lang::XUnoTunnel,
@@ -247,8 +252,12 @@ public:
                             // XSheetCondition
     virtual ::com::sun::star::sheet::ConditionOperator SAL_CALL getOperator()
                                 throw(::com::sun::star::uno::RuntimeException);
+    virtual sal_Int32 SAL_CALL getConditionOperator()
+                                throw(::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL	setOperator( ::com::sun::star::sheet::ConditionOperator nOperator )
                                 throw(::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL	setConditionOperator( sal_Int32 nOperator )
+                                throw(::com::sun::star::uno::RuntimeException);
     virtual ::rtl::OUString SAL_CALL getFormula1() throw(::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL	setFormula1( const ::rtl::OUString& aFormula1 )
                                 throw(::com::sun::star::uno::RuntimeException);
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 3157788..3d2f1ff 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -2305,6 +2305,8 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
 
                                 ScConditionalFormat aNew( 0, pDoc );	// Index wird beim Einfuegen gesetzt
                                 pFormat->FillFormat( aNew, pDoc, eGrammar );
+                                ScRangeListRef pRanges = new ScRangeList( aRanges );
+                                aNew.AddRangeInfo( pRanges );
                                 ULONG nIndex = pDoc->AddCondFormat( aNew );
 
                                 ScDocFunc aFunc(*pDocShell);
diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx
index 135f864..47550d2 100644
--- a/sc/source/ui/unoobj/fmtuno.cxx
+++ b/sc/source/ui/unoobj/fmtuno.cxx
@@ -82,20 +82,66 @@ SC_SIMPLE_SERVICE_INFO( ScTableValidationObj, "ScTableValidationObj", "com.sun.s
 
 //------------------------------------------------------------------------
 
+sal_Int32 lcl_ConditionModeToOperatorNew( ScConditionMode eMode )
+{
+    sal_Int32 eOper = sheet::ConditionOperator2::NONE;
+    switch (eMode)
+    {
+        case SC_COND_EQUAL:         eOper = sheet::ConditionOperator2::EQUAL;           break;
+        case SC_COND_LESS:          eOper = sheet::ConditionOperator2::LESS;            break;
+        case SC_COND_GREATER:       eOper = sheet::ConditionOperator2::GREATER;         break;
+        case SC_COND_EQLESS:        eOper = sheet::ConditionOperator2::LESS_EQUAL;      break;
+        case SC_COND_EQGREATER:     eOper = sheet::ConditionOperator2::GREATER_EQUAL;   break;
+        case SC_COND_NOTEQUAL:      eOper = sheet::ConditionOperator2::NOT_EQUAL;       break;
+        case SC_COND_BETWEEN:       eOper = sheet::ConditionOperator2::BETWEEN;         break;
+        case SC_COND_NOTBETWEEN:    eOper = sheet::ConditionOperator2::NOT_BETWEEN;     break;
+        case SC_COND_DIRECT:        eOper = sheet::ConditionOperator2::FORMULA;         break;
+        case SC_COND_DUPLICATE:     eOper = sheet::ConditionOperator2::DUPLICATE;       break;
+        default:
+        {
+            // added to avoid warnings
+        }
+    }
+    return eOper;
+}
+
+ScConditionMode lcl_ConditionOperatorToModeNew( sal_Int32 eOper )
+{
+    ScConditionMode eMode = SC_COND_NONE;
+    switch (eOper)
+    {
+        case sheet::ConditionOperator2::EQUAL:          eMode = SC_COND_EQUAL;      break;
+        case sheet::ConditionOperator2::LESS:           eMode = SC_COND_LESS;       break;
+        case sheet::ConditionOperator2::GREATER:        eMode = SC_COND_GREATER;    break;
+        case sheet::ConditionOperator2::LESS_EQUAL:     eMode = SC_COND_EQLESS;     break;
+        case sheet::ConditionOperator2::GREATER_EQUAL:  eMode = SC_COND_EQGREATER;  break;
+        case sheet::ConditionOperator2::NOT_EQUAL:      eMode = SC_COND_NOTEQUAL;   break;
+        case sheet::ConditionOperator2::BETWEEN:        eMode = SC_COND_BETWEEN;    break;
+        case sheet::ConditionOperator2::NOT_BETWEEN:    eMode = SC_COND_NOTBETWEEN; break;
+        case sheet::ConditionOperator2::FORMULA:        eMode = SC_COND_DIRECT;     break;
+        case sheet::ConditionOperator2::DUPLICATE:      eMode = SC_COND_DUPLICATE;  break;
+        default:
+        {
+            // added to avoid warnings
+        }
+    }
+    return eMode;
+}
+
 sheet::ConditionOperator lcl_ConditionModeToOperator( ScConditionMode eMode )
 {
     sheet::ConditionOperator eOper = sheet::ConditionOperator_NONE;
     switch (eMode)
     {
-        case SC_COND_EQUAL:		 eOper = sheet::ConditionOperator_EQUAL;		 break;
-        case SC_COND_LESS:		 eOper = sheet::ConditionOperator_LESS;			 break;
-        case SC_COND_GREATER:	 eOper = sheet::ConditionOperator_GREATER;		 break;
-        case SC_COND_EQLESS:	 eOper = sheet::ConditionOperator_LESS_EQUAL;	 break;
-        case SC_COND_EQGREATER:	 eOper = sheet::ConditionOperator_GREATER_EQUAL; break;
-        case SC_COND_NOTEQUAL:	 eOper = sheet::ConditionOperator_NOT_EQUAL;	 break;
-        case SC_COND_BETWEEN:	 eOper = sheet::ConditionOperator_BETWEEN;		 break;
-        case SC_COND_NOTBETWEEN: eOper = sheet::ConditionOperator_NOT_BETWEEN;	 break;
-        case SC_COND_DIRECT:	 eOper = sheet::ConditionOperator_FORMULA;		 break;
+        case SC_COND_EQUAL:         eOper = sheet::ConditionOperator_EQUAL;         break;
+        case SC_COND_LESS:          eOper = sheet::ConditionOperator_LESS;          break;
+        case SC_COND_GREATER:       eOper = sheet::ConditionOperator_GREATER;       break;
+        case SC_COND_EQLESS:        eOper = sheet::ConditionOperator_LESS_EQUAL;    break;
+        case SC_COND_EQGREATER:     eOper = sheet::ConditionOperator_GREATER_EQUAL; break;
+        case SC_COND_NOTEQUAL:      eOper = sheet::ConditionOperator_NOT_EQUAL;     break;
+        case SC_COND_BETWEEN:       eOper = sheet::ConditionOperator_BETWEEN;       break;
+        case SC_COND_NOTBETWEEN:    eOper = sheet::ConditionOperator_NOT_BETWEEN;   break;
+        case SC_COND_DIRECT:        eOper = sheet::ConditionOperator_FORMULA;       break;
         default:
         {
             // added to avoid warnings
@@ -109,15 +155,15 @@ ScConditionMode lcl_ConditionOperatorToMode( sheet::ConditionOperator eOper )
     ScConditionMode eMode = SC_COND_NONE;
     switch (eOper)
     {
-        case sheet::ConditionOperator_EQUAL:		 eMode = SC_COND_EQUAL;		 break;
-        case sheet::ConditionOperator_LESS:			 eMode = SC_COND_LESS;		 break;
-        case sheet::ConditionOperator_GREATER:		 eMode = SC_COND_GREATER;	 break;
-        case sheet::ConditionOperator_LESS_EQUAL:	 eMode = SC_COND_EQLESS;	 break;
-        case sheet::ConditionOperator_GREATER_EQUAL: eMode = SC_COND_EQGREATER;  break;
-        case sheet::ConditionOperator_NOT_EQUAL:	 eMode = SC_COND_NOTEQUAL;	 break;
-        case sheet::ConditionOperator_BETWEEN:		 eMode = SC_COND_BETWEEN;	 break;
-        case sheet::ConditionOperator_NOT_BETWEEN:	 eMode = SC_COND_NOTBETWEEN; break;
-        case sheet::ConditionOperator_FORMULA:		 eMode = SC_COND_DIRECT;	 break;
+        case sheet::ConditionOperator_EQUAL:            eMode = SC_COND_EQUAL;      break;
+        case sheet::ConditionOperator_LESS:             eMode = SC_COND_LESS;       break;
+        case sheet::ConditionOperator_GREATER:          eMode = SC_COND_GREATER;    break;
+        case sheet::ConditionOperator_LESS_EQUAL:       eMode = SC_COND_EQLESS;     break;
+        case sheet::ConditionOperator_GREATER_EQUAL:    eMode = SC_COND_EQGREATER;  break;
+        case sheet::ConditionOperator_NOT_EQUAL:        eMode = SC_COND_NOTEQUAL;   break;
+        case sheet::ConditionOperator_BETWEEN:          eMode = SC_COND_BETWEEN;    break;
+        case sheet::ConditionOperator_NOT_BETWEEN:      eMode = SC_COND_NOTBETWEEN; break;
+        case sheet::ConditionOperator_FORMULA:          eMode = SC_COND_DIRECT;     break;
         default:
         {
             // added to avoid warnings
@@ -270,9 +316,8 @@ void SAL_CALL ScTableConditionalFormat::addNew(
 
         if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_OPERATOR ) ) )
         {
-            sheet::ConditionOperator eOper = (sheet::ConditionOperator)
-                            ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
-            aEntry.meMode = lcl_ConditionOperatorToMode( eOper );
+            sal_Int32 eOper = ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
+            aEntry.meMode = lcl_ConditionOperatorToModeNew( eOper );
         }
         else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_FORMULA1 ) ) )
         {
@@ -557,6 +602,22 @@ void SAL_CALL ScTableConditionalEntry::setOperator( sheet::ConditionOperator nOp
         pParent->DataChanged();
 }
 
+sal_Int32 SAL_CALL ScTableConditionalEntry::getConditionOperator()
+                                                throw(uno::RuntimeException)
+{
+    SolarMutexGuard aGuard;
+    return lcl_ConditionModeToOperatorNew( aData.meMode );
+}
+
+void SAL_CALL ScTableConditionalEntry::setConditionOperator( sal_Int32 nOperator )
+                                                throw(uno::RuntimeException)
+{
+    SolarMutexGuard aGuard;
+    aData.meMode = lcl_ConditionOperatorToModeNew( nOperator );
+    if (pParent)
+        pParent->DataChanged();
+}
+
 rtl::OUString SAL_CALL ScTableConditionalEntry::getFormula1() throw(uno::RuntimeException)
 {
     SolarMutexGuard aGuard;
@@ -755,6 +816,21 @@ void SAL_CALL ScTableValidationObj::setOperator( sheet::ConditionOperator nOpera
     DataChanged();
 }
 
+sal_Int32 SAL_CALL ScTableValidationObj::getConditionOperator()
+                                                throw(uno::RuntimeException)
+{
+    SolarMutexGuard aGuard;
+    return lcl_ConditionModeToOperatorNew( (ScConditionMode)nMode );
+}
+
+void SAL_CALL ScTableValidationObj::setConditionOperator( sal_Int32 nOperator )
+                                                throw(uno::RuntimeException)
+{
+    SolarMutexGuard aGuard;
+    nMode = sal::static_int_cast<USHORT>( lcl_ConditionOperatorToModeNew( nOperator ) );
+    DataChanged();
+}
+
 rtl::OUString SAL_CALL ScTableValidationObj::getFormula1() throw(uno::RuntimeException)
 {
     SolarMutexGuard aGuard;


More information about the Libreoffice-commits mailing list