LCOV - code coverage report
Current view: top level - sc/source/filter/oox - stylesfragment.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 57 127 44.9 %
Date: 2012-08-25 Functions: 11 17 64.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 47 167 28.1 %

           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 "stylesfragment.hxx"
      30                 :            : 
      31                 :            : #include "oox/helper/attributelist.hxx"
      32                 :            : 
      33                 :            : namespace oox {
      34                 :            : namespace xls {
      35                 :            : 
      36                 :            : // ============================================================================
      37                 :            : 
      38                 :            : using namespace ::oox::core;
      39                 :            : 
      40                 :            : using ::rtl::OUString;
      41                 :            : 
      42                 :            : // ============================================================================
      43                 :            : 
      44                 :          0 : IndexedColorsContext::IndexedColorsContext( WorkbookFragmentBase& rFragment ) :
      45                 :          0 :     WorkbookContextBase( rFragment )
      46                 :            : {
      47                 :          0 : }
      48                 :            : 
      49                 :          0 : ContextHandlerRef IndexedColorsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      50                 :            : {
      51         [ #  # ]:          0 :     switch( getCurrentElement() )
      52                 :            :     {
      53                 :            :         case XLS_TOKEN( indexedColors ):
      54         [ #  # ]:          0 :             if( nElement == XLS_TOKEN( rgbColor ) ) getStyles().importPaletteColor( rAttribs );
      55                 :          0 :         break;
      56                 :            :     }
      57                 :          0 :     return 0;
      58                 :            : }
      59                 :            : 
      60                 :          0 : ContextHandlerRef IndexedColorsContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
      61                 :            : {
      62         [ #  # ]:          0 :     switch( getCurrentElement() )
      63                 :            :     {
      64                 :            :         case BIFF12_ID_INDEXEDCOLORS:
      65         [ #  # ]:          0 :             if( nRecId == BIFF12_ID_RGBCOLOR ) getStyles().importPaletteColor( rStrm );
      66                 :          0 :         break;
      67                 :            :     }
      68                 :          0 :     return 0;
      69                 :            : }
      70                 :            : 
      71                 :            : // ============================================================================
      72                 :            : 
      73                 :        417 : ContextHandlerRef FontContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      74                 :            : {
      75         [ +  - ]:        417 :     if( mxFont.get() )
      76                 :        417 :         mxFont->importAttribs( nElement, rAttribs );
      77                 :        417 :     return 0;
      78                 :            : }
      79                 :            : 
      80                 :            : // ============================================================================
      81                 :            : 
      82                 :        144 : void BorderContext::onStartElement( const AttributeList& rAttribs )
      83                 :            : {
      84 [ +  - ][ +  + ]:        144 :     if( mxBorder.get() && (getCurrentElement() == XLS_TOKEN( border )) )
                 [ +  + ]
      85                 :         24 :         mxBorder->importBorder( rAttribs );
      86                 :        144 : }
      87                 :            : 
      88                 :        120 : ContextHandlerRef BorderContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      89                 :            : {
      90 [ +  - ][ +  - ]:        120 :     if( mxBorder.get() ) switch( getCurrentElement() )
      91                 :            :     {
      92                 :            :         case XLS_TOKEN( border ):
      93                 :        120 :             mxBorder->importStyle( nElement, rAttribs );
      94                 :        120 :             return this;
      95                 :            : 
      96                 :            :         default:
      97         [ #  # ]:          0 :             if( nElement == XLS_TOKEN( color ) )
      98                 :          0 :                 mxBorder->importColor( getCurrentElement(), rAttribs );
      99                 :            :     }
     100                 :        120 :     return 0;
     101                 :            : }
     102                 :            : 
     103                 :            : // ============================================================================
     104                 :            : 
     105                 :         57 : ContextHandlerRef FillContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     106                 :            : {
     107 [ +  - ][ +  +  :         57 :     if( mxFill.get() ) switch( getCurrentElement() )
                -  -  - ]
     108                 :            :     {
     109                 :            :         case XLS_TOKEN( fill ):
     110      [ +  -  - ]:         51 :             switch( nElement )
     111                 :            :             {
     112                 :         51 :                 case XLS_TOKEN( patternFill ):  mxFill->importPatternFill( rAttribs );  return this;
     113                 :          0 :                 case XLS_TOKEN( gradientFill ): mxFill->importGradientFill( rAttribs ); return this;
     114                 :            :             }
     115                 :          0 :         break;
     116                 :            :         case XLS_TOKEN( patternFill ):
     117      [ +  +  - ]:          6 :             switch( nElement )
     118                 :            :             {
     119                 :          3 :                 case XLS_TOKEN( fgColor ):      mxFill->importFgColor( rAttribs );      break;
     120                 :          3 :                 case XLS_TOKEN( bgColor ):      mxFill->importBgColor( rAttribs );      break;
     121                 :            :             }
     122                 :          6 :         break;
     123                 :            :         case XLS_TOKEN( gradientFill ):
     124         [ #  # ]:          0 :             if( nElement == XLS_TOKEN( stop ) )
     125                 :            :             {
     126                 :          0 :                 mfGradPos = rAttribs.getDouble( XML_position, -1.0 );
     127                 :          0 :                 return this;
     128                 :            :             }
     129                 :          0 :         break;
     130                 :            :         case XLS_TOKEN( stop ):
     131         [ #  # ]:          0 :             if( nElement == XLS_TOKEN( color ) )
     132                 :          0 :                 mxFill->importColor( rAttribs, mfGradPos );
     133                 :          6 :         break;
     134                 :            :     }
     135                 :         57 :     return 0;
     136                 :            : }
     137                 :            : 
     138                 :            : // ============================================================================
     139                 :            : 
     140                 :        465 : void XfContext::onStartElement( const AttributeList& rAttribs )
     141                 :            : {
     142 [ +  - ][ +  - ]:        465 :     if( mxXf.get() && (getCurrentElement() == XLS_TOKEN( xf )) )
                 [ +  - ]
     143                 :        465 :         mxXf->importXf( rAttribs, mbCellXf );
     144                 :        465 : }
     145                 :            : 
     146                 :         51 : ContextHandlerRef XfContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     147                 :            : {
     148 [ +  - ][ +  - ]:         51 :     if( mxXf.get() ) switch( getCurrentElement() )
     149                 :            :     {
     150                 :            :         case XLS_TOKEN( xf ):
     151      [ +  +  - ]:         51 :             switch( nElement )
     152                 :            :             {
     153                 :         33 :                 case XLS_TOKEN( alignment ):    mxXf->importAlignment( rAttribs );  break;
     154                 :         18 :                 case XLS_TOKEN( protection ):   mxXf->importProtection( rAttribs ); break;
     155                 :            :             }
     156                 :         51 :         break;
     157                 :            :     }
     158                 :         51 :     return 0;
     159                 :            : }
     160                 :            : 
     161                 :            : // ============================================================================
     162                 :            : 
     163                 :          0 : ContextHandlerRef DxfContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     164                 :            : {
     165 [ #  # ][ #  # ]:          0 :     if( mxDxf.get() ) switch( getCurrentElement() )
     166                 :            :     {
     167                 :            :         case XLS_TOKEN( dxf ):
     168   [ #  #  #  #  :          0 :             switch( nElement )
                      # ]
     169                 :            :             {
     170         [ #  # ]:          0 :                 case XLS_TOKEN( font ):         return new FontContext( *this, mxDxf->createFont() );
     171         [ #  # ]:          0 :                 case XLS_TOKEN( border ):       return new BorderContext( *this, mxDxf->createBorder() );
     172         [ #  # ]:          0 :                 case XLS_TOKEN( fill ):         return new FillContext( *this, mxDxf->createFill() );
     173                 :            : 
     174                 :          0 :                 case XLS_TOKEN( numFmt ):       mxDxf->importNumFmt( rAttribs );        break;
     175                 :            : #if 0
     176                 :            :                 case XLS_TOKEN( alignment ):    mxDxf->importAlignment( rAttribs );     break;
     177                 :            :                 case XLS_TOKEN( protection ):   mxDxf->importProtection( rAttribs );    break;
     178                 :            : #endif
     179                 :            :             }
     180                 :          0 :         break;
     181                 :            :     }
     182                 :          0 :     return 0;
     183                 :            : }
     184                 :            : 
     185                 :            : // ============================================================================
     186                 :            : 
     187                 :         24 : StylesFragment::StylesFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
     188                 :         24 :     WorkbookFragmentBase( rHelper, rFragmentPath )
     189                 :            : {
     190                 :         24 : }
     191                 :            : 
     192                 :       1026 : ContextHandlerRef StylesFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     193                 :            : {
     194   [ +  +  -  +  :       1026 :     switch( getCurrentElement() )
          +  +  +  +  +  
                -  +  - ]
     195                 :            :     {
     196                 :            :         case XML_ROOT_CONTEXT:
     197         [ +  - ]:         24 :             if( nElement == XLS_TOKEN( styleSheet ) ) return this;
     198                 :          0 :         break;
     199                 :            : 
     200                 :            :         case XLS_TOKEN( styleSheet ):
     201         [ +  + ]:        180 :             switch( nElement )
     202                 :            :             {
     203                 :            :                 case XLS_TOKEN( colors ):
     204                 :            :                 case XLS_TOKEN( numFmts ):
     205                 :            :                 case XLS_TOKEN( fonts ):
     206                 :            :                 case XLS_TOKEN( borders ):
     207                 :            :                 case XLS_TOKEN( fills ):
     208                 :            :                 case XLS_TOKEN( cellXfs ):
     209                 :            :                 case XLS_TOKEN( cellStyleXfs ):
     210                 :            :                 case XLS_TOKEN( dxfs ):
     211                 :        171 :                 case XLS_TOKEN( cellStyles ):   return this;
     212                 :            :             }
     213                 :          9 :         break;
     214                 :            : 
     215                 :            :         case XLS_TOKEN( colors ):
     216 [ #  # ][ #  # ]:          0 :             if( nElement == XLS_TOKEN( indexedColors ) ) return new IndexedColorsContext( *this );
     217                 :          0 :         break;
     218                 :            :         case XLS_TOKEN( numFmts ):
     219         [ +  - ]:         48 :             if( nElement == XLS_TOKEN( numFmt ) ) getStyles().importNumFmt( rAttribs );
     220                 :         48 :         break;
     221                 :            :         case XLS_TOKEN( fonts ):
     222 [ +  - ][ +  - ]:        108 :             if( nElement == XLS_TOKEN( font ) ) return new FontContext( *this, getStyles().createFont() );
     223                 :          0 :         break;
     224                 :            :         case XLS_TOKEN( borders ):
     225 [ +  - ][ +  - ]:         24 :             if( nElement == XLS_TOKEN( border ) ) return new BorderContext( *this, getStyles().createBorder() );
     226                 :          0 :         break;
     227                 :            :         case XLS_TOKEN( fills ):
     228 [ +  - ][ +  - ]:         51 :             if( nElement == XLS_TOKEN( fill ) ) return new FillContext( *this, getStyles().createFill() );
     229                 :          0 :         break;
     230                 :            :         case XLS_TOKEN( cellXfs ):
     231 [ +  - ][ +  - ]:         87 :             if( nElement == XLS_TOKEN( xf ) ) return new XfContext( *this, getStyles().createCellXf(), true );
     232                 :          0 :         break;
     233                 :            :         case XLS_TOKEN( cellStyleXfs ):
     234 [ +  - ][ +  - ]:        378 :             if( nElement == XLS_TOKEN( xf ) ) return new XfContext( *this, getStyles().createStyleXf(), false );
     235                 :          0 :         break;
     236                 :            :         case XLS_TOKEN( dxfs ):
     237 [ #  # ][ #  # ]:          0 :             if( nElement == XLS_TOKEN( dxf ) ) return new DxfContext( *this, getStyles().createDxf() );
     238                 :          0 :         break;
     239                 :            :         case XLS_TOKEN( cellStyles ):
     240         [ +  - ]:        126 :             if( nElement == XLS_TOKEN( cellStyle ) ) getStyles().importCellStyle( rAttribs );
     241                 :        126 :         break;
     242                 :            :     }
     243                 :       1026 :     return 0;
     244                 :            : }
     245                 :            : 
     246                 :          0 : ContextHandlerRef StylesFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
     247                 :            : {
     248   [ #  #  #  #  :          0 :     switch( getCurrentElement() )
          #  #  #  #  #  
                #  #  # ]
     249                 :            :     {
     250                 :            :         case XML_ROOT_CONTEXT:
     251         [ #  # ]:          0 :             if( nRecId == BIFF12_ID_STYLESHEET ) return this;
     252                 :          0 :         break;
     253                 :            : 
     254                 :            :         case BIFF12_ID_STYLESHEET:
     255         [ #  # ]:          0 :             switch( nRecId )
     256                 :            :             {
     257                 :            :                 case BIFF12_ID_COLORS:
     258                 :            :                 case BIFF12_ID_NUMFMTS:
     259                 :            :                 case BIFF12_ID_FONTS:
     260                 :            :                 case BIFF12_ID_BORDERS:
     261                 :            :                 case BIFF12_ID_FILLS:
     262                 :            :                 case BIFF12_ID_CELLXFS:
     263                 :            :                 case BIFF12_ID_CELLSTYLEXFS:
     264                 :            :                 case BIFF12_ID_DXFS:
     265                 :          0 :                 case BIFF12_ID_CELLSTYLES:      return this;
     266                 :            :             }
     267                 :          0 :         break;
     268                 :            : 
     269                 :            :         case BIFF12_ID_COLORS:
     270 [ #  # ][ #  # ]:          0 :             if( nRecId == BIFF12_ID_INDEXEDCOLORS ) return new IndexedColorsContext( *this );
     271                 :          0 :         break;
     272                 :            :         case BIFF12_ID_NUMFMTS:
     273         [ #  # ]:          0 :             if( nRecId == BIFF12_ID_NUMFMT ) getStyles().importNumFmt( rStrm );
     274                 :          0 :         break;
     275                 :            :         case BIFF12_ID_FONTS:
     276 [ #  # ][ #  # ]:          0 :             if( nRecId == BIFF12_ID_FONT ) getStyles().createFont()->importFont( rStrm );
     277                 :          0 :         break;
     278                 :            :         case BIFF12_ID_BORDERS:
     279 [ #  # ][ #  # ]:          0 :             if( nRecId == BIFF12_ID_BORDER ) getStyles().createBorder()->importBorder( rStrm );
     280                 :          0 :         break;
     281                 :            :         case BIFF12_ID_FILLS:
     282 [ #  # ][ #  # ]:          0 :             if( nRecId == BIFF12_ID_FILL ) getStyles().createFill()->importFill( rStrm );
     283                 :          0 :         break;
     284                 :            :         case BIFF12_ID_CELLXFS:
     285 [ #  # ][ #  # ]:          0 :             if( nRecId == BIFF12_ID_XF ) getStyles().createCellXf()->importXf( rStrm, true );
     286                 :          0 :         break;
     287                 :            :         case BIFF12_ID_CELLSTYLEXFS:
     288 [ #  # ][ #  # ]:          0 :             if( nRecId == BIFF12_ID_XF ) getStyles().createStyleXf()->importXf( rStrm, false );
     289                 :          0 :         break;
     290                 :            :         case BIFF12_ID_DXFS:
     291 [ #  # ][ #  # ]:          0 :             if( nRecId == BIFF12_ID_DXF ) getStyles().createDxf()->importDxf( rStrm );
     292                 :          0 :         break;
     293                 :            :         case BIFF12_ID_CELLSTYLES:
     294         [ #  # ]:          0 :             if( nRecId == BIFF12_ID_CELLSTYLE ) getStyles().importCellStyle( rStrm );
     295                 :          0 :         break;
     296                 :            :     }
     297                 :          0 :     return 0;
     298                 :            : }
     299                 :            : 
     300                 :          0 : const RecordInfo* StylesFragment::getRecordInfos() const
     301                 :            : {
     302                 :            :     static const RecordInfo spRecInfos[] =
     303                 :            :     {
     304                 :            :         { BIFF12_ID_BORDERS,        BIFF12_ID_BORDERS + 1       },
     305                 :            :         { BIFF12_ID_CELLSTYLES,     BIFF12_ID_CELLSTYLES + 1    },
     306                 :            :         { BIFF12_ID_CELLSTYLEXFS,   BIFF12_ID_CELLSTYLEXFS + 1  },
     307                 :            :         { BIFF12_ID_CELLXFS,        BIFF12_ID_CELLXFS + 1       },
     308                 :            :         { BIFF12_ID_COLORS,         BIFF12_ID_COLORS + 1        },
     309                 :            :         { BIFF12_ID_DXFS,           BIFF12_ID_DXFS + 1          },
     310                 :            :         { BIFF12_ID_FILLS,          BIFF12_ID_FILLS + 1         },
     311                 :            :         { BIFF12_ID_FONTS,          BIFF12_ID_FONTS + 1         },
     312                 :            :         { BIFF12_ID_INDEXEDCOLORS,  BIFF12_ID_INDEXEDCOLORS + 1 },
     313                 :            :         { BIFF12_ID_MRUCOLORS,      BIFF12_ID_MRUCOLORS + 1     },
     314                 :            :         { BIFF12_ID_NUMFMTS,        BIFF12_ID_NUMFMTS + 1       },
     315                 :            :         { BIFF12_ID_STYLESHEET,     BIFF12_ID_STYLESHEET + 1    },
     316                 :            :         { BIFF12_ID_TABLESTYLES,    BIFF12_ID_TABLESTYLES + 1   },
     317                 :            :         { -1,                       -1                          }
     318                 :            :     };
     319                 :          0 :     return spRecInfos;
     320                 :            : }
     321                 :            : 
     322                 :         24 : void StylesFragment::finalizeImport()
     323                 :            : {
     324                 :         24 :     getStyles().finalizeImport();
     325                 :         24 : }
     326                 :            : 
     327                 :            : // ============================================================================
     328                 :            : 
     329                 :            : } // namespace xls
     330 [ +  - ][ +  - ]:         24 : } // namespace oox
     331                 :            : 
     332                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10