LCOV - code coverage report
Current view: top level - sc/source/ui/cctrl - tbinsert.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 43 4.7 %
Date: 2014-11-03 Functions: 3 11 27.3 %
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 <string>
      21             : 
      22             : #include <svl/intitem.hxx>
      23             : #include <sfx2/dispatch.hxx>
      24             : #include <sfx2/viewsh.hxx>
      25             : #include <sfx2/viewfrm.hxx>
      26             : #include <sfx2/imagemgr.hxx>
      27             : #include <vcl/toolbox.hxx>
      28             : 
      29             : #include "tbinsert.hxx"
      30             : #include "tbinsert.hrc"
      31             : #include "global.hxx"
      32             : #include "scmod.hxx"
      33             : #include "scresid.hxx"
      34             : #include "sc.hrc"
      35             : 
      36         228 : SFX_IMPL_TOOLBOX_CONTROL( ScTbxInsertCtrl, SfxUInt16Item);
      37             : 
      38             : //  ToolBox - Controller
      39             : 
      40           0 : ScTbxInsertCtrl::ScTbxInsertCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx  ) :
      41             :         SfxToolBoxControl( nSlotId, nId, rTbx ),
      42           0 :         nLastSlotId(0)
      43             : {
      44           0 :     rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
      45           0 : }
      46             : 
      47           0 : ScTbxInsertCtrl::~ScTbxInsertCtrl()
      48             : {
      49           0 : }
      50             : 
      51           0 : void ScTbxInsertCtrl::StateChanged( sal_uInt16 /* nSID */, SfxItemState eState,
      52             :                                               const SfxPoolItem* pState )
      53             : {
      54           0 :     GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SfxItemState::DISABLED) );
      55             : 
      56           0 :     if( eState == SfxItemState::DEFAULT )
      57             :     {
      58             : 
      59           0 :         const SfxUInt16Item* pItem = PTR_CAST( SfxUInt16Item, pState );
      60           0 :         if(pItem)
      61             :         {
      62           0 :             nLastSlotId = pItem->GetValue();
      63           0 :             sal_uInt16 nImageId = nLastSlotId ? nLastSlotId : GetSlotId();
      64           0 :             OUString aSlotURL( "slot:" );
      65           0 :             aSlotURL += OUString::number( nImageId);
      66             :             Image aImage = GetImage( m_xFrame,
      67             :                                      aSlotURL,
      68           0 :                                      hasBigImages()
      69           0 :                                      );
      70           0 :             GetToolBox().SetItemImage(GetId(), aImage);
      71             :         }
      72             :     }
      73           0 : }
      74             : 
      75           0 : SfxPopupWindow* ScTbxInsertCtrl::CreatePopupWindow()
      76             : {
      77           0 :     sal_uInt16 nSlotId = GetSlotId();
      78           0 :     if (nSlotId == SID_TBXCTL_INSERT)
      79             :     {
      80           0 :         OUString aInsertBarResStr( "private:resource/toolbar/insertbar" );
      81           0 :         createAndPositionSubToolBar( aInsertBarResStr );
      82             :     }
      83           0 :     else if (nSlotId == SID_TBXCTL_INSCELLS)
      84             :     {
      85           0 :         OUString aInsertCellsBarResStr( "private:resource/toolbar/insertcellsbar" );
      86           0 :         createAndPositionSubToolBar( aInsertCellsBarResStr );
      87             :     }
      88             :     else
      89             :     {
      90           0 :         OUString aInsertObjectBarResStr( "private:resource/toolbar/insertobjectbar" );
      91           0 :         createAndPositionSubToolBar( aInsertObjectBarResStr );
      92             :     }
      93           0 :     return NULL;
      94             : }
      95             : 
      96           0 : SfxPopupWindowType ScTbxInsertCtrl::GetPopupWindowType() const
      97             : {
      98           0 :     return nLastSlotId ? SFX_POPUPWINDOW_ONTIMEOUT : SFX_POPUPWINDOW_ONCLICK;
      99             : }
     100             : 
     101           0 : void ScTbxInsertCtrl::Select( bool /* bMod1 */ )
     102             : {
     103           0 :     SfxViewShell*   pCurSh( SfxViewShell::Current() );
     104           0 :     SfxDispatcher*  pDispatch( 0 );
     105             : 
     106           0 :     if ( pCurSh )
     107             :     {
     108           0 :         SfxViewFrame*   pViewFrame = pCurSh->GetViewFrame();
     109           0 :         if ( pViewFrame )
     110           0 :             pDispatch = pViewFrame->GetDispatcher();
     111             :     }
     112             : 
     113           0 :     if ( pDispatch )
     114           0 :         pDispatch->Execute(nLastSlotId);
     115         228 : }
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10