[Libreoffice-commits] .: 4 commits - formula/inc formula/source reportdesign/source sc/source sfx2/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Wed Mar 21 16:24:50 PDT 2012


 formula/inc/formula/formula.hxx        |   13 ++++++----
 formula/source/ui/dlg/formula.cxx      |   42 ++++++++++++++++++++++-----------
 reportdesign/source/ui/dlg/Formula.cxx |    4 ++-
 reportdesign/source/ui/inc/Formula.hxx |    2 -
 sc/source/ui/formdlg/formula.cxx       |    3 +-
 sc/source/ui/inc/formula.hxx           |    7 -----
 sfx2/source/appl/childwin.cxx          |    6 +---
 7 files changed, 45 insertions(+), 32 deletions(-)

New commits:
commit 278c53c93333bed24a74c4c1931e725b64deef02
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Mar 21 21:44:01 2012 +0100

    restructure the code a bit more

diff --git a/formula/inc/formula/formula.hxx b/formula/inc/formula/formula.hxx
index 55cc0bc..7a16b3d 100644
--- a/formula/inc/formula/formula.hxx
+++ b/formula/inc/formula/formula.hxx
@@ -33,6 +33,7 @@
 #include <memory>
 #include "formula/formuladllapi.h"
 #include "formula/omoduleclient.hxx"
+#include <formula/IFunctionDescription.hxx>
 
 namespace formula
 {
@@ -48,7 +49,6 @@ enum FormulaDlgMode { FORMULA_FORMDLG_FORMULA, FORMULA_FORMDLG_ARGS, FORMULA_FOR
 
 //============================================================================
 
-class IFormulaEditorHelper;
 class FormulaDlg_Impl;
 class IControlReferenceHandler;
 class IFunctionDescription;
@@ -58,7 +58,7 @@ class RefEdit;
 class RefButton;
 class FormEditData;
 //============================================================================
-class FORMULA_DLLPUBLIC FormulaModalDialog :   public ModalDialog
+class FORMULA_DLLPUBLIC FormulaModalDialog :   public ModalDialog, public formula::IFormulaEditorHelper
 {
     friend class FormulaDlg_Impl;
 public:
@@ -66,7 +66,6 @@ public:
                                             , bool _bSupportFunctionResult
                                             , bool _bSupportResult
                                             , bool _bSupportMatrix
-                                            ,IFormulaEditorHelper* _pHelper
                                             ,IFunctionManager* _pFunctionMgr
                                             ,IControlReferenceHandler* _pDlg = NULL );
                     virtual ~FormulaModalDialog();
@@ -92,7 +91,7 @@ protected:
 };
 
 class FORMULA_DLLPUBLIC FormulaDlg:
-    private OModuleClient, public SfxModelessDialog
+    private OModuleClient, public SfxModelessDialog, public IFormulaEditorHelper
         // order of base classes is important, as OModuleClient controls the
         // lifecycle of the ResMgr passed into SfxModelessDialog (via
         // formula::ModuleRes), and at least with DBG_UTIL calling TestRes in
@@ -107,7 +106,6 @@ public:
                                     , bool _bSupportFunctionResult
                                     , bool _bSupportResult
                                     , bool _bSupportMatrix
-                                    , IFormulaEditorHelper* _pHelper
                                     , IFunctionManager* _pFunctionMgr
                                     , IControlReferenceHandler* _pDlg = NULL );
                     virtual ~FormulaDlg();
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 70eccb3..ac0cac6 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -1657,14 +1657,13 @@ FormulaModalDialog::FormulaModalDialog( Window* pParent
                                             , bool _bSupportFunctionResult
                                             , bool _bSupportResult
                                             , bool _bSupportMatrix
-                                            , IFormulaEditorHelper* _pHelper
                                             , IFunctionManager* _pFunctionMgr
                                             , IControlReferenceHandler* _pDlg ) :
         ModalDialog( pParent, ModuleRes(RID_FORMULADLG_FORMULA_MODAL) ),
         m_pImpl( new FormulaDlg_Impl(this,_bSupportFunctionResult
                                             , _bSupportResult
                                             , _bSupportMatrix
-                                            ,_pHelper,_pFunctionMgr,_pDlg))
+                                            ,this,_pFunctionMgr,_pDlg))
 {
     FreeResource();
     SetText(m_pImpl->aTitle1);
@@ -1745,12 +1744,12 @@ FormulaDlg::FormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
                             , bool _bSupportFunctionResult
                             , bool _bSupportResult
                             , bool _bSupportMatrix
-                            , IFormulaEditorHelper* _pHelper,IFunctionManager* _pFunctionMgr,IControlReferenceHandler* _pDlg ) :
+                            , IFunctionManager* _pFunctionMgr, IControlReferenceHandler* _pDlg ) :
         SfxModelessDialog( pB, pCW, pParent, ModuleRes(RID_FORMULADLG_FORMULA) ),
         m_pImpl( new FormulaDlg_Impl(this, _bSupportFunctionResult
                                             , _bSupportResult
                                             , _bSupportMatrix
-                                            ,_pHelper,_pFunctionMgr,_pDlg))
+                                            , this, _pFunctionMgr, _pDlg))
 {
     FreeResource();
     if(GetHelpId().isEmpty())    //Hack which hides the HelpId for a model Dialog in SfxModelessDialog
diff --git a/reportdesign/source/ui/dlg/Formula.cxx b/reportdesign/source/ui/dlg/Formula.cxx
index c09e06b..184d25d 100644
--- a/reportdesign/source/ui/dlg/Formula.cxx
+++ b/reportdesign/source/ui/dlg/Formula.cxx
@@ -60,7 +60,7 @@ FormulaDialog::FormulaDialog(Window* pParent
                              , const ::boost::shared_ptr< IFunctionManager >&  _pFunctionMgr
                              , const ::rtl::OUString& _sFormula
                              , const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet >& _xRowSet)
-    : FormulaModalDialog( pParent, false,false,false,this,_pFunctionMgr.get(),this)
+    : FormulaModalDialog( pParent, false,false,false,_pFunctionMgr.get(),this)
     ,m_aFunctionManager(_pFunctionMgr)
     ,m_pFormulaData(new FormEditData())
     ,m_pAddField(NULL)
diff --git a/reportdesign/source/ui/inc/Formula.hxx b/reportdesign/source/ui/inc/Formula.hxx
index a297027..623d1c7 100644
--- a/reportdesign/source/ui/inc/Formula.hxx
+++ b/reportdesign/source/ui/inc/Formula.hxx
@@ -30,7 +30,6 @@
 #define RPTUI_FORMULA_HXX
 
 #include <formula/formula.hxx>
-#include <formula/IFunctionDescription.hxx>
 #include <formula/IControlReferenceHandler.hxx>
 #include <boost/shared_ptr.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
@@ -45,8 +44,7 @@ class FunctionManager;
 class OAddFieldWindow;
 
 //============================================================================
-class FormulaDialog : public formula::IFormulaEditorHelper,
-                      public formula::FormulaModalDialog,
+class FormulaDialog : public formula::FormulaModalDialog,
                       public formula::IControlReferenceHandler
 {
     ::boost::shared_ptr< formula::IFunctionManager > m_aFunctionManager;
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index 6556164..790a020 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -84,7 +84,7 @@ ScAddress ScFormulaDlg::aCursorPos;
 
 ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
                                     Window* pParent, ScViewData* pViewData,formula::IFunctionManager* _pFunctionMgr )
-    : formula::FormulaDlg( pB, pCW, pParent, true,true,true,this, _pFunctionMgr,this)
+    : formula::FormulaDlg( pB, pCW, pParent, true,true,true, _pFunctionMgr,this)
     , m_aHelper(this,pB)
 {
     m_aHelper.SetWindow(this);
diff --git a/sc/source/ui/inc/formula.hxx b/sc/source/ui/inc/formula.hxx
index f8969c5..8404e6e 100644
--- a/sc/source/ui/inc/formula.hxx
+++ b/sc/source/ui/inc/formula.hxx
@@ -43,7 +43,6 @@
 #include "formula/formula.hxx"
 #include "IAnyRefDialog.hxx"
 #include "anyrefdg.hxx"
-#include <formula/IFunctionDescription.hxx>
 
 class ScViewData;
 class ScDocument;
@@ -56,11 +55,7 @@ class SvLBoxEntry;
 typedef ScTabViewShell* PtrTabViewShell;
 //============================================================================
 
-// Order of base classes is important, as pointer to IFormulaEditorHelper base
-// is passed into constructor of FormulaDlg base, which expects the former to
-// outlive itself:
-class ScFormulaDlg : public formula::IFormulaEditorHelper,
-                     public formula::FormulaDlg,
+class ScFormulaDlg : public formula::FormulaDlg,
                      public IAnyRefDialog
 {
     ScFormulaReferenceHelper m_aHelper;
commit ac5455a6883b9a774a13d9a29267669fe4d5c38d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Mar 21 20:58:48 2012 +0100

    prevent call to virtual method in destructor, fdo#47589

diff --git a/formula/inc/formula/formula.hxx b/formula/inc/formula/formula.hxx
index ac9023d..55cc0bc 100644
--- a/formula/inc/formula/formula.hxx
+++ b/formula/inc/formula/formula.hxx
@@ -56,6 +56,7 @@ class IFunctionManager;
 class FormulaHelper;
 class RefEdit;
 class RefButton;
+class FormEditData;
 //============================================================================
 class FORMULA_DLLPUBLIC FormulaModalDialog :   public ModalDialog
 {
@@ -86,6 +87,8 @@ protected:
     void            Update();
     sal_Bool            CheckMatrix(String& aFormula /*IN/OUT*/);
     void            Update(const String& _sExp);
+
+    void            StoreFormEditData(FormEditData* pData);
 };
 
 class FORMULA_DLLPUBLIC FormulaDlg:
@@ -141,6 +144,8 @@ protected:
     RefEdit*        GetActiveEdit();
     void            SetEdSelection();
 
+    void            StoreFormEditData(FormEditData* pData);
+
     const FormulaHelper& GetFormulaHelper() const;
 };
 
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 5b9987a..70eccb3 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -114,6 +114,8 @@ namespace formula
         void            EditNextFunc( sal_Bool bForward, xub_StrLen nFStart=NOT_FOUND );
         void            EditThisFunc(xub_StrLen nFStart);
 
+        void            StoreFormEditData(FormEditData* pEditData);
+
         void            UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 nInput );
         void            Update();
         void            Update(const String& _sExp);
@@ -364,7 +366,18 @@ FormulaDlg_Impl::~FormulaDlg_Impl()
         aTimer.Stop();
     }// if(aTimer.IsActive())
     bIsShutDown=sal_True;// Set it in order to PreNotify not to save GetFocus.
