LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLSectionFootnoteConfigImport.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 64 78 82.1 %
Date: 2015-06-13 12:38:46 Functions: 4 9 44.4 %
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 "XMLSectionFootnoteConfigImport.hxx"
      21             : 
      22             : #include <rtl/ustring.hxx>
      23             : #include <com/sun/star/uno/Reference.h>
      24             : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      25             : #include <com/sun/star/style/NumberingType.hpp>
      26             : #include <sax/tools/converter.hxx>
      27             : #include <xmloff/xmlimp.hxx>
      28             : #include <xmloff/xmltoken.hxx>
      29             : #include <xmloff/xmluconv.hxx>
      30             : #include <xmloff/xmlprmap.hxx>
      31             : #include <xmloff/xmlnmspe.hxx>
      32             : #include <xmloff/nmspmap.hxx>
      33             : #include <xmloff/maptype.hxx>
      34             : #include <xmloff/xmlnumi.hxx>
      35             : #include <xmloff/txtprmap.hxx>
      36             : 
      37             : #include <vector>
      38             : 
      39             : 
      40             : using namespace ::xmloff::token;
      41             : using namespace ::com::sun::star::style;
      42             : 
      43             : using ::std::vector;
      44             : using ::com::sun::star::uno::Any;
      45             : using ::com::sun::star::uno::Reference;
      46             : using ::com::sun::star::xml::sax::XAttributeList;
      47             : 
      48             : 
      49           0 : TYPEINIT1(XMLSectionFootnoteConfigImport, SvXMLImportContext);
      50             : 
      51             : 
      52           4 : XMLSectionFootnoteConfigImport::XMLSectionFootnoteConfigImport(
      53             :     SvXMLImport& rImport,
      54             :     sal_uInt16 nPrefix,
      55             :     const OUString& rLocalName,
      56             :     vector<XMLPropertyState> & rProps,
      57             :     const rtl::Reference<XMLPropertySetMapper> & rMapperRef) :
      58             :         SvXMLImportContext(rImport, nPrefix, rLocalName),
      59             :         rProperties(rProps),
      60           4 :         rMapper(rMapperRef)
      61             : {
      62           4 : }
      63             : 
      64           8 : XMLSectionFootnoteConfigImport::~XMLSectionFootnoteConfigImport()
      65             : {
      66           8 : }
      67             : 
      68           4 : void XMLSectionFootnoteConfigImport::StartElement(
      69             :     const Reference<XAttributeList> & xAttrList)
      70             : {
      71           4 :     sal_Bool bEnd = sal_True;   // we're inside the element, so this is true
      72           4 :     sal_Bool bNumOwn = sal_False;
      73           4 :     sal_Bool bNumRestart = sal_False;
      74           4 :     bool bEndnote = false;
      75           4 :     sal_Int16 nNumRestartAt = 0;
      76           4 :     OUString sNumPrefix;
      77           8 :     OUString sNumSuffix;
      78           8 :     OUString sNumFormat;
      79           8 :     OUString sNumLetterSync;
      80             : 
      81             :     // iterate over xattribute list and fill values
      82           4 :     sal_Int16 nLength = xAttrList->getLength();
      83          12 :     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
      84             :     {
      85           8 :         OUString sLocalName;
      86           8 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
      87           8 :             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
      88          16 :                               &sLocalName );
      89          16 :         OUString sAttrValue = xAttrList->getValueByIndex(nAttr);
      90             : 
      91           8 :         if (XML_NAMESPACE_TEXT == nPrefix)
      92             :         {
      93           8 :             if (IsXMLToken(sLocalName, XML_START_VALUE))
      94             :             {
      95             :                 sal_Int32 nTmp;
      96           4 :                 if (::sax::Converter::convertNumber(nTmp, sAttrValue))
      97             :                 {
      98           4 :                     nNumRestartAt = static_cast< sal_Int16 >( nTmp ) - 1;
      99           4 :                     bNumRestart = sal_True;
     100             :                 }
     101             :             }
     102           4 :             else if( IsXMLToken( sLocalName, XML_NOTE_CLASS ) )
     103             :             {
     104           4 :                 if( IsXMLToken( sAttrValue, XML_ENDNOTE ) )
     105           2 :                     bEndnote = true;
     106             :             }
     107             :         }
     108           0 :         else if (XML_NAMESPACE_STYLE == nPrefix)
     109             :         {
     110           0 :             if (IsXMLToken(sLocalName, XML_NUM_PREFIX))
     111             :             {
     112           0 :                 sNumPrefix = sAttrValue;
     113           0 :                 bNumOwn = sal_True;
     114             :             }
     115           0 :             else if (IsXMLToken(sLocalName, XML_NUM_SUFFIX))
     116             :             {
     117           0 :                 sNumSuffix = sAttrValue;
     118           0 :                 bNumOwn = sal_True;
     119             :             }
     120           0 :             else if (IsXMLToken(sLocalName, XML_NUM_FORMAT))
     121             :             {
     122           0 :                 sNumFormat = sAttrValue;
     123           0 :                 bNumOwn = sal_True;
     124             :             }
     125           0 :             else if (IsXMLToken(sLocalName, XML_NUM_LETTER_SYNC))
     126             :             {
     127           0 :                 sNumLetterSync = sAttrValue;
     128           0 :                 bNumOwn = sal_True;
     129             :             }
     130             :         }
     131           8 :     }
     132             : 
     133             :     // OK, now we have all values and can fill the XMLPropertyState vector
     134           8 :     Any aAny;
     135             : 
     136           4 :     aAny.setValue( &bNumOwn, cppu::UnoType<bool>::get() );
     137             :     sal_Int32 nIndex = rMapper->FindEntryIndex( bEndnote ?
     138           4 :         CTF_SECTION_ENDNOTE_NUM_OWN : CTF_SECTION_FOOTNOTE_NUM_OWN );
     139           8 :     XMLPropertyState aNumOwn( nIndex, aAny );
     140           4 :     rProperties.push_back( aNumOwn );
     141             : 
     142           4 :     aAny.setValue( &bNumRestart, cppu::UnoType<bool>::get() );
     143             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     144           4 :         CTF_SECTION_ENDNOTE_NUM_RESTART : CTF_SECTION_FOOTNOTE_NUM_RESTART );
     145           8 :     XMLPropertyState aNumRestart( nIndex, aAny );
     146           4 :     rProperties.push_back( aNumRestart );
     147             : 
     148           4 :     aAny <<= nNumRestartAt;
     149             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     150             :         CTF_SECTION_ENDNOTE_NUM_RESTART_AT :
     151           4 :         CTF_SECTION_FOOTNOTE_NUM_RESTART_AT );
     152           8 :     XMLPropertyState aNumRestartAtState( nIndex, aAny );
     153           4 :     rProperties.push_back( aNumRestartAtState );
     154             : 
     155           4 :     sal_Int16 nNumType = NumberingType::ARABIC;
     156           4 :     GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
     157             :                                                     sNumFormat,
     158           4 :                                                     sNumLetterSync );
     159           4 :     aAny <<= nNumType;
     160             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     161           4 :         CTF_SECTION_ENDNOTE_NUM_TYPE : CTF_SECTION_FOOTNOTE_NUM_TYPE );
     162           8 :     XMLPropertyState aNumFormatState( nIndex, aAny );
     163           4 :     rProperties.push_back( aNumFormatState );
     164             : 
     165           4 :     aAny <<= sNumPrefix;
     166             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     167           4 :         CTF_SECTION_ENDNOTE_NUM_PREFIX : CTF_SECTION_FOOTNOTE_NUM_PREFIX );
     168           8 :     XMLPropertyState aPrefixState( nIndex, aAny );
     169           4 :     rProperties.push_back( aPrefixState );
     170             : 
     171           4 :     aAny <<= sNumSuffix;
     172             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     173           4 :         CTF_SECTION_ENDNOTE_NUM_SUFFIX : CTF_SECTION_FOOTNOTE_NUM_SUFFIX );
     174           8 :     XMLPropertyState aSuffixState( nIndex, aAny );
     175           4 :     rProperties.push_back( aSuffixState );
     176             : 
     177           4 :     aAny.setValue( &bEnd, cppu::UnoType<bool>::get() );
     178             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     179           4 :         CTF_SECTION_ENDNOTE_END : CTF_SECTION_FOOTNOTE_END );
     180           8 :     XMLPropertyState aEndState( nIndex, aAny );
     181           8 :     rProperties.push_back( aEndState );
     182           4 : }
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11