LCOV - code coverage report
Current view: top level - libreoffice/svx/source/form - formtoolbars.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 30 0.0 %
Date: 2012-12-27 Functions: 0 4 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             : #include "formtoolbars.hxx"
      21             : 
      22             : #include <com/sun/star/beans/XPropertySet.hpp>
      23             : 
      24             : #include <svx/svxids.hrc>
      25             : 
      26             : //........................................................................
      27             : namespace svxform
      28             : {
      29             : //........................................................................
      30             : 
      31             :     using namespace ::com::sun::star::uno;
      32             :     using namespace ::com::sun::star::frame;
      33             :     using namespace ::com::sun::star::beans;
      34             :     using namespace ::com::sun::star::frame;
      35             : 
      36             :     //====================================================================
      37             :     //= FormToolboxes
      38             :     //====================================================================
      39             :     //--------------------------------------------------------------------
      40           0 :     FormToolboxes::FormToolboxes( const Reference< XFrame >& _rxFrame )
      41             :     {
      42             :         // the layout manager
      43           0 :         Reference< XPropertySet > xFrameProps( _rxFrame, UNO_QUERY );
      44           0 :         if ( xFrameProps.is() )
      45           0 :             xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ) >>= m_xLayouter;
      46           0 :     }
      47             : 
      48             :     //--------------------------------------------------------------------
      49           0 :     void FormToolboxes::toggleToolbox( sal_uInt16 _nSlotId ) const
      50             :     {
      51             :         try
      52             :         {
      53           0 :             Reference< XLayoutManager > xManager( m_xLayouter );
      54             :             OSL_ENSURE( xManager. is(), "FormToolboxes::toggleToolbox: couldn't obtain the layout manager!" );
      55           0 :             if ( xManager. is() )
      56             :             {
      57           0 :                 ::rtl::OUString sToolboxResource( getToolboxResourceName( _nSlotId ) );
      58           0 :                 if ( xManager->isElementVisible( sToolboxResource ) )
      59             :                 {
      60           0 :                     xManager->hideElement( sToolboxResource );
      61           0 :                     xManager->destroyElement( sToolboxResource );
      62             :                 }
      63             :                 else
      64             :                 {
      65           0 :                     xManager->createElement( sToolboxResource );
      66           0 :                     xManager->showElement( sToolboxResource );
      67           0 :                 }
      68           0 :             }
      69             :         }
      70           0 :         catch( const Exception& )
      71             :         {
      72             :             OSL_FAIL( "FormToolboxes::toggleToolbox: caught an exception!" );
      73             :         }
      74           0 :     }
      75             : 
      76             :     //--------------------------------------------------------------------
      77           0 :     bool FormToolboxes::isToolboxVisible( sal_uInt16 _nSlotId ) const
      78             :     {
      79           0 :         return m_xLayouter.is() && m_xLayouter->isElementVisible(
      80           0 :             getToolboxResourceName( _nSlotId ) );
      81             :     }
      82             : 
      83             :     //--------------------------------------------------------------------
      84           0 :     ::rtl::OUString FormToolboxes::getToolboxResourceName( sal_uInt16 _nSlotId ) const
      85             :     {
      86             :         OSL_ENSURE( ( _nSlotId == SID_FM_MORE_CONTROLS ) || ( _nSlotId == SID_FM_FORM_DESIGN_TOOLS ) || ( _nSlotId == SID_FM_CONFIG ),
      87             :             "FormToolboxes::getToolboxResourceName: unsupported slot!" );
      88             : 
      89           0 :         const sal_Char* pToolBarName = "formcontrols";
      90           0 :         if ( _nSlotId == SID_FM_MORE_CONTROLS )
      91           0 :             pToolBarName = "moreformcontrols";
      92           0 :         else if ( _nSlotId == SID_FM_FORM_DESIGN_TOOLS )
      93           0 :             pToolBarName = "formdesign";
      94             : 
      95           0 :         ::rtl::OUString aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" ));
      96           0 :         aToolBarResStr += ::rtl::OUString::createFromAscii( pToolBarName );
      97           0 :         return aToolBarResStr;
      98             :     }
      99             : 
     100             : //........................................................................
     101             : } // namespace svxform
     102             : //........................................................................
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10