LCOV - code coverage report
Current view: top level - sfx2/source/dialog - tplcitem.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 66 1.5 %
Date: 2014-11-03 Functions: 2 8 25.0 %
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 <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           0 : 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           0 :     nUserEventId(0)
      45             : {
      46           0 : }
      47             : 
      48           0 : SfxTemplateControllerItem::~SfxTemplateControllerItem()
      49             : {
      50           0 :     if(nUserEventId)
      51           0 :         Application::RemoveUserEvent(nUserEventId);
      52           0 : }
      53             : 
      54             : 
      55             : // Notice about change of status, is  propagated through the Controller
      56             : // passed on by the constructor
      57             : 
      58           0 : void SfxTemplateControllerItem::StateChanged( sal_uInt16 nSID, SfxItemState eState,
      59             :                                               const SfxPoolItem* pItem )
      60             : {
      61           0 :     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           0 :             bool bAvailable = SfxItemState::DEFAULT == eState;
      70           0 :             if ( !bAvailable )
      71           0 :                 rTemplateDlg.SetFamilyState(GetId(), 0);
      72             :             else {
      73           0 :                 const SfxTemplateItem *pStateItem = PTR_CAST(
      74             :                     SfxTemplateItem, pItem);
      75             :                 DBG_ASSERT(pStateItem != 0, "SfxTemplateItem expected");
      76           0 :                 rTemplateDlg.SetFamilyState( GetId(), pStateItem );
      77             :             }
      78           0 :             bool bDisable = eState == SfxItemState::DISABLED;
      79             :             // Disable Familly
      80           0 :             sal_uInt16 nFamily = 0;
      81           0 :             switch( GetId())
      82             :             {
      83             :                 case SID_STYLE_FAMILY1:
      84           0 :                     nFamily = 1; break;
      85             :                 case SID_STYLE_FAMILY2:
      86           0 :                     nFamily = 2; break;
      87             :                 case SID_STYLE_FAMILY3:
      88           0 :                     nFamily = 3; break;
      89             :                 case SID_STYLE_FAMILY4:
      90           0 :                     nFamily = 4; break;
      91             :                 case SID_STYLE_FAMILY5:
      92           0 :                     nFamily = 5; break;
      93             : 
      94           0 :                 default: OSL_FAIL("unknown StyleFamily"); break;
      95             :             }
      96           0 :             rTemplateDlg.EnableFamilyItem( nFamily, !bDisable );
      97           0 :             break;
      98             :         }
      99             :         case SID_STYLE_WATERCAN:
     100             :         {
     101           0 :             if ( eState == SfxItemState::DISABLED )
     102           0 :                 nWaterCanState = 0xff;
     103           0 :             else if( eState == SfxItemState::DEFAULT )
     104             :             {
     105           0 :                 const SfxBoolItem *pStateItem = PTR_CAST(SfxBoolItem, pItem);
     106             :                 assert(pStateItem); //BoolItem expected
     107           0 :                 if (pStateItem)
     108           0 :                     nWaterCanState = pStateItem->GetValue() ? 1 : 0;
     109             :                 else
     110           0 :                     nWaterCanState = 0xff;
     111             :             }
     112             :             //not necessary if the last event is still on the way
     113           0 :             if(!nUserEventId)
     114             :                 nUserEventId = Application::PostUserEvent( STATIC_LINK(
     115           0 :                             this, SfxTemplateControllerItem, SetWaterCanStateHdl_Impl ) );
     116           0 :             break;
     117             :         }
     118             :         case SID_STYLE_EDIT:
     119           0 :             rTemplateDlg.EnableEdit( SfxItemState::DISABLED != eState );
     120           0 :             break;
     121             :         case SID_STYLE_DELETE:
     122           0 :             rTemplateDlg.EnableDel( SfxItemState::DISABLED != eState );
     123           0 :             break;
     124             :         case SID_STYLE_HIDE:
     125           0 :             rTemplateDlg.EnableHide( SfxItemState::DISABLED != eState );
     126           0 :             break;
     127             :         case SID_STYLE_SHOW:
     128           0 :             rTemplateDlg.EnableShow( SfxItemState::DISABLED != eState );
     129           0 :             break;
     130             :         case SID_STYLE_NEW_BY_EXAMPLE:
     131             : 
     132             :             rTemplateDlg.EnableExample_Impl(
     133           0 :                 GetId(), SfxItemState::DISABLED != eState );
     134           0 :             break;
     135             :         case SID_STYLE_UPDATE_BY_EXAMPLE:
     136             :         {
     137             :             rTemplateDlg.EnableExample_Impl(
     138           0 :                 GetId(), eState != SfxItemState::DISABLED );
     139           0 :             break;
     140             :         }
     141             :         case SID_STYLE_NEW:
     142             :         {
     143           0 :             rTemplateDlg.EnableNew( SfxItemState::DISABLED != eState );
     144           0 :             break;
     145             :         }
     146             :         case SID_STYLE_DRAGHIERARCHIE:
     147             :         {
     148           0 :             rTemplateDlg.EnableTreeDrag( SfxItemState::DISABLED != eState );
     149           0 :             break;
     150             :         }
     151             :         case SID_STYLE_FAMILY :
     152             :         {
     153           0 :             const SfxUInt16Item *pStateItem = PTR_CAST( SfxUInt16Item, pItem);
     154           0 :             if (pStateItem)
     155           0 :                 rTemplateDlg.SetFamily( pStateItem->GetValue() );
     156           0 :             break;
     157             :         }
     158             :     }
     159           0 : }
     160             : 
     161           0 : IMPL_STATIC_LINK(SfxTemplateControllerItem, SetWaterCanStateHdl_Impl,
     162             :                                     SfxTemplateControllerItem*, EMPTYARG)
     163             : {
     164           0 :     pThis->nUserEventId = 0;
     165           0 :     SfxBoolItem* pState = 0;
     166           0 :     switch(pThis->nWaterCanState)
     167             :     {
     168             :         case 0 :
     169             :         case 1 :
     170           0 :             pState = new SfxBoolItem(SID_STYLE_WATERCAN, pThis->nWaterCanState ? sal_True : sal_False);
     171           0 :         break;
     172             :     }
     173           0 :     pThis->rTemplateDlg.SetWaterCanState(pState);
     174           0 :     delete pState;
     175           0 :     return 0;
     176         951 : }
     177             : 
     178             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10