diff options
-rw-r--r-- | cui/source/dialogs/cuicharmap.cxx | 2 | ||||
-rw-r--r-- | cui/source/inc/cuicharmap.hxx | 2 | ||||
-rw-r--r-- | include/sfx2/basedlgs.hxx | 14 | ||||
-rw-r--r-- | include/vcl/dialog.hxx | 2 | ||||
-rw-r--r-- | include/vcl/weld.hxx | 8 | ||||
-rw-r--r-- | sfx2/source/dialog/basedlgs.cxx | 64 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 5 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 32 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 5 |
9 files changed, 88 insertions, 46 deletions
diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx index cdcadbb691af..c0de50c1e564 100644 --- a/cui/source/dialogs/cuicharmap.cxx +++ b/cui/source/dialogs/cuicharmap.cxx @@ -53,7 +53,7 @@ using namespace css; SvxCharacterMap::SvxCharacterMap(weld::Window* pParent, const SfxItemSet* pSet, bool bInsert) - : GenericDialogController(pParent, "cui/ui/specialcharacters.ui", "SpecialCharactersDialog") + : SfxDialogController(pParent, "cui/ui/specialcharacters.ui", "SpecialCharactersDialog") , m_xVirDev(VclPtr<VirtualDevice>::Create()) , isSearchMode(true) , m_bHasInsert(bInsert) diff --git a/cui/source/inc/cuicharmap.hxx b/cui/source/inc/cuicharmap.hxx index bc2dcf0844a5..bcf952a62123 100644 --- a/cui/source/inc/cuicharmap.hxx +++ b/cui/source/inc/cuicharmap.hxx @@ -68,7 +68,7 @@ public: /** The main purpose of this dialog is to enable the use of characters that are not easily accessible from the keyboard. */ -class SvxCharacterMap : public weld::GenericDialogController +class SvxCharacterMap : public SfxDialogController { private: diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx index 39f74dc024e8..bb861366f9d7 100644 --- a/include/sfx2/basedlgs.hxx +++ b/include/sfx2/basedlgs.hxx @@ -56,6 +56,7 @@ private: SAL_DLLPRIVATE void SetDialogData_Impl(); SAL_DLLPRIVATE void GetDialogData_Impl(); + DECL_DLLPRIVATE_LINK(InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*); protected: SfxModalDialog(vcl::Window *pParent, const OUString& rID, const OUString& rUIXMLDescription); @@ -71,7 +72,6 @@ public: const SfxItemSet* GetOutputItemSet() const { return pOutputSet.get(); } const SfxItemSet* GetInputItemSet() const { return pInputSet; } - void StateChanged( StateChangedType nStateChange ) override; }; // class SfxModelessDialog -------------------------------------------------- @@ -87,6 +87,7 @@ class SFX2_DLLPUBLIC SfxModelessDialog: public ModelessDialog void Init(SfxBindings *pBindinx, SfxChildWindow *pCW); + DECL_DLLPRIVATE_LINK(InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*); protected: SfxModelessDialog( SfxBindings*, SfxChildWindow*, vcl::Window*, const OUString& rID, const OUString& rUIXMLDescription ); @@ -105,7 +106,6 @@ public: { return *pBindings; } DECL_LINK(TimerHdl, Timer *, void); - }; // class SfxFloatingWindow -------------------------------------------------- @@ -190,7 +190,15 @@ private: std::unique_ptr<SingleTabDlgImpl> pImpl; }; -class SFX2_DLLPUBLIC SfxSingleTabDialogController : public weld::GenericDialogController +class SFX2_DLLPUBLIC SfxDialogController : public weld::GenericDialogController +{ +private: + DECL_DLLPRIVATE_LINK(InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*); +public: + SfxDialogController(weld::Widget* pParent, const OUString& rUIFile, const OString& rDialogId); +}; + +class SFX2_DLLPUBLIC SfxSingleTabDialogController : public SfxDialogController { private: VclPtr<SfxTabPage> m_xSfxPage; diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index 1996ac8651e4..66d6e2bccd6f 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -179,6 +179,8 @@ public: void GrabFocusToFirstControl(); virtual void Resize() override; + void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink); + void add_button(PushButton* pButton, int nResponse, bool bTransferOwnership); void set_default_response(int nResponse); vcl::Window* get_widget_for_response(int nResponse); diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 3d8b8fa2a049..e35befc64168 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -24,6 +24,11 @@ typedef css::uno::Reference<css::accessibility::XAccessible> a11yref; typedef css::uno::Reference<css::accessibility::XAccessibleRelationSet> a11yrelationset; +namespace vcl +{ +class ILibreOfficeKitNotifier; +} + namespace weld { class Container; @@ -232,6 +237,9 @@ public: virtual void set_default_response(int response) = 0; virtual Button* get_widget_for_response(int response) = 0; virtual Container* weld_content_area() = 0; + + virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink) + = 0; }; class VCL_DLLPUBLIC MessageDialog : virtual public Dialog diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index f40dbc910efe..f8dfdc33123f 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -126,9 +126,15 @@ SfxModalDialog::SfxModalDialog(vcl::Window *pParent, const OUString& rID, const : ModalDialog(pParent, rID, rUIXMLDescription), pInputSet(nullptr) { + SetInstallLOKNotifierHdl(LINK(this, SfxModalDialog, InstallLOKNotifierHdl)); GetDialogData_Impl(); } +IMPL_LINK_NOARG(SfxModalDialog, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*) +{ + return SfxViewShell::Current(); +} + SfxModalDialog::~SfxModalDialog() { disposeOnce(); @@ -152,41 +158,6 @@ void SfxModalDialog::CreateOutputItemSet( const SfxItemSet& rSet ) } } -namespace -{ - void InstallLOKNotifierCallback(Dialog& rDialog) - { - if (rDialog.GetLOKNotifier()) - return; - - SfxViewShell* pViewShell = SfxViewShell::Current(); - if (!pViewShell) - return; - - // There are some dialogs, like Hyperlink dialog, which inherit from - // SfxModalDialog even though they are modeless, i.e., their Execute method - // isn't called. - rDialog.SetLOKNotifier(pViewShell); - std::vector<vcl::LOKPayloadItem> aItems; - aItems.emplace_back("type", "dialog"); - aItems.emplace_back("size", rDialog.GetSizePixel().toString()); - if (!rDialog.GetText().isEmpty()) - aItems.emplace_back("title", rDialog.GetText().toUtf8()); - pViewShell->notifyWindow(rDialog.GetLOKWindowId(), "created", aItems); - } -} - -void SfxModalDialog::StateChanged( StateChangedType nType ) -{ - if (comphelper::LibreOfficeKit::isActive()) - { - if (nType == StateChangedType::InitShow) - InstallLOKNotifierCallback(*this); - } - - ModalDialog::StateChanged(nType); -} - void SfxModelessDialog::StateChanged( StateChangedType nStateChange ) { if ( nStateChange == StateChangedType::InitShow ) @@ -226,9 +197,6 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange ) } } - if (comphelper::LibreOfficeKit::isActive()) - InstallLOKNotifierCallback(*this); - pImpl->bConstructed = true; } @@ -302,9 +270,15 @@ SfxModelessDialog::SfxModelessDialog(SfxBindings* pBindinx, const OUString& rUIXMLDescription) : ModelessDialog(pParent, rID, rUIXMLDescription) { + SetInstallLOKNotifierHdl(LINK(this, SfxModelessDialog, InstallLOKNotifierHdl)); Init(pBindinx, pCW); } +IMPL_LINK_NOARG(SfxModelessDialog, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*) +{ + return SfxViewShell::Current(); +} + void SfxModelessDialog::Init(SfxBindings *pBindinx, SfxChildWindow *pCW) { pBindings = pBindinx; @@ -735,9 +709,21 @@ void SfxSingleTabDialog::SetTabPage(SfxTabPage* pTabPage) } } +SfxDialogController::SfxDialogController(weld::Widget* pParent, const OUString& rUIFile, + const OString& rDialogId) + : GenericDialogController(pParent, rUIFile, rDialogId) +{ + m_xDialog->SetInstallLOKNotifierHdl(LINK(this, SfxDialogController, InstallLOKNotifierHdl)); +} + +IMPL_LINK_NOARG(SfxDialogController, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*) +{ + return SfxViewShell::Current(); +} + SfxSingleTabDialogController::SfxSingleTabDialogController(weld::Window *pParent, const SfxItemSet& rSet, const OUString& rUIXMLDescription, const OString& rID) - : GenericDialogController(pParent, rUIXMLDescription, rID) + : SfxDialogController(pParent, rUIXMLDescription, rID) , m_pInputSet(&rSet) , m_xContainer(m_xDialog->weld_content_area()) , m_xOKBtn(m_xBuilder->weld_button("ok")) diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 739b6d97a5b7..e4647b02cb04 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -773,6 +773,11 @@ public: return m_xDialog->StartExecuteAsync(aCtx); } + virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink) override + { + m_xDialog->SetInstallLOKNotifierHdl(rLink); + } + virtual int run() override { VclButtonBox* pActionArea = m_xDialog->get_action_area(); diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index f3e977e42c63..bc8da4fb219d 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -347,6 +347,7 @@ struct DialogImpl long mnResult; bool mbStartedModal; VclAbstractDialog::AsyncContext maEndCtx; + Link<void*, vcl::ILibreOfficeKitNotifier*> m_aInstallLOKNotifierHdl; DialogImpl() : mnResult( -1 ), mbStartedModal( false ) {} @@ -721,10 +722,30 @@ Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize) std::max<long>(h, 480 - 50)); } +void Dialog::SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink) +{ + mpDialogImpl->m_aInstallLOKNotifierHdl = rLink; +} + void Dialog::StateChanged( StateChangedType nType ) { if (nType == StateChangedType::InitShow) { + if (comphelper::LibreOfficeKit::isActive() && !GetLOKNotifier()) + { + vcl::ILibreOfficeKitNotifier* pViewShell = mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr); + if (pViewShell) + { + SetLOKNotifier(pViewShell); + std::vector<vcl::LOKPayloadItem> aItems; + aItems.emplace_back("type", "dialog"); + aItems.emplace_back("size", GetSizePixel().toString()); + if (!GetText().isEmpty()) + aItems.emplace_back("title", GetText().toUtf8()); + pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems); + } + } + DoInitialLayout(); if ( !HasChildPathFocus() || HasFocus() ) @@ -830,6 +851,13 @@ bool Dialog::ImplStartExecuteModal() ImplSVData* pSVData = ImplGetSVData(); + const bool bKitActive = comphelper::LibreOfficeKit::isActive(); + if (bKitActive && !GetLOKNotifier()) + { + if (vcl::ILibreOfficeKitNotifier* pViewShell = mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr)) + SetLOKNotifier(pViewShell); + } + switch ( Application::GetDialogCancelMode() ) { case Application::DialogCancelMode::Off: @@ -891,7 +919,7 @@ bool Dialog::ImplStartExecuteModal() } mbInExecute = true; // no real modality in LibreOfficeKit - if (!comphelper::LibreOfficeKit::isActive()) + if (!bKitActive) SetModalInputMode(true); // FIXME: no layouting, workaround some clipping issues @@ -911,7 +939,7 @@ bool Dialog::ImplStartExecuteModal() xEventBroadcaster->documentEventOccured(aObject); UITestLogger::getInstance().log("ModalDialogExecuted Id:" + get_id()); - if (comphelper::LibreOfficeKit::isActive()) + if (bKitActive) { if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) { diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 6ca6886e83d6..2837d4902bc9 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2248,6 +2248,11 @@ public: return new GtkInstanceContainer(GTK_CONTAINER(gtk_dialog_get_content_area(m_pDialog)), false); } + virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>&) override + { + //not implemented for the gtk variant + } + virtual ~GtkInstanceDialog() override { g_signal_handler_disconnect(m_pDialog, m_nCloseSignalId); |