LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuinsert.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 335 0.0 %
Date: 2012-08-25 Functions: 0 32 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 930 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "fuinsert.hxx"
      31                 :            : 
      32                 :            : #include <comphelper/storagehelper.hxx>
      33                 :            : #include <comphelper/processfactory.hxx>
      34                 :            : #include <toolkit/helper/vclunohelper.hxx>
      35                 :            : #include <svx/svxdlg.hxx>
      36                 :            : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      37                 :            : #include <com/sun/star/embed/Aspects.hpp>
      38                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      39                 :            : #include <com/sun/star/chart2/XChartDocument.hpp>
      40                 :            : #include <com/sun/star/drawing/FillStyle.hpp>
      41                 :            : 
      42                 :            : #include <tools/urlobj.hxx>
      43                 :            : #include <svl/urihelper.hxx>
      44                 :            : #include <sfx2/msgpool.hxx>
      45                 :            : #include <svtools/sores.hxx>
      46                 :            : #include <svtools/insdlg.hxx>
      47                 :            : #include <sfx2/request.hxx>
      48                 :            : #include <svl/globalnameitem.hxx>
      49                 :            : #include <unotools/pathoptions.hxx>
      50                 :            : #include <svtools/miscopt.hxx>
      51                 :            : #include <svx/pfiledlg.hxx>
      52                 :            : #include <svx/dialogs.hrc>
      53                 :            : #include <sfx2/linkmgr.hxx>
      54                 :            : #include <svx/linkwarn.hxx>
      55                 :            : #include <svx/svdetc.hxx>
      56                 :            : #include <avmedia/mediawindow.hxx>
      57                 :            : #include <unotools/ucbstreamhelper.hxx>
      58                 :            : #include <sfx2/printer.hxx>
      59                 :            : #include <sot/clsids.hxx>
      60                 :            : #include <svtools/sfxecode.hxx>
      61                 :            : #include <svtools/transfer.hxx>
      62                 :            : #include <svl/urlbmk.hxx>
      63                 :            : #include <svx/svdobj.hxx>
      64                 :            : #include <svx/svdograf.hxx>
      65                 :            : #include <svx/svdoole2.hxx>
      66                 :            : #include <svx/svdomedia.hxx>
      67                 :            : #include <editeng/editeng.hxx>
      68                 :            : #include <sot/storage.hxx>
      69                 :            : #include <sot/formats.hxx>
      70                 :            : #include <svx/svdpagv.hxx>
      71                 :            : #include <vcl/msgbox.hxx>
      72                 :            : #include <sfx2/opengrf.hxx>
      73                 :            : 
      74                 :            : #include <sfx2/viewfrm.hxx>
      75                 :            : 
      76                 :            : #include "app.hrc"
      77                 :            : #include "sdresid.hxx"
      78                 :            : #include "View.hxx"
      79                 :            : #include "app.hxx"
      80                 :            : #include "Window.hxx"
      81                 :            : #include "drawview.hxx"
      82                 :            : #include "DrawViewShell.hxx"
      83                 :            : #include "DrawDocShell.hxx"
      84                 :            : #include "GraphicDocShell.hxx"
      85                 :            : #include "strings.hrc"
      86                 :            : #include "drawdoc.hxx"
      87                 :            : #include "sdgrffilter.hxx"
      88                 :            : #include "sdxfer.hxx"
      89                 :            : #include <vcl/svapp.hxx>
      90                 :            : #include "undo/undoobjects.hxx"
      91                 :            : 
      92                 :            : using namespace com::sun::star;
      93                 :            : 
      94                 :            : namespace sd {
      95                 :            : 
      96 [ #  # ][ #  # ]:          0 : TYPEINIT1( FuInsertGraphic, FuPoor );
      97 [ #  # ][ #  # ]:          0 : TYPEINIT1( FuInsertClipboard, FuPoor );
      98 [ #  # ][ #  # ]:          0 : TYPEINIT1( FuInsertOLE, FuPoor );
      99 [ #  # ][ #  # ]:          0 : TYPEINIT1( FuInsertAVMedia, FuPoor );
     100                 :            : 
     101                 :            : /*************************************************************************
     102                 :            : |*
     103                 :            : |* FuInsertGraphic::Konstruktor
     104                 :            : |*
     105                 :            : \************************************************************************/
     106                 :            : 
     107                 :          0 : FuInsertGraphic::FuInsertGraphic (
     108                 :            :     ViewShell* pViewSh,
     109                 :            :     ::sd::Window* pWin,
     110                 :            :     ::sd::View* pView,
     111                 :            :     SdDrawDocument* pDoc,
     112                 :            :     SfxRequest& rReq)
     113                 :          0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
     114                 :            : {
     115                 :          0 : }
     116                 :            : 
     117                 :          0 : FunctionReference FuInsertGraphic::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
     118                 :            : {
     119 [ #  # ][ #  # ]:          0 :     FunctionReference xFunc( new FuInsertGraphic( pViewSh, pWin, pView, pDoc, rReq ) );
     120         [ #  # ]:          0 :     xFunc->DoExecute(rReq);
     121                 :          0 :     return xFunc;
     122                 :            : }
     123                 :            : 
     124                 :            : #ifdef _MSC_VER
     125                 :            : #pragma optimize ( "", off )
     126                 :            : #endif
     127                 :            : 
     128                 :          0 : void FuInsertGraphic::DoExecute( SfxRequest&  )
     129                 :            : {
     130 [ #  # ][ #  # ]:          0 :     SvxOpenGraphicDialog    aDlg(SdResId(STR_INSERTGRAPHIC));
         [ #  # ][ #  # ]
     131                 :            : 
     132 [ #  # ][ #  # ]:          0 :     if( aDlg.Execute() == GRFILTER_OK )
     133                 :            :     {
     134         [ #  # ]:          0 :         Graphic     aGraphic;
     135         [ #  # ]:          0 :         int nError = aDlg.GetGraphic(aGraphic);
     136         [ #  # ]:          0 :         if( nError == GRFILTER_OK )
     137                 :            :         {
     138 [ #  # ][ #  # ]:          0 :             if( mpViewShell && mpViewShell->ISA(DrawViewShell))
         [ #  # ][ #  # ]
                 [ #  # ]
     139                 :            :             {
     140                 :          0 :                 sal_Int8    nAction = DND_ACTION_COPY;
     141         [ #  # ]:          0 :                 SdrObject* pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC );
     142         [ #  # ]:          0 :                 if( pPickObj )
     143                 :          0 :                     nAction = DND_ACTION_LINK;
     144                 :            : 
     145                 :          0 :                 Point aPos;
     146         [ #  # ]:          0 :                 Rectangle aRect(aPos, mpWindow->GetOutputSizePixel() );
     147         [ #  # ]:          0 :                 aPos = aRect.Center();
     148         [ #  # ]:          0 :                 aPos = mpWindow->PixelToLogic(aPos);
     149         [ #  # ]:          0 :                 SdrGrafObj* pGrafObj = mpView->InsertGraphic(aGraphic, nAction, aPos, pPickObj, NULL);
     150                 :            : 
     151 [ #  # ][ #  # ]:          0 :                 if(pGrafObj && aDlg.IsAsLink())
         [ #  # ][ #  # ]
     152                 :            :                 {
     153                 :            :                     // really store as link only?
     154 [ #  # ][ #  # ]:          0 :                     if( SvtMiscOptions().ShowLinkWarningDialog() )
         [ #  # ][ #  # ]
     155                 :            :                     {
     156 [ #  # ][ #  # ]:          0 :                         SvxLinkWarningDialog aWarnDlg(mpWindow,aDlg.GetPath());
                 [ #  # ]
     157 [ #  # ][ #  # ]:          0 :                         if( aWarnDlg.Execute() != RET_OK )
     158 [ #  # ][ #  # ]:          0 :                             return; // don't store as link
     159                 :            :                     }
     160                 :            : 
     161                 :            :                     // store as link
     162         [ #  # ]:          0 :                     String aFltName(aDlg.GetCurrentFilter());
     163         [ #  # ]:          0 :                     String aPath(aDlg.GetPath());
     164 [ #  # ][ #  # ]:          0 :                     pGrafObj->SetGraphicLink(aPath, aFltName);
         [ #  # ][ #  # ]
     165                 :            :                 }
     166                 :            :             }
     167                 :            :         }
     168                 :            :         else
     169                 :            :         {
     170 [ #  # ][ #  # ]:          0 :             SdGRFFilter::HandleGraphicFilterError( (sal_uInt16)nError, GraphicFilter::GetGraphicFilter().GetLastError().nStreamError );
                 [ #  # ]
     171 [ #  # ][ #  # ]:          0 :         }
     172 [ #  # ][ #  # ]:          0 :     }
     173                 :            : }
     174                 :            : 
     175                 :            : #ifdef _MSC_VER
     176                 :            : #pragma optimize ( "", on )
     177                 :            : #endif
     178                 :            : 
     179                 :            : /*************************************************************************
     180                 :            : |*
     181                 :            : |* FuInsertClipboard::Konstruktor
     182                 :            : |*
     183                 :            : \************************************************************************/
     184                 :            : 
     185                 :          0 : FuInsertClipboard::FuInsertClipboard (
     186                 :            :     ViewShell* pViewSh,
     187                 :            :     ::sd::Window* pWin,
     188                 :            :     ::sd::View* pView,
     189                 :            :     SdDrawDocument* pDoc,
     190                 :            :     SfxRequest& rReq)
     191                 :          0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
     192                 :            : {
     193                 :          0 : }
     194                 :            : 
     195                 :          0 : FunctionReference FuInsertClipboard::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
     196                 :            : {
     197 [ #  # ][ #  # ]:          0 :     FunctionReference xFunc( new FuInsertClipboard( pViewSh, pWin, pView, pDoc, rReq ) );
     198         [ #  # ]:          0 :     xFunc->DoExecute(rReq);
     199                 :          0 :     return xFunc;
     200                 :            : }
     201                 :            : 
     202                 :          0 : void FuInsertClipboard::DoExecute( SfxRequest&  )
     203                 :            : {
     204         [ #  # ]:          0 :     TransferableDataHelper                      aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpWindow ) );
     205                 :            :     sal_uLong                                       nFormatId;
     206                 :            : 
     207         [ #  # ]:          0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     208 [ #  # ][ #  # ]:          0 :     SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( mpViewShell->GetActiveWindow() );
     209         [ #  # ]:          0 :     if ( pDlg )
     210                 :            :     {
     211         [ #  # ]:          0 :         const String                                aEmptyString;
     212                 :          0 :         ::com::sun::star::datatransfer::DataFlavor  aFlavor;
     213                 :            : 
     214         [ #  # ]:          0 :         pDlg->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE, aEmptyString );
     215         [ #  # ]:          0 :         pDlg->Insert( SOT_FORMATSTR_ID_LINK_SOURCE, aEmptyString );
     216         [ #  # ]:          0 :         pDlg->Insert( SOT_FORMATSTR_ID_DRAWING, aEmptyString );
     217         [ #  # ]:          0 :         pDlg->Insert( SOT_FORMATSTR_ID_SVXB, aEmptyString );
     218         [ #  # ]:          0 :         pDlg->Insert( FORMAT_GDIMETAFILE, aEmptyString );
     219         [ #  # ]:          0 :         pDlg->Insert( FORMAT_BITMAP, aEmptyString );
     220         [ #  # ]:          0 :         pDlg->Insert( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aEmptyString );
     221         [ #  # ]:          0 :         pDlg->Insert( FORMAT_STRING, aEmptyString );
     222         [ #  # ]:          0 :         pDlg->Insert( SOT_FORMATSTR_ID_HTML, aEmptyString );
     223         [ #  # ]:          0 :         pDlg->Insert( FORMAT_RTF, aEmptyString );
     224         [ #  # ]:          0 :         pDlg->Insert( SOT_FORMATSTR_ID_EDITENGINE, aEmptyString );
     225                 :            : 
     226                 :            :         //TODO/MBA: testing
     227         [ #  # ]:          0 :         nFormatId = pDlg->GetFormat( aDataHelper );
     228 [ #  # ][ #  # ]:          0 :         if( nFormatId && aDataHelper.GetTransferable().is() )
                 [ #  # ]
     229                 :            :         {
     230                 :          0 :             sal_Int8 nAction = DND_ACTION_COPY;
     231                 :            : 
     232 [ #  # ][ #  # ]:          0 :             if( !mpView->InsertData( aDataHelper,
         [ #  # ][ #  # ]
     233 [ #  # ][ #  # ]:          0 :                                     mpWindow->PixelToLogic( Rectangle( Point(), mpWindow->GetOutputSizePixel() ).Center() ),
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
             #  #  #  # ]
     234 [ #  # ][ #  # ]:          0 :                                     nAction, sal_False, nFormatId ) &&
         [ #  # ][ #  # ]
     235 [ #  # ][ #  # ]:          0 :                 ( mpViewShell && mpViewShell->ISA( DrawViewShell ) ) )
     236                 :            :             {
     237                 :          0 :                 DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>(mpViewShell);
     238         [ #  # ]:          0 :                 INetBookmark        aINetBookmark( aEmptyStr, aEmptyStr );
     239                 :            : 
     240 [ #  # ][ #  # ]:          0 :                 if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     241         [ #  # ]:          0 :                     aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
     242         [ #  # ]:          0 :                     ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
     243         [ #  # ]:          0 :                     aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
     244         [ #  # ]:          0 :                     ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
     245         [ #  # ]:          0 :                     aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
     246                 :            :                 {
     247         [ #  # ]:          0 :                     pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
     248         [ #  # ]:          0 :                 }
     249                 :            :             }
     250                 :            :         }
     251                 :            : 
     252 [ #  # ][ #  # ]:          0 :         delete pDlg;
                 [ #  # ]
     253         [ #  # ]:          0 :     }
     254                 :          0 : }
     255                 :            : 
     256                 :            : 
     257                 :            : /*************************************************************************
     258                 :            : |*
     259                 :            : |* FuInsertOLE::Konstruktor
     260                 :            : |*
     261                 :            : \************************************************************************/
     262                 :            : 
     263                 :          0 : FuInsertOLE::FuInsertOLE (
     264                 :            :     ViewShell* pViewSh,
     265                 :            :     ::sd::Window* pWin,
     266                 :            :     ::sd::View* pView,
     267                 :            :     SdDrawDocument* pDoc,
     268                 :            :     SfxRequest& rReq)
     269                 :          0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
     270                 :            : {
     271                 :          0 : }
     272                 :            : 
     273                 :          0 : FunctionReference FuInsertOLE::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
     274                 :            : {
     275 [ #  # ][ #  # ]:          0 :     FunctionReference xFunc( new FuInsertOLE( pViewSh, pWin, pView, pDoc, rReq ) );
     276         [ #  # ]:          0 :     xFunc->DoExecute(rReq);
     277                 :          0 :     return xFunc;
     278                 :            : }
     279                 :            : 
     280                 :          0 : void FuInsertOLE::DoExecute( SfxRequest& rReq )
     281                 :            : {
     282 [ #  # ][ #  # ]:          0 :     if ( nSlotId == SID_ATTR_TABLE ||
                 [ #  # ]
     283                 :            :          nSlotId == SID_INSERT_DIAGRAM ||
     284                 :            :          nSlotId == SID_INSERT_MATH )
     285                 :            :     {
     286         [ #  # ]:          0 :         PresObjKind ePresObjKind = (nSlotId == SID_INSERT_DIAGRAM) ? PRESOBJ_CHART : PRESOBJ_OBJECT;
     287                 :            : 
     288         [ #  # ]:          0 :         SdrObject* pPickObj = mpView->GetEmptyPresentationObject( ePresObjKind );
     289                 :            : 
     290                 :            :         /**********************************************************************
     291                 :            :         * Diagramm oder StarCalc-Tabelle einfuegen
     292                 :            :         **********************************************************************/
     293                 :            : 
     294                 :          0 :         ::rtl::OUString aObjName;
     295         [ #  # ]:          0 :         SvGlobalName aName;
     296         [ #  # ]:          0 :         if (nSlotId == SID_INSERT_DIAGRAM)
     297 [ #  # ][ #  # ]:          0 :             aName = SvGlobalName( SO3_SCH_CLASSID);
                 [ #  # ]
     298         [ #  # ]:          0 :         else if (nSlotId == SID_ATTR_TABLE)
     299 [ #  # ][ #  # ]:          0 :             aName = SvGlobalName(SO3_SC_CLASSID);
                 [ #  # ]
     300         [ #  # ]:          0 :         else if (nSlotId == SID_INSERT_MATH)
     301 [ #  # ][ #  # ]:          0 :             aName = SvGlobalName(SO3_SM_CLASSID);
                 [ #  # ]
     302                 :            : 
     303         [ #  # ]:          0 :         uno::Reference < embed::XEmbeddedObject > xObj = mpViewShell->GetViewFrame()->GetObjectShell()->
     304 [ #  # ][ #  # ]:          0 :                 GetEmbeddedObjectContainer().CreateEmbeddedObject( aName.GetByteSequence(), aObjName );
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     305         [ #  # ]:          0 :         if ( xObj.is() )
     306                 :            :         {
     307                 :          0 :             sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
     308                 :            : 
     309 [ #  # ][ #  # ]:          0 :             MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
                 [ #  # ]
     310                 :            : 
     311         [ #  # ]:          0 :             Rectangle aRect;
     312         [ #  # ]:          0 :             if( pPickObj )
     313                 :            :             {
     314         [ #  # ]:          0 :                 aRect = pPickObj->GetLogicRect();
     315                 :            : 
     316                 :          0 :                 awt::Size aSz;
     317         [ #  # ]:          0 :                 aSz.Width = aRect.GetWidth();
     318         [ #  # ]:          0 :                 aSz.Height = aRect.GetHeight();
     319 [ #  # ][ #  # ]:          0 :                 xObj->setVisualAreaSize( nAspect, aSz );
     320                 :            :             }
     321                 :            :             else
     322                 :            :             {
     323                 :          0 :                 awt::Size aSz;
     324                 :            :                 try
     325                 :            :                 {
     326 [ #  # ][ #  # ]:          0 :                     aSz = xObj->getVisualAreaSize( nAspect );
     327                 :            :                 }
     328         [ #  # ]:          0 :                 catch ( embed::NoVisualAreaSizeException& )
     329                 :            :                 {
     330                 :            :                     // the default size will be set later
     331                 :            :                 }
     332                 :            : 
     333                 :          0 :                 Size aSize( aSz.Width, aSz.Height );
     334                 :            : 
     335 [ #  # ][ #  # ]:          0 :                 if (aSize.Height() == 0 || aSize.Width() == 0)
                 [ #  # ]
     336                 :            :                 {
     337                 :            :                     // Rechteck mit ausgewogenem Kantenverhaeltnis
     338                 :          0 :                     aSize.Width()  = 14100;
     339                 :          0 :                     aSize.Height() = 10000;
     340 [ #  # ][ #  # ]:          0 :                     Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aUnit );
         [ #  # ][ #  # ]
                 [ #  # ]
     341                 :          0 :                     aSz.Width = aTmp.Width();
     342                 :          0 :                     aSz.Height = aTmp.Height();
     343 [ #  # ][ #  # ]:          0 :                     xObj->setVisualAreaSize( nAspect, aSz );
     344                 :            :                 }
     345                 :            :                 else
     346                 :            :                 {
     347 [ #  # ][ #  # ]:          0 :                     aSize = OutputDevice::LogicToLogic(aSize, aUnit, MAP_100TH_MM);
         [ #  # ][ #  # ]
                 [ #  # ]
     348                 :            :                 }
     349                 :            : 
     350                 :          0 :                 Point aPos;
     351         [ #  # ]:          0 :                 Rectangle aWinRect(aPos, mpWindow->GetOutputSizePixel() );
     352         [ #  # ]:          0 :                 aPos = aWinRect.Center();
     353         [ #  # ]:          0 :                 aPos = mpWindow->PixelToLogic(aPos);
     354                 :          0 :                 aPos.X() -= aSize.Width() / 2;
     355                 :          0 :                 aPos.Y() -= aSize.Height() / 2;
     356         [ #  # ]:          0 :                 aRect = Rectangle(aPos, aSize);
     357                 :            :             }
     358                 :            : 
     359 [ #  # ][ #  # ]:          0 :             SdrOle2Obj* pOleObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aObjName, aRect );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     360                 :          0 :             SdrPageView* pPV = mpView->GetSdrPageView();
     361                 :            : 
     362                 :            :             // if we have a pick obj we need to make this new ole a pres obj replacing the current pick obj
     363         [ #  # ]:          0 :             if( pPickObj )
     364                 :            :             {
     365         [ #  # ]:          0 :                 SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage());
     366 [ #  # ][ #  # ]:          0 :                 if(pPage && pPage->IsPresObj(pPickObj))
         [ #  # ][ #  # ]
     367                 :            :                 {
     368         [ #  # ]:          0 :                     pPage->InsertPresObj( pOleObj, ePresObjKind );
     369 [ #  # ][ #  # ]:          0 :                     pOleObj->SetUserCall(pPickObj->GetUserCall());
     370                 :            :                 }
     371                 :            :             }
     372                 :            : 
     373                 :          0 :             bool bRet = true;
     374         [ #  # ]:          0 :             if( pPickObj )
     375         [ #  # ]:          0 :                 mpView->ReplaceObjectAtView(pPickObj, *pPV, pOleObj, sal_True );
     376                 :            :             else
     377         [ #  # ]:          0 :                 bRet = mpView->InsertObjectAtView(pOleObj, *pPV, SDRINSERT_SETDEFLAYER);
     378                 :            : 
     379         [ #  # ]:          0 :             if( bRet )
     380                 :            :             {
     381         [ #  # ]:          0 :                 if (nSlotId == SID_INSERT_DIAGRAM)
     382                 :            :                 {
     383 [ #  # ][ #  # ]:          0 :                     pOleObj->SetProgName( rtl::OUString( "StarChart" ));
                 [ #  # ]
     384                 :            :                 }
     385         [ #  # ]:          0 :                 else if (nSlotId == SID_ATTR_TABLE)
     386                 :            :                 {
     387 [ #  # ][ #  # ]:          0 :                     pOleObj->SetProgName( rtl::OUString( "StarCalc" ) );
                 [ #  # ]
     388                 :            :                 }
     389         [ #  # ]:          0 :                 else if (nSlotId == SID_INSERT_MATH)
     390                 :            :                 {
     391 [ #  # ][ #  # ]:          0 :                     pOleObj->SetProgName( rtl::OUString( "StarMath" ) );
                 [ #  # ]
     392                 :            :                 }
     393                 :            : 
     394         [ #  # ]:          0 :                 pOleObj->SetLogicRect(aRect);
     395 [ #  # ][ #  # ]:          0 :                 Size aTmp( OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aUnit ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     396                 :          0 :                 awt::Size aVisualSize;
     397                 :          0 :                 aVisualSize.Width = aTmp.Width();
     398                 :          0 :                 aVisualSize.Height = aTmp.Height();
     399 [ #  # ][ #  # ]:          0 :                 xObj->setVisualAreaSize( nAspect, aVisualSize );
     400         [ #  # ]:          0 :                 mpViewShell->ActivateObject(pOleObj, SVVERB_SHOW);
     401                 :            : 
     402         [ #  # ]:          0 :                 if (nSlotId == SID_INSERT_DIAGRAM)
     403                 :            :                 {
     404                 :            :                     // note, that this call modified the chart model which
     405                 :            :                     // results in a change notification.  So call this after
     406                 :            :                     // everything else is finished.
     407         [ #  # ]:          0 :                     mpViewShell->AdaptDefaultsForChart( xObj );
     408                 :            :                 }
     409                 :            :             }
     410                 :            :         }
     411                 :            :         else
     412                 :            :         {
     413                 :            :             ErrorHandler::HandleError(* new StringErrorInfo(ERRCODE_SFX_OLEGENERAL,
     414 [ #  # ][ #  # ]:          0 :                                         aEmptyStr ) );
         [ #  # ][ #  # ]
     415         [ #  # ]:          0 :         }
     416                 :            :     }
     417                 :            :     else
     418                 :            :     {
     419                 :            :         /**********************************************************************
     420                 :            :         * Objekt einfuegen
     421                 :            :         **********************************************************************/
     422                 :          0 :         sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
     423                 :          0 :         sal_Bool bCreateNew = sal_False;
     424                 :          0 :         uno::Reference < embed::XEmbeddedObject > xObj;
     425         [ #  # ]:          0 :         uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
     426         [ #  # ]:          0 :         SvObjectServerList aServerLst;
     427                 :          0 :         ::rtl::OUString aName;
     428                 :            : 
     429                 :          0 :         ::rtl::OUString aIconMediaType;
     430                 :          0 :         uno::Reference< io::XInputStream > xIconMetaFile;
     431                 :            : 
     432 [ #  # ][ #  # ]:          0 :         SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, sal_False );
     433 [ #  # ][ #  # ]:          0 :         if ( nSlotId == SID_INSERT_OBJECT && pNameItem )
     434                 :            :         {
     435         [ #  # ]:          0 :             SvGlobalName aClassName = pNameItem->GetValue();
     436         [ #  # ]:          0 :             xObj =  mpViewShell->GetViewFrame()->GetObjectShell()->
     437 [ #  # ][ #  # ]:          0 :                     GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aName );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     438                 :            :         }
     439                 :            :         else
     440                 :            :         {
     441   [ #  #  #  # ]:          0 :             switch ( nSlotId )
     442                 :            :             {
     443                 :            :                 case SID_INSERT_OBJECT :
     444                 :            :                 {
     445         [ #  # ]:          0 :                     aServerLst.FillInsertObjects();
     446         [ #  # ]:          0 :                     if (mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW)
     447                 :            :                     {
     448 [ #  # ][ #  # ]:          0 :                         aServerLst.Remove( GraphicDocShell::Factory().GetClassId() );
                 [ #  # ]
     449                 :            :                     }
     450                 :            :                     else
     451                 :            :                     {
     452 [ #  # ][ #  # ]:          0 :                         aServerLst.Remove( DrawDocShell::Factory().GetClassId() );
                 [ #  # ]
     453                 :            :                     }
     454                 :            : 
     455                 :            :                     // intentionally no break!
     456                 :            :                 }
     457                 :            :                 case SID_INSERT_PLUGIN :
     458                 :            :                 case SID_INSERT_FLOATINGFRAME :
     459                 :            :                 {
     460         [ #  # ]:          0 :                     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     461                 :            :                     SfxAbstractInsertObjectDialog* pDlg =
     462 [ #  # ][ #  # ]:          0 :                             pFact->CreateInsertObjectDialog( mpViewShell->GetActiveWindow(), SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommandString(),
     463 [ #  # ][ #  # ]:          0 :                             xStorage, &aServerLst );
         [ #  # ][ #  # ]
     464         [ #  # ]:          0 :                     if ( pDlg )
     465                 :            :                     {
     466         [ #  # ]:          0 :                         pDlg->Execute();
     467         [ #  # ]:          0 :                         bCreateNew = pDlg->IsCreateNew();
     468 [ #  # ][ #  # ]:          0 :                         xObj = pDlg->GetObject();
     469                 :            : 
     470 [ #  # ][ #  # ]:          0 :                         xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
     471         [ #  # ]:          0 :                         if ( xIconMetaFile.is() )
     472                 :          0 :                             nAspect = embed::Aspects::MSOLE_ICON;
     473                 :            : 
     474         [ #  # ]:          0 :                         if ( xObj.is() )
     475 [ #  # ][ #  # ]:          0 :                             mpViewShell->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
                 [ #  # ]
     476 [ #  # ][ #  # ]:          0 :                         DELETEZ( pDlg );
     477                 :            :                     }
     478                 :            : 
     479                 :          0 :                     break;
     480                 :            :                 }
     481                 :            :                 case SID_INSERT_SOUND :
     482                 :            :                 case SID_INSERT_VIDEO :
     483                 :            :                 {
     484                 :            :                     // create special filedialog for plugins
     485         [ #  # ]:          0 :                     SvxPluginFileDlg aPluginFileDialog (mpWindow, nSlotId);
     486 [ #  # ][ #  # ]:          0 :                     if( ERRCODE_NONE == aPluginFileDialog.Execute () )
     487                 :            :                     {
     488                 :            :                         // get URL
     489         [ #  # ]:          0 :                         String aStrURL(aPluginFileDialog.GetPath());
     490 [ #  # ][ #  # ]:          0 :                         INetURLObject aURL( aStrURL, INET_PROT_FILE );
     491         [ #  # ]:          0 :                         if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
     492                 :            :                         {
     493                 :            :                             // create a plugin object
     494 [ #  # ][ #  # ]:          0 :                             xObj = mpViewShell->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aName );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     495                 :            :                         }
     496                 :            : 
     497 [ #  # ][ #  # ]:          0 :                         if ( xObj.is() && svt::EmbeddedObjectRef::TryRunningState( xObj ) )
         [ #  # ][ #  # ]
     498                 :            :                         {
     499                 :            :                             // set properties from dialog
     500         [ #  # ]:          0 :                             uno::Reference < embed::XComponentSupplier > xSup( xObj, uno::UNO_QUERY );
     501         [ #  # ]:          0 :                             if ( xSup.is() )
     502                 :            :                             {
     503 [ #  # ][ #  # ]:          0 :                                 uno::Reference < beans::XPropertySet > xSet( xSup->getComponent(), uno::UNO_QUERY );
                 [ #  # ]
     504         [ #  # ]:          0 :                                 if ( xSet.is() )
     505                 :            :                                 {
     506         [ #  # ]:          0 :                                     xSet->setPropertyValue("PluginURL",
     507 [ #  # ][ #  # ]:          0 :                                             uno::makeAny( ::rtl::OUString( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) );
                 [ #  # ]
     508                 :          0 :                                 }
     509                 :          0 :                             }
     510                 :            :                         }
     511                 :            :                         else
     512                 :            :                         {
     513                 :            :                             // PlugIn konnte nicht erzeugt werden
     514 [ #  # ][ #  # ]:          0 :                             String aStrErr( SdResId( STR_ERROR_OBJNOCREATE_PLUGIN ) );
     515         [ #  # ]:          0 :                             String aMask;
     516         [ #  # ]:          0 :                             aMask += sal_Unicode('%');
     517         [ #  # ]:          0 :                             aStrErr.SearchAndReplace( aMask, aStrURL );
     518 [ #  # ][ #  # ]:          0 :                             ErrorBox( mpWindow, WB_3DLOOK | WB_OK, aStrErr ).Execute();
         [ #  # ][ #  # ]
                 [ #  # ]
     519 [ #  # ][ #  # ]:          0 :                         }
     520 [ #  # ][ #  # ]:          0 :                     }
     521                 :            :                 }
     522                 :            :             }
     523                 :            :         }
     524                 :            : 
     525                 :            :         try
     526                 :            :         {
     527         [ #  # ]:          0 :             if (xObj.is())
     528                 :            :             {
     529                 :            :                 //TODO/LATER: needs status for RESIZEONPRINTERCHANGE
     530                 :            :                 //if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xObj->getStatus( nAspect ) )
     531                 :            :                 //    aIPObj->OnDocumentPrinterChanged( mpDocSh->GetPrinter(sal_False) );
     532                 :            : 
     533                 :          0 :                 sal_Bool bInsertNewObject = sal_True;
     534                 :            : 
     535                 :          0 :                 Size aSize;
     536                 :          0 :                 MapUnit aMapUnit = MAP_100TH_MM;
     537         [ #  # ]:          0 :                 if ( nAspect != embed::Aspects::MSOLE_ICON )
     538                 :            :                 {
     539                 :          0 :                     awt::Size aSz;
     540                 :            :                     try
     541                 :            :                     {
     542 [ #  # ][ #  # ]:          0 :                         aSz = xObj->getVisualAreaSize( nAspect );
     543                 :            :                     }
     544         [ #  # ]:          0 :                     catch( embed::NoVisualAreaSizeException& )
     545                 :            :                     {
     546                 :            :                         // the default size will be set later
     547                 :            :                     }
     548                 :            : 
     549                 :          0 :                     aSize =Size( aSz.Width, aSz.Height );
     550                 :            : 
     551 [ #  # ][ #  # ]:          0 :                     aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
                 [ #  # ]
     552 [ #  # ][ #  # ]:          0 :                     if (aSize.Height() == 0 || aSize.Width() == 0)
                 [ #  # ]
     553                 :            :                     {
     554                 :            :                         // Rechteck mit ausgewogenem Kantenverhaeltnis
     555                 :          0 :                         aSize.Width()  = 14100;
     556                 :          0 :                         aSize.Height() = 10000;
     557 [ #  # ][ #  # ]:          0 :                         Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aMapUnit );
         [ #  # ][ #  # ]
                 [ #  # ]
     558                 :          0 :                         aSz.Width = aTmp.Width();
     559                 :          0 :                         aSz.Height = aTmp.Height();
     560 [ #  # ][ #  # ]:          0 :                         xObj->setVisualAreaSize( nAspect, aSz );
     561                 :            :                     }
     562                 :            :                     else
     563                 :            :                     {
     564 [ #  # ][ #  # ]:          0 :                         aSize = OutputDevice::LogicToLogic(aSize, aMapUnit, MAP_100TH_MM);
         [ #  # ][ #  # ]
                 [ #  # ]
     565                 :            :                     }
     566                 :            :                 }
     567                 :            : 
     568         [ #  # ]:          0 :                 if ( mpView->AreObjectsMarked() )
     569                 :            :                 {
     570                 :            :                     /**********************************************************
     571                 :            :                         * Ist ein leeres OLE-Objekt vorhanden?
     572                 :            :                         **********************************************************/
     573                 :          0 :                     const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
     574                 :            : 
     575         [ #  # ]:          0 :                     if (rMarkList.GetMarkCount() == 1)
     576                 :            :                     {
     577         [ #  # ]:          0 :                         SdrMark* pMark = rMarkList.GetMark(0);
     578         [ #  # ]:          0 :                         SdrObject* pObj = pMark->GetMarkedSdrObj();
     579                 :            : 
     580 [ #  # ][ #  # ]:          0 :                         if (pObj->GetObjInventor() == SdrInventor &&
         [ #  # ][ #  # ]
     581         [ #  # ]:          0 :                         pObj->GetObjIdentifier() == OBJ_OLE2)
     582                 :            :                         {
     583 [ #  # ][ #  # ]:          0 :                             if ( !( (SdrOle2Obj*) pObj)->GetObjRef().is() )
     584                 :            :                             {
     585                 :            :                                 /**************************************************
     586                 :            :                                     * Das leere OLE-Objekt bekommt ein neues IPObj
     587                 :            :                                     **************************************************/
     588                 :          0 :                                 bInsertNewObject = sal_False;
     589         [ #  # ]:          0 :                                 pObj->SetEmptyPresObj(sal_False);
     590         [ #  # ]:          0 :                                 ( (SdrOle2Obj*) pObj)->SetOutlinerParaObject(NULL);
     591         [ #  # ]:          0 :                                 ( (SdrOle2Obj*) pObj)->SetObjRef(xObj);
     592 [ #  # ][ #  # ]:          0 :                                 ( (SdrOle2Obj*) pObj)->SetPersistName(aName);
                 [ #  # ]
     593         [ #  # ]:          0 :                                 ( (SdrOle2Obj*) pObj)->SetName(aName);
     594         [ #  # ]:          0 :                                 ( (SdrOle2Obj*) pObj)->SetAspect(nAspect);
     595         [ #  # ]:          0 :                                 Rectangle aRect = ( (SdrOle2Obj*) pObj)->GetLogicRect();
     596                 :            : 
     597         [ #  # ]:          0 :                                 if ( nAspect == embed::Aspects::MSOLE_ICON )
     598                 :            :                                 {
     599         [ #  # ]:          0 :                                     if( xIconMetaFile.is() )
     600         [ #  # ]:          0 :                                         ( (SdrOle2Obj*) pObj)->SetGraphicToObj( xIconMetaFile, aIconMediaType );
     601                 :            :                                 }
     602                 :            :                                 else
     603                 :            :                                 {
     604 [ #  # ][ #  # ]:          0 :                                     Size aTmp = OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aMapUnit );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     605                 :          0 :                                     awt::Size aSz( aTmp.Width(), aTmp.Height() );
     606 [ #  # ][ #  # ]:          0 :                                     xObj->setVisualAreaSize( nAspect, aSz );
     607                 :            :                                 }
     608                 :            :                             }
     609                 :            :                         }
     610                 :            :                     }
     611                 :            :                 }
     612                 :            : 
     613         [ #  # ]:          0 :                 if (bInsertNewObject)
     614                 :            :                 {
     615                 :            :                     /**************************************************************
     616                 :            :                         * Ein neues OLE-Objekt wird erzeugt
     617                 :            :                         **************************************************************/
     618                 :          0 :                     SdrPageView* pPV = mpView->GetSdrPageView();
     619         [ #  # ]:          0 :                     Size aPageSize = pPV->GetPage()->GetSize();
     620                 :            : 
     621                 :            :                     // get the size from the iconified object
     622         [ #  # ]:          0 :                     ::svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
     623         [ #  # ]:          0 :                     if ( nAspect == embed::Aspects::MSOLE_ICON )
     624                 :            :                     {
     625         [ #  # ]:          0 :                         aObjRef.SetGraphicStream( xIconMetaFile, aIconMediaType );
     626         [ #  # ]:          0 :                         MapMode aMapMode( MAP_100TH_MM );
     627 [ #  # ][ #  # ]:          0 :                         aSize = aObjRef.GetSize( &aMapMode );
     628                 :            :                     }
     629                 :            : 
     630                 :          0 :                     Point aPnt ((aPageSize.Width()  - aSize.Width())  / 2,
     631                 :          0 :                         (aPageSize.Height() - aSize.Height()) / 2);
     632         [ #  # ]:          0 :                     Rectangle aRect (aPnt, aSize);
     633                 :            : 
     634 [ #  # ][ #  # ]:          0 :                     SdrOle2Obj* pObj = new SdrOle2Obj( aObjRef, aName, aRect);
         [ #  # ][ #  # ]
     635                 :            : 
     636 [ #  # ][ #  # ]:          0 :                     if( mpView->InsertObjectAtView(pObj, *pPV, SDRINSERT_SETDEFLAYER) )
     637                 :            :                     {
     638                 :            :                         //  Math objects change their object size during InsertObject.
     639                 :            :                         //  New size must be set in SdrObject, or a wrong scale will be set at
     640                 :            :                         //  ActivateObject.
     641                 :            : 
     642         [ #  # ]:          0 :                         if ( nAspect != embed::Aspects::MSOLE_ICON )
     643                 :            :                         {
     644                 :            :                             try
     645                 :            :                             {
     646 [ #  # ][ #  # ]:          0 :                                 awt::Size aSz = xObj->getVisualAreaSize( nAspect );
     647                 :            : 
     648                 :            :                                 Size aNewSize = Window::LogicToLogic( Size( aSz.Width, aSz.Height ),
     649 [ #  # ][ #  # ]:          0 :                                     MapMode( aMapUnit ), MapMode( MAP_100TH_MM ) );
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     650         [ #  # ]:          0 :                                 if ( aNewSize != aSize )
     651                 :            :                                 {
     652         [ #  # ]:          0 :                                     aRect.SetSize( aNewSize );
     653         [ #  # ]:          0 :                                     pObj->SetLogicRect( aRect );
     654                 :            :                                 }
     655                 :            :                             }
     656         [ #  # ]:          0 :                             catch( embed::NoVisualAreaSizeException& )
     657                 :            :                             {}
     658                 :            :                         }
     659                 :            : 
     660         [ #  # ]:          0 :                         if (bCreateNew)
     661                 :            :                         {
     662         [ #  # ]:          0 :                             pObj->SetLogicRect(aRect);
     663                 :            : 
     664         [ #  # ]:          0 :                             if ( nAspect != embed::Aspects::MSOLE_ICON )
     665                 :            :                             {
     666 [ #  # ][ #  # ]:          0 :                                 Size aTmp = OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aMapUnit );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     667                 :          0 :                                 awt::Size aSz( aTmp.Width(), aTmp.Height() );
     668 [ #  # ][ #  # ]:          0 :                                 xObj->setVisualAreaSize( nAspect, aSz );
     669                 :            :                             }
     670                 :            : 
     671         [ #  # ]:          0 :                             mpViewShell->ActivateObject(pObj, SVVERB_SHOW);
     672                 :            :                         }
     673                 :            : 
     674                 :          0 :                         Size aVisSizePixel = mpWindow->GetOutputSizePixel();
     675 [ #  # ][ #  # ]:          0 :                         Rectangle aVisAreaWin = mpWindow->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
     676         [ #  # ]:          0 :                         mpViewShell->VisAreaChanged(aVisAreaWin);
     677         [ #  # ]:          0 :                         mpDocSh->SetVisArea(aVisAreaWin);
     678 [ #  # ][ #  # ]:          0 :                     }
     679                 :            :                 }
     680                 :            :             }
     681                 :            :         }
     682         [ #  # ]:          0 :         catch (uno::Exception&)
     683                 :            :         {
     684                 :            :             // For some reason the object can not be inserted.  For example
     685                 :            :             // because it is password protected and is not properly unlocked.
     686                 :          0 :         }
     687                 :            :     }
     688                 :          0 : }
     689                 :            : 
     690                 :            : 
     691                 :            : /*************************************************************************
     692                 :            : |*
     693                 :            : |* FuInsertAVMedia::Konstruktor
     694                 :            : |*
     695                 :            : \************************************************************************/
     696                 :            : 
     697                 :          0 : FuInsertAVMedia::FuInsertAVMedia(
     698                 :            :     ViewShell* pViewSh,
     699                 :            :     ::sd::Window* pWin,
     700                 :            :     ::sd::View* pView,
     701                 :            :     SdDrawDocument* pDoc,
     702                 :            :     SfxRequest& rReq)
     703                 :          0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
     704                 :            : {
     705                 :          0 : }
     706                 :            : 
     707                 :          0 : FunctionReference FuInsertAVMedia::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
     708                 :            : {
     709 [ #  # ][ #  # ]:          0 :     FunctionReference xFunc( new FuInsertAVMedia( pViewSh, pWin, pView, pDoc, rReq ) );
     710         [ #  # ]:          0 :     xFunc->DoExecute(rReq);
     711                 :          0 :     return xFunc;
     712                 :            : }
     713                 :            : 
     714                 :          0 : void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
     715                 :            : {
     716                 :          0 :     ::rtl::OUString     aURL;
     717                 :          0 :     const SfxItemSet*   pReqArgs = rReq.GetArgs();
     718                 :          0 :     bool                bAPI = false;
     719                 :            : 
     720         [ #  # ]:          0 :     if( pReqArgs )
     721                 :            :     {
     722 [ #  # ][ #  # ]:          0 :         const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     723                 :            : 
     724         [ #  # ]:          0 :         if( pStringItem )
     725                 :            :         {
     726         [ #  # ]:          0 :             aURL = pStringItem->GetValue();
     727                 :          0 :             bAPI = !aURL.isEmpty();
     728                 :            :         }
     729                 :            :     }
     730                 :            : 
     731                 :          0 :     bool bLink(true);
     732 [ #  # ][ #  # ]:          0 :     if (bAPI ||
                 [ #  # ]
     733         [ #  # ]:          0 :         ::avmedia::MediaWindow::executeMediaURLDialog(mpWindow, aURL, & bLink))
     734                 :            :     {
     735                 :          0 :         Size aPrefSize;
     736                 :            : 
     737         [ #  # ]:          0 :         if( mpWindow )
     738         [ #  # ]:          0 :             mpWindow->EnterWait();
     739                 :            : 
     740 [ #  # ][ #  # ]:          0 :         if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) )
     741                 :            :         {
     742         [ #  # ]:          0 :             if( mpWindow )
     743         [ #  # ]:          0 :                 mpWindow->LeaveWait();
     744                 :            : 
     745         [ #  # ]:          0 :             if( !bAPI )
     746         [ #  # ]:          0 :                 ::avmedia::MediaWindow::executeFormatErrorBox( mpWindow );
     747                 :            :         }
     748                 :            :         else
     749                 :            :         {
     750                 :          0 :             Point       aPos;
     751                 :          0 :             Size        aSize;
     752                 :          0 :             sal_Int8    nAction = DND_ACTION_COPY;
     753                 :            : 
     754 [ #  # ][ #  # ]:          0 :             if( aPrefSize.Width() && aPrefSize.Height() )
                 [ #  # ]
     755                 :            :             {
     756         [ #  # ]:          0 :                 if( mpWindow )
     757 [ #  # ][ #  # ]:          0 :                     aSize = mpWindow->PixelToLogic( aPrefSize, MAP_100TH_MM );
                 [ #  # ]
     758                 :            :                 else
     759 [ #  # ][ #  # ]:          0 :                     aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_100TH_MM );
         [ #  # ][ #  # ]
     760                 :            :             }
     761                 :            :             else
     762                 :          0 :                 aSize = Size( 5000, 5000 );
     763                 :            : 
     764         [ #  # ]:          0 :             if( mpWindow )
     765                 :            :             {
     766 [ #  # ][ #  # ]:          0 :                 aPos = mpWindow->PixelToLogic( Rectangle( aPos, mpWindow->GetOutputSizePixel() ).Center() );
                 [ #  # ]
     767                 :          0 :                 aPos.X() -= aSize.Width() >> 1;
     768                 :          0 :                 aPos.Y() -= aSize.Height() >> 1;
     769                 :            :             }
     770                 :            : 
     771         [ #  # ]:          0 :             mpView->InsertMediaURL( aURL, nAction, aPos, aSize, bLink ) ;
     772                 :            : 
     773         [ #  # ]:          0 :             if( mpWindow )
     774         [ #  # ]:          0 :                 mpWindow->LeaveWait();
     775                 :            :         }
     776                 :          0 :     }
     777                 :          0 : }
     778                 :            : 
     779                 :            : } // end of namespace sd
     780                 :            : 
     781                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10