xref: /aoo41x/main/sd/source/ui/view/sdview4.cxx (revision 4bf7a51a)
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_sd.hxx"
26 
27 #include "View.hxx"
28 #include <unotools/localfilehelper.hxx>
29 #include <sfx2/request.hxx>
30 #include <sfx2/docfilt.hxx>
31 #include <sfx2/fcontnr.hxx>
32 #include <sfx2/docfile.hxx>
33 #include <vcl/msgbox.hxx>
34 #include <svl/urlbmk.hxx>
35 #include <svx/svdpagv.hxx>
36 #include <svx/xfillit.hxx>
37 #include <svx/svdundo.hxx>
38 #include <svx/xoutbmp.hxx>
39 #include <svx/svdograf.hxx>
40 #include <svx/svdomedia.hxx>
41 #include <svx/svdoole2.hxx>
42 #include <sot/storage.hxx>
43 #include <sfx2/app.hxx>
44 #include <avmedia/mediawindow.hxx>
45 #include <svtools/ehdl.hxx>
46 #include <svtools/sfxecode.hxx>
47 #include <svtools/filter.hxx>
48 #include "app.hrc"
49 #include "Window.hxx"
50 #include "DrawDocShell.hxx"
51 #include "DrawViewShell.hxx"
52 #include "fuinsfil.hxx"
53 #include "drawdoc.hxx"
54 #include "sdresid.hxx"
55 #include "strings.hrc"
56 #include "imapinfo.hxx"
57 #include "sdpage.hxx"
58 #include "view/SlideSorterView.hxx"
59 #include "undo/undoobjects.hxx"
60 
61 #include <comphelper/processfactory.hxx>
62 #include <com/sun/star/embed/ElementModes.hpp>
63 #include <com/sun/star/embed/XEmbedPersist.hpp>
64 #include <com/sun/star/embed/Aspects.hpp>
65 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
66 #include <svtools/soerr.hxx>
67 
68 #include <sfx2/ipclient.hxx>
69 #include "glob.hrc"
70 
71 using namespace com::sun::star;
72 
73 namespace sd {
74 
75 #ifdef _MSC_VER
76 #pragma optimize ( "", off )
77 #endif
78 
79 /*************************************************************************
80 |*
81 |* Graphik einfuegen
82 |* Wird ein leeres Graphikobjekt uebergeben, so wird dieses gefuellt.
83 |* Andernfalls wird ein an der gegebenen Position vorhandenes Objekt
84 |* gefuellt. Ist an der Position kein Objekt vorhanden, so wird ein neues
85 |* Objekt erzeugt und ein Pointer auf dieses Objekt zurueckgegeben.
86 |*
87 \************************************************************************/
88 
89 SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
90 								   const Point& rPos, SdrObject* pObj, ImageMap* pImageMap )
91 {
92 	SdrEndTextEdit();
93 	mnAction = rAction;
94 
95 	// Liegt ein Objekt an der Position rPos?
96 	SdrGrafObj*		pNewGrafObj = NULL;
97 	SdrPageView*	pPV = GetSdrPageView();
98 	SdrObject*		pPickObj = pObj;
99 	const bool bOnMaster = pPV && pPV->GetPage() && pPV->GetPage()->IsMasterPage();
100 
101 	if(pPV && this->ISA(::sd::slidesorter::view::SlideSorterView))
102 	{
103 		if(!pPV->GetPageRect().IsInside(rPos))
104 			pPV = 0L;
105 	}
106 
107 	if( !pPickObj && pPV )
108 	{
109 		SdrPageView* pPageView = pPV;
110 		PickObj(rPos, getHitTolLog(), pPickObj, pPageView);
111 	}
112 
113 	if( mnAction == DND_ACTION_LINK && pPickObj && pPV )
114 	{
115 		const bool bIsGraphic = pPickObj->ISA( SdrGrafObj );
116 		if( bIsGraphic || (pObj->IsEmptyPresObj() && !bOnMaster) )
117 		{
118 			if( IsUndoEnabled() )
119 				BegUndo(String(SdResId(STR_INSERTGRAPHIC)));
120 
121 			SdPage* pPage = (SdPage*) pPickObj->GetPage();
122 
123 			if( bIsGraphic )
124 			{
125 				// Das Objekt wird mit der Bitmap gefuellt
126 				pNewGrafObj = (SdrGrafObj*) pPickObj->Clone();
127 				pNewGrafObj->SetGraphic(rGraphic);
128 			}
129 			else
130 			{
131 				pNewGrafObj = new SdrGrafObj( rGraphic, pPickObj->GetLogicRect() );
132 				pNewGrafObj->SetEmptyPresObj(sal_True);
133 			}
134 
135 			if ( pNewGrafObj->IsEmptyPresObj() )
136 			{
137 				Rectangle aRect( pNewGrafObj->GetLogicRect() );
138 				pNewGrafObj->AdjustToMaxRect( aRect, sal_False );
139 				pNewGrafObj->SetOutlinerParaObject(NULL);
140 				pNewGrafObj->SetEmptyPresObj(sal_False);
141 			}
142 
143 			if (pPage && pPage->IsPresObj(pPickObj))
144 			{
145 				// Neues PresObj in die Liste eintragen
146 				pPage->InsertPresObj( pNewGrafObj, PRESOBJ_GRAPHIC );
147 				pNewGrafObj->SetUserCall(pPickObj->GetUserCall());
148 			}
149 
150 			if (pImageMap)
151 				pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap));
152 
153 			ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView
154 
155 			if( IsUndoEnabled() )
156 				EndUndo();
157 		}
158 		else if (pPickObj->IsClosedObj() && !pPickObj->ISA(SdrOle2Obj))
159 		{
160 			/******************************************************************
161 			* Das Objekt wird mit der Graphik gefuellt
162 			******************************************************************/
163 			if( IsUndoEnabled() )
164 			{
165 				BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
166 				AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj));
167 				EndUndo();
168 			}
169 
170 			SfxItemSet aSet(mpDocSh->GetPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP);
171 			aSet.Put(XFillStyleItem(XFILL_BITMAP));
172 			aSet.Put(XFillBitmapItem(&mpDocSh->GetPool(), rGraphic));
173 			pPickObj->SetMergedItemSetAndBroadcast(aSet);
174 		}
175 	}
176 	else if ( pPV )
177 	{
178 		// create  new object
179 		Size aSize;
180 
181 		if ( rGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
182 		{
183 			::OutputDevice* pOutDev = 0;
184 			if( mpViewSh )
185 				pOutDev = mpViewSh->GetActiveWindow();
186 
187 			if( !pOutDev )
188 				pOutDev = Application::GetDefaultDevice();
189 
190 			if( pOutDev )
191 				aSize = pOutDev->PixelToLogic( rGraphic.GetPrefSize(), MAP_100TH_MM );
192 		}
193 		else
194 		{
195 			aSize = OutputDevice::LogicToLogic( rGraphic.GetPrefSize(),
196 											    rGraphic.GetPrefMapMode(),
197 											    MapMode( MAP_100TH_MM ) );
198 		}
199 
200 		pNewGrafObj = new SdrGrafObj( rGraphic, Rectangle( rPos, aSize ) );
201 		SdrPage* pPage = pPV->GetPage();
202 		Size aPageSize( pPage->GetSize() );
203 		aPageSize.Width()  -= pPage->GetLftBorder() + pPage->GetRgtBorder();
204 		aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
205 		pNewGrafObj->AdjustToMaxRect( Rectangle( Point(), aPageSize ), sal_True );
206 //		pNewGrafObj->AdjustToMaxRect( Rectangle( pPV->GetOffset(), aPageSize ), sal_True );
207 
208 		sal_uLong	nOptions = SDRINSERT_SETDEFLAYER;
209 		sal_Bool	bIsPresTarget = sal_False;
210 
211         if ((mpViewSh
212                 && mpViewSh->GetViewShell()!=NULL
213                 && mpViewSh->GetViewShell()->GetIPClient()
214                 && mpViewSh->GetViewShell()->GetIPClient()->IsObjectInPlaceActive())
215             || this->ISA(::sd::slidesorter::view::SlideSorterView))
216 			nOptions |= SDRINSERT_DONTMARK;
217 
218 		if( ( mnAction & DND_ACTION_MOVE ) && pPickObj && (pPickObj->IsEmptyPresObj() || pPickObj->GetUserCall()) )
219 		{
220 			SdPage* pP = static_cast< SdPage* >( pPickObj->GetPage() );
221 
222 			if ( pP && pP->IsMasterPage() )
223 				bIsPresTarget = pP->IsPresObj(pPickObj);
224 		}
225 
226         if(pNewGrafObj)
227         {
228             // #119287#
229             SdrModel* pModel = pPV->GetView().GetModel();
230             SfxStyleSheetBasePool* pSfxStyleSheetBasePool = pModel ? pModel->GetStyleSheetPool() : 0;
231 		    SfxStyleSheet* pSheet = pSfxStyleSheetBasePool ? dynamic_cast< SfxStyleSheet* >(pSfxStyleSheetBasePool->Find(String(SdResId(STR_POOLSHEET_OBJNOLINENOFILL)), SD_STYLE_FAMILY_GRAPHICS)) : 0;
232 
233 		    if(pSheet)
234 		    {
235 			    pNewGrafObj->SetStyleSheet(pSheet, false);
236 		    }
237             else
238             {
239 		        pNewGrafObj->SetMergedItem(XFillStyleItem(XFILL_NONE));
240 		        pNewGrafObj->SetMergedItem(XLineStyleItem(XLINE_NONE));
241     		    OSL_ENSURE(false, "Style Sheet for GraphicObject not found (!)");
242             }
243         }
244 
245 		if( ( mnAction & DND_ACTION_MOVE ) && pPickObj && !bIsPresTarget )
246 		{
247 			// replace object
248 			if (pImageMap)
249 				pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap));
250 
251 			Rectangle aPickObjRect(pPickObj->GetCurrentBoundRect());
252 			Size aPickObjSize(aPickObjRect.GetSize());
253 			Rectangle aObjRect(pNewGrafObj->GetCurrentBoundRect());
254 			Size aObjSize(aObjRect.GetSize());
255 
256 			Fraction aScaleWidth(aPickObjSize.Width(), aObjSize.Width());
257 			Fraction aScaleHeight(aPickObjSize.Height(), aObjSize.Height());
258 			pNewGrafObj->NbcResize(aObjRect.TopLeft(), aScaleWidth, aScaleHeight);
259 
260 			Point aVec = aPickObjRect.TopLeft() - aObjRect.TopLeft();
261 			pNewGrafObj->NbcMove(Size(aVec.X(), aVec.Y()));
262 
263 			const bool bUndo = IsUndoEnabled();
264 
265 			if( bUndo )
266 				BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
267 			pNewGrafObj->NbcSetLayer(pPickObj->GetLayer());
268 			SdrPage* pP = pPV->GetPage();
269 			pP->InsertObject(pNewGrafObj);
270 			if( bUndo )
271 			{
272 				AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewObject(*pNewGrafObj));
273 				AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pPickObj));
274 			}
275 			pP->RemoveObject(pPickObj->GetOrdNum());
276 
277 			if( bUndo )
278 			{
279 				EndUndo();
280 			}
281 			else
282 			{
283 				SdrObject::Free(pPickObj);
284 			}
285 			mnAction = DND_ACTION_COPY;
286 		}
287 		else
288 		{
289 			InsertObjectAtView(pNewGrafObj, *pPV, nOptions);
290 
291 			if( pImageMap )
292 				pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap));
293 		}
294 	}
295 
296 	rAction = mnAction;
297 
298 	return pNewGrafObj;
299 }
300 
301 // -----------------------------------------------------------------------------
302 
303 SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAction,
304 								   const Point& rPos, const Size& rSize )
305 {
306 	SdrEndTextEdit();
307 	mnAction = rAction;
308 
309 	SdrMediaObj*	pNewMediaObj = NULL;
310 	SdrPageView*	pPV = GetSdrPageView();
311 	SdrObject*		pPickObj = GetEmptyPresentationObject( PRESOBJ_MEDIA );
312 
313 	if(pPV && this->ISA(::sd::slidesorter::view::SlideSorterView ))
314 	{
315 		if(!pPV->GetPageRect().IsInside(rPos))
316 			pPV = 0L;
317 	}
318 
319 	if( !pPickObj && pPV )
320 	{
321 		SdrPageView* pPageView = pPV;
322 		PickObj(rPos, getHitTolLog(), pPickObj, pPageView);
323 	}
324 
325 	if( mnAction == DND_ACTION_LINK && pPickObj && pPV && pPickObj->ISA( SdrMediaObj ) )
326 	{
327 		pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->Clone() );
328 		pNewMediaObj->setURL( rMediaURL );
329 
330     	BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
331 		ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
332 		EndUndo();
333 	}
334 	else if( pPV )
335 	{
336 		Rectangle aRect( rPos, rSize );
337 		if( pPickObj )
338 			aRect = pPickObj->GetLogicRect();
339 
340 
341     	pNewMediaObj = new SdrMediaObj( aRect );
342 
343 		bool bIsPres = false;
344 		if( pPickObj )
345 		{
346 			SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage());
347 			bIsPres = pPage && pPage->IsPresObj(pPickObj);
348 			if( bIsPres )
349 			{
350 				pPage->InsertPresObj( pNewMediaObj, PRESOBJ_MEDIA );
351 			}
352 		}
353 
354 		if( pPickObj )
355 			ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
356 		else
357 			InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER );
358 
359 	    pNewMediaObj->setURL( rMediaURL );
360 
361 		if( pPickObj )
362 		{
363 			pNewMediaObj->AdjustToMaxRect( pPickObj->GetLogicRect() );
364 			if( bIsPres )
365 				pNewMediaObj->SetUserCall(pPickObj->GetUserCall());
366 		}
367 	}
368 
369 	rAction = mnAction;
370 
371 	return pNewMediaObj;
372 }
373 
374 /*************************************************************************
375 |*
376 |* Timer-Handler fuer InsertFile beim Drop()
377 |*
378 \************************************************************************/
379 
380 IMPL_LINK( View, DropInsertFileHdl, Timer*, EMPTYARG )
381 {
382 	DBG_ASSERT( mpViewSh, "sd::View::DropInsertFileHdl(), I need a view shell to work!" );
383 	if( !mpViewSh )
384 		return 0;
385 
386     SfxErrorContext aEc( ERRCTX_ERROR, mpViewSh->GetActiveWindow(), RID_SO_ERRCTX );
387     ErrCode nError = 0;
388 
389 	::std::vector< String >::const_iterator aIter( maDropFileVector.begin() );
390 
391     while( (aIter != maDropFileVector.end()) && !nError )
392     {
393 	    String          aCurrentDropFile( *aIter );
394         INetURLObject   aURL( aCurrentDropFile );
395 	    sal_Bool		    bOK = sal_False;
396 
397 	    if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
398 	    {
399 		    String aURLStr;
400 		    ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aCurrentDropFile, aURLStr );
401 		    aURL = INetURLObject( aURLStr );
402 	    }
403 
404         GraphicFilter*  pGraphicFilter = GraphicFilter::GetGraphicFilter();
405 	    Graphic			aGraphic;
406 
407         aCurrentDropFile = aURL.GetMainURL( INetURLObject::NO_DECODE );
408 
409 		if( !::avmedia::MediaWindow::isMediaURL( aCurrentDropFile ) )
410 		{
411 			if( !pGraphicFilter->ImportGraphic( aGraphic, aURL ) )
412 			{
413 				sal_Int8    nTempAction = ( aIter == maDropFileVector.begin() ) ? mnAction : 0;
414 				const bool bLink = ( ( nTempAction & DND_ACTION_LINK ) != 0 );
415 				SdrGrafObj* pGrafObj = InsertGraphic( aGraphic, nTempAction, maDropPos, NULL, NULL );
416 
417 				if(pGrafObj && bLink)
418                 {
419     				pGrafObj->SetGraphicLink( aCurrentDropFile, String() );
420                 }
421 
422 				// return action from first inserted graphic
423 				if( aIter == maDropFileVector.begin() )
424 					mnAction = nTempAction;
425 
426 				bOK = sal_True;
427 			}
428 			if( !bOK )
429 			{
430     			const SfxFilter*        pFoundFilter = NULL;
431 				SfxMedium	            aSfxMedium( aCurrentDropFile, STREAM_READ | STREAM_SHARE_DENYNONE, sal_False );
432 				ErrCode		            nErr = SFX_APP()->GetFilterMatcher().GuessFilter(  aSfxMedium, &pFoundFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE );
433 
434 				if( pFoundFilter && !nErr )
435 				{
436 					::std::vector< String > aFilterVector;
437 					const String	        aFilterName( pFoundFilter->GetFilterName() );
438 					String	        		aLowerAsciiFileName( aCurrentDropFile );
439 					aLowerAsciiFileName.ToLowerAscii();
440 
441 					FuInsertFile::GetSupportedFilterVector( aFilterVector );
442 
443 					if( ( ::std::find( aFilterVector.begin(), aFilterVector.end(), pFoundFilter->GetMimeType() ) != aFilterVector.end() ) ||
444 						aFilterName.SearchAscii( "Text" ) != STRING_NOTFOUND ||
445 						aFilterName.SearchAscii( "Rich" ) != STRING_NOTFOUND ||
446 						aFilterName.SearchAscii( "RTF" ) != STRING_NOTFOUND ||
447 						aFilterName.SearchAscii( "HTML" ) != STRING_NOTFOUND ||
448 						aLowerAsciiFileName.SearchAscii(".sdd") != STRING_NOTFOUND ||
449 						aLowerAsciiFileName.SearchAscii(".sda") != STRING_NOTFOUND ||
450 						aLowerAsciiFileName.SearchAscii(".sxd") != STRING_NOTFOUND ||
451 						aLowerAsciiFileName.SearchAscii(".sxi") != STRING_NOTFOUND ||
452 						aLowerAsciiFileName.SearchAscii(".std") != STRING_NOTFOUND ||
453 						aLowerAsciiFileName.SearchAscii(".sti") != STRING_NOTFOUND )
454 					{
455 						::sd::Window* pWin = mpViewSh->GetActiveWindow();
456 						SfxRequest      aReq(SID_INSERTFILE, 0, mpDoc->GetItemPool());
457 						SfxStringItem   aItem1( ID_VAL_DUMMY0, aCurrentDropFile ), aItem2( ID_VAL_DUMMY1, pFoundFilter->GetFilterName() );
458 
459 						aReq.AppendItem( aItem1 );
460 						aReq.AppendItem( aItem2 );
461 						FuInsertFile::Create( mpViewSh, pWin, this, mpDoc, aReq );
462 						bOK = sal_True;
463 					}
464 				}
465 			}
466 		}
467 
468 	    if( !bOK )
469 	    {
470 	        Size aPrefSize;
471 
472 	        if( ::avmedia::MediaWindow::isMediaURL( aCurrentDropFile ) &&
473 	            ::avmedia::MediaWindow::isMediaURL( aCurrentDropFile, true, &aPrefSize ) )
474 	        {
475 			    if( aPrefSize.Width() && aPrefSize.Height() )
476 			    {
477 					::sd::Window* pWin = mpViewSh->GetActiveWindow();
478 
479 				    if( pWin )
480 					    aPrefSize = pWin->PixelToLogic( aPrefSize, MAP_100TH_MM );
481 				    else
482 					    aPrefSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_100TH_MM );
483 			    }
484 			    else
485 				    aPrefSize  = Size( 5000, 5000 );
486 
487     		    InsertMediaURL( aCurrentDropFile, mnAction, maDropPos, aPrefSize ) ;
488 	        }
489 	        else if( mnAction & DND_ACTION_LINK )
490 			    static_cast< DrawViewShell* >( mpViewSh )->InsertURLButton( aCurrentDropFile, aCurrentDropFile, String(), &maDropPos );
491 		    else
492 		    {
493 			    if( mpViewSh )
494 			    {
495 					try
496 					{
497 						//TODO/MBA: testing
498 						::rtl::OUString aName;
499 						uno::Sequence < beans::PropertyValue > aMedium(1);
500 						aMedium[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
501 						aMedium[0].Value <<= ::rtl::OUString( aCurrentDropFile );
502 
503 						uno::Reference < embed::XEmbeddedObject > xObj = mpDocSh->GetEmbeddedObjectContainer().
504 								InsertEmbeddedObject( aMedium, aName );
505 
506 						uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
507 						if ( xPersist.is())
508 						{
509 							// TODO/LEAN: VisualArea access can switch the object to running state
510 							sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
511 
512 							xPersist->storeOwn();
513 
514 							awt::Size aSz;
515 							try
516 							{
517 								aSz = xObj->getVisualAreaSize( nAspect );
518 							}
519 							catch( embed::NoVisualAreaSizeException& )
520 							{
521 								// the default size will be set later
522 							}
523 
524 							Size        aSize( aSz.Width, aSz.Height );
525 							Rectangle   aRect;
526 
527 							if (!aSize.Width() || !aSize.Height())
528 							{
529 								aSize.Width()   = 1410;
530 								aSize.Height()  = 1000;
531 							}
532 
533 							aRect = Rectangle( maDropPos, aSize );
534 
535 							SdrOle2Obj* pOleObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect );
536 							sal_uLong       nOptions = SDRINSERT_SETDEFLAYER;
537 
538 							if (mpViewSh != NULL)
539 							{
540 								OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
541 								SfxInPlaceClient* pIpClient =
542 									mpViewSh->GetViewShell()->GetIPClient();
543 								if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
544 									nOptions |= SDRINSERT_DONTMARK;
545 							}
546 
547 							InsertObjectAtView( pOleObj, *GetSdrPageView(), nOptions );
548 							pOleObj->SetLogicRect( aRect );
549 							aSz.Width = aRect.GetWidth();
550 							aSz.Height = aRect.GetHeight();
551 							xObj->setVisualAreaSize( nAspect,aSz );
552 						}
553 					}
554 					catch( uno::Exception& )
555 					{
556 						nError = ERRCODE_IO_GENERAL;
557 						// TODO/LATER: better error handling
558 					}
559 				}
560 		    }
561 	    }
562 
563         ++aIter;
564     }
565 
566     if( nError )
567         ErrorHandler::HandleError( nError );
568 
569     return nError;
570 }
571 
572 /*************************************************************************
573 |*
574 |* Timer-Handler fuer Errorhandling beim Drop()
575 |*
576 \************************************************************************/
577 
578 IMPL_LINK( View, DropErrorHdl, Timer*, EMPTYARG )
579 {
580 	InfoBox( mpViewSh ? mpViewSh->GetActiveWindow() : 0, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
581 	return 0;
582 }
583 
584 #ifdef _MSC_VER
585 #pragma optimize ( "", on )
586 #endif
587 
588 /*************************************************************************
589 |*
590 |* Redraw sperren oder erlauben
591 |*
592 \************************************************************************/
593 
594 void View::LockRedraw(sal_Bool bLock)
595 {
596 	if (bLock)
597 	{
598 		mnLockRedrawSmph++;
599 		DBG_ASSERT(mnLockRedrawSmph, "Ueberlauf im LockRedraw");
600 	}
601 	else
602 	{
603 		DBG_ASSERT(mnLockRedrawSmph, "Unterlauf im LockRedraw");
604 		mnLockRedrawSmph--;
605 
606 		// alle gespeicherten Redraws ausfuehren
607 		if (!mnLockRedrawSmph)
608 		{
609 			while (mpLockedRedraws && mpLockedRedraws->Count())
610 			{
611 				SdViewRedrawRec* pRec = (SdViewRedrawRec*)mpLockedRedraws->First();
612 				OutputDevice* pCurrentOut = pRec->mpOut;
613 				Rectangle aBoundRect(pRec->aRect);
614 				mpLockedRedraws->Remove(pRec);
615 				delete pRec;
616 
617 				pRec = (SdViewRedrawRec*)mpLockedRedraws->First();
618 				while (pRec)
619 				{
620 					if (pRec->mpOut == pCurrentOut)
621 					{
622 						aBoundRect.Union(pRec->aRect);
623 						mpLockedRedraws->Remove(pRec);
624 						delete pRec;
625 						pRec = (SdViewRedrawRec*)mpLockedRedraws->GetCurObject();
626 					}
627 					else
628 					{
629 						pRec = (SdViewRedrawRec*)mpLockedRedraws->Next();
630 					}
631 				}
632 
633 				CompleteRedraw(pCurrentOut, Region(aBoundRect));
634 			}
635 			delete mpLockedRedraws;
636 			mpLockedRedraws = NULL;
637 		}
638 	}
639 }
640 
641 
642 
643 
644 /*************************************************************************
645 |*
646 |* StyleSheet aus der Sleketion besorgen
647 |*
648 \************************************************************************/
649 
650 SfxStyleSheet* View::GetStyleSheet() const
651 {
652 	return SdrView::GetStyleSheet();
653 }
654 
655 } // end of namespace sd
656