LCOV - code coverage report
Current view: top level - libreoffice/accessibility/source/helper - characterattributeshelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 46 0.0 %
Date: 2012-12-27 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      20             : #include <accessibility/helper/characterattributeshelper.hxx>
      21             : 
      22             : using namespace ::com::sun::star::uno;
      23             : using namespace ::com::sun::star::beans;
      24             : 
      25             : 
      26           0 : CharacterAttributesHelper::CharacterAttributesHelper( const Font& rFont, sal_Int32 nBackColor, sal_Int32 nColor )
      27             : {
      28           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharBackColor" ),     makeAny( (sal_Int32) nBackColor ) ) );
      29           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharColor" ),         makeAny( (sal_Int32) nColor ) ) );
      30           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharFontCharSet" ),   makeAny( (sal_Int16) rFont.GetCharSet() ) ) );
      31           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharFontFamily" ),    makeAny( (sal_Int16) rFont.GetFamily() ) ) );
      32           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharFontName" ),      makeAny( (OUString) rFont.GetName() ) ) );
      33           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharFontPitch" ),     makeAny( (sal_Int16) rFont.GetPitch() ) ) );
      34           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharFontStyleName" ), makeAny( (OUString) rFont.GetStyleName() ) ) );
      35           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharHeight" ),        makeAny( (sal_Int16) rFont.GetSize().Height() ) ) );
      36           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharScaleWidth" ),    makeAny( (sal_Int16) rFont.GetSize().Width() ) ) );
      37           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharStrikeout" ),     makeAny( (sal_Int16) rFont.GetStrikeout() ) ) );
      38           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharUnderline" ),     makeAny( (sal_Int16) rFont.GetUnderline() ) ) );
      39           0 :     m_aAttributeMap.insert( AttributeMap::value_type( OUString( "CharWeight" ),        makeAny( (float) rFont.GetWeight() ) ) );
      40           0 : }
      41             : 
      42             : 
      43           0 : CharacterAttributesHelper::~CharacterAttributesHelper()
      44             : {
      45           0 :     m_aAttributeMap.clear();
      46           0 : }
      47             : 
      48             : 
      49           0 : Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes()
      50             : {
      51           0 :     Sequence< PropertyValue > aValues( m_aAttributeMap.size() );
      52           0 :     PropertyValue* pValues = aValues.getArray();
      53             : 
      54           0 :     for ( AttributeMap::iterator aIt = m_aAttributeMap.begin(); aIt != m_aAttributeMap.end(); ++aIt, ++pValues )
      55             :     {
      56           0 :         pValues->Name   = aIt->first;
      57           0 :         pValues->Handle = (sal_Int32) -1;
      58           0 :         pValues->Value  = aIt->second;
      59           0 :         pValues->State  = PropertyState_DIRECT_VALUE;
      60             :     }
      61             : 
      62           0 :     return aValues;
      63             : }
      64             : 
      65             : 
      66           0 : Sequence< PropertyValue > CharacterAttributesHelper::GetCharacterAttributes( const Sequence< OUString >& aRequestedAttributes )
      67             : {
      68           0 :     Sequence< PropertyValue > aValues;
      69           0 :     sal_Int32 nLength = aRequestedAttributes.getLength();
      70             : 
      71           0 :     if ( nLength != 0 )
      72             :     {
      73           0 :         const OUString* pNames = aRequestedAttributes.getConstArray();
      74           0 :         AttributeMap aAttributeMap;
      75             : 
      76           0 :         for ( sal_Int32 i = 0; i < nLength; ++i )
      77             :         {
      78           0 :             AttributeMap::iterator aFound = m_aAttributeMap.find( pNames[i] );
      79           0 :             if ( aFound != m_aAttributeMap.end() )
      80           0 :                 aAttributeMap.insert( *aFound );
      81             :         }
      82             : 
      83           0 :         aValues.realloc( aAttributeMap.size() );
      84           0 :         PropertyValue* pValues = aValues.getArray();
      85             : 
      86           0 :         for ( AttributeMap::iterator aIt = aAttributeMap.begin(); aIt != aAttributeMap.end(); ++aIt, ++pValues )
      87             :         {
      88           0 :             pValues->Name   = aIt->first;
      89           0 :             pValues->Handle = (sal_Int32) -1;
      90           0 :             pValues->Value  = aIt->second;
      91           0 :             pValues->State  = PropertyState_DIRECT_VALUE;
      92           0 :         }
      93             :     }
      94             :     else
      95             :     {
      96           0 :         aValues = GetCharacterAttributes();
      97             :     }
      98             : 
      99           0 :     return aValues;
     100             : }
     101             : 
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10