diff options
-rw-r--r-- | accessibility/Library_acc.mk | 1 | ||||
-rw-r--r-- | accessibility/inc/standard/svtaccessiblenumericfield.hxx | 50 | ||||
-rw-r--r-- | accessibility/inc/standard/vclxaccessibleedit.hxx | 5 | ||||
-rw-r--r-- | accessibility/source/helper/acc_factory.cxx | 8 | ||||
-rw-r--r-- | accessibility/source/standard/svtaccessiblenumericfield.cxx | 93 | ||||
-rw-r--r-- | include/toolkit/awt/vclxwindows.hxx | 4 | ||||
-rw-r--r-- | include/toolkit/helper/accessiblefactory.hxx | 6 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindows.cxx | 7 | ||||
-rw-r--r-- | toolkit/source/helper/accessibilityclient.cxx | 5 | ||||
-rw-r--r-- | toolkit/source/helper/unowrapper.cxx | 2 |
10 files changed, 177 insertions, 4 deletions
diff --git a/accessibility/Library_acc.mk b/accessibility/Library_acc.mk index caf3d612330b..fe88dafe10da 100644 --- a/accessibility/Library_acc.mk +++ b/accessibility/Library_acc.mk @@ -78,6 +78,7 @@ $(eval $(call gb_Library_add_exception_objects,acc,\ accessibility/source/standard/accessiblemenucomponent \ accessibility/source/standard/accessiblemenuitemcomponent \ accessibility/source/standard/floatingwindowaccessible \ + accessibility/source/standard/svtaccessiblenumericfield \ accessibility/source/standard/vclxaccessiblebox \ accessibility/source/standard/vclxaccessiblebutton \ accessibility/source/standard/vclxaccessiblecheckbox \ diff --git a/accessibility/inc/standard/svtaccessiblenumericfield.hxx b/accessibility/inc/standard/svtaccessiblenumericfield.hxx new file mode 100644 index 000000000000..940f72fa03f2 --- /dev/null +++ b/accessibility/inc/standard/svtaccessiblenumericfield.hxx @@ -0,0 +1,50 @@ +/* -*- 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 . + */ + +#pragma once + +#include <cppuhelper/implbase1.hxx> +#include <standard/vclxaccessibleedit.hxx> + +#include <com/sun/star/accessibility/XAccessibleValue.hpp> + +typedef ::cppu::ImplHelper1<css::accessibility::XAccessibleValue> SVTXAccessibleNumericField_BASE; + +class SVTXAccessibleNumericField : public VCLXAccessibleEdit, public SVTXAccessibleNumericField_BASE +{ +public: + SVTXAccessibleNumericField(VCLXWindow* pVCLXindow); + + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XAccessibleContext + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + + // XAccessibleValue + virtual ::css::uno::Any SAL_CALL getCurrentValue() override; + virtual ::sal_Bool SAL_CALL setCurrentValue(const css::uno::Any& aNumber) override; + virtual ::css::uno::Any SAL_CALL getMaximumValue() override; + virtual ::css::uno::Any SAL_CALL getMinimumValue() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/accessibility/inc/standard/vclxaccessibleedit.hxx b/accessibility/inc/standard/vclxaccessibleedit.hxx index a02d03319e8a..2f2ee88cc29b 100644 --- a/accessibility/inc/standard/vclxaccessibleedit.hxx +++ b/accessibility/inc/standard/vclxaccessibleedit.hxx @@ -33,14 +33,15 @@ typedef ::cppu::ImplHelper2< css::accessibility::XAccessibleAction, css::accessibility::XAccessibleEditableText > VCLXAccessibleEdit_BASE; -class VCLXAccessibleEdit final : public VCLXAccessibleTextComponent, - public VCLXAccessibleEdit_BASE +class VCLXAccessibleEdit : public VCLXAccessibleTextComponent, + public VCLXAccessibleEdit_BASE { friend class VCLXAccessibleBox; private: sal_Int32 m_nCaretPosition; +protected: virtual ~VCLXAccessibleEdit() override = default; virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; diff --git a/accessibility/source/helper/acc_factory.cxx b/accessibility/source/helper/acc_factory.cxx index 720ecda1808b..51adeaca8d21 100644 --- a/accessibility/source/helper/acc_factory.cxx +++ b/accessibility/source/helper/acc_factory.cxx @@ -22,6 +22,7 @@ #include <toolkit/awt/vclxwindows.hxx> #include <toolkit/helper/accessiblefactory.hxx> #include <vcl/accessiblefactory.hxx> +#include <standard/svtaccessiblenumericfield.hxx> #include <standard/vclxaccessiblebutton.hxx> #include <standard/vclxaccessiblecheckbox.hxx> #include <standard/vclxaccessibledropdowncombobox.hxx> @@ -106,6 +107,8 @@ public: virtual css::uno::Reference< css::accessibility::XAccessibleContext > createAccessibleContext( VCLXHeaderBar* _pXWindow ) override; virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( SVTXNumericField* _pXWindow ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > createAccessibleContext( VCLXWindow* _pXWindow ) override; virtual css::uno::Reference< css::accessibility::XAccessible > createAccessible( Menu* _pMenu, bool _bIsMenuBar ) override; @@ -352,6 +355,11 @@ Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLX return new VCLXAccessibleHeaderBar(_pXWindow); } +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( SVTXNumericField* _pXWindow ) +{ + return new SVTXAccessibleNumericField( _pXWindow ); +} + vcl::IAccessibleTabListBox* AccessibleFactory::createAccessibleTabListBox( const Reference< XAccessible >& rxParent, SvHeaderTabListBox& rBox ) const { diff --git a/accessibility/source/standard/svtaccessiblenumericfield.cxx b/accessibility/source/standard/svtaccessiblenumericfield.cxx new file mode 100644 index 000000000000..114bf71802fe --- /dev/null +++ b/accessibility/source/standard/svtaccessiblenumericfield.cxx @@ -0,0 +1,93 @@ +/* -*- 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 <standard/svtaccessiblenumericfield.hxx> +#include <toolkit/awt/vclxwindows.hxx> + +#include <com/sun/star/accessibility/AccessibleRole.hpp> + +using namespace ::com::sun::star::accessibility; +using namespace ::comphelper; + +SVTXAccessibleNumericField::SVTXAccessibleNumericField(VCLXWindow* pVCLWindow) + : VCLXAccessibleEdit(pVCLWindow) +{ +} + +// XInterface +IMPLEMENT_FORWARD_XINTERFACE2(SVTXAccessibleNumericField, VCLXAccessibleTextComponent, + SVTXAccessibleNumericField_BASE) + +// XTypeProvider +IMPLEMENT_FORWARD_XTYPEPROVIDER2(SVTXAccessibleNumericField, VCLXAccessibleTextComponent, + SVTXAccessibleNumericField_BASE) + +sal_Int16 SVTXAccessibleNumericField::getAccessibleRole() { return AccessibleRole::SPIN_BOX; } + +css::uno::Any SAL_CALL SVTXAccessibleNumericField::getCurrentValue() +{ + OExternalLockGuard aGuard(this); + + double dValue = 0; + SVTXNumericField* pField = static_cast<SVTXNumericField*>(GetVCLXWindow()); + if (pField) + dValue = pField->getValue(); + + return css::uno::Any(dValue); +} + +sal_Bool SVTXAccessibleNumericField::setCurrentValue(const css::uno::Any& aNumber) +{ + OExternalLockGuard aGuard(this); + + SVTXNumericField* pField = static_cast<SVTXNumericField*>(GetVCLXWindow()); + if (!pField) + return false; + + double dValue = 0; + aNumber >>= dValue; + pField->setValue(dValue); + return true; +} + +css::uno::Any SAL_CALL SVTXAccessibleNumericField::getMaximumValue() +{ + OExternalLockGuard aGuard(this); + + double dValue = 0; + SVTXNumericField* pField = static_cast<SVTXNumericField*>(GetVCLXWindow()); + if (pField) + dValue = pField->getMax(); + + return css::uno::Any(dValue); +} + +css::uno::Any SAL_CALL SVTXAccessibleNumericField::getMinimumValue() +{ + OExternalLockGuard aGuard(this); + + double dValue = 0; + SVTXNumericField* pField = static_cast<SVTXNumericField*>(GetVCLXWindow()); + if (pField) + dValue = pField->getMin(); + + return css::uno::Any(dValue); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/toolkit/awt/vclxwindows.hxx b/include/toolkit/awt/vclxwindows.hxx index 99f8fea450fa..9e365eeb6d3f 100644 --- a/include/toolkit/awt/vclxwindows.hxx +++ b/include/toolkit/awt/vclxwindows.hxx @@ -542,7 +542,7 @@ protected: virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } }; -class SVTXNumericField final : public css::awt::XNumericField, public SVTXFormattedField +class TOOLKIT_DLLPUBLIC SVTXNumericField final : public css::awt::XNumericField, public SVTXFormattedField { public: SVTXNumericField(); @@ -576,6 +576,8 @@ public: sal_Bool SAL_CALL isStrictFormat( ) override; virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override; }; // class VCLXListBox diff --git a/include/toolkit/helper/accessiblefactory.hxx b/include/toolkit/helper/accessiblefactory.hxx index 109e1cbea038..bd7ae90976d4 100644 --- a/include/toolkit/helper/accessiblefactory.hxx +++ b/include/toolkit/helper/accessiblefactory.hxx @@ -27,6 +27,7 @@ namespace com::sun::star::accessibility { class XAccessible; class XAccessibleContext; } +class SVTXNumericField; class VCLXButton; class VCLXCheckBox; class VCLXRadioButton; @@ -116,6 +117,11 @@ namespace toolkit virtual css::uno::Reference< css::accessibility::XAccessibleContext > createAccessibleContext( VCLXHeaderBar* _pXWindow ) = 0; + /** creates an accessible context for a numeric field + */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( SVTXNumericField* _pXWindow ) = 0; + /** creates an accessible context for a generic window */ virtual css::uno::Reference< css::accessibility::XAccessibleContext > diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index caf63ba3b5d0..02bd6b8799e8 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -7665,6 +7665,13 @@ css::uno::Sequence< css::uno::Type > SVTXNumericField::getTypes() return aTypeList.getTypes(); } + +css::uno::Reference<accessibility::XAccessibleContext> SVTXNumericField::CreateAccessibleContext() +{ + return getAccessibleFactory().createAccessibleContext(this); +} + + void SVTXNumericField::setValue( double Value ) { SolarMutexGuard aGuard; diff --git a/toolkit/source/helper/accessibilityclient.cxx b/toolkit/source/helper/accessibilityclient.cxx index 9d795ac620e4..7136dc5a3a8d 100644 --- a/toolkit/source/helper/accessibilityclient.cxx +++ b/toolkit/source/helper/accessibilityclient.cxx @@ -120,6 +120,11 @@ namespace toolkit return nullptr; } css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( SVTXNumericField* /*_pXWindow*/ ) override + { + return nullptr; + } + css::uno::Reference< css::accessibility::XAccessibleContext > createAccessibleContext( VCLXWindow* /*_pXWindow*/ ) override { return nullptr; diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx index aa32d1b86aa6..4f3f3b22b604 100644 --- a/toolkit/source/helper/unowrapper.cxx +++ b/toolkit/source/helper/unowrapper.cxx @@ -55,8 +55,8 @@ static rtl::Reference<VCLXWindow> CreateXWindow( vcl::Window const * pWindow ) // corresponding accessibility API. case WindowType::METRICBOX: case WindowType::COMBOBOX: return new VCLXComboBox; + case WindowType::FORMATTEDFIELD: return new SVTXNumericField; case WindowType::SPINFIELD: - case WindowType::FORMATTEDFIELD: case WindowType::CURRENCYFIELD: return new VCLXNumericField; case WindowType::DATEFIELD: return new VCLXDateField; case WindowType::MULTILINEEDIT: |