LCOV - code coverage report
Current view: top level - xmloff/source/text - txtdropi.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 45 0.0 %
Date: 2014-04-14 Functions: 0 10 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             : 
      21             : #include "txtdropi.hxx"
      22             : 
      23             : #include <com/sun/star/style/DropCapFormat.hpp>
      24             : 
      25             : #include <sax/tools/converter.hxx>
      26             : 
      27             : #include <xmloff/xmltkmap.hxx>
      28             : #include <xmloff/xmluconv.hxx>
      29             : #include <xmloff/nmspmap.hxx>
      30             : #include <xmloff/xmlnmspe.hxx>
      31             : #include <xmloff/xmlimp.hxx>
      32             : #include <xmloff/xmltoken.hxx>
      33             : 
      34             : 
      35             : using namespace ::com::sun::star;
      36             : using namespace ::com::sun::star::uno;
      37             : using namespace ::com::sun::star::style;
      38             : using namespace ::xmloff::token;
      39             : 
      40             : 
      41             : enum SvXMLTokenMapDropAttrs
      42             : {
      43             :     XML_TOK_DROP_LINES,
      44             :     XML_TOK_DROP_LENGTH,
      45             :     XML_TOK_DROP_DISTANCE,
      46             :     XML_TOK_DROP_STYLE,
      47             :     XML_TOK_DROP_END=XML_TOK_UNKNOWN
      48             : };
      49             : 
      50             : static const SvXMLTokenMapEntry aDropAttrTokenMap[] =
      51             : {
      52             :     { XML_NAMESPACE_STYLE, XML_LINES,       XML_TOK_DROP_LINES  },
      53             :     { XML_NAMESPACE_STYLE, XML_LENGTH,      XML_TOK_DROP_LENGTH },
      54             :     { XML_NAMESPACE_STYLE, XML_DISTANCE,    XML_TOK_DROP_DISTANCE   },
      55             :     { XML_NAMESPACE_STYLE, XML_STYLE_NAME,  XML_TOK_DROP_STYLE  },
      56             :     XML_TOKEN_MAP_END
      57             : };
      58             : 
      59           0 : TYPEINIT1( XMLTextDropCapImportContext, XMLElementPropertyContext );
      60           0 : void XMLTextDropCapImportContext::ProcessAttrs(
      61             :         const Reference< xml::sax::XAttributeList >& xAttrList )
      62             : {
      63           0 :     SvXMLTokenMap aTokenMap( aDropAttrTokenMap );
      64             : 
      65           0 :     DropCapFormat aFormat;
      66           0 :     sal_Bool bWholeWord = sal_False;
      67             : 
      68             :     sal_Int32 nTmp;
      69           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
      70           0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
      71             :     {
      72           0 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
      73           0 :         OUString aLocalName;
      74             :         sal_uInt16 nPrefix =
      75           0 :             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      76           0 :                                                             &aLocalName );
      77           0 :         const OUString& rValue = xAttrList->getValueByIndex( i );
      78             : 
      79           0 :         switch( aTokenMap.Get( nPrefix, aLocalName ) )
      80             :         {
      81             :         case XML_TOK_DROP_LINES:
      82           0 :             if (::sax::Converter::convertNumber( nTmp, rValue, 0, 255 ))
      83             :             {
      84           0 :                 aFormat.Lines = nTmp < 2 ? 0 : (sal_Int8)nTmp;
      85             :             }
      86           0 :             break;
      87             : 
      88             :         case XML_TOK_DROP_LENGTH:
      89           0 :             if( IsXMLToken( rValue, XML_WORD ) )
      90             :             {
      91           0 :                 bWholeWord = sal_True;
      92             :             }
      93           0 :             else if (::sax::Converter::convertNumber( nTmp, rValue, 1, 255 ))
      94             :             {
      95           0 :                 bWholeWord = sal_False;
      96           0 :                 aFormat.Count = (sal_Int8)nTmp;
      97             :             }
      98           0 :             break;
      99             : 
     100             :         case XML_TOK_DROP_DISTANCE:
     101           0 :             if (GetImport().GetMM100UnitConverter().convertMeasureToCore(
     102             :                         nTmp, rValue, 0 ))
     103             :             {
     104           0 :                 aFormat.Distance = (sal_uInt16)nTmp;
     105             :             }
     106           0 :             break;
     107             : 
     108             :         case XML_TOK_DROP_STYLE:
     109           0 :             sStyleName = rValue;
     110           0 :             break;
     111             :         }
     112           0 :     }
     113             : 
     114           0 :     if( aFormat.Lines > 1 && aFormat.Count < 1 )
     115           0 :         aFormat.Count = 1;
     116             : 
     117           0 :     aProp.maValue <<= aFormat;
     118             : 
     119           0 :     aWholeWordProp.maValue.setValue( &bWholeWord, ::getBooleanCppuType() );
     120           0 : }
     121             : 
     122           0 : XMLTextDropCapImportContext::XMLTextDropCapImportContext(
     123             :         SvXMLImport& rImport, sal_uInt16 nPrfx,
     124             :         const OUString& rLName,
     125             :         const Reference< xml::sax::XAttributeList > & xAttrList,
     126             :         const XMLPropertyState& rProp,
     127             :         sal_Int32 nWholeWordIdx,
     128             :         ::std::vector< XMLPropertyState > &rProps ) :
     129             :     XMLElementPropertyContext( rImport, nPrfx, rLName, rProp, rProps ),
     130           0 :     aWholeWordProp( nWholeWordIdx )
     131             : {
     132           0 :     ProcessAttrs( xAttrList );
     133           0 : }
     134             : 
     135           0 : XMLTextDropCapImportContext::~XMLTextDropCapImportContext()
     136             : {
     137           0 : }
     138             : 
     139           0 : void XMLTextDropCapImportContext::EndElement()
     140             : {
     141           0 :     SetInsert( sal_True );
     142           0 :     XMLElementPropertyContext::EndElement();
     143             : 
     144           0 :     if( -1 != aWholeWordProp.mnIndex )
     145           0 :         rProperties.push_back( aWholeWordProp );
     146           0 : }
     147             : 
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10