1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "svx/tbxcolor.hxx"
31 #include <sfx2/viewfrm.hxx>
32 #include <com/sun/star/beans/XPropertySet.hpp>
34 //........................................................................
37 //........................................................................
39 using namespace ::com::sun::star::uno
;
40 using namespace ::com::sun::star::frame
;
41 using namespace ::com::sun::star::beans
;
42 using namespace ::com::sun::star::frame
;
44 #define DECLARE_ASCII(s) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
45 #define TOOLBAR_RESNAME DECLARE_ASCII("private:resource/toolbar/")
46 #define PROPNAME_LAYOUTMANAGER DECLARE_ASCII("LayoutManager")
48 //====================================================================
50 //====================================================================
51 ToolboxAccess::ToolboxAccess( const ::rtl::OUString
& rToolboxName
) :
54 m_sToolboxResName ( TOOLBAR_RESNAME
)
57 m_sToolboxResName
+= rToolboxName
;
60 if ( SfxViewFrame::Current() )
64 Reference
< XFrame
> xFrame
= SfxViewFrame::Current()->GetFrame().GetFrameInterface();
65 Reference
< XPropertySet
> xFrameProps( xFrame
, UNO_QUERY
);
66 if ( xFrameProps
.is() )
67 xFrameProps
->getPropertyValue( PROPNAME_LAYOUTMANAGER
) >>= m_xLayouter
;
71 SAL_WARN( "svx.tbxcrtls", "ToolboxAccess::Ctor(): exception" );
76 //--------------------------------------------------------------------
77 void ToolboxAccess::toggleToolbox() const
81 Reference
< XLayoutManager
> xManager( m_xLayouter
);
82 OSL_ENSURE( xManager
. is(), "ToolboxAccess::toggleToolbox: couldn't obtain the layout manager!" );
85 if ( xManager
->isElementVisible( m_sToolboxResName
) )
87 xManager
->hideElement( m_sToolboxResName
);
88 xManager
->destroyElement( m_sToolboxResName
);
92 xManager
->createElement( m_sToolboxResName
);
93 xManager
->showElement( m_sToolboxResName
);
94 ::com::sun::star::awt::Point aPos
;
97 xManager
->dockWindow( m_sToolboxResName
,
98 ::com::sun::star::ui::DockingArea_DOCKINGAREA_BOTTOM
, aPos
);
102 catch( const Exception
& )
104 OSL_FAIL( "ToolboxAccess::toggleToolbox: caught an exception!" );
108 //--------------------------------------------------------------------
109 bool ToolboxAccess::isToolboxVisible() const
111 return ( m_xLayouter
.is() && m_xLayouter
->isElementVisible( m_sToolboxResName
) );
114 //........................................................................
116 //........................................................................
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */