From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../source/helper/IComboListBoxHelper.cxx | 17 + accessibility/source/helper/acc_factory.cxx | 500 +++++++++++++++++++++ accessibility/source/helper/accresmgr.cxx | 24 + .../source/helper/characterattributeshelper.cxx | 78 ++++ 4 files changed, 619 insertions(+) create mode 100644 accessibility/source/helper/IComboListBoxHelper.cxx create mode 100644 accessibility/source/helper/acc_factory.cxx create mode 100644 accessibility/source/helper/accresmgr.cxx create mode 100644 accessibility/source/helper/characterattributeshelper.cxx (limited to 'accessibility/source/helper') diff --git a/accessibility/source/helper/IComboListBoxHelper.cxx b/accessibility/source/helper/IComboListBoxHelper.cxx new file mode 100644 index 000000000..f4830815f --- /dev/null +++ b/accessibility/source/helper/IComboListBoxHelper.cxx @@ -0,0 +1,17 @@ +/* -*- 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/. + */ + +#include + +namespace accessibility +{ +IComboListBoxHelper::~IComboListBoxHelper() {} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/accessibility/source/helper/acc_factory.cxx b/accessibility/source/helper/acc_factory.cxx new file mode 100644 index 000000000..10cc27f00 --- /dev/null +++ b/accessibility/source/helper/acc_factory.cxx @@ -0,0 +1,500 @@ +/* -*- 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace ::accessibility; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::accessibility; +using namespace ::vcl; +using namespace ::vcl::table; + +namespace { + +bool hasFloatingChild(vcl::Window *pWindow) +{ + vcl::Window * pChild = pWindow->GetAccessibleChildWindow(0); + return pChild && pChild->GetType() == WindowType::FLOATINGWINDOW; +} + +// IAccessibleFactory +class AccessibleFactory :public ::toolkit::IAccessibleFactory + ,public ::vcl::IAccessibleFactory +{ +public: + AccessibleFactory(); + + // ::toolkit::IAccessibleFactory + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXButton* _pXWindow ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXCheckBox* _pXWindow ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXRadioButton* _pXWindow ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXListBox* _pXWindow ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXFixedText* _pXWindow ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXFixedHyperlink* _pXWindow ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXScrollBar* _pXWindow ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXEdit* _pXWindow ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXComboBox* _pXWindow ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleContext( VCLXToolBox* _pXWindow ) override; + 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; + + // ::vcl::IAccessibleFactory + virtual vcl::IAccessibleTabListBox* + createAccessibleTabListBox( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + SvHeaderTabListBox& rBox + ) const override; + + virtual vcl::IAccessibleBrowseBox* + createAccessibleBrowseBox( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + vcl::IAccessibleTableProvider& _rBrowseBox + ) const override; + + virtual IAccessibleTableControl* + createAccessibleTableControl( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + IAccessibleTable& _rTable + ) const override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleIconChoiceCtrl( + SvtIconChoiceCtrl& _rIconCtrl, + const css::uno::Reference< css::accessibility::XAccessible >& _xParent + ) const override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleTabBar( + TabBar& _rTabBar + ) const override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleTextWindowContext( + VCLXWindow* pVclXWindow, TextEngine& rEngine, TextView& rView + ) const override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleTreeListBox( + SvTreeListBox& _rListBox, + const css::uno::Reference< css::accessibility::XAccessible >& _xParent + ) const override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleIconView( + SvTreeListBox& _rListBox, + const css::uno::Reference< css::accessibility::XAccessible >& _xParent + ) const override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleBrowseBoxHeaderBar( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + vcl::IAccessibleTableProvider& _rOwningTable, + AccessibleBrowseBoxObjType _eObjType + ) const override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleBrowseBoxTableCell( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + vcl::IAccessibleTableProvider& _rBrowseBox, + const css::uno::Reference< css::awt::XWindow >& _xFocusWindow, + sal_Int32 _nRowId, + sal_uInt16 _nColId, + sal_Int32 _nOffset + ) const override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleBrowseBoxHeaderCell( + sal_Int32 _nColumnRowId, + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + vcl::IAccessibleTableProvider& _rBrowseBox, + const css::uno::Reference< css::awt::XWindow >& _xFocusWindow, + AccessibleBrowseBoxObjType _eObjType + ) const override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleCheckBoxCell( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + vcl::IAccessibleTableProvider& _rBrowseBox, + const css::uno::Reference< css::awt::XWindow >& _xFocusWindow, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos, + const TriState& _eState, + bool _bIsTriState + ) const override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createEditBrowseBoxTableCellAccess( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + const css::uno::Reference< css::accessibility::XAccessible >& _rxControlAccessible, + const css::uno::Reference< css::awt::XWindow >& _rxFocusWindow, + vcl::IAccessibleTableProvider& _rBrowseBox, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos + ) const override; + +protected: + virtual ~AccessibleFactory() override; +}; + +AccessibleFactory::AccessibleFactory() +{ +} + +AccessibleFactory::~AccessibleFactory() +{ +} + +Reference< XAccessible > AccessibleFactory::createAccessible( Menu* _pMenu, bool _bIsMenuBar ) +{ + rtl::Reference pAccessible; + if ( _bIsMenuBar ) + pAccessible = new VCLXAccessibleMenuBar( _pMenu ); + else + pAccessible = new VCLXAccessiblePopupMenu( _pMenu ); + pAccessible->SetStates(); + return pAccessible; +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXButton* _pXWindow ) +{ + return new VCLXAccessibleButton( _pXWindow ); +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXCheckBox* _pXWindow ) +{ + return new VCLXAccessibleCheckBox( _pXWindow ); +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXRadioButton* _pXWindow ) +{ + return new VCLXAccessibleRadioButton( _pXWindow ); +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXListBox* _pXWindow ) +{ + bool bIsDropDownBox = false; + VclPtr< ListBox > pBox = _pXWindow->GetAs< ListBox >(); + if ( pBox ) + bIsDropDownBox = ( ( pBox->GetStyle() & WB_DROPDOWN ) == WB_DROPDOWN ); + + if ( bIsDropDownBox ) + return new VCLXAccessibleDropDownListBox( _pXWindow ); + else + return new VCLXAccessibleListBox( _pXWindow ); +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXFixedText* _pXWindow ) +{ + return new VCLXAccessibleFixedText( _pXWindow ); +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXFixedHyperlink* _pXWindow ) +{ + return new VCLXAccessibleFixedHyperlink( _pXWindow ); +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXScrollBar* _pXWindow ) +{ + return new VCLXAccessibleScrollBar( _pXWindow ); +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXEdit* _pXWindow ) +{ + return new VCLXAccessibleEdit( _pXWindow ); +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXComboBox* _pXWindow ) +{ + bool bIsDropDownBox = false; + VclPtr< ComboBox > pBox = _pXWindow->GetAs< ComboBox >(); + if ( pBox ) + bIsDropDownBox = ( ( pBox->GetStyle() & WB_DROPDOWN ) == WB_DROPDOWN ); + + if ( bIsDropDownBox ) + return new VCLXAccessibleDropDownComboBox( _pXWindow ); + else + return new VCLXAccessibleComboBox( _pXWindow ); +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXWindow* _pXWindow ) +{ + Reference< XAccessibleContext > xContext; + + VclPtr pWindow = _pXWindow->GetWindow(); + if ( pWindow ) + { + WindowType nType = pWindow->GetType(); + + if ( nType == WindowType::MENUBARWINDOW || pWindow->IsMenuFloatingWindow() || pWindow->IsToolbarFloatingWindow() ) + { + Reference< XAccessible > xAcc( pWindow->GetAccessible() ); + if ( xAcc.is() ) + { + Reference< XAccessibleContext > xCont( xAcc->getAccessibleContext() ); + if ( pWindow->GetType() == WindowType::MENUBARWINDOW || + ( xCont.is() && xCont->getAccessibleRole() == AccessibleRole::POPUP_MENU ) ) + { + xContext = xCont; + } + } + } + + else if ( nType == WindowType::STATUSBAR ) + { + xContext = new VCLXAccessibleStatusBar(_pXWindow); + } + + else if ( nType == WindowType::TABCONTROL ) + { + xContext = new VCLXAccessibleTabControl(_pXWindow); + } + + else if ( nType == WindowType::TABPAGE && pWindow->GetAccessibleParentWindow() && pWindow->GetAccessibleParentWindow()->GetType() == WindowType::TABCONTROL ) + { + xContext = new VCLXAccessibleTabPageWindow( _pXWindow ); + } + + else if ( nType == WindowType::FLOATINGWINDOW ) + { + xContext = new FloatingWindowAccessible( _pXWindow ); + } + + else if ( nType == WindowType::BORDERWINDOW && hasFloatingChild( pWindow ) ) + { + xContext = new FloatingWindowAccessible( _pXWindow ); + } + + else if ( ( nType == WindowType::HELPTEXTWINDOW ) || ( nType == WindowType::FIXEDLINE ) ) + { + xContext = new VCLXAccessibleFixedText(_pXWindow); + } + else + { + xContext = new VCLXAccessibleComponent(_pXWindow); + } + } + return xContext; +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXToolBox* _pXWindow ) +{ + return new VCLXAccessibleToolBox( _pXWindow ); +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXHeaderBar* _pXWindow ) +{ + 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 +{ + return new AccessibleTabListBox( rxParent, rBox ); +} + +vcl::IAccessibleBrowseBox* AccessibleFactory::createAccessibleBrowseBox( + const Reference< XAccessible >& _rxParent, vcl::IAccessibleTableProvider& _rBrowseBox ) const +{ + return new AccessibleBrowseBoxAccess( _rxParent, _rBrowseBox ); +} + +IAccessibleTableControl* AccessibleFactory::createAccessibleTableControl( + const Reference< XAccessible >& _rxParent, IAccessibleTable& _rTable ) const +{ + return new AccessibleGridControlAccess( _rxParent, _rTable ); +} + +Reference< XAccessible > AccessibleFactory::createAccessibleIconChoiceCtrl( + SvtIconChoiceCtrl& _rIconCtrl, const Reference< XAccessible >& _xParent ) const +{ + return new AccessibleIconChoiceCtrl( _rIconCtrl, _xParent ); +} + +Reference< XAccessible > AccessibleFactory::createAccessibleTabBar( TabBar& _rTabBar ) const +{ +#if HAVE_FEATURE_SCRIPTING + return new AccessibleTabBar( &_rTabBar ); +#else + (void)_rTabBar; + return nullptr; +#endif +} + +Reference< XAccessibleContext > AccessibleFactory::createAccessibleTextWindowContext( + VCLXWindow* pVclXWindow, TextEngine& rEngine, TextView& rView ) const +{ + return new Document( pVclXWindow, rEngine, rView ); +} + +Reference< XAccessible > AccessibleFactory::createAccessibleTreeListBox( + SvTreeListBox& _rListBox, const Reference< XAccessible >& _xParent ) const +{ + return new AccessibleListBox( _rListBox, _xParent ); +} + +Reference< XAccessible > AccessibleFactory::createAccessibleIconView( + SvTreeListBox& _rListBox, const Reference< XAccessible >& _xParent ) const +{ + return new AccessibleIconView( _rListBox, _xParent ); +} + +Reference< XAccessible > AccessibleFactory::createAccessibleBrowseBoxHeaderBar( + const Reference< XAccessible >& rxParent, vcl::IAccessibleTableProvider& _rOwningTable, + AccessibleBrowseBoxObjType _eObjType ) const +{ + return new AccessibleBrowseBoxHeaderBar( rxParent, _rOwningTable, _eObjType ); +} + +Reference< XAccessible > AccessibleFactory::createAccessibleBrowseBoxTableCell( + const Reference< XAccessible >& _rxParent, vcl::IAccessibleTableProvider& _rBrowseBox, + const Reference< XWindow >& _xFocusWindow, sal_Int32 _nRowId, sal_uInt16 _nColId, sal_Int32 _nOffset ) const +{ + return new AccessibleBrowseBoxTableCell( _rxParent, _rBrowseBox, _xFocusWindow, + _nRowId, _nColId, _nOffset ); +} + +Reference< XAccessible > AccessibleFactory::createAccessibleBrowseBoxHeaderCell( + sal_Int32 _nColumnRowId, const Reference< XAccessible >& rxParent, vcl::IAccessibleTableProvider& _rBrowseBox, + const Reference< XWindow >& _xFocusWindow, AccessibleBrowseBoxObjType _eObjType ) const +{ + return new AccessibleBrowseBoxHeaderCell( _nColumnRowId, rxParent, _rBrowseBox, + _xFocusWindow, _eObjType ); +} + +Reference< XAccessible > AccessibleFactory::createAccessibleCheckBoxCell( + const Reference< XAccessible >& _rxParent, vcl::IAccessibleTableProvider& _rBrowseBox, + const Reference< XWindow >& _xFocusWindow, sal_Int32 _nRowPos, sal_uInt16 _nColPos, + const TriState& _eState, bool _bIsTriState ) const +{ + return new AccessibleCheckBoxCell( _rxParent, _rBrowseBox, _xFocusWindow, + _nRowPos, _nColPos, _eState, _bIsTriState ); +} + +Reference< XAccessible > AccessibleFactory::createEditBrowseBoxTableCellAccess( + const Reference< XAccessible >& _rxParent, const Reference< XAccessible >& _rxControlAccessible, + const Reference< XWindow >& _rxFocusWindow, vcl::IAccessibleTableProvider& _rBrowseBox, + sal_Int32 _nRowPos, sal_uInt16 _nColPos ) const +{ + return new EditBrowseBoxTableCellAccess( _rxParent, _rxControlAccessible, + _rxFocusWindow, _rBrowseBox, _nRowPos, _nColPos ); +} + +} // anonymous namespace + +#if HAVE_FEATURE_DESKTOP +/* this is the entry point to retrieve a factory for the toolkit-level Accessible/Contexts supplied + by this library + + This function implements the factory function needed in toolkit + (of type GetStandardAccComponentFactory). +*/ +extern "C" +{ + SAL_DLLPUBLIC_EXPORT void* getStandardAccessibleFactory() + { + ::toolkit::IAccessibleFactory* pFactory = new AccessibleFactory; + pFactory->acquire(); + return pFactory; + } +} + +/** this is the entry point to retrieve a factory for the svtools-level Accessible/Contexts supplied + by this library + + This function implements the factory function needed in svtools + (of type GetSvtAccessibilityComponentFactory). +*/ +extern "C" +{ + SAL_DLLPUBLIC_EXPORT void* getSvtAccessibilityComponentFactory() + { + ::vcl::IAccessibleFactory* pFactory = new AccessibleFactory; + pFactory->acquire(); + return pFactory; + } +} +#endif // HAVE_FEATURE_DESKTOP + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/accessibility/source/helper/accresmgr.cxx b/accessibility/source/helper/accresmgr.cxx new file mode 100644 index 000000000..f120dcb26 --- /dev/null +++ b/accessibility/source/helper/accresmgr.cxx @@ -0,0 +1,24 @@ +/* -*- 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 + +OUString AccResId(TranslateId aId) { return Translate::get(aId, Translate::Create("acc")); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/accessibility/source/helper/characterattributeshelper.cxx b/accessibility/source/helper/characterattributeshelper.cxx new file mode 100644 index 000000000..9cbeaaee8 --- /dev/null +++ b/accessibility/source/helper/characterattributeshelper.cxx @@ -0,0 +1,78 @@ +/* -*- 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 +#include +#include + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; + + +CharacterAttributesHelper::CharacterAttributesHelper( const vcl::Font& rFont, sal_Int32 nBackColor, sal_Int32 nColor ) +{ + m_aAttributeMap.emplace( OUString( "CharBackColor" ), Any( nBackColor ) ); + m_aAttributeMap.emplace( OUString( "CharColor" ), Any( nColor ) ); + m_aAttributeMap.emplace( OUString( "CharFontCharSet" ), Any( static_cast(rFont.GetCharSet()) ) ); + m_aAttributeMap.emplace( OUString( "CharFontFamily" ), Any( static_cast(rFont.GetFamilyType()) ) ); + m_aAttributeMap.emplace( OUString( "CharFontName" ), Any( rFont.GetFamilyName() ) ); + m_aAttributeMap.emplace( OUString( "CharFontPitch" ), Any( static_cast(rFont.GetPitch()) ) ); + m_aAttributeMap.emplace( OUString( "CharFontStyleName" ), Any( rFont.GetStyleName() ) ); + m_aAttributeMap.emplace( OUString( "CharHeight" ), Any( static_cast(rFont.GetFontSize().Height()) ) ); + m_aAttributeMap.emplace( OUString( "CharScaleWidth" ), Any( static_cast(rFont.GetFontSize().Width()) ) ); + m_aAttributeMap.emplace( OUString( "CharStrikeout" ), Any( static_cast(rFont.GetStrikeout()) ) ); + m_aAttributeMap.emplace( OUString( "CharUnderline" ), Any( static_cast(rFont.GetUnderline()) ) ); + m_aAttributeMap.emplace( OUString( "CharWeight" ), Any( static_cast(rFont.GetWeight()) ) ); + m_aAttributeMap.emplace( OUString( "CharPosture" ), Any( static_cast(rFont.GetItalic()) ) ); +} + + +std::vector< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes() +{ + std::vector< PropertyValue > aValues; + aValues.reserve( m_aAttributeMap.size() ); + + for ( const auto& aIt : m_aAttributeMap) + { + aValues.emplace_back(aIt.first, sal_Int32(-1), aIt.second, PropertyState_DIRECT_VALUE); + } + + return aValues; +} + + +Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes( const css::uno::Sequence< OUString >& aRequestedAttributes ) +{ + if ( !aRequestedAttributes.hasElements() ) + return comphelper::containerToSequence(GetCharacterAttributes()); + + std::vector< PropertyValue > aValues; + + for ( const auto& aRequestedAttribute: aRequestedAttributes) + { + AttributeMap::iterator aFound = m_aAttributeMap.find( aRequestedAttribute ); + if ( aFound != m_aAttributeMap.end() ) + aValues.emplace_back(aFound->first, sal_Int32(-1), aFound->second, PropertyState_DIRECT_VALUE); + } + + return comphelper::containerToSequence(aValues); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3