-    FormEditData* pData = m_pHelper->getFormEditData();
+
+    aTabCtrl.RemovePage(TP_FUNCTION);
+    aTabCtrl.RemovePage(TP_STRUCT);
+
+    delete pStructPage;
+    delete pFuncPage;
+    delete pParaWin;
+    DeleteArgs();
+}
+
+void FormulaDlg_Impl::StoreFormEditData(FormEditData* pData)
+{
     if (pData) // it won't be destroyed over Close;
     {
         pData->SetFStart((xub_StrLen)pMEdit->GetSelection().Min());
@@ -377,15 +390,8 @@ FormulaDlg_Impl::~FormulaDlg_Impl()
         pData->SetUndoStr(pMEdit->GetText());
         pData->SetMatrixFlag(aBtnMatrix.IsChecked());
     }
-
-    aTabCtrl.RemovePage(TP_FUNCTION);
-    aTabCtrl.RemovePage(TP_STRUCT);
-
-    delete pStructPage;
-    delete pFuncPage;
-    delete pParaWin;
-    DeleteArgs();
 }
+
 // -----------------------------------------------------------------------------
 void FormulaDlg_Impl::PreNotify( NotifyEvent& rNEvt )
 {
@@ -1726,6 +1732,11 @@ long FormulaModalDialog::PreNotify( NotifyEvent& rNEvt )
     return ModalDialog::PreNotify(rNEvt);
 }
 
+void FormulaModalDialog::StoreFormEditData(FormEditData* pData)
+{
+    m_pImpl->StoreFormEditData(pData);
+}
+
 //  --------------------------------------------------------------------------
 //      Initialisation / General functions  for Dialog
 //  --------------------------------------------------------------------------
@@ -1843,6 +1854,12 @@ void FormulaDlg::disableOk()
 {
     m_pImpl->aBtnEnd.Disable();
 }
+
+void FormulaDlg::StoreFormEditData(FormEditData* pData)
+{
+    m_pImpl->StoreFormEditData(pData);
+}
+
 // -----------------------------------------------------------------------------
 const IFunctionDescription* FormulaDlg::getCurrentFunctionDescription() const
 {
diff --git a/reportdesign/source/ui/dlg/Formula.cxx b/reportdesign/source/ui/dlg/Formula.cxx
index 5dae671..c09e06b 100644
--- a/reportdesign/source/ui/dlg/Formula.cxx
+++ b/reportdesign/source/ui/dlg/Formula.cxx
@@ -105,6 +105,8 @@ FormulaDialog::~FormulaDialog()
         boost::scoped_ptr<Window> aTemp2(m_pAddField);
         m_pAddField = NULL;
     }
+
+    StoreFormEditData( m_pFormulaData );
 }
 
 //  --------------------------------------------------------------------------
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index 5692594..6556164 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -272,6 +272,7 @@ ScFormulaDlg::~ScFormulaDlg()
     {
         //Referenz Inputhandler zuruecksetzen
         pScMod->SetRefInputHdl(NULL);
+        StoreFormEditData(pData);
     } // if (pData) // wird nicht ueber Close zerstoert;
 
     delete pCell;
commit 1ab961d98a079d70654041219b14797cc6c62447
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Mar 21 20:09:55 2012 +0100

    Make sure one base class does not use another one after destruction
    
    see 706ac4779de1870cf0d922f1cc3f6d4470392403 and fdo#47589

diff --git a/reportdesign/source/ui/inc/Formula.hxx b/reportdesign/source/ui/inc/Formula.hxx
index c458ccf..a297027 100644
--- a/reportdesign/source/ui/inc/Formula.hxx
+++ b/reportdesign/source/ui/inc/Formula.hxx
@@ -45,8 +45,8 @@ class FunctionManager;
 class OAddFieldWindow;
 
 //============================================================================
-class FormulaDialog : public formula::FormulaModalDialog,
-                      public formula::IFormulaEditorHelper,
+class FormulaDialog : public formula::IFormulaEditorHelper,
+                      public formula::FormulaModalDialog,
                       public formula::IControlReferenceHandler
 {
     ::boost::shared_ptr< formula::IFunctionManager > m_aFunctionManager;
commit ec64924ea82df15ce2d340b7dca0f2301efbf77c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Mar 20 21:08:43 2012 +0100

    don't need to check for null before delete

diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx
index ab61c0f..a698002 100644
--- a/sfx2/source/appl/childwin.cxx
+++ b/sfx2/source/appl/childwin.cxx
@@ -197,10 +197,8 @@ void SfxChildWindow::Destroy()
 SfxChildWindow::~SfxChildWindow()
 {
     DBG_DTOR(SfxChildWindow,0);
-    if ( pContext )
-        delete pContext;
-    if ( pWindow )
-        delete pWindow;
+    delete pContext;
+    delete pWindow;
     delete pImp;
 }
 


More information about the Libreoffice-commits mailing list