Branch data Line data Source code
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 <string>
22 : :
23 : : #include <tools/shl.hxx>
24 : : #include <svl/aeitem.hxx>
25 : : #include <sfx2/dispatch.hxx>
26 : : #include <sfx2/viewsh.hxx>
27 : : #include <sfx2/imagemgr.hxx>
28 : : #include <sfx2/viewfrm.hxx>
29 : : #include <vcl/toolbox.hxx>
30 : :
31 : : #include <svx/dialmgr.hxx>
32 : : #include <svx/dialogs.hrc>
33 : :
34 : : #include "svx/tbxctl.hxx"
35 : : #include "svx/tbxdraw.hxx"
36 : : #include "svx/tbxcolor.hxx"
37 : : #include <com/sun/star/frame/XLayoutManager.hpp>
38 : :
39 [ + - ]: 1099 : SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw, SfxAllEnumItem);
40 : :
41 : : using namespace ::com::sun::star::uno;
42 : : using namespace ::com::sun::star::frame;
43 : :
44 : : // -----------------------------------------------------------------------
45 : :
46 : 975 : SvxTbxCtlDraw::SvxTbxCtlDraw( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
47 : :
48 : : SfxToolBoxControl( nSlotId, nId, rTbx ),
49 : :
50 [ + - ]: 975 : m_sToolboxName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/drawbar" ) )
51 : :
52 : : {
53 [ + - ][ + - ]: 975 : rTbx.SetItemBits( nId, TIB_CHECKABLE | rTbx.GetItemBits( nId ) );
54 [ + - ]: 975 : rTbx.Invalidate();
55 : 975 : }
56 : :
57 : : // -----------------------------------------------------------------------
58 : :
59 : 1438 : void SvxTbxCtlDraw::StateChanged( sal_uInt16 nSID, SfxItemState eState,
60 : : const SfxPoolItem* pState )
61 : : {
62 [ + - ][ + - ]: 1438 : GetToolBox().EnableItem( GetId(), ( eState != SFX_ITEM_DISABLED ) );
[ + - ]
63 [ + - ]: 1438 : SfxToolBoxControl::StateChanged( nSID, eState, pState );
64 : :
65 [ + - ]: 1438 : Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
66 [ + - ]: 1438 : if ( xLayoutMgr.is() )
67 [ + - ]: 1438 : GetToolBox().CheckItem(
68 [ + - ][ + - ]: 2876 : GetId(), xLayoutMgr->isElementVisible( m_sToolboxName ) != sal_False );
[ + - ][ + - ]
69 : 1438 : }
70 : :
71 : : // -----------------------------------------------------------------------
72 : :
73 : 0 : SfxPopupWindowType SvxTbxCtlDraw::GetPopupWindowType() const
74 : : {
75 : 0 : return SFX_POPUPWINDOW_ONCLICK;
76 : : }
77 : :
78 : : // -----------------------------------------------------------------------
79 : :
80 : 0 : void SvxTbxCtlDraw::toggleToolbox()
81 : : {
82 [ # # ]: 0 : Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
83 [ # # ]: 0 : if ( xLayoutMgr.is() )
84 : : {
85 : 0 : sal_Bool bCheck = sal_False;
86 [ # # ][ # # ]: 0 : if ( xLayoutMgr->isElementVisible( m_sToolboxName ) )
[ # # ]
87 : : {
88 [ # # ][ # # ]: 0 : xLayoutMgr->hideElement( m_sToolboxName );
89 [ # # ][ # # ]: 0 : xLayoutMgr->destroyElement( m_sToolboxName );
90 : : }
91 : : else
92 : : {
93 : 0 : bCheck = sal_True;
94 [ # # ][ # # ]: 0 : xLayoutMgr->createElement( m_sToolboxName );
95 [ # # ][ # # ]: 0 : xLayoutMgr->showElement( m_sToolboxName );
96 : : }
97 : :
98 [ # # ][ # # ]: 0 : GetToolBox().CheckItem( GetId(), bCheck );
[ # # ]
99 : 0 : }
100 : 0 : }
101 : :
102 : : // -----------------------------------------------------------------------
103 : :
104 : 0 : void SvxTbxCtlDraw::Select( sal_Bool )
105 : : {
106 : 0 : toggleToolbox();
107 : 0 : }
108 : :
109 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|