include/vcl/jsdialog/executor.hxx | 2 include/vcl/toolkit/dialog.hxx | 3 sc/source/ui/attrdlg/scdlgfact.cxx | 21 ++ sc/source/ui/attrdlg/scdlgfact.hxx | 15 +- sc/source/ui/cctrl/checklistmenu.cxx | 20 ++ sc/source/ui/view/cellsh1.cxx | 254 ++++++++++++++++++++--------------- sc/source/ui/view/gridwin2.cxx | 8 - vcl/inc/jsdialog/jsdialogbuilder.hxx | 55 +++++++ vcl/jsdialog/executor.cxx | 34 ++++ vcl/jsdialog/jsdialogbuilder.cxx | 133 +++++++++++++++++- vcl/source/window/builder.cxx | 30 ++-- vcl/source/window/dialog.cxx | 37 ++++- 12 files changed, 474 insertions(+), 138 deletions(-)
New commits: commit e02eebde65bfe427b56970ef2704a8f746ac563d Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Dec 2 15:06:35 2020 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Apr 7 13:05:36 2021 +0200 jsdialog: use valid window instance Change-Id: I3b7e98de41f56abbab1d8c15b7928089ebf8159a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107077 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107339 Tested-by: Jenkins diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 051c90c7b6db..3c663bac10e0 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -363,12 +363,6 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) InsertWindowToMap(m_nWindowId); - std::unique_ptr<weld::Dialog> pRet(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, - pDialog, this, false, m_sTypeOfJSON) - : nullptr); - - RememberWidget("__DIALOG__", pRet.get()); - if (pDialog) { assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); @@ -377,6 +371,12 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) m_bHasTopLevelDialog = true; } + std::unique_ptr<weld::Dialog> pRet(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, + pDialog, this, false, m_sTypeOfJSON) + : nullptr); + + RememberWidget("__DIALOG__", pRet.get()); + const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier(); if (pNotifier) { commit cd96198e70c29865c96fa3daebe5a0f5b506a5ed Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Mon Nov 30 05:55:55 2020 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Apr 7 13:05:04 2021 +0200 Make Pivot table db & external source dialogs async Change-Id: Iff1a49a9fa04b55ece1aa30259ab57d105883eda Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106996 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108798 Tested-by: Jenkins diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 295d61f5270a..00b62493743f 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -105,6 +105,11 @@ short AbstractScDataPilotDatabaseDlg_Impl::Execute() return m_xDlg->run(); } +bool AbstractScDataPilotDatabaseDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + short AbstractScDataPilotSourceTypeDlg_Impl::Execute() { return m_xDlg->run(); @@ -120,6 +125,11 @@ short AbstractScDataPilotServiceDlg_Impl::Execute() return m_xDlg->run(); } +bool AbstractScDataPilotServiceDlg_Impl::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) +{ + return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + short AbstractScDeleteCellDlg_Impl::Execute() { return m_xDlg->run(); @@ -985,7 +995,7 @@ VclPtr<AbstractScCondFormatManagerDlg> ScAbstractDialogFactory_Impl::CreateScCon VclPtr<AbstractScDataPilotDatabaseDlg> ScAbstractDialogFactory_Impl::CreateScDataPilotDatabaseDlg(weld::Window* pParent) { - return VclPtr<AbstractScDataPilotDatabaseDlg_Impl>::Create(std::make_unique<ScDataPilotDatabaseDlg>(pParent)); + return VclPtr<AbstractScDataPilotDatabaseDlg_Impl>::Create(std::make_shared<ScDataPilotDatabaseDlg>(pParent)); } VclPtr<AbstractScDataPilotSourceTypeDlg> ScAbstractDialogFactory_Impl::CreateScDataPilotSourceTypeDlg( @@ -997,7 +1007,7 @@ VclPtr<AbstractScDataPilotSourceTypeDlg> ScAbstractDialogFactory_Impl::CreateScD VclPtr<AbstractScDataPilotServiceDlg> ScAbstractDialogFactory_Impl::CreateScDataPilotServiceDlg(weld::Window* pParent, const std::vector<OUString>& rServices) { - return VclPtr<AbstractScDataPilotServiceDlg_Impl>::Create(std::make_unique<ScDataPilotServiceDlg>(pParent, rServices)); + return VclPtr<AbstractScDataPilotServiceDlg_Impl>::Create(std::make_shared<ScDataPilotServiceDlg>(pParent, rServices)); } VclPtr<AbstractScDeleteCellDlg> ScAbstractDialogFactory_Impl::CreateScDeleteCellDlg(weld::Window* pParent, diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index aaa94d0ddae9..088dae2b5547 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -165,13 +165,14 @@ public: class AbstractScDataPilotDatabaseDlg_Impl :public AbstractScDataPilotDatabaseDlg { - std::unique_ptr<ScDataPilotDatabaseDlg> m_xDlg; + std::shared_ptr<ScDataPilotDatabaseDlg> m_xDlg; public: - explicit AbstractScDataPilotDatabaseDlg_Impl(std::unique_ptr<ScDataPilotDatabaseDlg> p) + explicit AbstractScDataPilotDatabaseDlg_Impl(std::shared_ptr<ScDataPilotDatabaseDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &) override; virtual void GetValues( ScImportSourceDesc& rDesc ) override; // screenshotting @@ -202,13 +203,14 @@ public: class AbstractScDataPilotServiceDlg_Impl : public AbstractScDataPilotServiceDlg { - std::unique_ptr<ScDataPilotServiceDlg> m_xDlg; + std::shared_ptr<ScDataPilotServiceDlg> m_xDlg; public: - explicit AbstractScDataPilotServiceDlg_Impl(std::unique_ptr<ScDataPilotServiceDlg> p) + explicit AbstractScDataPilotServiceDlg_Impl(std::shared_ptr<ScDataPilotServiceDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &) override; virtual OUString GetServiceName() const override; virtual OUString GetParSource() const override; virtual OUString GetParName() const override; diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index d49fe9f32188..84e6422d3511 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2956,124 +2956,149 @@ void ScCellShell::ExecuteDataPilotDialog() pTypeDlg->StartExecuteAsync([this, pTypeDlg, pTabViewShell, pScMod, pFact, &rDoc, &rMark, aDestPos](int nResult) mutable { - const char* pSrcErrorId = nullptr; - std::unique_ptr<ScDPObject> pNewDPObject; if (nResult == RET_OK ) { if ( pTypeDlg->IsExternal() ) { std::vector<OUString> aSources = ScDPObject::GetRegisteredSources(); - ScopedVclPtr<AbstractScDataPilotServiceDlg> pServDlg( + VclPtr<AbstractScDataPilotServiceDlg> pServDlg( pFact->CreateScDataPilotServiceDlg( pTabViewShell->GetFrameWeld(), aSources)); - if ( pServDlg->Execute() == RET_OK ) - { - ScDPServiceDesc aServDesc( - pServDlg->GetServiceName(), - pServDlg->GetParSource(), - pServDlg->GetParName(), - pServDlg->GetParUser(), - pServDlg->GetParPass() ); - pNewDPObject.reset(new ScDPObject(&rDoc)); - pNewDPObject->SetServiceData( aServDesc ); - } + pServDlg->StartExecuteAsync([pServDlg, pScMod, pTabViewShell, + aDestPos, &rDoc](int nResult2) mutable { + if ( nResult2 == RET_OK ) + { + ScDPServiceDesc aServDesc( + pServDlg->GetServiceName(), + pServDlg->GetParSource(), + pServDlg->GetParName(), + pServDlg->GetParUser(), + pServDlg->GetParPass() ); + std::unique_ptr<ScDPObject> pNewDPObject(new ScDPObject(&rDoc)); + pNewDPObject->SetServiceData( aServDesc ); + + if ( pNewDPObject ) + pNewDPObject->SetOutRange( aDestPos ); + + RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject); + } + + pServDlg->disposeOnce(); + }); } else if ( pTypeDlg->IsDatabase() ) { assert(pFact && "ScAbstractFactory create fail!"); - ScopedVclPtr<AbstractScDataPilotDatabaseDlg> pDataDlg( + VclPtr<AbstractScDataPilotDatabaseDlg> pDataDlg( pFact->CreateScDataPilotDatabaseDlg(pTabViewShell->GetFrameWeld())); assert(pDataDlg && "Dialog create fail!"); - if ( pDataDlg->Execute() == RET_OK ) - { - ScImportSourceDesc aImpDesc(&rDoc); - pDataDlg->GetValues( aImpDesc ); - pNewDPObject.reset(new ScDPObject(&rDoc)); - pNewDPObject->SetImportDesc( aImpDesc ); - } + + pDataDlg->StartExecuteAsync([pDataDlg, pScMod, pTabViewShell, + aDestPos, &rDoc](int nResult2) mutable { + if ( nResult2 == RET_OK ) + { + ScImportSourceDesc aImpDesc(&rDoc); + pDataDlg->GetValues( aImpDesc ); + std::unique_ptr<ScDPObject> pNewDPObject(new ScDPObject(&rDoc)); + pNewDPObject->SetImportDesc( aImpDesc ); + + if ( pNewDPObject ) + pNewDPObject->SetOutRange( aDestPos ); + + RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject); + } + + pDataDlg->disposeOnce(); + }); } - else if (pTypeDlg->IsNamedRange()) + else { - OUString aName = pTypeDlg->GetSelectedNamedRange(); - ScSheetSourceDesc aShtDesc(&rDoc); - aShtDesc.SetRangeName(aName); - pSrcErrorId = aShtDesc.CheckSourceRange(); - if (!pSrcErrorId) + std::unique_ptr<ScDPObject> pNewDPObject; + const char* pSrcErrorId = nullptr; + + if (pTypeDlg->IsNamedRange()) { - pNewDPObject.reset(new ScDPObject(&rDoc)); - pNewDPObject->SetSheetDesc(aShtDesc); + OUString aName = pTypeDlg->GetSelectedNamedRange(); + ScSheetSourceDesc aShtDesc(&rDoc); + aShtDesc.SetRangeName(aName); + pSrcErrorId = aShtDesc.CheckSourceRange(); + if (!pSrcErrorId) + { + pNewDPObject.reset(new ScDPObject(&rDoc)); + pNewDPObject->SetSheetDesc(aShtDesc); + } } - } - else // selection - { - //! use database ranges (select before type dialog?) - ScRange aRange; - ScMarkType eType = GetViewData()->GetSimpleArea(aRange); - if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE ) + else // selection { - // Shrink the range to the data area. - SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col(); - SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row(); - if (rDoc.ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow)) + //! use database ranges (select before type dialog?) + ScRange aRange; + ScMarkType eType = GetViewData()->GetSimpleArea(aRange); + if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE ) { - aRange.aStart.SetCol(nStartCol); - aRange.aStart.SetRow(nStartRow); - aRange.aEnd.SetCol(nEndCol); - aRange.aEnd.SetRow(nEndRow); - rMark.SetMarkArea(aRange); - pTabViewShell->MarkRange(aRange); - } + // Shrink the range to the data area. + SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col(); + SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row(); + if (rDoc.ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow)) + { + aRange.aStart.SetCol(nStartCol); + aRange.aStart.SetRow(nStartRow); + aRange.aEnd.SetCol(nEndCol); + aRange.aEnd.SetRow(nEndRow); + rMark.SetMarkArea(aRange); + pTabViewShell->MarkRange(aRange); + } - bool bOK = true; - if ( rDoc.HasSubTotalCells( aRange ) ) - { - // confirm selection if it contains SubTotal cells - std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), - VclMessageType::Question, VclButtonsType::YesNo, - ScResId(STR_DATAPILOT_SUBTOTAL))); - xQueryBox->set_default_response(RET_YES); - if (xQueryBox->run() == RET_NO) - bOK = false; - } - if (bOK) - { - ScSheetSourceDesc aShtDesc(&rDoc); - aShtDesc.SetSourceRange(aRange); - pSrcErrorId = aShtDesc.CheckSourceRange(); - if (!pSrcErrorId) + bool bOK = true; + if ( rDoc.HasSubTotalCells( aRange ) ) { - pNewDPObject.reset(new ScDPObject(&rDoc)); - pNewDPObject->SetSheetDesc( aShtDesc ); + // confirm selection if it contains SubTotal cells + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + ScResId(STR_DATAPILOT_SUBTOTAL))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_NO) + bOK = false; } + if (bOK) + { + ScSheetSourceDesc aShtDesc(&rDoc); + aShtDesc.SetSourceRange(aRange); + pSrcErrorId = aShtDesc.CheckSourceRange(); + if (!pSrcErrorId) + { + pNewDPObject.reset(new ScDPObject(&rDoc)); + pNewDPObject->SetSheetDesc( aShtDesc ); + } - // output below source data - if ( aRange.aEnd.Row()+2 <= rDoc.MaxRow() - 4 ) - aDestPos = ScAddress( aRange.aStart.Col(), - aRange.aEnd.Row()+2, - aRange.aStart.Tab() ); + // output below source data + if ( aRange.aEnd.Row()+2 <= rDoc.MaxRow() - 4 ) + aDestPos = ScAddress( aRange.aStart.Col(), + aRange.aEnd.Row()+2, + aRange.aStart.Tab() ); + } } } - } - } - if (pSrcErrorId) - { - // Error occurred during data creation. Launch an error and bail out. - std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), - VclMessageType::Info, VclButtonsType::Ok, - ScResId(pSrcErrorId))); - xInfoBox->run(); - return; - } + if (pSrcErrorId) + { + // Error occurred during data creation. Launch an error and bail out. + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + ScResId(pSrcErrorId))); + xInfoBox->run(); + return; + } - if ( pNewDPObject ) - pNewDPObject->SetOutRange( aDestPos ); + if ( pNewDPObject ) + pNewDPObject->SetOutRange( aDestPos ); - pTypeDlg->disposeOnce(); + RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject); + } + } - RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject); + pTypeDlg->disposeOnce(); }); } } commit 5e660a454f91b9fff0b2246854bf767226804020 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Nov 25 13:39:28 2020 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Apr 7 13:04:47 2021 +0200 jsdialog: enable Pivot Table dialogs Change-Id: Ic467c95f0d56d28e6c6590d488e2a0b10f65e803 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106997 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107338 Tested-by: Jenkins diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 268707b37859..ccca582b7dc8 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -165,17 +165,27 @@ weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString { bool bUseJSBuilder = false; - if (bMobile) - { - if (rUIFile == "modules/swriter/ui/wordcount-mobile.ui" || - rUIFile == "svx/ui/findreplacedialog-mobile.ui" || - rUIFile == "modules/swriter/ui/watermarkdialog.ui" || - rUIFile == "modules/scalc/ui/validationdialog.ui" || - rUIFile == "modules/scalc/ui/validationcriteriapage.ui" || - rUIFile == "modules/scalc/ui/validationhelptabpage-mobile.ui" || - rUIFile == "modules/scalc/ui/erroralerttabpage-mobile.ui" || - rUIFile == "modules/scalc/ui/validationdialog.ui") + if (comphelper::LibreOfficeKit::isActive()) + { + if (bMobile) + { + if (rUIFile == "modules/swriter/ui/wordcount-mobile.ui" || + rUIFile == "svx/ui/findreplacedialog-mobile.ui" || + rUIFile == "modules/swriter/ui/watermarkdialog.ui" || + rUIFile == "modules/scalc/ui/validationdialog.ui" || + rUIFile == "modules/scalc/ui/validationcriteriapage.ui" || + rUIFile == "modules/scalc/ui/validationhelptabpage-mobile.ui" || + rUIFile == "modules/scalc/ui/erroralerttabpage-mobile.ui" || + rUIFile == "modules/scalc/ui/validationdialog.ui") + { + bUseJSBuilder = true; + } + } + + if (rUIFile == "modules/scalc/ui/pivottablelayoutdialog.ui") + { bUseJSBuilder = true; + } } if (bUseJSBuilder) commit f72f9a6a23839880e09a44253dc7475bd76a0258 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Mon Nov 30 22:16:15 2020 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Apr 7 13:04:35 2021 +0200 Fix stack-use-after-return ...introduced with 244a447734d2abae8896884d4ab73eb4510d243c "Make Pivot table data source dialog async", as seen e.g. during UITest_calc_tests8: > ==1217030==ERROR: AddressSanitizer: stack-use-after-return on address 0x7f06d7133444 at pc 0x7f069f0cb613 bp 0x7ffe24058430 sp 0x7ffe24058428 > WRITE of size 2 at 0x7f06d7133444 thread T0 > #0 in ScAddress::operator=(ScAddress const&) at sc/inc/address.hxx:415:10 > #1 in ScCellShell::ExecuteDataPilotDialog()::$_4::operator()(int) const at sc/source/ui/view/cellsh1.cxx:3014:42 > #2 in void std::__invoke_impl<void, ScCellShell::ExecuteDataPilotDialog()::$_4&, int>(std::__invoke_other, ScCellShell::ExecuteDataPilotDialog()::$_4&, int&&) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/invoke.h:60:14 > #3 in std::enable_if<is_invocable_r_v<void, ScCellShell::ExecuteDataPilotDialog()::$_4&, int>, void>::type std::__invoke_r<void, ScCellShell::ExecuteDataPilotDialog()::$_4&, int>(ScCellShell::ExecuteDataPilotDialog()::$_4&, int&&) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/invoke.h:110:2 > #4 in std::_Function_handler<void (int), ScCellShell::ExecuteDataPilotDialog()::$_4>::_M_invoke(std::_Any_data const&, int&&) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/std_function.h:291:9 > #5 in std::function<void (int)>::operator()(int) const at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/std_function.h:560:9 > #6 in Dialog::EndDialog(long) at vcl/source/window/dialog.cxx:1137:9 > #7 in Dialog::ResponseHdl(Button*) at vcl/source/window/dialog.cxx:1391:5 > #8 in Dialog::LinkStubResponseHdl(void*, Button*) at vcl/source/window/dialog.cxx:1376:1 > #9 in Link<Button*, void>::Call(Button*) const at include/tools/link.hxx:111:45 > #10 in Button::Click()::$_0::operator()() const at vcl/source/control/button.cxx:124:87 > #11 in void std::__invoke_impl<void, Button::Click()::$_0&>(std::__invoke_other, Button::Click()::$_0&) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/invoke.h:60:14 > #12 in std::enable_if<is_invocable_r_v<void, Button::Click()::$_0&>, void>::type std::__invoke_r<void, Button::Click()::$_0&>(Button::Click()::$_0&) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/invoke.h:110:2 > #13 in std::_Function_handler<void (), Button::Click()::$_0>::_M_invoke(std::_Any_data const&) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/std_function.h:291:9 > #14 in std::function<void ()>::operator()() const at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/std_function.h:560:9 > #15 in Control::ImplCallEventListenersAndHandler(VclEventId, std::function<void ()> const&) at vcl/source/control/ctrl.cxx:315:13 > #16 in Button::Click() at vcl/source/control/button.cxx:124:5 > #17 in ButtonUIObject::execute(rtl::OUString const&, std::__debug::map<rtl::OUString const, rtl::OUString, std::less<rtl::OUString const>, std::allocator<std::pair<rtl::OUString const, rtl::OUString> > > const&) at vcl/source/uitest/uiobject.cxx:614:19 > #18 in UIObjectUnoObj::executeAction(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)::$_0::operator()() const at vcl/source/uitest/uno/uiobject_uno.cxx:124:16 > #19 in void std::__invoke_impl<void, UIObjectUnoObj::executeAction(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)::$_0&>(std::__invoke_other, UIObjectUnoObj::executeAction(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)::$_0&) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/invoke.h:60:14 > #20 in std::enable_if<is_invocable_r_v<void, UIObjectUnoObj::executeAction(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)::$_0&>, void>::type std::__invoke_r<void, UIObjectUnoObj::executeAction(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)::$_0&>(UIObjectUnoObj::executeAction(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)::$_0&) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/invoke.h:110:2 > #21 in std::_Function_handler<void (), UIObjectUnoObj::executeAction(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)::$_0>::_M_invoke(std::_Any_data const&) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/std_function.h:291:9 > #22 in std::function<void ()>::operator()() const at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/std_function.h:560:9 > #23 in (anonymous namespace)::ExecuteWrapper::ExecuteActionHdl(Timer*) at vcl/source/uitest/uno/uiobject_uno.cxx:83:13 > #24 in (anonymous namespace)::ExecuteWrapper::LinkStubExecuteActionHdl(void*, Timer*) at vcl/source/uitest/uno/uiobject_uno.cxx:78:1 > #25 in Link<Timer*, void>::Call(Timer*) const at include/tools/link.hxx:111:45 > #26 in Timer::Invoke() at vcl/source/app/timer.cxx:75:21 > #27 in Scheduler::ProcessTaskScheduling() at vcl/source/app/scheduler.cxx:486:20 > #28 in Scheduler::CallbackTaskScheduling() at vcl/source/app/scheduler.cxx:288:5 > #29 in SalTimer::CallCallback() at vcl/inc/saltimer.hxx:54:13 > #30 in SvpSalInstance::CheckTimeout(bool) at vcl/headless/svpinst.cxx:210:53 > #31 in SvpSalInstance::DoYield(bool, bool) at vcl/headless/svpinst.cxx:463:21 > #32 in ImplYield(bool, bool) at vcl/source/app/svapp.cxx:447:48 > #33 in Application::Yield() at vcl/source/app/svapp.cxx:511:5 > #34 in Application::Execute() at vcl/source/app/svapp.cxx:426:9 > #35 in desktop::Desktop::Main() at desktop/source/app/app.cxx:1588:13 > #36 in ImplSVMain() at vcl/source/app/svmain.cxx:196:35 > #37 in SVMain() at vcl/source/app/svmain.cxx:228:12 > #38 in soffice_main at desktop/source/app/sofficemain.cxx:98:12 > #39 in sal_main at desktop/source/app/main.c:49:15 > #40 in main at desktop/source/app/main.c:47:1 Change-Id: I7ff5148f4bf9170fc7add312053de5acc153125b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106919 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 1905e32c0ddd..d49fe9f32188 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2955,7 +2955,7 @@ void ScCellShell::ExecuteDataPilotDialog() } pTypeDlg->StartExecuteAsync([this, pTypeDlg, pTabViewShell, - pScMod, pFact, &rDoc, &rMark, &aDestPos](int nResult) { + pScMod, pFact, &rDoc, &rMark, aDestPos](int nResult) mutable { const char* pSrcErrorId = nullptr; std::unique_ptr<ScDPObject> pNewDPObject; commit 6209b6bacde46762052483403e8bd1fc2c5e7b66 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Mon Nov 23 12:02:07 2020 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Apr 7 13:04:20 2021 +0200 Make Pivot table data source dialog async Change-Id: I573038935e31c5393293197c1a9706110a970837 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106848 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 40dc203d56c1..295d61f5270a 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -110,6 +110,11 @@ short AbstractScDataPilotSourceTypeDlg_Impl::Execute() return m_xDlg->run(); } +bool AbstractScDataPilotSourceTypeDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + short AbstractScDataPilotServiceDlg_Impl::Execute() { return m_xDlg->run(); @@ -986,7 +991,7 @@ VclPtr<AbstractScDataPilotDatabaseDlg> ScAbstractDialogFactory_Impl::CreateScDat VclPtr<AbstractScDataPilotSourceTypeDlg> ScAbstractDialogFactory_Impl::CreateScDataPilotSourceTypeDlg( weld::Window* pParent, bool bEnableExternal) { - return VclPtr<AbstractScDataPilotSourceTypeDlg_Impl>::Create(std::make_unique<ScDataPilotSourceTypeDlg>(pParent, bEnableExternal)); + return VclPtr<AbstractScDataPilotSourceTypeDlg_Impl>::Create(std::make_shared<ScDataPilotSourceTypeDlg>(pParent, bEnableExternal)); } VclPtr<AbstractScDataPilotServiceDlg> ScAbstractDialogFactory_Impl::CreateScDataPilotServiceDlg(weld::Window* pParent, diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 1e3be87c34cc..aaa94d0ddae9 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -181,13 +181,14 @@ public: class AbstractScDataPilotSourceTypeDlg_Impl :public AbstractScDataPilotSourceTypeDlg { - std::unique_ptr<ScDataPilotSourceTypeDlg> m_xDlg; + std::shared_ptr<ScDataPilotSourceTypeDlg> m_xDlg; public: - explicit AbstractScDataPilotSourceTypeDlg_Impl(std::unique_ptr<ScDataPilotSourceTypeDlg> p) + explicit AbstractScDataPilotSourceTypeDlg_Impl(std::shared_ptr<ScDataPilotSourceTypeDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &) override; virtual bool IsDatabase() const override; virtual bool IsExternal() const override; virtual bool IsNamedRange() const override; diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index afe2301df103..1905e32c0ddd 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2884,6 +2884,23 @@ bool isDPSourceValid(const ScDPObject& rDPObj) return true; } +void RunPivotLayoutDialog(ScModule* pScMod, + ScTabViewShell* pTabViewShell, + std::unique_ptr<ScDPObject>& pNewDPObject) +{ + bool bHadNewDPObject = pNewDPObject != nullptr; + pTabViewShell->SetDialogDPObject( std::move(pNewDPObject) ); + if ( bHadNewDPObject ) + { + // start layout dialog + + sal_uInt16 nId = ScPivotLayoutWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + pScMod->SetRefDialog( nId, pWnd == nullptr ); + } +} + } void ScCellShell::ExecuteDataPilotDialog() @@ -2893,21 +2910,21 @@ void ScCellShell::ExecuteDataPilotDialog() ScViewData* pData = GetViewData(); ScDocument& rDoc = pData->GetDocument(); - std::unique_ptr<ScDPObject> pNewDPObject; - // ScPivot is no longer used... ScDPObject* pDPObj = rDoc.GetDPAtCursor( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() ); if ( pDPObj ) // on an existing table? { + std::unique_ptr<ScDPObject> pNewDPObject; + if (isDPSourceValid(*pDPObj)) pNewDPObject.reset(new ScDPObject(*pDPObj)); + + RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject); } else // create new table { - const char* pSrcErrorId = nullptr; - // select database range or data pTabViewShell->GetDBData( true, SC_DB_OLD ); ScMarkData& rMark = GetViewData()->GetMarkData(); @@ -2924,7 +2941,7 @@ void ScCellShell::ExecuteDataPilotDialog() ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractScDataPilotSourceTypeDlg> pTypeDlg( + VclPtr<AbstractScDataPilotSourceTypeDlg> pTypeDlg( pFact->CreateScDataPilotSourceTypeDlg( pTabViewShell->GetFrameWeld(), bEnableExt)); @@ -2937,129 +2954,127 @@ void ScCellShell::ExecuteDataPilotDialog() pTypeDlg->AppendNamedRange(itr->second->GetName()); } - if ( pTypeDlg->Execute() == RET_OK ) - { - if ( pTypeDlg->IsExternal() ) - { - std::vector<OUString> aSources = ScDPObject::GetRegisteredSources(); - ScopedVclPtr<AbstractScDataPilotServiceDlg> pServDlg( - pFact->CreateScDataPilotServiceDlg( - pTabViewShell->GetFrameWeld(), aSources)); + pTypeDlg->StartExecuteAsync([this, pTypeDlg, pTabViewShell, + pScMod, pFact, &rDoc, &rMark, &aDestPos](int nResult) { + const char* pSrcErrorId = nullptr; + std::unique_ptr<ScDPObject> pNewDPObject; - if ( pServDlg->Execute() == RET_OK ) - { - ScDPServiceDesc aServDesc( - pServDlg->GetServiceName(), - pServDlg->GetParSource(), - pServDlg->GetParName(), - pServDlg->GetParUser(), - pServDlg->GetParPass() ); - pNewDPObject.reset(new ScDPObject(&rDoc)); - pNewDPObject->SetServiceData( aServDesc ); - } - } - else if ( pTypeDlg->IsDatabase() ) + if (nResult == RET_OK ) { - assert(pFact && "ScAbstractFactory create fail!"); - ScopedVclPtr<AbstractScDataPilotDatabaseDlg> pDataDlg( - pFact->CreateScDataPilotDatabaseDlg(pTabViewShell->GetFrameWeld())); - assert(pDataDlg && "Dialog create fail!"); - if ( pDataDlg->Execute() == RET_OK ) + if ( pTypeDlg->IsExternal() ) { - ScImportSourceDesc aImpDesc(&rDoc); - pDataDlg->GetValues( aImpDesc ); - pNewDPObject.reset(new ScDPObject(&rDoc)); - pNewDPObject->SetImportDesc( aImpDesc ); - } - } - else if (pTypeDlg->IsNamedRange()) - { - OUString aName = pTypeDlg->GetSelectedNamedRange(); - ScSheetSourceDesc aShtDesc(&rDoc); - aShtDesc.SetRangeName(aName); - pSrcErrorId = aShtDesc.CheckSourceRange(); - if (!pSrcErrorId) - { - pNewDPObject.reset(new ScDPObject(&rDoc)); - pNewDPObject->SetSheetDesc(aShtDesc); + std::vector<OUString> aSources = ScDPObject::GetRegisteredSources(); + ScopedVclPtr<AbstractScDataPilotServiceDlg> pServDlg( + pFact->CreateScDataPilotServiceDlg( + pTabViewShell->GetFrameWeld(), aSources)); + + if ( pServDlg->Execute() == RET_OK ) + { + ScDPServiceDesc aServDesc( + pServDlg->GetServiceName(), + pServDlg->GetParSource(), + pServDlg->GetParName(), + pServDlg->GetParUser(), + pServDlg->GetParPass() ); + pNewDPObject.reset(new ScDPObject(&rDoc)); + pNewDPObject->SetServiceData( aServDesc ); + } } - } - else // selection - { - //! use database ranges (select before type dialog?) - ScRange aRange; - ScMarkType eType = GetViewData()->GetSimpleArea(aRange); - if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE ) + else if ( pTypeDlg->IsDatabase() ) { - // Shrink the range to the data area. - SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col(); - SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row(); - if (rDoc.ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow)) + assert(pFact && "ScAbstractFactory create fail!"); + ScopedVclPtr<AbstractScDataPilotDatabaseDlg> pDataDlg( + pFact->CreateScDataPilotDatabaseDlg(pTabViewShell->GetFrameWeld())); + assert(pDataDlg && "Dialog create fail!"); + if ( pDataDlg->Execute() == RET_OK ) { - aRange.aStart.SetCol(nStartCol); - aRange.aStart.SetRow(nStartRow); - aRange.aEnd.SetCol(nEndCol); - aRange.aEnd.SetRow(nEndRow); - rMark.SetMarkArea(aRange); - pTabViewShell->MarkRange(aRange); + ScImportSourceDesc aImpDesc(&rDoc); + pDataDlg->GetValues( aImpDesc ); + pNewDPObject.reset(new ScDPObject(&rDoc)); + pNewDPObject->SetImportDesc( aImpDesc ); } - - bool bOK = true; - if ( rDoc.HasSubTotalCells( aRange ) ) + } + else if (pTypeDlg->IsNamedRange()) + { + OUString aName = pTypeDlg->GetSelectedNamedRange(); + ScSheetSourceDesc aShtDesc(&rDoc); + aShtDesc.SetRangeName(aName); + pSrcErrorId = aShtDesc.CheckSourceRange(); + if (!pSrcErrorId) { - // confirm selection if it contains SubTotal cells - std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), - VclMessageType::Question, VclButtonsType::YesNo, - ScResId(STR_DATAPILOT_SUBTOTAL))); - xQueryBox->set_default_response(RET_YES); - if (xQueryBox->run() == RET_NO) - bOK = false; + pNewDPObject.reset(new ScDPObject(&rDoc)); + pNewDPObject->SetSheetDesc(aShtDesc); } - if (bOK) + } + else // selection + { + //! use database ranges (select before type dialog?) + ScRange aRange; + ScMarkType eType = GetViewData()->GetSimpleArea(aRange); + if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE ) { - ScSheetSourceDesc aShtDesc(&rDoc); - aShtDesc.SetSourceRange(aRange); - pSrcErrorId = aShtDesc.CheckSourceRange(); - if (!pSrcErrorId) + // Shrink the range to the data area. + SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col(); + SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row(); + if (rDoc.ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow)) { - pNewDPObject.reset(new ScDPObject(&rDoc)); - pNewDPObject->SetSheetDesc( aShtDesc ); + aRange.aStart.SetCol(nStartCol); + aRange.aStart.SetRow(nStartRow); + aRange.aEnd.SetCol(nEndCol); + aRange.aEnd.SetRow(nEndRow); + rMark.SetMarkArea(aRange); + pTabViewShell->MarkRange(aRange); } - // output below source data - if ( aRange.aEnd.Row()+2 <= rDoc.MaxRow() - 4 ) - aDestPos = ScAddress( aRange.aStart.Col(), - aRange.aEnd.Row()+2, - aRange.aStart.Tab() ); + bool bOK = true; + if ( rDoc.HasSubTotalCells( aRange ) ) + { + // confirm selection if it contains SubTotal cells + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + ScResId(STR_DATAPILOT_SUBTOTAL))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_NO) + bOK = false; + } + if (bOK) + { + ScSheetSourceDesc aShtDesc(&rDoc); + aShtDesc.SetSourceRange(aRange); + pSrcErrorId = aShtDesc.CheckSourceRange(); + if (!pSrcErrorId) + { + pNewDPObject.reset(new ScDPObject(&rDoc)); + pNewDPObject->SetSheetDesc( aShtDesc ); + } + + // output below source data + if ( aRange.aEnd.Row()+2 <= rDoc.MaxRow() - 4 ) + aDestPos = ScAddress( aRange.aStart.Col(), + aRange.aEnd.Row()+2, + aRange.aStart.Tab() ); + } } } } - } - if (pSrcErrorId) - { - // Error occurred during data creation. Launch an error and bail out. - std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), - VclMessageType::Info, VclButtonsType::Ok, - ScResId(pSrcErrorId))); - xInfoBox->run(); - return; - } + if (pSrcErrorId) + { + // Error occurred during data creation. Launch an error and bail out. + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + ScResId(pSrcErrorId))); + xInfoBox->run(); + return; + } - if ( pNewDPObject ) - pNewDPObject->SetOutRange( aDestPos ); - } + if ( pNewDPObject ) + pNewDPObject->SetOutRange( aDestPos ); - bool bHadNewDPObject = pNewDPObject != nullptr; - pTabViewShell->SetDialogDPObject( std::move(pNewDPObject) ); - if ( bHadNewDPObject ) - { - // start layout dialog + pTypeDlg->disposeOnce(); - sal_uInt16 nId = ScPivotLayoutWrapper::GetChildWindowId(); - SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); - SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); - pScMod->SetRefDialog( nId, pWnd == nullptr ); + RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject); + }); } } commit 4bfbc798773d137b3ab66dfd77ce93e60901ab85 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Nov 20 12:23:45 2020 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Apr 7 13:02:43 2021 +0200 autofilter: fix submenu popup for online Change-Id: If48428f99b921d3c6f9927c612e6ade81b980678 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106847 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/include/vcl/jsdialog/executor.hxx b/include/vcl/jsdialog/executor.hxx index 5dde733a3823..038b86b30f64 100644 --- a/include/vcl/jsdialog/executor.hxx +++ b/include/vcl/jsdialog/executor.hxx @@ -29,6 +29,8 @@ public: rTreeView.signal_row_activated(); } + static void trigger_changed(weld::TreeView& rTreeView) { rTreeView.signal_changed(); } + static void trigger_clicked(weld::Toolbar& rToolbar, const OString& rIdent) { rToolbar.signal_clicked(rIdent); diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 6312b2062a16..c61c52cf7840 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -35,6 +35,8 @@ #include <comphelper/lok.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <tools/json_writer.hxx> +#include <sfx2/viewsh.hxx> +#include <vcl/jsdialog/executor.hxx> #include <document.hxx> @@ -170,8 +172,14 @@ ScCheckListMenuWindow* ScCheckListMenuControl::addSubMenuItem(const OUString& rT MenuItemData aItem; aItem.mbEnabled = bEnabled; vcl::Window *pContainer = mxFrame->GetWindow(GetWindowType::FirstChild); + + vcl::ILibreOfficeKitNotifier* pNotifier = nullptr; + if (comphelper::LibreOfficeKit::isActive()) + pNotifier = SfxViewShell::Current(); + aItem.mxSubMenuWin.reset(VclPtr<ScCheckListMenuWindow>::Create(pContainer, mpDoc, false, - false, -1, mxFrame.get())); + false, -1, mxFrame.get(), + pNotifier)); maMenuItems.emplace_back(std::move(aItem)); mxMenu->append_text(rText); @@ -288,6 +296,16 @@ void ScCheckListMenuControl::launchSubMenu(bool bSetMenuPos) mxMenu->select(*mxScratchIter); rSubMenuControl.GrabFocus(); + + // TODO: something better to retrigger JSON dialog invalidation + if (comphelper::LibreOfficeKit::isActive()) + { + StringMap args; + args["cmd"] = "change"; + args["type"] = "checkbox"; + args["data"] = "true"; + jsdialog::ExecuteAction(pSubMenu->GetLOKWindowId(), "toggle_all", args); + } } IMPL_LINK_NOARG(ScCheckListMenuControl, PostPopdownHdl, void*, void) diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index efb952dc7721..d71741cda2bc 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -467,8 +467,14 @@ void ScGridWindow::DPLaunchFieldPopupMenu(const Point& rScrPos, const Size& rScr const ScDPLabelData& rLabelData = pDPData->maLabels; mpDPFieldPopup.disposeAndClear(); + + vcl::ILibreOfficeKitNotifier* pNotifier = nullptr; + if (comphelper::LibreOfficeKit::isActive()) + pNotifier = SfxViewShell::Current(); + mpDPFieldPopup.reset(VclPtr<ScCheckListMenuWindow>::Create(this, &mrViewData.GetDocument(), - bDimOrientNotPage, false)); + bDimOrientNotPage, false, -1, + nullptr, pNotifier)); ScCheckListMenuControl& rControl = mpDPFieldPopup->get_widget(); rControl.setExtendedData(std::move(pDPData)); diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 83d19fd7b657..b2103fbe865f 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -205,6 +205,7 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat int nRow = std::atoi(nRowString.getStr()); pTreeView->select(nRow); + LOKTrigger::trigger_changed(*pTreeView); LOKTrigger::trigger_row_activated(*pTreeView); return true; } commit f8536a478f2c8893491cfa55b88c7bac7cb317ce Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Nov 19 13:50:30 2020 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Apr 7 13:02:28 2021 +0200 jsdialog: dump dialog title Change-Id: Id4c9f336039f8a0b8d1d43fdff4852f32e2c7ae6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106707 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/include/vcl/toolkit/dialog.hxx b/include/vcl/toolkit/dialog.hxx index bd497e60035d..efd2d2f0f6c0 100644 --- a/include/vcl/toolkit/dialog.hxx +++ b/include/vcl/toolkit/dialog.hxx @@ -155,6 +155,8 @@ public: void set_default_response(int nResponse); int get_default_response() const; vcl::Window* get_widget_for_response(int nResponse); + + void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override; }; #endif // INCLUDED_VCL_DIALOG_HXX diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index cb2d845fbf92..9a237ba5df9f 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -60,6 +60,7 @@ #include <vcl/IDialogRenderable.hxx> #include <messagedialog.hxx> #include <salframe.hxx> +#include <tools/json_writer.hxx> #include <iostream> #include <utility> @@ -1630,4 +1631,10 @@ void TopLevelWindowLocker::decBusy() m_aBusyStack.pop(); } +void Dialog::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) +{ + SystemWindow::DumpAsPropertyTree(rJsonWriter); + rJsonWriter.put("title", GetText()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 74a39123df3202de60273529fbaafa532c192bd2 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Nov 18 12:14:35 2020 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Apr 7 13:02:01 2021 +0200 jsdialog: remember dialog instance & handle close Change-Id: I1b10d12edfa7ffca1061f50b5219baae1ac3caeb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106706 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 13ffc1a33e06..83d19fd7b657 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -242,6 +242,18 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat } } } + else if (sControlType == "dialog") + { + auto pDialog = dynamic_cast<weld::Dialog*>(pWidget); + if (pDialog) + { + if (sAction == "close") + { + pDialog->response(RET_CANCEL); + return true; + } + } + } } return false; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index f44cd42e97cf..051c90c7b6db 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -366,6 +366,9 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) std::unique_ptr<weld::Dialog> pRet(pDialog ? new JSDialog(m_aOwnedToplevel, m_aOwnedToplevel, pDialog, this, false, m_sTypeOfJSON) : nullptr); + + RememberWidget("__DIALOG__", pRet.get()); + if (pDialog) { assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); commit 87ddbb81e651ef7cbe535aabd149c33b4922e51b Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Nov 18 12:00:03 2020 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Apr 7 13:01:43 2021 +0200 jsdialog: turn off tunneling for JSON dialogs Change-Id: I9a9d359d1769f6c34203bc558efe8189fbf81fd3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106929 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107337 Tested-by: Jenkins diff --git a/include/vcl/toolkit/dialog.hxx b/include/vcl/toolkit/dialog.hxx index 3c519d0a5004..bd497e60035d 100644 --- a/include/vcl/toolkit/dialog.hxx +++ b/include/vcl/toolkit/dialog.hxx @@ -149,6 +149,7 @@ public: void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink); void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink); + void SetLOKTunnelingState(bool bEnabled); void add_button(PushButton* pButton, int nResponse, bool bTransferOwnership); void set_default_response(int nResponse); diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 58c8c64d1108..f44cd42e97cf 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -359,6 +359,7 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id) { ::Dialog* pDialog = m_xBuilder->get<::Dialog>(id); m_nWindowId = pDialog->GetLOKWindowId(); + pDialog->SetLOKTunnelingState(false); InsertWindowToMap(m_nWindowId); diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 5618af225d4c..cb2d845fbf92 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -355,8 +355,9 @@ struct DialogImpl VclAbstractDialog::AsyncContext maEndCtx; Link<const CommandEvent&, bool> m_aPopupMenuHdl; Link<void*, vcl::ILibreOfficeKitNotifier*> m_aInstallLOKNotifierHdl; + bool m_bLOKTunneling; - DialogImpl() : mnResult( -1 ), mbStartedModal( false ) {} + DialogImpl() : mnResult( -1 ), mbStartedModal( false ), m_bLOKTunneling( true ) {} #ifndef NDEBUG short get_response(vcl::Window *pWindow) const @@ -609,6 +610,8 @@ Dialog::~Dialog() void Dialog::dispose() { + bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling; + mpDialogImpl.reset(); RemoveFromDlgList(); mpActionArea.clear(); @@ -626,7 +629,8 @@ void Dialog::dispose() { if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) { - pNotifier->notifyWindow(GetLOKWindowId(), "close"); + if (bTunnelingEnabled) + pNotifier->notifyWindow(GetLOKWindowId(), "close"); ReleaseLOKNotifier(); } } @@ -733,14 +737,21 @@ void Dialog::SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNoti mpDialogImpl->m_aInstallLOKNotifierHdl = rLink; } +void Dialog::SetLOKTunnelingState(bool bEnabled) +{ + mpDialogImpl->m_bLOKTunneling = bEnabled; +} + void Dialog::StateChanged( StateChangedType nType ) { + bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling; + if (nType == StateChangedType::InitShow) { DoInitialLayout(); const bool bKitActive = comphelper::LibreOfficeKit::isActive(); - if (bKitActive) + if (bKitActive && bTunnelingEnabled) { std::vector<vcl::LOKPayloadItem> aItems; aItems.emplace_back("type", "dialog"); @@ -779,7 +790,8 @@ void Dialog::StateChanged( StateChangedType nType ) } else if (nType == StateChangedType::Text) { - if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier(); + if (pNotifier && bTunnelingEnabled) { std::vector<vcl::LOKPayloadItem> aPayload; aPayload.emplace_back("title", GetText().toUtf8()); @@ -797,7 +809,8 @@ void Dialog::StateChanged( StateChangedType nType ) if (!mbModalMode && nType == StateChangedType::Visible) { - if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier(); + if (pNotifier && bTunnelingEnabled) { std::vector<vcl::LOKPayloadItem> aPayload; aPayload.emplace_back("title", GetText().toUtf8()); @@ -985,7 +998,8 @@ bool Dialog::ImplStartExecute() else UITestLogger::getInstance().log("Open Modeless " + get_id()); - if (comphelper::LibreOfficeKit::isActive()) + bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling; + if (comphelper::LibreOfficeKit::isActive() && bTunnelingEnabled) { if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) { @@ -1350,7 +1364,9 @@ void Dialog::Resize() if (comphelper::LibreOfficeKit::isDialogPainting()) return; - if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling; + const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier(); + if (pNotifier && bTunnelingEnabled) { std::vector<vcl::LOKPayloadItem> aItems; aItems.emplace_back("size", GetSizePixel().toString()); commit d5c797249981d318793c93ce0f13576135563980 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Nov 18 10:12:38 2020 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Apr 7 13:00:37 2021 +0200 jsdialog: drag and drop support for TreeView Change-Id: I67e2eb986b48591b7f758bbb5c1d72b6a322d4d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106705 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 4b9e042960f4..ab7c038648d3 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -19,6 +19,11 @@ #include <vcl/toolkit/button.hxx> #include <vcl/toolkit/fmtfield.hxx> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> +#include <cppuhelper/compbase.hxx> + class ToolBox; class ComboBox; class VclMultiLineEdit; @@ -58,6 +63,40 @@ public: void notifyDialogState(bool bForce = false); }; +class JSDropTarget final + : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDropTarget, + css::lang::XInitialization, css::lang::XServiceInfo> +{ + osl::Mutex m_aMutex; + std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners; + +public: + JSDropTarget(); + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArgs) override; + + // XDropTarget + virtual void SAL_CALL addDropTargetListener( + const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override; + virtual void SAL_CALL removeDropTargetListener( + const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override; + virtual sal_Bool SAL_CALL isActive() override; + virtual void SAL_CALL setActive(sal_Bool active) override; + virtual sal_Int8 SAL_CALL getDefaultActions() override; + virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override; + + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde); + + void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde); +}; + class JSInstanceBuilder : public SalInstanceBuilder { sal_uInt64 m_nWindowId; @@ -128,6 +167,9 @@ private: template <class BaseInstanceClass, class VclClass> class JSWidget : public BaseInstanceClass, public JSDialogSender { +protected: + rtl::Reference<JSDropTarget> m_xDropTarget; + public: JSWidget(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, VclClass* pObject, SalInstanceBuilder* pBuilder, bool bTakeOwnership, @@ -155,6 +197,14 @@ public: BaseInstanceClass::set_sensitive(sensitive); notifyDialogState(); } + + virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() override + { + if (!m_xDropTarget) + m_xDropTarget.set(new JSDropTarget); + + return m_xDropTarget.get(); + } }; class JSDialog : public JSWidget<SalInstanceDialog, ::Dialog> @@ -309,6 +359,11 @@ public: using SalInstanceTreeView::select; /// pos is used differently here, it defines how many steps of iterator we need to perform to take entry virtual void select(int pos) override; + + virtual weld::TreeView* get_drag_source() const override; + + void drag_start(); + void drag_end(); }; class JSExpander : public JSWidget<SalInstanceExpander, ::VclExpander> diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 24e3eb1f14d3..13ffc1a33e06 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -206,6 +206,27 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat pTreeView->select(nRow); LOKTrigger::trigger_row_activated(*pTreeView); + return true; + } + else if (sAction == "dragstart") + { + OString nRowString + = OUStringToOString(rData["data"], RTL_TEXTENCODING_ASCII_US); + int nRow = std::atoi(nRowString.getStr()); + + pTreeView->select(nRow); + + JSTreeView* pJSTreeView = dynamic_cast<JSTreeView*>(pTreeView); + if (pJSTreeView) + pJSTreeView->drag_start(); + return true; + } + else if (sAction == "dragend") + { + JSTreeView* pJSTreeView = dynamic_cast<JSTreeView*>(pTreeView); + if (pJSTreeView) + pJSTreeView->drag_end(); + return true; } } } diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 4fb351b5439f..58c8c64d1108 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -24,6 +24,7 @@ #include <boost/property_tree/json_parser.hpp> #include <vcl/toolkit/treelistentry.hxx> #include <vcl/jsdialog/executor.hxx> +#include <cppuhelper/supportsservice.hxx> JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, std::string sTypeOfJSON) @@ -96,6 +97,102 @@ vcl::Window* extract_sal_widget(weld::Widget* pParent) } } +// Drag and drop + +namespace +{ +class JSDropTargetDropContext + : public cppu::WeakImplHelper<css::datatransfer::dnd::XDropTargetDropContext> +{ +public: + JSDropTargetDropContext() {} + + // XDropTargetDropContext + virtual void SAL_CALL acceptDrop(sal_Int8 /*dragOperation*/) override {} + + virtual void SAL_CALL rejectDrop() override {} + + virtual void SAL_CALL dropComplete(sal_Bool /*bSuccess*/) override {} +}; +} + +static JSTreeView* g_DragSource; + +JSDropTarget::JSDropTarget() + : WeakComponentImplHelper(m_aMutex) +{ +} + +void JSDropTarget::initialize(const css::uno::Sequence<css::uno::Any>& /*rArgs*/) {} + +void JSDropTarget::addDropTargetListener( + const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>& xListener) +{ + ::osl::Guard<::osl::Mutex> aGuard(m_aMutex); + + m_aListeners.push_back(xListener); +} + +void JSDropTarget::removeDropTargetListener( + const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>& xListener) +{ + ::osl::Guard<::osl::Mutex> aGuard(m_aMutex); + + m_aListeners.erase(std::remove(m_aListeners.begin(), m_aListeners.end(), xListener), + m_aListeners.end()); +} + +sal_Bool JSDropTarget::isActive() { return false; } + +void JSDropTarget::setActive(sal_Bool /*active*/) {} + +sal_Int8 JSDropTarget::getDefaultActions() { return 0; } + +void JSDropTarget::setDefaultActions(sal_Int8 /*actions*/) {} + +OUString JSDropTarget::getImplementationName() +{ + return "com.sun.star.datatransfer.dnd.JSDropTarget"; +} + +sal_Bool JSDropTarget::supportsService(OUString const& ServiceName) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence<OUString> JSDropTarget::getSupportedServiceNames() +{ + css::uno::Sequence<OUString> aRet{ "com.sun.star.datatransfer.dnd.JSDropTarget" }; + return aRet; +} + +void JSDropTarget::fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde) +{ + osl::ClearableGuard<osl::Mutex> aGuard(m_aMutex); + std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners( + m_aListeners); + aGuard.clear(); + + for (auto const& listener : aListeners) + { + listener->drop(dtde); + } +} + +void JSDropTarget::fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde) +{ + osl::ClearableGuard<::osl::Mutex> aGuard(m_aMutex); + std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners( + m_aListeners); + aGuard.clear(); + + for (auto const& listener : aListeners) + { + listener->dragEnter(dtde); + } +} + +// used for dialogs JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile) : SalInstanceBuilder(extract_sal_widget(pParent), rUIRoot, rUIFile) @@ -793,6 +890,32 @@ void JSTreeView::select(int pos) enable_notify_events(); } +weld::TreeView* JSTreeView::get_drag_source() const { return g_DragSource; } + +void JSTreeView::drag_start() { g_DragSource = this; } + +void JSTreeView::drag_end() +{ + css::datatransfer::dnd::XDropTarget* xDropTarget = m_xDropTarget.get(); + if (xDropTarget) + { + css::datatransfer::dnd::DropTargetDropEvent aEvent; + aEvent.Source = xDropTarget; + aEvent.Context = new JSDropTargetDropContext(); + // dummy values + aEvent.LocationX = 50; + aEvent.LocationY = 50; + aEvent.DropAction = css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT; + aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT; + + m_xDropTarget->fire_drop(aEvent); + + notifyDialogState(); + } + + g_DragSource = nullptr; +} + JSExpander::JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership, std::string sTypeOfJSON) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits