1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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
) );
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
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";
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() )
82 if ( xLayoutMgr
->isElementVisible( m_sToolboxName
) )
84 xLayoutMgr
->hideElement( m_sToolboxName
);
85 xLayoutMgr
->destroyElement( m_sToolboxName
);
90 xLayoutMgr
->createElement( m_sToolboxName
);
91 xLayoutMgr
->showElement( m_sToolboxName
);
94 GetToolBox().CheckItem( GetId(), bCheck
);
99 void SvxTbxCtlDraw::Select(sal_uInt16
/*nSelectModifier*/)
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */