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

Generated by: LCOV version 1.10