LCOV - code coverage report
Current view: top level - xmloff/source/chart - SchXMLParagraphContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 35 48.6 %
Date: 2012-08-25 Functions: 6 7 85.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 40 12.5 %

           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 "SchXMLImport.hxx"
      31                 :            : #include "SchXMLParagraphContext.hxx"
      32                 :            : 
      33                 :            : #include "xmloff/xmlnmspe.hxx"
      34                 :            : #include <xmloff/xmltoken.hxx>
      35                 :            : #include <xmloff/nmspmap.hxx>
      36                 :            : 
      37                 :            : using ::rtl::OUString;
      38                 :            : using namespace com::sun::star;
      39                 :            : using namespace ::xmloff::token;
      40                 :            : 
      41                 :        126 : SchXMLParagraphContext::SchXMLParagraphContext( SvXMLImport& rImport,
      42                 :            :                                                 const OUString& rLocalName,
      43                 :            :                                                 OUString& rText,
      44                 :            :                                                 OUString * pOutId /* = 0 */ ) :
      45                 :            :         SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName ),
      46                 :            :         mrText( rText ),
      47                 :        126 :         mpId( pOutId )
      48                 :            : {
      49                 :        126 : }
      50                 :            : 
      51                 :        126 : SchXMLParagraphContext::~SchXMLParagraphContext()
      52         [ -  + ]:        252 : {}
      53                 :            : 
      54                 :        126 : void SchXMLParagraphContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
      55                 :            : {
      56                 :            :     // remember the id. It is used for storing the original cell range string in
      57                 :            :     // a local table (cached data)
      58         [ +  + ]:        126 :     if( mpId )
      59                 :            :     {
      60         [ +  - ]:        114 :         sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
      61                 :        114 :         bool bHaveXmlId( false );
      62                 :            : 
      63         [ -  + ]:        114 :         for( sal_Int16 i = 0; i < nAttrCount; i++ )
      64                 :            :         {
      65 [ #  # ][ #  # ]:          0 :             rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
      66                 :          0 :             rtl::OUString aLocalName;
      67         [ #  # ]:          0 :             sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
      68                 :            : 
      69 [ #  # ][ #  # ]:          0 :             if (IsXMLToken(aLocalName, XML_ID))
      70                 :            :             {
      71         [ #  # ]:          0 :                 if (nPrefix == XML_NAMESPACE_XML)
      72                 :            :                 {
      73 [ #  # ][ #  # ]:          0 :                     (*mpId) = xAttrList->getValueByIndex( i );
      74                 :          0 :                     bHaveXmlId = true;
      75                 :            :                 }
      76         [ #  # ]:          0 :                 if (nPrefix == XML_NAMESPACE_TEXT)
      77                 :            :                 {   // text:id shall be ignored if xml:id exists
      78         [ #  # ]:          0 :                     if (!bHaveXmlId)
      79                 :            :                     {
      80 [ #  # ][ #  # ]:          0 :                         (*mpId) = xAttrList->getValueByIndex( i );
      81                 :            :                     }
      82                 :            :                 }
      83                 :            :             }
      84                 :          0 :         }
      85                 :            :     }
      86                 :        126 : }
      87                 :            : 
      88                 :        126 : void SchXMLParagraphContext::EndElement()
      89                 :            : {
      90                 :        126 :     mrText = maBuffer.makeStringAndClear();
      91                 :        126 : }
      92                 :            : 
      93                 :          0 : SvXMLImportContext* SchXMLParagraphContext::CreateChildContext(
      94                 :            :     sal_uInt16 nPrefix,
      95                 :            :     const OUString& rLocalName,
      96                 :            :     const uno::Reference< xml::sax::XAttributeList >& )
      97                 :            : {
      98         [ #  # ]:          0 :     if( nPrefix == XML_NAMESPACE_TEXT )
      99                 :            :     {
     100         [ #  # ]:          0 :         if( rLocalName.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_TAB_STOP )))
     101                 :            :         {
     102                 :          0 :             maBuffer.append( sal_Unicode( 0x0009 ));  // tabulator
     103                 :            :         }
     104         [ #  # ]:          0 :         else if( rLocalName.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_LINE_BREAK )))
     105                 :            :         {
     106                 :          0 :             maBuffer.append( sal_Unicode( 0x000A ));  // linefeed
     107                 :            :         }
     108                 :            :     }
     109                 :            : 
     110         [ #  # ]:          0 :     return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     111                 :            : }
     112                 :            : 
     113                 :        126 : void SchXMLParagraphContext::Characters( const OUString& rChars )
     114                 :            : {
     115                 :        126 :     maBuffer.append( rChars );
     116                 :        126 : }
     117                 :            : 
     118                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10