vcl/inc/jsdialog/jsdialogbuilder.hxx | 95 ----------------------------- vcl/inc/jsdialog/jsdialogmessages.hxx | 110 ++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 93 deletions(-)
New commits: commit 9877694e27f7e52ab8ac69c3729677cd8090e41f Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Tue Dec 3 19:05:30 2024 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Tue Dec 10 16:49:21 2024 +0100 jsdialog: move message related classes to separate header no functional change - just make files shorter Signed-off-by: Szymon Kłos <szymon.k...@collabora.com> Change-Id: Ice8ccedc235c81f26cbe6e753785bb3e0d960324 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178208 Tested-by: Jenkins diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 41f261924288..ed47d8a16f9e 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -10,9 +10,10 @@ #pragma once #include <jsdialog/jsdialogregister.hxx> +#include <jsdialog/jsdialogmessages.hxx> + #include <utility> #include <vcl/weld.hxx> -#include <vcl/jsdialog/executor.hxx> #include <vcl/virdev.hxx> #include <salvtables.hxx> #include <vcl/toolkit/button.hxx> @@ -24,7 +25,6 @@ #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> #include <comphelper/compbase.hxx> -#include <deque> #include <list> #include <mutex> @@ -45,99 +45,8 @@ namespace vcl class ILibreOfficeKitNotifier; } -namespace jsdialog -{ -enum MessageType -{ - FullUpdate, - WidgetUpdate, - Close, - Action, - Popup, - PopupClose -}; -} - typedef jsdialog::WidgetRegister<weld::Widget*> WidgetMap; -/// Class with the message description for storing in the queue -class JSDialogMessageInfo -{ -public: - jsdialog::MessageType m_eType; - VclPtr<vcl::Window> m_pWindow; - std::unique_ptr<jsdialog::ActionDataMap> m_pData; - -private: - void copy(const JSDialogMessageInfo& rInfo) - { - this->m_eType = rInfo.m_eType; - this->m_pWindow = rInfo.m_pWindow; - if (rInfo.m_pData) - { - std::unique_ptr<jsdialog::ActionDataMap> pData( - new jsdialog::ActionDataMap(*rInfo.m_pData)); - this->m_pData = std::move(pData); - } - } - -public: - JSDialogMessageInfo(jsdialog::MessageType eType, VclPtr<vcl::Window> pWindow, - std::unique_ptr<jsdialog::ActionDataMap> pData) - : m_eType(eType) - , m_pWindow(std::move(pWindow)) - , m_pData(std::move(pData)) - { - } - - JSDialogMessageInfo(const JSDialogMessageInfo& rInfo) { copy(rInfo); } - - JSDialogMessageInfo& operator=(JSDialogMessageInfo aInfo) - { - if (this == &aInfo) - return *this; - - copy(aInfo); - return *this; - } -}; - -class JSDialogNotifyIdle final : public Idle -{ - // used to send message - VclPtr<vcl::Window> m_aNotifierWindow; - // used to generate JSON - VclPtr<vcl::Window> m_aContentWindow; - OUString m_sTypeOfJSON; - OString m_LastNotificationMessage; - bool m_bForce; - - std::deque<JSDialogMessageInfo> m_aMessageQueue; - std::mutex m_aQueueMutex; - -public: - JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, - const OUString& sTypeOfJSON); - - void Invoke() override; - - void clearQueue(); - void forceUpdate(); - void sendMessage(jsdialog::MessageType eType, const VclPtr<vcl::Window>& pWindow, - std::unique_ptr<jsdialog::ActionDataMap> pData = nullptr); - -private: - void send(const OString& sMsg); - OString generateFullUpdate() const; - OString generateWidgetUpdate(VclPtr<vcl::Window> pWindow) const; - OString generateCloseMessage() const; - OString generateActionMessage(VclPtr<vcl::Window> pWindow, - std::unique_ptr<jsdialog::ActionDataMap> pData) const; - OString generatePopupMessage(VclPtr<vcl::Window> pWindow, const OUString& sParentId, - const OUString& sCloseId) const; - OString generateClosePopupMessage(const OUString& sWindowId) const; -}; - class JSDialogSender { std::unique_ptr<JSDialogNotifyIdle> mpIdleNotify; diff --git a/vcl/inc/jsdialog/jsdialogmessages.hxx b/vcl/inc/jsdialog/jsdialogmessages.hxx new file mode 100644 index 000000000000..67e937ecdb0f --- /dev/null +++ b/vcl/inc/jsdialog/jsdialogmessages.hxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <deque> + +#include <rtl/ustring.hxx> +#include <vcl/idle.hxx> +#include <vcl/jsdialog/executor.hxx> +#include <vcl/window.hxx> + +namespace jsdialog +{ +enum MessageType +{ + FullUpdate, + WidgetUpdate, + Close, + Action, + Popup, + PopupClose +}; +} + +/// Class with the message description for storing in the queue +class JSDialogMessageInfo +{ +public: + jsdialog::MessageType m_eType; + VclPtr<vcl::Window> m_pWindow; + std::unique_ptr<jsdialog::ActionDataMap> m_pData; + +private: + void copy(const JSDialogMessageInfo& rInfo) + { + this->m_eType = rInfo.m_eType; + this->m_pWindow = rInfo.m_pWindow; + if (rInfo.m_pData) + { + std::unique_ptr<jsdialog::ActionDataMap> pData( + new jsdialog::ActionDataMap(*rInfo.m_pData)); + this->m_pData = std::move(pData); + } + } + +public: + JSDialogMessageInfo(jsdialog::MessageType eType, VclPtr<vcl::Window> pWindow, + std::unique_ptr<jsdialog::ActionDataMap> pData) + : m_eType(eType) + , m_pWindow(std::move(pWindow)) + , m_pData(std::move(pData)) + { + } + + JSDialogMessageInfo(const JSDialogMessageInfo& rInfo) { copy(rInfo); } + + JSDialogMessageInfo& operator=(JSDialogMessageInfo aInfo) + { + if (this == &aInfo) + return *this; + + copy(aInfo); + return *this; + } +}; + +class JSDialogNotifyIdle final : public Idle +{ + // used to send message + VclPtr<vcl::Window> m_aNotifierWindow; + // used to generate JSON + VclPtr<vcl::Window> m_aContentWindow; + OUString m_sTypeOfJSON; + OString m_LastNotificationMessage; + bool m_bForce; + + std::deque<JSDialogMessageInfo> m_aMessageQueue; + std::mutex m_aQueueMutex; + +public: + JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, + const OUString& sTypeOfJSON); + + void Invoke() override; + + void clearQueue(); + void forceUpdate(); + void sendMessage(jsdialog::MessageType eType, const VclPtr<vcl::Window>& pWindow, + std::unique_ptr<jsdialog::ActionDataMap> pData = nullptr); + +private: + void send(const OString& sMsg); + OString generateFullUpdate() const; + OString generateWidgetUpdate(VclPtr<vcl::Window> pWindow) const; + OString generateCloseMessage() const; + OString generateActionMessage(VclPtr<vcl::Window> pWindow, + std::unique_ptr<jsdialog::ActionDataMap> pData) const; + OString generatePopupMessage(VclPtr<vcl::Window> pWindow, const rtl::OUString& sParentId, + const rtl::OUString& sCloseId) const; + OString generateClosePopupMessage(const rtl::OUString& sWindowId) const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */