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

Noel Grandin noel.grandin at collabora.co.uk
Thu Apr 6 07:04:00 UTC 2017


 sc/inc/arealink.hxx                |    1 
 sc/inc/scabstdlg.hxx               |    2 -
 sc/source/ui/attrdlg/scdlgfact.cxx |    9 ++++
 sc/source/ui/attrdlg/scdlgfact.hxx |    8 +++-
 sc/source/ui/docshell/arealink.cxx |   32 ++++++-----------
 sc/source/ui/view/cellsh1.cxx      |   69 ++++++++++++++++---------------------
 6 files changed, 57 insertions(+), 64 deletions(-)

New commits:
commit 16e2701d02e777673c957ff77bcc0a66e24f9d81
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Apr 4 14:16:43 2017 +0200

    tdf#106868: fix crash when modify external link
    
    The EndDialog callback Hdl was disposing the Dialog, which is a little
    troublesome since the stack wants to go back through the Dialog code
    when the callback is done.
    Rather just the more normal synchronous Execute() style of Dialog
    execute, instead of the asynchronous StartExecuteModal.
    
    Change-Id: I14933bd475da228c9648a6fa0564bda4a60d9d12
    Reviewed-on: https://gerrit.libreoffice.org/36074
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit cedbc4031f26ea13b188a4ecc5b90cc9646095fb)
    Reviewed-on: https://gerrit.libreoffice.org/36179

diff --git a/sc/inc/arealink.hxx b/sc/inc/arealink.hxx
index c7e5aa3d1291..69b6b5a8d40f 100644
--- a/sc/inc/arealink.hxx
+++ b/sc/inc/arealink.hxx
@@ -75,7 +75,6 @@ public:
     const ScRange&  GetDestArea() const     { return aDestArea;     }
 
     DECL_LINK( RefreshHdl, Timer*, void );
-    DECL_LINK( AreaEndEditHdl, Dialog&, void );
 };
 
 #endif
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 9b9b130ebf05..67be06b9ad73 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -221,7 +221,7 @@ public:
     virtual OUString GetSelectEntry() const = 0;
 };
 
