1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <config_features.h>
21 
22 #include <View.hxx>
23 #include <osl/file.hxx>
24 #include <editeng/outlobj.hxx>
25 #include <sfx2/bindings.hxx>
26 #include <sfx2/request.hxx>
27 #include <sfx2/docfilt.hxx>
28 #include <sfx2/fcontnr.hxx>
29 #include <sfx2/docfile.hxx>
30 #include <sfx2/sfxsids.hrc>
31 #include <vcl/svapp.hxx>
32 #include <vcl/weld.hxx>
33 #include <svx/svdpagv.hxx>
34 #include <svx/xbtmpit.hxx>
35 #include <svx/svdundo.hxx>
36 #include <svx/xfillit0.hxx>
37 #include <svx/svdograf.hxx>
38 #include <svx/svdomedia.hxx>
39 #include <svx/svdoole2.hxx>
40 #include <svx/ImageMapInfo.hxx>
41 #include <sfx2/app.hxx>
42 #include <avmedia/mediawindow.hxx>
43 #include <svtools/ehdl.hxx>
44 #include <svtools/sfxecode.hxx>
45 #include <svtools/embedhlp.hxx>
46 #include <vcl/graphicfilter.hxx>
47 #include <app.hrc>
48 #include <Window.hxx>
49 #include <DrawDocShell.hxx>
50 #include <DrawViewShell.hxx>
51 #include <fuinsfil.hxx>
52 #include <drawdoc.hxx>
53 #include <sdresid.hxx>
54 #include <strings.hrc>
55 #include <sdpage.hxx>
56 #include <view/SlideSorterView.hxx>
57 #include <com/sun/star/embed/XEmbedPersist.hpp>
58 #include <com/sun/star/embed/Aspects.hpp>
59 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
60 #include <com/sun/star/embed/XEmbeddedObject.hpp>
61 #include <svtools/soerr.hxx>
62 #include <sfx2/ipclient.hxx>
63 #include <tools/debug.hxx>
64 
65 using namespace com::sun::star;
66 
67 namespace sd {
68 
69 /**
70  * If an empty graphic object is provided, we fill it. Otherwise we fill an
71  * existing object at the specified position. If there is no object at the
72  * position, we create a new object and return a pointer to it.
73  */
InsertGraphic(const Graphic & rGraphic,sal_Int8 & rAction,const Point & rPos,SdrObject * pObj,ImageMap const * pImageMap)74 SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
75                                    const Point& rPos, SdrObject* pObj, ImageMap const * pImageMap )
76 {
77     SdrEndTextEdit();
78     mnAction = rAction;
79 
80     // Is there an object at the position rPos?
81     SdrGrafObj*     pNewGrafObj = nullptr;
82     SdrPageView*    pPV = GetSdrPageView();
83     SdrObject*      pPickObj = pObj;
84     const bool bOnMaster = pPV && pPV->GetPage() && pPV->GetPage()->IsMasterPage();
85 
86     if(pPV && dynamic_cast< const ::sd::slidesorter::view::SlideSorterView* >(this) !=  nullptr)
87     {
88         if(!pPV->GetPageRect().IsInside(rPos))
89             pPV = nullptr;
90     }
91 
92     if( !pPickObj && pPV )
93     {
94         SdrPageView* pPageView = pPV;
95         pPickObj = PickObj(rPos, getHitTolLog(), pPageView);
96     }
97 
98     const bool bIsGraphic(dynamic_cast< const SdrGrafObj* >(pPickObj) !=  nullptr);
99 
100     if (DND_ACTION_LINK == mnAction
101         && pPickObj
102         && pPV
103         && (bIsGraphic || (pPickObj->IsEmptyPresObj() && !bOnMaster))) // #121603# Do not use pObj, it may be NULL
104     {
105         // hit on SdrGrafObj with wanted new linked graphic (or PresObj placeholder hit)
106         if( IsUndoEnabled() )
107             BegUndo(SdResId(STR_INSERTGRAPHIC));
108 
109         SdPage* pPage = static_cast<SdPage*>( pPickObj->getSdrPageFromSdrObject() );
110 
111         if( bIsGraphic )
112         {
113             // We fill the object with the Bitmap
114             pNewGrafObj = static_cast<SdrGrafObj*>( pPickObj->CloneSdrObject(pPickObj->getSdrModelFromSdrObject()) );
115             pNewGrafObj->SetGraphic(rGraphic);
116         }
117         else
118         {
119             pNewGrafObj = new SdrGrafObj(
120                 getSdrModelFromSdrView(),
121                 rGraphic,
122                 pPickObj->GetLogicRect());
123             pNewGrafObj->SetEmptyPresObj(true);
124         }
125 
126         if ( pNewGrafObj->IsEmptyPresObj() )
127         {
128             ::tools::Rectangle aRect( pNewGrafObj->GetLogicRect() );
129             pNewGrafObj->AdjustToMaxRect( aRect );
130             pNewGrafObj->SetOutlinerParaObject(nullptr);
131             pNewGrafObj->SetEmptyPresObj(false);
132         }
133 
134         if (pPage && pPage->IsPresObj(pPickObj))
135         {
136             // Insert new PresObj into the list
137             pPage->InsertPresObj( pNewGrafObj, PRESOBJ_GRAPHIC );
138             pNewGrafObj->SetUserCall(pPickObj->GetUserCall());
139         }
140 
141         if (pImageMap)
142             pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(*pImageMap)));
143 
144         ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView
145 
146         if( IsUndoEnabled() )
147             EndUndo();
148     }
149     else if (DND_ACTION_LINK == mnAction
150         && pPickObj
151         && !bIsGraphic
152         && pPickObj->IsClosedObj()
153         && !dynamic_cast< const SdrOle2Obj* >(pPickObj))
154     {
155         // fill style change (fill object with graphic), independent of mnAction
156         // and thus of DND_ACTION_LINK or DND_ACTION_MOVE
157         if( IsUndoEnabled() )
158         {
159             BegUndo(SdResId(STR_UNDO_DRAGDROP));
160             AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj));
161             EndUndo();
162         }
163 
164         SfxItemSet aSet(mpDocSh->GetPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLBITMAP>{});
165 
166         aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
167         aSet.Put(XFillBitmapItem(rGraphic));
168         pPickObj->SetMergedItemSetAndBroadcast(aSet);
169     }
170 
171     else if ( pPV )
172     {
173         // create  new object
174         Size aSize;
175 
176         if ( rGraphic.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel )
177         {
178             ::OutputDevice* pOutDev = nullptr;
179             if( mpViewSh )
180                 pOutDev = mpViewSh->GetActiveWindow();
181 
182             if( !pOutDev )
183                 pOutDev = Application::GetDefaultDevice();
184 
185             if( pOutDev )
186                 aSize = pOutDev->PixelToLogic(rGraphic.GetPrefSize(), MapMode(MapUnit::Map100thMM));
187         }
188         else
189         {
190             aSize = OutputDevice::LogicToLogic( rGraphic.GetPrefSize(),
191                                                 rGraphic.GetPrefMapMode(),
192                                                 MapMode( MapUnit::Map100thMM ) );
193         }
194 
195         pNewGrafObj = new SdrGrafObj(
196             getSdrModelFromSdrView(),
197             rGraphic,
198             ::tools::Rectangle(rPos, aSize));
199         SdrPage* pPage = pPV->GetPage();
200         Size aPageSize( pPage->GetSize() );
201         aPageSize.AdjustWidth( -(pPage->GetLeftBorder() + pPage->GetRightBorder()) );
202         aPageSize.AdjustHeight( -(pPage->GetUpperBorder() + pPage->GetLowerBorder()) );
203         pNewGrafObj->AdjustToMaxRect( ::tools::Rectangle( Point(), aPageSize ), true );
204 
205         SdrInsertFlags nOptions = SdrInsertFlags::SETDEFLAYER;
206         bool    bIsPresTarget = false;
207 
208         if ((mpViewSh
209                 && mpViewSh->GetViewShell()!=nullptr
210                 && mpViewSh->GetViewShell()->GetIPClient()
211                 && mpViewSh->GetViewShell()->GetIPClient()->IsObjectInPlaceActive())
212             || dynamic_cast<const ::sd::slidesorter::view::SlideSorterView* >(this))
213             nOptions |= SdrInsertFlags::DONTMARK;
214 
215         if( ( mnAction & DND_ACTION_MOVE ) && pPickObj && (pPickObj->IsEmptyPresObj() || pPickObj->GetUserCall()) )
216         {
217             SdPage* pP = static_cast< SdPage* >( pPickObj->getSdrPageFromSdrObject() );
218 
219             if ( pP && pP->IsMasterPage() )
220                 bIsPresTarget = pP->IsPresObj(pPickObj);
221         }
222 
223         if( ( mnAction & DND_ACTION_MOVE ) && pPickObj && !bIsPresTarget )
224         {
225             // replace object
226             if (pImageMap)
227                 pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(*pImageMap)));
228 
229             ::tools::Rectangle aPickObjRect(pPickObj->GetCurrentBoundRect());
230             Size aPickObjSize(aPickObjRect.GetSize());
231             ::tools::Rectangle aObjRect(pNewGrafObj->GetCurrentBoundRect());
232             Size aObjSize(aObjRect.GetSize());
233 
234             Fraction aScaleWidth(aPickObjSize.Width(), aObjSize.Width());
235             Fraction aScaleHeight(aPickObjSize.Height(), aObjSize.Height());
236             pNewGrafObj->NbcResize(aObjRect.TopLeft(), aScaleWidth, aScaleHeight);
237 
238             Point aVec = aPickObjRect.TopLeft() - aObjRect.TopLeft();
239             pNewGrafObj->NbcMove(Size(aVec.X(), aVec.Y()));
240 
241             const bool bUndo = IsUndoEnabled();
242 
243             if( bUndo )
244                 BegUndo(SdResId(STR_UNDO_DRAGDROP));
245             pNewGrafObj->NbcSetLayer(pPickObj->GetLayer());
246             SdrPage* pP = pPV->GetPage();
247             pP->InsertObject(pNewGrafObj);
248             if( bUndo )
249             {
250                 AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoNewObject(*pNewGrafObj));
251                 AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoDeleteObject(*pPickObj));
252             }
253             pP->RemoveObject(pPickObj->GetOrdNum());
254 
255             if( bUndo )
256             {
257                 EndUndo();
258             }
259             else
260             {
261                 SdrObject::Free(pPickObj);
262             }
263             mnAction = DND_ACTION_COPY;
264         }
265         else
266         {
267             bool bSuccess = InsertObjectAtView(pNewGrafObj, *pPV, nOptions);
268             if (!bSuccess)
269                 pNewGrafObj = nullptr;
270             else if (pImageMap)
271                 pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(*pImageMap)));
272         }
273     }
274 
275     rAction = mnAction;
276 
277     return pNewGrafObj;
278 }
279 
InsertMediaURL(const OUString & rMediaURL,sal_Int8 & rAction,const Point & rPos,const Size & rSize,bool const bLink)280 void View::InsertMediaURL( const OUString& rMediaURL, sal_Int8& rAction,
281                                    const Point& rPos, const Size& rSize,
282                                    bool const bLink )
283 {
284     OUString realURL;
285     if (bLink)
286     {
287         realURL = rMediaURL;
288     }
289     else
290     {
291         uno::Reference<frame::XModel> const xModel(
292                 GetDoc().GetObjectShell()->GetModel());
293 #if HAVE_FEATURE_AVMEDIA
294         bool const bRet = ::avmedia::EmbedMedia(xModel, rMediaURL, realURL);
295         if (!bRet) { return; }
296 #else
297         return;
298 #endif
299     }
300 
301     InsertMediaObj( realURL, "application/vnd.sun.star.media", rAction, rPos, rSize );
302 }
303 
InsertMediaObj(const OUString & rMediaURL,const OUString & rMimeType,sal_Int8 & rAction,const Point & rPos,const Size & rSize)304 SdrMediaObj* View::InsertMediaObj( const OUString& rMediaURL, const OUString& rMimeType, sal_Int8& rAction,
305                                    const Point& rPos, const Size& rSize )
306 {
307     SdrEndTextEdit();
308     mnAction = rAction;
309 
310     SdrMediaObj*    pNewMediaObj = nullptr;
311     SdrPageView*    pPV = GetSdrPageView();
312     SdrObject*      pPickObj = GetEmptyPresentationObject( PRESOBJ_MEDIA );
313 
314     if(pPV && dynamic_cast<const ::sd::slidesorter::view::SlideSorterView* >(this) )
315     {
316         if(!pPV->GetPageRect().IsInside(rPos))
317             pPV = nullptr;
318     }
319 
320     if( mnAction == DND_ACTION_LINK && pPV && dynamic_cast< SdrMediaObj *>( pPickObj ) )
321     {
322         pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->CloneSdrObject(pPickObj->getSdrModelFromSdrObject()) );
323         pNewMediaObj->setURL( rMediaURL, ""/*TODO?*/, rMimeType );
324 
325         BegUndo(SdResId(STR_UNDO_DRAGDROP));
326         ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
327         EndUndo();
328     }
329     else if( pPV )
330     {
331         ::tools::Rectangle aRect( rPos, rSize );
332         SdrObjUserCall* pUserCall = nullptr;
333         if( pPickObj )
334         {
335             aRect = pPickObj->GetLogicRect();
336             pUserCall = pPickObj->GetUserCall(); // ReplaceObjectAtView can free pPickObj
337         }
338 
339         pNewMediaObj = new SdrMediaObj(
340             getSdrModelFromSdrView(),
341             aRect);
342 
343         bool bIsPres = false;
344         if( pPickObj )
345         {
346             SdPage* pPage = static_cast< SdPage* >(pPickObj->getSdrPageFromSdrObject());
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         {
358             if (!InsertObjectAtView(pNewMediaObj, *pPV, SdrInsertFlags::SETDEFLAYER))
359                 pNewMediaObj = nullptr;
360         }
361 
362         OUString referer;
363         DrawDocShell * sh = GetDocSh();
364         if (sh != nullptr && sh->HasName()) {
365             referer = sh->GetMedium()->GetName();
366         }
367 
368         if (pNewMediaObj)
369         {
370             pNewMediaObj->setURL( rMediaURL, referer, rMimeType );
371 
372             if( pPickObj )
373             {
374                 pNewMediaObj->AdjustToMaxRect( aRect );
375                 if( bIsPres )
376                     pNewMediaObj->SetUserCall( pUserCall );
377             }
378         }
379     }
380 
381     rAction = mnAction;
382 
383     return pNewMediaObj;
384 }
385 
386 /**
387  * Timer handler for InsertFile at Drop()
388  */
IMPL_LINK_NOARG(View,DropInsertFileHdl,Timer *,void)389 IMPL_LINK_NOARG(View, DropInsertFileHdl, Timer *, void)
390 {
391     DBG_ASSERT( mpViewSh, "sd::View::DropInsertFileHdl(), I need a view shell to work!" );
392     if( !mpViewSh )
393         return;
394 
395     SfxErrorContext aEc( ERRCTX_ERROR, mpViewSh->GetFrameWeld(), RID_SO_ERRCTX );
396     ErrCode nError = ERRCODE_NONE;
397 
398     ::std::vector< OUString >::const_iterator aIter( maDropFileVector.begin() );
399 
400     while( (aIter != maDropFileVector.end()) && !nError )
401     {
402         OUString aCurrentDropFile( *aIter );
403         INetURLObject   aURL( aCurrentDropFile );
404         bool            bOK = false;
405 
406         if( aURL.GetProtocol() == INetProtocol::NotValid )
407         {
408             OUString aURLStr;
409             osl::FileBase::getFileURLFromSystemPath( aCurrentDropFile, aURLStr );
410             aURL = INetURLObject( aURLStr );
411         }
412 
413         GraphicFilter&  rGraphicFilter = GraphicFilter::GetGraphicFilter();
414         Graphic         aGraphic;
415 
416         aCurrentDropFile = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
417 
418 #if HAVE_FEATURE_AVMEDIA
419         if( !::avmedia::MediaWindow::isMediaURL( aCurrentDropFile, ""/*TODO?*/ ) )
420 #else
421 #endif
422         {
423             if( !rGraphicFilter.ImportGraphic( aGraphic, aURL ) )
424             {
425                 sal_Int8    nTempAction = ( aIter == maDropFileVector.begin() ) ? mnAction : 0;
426                 const bool bLink = ( ( nTempAction & DND_ACTION_LINK ) != 0 );
427                 SdrGrafObj* pGrafObj = InsertGraphic( aGraphic, nTempAction, maDropPos, nullptr, nullptr );
428                 if(pGrafObj && bLink)
429                 {
430                     pGrafObj->SetGraphicLink( aCurrentDropFile, ""/*TODO?*/, OUString() );
431                 }
432 
433                 // return action from first inserted graphic
434                 if( aIter == maDropFileVector.begin() )
435                     mnAction = nTempAction;
436 
437                 bOK = true;
438             }
439             if( !bOK )
440             {
441                 std::shared_ptr<const SfxFilter> pFoundFilter;
442                 SfxMedium               aSfxMedium( aCurrentDropFile, StreamMode::READ | StreamMode::SHARE_DENYNONE );
443                 ErrCode                 nErr = SfxGetpApp()->GetFilterMatcher().GuessFilter(  aSfxMedium, pFoundFilter );
444 
445                 if( pFoundFilter && !nErr )
446                 {
447                     ::std::vector< OUString > aFilterVector;
448                     OUString aFilterName = pFoundFilter->GetFilterName();
449                     OUString aLowerAsciiFileName = aCurrentDropFile.toAsciiLowerCase();
450 
451                     FuInsertFile::GetSupportedFilterVector( aFilterVector );
452 
453                     if( ( ::std::find( aFilterVector.begin(), aFilterVector.end(), pFoundFilter->GetMimeType() ) != aFilterVector.end() ) ||
454                         aFilterName.indexOf( "Text" ) != -1 ||
455                         aFilterName.indexOf( "Rich" ) != -1 ||
456                         aFilterName.indexOf( "RTF" ) != -1 ||
457                         aFilterName.indexOf( "HTML" ) != -1 ||
458                         aLowerAsciiFileName.indexOf(".sdd") != -1 ||
459                         aLowerAsciiFileName.indexOf(".sda") != -1 ||
460                         aLowerAsciiFileName.indexOf(".sxd") != -1 ||
461                         aLowerAsciiFileName.indexOf(".sxi") != -1 ||
462                         aLowerAsciiFileName.indexOf(".std") != -1 ||
463                         aLowerAsciiFileName.indexOf(".sti") != -1 )
464                     {
465                         ::sd::Window* pWin = mpViewSh->GetActiveWindow();
466                         SfxRequest      aReq(SID_INSERTFILE, ::SfxCallMode::SLOT, mrDoc.GetItemPool());
467                         SfxStringItem   aItem1( ID_VAL_DUMMY0, aCurrentDropFile ), aItem2( ID_VAL_DUMMY1, pFoundFilter->GetFilterName() );
468 
469                         aReq.AppendItem( aItem1 );
470                         aReq.AppendItem( aItem2 );
471                         FuInsertFile::Create( mpViewSh, pWin, this, &mrDoc, aReq );
472                         bOK = true;
473                     }
474                 }
475             }
476         }
477 
478         if( !bOK )
479         {
480 #if HAVE_FEATURE_AVMEDIA
481             Size aPrefSize;
482 
483             if( ::avmedia::MediaWindow::isMediaURL( aCurrentDropFile, ""/*TODO?*/ ) &&
484                 ::avmedia::MediaWindow::isMediaURL( aCurrentDropFile, ""/*TODO?*/, true, &aPrefSize ) )
485             {
486                 if( aPrefSize.Width() && aPrefSize.Height() )
487                 {
488                     ::sd::Window* pWin = mpViewSh->GetActiveWindow();
489 
490                     if( pWin )
491                         aPrefSize = pWin->PixelToLogic(aPrefSize, MapMode(MapUnit::Map100thMM));
492                     else
493                         aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MapMode(MapUnit::Map100thMM));
494                 }
495                 else
496                     aPrefSize  = Size( 5000, 5000 );
497 
498                 InsertMediaURL( aCurrentDropFile, mnAction, maDropPos, aPrefSize, true ) ;
499             }
500             else
501 #endif
502             if( mnAction & DND_ACTION_LINK )
503                 static_cast< DrawViewShell* >( mpViewSh )->InsertURLButton( aCurrentDropFile, aCurrentDropFile, OUString(), &maDropPos );
504             else
505             {
506                 if( mpViewSh )
507                 {
508                     try
509                     {
510                         //TODO/MBA: testing
511                         OUString aName;
512                         uno::Sequence < beans::PropertyValue > aMedium(1);
513                         aMedium[0].Name = "URL" ;
514                         aMedium[0].Value <<= aCurrentDropFile ;
515 
516                         uno::Reference < embed::XEmbeddedObject > xObj = mpDocSh->GetEmbeddedObjectContainer().
517                                 InsertEmbeddedObject( aMedium, aName );
518 
519                         uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
520                         if ( xPersist.is())
521                         {
522                             // TODO/LEAN: VisualArea access can switch the object to running state
523                             sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
524 
525                             xPersist->storeOwn();
526 
527                             awt::Size aSz;
528                             try
529                             {
530                                 aSz = xObj->getVisualAreaSize( nAspect );
531                             }
532                             catch( embed::NoVisualAreaSizeException& )
533                             {
534                                 // the default size will be set later
535                             }
536 
537                             Size        aSize( aSz.Width, aSz.Height );
538                             ::tools::Rectangle   aRect;
539 
540                             if (!aSize.Width() || !aSize.Height())
541                             {
542                                 aSize.setWidth( 1410 );
543                                 aSize.setHeight( 1000 );
544                             }
545 
546                             aRect = ::tools::Rectangle( maDropPos, aSize );
547 
548                             SdrOle2Obj* pOleObj = new SdrOle2Obj(
549                                 getSdrModelFromSdrView(),
550                                 svt::EmbeddedObjectRef(xObj, nAspect),
551                                 aName,
552                                 aRect);
553                             SdrInsertFlags nOptions = SdrInsertFlags::SETDEFLAYER;
554 
555                             if (mpViewSh != nullptr)
556                             {
557                                 OSL_ASSERT (mpViewSh->GetViewShell()!=nullptr);
558                                 SfxInPlaceClient* pIpClient =
559                                     mpViewSh->GetViewShell()->GetIPClient();
560                                 if (pIpClient!=nullptr && pIpClient->IsObjectInPlaceActive())
561                                     nOptions |= SdrInsertFlags::DONTMARK;
562                             }
563 
564                             if (InsertObjectAtView( pOleObj, *GetSdrPageView(), nOptions ))
565                                 pOleObj->SetLogicRect( aRect );
566                             aSz.Width = aRect.GetWidth();
567                             aSz.Height = aRect.GetHeight();
568                             xObj->setVisualAreaSize( nAspect,aSz );
569                         }
570                     }
571                     catch( uno::Exception& )
572                     {
573                         nError = ERRCODE_IO_GENERAL;
574                         // TODO/LATER: better error handling
575                     }
576                 }
577             }
578         }
579 
580         ++aIter;
581     }
582 
583     if( nError )
584         ErrorHandler::HandleError( nError );
585 }
586 
587 /**
588  * Timer handler for Errorhandling at Drop()
589  */
IMPL_LINK_NOARG(View,DropErrorHdl,Timer *,void)590 IMPL_LINK_NOARG(View, DropErrorHdl, Timer *, void)
591 {
592     vcl::Window* pWin = mpViewSh ? mpViewSh->GetActiveWindow() : nullptr;
593     std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr,
594                                                   VclMessageType::Info, VclButtonsType::Ok,
595                                                   SdResId(STR_ACTION_NOTPOSSIBLE)));
596     xInfoBox->run();
597 }
598 
599 /**
600  * @returns StyleSheet from selection
601  */
GetStyleSheet() const602 SfxStyleSheet* View::GetStyleSheet() const
603 {
604     return SdrView::GetStyleSheet();
605 }
606 
607 } // end of namespace sd
608 
609 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
610