diff options
-rw-r--r-- | include/vcl/svapp.hxx | 2 | ||||
-rw-r--r-- | include/vcl/weld.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/basedlgs.cxx | 7 | ||||
-rw-r--r-- | vcl/Library_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 31 | ||||
-rw-r--r-- | vcl/inc/salvtables.hxx | 4 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 72 | ||||
-rw-r--r-- | vcl/source/app/weldutils.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 17 |
9 files changed, 131 insertions, 9 deletions
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index b450043767f7..48a764b80125 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -1328,7 +1328,7 @@ public: // For vclbootstrapprotector: static void setDeInitHook(Link<LinkParamNone*,void> const & hook); - static weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString &rUIFile); + static weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString &rUIFile, bool bMobile = false); static weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile); //for the duration of vcl parent windows static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 684c70885231..fd734309d6a9 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -2305,7 +2305,7 @@ protected: public: GenericDialogController(weld::Widget* pParent, const OUString& rUIFile, - const OString& rDialogId); + const OString& rDialogId, bool bMobile = false); virtual Dialog* getDialog() override; virtual ~GenericDialogController() COVERITY_NOEXCEPT_FALSE override; }; diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index 4bf16c55927e..d0cafa6926e2 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -29,6 +29,8 @@ #include <sfx2/childwin.hxx> #include <sfx2/viewsh.hxx> #include <workwin.hxx> +#include <sfx2/lokhelper.hxx> +#include <comphelper/lok.hxx> using namespace ::com::sun::star::uno; @@ -200,7 +202,10 @@ void SfxModelessDialogController::Close() SfxDialogController::SfxDialogController(weld::Widget* pParent, const OUString& rUIFile, const OString& rDialogId) - : GenericDialogController(pParent, rUIFile, rDialogId) + : GenericDialogController(pParent, rUIFile, rDialogId, + comphelper::LibreOfficeKit::isActive() + && SfxViewShell::Current() + && SfxViewShell::Current()->isLOKMobilePhone()) { m_xDialog->SetInstallLOKNotifierHdl(LINK(this, SfxDialogController, InstallLOKNotifierHdl)); m_xDialog->connect_toplevel_focus_changed(LINK(this, SfxDialogController, FocusChangeHdl)); diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 65f65b525f4c..35590174946e 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -472,6 +472,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/backendtest/outputdevice/polyline \ vcl/backendtest/outputdevice/polyline_b2d \ vcl/backendtest/outputdevice/rectangle \ + vcl/jsdialog/jsdialogbuilder \ )) $(eval $(call gb_Library_add_cobjects,vcl,\ diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx new file mode 100644 index 000000000000..9d8c68516320 --- /dev/null +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -0,0 +1,31 @@ +#ifndef INCLUDED_VCL_INC_JSDIALOG_JSDIALOG_HXX +#define INCLUDED_VCL_INC_JSDIALOG_JSDIALOG_HXX + +#include <vcl/weld.hxx> +#include <comphelper/string.hxx> +#include <vcl/sysdata.hxx> +#include <vcl/virdev.hxx> +#include <vcl/builder.hxx> +#include <salvtables.hxx> + +class VCL_DLLPUBLIC JSInstanceBuilder : public SalInstanceBuilder +{ +public: + JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile); + virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id, + bool bTakeOwnership = true) override; + virtual std::unique_ptr<weld::Label> weld_label(const OString& id, + bool bTakeOwnership = false) override; +}; + +class VCL_DLLPUBLIC JSLabel : public SalInstanceLabel +{ + VclPtr<vcl::Window> m_aOwnedToplevel; + +public: + JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); + virtual void set_label(const OUString& rText) override; +}; + +#endif
\ No newline at end of file diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 628b4b707c34..c95f093c898f 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -26,7 +26,7 @@ class SalInstanceBuilder : public weld::Builder { -private: +protected: std::unique_ptr<VclBuilder> m_xBuilder; VclPtr<vcl::Window> m_aOwnedToplevel; @@ -393,7 +393,7 @@ public: SystemWindow* getSystemWindow(); }; -class SalInstanceLabel final : public SalInstanceWidget, public virtual weld::Label +class SalInstanceLabel : public SalInstanceWidget, public virtual weld::Label { private: // Control instead of FixedText so we can also use this for diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx new file mode 100644 index 000000000000..1d751ea42847 --- /dev/null +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -0,0 +1,72 @@ +#include <jsdialog/jsdialogbuilder.hxx> +#include <sal/log.hxx> +#include <boost/property_tree/json_parser.hpp> +#include <comphelper/lok.hxx> +#include <vcl/toolkit/dialog.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> + +using namespace weld; + +JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, + const OUString& rUIFile) + : SalInstanceBuilder(dynamic_cast<SalInstanceWidget*>(pParent) + ? dynamic_cast<SalInstanceWidget*>(pParent)->getWidget() + : nullptr, + rUIRoot, rUIFile) +{ +} + +std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id, bool bTakeOwnership) +{ + ::Dialog* pDialog = m_xBuilder->get<::Dialog>(id); + std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false) + : nullptr); + if (bTakeOwnership && pDialog) + { + assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); + m_aOwnedToplevel.set(pDialog); + m_xBuilder->drop_ownership(pDialog); + } + + const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier(); + if (pNotifier) + { + std::stringstream aStream; + boost::property_tree::ptree aTree = m_aOwnedToplevel->DumpAsPropertyTree(); + aTree.put("id", m_aOwnedToplevel->GetLOKWindowId()); + boost::property_tree::write_json(aStream, aTree); + const std::string message = aStream.str(); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); + } + + return pRet; +} + +std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString& id, bool bTakeOwnership) +{ + ::FixedText* pLabel = m_xBuilder->get<FixedText>(id); + return std::make_unique<JSLabel>(m_aOwnedToplevel, pLabel, this, bTakeOwnership); +} + +JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceLabel(pLabel, pBuilder, bTakeOwnership) + , m_aOwnedToplevel(aOwnedToplevel) +{ +} + +void JSLabel::set_label(const OUString& rText) +{ + SalInstanceLabel::set_label(rText); + + const vcl::ILibreOfficeKitNotifier* pNotifier = m_aOwnedToplevel->GetLOKNotifier(); + if (pNotifier) + { + std::stringstream aStream; + boost::property_tree::ptree aTree = m_aOwnedToplevel->DumpAsPropertyTree(); + aTree.put("id", m_aOwnedToplevel->GetLOKWindowId()); + boost::property_tree::write_json(aStream, aTree); + const std::string message = aStream.str(); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); + } +}; diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx index 19f6464052d6..69562cf0d8c7 100644 --- a/vcl/source/app/weldutils.cxx +++ b/vcl/source/app/weldutils.cxx @@ -40,8 +40,8 @@ DialogController::~DialogController() COVERITY_NOEXCEPT_FALSE {} Dialog* GenericDialogController::getDialog() { return m_xDialog.get(); } GenericDialogController::GenericDialogController(weld::Widget* pParent, const OUString& rUIFile, - const OString& rDialogId) - : m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) + const OString& rDialogId, bool bMobile) + : m_xBuilder(Application::CreateBuilder(pParent, rUIFile, bMobile)) , m_xDialog(m_xBuilder->weld_dialog(rDialogId)) { } diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 6189412ac8b9..03f9de9926bd 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -68,6 +68,8 @@ #include <tools/diagnose_ex.h> #include <wizdlg.hxx> #include <tools/svlibrary.h> +#include <comphelper/lok.hxx> +#include <jsdialog/jsdialogbuilder.hxx> #if defined(DISABLE_DYNLOADING) || defined(LINUX) #include <dlfcn.h> @@ -151,9 +153,20 @@ namespace } #endif -weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString &rUIFile) +weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString &rUIFile, bool bMobile) { - return ImplGetSVData()->mpDefInst->CreateBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile); + bool bUseJSBuilder = false; + + if (bMobile) + { + if (rUIFile == "modules/swriter/ui/wordcount-mobile.ui") + bUseJSBuilder = true; + } + + if (bUseJSBuilder) + return new JSInstanceBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile); + else + return ImplGetSVData()->mpDefInst->CreateBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile); } weld::Builder* Application::CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile) |