sw/source/ui/dialog/swdlgfact.cxx | 22 +++++++++++++ sw/source/ui/dialog/swdlgfact.hxx | 14 ++++++++ sw/source/ui/frmdlg/cption.cxx | 34 ++++++++++++--------- sw/source/uibase/shells/tabsh.cxx | 60 ++++++++++++++++++++------------------ vcl/jsdialog/enabled.cxx | 5 ++- 5 files changed, 90 insertions(+), 45 deletions(-)
New commits: commit 19d02a1267cfa1e7a950af31a77d4a7888594630 Author: Skyler Grey <skyler3...@gmail.com> AuthorDate: Fri Aug 12 10:31:42 2022 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Nov 21 11:17:21 2022 +0100 Make the number format dialog an async jsdialog - The dialog needs to be async in order for multiple people to be able to use it at once - If we don't make the item set a shared pointer, we will crash out with an error when we try to copy it after the OK button is pressed - As the dialog is tabbed, we need to enable the dialog for all UI files that the dialog uses rather than just the main dialog UI file Change-Id: I8d684e9e9ad49b8a85ee940864d7219b4115a6e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138270 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142990 Tested-by: Jenkins diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 68135716fcb9..56bce661390d 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -110,6 +110,16 @@ short SwAbstractSfxController_Impl::Execute() return m_xDlg->run(); } +short AbstractNumFormatDlg_Impl::Execute() +{ + return m_xDlg->run(); +} + +bool AbstractNumFormatDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return SfxSingleTabDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + short AbstractSwAsciiFilterDlg_Impl::Execute() { return m_xDlg->run(); @@ -356,11 +366,21 @@ const SfxItemSet* SwAbstractSfxController_Impl::GetOutputItemSet() const return m_xDlg->GetOutputItemSet(); } +const SfxItemSet* AbstractNumFormatDlg_Impl::GetOutputItemSet() const +{ + return m_xDlg->GetOutputItemSet(); +} + void SwAbstractSfxController_Impl::SetText(const OUString& rStr) { m_xDlg->set_title(rStr); } +void AbstractNumFormatDlg_Impl::SetText(const OUString& rStr) +{ + m_xDlg->set_title(rStr); +} + void AbstractSwAsciiFilterDlg_Impl::FillOptions( SwAsciiOptions& rOptions ) { m_xDlg->FillOptions(rOptions); @@ -833,7 +853,7 @@ VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwBackgroundDialog VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateNumFormatDialog(weld::Widget* pParent, const SfxItemSet& rSet) { - return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwNumFormatDlg>(pParent, rSet)); + return VclPtr<AbstractNumFormatDlg_Impl>::Create(std::make_shared<SwNumFormatDlg>(pParent, rSet)); } VclPtr<AbstractSwAsciiFilterDlg> SwAbstractDialogFactory_Impl::CreateSwAsciiFilterDlg(weld::Window* pParent, diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index c0326249a15b..5e110dfbdd59 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -126,6 +126,20 @@ public: virtual void SetText(const OUString& rStr) override; }; +class AbstractNumFormatDlg_Impl : public SfxAbstractDialog +{ + std::shared_ptr<SfxSingleTabDialogController> m_xDlg; +public: + explicit AbstractNumFormatDlg_Impl(std::shared_ptr<SfxSingleTabDialogController> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; + virtual const SfxItemSet* GetOutputItemSet() const override; + virtual void SetText(const OUString& rStr) override; +}; + class AbstractSwAsciiFilterDlg_Impl : public AbstractSwAsciiFilterDlg { std::unique_ptr<SwAsciiFilterDlg> m_xDlg; diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index ab93b027e69f..3082c5e36e98 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -695,58 +695,62 @@ void SwTableShell::Execute(SfxRequest &rReq) FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr ); SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric))); SvNumberFormatter* pFormatter = rSh.GetNumberFormatter(); - SfxItemSetFixed<SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO> - aCoreSet( GetPool() ); + auto pCoreSet = std::make_shared<SfxItemSetFixed<SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO>>( GetPool() ); SfxItemSetFixed<RES_BOXATR_FORMAT, RES_BOXATR_FORMAT, RES_BOXATR_VALUE, RES_BOXATR_VALUE> - aBoxSet( *aCoreSet.GetPool() ); + aBoxSet( *pCoreSet->GetPool() ); rSh.GetTableBoxFormulaAttrs( aBoxSet ); SfxItemState eState = aBoxSet.GetItemState(RES_BOXATR_FORMAT); if(eState == SfxItemState::DEFAULT) { - aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, + pCoreSet->Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, pFormatter->GetFormatIndex(NF_TEXT, LANGUAGE_SYSTEM))); } else - aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, + pCoreSet->Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, aBoxSet.Get( RES_BOXATR_FORMAT ).GetValue() )); OUString sCurText( rSh.GetTableBoxText() ); - aCoreSet.Put( SvxNumberInfoItem( pFormatter, + pCoreSet->Put( SvxNumberInfoItem( pFormatter, aBoxSet.Get( RES_BOXATR_VALUE).GetValue(), sCurText, SID_ATTR_NUMBERFORMAT_INFO )); + SwWrtShell* pSh = &rSh; SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateNumFormatDialog(GetView().GetFrameWeld(), aCoreSet)); - - if (RET_OK == pDlg->Execute()) - { - const SvxNumberInfoItem* pNumberFormatItem - = GetView().GetDocShell()->GetItem( SID_ATTR_NUMBERFORMAT_INFO ); + VclPtr<SfxAbstractDialog> pDlg(pFact->CreateNumFormatDialog(GetView().GetFrameWeld(), *pCoreSet)); - if( pNumberFormatItem ) + pDlg->StartExecuteAsync([pDlg, pCoreSet, pSh](sal_uInt32 nResult){ + if (RET_OK == nResult) { - for ( sal_uInt32 key : pNumberFormatItem->GetDelFormats() ) - pNumberFormatItem->GetNumberFormatter()->DeleteEntry( key ); + const SvxNumberInfoItem* pNumberFormatItem + = pSh->GetView().GetDocShell()->GetItem( SID_ATTR_NUMBERFORMAT_INFO ); + + if( pNumberFormatItem ) + { + for ( sal_uInt32 key : pNumberFormatItem->GetDelFormats() ) + pNumberFormatItem->GetNumberFormatter()->DeleteEntry( key ); + } + + const SfxPoolItem* pNumberFormatValueItem = + pDlg->GetOutputItemSet()->GetItemIfSet( + SID_ATTR_NUMBERFORMAT_VALUE, false); + if( pNumberFormatValueItem ) + { + SfxItemSetFixed<RES_BOXATR_FORMAT, RES_BOXATR_FORMAT> + aBoxFormatSet( *pCoreSet->GetPool() ); + aBoxFormatSet.Put( SwTableBoxNumFormat( + static_cast<const SfxUInt32Item*>(pNumberFormatValueItem)->GetValue() )); + pSh->SetTableBoxFormulaAttrs( aBoxFormatSet ); + + } } - const SfxUInt32Item* pNumberFormatValueItem = - pDlg->GetOutputItemSet()->GetItemIfSet( - SID_ATTR_NUMBERFORMAT_VALUE, false); - if( pNumberFormatValueItem ) - { - SfxItemSetFixed<RES_BOXATR_FORMAT, RES_BOXATR_FORMAT> - aBoxFormatSet( *aCoreSet.GetPool() ); - aBoxFormatSet.Put( SwTableBoxNumFormat( - pNumberFormatValueItem->GetValue() )); - rSh.SetTableBoxFormulaAttrs( aBoxFormatSet ); - - } - } + pDlg->disposeOnce(); + }); } break; } diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 506838da2cff..ca930621ea31 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -71,7 +71,9 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile) || rUIFile == u"sfx/ui/descriptioninfopage.ui" || rUIFile == u"sfx/ui/documentinfopage.ui" || rUIFile == u"sfx/ui/linefragment.ui" || rUIFile == u"sfx/ui/editdurationdialog.ui" || rUIFile == u"modules/swriter/ui/insertcaption.ui" - || rUIFile == u"modules/swriter/ui/captionoptions.ui") + || rUIFile == u"modules/swriter/ui/captionoptions.ui" + || rUIFile == u"cui/ui/formatnumberdialog.ui" + || rUIFile == u"cui/ui/numberingformatpage.ui") { return true; } commit 4b4e7ac74e2b72833de6b464b25b077b7541f43a Author: Skyler Grey <skyler3...@gmail.com> AuthorDate: Wed Aug 17 13:17:25 2022 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Nov 21 11:17:07 2022 +0100 Make the insert caption options an async jsdialog - In https://gerrit.libreoffice.org/c/core/+/138313, the insert caption dialog was converted to an async jsdialog. It has 2 subdialogs which it opens when you press the 'options' and 'auto' buttons - This review converts the first of these (the options dialog) to an async jsdialog as well, bringing it up to parity with the parent dialog Change-Id: I703b66d8c786d8cbb0b1285014247b38d8d70605 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138442 Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142989 Tested-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx index 8b3c14afe0a6..ce67b81de2f1 100644 --- a/sw/source/ui/frmdlg/cption.cxx +++ b/sw/source/ui/frmdlg/cption.cxx @@ -313,21 +313,25 @@ IMPL_LINK_NOARG(SwCaptionDialog, OptionHdl, weld::Button&, void) OUString sFieldTypeName = m_xCategoryBox->get_active_text(); if(sFieldTypeName == m_sNone) sFieldTypeName.clear(); - SwSequenceOptionDialog aDlg(m_xDialog.get(), m_rView, sFieldTypeName); - aDlg.SetApplyBorderAndShadow(m_bCopyAttributes); - aDlg.SetCharacterStyle( m_sCharacterStyle ); - aDlg.SetOrderNumberingFirst( m_bOrderNumberingFirst ); - aDlg.run(); - m_bCopyAttributes = aDlg.IsApplyBorderAndShadow(); - m_sCharacterStyle = aDlg.GetCharacterStyle(); - //#i61007# order of captions - if( m_bOrderNumberingFirst != aDlg.IsOrderNumberingFirst() ) - { - m_bOrderNumberingFirst = aDlg.IsOrderNumberingFirst(); - SW_MOD()->GetModuleConfig()->SetCaptionOrderNumberingFirst(m_bOrderNumberingFirst); - ApplyCaptionOrder(); - } - DrawSample(); + auto pDlg = std::make_shared<SwSequenceOptionDialog>(m_xDialog.get(), m_rView, sFieldTypeName); + pDlg->SetApplyBorderAndShadow(m_bCopyAttributes); + pDlg->SetCharacterStyle( m_sCharacterStyle ); + pDlg->SetOrderNumberingFirst( m_bOrderNumberingFirst ); + + GenericDialogController::runAsync(pDlg, [pDlg, this](sal_Int32 nResult){ + if (nResult == RET_OK) { + m_bCopyAttributes = pDlg->IsApplyBorderAndShadow(); + m_sCharacterStyle = pDlg->GetCharacterStyle(); + //#i61007# order of captions + if( m_bOrderNumberingFirst != pDlg->IsOrderNumberingFirst() ) + { + m_bOrderNumberingFirst = pDlg->IsOrderNumberingFirst(); + SW_MOD()->GetModuleConfig()->SetCaptionOrderNumberingFirst(m_bOrderNumberingFirst); + ApplyCaptionOrder(); + } + DrawSample(); + } + }); } IMPL_LINK_NOARG(SwCaptionDialog, SelectListBoxHdl, weld::ComboBox&, void) diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 89b50c96fab1..506838da2cff 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -70,7 +70,8 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile) || rUIFile == u"sfx/ui/custominfopage.ui" || rUIFile == u"sfx/ui/cmisinfopage.ui" || rUIFile == u"sfx/ui/descriptioninfopage.ui" || rUIFile == u"sfx/ui/documentinfopage.ui" || rUIFile == u"sfx/ui/linefragment.ui" || rUIFile == u"sfx/ui/editdurationdialog.ui" - || rUIFile == u"modules/swriter/ui/insertcaption.ui") + || rUIFile == u"modules/swriter/ui/insertcaption.ui" + || rUIFile == u"modules/swriter/ui/captionoptions.ui") { return true; }