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

Generated by: LCOV version 1.10