[Libreoffice-commits] .: sc/source

Katarina Machalkova bubli at kemper.freedesktop.org
Tue Jun 14 08:24:46 PDT 2011


 sc/source/ui/attrdlg/condfrmt.cxx |  584 +++++++++++++++++++++++++++-----------
 sc/source/ui/inc/condfrmt.hrc     |    7 
 sc/source/ui/inc/condfrmt.hxx     |   67 +++-
 sc/source/ui/src/condfrmt.src     |   49 ++-
 4 files changed, 520 insertions(+), 187 deletions(-)

New commits:
commit d358620b76bb0fedaab93f332abe045fd0740667
Author: Robert Dargaud <libo at bobiciel.com>
Date:   Tue Jun 14 17:12:06 2011 +0200

    Unlimited number of conditions for conditional formatting
    
    (Calc part)

diff --git a/sc/source/ui/attrdlg/condfrmt.cxx b/sc/source/ui/attrdlg/condfrmt.cxx
index 378655b..9b34e46 100644
--- a/sc/source/ui/attrdlg/condfrmt.cxx
+++ b/sc/source/ui/attrdlg/condfrmt.cxx
@@ -72,6 +72,8 @@ ScConditionalFormatDlg::ScConditionalFormatDlg(
         aFtCond1Template	( this, ScResId( FT_COND1_TEMPLATE ) ),
         aLbCond1Template	( this, ScResId( LB_COND1_TEMPLATE ) ),
         aBtnNew1            ( this, ScResId( BTN_COND1_NEW ) ),
+        aPreviewWin1        ( this, ScResId( WIN_CHAR_PREVIEW_COND1 ) ),
+        aFlSep1             ( this, ScResId( FL_SEP1 ) ),
 
         aCbxCond2			( this, ScResId( CBX_COND2 ) ),
         aLbCond21			( this, ScResId( LB_COND2_1 ) ),
@@ -84,6 +86,8 @@ ScConditionalFormatDlg::ScConditionalFormatDlg(
         aFtCond2Template	( this, ScResId( FT_COND2_TEMPLATE ) ),
         aLbCond2Template	( this, ScResId( LB_COND2_TEMPLATE ) ),
         aBtnNew2            ( this, ScResId( BTN_COND2_NEW ) ),
+        aPreviewWin2        ( this, ScResId( WIN_CHAR_PREVIEW_COND2 ) ),
+        aFlSep2             ( this, ScResId( FL_SEP2 ) ),
 
         aCbxCond3			( this, ScResId( CBX_COND3 ) ),
         aLbCond31			( this, ScResId( LB_COND3_1 ) ),
@@ -96,38 +100,71 @@ ScConditionalFormatDlg::ScConditionalFormatDlg(
         aFtCond3Template	( this, ScResId( FT_COND3_TEMPLATE ) ),
         aLbCond3Template	( this, ScResId( LB_COND3_TEMPLATE ) ),
         aBtnNew3            ( this, ScResId( BTN_COND3_NEW ) ),
+        aPreviewWin3        ( this, ScResId( WIN_CHAR_PREVIEW_COND3 ) ),
 
+        aScrollBar          ( this, ScResId( LB_SCROLL ) ),
         aBtnOk				( this, ScResId( BTN_OK ) ),
         aBtnCancel			( this, ScResId( BTN_CANCEL ) ),
+        aBtnInsert			( this, ScResId( BTN_INSERT ) ),
+
         aBtnHelp			( this, ScResId( BTN_HELP ) ),
-        aFlSep2             ( this, ScResId( FL_SEP2 ) ),
-        aFlSep1             ( this, ScResId( FL_SEP1 ) ),
         pEdActive			( NULL ),
         bDlgLostFocus       ( false ),
 
-        pDoc				( pCurDoc )
+        pDoc				( pCurDoc ),
+        ppEntries           ( NULL ),
+        nEntryCount         ( 0 ),
+        nCurrentOffset      ( 0 )
 {
     Point aPos;
     String aName;
     SfxStyleSheetBase* pStyle;
 
+    // load entries from current format
+    if ( pCurrentFormat && ( pCurrentFormat->Count() > 2 ) )
+        nEntryCount = pCurrentFormat->Count() + 1;
+    else
+        nEntryCount = 3;
+    ppEntries = new ScCondFormatEntry*[nEntryCount];
+
+    const ScCondFormatEntry* pEntry;
+    for (SCSIZE i=0; i<nEntryCount; i++)
+    {
+        if ( pCurrentFormat && ( i < pCurrentFormat->Count() ) )
+        {
+            pEntry = pCurrentFormat->GetEntry( i );
+            ppEntries[i] = new ScCondFormatEntry( *pEntry );
+        }
+        else
+            ppEntries[i] = NULL;
+    }
+
     FreeResource();
 
+    aScrollBar.SetEndScrollHdl( LINK( this, ScConditionalFormatDlg, ScrollHdl ) );
+    aScrollBar.SetScrollHdl( LINK( this, ScConditionalFormatDlg, ScrollHdl ) );
+    aScrollBar.SetRange( Range( 0, nEntryCount - 3 ) );
+    aScrollBar.SetLineSize( 1 );
+
     // Handler setzen
     aCbxCond1.SetClickHdl ( LINK( this, ScConditionalFormatDlg, ClickCond1Hdl ) );
     aLbCond11.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond11Hdl ) );
     aLbCond12.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond12Hdl ) );
+    aLbCond1Template.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond1TemplateHdl ) );
 
     aCbxCond2.SetClickHdl ( LINK( this, ScConditionalFormatDlg, ClickCond2Hdl ) );
     aLbCond21.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond21Hdl ) );
     aLbCond22.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond22Hdl ) );
+    aLbCond2Template.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond2TemplateHdl ) );
 
     aCbxCond3.SetClickHdl ( LINK( this, ScConditionalFormatDlg, ClickCond3Hdl ) );
     aLbCond31.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond31Hdl ) );
     aLbCond32.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond32Hdl ) );
+    aLbCond3Template.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond3TemplateHdl ) );
 
     aBtnOk.SetClickHdl    ( LINK( this, ScConditionalFormatDlg, BtnHdl ) );
 //?	aBtnCancel.SetClickHdl( LINK( this, ScConditionalFormatDlg, BtnHdl ) );
+    aBtnInsert.SetClickHdl( LINK( this, ScConditionalFormatDlg, BtnHdl ) );
 
     Link aLink = LINK( this, ScConditionalFormatDlg, NewBtnHdl );
     aBtnNew1.SetClickHdl( aLink );
@@ -172,10 +209,13 @@ ScConditionalFormatDlg::ScConditionalFormatDlg(
     aCond1Size3 = aEdtCond11.GetSizePixel();
     aCond1Size2 = Size( aPos.X() - aCond1Pos2.X(), aCond1Size3.Height() );
     aCond1Size1 = Size( aPos.X() - aCond1Pos1.X(), aCond1Size3.Height() );
+    aCbxCond1InitialText = aCbxCond1.GetText();
 
     aCbxCond1.Check();
     aLbCond11.SelectEntryPos( 0 );
     aLbCond12.SelectEntryPos( 0 );
+    aPreviewWin1.SetDrawBaseLine( false );
+    aPreviewWin1.UseResourceText( true );
 
     // Condition 2
     aCond2Pos1  = aLbCond22.GetPosPixel();		// Position Edit ohne Listbox
@@ -187,10 +227,13 @@ ScConditionalFormatDlg::ScConditionalFormatDlg(
     aCond2Size3 = aEdtCond21.GetSizePixel();
     aCond2Size2 = Size( aPos.X() - aCond2Pos2.X(), aCond2Size3.Height() );
     aCond2Size1 = Size( aPos.X() - aCond2Pos1.X(), aCond2Size3.Height() );
+    aCbxCond2InitialText = aCbxCond2.GetText();
 
     aCbxCond2.Check( false );
     aLbCond21.SelectEntryPos( 0 );
     aLbCond22.SelectEntryPos( 0 );
+    aPreviewWin2.SetDrawBaseLine( false );
+    aPreviewWin2.UseResourceText( true );
 
     // Condition 3
     aCond3Pos1  = aLbCond32.GetPosPixel();		// Position Edit ohne Listbox
@@ -202,10 +245,13 @@ ScConditionalFormatDlg::ScConditionalFormatDlg(
     aCond3Size3 = aEdtCond31.GetSizePixel();
     aCond3Size2 = Size( aPos.X() - aCond3Pos2.X(), aCond3Size3.Height() );
     aCond3Size1 = Size( aPos.X() - aCond3Pos1.X(), aCond3Size3.Height() );
+    aCbxCond3InitialText = aCbxCond3.GetText();
 
     aCbxCond3.Check( false );
     aLbCond31.SelectEntryPos( 0 );
     aLbCond32.SelectEntryPos( 0 );
+    aPreviewWin3.SetDrawBaseLine( false );
+    aPreviewWin3.UseResourceText( true );
 
     // Vorlagen aus pDoc holen
     SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
@@ -228,86 +274,8 @@ ScConditionalFormatDlg::ScConditionalFormatDlg(
     aLbCond2Template.SelectEntry( aName );
     aLbCond3Template.SelectEntry( aName );
 
-    ScAddress aCurPos;
-    ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
-    if (pViewShell)
-    {
-        ScViewData* pData = pViewShell->GetViewData();
-        aCurPos = ScAddress( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
-    }
-
-    // Inhalt aus ConditionalFormat holen
-    if ( pCurrentFormat )
-    {
-        const ScCondFormatEntry* pEntry;
-        if ( pCurrentFormat->Count() > 0 )
-        {
-            pEntry= pCurrentFormat->GetEntry( 0 );
-            aEdtCond11.SetText( pEntry->GetExpression( aCurPos, 0 ) );
-            aLbCond1Template.SelectEntry( pEntry->GetStyle() );
-
-            ScConditionMode	eMode = pEntry->GetOperation();
-            if ( eMode == SC_COND_DIRECT )			// via Formel
-            {
-                aLbCond11.SelectEntryPos( 1 );
-                ChangeCond11Hdl( NULL );
-            }
-            else if ( eMode == SC_COND_NONE )		// ???
-                ;
-            else									// via Werte
-            {
-                aLbCond12.SelectEntryPos( sal::static_int_cast<sal_uInt16>( eMode ) );
-                if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
-                    aEdtCond12.SetText( pEntry->GetExpression( aCurPos, 1 ) );
-            }
-        }
-
-        if ( pCurrentFormat->Count() > 1 )
-        {
-            aCbxCond2.Check( sal_True );
-            pEntry= pCurrentFormat->GetEntry( 1 );
-            aEdtCond21.SetText( pEntry->GetExpression( aCurPos, 0 ) );
-            aLbCond2Template.SelectEntry( pEntry->GetStyle() );
-
-            ScConditionMode	eMode = pEntry->GetOperation();
-            if ( eMode == SC_COND_DIRECT )			// via Formel
-            {
-                aLbCond21.SelectEntryPos( 1 );
-                ChangeCond21Hdl( NULL );
-            }
-            else if ( eMode == SC_COND_NONE )		// ???
-                ;
-            else									// via Werte
-            {
-                aLbCond22.SelectEntryPos( sal::static_int_cast<sal_uInt16>( eMode ) );
-                if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
-                    aEdtCond22.SetText( pEntry->GetExpression( aCurPos, 1 ) );
-            }
-        }
-
-        if ( pCurrentFormat->Count() > 2 )
-        {
-            aCbxCond3.Check( sal_True );
-            pEntry= pCurrentFormat->GetEntry( 2 );
-            aEdtCond31.SetText( pEntry->GetExpression( aCurPos, 0 ) );
-            aLbCond3Template.SelectEntry( pEntry->GetStyle() );
-
-            ScConditionMode	eMode = pEntry->GetOperation();
-            if ( eMode == SC_COND_DIRECT )			// via Formel
-            {
-                aLbCond31.SelectEntryPos( 1 );
-                ChangeCond31Hdl( NULL );
-            }
-            else if ( eMode == SC_COND_NONE )		// ???
-                ;
-            else									// via Werte
-            {
-                aLbCond32.SelectEntryPos( sal::static_int_cast<sal_uInt16>( eMode ) );
-                if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
-                    aEdtCond32.SetText( pEntry->GetExpression( aCurPos, 1 ) );
-            }
-        }
-    }
+    Refresh( nCurrentOffset );
+    Cond1Cheked( true );
 
     ClickCond1Hdl( NULL );
     ClickCond2Hdl( NULL );
@@ -355,10 +323,292 @@ ScConditionalFormatDlg::ScConditionalFormatDlg(
 
 ScConditionalFormatDlg::~ScConditionalFormatDlg()
 {
+    for (SCSIZE i=0; i<nEntryCount; i++)
+        delete ppEntries[i];
+    delete[] ppEntries;
+}
+
+//----------------------------------------------------------------------------
+void ScConditionalFormatDlg::InsertEntry()
+{
+    UpdateValueList( nCurrentOffset );
+    ScCondFormatEntry** ppNew = new ScCondFormatEntry*[nEntryCount+1];
+    for (sal_uInt16 i=0; i<nCurrentOffset; i++)
+        ppNew[i] = ppEntries[i];
+    ppNew[nCurrentOffset] = NULL;
+    for (sal_uInt16 j=(nCurrentOffset); j<nEntryCount; j++)
+        ppNew[j+1] = ppEntries[j];
+    ++nEntryCount;
+    delete[] ppEntries;
+    ppEntries = ppNew;
+    aScrollBar.SetRange( Range( 0, nEntryCount - 3 ) );
+    Refresh( nCurrentOffset );
+    Cond1Cheked( true );
+}
+
+//----------------------------------------------------------------------------
+void ScConditionalFormatDlg::AddEntry()
+{
+    ScCondFormatEntry** ppNew = new ScCondFormatEntry*[nEntryCount+1];
+    for (sal_uInt16 i=0; i<nEntryCount; i++)
+        ppNew[i] = ppEntries[i];
+    ppNew[nEntryCount] = NULL;
+    ++nEntryCount;
+    delete[] ppEntries;
+    ppEntries = ppNew;
+    aScrollBar.SetRange( Range( 0, nEntryCount - 3 ) );
+}
+
+//----------------------------------------------------------------------------
+void ScConditionalFormatDlg::Cond1Cheked( sal_Bool bChecked )
+{
+    aCbxCond1.Check( bChecked );
+    aLbCond11.Enable( bChecked );
+    aLbCond12.Enable( bChecked );
+    aEdtCond11.Enable( bChecked );
+    aRbCond11.Enable( bChecked );
+    aFtCond1And.Enable( bChecked );
+    aEdtCond12.Enable( bChecked );
+    aRbCond12.Enable( bChecked );
+    aFtCond1Template.Enable( bChecked );
+    aLbCond1Template.Enable( bChecked );
+    aBtnNew1.Enable( bChecked );
+    aPreviewWin1.Enable( bChecked );
+}
+
+void ScConditionalFormatDlg::Cond2Cheked( sal_Bool bChecked )
+{
+    aCbxCond2.Check( bChecked );
+    aLbCond21.Enable( bChecked );
+    aLbCond22.Enable( bChecked );
+    aEdtCond21.Enable( bChecked );
+    aRbCond21.Enable( bChecked );
+    aFtCond2And.Enable( bChecked );
+    aEdtCond22.Enable( bChecked );
+    aRbCond22.Enable( bChecked );
+    aFtCond2Template.Enable( bChecked );
+    aLbCond2Template.Enable( bChecked );
+    aBtnNew2.Enable( bChecked );
+    aPreviewWin2.Enable( bChecked );
+}
+
+void ScConditionalFormatDlg::Cond3Cheked( sal_Bool bChecked )
+{
+    aCbxCond3.Check( bChecked );
+    aLbCond31.Enable( bChecked );
+    aLbCond32.Enable( bChecked );
+    aEdtCond31.Enable( bChecked );
+    aRbCond31.Enable( bChecked );
+    aFtCond3And.Enable( bChecked );
+    aEdtCond32.Enable( bChecked );
+    aRbCond32.Enable( bChecked );
+    aFtCond3Template.Enable( bChecked );
+    aLbCond3Template.Enable( bChecked );
+    aBtnNew3.Enable( bChecked );
+    aPreviewWin3.Enable( bChecked );
+}
+
+// -----------------------------------------------------------------------
+namespace
+{
+    // -----------------------------------------------------------------------
+    String OffsetAsText( sal_uInt16 nVal )
+    {
+        String aValNum = ScGlobal::GetEmptyString();
+        if ( nVal >= 10)
+            aValNum = String::CreateFromInt32( nVal / 10 );
+        aValNum += String::CreateFromAscii("~");
+        aValNum += String::CreateFromInt32( nVal % 10 );
+        return aValNum;
+    }
+}
+
+void ScConditionalFormatDlg::Refresh( sal_uInt16 nOffset )
+{
+    ScAddress aCurPos;
+    ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+    if (pViewShell)
+    {
+        ScViewData* pData = pViewShell->GetViewData();
+        aCurPos = ScAddress( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
+    }
+
+    String aEmptyString = ScGlobal::GetEmptyString();
+
+    // update checkBox text with nOffset
+    String aVal1 = aCbxCond1InitialText;
+    aVal1.SearchAndReplace( String::CreateFromAscii( "~1" ), OffsetAsText( nOffset + 1 ) );
+    aCbxCond1.SetText(aVal1);
+
+    String aVal2 = aCbxCond2InitialText;
+    aVal2.SearchAndReplace( String::CreateFromAscii( "~2" ), OffsetAsText( nOffset + 2 ) );
+    aCbxCond2.SetText(aVal2);
+
+    String aVal3 = aCbxCond3InitialText;
+    aVal3.SearchAndReplace( String::CreateFromAscii( "~3" ), OffsetAsText( nOffset + 3 ) );
+    aCbxCond3.SetText(aVal3);
+
+    const ScCondFormatEntry* pEntry;
+    if ( ppEntries[ nOffset + 0 ] )
+    {
+        Cond1Cheked( true );
+        pEntry= ppEntries[ nOffset + 0 ];
+        aEdtCond11.SetText( pEntry->GetExpression( aCurPos, 0 ) );
+        aLbCond1Template.SelectEntry( pEntry->GetStyle() );
+
+        ScConditionMode	eMode = pEntry->GetOperation();
+        if ( eMode == SC_COND_DIRECT )			// via Formel
+            aLbCond11.SelectEntryPos( 1 );
+        else if ( eMode == SC_COND_NONE )		// ???
+            ;
+        else									// via Werte
+        {
+            aLbCond11.SelectEntryPos( 0 );
+            aLbCond12.SelectEntryPos( sal::static_int_cast<sal_uInt16>( eMode ) );
+            if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
+                aEdtCond12.SetText( pEntry->GetExpression( aCurPos, 1 ) );
+        }
+    }
+    else
+    {
+        Cond1Cheked( false );
+        aLbCond11.SelectEntryPos( 0 );
+        aLbCond12.SelectEntryPos( 0 );
+        aLbCond1Template.SelectEntryPos( 0 );
+        aEdtCond11.SetText( aEmptyString );
+        aEdtCond12.SetText( aEmptyString );
+    }
+    ChangeCond11Hdl( NULL );
+    ChangeCond1TemplateHdl( NULL );
+
+    if ( ppEntries[ nOffset + 1 ] )
+    {
+        Cond2Cheked( true );
+        pEntry= ppEntries[ nOffset + 1 ];
+        aEdtCond21.SetText( pEntry->GetExpression( aCurPos, 0 ) );
+        aLbCond2Template.SelectEntry( pEntry->GetStyle() );
+
+        ScConditionMode	eMode = pEntry->GetOperation();
+        if ( eMode == SC_COND_DIRECT )			// via Formel
+            aLbCond21.SelectEntryPos( 1 );
+        else if ( eMode == SC_COND_NONE )		// ???
+            ;
+        else									// via Werte
+        {
+            aLbCond21.SelectEntryPos( 0 );
+            aLbCond22.SelectEntryPos( sal::static_int_cast<sal_uInt16>( eMode ) );
+            if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
+                aEdtCond22.SetText( pEntry->GetExpression( aCurPos, 1 ) );
+        }
+    }
+    else
+    {
+        Cond2Cheked( false );
+        aLbCond21.SelectEntryPos( 0 );
+        aLbCond22.SelectEntryPos( 0 );
+        aLbCond2Template.SelectEntryPos( 0 );
+        aEdtCond21.SetText( aEmptyString );
+        aEdtCond22.SetText( aEmptyString );
+    }
+    ChangeCond21Hdl( NULL );
+    ChangeCond2TemplateHdl( NULL );
+
+    if ( ppEntries[ nOffset + 2 ] )
+    {
+        Cond3Cheked( true );
+        pEntry= ppEntries[ nOffset + 2 ];
+        aEdtCond31.SetText( pEntry->GetExpression( aCurPos, 0 ) );
+        aLbCond3Template.SelectEntry( pEntry->GetStyle() );
+
+        ScConditionMode	eMode = pEntry->GetOperation();
+        if ( eMode == SC_COND_DIRECT )			// via Formel
+            aLbCond31.SelectEntryPos( 1 );
+        else if ( eMode == SC_COND_NONE )		// ???
+            ;
+        else									// via Werte
+        {
+            aLbCond31.SelectEntryPos( 0 );
+            aLbCond32.SelectEntryPos( sal::static_int_cast<sal_uInt16>( eMode ) );
+            if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
+                aEdtCond32.SetText( pEntry->GetExpression( aCurPos, 1 ) );
+        }
+    }
+    else
+    {
+        Cond3Cheked( false );
+        aLbCond31.SelectEntryPos( 0 );
+        aLbCond32.SelectEntryPos( 0 );
+        aLbCond3Template.SelectEntryPos( 0 );
+        aEdtCond31.SetText( aEmptyString );
+        aEdtCond32.SetText( aEmptyString );
+    }
+    ChangeCond31Hdl( NULL );
+    ChangeCond3TemplateHdl( NULL );
 }
 
 //----------------------------------------------------------------------------
+void ScConditionalFormatDlg::UpdateValueList( sal_uInt16 nOffset )
+{
+    ScConditionMode eOper;
+    String sExpr1;
+    String sExpr2;
+    String sStyle;
+    ScAddress aCurPos;
+
+    ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+    if (pViewShell)
+    {
+        ScViewData* pData = pViewShell->GetViewData();
+        aCurPos = ScAddress( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
+    }
+
+    delete ppEntries[ nOffset + 0 ];
+    if ( aCbxCond1.IsChecked() )
+    {
+        if ( aLbCond11.GetSelectEntryPos() == 1 )	// via Formel
+            eOper = SC_COND_DIRECT;
+        else
+            eOper = (ScConditionMode)aLbCond12.GetSelectEntryPos();
+        sExpr1 = aEdtCond11.GetText();
+        sExpr2 = aEdtCond12.GetText();
+        sStyle = aLbCond1Template.GetSelectEntry();
+        ppEntries[ nOffset + 0 ] = new ScCondFormatEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
+    }
+    else
+        ppEntries[ nOffset + 0 ] = NULL;
+
+    delete ppEntries[ nOffset + 1 ];
+    if ( aCbxCond2.IsChecked() )
+    {
+        if ( aLbCond21.GetSelectEntryPos() == 1 )	// via Formel???
+            eOper = SC_COND_DIRECT;
+        else
+            eOper = (ScConditionMode)aLbCond22.GetSelectEntryPos();
+        sExpr1 = aEdtCond21.GetText();
+        sExpr2 = aEdtCond22.GetText();
+        sStyle = aLbCond2Template.GetSelectEntry();
+        ppEntries[ nOffset + 1 ] = new ScCondFormatEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
+    }
+    else
+        ppEntries[ nOffset + 1 ] = NULL;
+
+    delete ppEntries[ nOffset + 2 ];
+    if ( aCbxCond3.IsChecked() )
+    {
+        if ( aLbCond31.GetSelectEntryPos() == 1 )	// via Formel???
+            eOper = SC_COND_DIRECT;
+        else
+            eOper = (ScConditionMode)aLbCond32.GetSelectEntryPos();
+        sExpr1 = aEdtCond31.GetText();
+        sExpr2 = aEdtCond32.GetText();
+        sStyle = aLbCond3Template.GetSelectEntry();
+        ppEntries[ nOffset + 2 ] = new ScCondFormatEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
+    }
+    else
+        ppEntries[ nOffset + 2 ] = NULL;
+}
 
+//----------------------------------------------------------------------------
 void ScConditionalFormatDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
 {
     if ( pEdActive )
@@ -424,12 +674,6 @@ void ScConditionalFormatDlg::SetActive()
 
 void ScConditionalFormatDlg::GetConditionalFormat( ScConditionalFormat& rCndFmt )
 {
-    ScConditionMode eOper;
-    String sExpr1;
-    String sExpr2;
-    String sStyle;
-    ScAddress aCurPos;
-
     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     if (pViewShell)
     {
@@ -437,47 +681,12 @@ void ScConditionalFormatDlg::GetConditionalFormat( ScConditionalFormat& rCndFmt
         ScRangeListRef rRanges;
         pData->GetMultiArea( rRanges );
         rCndFmt.AddRangeInfo( rRanges );
-        aCurPos = ScAddress( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
-    }
-
-    if ( aCbxCond1.IsChecked() )
-    {
-        if ( aLbCond11.GetSelectEntryPos() == 1 )	// via Formel
-            eOper = SC_COND_DIRECT;
-        else
-            eOper = (ScConditionMode)aLbCond12.GetSelectEntryPos();
-        sExpr1 = aEdtCond11.GetText();
-        sExpr2 = aEdtCond12.GetText();
-        sStyle = aLbCond1Template.GetSelectEntry();
-        ScCondFormatEntry aNewEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
-        rCndFmt.AddEntry( aNewEntry );
-    }
-
-    if ( aCbxCond2.IsChecked() )
-    {
-        if ( aLbCond21.GetSelectEntryPos() == 1 )	// via Formel???
-            eOper = SC_COND_DIRECT;
-        else
-            eOper = (ScConditionMode)aLbCond22.GetSelectEntryPos();
-        sExpr1 = aEdtCond21.GetText();
-        sExpr2 = aEdtCond22.GetText();
-        sStyle = aLbCond2Template.GetSelectEntry();
-        ScCondFormatEntry aNewEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
-        rCndFmt.AddEntry( aNewEntry );
     }
 
-    if ( aCbxCond3.IsChecked() )
-    {
-        if ( aLbCond31.GetSelectEntryPos() == 1 )	// via Formel???
-            eOper = SC_COND_DIRECT;
-        else
-            eOper = (ScConditionMode)aLbCond32.GetSelectEntryPos();
-        sExpr1 = aEdtCond31.GetText();
-        sExpr2 = aEdtCond32.GetText();
-        sStyle = aLbCond3Template.GetSelectEntry();
-        ScCondFormatEntry aNewEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
-        rCndFmt.AddEntry( aNewEntry );
-    }
+    UpdateValueList( nCurrentOffset );
+    for (SCSIZE i=0; i<nEntryCount; i++)
+        if ( ppEntries[i] )
+            rCndFmt.AddEntry( *ppEntries[i] );
 }
 
 //----------------------------------------------------------------------------
@@ -492,23 +701,35 @@ sal_Bool ScConditionalFormatDlg::Close()
 // Handler:
 
 //----------------------------------------------------------------------------
+IMPL_LINK( ScConditionalFormatDlg, ScrollHdl, ScrollBar*, EMPTYARG )
+{
+    SliderMoved();
+    return 0;
+}
+
+void ScConditionalFormatDlg::SliderMoved()
+{
+    sal_uInt16 nOffset = GetSliderPos();
+    if ( nOffset != nCurrentOffset )
+    {
+        UpdateValueList( nCurrentOffset );
+        Refresh( nOffset );
+    }
+    nCurrentOffset =  nOffset;
+}
+sal_uInt16 ScConditionalFormatDlg::GetSliderPos()
+{
+    return (sal_uInt16) aScrollBar.GetThumbPos();
+}
+
+//----------------------------------------------------------------------------
 // Enabled/Disabled Condition1-Controls
 
 IMPL_LINK( ScConditionalFormatDlg, ClickCond1Hdl, void *, EMPTYARG )
 {
     sal_Bool bChecked = aCbxCond1.IsChecked();
 
-    aLbCond11.Enable( bChecked );
-    aLbCond12.Enable( bChecked );
-    aEdtCond11.Enable( bChecked );
-    aRbCond11.Enable( bChecked );
-    aFtCond1And.Enable( bChecked );
-    aEdtCond12.Enable( bChecked );
-    aRbCond12.Enable( bChecked );
-    aFtCond1Template.Enable( bChecked );
-    aLbCond1Template.Enable( bChecked );
-    aBtnNew1.Enable( bChecked );
-
+    Cond1Cheked( bChecked );
     return( 0L );
 }
 
@@ -580,23 +801,30 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond12Hdl, void *, EMPTYARG )
 }
 
 //----------------------------------------------------------------------------
+
+IMPL_LINK( ScConditionalFormatDlg, ChangeCond1TemplateHdl, void *, EMPTYARG )
+{
+    String aStyleName = aLbCond1Template.GetSelectEntry();
+    SfxStyleSheetBase* pStyleSheet = pDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
+    if ( pStyleSheet )
+    {
+        const SfxItemSet& rSet = pStyleSheet->GetItemSet();
+        aPreviewWin1.Init( rSet );
+        aPreviewWin1.Show();
+    }
+    else
+        aPreviewWin1.Hide();
+    return( 0L );
+}
+
+//----------------------------------------------------------------------------
 // Enabled/Disabled Condition2-Controls
 
 IMPL_LINK( ScConditionalFormatDlg, ClickCond2Hdl, void *, EMPTYARG )
 {
     sal_Bool bChecked = aCbxCond2.IsChecked();
 
-    aLbCond21.Enable( bChecked );
-    aLbCond22.Enable( bChecked );
-    aEdtCond21.Enable( bChecked );
-    aRbCond21.Enable( bChecked );
-    aFtCond2And.Enable( bChecked );
-    aEdtCond22.Enable( bChecked );
-    aRbCond22.Enable( bChecked );
-    aFtCond2Template.Enable( bChecked );
-    aLbCond2Template.Enable( bChecked );
-    aBtnNew2.Enable( bChecked );
-
+    Cond2Cheked( bChecked );
     return( 0L );
 }
 
@@ -668,23 +896,32 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond22Hdl, void *, EMPTYARG )
 }
 
 //----------------------------------------------------------------------------
+
+IMPL_LINK( ScConditionalFormatDlg, ChangeCond2TemplateHdl, void *, EMPTYARG )
+{
+    String aStyleName = aLbCond2Template.GetSelectEntry();
+    SfxStyleSheetBase* pStyleSheet = pDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
+    if ( pStyleSheet )
+    {
+        const SfxItemSet& rSet = pStyleSheet->GetItemSet();
+        aPreviewWin2.Init( rSet );
+        aPreviewWin2.Show();
+    }
+    else
+        aPreviewWin2.Hide();
+    return( 0L );
+}
+
+//----------------------------------------------------------------------------
 // Enabled/Disabled Condition3-Controls
 
 IMPL_LINK( ScConditionalFormatDlg, ClickCond3Hdl, void *, EMPTYARG )
 {
     sal_Bool bChecked = aCbxCond3.IsChecked();
 
-    aLbCond31.Enable( bChecked );
-    aLbCond32.Enable( bChecked );
-    aEdtCond31.Enable( bChecked );
-    aRbCond31.Enable( bChecked );
-    aFtCond3And.Enable( bChecked );
-    aEdtCond32.Enable( bChecked );
-    aRbCond32.Enable( bChecked );
-    aFtCond3Template.Enable( bChecked );
-    aLbCond3Template.Enable( bChecked );
-    aBtnNew3.Enable( bChecked );
-
+    Cond3Cheked( bChecked );
+    if ( bChecked && ( ( nCurrentOffset + 3 ) == nEntryCount ) )
+        AddEntry();
     return( 0L );
 }
 
@@ -757,6 +994,23 @@ IMPL_LINK( ScConditionalFormatDlg, ChangeCond32Hdl, void *, EMPTYARG )
 
 //----------------------------------------------------------------------------
 
+IMPL_LINK( ScConditionalFormatDlg, ChangeCond3TemplateHdl, void *, EMPTYARG )
+{
+    String aStyleName = aLbCond3Template.GetSelectEntry();
+    SfxStyleSheetBase* pStyleSheet = pDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
+    if ( pStyleSheet )
+    {
+        const SfxItemSet& rSet = pStyleSheet->GetItemSet();
+        aPreviewWin3.Init( rSet );
+        aPreviewWin3.Show();
+    }
+    else
+        aPreviewWin3.Hide();
+    return( 0L );
+}
+
+//----------------------------------------------------------------------------
+
 IMPL_LINK( ScConditionalFormatDlg, GetFocusHdl, Control*, pCtrl )
 {
     if( (pCtrl == (Control*)&aEdtCond11) || (pCtrl == (Control*)&aRbCond11) )
@@ -806,6 +1060,10 @@ IMPL_LINK( ScConditionalFormatDlg, BtnHdl, PushButton*, pBtn )
                                   &aOutItem, 0L, 0L );
         Close();
     }
+
+    else if ( pBtn == &aBtnInsert )
+        InsertEntry();
+
     else if ( pBtn == &aBtnCancel )
         Close();
 
@@ -863,6 +1121,10 @@ IMPL_LINK( ScConditionalFormatDlg, NewBtnHdl, PushButton*, pBtn )
             pListBox = &aLbCond3Template;
 
         pListBox->SelectEntry( aNewStyle );
+
+        ChangeCond1TemplateHdl( NULL );
+        ChangeCond2TemplateHdl( NULL );
+        ChangeCond3TemplateHdl( NULL );
     }
 
     return 0;
diff --git a/sc/source/ui/inc/condfrmt.hrc b/sc/source/ui/inc/condfrmt.hrc
index 01db4be..0452018 100644
--- a/sc/source/ui/inc/condfrmt.hrc
+++ b/sc/source/ui/inc/condfrmt.hrc
@@ -63,6 +63,13 @@
 #define FL_SEP1             41
 #define FL_SEP2             42
 
+#define LB_SCROLL           43
+
+#define WIN_CHAR_PREVIEW_COND1		44
+#define WIN_CHAR_PREVIEW_COND2		45
+#define WIN_CHAR_PREVIEW_COND3		46
+#define BTN_INSERT	    47
+
 //IAccessibility2 Implementation 2009-----
 #define LABEL_FORMARTTING_CONDITIONS	5043
 #define LABEL_CONDITIONS 				5044
diff --git a/sc/source/ui/inc/condfrmt.hxx b/sc/source/ui/inc/condfrmt.hxx
index b5e9ed9..31a1fed 100644
--- a/sc/source/ui/inc/condfrmt.hxx
+++ b/sc/source/ui/inc/condfrmt.hxx
@@ -33,6 +33,7 @@
 #include "anyrefdg.hxx"
 #include <vcl/fixed.hxx>
 #include <vcl/lstbox.hxx>
+#include <svx/fntctrl.hxx>
 
 
 class ScDocument;
@@ -52,49 +53,60 @@ public:
                                             const ScConditionalFormat* pCurrentFormat );
                     ~ScConditionalFormatDlg();
 
-    virtual void	SetReference( const ScRange& rRef, ScDocument* pDoc );
-    virtual void	AddRefEntry();
+    virtual void	    SetReference( const ScRange& rRef, ScDocument* pDoc );
+    virtual void	    AddRefEntry();
     virtual sal_Bool    IsRefInputMode() const;
-    virtual void	SetActive();
+    virtual void	    SetActive();
+    void			    SliderMoved();
+    sal_uInt16			GetSliderPos();
     virtual sal_Bool	Close();
 
 private:
     CheckBox			aCbxCond1;
     ListBox				aLbCond11;
     ListBox				aLbCond12;
-    formula::RefEdit			aEdtCond11;
-    formula::RefButton			aRbCond11;
+    formula::RefEdit	aEdtCond11;
+    formula::RefButton	aRbCond11;
     FixedText			aFtCond1And;
-    formula::RefEdit			aEdtCond12;
-    formula::RefButton			aRbCond12;
+    formula::RefEdit	aEdtCond12;
+    formula::RefButton	aRbCond12;
     FixedText			aFtCond1Template;
     ListBox				aLbCond1Template;
     PushButton          aBtnNew1;
+    SvxFontPrevWindow	aPreviewWin1;
+    FixedLine           aFlSep1;
+
     CheckBox            aCbxCond2;
     ListBox				aLbCond21;
     ListBox				aLbCond22;
-    formula::RefEdit			aEdtCond21;
-    formula::RefButton			aRbCond21;
+    formula::RefEdit	aEdtCond21;
+    formula::RefButton	aRbCond21;
     FixedText			aFtCond2And;
-    formula::RefEdit			aEdtCond22;
-    formula::RefButton			aRbCond22;
+    formula::RefEdit	aEdtCond22;
+    formula::RefButton	aRbCond22;
     FixedText			aFtCond2Template;
     ListBox				aLbCond2Template;
     PushButton          aBtnNew2;
+    SvxFontPrevWindow	aPreviewWin2;
+    FixedLine           aFlSep2;
+
     CheckBox			aCbxCond3;
     ListBox				aLbCond31;
     ListBox				aLbCond32;
-    formula::RefEdit			aEdtCond31;
-    formula::RefButton			aRbCond31;
+    formula::RefEdit	aEdtCond31;
+    formula::RefButton	aRbCond31;
     FixedText			aFtCond3And;
-    formula::RefEdit			aEdtCond32;
-    formula::RefButton			aRbCond32;
+    formula::RefEdit	aEdtCond32;
+    formula::RefButton	aRbCond32;
     FixedText			aFtCond3Template;
     ListBox				aLbCond3Template;
     PushButton          aBtnNew3;
+    SvxFontPrevWindow	aPreviewWin3;
 
+    ScrollBar           aScrollBar;
     OKButton			aBtnOk;
     CancelButton		aBtnCancel;
+    PushButton          aBtnInsert;
     HelpButton			aBtnHelp;
 
     Point				aCond1Pos1;
@@ -120,31 +132,48 @@ private:
     Size				aCond3Size1;
     Size				aCond3Size2;
     Size				aCond3Size3;
-    FixedLine           aFlSep2;
-    FixedLine           aFlSep1;
-    formula::RefEdit*			pEdActive;
-    sal_Bool				bDlgLostFocus;
+
+    formula::RefEdit*	pEdActive;
+    sal_Bool			bDlgLostFocus;
     ScDocument*			pDoc;
+    ScCondFormatEntry**	ppEntries;
+    sal_uInt16			nEntryCount;
+    sal_uInt16			nCurrentOffset;
+    String              aCbxCond1InitialText;
+    String              aCbxCond2InitialText;
+    String              aCbxCond3InitialText;
 
 #ifdef _CONDFRMT_CXX
+    void    InsertEntry();
+    void    AddEntry();
     void	GetConditionalFormat( ScConditionalFormat& rCndFmt );
+    void    Refresh( sal_uInt16 nOffset );
+    void	UpdateValueList	( sal_uInt16 nOffset );
+    void    Cond1Cheked( sal_Bool bChecked );
+    void    Cond2Cheked( sal_Bool bChecked );
+    void    Cond3Cheked( sal_Bool bChecked );
 
     DECL_LINK( ClickCond1Hdl, void * );
     DECL_LINK( ChangeCond11Hdl, void * );
     DECL_LINK( ChangeCond12Hdl, void * );
+    DECL_LINK( ChangeCond1TemplateHdl, void * );
 
     DECL_LINK( ClickCond2Hdl, void * );
     DECL_LINK( ChangeCond21Hdl, void * );
     DECL_LINK( ChangeCond22Hdl, void * );
+    DECL_LINK( ChangeCond2TemplateHdl, void * );
 
     DECL_LINK( ClickCond3Hdl, void * );
     DECL_LINK( ChangeCond31Hdl, void * );
     DECL_LINK( ChangeCond32Hdl, void * );
+    DECL_LINK( ChangeCond3TemplateHdl, void * );
 
     DECL_LINK( GetFocusHdl, Control* );
     DECL_LINK( LoseFocusHdl, Control* );
     DECL_LINK( BtnHdl, PushButton* );
     DECL_LINK( NewBtnHdl, PushButton* );
+    DECL_LINK( ScrollHdl, ScrollBar* );
+
 #endif // _CONDFRMT_CXX
 };
 
diff --git a/sc/source/ui/src/condfrmt.src b/sc/source/ui/src/condfrmt.src
index bc10d1f..e223a25 100644
--- a/sc/source/ui/src/condfrmt.src
+++ b/sc/source/ui/src/condfrmt.src
@@ -31,7 +31,7 @@ ModelessDialog RID_SCDLG_CONDFORMAT
 {
     OutputSize = TRUE ;
     SVLook = TRUE ;
-    Size = MAP_APPFONT ( 316 , 161 ) ;
+    Size = MAP_APPFONT ( 326 , 161 ) ;
     Moveable = TRUE ;
     Closeable = TRUE ;
     HelpId = HID_SCDLG_CONDFORMAT ;
@@ -136,10 +136,17 @@ ModelessDialog RID_SCDLG_CONDFORMAT
         DropDown = TRUE ;
         Sort = TRUE ;
     };
+    Window WIN_CHAR_PREVIEW_COND1
+    {
+        Border = FALSE ;
+        Pos = MAP_APPFONT ( 124 , 34 ) ;
+        Size = MAP_APPFONT ( 41 , 14 ) ;
+        Text [ en-US ] = "Example";
+    };
     PushButton BTN_COND1_NEW
     {
         HelpID = "sc:PushButton:RID_SCDLG_CONDFORMAT:BTN_COND1_NEW";
-        Pos = MAP_APPFONT ( 124 , 34 ) ;
+        Pos = MAP_APPFONT ( 169 , 34 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
         TabStop = TRUE ;
         Text [ en-US ] = "~New Style..." ;
@@ -249,10 +256,17 @@ ModelessDialog RID_SCDLG_CONDFORMAT
         DropDown = TRUE ;
         Sort = TRUE ;
     };
+    Window WIN_CHAR_PREVIEW_COND2
+    {
+        Border = FALSE ;
+        Pos = MAP_APPFONT ( 124 , 88 ) ;
+        Size = MAP_APPFONT ( 41 , 14 ) ;
+        Text [ en-US ] = "Example";
+    };
     PushButton BTN_COND2_NEW
     {
         HelpID = "sc:PushButton:RID_SCDLG_CONDFORMAT:BTN_COND2_NEW";
-        Pos = MAP_APPFONT ( 124 , 88 ) ;
+        Pos = MAP_APPFONT ( 169 , 88 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
         TabStop = TRUE ;
         Text [ en-US ] = "Ne~w Style..." ;
@@ -362,30 +376,51 @@ ModelessDialog RID_SCDLG_CONDFORMAT
         DropDown = TRUE ;
         Sort = TRUE ;
     };
+    Window WIN_CHAR_PREVIEW_COND3
+    {
+        Border = FALSE ;
+        Pos = MAP_APPFONT ( 124 , 142 ) ;
+        Size = MAP_APPFONT ( 41 , 14 ) ;
+        Text [ en-US ] = "Example";
+    };
     PushButton BTN_COND3_NEW
     {
         HelpID = "sc:PushButton:RID_SCDLG_CONDFORMAT:BTN_COND3_NEW";
-        Pos = MAP_APPFONT ( 124 , 142 ) ;
+        Pos = MAP_APPFONT ( 169 , 142 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
         TabStop = TRUE ;
         Text [ en-US ] = "New ~Style..." ;
     };
+    ScrollBar LB_SCROLL
+    {
+        Pos = MAP_APPFONT ( 260, 6 ) ;
+        Size = MAP_APPFONT ( 8 , 150 ) ;
+        TabStop = TRUE ;
+        VScroll = TRUE ;
+    };
     OKButton BTN_OK
     {
-        Pos = MAP_APPFONT ( 260 , 6 ) ;
+        Pos = MAP_APPFONT ( 270 , 6 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
         TabStop = TRUE ;
         DefButton = TRUE ;
     };
     CancelButton BTN_CANCEL
     {
-        Pos = MAP_APPFONT ( 260 , 23 ) ;
+        Pos = MAP_APPFONT ( 270 , 23 ) ;
+        Size = MAP_APPFONT ( 50 , 14 ) ;
+        TabStop = TRUE ;
+    };
+    PushButton BTN_INSERT
+    {
+        Pos = MAP_APPFONT ( 270 , 57 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
         TabStop = TRUE ;
+        Text [ en-US ] = "~Insert" ;
     };
     HelpButton BTN_HELP
     {
-        Pos = MAP_APPFONT ( 260 , 43 ) ;
+        Pos = MAP_APPFONT ( 270 , 74 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
         TabStop = TRUE ;
     };


More information about the Libreoffice-commits mailing list