bump product version to 7.2.5.1
[LibreOffice.git] / svx / source / form / formtoolbars.cxx
blobd46e7cc1b34343058fb14b0b56bba6ad85420aeb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <formtoolbars.hxx>
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <osl/diagnose.h>
24 #include <tools/diagnose_ex.h>
26 #include <svx/svxids.hrc>
29 namespace svxform
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::frame;
35 using namespace ::com::sun::star::beans;
37 FormToolboxes::FormToolboxes( const Reference< XFrame >& _rxFrame )
39 // the layout manager
40 Reference< XPropertySet > xFrameProps( _rxFrame, UNO_QUERY );
41 if ( xFrameProps.is() )
42 xFrameProps->getPropertyValue("LayoutManager") >>= m_xLayouter;
46 void FormToolboxes::toggleToolbox( sal_uInt16 _nSlotId ) const
48 try
50 Reference< XLayoutManager > xManager( m_xLayouter );
51 OSL_ENSURE( xManager. is(), "FormToolboxes::toggleToolbox: couldn't obtain the layout manager!" );
52 if ( xManager. is() )
54 OUString sToolboxResource( getToolboxResourceName( _nSlotId ) );
55 if ( xManager->isElementVisible( sToolboxResource ) )
57 xManager->hideElement( sToolboxResource );
58 xManager->destroyElement( sToolboxResource );
60 else
62 xManager->createElement( sToolboxResource );
63 xManager->showElement( sToolboxResource );
67 catch( const Exception& )
69 TOOLS_WARN_EXCEPTION( "svx", "FormToolboxes::toggleToolbox" );
74 bool FormToolboxes::isToolboxVisible( sal_uInt16 _nSlotId ) const
76 return m_xLayouter.is() && m_xLayouter->isElementVisible(
77 getToolboxResourceName( _nSlotId ) );
81 OUString FormToolboxes::getToolboxResourceName( sal_uInt16 _nSlotId )
83 OSL_ENSURE( _nSlotId == SID_FM_FORM_DESIGN_TOOLS ,
84 "FormToolboxes::getToolboxResourceName: unsupported slot!" );
86 return "private:resource/toolbar/formdesign";
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */