Bump version to 6.4-15
[LibreOffice.git] / svx / source / tbxctrls / tbxdrctl.cxx
blob06b9498ebc5fc995c56c9467f5dc01936743bcfb
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 <string>
23 #include <svl/aeitem.hxx>
24 #include <sfx2/dispatch.hxx>
25 #include <sfx2/viewsh.hxx>
26 #include <sfx2/viewfrm.hxx>
27 #include <vcl/toolbox.hxx>
29 #include <svx/tbxctl.hxx>
30 #include <svx/tbxcolor.hxx>
31 #include <com/sun/star/frame/XLayoutManager.hpp>
33 SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw, SfxBoolItem);
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::frame;
39 SvxTbxCtlDraw::SvxTbxCtlDraw( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
40 SfxToolBoxControl( nSlotId, nId, rTbx )
42 rTbx.SetItemBits( nId, ToolBoxItemBits::CHECKABLE | rTbx.GetItemBits( nId ) );
43 rTbx.Invalidate();
46 void SAL_CALL SvxTbxCtlDraw::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
48 svt::ToolboxController::initialize(aArguments);
50 * Toolbar name is defined as "private:resource/toolbar/drawbar" in writer and calc,
51 * "private:resource/toolbar/toolbar" in draw and impress. Control is added for this
52 * difference.
54 if( m_aCommandURL==".uno:TrackChangesBar")
55 m_sToolboxName="private:resource/toolbar/changes";
56 else if ( m_sModuleName == "com.sun.star.presentation.PresentationDocument" || m_sModuleName == "com.sun.star.drawing.DrawingDocument" )
57 m_sToolboxName="private:resource/toolbar/toolbar";
58 else
59 m_sToolboxName="private:resource/toolbar/drawbar";
63 void SvxTbxCtlDraw::StateChanged( sal_uInt16 nSID, SfxItemState eState,
64 const SfxPoolItem* pState )
66 GetToolBox().EnableItem( GetId(), ( eState != SfxItemState::DISABLED ) );
67 SfxToolBoxControl::StateChanged( nSID, eState, pState );
69 Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
70 if ( xLayoutMgr.is() )
71 GetToolBox().CheckItem(
72 GetId(), xLayoutMgr->isElementVisible( m_sToolboxName ) );
76 void SvxTbxCtlDraw::toggleToolbox()
78 Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
79 if ( xLayoutMgr.is() )
81 bool bCheck = false;
82 if ( xLayoutMgr->isElementVisible( m_sToolboxName ) )
84 xLayoutMgr->hideElement( m_sToolboxName );
85 xLayoutMgr->destroyElement( m_sToolboxName );
87 else
89 bCheck = true;
90 xLayoutMgr->createElement( m_sToolboxName );
91 xLayoutMgr->showElement( m_sToolboxName );
94 GetToolBox().CheckItem( GetId(), bCheck );
99 void SvxTbxCtlDraw::Select(sal_uInt16 /*nSelectModifier*/)
101 toggleToolbox();
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */