LibreOffice Module accessibility (master) 1
characterattributeshelper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <tools/gen.hxx>
22#include <vcl/unohelp.hxx>
24
25using namespace ::com::sun::star::uno;
26using namespace ::com::sun::star::beans;
27
28
29CharacterAttributesHelper::CharacterAttributesHelper( const vcl::Font& rFont, sal_Int32 nBackColor, sal_Int32 nColor )
30{
31 m_aAttributeMap.emplace( OUString( "CharBackColor" ), Any( nBackColor ) );
32 m_aAttributeMap.emplace( OUString( "CharColor" ), Any( nColor ) );
33 m_aAttributeMap.emplace( OUString( "CharFontCharSet" ), Any( static_cast<sal_Int16>(rFont.GetCharSet()) ) );
34 m_aAttributeMap.emplace( OUString( "CharFontFamily" ), Any( static_cast<sal_Int16>(rFont.GetFamilyType()) ) );
35 m_aAttributeMap.emplace( OUString( "CharFontName" ), Any( rFont.GetFamilyName() ) );
36 m_aAttributeMap.emplace( OUString( "CharFontPitch" ), Any( static_cast<sal_Int16>(rFont.GetPitch()) ) );
37 m_aAttributeMap.emplace( OUString( "CharFontStyleName" ), Any( rFont.GetStyleName() ) );
38 m_aAttributeMap.emplace( OUString( "CharHeight" ), Any( static_cast<sal_Int16>(rFont.GetFontSize().Height()) ) );
39 m_aAttributeMap.emplace( OUString( "CharScaleWidth" ), Any( static_cast<sal_Int16>(rFont.GetFontSize().Width()) ) );
40 m_aAttributeMap.emplace( OUString( "CharStrikeout" ), Any( static_cast<sal_Int16>(rFont.GetStrikeout()) ) );
41 m_aAttributeMap.emplace( OUString( "CharUnderline" ), Any( static_cast<sal_Int16>(rFont.GetUnderline()) ) );
42 m_aAttributeMap.emplace( OUString( "CharWeight" ), Any( static_cast<float>(rFont.GetWeight()) ) );
43 m_aAttributeMap.emplace( OUString( "CharPosture" ), Any( vcl::unohelper::ConvertFontSlant(rFont.GetItalic()) ) );
44}
45
46
48{
49 std::vector< PropertyValue > aValues;
50 aValues.reserve( m_aAttributeMap.size() );
51
52 for ( const auto& aIt : m_aAttributeMap)
53 {
54 aValues.emplace_back(aIt.first, sal_Int32(-1), aIt.second, PropertyState_DIRECT_VALUE);
55 }
56
57 return aValues;
58}
59
60
61Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes( const css::uno::Sequence< OUString >& aRequestedAttributes )
62{
63 if ( !aRequestedAttributes.hasElements() )
65
66 std::vector< PropertyValue > aValues;
67
68 for ( const auto& aRequestedAttribute: aRequestedAttributes)
69 {
70 AttributeMap::iterator aFound = m_aAttributeMap.find( aRequestedAttribute );
71 if ( aFound != m_aAttributeMap.end() )
72 aValues.emplace_back(aFound->first, sal_Int32(-1), aFound->second, PropertyState_DIRECT_VALUE);
73 }
74
75 return comphelper::containerToSequence(aValues);
76}
77
78
79/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< css::beans::PropertyValue > GetCharacterAttributes()
CharacterAttributesHelper(const vcl::Font &rFont, sal_Int32 nBackColor, sal_Int32 nColor)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
FontFamily GetFamilyType()
const OUString & GetStyleName() const
FontStrikeout GetStrikeout() const
FontItalic GetItalic()
const OUString & GetFamilyName() const
const Size & GetFontSize() const
FontPitch GetPitch()
FontWeight GetWeight()
FontLineStyle GetUnderline() const
rtl_TextEncoding GetCharSet() const
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
VCL_DLLPUBLIC css::awt::FontSlant ConvertFontSlant(FontItalic eWeight)