-class AbstractScLinkedAreaDlg : public VclAbstractDialog2
+class AbstractScLinkedAreaDlg : public VclAbstractDialog
 {
 protected:
     virtual             ~AbstractScLinkedAreaDlg() override = default;
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index be4d216707b8..733afc03d39a 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -90,7 +90,6 @@ IMPL_ABSTDLG_BASE(AbstractScInsertCellDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractScInsertContentsDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractScInsertTableDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractScSelEntryDlg_Impl);
-IMPL_ABSTDLG2_BASE(AbstractScLinkedAreaDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractScMetricInputDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractScMoveTableDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractScNameCreateDlg_Impl);
@@ -110,6 +109,14 @@ IMPL_ABSTDLG_BASE(AbstractScImportOptionsDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractScTextImportOptionsDlg_Impl);
 IMPL_ABSTDLG_BASE(ScAbstractTabDialog_Impl);
 
+AbstractScLinkedAreaDlg_Impl::~AbstractScLinkedAreaDlg_Impl()
+{
+}
+short AbstractScLinkedAreaDlg_Impl::Execute()
+{
+    return pDlg->Execute();
+}
+
 void ScAbstractTabDialog_Impl::SetCurPageId( sal_uInt16 nId )
 {
     pDlg->SetCurPageId( nId );
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 30e69a2aab1e..b069c779efb2 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -258,8 +258,12 @@ class AbstractScSelEntryDlg_Impl : public AbstractScSelEntryDlg
 
 class AbstractScLinkedAreaDlg_Impl : public AbstractScLinkedAreaDlg
 {
-    DECL_ABSTDLG2_BASE( AbstractScLinkedAreaDlg_Impl, ScLinkedAreaDlg)
-
+    ScopedVclPtr<ScLinkedAreaDlg> pDlg;
+public:
+    explicit                AbstractScLinkedAreaDlg_Impl( ScLinkedAreaDlg* p)
+                              : pDlg(p) {}
+    virtual                 ~AbstractScLinkedAreaDlg_Impl() override;
+    virtual short           Execute() override;
     virtual void            InitFromOldLink( const OUString& rFile, const OUString& rFilter,
                                         const OUString& rOptions, const OUString& rSource,
                                         sal_uLong nRefresh ) override;
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index 10127c6e4888..d5b486afdb4b 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -92,7 +92,18 @@ void ScAreaLink::Edit(vcl::Window* pParent, const Link<SvBaseLink&,void>& /* rEn
     OSL_ENSURE(pDlg, "Dialog create fail!");
     pDlg->InitFromOldLink( aFileName, aFilterName, aOptions, aSourceArea, GetRefreshDelay() );
     pImpl->m_pDialog = pDlg;
-    pDlg->StartExecuteModal( LINK( this, ScAreaLink, AreaEndEditHdl ) );
+    if ( pDlg->Execute() == RET_OK )
+    {
+        aOptions = pImpl->m_pDialog->GetOptions();
+        Refresh( pImpl->m_pDialog->GetURL(), pImpl->m_pDialog->GetFilter(),
+                 pImpl->m_pDialog->GetSource(), pImpl->m_pDialog->GetRefresh() );
+
+        //  copy source data from members (set in Refresh) into link name for dialog
+        OUString aNewLinkName;
+        sfx2::MakeLnkName( aNewLinkName, nullptr, aFileName, aSourceArea, &aFilterName );
+        SetName( aNewLinkName );
+    }
+    pImpl->m_pDialog.clear();    // dialog is deleted with parent
 }
 
 ::sfx2::SvBaseLink::UpdateResult ScAreaLink::DataChanged(
@@ -482,23 +493,4 @@ IMPL_LINK_NOARG(ScAreaLink, RefreshHdl, Timer *, void)
     Refresh( aFileName, aFilterName, aSourceArea, GetRefreshDelay() );
 }
 
-IMPL_LINK_NOARG(ScAreaLink, AreaEndEditHdl, Dialog&, void)
-{
-    //  #i76514# can't use link argument to access the dialog,
-    //  because it's the ScLinkedAreaDlg, not AbstractScLinkedAreaDlg
-
-    if ( pImpl->m_pDialog && pImpl->m_pDialog->GetResult() == RET_OK )
-    {
-        aOptions = pImpl->m_pDialog->GetOptions();
-        Refresh( pImpl->m_pDialog->GetURL(), pImpl->m_pDialog->GetFilter(),
-                 pImpl->m_pDialog->GetSource(), pImpl->m_pDialog->GetRefresh() );
-
-        //  copy source data from members (set in Refresh) into link name for dialog
-        OUString aNewLinkName;
-        sfx2::MakeLnkName( aNewLinkName, nullptr, aFileName, aSourceArea, &aFilterName );
-        SetName( aNewLinkName );
-    }
-    pImpl->m_pDialog.clear();    // dialog is deleted with parent
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 2fa4fb65bcb0..5b734ad6158f 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2505,16 +2505,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 
         case SID_EXTERNAL_SOURCE:
             {
-                OUString aFile;
-                OUString aFilter;
-                OUString aOptions;
-                OUString aSource;
-                sal_uLong nRefresh=0;
-
                 const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>(SID_FILE_NAME);
                 const SfxStringItem* pSource = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
                 if ( pFile && pSource )
                 {
+                    OUString aFile;
+                    OUString aFilter;
+                    OUString aOptions;
+                    OUString aSource;
+                    sal_uLong nRefresh=0;
+
                     aFile = pFile->GetValue();
                     aSource = pSource->GetValue();
                     const SfxStringItem* pFilter = rReq.GetArg<SfxStringItem>(SID_FILTER_NAME);
@@ -2526,6 +2526,8 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                     const SfxUInt32Item* pRefresh = rReq.GetArg<SfxUInt32Item>(FN_PARAM_2);
                     if ( pRefresh )
                         nRefresh = pRefresh->GetValue();
+
+                    ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq );
                 }
                 else
                 {
@@ -2538,11 +2540,29 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                     OSL_ENSURE(pImpl->m_pLinkedDlg, "Dialog create fail!");
                     delete pImpl->m_pRequest;
                     pImpl->m_pRequest = new SfxRequest( rReq );
-                    pImpl->m_pLinkedDlg->StartExecuteModal( LINK( this, ScCellShell, DialogClosed ) );
-                    return;
-                }
+                    OUString sFile, sFilter, sOptions, sSource;
+                    sal_uLong nRefresh = 0;
+                    if (pImpl->m_pLinkedDlg->Execute() == RET_OK)
+                    {
+                        sFile = pImpl->m_pLinkedDlg->GetURL();
+                        sFilter = pImpl->m_pLinkedDlg->GetFilter();
+                        sOptions = pImpl->m_pLinkedDlg->GetOptions();
+                        sSource = pImpl->m_pLinkedDlg->GetSource();
+                        nRefresh = pImpl->m_pLinkedDlg->GetRefresh();
+                        if ( !sFile.isEmpty() )
+                            pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) );
+                        if ( !sFilter.isEmpty() )
+                            pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) );
+                        if ( !sOptions.isEmpty() )
+                            pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
+                        if ( !sSource.isEmpty() )
+                            pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) );
+                        if ( nRefresh )
+                            pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) );
+                    }
 
-                ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq );
+                    ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) );
+                }
             }
             break;
 
@@ -2959,35 +2979,6 @@ void ScCellShell::ExecuteFillSingleEdit()
     SC_MOD()->SetInputMode(SC_INPUT_TABLE, &aInit);
 }
 
-IMPL_LINK_NOARG(ScCellShell, DialogClosed, Dialog&, void)
-{
-    assert(pImpl->m_pLinkedDlg && "ScCellShell::DialogClosed(): invalid request");
-    assert(pImpl->m_pRequest && "ScCellShell::DialogClosed(): invalid request");
-    OUString sFile, sFilter, sOptions, sSource;
-    sal_uLong nRefresh = 0;
-
-    if ( pImpl->m_pLinkedDlg->GetResult() == RET_OK )
-    {
-        sFile = pImpl->m_pLinkedDlg->GetURL();
-        sFilter = pImpl->m_pLinkedDlg->GetFilter();
-        sOptions = pImpl->m_pLinkedDlg->GetOptions();
-        sSource = pImpl->m_pLinkedDlg->GetSource();
-        nRefresh = pImpl->m_pLinkedDlg->GetRefresh();
-        if ( !sFile.isEmpty() )
-            pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) );
-        if ( !sFilter.isEmpty() )
-            pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) );
-        if ( !sOptions.isEmpty() )
-            pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
-        if ( !sSource.isEmpty() )
-            pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) );
-        if ( nRefresh )
-            pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) );
-    }
-
-    ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) );
-}
-
 CellShell_Impl::~CellShell_Impl()
 {
 }


More information about the Libreoffice-commits mailing list