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