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

Muthu Subramanian sumuthu at kemper.freedesktop.org
Thu Jan 6 02:12:58 PST 2011


 sc/inc/conditio.hxx               |   25 ++--
 sc/source/core/data/conditio.cxx  |  200 ++++++++++++++++++++++++++------------
 sc/source/ui/attrdlg/condfrmt.cxx |   62 +++++++----
 sc/source/ui/src/condfrmt.src     |    6 +
 sc/source/ui/view/viewfunc.cxx    |   17 +++
 5 files changed, 214 insertions(+), 96 deletions(-)

New commits:
commit 9d8469e97f9b7494107769f10c7a7f8dc5e884b6
Author: Muthu Subramanian K <sumuthu at novell.com>
Date:   Thu Jan 6 15:35:57 2011 +0530

    Feature: Formatting Duplicate cells: Conditional Formating.
    
    Please note that the importing/exporting of this
    (as ods or other formats) are not yet supported.

diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 8432f93..63e3a60 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -34,11 +34,11 @@
 #include "formula/grammar.hxx"
 #include <svl/svarray.hxx>
 #include "scdllapi.h"
+#include "rangelst.hxx"
 
 class ScBaseCell;
 class ScFormulaCell;
 class ScTokenArray;
-class ScRangeList;
 
 
 #define SC_COND_GROW 16
@@ -47,8 +47,8 @@ class ScRangeList;
 #define SC_COND_NOBLANKS	1
 
 
-            // ordering of ScConditionMode and ScQueryOp is equal,
-            // to facilitate the merging of both in the future
+// ordering of ScConditionMode and ScQueryOp is equal,
+// to facilitate the merging of both in the future
 
 enum ScConditionMode
 {
@@ -60,6 +60,8 @@ enum ScConditionMode
     SC_COND_NOTEQUAL,
     SC_COND_BETWEEN,
     SC_COND_NOTBETWEEN,
+    SC_COND_DUPLICATE,
+    SC_COND_NOTDUPLICATE,
     SC_COND_DIRECT,
     SC_COND_NONE
 };
@@ -71,6 +73,8 @@ enum ScConditionValType
     SC_VAL_FORMULA
 };
 
+class ScConditionalFormat;
+
 class SC_DLLPUBLIC ScConditionEntry
 {
                                         // stored data:
@@ -106,8 +110,8 @@ class SC_DLLPUBLIC ScConditionEntry
                         BOOL bTextToReal );
     void	Interpret( const ScAddress& rPos );
 
-    BOOL	IsValid( double nArg ) const;
-    BOOL	IsValidStr( const String& rArg ) const;
+    BOOL	IsValid( double nArg, const ScAddress& rAddr ) const;
+    BOOL	IsValidStr( const String& rArg, const ScAddress& rAddr ) const;
 
 public:
             ScConditionEntry( ScConditionMode eOper,
@@ -126,6 +130,8 @@ public:
 
     int				operator== ( const ScConditionEntry& r ) const;
 
+    void			SetParent( ScConditionalFormat* pNew )	{ pCondFormat = pNew; }
+
     BOOL			IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) const;
 
     ScConditionMode	GetOperation() const		{ return eOp; }
@@ -158,18 +164,16 @@ public:
 protected:
     virtual void	DataChanged( const ScRange* pModified ) const;
     ScDocument*		GetDocument() const		{ return pDoc; }
+    ScConditionalFormat*    pCondFormat;
 };
 
 //
 //	single entry for conditional formatting
 //
 
-class ScConditionalFormat;
-
 class SC_DLLPUBLIC ScCondFormatEntry : public ScConditionEntry
 {
     String					aStyleName;
-    ScConditionalFormat*	pParent;
 
     using ScConditionEntry::operator==;
 
@@ -190,8 +194,6 @@ public:
             ScCondFormatEntry( ScDocument* pDocument, const ScCondFormatEntry& r );
     virtual	~ScCondFormatEntry();
 
-    void			SetParent( ScConditionalFormat* pNew )	{ pParent = pNew; }
-
     int				operator== ( const ScCondFormatEntry& r ) const;
 
     const String&	GetStyle() const		{ return aStyleName; }
@@ -213,6 +215,7 @@ class SC_DLLPUBLIC ScConditionalFormat
     ScCondFormatEntry**	ppEntries;
     USHORT				nEntryCount;
     BOOL				bIsUsed;			// temporary at Save
+    ScRangeListRef      pRanges;            // Ranges for conditional format
 
 public:
             ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument);
@@ -223,6 +226,8 @@ public:
     ScConditionalFormat* Clone(ScDocument* pNewDoc = NULL) const;
 
     void			AddEntry( const ScCondFormatEntry& rNew );
+    void            AddRangeInfo( const ScRangeListRef& rRanges );
+    const ScRangeListRef&  GetRangeInfo() const  { return pRanges; }
 
     BOOL			IsEmpty() const			{ return (nEntryCount == 0); }
     USHORT			Count() const			{ return nEntryCount; }
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index c52717a..714c9e8 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -29,8 +29,6 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sc.hxx"
 
-
-
 //------------------------------------------------------------------
 
 #include "scitems.hxx"
@@ -143,7 +141,8 @@ ScConditionEntry::ScConditionEntry( const ScConditionEntry& r ) :
     pDoc(r.pDoc),
     bRelRef1(r.bRelRef1),
     bRelRef2(r.bRelRef2),
-    bFirstRun(TRUE)
+    bFirstRun(TRUE),
+    pCondFormat(r.pCondFormat)
 {
     //	ScTokenArray copy ctor erzeugt flache Kopie
 
@@ -177,7 +176,8 @@ ScConditionEntry::ScConditionEntry( ScDocument* pDocument, const ScConditionEntr
     pDoc(pDocument),
     bRelRef1(r.bRelRef1),
     bRelRef2(r.bRelRef2),
-    bFirstRun(TRUE)
+    bFirstRun(TRUE),
+    pCondFormat(r.pCondFormat)
 {
     // echte Kopie der Formeln (fuer Ref-Undo)
 
@@ -212,7 +212,8 @@ ScConditionEntry::ScConditionEntry( ScConditionMode eOper,
     pDoc(pDocument),
     bRelRef1(FALSE),
     bRelRef2(FALSE),
-    bFirstRun(TRUE)
+    bFirstRun(TRUE),
+    pCondFormat(NULL)
 {
     Compile( rExpr1, rExpr2, rExprNmsp1, rExprNmsp2, eGrammar1, eGrammar2, FALSE );
 
@@ -238,7 +239,8 @@ ScConditionEntry::ScConditionEntry( ScConditionMode eOper,
     pDoc(pDocument),
     bRelRef1(FALSE),
     bRelRef2(FALSE),
-    bFirstRun(TRUE)
+    bFirstRun(TRUE),
+    pCondFormat(NULL)
 {
     if ( pArr1 )
     {
@@ -697,7 +699,88 @@ void ScConditionEntry::Interpret( const ScAddress& rPos )
     bFirstRun = FALSE;
 }
 
-BOOL ScConditionEntry::IsValid( double nArg ) const
+static BOOL lcl_GetCellContent( ScBaseCell* pCell, BOOL bIsStr1, double& rArg, String& rArgStr )
+{
+    BOOL bVal = TRUE;
+
+    if ( pCell )
+    {
+        CellType eType = pCell->GetCellType();
+        switch( eType )
+        {
+            case CELLTYPE_VALUE:
+                rArg = ((ScValueCell*)pCell)->GetValue();
+                break;
+            case CELLTYPE_FORMULA:
+                {
+                    ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
+                    bVal = pFCell->IsValue();
+                    if (bVal)
+                        rArg = pFCell->GetValue();
+                    else
+                        pFCell->GetString(rArgStr);
+                }
+                break;
+            case CELLTYPE_STRING:
+            case CELLTYPE_EDIT:
+                bVal = FALSE;
+                if ( eType == CELLTYPE_STRING )
+                    ((ScStringCell*)pCell)->GetString(rArgStr);
+                else
+                    ((ScEditCell*)pCell)->GetString(rArgStr);
+                break;
+
+            default:
+                pCell = NULL;			// Note-Zellen wie leere
+                break;
+        }
+    }
+
+    if( !pCell )
+        if( bIsStr1 )
+            bVal = FALSE;				// leere Zellen je nach Bedingung
+
+    return bVal;
+}
+
+static BOOL lcl_IsDuplicate( ScDocument *pDoc, double nArg, const String& rStr, const ScAddress& rAddr, const ScRangeListRef& rRanges )
+{
+    ULONG nListCount = rRanges->Count();
+    for( ULONG i = 0; i < nListCount; i++ )
+    {
+        ScRange *aRange = rRanges->GetObject(i);
+        SCROW nRow = aRange->aEnd.Row();
+        SCCOL nCol = aRange->aEnd.Col();
+        for( SCROW r = aRange->aStart.Row(); r <= nRow; r++ )
+            for( SCCOL c = aRange->aStart.Col(); c <= nCol; c++ )
+            {
+                double nVal = 0.0;
+                ScBaseCell *pCell = NULL;
+                String aStr;
+
+                if( c == rAddr.Col() && r == rAddr.Row() )
+                    continue;
+                pDoc->GetCell( c, r, rAddr.Tab(), pCell );
+                if( !pCell )
+                    continue;
+
+                if( !lcl_GetCellContent( pCell, FALSE, nVal, aStr ) )
+                {
+                    if( rStr.Len() &&
+                        ( ScGlobal::GetCollator()->compareString( rStr, aStr ) == COMPARE_EQUAL ) )
+                        return TRUE;
+                }
+                else
+                {
+                    if( !rStr.Len() && ::rtl::math::approxEqual( nArg, nVal ) )
+                        return TRUE;
+                }
+            }
+    }
+    return FALSE;
+}
+
+BOOL ScConditionEntry::IsValid( double nArg, const ScAddress& rAddr ) const
 {
     //	Interpret muss schon gerufen sein
 
@@ -755,6 +838,16 @@ BOOL ScConditionEntry::IsValid( double nArg ) const
             bValid = ( nArg < nComp1 || nArg > nComp2 ) &&
                      !::rtl::math::approxEqual( nArg, nComp1 ) && !::rtl::math::approxEqual( nArg, nComp2 );
             break;
+        case SC_COND_DUPLICATE:
+        case SC_COND_NOTDUPLICATE:
+            if( pCondFormat )
+            {
+                ScRangeListRef pRanges = pCondFormat->GetRangeInfo();
+                bValid = lcl_IsDuplicate( pDoc, nArg, String(), rAddr, pRanges );
+                if( eOp == SC_COND_NOTDUPLICATE )
+                    bValid = !bValid;
+            }
+            break;
         case SC_COND_DIRECT:
             bValid = !::rtl::math::approxEqual( nComp1, 0.0 );
             break;
@@ -765,13 +858,26 @@ BOOL ScConditionEntry::IsValid( double nArg ) const
     return bValid;
 }
 
-BOOL ScConditionEntry::IsValidStr( const String& rArg ) const
+BOOL ScConditionEntry::IsValidStr( const String& rArg, const ScAddress& rAddr ) const
 {
+    BOOL bValid = FALSE;
     //	Interpret muss schon gerufen sein
 
     if ( eOp == SC_COND_DIRECT )				// Formel ist unabhaengig vom Inhalt
         return !::rtl::math::approxEqual( nVal1, 0.0 );
 
+    if ( eOp == SC_COND_DUPLICATE || eOp == SC_COND_NOTDUPLICATE )
+    {
+        if( pCondFormat && rArg.Len() )
+        {
+            ScRangeListRef pRanges = pCondFormat->GetRangeInfo();
+            bValid = lcl_IsDuplicate( pDoc, 0.0, rArg, rAddr, pRanges );
+            if( eOp == SC_COND_NOTDUPLICATE )
+                bValid = !bValid;
+            return bValid;
+        }
+    }
+
     //	Wenn Bedingung Zahl enthaelt, immer FALSE, ausser bei "ungleich"
 
     if ( !bIsStr1 )
@@ -791,7 +897,6 @@ BOOL ScConditionEntry::IsValidStr( const String& rArg ) const
             String aTemp( aUpVal1 ); aUpVal1 = aUpVal2; aUpVal2 = aTemp;
         }
 
-    BOOL bValid;
     switch ( eOp )
     {
         case SC_COND_EQUAL:
@@ -846,49 +951,11 @@ BOOL ScConditionEntry::IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) c
 
     double nArg = 0.0;
     String aArgStr;
-    BOOL bVal = TRUE;
-
-    if ( pCell )
-    {
-        CellType eType = pCell->GetCellType();
-        switch (eType)
-        {
-            case CELLTYPE_VALUE:
-                nArg = ((ScValueCell*)pCell)->GetValue();
-                break;
-            case CELLTYPE_FORMULA:
-                {
-                    ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
-                    bVal = pFCell->IsValue();
-                    if (bVal)
-                        nArg = pFCell->GetValue();
-                    else
-                        pFCell->GetString(aArgStr);
-                }
-                break;
-            case CELLTYPE_STRING:
-            case CELLTYPE_EDIT:
-                bVal = FALSE;
-                if ( eType == CELLTYPE_STRING )
-                    ((ScStringCell*)pCell)->GetString(aArgStr);
-                else
-                    ((ScEditCell*)pCell)->GetString(aArgStr);
-                break;
-
-            default:
-                pCell = NULL;			// Note-Zellen wie leere
-                break;
-        }
-    }
-
-    if (!pCell)
-        if (bIsStr1)
-            bVal = FALSE;				// leere Zellen je nach Bedingung
-
+    BOOL bVal = lcl_GetCellContent( pCell, bIsStr1, nArg, aArgStr );
     if (bVal)
-        return IsValid( nArg );
+        return IsValid( nArg, rPos );
     else
-        return IsValidStr( aArgStr );
+        return IsValidStr( aArgStr, rPos );
 }
 
 String ScConditionEntry::GetExpression( const ScAddress& rCursor, USHORT nIndex,
@@ -1143,8 +1210,7 @@ ScCondFormatEntry::ScCondFormatEntry( ScConditionMode eOper,
                                         FormulaGrammar::Grammar eGrammar1,
                                         FormulaGrammar::Grammar eGrammar2 ) :
     ScConditionEntry( eOper, rExpr1, rExpr2, pDocument, rPos, rExprNmsp1, rExprNmsp2, eGrammar1, eGrammar2 ),
-    aStyleName( rStyle ),
-    pParent( NULL )
+    aStyleName( rStyle )
 {
 }
 
@@ -1153,22 +1219,19 @@ ScCondFormatEntry::ScCondFormatEntry( ScConditionMode eOper,
                                         ScDocument* pDocument, const ScAddress& rPos,
                                         const String& rStyle ) :
     ScConditionEntry( eOper, pArr1, pArr2, pDocument, rPos ),
-    aStyleName( rStyle ),
-    pParent( NULL )
+    aStyleName( rStyle )
 {
 }
 
 ScCondFormatEntry::ScCondFormatEntry( const ScCondFormatEntry& r ) :
     ScConditionEntry( r ),
-    aStyleName( r.aStyleName ),
-    pParent( NULL )
+    aStyleName( r.aStyleName )
 {
 }
 
 ScCondFormatEntry::ScCondFormatEntry( ScDocument* pDocument, const ScCondFormatEntry& r ) :
     ScConditionEntry( pDocument, r ),
-    aStyleName( r.aStyleName ),
-    pParent( NULL )
+    aStyleName( r.aStyleName )
 {
 }
 
@@ -1186,8 +1249,8 @@ ScCondFormatEntry::~ScCondFormatEntry()
 
 void ScCondFormatEntry::DataChanged( const ScRange* pModified ) const
 {
-    if ( pParent )
-        pParent->DoRepaint( pModified );
+    if ( pCondFormat )
+        pCondFormat->DoRepaint( pModified );
 }
 
 //------------------------------------------------------------------------
@@ -1197,7 +1260,8 @@ ScConditionalFormat::ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocume
     pAreas( NULL ),
     nKey( nNewKey ),
     ppEntries( NULL ),
-    nEntryCount( 0 )
+    nEntryCount( 0 ),
+    pRanges( NULL )
 {
 }
 
@@ -1217,6 +1281,7 @@ ScConditionalFormat::ScConditionalFormat(const ScConditionalFormat& r) :
             ppEntries[i]->SetParent(this);
         }
     }
+    pRanges = new ScRangeList( *r.pRanges );
 }
 
 ScConditionalFormat* ScConditionalFormat::Clone(ScDocument* pNewDoc) const
@@ -1239,6 +1304,7 @@ ScConditionalFormat* ScConditionalFormat::Clone(ScDocument* pNewDoc) const
         }
         pNew->nEntryCount = nEntryCount;
     }
+    pNew->AddRangeInfo( pRanges );
 
     return pNew;
 }
@@ -1254,9 +1320,19 @@ BOOL ScConditionalFormat::EqualEntries( const ScConditionalFormat& r ) const
         if ( ! (*ppEntries[i] == *r.ppEntries[i]) )
             return FALSE;
 
+    if( *pRanges != *r.pRanges )
+        return FALSE;
+
     return TRUE;
 }
 
+void ScConditionalFormat::AddRangeInfo( const ScRangeListRef& rRanges )
+{
+    if( !rRanges.Is() )
+        return;
+    pRanges = new ScRangeList( *rRanges );
+}
+
 void ScConditionalFormat::AddEntry( const ScCondFormatEntry& rNew )
 {
     ScCondFormatEntry** ppNew = new ScCondFormatEntry*[nEntryCount+1];
diff --git a/sc/source/ui/attrdlg/condfrmt.cxx b/sc/source/ui/attrdlg/condfrmt.cxx
index 9ea7f7f..267998e 100644
--- a/sc/source/ui/attrdlg/condfrmt.cxx
+++ b/sc/source/ui/attrdlg/condfrmt.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -29,7 +29,6 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sc.hxx"
 
-
 #include <sfx2/dispatch.hxx>
 #include <svl/stritem.hxx>
 
@@ -48,6 +47,7 @@
 #include "condfrmt.hxx"
 #undef _CONDFRMT_CXX
 
+#include "rangelst.hxx"
 
 //============================================================================
 //	class ScConditionalFormat
@@ -262,7 +262,6 @@ ScConditionalFormatDlg::ScConditionalFormatDlg(
             }
         }
 
-
         if ( pCurrentFormat->Count() > 1 )
         {
             aCbxCond2.Check( TRUE );
@@ -325,7 +324,6 @@ ScConditionalFormatDlg::ScConditionalFormatDlg(
 //	SFX_APPWINDOW->Disable();
 }
 
-
 //----------------------------------------------------------------------------
 // Destruktor
 
@@ -333,7 +331,6 @@ ScConditionalFormatDlg::~ScConditionalFormatDlg()
 {
 }
 
-
 //----------------------------------------------------------------------------
 
 void ScConditionalFormatDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
@@ -380,7 +377,6 @@ BOOL ScConditionalFormatDlg::IsRefInputMode() const
     return (pEdActive != NULL);
 }
 
-
 //----------------------------------------------------------------------------
 
 void ScConditionalFormatDlg::SetActive()
@@ -397,7 +393,6 @@ void ScConditionalFormatDlg::SetActive()
     RefInputDone();
 }
 
-
 //----------------------------------------------------------------------------
 // Holt die ausgewaehlte bedingte Formatierung ab
 
@@ -413,6 +408,9 @@ void ScConditionalFormatDlg::GetConditionalFormat( ScConditionalFormat& rCndFmt
     if (pViewShell)
     {
         ScViewData* pData = pViewShell->GetViewData();
+        ScRangeListRef rRanges;
+        pData->GetMultiArea( rRanges );
+        rCndFmt.AddRangeInfo( rRanges );
         aCurPos = ScAddress( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
     }
 
@@ -456,7 +454,6 @@ void ScConditionalFormatDlg::GetConditionalFormat( ScConditionalFormat& rCndFmt
     }
 }
 
-
 //----------------------------------------------------------------------------
 // Zerstoert den Dialog
 
@@ -465,7 +462,6 @@ BOOL ScConditionalFormatDlg::Close()
     return DoClose( ScCondFormatDlgWrapper::GetChildWindowId() );
 }
 
-
 //----------------------------------------------------------------------------
 // Handler:
 
@@ -490,7 +486,6 @@ IMPL_LINK( ScConditionalFormatDlg, ClickCond1Hdl, void *, EMPTYARG )
     return( 0L );
 }
 
-
 //----------------------------------------------------------------------------
 // Zellwert/Formel
 
@@ -518,7 +513,6 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond11Hdl, void *, EMPTYARG )
     return( 0L );
 }
 
-
 //----------------------------------------------------------------------------
 // zwischen, gleich, groesser, ...
 
@@ -528,7 +522,17 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond12Hdl, void *, EMPTYARG )
     {
         USHORT nPos = aLbCond12.GetSelectEntryPos();
 
-        if( nPos == 6  || nPos == 7 ) // zwischen, n. zwischen
+        aEdtCond11.Show();
+        aRbCond11.Show();
+        if( nPos > 7 )
+        {
+            aEdtCond11.Hide();
+            aRbCond11.Hide();
+            aFtCond1And.Hide();
+            aEdtCond12.Hide();
+            aRbCond12.Hide();
+        }
+        else if( nPos == 6  || nPos == 7 ) // zwischen, n. zwischen
         {
             aEdtCond11.SetSizePixel( aCond1Size3 );
             aRbCond11.SetPosPixel( aRBtn1Pos1 );
@@ -549,7 +553,6 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond12Hdl, void *, EMPTYARG )
     return( 0L );
 }
 
-
 //----------------------------------------------------------------------------
 // Enabled/Disabled Condition2-Controls
 
