sw/inc/docsh.hxx | 1 + sw/source/ui/chrdlg/numpara.cxx | 11 +++++++++-- sw/source/uibase/app/docst.cxx | 14 ++++++++++---- sw/source/uibase/inc/numpara.hxx | 4 ++-- 4 files changed, 22 insertions(+), 8 deletions(-)
New commits: commit e78a519285a5d2ca5ccc9ae6a5fda81975fa38d7 Author: Caolán McNamara <[email protected]> AuthorDate: Mon Nov 1 16:38:56 2021 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Mon Nov 1 20:35:49 2021 +0100 tdf#145363 provide an explicit parent for numbering-style dialog when launched from another dialog let it take that as the parent Change-Id: I64247b0b670c3e44176b6323c074cfd0711feefb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124558 Tested-by: Jenkins Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index 5dd105e1fdb3..73dc9cdee19d 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -128,6 +128,7 @@ class SW_DLLPUBLIC SwDocShell /// Only used for nFamily == SfxStyleFamily::Page. Identifies optional Slot by which the edit is triggered. /// Used to activate certain dialog pane SAL_DLLPRIVATE void Edit( + weld::Window* pDialogParent, const OUString &rName, const OUString& rParent, const SfxStyleFamily nFamily, diff --git a/sw/source/ui/chrdlg/numpara.cxx b/sw/source/ui/chrdlg/numpara.cxx index e57009b3b1fb..95b533c9c6bb 100644 --- a/sw/source/ui/chrdlg/numpara.cxx +++ b/sw/source/ui/chrdlg/numpara.cxx @@ -30,6 +30,7 @@ #include <numpara.hxx> #include <sfx2/dispatch.hxx> +#include <sfx2/frame.hxx> #include <sfx2/viewsh.hxx> const WhichRangesContainer SwParagraphNumTabPage::aPageRg(svl::Items<FN_NUMBER_NEWSTART, FN_NUMBER_NEWSTART_AT>); @@ -306,7 +307,6 @@ IMPL_LINK_NOARG(SwParagraphNumTabPage, EditNumStyleHdl_Impl, weld::Button&, void bool SwParagraphNumTabPage::ExecuteEditNumStyle_Impl( sal_uInt16 nId, const OUString &rStr, SfxStyleFamily nFamily) { - SfxDispatcher &rDispatcher = *SfxViewShell::Current()->GetDispatcher(); SfxStringItem aItem(nId, rStr); SfxUInt16Item aFamily(SID_STYLE_FAMILY, static_cast<sal_uInt16>(nFamily)); @@ -318,9 +318,16 @@ bool SwParagraphNumTabPage::ExecuteEditNumStyle_Impl( pItems[ nCount++ ] = nullptr; + // tdf#145363 we want the current dialog to be the parent of the new dialog + weld::Window* pDialogParent = GetFrameWeld(); + css::uno::Any aAny(pDialogParent->GetXWindow()); + SfxUnoAnyItem aDialogParent(SID_DIALOG_PARENT, aAny); + const SfxPoolItem* pInternalItems[ 1 ]; + pInternalItems[ 0 ] = &aDialogParent; + const SfxPoolItem* pItem = rDispatcher.Execute( nId, SfxCallMode::SYNCHRON | SfxCallMode::RECORD, - pItems ); + pItems, 0, pInternalItems); return pItem != nullptr; diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index 1654dfca3e36..f9514a81fc5c 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -319,7 +319,7 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) if (sName.isEmpty() && m_xBasePool) sName = SfxStyleDialogController::GenerateUnusedName(*m_xBasePool, nFamily); - Edit(sName, sParent, nFamily, nMask, true, OString(), nullptr, &rReq, nSlot); + Edit(rReq.GetFrameWeld(), sName, sParent, nFamily, nMask, true, OString(), nullptr, &rReq, nSlot); } break; @@ -491,7 +491,7 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) switch(nSlot) { case SID_STYLE_EDIT: - Edit(aParam, OUString(), nFamily, nMask, false, OString(), pActShell); + Edit(rReq.GetFrameWeld(), aParam, OUString(), nFamily, nMask, false, OString(), pActShell); break; case SID_STYLE_DELETE: Delete(aParam, nFamily); @@ -754,6 +754,7 @@ void syncEndnoteOrientation(const uno::Reference< style::XStyleFamiliesSupplier } void SwDocShell::Edit( + weld::Window* pDialogParent, const OUString &rName, const OUString &rParent, const SfxStyleFamily nFamily, @@ -953,7 +954,12 @@ void SwDocShell::Edit( FieldUnit eMetric = ::GetDfltMetric(0 != (HTMLMODE_ON&nHtmlMode)); SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric))); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - VclPtr<SfxAbstractApplyTabDialog> pDlg(pFact->CreateTemplateDialog(GetView()->GetFrameWeld(), + if (!pDialogParent) + { + SAL_WARN("sw.ui", "no parent for dialog supplied, assuming document frame is good enough"); + pDialogParent = GetView()->GetFrameWeld(); + } + VclPtr<SfxAbstractApplyTabDialog> pDlg(pFact->CreateTemplateDialog(pDialogParent, *xTmp, nFamily, sPage, pCurrShell, bNew)); auto pApplyStyleHelper = std::make_shared<ApplyStyle>(*this, bNew, xTmp, nFamily, pDlg.get(), m_xBasePool, bModified); pDlg->SetApplyHdl(LINK(pApplyStyleHelper.get(), ApplyStyle, ApplyHdl)); @@ -1627,7 +1633,7 @@ void SwDocShell::FormatPage( SwWrtShell& rActShell, SfxRequest* pRequest) { - Edit(rPage, OUString(), SfxStyleFamily::Page, SfxStyleSearchBits::Auto, false, rPageId, &rActShell, pRequest); + Edit(nullptr, rPage, OUString(), SfxStyleFamily::Page, SfxStyleSearchBits::Auto, false, rPageId, &rActShell, pRequest); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/numpara.hxx b/sw/source/uibase/inc/numpara.hxx index f6398cb96146..cf43a1b6b155 100644 --- a/sw/source/uibase/inc/numpara.hxx +++ b/sw/source/uibase/inc/numpara.hxx @@ -58,8 +58,8 @@ class SwParagraphNumTabPage final : public SfxTabPage static const WhichRangesContainer aPageRg; - static bool ExecuteEditNumStyle_Impl( sal_uInt16 nId, const OUString& rStr, - SfxStyleFamily nFamily ); + bool ExecuteEditNumStyle_Impl(sal_uInt16 nId, const OUString& rStr, + SfxStyleFamily nFamily); public: SwParagraphNumTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet );
