LCOV - code coverage report
Current view: top level - sfx2/source/dialog - tplcitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 57 59 96.6 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 38 56 67.9 %

           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 <svl/intitem.hxx>
      21                 :            : #include <vcl/svapp.hxx>
      22                 :            : 
      23                 :            : #include <sfx2/templdlg.hxx>
      24                 :            : #include <sfx2/bindings.hxx>
      25                 :            : #include "sfx2/tplpitem.hxx"
      26                 :            : #include "tplcitem.hxx"
      27                 :            : #include "templdgi.hxx"
      28                 :            : 
      29                 :            : #include <sfx2/sfx.hrc>
      30                 :            : #include "dialog.hrc"
      31                 :            : 
      32                 :            : // STATIC DATA -----------------------------------------------------------
      33                 :            : 
      34                 :            : // Constructor
      35                 :            : 
      36                 :       1554 : SfxTemplateControllerItem::SfxTemplateControllerItem(
      37                 :            :         sal_uInt16 nSlotId,                 // ID
      38                 :            :         SfxCommonTemplateDialog_Impl &rDlg,  // Controller-Instance,
      39                 :            :                                              // which is assigned to this item.
      40                 :            :         SfxBindings &rBindings):
      41                 :            :     SfxControllerItem(nSlotId, rBindings),
      42                 :            :     rTemplateDlg(rDlg),
      43                 :            :     nWaterCanState(0xff),
      44                 :       1554 :     nUserEventId(0)
      45                 :            : {
      46                 :       1554 : }
      47                 :            : // -----------------------------------------------------------------------
      48                 :       1554 : SfxTemplateControllerItem::~SfxTemplateControllerItem()
      49                 :            : {
      50         [ -  + ]:       1554 :     if(nUserEventId)
      51         [ #  # ]:          0 :         Application::RemoveUserEvent(nUserEventId);
      52         [ -  + ]:       3108 : }
      53                 :            : 
      54                 :            : // -----------------------------------------------------------------------
      55                 :            : // Notice about change of status, is  propagated through the Controller
      56                 :            : // passed on by the constructor
      57                 :            : 
      58                 :       2543 : void SfxTemplateControllerItem::StateChanged( sal_uInt16 nSID, SfxItemState eState,
      59                 :            :                                               const SfxPoolItem* pItem )
      60                 :            : {
      61   [ +  +  +  +  :       2543 :     switch(nSID)
          +  +  +  +  +  
                      - ]
      62                 :            :     {
      63                 :            :         case SID_STYLE_FAMILY1:
      64                 :            :         case SID_STYLE_FAMILY2:
      65                 :            :         case SID_STYLE_FAMILY3:
      66                 :            :         case SID_STYLE_FAMILY4:
      67                 :            :         case SID_STYLE_FAMILY5:
      68                 :            :         {
      69                 :        594 :             bool bAvailable = SFX_ITEM_AVAILABLE == eState;
      70         [ +  + ]:        594 :             if ( !bAvailable )
      71                 :        120 :                 rTemplateDlg.SetFamilyState(GetId(), 0);
      72                 :            :             else {
      73 [ +  - ][ +  - ]:        474 :                 const SfxTemplateItem *pStateItem = PTR_CAST(
      74                 :            :                     SfxTemplateItem, pItem);
      75                 :            :                 DBG_ASSERT(pStateItem != 0, "SfxTemplateItem expected");
      76                 :        474 :                 rTemplateDlg.SetFamilyState( GetId(), pStateItem );
      77                 :            :             }
      78                 :        594 :             sal_Bool bDisable = eState == SFX_ITEM_DISABLED;
      79                 :            :             // Disable Familly
      80                 :        594 :             sal_uInt16 nFamily = 0;
      81   [ +  +  +  +  :        594 :             switch( GetId())
                   +  - ]
      82                 :            :             {
      83                 :            :                 case SID_STYLE_FAMILY1:
      84                 :        118 :                     nFamily = 1; break;
      85                 :            :                 case SID_STYLE_FAMILY2:
      86                 :        120 :                     nFamily = 2; break;
      87                 :            :                 case SID_STYLE_FAMILY3:
      88                 :        118 :                     nFamily = 3; break;
      89                 :            :                 case SID_STYLE_FAMILY4:
      90                 :        118 :                     nFamily = 4; break;
      91                 :            :                 case SID_STYLE_FAMILY5:
      92                 :        120 :                     nFamily = 5; break;
      93                 :            : 
      94                 :          0 :                 default: OSL_FAIL("unknown StyleFamily"); break;
      95                 :            :             }
      96                 :        594 :             rTemplateDlg.EnableFamilyItem( nFamily, !bDisable );
      97                 :        594 :             break;
      98                 :            :         }
      99                 :            :         case SID_STYLE_WATERCAN:
     100                 :            :         {
     101         [ +  + ]:        327 :             if ( eState == SFX_ITEM_DISABLED )
     102                 :        236 :                 nWaterCanState = 0xff;
     103         [ +  - ]:         91 :             else if( eState == SFX_ITEM_AVAILABLE )
     104                 :            :             {
     105 [ +  - ][ +  - ]:         91 :                 const SfxBoolItem *pStateItem = PTR_CAST(SfxBoolItem, pItem);
     106                 :            :                 DBG_ASSERT(pStateItem != 0, "BoolItem expected");
     107         [ -  + ]:         91 :                 nWaterCanState = pStateItem->GetValue() ? 1 : 0;
     108                 :            :             }
     109                 :            :             //not necessary if the last event is still on the way
     110         [ +  + ]:        327 :             if(!nUserEventId)
     111                 :            :                 nUserEventId = Application::PostUserEvent( STATIC_LINK(
     112         [ +  - ]:        205 :                             this, SfxTemplateControllerItem, SetWaterCanStateHdl_Impl ) );
     113                 :        327 :             break;
     114                 :            :         }
     115                 :            :         case SID_STYLE_EDIT:
     116                 :        120 :             rTemplateDlg.EnableEdit( SFX_ITEM_DISABLED != eState );
     117                 :        120 :             break;
     118                 :            :         case SID_STYLE_DELETE:
     119                 :        120 :             rTemplateDlg.EnableDel( SFX_ITEM_DISABLED != eState );
     120                 :        120 :             break;
     121                 :            :         case SID_STYLE_NEW_BY_EXAMPLE:
     122                 :            : 
     123                 :            :             rTemplateDlg.EnableExample_Impl(
     124                 :        327 :                 GetId(), SFX_ITEM_DISABLED != eState );
     125                 :        327 :             break;
     126                 :            :         case SID_STYLE_UPDATE_BY_EXAMPLE:
     127                 :            :         {
     128                 :            :             rTemplateDlg.EnableExample_Impl(
     129                 :        327 :                 GetId(), eState != SFX_ITEM_DISABLED );
     130                 :        327 :             break;
     131                 :            :         }
     132                 :            :         case SID_STYLE_NEW:
     133                 :            :         {
     134                 :        244 :             rTemplateDlg.EnableNew( SFX_ITEM_DISABLED != eState );
     135                 :        244 :             break;
     136                 :            :         }
     137                 :            :         case SID_STYLE_DRAGHIERARCHIE:
     138                 :            :         {
     139                 :        244 :             rTemplateDlg.EnableTreeDrag( SFX_ITEM_DISABLED != eState );
     140                 :        244 :             break;
     141                 :            :         }
     142                 :            :         case SID_STYLE_FAMILY :
     143                 :            :         {
     144 [ +  - ][ +  - ]:        240 :             const SfxUInt16Item *pStateItem = PTR_CAST( SfxUInt16Item, pItem);
     145         [ +  - ]:        240 :             if (pStateItem)
     146                 :        240 :                 rTemplateDlg.SetFamily( pStateItem->GetValue() );
     147                 :        240 :             break;
     148                 :            :         }
     149                 :            :     }
     150                 :       2543 : }
     151                 :            : 
     152                 :        205 : IMPL_STATIC_LINK(SfxTemplateControllerItem, SetWaterCanStateHdl_Impl,
     153                 :            :                                     SfxTemplateControllerItem*, EMPTYARG)
     154                 :            : {
     155                 :        205 :     pThis->nUserEventId = 0;
     156                 :        205 :     SfxBoolItem* pState = 0;
     157         [ +  + ]:        205 :     switch(pThis->nWaterCanState)
     158                 :            :     {
     159                 :            :         case 0 :
     160                 :            :         case 1 :
     161 [ -  + ][ +  - ]:         87 :             pState = new SfxBoolItem(SID_STYLE_WATERCAN, pThis->nWaterCanState ? sal_True : sal_False);
     162                 :         87 :         break;
     163                 :            :     }
     164                 :        205 :     pThis->rTemplateDlg.SetWaterCanState(pState);
     165         [ +  + ]:        205 :     delete pState;
     166                 :        205 :     return 0;
     167                 :            : }
     168                 :            : 
     169                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10