LCOV - code coverage report
Current view: top level - svx/source/tbxctrls - tbxdrctl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 15 32 46.9 %
Date: 2015-06-13 12:38:46 Functions: 6 9 66.7 %
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             : 
      21             : #include <string>
      22             : 
      23             : #include <svl/aeitem.hxx>
      24             : #include <sfx2/dispatch.hxx>
      25             : #include <sfx2/viewsh.hxx>
      26             : #include <sfx2/imagemgr.hxx>
      27             : #include <sfx2/viewfrm.hxx>
      28             : #include <vcl/toolbox.hxx>
      29             : 
      30             : #include <svx/dialmgr.hxx>
      31             : #include <svx/dialogs.hrc>
      32             : 
      33             : #include "svx/tbxctl.hxx"
      34             : #include "svx/tbxcolor.hxx"
      35             : #include <com/sun/star/frame/XLayoutManager.hpp>
      36             : 
      37         617 : SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw, SfxAllEnumItem);
      38             : 
      39             : using namespace ::com::sun::star::uno;
      40             : using namespace ::com::sun::star::frame;
      41             : 
      42             : 
      43             : 
      44         506 : SvxTbxCtlDraw::SvxTbxCtlDraw( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
      45             : 
      46             :     SfxToolBoxControl( nSlotId, nId, rTbx ),
      47             : 
      48         506 :     m_sToolboxName( "private:resource/toolbar/drawbar" )
      49             : 
      50             : {
      51         506 :     rTbx.SetItemBits( nId, ToolBoxItemBits::CHECKABLE | rTbx.GetItemBits( nId ) );
      52         506 :     rTbx.Invalidate();
      53         506 : }
      54             : 
      55             : 
      56             : 
      57         796 : void SvxTbxCtlDraw::StateChanged( sal_uInt16 nSID, SfxItemState eState,
      58             :                                   const SfxPoolItem* pState )
      59             : {
      60         796 :     GetToolBox().EnableItem( GetId(), ( eState != SfxItemState::DISABLED ) );
      61         796 :     SfxToolBoxControl::StateChanged( nSID, eState, pState );
      62             : 
      63         796 :     Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
      64         796 :     if ( xLayoutMgr.is() )
      65         796 :         GetToolBox().CheckItem(
      66        1592 :             GetId(), xLayoutMgr->isElementVisible( m_sToolboxName ) != sal_False );
      67         796 : }
      68             : 
      69             : 
      70             : 
      71           0 : SfxPopupWindowType SvxTbxCtlDraw::GetPopupWindowType() const
      72             : {
      73           0 :     return SfxPopupWindowType::ONCLICK;
      74             : }
      75             : 
      76             : 
      77             : 
      78           0 : void SvxTbxCtlDraw::toggleToolbox()
      79             : {
      80           0 :     Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
      81           0 :     if ( xLayoutMgr.is() )
      82             :     {
      83           0 :         bool bCheck = false;
      84           0 :         if ( xLayoutMgr->isElementVisible( m_sToolboxName ) )
      85             :         {
      86           0 :             xLayoutMgr->hideElement( m_sToolboxName );
      87           0 :             xLayoutMgr->destroyElement( m_sToolboxName );
      88             :         }
      89             :         else
      90             :         {
      91           0 :             bCheck = true;
      92           0 :             xLayoutMgr->createElement( m_sToolboxName );
      93           0 :             xLayoutMgr->showElement( m_sToolboxName );
      94             :         }
      95             : 
      96           0 :         GetToolBox().CheckItem( GetId(), bCheck );
      97           0 :     }
      98           0 : }
      99             : 
     100             : 
     101             : 
     102           0 : void SvxTbxCtlDraw::Select(sal_uInt16 /*nSelectModifier*/)
     103             : {
     104           0 :     toggleToolbox();
     105         390 : }
     106             : 
     107             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11