LibreOffice Module svx (master) 1
formtoolbars.cxx
Go to the documentation of this file.
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>
25
26#include <svx/svxids.hrc>
27
28
29namespace svxform
30{
31
32
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::frame;
35 using namespace ::com::sun::star::beans;
36
37 FormToolboxes::FormToolboxes( const Reference< XFrame >& _rxFrame )
38 {
39 // the layout manager
40 Reference< XPropertySet > xFrameProps( _rxFrame, UNO_QUERY );
41 if ( xFrameProps.is() )
42 xFrameProps->getPropertyValue("LayoutManager") >>= m_xLayouter;
43 }
44
45
46 void FormToolboxes::toggleToolbox( sal_uInt16 _nSlotId ) const
47 {
48 try
49 {
50 Reference< XLayoutManager > xManager( m_xLayouter );
51 OSL_ENSURE( xManager. is(), "FormToolboxes::toggleToolbox: couldn't obtain the layout manager!" );
52 if ( xManager. is() )
53 {
54 OUString sToolboxResource( getToolboxResourceName( _nSlotId ) );
55 if ( xManager->isElementVisible( sToolboxResource ) )
56 {
57 xManager->hideElement( sToolboxResource );
58 xManager->destroyElement( sToolboxResource );
59 }
60 else
61 {
62 xManager->createElement( sToolboxResource );
63 xManager->showElement( sToolboxResource );
64 }
65 }
66 }
67 catch( const Exception& )
68 {
69 TOOLS_WARN_EXCEPTION( "svx", "FormToolboxes::toggleToolbox" );
70 }
71 }
72
73
74 bool FormToolboxes::isToolboxVisible( sal_uInt16 _nSlotId ) const
75 {
76 return m_xLayouter.is() && m_xLayouter->isElementVisible(
77 getToolboxResourceName( _nSlotId ) );
78 }
79
80
81 OUString FormToolboxes::getToolboxResourceName( sal_uInt16 _nSlotId )
82 {
83 OSL_ENSURE( _nSlotId == SID_FM_FORM_DESIGN_TOOLS ,
84 "FormToolboxes::getToolboxResourceName: unsupported slot!" );
85
86 return "private:resource/toolbar/formdesign";
87 }
88
89
90}
91
92
93/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::frame::XLayoutManager > m_xLayouter
void toggleToolbox(sal_uInt16 _nSlotId) const
toggles the toolbox associated with the given slot
static OUString getToolboxResourceName(sal_uInt16 _nSlotId)
retrieves the URI for the toolbox associated with the given slot, depending on the type of our docume...
FormToolboxes(const css::uno::Reference< css::frame::XFrame > &_rxFrame)
constructs an instance
bool isToolboxVisible(sal_uInt16 _nSlotId) const
determines whether the toolbox associated with the given slot is currently visible
#define TOOLS_WARN_EXCEPTION(area, stream)
@ Exception
class FmSearchEngine - Impl class for FmSearchDialog