LCOV - code coverage report
Current view: top level - xmloff/source/chart - SchXMLParagraphContext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 17 35 48.6 %
Date: 2014-11-03 Functions: 6 7 85.7 %
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 "SchXMLImport.hxx"
      22             : #include "SchXMLParagraphContext.hxx"
      23             : 
      24             : #include <xmloff/xmlnmspe.hxx>
      25             : #include <xmloff/xmltoken.hxx>
      26             : #include <xmloff/nmspmap.hxx>
      27             : 
      28             : using namespace com::sun::star;
      29             : using namespace ::xmloff::token;
      30             : 
      31        4976 : SchXMLParagraphContext::SchXMLParagraphContext( SvXMLImport& rImport,
      32             :                                                 const OUString& rLocalName,
      33             :                                                 OUString& rText,
      34             :                                                 OUString * pOutId /* = 0 */ ) :
      35             :         SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName ),
      36             :         mrText( rText ),
      37        4976 :         mpId( pOutId )
      38             : {
      39        4976 : }
      40             : 
      41        9952 : SchXMLParagraphContext::~SchXMLParagraphContext()
      42        9952 : {}
      43             : 
      44        4976 : void SchXMLParagraphContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
      45             : {
      46             :     // remember the id. It is used for storing the original cell range string in
      47             :     // a local table (cached data)
      48        4976 :     if( mpId )
      49             :     {
      50        4524 :         sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
      51        4524 :         bool bHaveXmlId( false );
      52             : 
      53        4524 :         for( sal_Int16 i = 0; i < nAttrCount; i++ )
      54             :         {
      55           0 :             OUString sAttrName = xAttrList->getNameByIndex( i );
      56           0 :             OUString aLocalName;
      57           0 :             sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
      58             : 
      59           0 :             if (IsXMLToken(aLocalName, XML_ID))
      60             :             {
      61           0 :                 if (nPrefix == XML_NAMESPACE_XML)
      62             :                 {
      63           0 :                     (*mpId) = xAttrList->getValueByIndex( i );
      64           0 :                     bHaveXmlId = true;
      65             :                 }
      66           0 :                 if (nPrefix == XML_NAMESPACE_TEXT)
      67             :                 {   // text:id shall be ignored if xml:id exists
      68           0 :                     if (!bHaveXmlId)
      69             :                     {
      70           0 :                         (*mpId) = xAttrList->getValueByIndex( i );
      71             :                     }
      72             :                 }
      73             :             }
      74           0 :         }
      75             :     }
      76        4976 : }
      77             : 
      78        4976 : void SchXMLParagraphContext::EndElement()
      79             : {
      80        4976 :     mrText = maBuffer.makeStringAndClear();
      81        4976 : }
      82             : 
      83           0 : SvXMLImportContext* SchXMLParagraphContext::CreateChildContext(
      84             :     sal_uInt16 nPrefix,
      85             :     const OUString& rLocalName,
      86             :     const uno::Reference< xml::sax::XAttributeList >& )
      87             : {
      88           0 :     if( nPrefix == XML_NAMESPACE_TEXT )
      89             :     {
      90           0 :         if( rLocalName.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_TAB_STOP )))
      91             :         {
      92           0 :             maBuffer.append( sal_Unicode( 0x0009 ));  // tabulator
      93             :         }
      94           0 :         else if( rLocalName.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_LINE_BREAK )))
      95             :         {
      96           0 :             maBuffer.append( sal_Unicode( 0x000A ));  // linefeed
      97             :         }
      98             :     }
      99             : 
     100           0 :     return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     101             : }
     102             : 
     103        4726 : void SchXMLParagraphContext::Characters( const OUString& rChars )
     104             : {
     105        4726 :     maBuffer.append( rChars );
     106        4726 : }
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10