fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / cctrl / tbinsert.cxx
blob2df6456fef197cd3e27d78777625f5ee19426c52
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <string>
22 #include <svl/intitem.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <sfx2/viewsh.hxx>
25 #include <sfx2/viewfrm.hxx>
26 #include <sfx2/imagemgr.hxx>
27 #include <vcl/toolbox.hxx>
29 #include "tbinsert.hxx"
30 #include "tbinsert.hrc"
31 #include "global.hxx"
32 #include "scmod.hxx"
33 #include "scresid.hxx"
34 #include "sc.hrc"
36 SFX_IMPL_TOOLBOX_CONTROL( ScTbxInsertCtrl, SfxUInt16Item);
38 // ToolBox - Controller
40 ScTbxInsertCtrl::ScTbxInsertCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
41 SfxToolBoxControl( nSlotId, nId, rTbx ),
42 nLastSlotId(0)
44 rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
47 ScTbxInsertCtrl::~ScTbxInsertCtrl()
51 void ScTbxInsertCtrl::StateChanged( sal_uInt16 /* nSID */, SfxItemState eState,
52 const SfxPoolItem* pState )
54 GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SfxItemState::DISABLED) );
56 if( eState == SfxItemState::DEFAULT )
59 const SfxUInt16Item* pItem = PTR_CAST( SfxUInt16Item, pState );
60 if(pItem)
62 nLastSlotId = pItem->GetValue();
63 sal_uInt16 nImageId = nLastSlotId ? nLastSlotId : GetSlotId();
64 OUString aSlotURL( "slot:" );
65 aSlotURL += OUString::number( nImageId);
66 Image aImage = GetImage( m_xFrame,
67 aSlotURL,
68 hasBigImages()
70 GetToolBox().SetItemImage(GetId(), aImage);
75 VclPtr<SfxPopupWindow> ScTbxInsertCtrl::CreatePopupWindow()
77 sal_uInt16 nSlotId = GetSlotId();
78 if (nSlotId == SID_TBXCTL_INSERT)
80 OUString aInsertBarResStr( "private:resource/toolbar/insertbar" );
81 createAndPositionSubToolBar( aInsertBarResStr );
83 else if (nSlotId == SID_TBXCTL_INSCELLS)
85 OUString aInsertCellsBarResStr( "private:resource/toolbar/insertcellsbar" );
86 createAndPositionSubToolBar( aInsertCellsBarResStr );
88 else
90 OUString aInsertObjectBarResStr( "private:resource/toolbar/insertobjectbar" );
91 createAndPositionSubToolBar( aInsertObjectBarResStr );
93 return NULL;
96 SfxPopupWindowType ScTbxInsertCtrl::GetPopupWindowType() const
98 return nLastSlotId ? SfxPopupWindowType::ONTIMEOUT : SfxPopupWindowType::ONCLICK;
101 void ScTbxInsertCtrl::Select( sal_uInt16 /*nSelectModifier*/ )
103 SfxViewShell* pCurSh( SfxViewShell::Current() );
104 SfxDispatcher* pDispatch( 0 );
106 if ( pCurSh )
108 SfxViewFrame* pViewFrame = pCurSh->GetViewFrame();
109 if ( pViewFrame )
110 pDispatch = pViewFrame->GetDispatcher();
113 if ( pDispatch )
114 pDispatch->Execute(nLastSlotId);
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */