LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexTabStopEntryContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 43 54 79.6 %
Date: 2012-08-25 Functions: 5 10 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 22 56 39.3 %

           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 "XMLIndexTabStopEntryContext.hxx"
      31                 :            : 
      32                 :            : #include <sax/tools/converter.hxx>
      33                 :            : 
      34                 :            : #include "XMLIndexTemplateContext.hxx"
      35                 :            : #include <xmloff/xmlictxt.hxx>
      36                 :            : #include <xmloff/xmlimp.hxx>
      37                 :            : #include <xmloff/txtimp.hxx>
      38                 :            : #include <xmloff/nmspmap.hxx>
      39                 :            : #include "xmloff/xmlnmspe.hxx"
      40                 :            : #include <xmloff/xmltoken.hxx>
      41                 :            : #include <xmloff/xmluconv.hxx>
      42                 :            : #include <rtl/ustring.hxx>
      43                 :            : #include <tools/debug.hxx>
      44                 :            : 
      45                 :            : using namespace ::xmloff::token;
      46                 :            : 
      47                 :            : using ::rtl::OUString;
      48                 :            : using ::com::sun::star::uno::Sequence;
      49                 :            : using ::com::sun::star::uno::Reference;
      50                 :            : using ::com::sun::star::uno::Any;
      51                 :            : using ::com::sun::star::beans::PropertyValue;
      52                 :            : using ::com::sun::star::xml::sax::XAttributeList;
      53                 :            : 
      54                 :            : 
      55 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLIndexTabStopEntryContext, XMLIndexSimpleEntryContext );
      56                 :            : 
      57                 :        104 : XMLIndexTabStopEntryContext::XMLIndexTabStopEntryContext(
      58                 :            :     SvXMLImport& rImport,
      59                 :            :     XMLIndexTemplateContext& rTemplate,
      60                 :            :     sal_uInt16 nPrfx,
      61                 :            :     const OUString& rLocalName ) :
      62                 :            :         XMLIndexSimpleEntryContext(rImport, rTemplate.sTokenTabStop,
      63                 :            :                                    rTemplate, nPrfx, rLocalName),
      64                 :            :         sLeaderChar(),
      65                 :            :         nTabPosition(0),
      66                 :            :         bTabPositionOK(sal_False),
      67                 :            :         bTabRightAligned(sal_False),
      68                 :            :         bLeaderCharOK(sal_False),
      69                 :        104 :         bWithTab(sal_True) // #i21237#
      70                 :            : {
      71                 :        104 : }
      72                 :            : 
      73                 :        104 : XMLIndexTabStopEntryContext::~XMLIndexTabStopEntryContext()
      74                 :            : {
      75         [ -  + ]:        208 : }
      76                 :            : 
      77                 :        104 : void XMLIndexTabStopEntryContext::StartElement(
      78                 :            :     const Reference<XAttributeList> & xAttrList)
      79                 :            : {
      80                 :            :     // process three attributes: type, position, leader char
      81                 :        104 :     sal_Int16 nLength = xAttrList->getLength();
      82         [ +  + ]:        312 :     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
      83                 :            :     {
      84                 :        208 :         OUString sLocalName;
      85                 :        208 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
      86         [ +  - ]:        208 :             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
      87   [ +  -  +  - ]:        416 :                               &sLocalName );
      88 [ +  - ][ +  - ]:        208 :         OUString sAttr = xAttrList->getValueByIndex(nAttr);
      89         [ +  - ]:        208 :         if (XML_NAMESPACE_STYLE == nPrefix)
      90                 :            :         {
      91 [ +  - ][ +  + ]:        208 :             if ( IsXMLToken( sLocalName, XML_TYPE ) )
      92                 :            :             {
      93                 :            :                 // if it's neither left nor right, value is
      94                 :            :                 // ignored. Since left is default, we only need to
      95                 :            :                 // check for right
      96         [ +  - ]:        104 :                 bTabRightAligned = IsXMLToken( sAttr, XML_RIGHT );
      97                 :            :             }
      98 [ +  - ][ -  + ]:        104 :             else if ( IsXMLToken( sLocalName, XML_POSITION ) )
      99                 :            :             {
     100                 :            :                 sal_Int32 nTmp;
     101 [ #  # ][ #  # ]:          0 :                 if (GetImport().GetMM100UnitConverter().
     102                 :            :                                         convertMeasureToCore(nTmp, sAttr))
     103                 :            :                 {
     104                 :          0 :                     nTabPosition = nTmp;
     105                 :          0 :                     bTabPositionOK = sal_True;
     106                 :            :                 }
     107                 :            :             }
     108 [ +  - ][ +  - ]:        104 :             else if ( IsXMLToken( sLocalName, XML_LEADER_CHAR ) )
     109                 :            :             {
     110                 :        104 :                 sLeaderChar = sAttr;
     111                 :            :                 // valid only, if we have a char!
     112                 :        104 :                 bLeaderCharOK = !sAttr.isEmpty();
     113                 :            :             }
     114                 :            :             // #i21237#
     115 [ #  # ][ #  # ]:          0 :             else if ( IsXMLToken( sLocalName, XML_WITH_TAB ) )
     116                 :            :             {
     117                 :          0 :                 bool bTmp(false);
     118 [ #  # ][ #  # ]:          0 :                 if (::sax::Converter::convertBool(bTmp, sAttr))
     119                 :          0 :                     bWithTab = bTmp;
     120                 :            :             }
     121                 :            :             // else: unknown style: attribute -> ignore
     122                 :            :         }
     123                 :            :         // else: no style attribute -> ignore
     124                 :        208 :     }
     125                 :            : 
     126                 :            :     // how many entries? #i21237#
     127 [ -  + ][ +  - ]:        104 :     nValues += 2 + (bTabPositionOK ? 1 : 0) + (bLeaderCharOK ? 1 : 0);
     128                 :            : 
     129                 :            :     // now try parent class (for character style)
     130                 :        104 :     XMLIndexSimpleEntryContext::StartElement( xAttrList );
     131                 :        104 : }
     132                 :            : 
     133                 :        104 : void XMLIndexTabStopEntryContext::FillPropertyValues(
     134                 :            :     Sequence<PropertyValue> & rValues)
     135                 :            : {
     136                 :            :     // fill vlues from parent class (type + style name)
     137                 :        104 :     XMLIndexSimpleEntryContext::FillPropertyValues(rValues);
     138                 :            : 
     139                 :            :     // get values array and next entry to be written;
     140         [ -  + ]:        104 :     sal_Int32 nNextEntry = bCharStyleNameOK ? 2 : 1;
     141                 :        104 :     PropertyValue* pValues = rValues.getArray();
     142                 :            : 
     143                 :            :     // right aligned?
     144                 :        104 :     pValues[nNextEntry].Name = rTemplateContext.sTabStopRightAligned;
     145                 :        104 :     pValues[nNextEntry].Value.setValue( &bTabRightAligned,
     146                 :        104 :                                         ::getBooleanCppuType());
     147                 :        104 :     nNextEntry++;
     148                 :            : 
     149                 :            :     // position
     150         [ -  + ]:        104 :     if (bTabPositionOK)
     151                 :            :     {
     152                 :          0 :         pValues[nNextEntry].Name = rTemplateContext.sTabStopPosition;
     153                 :          0 :         pValues[nNextEntry].Value <<= nTabPosition;
     154                 :          0 :         nNextEntry++;
     155                 :            :     }
     156                 :            : 
     157                 :            :     // leader char
     158         [ +  - ]:        104 :     if (bLeaderCharOK)
     159                 :            :     {
     160                 :        104 :         pValues[nNextEntry].Name = rTemplateContext.sTabStopFillCharacter;
     161                 :        104 :         pValues[nNextEntry].Value <<= sLeaderChar;
     162                 :        104 :         nNextEntry++;
     163                 :            :     }
     164                 :            : 
     165                 :            :     // tab character #i21237#
     166                 :        104 :      pValues[nNextEntry].Name =
     167                 :        104 :         OUString( RTL_CONSTASCII_USTRINGPARAM("WithTab") );
     168                 :        104 :     pValues[nNextEntry].Value.setValue( &bWithTab,
     169                 :        104 :                                         ::getBooleanCppuType());
     170                 :        104 :     nNextEntry++;
     171                 :            : 
     172                 :            :     // check whether we really filled all elements of the sequence
     173                 :            :     DBG_ASSERT( nNextEntry == rValues.getLength(),
     174                 :            :                 "length incorrectly precumputed!" );
     175                 :        104 : }
     176                 :            : 
     177                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10