Adjust includes
[LibreOffice.git] / svx / source / tbxctrls / tbxdrctl.cxx
blob2d0dc4c745be5ffcd2a19dfc7d7fec5106f17b17
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/dialmgr.hxx>
30 #include <svx/strings.hrc>
31 #include <svx/tbxctl.hxx>
32 #include <svx/tbxcolor.hxx>
33 #include <com/sun/star/frame/XLayoutManager.hpp>
35 SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw, SfxBoolItem);
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::frame;
41 SvxTbxCtlDraw::SvxTbxCtlDraw( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
42 SfxToolBoxControl( nSlotId, nId, rTbx )
44 rTbx.SetItemBits( nId, ToolBoxItemBits::CHECKABLE | rTbx.GetItemBits( nId ) );
45 rTbx.Invalidate();
48 void SAL_CALL SvxTbxCtlDraw::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
50 svt::ToolboxController::initialize(aArguments);
52 * Toolbar name is defined as "private:resource/toolbar/drawbar" in writer and calc,
53 * "private:resource/toolbar/toolbar" in draw and impress. Control is added for this
54 * difference.
56 if( m_aCommandURL==".uno:TrackChangesBar")
57 m_sToolboxName="private:resource/toolbar/changes";
58 else if ( m_sModuleName == "com.sun.star.presentation.PresentationDocument" || m_sModuleName == "com.sun.star.drawing.DrawingDocument" )
59 m_sToolboxName="private:resource/toolbar/toolbar";
60 else
61 m_sToolboxName="private:resource/toolbar/drawbar";
65 void SvxTbxCtlDraw::StateChanged( sal_uInt16 nSID, SfxItemState eState,
66 const SfxPoolItem* pState )
68 GetToolBox().EnableItem( GetId(), ( eState != SfxItemState::DISABLED ) );
69 SfxToolBoxControl::StateChanged( nSID, eState, pState );
71 Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
72 if ( xLayoutMgr.is() )
73 GetToolBox().CheckItem(
74 GetId(), xLayoutMgr->isElementVisible( m_sToolboxName ) );
78 void SvxTbxCtlDraw::toggleToolbox()
80 Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
81 if ( xLayoutMgr.is() )
83 bool bCheck = false;
84 if ( xLayoutMgr->isElementVisible( m_sToolboxName ) )
86 xLayoutMgr->hideElement( m_sToolboxName );
87 xLayoutMgr->destroyElement( m_sToolboxName );
89 else
91 bCheck = true;
92 xLayoutMgr->createElement( m_sToolboxName );
93 xLayoutMgr->showElement( m_sToolboxName );
96 GetToolBox().CheckItem( GetId(), bCheck );
101 void SvxTbxCtlDraw::Select(sal_uInt16 /*nSelectModifier*/)
103 toggleToolbox();
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */