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

Generated by: LCOV version 1.10