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

Generated by: LCOV version 1.10