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

the dialog hierarchy changed iwith the ui format, fdo#81867

We need to be explicit now and can no longer rely on GetParent returning
the right object. Seems like sometimes you get punished for an ugly hack
a bit later than expected.

Change-Id: I145e97ae0ceee741c4128c29a6ca26fad2178cb5
üst 21bd05d6
......@@ -46,9 +46,11 @@ ScCondFormatList::ScCondFormatList(Window* pParent, WinBits nStyle)
SetBackground(GetControlBackground());
}
void ScCondFormatList::init(ScDocument* pDoc, const ScConditionalFormat* pFormat,
const ScRangeList& rRanges, const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType)
void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
const ScConditionalFormat* pFormat, const ScRangeList& rRanges,
const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType)
{
mpDialogParent = pDialogParent;
mpDoc = pDoc;
maPos = rPos;
maRanges = rRanges;
......@@ -65,9 +67,9 @@ void ScCondFormatList::init(ScDocument* pDoc, const ScConditionalFormat* pFormat
{
const ScCondFormatEntry* pConditionEntry = static_cast<const ScCondFormatEntry*>( pEntry );
if(pConditionEntry->GetOperation() != SC_COND_DIRECT)
maEntries.push_back(new ScConditionFrmtEntry( this, mpDoc, maPos, pConditionEntry ) );
maEntries.push_back(new ScConditionFrmtEntry( this, mpDoc, pDialogParent, maPos, pConditionEntry ) );
else
maEntries.push_back(new ScFormulaFrmtEntry( this, mpDoc, maPos, pConditionEntry ) );
maEntries.push_back(new ScFormulaFrmtEntry( this, mpDoc, pDialogParent, maPos, pConditionEntry ) );
}
break;
......@@ -99,7 +101,7 @@ void ScCondFormatList::init(ScDocument* pDoc, const ScConditionalFormat* pFormat
switch(eType)
{
case condformat::dialog::CONDITION:
maEntries.push_back(new ScConditionFrmtEntry( this, mpDoc, maPos ));
maEntries.push_back(new ScConditionFrmtEntry( this, mpDoc, pDialogParent, maPos ));
break;
case condformat::dialog::COLORSCALE:
maEntries.push_back(new ScColorScale3FrmtEntry( this, mpDoc, maPos ));
......@@ -258,7 +260,7 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox*, pBox)
default:
break;
}
static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData();
mpDialogParent->InvalidateRefData();
itr->SetActive();
RecalcAll();
return 0;
......@@ -302,23 +304,23 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, ListBox*, pBox)
return 0;
}
maEntries.replace( itr, new ScColorScale3FrmtEntry(this, mpDoc, maPos));
static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData();
mpDialogParent->InvalidateRefData();
itr->SetActive();
break;
case 1:
if(itr->GetType() == condformat::entry::CONDITION)
return 0;
maEntries.replace( itr, new ScConditionFrmtEntry(this, mpDoc, maPos));
static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData();
maEntries.replace( itr, new ScConditionFrmtEntry(this, mpDoc, mpDialogParent, maPos));
mpDialogParent->InvalidateRefData();
itr->SetActive();
break;
case 2:
if(itr->GetType() == condformat::entry::FORMULA)
return 0;
maEntries.replace( itr, new ScFormulaFrmtEntry(this, mpDoc, maPos));
static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData();
maEntries.replace( itr, new ScFormulaFrmtEntry(this, mpDoc, mpDialogParent, maPos));
mpDialogParent->InvalidateRefData();
itr->SetActive();
break;
case 3:
......@@ -326,7 +328,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, ListBox*, pBox)
return 0;
maEntries.replace( itr, new ScDateFrmtEntry( this, mpDoc ));
static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData();
mpDialogParent->InvalidateRefData();
itr->SetActive();
break;
......@@ -337,13 +339,13 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, ListBox*, pBox)
IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl )
{
ScCondFrmtEntry* pNewEntry = new ScConditionFrmtEntry(this, mpDoc, maPos);
ScCondFrmtEntry* pNewEntry = new ScConditionFrmtEntry(this, mpDoc, mpDialogParent, maPos);
maEntries.push_back( pNewEntry );
for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
{
itr->SetInactive();
}
static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData();
mpDialogParent->InvalidateRefData();
pNewEntry->SetActive();
RecalcAll();
return 0;
......@@ -359,7 +361,7 @@ IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl )
break;
}
}
static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData();
mpDialogParent->InvalidateRefData();
RecalcAll();
return 0;
}
......@@ -376,7 +378,7 @@ IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry*, pEntry )
{
itr->SetInactive();
}
static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData();
mpDialogParent->InvalidateRefData();
pEntry->SetActive();
RecalcAll();
if (bReGrabFocus)
......@@ -412,7 +414,7 @@ ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc,
mpRbRange->SetReferences(this, mpEdRange);
get(mpCondFormList, "list");
mpCondFormList->init(pDoc, pFormat, rRange, rPos, eType);
mpCondFormList->init(pDoc, this, pFormat, rRange, rPos, eType);
OUStringBuffer aTitle( GetText() );
aTitle.append(" ");
......
......@@ -164,7 +164,8 @@ void FillStyleListBox( ScDocument* pDoc, ListBox& rLbStyle )
}
ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry ):
ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry ):
ScCondFrmtEntry( pParent, pDoc, rPos ),
maLbCondType( this, ScResId( LB_CELLIS_TYPE ) ),
maEdVal1( this, NULL, NULL, ScResId( ED_VAL1 ) ),
......@@ -178,7 +179,7 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
FreeResource();
maLbType.SelectEntryPos(1);
Init();
Init(pDialogParent);
StartListening(*pDoc->GetStyleSheetPool(), true);
......@@ -291,12 +292,12 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
maLbType.SelectEntryPos(1);
}
void ScConditionFrmtEntry::Init()
void ScConditionFrmtEntry::Init(ScCondFormatDlg* pDialogParent)
{
maEdVal1.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) );
maEdVal2.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) );
maEdVal1.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeLoseFocusHdl ) );
maEdVal2.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeLoseFocusHdl ) );
maEdVal1.SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );
maEdVal2.SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );
maEdVal1.SetLoseFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeLoseFocusHdl ) );
maEdVal2.SetLoseFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeLoseFocusHdl ) );
maEdVal1.SetStyle( maEdVal1.GetStyle() | WB_FORCECTRLBACKGROUND );
maEdVal2.SetStyle( maEdVal2.GetStyle() | WB_FORCECTRLBACKGROUND );
......@@ -547,14 +548,14 @@ IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl)
// formula
ScFormulaFrmtEntry::ScFormulaFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormat ):
ScFormulaFrmtEntry::ScFormulaFrmtEntry( Window* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent, 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, NULL, NULL, ScResId( ED_FORMULA ) )
{
Init();
Init(pDialogParent);
FreeResource();
maLbType.SelectEntryPos(2);
......@@ -572,10 +573,10 @@ ScFormulaFrmtEntry::ScFormulaFrmtEntry( Window* pParent, ScDocument* pDoc, const
StyleSelectHdl(NULL);
}
void ScFormulaFrmtEntry::Init()
void ScFormulaFrmtEntry::Init(ScCondFormatDlg* pDialogParent)
{
maEdFormula.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) );
maEdFormula.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeLoseFocusHdl ) );
maEdFormula.SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );
maEdFormula.SetLoseFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeLoseFocusHdl ) );
FillStyleListBox( mpDoc, maLbStyle );
maLbStyle.SetSelectHdl( LINK( this, ScFormulaFrmtEntry, StyleSelectHdl ) );
......
......@@ -51,6 +51,8 @@ enum ScCondFormatDialogType
}
class ScCondFormatDlg;
class ScCondFormatList : public Control
{
private:
......@@ -63,13 +65,14 @@ private:
ScDocument* mpDoc;
ScAddress maPos;
ScRangeList maRanges;
ScCondFormatDlg* mpDialogParent;
void DoScroll(long nDiff);
public:
ScCondFormatList(Window* pParent, WinBits nStyle);
void init(ScDocument* pDoc, const ScConditionalFormat* pFormat,
void init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent, const ScConditionalFormat* pFormat,
const ScRangeList& rRanges, const ScAddress& rPos,
condformat::dialog::ScCondFormatDialogType eType);
......
......@@ -17,6 +17,7 @@
#include <svl/lstner.hxx>
class ScIconSetFrmtDataEntry;
class ScCondFormatDlg;
namespace condformat {
......@@ -95,12 +96,13 @@ class ScConditionFrmtEntry : public ScCondFrmtEntry, public SfxListener
ScFormatEntry* createConditionEntry() const;
virtual OUString GetExpressionString() SAL_OVERRIDE;
void Init();
void Init(ScCondFormatDlg* pDialogParent);
DECL_LINK( StyleSelectHdl, void* );
DECL_LINK( ConditionTypeSelectHdl, void* );
public:
ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = NULL );
ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = NULL );
virtual ScFormatEntry* GetEntry() const SAL_OVERRIDE;
virtual void SetActive() SAL_OVERRIDE;
......@@ -121,12 +123,12 @@ class ScFormulaFrmtEntry : public ScCondFrmtEntry
ScFormatEntry* createFormulaEntry() const;
virtual OUString GetExpressionString() SAL_OVERRIDE;
void Init();
void Init(ScCondFormatDlg* pDialogParent);
DECL_LINK( StyleSelectHdl, void* );
public:
ScFormulaFrmtEntry( Window* pParent, ScDocument* PDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = NULL );
ScFormulaFrmtEntry( Window* pParent, ScDocument* PDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = NULL );
virtual ScFormatEntry* GetEntry() const SAL_OVERRIDE;
virtual void SetActive() SAL_OVERRIDE;
......
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