LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/filter/oox - commentsfragment.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 30 64 46.9 %
Date: 2013-07-09 Functions: 7 11 63.6 %
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             : #include "commentsfragment.hxx"
      21             : 
      22             : #include "richstringcontext.hxx"
      23             : 
      24             : namespace oox {
      25             : namespace xls {
      26             : 
      27             : // ============================================================================
      28             : 
      29             : using namespace ::oox::core;
      30             : 
      31             : 
      32             : // ============================================================================
      33             : 
      34           1 : CommentsFragment::CommentsFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
      35           1 :     WorksheetFragmentBase( rHelper, rFragmentPath )
      36             : {
      37           1 : }
      38             : 
      39          18 : ContextHandlerRef CommentsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      40             : {
      41          18 :     switch( getCurrentElement() )
      42             :     {
      43             :         case XML_ROOT_CONTEXT:
      44           1 :             if( nElement == XLS_TOKEN( comments ) ) return this;
      45           0 :         break;
      46             :         case XLS_TOKEN( comments ):
      47           2 :             if( nElement == XLS_TOKEN( authors ) ) return this;
      48           1 :             if( nElement == XLS_TOKEN( commentList ) ) return this;
      49           0 :         break;
      50             :         case XLS_TOKEN( authors ):
      51           1 :             if( nElement == XLS_TOKEN( author ) ) return this;  // collect author in onCharacters()
      52           0 :         break;
      53             :         case XLS_TOKEN( commentList ):
      54           1 :             if( nElement == XLS_TOKEN( comment ) ) { importComment( rAttribs ); return this; }
      55           0 :         break;
      56             :         case XLS_TOKEN( commentPr ):
      57           1 :             if( nElement == XLS_TOKEN( anchor ) )
      58           1 :                 return this;
      59           0 :             break;
      60             :         case XLS_TOKEN( anchor ):
      61           2 :             if( nElement == XDR_TOKEN( from ) || nElement == XDR_TOKEN( to ) )
      62           2 :                 return this;
      63           0 :             break;
      64             :         case XDR_TOKEN( from ):
      65             :         case XDR_TOKEN( to ):
      66           8 :             return this;
      67             :         case XLS_TOKEN( comment ):
      68           2 :             if( (nElement == XLS_TOKEN( text )) && mxComment.get() )
      69           1 :                 return new RichStringContext( *this, mxComment->createText() );
      70           1 :             if( nElement == XLS_TOKEN( commentPr ) ) { mxComment->importCommentPr( rAttribs ); return this; }
      71           0 :         break;
      72             :     }
      73           0 :     return 0;
      74             : }
      75             : 
      76           8 : void CommentsFragment::onCharacters( const OUString& rChars )
      77             : {
      78           8 :     if( isCurrentElement( XLS_TOKEN( author ) ) )
      79           0 :         getComments().appendAuthor( rChars );
      80           8 : }
      81             : 
      82          19 : void CommentsFragment::onEndElement()
      83             : {
      84          19 :     if( isCurrentElement( XLS_TOKEN( comment ) ) )
      85           3 :         mxComment.reset();
      86          19 : }
      87             : 
      88           0 : ContextHandlerRef CommentsFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
      89             : {
      90           0 :     switch( getCurrentElement() )
      91             :     {
      92             :         case XML_ROOT_CONTEXT:
      93           0 :             if( nRecId == BIFF12_ID_COMMENTS ) return this;
      94           0 :         break;
      95             :         case BIFF12_ID_COMMENTS:
      96           0 :             if( nRecId == BIFF12_ID_COMMENTAUTHORS ) return this;
      97           0 :             if( nRecId == BIFF12_ID_COMMENTLIST ) return this;
      98           0 :         break;
      99             :         case BIFF12_ID_COMMENTAUTHORS:
     100           0 :             if( nRecId == BIFF12_ID_COMMENTAUTHOR ) getComments().appendAuthor( BiffHelper::readString( rStrm ) );
     101           0 :         break;
     102             :         case BIFF12_ID_COMMENTLIST:
     103           0 :             if( nRecId == BIFF12_ID_COMMENT ) { importComment( rStrm ); return this; }
     104           0 :         break;
     105             :         case BIFF12_ID_COMMENT:
     106           0 :             if( (nRecId == BIFF12_ID_COMMENTTEXT) && mxComment.get() )
     107           0 :                 mxComment->createText()->importString( rStrm, true );
     108           0 :         break;
     109             :     }
     110           0 :     return 0;
     111             : }
     112             : 
     113           0 : void CommentsFragment::onEndRecord()
     114             : {
     115           0 :     if( isCurrentElement( BIFF12_ID_COMMENT ) )
     116           0 :         mxComment.reset();
     117           0 : }
     118             : 
     119           0 : const RecordInfo* CommentsFragment::getRecordInfos() const
     120             : {
     121             :     static const RecordInfo spRecInfos[] =
     122             :     {
     123             :         { BIFF12_ID_COMMENT,        BIFF12_ID_COMMENT + 1           },
     124             :         { BIFF12_ID_COMMENTAUTHORS, BIFF12_ID_COMMENTAUTHORS + 1    },
     125             :         { BIFF12_ID_COMMENTLIST,    BIFF12_ID_COMMENTLIST + 1       },
     126             :         { BIFF12_ID_COMMENTS,       BIFF12_ID_COMMENTS + 1          },
     127             :         { -1,                       -1                              }
     128             :     };
     129           0 :     return spRecInfos;
     130             : }
     131             : 
     132             : // private --------------------------------------------------------------------
     133             : 
     134           1 : void CommentsFragment::importComment( const AttributeList& rAttribs )
     135             : {
     136           1 :     mxComment = getComments().createComment();
     137           1 :     mxComment->importComment( rAttribs );
     138           1 : }
     139             : 
     140           0 : void CommentsFragment::importComment( SequenceInputStream& rStrm )
     141             : {
     142           0 :     mxComment = getComments().createComment();
     143           0 :     mxComment->importComment( rStrm );
     144           0 : }
     145             : 
     146             : // ============================================================================
     147             : 
     148             : } // namespace xls
     149          15 : } // namespace oox
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10