summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-07-30 23:29:26 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-07-30 23:31:30 +0200
commitfe5463fb7bc740bfec5d2eb7408b8ff3624d8c31 (patch)
treec923d57f0306d82c6b975d75238f93ac79ce2aff
parent21bd05d61febe5e99df790fdad572ec731a15213 (diff)
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
-rw-r--r--sc/source/ui/condformat/condformatdlg.cxx36
-rw-r--r--sc/source/ui/condformat/condformatdlgentry.cxx25
-rw-r--r--sc/source/ui/inc/condformatdlg.hxx5
-rw-r--r--sc/source/ui/inc/condformatdlgentry.hxx10
4 files changed, 42 insertions, 34 deletions
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index fd4efc5c42ca..f5cbf34a6e9e 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -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(" ");
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 9065ff4ff9d0..d8b33a23f2fa 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -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 ) );
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 123d9ea3ad1b..833578f4ba4f 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -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);
diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx
index aa38d0d0a7d4..fd6ba0a8623a 100644
--- a/sc/source/ui/inc/condformatdlgentry.hxx
+++ b/sc/source/ui/inc/condformatdlgentry.hxx
@@ -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;