LibreOffice Module sc (master) 1
tabvwsh9.cxx
Go to the documentation of this file.
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 <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>
30#include <svl/whiter.hxx>
31#include <svl/stritem.hxx>
32
33#include "imapwrap.hxx"
34#include <tabvwsh.hxx>
35#include <viewdata.hxx>
36#include <docsh.hxx>
37
38#include <svx/galleryitem.hxx>
39#include <com/sun/star/gallery/GalleryItemType.hpp>
40
41class SvxIMapDlg;
42
44{
45 sal_uInt16 nSlot = rReq.GetSlot();
46 switch(nSlot)
47 {
48 case SID_GALLERY:
49 {
50 // First make sure that the sidebar is visible
51 GetViewFrame().ShowChildWindow(SID_SIDEBAR);
52
54 u"GalleryPanel",
55 GetViewFrame().GetFrame().GetFrameInterface());
56 }
57 break;
58 }
59}
60
62{
63 const SfxItemSet* pArgs = rReq.GetArgs();
64
65 const SvxGalleryItem* pGalleryItem = SfxItemSet::GetItem<SvxGalleryItem>(pArgs, SID_GALLERY_FORMATS, false);
66 if ( !pGalleryItem )
67 return;
68
69 sal_Int8 nType( pGalleryItem->GetType() );
70 if ( nType == css::gallery::GalleryItemType::GRAPHIC )
71 {
73
74 Graphic aGraphic( pGalleryItem->GetGraphic() );
75 Point aPos = GetInsertPos();
76
77 PasteGraphic( aPos, aGraphic, OUString() );
78 }
79 else if ( nType == css::gallery::GalleryItemType::MEDIA )
80 {
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 });
86 }
87}
88
90{
91 sal_uInt16 nSlot = rReq.GetSlot();
92 switch(nSlot)
93 {
94 case SID_IMAP:
95 {
96 SfxViewFrame& rThisFrame = GetViewFrame();
97 sal_uInt16 nId = ScIMapChildWindowId();
98 rThisFrame.ToggleChildWindow( nId );
99 GetViewFrame().GetBindings().Invalidate( SID_IMAP );
100
101 if ( rThisFrame.HasChildWindow( nId ) )
102 {
103 SvxIMapDlg* pDlg = GetIMapDlg();
104 if ( pDlg )
105 {
106 SdrView* pDrView = GetScDrawView();
107 if ( pDrView )
108 {
109 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
110 if ( rMarkList.GetMarkCount() == 1 )
111 UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
112 }
113 }
114 }
115
116 rReq.Ignore();
117 }
118 break;
119
120 case SID_IMAP_EXEC:
121 {
122 SdrView* pDrView = GetScDrawView();
123 SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : nullptr;
124
125 if ( pMark )
126 {
127 SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
128 SvxIMapDlg* pDlg = GetIMapDlg();
129
130 if ( ScIMapDlgGetObj(pDlg) == static_cast<void*>(pSdrObj) )
131 {
132 const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
133 SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo( pSdrObj );
134
135 if ( !pIMapInfo )
136 pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SvxIMapInfo( rImageMap )) );
137 else
138 pIMapInfo->SetImageMap( rImageMap );
139
141 }
142 }
143 }
144 break;
145 }
146}
147
149{
150 SfxWhichIter aIter(rSet);
151 sal_uInt16 nWhich = aIter.FirstWhich();
152 while ( nWhich )
153 {
154 switch ( nWhich )
155 {
156 case SID_IMAP:
157 {
158 // We don't disable this anymore
159
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;
166
168 bool bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
169 if(!bThere && !bEnable)
170 {
171 rSet.DisableItem( nWhich );
172 }
173 else
174 {
175 rSet.Put( SfxBoolItem( nWhich, bThere ) );
176 }
177 }
178 break;
179
180 case SID_IMAP_EXEC:
181 {
182 bool bDisable = true;
183
184 SdrView* pDrView = GetScDrawView();
185 if ( pDrView )
186 {
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;
192 }
193
194 rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
195 }
196 break;
197 }
198
199 nWhich = aIter.NextWhich();
200 }
201}
202
203/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetDrawModified()
SetDrawModified - without Formula update.
Definition: docsh.cxx:3046
void ExecImageMap(SfxRequest &rReq)
Definition: tabvwsh9.cxx:89
void GetImageMapState(SfxItemSet &rSet)
Definition: tabvwsh9.cxx:148
void ExecGallery(const SfxRequest &rReq)
Definition: tabvwsh9.cxx:61
void ExecChildWin(const SfxRequest &rReq)
Definition: tabvwsh9.cxx:43
ObjectSelectionType GetCurObjectSelectionType() const
Definition: tabvwsh.hxx:307
void MakeDrawLayer()
Definition: tabview2.cxx:1529
Point GetInsertPos() const
Definition: tabview.cxx:1737
ScViewData & GetViewData()
Definition: tabview.hxx:344
void UpdateIMap(SdrObject *pObj)
Definition: tabview5.cxx:495
ScDrawView * GetScDrawView()
Definition: tabview.hxx:352
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
bool PasteGraphic(const Point &rPos, const Graphic &rGraphic, const OUString &rFile)
Definition: viewfun7.cxx:384
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
SdrObject * GetMarkedSdrObj() const
void AppendUserData(std::unique_ptr< SdrObjUserData > pData)
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void DisableItem(sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
void Ignore()
const SfxItemSet * GetArgs() const
SfxViewFrame * GetFrame() const
void ToggleChildWindow(sal_uInt16)
SfxBindings & GetBindings()
bool HasChildWindow(sal_uInt16)
SfxDispatcher * GetDispatcher()
bool KnowsChildWindow(sal_uInt16)
void ShowChildWindow(sal_uInt16, bool bVisible=true)
SfxViewFrame & GetViewFrame() const
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
sal_Int8 GetType() const
const OUString & GetURL() const
const css::uno::Reference< css::graphic::XGraphic > & GetGraphic() const
void SetImageMap(const ImageMap &rIMap)
static SvxIMapInfo * GetIMapInfo(const SdrObject *pObject)
static void ShowPanel(std::u16string_view rsPanelId, const css::uno::Reference< css::frame::XFrame > &rxFrame, bool bFocus=false)
float u
DocumentType eType
SVX_DLLPUBLIC SvxIMapDlg * GetIMapDlg()
const void * ScIMapDlgGetObj(const SvxIMapDlg *pDlg)
Definition: imapwrap.cxx:35
sal_uInt16 ScIMapChildWindowId()
Definition: imapwrap.cxx:24
const ImageMap & ScIMapDlgGetMap(const SvxIMapDlg *pDlg)
Definition: imapwrap.cxx:43
sal_Int16 nId
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
static SfxItemSet & rSet
ObjectSelectionType
Definition: tabvwsh.hxx:77
@ OST_Graphic
Definition: tabvwsh.hxx:88
@ OST_OleObject
Definition: tabvwsh.hxx:86
signed char sal_Int8