[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Wed Jul 30 14:44:34 PDT 2014


 sc/source/ui/condformat/condformatdlg.cxx      |   36 +++++++++++++------------
 sc/source/ui/condformat/condformatdlgentry.cxx |   25 +++++++++--------
 sc/source/ui/inc/condformatdlg.hxx             |    5 ++-
 sc/source/ui/inc/condformatdlgentry.hxx        |   10 ++++--
 4 files changed, 42 insertions(+), 34 deletions(-)

New commits:
commit 29803d51fe6db96d2a98475c059cd56f36e0da6b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Jul 30 23:29:26 2014 +0200

    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
    (cherry picked from commit fe5463fb7bc740bfec5d2eb7408b8ff3624d8c31)
    Reviewed-on: https://gerrit.libreoffice.org/10653
    Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>
    Tested-by: Kohei Yoshida <libreoffice at kohei.us>

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 9c0a6d9..cb55ef7 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)
@@ -414,7 +416,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 dfcbb4b..db44e60 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -170,7 +170,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 ) ),
@@ -184,7 +185,7 @@ ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, c
     FreeResource();
     maLbType.SelectEntryPos(1);
 
-    Init();
+    Init(pDialogParent);
 
     StartListening(*pDoc->GetStyleSheetPool(), true);
 
@@ -297,12 +298,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 );
@@ -553,14 +554,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);
@@ -578,10 +579,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 12b522f..a4f242b 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 1b54fa3..05990dc 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;


More information about the Libreoffice-commits mailing list