1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
38 #include <svx/galleryitem.hxx>
39 #include <com/sun/star/gallery/GalleryItemType.hpp>
43 void ScTabViewShell::ExecChildWin(const SfxRequest
& rReq
)
45 sal_uInt16 nSlot
= rReq
.GetSlot();
50 // First make sure that the sidebar is visible
51 GetViewFrame().ShowChildWindow(SID_SIDEBAR
);
53 ::sfx2::sidebar::Sidebar::ShowPanel(
55 GetViewFrame().GetFrame().GetFrameInterface());
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);
69 sal_Int8
nType( pGalleryItem
->GetType() );
70 if ( nType
== css::gallery::GalleryItemType::GRAPHIC
)
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();
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();
106 SdrView
* pDrView
= GetScDrawView();
109 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
110 if ( rMarkList
.GetMarkCount() == 1 )
111 UpdateIMap( rMarkList
.GetMark( 0 )->GetMarkedSdrObj() );
122 SdrView
* pDrView
= GetScDrawView();
123 SdrMark
* pMark
= pDrView
? pDrView
->GetMarkedObjectList().GetMark(0) : nullptr;
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
);
136 pSdrObj
->AppendUserData( std::unique_ptr
<SdrObjUserData
>(new SvxIMapInfo( rImageMap
)) );
138 pIMapInfo
->SetImageMap( rImageMap
);
140 GetViewData().GetDocShell()->SetDrawModified();
148 void ScTabViewShell::GetImageMapState( SfxItemSet
& rSet
)
150 SfxWhichIter
aIter(rSet
);
151 sal_uInt16 nWhich
= aIter
.FirstWhich();
158 // We don't disable this anymore
161 SfxViewFrame
& rThisFrame
= GetViewFrame();
162 sal_uInt16 nId
= ScIMapChildWindowId();
163 if ( rThisFrame
.KnowsChildWindow(nId
) )
164 if ( rThisFrame
.HasChildWindow(nId
) )
167 ObjectSelectionType eType
=GetCurObjectSelectionType();
168 bool bEnable
=(eType
==OST_OleObject
) ||(eType
==OST_Graphic
);
169 if(!bThere
&& !bEnable
)
171 rSet
.DisableItem( nWhich
);
175 rSet
.Put( SfxBoolItem( nWhich
, bThere
) );
182 bool bDisable
= true;
184 SdrView
* pDrView
= GetScDrawView();
187 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
188 if ( rMarkList
.GetMarkCount() == 1 )
189 if ( ScIMapDlgGetObj(GetIMapDlg()) ==
190 static_cast<void*>(rMarkList
.GetMark(0)->GetMarkedSdrObj()) )
194 rSet
.Put( SfxBoolItem( SID_IMAP_EXEC
, bDisable
) );
199 nWhich
= aIter
.NextWhich();
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */