update dev300-m58
[ooovba.git] / svx / source / form / formtoolbars.cxx
blob0329eabfa2b8c8fd1dac713c58c69f8e158e45a6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: formtoolbars.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include "formtoolbars.hxx"
35 /** === begin UNO includes === **/
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 /** === end UNO includes === **/
39 #ifndef _SVX_SVXIDS_HRC
40 #include <svx/svxids.hrc>
41 #endif
43 //........................................................................
44 namespace svxform
46 //........................................................................
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::frame;
50 using namespace ::com::sun::star::beans;
51 using namespace ::com::sun::star::frame;
53 //====================================================================
54 //= FormToolboxes
55 //====================================================================
56 //--------------------------------------------------------------------
57 FormToolboxes::FormToolboxes( const Reference< XFrame >& _rxFrame )
59 // the layout manager
60 Reference< XPropertySet > xFrameProps( _rxFrame, UNO_QUERY );
61 if ( xFrameProps.is() )
62 xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ) >>= m_xLayouter;
65 //--------------------------------------------------------------------
66 void FormToolboxes::toggleToolbox( USHORT _nSlotId ) const
68 try
70 Reference< XLayoutManager > xManager( m_xLayouter );
71 OSL_ENSURE( xManager. is(), "FormToolboxes::toggleToolbox: couldn't obtain the layout manager!" );
72 if ( xManager. is() )
74 ::rtl::OUString sToolboxResource( getToolboxResourceName( _nSlotId ) );
75 if ( xManager->isElementVisible( sToolboxResource ) )
77 xManager->hideElement( sToolboxResource );
78 xManager->destroyElement( sToolboxResource );
80 else
82 xManager->createElement( sToolboxResource );
83 xManager->showElement( sToolboxResource );
87 catch( const Exception& )
89 OSL_ENSURE( sal_False, "FormToolboxes::toggleToolbox: caught an exception!" );
93 //--------------------------------------------------------------------
94 bool FormToolboxes::isToolboxVisible( USHORT _nSlotId ) const
96 return m_xLayouter.is() && m_xLayouter->isElementVisible(
97 getToolboxResourceName( _nSlotId ) );
100 //--------------------------------------------------------------------
101 ::rtl::OUString FormToolboxes::getToolboxResourceName( USHORT _nSlotId ) const
103 OSL_ENSURE( ( _nSlotId == SID_FM_MORE_CONTROLS ) || ( _nSlotId == SID_FM_FORM_DESIGN_TOOLS ) || ( _nSlotId == SID_FM_CONFIG ),
104 "FormToolboxes::getToolboxResourceName: unsupported slot!" );
106 const sal_Char* pToolBarName = "formcontrols";
107 if ( _nSlotId == SID_FM_MORE_CONTROLS )
108 pToolBarName = "moreformcontrols";
109 else if ( _nSlotId == SID_FM_FORM_DESIGN_TOOLS )
110 pToolBarName = "formdesign";
112 ::rtl::OUString aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" ));
113 aToolBarResStr += ::rtl::OUString::createFromAscii( pToolBarName );
114 return aToolBarResStr;
117 //........................................................................
118 } // namespace svxform
119 //........................................................................