summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2020-12-08 16:07:40 +0200
committerTor Lillqvist <tml@collabora.com>2020-12-08 20:42:53 +0100
commitc0d770d4feb919cb3306c48d576ac30709154eae (patch)
tree3f47b3c8f4ba0674c41ce8ccb0efeb6ef373ca03
parent69a9b48d50d98130a65aa6c823dc6cc464fefd71 (diff)
Very early work-in-progress commit for the "DevTools" dockable toolbar
This commit mostly just adds the plumbing to officecfg to display the DevTools toolbar. The code for it does not yet implement any specific functionality. The name "DevTools" is likely not what this will actually be called in the end. The DevTools toolbar just contains two unrelated combo boxes. (See https://blog.documentfoundation.org/blog/2020/07/27/tender-for-implementing-support-for-a-dedicated-built-in-uno-object-inspection-tool-in-libreoffice-202007-02/ ) Change-Id: I23cb129b48fde64ae39de5db5811cdf61c8993e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107432 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r--officecfg/registry/data/org/openoffice/Office/Accelerators.xcu6
-rw-r--r--officecfg/registry/data/org/openoffice/Office/ProtocolHandler.xcu5
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu8
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu20
-rw-r--r--svx/Library_svx.mk1
-rw-r--r--svx/source/tbxctrls/tbunodevtoolscontrollers.cxx266
-rw-r--r--svx/util/svx.component5
-rw-r--r--sw/UIConfig_swriter.mk1
-rw-r--r--sw/uiconfig/swriter/menubar/menubar.xml1
-rw-r--r--sw/uiconfig/swriter/toolbar/devtools.xml15
10 files changed, 328 insertions, 0 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
index ea03ebf56377..d3d7c38e0789 100644
--- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
@@ -6171,6 +6171,12 @@ Ctrl+Shift+e aka E_SHIFT_MOD1 under GTK/IBUS is for some emoji thing
<value xml:lang="en-US">.uno:UpdateInputFields</value>
</prop>
</node>
+ <node oor:name="F11_MOD1_MOD2" oor:op="replace">
+ <prop oor:name="Command">
+ <value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
+ <value xml:lang="en-US">vnd.libreoffice.devtools:FocusToDevTools</value>
+ </prop>
+ </node>
<node oor:name="F_MOD1_MOD2" oor:op="replace">
<prop oor:name="Command">
<value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
diff --git a/officecfg/registry/data/org/openoffice/Office/ProtocolHandler.xcu b/officecfg/registry/data/org/openoffice/Office/ProtocolHandler.xcu
index 3e64280d514c..822dc8da9584 100644
--- a/officecfg/registry/data/org/openoffice/Office/ProtocolHandler.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/ProtocolHandler.xcu
@@ -75,5 +75,10 @@
<value>vnd.org.libreoffice.recentdocs:*</value>
</prop>
</node>
+ <node oor:name="org.libreoffice.DevToolsDispatcher" oor:op="replace">
+ <prop oor:name="Protocols">
+ <value>vnd.libreoffice.devtools:*</value>
+ </prop>
+ </node>
</node>
</oor:component-data>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index 7a66a901e65c..14573121ab1e 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -1697,6 +1697,14 @@
<value>1</value>
</prop>
</node>
+ <node oor:name="vnd.libreoffice.devtools:FocusToDevTools" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">DevTools...</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
<node oor:name=".uno:ExtendedHelp" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~What's This?</value>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu
index f5d7bdf862d3..cd05d2951869 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu
@@ -139,6 +139,26 @@
<value>false</value>
</prop>
</node>
+ <node oor:name="private:resource/toolbar/devtools" oor:op="replace">
+ <prop oor:name="DockPos" oor:type="xs:string">
+ <value>0,1</value>
+ </prop>
+ <prop oor:name="Docked" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ <prop oor:name="DockingArea" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value xml:lang="en-US">DevTools</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="ContextSensitive" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
<node oor:name="private:resource/toolbar/textobjectbar" oor:op="replace">
<prop oor:name="DockPos" oor:type="xs:string">
<value>0,1</value>
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk
index f7b947934546..b98a3cc12a6a 100644
--- a/svx/Library_svx.mk
+++ b/svx/Library_svx.mk
@@ -237,6 +237,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
svx/source/tbxctrls/linewidthctrl \
svx/source/tbxctrls/tbunocontroller \
svx/source/tbxctrls/tbunosearchcontrollers \
+ svx/source/tbxctrls/tbunodevtoolscontrollers \
svx/source/tbxctrls/tbxcolor \
svx/source/tbxctrls/tbxdrctl \
svx/source/tbxctrls/verttexttbxctrl \
diff --git a/svx/source/tbxctrls/tbunodevtoolscontrollers.cxx b/svx/source/tbxctrls/tbunodevtoolscontrollers.cxx
new file mode 100644
index 000000000000..37925815dfb9
--- /dev/null
+++ b/svx/source/tbxctrls/tbunodevtoolscontrollers.cxx
@@ -0,0 +1,266 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <map>
+#include <vector>
+
+#include <config_feature_desktop.h>
+
+#include <svx/strings.hrc>
+#include <svx/dialmgr.hxx>
+
+#include <comphelper/propertysequence.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/weak.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/DispatchDescriptor.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/ui/XUIElement.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <com/sun/star/util/URLTransformer.hpp>
+#include <com/sun/star/util/SearchAlgorithms.hpp>
+#include <com/sun/star/util/SearchAlgorithms2.hpp>
+
+#include <vcl/InterimItemWindow.hxx>
+#include <svl/ctloptions.hxx>
+#include <svl/srchitem.hxx>
+#include <svtools/acceleratorexecute.hxx>
+#include <svtools/toolboxcontroller.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/svapp.hxx>
+#include <rtl/instance.hxx>
+#include <svx/labelitemwindow.hxx>
+#include <svx/srchdlg.hxx>
+#include <vcl/event.hxx>
+
+namespace
+{
+// protocol handler for "vnd.libreoffice.devtools:*" URLs
+// The dispatch object will be used for shortcut commands for findbar
+class DevToolsDispatcher : public css::lang::XServiceInfo,
+ public css::lang::XInitialization,
+ public css::frame::XDispatchProvider,
+ public css::frame::XDispatch,
+ public ::cppu::OWeakObject
+{
+public:
+ DevToolsDispatcher();
+ virtual ~DevToolsDispatcher() override;
+
+ // XInterface
+ virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& aType) override;
+ virtual void SAL_CALL acquire() throw() override;
+ virtual void SAL_CALL release() throw() override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+
+ // XInitialization
+ virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& aArguments) override;
+
+ // XDispatchProvider
+ virtual css::uno::Reference<css::frame::XDispatch>
+ SAL_CALL queryDispatch(const css::util::URL& aURL, const OUString& sTargetFrameName,
+ sal_Int32 nSearchFlags) override;
+ virtual css::uno::Sequence<css::uno::Reference<css::frame::XDispatch>> SAL_CALL queryDispatches(
+ const css::uno::Sequence<css::frame::DispatchDescriptor>& lDescriptions) override;
+
+ // XDispatch
+ virtual void SAL_CALL
+ dispatch(const css::util::URL& aURL,
+ const css::uno::Sequence<css::beans::PropertyValue>& lArguments) override;
+ virtual void SAL_CALL
+ addStatusListener(const css::uno::Reference<css::frame::XStatusListener>& xListener,
+ const css::util::URL& aURL) override;
+ virtual void SAL_CALL
+ removeStatusListener(const css::uno::Reference<css::frame::XStatusListener>& xListener,
+ const css::util::URL& aURL) override;
+
+private:
+ css::uno::Reference<css::frame::XFrame> m_xFrame;
+};
+
+DevToolsDispatcher::DevToolsDispatcher() {}
+
+DevToolsDispatcher::~DevToolsDispatcher() { m_xFrame = nullptr; }
+
+// XInterface
+css::uno::Any SAL_CALL DevToolsDispatcher::queryInterface(const css::uno::Type& aType)
+{
+ css::uno::Any aReturn(::cppu::queryInterface(aType, static_cast<css::lang::XServiceInfo*>(this),
+ static_cast<css::lang::XInitialization*>(this),
+ static_cast<css::frame::XDispatchProvider*>(this),
+ static_cast<css::frame::XDispatch*>(this)));
+
+ if (aReturn.hasValue())
+ return aReturn;
+
+ return OWeakObject::queryInterface(aType);
+}
+
+void SAL_CALL DevToolsDispatcher::acquire() throw() { OWeakObject::acquire(); }
+
+void SAL_CALL DevToolsDispatcher::release() throw() { OWeakObject::release(); }
+
+// XServiceInfo
+OUString SAL_CALL DevToolsDispatcher::getImplementationName()
+{
+ return "org.libreoffice.Impl.DevToolsDispatcher";
+}
+
+sal_Bool SAL_CALL DevToolsDispatcher::supportsService(const OUString& ServiceName)
+{
+ return cppu::supportsService(this, ServiceName);
+}
+
+css::uno::Sequence<OUString> SAL_CALL DevToolsDispatcher::getSupportedServiceNames()
+{
+ return { "org.libreoffice.DevToolsDispatcher", "com.sun.star.frame.ProtocolHandler" };
+}
+
+// XInitialization
+void SAL_CALL DevToolsDispatcher::initialize(const css::uno::Sequence<css::uno::Any>& aArguments)
+{
+ if (aArguments.hasElements())
+ aArguments[0] >>= m_xFrame;
+}
+
+// XDispatchProvider
+css::uno::Reference<css::frame::XDispatch> SAL_CALL DevToolsDispatcher::queryDispatch(
+ const css::util::URL& aURL, const OUString& /*sTargetFrameName*/, sal_Int32 /*nSearchFlags*/)
+{
+ css::uno::Reference<css::frame::XDispatch> xDispatch;
+
+ if (aURL.Protocol == "vnd.libreoffice.devtools:")
+ xDispatch = this;
+
+ return xDispatch;
+}
+
+css::uno::Sequence<css::uno::Reference<css::frame::XDispatch>>
+ SAL_CALL DevToolsDispatcher::queryDispatches(
+ const css::uno::Sequence<css::frame::DispatchDescriptor>& seqDescripts)
+{
+ sal_Int32 nCount = seqDescripts.getLength();
+ css::uno::Sequence<css::uno::Reference<XDispatch>> lDispatcher(nCount);
+
+ std::transform(
+ seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(),
+ [this](const css::frame::DispatchDescriptor& rDescript) -> css::uno::Reference<XDispatch> {
+ return queryDispatch(rDescript.FeatureURL, rDescript.FrameName, rDescript.SearchFlags);
+ });
+
+ return lDispatcher;
+}
+
+// XDispatch
+void SAL_CALL DevToolsDispatcher::dispatch(
+ const css::util::URL& aURL, const css::uno::Sequence<css::beans::PropertyValue>& /*lArgs*/)
+{
+ //vnd.libreoffice.devtools:FocusToDevTools - set cursor to the XXX of the devtools
+ if (aURL.Path != "FocusToDevTools")
+ return;
+
+ css::uno::Reference<css::beans::XPropertySet> xPropSet(m_xFrame, css::uno::UNO_QUERY);
+ if (!xPropSet.is())
+ return;
+
+ css::uno::Reference<css::frame::XLayoutManager> xLayoutManager;
+ css::uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
+ aValue >>= xLayoutManager;
+ if (!xLayoutManager.is())
+ return;
+
+ const OUString sResourceURL("private:resource/toolbar/devtools");
+ css::uno::Reference<css::ui::XUIElement> xUIElement = xLayoutManager->getElement(sResourceURL);
+ if (!xUIElement.is())
+ {
+ // show the devtools if necessary
+ xLayoutManager->createElement(sResourceURL);
+ xLayoutManager->showElement(sResourceURL);
+ xUIElement = xLayoutManager->getElement(sResourceURL);
+ if (!xUIElement.is())
+ return;
+ }
+
+ css::uno::Reference<css::awt::XWindow> xWindow(xUIElement->getRealInterface(),
+ css::uno::UNO_QUERY);
+ VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow);
+ ToolBox* pToolBox = static_cast<ToolBox*>(pWindow.get());
+ pToolBox->set_id("DevTools");
+ if (!pToolBox)
+ return;
+
+ ToolBox::ImplToolItems::size_type nItemCount = pToolBox->GetItemCount();
+ for (ToolBox::ImplToolItems::size_type i = 0; i < nItemCount; ++i)
+ {
+ sal_uInt16 id = pToolBox->GetItemId(i);
+ OUString sItemCommand = pToolBox->GetItemCommand(id);
+ if (sItemCommand == ".uno:DevTools")
+ {
+ vcl::Window* pItemWin = pToolBox->GetItemWindow(id);
+ if (pItemWin)
+ {
+ SolarMutexGuard aSolarMutexGuard;
+#if 0 // ???
+ Control* pControl = dynamic_cast<Control*>(pItemWin);
+ if ( pControl )
+ pControl->SetTextToSelected_Impl();
+#endif
+ pItemWin->GrabFocus();
+ return;
+ }
+ }
+ }
+}
+
+void SAL_CALL DevToolsDispatcher::addStatusListener(
+ const css::uno::Reference<css::frame::XStatusListener>& /*xControl*/,
+ const css::util::URL& /*aURL*/)
+{
+}
+
+void SAL_CALL DevToolsDispatcher::removeStatusListener(
+ const css::uno::Reference<css::frame::XStatusListener>& /*xControl*/,
+ const css::util::URL& /*aURL*/)
+{
+}
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+org_libreoffice_Impl_DevToolsDispatcher_get_implementation(
+ SAL_UNUSED_PARAMETER css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new DevToolsDispatcher);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/util/svx.component b/svx/util/svx.component
index ff8d802394ac..f9d2cce75229 100644
--- a/svx/util/svx.component
+++ b/svx/util/svx.component
@@ -28,6 +28,11 @@
<service name="com.sun.star.comp.svx.FindbarDispatcher"/>
<service name="com.sun.star.frame.ProtocolHandler"/>
</implementation>
+ <implementation name="org.libreoffice.Impl.DevToolsDispatcher"
+ constructor="org_libreoffice_Impl_DevToolsDispatcher_get_implementation">
+ <service name="org.libreoffice.DevToolsDispatcher"/>
+ <service name="com.sun.star.frame.ProtocolHandler"/>
+ </implementation>
<implementation name="com.sun.star.comp.svx.RecoveryUI"
constructor="com_sun_star_comp_svx_RecoveryUI_get_implementation">
<service name="com.sun.star.dialog.RecoveryUI"/>
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 71a0632d6979..4d78aa0cb550 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -46,6 +46,7 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/swriter,\
sw/uiconfig/swriter/toolbar/changes \
sw/uiconfig/swriter/toolbar/classificationbar \
sw/uiconfig/swriter/toolbar/colorbar \
+ sw/uiconfig/swriter/toolbar/devtools \
sw/uiconfig/swriter/toolbar/drawbar \
sw/uiconfig/swriter/toolbar/drawingobjectbar \
sw/uiconfig/swriter/toolbar/drawtextobjectbar \
diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml
index 6b83059e213b..6f479f65bf24 100644
--- a/sw/uiconfig/swriter/menubar/menubar.xml
+++ b/sw/uiconfig/swriter/menubar/menubar.xml
@@ -787,6 +787,7 @@
</menu:menupopup>
</menu:menu>
<menu:menuitem menu:id="service:com.sun.star.deployment.ui.PackageManagerDialog" menu:style="text"/>
+ <menu:menuitem menu:id="vnd.libreoffice.devtools:FocusToDevTools" menu:style="text"/>
<menu:menuitem menu:id=".uno:ConfigureDialog" menu:style="text"/>
<menu:menuitem menu:id=".uno:OptionsTreeDialog"/>
</menu:menupopup>
diff --git a/sw/uiconfig/swriter/toolbar/devtools.xml b/sw/uiconfig/swriter/toolbar/devtools.xml
new file mode 100644
index 000000000000..5b8ed5f673f0
--- /dev/null
+++ b/sw/uiconfig/swriter/toolbar/devtools.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
+<!--
+ * 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/.
+-->
+<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
+ <!-- Unrelated items, just temporary -->
+ <toolbar:toolbaritem xlink:href=".uno:FontHeight"/>
+ <toolbar:toolbarseparator/>
+ <toolbar:toolbaritem xlink:href=".uno:FontHeight"/>
+</toolbar:toolbar>