LCOV - code coverage report
Current view: top level - svx/source/customshapes - tbxcustomshapes.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 34 58 58.6 %
Date: 2015-06-13 12:38:46 Functions: 8 13 61.5 %
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 <svx/svxids.hrc>
      24             : #include <svl/eitem.hxx>
      25             : #include <sfx2/dispatch.hxx>
      26             : #include <sfx2/viewsh.hxx>
      27             : #include <sfx2/viewfrm.hxx>
      28             : #include <vcl/toolbox.hxx>
      29             : #include <osl/mutex.hxx>
      30             : 
      31             : #include <sfx2/imagemgr.hxx>
      32             : #include <vcl/svapp.hxx>
      33             : #include "svx/tbxcustomshapes.hxx"
      34             : 
      35        1664 : SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlCustomShapes, SfxBoolItem);
      36             : 
      37         974 : SvxTbxCtlCustomShapes::SvxTbxCtlCustomShapes( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
      38             :     SfxToolBoxControl( nSlotId, nId, rTbx ),
      39         974 :     m_aSubTbxResName( "private:resource/toolbar/" )
      40             : {
      41         974 :     switch( nSlotId )
      42             :     {
      43             :         default :
      44             :             DBG_ASSERT( false, "SvxTbxCtlCustomShapes: unknown slot executed. ?" );
      45             :             //fall-through
      46             :         case SID_DRAWTBX_CS_BASIC :
      47             :         {
      48         584 :             m_aCommand = ".uno:BasicShapes.diamond";
      49         584 :             m_aSubTbName = "basicshapes";
      50             :         }
      51         584 :         break;
      52             : 
      53             :         case SID_DRAWTBX_CS_SYMBOL :
      54             :         {
      55          78 :             m_aCommand = ".uno:SymbolShapes.smiley";
      56          78 :             m_aSubTbName = "symbolshapes";
      57             :         }
      58          78 :         break;
      59             : 
      60             :         case SID_DRAWTBX_CS_ARROW :
      61             :         {
      62          78 :             m_aCommand = ".uno:ArrowShapes.left-right-arrow";
      63          78 :             m_aSubTbName = "arrowshapes";
      64             :         }
      65          78 :         break;
      66             :         case SID_DRAWTBX_CS_FLOWCHART :
      67             :         {
      68          78 :             m_aCommand = ".uno:FlowChartShapes.flowchart-internal-storage";
      69          78 :             m_aSubTbName = "flowchartshapes";
      70             :         }
      71          78 :         break;
      72             :         case SID_DRAWTBX_CS_CALLOUT :
      73             :         {
      74          78 :             m_aCommand = ".uno:CalloutShapes.round-rectangular-callout";
      75          78 :             m_aSubTbName = "calloutshapes";
      76             :         }
      77          78 :         break;
      78             :         case SID_DRAWTBX_CS_STAR :
      79             :         {
      80          78 :             m_aCommand = ".uno:StarShapes.star5";
      81          78 :             m_aSubTbName = "starshapes";
      82             :         }
      83          78 :         break;
      84             :     }
      85         974 :     m_aSubTbxResName += m_aSubTbName;
      86         974 :     rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
      87         974 :     rTbx.Invalidate();
      88         974 : }
      89             : 
      90             : // Notification when the application status has changed
      91        1360 : void SvxTbxCtlCustomShapes::StateChanged( sal_uInt16 nSID, SfxItemState eState,
      92             :                                   const SfxPoolItem* pState )
      93             : {
      94        1360 :     SfxToolBoxControl::StateChanged( nSID, eState, pState );
      95        1360 : }
      96             : 
      97             : // when one wants to create a popup window
      98           0 : SfxPopupWindowType SvxTbxCtlCustomShapes::GetPopupWindowType() const
      99             : {
     100           0 :     return( m_aCommand.isEmpty() ? SfxPopupWindowType::ONCLICK : SfxPopupWindowType::ONTIMEOUT);
     101             : }
     102             : 
     103             : // Here is the window created
     104             : // The location of the Toolbox is queried through GetToolBox()
     105             : // rItemRect are the screen coordinates
     106           0 : VclPtr<SfxPopupWindow> SvxTbxCtlCustomShapes::CreatePopupWindow()
     107             : {
     108           0 :     createAndPositionSubToolBar( m_aSubTbxResName );
     109           0 :     return NULL;
     110             : }
     111             : 
     112             : 
     113             : 
     114           0 : void SvxTbxCtlCustomShapes::Select(sal_uInt16 nSelectModifier)
     115             : {
     116           0 :      if ( !m_aCommand.isEmpty() )
     117             :     {
     118           0 :         com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aParamSeq( 1 );
     119           0 :         aParamSeq[0].Name = "KeyModifier";
     120           0 :         aParamSeq[0].Value <<= static_cast< sal_Int16 >( nSelectModifier );
     121           0 :         Dispatch( m_aCommand, aParamSeq );
     122             :     }
     123           0 : }
     124             : 
     125             : 
     126         872 : sal_Bool SAL_CALL SvxTbxCtlCustomShapes::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException, std::exception)
     127             : {
     128             :     // We control a sub-toolbar therefore we have to return true.
     129         872 :     return sal_True;
     130             : }
     131             : 
     132         974 : OUString SAL_CALL SvxTbxCtlCustomShapes::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException, std::exception)
     133             : {
     134             :     // Provide the controlled sub-toolbar name, so we are notified whenever
     135             :     // this toolbar executes a function.
     136         974 :     return m_aSubTbName;
     137             : }
     138             : 
     139           0 : void SAL_CALL SvxTbxCtlCustomShapes::functionSelected( const OUString& rCommand ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     140             : {
     141             :     // remember the new command
     142           0 :     m_aCommand = rCommand;
     143             : 
     144             :     // Our sub-toolbar wants to execute a function.
     145             :     // We have to change the image of our toolbar button to reflect the new function.
     146           0 :     updateImage();
     147           0 : }
     148             : 
     149           0 : void SAL_CALL SvxTbxCtlCustomShapes::updateImage(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     150             : {
     151             :     // We should update the button image of our parent (toolbar).
     152             :     // Use the stored command to set the correct current image.
     153           0 :     SolarMutexGuard aGuard;
     154           0 :     if ( !m_aCommand.isEmpty() )
     155             :     {
     156           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
     157           0 :         Image aImage = GetImage( xFrame, m_aCommand, hasBigImages() );
     158           0 :         if ( !!aImage )
     159           0 :             GetToolBox().SetItemImage( GetId(), aImage );
     160           0 :     }
     161         390 : }
     162             : 
     163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11