Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hello,

I finally finished my work on the conditional formatting with an unlimited number of rules.

Thank you to those who have helped me to create patch.
I hope I have done things correctly. You will find the patch in 2 attachment.

Changes were made ​​to module svx sc.

The development and testing was done on Ubuntu 10.10 and everything seems ok. I have only a display issue on scrollbar!

You is it possible to test it on other platforms and other languages?

Screen shot : http://archives.bobiciel.com/libo/condfrmt/condfrmt.jpg
Test file : http://archives.bobiciel.com/libo/condfrmt/test_condfrmt_100.ods

Thank you for your feedback

Bob

From 5e7a0dc80bbdfc9c513c15985a66569938020038 Mon Sep 17 00:00:00 2001
From: Robert DARGAUD <libo@bobiciel.com>
Date: Mon, 4 Apr 2011 23:04:56 +0200
Subject: [PATCH] Conditional formatting with an unlimited rules number

---
 svx/inc/svx/fntctrl.hxx       |   14 +-
 svx/source/dialog/fntctrl.cxx |  649 +++++++++++++++++++++++++++++++++--------
 2 files changed, 536 insertions(+), 127 deletions(-)
 mode change 100755 => 100644 svx/inc/svx/fntctrl.hxx
 mode change 100755 => 100644 svx/source/dialog/fntctrl.cxx

diff --git a/svx/inc/svx/fntctrl.hxx b/svx/inc/svx/fntctrl.hxx
old mode 100755
new mode 100644
index c9a4c34..bdac4cc
--- a/svx/inc/svx/fntctrl.hxx
+++ b/svx/inc/svx/fntctrl.hxx
@@ -33,6 +33,8 @@
 #include <vcl/window.hxx>
 #include <editeng/svxfont.hxx>
 #include "svx/svxdllapi.h"
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
 
 #include <rtl/ustring.hxx>
 
@@ -57,6 +59,8 @@ public:
     virtual void               StateChanged( StateChangedType nStateChange );
     virtual void               DataChanged( const DataChangedEvent& rDCEvt );
 
+    void                Init( const SfxItemSet& rSet );
+
     // for reasons of efficiency not const
     SvxFont&                   GetFont();
     const SvxFont&             GetFont() const;
@@ -70,9 +74,11 @@ public:
     void                ResetColor();
     void                SetBackColor( const Color& rColor );
     void                UseResourceText( sal_Bool bUse = sal_True );
+    void                SetDrawBaseLine( sal_Bool bSet = sal_True );
+    void                SetPreviewBackgroundToCharacter( sal_Bool bSet = sal_True );
     void                               Paint( const Rectangle& );
 
-    sal_Bool                           IsTwoLines() const;
+    sal_Bool                   IsTwoLines() const;
     void                               SetTwoLines(sal_Bool bSet);
 
     void                               SetBrackets(sal_Unicode cStart, sal_Unicode cEnd);
@@ -83,6 +89,12 @@ public:
 
     void                SetPreviewText( const ::rtl::OUString& rString );
     void                SetFontNameAsPreviewText();
+
+    void                               SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, 
SvxFont& rFont );
+    void                               SetFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& 
rFont );
+    void                               SetFontStyle( const SfxItemSet& rSet, sal_uInt16 
nSlotPosture, sal_uInt16 nSlotWeight, SvxFont& rFont ); // posture/weight
+    void                               SetFontWidthScale( const SfxItemSet& rSet );
+    void                               SetFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, 
short nEsc );
 };
 
 #endif // #ifndef _SVX_FNTCTRL_HXX
diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx
old mode 100755
new mode 100644
index a34cae1..1fc210d
--- a/svx/source/dialog/fntctrl.cxx
+++ b/svx/source/dialog/fntctrl.cxx
@@ -54,6 +54,39 @@
 #include <svx/dialogs.hrc>
 #define TEXT_WIDTH     20
 
+// RMQ voir si tous ces include sont indispensables
+#include <editeng/editids.hrc>
+#include "editeng/fontitem.hxx"
+#include <editeng/postitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/escpitem.hxx>
+#include <editeng/prszitem.hxx>
+#include <editeng/wrlmitem.hxx>
+#include <editeng/cmapitem.hxx>
+#include <editeng/kernitem.hxx>
+#include <editeng/blnkitem.hxx>
+#include "editeng/flstitem.hxx"
+#include <editeng/akrnitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/emphitem.hxx>
+#include <editeng/charreliefitem.hxx>
+#include <editeng/twolinesitem.hxx>
+#include <editeng/charhiddenitem.hxx>
+#include <svl/stritem.hxx>
+#include <editeng/charscaleitem.hxx>
+#include <editeng/charrotateitem.hxx>
+
+// define ----------------------------------------------------------------
+
+#define ISITEMSET      rSet.GetItemState(nWhich)>=SFX_ITEM_DEFAULT
+
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
 using ::com::sun::star::i18n::XBreakIterator;
@@ -113,7 +146,7 @@ class FontPrevWin_Impl
 
     SvxFont                                    aFont;
     Printer*                                   pPrinter;
-    sal_Bool                                           bDelPrinter;
+    sal_Bool                                   bDelPrinter;
 
     Reference < XBreakIterator >       xBreak;
     SvULongs                                           aTextWidth;
@@ -132,11 +165,13 @@ class FontPrevWin_Impl
     long                                                       n100PercentFontWidth;           // 
initial -1 -> not set yet
     long                                                       n100PercentFontWidthCJK;
     long                                                       n100PercentFontWidthCTL;
-    sal_uInt16                                                 nFontWidthScale;
+    sal_uInt16                                         nFontWidthScale;
 
-    sal_Bool                                                   bSelection              : 1,
+    sal_Bool                                           bSelection              : 1,
                                     bGetSelection   : 1,
                                     bUseResText     : 1,
+                                    bDrawBaseLine   : 1,
+                                    bPreviewBackgroundToCharacter : 1,
                                     bTwoLines       : 1,
                                     bIsCJKUI        : 1,
                                     bIsCTLUI        : 1,
@@ -150,7 +185,7 @@ public:
         pColor( NULL ), pBackColor( 0 ), nAscent( 0 ),
         cStartBracket( 0 ), cEndBracket( 0 ), nFontWidthScale( 100 ),
         bSelection( sal_False ), bGetSelection( sal_False ), bUseResText( sal_False ),
-        bTwoLines( sal_False ),
+        bDrawBaseLine( sal_True ), bPreviewBackgroundToCharacter( sal_False ), bTwoLines( 
sal_False ),
         bIsCJKUI( sal_False ), bIsCTLUI( sal_False ),
         bUseFontNameAsText( sal_False ), bTextInited( sal_False )
         {
@@ -169,9 +204,9 @@ public:
     Size                               CalcTextSize( OutputDevice* pWin, OutputDevice* pPrt, 
SvxFont &rFont );
     void                               DrawPrev( OutputDevice* pWin, Printer* pPrt, Point &rPt, 
SvxFont &rFont );
 
-    sal_Bool                           SetFontWidthScale( sal_uInt16 nScaleInPercent );
+    sal_Bool                   SetFontWidthScale( sal_uInt16 nScaleInPercent );
     inline void                        Invalidate100PercentFontWidth();
-    inline sal_Bool                    Is100PercentFontWidthValid() const;
+    inline sal_Bool            Is100PercentFontWidthValid() const;
     void                               ScaleFontWidth( const OutputDevice& rOutDev );
                             // scales rNonCJKFont and aCJKFont depending on nFontWidthScale and
                             //  sets the 100%-Font-Widths
@@ -532,6 +567,7 @@ void SvxFontPrevWindow::StateChanged( StateChangedType nType )
         InitSettings( sal_False, sal_True );
 
     Window::StateChanged( nType );
+    Invalidate();
 }
 
 // -----------------------------------------------------------------------
@@ -646,6 +682,20 @@ void SvxFontPrevWindow::UseResourceText( sal_Bool bUse )
 
 // -----------------------------------------------------------------------
 
+void SvxFontPrevWindow::SetDrawBaseLine( sal_Bool bSet )
+{
+    pImpl->bDrawBaseLine = bSet;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetPreviewBackgroundToCharacter(sal_Bool bSet)
+{
+    pImpl->bPreviewBackgroundToCharacter = bSet;
+}
+
+// -----------------------------------------------------------------------
+
 void SvxFontPrevWindow::Paint( const Rectangle& )
 {
     Printer* pPrinter = pImpl->pPrinter;
@@ -653,153 +703,171 @@ void SvxFontPrevWindow::Paint( const Rectangle& )
     SvxFont& rCJKFont = pImpl->aCJKFont;
     // TODO: SvxFont& rCTLFont = pImpl->aCTLFont;
 
-    if ( pImpl->bUseResText )
-        pImpl->aText = GetText();
-    else if ( !pImpl->bSelection && !pImpl->bTextInited )
+    if ( !IsEnabled() )
     {
-        SfxViewShell* pSh = SfxViewShell::Current();
+        const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+        const Size aLogSize( GetOutputSize() );
 
-        if ( pSh && !pImpl->bGetSelection && !pImpl->bUseFontNameAsText )
-        {
-            pImpl->aText = pSh->GetSelectionText();
-            pImpl->bGetSelection = sal_True;
-            pImpl->bSelection = pImpl->aText.Len() != 0;
-
-        }
-
-        if ( !pImpl->bSelection || pImpl->bUseFontNameAsText )
+        Rectangle aRect( Point( 0, 0 ), aLogSize );
+        SetLineColor();
+        SetFillColor( rStyleSettings.GetWindowColor() );
+        DrawRect( aRect );
+    }
+    else
+    {
+        if ( pImpl->bUseResText )
+            pImpl->aText = GetText();
+        else if ( !pImpl->bSelection && !pImpl->bTextInited )
         {
-            pImpl->aText = rFont.GetName();
-            if( pImpl->bIsCJKUI )
-                pImpl->aText += rCJKFont.GetName();
-            //TODO bIsCTLUI
-        }
+            SfxViewShell* pSh = SfxViewShell::Current();
 
-        if ( !pImpl->aText.Len() )
-            pImpl->aText = GetText();
+            if ( pSh && !pImpl->bGetSelection && !pImpl->bUseFontNameAsText )
+            {
+                pImpl->aText = pSh->GetSelectionText();
+                pImpl->bGetSelection = sal_True;
+                pImpl->bSelection = pImpl->aText.Len() != 0;
 
-        // remove line feeds and carriage returns from string
-        bool bNotEmpty = false;
-        for ( xub_StrLen i = 0; i < pImpl->aText.Len(); ++i )
-        {
-            if ( 0xa == pImpl->aText.GetChar( i ) ||
-                 0xd == pImpl->aText.GetChar( i ) )
-                 pImpl->aText.SetChar( i, ' ' );
-            else
-                bNotEmpty = true;
-        }
-        if ( !bNotEmpty )
-            pImpl->aText = GetText();
+            }
 
-        if ( pImpl->aText.Len() > (TEXT_WIDTH-1) )
-            pImpl->aText.Erase( pImpl->aText.Search( sal_Unicode( ' ' ), TEXT_WIDTH ) );
-    }
+            if ( !pImpl->bSelection || pImpl->bUseFontNameAsText )
+            {
+                pImpl->aText = rFont.GetName();
+                if( pImpl->bIsCJKUI )
+                    pImpl->aText += rCJKFont.GetName();
+                //TODO bIsCTLUI
+            }
 
-    // calculate text width scaling
-    pImpl->ScaleFontWidth( *this/*, rFont*/ );
+            if ( !pImpl->aText.Len() )
+                pImpl->aText = GetText();
 
-    pImpl->CheckScript();
-    Size aTxtSize = pImpl->CalcTextSize( this, pPrinter, rFont );
+            // remove line feeds and carriage returns from string
+            bool bNotEmpty = false;
+            for ( xub_StrLen i = 0; i < pImpl->aText.Len(); ++i )
+            {
+                if ( 0xa == pImpl->aText.GetChar( i ) ||
+                     0xd == pImpl->aText.GetChar( i ) )
+                     pImpl->aText.SetChar( i, ' ' );
+                else
+                    bNotEmpty = true;
+            }
+            if ( !bNotEmpty )
+                pImpl->aText = GetText();
 
-    const Size aLogSize( GetOutputSize() );
+            if ( pImpl->aText.Len() > (TEXT_WIDTH-1) )
+                pImpl->aText.Erase( pImpl->aText.Search( sal_Unicode( ' ' ), TEXT_WIDTH ) );
+        }
 
-    long nX = aLogSize.Width()  / 2 - aTxtSize.Width() / 2;
-    long nY = aLogSize.Height() / 2 - aTxtSize.Height() / 2;
+        // calculate text width scaling
+        pImpl->ScaleFontWidth( *this/*, rFont*/ );
 
-    if ( nY + pImpl->nAscent > aLogSize.Height() )
-        nY = aLogSize.Height() - pImpl->nAscent;
+        pImpl->CheckScript();
+        Size aTxtSize = pImpl->CalcTextSize( this, pPrinter, rFont );
 
-    if ( pImpl->pBackColor )
-    {
-        Rectangle aRect( Point( 0, 0 ), aLogSize );
-        Color aLineCol = GetLineColor();
-        Color aFillCol = GetFillColor();
-        SetLineColor();
-        SetFillColor( *pImpl->pBackColor );
-        DrawRect( aRect );
-        SetLineColor( aLineCol );
-        SetFillColor( aFillCol );
-    }
-    if ( pImpl->pColor )
-    {
-        Rectangle aRect( Point( nX, nY ), aTxtSize );
-        Color aLineCol = GetLineColor();
-        Color aFillCol = GetFillColor();
-        SetLineColor();
-        SetFillColor( *pImpl->pColor );
-        DrawRect( aRect );
-        SetLineColor( aLineCol );
-        SetFillColor( aFillCol );
-    }
+        const Size aLogSize( GetOutputSize() );
 
-    long nStdAscent = pImpl->nAscent;
-    nY += nStdAscent;
+        long nX = aLogSize.Width()  / 2 - aTxtSize.Width() / 2;
+        long nY = aLogSize.Height() / 2 - aTxtSize.Height() / 2;
 
-    if(pImpl->bTwoLines)
-    {
-        SvxFont aSmallFont( rFont );
-        Size aOldSize = pImpl->aCJKFont.GetSize();
-        setFontSize(aSmallFont);
-        setFontSize(pImpl->aCJKFont);
+        if ( nY + pImpl->nAscent > aLogSize.Height() )
+            nY = aLogSize.Height() - pImpl->nAscent;
 
-        long nStartBracketWidth = 0;
-        long nEndBracketWidth = 0;
-        long nTextWidth = 0;
-        if(pImpl->cStartBracket)
+        if ( pImpl->pBackColor )
         {
-            String sBracket(pImpl->cStartBracket);
-            nStartBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width();
+            Rectangle aRect( Point( 0, 0 ), aLogSize );
+            Color aLineCol = GetLineColor();
+            Color aFillCol = GetFillColor();
+            SetLineColor();
+            SetFillColor( *pImpl->pBackColor );
+            DrawRect( aRect );
+            SetLineColor( aLineCol );
+            SetFillColor( aFillCol );
         }
-        if(pImpl->cEndBracket)
+        if ( pImpl->pColor )
         {
-            String sBracket(pImpl->cEndBracket);
-            nEndBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width();
+            Rectangle aRect( Point( nX, nY ), aTxtSize );
+            Color aLineCol = GetLineColor();
+            Color aFillCol = GetFillColor();
+            SetLineColor();
+            SetFillColor( *pImpl->pColor );
+            DrawRect( aRect );
+            SetLineColor( aLineCol );
+            SetFillColor( aFillCol );
         }
-        nTextWidth = pImpl->CalcTextSize( this, pPrinter, aSmallFont ).Width();
-        long nResultWidth = nStartBracketWidth;
-        nResultWidth += nEndBracketWidth;
-        nResultWidth += nTextWidth;
 
-        long _nX = (aLogSize.Width() - nResultWidth) / 2;
-        DrawLine( Point( 0,  nY ), Point( _nX, nY ) );
-        DrawLine( Point( _nX + nResultWidth, nY ), Point( aLogSize.Width(), nY ) );
+        long nStdAscent = pImpl->nAscent;
+        nY += nStdAscent;
 
-        long nSmallAscent = pImpl->nAscent;
-        long nOffset = (nStdAscent - nSmallAscent ) / 2;
-
-        if(pImpl->cStartBracket)
+        if(pImpl->bTwoLines)
         {
-            String sBracket(pImpl->cStartBracket);
-            rFont.DrawPrev( this, pPrinter, Point( _nX, nY - nOffset - 4), sBracket );
-            _nX += nStartBracketWidth;
-        }
+            SvxFont aSmallFont( rFont );
+            Size aOldSize = pImpl->aCJKFont.GetSize();
+            setFontSize(aSmallFont);
+            setFontSize(pImpl->aCJKFont);
+
+            long nStartBracketWidth = 0;
+            long nEndBracketWidth = 0;
+            long nTextWidth = 0;
+            if(pImpl->cStartBracket)
+            {
+                String sBracket(pImpl->cStartBracket);
+                nStartBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width();
+            }
+            if(pImpl->cEndBracket)
+            {
+                String sBracket(pImpl->cEndBracket);
+                nEndBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width();
+            }
+            nTextWidth = pImpl->CalcTextSize( this, pPrinter, aSmallFont ).Width();
+            long nResultWidth = nStartBracketWidth;
+            nResultWidth += nEndBracketWidth;
+            nResultWidth += nTextWidth;
 
-        Point aTmpPoint1( _nX, nY - nSmallAscent - 2 );
-        Point aTmpPoint2( _nX, nY );
-        pImpl->DrawPrev( this, pPrinter, aTmpPoint1, aSmallFont );
-        pImpl->DrawPrev( this, pPrinter, aTmpPoint2, aSmallFont );
+            long _nX = (aLogSize.Width() - nResultWidth) / 2;
+            if ( pImpl->bDrawBaseLine )
+            {
+                DrawLine( Point( 0,  nY ), Point( _nX, nY ) );
+                DrawLine( Point( _nX + nResultWidth, nY ), Point( aLogSize.Width(), nY ) );
+            }
 
-        _nX += nTextWidth;
-        if(pImpl->cEndBracket)
-        {
-            Point aTmpPoint( _nX + 1, nY - nOffset - 4);
-            String sBracket(pImpl->cEndBracket);
-            rFont.DrawPrev( this, pPrinter, aTmpPoint, sBracket );
-        }
-        pImpl->aCJKFont.SetSize( aOldSize );
-    }
-    else
-    {
-        Color aLineCol = GetLineColor();
+            long nSmallAscent = pImpl->nAscent;
+            long nOffset = (nStdAscent - nSmallAscent ) / 2;
+
+            if(pImpl->cStartBracket)
+            {
+                String sBracket(pImpl->cStartBracket);
+                rFont.DrawPrev( this, pPrinter, Point( _nX, nY - nOffset - 4), sBracket );
+                _nX += nStartBracketWidth;
+            }
+
+            Point aTmpPoint1( _nX, nY - nSmallAscent - 2 );
+            Point aTmpPoint2( _nX, nY );
+            pImpl->DrawPrev( this, pPrinter, aTmpPoint1, aSmallFont );
+            pImpl->DrawPrev( this, pPrinter, aTmpPoint2, aSmallFont );
 
-        SetLineColor( rFont.GetColor() );
-        DrawLine( Point( 0,  nY ), Point( nX, nY ) );
-        DrawLine( Point( nX + aTxtSize.Width(), nY ), Point( aLogSize.Width(), nY ) );
+            _nX += nTextWidth;
+            if(pImpl->cEndBracket)
+            {
+                Point aTmpPoint( _nX + 1, nY - nOffset - 4);
+                String sBracket(pImpl->cEndBracket);
+                rFont.DrawPrev( this, pPrinter, aTmpPoint, sBracket );
+            }
+            pImpl->aCJKFont.SetSize( aOldSize );
+        }
+        else
+        {
+            Color aLineCol = GetLineColor();
 
-        SetLineColor( aLineCol );
+            SetLineColor( rFont.GetColor() );
+            if ( pImpl->bDrawBaseLine )
+            {
+                DrawLine( Point( 0,  nY ), Point( nX, nY ) );
+                DrawLine( Point( nX + aTxtSize.Width(), nY ), Point( aLogSize.Width(), nY ) );
+            }
+            SetLineColor( aLineCol );
 
-        Point aTmpPoint( nX, nY );
-        pImpl->DrawPrev( this, pPrinter, aTmpPoint, rFont );
+            Point aTmpPoint( nX, nY );
+            pImpl->DrawPrev( this, pPrinter, aTmpPoint, rFont );
+        }
     }
 }
 
@@ -843,4 +911,333 @@ void SvxFontPrevWindow::AutoCorrectFontColor( void )
         pImpl->aCTLFont.SetColor( aFontColor );
 }
 
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::Init( const SfxItemSet& rSet )
+{
+    SvxFont&           rFont = GetFont();
+    SvxFont&           rCJKFont = GetCJKFont();
+    SvxFont&           rCTLFont = GetCTLFont();
+
+    initFont(rFont);
+    initFont(rCJKFont);
+    initFont(rCTLFont);
+    InitSettings( sal_True, sal_True );
+
+    sal_uInt16 nWhich;
+    nWhich = rSet.GetPool()->GetWhich( SID_CHAR_DLG_PREVIEW_STRING );
+    if( ISITEMSET )
+    {
+        const SfxStringItem& rItem = ( SfxStringItem& ) rSet.Get( nWhich );
+        ::rtl::OUString aString = rItem.GetValue();
+        if( aString.getLength() != 0 )
+            SetPreviewText( aString );
+        else
+            SetFontNameAsPreviewText();
+    }
+
+    // Underline
+    FontUnderline eUnderline;
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_UNDERLINE );
+    if( ISITEMSET )
+    {
+        const SvxUnderlineItem& rItem = ( SvxUnderlineItem& ) rSet.Get( nWhich );
+        eUnderline = ( FontUnderline ) rItem.GetValue();
+        SetTextLineColor( rItem.GetColor() );
+    }
+    else
+        eUnderline = UNDERLINE_NONE;
+
+    rFont.SetUnderline( eUnderline );
+    rCJKFont.SetUnderline( eUnderline );
+    rCTLFont.SetUnderline( eUnderline );
+
+    // Overline
+    FontUnderline eOverline;
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_OVERLINE );
+    if( ISITEMSET )
+    {
+        const SvxOverlineItem& rItem = ( SvxOverlineItem& ) rSet.Get( nWhich );
+        eOverline = ( FontUnderline ) rItem.GetValue();
+        SetOverlineColor( rItem.GetColor() );
+    }
+    else
+        eOverline = UNDERLINE_NONE;
+
+    rFont.SetOverline( eOverline );
+    rCJKFont.SetOverline( eOverline );
+    rCTLFont.SetOverline( eOverline );
+
+    // Strikeout
+    FontStrikeout eStrikeout;
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_STRIKEOUT );
+    if( ISITEMSET )
+    {
+        const SvxCrossedOutItem& rItem = ( SvxCrossedOutItem& ) rSet.Get( nWhich );
+        eStrikeout = ( FontStrikeout ) rItem.GetValue();
+    }
+    else
+        eStrikeout = STRIKEOUT_NONE;
+
+    rFont.SetStrikeout( eStrikeout );
+    rCJKFont.SetStrikeout( eStrikeout );
+    rCTLFont.SetStrikeout( eStrikeout );
+
+    // WordLineMode
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
+    if( ISITEMSET )
+    {
+        const SvxWordLineModeItem& rItem = ( SvxWordLineModeItem& ) rSet.Get( nWhich );
+        rFont.SetWordLineMode( rItem.GetValue() );
+        rCJKFont.SetWordLineMode( rItem.GetValue() );
+        rCTLFont.SetWordLineMode( rItem.GetValue() );
+    }
+
+    // Emphasis
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
+    if( ISITEMSET )
+    {
+        const SvxEmphasisMarkItem& rItem = ( SvxEmphasisMarkItem& ) rSet.Get( nWhich );
+        FontEmphasisMark eMark = rItem.GetEmphasisMark();
+        rFont.SetEmphasisMark( eMark );
+        rCJKFont.SetEmphasisMark( eMark );
+        rCTLFont.SetEmphasisMark( eMark );
+    }
+
+    // Relief
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_RELIEF );
+    if( ISITEMSET )
+    {
+        const SvxCharReliefItem& rItem = ( SvxCharReliefItem& ) rSet.Get( nWhich );
+        FontRelief eFontRelief = ( FontRelief ) rItem.GetValue();
+        rFont.SetRelief( eFontRelief );
+        rCJKFont.SetRelief( eFontRelief );
+        rCTLFont.SetRelief( eFontRelief );
+    }
+
+    // Effects
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_CASEMAP );
+    if( ISITEMSET )
+    {
+        const SvxCaseMapItem& rItem = ( SvxCaseMapItem& ) rSet.Get( nWhich );
+        SvxCaseMap eCaseMap = ( SvxCaseMap ) rItem.GetValue();
+        rFont.SetCaseMap( eCaseMap );
+        rCJKFont.SetCaseMap( eCaseMap );
+        // #i78474# small caps do not exist in CTL fonts
+        rCTLFont.SetCaseMap( eCaseMap == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : 
eCaseMap );
+    }
+
+    // Outline
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_CONTOUR );
+    if( ISITEMSET )
+    {
+        const SvxContourItem& rItem = ( SvxContourItem& ) rSet.Get( nWhich );
+        sal_Bool bOutline = rItem.GetValue();
+        rFont.SetOutline( bOutline );
+        rCJKFont.SetOutline( bOutline );
+        rCTLFont.SetOutline( bOutline );
+    }
+
+    // Shadow
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_SHADOWED );
+    if( ISITEMSET )
+    {
+        const SvxShadowedItem& rItem = ( SvxShadowedItem& ) rSet.Get( nWhich );
+        sal_Bool bShadow = rItem.GetValue();
+        rFont.SetShadow( bShadow );
+        rCJKFont.SetShadow( bShadow );
+        rCTLFont.SetShadow( bShadow );
+    }
+
+    // Background
+    sal_Bool bTransparent;
+    nWhich = rSet.GetPool()->GetWhich( pImpl->bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : 
SID_ATTR_BRUSH_CHAR );
+    if( ISITEMSET )
+    {
+         const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
+         const Color& rColor = rBrush.GetColor();
+         bTransparent = rColor.GetTransparency() > 0;
+         rFont.SetFillColor( rColor );
+         rCJKFont.SetFillColor( rColor );
+         rCTLFont.SetFillColor( rColor );
+    }
+    else
+        bTransparent = sal_True;
+
+    rFont.SetTransparent( bTransparent );
+    rCJKFont.SetTransparent( bTransparent );
+    rCTLFont.SetTransparent( bTransparent );
+
+    Color aBackCol( COL_TRANSPARENT );
+    if( !pImpl->bPreviewBackgroundToCharacter )
+    {
+        nWhich = rSet.GetPool()->GetWhich( SID_ATTR_BRUSH );
+        if( ISITEMSET )
+        {
+            const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich );
+            if( GPOS_NONE == rBrush.GetGraphicPos() )
+                aBackCol = rBrush.GetColor();
+        }
+    }
+    SetBackColor( aBackCol );
+
+    // Font
+    SetFont( rSet, SID_ATTR_CHAR_FONT, rFont );
+    SetFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont );
+    SetFont( rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont );
+
+    // Style
+    SetFontStyle( rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont );
+    SetFontStyle( rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont );
+    SetFontStyle( rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont );
+
+    // Size
+    SetFontSize( rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont );
+    SetFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont );
+    SetFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont );
+
+    // Color
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_COLOR );
+    if( ISITEMSET )
+    {
+        const SvxColorItem& rItem = ( SvxColorItem& ) rSet.Get( nWhich );
+        Color aCol( rItem.GetValue() );
+        rFont.SetColor( aCol );
+        rCJKFont.SetColor( aCol );
+        rCTLFont.SetColor( aCol );
+
+        AutoCorrectFontColor();        // handle color COL_AUTO
+    }
+
+    // Kerning
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_KERNING );
+    if( ISITEMSET )
+    {
+        const SvxKerningItem& rItem = ( SvxKerningItem& ) rSet.Get( nWhich );
+        short nKern = ( short )
+                        LogicToLogic( rItem.GetValue(), ( MapUnit ) rSet.GetPool()->GetMetric( 
nWhich ), MAP_TWIP );
+        rFont.SetFixKerning( nKern );
+        rCJKFont.SetFixKerning( nKern );
+        rCTLFont.SetFixKerning( nKern );
+    }
+
+    // Escapement
+    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
+    const sal_uInt8 nProp = 100;
+    short nEsc;
+    sal_uInt8 nEscProp;
+    if( ISITEMSET )
+    {
+        const SvxEscapementItem& rItem = ( SvxEscapementItem& ) rSet.Get( nWhich );
+        nEsc = rItem.GetEsc();
+        nEscProp = rItem.GetProp();
+
+        if( nEsc == DFLT_ESC_AUTO_SUPER )
+            nEsc = DFLT_ESC_SUPER;
+        else if( nEsc == DFLT_ESC_AUTO_SUB )
+            nEsc = DFLT_ESC_SUB;
+    }
+    else
+    {
+        nEsc  = 0;
+        nEscProp = 100;
+    }
+
+    SetFontEscapement( nProp, nEscProp, nEsc );
+
+    // Font width scale
+    SetFontWidthScale( rSet );
+
+    Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont )
+{
+    sal_uInt16 nWhich = rSet.GetPool()->GetWhich( nSlot );
+    long nH;
+    if( rSet.GetItemState( nWhich ) >= SFX_ITEM_SET )
+    {
+        nH = LogicToLogic(     ( ( SvxFontHeightItem& ) rSet.Get( nWhich ) ).GetHeight(),
+                            ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ),
+                            MAP_TWIP );
+    }
+    else
+        nH = 240;      // as default 12pt
+
+    rFont.SetSize( Size( 0, nH ) );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont )
+{
+    sal_uInt16 nWhich = rSet.GetPool()->GetWhich( nSlot );
+    if( ISITEMSET )
+    {
+        const SvxFontItem& rFontItem = ( SvxFontItem& ) rSet.Get( nWhich );
+        rFont.SetFamily( rFontItem.GetFamily() );
+        rFont.SetName( rFontItem.GetFamilyName() );
+        rFont.SetPitch( rFontItem.GetPitch() );
+        rFont.SetCharSet( rFontItem.GetCharSet() );
+        rFont.SetStyleName( rFontItem.GetStyleName() );
+    }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_uInt16 
nWeight, SvxFont& rFont )
+{
+    sal_uInt16 nWhich = rSet.GetPool()->GetWhich( nPosture );
+    if( ISITEMSET )
+    {
+        const SvxPostureItem& rItem = ( SvxPostureItem& ) rSet.Get( nWhich );
+        rFont.SetItalic( ( FontItalic ) rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : 
ITALIC_NONE );
+    }
+
+    nWhich = rSet.GetPool()->GetWhich( nWeight );
+    if( ISITEMSET )
+    {
+        SvxWeightItem& rItem = ( SvxWeightItem& ) rSet.Get( nWhich );
+        rFont.SetWeight( ( FontWeight ) rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : 
WEIGHT_NORMAL );
+    }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetFontWidthScale( const SfxItemSet& rSet )
+{
+    sal_uInt16 nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
+    if( ISITEMSET )
+    {
+        const SvxCharScaleWidthItem&   rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich );
+
+        SetFontWidthScale( rItem.GetValue() );
+    }
+}
+
+// -----------------------------------------------------------------------
+namespace
+{
+    // -----------------------------------------------------------------------
+    void setFontEscapement(SvxFont& _rFont,sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
+    {
+        _rFont.SetPropr( nProp );
+        _rFont.SetProprRel( nEscProp );
+        _rFont.SetEscapement( nEsc );
+    }
+    // -----------------------------------------------------------------------
+    // -----------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
+{
+    setFontEscapement(GetFont(),nProp,nEscProp,nEsc);
+    setFontEscapement(GetCJKFont(),nProp,nEscProp,nEsc);
+    setFontEscapement(GetCTLFont(),nProp,nEscProp,nEsc);
+    Invalidate();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-- 
1.7.1

From 229cc0e5a3bbfa792dee7604c924594b40897cc8 Mon Sep 17 00:00:00 2001
From: Robert DARGAUD <libo@bobiciel.com>
Date: Mon, 4 Apr 2011 23:04:28 +0200
Subject: [PATCH] Conditional formatting with an unlimited rules number

---
 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(-)

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 ;
     };
-- 
1.7.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.