LCOV - code coverage report
Current view: top level - sfx2/source/dialog - styfitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 57 63 90.5 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 67 154 43.5 %

           Branch data     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 <sfx2/styfitem.hxx>
      21                 :            : #include <svtools/localresaccess.hxx>
      22                 :            : #include <tools/debug.hxx>
      23                 :            : 
      24                 :            : // -----------------------------------------------------------------------
      25                 :            : 
      26                 :            : class SfxStyleFamilyItem_Impl
      27                 :            : {
      28                 :            :     Bitmap aBitmap;
      29                 :            :     Image   aImage;
      30                 :            : };
      31                 :            : 
      32                 :            : // -----------------------------------------------------------------------
      33                 :            : 
      34                 :            : // Implementierung des Resource-Konstruktors
      35                 :            : 
      36                 :        594 : SfxStyleFamilyItem::SfxStyleFamilyItem( const ResId &rResId ) :
      37                 :            : 
      38 [ +  - ][ +  - ]:        594 :     Resource( rResId.SetRT( RSC_SFX_STYLE_FAMILY_ITEM ) )
         [ +  - ][ +  - ]
                 [ +  - ]
      39                 :            : 
      40                 :            : {
      41         [ +  - ]:        594 :     sal_uIntPtr nMask = ReadLongRes();
      42                 :            : 
      43         [ +  - ]:        594 :     if(nMask & RSC_SFX_STYLE_ITEM_LIST)
      44                 :            :     {
      45         [ +  - ]:        594 :         sal_uIntPtr nCount = ReadLongRes();
      46         [ +  + ]:       3316 :         for( sal_uIntPtr i = 0; i < nCount; i++ )
      47                 :            :         {
      48 [ +  - ][ +  - ]:       2722 :             SfxFilterTupel *pTupel = new SfxFilterTupel;
      49 [ +  - ][ +  - ]:       2722 :             pTupel->aName = ReadStringRes();
      50         [ +  - ]:       2722 :             long lFlags = ReadLongRes();
      51                 :       2722 :             pTupel->nFlags = (sal_uInt16)lFlags;
      52         [ +  - ]:       2722 :             aFilterList.push_back( pTupel );
      53                 :            :         }
      54                 :            :     }
      55         [ -  + ]:        594 :     if(nMask & RSC_SFX_STYLE_ITEM_BITMAP)
      56                 :            :     {
      57 [ #  # ][ #  # ]:          0 :         aBitmap = Bitmap(ResId((RSHEADER_TYPE *)GetClassRes(),*rResId.GetResMgr()));
         [ #  # ][ #  # ]
      58 [ #  # ][ #  # ]:          0 :         IncrementRes( GetObjSizeRes( (RSHEADER_TYPE *)GetClassRes() ) );
                 [ #  # ]
      59                 :            :     }
      60         [ +  - ]:        594 :     if(nMask & RSC_SFX_STYLE_ITEM_TEXT)
      61                 :            :     {
      62 [ +  - ][ +  - ]:        594 :         aText = ReadStringRes();
      63                 :            :     }
      64         [ -  + ]:        594 :     if(nMask & RSC_SFX_STYLE_ITEM_HELPTEXT)
      65                 :            :     {
      66 [ #  # ][ #  # ]:          0 :         aHelpText = ReadStringRes();
      67                 :            :     }
      68         [ +  + ]:        594 :     if(nMask & RSC_SFX_STYLE_ITEM_STYLEFAMILY)
      69                 :            :     {
      70         [ +  - ]:        474 :         nFamily = (sal_uInt16)ReadLongRes();
      71                 :            :     }
      72                 :            :     else
      73                 :        120 :         nFamily = SFX_STYLE_FAMILY_PARA;
      74         [ -  + ]:        594 :     if(nMask & RSC_SFX_STYLE_ITEM_IMAGE)
      75                 :            :     {
      76 [ #  # ][ #  # ]:          0 :         aImage = Image(ResId((RSHEADER_TYPE *)GetClassRes(),*rResId.GetResMgr()));
         [ #  # ][ #  # ]
      77 [ #  # ][ #  # ]:          0 :         IncrementRes( GetObjSizeRes( (RSHEADER_TYPE *)GetClassRes() ) );
                 [ #  # ]
      78                 :            :     }
      79                 :            :     else
      80 [ +  - ][ +  - ]:        594 :         aImage = Image(aBitmap);
                 [ +  - ]
      81                 :        594 : }
      82                 :            : 
      83                 :            : // -----------------------------------------------------------------------
      84                 :            : 
      85                 :            : // Destructor; releases the internal data
      86                 :            : 
      87 [ +  - ][ +  - ]:        594 : SfxStyleFamilyItem::~SfxStyleFamilyItem()
         [ +  - ][ +  - ]
      88                 :            : {
      89         [ +  + ]:       3316 :     for ( size_t i = 0, n = aFilterList.size(); i < n; ++i )
      90 [ +  - ][ +  - ]:       2722 :         delete aFilterList[ i ];
      91                 :        594 :     aFilterList.clear();
      92                 :        594 : }
      93                 :            : 
      94                 :            : // -----------------------------------------------------------------------
      95                 :            : 
      96                 :            : // Implementation of the resource constructor
      97                 :            : 
      98                 :        120 : SfxStyleFamilies::SfxStyleFamilies( const ResId& rResId ) :
      99         [ +  - ]:        120 :     Resource( rResId.SetRT( RSC_SFX_STYLE_FAMILIES ).SetAutoRelease( false ) )
     100                 :            : {
     101         [ +  - ]:        120 :     sal_uIntPtr nCount = ReadLongRes();
     102         [ +  + ]:        714 :     for( sal_uIntPtr i = 0; i < nCount; i++ )
     103                 :            :     {
     104         [ +  - ]:        594 :         const ResId aResId((RSHEADER_TYPE *)GetClassRes(), *rResId.GetResMgr());
     105 [ +  - ][ +  - ]:        594 :         SfxStyleFamilyItem *pItem = new SfxStyleFamilyItem(aResId);
     106 [ +  - ][ +  - ]:        594 :         IncrementRes( GetObjSizeRes( (RSHEADER_TYPE *)GetClassRes() ) );
                 [ +  - ]
     107         [ +  - ]:        594 :         aEntryList.push_back( pItem );
     108                 :            :     }
     109                 :            : 
     110         [ +  - ]:        120 :     FreeResource();
     111                 :            : 
     112         [ +  - ]:        120 :     updateImages( rResId );
     113                 :        120 : }
     114                 :            : 
     115                 :            : // -----------------------------------------------------------------------
     116                 :            : 
     117                 :            : // Destructor; releases the internal data
     118                 :            : 
     119                 :        120 : SfxStyleFamilies::~SfxStyleFamilies()
     120                 :            : {
     121         [ +  + ]:        714 :     for ( size_t i = 0, n = aEntryList.size(); i < n; ++i )
     122 [ +  - ][ +  - ]:        594 :         delete aEntryList[ i ];
     123                 :        120 :     aEntryList.clear();
     124                 :        120 : }
     125                 :            : 
     126                 :            : 
     127                 :            : // -----------------------------------------------------------------------
     128                 :            : 
     129                 :        240 : sal_Bool SfxStyleFamilies::updateImages( const ResId& _rId )
     130                 :            : {
     131                 :        240 :     sal_Bool bSuccess = sal_False;
     132                 :            : 
     133                 :            :     {
     134         [ +  - ]:        240 :         ::svt::OLocalResourceAccess aLocalRes( _rId );
     135                 :            : 
     136                 :            :         // check if the image list is present
     137                 :        240 :         ResId aImageListId( (sal_uInt16) 1, *_rId.GetResMgr() );
     138                 :        240 :         aImageListId.SetRT( RSC_IMAGELIST );
     139                 :            : 
     140 [ +  - ][ +  - ]:        240 :         if ( aLocalRes.IsAvailableRes( aImageListId ) )
     141                 :            :         {   // there is such a list
     142         [ +  - ]:        240 :             ImageList aImages( aImageListId );
     143                 :            : 
     144                 :            :             // number of styles items/images
     145         [ +  - ]:        240 :             sal_uInt16 nCount = aImages.GetImageCount( );
     146                 :            :             DBG_ASSERT( aEntryList.size() == nCount, "SfxStyleFamilies::updateImages: found the image list, but missing some bitmaps!" );
     147         [ -  + ]:        240 :             if ( nCount > aEntryList.size() )
     148                 :          0 :                 nCount = aEntryList.size();
     149                 :            : 
     150                 :            :             // set the images on the items
     151         [ +  + ]:       1428 :             for ( size_t i = 0; i < nCount; ++i )
     152                 :            :             {
     153                 :       1188 :                 SfxStyleFamilyItem* pItem = aEntryList[ i ];
     154 [ +  - ][ +  - ]:       1188 :                 pItem->SetImage( aImages.GetImage( aImages.GetImageId( i ) ) );
         [ +  - ][ +  - ]
     155                 :            :             }
     156                 :            : 
     157         [ +  - ]:        240 :             bSuccess = sal_True;
     158         [ +  - ]:        240 :         }
     159                 :            :     }
     160                 :            : 
     161                 :        240 :     return bSuccess;
     162                 :            : }
     163                 :            : 
     164                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10