[Libreoffice-commits] .: 13 commits - sc/inc sc/Library_sc.mk sc/Library_scui.mk sc/sdi sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Oct 8 21:36:11 PDT 2012


 sc/Library_sc.mk                               |    4 
 sc/Library_scui.mk                             |    3 
 sc/inc/scabstdlg.hxx                           |   15 
 sc/sdi/cellsh.sdi                              |    2 
 sc/source/ui/app/scdll.cxx                     |    5 
 sc/source/ui/attrdlg/scdlgfact.cxx             |   52 -
 sc/source/ui/attrdlg/scdlgfact.hxx             |   19 
 sc/source/ui/condformat/condformatdlg.cxx      | 1208 ++++---------------------
 sc/source/ui/condformat/condformatdlgentry.cxx | 1091 ++++++++++++++++++++++
 sc/source/ui/condformat/condformatmgr.cxx      |   11 
 sc/source/ui/inc/condformatdlg.hrc             |   19 
 sc/source/ui/inc/condformatdlg.hxx             |  131 --
 sc/source/ui/inc/condformatdlgentry.hxx        |  211 ++++
 sc/source/ui/inc/condformathelper.hxx          |    6 
 sc/source/ui/inc/reffact.hxx                   |    3 
 sc/source/ui/src/condformatdlg.src             |   90 +
 sc/source/ui/view/cellsh1.cxx                  |  106 --
 sc/source/ui/view/reffact.cxx                  |   21 
 sc/source/ui/view/tabvwsh.cxx                  |    3 
 sc/source/ui/view/tabvwshc.cxx                 |   53 +
 20 files changed, 1768 insertions(+), 1285 deletions(-)

New commits:
commit 1ae1bca7e6108081b16c9bedd1078e6c8ba34bf6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Oct 9 06:34:18 2012 +0200

    forgot the licence header
    
    Change-Id: I85e58c241a3acd1caf949d4314ca9a05a5e51379

diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index ee83a7a..507a0ed 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -1,3 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
 #include "condformatdlg.hxx"
 #include "condformatdlgentry.hxx"
 #include "condformatdlg.hrc"
@@ -1078,3 +1087,5 @@ IMPL_LINK_NOARG( ScDataBarFrmtEntry, OptionBtnHdl )
     }
     return 0;
 }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx
index 94722d0..b0051ad 100644
--- a/sc/source/ui/inc/condformatdlgentry.hxx
+++ b/sc/source/ui/inc/condformatdlgentry.hxx
@@ -1,3 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
 #include "colorscale.hxx"
 #include "conditio.hxx"
 
@@ -199,3 +208,4 @@ public:
     virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATABAR; }
 };
 
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 937cee757ea243a18ea03b4d3e8662524a8ff090
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Oct 9 06:29:21 2012 +0200

    make the dialog actually do something useful again
    
    Change-Id: I440b38442f69bd50286fee8ce3ee1b289b45775d

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 6ffba85..332139e 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -47,6 +47,8 @@
 #include "colorscale.hxx"
 #include "colorformat.hxx"
 #include "reffact.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
 #include "condformatdlgentry.hxx"
 
 #include "globstr.hrc"
@@ -306,6 +308,7 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, Window* p
     maCondFormList( this, ScResId( CTRL_LIST ), pDoc, pFormat, rRange, rPos, eType ),
     maPos(rPos),
     mpDoc(pDoc),
+    mpFormat(pFormat),
     meType(eType)
 {
     rtl::OUStringBuffer aTitle( GetText() );
@@ -410,13 +413,21 @@ sal_Bool ScCondFormatDlg::Close()
 
 IMPL_LINK_NOARG( ScCondFormatDlg, OkBtnHdl )
 {
-    Close();
+    ScConditionalFormat* pFormat = GetConditionalFormat();
+    SfxObjectShell* pObjectShell = mpDoc->GetDocumentShell();
+    sal_Int32 nKey = 0;
+    if(mpFormat)
+        nKey = mpFormat->GetKey();
+
+    static_cast<ScDocShell*>(pObjectShell)->GetDocFunc().ReplaceConditionalFormat(nKey, pFormat, maPos.Tab(), pFormat->GetRange());
 
+    Close();
     return 0;
 }
 
 IMPL_LINK_NOARG( ScCondFormatDlg, CancelBtnHdl )
 {
+
     Close();
 
     return 0;
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index c179107..e91574b 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -112,6 +112,8 @@ private:
     ScAddress maPos;
     ScDocument* mpDoc;
 
+    const ScConditionalFormat* mpFormat;
+
     condformat::dialog::ScCondFormatDialogType meType;
 
     DECL_LINK( EdRangeModifyHdl, Edit* );
commit 025559813580370ffdf0de0a8844eed4cbe0ab1c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Oct 9 06:11:17 2012 +0200

    disable these buttons until figured out how to call the cond format dlg
    
    Change-Id: I519e4fec832a47e298512a0f0416bc12827913fb

diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
index 16c8291..dc5bb8b 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -183,6 +183,9 @@ ScCondFormatManagerDlg::ScCondFormatManagerDlg(Window* pParent, ScDocument* pDoc
     maBtnEdit.SetClickHdl(LINK(this, ScCondFormatManagerDlg, EditBtnHdl));
     maBtnAdd.SetClickHdl(LINK(this, ScCondFormatManagerDlg, AddBtnHdl));
     maCtrlManager.GetListControl().SetDoubleClickHdl(LINK(this, ScCondFormatManagerDlg, EditBtnHdl));
+
+    maBtnAdd.Disable();
+    maBtnEdit.Disable();
 }
 
 ScCondFormatManagerDlg::~ScCondFormatManagerDlg()
commit b5ac62c06d8dcbb7ecad325685fec80df7470458
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Oct 9 06:09:52 2012 +0200

    position all elements in the src file and not in the code
    
     # Changes to be committed:
    
    Change-Id: Idc3d2a7201c6d2e92a111ffc6cb60f88c4c0c4c2

diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 211c3bb..ee83a7a 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -590,13 +590,12 @@ ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListB
 ScColorScale2FrmtEntry::ScColorScale2FrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat ):
     ScCondFrmtEntry( pParent, pDoc, rPos ),
     maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
-    maLbColScale2( this, ScResId( LB_COL_SCALE2 ) ),
-    maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maLbEntryTypeMax( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maEdMin( this, ScResId( ED_COL_SCALE ) ),
-    maEdMax( this, ScResId( ED_COL_SCALE ) ),
-    maLbColMin( this, ScResId( LB_COL) ),
-    maLbColMax( this, ScResId( LB_COL) )
+    maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE_MIN ) ),
+    maLbEntryTypeMax( this, ScResId( LB_TYPE_COL_SCALE_MAX ) ),
+    maEdMin( this, ScResId( ED_COL_SCALE_MIN ) ),
+    maEdMax( this, ScResId( ED_COL_SCALE_MAX ) ),
+    maLbColMin( this, ScResId( LB_COL_MIN ) ),
+    maLbColMax( this, ScResId( LB_COL_MAX ) )
 {
     maLbType.SelectEntryPos(0);
     maLbColorFormat.SelectEntryPos(0);
@@ -695,8 +694,6 @@ ScFormatEntry* ScColorScale2FrmtEntry::GetEntry() const
 
 void ScColorScale2FrmtEntry::SetActive()
 {
-    maLbColScale2.Show();
-
     maLbEntryTypeMin.Show();
     maLbEntryTypeMax.Show();
 
@@ -711,8 +708,6 @@ void ScColorScale2FrmtEntry::SetActive()
 
 void ScColorScale2FrmtEntry::SetInactive()
 {
-    maLbColScale2.Hide();
-
     maLbEntryTypeMin.Hide();
     maLbEntryTypeMax.Hide();
 
@@ -751,17 +746,15 @@ IMPL_LINK( ScColorScale2FrmtEntry, EntryTypeHdl, ListBox*, pBox )
 ScColorScale3FrmtEntry::ScColorScale3FrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat ):
     ScCondFrmtEntry( pParent, pDoc, rPos ),
     maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
-    maLbColScale2( this, ScResId( LB_COL_SCALE2 ) ),
-    maLbColScale3( this, ScResId( LB_COL_SCALE3 ) ),
-    maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maLbEntryTypeMiddle( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maLbEntryTypeMax( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maEdMin( this, ScResId( ED_COL_SCALE ) ),
-    maEdMiddle( this, ScResId( ED_COL_SCALE ) ),
-    maEdMax( this, ScResId( ED_COL_SCALE ) ),
-    maLbColMin( this, ScResId( LB_COL) ),
-    maLbColMiddle( this, ScResId( LB_COL) ),
-    maLbColMax( this, ScResId( LB_COL) )
+    maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE_MIN ) ),
+    maLbEntryTypeMiddle( this, ScResId( LB_TYPE_COL_SCALE_MIDDLE ) ),
+    maLbEntryTypeMax( this, ScResId( LB_TYPE_COL_SCALE_MAX ) ),
+    maEdMin( this, ScResId( ED_COL_SCALE_MIN ) ),
+    maEdMiddle( this, ScResId( ED_COL_SCALE_MIDDLE ) ),
+    maEdMax( this, ScResId( ED_COL_SCALE_MAX ) ),
+    maLbColMin( this, ScResId( LB_COL_MIN ) ),
+    maLbColMiddle( this, ScResId( LB_COL_MIDDLE ) ),
+    maLbColMax( this, ScResId( LB_COL_MAX ) )
 {
     maLbType.SelectEntryPos(0);
     if(pFormat)
@@ -807,23 +800,6 @@ void ScColorScale3FrmtEntry::Init()
 
     DBG_ASSERT( pDocSh, "DocShell not found!" );
 
-    Point aPointLb = maLbEntryTypeMiddle.GetPosPixel();
-    Point aPointEd = maEdMiddle.GetPosPixel();
-    Point aPointCol = maLbColMiddle.GetPosPixel();
-    const long nMovePos = maLbEntryTypeMiddle.GetSizePixel().Width() * 1.2;
-    aPointLb.X() += nMovePos;
-    aPointEd.X() += nMovePos;
-    aPointCol.X() += nMovePos;
-    maLbEntryTypeMiddle.SetPosPixel(aPointLb);
-    maEdMiddle.SetPosPixel(aPointEd);
-    maLbColMiddle.SetPosPixel(aPointCol);
-    aPointLb.X() += nMovePos;
-    aPointEd.X() += nMovePos;
-    aPointCol.X() += nMovePos;
-    maLbEntryTypeMax.SetPosPixel(aPointLb);
-    maEdMax.SetPosPixel(aPointEd);
-    maLbColMax.SetPosPixel(aPointCol);
-
     if ( pDocSh )
     {
         pItem = pDocSh->GetItem( SID_COLOR_TABLE );
@@ -878,9 +854,6 @@ ScFormatEntry* ScColorScale3FrmtEntry::GetEntry() const
 
 void ScColorScale3FrmtEntry::SetActive()
 {
-    maLbColScale2.Show();
-    maLbColScale3.Show();
-
     maLbEntryTypeMin.Show();
     maLbEntryTypeMiddle.Show();
     maLbEntryTypeMax.Show();
@@ -898,9 +871,6 @@ void ScColorScale3FrmtEntry::SetActive()
 
 void ScColorScale3FrmtEntry::SetInactive()
 {
-    maLbColScale2.Hide();
-    maLbColScale3.Hide();
-
     maLbEntryTypeMin.Hide();
     maLbEntryTypeMiddle.Hide();
     maLbEntryTypeMax.Hide();
@@ -999,10 +969,10 @@ void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Ed
 ScDataBarFrmtEntry::ScDataBarFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat ):
     ScCondFrmtEntry( pParent, pDoc, rPos ),
     maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
-    maLbDataBarMinType( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maLbDataBarMaxType( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maEdDataBarMin( this, ScResId( ED_COL_SCALE ) ),
-    maEdDataBarMax( this, ScResId( ED_COL_SCALE ) ),
+    maLbDataBarMinType( this, ScResId( LB_TYPE_COL_SCALE_MIN ) ),
+    maLbDataBarMaxType( this, ScResId( LB_TYPE_COL_SCALE_MAX ) ),
+    maEdDataBarMin( this, ScResId( ED_COL_SCALE_MIN ) ),
+    maEdDataBarMax( this, ScResId( ED_COL_SCALE_MAX ) ),
     maBtOptions( this, ScResId( BTN_OPTIONS ) )
 {
     maLbColorFormat.SelectEntryPos(2);
@@ -1035,13 +1005,6 @@ void ScDataBarFrmtEntry::Init()
 {
     maLbDataBarMinType.SetSelectHdl( LINK( this, ScDataBarFrmtEntry, DataBarTypeSelectHdl ) );
     maLbDataBarMaxType.SetSelectHdl( LINK( this, ScDataBarFrmtEntry, DataBarTypeSelectHdl ) );
-    Point aPointEdDataBar = maEdDataBarMin.GetPosPixel();
-    Point aPointLbDataBar = maLbDataBarMaxType.GetPosPixel();
-    long nMovePos = 10;
-    aPointEdDataBar.X() += 2*nMovePos;
-    aPointLbDataBar.X() += 2*nMovePos;
-    maEdDataBarMax.SetPosPixel(aPointEdDataBar);
-    maLbDataBarMaxType.SetPosPixel(aPointLbDataBar);
 
     maBtOptions.SetClickHdl( LINK( this, ScDataBarFrmtEntry, OptionBtnHdl ) );
 
diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc
index f025856..dcb51d1 100644
--- a/sc/source/ui/inc/condformatdlg.hrc
+++ b/sc/source/ui/inc/condformatdlg.hrc
@@ -46,12 +46,7 @@
 #define FT_STYLE 21
 #define LB_COLOR_FORMAT 22
 
-#define LB_COL_SCALE2 23
-#define LB_COL_SCALE3 24
-#define LB_TYPE_COL_SCALE 25
-#define ED_COL_SCALE 28
 #define WD_PREVIEW 26
-#define LB_COL 27
 #define BTN_OPTIONS 30
 #define STR_CONDITION 31
 
@@ -61,4 +56,15 @@
 
 #define ED_FORMULA 35
 
+#define ED_COL_SCALE_MIN 36
+#define ED_COL_SCALE_MIDDLE 37
+#define ED_COL_SCALE_MAX 38
+
+#define LB_COL_MIN 39
+#define LB_COL_MIDDLE 40
+#define LB_COL_MAX 41
+
+#define LB_TYPE_COL_SCALE_MIN 42
+#define LB_TYPE_COL_SCALE_MIDDLE 43
+#define LB_TYPE_COL_SCALE_MAX 43
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx
index 3147bfb..94722d0 100644
--- a/sc/source/ui/inc/condformatdlgentry.hxx
+++ b/sc/source/ui/inc/condformatdlgentry.hxx
@@ -115,8 +115,6 @@ class ScColorScale2FrmtEntry : public ScCondFrmtEntry
     ListBox maLbColorFormat;
 
     //color scale ui elements
-    ListBox maLbColScale2;
-
     ListBox maLbEntryTypeMin;
     ListBox maLbEntryTypeMax;
 
@@ -146,9 +144,6 @@ class ScColorScale3FrmtEntry : public ScCondFrmtEntry
     ListBox maLbColorFormat;
 
     //color scale ui elements
-    ListBox maLbColScale2;
-    ListBox maLbColScale3;
-
     ListBox maLbEntryTypeMin;
     ListBox maLbEntryTypeMiddle;
     ListBox maLbEntryTypeMax;
diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src
index 16b2650..4adff8f 100644
--- a/sc/source/ui/src/condformatdlg.src
+++ b/sc/source/ui/src/condformatdlg.src
@@ -191,7 +191,7 @@ Control RID_COND_ENTRY
             "New Style...";
         };
     };
-    ListBox LB_TYPE_COL_SCALE
+    ListBox LB_TYPE_COL_SCALE_MIN
     {
         Pos = MAP_APPFONT( 5, 32 );
         Size = MAP_APPFONT( 80, 60 );
@@ -209,6 +209,42 @@ Control RID_COND_ENTRY
             "AutoMax";
         };
     };
+    ListBox LB_TYPE_COL_SCALE_MIDDLE
+    {
+        Pos = MAP_APPFONT( 100, 32 );
+        Size = MAP_APPFONT( 80, 60 );
+        Border = TRUE;
+        DropDown = TRUE;
+        StringList [ en-US ] =
+        {
+            "Min";
+            "Max";
+            "Percentile";
+            "Value";
+            "Percent";
+            "Formula";
+            "AutoMin";
+            "AutoMax";
+        };
+    };
+    ListBox LB_TYPE_COL_SCALE_MAX
+    {
+        Pos = MAP_APPFONT( 195, 32 );
+        Size = MAP_APPFONT( 80, 60 );
+        Border = TRUE;
+        DropDown = TRUE;
+        StringList [ en-US ] =
+        {
+            "Min";
+            "Max";
+            "Percentile";
+            "Value";
+            "Percent";
+            "Formula";
+            "AutoMin";
+            "AutoMax";
+        };
+    };
     Window WD_PREVIEW
     {
         Pos = MAP_APPFONT( 175, 32 );
@@ -216,16 +252,44 @@ Control RID_COND_ENTRY
         Text [ en-US ] = "Example";
         Border = TRUE;
     };
-    Edit ED_COL_SCALE
+    Edit ED_COL_SCALE_MIN
     {
         Pos = MAP_APPFONT( 5, 48 );
-        Size = MAP_APPFONT( 60, 12 );
+        Size = MAP_APPFONT( 80, 12 );
         Border = TRUE;
     };
-    ListBox LB_COL
+    Edit ED_COL_SCALE_MIDDLE
+    {
+        Pos = MAP_APPFONT( 100, 48 );
+        Size = MAP_APPFONT( 80, 12 );
+        Border = TRUE;
+    };
+    Edit ED_COL_SCALE_MAX
+    {
+        Pos = MAP_APPFONT( 195, 48 );
+        Size = MAP_APPFONT( 80, 12 );
+        Border = TRUE;
+    };
+    ListBox LB_COL_MIN
     {
         Pos = MAP_APPFONT( 5, 62 );
-        Size = MAP_APPFONT( 60, 40 );
+        Size = MAP_APPFONT( 80, 40 );
+        Border = TRUE;
+        DropDown = TRUE;
+        DDExtraWidth = TRUE;
+    };
+    ListBox LB_COL_MIDDLE
+    {
+        Pos = MAP_APPFONT( 100, 62 );
+        Size = MAP_APPFONT( 80, 40 );
+        Border = TRUE;
+        DropDown = TRUE;
+        DDExtraWidth = TRUE;
+    };
+    ListBox LB_COL_MAX
+    {
+        Pos = MAP_APPFONT( 195, 62 );
+        Size = MAP_APPFONT( 80, 40 );
         Border = TRUE;
         DropDown = TRUE;
         DDExtraWidth = TRUE;
commit 2741675caddb927653ec914f46025b3f6ab0d439
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Oct 9 05:03:21 2012 +0200

    only show two entries for between and not between
    
    Change-Id: I8cf41941d50f7fb868868f17d6f25206ae53c76f

diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index fc2e733..211c3bb 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -296,7 +296,8 @@ void ScConditionFrmtEntry::SetActive()
 {
     maLbCondType.Show();
     maEdVal1.Show();
-    maEdVal2.Show();
+    if(maLbCondType.GetSelectEntryPos() == 6 || maLbCondType.GetSelectEntryPos() == 7)
+        maEdVal2.Show();
     maFtStyle.Show();
     maLbStyle.Show();
     maWdPreview.Show();
commit 1b8f33153b98251e28da4d2b6e16ddd0380f8c56
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Oct 9 04:34:14 2012 +0200

    separate color scale with 2 and 3 entries
    
    Change-Id: Idd3cd7467850ee32cb1380fce307395f21076071

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 92af3ce..6ffba85 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -78,7 +78,7 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
                     maEntries.push_back(new ScConditionFrmtEntry( this, mpDoc, maPos, static_cast<const ScCondFormatEntry*>( pEntry ) ) );
                     break;
                 case condformat::COLORSCALE:
-                    maEntries.push_back(new ScColorScaleFrmtEntry( this, mpDoc, maPos, static_cast<const ScColorScaleFormat*>( pEntry ) ) );
+                    maEntries.push_back(new ScColorScale3FrmtEntry( this, mpDoc, maPos, static_cast<const ScColorScaleFormat*>( pEntry ) ) );
                     break;
                 case condformat::DATABAR:
                     maEntries.push_back(new ScDataBarFrmtEntry( this, mpDoc, maPos, static_cast<const ScDataBarFormat*>( pEntry ) ) );
@@ -94,7 +94,7 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
                 maEntries.push_back(new ScConditionFrmtEntry( this, mpDoc, maPos ));
                 break;
             case condformat::dialog::COLORSCALE:
-                maEntries.push_back(new ScColorScaleFrmtEntry( this, mpDoc, maPos ));
+                maEntries.push_back(new ScColorScale3FrmtEntry( this, mpDoc, maPos ));
                 break;
             case condformat::dialog::DATABAR:
                 maEntries.push_back(new ScDataBarFrmtEntry( this, mpDoc, maPos ));
@@ -182,6 +182,34 @@ void ScCondFormatList::DoScroll(long nDelta)
 
 IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox*, pBox)
 {
+    EntryContainer::iterator itr = maEntries.begin();
+    for(; itr != maEntries.end(); ++itr)
+    {
+        if(itr->IsSelected())
+            break;
+    }
+    if(itr == maEntries.end())
+        return 0;;
+
+    sal_Int32 nPos = pBox->GetSelectEntryPos();
+    switch(nPos)
+    {
+        case 0:
+            if(itr->GetType() != condformat::entry::COLORSCALE2)
+                maEntries.replace( itr, new ScColorScale2FrmtEntry( this, mpDoc, maPos ) );
+            break;
+        case 1:
+            if(itr->GetType() != condformat::entry::COLORSCALE3)
+                maEntries.replace( itr, new ScColorScale3FrmtEntry( this, mpDoc, maPos ) );
+            break;
+        case 2:
+            if(itr->GetType() != condformat::entry::DATABAR)
+                maEntries.replace( itr, new ScDataBarFrmtEntry( this, mpDoc, maPos ) );
+            break;
+        default:
+            break;
+    }
+    itr->SetActive();
     RecalcAll();
     return 0;
 }
@@ -201,7 +229,7 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox)
     switch(nPos)
     {
         case 0:
-            maEntries.replace( itr, new ScColorScaleFrmtEntry(this, mpDoc, maPos));
+            maEntries.replace( itr, new ScColorScale3FrmtEntry(this, mpDoc, maPos));
             itr->SetActive();
             break;
         case 1:
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 00c5b3e..fc2e733 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -151,6 +151,7 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
 {
 
     FreeResource();
+    maLbType.SelectEntryPos(1);
 
     Init();
 
@@ -378,6 +379,7 @@ ScFormulaFrmtEntry::ScFormulaFrmtEntry( Window* pParent, ScDocument* pDoc, const
     Init();
 
     FreeResource();
+    maLbType.SelectEntryPos(2);
 
     if(pFormat)
     {
@@ -584,7 +586,168 @@ ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListB
 
 }
 
-ScColorScaleFrmtEntry::ScColorScaleFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat ):
+ScColorScale2FrmtEntry::ScColorScale2FrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat ):
+    ScCondFrmtEntry( pParent, pDoc, rPos ),
+    maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
+    maLbColScale2( this, ScResId( LB_COL_SCALE2 ) ),
+    maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE ) ),
+    maLbEntryTypeMax( this, ScResId( LB_TYPE_COL_SCALE ) ),
+    maEdMin( this, ScResId( ED_COL_SCALE ) ),
+    maEdMax( this, ScResId( ED_COL_SCALE ) ),
+    maLbColMin( this, ScResId( LB_COL) ),
+    maLbColMax( this, ScResId( LB_COL) )
+{
+    maLbType.SelectEntryPos(0);
+    maLbColorFormat.SelectEntryPos(0);
+    if(pFormat)
+    {
+        ScColorScaleFormat::const_iterator itr = pFormat->begin();
+        SetColorScaleEntryTypes(*itr, maLbEntryTypeMin, maEdMin, maLbColMin);
+        ++itr;
+        SetColorScaleEntryTypes(*itr, maLbEntryTypeMax, maEdMax, maLbColMax);
+    }
+    else
+    {
+        maLbEntryTypeMin.SelectEntryPos(0);
+        maLbEntryTypeMax.SelectEntryPos(1);
+    }
+    FreeResource();
+
+    maLbColorFormat.SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
+
+    Init();
+}
+
+void ScColorScale2FrmtEntry::Init()
+{
+    maLbEntryTypeMin.SetSelectHdl( LINK( this, ScColorScale2FrmtEntry, EntryTypeHdl ) );
+    maLbEntryTypeMax.SetSelectHdl( LINK( this, ScColorScale2FrmtEntry, EntryTypeHdl ) );
+
+    SfxObjectShell*     pDocSh      = SfxObjectShell::Current();
+    const SfxPoolItem*  pItem       = NULL;
+    XColorListRef       pColorTable;
+
+    DBG_ASSERT( pDocSh, "DocShell not found!" );
+
+    /*
+    Point aPointLb = maLbEntryTypeMiddle.GetPosPixel();
+    Point aPointEd = maEdMiddle.GetPosPixel();
+    Point aPointCol = maLbColMiddle.GetPosPixel();
+    const long nMovePos = maLbEntryTypeMiddle.GetSizePixel().Width() * 1.2;
+    aPointLb.X() += nMovePos;
+    aPointEd.X() += nMovePos;
+    aPointCol.X() += nMovePos;
+    maLbEntryTypeMiddle.SetPosPixel(aPointLb);
+    maEdMiddle.SetPosPixel(aPointEd);
+    maLbColMiddle.SetPosPixel(aPointCol);
+    aPointLb.X() += nMovePos;
+    aPointEd.X() += nMovePos;
+    aPointCol.X() += nMovePos;
+    maLbEntryTypeMax.SetPosPixel(aPointLb);
+    maEdMax.SetPosPixel(aPointEd);
+    maLbColMax.SetPosPixel(aPointCol);
+    */
+
+    if ( pDocSh )
+    {
+        pItem = pDocSh->GetItem( SID_COLOR_TABLE );
+        if ( pItem != NULL )
+            pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
+    }
+    if ( pColorTable.is() )
+    {
+        // filling the line color box
+        maLbColMin.SetUpdateMode( false );
+        maLbColMax.SetUpdateMode( false );
+
+        for ( long i = 0; i < pColorTable->Count(); ++i )
+        {
+            XColorEntry* pEntry = pColorTable->GetColor(i);
+            maLbColMin.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+            maLbColMax.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+
+            if(pEntry->GetColor() == Color(COL_LIGHTRED))
+                maLbColMin.SelectEntryPos(i);
+            if(pEntry->GetColor() == Color(COL_LIGHTBLUE))
+                maLbColMax.SelectEntryPos(i);
+        }
+        maLbColMin.SetUpdateMode( sal_True );
+        maLbColMax.SetUpdateMode( sal_True );
+    }
+
+    EntryTypeHdl(&maLbEntryTypeMin);
+    EntryTypeHdl(&maLbEntryTypeMax);
+}
+
+ScFormatEntry* ScColorScale2FrmtEntry::createColorscaleEntry() const
+{
+    ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
+    pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMin, maLbColMin, maEdMin, mpDoc, maPos));
+    pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMax, maLbColMax, maEdMax, mpDoc, maPos));
+    return pColorScale;
+}
+
+ScFormatEntry* ScColorScale2FrmtEntry::GetEntry() const
+{
+    return createColorscaleEntry();
+}
+
+void ScColorScale2FrmtEntry::SetActive()
+{
+    maLbColScale2.Show();
+
+    maLbEntryTypeMin.Show();
+    maLbEntryTypeMax.Show();
+
+    maEdMin.Show();
+    maEdMax.Show();
+
+    maLbColMin.Show();
+    maLbColMax.Show();
+
+    Select();
+}
+
+void ScColorScale2FrmtEntry::SetInactive()
+{
+    maLbColScale2.Hide();
+
+    maLbEntryTypeMin.Hide();
+    maLbEntryTypeMax.Hide();
+
+    maEdMin.Hide();
+    maEdMax.Hide();
+
+    maLbColMin.Hide();
+    maLbColMax.Hide();
+
+    Deselect();
+}
+
+IMPL_LINK( ScColorScale2FrmtEntry, EntryTypeHdl, ListBox*, pBox )
+{
+    bool bEnableEdit = true;
+    sal_Int32 nPos = pBox->GetSelectEntryPos();
+    if(nPos == 0 || nPos == 1)
+    {
+        bEnableEdit = false;
+    }
+
+    Edit* pEd = NULL;
+    if(pBox == &maLbEntryTypeMin)
+        pEd = &maEdMin;
+    else if(pBox == &maLbEntryTypeMax)
+        pEd = &maEdMax;
+
+    if(bEnableEdit)
+        pEd->Enable();
+    else
+        pEd->Disable();
+
+    return 0;
+}
+
+ScColorScale3FrmtEntry::ScColorScale3FrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat ):
     ScCondFrmtEntry( pParent, pDoc, rPos ),
     maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
     maLbColScale2( this, ScResId( LB_COL_SCALE2 ) ),
@@ -599,6 +762,7 @@ ScColorScaleFrmtEntry::ScColorScaleFrmtEntry( Window* pParent, ScDocument* pDoc,
     maLbColMiddle( this, ScResId( LB_COL) ),
     maLbColMax( this, ScResId( LB_COL) )
 {
+    maLbType.SelectEntryPos(0);
     if(pFormat)
     {
         if(pFormat->size() == 2)
@@ -630,11 +794,11 @@ ScColorScaleFrmtEntry::ScColorScaleFrmtEntry( Window* pParent, ScDocument* pDoc,
     Init();
 }
 
-void ScColorScaleFrmtEntry::Init()
+void ScColorScale3FrmtEntry::Init()
 {
-    maLbEntryTypeMin.SetSelectHdl( LINK( this, ScColorScaleFrmtEntry, EntryTypeHdl ) );
-    maLbEntryTypeMax.SetSelectHdl( LINK( this, ScColorScaleFrmtEntry, EntryTypeHdl ) );
-    maLbEntryTypeMiddle.SetSelectHdl( LINK( this, ScColorScaleFrmtEntry, EntryTypeHdl ) );
+    maLbEntryTypeMin.SetSelectHdl( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
+    maLbEntryTypeMax.SetSelectHdl( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
+    maLbEntryTypeMiddle.SetSelectHdl( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
 
     SfxObjectShell*     pDocSh      = SfxObjectShell::Current();
     const SfxPoolItem*  pItem       = NULL;
@@ -696,7 +860,7 @@ void ScColorScaleFrmtEntry::Init()
     EntryTypeHdl(&maLbEntryTypeMax);
 }
 
-ScFormatEntry* ScColorScaleFrmtEntry::createColorscaleEntry() const
+ScFormatEntry* ScColorScale3FrmtEntry::createColorscaleEntry() const
 {
     ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
     pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMin, maLbColMin, maEdMin, mpDoc, maPos));
@@ -706,12 +870,12 @@ ScFormatEntry* ScColorScaleFrmtEntry::createColorscaleEntry() const
     return pColorScale;
 }
 
-ScFormatEntry* ScColorScaleFrmtEntry::GetEntry() const
+ScFormatEntry* ScColorScale3FrmtEntry::GetEntry() const
 {
     return createColorscaleEntry();
 }
 
-void ScColorScaleFrmtEntry::SetActive()
+void ScColorScale3FrmtEntry::SetActive()
 {
     maLbColScale2.Show();
     maLbColScale3.Show();
@@ -731,7 +895,7 @@ void ScColorScaleFrmtEntry::SetActive()
     Select();
 }
 
-void ScColorScaleFrmtEntry::SetInactive()
+void ScColorScale3FrmtEntry::SetInactive()
 {
     maLbColScale2.Hide();
     maLbColScale3.Hide();
@@ -751,7 +915,7 @@ void ScColorScaleFrmtEntry::SetInactive()
     Deselect();
 }
 
-IMPL_LINK( ScColorScaleFrmtEntry, EntryTypeHdl, ListBox*, pBox )
+IMPL_LINK( ScColorScale3FrmtEntry, EntryTypeHdl, ListBox*, pBox )
 {
     bool bEnableEdit = true;
     sal_Int32 nPos = pBox->GetSelectEntryPos();
@@ -841,6 +1005,7 @@ ScDataBarFrmtEntry::ScDataBarFrmtEntry( Window* pParent, ScDocument* pDoc, const
     maBtOptions( this, ScResId( BTN_OPTIONS ) )
 {
     maLbColorFormat.SelectEntryPos(2);
+    maLbType.SelectEntryPos(0);
     if(pFormat)
     {
         mpDataBarData.reset(new ScDataBarFormatData(*pFormat->GetDataBarData()));
diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx
index 75f4502..3147bfb 100644
--- a/sc/source/ui/inc/condformatdlgentry.hxx
+++ b/sc/source/ui/inc/condformatdlgentry.hxx
@@ -1,6 +1,23 @@
 #include "colorscale.hxx"
 #include "conditio.hxx"
 
+namespace condformat {
+
+namespace entry {
+
+enum ScCondFrmtEntryType
+{
+    CONDITION,
+    FORMULA,
+    COLORSCALE2,
+    COLORSCALE3,
+    DATABAR
+};
+
+}
+
+}
+
 class ScCondFrmtEntry : public Control
 {
 private:
@@ -41,6 +58,8 @@ public:
     virtual ScFormatEntry* GetEntry() const = 0;
     virtual void SetActive() = 0;
     virtual void SetInactive() = 0;
+
+    virtual condformat::entry::ScCondFrmtEntryType GetType() = 0;
 };
 
 class ScConditionFrmtEntry : public ScCondFrmtEntry
@@ -65,6 +84,8 @@ public:
     virtual ScFormatEntry* GetEntry() const;
     virtual void SetActive();
     virtual void SetInactive();
+
+    virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::CONDITION; }
 };
 
 class ScFormulaFrmtEntry : public ScCondFrmtEntry
@@ -84,9 +105,41 @@ public:
     virtual ScFormatEntry* GetEntry() const;
     virtual void SetActive();
     virtual void SetInactive();
+    virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::FORMULA; }
+};
+
+class ScColorScale2FrmtEntry : public ScCondFrmtEntry
+{
+
+    //color format ui elements
+    ListBox maLbColorFormat;
+
+    //color scale ui elements
+    ListBox maLbColScale2;
+
+    ListBox maLbEntryTypeMin;
+    ListBox maLbEntryTypeMax;
+
+    Edit maEdMin;
+    Edit maEdMax;
+
+    ColorListBox maLbColMin;
+    ColorListBox maLbColMax;
+
+    ScFormatEntry* createColorscaleEntry() const;
+
+    void Init();
+
+    DECL_LINK( EntryTypeHdl, ListBox* );
+public:
+    ScColorScale2FrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = NULL );
+    virtual ScFormatEntry* GetEntry() const;
+    virtual void SetActive();
+    virtual void SetInactive();
+    virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::COLORSCALE2; }
 };
 
-class ScColorScaleFrmtEntry : public ScCondFrmtEntry
+class ScColorScale3FrmtEntry : public ScCondFrmtEntry
 {
 
     //color format ui elements
@@ -114,10 +167,11 @@ class ScColorScaleFrmtEntry : public ScCondFrmtEntry
 
     DECL_LINK( EntryTypeHdl, ListBox* );
 public:
-    ScColorScaleFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = NULL );
+    ScColorScale3FrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = NULL );
     virtual ScFormatEntry* GetEntry() const;
     virtual void SetActive();
     virtual void SetInactive();
+    virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::COLORSCALE3; }
 };
 
 class ScDataBarFrmtEntry : public ScCondFrmtEntry
@@ -146,5 +200,7 @@ public:
     virtual ScFormatEntry* GetEntry() const;
     virtual void SetActive();
     virtual void SetInactive();
+
+    virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::DATABAR; }
 };
 
commit 7bc0c2bd9edac11d17d2483ec79b845854db3da4
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Oct 8 22:47:55 2012 +0200

    handle all kinds of condition entries correctly in the dialog
    
    Change-Id: Ibad8d9000db20819b906e9d97002e1043794adcf

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index e9234e6..92af3ce 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -71,7 +71,19 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
         size_t nCount = pFormat->size();
         for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
         {
-            maEntries.push_back(new ScConditionFrmtEntry( this, mpDoc, maPos, static_cast<const ScCondFormatEntry*>(pFormat->GetEntry(nIndex) ) ) );
+            const ScFormatEntry* pEntry = pFormat->GetEntry(nIndex);
+            switch(pEntry->GetType())
+            {
+                case condformat::CONDITION:
+                    maEntries.push_back(new ScConditionFrmtEntry( this, mpDoc, maPos, static_cast<const ScCondFormatEntry*>( pEntry ) ) );
+                    break;
+                case condformat::COLORSCALE:
+                    maEntries.push_back(new ScColorScaleFrmtEntry( this, mpDoc, maPos, static_cast<const ScColorScaleFormat*>( pEntry ) ) );
+                    break;
+                case condformat::DATABAR:
+                    maEntries.push_back(new ScDataBarFrmtEntry( this, mpDoc, maPos, static_cast<const ScDataBarFormat*>( pEntry ) ) );
+                    break;
+            }
         }
     }
     else
commit ee93051d46db4332f779bac9cb2b75850afc98b0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Oct 8 13:55:26 2012 +0200

    add own class for formula type cond formats
    
    Change-Id: I0348797babb9e94e1d552dce341504144c837325

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index a3be003..e9234e6 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -190,13 +190,15 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox)
     {
         case 0:
             maEntries.replace( itr, new ScColorScaleFrmtEntry(this, mpDoc, maPos));
-            itr->SetHeight();
+            itr->SetActive();
             break;
         case 1:
             maEntries.replace( itr, new ScConditionFrmtEntry(this, mpDoc, maPos));
-            itr->SetHeight();
+            itr->SetActive();
             break;
         case 2:
+            maEntries.replace( itr, new ScFormulaFrmtEntry(this, mpDoc, maPos));
+            itr->SetActive();
             break;
     }
     RecalcAll();
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index f1d4379..00c5b3e 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -1,6 +1,7 @@
 #include "condformatdlg.hxx"
 #include "condformatdlgentry.hxx"
 #include "condformatdlg.hrc"
+#include "conditio.hxx"
 
 #include "document.hxx"
 
@@ -139,18 +140,6 @@ IMPL_LINK(ScCondFrmtEntry, EdModifyHdl, Edit*, pEdit)
 //
 //condition
 
-ScFormatEntry* ScConditionFrmtEntry::createFormulaEntry() const
-{
-    ScConditionMode eMode = SC_COND_DIRECT;
-    rtl::OUString aFormula = maEdVal1.GetText();
-    if(aFormula.isEmpty())
-        return NULL;
-
-    rtl::OUString aExpr2;
-    ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aFormula, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry());
-    return pEntry;
-}
-
 ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry ):
     ScCondFrmtEntry( pParent, pDoc, rPos ),
     maLbCondType( this, ScResId( LB_CELLIS_TYPE ) ),
@@ -377,6 +366,131 @@ IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl)
     return 0;
 }
 
+// formula
+
+ScFormulaFrmtEntry::ScFormulaFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormat ):
+    ScCondFrmtEntry( pParent, pDoc, rPos ),
+    maFtStyle( this, ScResId( FT_STYLE ) ),
+    maLbStyle( this, ScResId( LB_STYLE ) ),
+    maWdPreview( this, ScResId( WD_PREVIEW ) ),
+    maEdFormula( this, ScResId( ED_FORMULA ) )
+{
+    Init();
+
+    FreeResource();
+
+    if(pFormat)
+    {
+        maEdFormula.SetText(pFormat->GetExpression(rPos, 0, 0, pDoc->GetGrammar()));
+        maLbStyle.SelectEntry(pFormat->GetStyle());
+    }
+    else
+    {
+        maLbStyle.SelectEntryPos(1);
+    }
+}
+
+void ScFormulaFrmtEntry::Init()
+{
+    maLbStyle.SetSeparatorPos(0);
+
+    SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
+    for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
+    {
+        rtl::OUString aName = pStyle->GetName();
+        maLbStyle.InsertEntry( aName );
+    }
+    maLbStyle.SetSelectHdl( LINK( this, ScFormulaFrmtEntry, StyleSelectHdl ) );
+}
+
+IMPL_LINK_NOARG(ScFormulaFrmtEntry, StyleSelectHdl)
+{
+    if(maLbStyle.GetSelectEntryPos() == 0)
+    {
+        // call new style dialog
+        SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA );
+        SfxStringItem aRefItem( SID_STYLE_REFERENCE, ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
+
+        // unlock the dispatcher so SID_STYLE_NEW can be executed
+        // (SetDispatcherLock would affect all Calc documents)
+        ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+        SfxDispatcher* pDisp = pViewShell->GetDispatcher();
+        sal_Bool bLocked = pDisp->IsLocked();
+        if (bLocked)
+            pDisp->Lock(false);
+
+        // Execute the "new style" slot, complete with undo and all necessary updates.
+        // The return value (SfxUInt16Item) is ignored, look for new styles instead.
+        pDisp->Execute( SID_STYLE_NEW, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL,
+                &aFamilyItem,
+                &aRefItem,
+                0L );
+
+        if (bLocked)
+            pDisp->Lock(sal_True);
+
+        // Find the new style and add it into the style list boxes
+        rtl::OUString aNewStyle;
+        SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
+        for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
+        {
+            rtl::OUString aName = pStyle->GetName();
+            if ( maLbStyle.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND )    // all lists contain the same entries
+            {
+                maLbStyle.InsertEntry(aName);
+                maLbStyle.SelectEntry(aName);
+            }
+        }
+    }
+
+    rtl::OUString aStyleName = maLbStyle.GetSelectEntry();
+    SfxStyleSheetBase* pStyleSheet = mpDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
+    if(pStyleSheet)
+    {
+        const SfxItemSet& rSet = pStyleSheet->GetItemSet();
+        maWdPreview.Init( rSet );
+    }
+
+    return 0;
+}
+
+ScFormatEntry* ScFormulaFrmtEntry::createFormulaEntry() const
+{
+    ScConditionMode eMode = SC_COND_DIRECT;
+    rtl::OUString aFormula = maEdFormula.GetText();
+    if(aFormula.isEmpty())
+        return NULL;
+
+    rtl::OUString aExpr2;
+    ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aFormula, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry());
+    return pEntry;
+}
+
+ScFormatEntry* ScFormulaFrmtEntry::GetEntry() const
+{
+    return createFormulaEntry();
+}
+
+void ScFormulaFrmtEntry::SetActive()
+{
+    maWdPreview.Show();
+    maFtStyle.Show();
+    maLbStyle.Show();
+    maEdFormula.Show();
+
+    Select();
+}
+
+void ScFormulaFrmtEntry::SetInactive()
+{
+    maWdPreview.Hide();
+    maFtStyle.Hide();
+    maLbStyle.Hide();
+    maEdFormula.Hide();
+
+    Deselect();
+}
+
 //color scale
 
 namespace {
diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc
index 960faec..f025856 100644
--- a/sc/source/ui/inc/condformatdlg.hrc
+++ b/sc/source/ui/inc/condformatdlg.hrc
@@ -59,4 +59,6 @@
 #define ED_RANGE 33
 #define RB_RANGE 34
 
+#define ED_FORMULA 35
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx
index 4484b0a..75f4502 100644
--- a/sc/source/ui/inc/condformatdlgentry.hxx
+++ b/sc/source/ui/inc/condformatdlgentry.hxx
@@ -55,7 +55,6 @@ class ScConditionFrmtEntry : public ScCondFrmtEntry
     SvxFontPrevWindow maWdPreview;
 
     ScFormatEntry* createConditionEntry() const;
-    ScFormatEntry* createFormulaEntry() const;
 
     void Init();
     DECL_LINK( StyleSelectHdl, void* );
@@ -68,6 +67,25 @@ public:
     virtual void SetInactive();
 };
 
+class ScFormulaFrmtEntry : public ScCondFrmtEntry
+{
+    FixedText maFtStyle;
+    ListBox maLbStyle;
+    SvxFontPrevWindow maWdPreview;
+    Edit maEdFormula;
+
+    ScFormatEntry* createFormulaEntry() const;
+    void Init();
+
+    DECL_LINK( StyleSelectHdl, void* );
+public:
+    ScFormulaFrmtEntry( Window* pParent, ScDocument* PDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = NULL );
+
+    virtual ScFormatEntry* GetEntry() const;
+    virtual void SetActive();
+    virtual void SetInactive();
+};
+
 class ScColorScaleFrmtEntry : public ScCondFrmtEntry
 {
 
diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src
index e7fa731..16b2650 100644
--- a/sc/source/ui/src/condformatdlg.src
+++ b/sc/source/ui/src/condformatdlg.src
@@ -149,6 +149,12 @@ Control RID_COND_ENTRY
         Size = MAP_APPFONT( 50, 12 );
         Border = TRUE;
     };
+    Edit ED_FORMULA
+    {
+        Pos = MAP_APPFONT( 90, 15 );
+        Size = MAP_APPFONT( 135, 12 );
+        Border = TRUE;
+    };
     Edit ED_VAL2
     {
         Pos = MAP_APPFONT( 230, 15 );
commit d7a27f400fa148037822e93857a2b6d9d37750b8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Oct 8 12:31:05 2012 +0200

    make more parts of the conditional format dlg work again
    
    Change-Id: I86ff7911bcc7cc916766d583881e605dfe1a3942

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 730e7bf..a3be003 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -92,7 +92,7 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
         }
     }
     if (!maEntries.empty())
-        maEntries.begin()->Select();
+        maEntries.begin()->SetActive();
 
     RecalcAll();
     FreeResource();
@@ -176,9 +176,28 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox*, pBox)
 
 IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox)
 {
+    EntryContainer::iterator itr = maEntries.begin();
+    for(; itr != maEntries.end(); ++itr)
+    {
+        if(itr->IsSelected())
+            break;
+    }
+    if(itr == maEntries.end())
+        return 0;;
+
     sal_Int32 nPos = pBox->GetSelectEntryPos();
     switch(nPos)
     {
+        case 0:
+            maEntries.replace( itr, new ScColorScaleFrmtEntry(this, mpDoc, maPos));
+            itr->SetHeight();
+            break;
+        case 1:
+            maEntries.replace( itr, new ScConditionFrmtEntry(this, mpDoc, maPos));
+            itr->SetHeight();
+            break;
+        case 2:
+            break;
     }
     RecalcAll();
     return 0;
@@ -190,9 +209,9 @@ IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl )
     maEntries.push_back( pNewEntry );
     for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
     {
-        itr->Deselect();
+        itr->SetInactive();
     }
-    pNewEntry->Select();
+    pNewEntry->SetActive();
     RecalcAll();
     return 0;
 }
@@ -215,9 +234,9 @@ IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry*, pEntry )
 {
     for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
     {
-        itr->Deselect();
+        itr->SetInactive();
     }
-    pEntry->Select();
+    pEntry->SetActive();
     RecalcAll();
     return 0;
 }
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 63dfcec..f1d4379 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -22,27 +22,23 @@
 ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScAddress& rPos):
     Control(pParent, ScResId( RID_COND_ENTRY ) ),
     mbActive(false),
-    maLbType( this, ScResId( LB_TYPE ) ),
     maFtCondNr( this, ScResId( FT_COND_NR ) ),
     maFtCondition( this, ScResId( FT_CONDITION ) ),
     mnIndex(0),
     maStrCondition(ScResId( STR_CONDITION ).toString()),
+    maLbType( this, ScResId( LB_TYPE ) ),
     mpDoc(pDoc),
     maPos(rPos)
 {
     SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
-    FreeResource();
 
     /*
-    maLbType.SelectEntryPos(1);
-    maLbCondType.SelectEntryPos(0);
-    maEdVal2.Hide();
     */
     //disable entries for color formats
 
+    maLbType.SetSelectHdl( LINK( pParent, ScCondFormatList, TypeListHdl ) );
     Init();
     maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
-    SetHeight();
 }
 
 ScCondFrmtEntry::~ScCondFrmtEntry()
@@ -51,9 +47,7 @@ ScCondFrmtEntry::~ScCondFrmtEntry()
 
 void ScCondFrmtEntry::Init()
 {
-    maLbType.SetSelectHdl( LINK( this, ScCondFormatList, TypeListHdl ) );
     /*
-    maLbColorFormat.SetSelectHdl( LINK( this, ScCondFormatList, ColFormatTypeHdl ) );
 
     */
 }
@@ -103,12 +97,19 @@ void ScCondFrmtEntry::SetHeight()
 
 void ScCondFrmtEntry::Select()
 {
+    maFtCondition.SetText(rtl::OUString());
+    maFtCondition.Hide();
+    maLbType.Show();
     mbActive = true;
     SetHeight();
 }
 
 void ScCondFrmtEntry::Deselect()
 {
+    rtl::OUString maCondText("deselected");// = ScCondFormatHelper::GetExpression(CONDITION, maLbCondType.GetSelectEntryPos());
+    maFtCondition.SetText(maCondText);
+    maFtCondition.Show();
+    maLbType.Hide();
     mbActive = false;
     SetHeight();
 }
@@ -159,6 +160,11 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
     maLbStyle( this, ScResId( LB_STYLE ) ),
     maWdPreview( this, ScResId( WD_PREVIEW ) )
 {
+
+    FreeResource();
+
+    Init();
+
     if(pFormatEntry)
     {
         rtl::OUString aStyleName = pFormatEntry->GetStyle();
@@ -209,9 +215,11 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
     }
     else
     {
+        maLbCondType.SelectEntryPos(0);
+        maEdVal2.Hide();
         maLbStyle.SelectEntryPos(1);
     }
-
+    maLbType.SelectEntryPos(1);
 }
 
 void ScConditionFrmtEntry::Init()
@@ -294,6 +302,30 @@ ScFormatEntry* ScConditionFrmtEntry::GetEntry() const
     return createConditionEntry();
 }
 
+void ScConditionFrmtEntry::SetActive()
+{
+    maLbCondType.Show();
+    maEdVal1.Show();
+    maEdVal2.Show();
+    maFtStyle.Show();
+    maLbStyle.Show();
+    maWdPreview.Show();
+
+    Select();
+}
+
+void ScConditionFrmtEntry::SetInactive()
+{
+    maLbCondType.Hide();
+    maEdVal1.Hide();
+    maEdVal2.Hide();
+    maFtStyle.Hide();
+    maLbStyle.Hide();
+    maWdPreview.Hide();
+
+    Deselect();
+}
+
 IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl)
 {
     if(maLbStyle.GetSelectEntryPos() == 0)
@@ -440,7 +472,7 @@ ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListB
 
 ScColorScaleFrmtEntry::ScColorScaleFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat ):
     ScCondFrmtEntry( pParent, pDoc, rPos ),
-    //maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
+    maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
     maLbColScale2( this, ScResId( LB_COL_SCALE2 ) ),
     maLbColScale3( this, ScResId( LB_COL_SCALE3 ) ),
     maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE ) ),
@@ -455,12 +487,10 @@ ScColorScaleFrmtEntry::ScColorScaleFrmtEntry( Window* pParent, ScDocument* pDoc,
 {
     if(pFormat)
     {
-        /*
         if(pFormat->size() == 2)
             maLbColorFormat.SelectEntryPos(0);
         else
             maLbColorFormat.SelectEntryPos(1);
-        */
         ScColorScaleFormat::const_iterator itr = pFormat->begin();
         SetColorScaleEntryTypes(*itr, maLbEntryTypeMin, maEdMin, maLbColMin);
         if(pFormat->size() == 3)
@@ -473,12 +503,17 @@ ScColorScaleFrmtEntry::ScColorScaleFrmtEntry( Window* pParent, ScDocument* pDoc,
     }
     else
     {
-        //maLbColorFormat.SelectEntryPos(0);
+        maLbColorFormat.SelectEntryPos(1);
         maLbEntryTypeMin.SelectEntryPos(0);
         maLbEntryTypeMiddle.SelectEntryPos(2);
         maLbEntryTypeMax.SelectEntryPos(1);
         maEdMiddle.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(50)));
     }
+    FreeResource();
+
+    maLbColorFormat.SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
+
+    Init();
 }
 
 void ScColorScaleFrmtEntry::Init()
@@ -551,10 +586,8 @@ ScFormatEntry* ScColorScaleFrmtEntry::createColorscaleEntry() const
 {
     ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
     pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMin, maLbColMin, maEdMin, mpDoc, maPos));
-    /*
     if(maLbColorFormat.GetSelectEntryPos() == 1)
         pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMiddle, maLbColMiddle, maEdMiddle, mpDoc, maPos));
-        */
     pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMax, maLbColMax, maEdMax, mpDoc, maPos));
     return pColorScale;
 }
@@ -564,6 +597,46 @@ ScFormatEntry* ScColorScaleFrmtEntry::GetEntry() const
     return createColorscaleEntry();
 }
 
+void ScColorScaleFrmtEntry::SetActive()
+{
+    maLbColScale2.Show();
+    maLbColScale3.Show();
+
+    maLbEntryTypeMin.Show();
+    maLbEntryTypeMiddle.Show();
+    maLbEntryTypeMax.Show();
+
+    maEdMin.Show();
+    maEdMiddle.Show();
+    maEdMax.Show();
+
+    maLbColMin.Show();
+    maLbColMiddle.Show();
+    maLbColMax.Show();
+
+    Select();
+}
+
+void ScColorScaleFrmtEntry::SetInactive()
+{
+    maLbColScale2.Hide();
+    maLbColScale3.Hide();
+
+    maLbEntryTypeMin.Hide();
+    maLbEntryTypeMiddle.Hide();
+    maLbEntryTypeMax.Hide();
+
+    maEdMin.Hide();
+    maEdMiddle.Hide();
+    maEdMax.Hide();
+
+    maLbColMin.Hide();
+    maLbColMiddle.Hide();
+    maLbColMax.Hide();
+
+    Deselect();
+}
+
 IMPL_LINK( ScColorScaleFrmtEntry, EntryTypeHdl, ListBox*, pBox )
 {
     bool bEnableEdit = true;
@@ -646,16 +719,17 @@ void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Ed
 
 ScDataBarFrmtEntry::ScDataBarFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat ):
     ScCondFrmtEntry( pParent, pDoc, rPos ),
+    maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
     maLbDataBarMinType( this, ScResId( LB_TYPE_COL_SCALE ) ),
     maLbDataBarMaxType( this, ScResId( LB_TYPE_COL_SCALE ) ),
     maEdDataBarMin( this, ScResId( ED_COL_SCALE ) ),
     maEdDataBarMax( this, ScResId( ED_COL_SCALE ) ),
     maBtOptions( this, ScResId( BTN_OPTIONS ) )
 {
+    maLbColorFormat.SelectEntryPos(2);
     if(pFormat)
     {
         mpDataBarData.reset(new ScDataBarFormatData(*pFormat->GetDataBarData()));
-        //maLbColorFormat.SelectEntryPos(2);
         SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, maLbDataBarMinType, maEdDataBarMin);
         SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, maLbDataBarMaxType, maEdDataBarMax);
         DataBarTypeSelectHdl(NULL);
@@ -665,7 +739,11 @@ ScDataBarFrmtEntry::ScDataBarFrmtEntry( Window* pParent, ScDocument* pDoc, const
         maLbDataBarMinType.SelectEntryPos(0);
         maLbDataBarMaxType.SelectEntryPos(1);
     }
+    Init();
+
+    maLbColorFormat.SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
 
+    FreeResource();
 }
 
 ScFormatEntry* ScDataBarFrmtEntry::GetEntry() const
@@ -704,6 +782,28 @@ ScFormatEntry* ScDataBarFrmtEntry::createDatabarEntry() const
     return pDataBar;
 }
 
+void ScDataBarFrmtEntry::SetActive()
+{
+    maLbDataBarMinType.Show();
+    maLbDataBarMaxType.Show();
+    maEdDataBarMin.Show();
+    maEdDataBarMax.Show();
+    maBtOptions.Show();
+
+    Select();
+}
+
+void ScDataBarFrmtEntry::SetInactive()
+{
+    maLbDataBarMinType.Hide();
+    maLbDataBarMaxType.Hide();
+    maEdDataBarMin.Hide();
+    maEdDataBarMax.Hide();
+    maBtOptions.Hide();
+
+    Deselect();
+}
+
 IMPL_LINK_NOARG( ScDataBarFrmtEntry, DataBarTypeSelectHdl )
 {
     sal_Int32 nSelectPos = maLbDataBarMinType.GetSelectEntryPos();
diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx
index ee782b1..4484b0a 100644
--- a/sc/source/ui/inc/condformatdlgentry.hxx
+++ b/sc/source/ui/inc/condformatdlgentry.hxx
@@ -9,34 +9,38 @@ private:
     Link maClickHdl;
 
     //general ui elements
-    ListBox maLbType;
     FixedText maFtCondNr;
     FixedText maFtCondition;
 
-    void SetHeight();
     void Init();
 
     sal_Int32 mnIndex;
     rtl::OUString maStrCondition;
 protected:
+    ListBox maLbType;
+
     ScDocument* mpDoc;
     ScAddress maPos;
 
     DECL_LINK( EdModifyHdl, Edit* );
 
+    void Select();
+    void Deselect();
+
 public:
     ScCondFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos );
     virtual ~ScCondFrmtEntry();
 
     virtual long Notify( NotifyEvent& rNEvt );
 
-    void Select();
-    void Deselect();
-
     bool IsSelected() const;
     void SetIndex(sal_Int32 nIndex);
+    sal_Int32 GetIndex() const { return mnIndex; }
+    void SetHeight();
 
     virtual ScFormatEntry* GetEntry() const = 0;
+    virtual void SetActive() = 0;
+    virtual void SetInactive() = 0;
 };
 
 class ScConditionFrmtEntry : public ScCondFrmtEntry
@@ -53,7 +57,6 @@ class ScConditionFrmtEntry : public ScCondFrmtEntry
     ScFormatEntry* createConditionEntry() const;
     ScFormatEntry* createFormulaEntry() const;
 
-    void SetHeight();
     void Init();
     DECL_LINK( StyleSelectHdl, void* );
     DECL_LINK( ConditionTypeSelectHdl, void* );
@@ -61,13 +64,15 @@ public:
     ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = NULL );
 
     virtual ScFormatEntry* GetEntry() const;
+    virtual void SetActive();
+    virtual void SetInactive();
 };
 
 class ScColorScaleFrmtEntry : public ScCondFrmtEntry
 {
 
     //color format ui elements
-    //ListBox maLbColorFormat;
+    ListBox maLbColorFormat;
 
     //color scale ui elements
     ListBox maLbColScale2;
@@ -87,19 +92,20 @@ class ScColorScaleFrmtEntry : public ScCondFrmtEntry
 
     ScFormatEntry* createColorscaleEntry() const;
 
-    void SetHeight();
     void Init();
 
     DECL_LINK( EntryTypeHdl, ListBox* );
 public:
     ScColorScaleFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = NULL );
     virtual ScFormatEntry* GetEntry() const;
+    virtual void SetActive();
+    virtual void SetInactive();
 };
 
 class ScDataBarFrmtEntry : public ScCondFrmtEntry
 {
     //color format ui elements
-    //ListBox maLbColorFormat;
+    ListBox maLbColorFormat;
 
     //data bar ui elements
     ListBox maLbDataBarMinType;
@@ -113,7 +119,6 @@ class ScDataBarFrmtEntry : public ScCondFrmtEntry
 
     ScFormatEntry* createDatabarEntry() const;
 
-    void SetHeight();
     void Init();
 
     DECL_LINK( OptionBtnHdl, void* );
@@ -121,5 +126,7 @@ class ScDataBarFrmtEntry : public ScCondFrmtEntry
 public:
     ScDataBarFrmtEntry( Window* pParemt, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat = NULL );
     virtual ScFormatEntry* GetEntry() const;
+    virtual void SetActive();
+    virtual void SetInactive();
 };
 
commit 1491483543ae6d32d7d487c26ca94a734f157532
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Oct 8 03:31:16 2012 +0200

    split the cond format entry code a bit up
    
    Change-Id: Ib066c18d54ac40c24b51ca5c399d09482897709f

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index f7c73d7..f4cdafa 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -330,6 +330,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 	sc/source/ui/cctrl/tbinsert \
 	sc/source/ui/cctrl/tbzoomsliderctrl \
 	sc/source/ui/condformat/condformatdlg \
+	sc/source/ui/condformat/condformatdlgentry \
 	sc/source/ui/condformat/condformathelper \
 	sc/source/ui/condformat/colorformat \
 	sc/source/ui/dbgui/asciiopt \
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index eaeb6d1..730e7bf 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -47,955 +47,13 @@
 #include "colorscale.hxx"
 #include "colorformat.hxx"
 #include "reffact.hxx"
+#include "condformatdlgentry.hxx"
 
 #include "globstr.hrc"
 
 #include <cassert>
 #include <iostream>
 
-namespace {
-
-void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit, ColorListBox& rLbCol )
-{
-    switch(rEntry.GetType())
-    {
-        case COLORSCALE_MIN:
-            rLbType.SelectEntryPos(0);
-            break;
-        case COLORSCALE_MAX:
-            rLbType.SelectEntryPos(1);
-            break;
-        case COLORSCALE_PERCENTILE:
-            rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
-            rLbType.SelectEntryPos(2);
-            break;
-        case COLORSCALE_PERCENT:
-            rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
-            rLbType.SelectEntryPos(4);
-            break;
-        case COLORSCALE_FORMULA:
-            rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
-            rLbType.SelectEntryPos(5);
-            break;
-        case COLORSCALE_VALUE:
-            rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
-            rLbType.SelectEntryPos(3);
-            break;
-        case COLORSCALE_AUTOMIN:
-            rLbType.SelectEntryPos(6);
-            break;
-        case COLORSCALE_AUTOMAX:
-            rLbType.SelectEntryPos(7);
-            break;
-    }
-    rLbCol.SelectEntry(rEntry.GetColor());
-}
-
-void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit )
-{
-    switch(rEntry.GetType())
-    {
-        case COLORSCALE_MIN:
-            rLbType.SelectEntryPos(0);
-            break;
-        case COLORSCALE_MAX:
-            rLbType.SelectEntryPos(1);
-            break;
-        case COLORSCALE_PERCENTILE:
-            rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
-            rLbType.SelectEntryPos(2);
-            break;
-        case COLORSCALE_PERCENT:
-            rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
-            rLbType.SelectEntryPos(4);
-            break;
-        case COLORSCALE_FORMULA:
-            rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
-            rLbType.SelectEntryPos(5);
-            break;
-        case COLORSCALE_VALUE:
-            rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
-            rLbType.SelectEntryPos(3);
-            break;
-        case COLORSCALE_AUTOMIN:
-            rLbType.SelectEntryPos(6);
-            break;
-        case COLORSCALE_AUTOMAX:
-            rLbType.SelectEntryPos(7);
-            break;
-    }
-}
-
-}
-
-ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScAddress& rPos):
-    Control(pParent, ScResId( RID_COND_ENTRY ) ),
-    mbActive(false),
-    meType(CONDITION),
-    maLbType( this, ScResId( LB_TYPE ) ),
-    maFtCondNr( this, ScResId( FT_COND_NR ) ),
-    maFtCondition( this, ScResId( FT_CONDITION ) ),
-    maLbCondType( this, ScResId( LB_CELLIS_TYPE ) ),
-    maEdVal1( this, ScResId( ED_VAL1 ) ),
-    maEdVal2( this, ScResId( ED_VAL2 ) ),
-    maFtStyle( this, ScResId( FT_STYLE ) ),
-    maLbStyle( this, ScResId( LB_STYLE ) ),
-    maWdPreview( this, ScResId( WD_PREVIEW ) ),
-    maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
-    maLbColScale2( this, ScResId( LB_COL_SCALE2 ) ),
-    maLbColScale3( this, ScResId( LB_COL_SCALE3 ) ),
-    maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maLbEntryTypeMiddle( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maLbEntryTypeMax( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maEdMin( this, ScResId( ED_COL_SCALE ) ),
-    maEdMiddle( this, ScResId( ED_COL_SCALE ) ),
-    maEdMax( this, ScResId( ED_COL_SCALE ) ),
-    maLbColMin( this, ScResId( LB_COL) ),
-    maLbColMiddle( this, ScResId( LB_COL) ),
-    maLbColMax( this, ScResId( LB_COL) ),
-    maLbDataBarMinType( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maLbDataBarMaxType( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maEdDataBarMin( this, ScResId( ED_COL_SCALE ) ),
-    maEdDataBarMax( this, ScResId( ED_COL_SCALE ) ),
-    maBtOptions( this, ScResId( BTN_OPTIONS ) ),
-    mpDoc(pDoc),
-    maPos(rPos),
-    mnIndex(0),
-    maStrCondition(ScResId( STR_CONDITION ).toString())
-{
-    SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
-    FreeResource();
-
-    maLbType.SelectEntryPos(1);
-    maLbCondType.SelectEntryPos(0);
-    maEdVal2.Hide();
-
-    maLbStyle.SetSeparatorPos(0);
-
-    //disable entries for color formats
-    maLbColorFormat.SelectEntryPos(0);
-    maLbEntryTypeMin.SelectEntryPos(0);
-    maLbEntryTypeMiddle.SelectEntryPos(2);
-    maLbEntryTypeMax.SelectEntryPos(1);
-    maLbDataBarMinType.SelectEntryPos(0);
-    maLbDataBarMaxType.SelectEntryPos(1);
-    maEdMiddle.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(50)));
-    maEdDataBarMin.Disable();
-    maEdDataBarMax.Disable();
-
-    Init();
-    maLbStyle.SelectEntryPos(1);
-    maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
-    SwitchToType(COLLAPSED);
-    SetHeight();
-    SetCondType();
-
-    EntryTypeHdl(&maLbEntryTypeMin);
-    EntryTypeHdl(&maLbEntryTypeMiddle);
-    EntryTypeHdl(&maLbEntryTypeMax);
-}
-
-ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScFormatEntry* pFormatEntry, const ScAddress& rPos):
-    Control(pParent, ScResId( RID_COND_ENTRY ) ),
-    mbActive(false),
-    meType(CONDITION),
-    maLbType( this, ScResId( LB_TYPE ) ),
-    maFtCondNr( this, ScResId( FT_COND_NR ) ),
-    maFtCondition( this, ScResId( FT_CONDITION ) ),
-    maLbCondType( this, ScResId( LB_CELLIS_TYPE ) ),
-    maEdVal1( this, ScResId( ED_VAL1 ) ),
-    maEdVal2( this, ScResId( ED_VAL2 ) ),
-    maFtStyle( this, ScResId( FT_STYLE ) ),
-    maLbStyle( this, ScResId( LB_STYLE ) ),
-    maWdPreview( this, ScResId( WD_PREVIEW ) ),
-    maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
-    maLbColScale2( this, ScResId( LB_COL_SCALE2 ) ),
-    maLbColScale3( this, ScResId( LB_COL_SCALE3 ) ),
-    maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maLbEntryTypeMiddle( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maLbEntryTypeMax( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maEdMin( this, ScResId( ED_COL_SCALE ) ),
-    maEdMiddle( this, ScResId( ED_COL_SCALE ) ),
-    maEdMax( this, ScResId( ED_COL_SCALE ) ),
-    maLbColMin( this, ScResId( LB_COL) ),
-    maLbColMiddle( this, ScResId( LB_COL) ),
-    maLbColMax( this, ScResId( LB_COL) ),
-    maLbDataBarMinType( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maLbDataBarMaxType( this, ScResId( LB_TYPE_COL_SCALE ) ),
-    maEdDataBarMin( this, ScResId( ED_COL_SCALE ) ),
-    maEdDataBarMax( this, ScResId( ED_COL_SCALE ) ),
-    maBtOptions( this, ScResId( BTN_OPTIONS ) ),
-    mpDoc(pDoc),
-    maPos(rPos)
-{
-    SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
-    FreeResource();
-    Init();
-
-    if(pFormatEntry && pFormatEntry->GetType() == condformat::CONDITION)
-    {
-        const ScCondFormatEntry* pEntry = static_cast<const ScCondFormatEntry*>(pFormatEntry);
-        rtl::OUString aStyleName = pEntry->GetStyle();
-        maLbStyle.SelectEntry(aStyleName);
-        StyleSelectHdl(NULL);
-        ScConditionMode eMode = pEntry->GetOperation();
-        maLbType.SelectEntryPos(1);
-        maEdVal1.SetText(pEntry->GetExpression(maPos, 0));
-        SetCondType();
-        switch(eMode)
-        {
-            case SC_COND_EQUAL:
-                maLbCondType.SelectEntryPos(0);
-                break;
-            case SC_COND_LESS:
-                maLbCondType.SelectEntryPos(1);
-                break;
-            case SC_COND_GREATER:
-                maLbCondType.SelectEntryPos(2);
-                break;
-            case SC_COND_EQLESS:
-                maLbCondType.SelectEntryPos(3);
-                break;
-            case SC_COND_EQGREATER:
-                maLbCondType.SelectEntryPos(4);
-                break;
-            case SC_COND_NOTEQUAL:
-                maLbCondType.SelectEntryPos(5);
-                break;
-            case SC_COND_BETWEEN:
-                maEdVal2.SetText(pEntry->GetExpression(maPos, 1));
-                maLbCondType.SelectEntryPos(6);
-                break;
-            case SC_COND_NOTBETWEEN:
-                maEdVal2.SetText(pEntry->GetExpression(maPos, 1));
-                maLbCondType.SelectEntryPos(7);
-                break;
-            case SC_COND_DUPLICATE:
-                maLbCondType.SelectEntryPos(8);
-                break;
-            case SC_COND_NOTDUPLICATE:
-                maLbCondType.SelectEntryPos(9);
-                break;
-            case SC_COND_DIRECT:
-                maLbType.SelectEntryPos(2);
-                SwitchToType(FORMULA);
-                break;
-            case SC_COND_NONE:
-                break;
-        }
-    }
-    else if( pFormatEntry && pFormatEntry->GetType() == condformat::COLORSCALE )
-    {
-        const ScColorScaleFormat* pEntry = static_cast<const ScColorScaleFormat*>(pFormatEntry);
-        maLbType.SelectEntryPos(0);
-        if(pEntry->size() == 2)
-            maLbColorFormat.SelectEntryPos(0);
-        else
-            maLbColorFormat.SelectEntryPos(1);
-        SetColorScaleType();
-        ScColorScaleFormat::const_iterator itr = pEntry->begin();
-        SetColorScaleEntryTypes(*itr, maLbEntryTypeMin, maEdMin, maLbColMin);
-        if(pEntry->size() == 3)
-        {
-            ++itr;
-            SetColorScaleEntryTypes(*itr, maLbEntryTypeMiddle, maEdMiddle, maLbColMiddle);
-        }
-        ++itr;
-        SetColorScaleEntryTypes(*itr, maLbEntryTypeMax, maEdMax, maLbColMax);
-    }
-    else if( pFormatEntry && pFormatEntry->GetType() == condformat::DATABAR )
-    {
-        const ScDataBarFormat* pEntry = static_cast<const ScDataBarFormat*>(pFormatEntry);
-        mpDataBarData.reset(new ScDataBarFormatData(*pEntry->GetDataBarData()));
-        maLbType.SelectEntryPos(0);
-        maLbColorFormat.SelectEntryPos(2);
-        SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, maLbDataBarMinType, maEdDataBarMin);
-        SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, maLbDataBarMaxType, maEdDataBarMax);
-        DataBarTypeSelectHdl(NULL);
-        SetDataBarType();
-    }
-
-    maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
-    SwitchToType(COLLAPSED);
-    SetHeight();
-
-    EntryTypeHdl(&maLbEntryTypeMin);
-    EntryTypeHdl(&maLbEntryTypeMiddle);
-    EntryTypeHdl(&maLbEntryTypeMax);
-}
-
-ScCondFrmtEntry::~ScCondFrmtEntry()
-{
-}
-
-void ScCondFrmtEntry::Init()
-{
-    maLbType.SetSelectHdl( LINK( this, ScCondFrmtEntry, TypeListHdl ) );
-    maLbColorFormat.SetSelectHdl( LINK( this, ScCondFrmtEntry, ColFormatTypeHdl ) );
-    maLbEntryTypeMin.SetSelectHdl( LINK( this, ScCondFrmtEntry, EntryTypeHdl ) );
-    maLbEntryTypeMax.SetSelectHdl( LINK( this, ScCondFrmtEntry, EntryTypeHdl ) );
-    maLbEntryTypeMiddle.SetSelectHdl( LINK( this, ScCondFrmtEntry, EntryTypeHdl ) );
-    maEdVal1.SetStyle( maEdVal1.GetStyle() | WB_FORCECTRLBACKGROUND );
-    maEdVal2.SetStyle( maEdVal2.GetStyle() | WB_FORCECTRLBACKGROUND );
-
-    maEdVal1.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) );
-    maEdVal2.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) );
-
-    SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
-    for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
-    {
-        rtl::OUString aName = pStyle->GetName();
-        maLbStyle.InsertEntry( aName );
-    }
-    maLbStyle.SetSelectHdl( LINK( this, ScCondFrmtEntry, StyleSelectHdl ) );
-
-    Point aPointLb = maLbEntryTypeMiddle.GetPosPixel();
-    Point aPointEd = maEdMiddle.GetPosPixel();
-    Point aPointCol = maLbColMiddle.GetPosPixel();
-    Point aPointEdDataBar = maEdDataBarMin.GetPosPixel();
-    Point aPointLbDataBar = maLbDataBarMaxType.GetPosPixel();
-    const long nMovePos = maLbEntryTypeMiddle.GetSizePixel().Width() * 1.2;
-    aPointLb.X() += nMovePos;
-    aPointEd.X() += nMovePos;
-    aPointCol.X() += nMovePos;
-    aPointEdDataBar.X() += 2*nMovePos;
-    aPointLbDataBar.X() += 2*nMovePos;
-    maLbEntryTypeMiddle.SetPosPixel(aPointLb);
-    maEdMiddle.SetPosPixel(aPointEd);
-    maLbColMiddle.SetPosPixel(aPointCol);
-    maEdDataBarMax.SetPosPixel(aPointEdDataBar);
-    maLbDataBarMaxType.SetPosPixel(aPointLbDataBar);
-    aPointLb.X() += nMovePos;
-    aPointEd.X() += nMovePos;
-    aPointCol.X() += nMovePos;
-    maLbEntryTypeMax.SetPosPixel(aPointLb);
-    maEdMax.SetPosPixel(aPointEd);
-    maLbColMax.SetPosPixel(aPointCol);
-
-    SfxObjectShell*     pDocSh      = SfxObjectShell::Current();
-    const SfxPoolItem*  pItem       = NULL;
-    XColorListRef       pColorTable;
-
-    DBG_ASSERT( pDocSh, "DocShell not found!" );
-
-    if ( pDocSh )
-    {
-        pItem = pDocSh->GetItem( SID_COLOR_TABLE );
-        if ( pItem != NULL )
-            pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
-    }
-    if ( pColorTable.is() )
-    {
-        // filling the line color box
-        maLbColMin.SetUpdateMode( false );
-        maLbColMiddle.SetUpdateMode( false );
-        maLbColMax.SetUpdateMode( false );
-
-        for ( long i = 0; i < pColorTable->Count(); ++i )
-        {
-            XColorEntry* pEntry = pColorTable->GetColor(i);
-            maLbColMin.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
-            maLbColMiddle.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
-            maLbColMax.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
-
-            if(pEntry->GetColor() == Color(COL_LIGHTRED))
-                maLbColMin.SelectEntryPos(i);
-            if(pEntry->GetColor() == Color(COL_GREEN))
-                maLbColMiddle.SelectEntryPos(i);
-            if(pEntry->GetColor() == Color(COL_LIGHTBLUE))
-                maLbColMax.SelectEntryPos(i);
-        }
-        maLbColMin.SetUpdateMode( sal_True );
-        maLbColMiddle.SetUpdateMode( sal_True );
-        maLbColMax.SetUpdateMode( sal_True );
-    }
-
-    maBtOptions.SetClickHdl( LINK( this, ScCondFrmtEntry, OptionBtnHdl ) );
-    maLbDataBarMinType.SetSelectHdl( LINK( this, ScCondFrmtEntry, DataBarTypeSelectHdl ) );
-    maLbDataBarMaxType.SetSelectHdl( LINK( this, ScCondFrmtEntry, DataBarTypeSelectHdl ) );
-    maLbCondType.SetSelectHdl( LINK( this, ScCondFrmtEntry, ConditionTypeSelectHdl ) );
-
-    mpDataBarData.reset(new ScDataBarFormatData());
-    mpDataBarData->mpUpperLimit.reset(new ScColorScaleEntry());
-    mpDataBarData->mpLowerLimit.reset(new ScColorScaleEntry());
-    mpDataBarData->mpLowerLimit->SetType(COLORSCALE_MIN);
-    mpDataBarData->mpUpperLimit->SetType(COLORSCALE_MAX);
-    mpDataBarData->maPositiveColor = COL_LIGHTBLUE;
-}
-
-long ScCondFrmtEntry::Notify( NotifyEvent& rNEvt )
-{
-    if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
-    {
-        ImplCallEventListenersAndHandler( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, maClickHdl, this );
-    }
-    return Control::Notify(rNEvt);
-}
-
-void ScCondFrmtEntry::SwitchToType( ScCondFormatEntryType eType )
-{
-    switch(eType)
-    {
-        case COLLAPSED:
-            {
-                maLbType.Hide();
-                rtl::OUString maCondText = ScCondFormatHelper::GetExpression(meType, maLbCondType.GetSelectEntryPos());
-                maFtCondition.SetText(maCondText);
-                maFtCondition.Show();
-                maLbType.Hide();
-                HideCondElements();
-                HideColorScaleElements();
-                HideDataBarElements();
-            }
-            break;
-        default:
-            meType = eType;
-            maLbType.Show();
-            maFtCondition.SetText(rtl::OUString(""));
-            maFtCondition.Hide();
-            maLbType.Show();
-            break;
-    }
-}
-
-void ScCondFrmtEntry::SetIndex(sal_Int32 nIndex)
-{
-    mnIndex = nIndex;
-    rtl::OUStringBuffer aBuffer(maStrCondition);
-    aBuffer.append(rtl::OUString::valueOf(nIndex));
-    maFtCondNr.SetText(aBuffer.makeStringAndClear());
-}
-
-void ScCondFrmtEntry::HideCondElements()
-{
-    maEdVal1.Hide();
-    maEdVal2.Hide();
-    maLbStyle.Hide();
-    maFtStyle.Hide();
-    maLbCondType.Hide();
-    maWdPreview.Hide();
-}
-
-void ScCondFrmtEntry::SetCondType()
-{
-    maEdVal1.SetSizePixel(maEdVal2.GetSizePixel());
-    Point aPoint(maLbCondType.GetPosPixel().X() + maLbCondType.GetSizePixel().Width() + LogicToPixel(Size(5,1), MapMode(MAP_APPFONT)).getWidth(),
-            maEdVal1.GetPosPixel().Y());
-    maEdVal1.SetPosPixel(aPoint);
-    maEdVal1.Show();
-    maEdVal2.Show();
-    maLbStyle.Show();
-    maLbCondType.Show();
-    maFtStyle.Show();
-    maWdPreview.Show();
-    HideColorScaleElements();
-    HideDataBarElements();
-    SwitchToType(CONDITION);
-    ConditionTypeSelectHdl(NULL);
-}
-
-void ScCondFrmtEntry::HideColorScaleElements()
-{
-    maLbColorFormat.Hide();
-    maLbColScale2.Hide();
-    maLbColScale3.Hide();
-    maLbEntryTypeMin.Hide();
-    maLbEntryTypeMiddle.Hide();
-    maLbEntryTypeMax.Hide();
-    maEdMin.Hide();
-    maEdMiddle.Hide();
-    maEdMax.Hide();
-    maLbColMin.Hide();
-    maLbColMiddle.Hide();
-    maLbColMax.Hide();
-}
-
-void ScCondFrmtEntry::SetHeight()
-{
-    long nPad = LogicToPixel(Size(42,2), MapMode(MAP_APPFONT)).getHeight();
-
-    // Calculate maximum height we need from visible widgets
-    sal_uInt16 nChildren = GetChildCount();
-
-    long nMaxHeight = 0;
-    for(sal_uInt16 i = 0; i < nChildren; i++)
-    {
-        Window *pChild  = GetChild(i);
-        if(!pChild || !pChild->IsVisible())
-            continue;
-        Point aPos = pChild->GetPosPixel();
-        Size aSize = pChild->GetSizePixel();
-        nMaxHeight = std::max(aPos.Y() + aSize.Height(), nMaxHeight);
-    }
-    Size aSize = GetSizePixel();
-    if(nMaxHeight > 0)
-    {
-        aSize.Height() = nMaxHeight + nPad;
-        SetSizePixel(aSize);
-    }
-}
-
-void ScCondFrmtEntry::SetColorScaleType()
-{
-    HideCondElements();
-    HideDataBarElements();
-    maLbColorFormat.Show();
-    if(maLbColorFormat.GetSelectEntryPos() == 0)
-    {
-        maEdMiddle.Hide();
-        maLbEntryTypeMiddle.Hide();
-        // TODO: enale for 3.7 again with good presets
-        //maLbColScale2.Show();
-        maLbColScale3.Hide();
-        maLbColMiddle.Hide();
-    }
-    else
-    {
-        maEdMiddle.Show();
-        maLbEntryTypeMiddle.Show();
-        maLbColScale2.Hide();
-        // TODO: enale for 3.7 again with good presets
-        // maLbColScale3.Show();
-        maLbColMiddle.Show();
-    }
-    maLbEntryTypeMin.Show();
-    maLbEntryTypeMax.Show();
-    maEdMin.Show();
-    maEdMax.Show();
-    maLbColMin.Show();
-    maLbColMax.Show();
-    SwitchToType(COLORSCALE);
-}
-
-void ScCondFrmtEntry::HideDataBarElements()
-{
-    maLbColorFormat.Hide();
-    maLbDataBarMinType.Hide();
-    maLbDataBarMaxType.Hide();
-    maEdDataBarMin.Hide();
-    maEdDataBarMax.Hide();
-    maBtOptions.Hide();
-}
-
-void ScCondFrmtEntry::SetDataBarType()
-{
-    SwitchToType(DATABAR);
-    HideCondElements();
-    HideColorScaleElements();
-    maLbColorFormat.Show();
-    maLbDataBarMinType.Show();
-    maLbDataBarMaxType.Show();
-    maEdDataBarMin.Show();
-    maEdDataBarMax.Show();
-    maBtOptions.Show();
-}
-
-void ScCondFrmtEntry::SetFormulaType()
-{
-    SwitchToType(FORMULA);
-    HideColorScaleElements();
-    HideDataBarElements();
-    maEdVal1.SetPosPixel(maLbCondType.GetPosPixel());
-    Size aSize(maEdVal2.GetPosPixel().X() + maEdVal2.GetSizePixel().Width() - maLbCondType.GetPosPixel().X(), maEdVal1.GetSizePixel().Height());
-    maEdVal1.SetPosPixel(maLbCondType.GetPosPixel());
-    maEdVal1.SetSizePixel(aSize);
-    maEdVal1.Show();
-    maEdVal2.Hide();
-    maLbCondType.Hide();
-    maLbStyle.Show();
-    maFtCondition.Show();
-    maWdPreview.Show();
-    maFtStyle.Show();
-}
-
-void ScCondFrmtEntry::Select()
-{
-    SetControlForeground(Color(COL_RED));
-    switch(meType)
-    {
-        case CONDITION:
-            SetCondType();
-            break;
-        case COLORSCALE:
-            SetColorScaleType();
-            break;
-        case DATABAR:
-            SetDataBarType();
-            break;
-        case FORMULA:
-            SetFormulaType();
-            break;
-        default:
-            //should not happen
-            break;
-    }
-    SwitchToType(meType);
-    mbActive = true;
-    SetHeight();
-}
-
-void ScCondFrmtEntry::SetType( ScCondFormatEntryType eType )
-{
-    meType = eType;
-    if(eType == DATABAR)
-        maLbColorFormat.SelectEntryPos(2);
-    Select();
-}
-
-void ScCondFrmtEntry::Deselect()
-{
-    SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
-    SwitchToType(COLLAPSED);
-    mbActive = false;
-    SetHeight();
-}
-
-bool ScCondFrmtEntry::IsSelected() const
-{
-    return mbActive;
-}
-
-ScFormatEntry* ScCondFrmtEntry::createConditionEntry() const
-{
-    ScConditionMode eMode;
-    rtl::OUString aExpr2;
-    switch(maLbCondType.GetSelectEntryPos())
-    {
-        case 0:
-            eMode = SC_COND_EQUAL;
-            break;
-        case 1:
-            eMode = SC_COND_LESS;
-            break;
-        case 2:
-            eMode = SC_COND_GREATER;
-            break;
-        case 3:
-            eMode = SC_COND_EQLESS;
-            break;
-        case 4:
-            eMode = SC_COND_EQGREATER;
-            break;
-        case 5:
-            eMode = SC_COND_NOTEQUAL;
-            break;
-        case 6:
-            aExpr2 = maEdVal2.GetText();
-            eMode = SC_COND_BETWEEN;
-            if(aExpr2.isEmpty())
-                return NULL;
-            break;
-        case 7:
-            eMode = SC_COND_NOTBETWEEN;
-            aExpr2 = maEdVal2.GetText();
-            if(aExpr2.isEmpty())
-                return NULL;
-            break;
-        case 8:
-            eMode = SC_COND_DUPLICATE;
-            break;
-        case 9:
-            eMode = SC_COND_NOTDUPLICATE;
-            break;
-        default:
-            assert(false); // this cannot happen
-            return NULL;
-    }
-
-    rtl::OUString aExpr1 = maEdVal1.GetText();
-
-    ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry());
-
-    return pEntry;
-}
-
-namespace {
-
-void SetColorScaleEntry( ScColorScaleEntry* pEntry, const ListBox& rType, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos )
-{
-    sal_uInt32 nIndex = 0;
-    double nVal = 0;
-    SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
-    pNumberFormatter->IsNumberFormat(rValue.GetText(), nIndex, nVal);
-    switch(rType.GetSelectEntryPos())
-    {
-        case 0:
-            pEntry->SetType(COLORSCALE_MIN);
-            break;
-        case 1:
-            pEntry->SetType(COLORSCALE_MAX);
-            break;
-        case 2:
-            pEntry->SetType(COLORSCALE_PERCENTILE);
-            pEntry->SetValue(nVal);
-            break;
-        case 3:
-            pEntry->SetType(COLORSCALE_VALUE);
-            pEntry->SetValue(nVal);
-            break;
-        case 4:
-            pEntry->SetType(COLORSCALE_PERCENT);
-            pEntry->SetValue(nVal);
-            break;
-        case 5:
-            pEntry->SetType(COLORSCALE_FORMULA);
-            pEntry->SetFormula(rValue.GetText(), pDoc, rPos);
-            break;
-        case 6:
-            pEntry->SetType(COLORSCALE_AUTOMIN);
-            break;
-        case 7:
-            pEntry->SetType(COLORSCALE_AUTOMAX);
-            break;
-        default:
-            break;
-    }
-}
-
-ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListBox& rColor, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos )
-{
-    ScColorScaleEntry* pEntry = new ScColorScaleEntry();
-
-    SetColorScaleEntry( pEntry, rType, rValue, pDoc, rPos );
-    Color aColor = rColor.GetSelectEntryColor();
-    pEntry->SetColor(aColor);
-    return pEntry;
-}
-
-}
-
-ScFormatEntry* ScCondFrmtEntry::createColorscaleEntry() const
-{
-    ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
-    pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMin, maLbColMin, maEdMin, mpDoc, maPos));
-    if(maLbColorFormat.GetSelectEntryPos() == 1)
-        pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMiddle, maLbColMiddle, maEdMiddle, mpDoc, maPos));
-    pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMax, maLbColMax, maEdMax, mpDoc, maPos));
-    return pColorScale;
-}
-
-ScFormatEntry* ScCondFrmtEntry::createDatabarEntry() const
-{
-    SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), maLbDataBarMinType, maEdDataBarMin, mpDoc, maPos);
-    SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), maLbDataBarMaxType, maEdDataBarMax, mpDoc, maPos);
-    ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc);
-    pDataBar->SetDataBarData(new ScDataBarFormatData(*mpDataBarData.get()));
-    return pDataBar;
-}
-
-ScFormatEntry* ScCondFrmtEntry::createFormulaEntry() const
-{
-    ScConditionMode eMode = SC_COND_DIRECT;
-    rtl::OUString aFormula = maEdVal1.GetText();
-    if(aFormula.isEmpty())
-        return NULL;
-
-    rtl::OUString aExpr2;
-    ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aFormula, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry());
-    return pEntry;
-}
-
-ScFormatEntry* ScCondFrmtEntry::GetEntry() const
-{
-    switch(meType)
-    {
-        case CONDITION:
-            return createConditionEntry();
-            break;
-        case COLORSCALE:
-            return createColorscaleEntry();
-            break;
-        case DATABAR:
-            return createDatabarEntry();
-            break;
-        case FORMULA:
-            return createFormulaEntry();
-            break;
-        default:
-            break;
-    }
-    return NULL;
-}
-
-IMPL_LINK_NOARG(ScCondFrmtEntry, TypeListHdl)
-{
-    sal_Int32 nPos = maLbType.GetSelectEntryPos();
-    switch(nPos)
-    {
-        case 1:
-            SetCondType();
-            break;
-        case 0:
-            if(maLbColorFormat.GetSelectEntryPos() < 2)
-                SetColorScaleType();
-            else
-                SetDataBarType();
-            break;
-        case 2:
-            SetFormulaType();
-            break;
-        default:
-            break;
-    }
-    SetHeight();
-    return 0;
-}
-
-IMPL_LINK(ScCondFrmtEntry, EdModifyHdl, Edit*, pEdit)
-{
-    rtl::OUString aFormula = pEdit->GetText();
-    ScCompiler aComp( mpDoc, maPos );
-    aComp.SetGrammar( mpDoc->GetGrammar() );
-    boost::scoped_ptr<ScTokenArray> mpCode(aComp.CompileString(aFormula));
-    if(mpCode->GetCodeError())
-    {
-        pEdit->SetControlBackground(COL_LIGHTRED);
-    }
-    else
-    {
-        pEdit->SetControlBackground(GetSettings().GetStyleSettings().GetWindowColor());
-    }
-    return 0;
-}
-
-IMPL_LINK_NOARG(ScCondFrmtEntry, ColFormatTypeHdl)
-{
-    if(maLbColorFormat.GetSelectEntryPos() < 2)
-    {
-        SetColorScaleType();
-    }
-    else
-    {
-        SetDataBarType();
-    }
-
-    SetHeight();
-
-    return 0;
-}
-
-IMPL_LINK( ScCondFrmtEntry, EntryTypeHdl, ListBox*, pBox )
-{
-    bool bEnableEdit = true;
-    sal_Int32 nPos = pBox->GetSelectEntryPos();
-    if(nPos == 0 || nPos == 1)
-    {
-        bEnableEdit = false;
-    }
-
-    Edit* pEd = NULL;
-    if(pBox == &maLbEntryTypeMin)
-        pEd = &maEdMin;
-    else if(pBox == &maLbEntryTypeMiddle)
-        pEd = &maEdMiddle;
-    else if(pBox == &maLbEntryTypeMax)
-        pEd = &maEdMax;
-
-    if(bEnableEdit)
-        pEd->Enable();
-    else
-        pEd->Disable();
-
-    return 0;
-}
-
-IMPL_LINK_NOARG(ScCondFrmtEntry, StyleSelectHdl)
-{
-    if(maLbStyle.GetSelectEntryPos() == 0)
-    {
-        // call new style dialog
-        SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA );
-        SfxStringItem aRefItem( SID_STYLE_REFERENCE, ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
-
-        // unlock the dispatcher so SID_STYLE_NEW can be executed
-        // (SetDispatcherLock would affect all Calc documents)
-        ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
-        SfxDispatcher* pDisp = pViewShell->GetDispatcher();
-        sal_Bool bLocked = pDisp->IsLocked();
-        if (bLocked)
-            pDisp->Lock(false);
-
-        // Execute the "new style" slot, complete with undo and all necessary updates.
-        // The return value (SfxUInt16Item) is ignored, look for new styles instead.
-        pDisp->Execute( SID_STYLE_NEW, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL,
-                &aFamilyItem,
-                &aRefItem,
-                0L );
-
-        if (bLocked)
-            pDisp->Lock(sal_True);
-
-        // Find the new style and add it into the style list boxes
-        rtl::OUString aNewStyle;
-        SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
-        for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
-        {
-            rtl::OUString aName = pStyle->GetName();
-            if ( maLbStyle.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND )    // all lists contain the same entries
-            {
-                maLbStyle.InsertEntry(aName);
-                maLbStyle.SelectEntry(aName);
-            }
-        }
-    }
-
-    rtl::OUString aStyleName = maLbStyle.GetSelectEntry();
-    SfxStyleSheetBase* pStyleSheet = mpDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
-    if(pStyleSheet)
-    {
-        const SfxItemSet& rSet = pStyleSheet->GetItemSet();
-        maWdPreview.Init( rSet );
-    }
-
-    return 0;
-}
-
-IMPL_LINK_NOARG( ScCondFrmtEntry, DataBarTypeSelectHdl )
-{
-    sal_Int32 nSelectPos = maLbDataBarMinType.GetSelectEntryPos();
-    if(nSelectPos == 0 || nSelectPos == 1)
-        maEdDataBarMin.Disable();
-    else
-        maEdDataBarMin.Enable();
-
-    nSelectPos = maLbDataBarMaxType.GetSelectEntryPos();
-    if(nSelectPos == 0 || nSelectPos == 1)
-        maEdDataBarMax.Disable();
-    else
-        maEdDataBarMax.Enable();
-
-    return 0;
-}
-
-IMPL_LINK_NOARG( ScCondFrmtEntry, OptionBtnHdl )
-{
-    SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), maLbDataBarMinType, maEdDataBarMin, mpDoc, maPos);
-    SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), maLbDataBarMaxType, maEdDataBarMax, mpDoc, maPos);
-    ScDataBarSettingsDlg* pDlg = new ScDataBarSettingsDlg(this, *mpDataBarData, mpDoc);
-    if( pDlg->Execute() == RET_OK)
-    {
-        mpDataBarData.reset(pDlg->GetData());
-        SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, maLbDataBarMinType, maEdDataBarMin);
-        SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, maLbDataBarMaxType, maEdDataBarMax);
-        DataBarTypeSelectHdl(NULL);
-    }
-    return 0;
-}
-
-IMPL_LINK_NOARG( ScCondFrmtEntry, ConditionTypeSelectHdl )
-{
-    if(maLbCondType.GetSelectEntryPos() == 6 || maLbCondType.GetSelectEntryPos() == 7)
-    {
-        maEdVal2.Show();
-    }
-    else
-    {
-        maEdVal2.Hide();
-    }
-
-    return 0;
-}
-
 ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc, const ScConditionalFormat* pFormat,
                                 const ScRangeList& rRanges, const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType):
     Control(pParent, rResId),
@@ -1013,7 +71,7 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
         size_t nCount = pFormat->size();
         for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
         {
-            maEntries.push_back(new ScCondFrmtEntry( this, mpDoc, pFormat->GetEntry(nIndex), maPos ));
+            maEntries.push_back(new ScConditionFrmtEntry( this, mpDoc, maPos, static_cast<const ScCondFormatEntry*>(pFormat->GetEntry(nIndex) ) ) );
         }
     }
     else
@@ -1021,15 +79,13 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
         switch(eType)
         {
             case condformat::dialog::CONDITION:
-                maEntries.push_back(new ScCondFrmtEntry( this, mpDoc, maPos ));
+                maEntries.push_back(new ScConditionFrmtEntry( this, mpDoc, maPos ));
                 break;
             case condformat::dialog::COLORSCALE:
-                maEntries.push_back(new ScCondFrmtEntry( this, mpDoc, maPos ));
-                maEntries[0].SetType(COLORSCALE);
+                maEntries.push_back(new ScColorScaleFrmtEntry( this, mpDoc, maPos ));
                 break;
             case condformat::dialog::DATABAR:
-                maEntries.push_back(new ScCondFrmtEntry( this, mpDoc, maPos ));
-                maEntries[0].SetType(DATABAR);
+                maEntries.push_back(new ScDataBarFrmtEntry( this, mpDoc, maPos ));
                 break;
             default:
                 break;
@@ -1112,6 +168,70 @@ void ScCondFormatList::DoScroll(long nDelta)
     mpScrollBar->SetPosPixel(aNewPoint);
 }
 
+IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox*, pBox)
+{
+    RecalcAll();
+    return 0;
+}
+
+IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox)
+{
+    sal_Int32 nPos = pBox->GetSelectEntryPos();
+    switch(nPos)
+    {
+    }
+    RecalcAll();
+    return 0;
+}
+
+IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl )
+{
+    ScCondFrmtEntry* pNewEntry = new ScConditionFrmtEntry(this, mpDoc, maPos);
+    maEntries.push_back( pNewEntry );
+    for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
+    {
+        itr->Deselect();
+    }
+    pNewEntry->Select();
+    RecalcAll();
+    return 0;
+}
+
+IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl )
+{
+    for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
+    {
+        if(itr->IsSelected())
+        {
+            maEntries.erase(itr);
+            break;
+        }
+    }
+    RecalcAll();
+    return 0;
+}
+
+IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry*, pEntry )
+{
+    for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
+    {
+        itr->Deselect();
+    }
+    pEntry->Select();
+    RecalcAll();
+    return 0;
+}
+
+IMPL_LINK_NOARG( ScCondFormatList, ScrollHdl )
+{
+    DoScroll(mpScrollBar->GetDelta());
+    return 0;
+}
+
+//---------------------------------------------------
+//ScCondFormatDlg
+//---------------------------------------------------
+
 ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange,
                                     const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType):
     ScAnyRefDlg(pB, pCW, pParent, RID_SCDLG_CONDFORMAT ),
@@ -1195,50 +315,6 @@ ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const
     return pFormat;
 }
 
-IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl )
-{
-    ScCondFrmtEntry* pNewEntry = new ScCondFrmtEntry(this, mpDoc, maPos);
-    maEntries.push_back( pNewEntry );
-    for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
-    {
-        itr->Deselect();
-    }
-    pNewEntry->Select();
-    RecalcAll();
-    return 0;
-}
-
-IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl )
-{
-    for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
-    {
-        if(itr->IsSelected())
-        {
-            maEntries.erase(itr);
-            break;
-        }
-    }
-    RecalcAll();
-    return 0;
-}
-
-IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry*, pEntry )
-{
-    for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
-    {
-        itr->Deselect();
-    }
-    pEntry->Select();
-    RecalcAll();
-    return 0;
-}
-
-IMPL_LINK_NOARG( ScCondFormatList, ScrollHdl )
-{
-    DoScroll(mpScrollBar->GetDelta());
-    return 0;
-}
-
 IMPL_LINK( ScCondFormatDlg, EdRangeModifyHdl, Edit*, pEdit )
 {
     rtl::OUString aRangeStr = pEdit->GetText();
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
new file mode 100644
index 0000000..63dfcec
--- /dev/null
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -0,0 +1,737 @@
+#include "condformatdlg.hxx"
+#include "condformatdlgentry.hxx"
+#include "condformatdlg.hrc"
+
+#include "document.hxx"
+
+#include <vcl/vclevent.hxx>
+#include <svl/style.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
+#include <svx/xtable.hxx>
+#include <svx/drawitem.hxx>
+#include <vcl/msgbox.hxx>
+#include "stlpool.hxx"
+#include "tabvwsh.hxx"
+
+#include "colorformat.hxx"
+
+#include "globstr.hrc"
+
+ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScAddress& rPos):
+    Control(pParent, ScResId( RID_COND_ENTRY ) ),
+    mbActive(false),
+    maLbType( this, ScResId( LB_TYPE ) ),
+    maFtCondNr( this, ScResId( FT_COND_NR ) ),
+    maFtCondition( this, ScResId( FT_CONDITION ) ),
+    mnIndex(0),
+    maStrCondition(ScResId( STR_CONDITION ).toString()),
+    mpDoc(pDoc),
+    maPos(rPos)
+{
+    SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
+    FreeResource();
+
+    /*
+    maLbType.SelectEntryPos(1);
+    maLbCondType.SelectEntryPos(0);
+    maEdVal2.Hide();
+    */
+    //disable entries for color formats
+
+    Init();
+    maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
+    SetHeight();
+}
+
+ScCondFrmtEntry::~ScCondFrmtEntry()
+{
+}
+
+void ScCondFrmtEntry::Init()
+{
+    maLbType.SetSelectHdl( LINK( this, ScCondFormatList, TypeListHdl ) );
+    /*
+    maLbColorFormat.SetSelectHdl( LINK( this, ScCondFormatList, ColFormatTypeHdl ) );
+
+    */
+}
+
+long ScCondFrmtEntry::Notify( NotifyEvent& rNEvt )
+{
+    if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
+    {
+        ImplCallEventListenersAndHandler( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, maClickHdl, this );
+    }
+    return Control::Notify(rNEvt);
+}
+
+void ScCondFrmtEntry::SetIndex(sal_Int32 nIndex)
+{
+    mnIndex = nIndex;
+    rtl::OUStringBuffer aBuffer(maStrCondition);
+    aBuffer.append(rtl::OUString::valueOf(nIndex));
+    maFtCondNr.SetText(aBuffer.makeStringAndClear());
+}
+
+void ScCondFrmtEntry::SetHeight()
+{
+    long nPad = LogicToPixel(Size(42,2), MapMode(MAP_APPFONT)).getHeight();
+
+    // Calculate maximum height we need from visible widgets
+    sal_uInt16 nChildren = GetChildCount();
+
+    long nMaxHeight = 0;
+    for(sal_uInt16 i = 0; i < nChildren; i++)
+    {
+        Window *pChild  = GetChild(i);
+        if(!pChild || !pChild->IsVisible())
+            continue;
+        Point aPos = pChild->GetPosPixel();
+        Size aSize = pChild->GetSizePixel();
+        nMaxHeight = std::max(aPos.Y() + aSize.Height(), nMaxHeight);
+    }
+    Size aSize = GetSizePixel();
+    if(nMaxHeight > 0)
+    {
+        aSize.Height() = nMaxHeight + nPad;
+        SetSizePixel(aSize);
+    }
+}
+
+
+void ScCondFrmtEntry::Select()
+{
+    mbActive = true;
+    SetHeight();
+}
+
+void ScCondFrmtEntry::Deselect()
+{
+    mbActive = false;
+    SetHeight();
+}
+
+bool ScCondFrmtEntry::IsSelected() const
+{
+    return mbActive;
+}
+
+IMPL_LINK(ScCondFrmtEntry, EdModifyHdl, Edit*, pEdit)
+{
+    rtl::OUString aFormula = pEdit->GetText();
+    ScCompiler aComp( mpDoc, maPos );
+    aComp.SetGrammar( mpDoc->GetGrammar() );
+    boost::scoped_ptr<ScTokenArray> mpCode(aComp.CompileString(aFormula));
+    if(mpCode->GetCodeError())
+    {
+        pEdit->SetControlBackground(COL_LIGHTRED);
+    }
+    else
+    {
+        pEdit->SetControlBackground(GetSettings().GetStyleSettings().GetWindowColor());
+    }
+    return 0;
+}
+
+//
+//condition
+
+ScFormatEntry* ScConditionFrmtEntry::createFormulaEntry() const
+{
+    ScConditionMode eMode = SC_COND_DIRECT;
+    rtl::OUString aFormula = maEdVal1.GetText();
+    if(aFormula.isEmpty())
+        return NULL;
+
+    rtl::OUString aExpr2;
+    ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aFormula, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry());
+    return pEntry;
+}
+
+ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry ):
+    ScCondFrmtEntry( pParent, pDoc, rPos ),
+    maLbCondType( this, ScResId( LB_CELLIS_TYPE ) ),
+    maEdVal1( this, ScResId( ED_VAL1 ) ),
+    maEdVal2( this, ScResId( ED_VAL2 ) ),
+    maFtStyle( this, ScResId( FT_STYLE ) ),
+    maLbStyle( this, ScResId( LB_STYLE ) ),
+    maWdPreview( this, ScResId( WD_PREVIEW ) )
+{
+    if(pFormatEntry)
+    {
+        rtl::OUString aStyleName = pFormatEntry->GetStyle();
+        maLbStyle.SelectEntry(aStyleName);
+        StyleSelectHdl(NULL);
+        ScConditionMode eMode = pFormatEntry->GetOperation();
+        maEdVal1.SetText(pFormatEntry->GetExpression(maPos, 0));
+        switch(eMode)
+        {
+            case SC_COND_EQUAL:
+                maLbCondType.SelectEntryPos(0);
+                break;
+            case SC_COND_LESS:
+                maLbCondType.SelectEntryPos(1);
+                break;
+            case SC_COND_GREATER:
+                maLbCondType.SelectEntryPos(2);
+                break;
+            case SC_COND_EQLESS:
+                maLbCondType.SelectEntryPos(3);
+                break;
+            case SC_COND_EQGREATER:
+                maLbCondType.SelectEntryPos(4);
+                break;
+            case SC_COND_NOTEQUAL:
+                maLbCondType.SelectEntryPos(5);
+                break;
+            case SC_COND_BETWEEN:
+                maEdVal2.SetText(pFormatEntry->GetExpression(maPos, 1));
+                maLbCondType.SelectEntryPos(6);
+                break;
+            case SC_COND_NOTBETWEEN:
+                maEdVal2.SetText(pFormatEntry->GetExpression(maPos, 1));
+                maLbCondType.SelectEntryPos(7);
+                break;
+            case SC_COND_DUPLICATE:
+                maLbCondType.SelectEntryPos(8);
+                break;
+            case SC_COND_NOTDUPLICATE:
+                maLbCondType.SelectEntryPos(9);
+                break;
+            case SC_COND_DIRECT:
+                //maLbType.SelectEntryPos(2);
+                break;
+            case SC_COND_NONE:
+                break;
+        }
+    }
+    else
+    {
+        maLbStyle.SelectEntryPos(1);
+    }
+
+}
+
+void ScConditionFrmtEntry::Init()
+{
+    maLbStyle.SetSeparatorPos(0);
+
+    maEdVal1.SetStyle( maEdVal1.GetStyle() | WB_FORCECTRLBACKGROUND );
+    maEdVal2.SetStyle( maEdVal2.GetStyle() | WB_FORCECTRLBACKGROUND );
+
+    maEdVal1.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) );
+    maEdVal2.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) );
+

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list