LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/text - XMLSectionFootnoteConfigImport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 78 0.0 %
Date: 2013-07-09 Functions: 0 9 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             : #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           0 : XMLSectionFootnoteConfigImport::XMLSectionFootnoteConfigImport(
      53             :     SvXMLImport& rImport,
      54             :     sal_uInt16 nPrefix,
      55             :     const OUString& rLocalName,
      56             :     vector<XMLPropertyState> & rProps,
      57             :     const UniReference<XMLPropertySetMapper> & rMapperRef) :
      58             :         SvXMLImportContext(rImport, nPrefix, rLocalName),
      59             :         rProperties(rProps),
      60           0 :         rMapper(rMapperRef)
      61             : {
      62           0 : }
      63             : 
      64           0 : XMLSectionFootnoteConfigImport::~XMLSectionFootnoteConfigImport()
      65             : {
      66           0 : }
      67             : 
      68           0 : void XMLSectionFootnoteConfigImport::StartElement(
      69             :     const Reference<XAttributeList> & xAttrList)
      70             : {
      71           0 :     sal_Bool bEnd = sal_True;   // we're inside the element, so this is true
      72           0 :     sal_Bool bNumOwn = sal_False;
      73           0 :     sal_Bool bNumRestart = sal_False;
      74           0 :     sal_Bool bEndnote = sal_False;
      75           0 :     sal_Int16 nNumRestartAt = 0;
      76           0 :     OUString sNumPrefix;
      77           0 :     OUString sNumSuffix;
      78           0 :     OUString sNumFormat;
      79           0 :     OUString sNumLetterSync;
      80             : 
      81             :     // iterate over xattribute list and fill values
      82           0 :     sal_Int16 nLength = xAttrList->getLength();
      83           0 :     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
      84             :     {
      85           0 :         OUString sLocalName;
      86           0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
      87           0 :             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
      88           0 :                               &sLocalName );
      89           0 :         OUString sAttrValue = xAttrList->getValueByIndex(nAttr);
      90             : 
      91           0 :         if (XML_NAMESPACE_TEXT == nPrefix)
      92             :         {
      93           0 :             if (IsXMLToken(sLocalName, XML_START_VALUE))
      94             :             {
      95             :                 sal_Int32 nTmp;
      96           0 :                 if (::sax::Converter::convertNumber(nTmp, sAttrValue))
      97             :                 {
      98           0 :                     nNumRestartAt = static_cast< sal_Int16 >( nTmp ) - 1;
      99           0 :                     bNumRestart = sal_True;
     100             :                 }
     101             :             }
     102           0 :             else if( IsXMLToken( sLocalName, XML_NOTE_CLASS ) )
     103             :             {
     104           0 :                 if( IsXMLToken( sAttrValue, XML_ENDNOTE ) )
     105           0 :                     bEndnote = sal_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           0 :     }
     132             : 
     133             :     // OK, now we have all values and can fill the XMLPropertyState vector
     134           0 :     Any aAny;
     135             : 
     136           0 :     aAny.setValue( &bNumOwn, ::getBooleanCppuType() );
     137             :     sal_Int32 nIndex = rMapper->FindEntryIndex( bEndnote ?
     138           0 :         CTF_SECTION_ENDNOTE_NUM_OWN : CTF_SECTION_FOOTNOTE_NUM_OWN );
     139           0 :     XMLPropertyState aNumOwn( nIndex, aAny );
     140           0 :     rProperties.push_back( aNumOwn );
     141             : 
     142           0 :     aAny.setValue( &bNumRestart, ::getBooleanCppuType() );
     143             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     144           0 :         CTF_SECTION_ENDNOTE_NUM_RESTART : CTF_SECTION_FOOTNOTE_NUM_RESTART );
     145           0 :     XMLPropertyState aNumRestart( nIndex, aAny );
     146           0 :     rProperties.push_back( aNumRestart );
     147             : 
     148           0 :     aAny <<= nNumRestartAt;
     149             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     150             :         CTF_SECTION_ENDNOTE_NUM_RESTART_AT :
     151           0 :         CTF_SECTION_FOOTNOTE_NUM_RESTART_AT );
     152           0 :     XMLPropertyState aNumRestartAtState( nIndex, aAny );
     153           0 :     rProperties.push_back( aNumRestartAtState );
     154             : 
     155           0 :     sal_Int16 nNumType = NumberingType::ARABIC;
     156           0 :     GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
     157             :                                                     sNumFormat,
     158           0 :                                                     sNumLetterSync );
     159           0 :     aAny <<= nNumType;
     160             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     161           0 :         CTF_SECTION_ENDNOTE_NUM_TYPE : CTF_SECTION_FOOTNOTE_NUM_TYPE );
     162           0 :     XMLPropertyState aNumFormatState( nIndex, aAny );
     163           0 :     rProperties.push_back( aNumFormatState );
     164             : 
     165           0 :     aAny <<= sNumPrefix;
     166             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     167           0 :         CTF_SECTION_ENDNOTE_NUM_PREFIX : CTF_SECTION_FOOTNOTE_NUM_PREFIX );
     168           0 :     XMLPropertyState aPrefixState( nIndex, aAny );
     169           0 :     rProperties.push_back( aPrefixState );
     170             : 
     171           0 :     aAny <<= sNumSuffix;
     172             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     173           0 :         CTF_SECTION_ENDNOTE_NUM_SUFFIX : CTF_SECTION_FOOTNOTE_NUM_SUFFIX );
     174           0 :     XMLPropertyState aSuffixState( nIndex, aAny );
     175           0 :     rProperties.push_back( aSuffixState );
     176             : 
     177           0 :     aAny.setValue( &bEnd, ::getBooleanCppuType() );
     178             :     nIndex = rMapper->FindEntryIndex( bEndnote ?
     179           0 :         CTF_SECTION_ENDNOTE_END : CTF_SECTION_FOOTNOTE_END );
     180           0 :     XMLPropertyState aEndState( nIndex, aAny );
     181           0 :     rProperties.push_back( aEndState );
     182           0 : }
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10