@@ -571,7 +574,6 @@ IMPL_LINK( ScConditionalFormatDlg, ClickCond2Hdl, void *, EMPTYARG )
     return( 0L );
 }
 
-
 //----------------------------------------------------------------------------
 // Zellwert/Formel
 
@@ -599,7 +601,6 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond21Hdl, void *, EMPTYARG )
     return( 0L );
 }
 
-
 //----------------------------------------------------------------------------
 // zwischen, gleich, groesser, ...
 
@@ -609,7 +610,17 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond22Hdl, void *, EMPTYARG )
     {
         USHORT nPos = aLbCond22.GetSelectEntryPos();
 
-        if( nPos == 6  || nPos == 7 ) // zwischen, n. zwischen
+        aEdtCond21.Show();
+        aRbCond21.Show();
+        if( nPos > 7 )
+        {
+            aEdtCond21.Hide();
+            aRbCond21.Hide();
+            aFtCond2And.Hide();
+            aEdtCond22.Hide();
+            aRbCond22.Hide();
+        }
+        else if( nPos == 6  || nPos == 7 ) // zwischen, n. zwischen
         {
             aEdtCond21.SetSizePixel( aCond2Size3 );
             aRbCond21.SetPosPixel( aRBtn2Pos1 );
@@ -630,7 +641,6 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond22Hdl, void *, EMPTYARG )
     return( 0L );
 }
 
-
 //----------------------------------------------------------------------------
 // Enabled/Disabled Condition3-Controls
 
@@ -652,7 +662,6 @@ IMPL_LINK( ScConditionalFormatDlg, ClickCond3Hdl, void *, EMPTYARG )
     return( 0L );
 }
 
-
 //----------------------------------------------------------------------------
 // Zellwert/Formel
 
@@ -680,7 +689,6 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond31Hdl, void *, EMPTYARG )
     return( 0L );
 }
 
-
 //----------------------------------------------------------------------------
 // zwischen, gleich, groesser, ...
 
@@ -690,7 +698,17 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond32Hdl, void *, EMPTYARG )
     {
         USHORT nPos = aLbCond32.GetSelectEntryPos();
 
-        if( nPos == 6  || nPos == 7 ) // zwischen, n. zwischen
+        aEdtCond31.Show();
+        aRbCond31.Show();
+        if( nPos > 7 )
+        {
+            aEdtCond31.Hide();
+            aRbCond31.Hide();
+            aFtCond3And.Hide();
+            aEdtCond32.Hide();
+            aRbCond32.Hide();
+        }
+        else if( nPos == 6  || nPos == 7 ) // zwischen, n. zwischen
         {
             aEdtCond31.SetSizePixel( aCond3Size3 );
             aRbCond31.SetPosPixel( aRBtn3Pos1 );
@@ -711,7 +729,6 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond32Hdl, void *, EMPTYARG )
     return( 0L );
 }
 
-
 //----------------------------------------------------------------------------
 
 IMPL_LINK( ScConditionalFormatDlg, GetFocusHdl, Control*, pCtrl )
@@ -737,7 +754,6 @@ IMPL_LINK( ScConditionalFormatDlg, GetFocusHdl, Control*, pCtrl )
     return 0;
 }
 
-
 //----------------------------------------------------------------------------
 
 IMPL_LINK( ScConditionalFormatDlg, LoseFocusHdl, Control*, EMPTYARG )
@@ -746,7 +762,6 @@ IMPL_LINK( ScConditionalFormatDlg, LoseFocusHdl, Control*, EMPTYARG )
     return 0;
 }
 
-
 //----------------------------------------------------------------------------
 //	[OK], [Cancel]
 
@@ -771,7 +786,6 @@ IMPL_LINK( ScConditionalFormatDlg, BtnHdl, PushButton*, pBtn )
     return( 0L );
 }
 
-
 //----------------------------------------------------------------------------
 
 IMPL_LINK( ScConditionalFormatDlg, NewBtnHdl, PushButton*, pBtn )
diff --git a/sc/source/ui/src/condfrmt.src b/sc/source/ui/src/condfrmt.src
index 8b73bd5..cacfef8 100644
--- a/sc/source/ui/src/condfrmt.src
+++ b/sc/source/ui/src/condfrmt.src
@@ -73,6 +73,8 @@ ModelessDialog RID_SCDLG_CONDFORMAT
             < "not equal to" ; Default ; > ;
             < "between" ; Default ; > ;
             < "not between" ; Default ; > ;
+            < "duplicated values" ; Default ; > ;
+            < "non duplicated values" ; Default ; > ;
         };
     };
     Edit EDT_COND1_1
@@ -175,6 +177,8 @@ ModelessDialog RID_SCDLG_CONDFORMAT
             < "not equal to" ; Default ; > ;
             < "between" ; Default ; > ;
             < "not between" ; Default ; > ;
+            < "duplicated values" ; Default ; > ;
+            < "non duplicated values" ; Default ; > ;
         };
     };
     Edit EDT_COND2_1
@@ -277,6 +281,8 @@ ModelessDialog RID_SCDLG_CONDFORMAT
             < "not equal to" ; Default ; > ;
             < "between" ; Default ; > ;
             < "not between" ; Default ; > ;
+            < "duplicated values" ; Default ; > ;
+            < "non duplicated values" ; Default ; > ;
         };
     };
     Edit EDT_COND3_1
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 70530b3..16e48cc 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -93,6 +93,21 @@
 #include "cellsuno.hxx"
 //==================================================================
 
+static void lcl_PostRepaintCondFormat( const ScConditionalFormat *pCondFmt, ScDocShell *pDocSh )
+{
+    if( pCondFmt )
+    {
+        const ScRangeListRef& aRanges = pCondFmt->GetRangeInfo();
+        ULONG nCount = aRanges->Count();
+        ULONG n;
+        for( n = 0 ; n < nCount; n++ )
+            pDocSh->PostPaint( *aRanges->GetObject( n ), PAINT_ALL );
+    }
+}
+
+
+//==================================================================
+
 ScViewFunc::ScViewFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) :
     ScTabView( pParent, rDocSh, pViewShell ),
     bFormatValid( FALSE )
@@ -667,6 +682,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS
         }
 
         aModificator.SetDocumentModified();
+        lcl_PostRepaintCondFormat( pDoc->GetCondFormat( nCol, nRow, nTab ), pDocSh );
     }
     else
     {
@@ -865,6 +881,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextOb
 
             aModificator.SetDocumentModified();
         }
+        lcl_PostRepaintCondFormat( pDoc->GetCondFormat( nCol, nRow, nTab ), pDocSh );
 
         delete pCellAttrs;
         delete pNewData;


More information about the Libreoffice-commits mailing list