1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tbxcolor.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include "tbxcolor.hxx"
35 #include <sfx2/viewfrm.hxx>
36 #include <com/sun/star/beans/XPropertySet.hpp>
38 //........................................................................
41 //........................................................................
43 using namespace ::com::sun::star::uno
;
44 using namespace ::com::sun::star::frame
;
45 using namespace ::com::sun::star::beans
;
46 using namespace ::com::sun::star::frame
;
48 #define DECLARE_ASCII(s) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
49 #define TOOLBAR_RESNAME DECLARE_ASCII("private:resource/toolbar/")
50 #define PROPNAME_LAYOUTMANAGER DECLARE_ASCII("LayoutManager")
52 //====================================================================
54 //====================================================================
55 ToolboxAccess::ToolboxAccess( const ::rtl::OUString
& rToolboxName
) :
58 m_sToolboxResName ( TOOLBAR_RESNAME
)
61 m_sToolboxResName
+= rToolboxName
;
64 if ( SfxViewFrame::Current() )
68 Reference
< XFrame
> xFrame
= SfxViewFrame::Current()->GetFrame()->GetFrameInterface();
69 Reference
< XPropertySet
> xFrameProps( xFrame
, UNO_QUERY
);
70 if ( xFrameProps
.is() )
71 xFrameProps
->getPropertyValue( PROPNAME_LAYOUTMANAGER
) >>= m_xLayouter
;
75 DBG_ERRORFILE( "ToolboxAccess::Ctor(): exception" );
80 //--------------------------------------------------------------------
81 void ToolboxAccess::toggleToolbox() const
85 Reference
< XLayoutManager
> xManager( m_xLayouter
);
86 OSL_ENSURE( xManager
. is(), "ToolboxAccess::toggleToolbox: couldn't obtain the layout manager!" );
89 if ( xManager
->isElementVisible( m_sToolboxResName
) )
91 xManager
->hideElement( m_sToolboxResName
);
92 xManager
->destroyElement( m_sToolboxResName
);
96 xManager
->createElement( m_sToolboxResName
);
97 xManager
->showElement( m_sToolboxResName
);
98 ::com::sun::star::awt::Point aPos
;
101 xManager
->dockWindow( m_sToolboxResName
,
102 ::com::sun::star::ui::DockingArea_DOCKINGAREA_BOTTOM
, aPos
);
106 catch( const Exception
& )
108 OSL_ENSURE( sal_False
, "ToolboxAccess::toggleToolbox: caught an exception!" );
112 //--------------------------------------------------------------------
113 bool ToolboxAccess::isToolboxVisible() const
115 return ( m_xLayouter
.is() && m_xLayouter
->isElementVisible( m_sToolboxResName
) );
118 //........................................................................
120 //........................................................................