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/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 <sfx2/sidebar/Sidebar.hxx>
30 #include <svl/whiter.hxx>
32 #include "imapwrap.hxx"
33 #include "tabvwsh.hxx"
34 #include "viewdata.hxx"
35 #include "tabview.hxx"
36 #include "drwlayer.hxx"
37 #include "userdat.hxx"
40 #include <svx/galleryitem.hxx>
41 #include <com/sun/star/gallery/GalleryItemType.hpp>
45 void ScTabViewShell::ExecChildWin(SfxRequest
& rReq
)
47 sal_uInt16 nSlot
= rReq
.GetSlot();
52 // First make sure that the sidebar is visible
53 GetViewFrame()->ShowChildWindow(SID_SIDEBAR
);
55 ::sfx2::sidebar::Sidebar::ShowPanel(
57 GetViewFrame()->GetFrame().GetFrameInterface());
63 void ScTabViewShell::ExecGallery( SfxRequest
& rReq
)
65 const SfxItemSet
* pArgs
= rReq
.GetArgs();
67 SFX_ITEMSET_ARG( pArgs
, pGalleryItem
, SvxGalleryItem
, SID_GALLERY_FORMATS
, false );
71 sal_Int8
nType( pGalleryItem
->GetType() );
72 if ( nType
== com::sun::star::gallery::GalleryItemType::GRAPHIC
)
76 Graphic
aGraphic( pGalleryItem
->GetGraphic() );
77 Point aPos
= GetInsertPos();
79 OUString aPath
, aFilter
;
80 PasteGraphic( aPos
, aGraphic
, aPath
, aFilter
);
82 else if ( nType
== com::sun::star::gallery::GalleryItemType::MEDIA
)
84 // for sounds (linked or not), insert a hyperlink button,
85 // like in Impress and Writer
86 const SfxStringItem
aMediaURLItem( SID_INSERT_AVMEDIA
, pGalleryItem
->GetURL() );
87 GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA
, SfxCallMode::SYNCHRON
, &aMediaURLItem
, 0L );
91 void ScTabViewShell::ExecImageMap( SfxRequest
& rReq
)
93 sal_uInt16 nSlot
= rReq
.GetSlot();
98 SfxViewFrame
* pThisFrame
= GetViewFrame();
99 sal_uInt16 nId
= ScIMapChildWindowId();
100 pThisFrame
->ToggleChildWindow( nId
);
101 GetViewFrame()->GetBindings().Invalidate( SID_IMAP
);
103 if ( pThisFrame
->HasChildWindow( nId
) )
105 SvxIMapDlg
* pDlg
= GetIMapDlg();
108 SdrView
* pDrView
= GetSdrView();
111 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
112 if ( rMarkList
.GetMarkCount() == 1 )
113 UpdateIMap( rMarkList
.GetMark( 0 )->GetMarkedSdrObj() );
124 SdrView
* pDrView
= GetSdrView();
125 SdrMark
* pMark
= pDrView
? pDrView
->GetMarkedObjectList().GetMark(0) : 0;
129 SdrObject
* pSdrObj
= pMark
->GetMarkedSdrObj();
130 SvxIMapDlg
* pDlg
= GetIMapDlg();
132 if ( ScIMapDlgGetObj(pDlg
) == (void*) pSdrObj
)
134 const ImageMap
& rImageMap
= ScIMapDlgGetMap(pDlg
);
135 ScIMapInfo
* pIMapInfo
= ScDrawLayer::GetIMapInfo( pSdrObj
);
138 pSdrObj
->AppendUserData( new ScIMapInfo( rImageMap
) );
140 pIMapInfo
->SetImageMap( rImageMap
);
142 GetViewData().GetDocShell()->SetDrawModified();
150 void ScTabViewShell::GetImageMapState( SfxItemSet
& rSet
)
152 SfxWhichIter
aIter(rSet
);
153 sal_uInt16 nWhich
= aIter
.FirstWhich();
160 // Disabled wird nicht mehr...
163 SfxViewFrame
* pThisFrame
= GetViewFrame();
164 sal_uInt16 nId
= ScIMapChildWindowId();
165 if ( pThisFrame
->KnowsChildWindow(nId
) )
166 if ( pThisFrame
->HasChildWindow(nId
) )
169 ObjectSelectionType eType
=GetCurObjectSelectionType();
170 bool bEnable
=(eType
==OST_OleObject
) ||(eType
==OST_Graphic
);
171 if(!bThere
&& !bEnable
)
173 rSet
.DisableItem( nWhich
);
177 rSet
.Put( SfxBoolItem( nWhich
, bThere
) );
184 bool bDisable
= true;
186 SdrView
* pDrView
= GetSdrView();
189 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
190 if ( rMarkList
.GetMarkCount() == 1 )
191 if ( ScIMapDlgGetObj(GetIMapDlg()) ==
192 (void*) rMarkList
.GetMark(0)->GetMarkedSdrObj() )
196 rSet
.Put( SfxBoolItem( SID_IMAP_EXEC
, bDisable
) );
201 nWhich
= aIter
.NextWhich();
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */