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 : #include <string>
21 :
22 : #include <tools/shl.hxx>
23 : #include <svl/intitem.hxx>
24 : #include <sfx2/dispatch.hxx>
25 : #include <sfx2/viewsh.hxx>
26 : #include <sfx2/viewfrm.hxx>
27 : #include <sfx2/imagemgr.hxx>
28 : #include <vcl/toolbox.hxx>
29 :
30 : #include "tbinsert.hxx"
31 : #include "tbinsert.hrc"
32 : #include "global.hxx"
33 : #include "scmod.hxx"
34 : #include "scresid.hxx"
35 : #include "sc.hrc"
36 :
37 0 : SFX_IMPL_TOOLBOX_CONTROL( ScTbxInsertCtrl, SfxUInt16Item);
38 :
39 : // ToolBox - Controller
40 :
41 0 : ScTbxInsertCtrl::ScTbxInsertCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
42 : SfxToolBoxControl( nSlotId, nId, rTbx ),
43 0 : nLastSlotId(0)
44 : {
45 0 : rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
46 0 : }
47 :
48 0 : ScTbxInsertCtrl::~ScTbxInsertCtrl()
49 : {
50 0 : }
51 :
52 0 : void ScTbxInsertCtrl::StateChanged( sal_uInt16 /* nSID */, SfxItemState eState,
53 : const SfxPoolItem* pState )
54 : {
55 0 : GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) );
56 :
57 0 : if( eState == SFX_ITEM_AVAILABLE )
58 : {
59 :
60 0 : const SfxUInt16Item* pItem = PTR_CAST( SfxUInt16Item, pState );
61 0 : if(pItem)
62 : {
63 0 : nLastSlotId = pItem->GetValue();
64 0 : sal_uInt16 nImageId = nLastSlotId ? nLastSlotId : GetSlotId();
65 0 : OUString aSlotURL( "slot:" );
66 0 : aSlotURL += OUString::number( nImageId);
67 : Image aImage = GetImage( m_xFrame,
68 : aSlotURL,
69 0 : hasBigImages()
70 0 : );
71 0 : GetToolBox().SetItemImage(GetId(), aImage);
72 : }
73 : }
74 0 : }
75 :
76 0 : SfxPopupWindow* ScTbxInsertCtrl::CreatePopupWindow()
77 : {
78 0 : sal_uInt16 nSlotId = GetSlotId();
79 0 : if (nSlotId == SID_TBXCTL_INSERT)
80 : {
81 0 : OUString aInsertBarResStr( "private:resource/toolbar/insertbar" );
82 0 : createAndPositionSubToolBar( aInsertBarResStr );
83 : }
84 0 : else if (nSlotId == SID_TBXCTL_INSCELLS)
85 : {
86 0 : OUString aInsertCellsBarResStr( "private:resource/toolbar/insertcellsbar" );
87 0 : createAndPositionSubToolBar( aInsertCellsBarResStr );
88 : }
89 : else
90 : {
91 0 : OUString aInsertObjectBarResStr( "private:resource/toolbar/insertobjectbar" );
92 0 : createAndPositionSubToolBar( aInsertObjectBarResStr );
93 : }
94 0 : return NULL;
95 : }
96 :
97 0 : SfxPopupWindowType ScTbxInsertCtrl::GetPopupWindowType() const
98 : {
99 0 : return nLastSlotId ? SFX_POPUPWINDOW_ONTIMEOUT : SFX_POPUPWINDOW_ONCLICK;
100 : }
101 :
102 0 : void ScTbxInsertCtrl::Select( sal_Bool /* bMod1 */ )
103 : {
104 0 : SfxViewShell* pCurSh( SfxViewShell::Current() );
105 0 : SfxDispatcher* pDispatch( 0 );
106 :
107 0 : if ( pCurSh )
108 : {
109 0 : SfxViewFrame* pViewFrame = pCurSh->GetViewFrame();
110 0 : if ( pViewFrame )
111 0 : pDispatch = pViewFrame->GetDispatcher();
112 : }
113 :
114 0 : if ( pDispatch )
115 0 : pDispatch->Execute(nLastSlotId);
116 0 : }
117 :
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|