sd/source/ui/animations/CustomAnimationDialog.cxx | 4 +- sd/source/ui/animations/CustomAnimationPane.cxx | 14 +++++++- vcl/inc/jsdialog/jsdialogbuilder.hxx | 14 +++++++- vcl/jsdialog/enabled.cxx | 3 + vcl/jsdialog/jsdialogbuilder.cxx | 38 ++++++++++++++++------ 5 files changed, 59 insertions(+), 14 deletions(-)
New commits: commit 490fcebb0dc160e56058a925e32f31ec7bcb6e4d Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Nov 24 13:11:18 2021 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Tue Feb 1 10:27:52 2022 +0100 jsdialog: sidebar: enable animation panel effects - enable subcontrol .ui for jsdialogs in annimation panel - optimize to not recreate widget on every sidebar refresh - don't sent close message for whole sidebar when called from subcontrol This fixes widgets in annimation panel like: Direction listbox, or other replacements for selecting color, font etc. for font effect Change-Id: I5683ca9cefe384ed0d2a34d46936ddf4a9b45bce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125757 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Mert Tumer <mert.tu...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129170 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx index 58e595e75877..2a23da8fed34 100644 --- a/sd/source/ui/animations/CustomAnimationDialog.cxx +++ b/sd/source/ui/animations/CustomAnimationDialog.cxx @@ -44,6 +44,7 @@ #include <svtools/ctrltool.hxx> #include <sfx2/objsh.hxx> +#include <sfx2/viewsh.hxx> #include <tools/debug.hxx> #include <tools/urlobj.hxx> #include <tools/diagnose_ex.h> @@ -84,7 +85,8 @@ using ::com::sun::star::beans::XPropertySet; namespace sd { SdPropertySubControl::SdPropertySubControl(weld::Container* pParent) - : mxBuilder(Application::CreateBuilder(pParent, "modules/simpress/ui/customanimationfragment.ui")) + : mxBuilder(Application::CreateBuilder(pParent, "modules/simpress/ui/customanimationfragment.ui", + false, reinterpret_cast<sal_uInt64>(SfxViewShell::Current()))) , mxContainer(mxBuilder->weld_container("EffectFragment")) , mpParent(pParent) { diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index b952a72f69ab..0b317da19c3d 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -551,6 +551,9 @@ void CustomAnimationPane::updateControls() if (!mxLBSubControl || nOldPropertyType != nNewPropertyType) { + // for LOK destroy old widgets first + mxLBSubControl.reset(nullptr); + // then create new control, to keep correct pointers for actions mxLBSubControl = SdPropertySubControl::create(nNewPropertyType, mxFTProperty.get(), mxPlaceholderBox.get(), GetFrameWeld(), aValue, pEffect->getPresetId(), LINK(this, CustomAnimationPane, implPropertyHdl)); } else @@ -661,7 +664,16 @@ void CustomAnimationPane::updateControls() else { // use an empty direction box to fill the space - mxLBSubControl = SdPropertySubControl::create(nPropertyTypeDirection, mxFTProperty.get(), mxPlaceholderBox.get(), GetFrameWeld(), uno::Any(), OUString(), LINK(this, CustomAnimationPane, implPropertyHdl)); + if (!mxLBSubControl || (nOldPropertyType != nPropertyTypeDirection && nOldPropertyType != nPropertyTypeNone)) + { + // for LOK destroy old widgets first + mxLBSubControl.reset(nullptr); + // then create new control, to keep correct pointers for actions + mxLBSubControl = SdPropertySubControl::create(nPropertyTypeDirection, mxFTProperty.get(), mxPlaceholderBox.get(), GetFrameWeld(), uno::Any(), OUString(), LINK(this, CustomAnimationPane, implPropertyHdl)); + } + else + mxLBSubControl->setValue(uno::Any(), OUString()); + mxPlaceholderBox->set_sensitive(false); mxFTProperty->set_sensitive(false); mxFTStartDelay->set_sensitive(false); diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 59462a92468c..e4f3227fd7ba 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -138,10 +138,17 @@ class JSDialogSender { std::unique_ptr<JSDialogNotifyIdle> mpIdleNotify; +protected: + bool m_bCanClose; // specifies if can send a close message + public: - JSDialogSender() = default; + JSDialogSender() + : m_bCanClose(true) + { + } JSDialogSender(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, std::string sTypeOfJSON) + : m_bCanClose(true) { initializeSender(aNotifierWindow, aContentWindow, sTypeOfJSON); } diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index d39833c71d84..6de05a65c9eb 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -121,7 +121,8 @@ bool isBuilderEnabledForSidebar(std::u16string_view rUIFile) || rUIFile == u"svx/ui/inspectortextpanel.ui" || rUIFile == u"modules/swriter/ui/sidebarstylepresets.ui" || rUIFile == u"modules/swriter/ui/sidebartheme.ui" - || rUIFile == u"modules/swriter/ui/sidebartableedit.ui") + || rUIFile == u"modules/swriter/ui/sidebartableedit.ui" + || rUIFile == u"modules/simpress/ui/customanimationfragment.ui") return true; return false; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 08fd92f6a57d..f527867c81b4 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -324,7 +324,7 @@ void JSDialogSender::sendFullUpdate(bool bForce) void JSDialogSender::sendClose() { - if (!mpIdleNotify) + if (!mpIdleNotify || !m_bCanClose) return; mpIdleNotify->clearQueue(); @@ -539,6 +539,10 @@ JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIR } else { + // embedded fragments cannot send close message for whole sidebar + if (rUIFile == "modules/simpress/ui/customanimationfragment.ui") + m_bCanClose = false; + // builder for PanelLayout, get SidebarDockingWindow as m_aContentWindow m_aContentWindow = pRoot; for (int i = 0; i < 9 && m_aContentWindow; i++) commit 1f847d09246a5bd437248234ddc32f1c491acdc7 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Tue Nov 23 09:55:00 2021 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Tue Feb 1 10:27:39 2022 +0100 jsdialog: correctly clean statically created message dialogs - remember WindowId for statically created message dialogs - remember _DIALOG_ handle for message dialogs so response action can be done Change-Id: I1f6c9877e20dcbed4855b32d1e89d9ce3ff12111 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125686 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Jan Holesovsky <ke...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129169 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 6c773312c3d0..59462a92468c 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -218,6 +218,8 @@ class JSInstanceBuilder final : public SalInstanceBuilder, public JSDialogSender static std::map<std::string, WidgetMap>& GetLOKWeldWidgetsMap(); static void InsertWindowToMap(const std::string& nWindowId); void RememberWidget(const OString& id, weld::Widget* pWidget); + static void RememberWidget(const std::string& nWindowId, const OString& id, + weld::Widget* pWidget); static weld::Widget* FindWeldWidgetsMap(const std::string& nWindowId, const OString& rWidget); std::string getMapIdFromWindowId() const; @@ -529,6 +531,9 @@ class JSMessageDialog final : public JSWidget<SalInstanceMessageDialog, ::Messag std::unique_ptr<JSButton> m_pOK; std::unique_ptr<JSButton> m_pCancel; + // used for message dialogs created using static functions + std::string m_sWindowId; + DECL_LINK(OKHdl, weld::Button&, void); DECL_LINK(CancelHdl, weld::Button&, void); diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 8c15f50ba78d..08fd92f6a57d 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -699,12 +699,18 @@ void JSInstanceBuilder::InsertWindowToMap(const std::string& nWindowId) void JSInstanceBuilder::RememberWidget(const OString& id, weld::Widget* pWidget) { - auto it = GetLOKWeldWidgetsMap().find(getMapIdFromWindowId()); + RememberWidget(getMapIdFromWindowId(), id, pWidget); + m_aRememberedWidgets.push_back(id.getStr()); +} + +void JSInstanceBuilder::RememberWidget(const std::string& nWindowId, const OString& id, + weld::Widget* pWidget) +{ + auto it = GetLOKWeldWidgetsMap().find(nWindowId); if (it != GetLOKWeldWidgetsMap().end()) { it->second.erase(id); it->second.insert(WidgetMap::value_type(id, pWidget)); - m_aRememberedWidgets.push_back(id.getStr()); } } @@ -1098,8 +1104,15 @@ weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParen } xMessageDialog->SetLOKTunnelingState(false); - InsertWindowToMap(std::to_string(xMessageDialog->GetLOKWindowId())); - return new JSMessageDialog(xMessageDialog, nullptr, true); + std::string sWindowId = std::to_string(xMessageDialog->GetLOKWindowId()); + InsertWindowToMap(sWindowId); + + weld::MessageDialog* pRet = new JSMessageDialog(xMessageDialog, nullptr, true); + + if (pRet) + RememberWidget(sWindowId, "__DIALOG__", pRet); + + return pRet; } JSDialog::JSDialog(JSDialogSender* pSender, ::Dialog* pDialog, SalInstanceBuilder* pBuilder, @@ -1309,12 +1322,13 @@ JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* p if (pBuilder) return; + m_sWindowId = std::to_string(m_xMessageDialog->GetLOKWindowId()); + if (::OKButton* pOKBtn = dynamic_cast<::OKButton*>(m_xMessageDialog->get_widget_for_response(RET_OK))) { m_pOK.reset(new JSButton(m_pSender, pOKBtn, nullptr, false)); - JSInstanceBuilder::AddChildWidget(std::to_string(m_xMessageDialog->GetLOKWindowId()), - pOKBtn->get_id().toUtf8(), m_pOK.get()); + JSInstanceBuilder::AddChildWidget(m_sWindowId, pOKBtn->get_id().toUtf8(), m_pOK.get()); m_pOK->connect_clicked(LINK(this, JSMessageDialog, OKHdl)); } @@ -1322,8 +1336,8 @@ JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* p = dynamic_cast<::CancelButton*>(m_xMessageDialog->get_widget_for_response(RET_CANCEL))) { m_pCancel.reset(new JSButton(m_pSender, pCancelBtn, nullptr, false)); - JSInstanceBuilder::AddChildWidget(std::to_string(m_xMessageDialog->GetLOKWindowId()), - pCancelBtn->get_id().toUtf8(), m_pCancel.get()); + JSInstanceBuilder::AddChildWidget(m_sWindowId, pCancelBtn->get_id().toUtf8(), + m_pCancel.get()); m_pCancel->connect_clicked(LINK(this, JSMessageDialog, CancelHdl)); } } @@ -1331,7 +1345,7 @@ JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* p JSMessageDialog::~JSMessageDialog() { if (m_pOK || m_pCancel) - JSInstanceBuilder::RemoveWindowWidget(std::to_string(m_xMessageDialog->GetLOKWindowId())); + JSInstanceBuilder::RemoveWindowWidget(m_sWindowId); } IMPL_LINK_NOARG(JSMessageDialog, OKHdl, weld::Button&, void) { response(RET_OK); }