update dev300-m58
[ooovba.git] / sc / source / ui / view / tabvwsh9.cxx
blob88ebdc97ce0ef1268420e3db2b01578e983790ba
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tabvwsh9.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include <svx/svdmark.hxx>
39 #include <svx/svdview.hxx>
40 #include <svx/galbrws.hxx>
41 #include <svx/gallery.hxx>
42 #include <svx/hlnkitem.hxx>
43 #include <sfx2/bindings.hxx>
44 #include <sfx2/request.hxx>
45 #include <sfx2/viewfrm.hxx>
46 #include <sfx2/dispatch.hxx>
47 #include <svtools/whiter.hxx>
48 #include <avmedia/mediaplayer.hxx>
50 #include "tabvwsh.hxx"
51 #include "viewdata.hxx"
52 #include "tabview.hxx"
53 #include "drwlayer.hxx"
54 #include "userdat.hxx"
55 #include "docsh.hxx"
57 // forwards -> galwrap.cxx (wg. CLOOKs)
59 USHORT GallerySGA_FORMAT_GRAPHIC();
60 Graphic GalleryGetGraphic ();
61 BOOL GalleryIsLinkage ();
62 String GalleryGetFullPath ();
63 String GalleryGetFilterName ();
65 // forwards -> imapwrap.cxx (wg. CLOOKs)
67 class SvxIMapDlg;
69 USHORT ScIMapChildWindowId();
70 SvxIMapDlg* ScGetIMapDlg();
71 const void* ScIMapDlgGetObj( SvxIMapDlg* pDlg );
72 const ImageMap& ScIMapDlgGetMap( SvxIMapDlg* pDlg );
74 //------------------------------------------------------------------
76 void ScTabViewShell::ExecChildWin(SfxRequest& rReq)
78 USHORT nSlot = rReq.GetSlot();
79 switch(nSlot)
81 case SID_GALLERY:
83 SfxViewFrame* pThisFrame = GetViewFrame();
84 pThisFrame->ToggleChildWindow( GalleryChildWindow::GetChildWindowId() );
85 pThisFrame->GetBindings().Invalidate( SID_GALLERY );
86 rReq.Ignore();
88 break;
90 case SID_AVMEDIA_PLAYER:
92 SfxViewFrame* pThisFrame = GetViewFrame();
93 pThisFrame->ToggleChildWindow( ::avmedia::MediaPlayer::GetChildWindowId() );
94 pThisFrame->GetBindings().Invalidate( SID_AVMEDIA_PLAYER );
95 rReq.Ignore();
97 break;
101 void ScTabViewShell::GetChildWinState( SfxItemSet& rSet )
103 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GALLERY ) )
105 USHORT nId = GalleryChildWindow::GetChildWindowId();
106 rSet.Put( SfxBoolItem( SID_GALLERY, GetViewFrame()->HasChildWindow( nId ) ) );
108 else if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_AVMEDIA_PLAYER ) )
110 USHORT nId = ::avmedia::MediaPlayer::GetChildWindowId();
111 rSet.Put( SfxBoolItem( SID_AVMEDIA_PLAYER, GetViewFrame()->HasChildWindow( nId ) ) );
115 //------------------------------------------------------------------
117 void ScTabViewShell::ExecGallery( SfxRequest& rReq )
119 const SfxItemSet* pArgs = rReq.GetArgs();
121 if ( pArgs )
123 const SfxPoolItem* pItem = NULL;
124 SfxItemState eState = pArgs->GetItemState(SID_GALLERY_FORMATS, TRUE, &pItem);
125 if ( eState == SFX_ITEM_SET )
127 UINT32 nFormats = ((const SfxUInt32Item*)pItem)->GetValue();
129 /******************************************************************
130 * Graphik einfuegen
131 ******************************************************************/
132 if ( nFormats & GallerySGA_FORMAT_GRAPHIC() )
134 MakeDrawLayer();
136 Graphic aGraphic = GalleryGetGraphic();
137 Point aPos = GetInsertPos();
139 String aPath, aFilter;
140 if ( GalleryIsLinkage() ) // als Link einfuegen?
142 aPath = GalleryGetFullPath();
143 aFilter = GalleryGetFilterName();
146 PasteGraphic( aPos, aGraphic, aPath, aFilter );
148 else if ( nFormats & SGA_FORMAT_SOUND )
150 // #98115# for sounds (linked or not), insert a hyperlink button,
151 // like in Impress and Writer
153 GalleryExplorer* pGal = SVX_GALLERY();
154 if ( pGal )
156 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
157 GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
164 void ScTabViewShell::GetGalleryState( SfxItemSet& /* rSet */ )
168 //------------------------------------------------------------------
170 ScInputHandler* ScTabViewShell::GetInputHandler() const
172 return pInputHandler;
175 //------------------------------------------------------------------
177 String __EXPORT ScTabViewShell::GetDescription() const
179 return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" ** Test ** "));
182 void ScTabViewShell::ExecImageMap( SfxRequest& rReq )
184 USHORT nSlot = rReq.GetSlot();
185 switch(nSlot)
187 case SID_IMAP:
189 SfxViewFrame* pThisFrame = GetViewFrame();
190 USHORT nId = ScIMapChildWindowId();
191 pThisFrame->ToggleChildWindow( nId );
192 GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
194 if ( pThisFrame->HasChildWindow( nId ) )
196 SvxIMapDlg* pDlg = ScGetIMapDlg();
197 if ( pDlg )
199 SdrView* pDrView = GetSdrView();
200 if ( pDrView )
202 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
203 if ( rMarkList.GetMarkCount() == 1 )
204 UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
209 rReq.Ignore();
211 break;
213 case SID_IMAP_EXEC:
215 SdrView* pDrView = GetSdrView();
216 SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : 0;
218 if ( pMark )
220 SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
221 SvxIMapDlg* pDlg = ScGetIMapDlg();
223 if ( ScIMapDlgGetObj(pDlg) == (void*) pSdrObj )
225 const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
226 ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj );
228 if ( !pIMapInfo )
229 pSdrObj->InsertUserData( new ScIMapInfo( rImageMap ) );
230 else
231 pIMapInfo->SetImageMap( rImageMap );
233 GetViewData()->GetDocShell()->SetDrawModified();
237 break;
241 void ScTabViewShell::GetImageMapState( SfxItemSet& rSet )
243 SfxWhichIter aIter(rSet);
244 USHORT nWhich = aIter.FirstWhich();
245 while ( nWhich )
247 switch ( nWhich )
249 case SID_IMAP:
251 // Disabled wird nicht mehr...
253 BOOL bThere = FALSE;
254 SfxViewFrame* pThisFrame = GetViewFrame();
255 USHORT nId = ScIMapChildWindowId();
256 if ( pThisFrame->KnowsChildWindow(nId) )
257 if ( pThisFrame->HasChildWindow(nId) )
258 bThere = TRUE;
260 ObjectSelectionType eType=GetCurObjectSelectionType();
261 BOOL bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
262 if(!bThere && !bEnable)
264 rSet.DisableItem( nWhich );
266 else
268 rSet.Put( SfxBoolItem( nWhich, bThere ) );
271 break;
273 case SID_IMAP_EXEC:
275 BOOL bDisable = TRUE;
277 SdrView* pDrView = GetSdrView();
278 if ( pDrView )
280 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
281 if ( rMarkList.GetMarkCount() == 1 )
282 if ( ScIMapDlgGetObj(ScGetIMapDlg()) ==
283 (void*) rMarkList.GetMark(0)->GetMarkedSdrObj() )
284 bDisable = FALSE;
287 rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
289 break;
292 nWhich = aIter.NextWhich();