LibreOffice Module svx (master) 1
tbxcolor.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
21#include <svx/tbxcolor.hxx>
22#include <sfx2/viewfrm.hxx>
23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <osl/diagnose.h>
26
27
28namespace svx
29{
30
31
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::frame;
34 using namespace ::com::sun::star::beans;
35
36 ToolboxAccess::ToolboxAccess( std::u16string_view rToolboxName ) :
37 m_sToolboxResName ( "private:resource/toolbar/" )
38 {
39 m_sToolboxResName += rToolboxName;
40
41 // the layout manager
43 if (!pViewFrm)
44 return;
45
46 try
47 {
48 Reference< XFrame > xFrame = pViewFrm->GetFrame().GetFrameInterface();
49 Reference< XPropertySet > xFrameProps( xFrame, UNO_QUERY );
50 if ( xFrameProps.is() )
51 xFrameProps->getPropertyValue( "LayoutManager" ) >>= m_xLayouter;
52 }
53 catch ( Exception const & )
54 {
55 TOOLS_WARN_EXCEPTION( "svx.tbxcrtls", "ToolboxAccess::Ctor()" );
56 }
57 }
58
59
61 {
62 try
63 {
64 Reference< XLayoutManager > xManager( m_xLayouter );
65 OSL_ENSURE( xManager. is(), "ToolboxAccess::toggleToolbox: couldn't obtain the layout manager!" );
66 if ( xManager. is() )
67 {
68 if ( xManager->isElementVisible( m_sToolboxResName ) )
69 {
70 xManager->hideElement( m_sToolboxResName );
71 xManager->destroyElement( m_sToolboxResName );
72 }
73 else
74 {
75 xManager->createElement( m_sToolboxResName );
76 xManager->showElement( m_sToolboxResName );
77 }
78 }
79 }
80 catch( const Exception& )
81 {
82 TOOLS_WARN_EXCEPTION( "svx", "ToolboxAccess::toggleToolbox" );
83 }
84 }
85
86
88 {
89 return ( m_xLayouter.is() && m_xLayouter->isElementVisible( m_sToolboxResName ) );
90 }
91
92
93}
94
95
96/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxFrame & GetFrame() const
void toggleToolbox() const
toggles the toolbox
Definition: tbxcolor.cxx:60
bool isToolboxVisible() const
determines whether the toolbox is currently visible
Definition: tbxcolor.cxx:87
ToolboxAccess(std::u16string_view rToolboxName)
Definition: tbxcolor.cxx:36
css::uno::Reference< css::frame::XLayoutManager > m_xLayouter
Definition: tbxcolor.hxx:41
OUString m_sToolboxResName
Definition: tbxcolor.hxx:39
#define TOOLS_WARN_EXCEPTION(area, stream)
@ Exception
Reference< XFrame > xFrame