Kaydet (Commit) ee93051d authored tarafından Markus Mohrhard's avatar Markus Mohrhard

add own class for formula type cond formats

Change-Id: I0348797babb9e94e1d552dce341504144c837325
üst d7a27f40
...@@ -190,13 +190,15 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox) ...@@ -190,13 +190,15 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox)
{ {
case 0: case 0:
maEntries.replace( itr, new ScColorScaleFrmtEntry(this, mpDoc, maPos)); maEntries.replace( itr, new ScColorScaleFrmtEntry(this, mpDoc, maPos));
itr->SetHeight(); itr->SetActive();
break; break;
case 1: case 1:
maEntries.replace( itr, new ScConditionFrmtEntry(this, mpDoc, maPos)); maEntries.replace( itr, new ScConditionFrmtEntry(this, mpDoc, maPos));
itr->SetHeight(); itr->SetActive();
break; break;
case 2: case 2:
maEntries.replace( itr, new ScFormulaFrmtEntry(this, mpDoc, maPos));
itr->SetActive();
break; break;
} }
RecalcAll(); RecalcAll();
......
#include "condformatdlg.hxx" #include "condformatdlg.hxx"
#include "condformatdlgentry.hxx" #include "condformatdlgentry.hxx"
#include "condformatdlg.hrc" #include "condformatdlg.hrc"
#include "conditio.hxx"
#include "document.hxx" #include "document.hxx"
...@@ -139,18 +140,6 @@ IMPL_LINK(ScCondFrmtEntry, EdModifyHdl, Edit*, pEdit) ...@@ -139,18 +140,6 @@ IMPL_LINK(ScCondFrmtEntry, EdModifyHdl, Edit*, pEdit)
// //
//condition //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 ): ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry ):
ScCondFrmtEntry( pParent, pDoc, rPos ), ScCondFrmtEntry( pParent, pDoc, rPos ),
maLbCondType( this, ScResId( LB_CELLIS_TYPE ) ), maLbCondType( this, ScResId( LB_CELLIS_TYPE ) ),
...@@ -377,6 +366,131 @@ IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl) ...@@ -377,6 +366,131 @@ IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl)
return 0; 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 //color scale
namespace { namespace {
......
...@@ -59,4 +59,6 @@ ...@@ -59,4 +59,6 @@
#define ED_RANGE 33 #define ED_RANGE 33
#define RB_RANGE 34 #define RB_RANGE 34
#define ED_FORMULA 35
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -55,7 +55,6 @@ class ScConditionFrmtEntry : public ScCondFrmtEntry ...@@ -55,7 +55,6 @@ class ScConditionFrmtEntry : public ScCondFrmtEntry
SvxFontPrevWindow maWdPreview; SvxFontPrevWindow maWdPreview;
ScFormatEntry* createConditionEntry() const; ScFormatEntry* createConditionEntry() const;
ScFormatEntry* createFormulaEntry() const;
void Init(); void Init();
DECL_LINK( StyleSelectHdl, void* ); DECL_LINK( StyleSelectHdl, void* );
...@@ -68,6 +67,25 @@ public: ...@@ -68,6 +67,25 @@ public:
virtual void SetInactive(); 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 class ScColorScaleFrmtEntry : public ScCondFrmtEntry
{ {
......
...@@ -149,6 +149,12 @@ Control RID_COND_ENTRY ...@@ -149,6 +149,12 @@ Control RID_COND_ENTRY
Size = MAP_APPFONT( 50, 12 ); Size = MAP_APPFONT( 50, 12 );
Border = TRUE; Border = TRUE;
}; };
Edit ED_FORMULA
{
Pos = MAP_APPFONT( 90, 15 );
Size = MAP_APPFONT( 135, 12 );
Border = TRUE;
};
Edit ED_VAL2 Edit ED_VAL2
{ {
Pos = MAP_APPFONT( 230, 15 ); Pos = MAP_APPFONT( 230, 15 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment