Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <accessibility/helper/characterattributeshelper.hxx>
30 : :
31 : : using namespace ::com::sun::star::uno;
32 : : using namespace ::com::sun::star::beans;
33 : :
34 : :
35 : 4 : CharacterAttributesHelper::CharacterAttributesHelper( const Font& rFont, sal_Int32 nBackColor, sal_Int32 nColor )
36 : : {
37 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackColor" )), makeAny( (sal_Int32) nBackColor ) ) );
[ + - ]
38 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" )), makeAny( (sal_Int32) nColor ) ) );
[ + - ]
39 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontCharSet" )), makeAny( (sal_Int16) rFont.GetCharSet() ) ) );
[ + - ][ + - ]
40 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontFamily" )), makeAny( (sal_Int16) rFont.GetFamily() ) ) );
[ + - ][ + - ]
41 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" )), makeAny( (::rtl::OUString) rFont.GetName() ) ) );
[ + - ][ + - ]
[ + - ]
42 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontPitch" )), makeAny( (sal_Int16) rFont.GetPitch() ) ) );
[ + - ][ + - ]
43 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontStyleName" )), makeAny( (::rtl::OUString) rFont.GetStyleName() ) ) );
[ + - ][ + - ]
[ + - ]
44 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" )), makeAny( (sal_Int16) rFont.GetSize().Height() ) ) );
[ + - ][ + - ]
45 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharScaleWidth" )), makeAny( (sal_Int16) rFont.GetSize().Width() ) ) );
[ + - ][ + - ]
46 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharStrikeout" )), makeAny( (sal_Int16) rFont.GetStrikeout() ) ) );
[ + - ][ + - ]
47 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharUnderline" )), makeAny( (sal_Int16) rFont.GetUnderline() ) ) );
[ + - ][ + - ]
48 [ + - ][ + - ]: 4 : m_aAttributeMap.insert( AttributeMap::value_type( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharWeight" )), makeAny( (float) rFont.GetWeight() ) ) );
[ + - ][ + - ]
49 : 4 : }
50 : :
51 : :
52 : 4 : CharacterAttributesHelper::~CharacterAttributesHelper()
53 : : {
54 : 4 : m_aAttributeMap.clear();
55 : 4 : }
56 : :
57 : :
58 : 0 : Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes()
59 : : {
60 : 0 : Sequence< PropertyValue > aValues( m_aAttributeMap.size() );
61 [ # # ]: 0 : PropertyValue* pValues = aValues.getArray();
62 : :
63 [ # # ]: 0 : for ( AttributeMap::iterator aIt = m_aAttributeMap.begin(); aIt != m_aAttributeMap.end(); ++aIt, ++pValues )
64 : : {
65 : 0 : pValues->Name = aIt->first;
66 : 0 : pValues->Handle = (sal_Int32) -1;
67 : 0 : pValues->Value = aIt->second;
68 : 0 : pValues->State = PropertyState_DIRECT_VALUE;
69 : : }
70 : :
71 : 0 : return aValues;
72 : : }
73 : :
74 : :
75 : 4 : Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes( const Sequence< ::rtl::OUString >& aRequestedAttributes )
76 : : {
77 : 4 : Sequence< PropertyValue > aValues;
78 : 4 : sal_Int32 nLength = aRequestedAttributes.getLength();
79 : :
80 [ + - ]: 4 : if ( nLength != 0 )
81 : : {
82 : 4 : const ::rtl::OUString* pNames = aRequestedAttributes.getConstArray();
83 [ + - ]: 4 : AttributeMap aAttributeMap;
84 : :
85 [ + + ]: 8 : for ( sal_Int32 i = 0; i < nLength; ++i )
86 : : {
87 [ + - ]: 4 : AttributeMap::iterator aFound = m_aAttributeMap.find( pNames[i] );
88 [ - + ]: 4 : if ( aFound != m_aAttributeMap.end() )
89 [ # # ]: 0 : aAttributeMap.insert( *aFound );
90 : : }
91 : :
92 [ + - ]: 4 : aValues.realloc( aAttributeMap.size() );
93 [ + - ]: 4 : PropertyValue* pValues = aValues.getArray();
94 : :
95 [ - + ]: 4 : for ( AttributeMap::iterator aIt = aAttributeMap.begin(); aIt != aAttributeMap.end(); ++aIt, ++pValues )
96 : : {
97 : 0 : pValues->Name = aIt->first;
98 : 0 : pValues->Handle = (sal_Int32) -1;
99 : 0 : pValues->Value = aIt->second;
100 : 0 : pValues->State = PropertyState_DIRECT_VALUE;
101 : 4 : }
102 : : }
103 : : else
104 : : {
105 [ # # ][ # # ]: 0 : aValues = GetCharacterAttributes();
[ # # ]
106 : : }
107 : :
108 : 4 : return aValues;
109 : : }
110 : :
111 : :
112 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|