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