LCOV - code coverage report
Current view: top level - oox/source/drawingml - textcharacterproperties.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 109 111 98.2 %
Date: 2014-04-11 Functions: 7 7 100.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 "oox/drawingml/textcharacterproperties.hxx"
      21             : #include <com/sun/star/lang/Locale.hpp>
      22             : #include <com/sun/star/awt/FontSlant.hpp>
      23             : #include <com/sun/star/awt/FontWeight.hpp>
      24             : #include <i18nlangtag/languagetag.hxx>
      25             : #include <editeng/escapementitem.hxx>
      26             : #include "oox/helper/helper.hxx"
      27             : #include "oox/helper/propertyset.hxx"
      28             : #include "oox/core/xmlfilterbase.hxx"
      29             : #include "oox/drawingml/drawingmltypes.hxx"
      30             : #include "oox/token/tokens.hxx"
      31             : 
      32             : using ::oox::core::XmlFilterBase;
      33             : using namespace ::com::sun::star;
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::beans;
      36             : 
      37             : namespace oox {
      38             : namespace drawingml {
      39             : 
      40             : 
      41             : 
      42       39119 : void TextCharacterProperties::assignUsed( const TextCharacterProperties& rSourceProps )
      43             : {
      44             :     // overwrite all properties exisiting in rSourceProps
      45       39119 :     maHyperlinkPropertyMap.assignUsed( rSourceProps.maHyperlinkPropertyMap );
      46       39119 :     maLatinFont.assignIfUsed( rSourceProps.maLatinFont );
      47       39119 :     maLatinThemeFont.assignIfUsed( rSourceProps.maLatinThemeFont );
      48       39119 :     maAsianFont.assignIfUsed( rSourceProps.maAsianFont );
      49       39119 :     maAsianThemeFont.assignIfUsed( rSourceProps.maAsianThemeFont );
      50       39119 :     maComplexFont.assignIfUsed( rSourceProps.maComplexFont );
      51       39119 :     maComplexThemeFont.assignIfUsed( rSourceProps.maComplexThemeFont );
      52       39119 :     maSymbolFont.assignIfUsed( rSourceProps.maSymbolFont );
      53       39119 :     maCharColor.assignIfUsed( rSourceProps.maCharColor );
      54       39119 :     maHighlightColor.assignIfUsed( rSourceProps.maHighlightColor );
      55       39119 :     maUnderlineColor.assignIfUsed( rSourceProps.maUnderlineColor );
      56       39119 :     moHeight.assignIfUsed( rSourceProps.moHeight );
      57       39119 :     moSpacing.assignIfUsed( rSourceProps.moSpacing );
      58       39119 :     moUnderline.assignIfUsed( rSourceProps.moUnderline );
      59       39119 :     moBaseline.assignIfUsed( rSourceProps.moBaseline );
      60       39119 :     moStrikeout.assignIfUsed( rSourceProps.moStrikeout );
      61       39119 :     moCaseMap.assignIfUsed( rSourceProps.moCaseMap );
      62       39119 :     moBold.assignIfUsed( rSourceProps.moBold );
      63       39119 :     moItalic.assignIfUsed( rSourceProps.moItalic );
      64       39119 :     moUnderlineLineFollowText.assignIfUsed( rSourceProps.moUnderlineLineFollowText );
      65       39119 :     moUnderlineFillFollowText.assignIfUsed( rSourceProps.moUnderlineFillFollowText );
      66             : 
      67       39119 :     maTextEffectsProperties = rSourceProps.maTextEffectsProperties;
      68       39119 :     maGradientProps.assignUsed( rSourceProps.maGradientProps );
      69       39119 : }
      70             : 
      71        1427 : void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFilterBase& rFilter, bool bUseOptional ) const
      72             : {
      73        1427 :     OUString aFontName;
      74        1427 :     sal_Int16 nFontPitch = 0;
      75        1427 :     sal_Int16 nFontFamily = 0;
      76             : 
      77        1427 :     bool bRet = maLatinFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter );
      78        1427 :     if (!bRet)
      79             :         // In case there is no direct font, try to look it up as a theme reference.
      80         269 :         bRet = maLatinThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter );
      81        1427 :     if (bRet)
      82             :     {
      83        1164 :         rPropMap.setProperty( PROP_CharFontName, aFontName);
      84        1164 :         rPropMap.setProperty( PROP_CharFontPitch, nFontPitch);
      85        1164 :         rPropMap.setProperty( PROP_CharFontFamily, nFontFamily);
      86             :     }
      87             : 
      88        1427 :     bRet = maAsianFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter );
      89        1427 :     if (!bRet)
      90        1373 :         bRet = maAsianThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter );
      91        1427 :     if (bRet)
      92             :     {
      93          55 :         rPropMap.setProperty( PROP_CharFontNameAsian, aFontName);
      94          55 :         rPropMap.setProperty( PROP_CharFontPitchAsian, nFontFamily);
      95          55 :         rPropMap.setProperty( PROP_CharFontFamilyAsian, nFontPitch);
      96             :     }
      97             : 
      98        1427 :     bRet = maComplexFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter );
      99        1427 :     if (!bRet)
     100        1236 :         bRet = maComplexThemeFont.getFontData( aFontName, nFontPitch, nFontFamily, rFilter );
     101        1427 :     if (bRet)
     102             :     {
     103         191 :         rPropMap.setProperty( PROP_CharFontNameComplex, aFontName);
     104         191 :         rPropMap.setProperty( PROP_CharFontPitchComplex, nFontPitch);
     105         191 :         rPropMap.setProperty( PROP_CharFontFamilyComplex, nFontFamily);
     106             :     }
     107             : 
     108             :     // symbolfont, will now be ... textrun.cxx ... ausgewertet !!!i#113673
     109             : 
     110        1427 :     if( maCharColor.isUsed() )
     111        1240 :         rPropMap.setProperty( PROP_CharColor, maCharColor.getColor( rFilter.getGraphicHelper() ));
     112        1427 :     if( maGradientProps.maGradientStops.size() > 0 )
     113           1 :         rPropMap.setProperty( PROP_CharColor, maGradientProps.maGradientStops.begin()->second.getColor( rFilter.getGraphicHelper() ));
     114             : 
     115        1427 :     if( moLang.has() && !moLang.get().isEmpty() )
     116             :     {
     117          80 :         lang::Locale aLocale( LanguageTag( moLang.get()).getLocale());
     118          80 :         rPropMap.setProperty( PROP_CharLocale, aLocale);
     119          80 :         rPropMap.setProperty( PROP_CharLocaleAsian, aLocale);
     120          80 :         rPropMap.setProperty( PROP_CharLocaleComplex, aLocale);
     121             :     }
     122             : 
     123        1427 :     if( moHeight.has() )
     124             :     {
     125        1281 :         float fHeight = GetFontHeight( moHeight.get() );
     126        1281 :         rPropMap.setProperty( PROP_CharHeight, fHeight);
     127        1281 :         rPropMap.setProperty( PROP_CharHeightAsian, fHeight);
     128        1281 :         rPropMap.setProperty( PROP_CharHeightComplex, fHeight);
     129             :     }
     130             : 
     131        1427 :     rPropMap.setProperty( PROP_CharKerning, (sal_Int16) GetTextSpacingPoint( moSpacing.get( 0 ) ));
     132             : 
     133        1427 :     rPropMap.setProperty( PROP_CharUnderline, GetFontUnderline( moUnderline.get( XML_none ) ));
     134        1427 :     rPropMap.setProperty( PROP_CharStrikeout, GetFontStrikeout( moStrikeout.get( XML_noStrike ) ));
     135        1427 :     rPropMap.setProperty( PROP_CharCaseMap, GetCaseMap( moCaseMap.get( XML_none ) ));
     136             : 
     137        1427 :     if( moBaseline.has() ) {
     138           4 :         rPropMap.setProperty( PROP_CharEscapement, sal_Int16(moBaseline.get( 0 ) / 1000));
     139           4 :         rPropMap.setProperty( PROP_CharEscapementHeight, sal_Int8(DFLT_ESC_PROP));
     140             :     } else {
     141        1423 :         rPropMap.setProperty( PROP_CharEscapement, sal_Int16(0));
     142        1423 :         rPropMap.setProperty( PROP_CharEscapementHeight, sal_Int8(100)); // 100%
     143             :     }
     144             : 
     145        1427 :     if( !bUseOptional || moBold.has() ) {
     146        1427 :         float fWeight = moBold.get( false ) ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL;
     147        1427 :         rPropMap.setProperty( PROP_CharWeight, fWeight);
     148        1427 :         rPropMap.setProperty( PROP_CharWeightAsian, fWeight);
     149        1427 :         rPropMap.setProperty( PROP_CharWeightComplex, fWeight);
     150             :     }
     151             : 
     152        1427 :     if( !bUseOptional || moItalic.has() ) {
     153        1427 :         awt::FontSlant eSlant = moItalic.get( false ) ? awt::FontSlant_ITALIC : awt::FontSlant_NONE;
     154        1427 :         rPropMap.setProperty( PROP_CharPosture, eSlant);
     155        1427 :         rPropMap.setProperty( PROP_CharPostureAsian, eSlant);
     156        1427 :         rPropMap.setProperty( PROP_CharPostureComplex, eSlant);
     157             :     }
     158             : 
     159        1427 :     bool bUnderlineFillFollowText = moUnderlineFillFollowText.get( false );
     160        1427 :     if( moUnderline.has() && maUnderlineColor.isUsed() && !bUnderlineFillFollowText )
     161             :     {
     162           0 :         rPropMap.setProperty( PROP_CharUnderlineHasColor, true);
     163           0 :         rPropMap.setProperty( PROP_CharUnderlineColor, maUnderlineColor.getColor( rFilter.getGraphicHelper() ));
     164        1427 :     }
     165        1427 : }
     166             : 
     167        1427 : void pushToGrabBag( PropertySet& rPropSet, const std::vector<PropertyValue>& aVectorOfProperyValues )
     168             : {
     169        1427 :     if (!rPropSet.hasProperty(PROP_CharInteropGrabBag) || aVectorOfProperyValues.empty())
     170        2851 :         return;
     171           3 :     Sequence<PropertyValue> aGrabBag;
     172           6 :     Any aAnyGrabBag = rPropSet.getAnyProperty(PROP_CharInteropGrabBag);
     173           3 :     aAnyGrabBag >>= aGrabBag;
     174             : 
     175           3 :     sal_Int32 nLength = aGrabBag.getLength();
     176           3 :     aGrabBag.realloc(nLength + aVectorOfProperyValues.size());
     177             : 
     178          33 :     for (size_t i = 0; i < aVectorOfProperyValues.size(); i++)
     179             :     {
     180          30 :         PropertyValue aPropertyValue = aVectorOfProperyValues[i];
     181          30 :         aGrabBag[nLength + i] = aPropertyValue;
     182          30 :     }
     183             : 
     184           6 :     rPropSet.setAnyProperty(PROP_CharInteropGrabBag, makeAny(aGrabBag));
     185             : }
     186             : 
     187        1427 : void TextCharacterProperties::pushToPropSet( PropertySet& rPropSet, const XmlFilterBase& rFilter, bool bUseOptional ) const
     188             : {
     189        1427 :     PropertyMap aPropMap;
     190        1427 :     pushToPropMap( aPropMap, rFilter, bUseOptional );
     191        1427 :     rPropSet.setProperties( aPropMap );
     192        1427 :     pushToGrabBag(rPropSet, maTextEffectsProperties);
     193        1427 : }
     194             : 
     195          62 : float TextCharacterProperties::getCharHeightPoints( float fDefault ) const
     196             : {
     197          62 :     return moHeight.has() ? GetFontHeight( moHeight.get() ) : fDefault;
     198             : }
     199             : 
     200             : 
     201             : 
     202             : } // namespace drawingml
     203         177 : } // namespace oox
     204             : 
     205             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10