Bump version to 6.4-15
[LibreOffice.git] / svx / source / tbxctrls / tbxcolor.cxx
blob3a17e38820a435907604d87b4d7b14f53eef05f6
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 .
21 #include <svx/tbxcolor.hxx>
22 #include <sfx2/viewfrm.hxx>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <sal/log.hxx>
25 #include <osl/diagnose.h>
26 #include <tools/diagnose_ex.h>
29 namespace svx
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::frame;
35 using namespace ::com::sun::star::beans;
37 ToolboxAccess::ToolboxAccess( const OUString& rToolboxName ) :
38 m_sToolboxResName ( "private:resource/toolbar/" )
40 m_sToolboxResName += rToolboxName;
42 // the layout manager
43 if ( SfxViewFrame::Current() )
45 try
47 Reference< XFrame > xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
48 Reference< XPropertySet > xFrameProps( xFrame, UNO_QUERY );
49 if ( xFrameProps.is() )
50 xFrameProps->getPropertyValue( "LayoutManager" ) >>= m_xLayouter;
52 catch ( Exception const & )
54 TOOLS_WARN_EXCEPTION( "svx.tbxcrtls", "ToolboxAccess::Ctor()" );
60 void ToolboxAccess::toggleToolbox() const
62 try
64 Reference< XLayoutManager > xManager( m_xLayouter );
65 OSL_ENSURE( xManager. is(), "ToolboxAccess::toggleToolbox: couldn't obtain the layout manager!" );
66 if ( xManager. is() )
68 if ( xManager->isElementVisible( m_sToolboxResName ) )
70 xManager->hideElement( m_sToolboxResName );
71 xManager->destroyElement( m_sToolboxResName );
73 else
75 xManager->createElement( m_sToolboxResName );
76 xManager->showElement( m_sToolboxResName );
80 catch( const Exception& )
82 OSL_FAIL( "ToolboxAccess::toggleToolbox: caught an exception!" );
87 bool ToolboxAccess::isToolboxVisible() const
89 return ( m_xLayouter.is() && m_xLayouter->isElementVisible( m_sToolboxResName ) );
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */