summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-06-08 05:10:33 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-06-11 08:01:25 +0200
commit76f5ca40207448dfb5a7c87ba2c27076e024a50f (patch)
treee7eedc3d82a247581d87d0f160bafca34b623d42 /sc
parentc41ee0d526c6d105d53cace1c81e43a9cc519c2d (diff)
use the result of the dialog and apply it to the document
Change-Id: I01dd992ccd3ddd6b8fc61ce0549ec71b5ff257c0
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/colorscale.hxx5
-rw-r--r--sc/inc/conditio.hxx2
-rw-r--r--sc/inc/scabstdlg.hxx7
-rw-r--r--sc/source/core/data/colorscale.cxx25
-rw-r--r--sc/source/core/data/conditio.cxx15
-rw-r--r--sc/source/core/data/documen4.cxx3
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx12
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx6
-rw-r--r--sc/source/ui/condformat/condformatdlg.cxx296
-rw-r--r--sc/source/ui/inc/condformatdlg.hrc1
-rw-r--r--sc/source/ui/inc/condformatdlg.hxx24
-rw-r--r--sc/source/ui/src/condformatdlg.src8
-rw-r--r--sc/source/ui/view/cellsh1.cxx26
13 files changed, 382 insertions, 48 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index fd2322b6fafc..56e653e211ca 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -55,12 +55,15 @@ private:
bool mbPercentile;
public:
ScColorScaleEntry(double nVal, const Color& rCol);
+ ScColorScaleEntry();
ScColorScaleEntry(const ScColorScaleEntry& rEntry);
ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry& rEntry);
~ScColorScaleEntry();
const Color& GetColor() const;
+ void SetColor(const Color&);
double GetValue() const;
+ void SetValue(double nValue);
void SetFormula(const rtl::OUString& rFormula, ScDocument* pDoc, const ScAddress& rAddr, formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT);
void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab, SCTAB nTabNo);
void UpdateReference( UpdateRefMode eUpdateRefMode,
@@ -208,6 +211,8 @@ public:
const_iterator begin() const;
iterator end();
const_iterator end() const;
+
+ size_t size() const;
};
class SC_DLLPUBLIC ScDataBarFormat : public ScColorFormat
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 70c182f74508..73e6ece6eda1 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -255,7 +255,6 @@ protected:
class SC_DLLPUBLIC ScConditionalFormat
{
ScDocument* pDoc;
- ScRangeList* pAreas; // area for Paint
sal_uInt32 nKey; // Index in attributes
typedef boost::ptr_vector<ScFormatEntry> CondFormatContainer;
@@ -296,7 +295,6 @@ public:
bool EqualEntries( const ScConditionalFormat& r ) const;
void DoRepaint( const ScRange* pModified );
- void InvalidateArea();
sal_uInt32 GetKey() const { return nKey; }
void SetKey(sal_uInt32 nNew) { nKey = nNew; } // only if not inserted!
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index f91be6650197..496ab89cec59 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -57,6 +57,7 @@ class ScDPObject;
struct ScDPFuncData;
struct ScDPNumGroupInfo;
class ScTabViewShell;
+class ScConditionalFormat;
namespace com { namespace sun { namespace star { namespace sheet {
struct DataPilotFieldReference;
@@ -87,6 +88,8 @@ public:
class AbstractScCondFormatDlg : public VclAbstractDialog
{
+public:
+ virtual ScConditionalFormat* GetConditionalFormat() = 0;
};
class AbstractScDataBarSettingsDlg : public VclAbstractDialog
@@ -356,8 +359,8 @@ public:
sal_Bool bColDefault = sal_True ) = 0;
virtual VclAbstractDialog * CreateScSortWarningDlg ( Window* pParent, const String& rExtendText, const String& rCurrentText, int nId ) = 0; //add for ScSortWarningDlg
- virtual AbstractScCondFormatDlg* CreateScCondFormatDlg (Window* pParent, ScDocument* pDoc, ScConditionalFormat* pFormat,
- const ScRangeList& rList, int nId ) = 0; //add for ScCondFormatDlg
+ virtual AbstractScCondFormatDlg* CreateScCondFormatDlg (Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat,
+ const ScRangeList& rList, const ScAddress& rPos, int nId ) = 0; //add for ScCondFormatDlg
virtual AbstractScDataBarSettingsDlg* CreateScDataBarSetttingsDlg (Window* pParent ,int nId ) = 0; //add for ScDataBarSettingsDlg
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index e16cc228deaf..e6a5c8ddefa5 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -31,6 +31,16 @@
#include "cell.hxx"
#include "fillinfo.hxx"
+ScColorScaleEntry::ScColorScaleEntry():
+ mnVal(0),
+ mpCell(NULL),
+ mbMin(false),
+ mbMax(false),
+ mbPercent(false),
+ mbPercentile(false)
+{
+}
+
ScColorScaleEntry::ScColorScaleEntry(double nVal, const Color& rCol):
mnVal(nVal),
maColor(rCol),
@@ -113,6 +123,11 @@ double ScColorScaleEntry::GetValue() const
return mnVal;
}
+void ScColorScaleEntry::SetValue(double nValue)
+{
+ mnVal = nValue;
+}
+
void ScColorScaleEntry::UpdateMoveTab( SCTAB nOldTab, SCTAB nNewTab, SCTAB nTabNo )
{
if(mpCell)
@@ -135,6 +150,11 @@ const Color& ScColorScaleEntry::GetColor() const
return maColor;
}
+void ScColorScaleEntry::SetColor(const Color& rColor)
+{
+ maColor = rColor;
+}
+
ScColorFormat::ScColorFormat(ScDocument* pDoc):
ScFormatEntry(pDoc)
{
@@ -585,6 +605,11 @@ ScColorScaleFormat::const_iterator ScColorScaleFormat::end() const
return maColorScales.end();
}
+size_t ScColorScaleFormat::size() const
+{
+ return maColorScales.size();
+}
+
ScDataBarFormat::ScDataBarFormat(ScDocument* pDoc):
ScColorFormat(pDoc)
{
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index a270e30fa846..77b1540ca499 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1309,14 +1309,12 @@ ScFormatEntry* ScCondFormatEntry::Clone( ScDocument* pDoc ) const
ScConditionalFormat::ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument) :
pDoc( pDocument ),
- pAreas( NULL ),
nKey( nNewKey )
{
}
ScConditionalFormat::ScConditionalFormat(const ScConditionalFormat& r) :
pDoc( r.pDoc ),
- pAreas( NULL ),
nKey( r.nKey ),
maRanges( r.maRanges )
{
@@ -1377,7 +1375,6 @@ void ScConditionalFormat::AddEntry( ScFormatEntry* pNew )
ScConditionalFormat::~ScConditionalFormat()
{
- delete pAreas;
}
const ScFormatEntry* ScConditionalFormat::GetEntry( sal_uInt16 nPos ) const
@@ -1572,12 +1569,6 @@ void ScConditionalFormat::DoRepaint( const ScRange* pModified )
*/
}
-void ScConditionalFormat::InvalidateArea()
-{
- delete pAreas;
- pAreas = NULL;
-}
-
void ScConditionalFormat::CompileAll()
{
for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
@@ -1598,9 +1589,6 @@ void ScConditionalFormat::UpdateReference( UpdateRefMode eUpdateRefMode,
maRanges.UpdateReference( eUpdateRefMode, pDoc, rRange, nDx, nDy, nDz );
for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
itr->UpdateReference(eUpdateRefMode, rRange, nDx, nDy, nDz);
-
- delete pAreas; // aus dem AttrArray kommt beim Einfuegen/Loeschen kein Aufruf
- pAreas = NULL;
}
void ScConditionalFormat::RenameCellStyle(const String& rOld, const String& rNew)
@@ -1649,9 +1637,6 @@ void ScConditionalFormat::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos )
for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
itr->UpdateMoveTab( nOldPos, nNewPos );
-
- delete pAreas; // aus dem AttrArray kommt beim Einfuegen/Loeschen kein Aufruf
- pAreas = NULL;
}
void ScConditionalFormat::SourceChanged( const ScAddress& rAddr )
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 8ec16e0f66ca..52b9f8b29124 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -738,9 +738,6 @@ void ScDocument::ConditionalChanged( sal_uLong nKey, SCTAB nTab )
ScConditionalFormatList* pCondFormList = GetCondFormList(nTab);
if ( nKey && pCondFormList && !bIsClip && !bIsUndo ) // nKey==0 -> noop
{
- ScConditionalFormat* pForm = pCondFormList->GetFormat( nKey );
- if (pForm)
- pForm->InvalidateArea();
}
}
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 649e4d347142..ee142d37c70e 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -455,6 +455,12 @@ sal_uLong AbstractScLinkedAreaDlg_Impl::GetRefresh()
}
+ScConditionalFormat* AbstractScCondFormatDlg_Impl::GetConditionalFormat()
+{
+ return pDlg->GetConditionalFormat();
+}
+
+
long AbstractScMetricInputDlg_Impl::GetInputValue( FieldUnit eUnit ) const
@@ -770,14 +776,14 @@ VclAbstractDialog * ScAbstractDialogFactory_Impl::CreateScSortWarningDlg( Window
}
-AbstractScCondFormatDlg* ScAbstractDialogFactory_Impl::CreateScCondFormatDlg(Window* pParent, ScDocument* pDoc, ScConditionalFormat* pFormat,
- const ScRangeList& rRange, int nId)
+AbstractScCondFormatDlg* ScAbstractDialogFactory_Impl::CreateScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat,
+ const ScRangeList& rRange, const ScAddress& rPos, int nId)
{
ScCondFormatDlg* pDlg = NULL;
switch( nId )
{
case RID_SCDLG_CONDFORMAT:
- pDlg = new ScCondFormatDlg( pParent, pDoc, pFormat, rRange );
+ pDlg = new ScCondFormatDlg( pParent, pDoc, pFormat, rRange, rPos );
break;
default:
break;
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 04aa60537cb3..8667db490d75 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -142,6 +142,8 @@ class AbstractScColRowLabelDlg_Impl : public AbstractScColRowLabelDlg //add for
class AbstractScCondFormatDlg_Impl : public AbstractScCondFormatDlg
{
DECL_ABSTDLG_BASE(AbstractScCondFormatDlg_Impl, ScCondFormatDlg)
+
+ virtual ScConditionalFormat* GetConditionalFormat();
};
class AbstractScDataBarSettingsDlg_Impl : public AbstractScDataBarSettingsDlg
@@ -427,8 +429,8 @@ public:
virtual VclAbstractDialog * CreateScSortWarningDlg( Window* pParent, const String& rExtendText, const String& rCurrentText, int nId );
- virtual AbstractScCondFormatDlg* CreateScCondFormatDlg(Window* pParent, ScDocument* pDoc, ScConditionalFormat* pFormat,
- const ScRangeList& rRange, int nId ); //add for ScDataBarSettingsDlg
+ virtual AbstractScCondFormatDlg* CreateScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat,
+ const ScRangeList& rRange, const ScAddress& rPos, int nId ); //add for ScDataBarSettingsDlg
virtual AbstractScDataBarSettingsDlg* CreateScDataBarSetttingsDlg (Window* pParent ,int nId ); //add for ScDataBarSettingsDlg
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index eb3d34c45d64..8d2d634c38d5 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -34,6 +34,8 @@
#include <sfx2/dispatch.hxx>
#include <svl/stritem.hxx>
#include <svl/intitem.hxx>
+#include <svx/xtable.hxx>
+#include <svx/drawitem.hxx>
#include "anyrefdg.hxx"
#include "document.hxx"
@@ -41,11 +43,47 @@
#include "stlpool.hxx"
#include "tabvwsh.hxx"
#include "conditio.hxx"
+#include "colorscale.hxx"
+
+#include <rtl/math.hxx>
#include "globstr.hrc"
#include <iostream>
+namespace {
+
+void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit, ColorListBox& rLbCol )
+{
+ if(rEntry.GetMin())
+ rLbType.SelectEntryPos(0);
+ else if(rEntry.GetMax())
+ rLbType.SelectEntryPos(1);
+ else if(rEntry.GetPercentile())
+ {
+ rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+ rLbType.SelectEntryPos(2);
+ }
+ else if(rEntry.GetPercent())
+ {
+ rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+ rLbType.SelectEntryPos(4);
+ }
+ else if(rEntry.HasFormula())
+ {
+ rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
+ rLbType.SelectEntryPos(5);
+ }
+ else
+ {
+ rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+ rLbType.SelectEntryPos(3);
+ }
+ rLbCol.SelectEntry(rEntry.GetColor());
+}
+
+}
+
ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
Control(pParent, ScResId( RID_COND_ENTRY ) ),
mbActive(false),
@@ -68,6 +106,9 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
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) ),
mpDoc(pDoc)
{
SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
@@ -78,7 +119,6 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
maEdVal2.Hide();
maLbStyle.SetSeparatorPos(0);
- maLbStyle.SelectEntryPos(1);
//disable entries for color formats
maLbColorFormat.SelectEntryPos(0);
@@ -87,6 +127,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
maLbEntryTypeMax.SelectEntryPos(1);
Init();
+ maLbStyle.SelectEntryPos(1);
maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
SwitchToType(COLLAPSED);
SetHeight();
@@ -115,10 +156,14 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
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) ),
mpDoc(pDoc)
{
SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
FreeResource();
+ Init();
if(pFormatEntry && pFormatEntry->GetType() == condformat::CONDITION)
{
@@ -165,13 +210,39 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
case SC_COND_NONE:
break;
}
+ SwitchToType(CONDITION);
+ SetCondType();
+ }
+ 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);
+ maLbType.SelectEntryPos(0);
+ maLbColorFormat.SelectEntryPos(2);
+ SetDataBarType();
}
- Init();
maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
SwitchToType(COLLAPSED);
SetHeight();
- SetCondType();
}
void ScCondFrmtEntry::Init()
@@ -188,15 +259,58 @@ void ScCondFrmtEntry::Init()
Point aPointLb = maLbEntryTypeMiddle.GetPosPixel();
Point aPointEd = maEdMiddle.GetPosPixel();
+ Point aPointCol = maLbColMiddle.GetPosPixel();
const long nMovePos = 150;
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);
+
+ 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 );
+ }
}
namespace {
@@ -304,6 +418,9 @@ void ScCondFrmtEntry::HideColorScaleElements()
maEdMin.Hide();
maEdMiddle.Hide();
maEdMax.Hide();
+ maLbColMin.Hide();
+ maLbColMiddle.Hide();
+ maLbColMax.Hide();
}
void ScCondFrmtEntry::SetHeight()
@@ -314,15 +431,12 @@ void ScCondFrmtEntry::SetHeight()
switch (meType)
{
case CONDITION:
- std::cout << "CONDITION: set height 120" << std::endl;
aSize.Height() = 120;
break;
case COLORSCALE:
- std::cout << "set height 200" << std::endl;
aSize.Height() = 200;
break;
case DATABAR:
- std::cout << "DATABAR: set height 120" << std::endl;
aSize.Height() = 120;
break;
default:
@@ -332,7 +446,6 @@ void ScCondFrmtEntry::SetHeight()
}
else
{
- std::cout << "set height 40" << std::endl;
Size aSize = GetSizePixel();
aSize.Height() = 40;
SetSizePixel(aSize);
@@ -350,6 +463,7 @@ void ScCondFrmtEntry::SetColorScaleType()
maLbEntryTypeMiddle.Hide();
maLbColScale2.Show();
maLbColScale3.Hide();
+ maLbColMiddle.Hide();
}
else
{
@@ -357,11 +471,14 @@ void ScCondFrmtEntry::SetColorScaleType()
maLbEntryTypeMiddle.Show();
maLbColScale2.Hide();
maLbColScale3.Show();
+ maLbColMiddle.Show();
}
maLbEntryTypeMin.Show();
maLbEntryTypeMax.Show();
maEdMin.Show();
maEdMax.Show();
+ maLbColMin.Show();
+ maLbColMax.Show();
SwitchToType(COLORSCALE);
}
@@ -399,6 +516,132 @@ 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 = maEdVal1.GetText();
+ eMode = SC_COND_BETWEEN;
+ if(aExpr2.isEmpty())
+ return NULL;
+ break;
+ case 7:
+ eMode = SC_COND_NOTBETWEEN;
+ aExpr2 = maEdVal1.GetText();
+ if(aExpr2.isEmpty())
+ return NULL;
+ break;
+ case 8:
+ eMode = SC_COND_DUPLICATE;
+ break;
+ case 9:
+ eMode = SC_COND_NOTDUPLICATE;
+ break;
+ default:
+ break;
+ }
+
+ rtl::OUString aExpr1 = maEdVal1.GetText();
+
+ ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry());
+
+ return pEntry;
+}
+
+namespace {
+
+ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListBox& rColor, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos )
+{
+ ScColorScaleEntry* pEntry = new ScColorScaleEntry();
+ double nVal = rtl::math::stringToDouble(rValue.GetText(), '.', ',');
+ switch(rType.GetSelectEntryPos())
+ {
+ case 0:
+ pEntry->SetMin(true);
+ break;
+ case 1:
+ pEntry->SetMax(true);
+ break;
+ case 2:
+ pEntry->SetPercentile(true);
+ pEntry->SetValue(nVal);
+ break;
+ case 3:
+ pEntry->SetValue(nVal);
+ break;
+ case 4:
+ pEntry->SetPercent(true);
+ pEntry->SetValue(nVal);
+ break;
+ case 5:
+ pEntry->SetFormula(rValue.GetText(), pDoc, rPos);
+ break;
+ }
+
+ 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
+{
+ ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc);
+ pDataBar->SetDataBarData(new ScDataBarFormatData());
+ return pDataBar;
+}
+
+ScFormatEntry* ScCondFrmtEntry::GetEntry() const
+{
+ switch(meType)
+ {
+ case CONDITION:
+ return createConditionEntry();
+ break;
+ case COLORSCALE:
+ return createColorscaleEntry();
+ break;
+ case DATABAR:
+ return createDatabarEntry();
+ break;
+ default:
+ break;
+ }
+ return NULL;
+}
+
IMPL_LINK_NOARG(ScCondFrmtEntry, TypeListHdl)
{
sal_Int32 nPos = maLbType.GetSelectEntryPos();
@@ -504,12 +747,14 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
FreeResource();
}
-ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc, ScConditionalFormat* pFormat):
+ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRanges, const ScAddress& rPos):
Control(pParent, rResId),
mbHasScrollBar(false),
mpScrollBar(new ScrollBar(this, WB_VERT )),
mnTopIndex(0),
- mpDoc(pDoc)
+ mpDoc(pDoc),
+ maPos(rPos),
+ maRanges(rRanges)
{
mpScrollBar->SetScrollHdl( LINK( this, ScCondFormatList, ScrollHdl ) );
mpScrollBar->EnableDrag();
@@ -527,6 +772,24 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
FreeResource();
}
+ScConditionalFormat* ScCondFormatList::GetConditionalFormat() const
+{
+ if(maEntries.empty())
+ return NULL;
+
+ ScConditionalFormat* pFormat = new ScConditionalFormat(0, mpDoc);
+ for(EntryContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
+ {
+ ScFormatEntry* pEntry = itr->GetEntry();
+ if(pEntry)
+ pFormat->AddEntry(pEntry);
+ }
+
+ pFormat->AddRange(maRanges);
+
+ return pFormat;
+}
+
void ScCondFormatList::RecalcAll()
{
sal_Int32 nTotalHeight = 0;
@@ -542,15 +805,12 @@ void ScCondFormatList::RecalcAll()
mbHasScrollBar = true;
mpScrollBar->SetPosSizePixel(Point(aCtrlSize.Width() -nSrcBarSize, 0),
Size(nSrcBarSize, aCtrlSize.Height()) );
- std::cout << "Need ScrollBar" << std::endl;
mpScrollBar->SetRangeMax(nTotalHeight);
mpScrollBar->SetVisibleSize(aCtrlSize.Height());
mpScrollBar->Show();
}
else
{
- std::cout << "Don't need ScrollBar" << std::endl;
-
mbHasScrollBar = false;
mpScrollBar->Hide();
}
@@ -579,15 +839,16 @@ void ScCondFormatList::DoScroll(long nDelta)
mpScrollBar->SetPosPixel(aNewPoint);
}
-ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, ScConditionalFormat* pFormat, const ScRangeList& rRange):
+ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange, const ScAddress& rPos):
ModalDialog(pParent, ScResId( RID_SCDLG_CONDFORMAT )),
maBtnAdd( this, ScResId( BTN_ADD ) ),
maBtnRemove( this, ScResId( BTN_REMOVE ) ),
maBtnOk( this, ScResId( BTN_OK ) ),
maBtnCancel( this, ScResId( BTN_CANCEL ) ),
- maCondFormList( this, ScResId( CTRL_LIST ), pDoc ),
+ maCondFormList( this, ScResId( CTRL_LIST ), pDoc, pFormat, rRange, maPos ),
mpDoc(pDoc),
- mpFormat(pFormat)
+ mpFormat(pFormat),
+ maPos(rPos)
{
rtl::OUStringBuffer aTitle( GetText() );
@@ -601,6 +862,11 @@ ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, ScConditiona
FreeResource();
}
+ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const
+{
+ return maCondFormList.GetConditionalFormat();
+}
+
IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl )
{
maEntries.push_back( new ScCondFrmtEntry(this, mpDoc) );
diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc
index d4f16b72a587..27aa1b2b2d44 100644
--- a/sc/source/ui/inc/condformatdlg.hrc
+++ b/sc/source/ui/inc/condformatdlg.hrc
@@ -51,5 +51,6 @@
#define LB_TYPE_COL_SCALE 25
#define ED_COL_SCALE 28
#define WD_PREVIEW 26
+#define LB_COL 27
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index f7693fc2699b..44b03623c26c 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -33,6 +33,7 @@
#include <vcl/fixed.hxx>
#include <vcl/edit.hxx>
#include <svx/fntctrl.hxx>
+#include <svtools/ctrlbox.hxx>
#include "rangelst.hxx"
@@ -87,6 +88,10 @@ private:
Edit maEdMiddle;
Edit maEdMax;
+ ColorListBox maLbColMin;
+ ColorListBox maLbColMiddle;
+ ColorListBox maLbColMax;
+
//data bar ui elements
//
//
@@ -101,7 +106,12 @@ private:
void SetHeight();
void Init();
+ ScFormatEntry* createConditionEntry() const;
+ ScFormatEntry* createColorscaleEntry() const;
+ ScFormatEntry* createDatabarEntry() const;
+
ScDocument* mpDoc;
+ ScAddress maPos;
DECL_LINK( TypeListHdl, void*);
DECL_LINK( ColFormatTypeHdl, void*);
@@ -117,6 +127,8 @@ public:
void Deselect();
bool IsSelected() const;
+
+ ScFormatEntry* GetEntry() const;
};
class ScCondFormatList : public Control
@@ -130,12 +142,16 @@ private:
long mnTopIndex;
ScDocument* mpDoc;
+ ScAddress maPos;
+ ScRangeList maRanges;
void RecalcAll();
void DoScroll(long nDiff);
public:
ScCondFormatList( Window* pParent, const ResId& rResId, ScDocument* pDoc );
- ScCondFormatList( Window* pParent, const ResId& rResId, ScDocument* pDoc, ScConditionalFormat* pFormat);
+ ScCondFormatList( Window* pParent, const ResId& rResId, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRanges, const ScAddress& rPos);
+
+ ScConditionalFormat* GetConditionalFormat() const;
DECL_LINK( AddBtnHdl, void* );
DECL_LINK( RemoveBtnHdl, void* );
@@ -155,11 +171,13 @@ private:
ScCondFormatList maCondFormList;
ScDocument* mpDoc;
- ScConditionalFormat* mpFormat;
+ const ScConditionalFormat* mpFormat;
+ ScAddress maPos;
public:
- ScCondFormatDlg(Window* pWindow, ScDocument* pDoc, ScConditionalFormat* pFormat, const ScRangeList& rRange);
+ ScCondFormatDlg(Window* pWindow, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange, const ScAddress& rPos);
+ ScConditionalFormat* GetConditionalFormat() const;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src
index ab2a0c55168a..f69b445dfaee 100644
--- a/sc/source/ui/src/condformatdlg.src
+++ b/sc/source/ui/src/condformatdlg.src
@@ -207,6 +207,14 @@ Control RID_COND_ENTRY
Text [ en-US ] = "Example";
Border = TRUE;
};
+ ListBox LB_COL
+ {
+ Pos = MAP_APPFONT( 5, 62 );
+ Size = MAP_APPFONT( 40, 40 );
+ Border = TRUE;
+ DropDown = TRUE;
+ DDExtraWidth = TRUE;
+ };
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index f6f15a325fac..d9c78cd69038 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -98,6 +98,7 @@
#include "docsh.hxx"
#include "cliputil.hxx"
#include "markdata.hxx"
+#include "docpool.hxx"
#include "globstr.hrc"
#include "scui_def.hxx"
@@ -2055,12 +2056,31 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
ScRangeList aRangeList;
- GetViewData()->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
+ ScViewData* pViewData = GetViewData();
+ pViewData->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
ScDocument* pDoc = GetViewData()->GetDocument();
- AbstractScCondFormatDlg* pDlg = pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, RID_SCDLG_CONDFORMAT );
+ ScAddress aPos(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
+ AbstractScCondFormatDlg* pDlg = NULL;
+ const ScConditionalFormat* pCondFormat = pDoc->GetCondFormat(aPos.Col(), aPos.Row(), aPos.Tab());
+ if(pCondFormat)
+ {
+ pDlg = pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, pCondFormat->GetRange(), aPos, RID_SCDLG_CONDFORMAT );
+ }
+ else
+ {
+ pDlg = pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aPos, RID_SCDLG_CONDFORMAT );
+ }
OSL_ENSURE(pDlg, "Dialog create fail!");
- pDlg->Execute();
+ if(pDlg->Execute() == RET_OK)
+ {
+ ScConditionalFormat* pFormat = pDlg->GetConditionalFormat();
+ sal_uLong nIndex = pDoc->AddCondFormat(pFormat, pViewData->GetTabNo());
+
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
+ pDoc->ApplySelectionPattern( aPattern , pViewData->GetMarkData() );
+ }
delete pDlg;
}
break;