tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / view / tabvwsh9.cxx
blob9127bb598a1bd4d76a64cd9bc0245be3abc4651e
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/imapdlg.hxx>
21 #include <svx/svdmark.hxx>
22 #include <svx/svdview.hxx>
23 #include <svx/ImageMapInfo.hxx>
24 #include <svx/svxids.hrc>
25 #include <sfx2/bindings.hxx>
26 #include <sfx2/request.hxx>
27 #include <sfx2/viewfrm.hxx>
28 #include <sfx2/dispatch.hxx>
29 #include <sfx2/sidebar/Sidebar.hxx>
30 #include <svl/whiter.hxx>
31 #include <svl/stritem.hxx>
33 #include "imapwrap.hxx"
34 #include <tabvwsh.hxx>
35 #include <viewdata.hxx>
36 #include <docsh.hxx>
38 #include <svx/galleryitem.hxx>
39 #include <com/sun/star/gallery/GalleryItemType.hpp>
41 class SvxIMapDlg;
43 void ScTabViewShell::ExecChildWin(const SfxRequest& rReq)
45 sal_uInt16 nSlot = rReq.GetSlot();
46 switch(nSlot)
48 case SID_GALLERY:
50 // First make sure that the sidebar is visible
51 GetViewFrame().ShowChildWindow(SID_SIDEBAR);
53 ::sfx2::sidebar::Sidebar::ShowPanel(
54 u"GalleryPanel",
55 GetViewFrame().GetFrame().GetFrameInterface());
57 break;
61 void ScTabViewShell::ExecGallery( const SfxRequest& rReq )
63 const SfxItemSet* pArgs = rReq.GetArgs();
65 const SvxGalleryItem* pGalleryItem = SfxItemSet::GetItem<SvxGalleryItem>(pArgs, SID_GALLERY_FORMATS, false);
66 if ( !pGalleryItem )
67 return;
69 sal_Int8 nType( pGalleryItem->GetType() );
70 if ( nType == css::gallery::GalleryItemType::GRAPHIC )
72 MakeDrawLayer();
74 Graphic aGraphic( pGalleryItem->GetGraphic() );
75 Point aPos = GetInsertPos();
77 PasteGraphic( aPos, aGraphic, OUString() );
79 else if ( nType == css::gallery::GalleryItemType::MEDIA )
81 // for sounds (linked or not), insert a hyperlink button,
82 // like in Impress and Writer
83 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
84 GetViewFrame().GetDispatcher()->ExecuteList(SID_INSERT_AVMEDIA,
85 SfxCallMode::SYNCHRON, { &aMediaURLItem });
89 void ScTabViewShell::ExecImageMap( SfxRequest& rReq )
91 sal_uInt16 nSlot = rReq.GetSlot();
92 switch(nSlot)
94 case SID_IMAP:
96 SfxViewFrame& rThisFrame = GetViewFrame();
97 sal_uInt16 nId = ScIMapChildWindowId();
98 rThisFrame.ToggleChildWindow( nId );
99 GetViewFrame().GetBindings().Invalidate( SID_IMAP );
101 if ( rThisFrame.HasChildWindow( nId ) )
103 SvxIMapDlg* pDlg = GetIMapDlg();
104 if ( pDlg )
106 SdrView* pDrView = GetScDrawView();
107 if ( pDrView )
109 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
110 if ( rMarkList.GetMarkCount() == 1 )
111 UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
116 rReq.Ignore();
118 break;
120 case SID_IMAP_EXEC:
122 SdrView* pDrView = GetScDrawView();
123 SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : nullptr;
125 if ( pMark )
127 SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
128 SvxIMapDlg* pDlg = GetIMapDlg();
130 if ( ScIMapDlgGetObj(pDlg) == static_cast<void*>(pSdrObj) )
132 const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
133 SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo( pSdrObj );
135 if ( !pIMapInfo )
136 pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( rImageMap )) );
137 else
138 pIMapInfo->SetImageMap( rImageMap );
140 GetViewData().GetDocShell()->SetDrawModified();
144 break;
148 void ScTabViewShell::GetImageMapState( SfxItemSet& rSet )
150 SfxWhichIter aIter(rSet);
151 sal_uInt16 nWhich = aIter.FirstWhich();
152 while ( nWhich )
154 switch ( nWhich )
156 case SID_IMAP:
158 // We don't disable this anymore
160 bool bThere = false;
161 SfxViewFrame& rThisFrame = GetViewFrame();
162 sal_uInt16 nId = ScIMapChildWindowId();
163 if ( rThisFrame.KnowsChildWindow(nId) )
164 if ( rThisFrame.HasChildWindow(nId) )
165 bThere = true;
167 ObjectSelectionType eType=GetCurObjectSelectionType();
168 bool bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
169 if(!bThere && !bEnable)
171 rSet.DisableItem( nWhich );
173 else
175 rSet.Put( SfxBoolItem( nWhich, bThere ) );
178 break;
180 case SID_IMAP_EXEC:
182 bool bDisable = true;
184 SdrView* pDrView = GetScDrawView();
185 if ( pDrView )
187 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
188 if ( rMarkList.GetMarkCount() == 1 )
189 if ( ScIMapDlgGetObj(GetIMapDlg()) ==
190 static_cast<void*>(rMarkList.GetMark(0)->GetMarkedSdrObj()) )
191 bDisable = false;
194 rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
196 break;
199 nWhich = aIter.NextWhich();
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */