From 7c4fe800c2b4f5150ff7193a45710304bcdf25f0 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 29 Apr 2016 16:36:25 +0200 Subject: sw: try to survive restoring a field dialog without SfxObjectShell The SFX will apparently restore the field dialog on startup if it was open on the last shutdown. Since i don't know how to disable this useless "feature", let's fudge things a bit so we don't crash immediately. Change-Id: I2c401440374d055774fdc8fcbd79a1262c42da0b (cherry picked from commit bf47fef3a87d8546f18a36ade4e85f7c6ecf993b) Reviewed-on: https://gerrit.libreoffice.org/24614 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- sw/source/ui/fldui/flddb.cxx | 8 ++++---- sw/source/ui/fldui/flddb.hxx | 2 +- sw/source/ui/fldui/flddinf.cxx | 12 +++++++----- sw/source/ui/fldui/flddinf.hxx | 2 +- sw/source/ui/fldui/flddok.cxx | 8 ++++---- sw/source/ui/fldui/flddok.hxx | 2 +- sw/source/ui/fldui/fldfunc.cxx | 8 ++++---- sw/source/ui/fldui/fldfunc.hxx | 2 +- sw/source/ui/fldui/fldpage.cxx | 5 +++-- sw/source/ui/fldui/fldpage.hxx | 2 +- sw/source/ui/fldui/fldref.cxx | 8 ++++---- sw/source/ui/fldui/fldref.hxx | 2 +- sw/source/ui/fldui/fldtdlg.cxx | 4 ++-- sw/source/ui/fldui/fldvar.cxx | 8 ++++---- sw/source/ui/fldui/fldvar.hxx | 2 +- 15 files changed, 39 insertions(+), 36 deletions(-) diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index 45fe095adea5..f3ddc962ecbf 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -33,9 +33,9 @@ #define USER_DATA_VERSION_1 "1" #define USER_DATA_VERSION USER_DATA_VERSION_1 -SwFieldDBPage::SwFieldDBPage(vcl::Window* pParent, const SfxItemSet& rCoreSet) +SwFieldDBPage::SwFieldDBPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet) : SwFieldPage(pParent, "FieldDbPage", - "modules/swriter/ui/flddbpage.ui", rCoreSet) + "modules/swriter/ui/flddbpage.ui", pCoreSet) , m_nOldFormat(0) , m_nOldSubType(0) { @@ -265,9 +265,9 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* ) } VclPtr SwFieldDBPage::Create( vcl::Window* pParent, - const SfxItemSet* rAttrSet ) + const SfxItemSet *const pAttrSet ) { - return VclPtr::Create( pParent, *rAttrSet ); + return VclPtr::Create( pParent, pAttrSet ); } sal_uInt16 SwFieldDBPage::GetGroup() diff --git a/sw/source/ui/fldui/flddb.hxx b/sw/source/ui/fldui/flddb.hxx index 6fcf77ef559e..dc635614b022 100644 --- a/sw/source/ui/fldui/flddb.hxx +++ b/sw/source/ui/fldui/flddb.hxx @@ -69,7 +69,7 @@ protected: virtual sal_uInt16 GetGroup() override; public: - SwFieldDBPage(vcl::Window* pParent, const SfxItemSet& rSet); + SwFieldDBPage(vcl::Window* pParent, const SfxItemSet* rSet); virtual ~SwFieldDBPage(); virtual void dispose() override; diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx index 58ea65708db5..b47988fc6a1f 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -47,9 +47,9 @@ using namespace nsSwDocInfoSubType; using namespace com::sun::star; -SwFieldDokInfPage::SwFieldDokInfPage(vcl::Window* pParent, const SfxItemSet& rCoreSet) +SwFieldDokInfPage::SwFieldDokInfPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet) : SwFieldPage(pParent, "FieldDocInfoPage", - "modules/swriter/ui/flddocinfopage.ui", rCoreSet) + "modules/swriter/ui/flddocinfopage.ui", pCoreSet) , pSelEntry(nullptr) , nOldSel(0) , nOldFormat(0) @@ -82,7 +82,9 @@ SwFieldDokInfPage::SwFieldDokInfPage(vcl::Window* pParent, const SfxItemSet& rCo //enable 'active' language selection m_pFormatLB->SetShowLanguageControl(true); - const SfxUnoAnyItem* pItem = rCoreSet.GetItem(SID_DOCINFO, false); + const SfxUnoAnyItem* pItem = (pCoreSet) + ? pCoreSet->GetItem(SID_DOCINFO, false) + : nullptr; if ( pItem ) pItem->GetValue() >>= xCustomPropertySet; } @@ -459,9 +461,9 @@ bool SwFieldDokInfPage::FillItemSet(SfxItemSet* ) } VclPtr SwFieldDokInfPage::Create( vcl::Window* pParent, - const SfxItemSet* rAttrSet ) + const SfxItemSet *const pAttrSet) { - return VclPtr::Create( pParent, *rAttrSet ); + return VclPtr::Create( pParent, pAttrSet ); } sal_uInt16 SwFieldDokInfPage::GetGroup() diff --git a/sw/source/ui/fldui/flddinf.hxx b/sw/source/ui/fldui/flddinf.hxx index a15fcbcdbcb2..f90394cfe47a 100644 --- a/sw/source/ui/fldui/flddinf.hxx +++ b/sw/source/ui/fldui/flddinf.hxx @@ -59,7 +59,7 @@ protected: virtual sal_uInt16 GetGroup() override; public: - SwFieldDokInfPage(vcl::Window* pWindow, const SfxItemSet& rSet); + SwFieldDokInfPage(vcl::Window* pWindow, const SfxItemSet* pSet); virtual ~SwFieldDokInfPage(); virtual void dispose() override; diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx index 00d91dc60038..d73b2570d1d0 100644 --- a/sw/source/ui/fldui/flddok.cxx +++ b/sw/source/ui/fldui/flddok.cxx @@ -34,9 +34,9 @@ #define USER_DATA_VERSION_1 "1" #define USER_DATA_VERSION USER_DATA_VERSION_1 -SwFieldDokPage::SwFieldDokPage(vcl::Window* pParent, const SfxItemSet& rCoreSet ) +SwFieldDokPage::SwFieldDokPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet) : SwFieldPage(pParent, "FieldDocumentPage", - "modules/swriter/ui/flddocumentpage.ui", rCoreSet) + "modules/swriter/ui/flddocumentpage.ui", pCoreSet) , nOldSel(0) , nOldFormat(0) { @@ -648,9 +648,9 @@ bool SwFieldDokPage::FillItemSet(SfxItemSet* ) } VclPtr SwFieldDokPage::Create( vcl::Window* pParent, - const SfxItemSet* rAttrSet ) + const SfxItemSet *const pAttrSet) { - return VclPtr::Create( pParent, *rAttrSet ); + return VclPtr::Create( pParent, pAttrSet ); } sal_uInt16 SwFieldDokPage::GetGroup() diff --git a/sw/source/ui/fldui/flddok.hxx b/sw/source/ui/fldui/flddok.hxx index d103b8f118f1..1c3245c4b6e6 100644 --- a/sw/source/ui/fldui/flddok.hxx +++ b/sw/source/ui/fldui/flddok.hxx @@ -61,7 +61,7 @@ protected: virtual sal_uInt16 GetGroup() override; public: - SwFieldDokPage(vcl::Window* pWindow, const SfxItemSet& rSet); + SwFieldDokPage(vcl::Window* pWindow, const SfxItemSet * pSet); virtual ~SwFieldDokPage(); virtual void dispose() override; diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx index aa8c6e9523b8..6069b4837d2c 100644 --- a/sw/source/ui/fldui/fldfunc.cxx +++ b/sw/source/ui/fldui/fldfunc.cxx @@ -37,9 +37,9 @@ using namespace ::com::sun::star; -SwFieldFuncPage::SwFieldFuncPage(vcl::Window* pParent, const SfxItemSet& rCoreSet) +SwFieldFuncPage::SwFieldFuncPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet) : SwFieldPage(pParent, "FieldFuncPage", - "modules/swriter/ui/fldfuncpage.ui", rCoreSet) + "modules/swriter/ui/fldfuncpage.ui", pCoreSet) , nOldFormat(0) , bDropDownLBChanged(false) { @@ -630,9 +630,9 @@ OUString SwFieldFuncPage::TurnMacroString(const OUString &rMacro) } VclPtr SwFieldFuncPage::Create( vcl::Window* pParent, - const SfxItemSet* rAttrSet ) + const SfxItemSet *const pAttrSet) { - return VclPtr::Create( pParent, *rAttrSet ); + return VclPtr::Create( pParent, pAttrSet ); } sal_uInt16 SwFieldFuncPage::GetGroup() diff --git a/sw/source/ui/fldui/fldfunc.hxx b/sw/source/ui/fldui/fldfunc.hxx index 7effcb4d0929..8615879317db 100644 --- a/sw/source/ui/fldui/fldfunc.hxx +++ b/sw/source/ui/fldui/fldfunc.hxx @@ -86,7 +86,7 @@ protected: virtual sal_uInt16 GetGroup() override; public: - SwFieldFuncPage(vcl::Window* pParent, const SfxItemSet& rSet); + SwFieldFuncPage(vcl::Window* pParent, const SfxItemSet* pSet); virtual ~SwFieldFuncPage(); virtual void dispose() override; diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx index afd645ac8bcc..618310d810f3 100644 --- a/sw/source/ui/fldui/fldpage.cxx +++ b/sw/source/ui/fldui/fldpage.cxx @@ -41,9 +41,10 @@ using namespace ::com::sun::star; +// note: pAttrSet may be null if the dialog is restored on startup SwFieldPage::SwFieldPage(vcl::Window *pParent, const OString& rID, - const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet) - : SfxTabPage(pParent, rID, rUIXMLDescription, &rAttrSet) + const OUString& rUIXMLDescription, const SfxItemSet *const pAttrSet) + : SfxTabPage(pParent, rID, rUIXMLDescription, pAttrSet) , m_pCurField(nullptr) , m_pWrtShell(nullptr) , m_nTypeSel(LISTBOX_ENTRY_NOTFOUND) diff --git a/sw/source/ui/fldui/fldpage.hxx b/sw/source/ui/fldui/fldpage.hxx index 68580af6d0fc..fa186d4ab582 100644 --- a/sw/source/ui/fldui/fldpage.hxx +++ b/sw/source/ui/fldui/fldpage.hxx @@ -81,7 +81,7 @@ protected: public: SwFieldPage(vcl::Window *pParent, const OString& rID, - const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet); + const OUString& rUIXMLDescription, const SfxItemSet *pAttrSet); virtual ~SwFieldPage(); diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index 66a5a42d43bf..b5d72b56e31e 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -47,9 +47,9 @@ static sal_uInt16 nFieldDlgFormatSel = 0; #define USER_DATA_VERSION_1 "1" #define USER_DATA_VERSION USER_DATA_VERSION_1 -SwFieldRefPage::SwFieldRefPage(vcl::Window* pParent, const SfxItemSet& rCoreSet ) +SwFieldRefPage::SwFieldRefPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet ) : SwFieldPage(pParent, "FieldRefPage", - "modules/swriter/ui/fldrefpage.ui", rCoreSet) + "modules/swriter/ui/fldrefpage.ui", pCoreSet) , maOutlineNodes() , maNumItems() , mpSavedSelectedTextNode(nullptr) @@ -958,9 +958,9 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) } VclPtr SwFieldRefPage::Create( vcl::Window* pParent, - const SfxItemSet* rAttrSet ) + const SfxItemSet *const pAttrSet) { - return VclPtr::Create( pParent, *rAttrSet ); + return VclPtr::Create( pParent, pAttrSet ); } sal_uInt16 SwFieldRefPage::GetGroup() diff --git a/sw/source/ui/fldui/fldref.hxx b/sw/source/ui/fldui/fldref.hxx index f06f114d6585..7f159034f198 100644 --- a/sw/source/ui/fldui/fldref.hxx +++ b/sw/source/ui/fldui/fldref.hxx @@ -76,7 +76,7 @@ protected: virtual sal_uInt16 GetGroup() override; public: - SwFieldRefPage(vcl::Window* pParent, const SfxItemSet& rSet); + SwFieldRefPage(vcl::Window* pParent, const SfxItemSet* pSet); virtual ~SwFieldRefPage(); virtual void dispose() override; diff --git a/sw/source/ui/fldui/fldtdlg.cxx b/sw/source/ui/fldui/fldtdlg.cxx index abb00aaefccb..72cfc891e05b 100644 --- a/sw/source/ui/fldui/fldtdlg.cxx +++ b/sw/source/ui/fldui/fldtdlg.cxx @@ -159,9 +159,9 @@ void SwFieldDlg::Initialize(SfxChildWinInfo *pInfo) SfxItemSet* SwFieldDlg::CreateInputItemSet( sal_uInt16 nID ) { - if ( nID == m_nDokInf ) + SwDocShell *const pDocSh(static_cast(SfxObjectShell::Current())); + if (nID == m_nDokInf && pDocSh) // might not have a shell if the dialog is restored on startup { - SwDocShell* pDocSh = static_cast(SfxObjectShell::Current()); SfxItemSet* pISet = new SfxItemSet( pDocSh->GetPool(), SID_DOCINFO, SID_DOCINFO ); using namespace ::com::sun::star; uno::Reference xDPS( diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx index 08e97332bfa2..0d4637a11eee 100644 --- a/sw/source/ui/fldui/fldvar.cxx +++ b/sw/source/ui/fldui/fldvar.cxx @@ -39,9 +39,9 @@ #define USER_DATA_VERSION_1 "1" #define USER_DATA_VERSION USER_DATA_VERSION_1 -SwFieldVarPage::SwFieldVarPage(vcl::Window* pParent, const SfxItemSet& rCoreSet ) +SwFieldVarPage::SwFieldVarPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet ) : SwFieldPage(pParent, "FieldVarPage", - "modules/swriter/ui/fldvarpage.ui", rCoreSet) + "modules/swriter/ui/fldvarpage.ui", pCoreSet) , nOldFormat(0) , bInit(true) { @@ -1242,9 +1242,9 @@ bool SwFieldVarPage::FillItemSet(SfxItemSet* ) } VclPtr SwFieldVarPage::Create( vcl::Window* pParent, - const SfxItemSet* rAttrSet ) + const SfxItemSet *const pAttrSet) { - return VclPtr::Create( pParent, *rAttrSet ); + return VclPtr::Create( pParent, pAttrSet ); } sal_uInt16 SwFieldVarPage::GetGroup() diff --git a/sw/source/ui/fldui/fldvar.hxx b/sw/source/ui/fldui/fldvar.hxx index 853edf348e74..dbc4c3994169 100644 --- a/sw/source/ui/fldui/fldvar.hxx +++ b/sw/source/ui/fldui/fldvar.hxx @@ -91,7 +91,7 @@ protected: virtual sal_uInt16 GetGroup() override; public: - SwFieldVarPage(vcl::Window* pParent, const SfxItemSet& rSet); + SwFieldVarPage(vcl::Window* pParent, const SfxItemSet* pSet); virtual ~SwFieldVarPage(); virtual void dispose() override; -- cgit v1.2.3