LCOV - code coverage report
Current view: top level - sd/source/ui/view - sdview4.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 285 0.0 %
Date: 2014-04-14 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10