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 .
21 #include <svl/eitem.hxx>
22 #include <vcl/toolbox.hxx>
24 #include <svx/tbxctl.hxx>
26 #include <com/sun/star/frame/XLayoutManager.hpp>
28 SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw
, SfxBoolItem
);
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::frame
;
34 SvxTbxCtlDraw::SvxTbxCtlDraw( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
) :
35 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
37 rTbx
.SetItemBits( nId
, ToolBoxItemBits::CHECKABLE
| rTbx
.GetItemBits( nId
) );
41 void SAL_CALL
SvxTbxCtlDraw::initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
)
43 svt::ToolboxController::initialize(aArguments
);
45 * Toolbar name is defined as "private:resource/toolbar/drawbar" in writer and calc,
46 * "private:resource/toolbar/toolbar" in draw and impress. Control is added for this
49 if( m_aCommandURL
==".uno:TrackChangesBar")
50 m_sToolboxName
="private:resource/toolbar/changes";
51 else if ( m_sModuleName
== "com.sun.star.presentation.PresentationDocument" || m_sModuleName
== "com.sun.star.drawing.DrawingDocument" )
52 m_sToolboxName
="private:resource/toolbar/toolbar";
54 m_sToolboxName
="private:resource/toolbar/drawbar";
58 void SvxTbxCtlDraw::StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
59 const SfxPoolItem
* pState
)
61 GetToolBox().EnableItem( GetId(), ( eState
!= SfxItemState::DISABLED
) );
62 SfxToolBoxControl::StateChanged( nSID
, eState
, pState
);
64 Reference
< XLayoutManager
> xLayoutMgr
= getLayoutManager();
65 if ( xLayoutMgr
.is() )
66 GetToolBox().CheckItem(
67 GetId(), xLayoutMgr
->isElementVisible( m_sToolboxName
) );
71 void SvxTbxCtlDraw::toggleToolbox()
73 Reference
< XLayoutManager
> xLayoutMgr
= getLayoutManager();
74 if ( !xLayoutMgr
.is() )
78 if ( xLayoutMgr
->isElementVisible( m_sToolboxName
) )
80 xLayoutMgr
->hideElement( m_sToolboxName
);
81 xLayoutMgr
->destroyElement( m_sToolboxName
);
86 xLayoutMgr
->createElement( m_sToolboxName
);
87 xLayoutMgr
->showElement( m_sToolboxName
);
90 GetToolBox().CheckItem( GetId(), bCheck
);
94 void SvxTbxCtlDraw::Select(sal_uInt16
/*nSelectModifier*/)
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */