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

Generated by: LCOV version 1.11