GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / sc / source / ui / view / tabvwsh9.cxx
blob22d2df68b9e6a259580b72058e96c49039d5718a
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 <svx/svdmark.hxx>
21 #include <svx/svdview.hxx>
22 #include <svx/galbrws.hxx>
23 #include <svx/gallery.hxx>
24 #include <svx/hlnkitem.hxx>
25 #include <sfx2/bindings.hxx>
26 #include <sfx2/request.hxx>
27 #include <sfx2/viewfrm.hxx>
28 #include <sfx2/dispatch.hxx>
29 #include <svl/whiter.hxx>
31 #include "tabvwsh.hxx"
32 #include "viewdata.hxx"
33 #include "tabview.hxx"
34 #include "drwlayer.hxx"
35 #include "userdat.hxx"
36 #include "docsh.hxx"
38 #include <svx/galleryitem.hxx>
39 #include <com/sun/star/gallery/GalleryItemType.hpp>
41 class SvxIMapDlg;
43 sal_uInt16 ScIMapChildWindowId();
44 SvxIMapDlg* ScGetIMapDlg();
45 const void* ScIMapDlgGetObj( SvxIMapDlg* pDlg );
46 const ImageMap& ScIMapDlgGetMap( SvxIMapDlg* pDlg );
48 //------------------------------------------------------------------
50 void ScTabViewShell::ExecChildWin(SfxRequest& rReq)
52 sal_uInt16 nSlot = rReq.GetSlot();
53 switch(nSlot)
55 case SID_GALLERY:
57 SfxViewFrame* pThisFrame = GetViewFrame();
58 pThisFrame->ToggleChildWindow( GalleryChildWindow::GetChildWindowId() );
59 pThisFrame->GetBindings().Invalidate( SID_GALLERY );
60 rReq.Ignore();
62 break;
66 void ScTabViewShell::GetChildWinState( SfxItemSet& rSet )
68 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GALLERY ) )
70 sal_uInt16 nId = GalleryChildWindow::GetChildWindowId();
71 rSet.Put( SfxBoolItem( SID_GALLERY, GetViewFrame()->HasChildWindow( nId ) ) );
75 //------------------------------------------------------------------
77 void ScTabViewShell::ExecGallery( SfxRequest& rReq )
79 const SfxItemSet* pArgs = rReq.GetArgs();
81 SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, sal_False );
82 if ( !pGalleryItem )
83 return;
85 sal_Int8 nType( pGalleryItem->GetType() );
86 if ( nType == com::sun::star::gallery::GalleryItemType::GRAPHIC )
88 MakeDrawLayer();
90 Graphic aGraphic( pGalleryItem->GetGraphic() );
91 Point aPos = GetInsertPos();
93 OUString aPath, aFilter;
94 PasteGraphic( aPos, aGraphic, aPath, aFilter );
96 else if ( nType == com::sun::star::gallery::GalleryItemType::MEDIA )
98 // for sounds (linked or not), insert a hyperlink button,
99 // like in Impress and Writer
100 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
101 GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
105 void ScTabViewShell::GetGalleryState( SfxItemSet& /* rSet */ )
109 //------------------------------------------------------------------
111 ScInputHandler* ScTabViewShell::GetInputHandler() const
113 return pInputHandler;
116 //------------------------------------------------------------------
118 OUString ScTabViewShell::GetDescription() const
120 return OUString(" ** Test ** ");
123 void ScTabViewShell::ExecImageMap( SfxRequest& rReq )
125 sal_uInt16 nSlot = rReq.GetSlot();
126 switch(nSlot)
128 case SID_IMAP:
130 SfxViewFrame* pThisFrame = GetViewFrame();
131 sal_uInt16 nId = ScIMapChildWindowId();
132 pThisFrame->ToggleChildWindow( nId );
133 GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
135 if ( pThisFrame->HasChildWindow( nId ) )
137 SvxIMapDlg* pDlg = ScGetIMapDlg();
138 if ( pDlg )
140 SdrView* pDrView = GetSdrView();
141 if ( pDrView )
143 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
144 if ( rMarkList.GetMarkCount() == 1 )
145 UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
150 rReq.Ignore();
152 break;
154 case SID_IMAP_EXEC:
156 SdrView* pDrView = GetSdrView();
157 SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : 0;
159 if ( pMark )
161 SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
162 SvxIMapDlg* pDlg = ScGetIMapDlg();
164 if ( ScIMapDlgGetObj(pDlg) == (void*) pSdrObj )
166 const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
167 ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj );
169 if ( !pIMapInfo )
170 pSdrObj->AppendUserData( new ScIMapInfo( rImageMap ) );
171 else
172 pIMapInfo->SetImageMap( rImageMap );
174 GetViewData()->GetDocShell()->SetDrawModified();
178 break;
182 void ScTabViewShell::GetImageMapState( SfxItemSet& rSet )
184 SfxWhichIter aIter(rSet);
185 sal_uInt16 nWhich = aIter.FirstWhich();
186 while ( nWhich )
188 switch ( nWhich )
190 case SID_IMAP:
192 // Disabled wird nicht mehr...
194 sal_Bool bThere = false;
195 SfxViewFrame* pThisFrame = GetViewFrame();
196 sal_uInt16 nId = ScIMapChildWindowId();
197 if ( pThisFrame->KnowsChildWindow(nId) )
198 if ( pThisFrame->HasChildWindow(nId) )
199 bThere = sal_True;
201 ObjectSelectionType eType=GetCurObjectSelectionType();
202 sal_Bool bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
203 if(!bThere && !bEnable)
205 rSet.DisableItem( nWhich );
207 else
209 rSet.Put( SfxBoolItem( nWhich, bThere ) );
212 break;
214 case SID_IMAP_EXEC:
216 sal_Bool bDisable = sal_True;
218 SdrView* pDrView = GetSdrView();
219 if ( pDrView )
221 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
222 if ( rMarkList.GetMarkCount() == 1 )
223 if ( ScIMapDlgGetObj(ScGetIMapDlg()) ==
224 (void*) rMarkList.GetMark(0)->GetMarkedSdrObj() )
225 bDisable = false;
228 rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
230 break;
233 nWhich = aIter.NextWhich();
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */