Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / tbxctrls / tbxcolor.cxx
blob97e4898065fe39358c7a8d37ee9588b5181337b7
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 <osl/diagnose.h>
25 #include <comphelper/diagnose_ex.hxx>
28 namespace svx
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::frame;
34 using namespace ::com::sun::star::beans;
36 ToolboxAccess::ToolboxAccess( std::u16string_view rToolboxName ) :
37 m_sToolboxResName ( "private:resource/toolbar/" )
39 m_sToolboxResName += rToolboxName;
41 // the layout manager
42 SfxViewFrame* pViewFrm = SfxViewFrame::Current();
43 if (!pViewFrm)
44 return;
46 try
48 Reference< XFrame > xFrame = pViewFrm->GetFrame().GetFrameInterface();
49 Reference< XPropertySet > xFrameProps( xFrame, UNO_QUERY );
50 if ( xFrameProps.is() )
51 xFrameProps->getPropertyValue( "LayoutManager" ) >>= m_xLayouter;
53 catch ( Exception const & )
55 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 TOOLS_WARN_EXCEPTION( "svx", "ToolboxAccess::toggleToolbox" );
87 bool ToolboxAccess::isToolboxVisible() const
89 return ( m_xLayouter.is() && m_xLayouter->isElementVisible( m_sToolboxResName ) );
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */