LCOV - code coverage report
Current view: top level - oox/source/drawingml - textcharacterpropertiescontext.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 73 78 93.6 %
Date: 2014-04-11 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 "oox/drawingml/textcharacterpropertiescontext.hxx"
      21             : 
      22             : #include "oox/helper/attributelist.hxx"
      23             : #include "oox/drawingml/drawingmltypes.hxx"
      24             : #include "oox/drawingml/colorchoicecontext.hxx"
      25             : #include "oox/drawingml/texteffectscontext.hxx"
      26             : #include "oox/drawingml/lineproperties.hxx"
      27             : #include "oox/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        3291 : TextCharacterPropertiesContext::TextCharacterPropertiesContext(
      40             :         ContextHandler2Helper& rParent,
      41             :         const AttributeList& rAttribs,
      42             :         TextCharacterProperties& rTextCharacterProperties )
      43             : : ContextHandler2( rParent )
      44        3291 : , mrTextCharacterProperties( rTextCharacterProperties )
      45             : {
      46        3291 :     if ( rAttribs.hasAttribute( XML_lang ) )
      47        2113 :         mrTextCharacterProperties.moLang = rAttribs.getString( XML_lang );
      48        3291 :     if ( rAttribs.hasAttribute( XML_sz ) )
      49        1342 :         mrTextCharacterProperties.moHeight = rAttribs.getInteger( XML_sz );
      50        3291 :     if ( rAttribs.hasAttribute( XML_spc ) )
      51          11 :         mrTextCharacterProperties.moSpacing = rAttribs.getInteger( XML_spc );
      52        3291 :     if ( rAttribs.hasAttribute( XML_u ) )
      53          58 :         mrTextCharacterProperties.moUnderline = rAttribs.getToken( XML_u );
      54        3291 :     if ( rAttribs.hasAttribute( XML_strike ) )
      55          55 :         mrTextCharacterProperties.moStrikeout = rAttribs.getToken( XML_strike );
      56        3291 :     if ( rAttribs.hasAttribute( XML_baseline ) && rAttribs.getInteger( XML_baseline ).get() != 0 )
      57           5 :         mrTextCharacterProperties.moBaseline = rAttribs.getInteger( XML_baseline );
      58             : 
      59        3291 :     if ( rAttribs.hasAttribute( XML_b ) )
      60         363 :         mrTextCharacterProperties.moBold = rAttribs.getBool( XML_b );
      61        3291 :     if ( rAttribs.hasAttribute( XML_i ) )
      62          76 :         mrTextCharacterProperties.moItalic = rAttribs.getBool( XML_i );
      63        3291 :     if( rAttribs.hasAttribute( XML_cap ) )
      64          36 :         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        3291 : }
      79             : 
      80        6582 : TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
      81             : {
      82        6582 : }
      83             : 
      84        4268 : ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      85             : {
      86        4268 :     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        1010 :             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          53 :         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           6 :             mrTextCharacterProperties.moUnderlineLineFollowText = true;
     106           6 :         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           6 :             mrTextCharacterProperties.moUnderlineFillFollowText = true;
     114           6 :         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         931 :             mrTextCharacterProperties.maLatinFont.setAttributes( rAttribs );
     121         931 :         break;
     122             :         case A_TOKEN( ea ):         // CT_TextFont
     123         697 :             mrTextCharacterProperties.maAsianFont.setAttributes( rAttribs );
     124         697 :         break;
     125             :         case A_TOKEN( cs ):         // CT_TextFont
     126         770 :             mrTextCharacterProperties.maComplexFont.setAttributes( rAttribs );
     127         770 :         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           1 :             return new GradientFillContext( *this, rAttribs, mrTextCharacterProperties.maGradientProps );
     138             : 
     139             :         case OOX_TOKEN( doc, rFonts ):
     140          21 :             if( rAttribs.hasAttribute(OOX_TOKEN(doc, ascii)) )
     141             :             {
     142          13 :                 mrTextCharacterProperties.maLatinFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, ascii), OUString()));
     143             :             }
     144          21 :             if (rAttribs.hasAttribute(OOX_TOKEN(doc, asciiTheme)))
     145             :             {
     146           8 :                 mrTextCharacterProperties.maLatinThemeFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, asciiTheme), OUString()));
     147             :             }
     148          21 :             if( rAttribs.hasAttribute(OOX_TOKEN(doc, cs)) )
     149             :             {
     150           1 :                 mrTextCharacterProperties.maComplexFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, cs), OUString()));
     151             :             }
     152          21 :             if (rAttribs.hasAttribute(OOX_TOKEN(doc, cstheme)))
     153             :             {
     154           6 :                 mrTextCharacterProperties.maComplexThemeFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, cstheme), OUString()));
     155             :             }
     156          21 :             if( rAttribs.hasAttribute(OOX_TOKEN(doc, eastAsia)) )
     157             :             {
     158           1 :                 mrTextCharacterProperties.maAsianFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, eastAsia), OUString()));
     159             :             }
     160          21 :             if (rAttribs.hasAttribute(OOX_TOKEN(doc, eastAsiaTheme)))
     161             :             {
     162           6 :                 mrTextCharacterProperties.maAsianThemeFont.setAttributes(rAttribs.getString(OOX_TOKEN(doc, eastAsiaTheme), OUString()));
     163             :             }
     164          21 :             break;
     165             :         case OOX_TOKEN( doc, b ):
     166          30 :             mrTextCharacterProperties.moBold = rAttribs.getBool(OOX_TOKEN( doc, val ), true);
     167          30 :             break;
     168             :         case OOX_TOKEN( doc, bCs ):
     169          22 :             break;
     170             :         case OOX_TOKEN( doc, color ):
     171         108 :             if (rAttribs.getInteger(OOX_TOKEN(doc, val)).has())
     172             :             {
     173         108 :                 mrTextCharacterProperties.maCharColor.setSrgbClr(rAttribs.getIntegerHex(OOX_TOKEN(doc, val)).get());
     174             :             }
     175         108 :             break;
     176             :         case OOX_TOKEN( doc, sz ):
     177         153 :             if (rAttribs.getInteger(OOX_TOKEN(doc, val)).has())
     178             :             {
     179         153 :                 sal_Int32 nVal = rAttribs.getInteger(OOX_TOKEN(doc, val)).get();
     180             :                 // wml has half points, dml has hundred points
     181         153 :                 mrTextCharacterProperties.moHeight = nVal * 50;
     182             :             }
     183         153 :             break;
     184             :         case OOX_TOKEN( doc, szCs ):
     185          36 :             break;
     186             :         case OOX_TOKEN( doc, caps ):
     187             :             {
     188          26 :                 if( rAttribs.getBool(OOX_TOKEN( doc, val ), true) )
     189           8 :                     mrTextCharacterProperties.moCaseMap = XML_all;
     190             :                 else
     191          18 :                     mrTextCharacterProperties.moCaseMap = XML_none;
     192             :             }
     193          26 :             break;
     194             :         case OOX_TOKEN( doc, smallCaps ):
     195             :             {
     196          19 :                 if( rAttribs.getBool(OOX_TOKEN( doc, val ), true) )
     197           1 :                     mrTextCharacterProperties.moCaseMap = XML_small;
     198             :                 else
     199          18 :                     mrTextCharacterProperties.moCaseMap = XML_none;
     200             :             }
     201          19 :             break;
     202             :         case OOX_TOKEN(w14, glow):
     203             :         case OOX_TOKEN(w14, shadow):
     204             :         case OOX_TOKEN(w14, reflection):
     205             :         case OOX_TOKEN(w14, textOutline):
     206             :         case OOX_TOKEN(w14, textFill):
     207             :         case OOX_TOKEN(w14, scene3d):
     208             :         case OOX_TOKEN(w14, props3d):
     209             :         case OOX_TOKEN(w14, ligatures):
     210             :         case OOX_TOKEN(w14, numForm):
     211             :         case OOX_TOKEN(w14, numSpacing):
     212             :         case OOX_TOKEN(w14, stylisticSets):
     213             :         case OOX_TOKEN(w14, cntxtAlts):
     214             :             {
     215          30 :                 return new TextEffectsContext( *this, aElementToken, mrTextCharacterProperties.maTextEffectsProperties );
     216             :             }
     217             :             break;
     218             :         default:
     219             :             SAL_WARN("oox", "TextCharacterPropertiesContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
     220         349 :             break;
     221             :     }
     222             : 
     223        3227 :     return this;
     224             : }
     225             : 
     226             : } }
     227             : 
     228             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10