Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / svx / source / tbxctrls / tbxdrctl.cxx
blob3706c17a9111a8b9fa9cded2059e1f7526414dd0
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 <string>
32 #include <tools/shl.hxx>
33 #include <svl/aeitem.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <sfx2/viewsh.hxx>
36 #include <sfx2/imagemgr.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <vcl/toolbox.hxx>
40 #include <svx/dialmgr.hxx>
41 #include <svx/dialogs.hrc>
43 #include "svx/tbxctl.hxx"
44 #include "svx/tbxdraw.hxx"
45 #include "svx/tbxcolor.hxx"
46 #include "tbxdraw.hrc"
47 #include <com/sun/star/frame/XLayoutManager.hpp>
49 SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw, SfxAllEnumItem);
51 using namespace ::com::sun::star::uno;
52 using namespace ::com::sun::star::frame;
54 // -----------------------------------------------------------------------
56 SvxTbxCtlDraw::SvxTbxCtlDraw( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
58 SfxToolBoxControl( nSlotId, nId, rTbx ),
60 m_sToolboxName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/drawbar" ) )
63 rTbx.SetItemBits( nId, TIB_CHECKABLE | rTbx.GetItemBits( nId ) );
64 rTbx.Invalidate();
67 // -----------------------------------------------------------------------
69 void SvxTbxCtlDraw::StateChanged( sal_uInt16 nSID, SfxItemState eState,
70 const SfxPoolItem* pState )
72 GetToolBox().EnableItem( GetId(), ( eState != SFX_ITEM_DISABLED ) );
73 SfxToolBoxControl::StateChanged( nSID, eState, pState );
75 Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
76 if ( xLayoutMgr.is() )
77 GetToolBox().CheckItem(
78 GetId(), xLayoutMgr->isElementVisible( m_sToolboxName ) != sal_False );
81 // -----------------------------------------------------------------------
83 SfxPopupWindowType SvxTbxCtlDraw::GetPopupWindowType() const
85 return SFX_POPUPWINDOW_ONCLICK;
88 // -----------------------------------------------------------------------
90 void SvxTbxCtlDraw::toggleToolbox()
92 Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
93 if ( xLayoutMgr.is() )
95 sal_Bool bCheck = sal_False;
96 if ( xLayoutMgr->isElementVisible( m_sToolboxName ) )
98 xLayoutMgr->hideElement( m_sToolboxName );
99 xLayoutMgr->destroyElement( m_sToolboxName );
101 else
103 bCheck = sal_True;
104 xLayoutMgr->createElement( m_sToolboxName );
105 xLayoutMgr->showElement( m_sToolboxName );
108 GetToolBox().CheckItem( GetId(), bCheck );
112 // -----------------------------------------------------------------------
114 void SvxTbxCtlDraw::Select( sal_Bool )
116 toggleToolbox();
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */