LCOV - code coverage report
Current view: top level - sc/source/filter/oox - pivottablefragment.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 128 0.8 %
Date: 2012-08-25 Functions: 2 16 12.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 140 1.4 %

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

Generated by: LCOV version 1.10