summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2019-10-18 13:57:22 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-11-01 00:24:05 +0100
commitc538764082f29ef98fb859cae37a895cee2de889 (patch)
tree7c7374c81a77f88ae2c11408c2b4fbd6a205494e /framework
parentc720ad95d0c375d217db2816877a6d25d825163a (diff)
Toolbar: add usage of FixedText as toolbar control
Change-Id: I26a79c485fa2e168058025e058bcfb793af7515f Reviewed-on: https://gerrit.libreoffice.org/81039 Reviewed-by: Serge Krot (CIB) <Serge.Krot@cib.de> Tested-by: Serge Krot (CIB) <Serge.Krot@cib.de> (cherry picked from commit c2682ba52ea0cbb7af95e80f6d67b286061aeae2) Reviewed-on: https://gerrit.libreoffice.org/81643 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'framework')
-rw-r--r--framework/Library_fwk.mk1
-rw-r--r--framework/inc/uielement/FixedTextToolbarController.hxx55
-rw-r--r--framework/inc/uielement/toolbarmerger.hxx1
-rw-r--r--framework/source/uielement/FixedTextToolbarController.cxx98
-rw-r--r--framework/source/uielement/toolbarmerger.cxx3
5 files changed, 158 insertions, 0 deletions
diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk
index 665df00be044..5d59402c2be5 100644
--- a/framework/Library_fwk.mk
+++ b/framework/Library_fwk.mk
@@ -132,6 +132,7 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
framework/source/uielement/controlmenucontroller \
framework/source/uielement/dropdownboxtoolbarcontroller \
framework/source/uielement/edittoolbarcontroller \
+ framework/source/uielement/FixedTextToolbarController \
framework/source/uielement/genericstatusbarcontroller \
framework/source/uielement/generictoolbarcontroller \
framework/source/uielement/imagebuttontoolbarcontroller \
diff --git a/framework/inc/uielement/FixedTextToolbarController.hxx b/framework/inc/uielement/FixedTextToolbarController.hxx
new file mode 100644
index 000000000000..cd8afb9499eb
--- /dev/null
+++ b/framework/inc/uielement/FixedTextToolbarController.hxx
@@ -0,0 +1,55 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDTEXTTOOLBARCONTROLLER_HXX
+#define INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDTEXTTOOLBARCONTROLLER_HXX
+
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/frame/ControlCommand.hpp>
+
+#include <uielement/complextoolbarcontroller.hxx>
+
+class ToolBox;
+class FixedText;
+
+namespace framework
+{
+class FixedTextToolbarController : public ComplexToolbarController
+{
+public:
+ FixedTextToolbarController(const css::uno::Reference<css::uno::XComponentContext>& rxContext,
+ const css::uno::Reference<css::frame::XFrame>& rFrame,
+ ToolBox* pToolBar, sal_uInt16 nID, const OUString& aCommand);
+
+ // XComponent
+ virtual void SAL_CALL dispose() override;
+
+protected:
+ virtual void executeControlCommand(const css::frame::ControlCommand& rControlCommand) override;
+ virtual css::uno::Sequence<css::beans::PropertyValue>
+ getExecuteArgs(sal_Int16 KeyModifier) const override;
+
+private:
+ VclPtr<FixedText> m_pFixedTextControl;
+};
+}
+
+#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDTEXTTOOLBARCONTROLLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/framework/inc/uielement/toolbarmerger.hxx b/framework/inc/uielement/toolbarmerger.hxx
index cc0448a8f76f..cfe236f8328a 100644
--- a/framework/inc/uielement/toolbarmerger.hxx
+++ b/framework/inc/uielement/toolbarmerger.hxx
@@ -27,6 +27,7 @@
#include <uielement/spinfieldtoolbarcontroller.hxx>
#include <uielement/edittoolbarcontroller.hxx>
#include <uielement/dropdownboxtoolbarcontroller.hxx>
+#include <uielement/FixedTextToolbarController.hxx>
#include <uielement/commandinfo.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
diff --git a/framework/source/uielement/FixedTextToolbarController.cxx b/framework/source/uielement/FixedTextToolbarController.cxx
new file mode 100644
index 000000000000..7a2a41ae9c0f
--- /dev/null
+++ b/framework/source/uielement/FixedTextToolbarController.cxx
@@ -0,0 +1,98 @@
+/* -*- 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 <uielement/FixedTextToolbarController.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <vcl/window.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+
+namespace framework
+{
+FixedTextToolbarController::FixedTextToolbarController(
+ const Reference<XComponentContext>& rxContext, const Reference<XFrame>& rFrame,
+ ToolBox* pToolbar, sal_uInt16 nID, const OUString& aCommand)
+ : ComplexToolbarController(rxContext, rFrame, pToolbar, nID, aCommand)
+{
+ m_pFixedTextControl = VclPtr<FixedText>::Create(m_pToolbar, WB_NOMULTILINE | WB_VCENTER
+ | WB_LEFT | WB_NOPOINTERFOCUS);
+ m_pToolbar->SetItemWindow(m_nID, m_pFixedTextControl);
+ m_pToolbar->SetItemBits(m_nID, ToolBoxItemBits::AUTOSIZE | m_pToolbar->GetItemBits(m_nID));
+}
+
+void SAL_CALL FixedTextToolbarController::dispose()
+{
+ SolarMutexGuard aSolarMutexGuard;
+ m_pToolbar->SetItemWindow(m_nID, nullptr);
+ m_pFixedTextControl.disposeAndClear();
+ ComplexToolbarController::dispose();
+}
+
+Sequence<PropertyValue> FixedTextToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const
+{
+ Sequence<PropertyValue> aArgs(2);
+ const OUString aSelectedText = m_pFixedTextControl->GetText();
+
+ // Add key modifier to argument list
+ aArgs[0].Name = "KeyModifier";
+ aArgs[0].Value <<= KeyModifier;
+ aArgs[1].Name = "Text";
+ aArgs[1].Value <<= aSelectedText;
+ return aArgs;
+}
+
+void FixedTextToolbarController::executeControlCommand(
+ const css::frame::ControlCommand& rControlCommand)
+{
+ SolarMutexGuard aSolarMutexGuard;
+
+ if (rControlCommand.Command == "SetText")
+ {
+ for (sal_Int32 i = 0; i < rControlCommand.Arguments.getLength(); i++)
+ {
+ if (rControlCommand.Arguments[i].Name == "Text")
+ {
+ OUString aText;
+ rControlCommand.Arguments[i].Value >>= aText;
+ m_pFixedTextControl->SetText(aText);
+ m_pFixedTextControl->SetSizePixel(m_pFixedTextControl->GetOptimalSize());
+
+ // send notification
+ notifyTextChanged(aText);
+ break;
+ }
+ }
+ }
+}
+
+} // namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/framework/source/uielement/toolbarmerger.cxx b/framework/source/uielement/toolbarmerger.cxx
index 4e257d02954b..22a9169ce73e 100644
--- a/framework/source/uielement/toolbarmerger.cxx
+++ b/framework/source/uielement/toolbarmerger.cxx
@@ -50,6 +50,7 @@ static const char TOOLBARCONTROLLER_IMGBUTTON[] = "ImageButton";
static const char TOOLBARCONTROLLER_DROPDOWNBOX[] = "Dropdownbox";
static const char TOOLBARCONTROLLER_DROPDOWNBTN[] = "DropdownButton";
static const char TOOLBARCONTROLLER_TOGGLEDDBTN[] = "ToggleDropdownButton";
+static const char TOOLBARCONTROLLER_FIXEDTEXT[] = "FixedText";
static const char TOOLBOXITEM_SEPARATOR_STR[] = "private:separator";
@@ -605,6 +606,8 @@ void ToolBarMerger::RemoveItems(
else if ( rControlType == TOOLBARCONTROLLER_DROPDOWNBTN )
pResult = new ToggleButtonToolbarController( rxContext, xFrame, pToolbar, nId,
ToggleButtonToolbarController::Style::DropDownButton, rCommandURL );
+ else if ( rControlType == TOOLBARCONTROLLER_FIXEDTEXT )
+ pResult = new FixedTextToolbarController( rxContext, xFrame, pToolbar, nId, rCommandURL );
else if ( rControlType == TOOLBARCONTROLLER_TOGGLEDDBTN )
pResult = new ToggleButtonToolbarController( rxContext, xFrame, pToolbar, nId,
ToggleButtonToolbarController::Style::ToggleDropDownButton, rCommandURL );