1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 32 33 // INCLUDE --------------------------------------------------------------- 34 35 #include <svx/svdmark.hxx> 36 #include <svx/svdview.hxx> 37 #include <svx/galbrws.hxx> 38 #include <svx/gallery.hxx> 39 #include <svx/hlnkitem.hxx> 40 #include <sfx2/bindings.hxx> 41 #include <sfx2/request.hxx> 42 #include <sfx2/viewfrm.hxx> 43 #include <sfx2/dispatch.hxx> 44 #include <svl/whiter.hxx> 45 #include <avmedia/mediaplayer.hxx> 46 47 #include "tabvwsh.hxx" 48 #include "viewdata.hxx" 49 #include "tabview.hxx" 50 #include "drwlayer.hxx" 51 #include "userdat.hxx" 52 #include "docsh.hxx" 53 54 // forwards -> galwrap.cxx (wg. CLOOKs) 55 56 sal_uInt16 GallerySGA_FORMAT_GRAPHIC(); 57 Graphic GalleryGetGraphic (); 58 sal_Bool GalleryIsLinkage (); 59 String GalleryGetFullPath (); 60 String GalleryGetFilterName (); 61 62 // forwards -> imapwrap.cxx (wg. CLOOKs) 63 64 class SvxIMapDlg; 65 66 sal_uInt16 ScIMapChildWindowId(); 67 SvxIMapDlg* ScGetIMapDlg(); 68 const void* ScIMapDlgGetObj( SvxIMapDlg* pDlg ); 69 const ImageMap& ScIMapDlgGetMap( SvxIMapDlg* pDlg ); 70 71 //------------------------------------------------------------------ 72 73 void ScTabViewShell::ExecChildWin(SfxRequest& rReq) 74 { 75 sal_uInt16 nSlot = rReq.GetSlot(); 76 switch(nSlot) 77 { 78 case SID_GALLERY: 79 { 80 SfxViewFrame* pThisFrame = GetViewFrame(); 81 pThisFrame->ToggleChildWindow( GalleryChildWindow::GetChildWindowId() ); 82 pThisFrame->GetBindings().Invalidate( SID_GALLERY ); 83 rReq.Ignore(); 84 } 85 break; 86 87 case SID_AVMEDIA_PLAYER: 88 { 89 SfxViewFrame* pThisFrame = GetViewFrame(); 90 pThisFrame->ToggleChildWindow( ::avmedia::MediaPlayer::GetChildWindowId() ); 91 pThisFrame->GetBindings().Invalidate( SID_AVMEDIA_PLAYER ); 92 rReq.Ignore(); 93 } 94 break; 95 } 96 } 97 98 void ScTabViewShell::GetChildWinState( SfxItemSet& rSet ) 99 { 100 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GALLERY ) ) 101 { 102 sal_uInt16 nId = GalleryChildWindow::GetChildWindowId(); 103 rSet.Put( SfxBoolItem( SID_GALLERY, GetViewFrame()->HasChildWindow( nId ) ) ); 104 } 105 else if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_AVMEDIA_PLAYER ) ) 106 { 107 sal_uInt16 nId = ::avmedia::MediaPlayer::GetChildWindowId(); 108 rSet.Put( SfxBoolItem( SID_AVMEDIA_PLAYER, GetViewFrame()->HasChildWindow( nId ) ) ); 109 } 110 } 111 112 //------------------------------------------------------------------ 113 114 void ScTabViewShell::ExecGallery( SfxRequest& rReq ) 115 { 116 const SfxItemSet* pArgs = rReq.GetArgs(); 117 118 if ( pArgs ) 119 { 120 const SfxPoolItem* pItem = NULL; 121 SfxItemState eState = pArgs->GetItemState(SID_GALLERY_FORMATS, sal_True, &pItem); 122 if ( eState == SFX_ITEM_SET ) 123 { 124 sal_uInt32 nFormats = ((const SfxUInt32Item*)pItem)->GetValue(); 125 126 /****************************************************************** 127 * Graphik einfuegen 128 ******************************************************************/ 129 if ( nFormats & GallerySGA_FORMAT_GRAPHIC() ) 130 { 131 MakeDrawLayer(); 132 133 Graphic aGraphic = GalleryGetGraphic(); 134 Point aPos = GetInsertPos(); 135 136 String aPath, aFilter; 137 if ( GalleryIsLinkage() ) // als Link einfuegen? 138 { 139 aPath = GalleryGetFullPath(); 140 aFilter = GalleryGetFilterName(); 141 } 142 143 PasteGraphic( aPos, aGraphic, aPath, aFilter ); 144 } 145 else if ( nFormats & SGA_FORMAT_SOUND ) 146 { 147 // #98115# for sounds (linked or not), insert a hyperlink button, 148 // like in Impress and Writer 149 150 GalleryExplorer* pGal = SVX_GALLERY(); 151 if ( pGal ) 152 { 153 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) ); 154 GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L ); 155 } 156 } 157 } 158 } 159 } 160 161 void ScTabViewShell::GetGalleryState( SfxItemSet& /* rSet */ ) 162 { 163 } 164 165 //------------------------------------------------------------------ 166 167 ScInputHandler* ScTabViewShell::GetInputHandler() const 168 { 169 return pInputHandler; 170 } 171 172 //------------------------------------------------------------------ 173 174 String __EXPORT ScTabViewShell::GetDescription() const 175 { 176 return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" ** Test ** ")); 177 } 178 179 void ScTabViewShell::ExecImageMap( SfxRequest& rReq ) 180 { 181 sal_uInt16 nSlot = rReq.GetSlot(); 182 switch(nSlot) 183 { 184 case SID_IMAP: 185 { 186 SfxViewFrame* pThisFrame = GetViewFrame(); 187 sal_uInt16 nId = ScIMapChildWindowId(); 188 pThisFrame->ToggleChildWindow( nId ); 189 GetViewFrame()->GetBindings().Invalidate( SID_IMAP ); 190 191 if ( pThisFrame->HasChildWindow( nId ) ) 192 { 193 SvxIMapDlg* pDlg = ScGetIMapDlg(); 194 if ( pDlg ) 195 { 196 SdrView* pDrView = GetSdrView(); 197 if ( pDrView ) 198 { 199 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); 200 if ( rMarkList.GetMarkCount() == 1 ) 201 UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() ); 202 } 203 } 204 } 205 206 rReq.Ignore(); 207 } 208 break; 209 210 case SID_IMAP_EXEC: 211 { 212 SdrView* pDrView = GetSdrView(); 213 SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : 0; 214 215 if ( pMark ) 216 { 217 SdrObject* pSdrObj = pMark->GetMarkedSdrObj(); 218 SvxIMapDlg* pDlg = ScGetIMapDlg(); 219 220 if ( ScIMapDlgGetObj(pDlg) == (void*) pSdrObj ) 221 { 222 const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg); 223 ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj ); 224 225 if ( !pIMapInfo ) 226 pSdrObj->InsertUserData( new ScIMapInfo( rImageMap ) ); 227 else 228 pIMapInfo->SetImageMap( rImageMap ); 229 230 GetViewData()->GetDocShell()->SetDrawModified(); 231 } 232 } 233 } 234 break; 235 } 236 } 237 238 void ScTabViewShell::GetImageMapState( SfxItemSet& rSet ) 239 { 240 SfxWhichIter aIter(rSet); 241 sal_uInt16 nWhich = aIter.FirstWhich(); 242 while ( nWhich ) 243 { 244 switch ( nWhich ) 245 { 246 case SID_IMAP: 247 { 248 // Disabled wird nicht mehr... 249 250 sal_Bool bThere = sal_False; 251 SfxViewFrame* pThisFrame = GetViewFrame(); 252 sal_uInt16 nId = ScIMapChildWindowId(); 253 if ( pThisFrame->KnowsChildWindow(nId) ) 254 if ( pThisFrame->HasChildWindow(nId) ) 255 bThere = sal_True; 256 257 ObjectSelectionType eType=GetCurObjectSelectionType(); 258 sal_Bool bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic); 259 if(!bThere && !bEnable) 260 { 261 rSet.DisableItem( nWhich ); 262 } 263 else 264 { 265 rSet.Put( SfxBoolItem( nWhich, bThere ) ); 266 } 267 } 268 break; 269 270 case SID_IMAP_EXEC: 271 { 272 sal_Bool bDisable = sal_True; 273 274 SdrView* pDrView = GetSdrView(); 275 if ( pDrView ) 276 { 277 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); 278 if ( rMarkList.GetMarkCount() == 1 ) 279 if ( ScIMapDlgGetObj(ScGetIMapDlg()) == 280 (void*) rMarkList.GetMark(0)->GetMarkedSdrObj() ) 281 bDisable = sal_False; 282 } 283 284 rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) ); 285 } 286 break; 287 } 288 289 nWhich = aIter.NextWhich(); 290 } 291 } 292 293 294 295 296