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 .
21 #include "svx/tbxcolor.hxx"
22 #include <sfx2/viewfrm.hxx>
23 #include <com/sun/star/beans/XPropertySet.hpp>
25 //........................................................................
28 //........................................................................
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::frame
;
32 using namespace ::com::sun::star::beans
;
34 #define TOOLBAR_RESNAME "private:resource/toolbar/"
35 #define PROPNAME_LAYOUTMANAGER "LayoutManager"
37 //====================================================================
39 //====================================================================
40 ToolboxAccess::ToolboxAccess( const ::rtl::OUString
& rToolboxName
) :
43 m_sToolboxResName ( TOOLBAR_RESNAME
)
46 m_sToolboxResName
+= rToolboxName
;
49 if ( SfxViewFrame::Current() )
53 Reference
< XFrame
> xFrame
= SfxViewFrame::Current()->GetFrame().GetFrameInterface();
54 Reference
< XPropertySet
> xFrameProps( xFrame
, UNO_QUERY
);
55 if ( xFrameProps
.is() )
56 xFrameProps
->getPropertyValue( PROPNAME_LAYOUTMANAGER
) >>= m_xLayouter
;
60 SAL_WARN( "svx.tbxcrtls", "ToolboxAccess::Ctor(): exception" );
65 //--------------------------------------------------------------------
66 void ToolboxAccess::toggleToolbox() const
70 Reference
< XLayoutManager
> xManager( m_xLayouter
);
71 OSL_ENSURE( xManager
. is(), "ToolboxAccess::toggleToolbox: couldn't obtain the layout manager!" );
74 if ( xManager
->isElementVisible( m_sToolboxResName
) )
76 xManager
->hideElement( m_sToolboxResName
);
77 xManager
->destroyElement( m_sToolboxResName
);
81 xManager
->createElement( m_sToolboxResName
);
82 xManager
->showElement( m_sToolboxResName
);
83 ::com::sun::star::awt::Point aPos
;
86 xManager
->dockWindow( m_sToolboxResName
,
87 ::com::sun::star::ui::DockingArea_DOCKINGAREA_BOTTOM
, aPos
);
91 catch( const Exception
& )
93 OSL_FAIL( "ToolboxAccess::toggleToolbox: caught an exception!" );
97 //--------------------------------------------------------------------
98 bool ToolboxAccess::isToolboxVisible() const
100 return ( m_xLayouter
.is() && m_xLayouter
->isElementVisible( m_sToolboxResName
) );
103 //........................................................................
105 //........................................................................
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */