LCOV - code coverage report
Current view: top level - oox/source/drawingml - textcharacterpropertiescontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 75 80 93.8 %
Date: 2014-11-03 Functions: 4 4 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/textcharacterpropertiescontext.hxx"
      21             : 
      22             : #include "oox/helper/attributelist.hxx"
      23             : #include "oox/drawingml/drawingmltypes.hxx"
      24             : #include "drawingml/colorchoicecontext.hxx"
      25             : #include "drawingml/texteffectscontext.hxx"
      26             : #include "oox/drawingml/lineproperties.hxx"
      27             : #include "drawingml/textparagraphproperties.hxx"
      28             : #include "oox/core/relations.hxx"
      29             : #include "hyperlinkcontext.hxx"
      30             : 
      31             : using namespace ::oox::core;
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::xml::sax;
      34             : using namespace ::com::sun::star::awt;
      35             : 
      36             : namespace oox { namespace drawingml {
      37             : 
      38             : // CT_TextCharacterProperties
      39       13010 : TextCharacterPropertiesContext::TextCharacterPropertiesContext(
      40             :         ContextHandler2Helper& rParent,
      41             :         const AttributeList& rAttribs,
      42             :         TextCharacterProperties& rTextCharacterProperties )
      43             : : ContextHandler2( rParent )
      44       13010 : , mrTextCharacterProperties( rTextCharacterProperties )
      45             : {
      46       13010 :     if ( rAttribs.hasAttribute( XML_lang ) )
      47        8050 :         mrTextCharacterProperties.moLang = rAttribs.getString( XML_lang );
      48       13010 :     if ( rAttribs.hasAttribute( XML_sz ) )
      49        6666 :         mrTextCharacterProperties.moHeight = rAttribs.getInteger( XML_sz );
      50       13010 :     if ( rAttribs.hasAttribute( XML_spc ) )
      51          28 :         mrTextCharacterProperties.moSpacing = rAttribs.getInteger( XML_spc );
      52       13010 :     if ( rAttribs.hasAttribute( XML_u ) )
      53         168 :         mrTextCharacterProperties.moUnderline = rAttribs.getToken( XML_u );
      54       13010 :     if ( rAttribs.hasAttribute( XML_strike ) )
      55         254 :         mrTextCharacterProperties.moStrikeout = rAttribs.getToken( XML_strike );
      56       13010 :     if ( rAttribs.hasAttribute( XML_baseline ) && rAttribs.getInteger( XML_baseline ).get() != 0 )
      57          12 :         mrTextCharacterProperties.moBaseline = rAttribs.getInteger( XML_baseline );
      58             : 
      59       13010 :     if ( rAttribs.hasAttribute( XML_b ) )
      60        2470 :         mrTextCharacterProperties.moBold = rAttribs.getBool( XML_b );
      61       13010 :     if ( rAttribs.hasAttribute( XML_i ) )
      62         308 :         mrTextCharacterProperties.moItalic = rAttribs.getBool( XML_i );
      63       13010 :     if( rAttribs.hasAttribute( XML_cap ) )
      64         156 :         mrTextCharacterProperties.moCaseMap = rAttribs.getToken( XML_cap );
      65             : 
      66             :     /* TODO / unhandled so far:
      67             :        A_TOKEN( kern )
      68             :        XML_altLang
      69             :        A_TOKEN( kumimoji )
      70             :        A_TOKEN( spc )
      71             :        A_TOKEN( normalizeH )
      72             :        A_TOKEN( noProof )
      73             :        A_TOKEN( dirty )
      74             :        A_TOKEN( err )
      75             :        A_TOKEN( smtClean )
      76             :        A_TOKEN( smtId )
      77             :     */
      78       13010 : }
      79             : 
      80       26020 : TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
      81             : {
      82       26020 : }
      83             : 
      84       18598 : ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      85             : {
      86       18598 :     switch( aElementToken )
      87             :     {
      88             : // TODO unsupported yet
      89             : //        case A_TOKEN( ln ):         // CT_LineProperties
      90             : //            return new LinePropertiesContext( getHandler(), rAttribs, maTextOutlineProperties );
      91             : 
      92             :         case A_TOKEN( solidFill ):  // EG_FillProperties
      93        5862 :             return new ColorContext( *this, mrTextCharacterProperties.maCharColor );
      94             : 
      95             :         // EG_EffectProperties
      96             :         case A_TOKEN( effectDag ):  // CT_EffectContainer 5.1.10.25
      97             :         case A_TOKEN( effectLst ):  // CT_EffectList 5.1.10.26
      98         138 :         break;
      99             : 
     100             :         case A_TOKEN( highlight ):  // CT_Color
     101           0 :             return new ColorContext( *this, mrTextCharacterProperties.maHighlightColor );
     102             : 
     103             :         // EG_TextUnderlineLine
     104             :         case A_TOKEN( uLnTx ):      // CT_TextUnderlineLineFollowText
     105          12 :             mrTextCharacterProperties.moUnderlineLineFollowText = true;
     106          12 :         break;
     107             : // TODO unsupported yet
     108             : //        case A_TOKEN( uLn ):        // CT_LineProperties
     109             : //            return new LinePropertiesContext( getHandler(), rAttribs, maUnderlineProperties );
     110             : 
     111             :         // EG_TextUnderlineFill
     112             :         case A_TOKEN( uFillTx ):    // CT_TextUnderlineFillFollowText
     113          12 :             mrTextCharacterProperties.moUnderlineFillFollowText = true;
     114          12 :         break;
     115             :         case A_TOKEN( uFill ):      // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
     116           0 :             return new SimpleFillPropertiesContext( *this, mrTextCharacterProperties.maUnderlineColor );
     117             : 
     118             :         // CT_FontCollection
     119             :         case A_TOKEN( latin ):      // CT_TextFont
     120        3904 :             mrTextCharacterProperties.maLatinFont.setAttributes( rAttribs );
     121        3904 :         break;
     122             :         case A_TOKEN( ea ):         // CT_TextFont
     123        3250 :             mrTextCharacterProperties.maAsianFont.setAttributes( rAttribs );
     124        3250 :         break;
     125             :         case A_TOKEN( cs ):         // CT_TextFont
     126        3398 :             mrTextCharacterProperties.maComplexFont.setAttributes( rAttribs );
     127        3398 :         break;
     128             :         case A_TOKEN( sym ):        // CT_TextFont
     129           0 :             mrTextCharacterProperties.maSymbolFont.setAttributes( rAttribs );
     130           0 :         break;
     131             : 
     132             :         case A_TOKEN( hlinkClick ):     // CT_Hyperlink
     133             :         case A_TOKEN( hlinkMouseOver ): // CT_Hyperlink
     134           0 :             return new HyperLinkContext( *this, rAttribs,  mrTextCharacterProperties.maHyperlinkPropertyMap );
     135             : 
     136             :         case A_TOKEN( gradFill ):
     137           2 :             return new GradientFillContext( *this, rAttribs, mrTextCharacterProperties.maGradientProps );
     138             : 
     139             :         case W_TOKEN( rFonts ):
     140         104 :             if( rAttribs.hasAttribute(W_TOKEN(ascii)) )
     141             :             {
     142          56 :                 mrTextCharacterProperties.maLatinFont.setAttributes(rAttribs.getString(W_TOKEN(ascii), OUString()));
     143             :             }
     144         104 :             if (rAttribs.hasAttribute(W_TOKEN(asciiTheme)))
     145             :             {
     146          16 :                 mrTextCharacterProperties.maLatinThemeFont.setAttributes(rAttribs.getString(W_TOKEN(asciiTheme), OUString()));
     147             :             }
     148         104 :             if( rAttribs.hasAttribute(W_TOKEN(cs)) )
     149             :             {
     150          64 :                 mrTextCharacterProperties.maComplexFont.setAttributes(rAttribs.getString(W_TOKEN(cs), OUString()));
     151             :             }
     152         104 :             if (rAttribs.hasAttribute(W_TOKEN(cstheme)))
     153             :             {
     154          12 :                 mrTextCharacterProperties.maComplexThemeFont.setAttributes(rAttribs.getString(W_TOKEN(cstheme), OUString()));
     155             :             }
     156         104 :             if( rAttribs.hasAttribute(W_TOKEN(eastAsia)) )
     157             :             {
     158           2 :                 mrTextCharacterProperties.maAsianFont.setAttributes(rAttribs.getString(W_TOKEN(eastAsia), OUString()));
     159             :             }
     160         104 :             if (rAttribs.hasAttribute(W_TOKEN(eastAsiaTheme)))
     161             :             {
     162          12 :                 mrTextCharacterProperties.maAsianThemeFont.setAttributes(rAttribs.getString(W_TOKEN(eastAsiaTheme), OUString()));
     163             :             }
     164         104 :             break;
     165             :         case W_TOKEN( b ):
     166          74 :             mrTextCharacterProperties.moBold = rAttribs.getBool(W_TOKEN( val ), true);
     167          74 :             break;
     168             :         case W_TOKEN( i ):
     169          78 :             mrTextCharacterProperties.moItalic = rAttribs.getBool(W_TOKEN( val ), true);
     170          78 :             break;
     171             :         case W_TOKEN( bCs ):
     172          58 :             break;
     173             :         case W_TOKEN( color ):
     174         238 :             if (rAttribs.getInteger(W_TOKEN(val)).has())
     175             :             {
     176         238 :                 mrTextCharacterProperties.maCharColor.setSrgbClr(rAttribs.getIntegerHex(W_TOKEN(val)).get());
     177             :             }
     178         238 :             break;
     179             :         case W_TOKEN(  sz ):
     180         300 :             if (rAttribs.getInteger(W_TOKEN(val)).has())
     181             :             {
     182         300 :                 sal_Int32 nVal = rAttribs.getInteger(W_TOKEN(val)).get();
     183             :                 // wml has half points, dml has hundred points
     184         300 :                 mrTextCharacterProperties.moHeight = nVal * 50;
     185             :             }
     186         300 :             break;
     187             :         case W_TOKEN( szCs ):
     188         102 :             break;
     189             :         case W_TOKEN( caps ):
     190             :             {
     191          66 :                 if( rAttribs.getBool(W_TOKEN( val ), true) )
     192          16 :                     mrTextCharacterProperties.moCaseMap = XML_all;
     193             :                 else
     194          50 :                     mrTextCharacterProperties.moCaseMap = XML_none;
     195             :             }
     196          66 :             break;
     197             :         case W_TOKEN( smallCaps ):
     198             :             {
     199          52 :                 if( rAttribs.getBool(W_TOKEN( val ), true) )
     200           2 :                     mrTextCharacterProperties.moCaseMap = XML_small;
     201             :                 else
     202          50 :                     mrTextCharacterProperties.moCaseMap = XML_none;
     203             :             }
     204          52 :             break;
     205             :         case OOX_TOKEN(w14, glow):
     206             :         case OOX_TOKEN(w14, shadow):
     207             :         case OOX_TOKEN(w14, reflection):
     208             :         case OOX_TOKEN(w14, textOutline):
     209             :         case OOX_TOKEN(w14, textFill):
     210             :         case OOX_TOKEN(w14, scene3d):
     211             :         case OOX_TOKEN(w14, props3d):
     212             :         case OOX_TOKEN(w14, ligatures):
     213             :         case OOX_TOKEN(w14, numForm):
     214             :         case OOX_TOKEN(w14, numSpacing):
     215             :         case OOX_TOKEN(w14, stylisticSets):
     216             :         case OOX_TOKEN(w14, cntxtAlts):
     217             :             {
     218          60 :                 return new TextEffectsContext( *this, aElementToken, mrTextCharacterProperties.maTextEffectsProperties );
     219             :             }
     220             :             break;
     221             :         default:
     222             :             SAL_WARN("oox", "TextCharacterPropertiesContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
     223         888 :             break;
     224             :     }
     225             : 
     226       12674 :     return this;
     227             : }
     228             : 
     229             : } }
     230             : 
     231             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10