xref: /aoo41x/main/sc/source/ui/drawfunc/fuins1.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <sfx2/opengrf.hxx>
32*cdf0e10cSrcweir #include <svx/svdograf.hxx>
33*cdf0e10cSrcweir #include <svx/svdomedia.hxx>
34*cdf0e10cSrcweir #include <svx/svdpage.hxx>
35*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
36*cdf0e10cSrcweir #include <svx/svdview.hxx>
37*cdf0e10cSrcweir #include <svtools/filter.hxx>
38*cdf0e10cSrcweir #include <svl/stritem.hxx>
39*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
40*cdf0e10cSrcweir #include <tools/urlobj.hxx>
41*cdf0e10cSrcweir #include <avmedia/mediawindow.hxx>
42*cdf0e10cSrcweir #include <vcl/svapp.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include "fuinsert.hxx"
45*cdf0e10cSrcweir #include "tabvwsh.hxx"
46*cdf0e10cSrcweir #include "drwlayer.hxx"
47*cdf0e10cSrcweir #include "drawview.hxx"
48*cdf0e10cSrcweir #include "document.hxx"
49*cdf0e10cSrcweir #include "scresid.hxx"
50*cdf0e10cSrcweir #include "progress.hxx"
51*cdf0e10cSrcweir #include "sc.hrc"
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir ////========================================================================
56*cdf0e10cSrcweir ////	class ImportProgress
57*cdf0e10cSrcweir ////
58*cdf0e10cSrcweir ////  Bemerkung:
59*cdf0e10cSrcweir ////	Diese Klasse stellt lediglich den Handler fuer den ImportProgress des
60*cdf0e10cSrcweir ////	Grafikfilters bereit.
61*cdf0e10cSrcweir ////========================================================================
62*cdf0e10cSrcweir //
63*cdf0e10cSrcweir //class ImportProgress
64*cdf0e10cSrcweir //{
65*cdf0e10cSrcweir //public:
66*cdf0e10cSrcweir //		ImportProgress( GraphicFilter& rFilter );
67*cdf0e10cSrcweir //		~ImportProgress();
68*cdf0e10cSrcweir //
69*cdf0e10cSrcweir //	DECL_LINK( Update, GraphicFilter* );
70*cdf0e10cSrcweir //
71*cdf0e10cSrcweir //private:
72*cdf0e10cSrcweir //	ScProgress aProgress;
73*cdf0e10cSrcweir //};
74*cdf0e10cSrcweir //
75*cdf0e10cSrcweir ////------------------------------------------------------------------------
76*cdf0e10cSrcweir //
77*cdf0e10cSrcweir //ImportProgress::ImportProgress( GraphicFilter& rFilter )
78*cdf0e10cSrcweir //	: aProgress( NULL, // SfxViewFrame*, NULL == alle Docs locken
79*cdf0e10cSrcweir //				 String( ScResId(STR_INSERTGRAPHIC) ),
80*cdf0e10cSrcweir //				 100 )
81*cdf0e10cSrcweir //{
82*cdf0e10cSrcweir //	rFilter.SetUpdatePercentHdl( LINK( this, ImportProgress, Update) );
83*cdf0e10cSrcweir //}
84*cdf0e10cSrcweir //
85*cdf0e10cSrcweir ////------------------------------------------------------------------------
86*cdf0e10cSrcweir //
87*cdf0e10cSrcweir //__EXPORT ImportProgress::~ImportProgress()
88*cdf0e10cSrcweir //{
89*cdf0e10cSrcweir //	aProgress.SetState( 100 );
90*cdf0e10cSrcweir //}
91*cdf0e10cSrcweir //
92*cdf0e10cSrcweir ////------------------------------------------------------------------------
93*cdf0e10cSrcweir //
94*cdf0e10cSrcweir //IMPL_LINK( ImportProgress, Update, GraphicFilter*, pGraphicFilter )
95*cdf0e10cSrcweir //{
96*cdf0e10cSrcweir //	aProgress.SetState( pGraphicFilter->GetPercent() );
97*cdf0e10cSrcweir //	return 0;
98*cdf0e10cSrcweir //}
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir //------------------------------------------------------------------------
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir void SC_DLLPUBLIC ScLimitSizeOnDrawPage( Size& rSize, Point& rPos, const Size& rPage )
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir 	if ( !rPage.Width() || !rPage.Height() )
106*cdf0e10cSrcweir 		return;
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	Size aPageSize = rPage;
109*cdf0e10cSrcweir 	sal_Bool bNegative = aPageSize.Width() < 0;
110*cdf0e10cSrcweir 	if ( bNegative )
111*cdf0e10cSrcweir 	{
112*cdf0e10cSrcweir 		//	make everything positive temporarily
113*cdf0e10cSrcweir 		aPageSize.Width() = -aPageSize.Width();
114*cdf0e10cSrcweir 		rPos.X() = -rPos.X() - rSize.Width();
115*cdf0e10cSrcweir 	}
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	if ( rSize.Width() > aPageSize.Width() || rSize.Height() > aPageSize.Height() )
118*cdf0e10cSrcweir 	{
119*cdf0e10cSrcweir 		double fX = aPageSize.Width()  / (double) rSize.Width();
120*cdf0e10cSrcweir 		double fY = aPageSize.Height() / (double) rSize.Height();
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 		if ( fX < fY )
123*cdf0e10cSrcweir 		{
124*cdf0e10cSrcweir 			rSize.Width()  = aPageSize.Width();
125*cdf0e10cSrcweir 			rSize.Height() = (long) ( rSize.Height() * fX );
126*cdf0e10cSrcweir 		}
127*cdf0e10cSrcweir 		else
128*cdf0e10cSrcweir 		{
129*cdf0e10cSrcweir 			rSize.Height() = aPageSize.Height();
130*cdf0e10cSrcweir 			rSize.Width()  = (long) ( rSize.Width() * fY );
131*cdf0e10cSrcweir 		}
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 		if (!rSize.Width())
134*cdf0e10cSrcweir 			rSize.Width() = 1;
135*cdf0e10cSrcweir 		if (!rSize.Height())
136*cdf0e10cSrcweir 			rSize.Height() = 1;
137*cdf0e10cSrcweir 	}
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 	if ( rPos.X() + rSize.Width() > aPageSize.Width() )
140*cdf0e10cSrcweir 		rPos.X() = aPageSize.Width() - rSize.Width();
141*cdf0e10cSrcweir 	if ( rPos.Y() + rSize.Height() > aPageSize.Height() )
142*cdf0e10cSrcweir 		rPos.Y() = aPageSize.Height() - rSize.Height();
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 	if ( bNegative )
145*cdf0e10cSrcweir 		rPos.X() = -rPos.X() - rSize.Width();		// back to real position
146*cdf0e10cSrcweir }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir //------------------------------------------------------------------------
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir void lcl_InsertGraphic( const Graphic& rGraphic,
151*cdf0e10cSrcweir 						const String& rFileName, const String& rFilterName, sal_Bool bAsLink, sal_Bool bApi,
152*cdf0e10cSrcweir 						ScTabViewShell*	pViewSh, Window* pWindow, SdrView* pView )
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir 	//	#74778# set the size so the graphic has its original pixel size
155*cdf0e10cSrcweir 	//	at 100% view scale (as in SetMarkedOriginalSize),
156*cdf0e10cSrcweir 	//	instead of respecting the current view scale
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	ScDrawView* pDrawView = pViewSh->GetScDrawView();
159*cdf0e10cSrcweir 	MapMode aSourceMap = rGraphic.GetPrefMapMode();
160*cdf0e10cSrcweir 	MapMode aDestMap( MAP_100TH_MM );
161*cdf0e10cSrcweir 	if ( aSourceMap.GetMapUnit() == MAP_PIXEL && pDrawView )
162*cdf0e10cSrcweir 	{
163*cdf0e10cSrcweir 		Fraction aScaleX, aScaleY;
164*cdf0e10cSrcweir 		pDrawView->CalcNormScale( aScaleX, aScaleY );
165*cdf0e10cSrcweir 		aDestMap.SetScaleX(aScaleX);
166*cdf0e10cSrcweir 		aDestMap.SetScaleY(aScaleY);
167*cdf0e10cSrcweir 	}
168*cdf0e10cSrcweir 	Size aLogicSize = pWindow->LogicToLogic(
169*cdf0e10cSrcweir 							rGraphic.GetPrefSize(), &aSourceMap, &aDestMap );
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	//	Limit size
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	SdrPageView* pPV  = pView->GetSdrPageView();
174*cdf0e10cSrcweir 	SdrPage* pPage = pPV->GetPage();
175*cdf0e10cSrcweir 	Point aInsertPos = pViewSh->GetInsertPos();
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 	ScViewData* pData = pViewSh->GetViewData();
178*cdf0e10cSrcweir 	if ( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) )
179*cdf0e10cSrcweir 		aInsertPos.X() -= aLogicSize.Width();		// move position to left edge
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 	ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() );
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 	Rectangle aRect ( aInsertPos, aLogicSize );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 	SdrGrafObj* pObj = new SdrGrafObj( rGraphic, aRect );
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     // #118522# calling SetGraphicLink here doesn't work
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	//	#49961# Path is no longer used as name for the graphics object
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 	ScDrawLayer* pLayer = (ScDrawLayer*) pView->GetModel();
192*cdf0e10cSrcweir 	String aName = pLayer->GetNewGraphicName();					// "Grafik x"
193*cdf0e10cSrcweir 	pObj->SetName(aName);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 	//	don't select if from (dispatch) API, to allow subsequent cell operations
196*cdf0e10cSrcweir 	sal_uLong nInsOptions = bApi ? SDRINSERT_DONTMARK : 0;
197*cdf0e10cSrcweir 	pView->InsertObjectAtView( pObj, *pPV, nInsOptions );
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     // #118522# SetGraphicLink has to be used after inserting the object,
200*cdf0e10cSrcweir     // otherwise an empty graphic is swapped in and the contact stuff crashes.
201*cdf0e10cSrcweir     // See #i37444#.
202*cdf0e10cSrcweir 	if ( bAsLink )
203*cdf0e10cSrcweir 		pObj->SetGraphicLink( rFileName, rFilterName );
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir //------------------------------------------------------------------------
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir void lcl_InsertMedia( const ::rtl::OUString& rMediaURL, bool bApi,
209*cdf0e10cSrcweir 					  ScTabViewShell* pViewSh, Window* pWindow, SdrView* pView,
210*cdf0e10cSrcweir 					  const Size& rPrefSize )
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir 	SdrPageView* 	pPV  = pView->GetSdrPageView();
213*cdf0e10cSrcweir 	SdrPage* 		pPage = pPV->GetPage();
214*cdf0e10cSrcweir 	ScViewData* 	pData = pViewSh->GetViewData();
215*cdf0e10cSrcweir 	Point 			aInsertPos( pViewSh->GetInsertPos() );
216*cdf0e10cSrcweir 	Size 			aSize;
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 	if( rPrefSize.Width() && rPrefSize.Height() )
219*cdf0e10cSrcweir 	{
220*cdf0e10cSrcweir 		if( pWindow )
221*cdf0e10cSrcweir 			aSize = pWindow->PixelToLogic( rPrefSize, MAP_100TH_MM );
222*cdf0e10cSrcweir 		else
223*cdf0e10cSrcweir 			aSize = Application::GetDefaultDevice()->PixelToLogic( rPrefSize, MAP_100TH_MM );
224*cdf0e10cSrcweir 	}
225*cdf0e10cSrcweir 	else
226*cdf0e10cSrcweir 		aSize = Size( 5000, 5000 );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	ScLimitSizeOnDrawPage( aSize, aInsertPos, pPage->GetSize() );
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 	if( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) )
231*cdf0e10cSrcweir 		aInsertPos.X() -= aSize.Width();
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 	SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aInsertPos, aSize ) );
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 	pObj->setURL( rMediaURL );
236*cdf0e10cSrcweir 	pView->InsertObjectAtView( pObj, *pPV, bApi ? SDRINSERT_DONTMARK : 0 );
237*cdf0e10cSrcweir }
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir /*************************************************************************
240*cdf0e10cSrcweir |*
241*cdf0e10cSrcweir |* FuInsertGraphic::Konstruktor
242*cdf0e10cSrcweir |*
243*cdf0e10cSrcweir \************************************************************************/
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir #ifdef _MSC_VER
246*cdf0e10cSrcweir #pragma optimize("",off)
247*cdf0e10cSrcweir #endif
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir FuInsertGraphic::FuInsertGraphic( ScTabViewShell*	pViewSh,
250*cdf0e10cSrcweir 								  Window*			pWin,
251*cdf0e10cSrcweir                                   ScDrawView*       pViewP,
252*cdf0e10cSrcweir 								  SdrModel*			pDoc,
253*cdf0e10cSrcweir 								  SfxRequest&		rReq )
254*cdf0e10cSrcweir        : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq)
255*cdf0e10cSrcweir {
256*cdf0e10cSrcweir 	const SfxItemSet* pReqArgs = rReq.GetArgs();
257*cdf0e10cSrcweir 	const SfxPoolItem* pItem;
258*cdf0e10cSrcweir 	if ( pReqArgs &&
259*cdf0e10cSrcweir 		 pReqArgs->GetItemState( SID_INSERT_GRAPHIC, sal_True, &pItem ) == SFX_ITEM_SET )
260*cdf0e10cSrcweir 	{
261*cdf0e10cSrcweir 		String aFileName = ((const SfxStringItem*)pItem)->GetValue();
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir 		String aFilterName;
264*cdf0e10cSrcweir 		if ( pReqArgs->GetItemState( FN_PARAM_FILTER, sal_True, &pItem ) == SFX_ITEM_SET )
265*cdf0e10cSrcweir 			aFilterName = ((const SfxStringItem*)pItem)->GetValue();
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 		sal_Bool bAsLink = sal_False;
268*cdf0e10cSrcweir 		if ( pReqArgs->GetItemState( FN_PARAM_1, sal_True, &pItem ) == SFX_ITEM_SET )
269*cdf0e10cSrcweir 			bAsLink = ((const SfxBoolItem*)pItem)->GetValue();
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 		Graphic aGraphic;
272*cdf0e10cSrcweir         int nError = GraphicFilter::LoadGraphic( aFileName, aFilterName, aGraphic, GraphicFilter::GetGraphicFilter() );
273*cdf0e10cSrcweir         if ( nError == GRFILTER_OK )
274*cdf0e10cSrcweir         {
275*cdf0e10cSrcweir 			lcl_InsertGraphic( aGraphic, aFileName, aFilterName, bAsLink, sal_True, pViewSh, pWindow, pView );
276*cdf0e10cSrcweir         }
277*cdf0e10cSrcweir 	}
278*cdf0e10cSrcweir 	else
279*cdf0e10cSrcweir 	{
280*cdf0e10cSrcweir 		SvxOpenGraphicDialog aDlg(ScResId(STR_INSERTGRAPHIC));
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 		if( aDlg.Execute() == GRFILTER_OK )
283*cdf0e10cSrcweir 		{
284*cdf0e10cSrcweir 			Graphic aGraphic;
285*cdf0e10cSrcweir             int nError = aDlg.GetGraphic(aGraphic);
286*cdf0e10cSrcweir 			if( nError == GRFILTER_OK )
287*cdf0e10cSrcweir 			{
288*cdf0e10cSrcweir 				String aFileName = aDlg.GetPath();
289*cdf0e10cSrcweir 				String aFilterName = aDlg.GetCurrentFilter();
290*cdf0e10cSrcweir 				sal_Bool bAsLink = aDlg.IsAsLink();
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 				lcl_InsertGraphic( aGraphic, aFileName, aFilterName, bAsLink, sal_False, pViewSh, pWindow, pView );
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 				//	append items for recording
295*cdf0e10cSrcweir 				rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) );
296*cdf0e10cSrcweir 				rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) );
297*cdf0e10cSrcweir 				rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
298*cdf0e10cSrcweir 				rReq.Done();
299*cdf0e10cSrcweir 			}
300*cdf0e10cSrcweir 			else
301*cdf0e10cSrcweir 			{
302*cdf0e10cSrcweir 				//	error is handled in SvxOpenGraphicDialog::GetGraphic
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir #if 0
305*cdf0e10cSrcweir 				sal_uInt16 nRes = 0;
306*cdf0e10cSrcweir 				switch ( nError )
307*cdf0e10cSrcweir 				{
308*cdf0e10cSrcweir 					case GRFILTER_OPENERROR:	nRes = SCSTR_GRFILTER_OPENERROR;	break;
309*cdf0e10cSrcweir 					case GRFILTER_IOERROR:		nRes = SCSTR_GRFILTER_IOERROR;		break;
310*cdf0e10cSrcweir 					case GRFILTER_FORMATERROR:	nRes = SCSTR_GRFILTER_FORMATERROR;	break;
311*cdf0e10cSrcweir 					case GRFILTER_VERSIONERROR:	nRes = SCSTR_GRFILTER_VERSIONERROR;	break;
312*cdf0e10cSrcweir 					case GRFILTER_FILTERERROR:	nRes = SCSTR_GRFILTER_FILTERERROR;	break;
313*cdf0e10cSrcweir 					case GRFILTER_TOOBIG:		nRes = SCSTR_GRFILTER_TOOBIG;		break;
314*cdf0e10cSrcweir 				}
315*cdf0e10cSrcweir 				if ( nRes )
316*cdf0e10cSrcweir 				{
317*cdf0e10cSrcweir 					InfoBox aInfoBox( pWindow, String(ScResId(nRes)) );
318*cdf0e10cSrcweir 					aInfoBox.Execute();
319*cdf0e10cSrcweir 				}
320*cdf0e10cSrcweir 				else
321*cdf0e10cSrcweir 				{
322*cdf0e10cSrcweir 					sal_uLong nStreamError = GetGrfFilter()->GetLastError().nStreamError;
323*cdf0e10cSrcweir 					if( ERRCODE_NONE != nStreamError )
324*cdf0e10cSrcweir 						ErrorHandler::HandleError( nStreamError );
325*cdf0e10cSrcweir 				}
326*cdf0e10cSrcweir #endif
327*cdf0e10cSrcweir 			}
328*cdf0e10cSrcweir 		}
329*cdf0e10cSrcweir 	}
330*cdf0e10cSrcweir }
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir /*************************************************************************
333*cdf0e10cSrcweir |*
334*cdf0e10cSrcweir |* FuInsertGraphic::Destruktor
335*cdf0e10cSrcweir |*
336*cdf0e10cSrcweir \************************************************************************/
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir FuInsertGraphic::~FuInsertGraphic()
339*cdf0e10cSrcweir {
340*cdf0e10cSrcweir }
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir /*************************************************************************
343*cdf0e10cSrcweir |*
344*cdf0e10cSrcweir |* FuInsertGraphic::Function aktivieren
345*cdf0e10cSrcweir |*
346*cdf0e10cSrcweir \************************************************************************/
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir void FuInsertGraphic::Activate()
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir 	FuPoor::Activate();
351*cdf0e10cSrcweir }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir /*************************************************************************
354*cdf0e10cSrcweir |*
355*cdf0e10cSrcweir |* FuInsertGraphic::Function deaktivieren
356*cdf0e10cSrcweir |*
357*cdf0e10cSrcweir \************************************************************************/
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir void FuInsertGraphic::Deactivate()
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir 	FuPoor::Deactivate();
362*cdf0e10cSrcweir }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir /*************************************************************************
365*cdf0e10cSrcweir |*
366*cdf0e10cSrcweir |* FuInsertMedia::Konstruktor
367*cdf0e10cSrcweir |*
368*cdf0e10cSrcweir \************************************************************************/
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir FuInsertMedia::FuInsertMedia( ScTabViewShell*	pViewSh,
371*cdf0e10cSrcweir 							  Window*			pWin,
372*cdf0e10cSrcweir                               ScDrawView*       pViewP,
373*cdf0e10cSrcweir 							  SdrModel*			pDoc,
374*cdf0e10cSrcweir 							  SfxRequest&		rReq ) :
375*cdf0e10cSrcweir     FuPoor(pViewSh, pWin, pViewP, pDoc, rReq)
376*cdf0e10cSrcweir {
377*cdf0e10cSrcweir 	::rtl::OUString 	aURL;
378*cdf0e10cSrcweir 	const SfxItemSet*	pReqArgs = rReq.GetArgs();
379*cdf0e10cSrcweir 	bool				bAPI = false;
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 	if( pReqArgs )
382*cdf0e10cSrcweir 	{
383*cdf0e10cSrcweir 		const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) );
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir 		if( pStringItem )
386*cdf0e10cSrcweir 		{
387*cdf0e10cSrcweir 			aURL = pStringItem->GetValue();
388*cdf0e10cSrcweir 			bAPI = aURL.getLength();
389*cdf0e10cSrcweir 		}
390*cdf0e10cSrcweir 	}
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir 	if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( pWindow, aURL ) )
393*cdf0e10cSrcweir 	{
394*cdf0e10cSrcweir 		Size aPrefSize;
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir 		if( pWin )
397*cdf0e10cSrcweir 			pWin->EnterWait();
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir 		if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) )
400*cdf0e10cSrcweir 		{
401*cdf0e10cSrcweir 			if( pWin )
402*cdf0e10cSrcweir 				pWin->LeaveWait();
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir 			if( !bAPI )
405*cdf0e10cSrcweir 				::avmedia::MediaWindow::executeFormatErrorBox( pWindow );
406*cdf0e10cSrcweir 		}
407*cdf0e10cSrcweir 		else
408*cdf0e10cSrcweir 		{
409*cdf0e10cSrcweir 			lcl_InsertMedia( aURL, bAPI, pViewSh, pWindow, pView, aPrefSize );
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 			if( pWin )
412*cdf0e10cSrcweir 				pWin->LeaveWait();
413*cdf0e10cSrcweir 		}
414*cdf0e10cSrcweir 	}
415*cdf0e10cSrcweir }
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir /*************************************************************************
418*cdf0e10cSrcweir |*
419*cdf0e10cSrcweir |* FuInsertMedia::Destruktor
420*cdf0e10cSrcweir |*
421*cdf0e10cSrcweir \************************************************************************/
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir FuInsertMedia::~FuInsertMedia()
424*cdf0e10cSrcweir {
425*cdf0e10cSrcweir }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir /*************************************************************************
428*cdf0e10cSrcweir |*
429*cdf0e10cSrcweir |* FuInsertMedia::Function aktivieren
430*cdf0e10cSrcweir |*
431*cdf0e10cSrcweir \************************************************************************/
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir void FuInsertMedia::Activate()
434*cdf0e10cSrcweir {
435*cdf0e10cSrcweir 	FuPoor::Activate();
436*cdf0e10cSrcweir }
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir /*************************************************************************
439*cdf0e10cSrcweir |*
440*cdf0e10cSrcweir |* FuInsertMedia::Function deaktivieren
441*cdf0e10cSrcweir |*
442*cdf0e10cSrcweir \************************************************************************/
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir void FuInsertMedia::Deactivate()
445*cdf0e10cSrcweir {
446*cdf0e10cSrcweir 	FuPoor::Deactivate();
447*cdf0e10cSrcweir }
448