LibreOffice Module svx (master) 1
tbxdrctl.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21#include <svl/eitem.hxx>
22#include <vcl/toolbox.hxx>
23
24#include <svx/tbxctl.hxx>
25
26#include <com/sun/star/frame/XLayoutManager.hpp>
27
29
30using namespace ::com::sun::star::uno;
31using namespace ::com::sun::star::frame;
32
33
34SvxTbxCtlDraw::SvxTbxCtlDraw( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx ) :
35 SfxToolBoxControl( nSlotId, nId, rTbx )
36{
37 rTbx.SetItemBits( nId, ToolBoxItemBits::CHECKABLE | rTbx.GetItemBits( nId ) );
38 rTbx.Invalidate();
39}
40
41void SAL_CALL SvxTbxCtlDraw::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
42{
44 /*
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
47 * difference.
48 */
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";
53 else
54 m_sToolboxName="private:resource/toolbar/drawbar";
55}
56
57
59 const SfxPoolItem* pState )
60{
61 GetToolBox().EnableItem( GetId(), ( eState != SfxItemState::DISABLED ) );
63
64 Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
65 if ( xLayoutMgr.is() )
67 GetId(), xLayoutMgr->isElementVisible( m_sToolboxName ) );
68}
69
70
72{
73 Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
74 if ( !xLayoutMgr.is() )
75 return;
76
77 bool bCheck = false;
78 if ( xLayoutMgr->isElementVisible( m_sToolboxName ) )
79 {
80 xLayoutMgr->hideElement( m_sToolboxName );
81 xLayoutMgr->destroyElement( m_sToolboxName );
82 }
83 else
84 {
85 bCheck = true;
86 xLayoutMgr->createElement( m_sToolboxName );
87 xLayoutMgr->showElement( m_sToolboxName );
88 }
89
90 GetToolBox().CheckItem( GetId(), bCheck );
91}
92
93
94void SvxTbxCtlDraw::Select(sal_uInt16 /*nSelectModifier*/)
95{
97}
98
99/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ToolBoxItemId GetId() const
ToolBox & GetToolBox() const
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: tbxdrctl.cxx:41
SvxTbxCtlDraw(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
Definition: tbxdrctl.cxx:34
OUString m_sToolboxName
Definition: tbxctl.hxx:34
virtual void Select(sal_uInt16 nSelectModifier) override
Definition: tbxdrctl.cxx:94
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: tbxdrctl.cxx:58
void toggleToolbox()
Definition: tbxdrctl.cxx:71
void EnableItem(ToolBoxItemId nItemId, bool bEnable=true)
void CheckItem(ToolBoxItemId nItemId, bool bCheck=true)
ToolBoxItemBits GetItemBits(ToolBoxItemId nItemId) const
void SetItemBits(ToolBoxItemId nItemId, ToolBoxItemBits nBits)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Sequence< PropertyValue > aArguments
sal_Int16 nId
SfxItemState
SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw, SfxBoolItem)