LCOV - code coverage report
Current view: top level - sc/source/filter/oox - pivottablefragment.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 39 128 30.5 %
Date: 2014-11-03 Functions: 7 16 43.8 %
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 "pivottablefragment.hxx"
      21             : 
      22             : #include "biffinputstream.hxx"
      23             : #include "pivottablebuffer.hxx"
      24             : 
      25             : namespace oox {
      26             : namespace xls {
      27             : 
      28             : using namespace ::oox::core;
      29             : 
      30          48 : PivotTableFieldContext::PivotTableFieldContext( WorksheetFragmentBase& rFragment, PivotTableField& rTableField ) :
      31             :     WorksheetContextBase( rFragment ),
      32          48 :     mrTableField( rTableField )
      33             : {
      34          48 : }
      35             : 
      36          50 : ContextHandlerRef PivotTableFieldContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      37             : {
      38          50 :     switch( getCurrentElement() )
      39             :     {
      40             :         case XLS_TOKEN( pivotField ):
      41          10 :             switch( nElement )
      42             :             {
      43          10 :                 case XLS_TOKEN( items ):            return this;
      44           0 :                 case XLS_TOKEN( autoSortScope ):    return this;
      45             :             }
      46           0 :         break;
      47             :         case XLS_TOKEN( items ):
      48          40 :             if( nElement == XLS_TOKEN( item ) ) mrTableField.importItem( rAttribs );
      49          40 :         break;
      50             :         case XLS_TOKEN( autoSortScope ):
      51           0 :             if( nElement == XLS_TOKEN( pivotArea ) ) return this;
      52           0 :         break;
      53             :         case XLS_TOKEN( pivotArea ):
      54           0 :             if( nElement == XLS_TOKEN( references ) ) return this;
      55           0 :         break;
      56             :         case XLS_TOKEN( references ):
      57           0 :             if( nElement == XLS_TOKEN( reference ) ) { mrTableField.importReference( rAttribs ); return this; }
      58           0 :         break;
      59             :         case XLS_TOKEN( reference ):
      60           0 :             if( nElement == XLS_TOKEN( x ) ) mrTableField.importReferenceItem( rAttribs );
      61           0 :         break;
      62             :     }
      63          40 :     return 0;
      64             : }
      65             : 
      66          58 : void PivotTableFieldContext::onStartElement( const AttributeList& rAttribs )
      67             : {
      68          58 :     if( isRootElement() )
      69          48 :         mrTableField.importPivotField( rAttribs );
      70          58 : }
      71             : 
      72           0 : ContextHandlerRef PivotTableFieldContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
      73             : {
      74           0 :     switch( getCurrentElement() )
      75             :     {
      76             :         case BIFF12_ID_PTFIELD:
      77           0 :             switch( nRecId )
      78             :             {
      79           0 :                 case BIFF12_ID_PTFITEMS:        return this;
      80           0 :                 case BIFF12_ID_AUTOSORTSCOPE:   return this;
      81             :             }
      82           0 :         break;
      83             :         case BIFF12_ID_PTFITEMS:
      84           0 :             if( nRecId == BIFF12_ID_PTFITEM ) mrTableField.importPTFItem( rStrm );
      85           0 :         break;
      86             :         case BIFF12_ID_AUTOSORTSCOPE:
      87           0 :             if( nRecId == BIFF12_ID_PIVOTAREA ) return this;
      88           0 :         break;
      89             :         case BIFF12_ID_PIVOTAREA:
      90           0 :             if( nRecId == BIFF12_ID_PTREFERENCES ) return this;
      91           0 :         break;
      92             :         case BIFF12_ID_PTREFERENCES:
      93           0 :             if( nRecId == BIFF12_ID_PTREFERENCE ) { mrTableField.importPTReference( rStrm ); return this; }
      94           0 :         break;
      95             :         case BIFF12_ID_PTREFERENCE:
      96           0 :             if( nRecId == BIFF12_ID_PTREFERENCEITEM ) mrTableField.importPTReferenceItem( rStrm );
      97           0 :         break;
      98             :     }
      99           0 :     return 0;
     100             : }
     101             : 
     102           0 : void PivotTableFieldContext::onStartRecord( SequenceInputStream& rStrm )
     103             : {
     104           0 :     if( isRootElement() )
     105           0 :         mrTableField.importPTField( rStrm );
     106           0 : }
     107             : 
     108           0 : PivotTableFilterContext::PivotTableFilterContext( WorksheetFragmentBase& rFragment, PivotTableFilter& rTableFilter ) :
     109             :     WorksheetContextBase( rFragment ),
     110           0 :     mrTableFilter( rTableFilter )
     111             : {
     112           0 : }
     113             : 
     114           0 : ContextHandlerRef PivotTableFilterContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     115             : {
     116           0 :     switch( getCurrentElement() )
     117             :     {
     118             :         case XLS_TOKEN( filter ):
     119           0 :             if( nElement == XLS_TOKEN( autoFilter ) ) return this;
     120           0 :         break;
     121             :         case XLS_TOKEN( autoFilter ):
     122           0 :             if( nElement == XLS_TOKEN( filterColumn ) ) return this;
     123           0 :         break;
     124             :         case XLS_TOKEN( filterColumn ):
     125           0 :             if( nElement == XLS_TOKEN( top10 ) ) mrTableFilter.importTop10( rAttribs );
     126           0 :         break;
     127             :     }
     128           0 :     return 0;
     129             : }
     130             : 
     131           0 : void PivotTableFilterContext::onStartElement( const AttributeList& rAttribs )
     132             : {
     133           0 :     if( isRootElement() )
     134           0 :         mrTableFilter.importFilter( rAttribs );
     135           0 : }
     136             : 
     137           0 : ContextHandlerRef PivotTableFilterContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
     138             : {
     139           0 :     switch( getCurrentElement() )
     140             :     {
     141             :         case BIFF12_ID_PTFILTER:
     142           0 :             if( nRecId == BIFF12_ID_AUTOFILTER ) return this;
     143           0 :         break;
     144             :         case BIFF12_ID_AUTOFILTER:
     145           0 :             if( nRecId == BIFF12_ID_FILTERCOLUMN ) return this;
     146           0 :         break;
     147             :         case BIFF12_ID_FILTERCOLUMN:
     148           0 :             if( nRecId == BIFF12_ID_TOP10FILTER ) mrTableFilter.importTop10Filter( rStrm );
     149           0 :         break;
     150             :     }
     151           0 :     return 0;
     152             : }
     153             : 
     154           0 : void PivotTableFilterContext::onStartRecord( SequenceInputStream& rStrm )
     155             : {
     156           0 :     if( isRootElement() )
     157           0 :         mrTableFilter.importPTFilter( rStrm );
     158           0 : }
     159             : 
     160           8 : PivotTableFragment::PivotTableFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
     161             :     WorksheetFragmentBase( rHelper, rFragmentPath ),
     162           8 :     mrPivotTable( getPivotTables().createPivotTable() )
     163             : {
     164           8 : }
     165             : 
     166         152 : ContextHandlerRef PivotTableFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     167             : {
     168         152 :     switch( getCurrentElement() )
     169             :     {
     170             :         case XML_ROOT_CONTEXT:
     171           8 :             if( nElement == XLS_TOKEN( pivotTableDefinition ) ) { mrPivotTable.importPivotTableDefinition( rAttribs ); return this; }
     172           0 :         break;
     173             : 
     174             :         case XLS_TOKEN( pivotTableDefinition ):
     175          60 :             switch( nElement )
     176             :             {
     177           8 :                 case XLS_TOKEN( location ):     mrPivotTable.importLocation( rAttribs, getSheetIndex() );   break;
     178           8 :                 case XLS_TOKEN( pivotFields ):  return this;
     179           8 :                 case XLS_TOKEN( rowFields ):    return this;
     180           8 :                 case XLS_TOKEN( colFields ):    return this;
     181           4 :                 case XLS_TOKEN( pageFields ):   return this;
     182           8 :                 case XLS_TOKEN( dataFields ):   return this;
     183           0 :                 case XLS_TOKEN( filters ):      return this;
     184             :             }
     185          24 :         break;
     186             : 
     187             :         case XLS_TOKEN( pivotFields ):
     188          48 :             if( nElement == XLS_TOKEN( pivotField ) ) return new PivotTableFieldContext( *this, mrPivotTable.createTableField() );
     189           0 :         break;
     190             :         case XLS_TOKEN( rowFields ):
     191           8 :             if( nElement == XLS_TOKEN( field ) ) mrPivotTable.importRowField( rAttribs );
     192           8 :         break;
     193             :         case XLS_TOKEN( colFields ):
     194           8 :             if( nElement == XLS_TOKEN( field ) ) mrPivotTable.importColField( rAttribs );
     195           8 :         break;
     196             :         case XLS_TOKEN( pageFields ):
     197           8 :             if( nElement == XLS_TOKEN( pageField ) ) mrPivotTable.importPageField( rAttribs );
     198           8 :         break;
     199             :         case XLS_TOKEN( dataFields ):
     200          12 :             if( nElement == XLS_TOKEN( dataField ) ) mrPivotTable.importDataField( rAttribs );
     201          12 :         break;
     202             :         case XLS_TOKEN( filters ):
     203           0 :             if( nElement == XLS_TOKEN( filter ) ) return new PivotTableFilterContext( *this, mrPivotTable.createTableFilter() );
     204           0 :         break;
     205             :     }
     206          60 :     return 0;
     207             : }
     208             : 
     209           0 : ContextHandlerRef PivotTableFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
     210             : {
     211           0 :     switch( getCurrentElement() )
     212             :     {
     213             :         case XML_ROOT_CONTEXT:
     214           0 :             if( nRecId == BIFF12_ID_PTDEFINITION ) { mrPivotTable.importPTDefinition( rStrm ); return this; }
     215           0 :         break;
     216             : 
     217             :         case BIFF12_ID_PTDEFINITION:
     218           0 :             switch( nRecId )
     219             :             {
     220           0 :                 case BIFF12_ID_PTLOCATION:      mrPivotTable.importPTLocation( rStrm, getSheetIndex() );    break;
     221           0 :                 case BIFF12_ID_PTFIELDS:        return this;
     222           0 :                 case BIFF12_ID_PTROWFIELDS:     mrPivotTable.importPTRowFields( rStrm );                    break;
     223           0 :                 case BIFF12_ID_PTCOLFIELDS:     mrPivotTable.importPTColFields( rStrm );                    break;
     224           0 :                 case BIFF12_ID_PTPAGEFIELDS:    return this;
     225           0 :                 case BIFF12_ID_PTDATAFIELDS:    return this;
     226           0 :                 case BIFF12_ID_PTFILTERS:       return this;
     227             :             }
     228           0 :         break;
     229             : 
     230             :         case BIFF12_ID_PTFIELDS:
     231           0 :             if( nRecId == BIFF12_ID_PTFIELD ) return new PivotTableFieldContext( *this, mrPivotTable.createTableField() );
     232           0 :         break;
     233             :         case BIFF12_ID_PTPAGEFIELDS:
     234           0 :             if( nRecId == BIFF12_ID_PTPAGEFIELD ) mrPivotTable.importPTPageField( rStrm );
     235           0 :         break;
     236             :         case BIFF12_ID_PTDATAFIELDS:
     237           0 :             if( nRecId == BIFF12_ID_PTDATAFIELD ) mrPivotTable.importPTDataField( rStrm );
     238           0 :         break;
     239             :         case BIFF12_ID_PTFILTERS:
     240           0 :             if( nRecId == BIFF12_ID_PTFILTER ) return new PivotTableFilterContext( *this, mrPivotTable.createTableFilter() );
     241           0 :         break;
     242             :     }
     243           0 :     return 0;
     244             : }
     245             : 
     246           0 : const RecordInfo* PivotTableFragment::getRecordInfos() const
     247             : {
     248             :     static const RecordInfo spRecInfos[] =
     249             :     {
     250             :         { BIFF12_ID_AUTOFILTER,         BIFF12_ID_AUTOFILTER + 1        },
     251             :         { BIFF12_ID_AUTOSORTSCOPE,      BIFF12_ID_AUTOSORTSCOPE + 1     },
     252             :         { BIFF12_ID_FILTERCOLUMN,       BIFF12_ID_FILTERCOLUMN + 1      },
     253             :         { BIFF12_ID_PIVOTAREA,          BIFF12_ID_PIVOTAREA + 1         },
     254             :         { BIFF12_ID_PTCOLFIELDS,        BIFF12_ID_PTCOLFIELDS + 1       },
     255             :         { BIFF12_ID_PTDATAFIELD,        BIFF12_ID_PTDATAFIELD + 1       },
     256             :         { BIFF12_ID_PTDATAFIELDS,       BIFF12_ID_PTDATAFIELDS + 1      },
     257             :         { BIFF12_ID_PTDEFINITION,       BIFF12_ID_PTDEFINITION + 35     },
     258             :         { BIFF12_ID_PTFIELD,            BIFF12_ID_PTFIELD + 1           },
     259             :         { BIFF12_ID_PTFIELDS,           BIFF12_ID_PTFIELDS + 1          },
     260             :         { BIFF12_ID_PTFILTER,           BIFF12_ID_PTFILTER + 1          },
     261             :         { BIFF12_ID_PTFILTERS,          BIFF12_ID_PTFILTERS + 1         },
     262             :         { BIFF12_ID_PTFITEM,            BIFF12_ID_PTFITEM - 1           },
     263             :         { BIFF12_ID_PTFITEMS,           BIFF12_ID_PTFITEMS + 1          },
     264             :         { BIFF12_ID_PTLOCATION,         BIFF12_ID_PTLOCATION - 1        },
     265             :         { BIFF12_ID_PTPAGEFIELD,        BIFF12_ID_PTPAGEFIELD + 1       },
     266             :         { BIFF12_ID_PTPAGEFIELDS,       BIFF12_ID_PTPAGEFIELDS + 1      },
     267             :         { BIFF12_ID_PTREFERENCE,        BIFF12_ID_PTREFERENCE + 1       },
     268             :         { BIFF12_ID_PTREFERENCEITEM,    BIFF12_ID_PTREFERENCEITEM + 1   },
     269             :         { BIFF12_ID_PTREFERENCES,       BIFF12_ID_PTREFERENCES + 1      },
     270             :         { BIFF12_ID_PTROWFIELDS,        BIFF12_ID_PTROWFIELDS + 1       },
     271             :         { -1,                           -1                              }
     272             :     };
     273           0 :     return spRecInfos;
     274             : }
     275             : 
     276             : } // namespace xls
     277          48 : } // namespace oox
     278             : 
     279             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10