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

Generated by: LCOV version 1.10