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

Generated by: LCOV version 1.10