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