summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-04-04 14:16:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-04-05 06:39:09 +0000
commitcedbc4031f26ea13b188a4ecc5b90cc9646095fb (patch)
tree89cf1e537891e91fd4904211b72b471832280c33
parent156f778593ca9c57845076a88c6b544a63e12e7a (diff)
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@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/inc/arealink.hxx1
-rw-r--r--sc/inc/scabstdlg.hxx2
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx9
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx8
-rw-r--r--sc/source/ui/docshell/arealink.cxx32
-rw-r--r--sc/source/ui/view/cellsh1.cxx69
6 files changed, 57 insertions, 64 deletions
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 10e962129758..7e4f992dd900 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -223,7 +223,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 cfefb627df5e..61efb1bb4be4 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 140701b0bec9..feeca4df5377 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 428a8a3412a8..2b01cddb41c7 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(
@@ -481,23 +492,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 0a1f250ceb7b..81b63f69678c 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2538,16 +2538,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);
@@ -2559,6 +2559,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
{
@@ -2571,11 +2573,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;
@@ -2992,35 +3012,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() :
m_pLinkedDlg(),
m_pRequest( nullptr ) {}