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