Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <string>
30 : :
31 : : #include <tools/shl.hxx>
32 : : #include <svl/intitem.hxx>
33 : : #include <sfx2/dispatch.hxx>
34 : : #include <sfx2/viewsh.hxx>
35 : : #include <sfx2/viewfrm.hxx>
36 : : #include <sfx2/imagemgr.hxx>
37 : : #include <vcl/toolbox.hxx>
38 : :
39 : : #include "tbinsert.hxx"
40 : : #include "tbinsert.hrc"
41 : : #include "global.hxx"
42 : : #include "scmod.hxx"
43 : : #include "scresid.hxx"
44 : : #include "sc.hrc"
45 : :
46 : : // -----------------------------------------------------------------------
47 : :
48 [ # # ]: 153 : SFX_IMPL_TOOLBOX_CONTROL( ScTbxInsertCtrl, SfxUInt16Item);
49 : :
50 : : //------------------------------------------------------------------
51 : : //
52 : : // ToolBox - Controller
53 : : //
54 : : //------------------------------------------------------------------
55 : :
56 : 0 : ScTbxInsertCtrl::ScTbxInsertCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
57 : : SfxToolBoxControl( nSlotId, nId, rTbx ),
58 : 0 : nLastSlotId(0)
59 : : {
60 [ # # ][ # # ]: 0 : rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
61 : 0 : }
62 : :
63 : 0 : ScTbxInsertCtrl::~ScTbxInsertCtrl()
64 : : {
65 [ # # ]: 0 : }
66 : :
67 : 0 : void ScTbxInsertCtrl::StateChanged( sal_uInt16 /* nSID */, SfxItemState eState,
68 : : const SfxPoolItem* pState )
69 : : {
70 : 0 : GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) );
71 : :
72 [ # # ]: 0 : if( eState == SFX_ITEM_AVAILABLE )
73 : : {
74 : :
75 [ # # ][ # # ]: 0 : const SfxUInt16Item* pItem = PTR_CAST( SfxUInt16Item, pState );
76 [ # # ]: 0 : if(pItem)
77 : : {
78 : 0 : nLastSlotId = pItem->GetValue();
79 [ # # ][ # # ]: 0 : sal_uInt16 nImageId = nLastSlotId ? nLastSlotId : GetSlotId();
80 [ # # ]: 0 : rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
81 : 0 : aSlotURL += rtl::OUString::valueOf( sal_Int32( nImageId ));
82 : : Image aImage = GetImage( m_xFrame,
83 : : aSlotURL,
84 [ # # ]: 0 : hasBigImages()
85 [ # # ]: 0 : );
86 [ # # ][ # # ]: 0 : GetToolBox().SetItemImage(GetId(), aImage);
[ # # ][ # # ]
87 : : }
88 : : }
89 : 0 : }
90 : :
91 : 0 : SfxPopupWindow* ScTbxInsertCtrl::CreatePopupWindow()
92 : : {
93 : 0 : sal_uInt16 nSlotId = GetSlotId();
94 [ # # ]: 0 : if (nSlotId == SID_TBXCTL_INSERT)
95 : : {
96 [ # # ]: 0 : rtl::OUString aInsertBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertbar" ));
97 [ # # ]: 0 : createAndPositionSubToolBar( aInsertBarResStr );
98 : : }
99 [ # # ]: 0 : else if (nSlotId == SID_TBXCTL_INSCELLS)
100 : : {
101 [ # # ]: 0 : rtl::OUString aInsertCellsBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertcellsbar" ));
102 [ # # ]: 0 : createAndPositionSubToolBar( aInsertCellsBarResStr );
103 : : }
104 : : else
105 : : {
106 [ # # ]: 0 : rtl::OUString aInsertObjectBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertobjectbar" ));
107 [ # # ]: 0 : createAndPositionSubToolBar( aInsertObjectBarResStr );
108 : : }
109 : 0 : return NULL;
110 : : }
111 : :
112 : 0 : SfxPopupWindowType ScTbxInsertCtrl::GetPopupWindowType() const
113 : : {
114 [ # # ]: 0 : return nLastSlotId ? SFX_POPUPWINDOW_ONTIMEOUT : SFX_POPUPWINDOW_ONCLICK;
115 : : }
116 : :
117 : 0 : void ScTbxInsertCtrl::Select( sal_Bool /* bMod1 */ )
118 : : {
119 : 0 : SfxViewShell* pCurSh( SfxViewShell::Current() );
120 : 0 : SfxDispatcher* pDispatch( 0 );
121 : :
122 [ # # ]: 0 : if ( pCurSh )
123 : : {
124 : 0 : SfxViewFrame* pViewFrame = pCurSh->GetViewFrame();
125 [ # # ]: 0 : if ( pViewFrame )
126 : 0 : pDispatch = pViewFrame->GetDispatcher();
127 : : }
128 : :
129 [ # # ]: 0 : if ( pDispatch )
130 : 0 : pDispatch->Execute(nLastSlotId);
131 : 0 : }
132 : :
133 : :
134 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|