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

Generated by: LCOV version 1.11