LCOV - code coverage report
Current view: top level - xmloff/source/style - XMLFootnoteSeparatorImport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 75 76 98.7 %
Date: 2012-08-25 Functions: 4 9 44.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 73 136 53.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "XMLFootnoteSeparatorImport.hxx"
      31                 :            : 
      32                 :            : #include <rtl/ustring.hxx>
      33                 :            : 
      34                 :            : #include <com/sun/star/uno/Reference.h>
      35                 :            : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      36                 :            : #include <com/sun/star/text/HorizontalAdjust.hpp>
      37                 :            : 
      38                 :            : #include <tools/debug.hxx>
      39                 :            : 
      40                 :            : #include <sax/tools/converter.hxx>
      41                 :            : 
      42                 :            : #include <xmloff/xmlimp.hxx>
      43                 :            : #include <xmloff/xmltoken.hxx>
      44                 :            : #include <xmloff/xmluconv.hxx>
      45                 :            : #include <xmloff/xmlprmap.hxx>
      46                 :            : #include "xmloff/xmlnmspe.hxx"
      47                 :            : #include <xmloff/nmspmap.hxx>
      48                 :            : #include <xmloff/maptype.hxx>
      49                 :            : 
      50                 :            : #include <xmloff/PageMasterStyleMap.hxx>
      51                 :            : 
      52                 :            : #include <vector>
      53                 :            : 
      54                 :            : 
      55                 :            : using namespace ::com::sun::star;
      56                 :            : using namespace ::xmloff::token;
      57                 :            : 
      58                 :            : using ::rtl::OUString;
      59                 :            : using ::std::vector;
      60                 :            : using ::com::sun::star::uno::Any;
      61                 :            : using ::com::sun::star::uno::Reference;
      62                 :            : using ::com::sun::star::xml::sax::XAttributeList;
      63                 :            : 
      64                 :            : 
      65 [ #  # ][ #  # ]:          0 : TYPEINIT1(XMLFootnoteSeparatorImport, SvXMLImportContext);
      66                 :            : 
      67                 :            : 
      68                 :        101 : XMLFootnoteSeparatorImport::XMLFootnoteSeparatorImport(
      69                 :            :     SvXMLImport& rImport,
      70                 :            :     sal_uInt16 nPrefix,
      71                 :            :     const OUString& rLocalName,
      72                 :            :     vector<XMLPropertyState> & rProps,
      73                 :            :     const UniReference<XMLPropertySetMapper> & rMapperRef,
      74                 :            :     sal_Int32 nIndex) :
      75                 :            :         SvXMLImportContext(rImport, nPrefix, rLocalName),
      76                 :            :         rProperties(rProps),
      77                 :            :         rMapper(rMapperRef),
      78         [ +  - ]:        101 :         nPropIndex(nIndex)
      79                 :            : {
      80                 :        101 : }
      81                 :            : 
      82         [ +  - ]:        101 : XMLFootnoteSeparatorImport::~XMLFootnoteSeparatorImport()
      83                 :            : {
      84         [ -  + ]:        202 : }
      85                 :            : 
      86                 :        101 : void XMLFootnoteSeparatorImport::StartElement(
      87                 :            :     const Reference<XAttributeList> & xAttrList)
      88                 :            : {
      89                 :            :     // get the values from the properties
      90                 :        101 :     sal_Int16 nLineWeight = 0;
      91                 :        101 :     sal_Int32 nLineColor = 0;
      92                 :        101 :     sal_Int8 nLineRelWidth = 0;
      93                 :        101 :     sal_Int16 eLineAdjust = text::HorizontalAdjust_LEFT; // enum text::HorizontalAdjust
      94                 :        101 :     sal_Int32 nLineTextDistance = 0;
      95                 :        101 :     sal_Int32 nLineDistance = 0;
      96                 :        101 :     sal_Int8 nLineStyle = 0;
      97                 :            : 
      98                 :            :     // iterate over xattribute list and fill values
      99 [ +  - ][ +  - ]:        101 :     sal_Int16 nLength = xAttrList->getLength();
     100         [ +  + ]:        774 :     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
     101                 :            :     {
     102                 :        673 :         OUString sLocalName;
     103                 :        673 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
     104         [ +  - ]:        673 :             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
     105   [ +  -  +  - ]:       1346 :                               &sLocalName );
     106                 :            : 
     107         [ +  - ]:        673 :         if (XML_NAMESPACE_STYLE == nPrefix)
     108                 :            :         {
     109 [ +  - ][ +  - ]:        673 :             OUString sAttrValue = xAttrList->getValueByIndex(nAttr);
     110                 :            :             sal_Int32 nTmp;
     111 [ +  - ][ +  + ]:        673 :             if (IsXMLToken( sLocalName, XML_WIDTH ))
     112                 :            :             {
     113 [ +  - ][ +  - ]:         96 :                 if (GetImport().GetMM100UnitConverter().convertMeasureToCore(
     114                 :            :                     nTmp, sAttrValue))
     115                 :            :                 {
     116                 :         96 :                     nLineWeight = (sal_Int16)nTmp;
     117                 :            :                 }
     118                 :            :             }
     119 [ +  - ][ +  + ]:        577 :             else if (IsXMLToken( sLocalName, XML_DISTANCE_BEFORE_SEP ))
     120                 :            :             {
     121 [ +  - ][ +  - ]:         96 :                 if (GetImport().GetMM100UnitConverter().convertMeasureToCore(
     122                 :            :                                                         nTmp, sAttrValue))
     123                 :         96 :                     nLineTextDistance = nTmp;
     124                 :            :             }
     125 [ +  - ][ +  + ]:        481 :             else if (IsXMLToken( sLocalName, XML_DISTANCE_AFTER_SEP ))
     126                 :            :             {
     127 [ +  - ][ +  - ]:         96 :                 if (GetImport().GetMM100UnitConverter().convertMeasureToCore(
     128                 :            :                                                         nTmp, sAttrValue))
     129                 :         96 :                     nLineDistance = nTmp;
     130                 :            :             }
     131 [ +  - ][ +  + ]:        385 :             else if (IsXMLToken( sLocalName, XML_ADJUSTMENT ))
     132                 :            :             {
     133                 :            :                 sal_uInt16 nTmpU;
     134                 :            :                 static const SvXMLEnumMapEntry aXML_HorizontalAdjust_Enum[] =
     135                 :            :                 {
     136                 :            :                     { XML_LEFT,     text::HorizontalAdjust_LEFT },
     137                 :            :                     { XML_CENTER,   text::HorizontalAdjust_CENTER },
     138                 :            :                     { XML_RIGHT,    text::HorizontalAdjust_RIGHT },
     139                 :            :                     { XML_TOKEN_INVALID, 0 }
     140                 :            :                 };
     141                 :            : 
     142         [ +  - ]:        101 :                 if (SvXMLUnitConverter::convertEnum(
     143         [ +  - ]:        101 :                             nTmpU, sAttrValue, aXML_HorizontalAdjust_Enum))
     144                 :        101 :                     eLineAdjust = (sal_Int16)nTmpU;
     145                 :            :             }
     146 [ +  - ][ +  + ]:        284 :             else if (IsXMLToken( sLocalName, XML_REL_WIDTH ))
     147                 :            :             {
     148 [ +  - ][ +  - ]:        101 :                 if (::sax::Converter::convertPercent(nTmp, sAttrValue))
     149                 :        101 :                     nLineRelWidth = (sal_uInt8)nTmp;
     150                 :            :             }
     151 [ +  - ][ +  + ]:        183 :             else if (IsXMLToken( sLocalName, XML_COLOR ))
     152                 :            :             {
     153 [ +  - ][ +  - ]:        101 :                 if (::sax::Converter::convertColor(nTmp, sAttrValue))
     154                 :            :                 {
     155                 :        101 :                     nLineColor = nTmp;
     156                 :            :                 }
     157                 :            :             }
     158 [ +  - ][ +  - ]:         82 :             else if (IsXMLToken( sLocalName, XML_LINE_STYLE ))
     159                 :            :             {
     160                 :            :                 sal_uInt16 nTmpU;
     161                 :            :                 static const SvXMLEnumMapEntry aXML_LineStyle_Enum[] =
     162                 :            :                 {
     163                 :            :                     { XML_NONE,     0 },
     164                 :            :                     { XML_SOLID,    1 },
     165                 :            :                     { XML_DOTTED,   2 },
     166                 :            :                     { XML_DASH,     3 },
     167                 :            :                     { XML_TOKEN_INVALID, 0 }
     168                 :            :                 };
     169                 :            : 
     170         [ +  - ]:         82 :                 if (SvXMLUnitConverter::convertEnum(
     171         [ +  - ]:         82 :                             nTmpU, sAttrValue, aXML_LineStyle_Enum))
     172                 :         82 :                     nLineStyle = (sal_Int8)nTmpU;
     173                 :            : 
     174                 :        673 :             }
     175                 :            :         }
     176                 :        673 :     }
     177                 :            : 
     178                 :            :     // OK, now we have all values and can fill the XMLPropertyState vector
     179                 :        101 :     Any aAny;
     180                 :            :     sal_Int32 nIndex;
     181                 :            : 
     182         [ +  - ]:        101 :     aAny <<= eLineAdjust;
     183 [ +  - ][ +  - ]:        101 :     nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_LINE_ADJUST);
     184                 :        101 :     XMLPropertyState aLineAdjust( nIndex, aAny);
     185         [ +  - ]:        101 :     rProperties.push_back(aLineAdjust);
     186                 :            : 
     187         [ +  - ]:        101 :     aAny <<= nLineColor;
     188 [ +  - ][ +  - ]:        101 :     nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_LINE_COLOR);
     189                 :        101 :     XMLPropertyState aLineColor( nIndex, aAny );
     190         [ +  - ]:        101 :     rProperties.push_back(aLineColor);
     191                 :            : 
     192         [ +  - ]:        101 :     aAny <<= nLineStyle;
     193 [ +  - ][ +  - ]:        101 :     nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_LINE_STYLE);
     194                 :        101 :     XMLPropertyState aLineStyle( nIndex, aAny );
     195         [ +  - ]:        101 :     rProperties.push_back(aLineStyle);
     196                 :            : 
     197         [ +  - ]:        101 :     aAny <<= nLineDistance;
     198 [ +  - ][ +  - ]:        101 :     nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_DISTANCE);
     199                 :        101 :     XMLPropertyState aLineDistance( nIndex, aAny );
     200         [ +  - ]:        101 :     rProperties.push_back(aLineDistance);
     201                 :            : 
     202         [ +  - ]:        101 :     aAny <<= nLineRelWidth;
     203 [ +  - ][ +  - ]:        101 :     nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_LINE_WIDTH);
     204                 :        101 :     XMLPropertyState aLineRelWidth( nIndex, aAny);
     205         [ +  - ]:        101 :     rProperties.push_back(aLineRelWidth);
     206                 :            : 
     207         [ +  - ]:        101 :     aAny <<= nLineTextDistance;
     208 [ +  - ][ +  - ]:        101 :     nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_LINE_DISTANCE);
     209                 :        101 :     XMLPropertyState aLineTextDistance( nIndex, aAny);
     210         [ +  - ]:        101 :     rProperties.push_back(aLineTextDistance);
     211                 :            : 
     212                 :            :     DBG_ASSERT( rMapper->FindEntryIndex(CTF_PM_FTN_LINE_WEIGTH) == nPropIndex,
     213                 :            :                 "Received wrong property map index!" );
     214         [ +  - ]:        101 :     aAny <<= nLineWeight;
     215                 :        101 :     XMLPropertyState aLineWeight( nPropIndex, aAny );
     216         [ +  - ]:        101 :     rProperties.push_back(aLineWeight);
     217                 :        101 : }
     218                 :            : 
     219                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10