1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tabvwsh9.cxx,v $
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"
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)
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();
83 SfxViewFrame
* pThisFrame
= GetViewFrame();
84 pThisFrame
->ToggleChildWindow( GalleryChildWindow::GetChildWindowId() );
85 pThisFrame
->GetBindings().Invalidate( SID_GALLERY
);
90 case SID_AVMEDIA_PLAYER
:
92 SfxViewFrame
* pThisFrame
= GetViewFrame();
93 pThisFrame
->ToggleChildWindow( ::avmedia::MediaPlayer::GetChildWindowId() );
94 pThisFrame
->GetBindings().Invalidate( SID_AVMEDIA_PLAYER
);
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();
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 /******************************************************************
131 ******************************************************************/
132 if ( nFormats
& GallerySGA_FORMAT_GRAPHIC() )
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();
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();
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();
199 SdrView
* pDrView
= GetSdrView();
202 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
203 if ( rMarkList
.GetMarkCount() == 1 )
204 UpdateIMap( rMarkList
.GetMark( 0 )->GetMarkedSdrObj() );
215 SdrView
* pDrView
= GetSdrView();
216 SdrMark
* pMark
= pDrView
? pDrView
->GetMarkedObjectList().GetMark(0) : 0;
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
);
229 pSdrObj
->InsertUserData( new ScIMapInfo( rImageMap
) );
231 pIMapInfo
->SetImageMap( rImageMap
);
233 GetViewData()->GetDocShell()->SetDrawModified();
241 void ScTabViewShell::GetImageMapState( SfxItemSet
& rSet
)
243 SfxWhichIter
aIter(rSet
);
244 USHORT nWhich
= aIter
.FirstWhich();
251 // Disabled wird nicht mehr...
254 SfxViewFrame
* pThisFrame
= GetViewFrame();
255 USHORT nId
= ScIMapChildWindowId();
256 if ( pThisFrame
->KnowsChildWindow(nId
) )
257 if ( pThisFrame
->HasChildWindow(nId
) )
260 ObjectSelectionType eType
=GetCurObjectSelectionType();
261 BOOL bEnable
=(eType
==OST_OleObject
) ||(eType
==OST_Graphic
);
262 if(!bThere
&& !bEnable
)
264 rSet
.DisableItem( nWhich
);
268 rSet
.Put( SfxBoolItem( nWhich
, bThere
) );
275 BOOL bDisable
= TRUE
;
277 SdrView
* pDrView
= GetSdrView();
280 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
281 if ( rMarkList
.GetMarkCount() == 1 )
282 if ( ScIMapDlgGetObj(ScGetIMapDlg()) ==
283 (void*) rMarkList
.GetMark(0)->GetMarkedSdrObj() )
287 rSet
.Put( SfxBoolItem( SID_IMAP_EXEC
, bDisable
) );
292 nWhich
= aIter
.NextWhich();