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/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"
38 #include <svx/galleryitem.hxx>
39 #include <com/sun/star/gallery/GalleryItemType.hpp>
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();
57 SfxViewFrame
* pThisFrame
= GetViewFrame();
58 pThisFrame
->ToggleChildWindow( GalleryChildWindow::GetChildWindowId() );
59 pThisFrame
->GetBindings().Invalidate( SID_GALLERY
);
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
);
85 sal_Int8
nType( pGalleryItem
->GetType() );
86 if ( nType
== com::sun::star::gallery::GalleryItemType::GRAPHIC
)
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();
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();
140 SdrView
* pDrView
= GetSdrView();
143 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
144 if ( rMarkList
.GetMarkCount() == 1 )
145 UpdateIMap( rMarkList
.GetMark( 0 )->GetMarkedSdrObj() );
156 SdrView
* pDrView
= GetSdrView();
157 SdrMark
* pMark
= pDrView
? pDrView
->GetMarkedObjectList().GetMark(0) : 0;
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
);
170 pSdrObj
->AppendUserData( new ScIMapInfo( rImageMap
) );
172 pIMapInfo
->SetImageMap( rImageMap
);
174 GetViewData()->GetDocShell()->SetDrawModified();
182 void ScTabViewShell::GetImageMapState( SfxItemSet
& rSet
)
184 SfxWhichIter
aIter(rSet
);
185 sal_uInt16 nWhich
= aIter
.FirstWhich();
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
) )
201 ObjectSelectionType eType
=GetCurObjectSelectionType();
202 sal_Bool bEnable
=(eType
==OST_OleObject
) ||(eType
==OST_Graphic
);
203 if(!bThere
&& !bEnable
)
205 rSet
.DisableItem( nWhich
);
209 rSet
.Put( SfxBoolItem( nWhich
, bThere
) );
216 sal_Bool bDisable
= sal_True
;
218 SdrView
* pDrView
= GetSdrView();
221 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
222 if ( rMarkList
.GetMarkCount() == 1 )
223 if ( ScIMapDlgGetObj(ScGetIMapDlg()) ==
224 (void*) rMarkList
.GetMark(0)->GetMarkedSdrObj() )
228 rSet
.Put( SfxBoolItem( SID_IMAP_EXEC
, bDisable
) );
233 nWhich
= aIter
.NextWhich();
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */