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>
23 #include <osl/diagnose.h>
25 #include <svx/svxids.hrc>
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::frame
;
34 using namespace ::com::sun::star::beans
;
36 FormToolboxes::FormToolboxes( const Reference
< XFrame
>& _rxFrame
)
39 Reference
< XPropertySet
> xFrameProps( _rxFrame
, UNO_QUERY
);
40 if ( xFrameProps
.is() )
41 xFrameProps
->getPropertyValue("LayoutManager") >>= m_xLayouter
;
45 void FormToolboxes::toggleToolbox( sal_uInt16 _nSlotId
) const
49 Reference
< XLayoutManager
> xManager( m_xLayouter
);
50 OSL_ENSURE( xManager
. is(), "FormToolboxes::toggleToolbox: couldn't obtain the layout manager!" );
53 OUString
sToolboxResource( getToolboxResourceName( _nSlotId
) );
54 if ( xManager
->isElementVisible( sToolboxResource
) )
56 xManager
->hideElement( sToolboxResource
);
57 xManager
->destroyElement( sToolboxResource
);
61 xManager
->createElement( sToolboxResource
);
62 xManager
->showElement( sToolboxResource
);
66 catch( const Exception
& )
68 OSL_FAIL( "FormToolboxes::toggleToolbox: caught an exception!" );
73 bool FormToolboxes::isToolboxVisible( sal_uInt16 _nSlotId
) const
75 return m_xLayouter
.is() && m_xLayouter
->isElementVisible(
76 getToolboxResourceName( _nSlotId
) );
80 OUString
FormToolboxes::getToolboxResourceName( sal_uInt16 _nSlotId
)
82 OSL_ENSURE( _nSlotId
== SID_FM_FORM_DESIGN_TOOLS
,
83 "FormToolboxes::getToolboxResourceName: unsupported slot!" );
85 return "private:resource/toolbar/formdesign";
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */