framework/Library_fwk.mk | 1 framework/inc/uielement/FixedTextToolbarController.hxx | 55 +++++++ framework/inc/uielement/toolbarmerger.hxx | 1 framework/source/uielement/FixedTextToolbarController.cxx | 97 ++++++++++++++ framework/source/uielement/toolbarmerger.cxx | 3 5 files changed, 157 insertions(+)
New commits: commit c2682ba52ea0cbb7af95e80f6d67b286061aeae2 Author: Serge Krot <serge.k...@cib.de> AuthorDate: Fri Oct 18 13:57:22 2019 +0200 Commit: Serge Krot (CIB) <serge.k...@cib.de> CommitDate: Fri Oct 18 14:06:03 2019 +0200 Toolbar: Added usage of FixedText as toolbar control Change-Id: I26a79c485fa2e168058025e058bcfb793af7515f Reviewed-on: https://gerrit.libreoffice.org/81039 Reviewed-by: Serge Krot (CIB) <serge.k...@cib.de> Tested-by: Serge Krot (CIB) <serge.k...@cib.de> 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 old mode 100644 new mode 100755 index cc0448a8f76f..cfe236f8328a --- 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..605e795f75fe --- /dev/null +++ b/framework/source/uielement/FixedTextToolbarController.cxx @@ -0,0 +1,97 @@ +/* -*- 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> + +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 old mode 100644 new mode 100755 index 4e257d02954b..22a9169ce73e --- 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 ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits