1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
24 #include <svx/svxids.hrc>
26 //........................................................................
29 //........................................................................
31 using namespace ::com::sun::star::uno
;
32 using namespace ::com::sun::star::frame
;
33 using namespace ::com::sun::star::beans
;
35 //====================================================================
37 //====================================================================
38 //--------------------------------------------------------------------
39 FormToolboxes::FormToolboxes( const Reference
< XFrame
>& _rxFrame
)
42 Reference
< XPropertySet
> xFrameProps( _rxFrame
, UNO_QUERY
);
43 if ( xFrameProps
.is() )
44 xFrameProps
->getPropertyValue( OUString( "LayoutManager" ) ) >>= m_xLayouter
;
47 //--------------------------------------------------------------------
48 void FormToolboxes::toggleToolbox( sal_uInt16 _nSlotId
) const
52 Reference
< XLayoutManager
> xManager( m_xLayouter
);
53 OSL_ENSURE( xManager
. is(), "FormToolboxes::toggleToolbox: couldn't obtain the layout manager!" );
56 OUString
sToolboxResource( getToolboxResourceName( _nSlotId
) );
57 if ( xManager
->isElementVisible( sToolboxResource
) )
59 xManager
->hideElement( sToolboxResource
);
60 xManager
->destroyElement( sToolboxResource
);
64 xManager
->createElement( sToolboxResource
);
65 xManager
->showElement( sToolboxResource
);
69 catch( const Exception
& )
71 OSL_FAIL( "FormToolboxes::toggleToolbox: caught an exception!" );
75 //--------------------------------------------------------------------
76 bool FormToolboxes::isToolboxVisible( sal_uInt16 _nSlotId
) const
78 return m_xLayouter
.is() && m_xLayouter
->isElementVisible(
79 getToolboxResourceName( _nSlotId
) );
82 //--------------------------------------------------------------------
83 OUString
FormToolboxes::getToolboxResourceName( sal_uInt16 _nSlotId
) const
85 OSL_ENSURE( ( _nSlotId
== SID_FM_MORE_CONTROLS
) || ( _nSlotId
== SID_FM_FORM_DESIGN_TOOLS
) || ( _nSlotId
== SID_FM_CONFIG
),
86 "FormToolboxes::getToolboxResourceName: unsupported slot!" );
88 const sal_Char
* pToolBarName
= "formcontrols";
89 if ( _nSlotId
== SID_FM_MORE_CONTROLS
)
90 pToolBarName
= "moreformcontrols";
91 else if ( _nSlotId
== SID_FM_FORM_DESIGN_TOOLS
)
92 pToolBarName
= "formdesign";
94 OUString
aToolBarResStr( "private:resource/toolbar/" );
95 aToolBarResStr
+= OUString::createFromAscii( pToolBarName
);
96 return aToolBarResStr
;
99 //........................................................................
100 } // namespace svxform
101 //........................................................................
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */