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

Generated by: LCOV version 1.10