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

Generated by: LCOV version 1.11