LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/view - sdview3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 714 0.1 %
Date: 2013-07-09 Functions: 2 7 28.6 %
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 <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
      22             : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      23             : #include <com/sun/star/embed/MSOLEObjectSystemCreator.hpp>
      24             : #include <com/sun/star/lang/XComponent.hpp>
      25             : #include <sot/filelist.hxx>
      26             : #include <unotools/pathoptions.hxx>
      27             : #include <editeng/editdata.hxx>
      28             : #include <svl/urlbmk.hxx>
      29             : #include <svx/xexch.hxx>
      30             : #include <svx/xflclit.hxx>
      31             : #include <svx/xlnclit.hxx>
      32             : #include <svx/svdpagv.hxx>
      33             : #include <editeng/eeitem.hxx>
      34             : #include <editeng/colritem.hxx>
      35             : #include <sfx2/docfile.hxx>
      36             : #include <svx/svditer.hxx>
      37             : #include <svx/svdogrp.hxx>
      38             : #include <svx/svdoole2.hxx>
      39             : #include <svx/svdograf.hxx>
      40             : #include <svx/svdetc.hxx>
      41             : #include <svx/svdundo.hxx>
      42             : #include <sfx2/app.hxx>
      43             : #include <svl/itempool.hxx>
      44             : #include <comphelper/classids.hxx>
      45             : #include <svx/fmmodel.hxx>
      46             : #include <sot/formats.hxx>
      47             : #include <editeng/outliner.hxx>
      48             : #include <editeng/editeng.hxx>
      49             : #include <svx/obj3d.hxx>
      50             : #include <svx/e3dundo.hxx>
      51             : #include <svx/unomodel.hxx>
      52             : #include <unotools/streamwrap.hxx>
      53             : #include <vcl/metaact.hxx>
      54             : #include <svx/svxids.hrc>
      55             : #include <toolkit/helper/vclunohelper.hxx>
      56             : #include "DrawDocShell.hxx"
      57             : #include "fupoor.hxx"
      58             : #include "Window.hxx"
      59             : #include "sdxfer.hxx"
      60             : #include "sdpage.hxx"
      61             : #include "DrawViewShell.hxx"
      62             : #include "drawdoc.hxx"
      63             : #include "sdresid.hxx"
      64             : #include "strings.hrc"
      65             : #include "imapinfo.hxx"
      66             : #include "SlideSorterViewShell.hxx"
      67             : #include "strmname.h"
      68             : #include "unomodel.hxx"
      69             : #include "ViewClipboard.hxx"
      70             : #include <sfx2/ipclient.hxx>
      71             : #include <comphelper/storagehelper.hxx>
      72             : #include <comphelper/processfactory.hxx>
      73             : #include <tools/stream.hxx>
      74             : #include <vcl/cvtgrf.hxx>
      75             : #include <svx/sdrhittesthelper.hxx>
      76             : #include <svx/xbtmpit.hxx>
      77             : 
      78             : // --------------
      79             : // - Namespaces -
      80             : // --------------
      81             : 
      82             : using namespace ::com::sun::star;
      83             : using namespace ::com::sun::star::lang;
      84             : using namespace ::com::sun::star::uno;
      85             : using namespace ::com::sun::star::io;
      86             : using namespace ::com::sun::star::datatransfer;
      87             : using namespace ::com::sun::star::datatransfer::clipboard;
      88             : 
      89             : namespace sd {
      90             : 
      91             : #define CHECK_FORMAT_TRANS( _def_Type ) ( ( nFormat == (_def_Type) || !nFormat ) && aDataHelper.HasFormat( _def_Type ) )
      92             : 
      93             : /*************************************************************************
      94             : |*
      95             : |* Paste
      96             : |*
      97             : \************************************************************************/
      98             : 
      99             : struct ImpRememberOrigAndClone
     100             : {
     101             :     SdrObject*      pOrig;
     102             :     SdrObject*      pClone;
     103             : };
     104             : 
     105           0 : SdrObject* ImpGetClone(std::vector<ImpRememberOrigAndClone*>& aConnectorContainer, SdrObject* pConnObj)
     106             : {
     107           0 :     for(sal_uInt32 a(0); a < aConnectorContainer.size(); a++)
     108             :     {
     109           0 :         if(pConnObj == aConnectorContainer[a]->pOrig)
     110           0 :             return aConnectorContainer[a]->pClone;
     111             :     }
     112           0 :     return 0L;
     113             : }
     114             : 
     115             : // restrict movement to WorkArea
     116           0 : void ImpCheckInsertPos(Point& rPos, const Size& rSize, const Rectangle& rWorkArea)
     117             : {
     118           0 :     if(!rWorkArea.IsEmpty())
     119             :     {
     120           0 :         Rectangle aMarkRect(Point(rPos.X() - (rSize.Width() / 2), rPos.Y() - (rSize.Height() / 2)), rSize);
     121             : 
     122           0 :         if(!aMarkRect.IsInside(rWorkArea))
     123             :         {
     124           0 :             if(aMarkRect.Left() < rWorkArea.Left())
     125             :             {
     126           0 :                 rPos.X() += rWorkArea.Left() - aMarkRect.Left();
     127             :             }
     128             : 
     129           0 :             if(aMarkRect.Right() > rWorkArea.Right())
     130             :             {
     131           0 :                 rPos.X() -= aMarkRect.Right() - rWorkArea.Right();
     132             :             }
     133             : 
     134           0 :             if(aMarkRect.Top() < rWorkArea.Top())
     135             :             {
     136           0 :                 rPos.Y() += rWorkArea.Top() - aMarkRect.Top();
     137             :             }
     138             : 
     139           0 :             if(aMarkRect.Bottom() > rWorkArea.Bottom())
     140             :             {
     141           0 :                 rPos.Y() -= aMarkRect.Bottom() - rWorkArea.Bottom();
     142             :             }
     143             :         }
     144             :     }
     145           0 : }
     146             : 
     147           0 : bool View::InsertMetaFile( TransferableDataHelper& rDataHelper, const Point& rPos, ImageMap* pImageMap, bool bOptimize )
     148             : {
     149           0 :     GDIMetaFile aMtf;
     150             : 
     151           0 :     if( !rDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE, aMtf ) )
     152           0 :         return false;
     153             : 
     154           0 :     bool bVector = false;
     155           0 :     Graphic aGraphic;
     156             : 
     157             :     // check if metafile only contains a pixel image, if so insert a bitmap instead
     158           0 :     if( bOptimize )
     159             :     {
     160           0 :         MetaAction* pAction = aMtf.FirstAction();
     161           0 :         while( pAction && !bVector )
     162             :         {
     163           0 :             switch( pAction->GetType() )
     164             :             {
     165             :                 case META_POINT_ACTION:
     166             :                 case META_LINE_ACTION:
     167             :                 case META_RECT_ACTION:
     168             :                 case META_ROUNDRECT_ACTION:
     169             :                 case META_ELLIPSE_ACTION:
     170             :                 case META_ARC_ACTION:
     171             :                 case META_PIE_ACTION:
     172             :                 case META_CHORD_ACTION:
     173             :                 case META_POLYLINE_ACTION:
     174             :                 case META_POLYGON_ACTION:
     175             :                 case META_POLYPOLYGON_ACTION:
     176             :                 case META_TEXT_ACTION:
     177             :                 case META_TEXTARRAY_ACTION:
     178             :                 case META_STRETCHTEXT_ACTION:
     179             :                 case META_TEXTRECT_ACTION:
     180             :                 case META_GRADIENT_ACTION:
     181             :                 case META_HATCH_ACTION:
     182             :                 case META_WALLPAPER_ACTION:
     183             :                 case META_EPS_ACTION:
     184             :                 case META_TEXTLINE_ACTION:
     185             :                 case META_FLOATTRANSPARENT_ACTION:
     186             :                 case META_GRADIENTEX_ACTION:
     187             :                 case META_BMPSCALEPART_ACTION:
     188             :                 case META_BMPEXSCALEPART_ACTION:
     189           0 :                     bVector = true;
     190           0 :                     break;
     191             :                 case META_BMP_ACTION:
     192             :                 case META_BMPSCALE_ACTION:
     193             :                 case META_BMPEX_ACTION:
     194             :                 case META_BMPEXSCALE_ACTION:
     195           0 :                     if( aGraphic.GetType() != GRAPHIC_NONE )
     196             :                     {
     197           0 :                         bVector = true;
     198             :                     }
     199           0 :                     else switch( pAction->GetType() )
     200             :                     {
     201             :                         case META_BMP_ACTION:
     202             :                             {
     203           0 :                                 MetaBmpAction* pBmpAction = dynamic_cast< MetaBmpAction* >( pAction );
     204           0 :                                 if( pBmpAction )
     205           0 :                                     aGraphic = Graphic( pBmpAction->GetBitmap() );
     206             :                             }
     207           0 :                             break;
     208             :                         case META_BMPSCALE_ACTION:
     209             :                             {
     210           0 :                                 MetaBmpScaleAction* pBmpScaleAction = dynamic_cast< MetaBmpScaleAction* >( pAction );
     211           0 :                                 if( pBmpScaleAction )
     212           0 :                                     aGraphic = Graphic( pBmpScaleAction->GetBitmap() );
     213             :                             }
     214           0 :                             break;
     215             :                         case META_BMPEX_ACTION:
     216             :                             {
     217           0 :                                 MetaBmpExAction* pBmpExAction = dynamic_cast< MetaBmpExAction* >( pAction );
     218           0 :                                 if( pBmpExAction )
     219           0 :                                     aGraphic = Graphic( pBmpExAction->GetBitmapEx() );
     220             :                             }
     221           0 :                             break;
     222             :                         case META_BMPEXSCALE_ACTION:
     223             :                             {
     224           0 :                                 MetaBmpExScaleAction* pBmpExScaleAction = dynamic_cast< MetaBmpExScaleAction* >( pAction );
     225           0 :                                 if( pBmpExScaleAction )
     226           0 :                                     aGraphic = Graphic( pBmpExScaleAction->GetBitmapEx() );
     227             :                             }
     228           0 :                             break;
     229             :                     }
     230             :             }
     231             : 
     232           0 :             pAction = aMtf.NextAction();
     233             :         }
     234             :     }
     235             : 
     236             :     // it is not a vector metafile but it also has no graphic?
     237           0 :     if( !bVector && (aGraphic.GetType() == GRAPHIC_NONE) )
     238           0 :         bVector = true;
     239             : 
     240             :     // restrict movement to WorkArea
     241           0 :     Point aInsertPos( rPos );
     242           0 :     Size aImageSize;
     243           0 :     aImageSize = bVector ? aMtf.GetPrefSize() : aGraphic.GetSizePixel();
     244           0 :     ImpCheckInsertPos(aInsertPos, aImageSize, GetWorkArea());
     245             : 
     246           0 :     if( bVector )
     247           0 :         aGraphic = Graphic( aMtf );
     248             : 
     249           0 :     aGraphic.SetPrefMapMode( aMtf.GetPrefMapMode() );
     250           0 :     aGraphic.SetPrefSize( aMtf.GetPrefSize() );
     251           0 :     InsertGraphic( aGraphic, mnAction, aInsertPos, NULL, pImageMap );
     252             : 
     253           0 :     return true;
     254             : }
     255             : 
     256           0 : sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper,
     257             :                          const Point& rPos, sal_Int8& rDnDAction, sal_Bool bDrag,
     258             :                          sal_uLong nFormat, sal_uInt16 nPage, sal_uInt16 nLayer )
     259             : {
     260           0 :     maDropPos = rPos;
     261           0 :     mnAction = rDnDAction;
     262           0 :     mbIsDropAllowed = sal_False;
     263             : 
     264           0 :     TransferableDataHelper  aDataHelper( rDataHelper );
     265           0 :     SdrObject*              pPickObj = NULL;
     266           0 :     SdPage*                 pPage = NULL;
     267           0 :     ImageMap*               pImageMap = NULL;
     268           0 :     bool bReturn = false;
     269           0 :     sal_Bool                    bLink = ( ( mnAction & DND_ACTION_LINK ) != 0 );
     270           0 :     sal_Bool                    bCopy = ( ( ( mnAction & DND_ACTION_COPY ) != 0 ) || bLink );
     271           0 :     sal_uLong                   nPasteOptions = SDRINSERT_SETDEFLAYER;
     272             : 
     273           0 :     if (mpViewSh != NULL)
     274             :     {
     275             :         OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
     276           0 :         SfxInPlaceClient* pIpClient = mpViewSh->GetViewShell()->GetIPClient();
     277           0 :         if( mpViewSh->ISA(::sd::slidesorter::SlideSorterViewShell)
     278           0 :             || (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive()))
     279           0 :         nPasteOptions |= SDRINSERT_DONTMARK;
     280             :     }
     281             : 
     282           0 :     if( bDrag )
     283             :     {
     284           0 :         SdrPageView* pPV = NULL;
     285           0 :         PickObj( rPos, getHitTolLog(), pPickObj, pPV );
     286             :     }
     287             : 
     288           0 :     if( nPage != SDRPAGE_NOTFOUND )
     289           0 :         pPage = (SdPage*) mrDoc.GetPage( nPage );
     290             : 
     291           0 :     SdTransferable* pOwnData = NULL;
     292           0 :     SdTransferable* pImplementation = SdTransferable::getImplementation( aDataHelper.GetTransferable() );
     293             : 
     294           0 :     if(pImplementation && (rDnDAction & DND_ACTION_LINK))
     295             :     {
     296             :         // suppress own data when it's intention is to use it as fill information
     297           0 :         pImplementation = 0;
     298             :     }
     299             : 
     300             :     // try to get own transfer data
     301           0 :     if( pImplementation )
     302             :     {
     303           0 :         if( SD_MOD()->pTransferClip == (SdTransferable*) pImplementation )
     304           0 :             pOwnData = SD_MOD()->pTransferClip;
     305           0 :         else if( SD_MOD()->pTransferDrag == (SdTransferable*) pImplementation )
     306           0 :             pOwnData = SD_MOD()->pTransferDrag;
     307           0 :         else if( SD_MOD()->pTransferSelection == (SdTransferable*) pImplementation )
     308           0 :             pOwnData = SD_MOD()->pTransferSelection;
     309             :     }
     310             : 
     311             :     // ImageMap?
     312           0 :     if( !pOwnData && aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVIM ) )
     313             :     {
     314           0 :         SotStorageStreamRef xStm;
     315             : 
     316           0 :         if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVIM, xStm ) )
     317             :         {
     318           0 :             pImageMap = new ImageMap;
     319             :             // mba: clipboard always must contain absolute URLs (could be from alien source)
     320           0 :             pImageMap->Read( *xStm, String() );
     321           0 :         }
     322             :     }
     323             : 
     324           0 :     bool bTable = false;
     325             :     // check special cases for pasting table formats as RTL
     326           0 :     if( !bLink && (!nFormat || (nFormat == SOT_FORMAT_RTF)) )
     327             :     {
     328             :         // if the objekt supports rtf and there is a table involved, default is to create a table
     329           0 :         if( aDataHelper.HasFormat( SOT_FORMAT_RTF ) && ! aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) )
     330             :         {
     331           0 :             SotStorageStreamRef xStm;
     332             : 
     333           0 :             if( aDataHelper.GetSotStorageStream( FORMAT_RTF, xStm ) )
     334             :             {
     335           0 :                 xStm->Seek( 0 );
     336             : 
     337           0 :                 OString aLine;
     338           0 :                 while (xStm->ReadLine(aLine))
     339             :                 {
     340           0 :                     sal_Int32 x = aLine.indexOf( "\\trowd" );
     341           0 :                     if (x != -1)
     342             :                     {
     343           0 :                         bTable = true;
     344           0 :                         nFormat = FORMAT_RTF;
     345           0 :                         break;
     346             :                     }
     347           0 :                 }
     348           0 :             }
     349             :         }
     350             :     }
     351             : 
     352             :     // Changed the whole decision tree to be dependent of bReturn as a flag that
     353             :     // the work was done; this allows to check multiple formats and not just fail
     354             :     // when a CHECK_FORMAT_TRANS(*format*) detected format does not work. This is
     355             :     // e.g. necessary for FORMAT_BITMAP
     356           0 :     if( pOwnData && !nFormat )
     357             :     {
     358           0 :         const View* pSourceView = pOwnData->GetView();
     359             : 
     360           0 :         if( pOwnData->GetDocShell() && pOwnData->IsPageTransferable() && ISA( View ) )
     361             :         {
     362           0 :             mpClipboard->HandlePageDrop (*pOwnData);
     363             :         }
     364           0 :         else if( pSourceView )
     365             :         {
     366           0 :             if( pSourceView == this )
     367             :             {
     368             :                 // same view
     369           0 :                 if( nLayer != SDRLAYER_NOTFOUND )
     370             :                 {
     371             :                     // drop on layer tab bar
     372           0 :                     SdrLayerAdmin&  rLayerAdmin = mrDoc.GetLayerAdmin();
     373           0 :                     SdrLayer*       pLayer = rLayerAdmin.GetLayerPerID( nLayer );
     374           0 :                     SdrPageView*    pPV = GetSdrPageView();
     375           0 :                     String          aLayer( pLayer->GetName() );
     376             : 
     377           0 :                     if( !pPV->IsLayerLocked( aLayer ) )
     378             :                     {
     379           0 :                         pOwnData->SetInternalMove( sal_True );
     380           0 :                         SortMarkedObjects();
     381             : 
     382           0 :                         for( sal_uLong nM = 0; nM < GetMarkedObjectCount(); nM++ )
     383             :                         {
     384           0 :                             SdrMark*    pM = GetSdrMarkByIndex( nM );
     385           0 :                             SdrObject*  pO = pM->GetMarkedSdrObj();
     386             : 
     387           0 :                             if( pO )
     388             :                             {
     389             :                                 // #i11702#
     390           0 :                                 if( IsUndoEnabled() )
     391             :                                 {
     392           0 :                                     BegUndo(String(SdResId(STR_MODIFYLAYER)));
     393           0 :                                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectLayerChange(*pO, pO->GetLayer(), (SdrLayerID)nLayer));
     394           0 :                                     EndUndo();
     395             :                                 }
     396             : 
     397           0 :                                 pO->SetLayer( (SdrLayerID) nLayer );
     398             :                             }
     399             :                         }
     400             : 
     401           0 :                         bReturn = true;
     402           0 :                     }
     403             :                 }
     404             :                 else
     405             :                 {
     406           0 :                     SdrPageView*    pPV = GetSdrPageView();
     407           0 :                     sal_Bool            bDropOnTabBar = sal_True;
     408             : 
     409           0 :                     if( !pPage && pPV->GetPage()->GetPageNum() != mnDragSrcPgNum )
     410             :                     {
     411           0 :                         pPage = (SdPage*) pPV->GetPage();
     412           0 :                         bDropOnTabBar = sal_False;
     413             :                     }
     414             : 
     415           0 :                     if( pPage )
     416             :                     {
     417             :                         // drop on other page
     418           0 :                         String aActiveLayer( GetActiveLayer() );
     419             : 
     420           0 :                         if( !pPV->IsLayerLocked( aActiveLayer ) )
     421             :                         {
     422           0 :                             if( !IsPresObjSelected() )
     423             :                             {
     424             :                                 SdrMarkList* pMarkList;
     425             : 
     426           0 :                                 if( (mnDragSrcPgNum != SDRPAGE_NOTFOUND) && (mnDragSrcPgNum != pPV->GetPage()->GetPageNum()) )
     427             :                                 {
     428           0 :                                     pMarkList = mpDragSrcMarkList;
     429             :                                 }
     430             :                                 else
     431             :                                 {
     432             :                                     // actual mark list is used
     433           0 :                                     pMarkList = new SdrMarkList( GetMarkedObjectList());
     434             :                                 }
     435             : 
     436           0 :                                 pMarkList->ForceSort();
     437             : 
     438             :                                 // stuff to remember originals and clones
     439           0 :                                 std::vector<ImpRememberOrigAndClone*> aConnectorContainer;
     440           0 :                                 sal_uInt32  a, nConnectorCount(0L);
     441           0 :                                 Point       aCurPos;
     442             : 
     443             :                                 // calculate real position of current
     444             :                                 // source objects, if necessary (#103207)
     445           0 :                                 if( pOwnData == SD_MOD()->pTransferSelection )
     446             :                                 {
     447           0 :                                     Rectangle aCurBoundRect;
     448             : 
     449           0 :                                     if( pMarkList->TakeBoundRect( pPV, aCurBoundRect ) )
     450           0 :                                         aCurPos = aCurBoundRect.TopLeft();
     451             :                                     else
     452           0 :                                         aCurPos = pOwnData->GetStartPos();
     453             :                                 }
     454             :                                 else
     455           0 :                                     aCurPos = pOwnData->GetStartPos();
     456             : 
     457           0 :                                 const Size aVector( maDropPos.X() - aCurPos.X(), maDropPos.Y() - aCurPos.Y() );
     458             : 
     459           0 :                                 for(a = 0; a < pMarkList->GetMarkCount(); a++)
     460             :                                 {
     461           0 :                                     SdrMark* pM = pMarkList->GetMark(a);
     462           0 :                                     SdrObject* pObj = pM->GetMarkedSdrObj()->Clone();
     463             : 
     464           0 :                                     if(pObj)
     465             :                                     {
     466           0 :                                         if(!bDropOnTabBar)
     467             :                                         {
     468             :                                             // do a NbcMove(...) instead of setting SnapRects here
     469           0 :                                             pObj->NbcMove(aVector);
     470             :                                         }
     471             : 
     472           0 :                                         pPage->InsertObject(pObj);
     473             : 
     474           0 :                                         if( IsUndoEnabled() )
     475             :                                         {
     476           0 :                                             BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
     477           0 :                                             AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
     478           0 :                                             EndUndo();
     479             :                                         }
     480             : 
     481           0 :                                         ImpRememberOrigAndClone* pRem = new ImpRememberOrigAndClone;
     482           0 :                                         pRem->pOrig = pM->GetMarkedSdrObj();
     483           0 :                                         pRem->pClone = pObj;
     484           0 :                                         aConnectorContainer.push_back(pRem);
     485             : 
     486           0 :                                         if(pObj->ISA(SdrEdgeObj))
     487           0 :                                             nConnectorCount++;
     488             :                                     }
     489             :                                 }
     490             : 
     491             :                                 // try to re-establish connections at clones
     492           0 :                                 if(nConnectorCount)
     493             :                                 {
     494           0 :                                     for(a = 0; a < aConnectorContainer.size(); a++)
     495             :                                     {
     496           0 :                                         ImpRememberOrigAndClone* pRem = aConnectorContainer[a];
     497             : 
     498           0 :                                         if(pRem->pClone->ISA(SdrEdgeObj))
     499             :                                         {
     500           0 :                                             SdrEdgeObj* pOrigEdge = (SdrEdgeObj*)pRem->pOrig;
     501           0 :                                             SdrEdgeObj* pCloneEdge = (SdrEdgeObj*)pRem->pClone;
     502             : 
     503             :                                             // test first connection
     504           0 :                                             SdrObjConnection& rConn0 = pOrigEdge->GetConnection(sal_False);
     505           0 :                                             SdrObject* pConnObj = rConn0.GetObject();
     506           0 :                                             if(pConnObj)
     507             :                                             {
     508           0 :                                                 SdrObject* pConnClone = ImpGetClone(aConnectorContainer, pConnObj);
     509           0 :                                                 if(pConnClone)
     510             :                                                 {
     511             :                                                     // if dest obj was cloned, too, re-establish connection
     512           0 :                                                     pCloneEdge->ConnectToNode(sal_False, pConnClone);
     513           0 :                                                     pCloneEdge->GetConnection(sal_False).SetConnectorId(rConn0.GetConnectorId());
     514             :                                                 }
     515             :                                                 else
     516             :                                                 {
     517             :                                                     // set position of connection point of original connected object
     518           0 :                                                     const SdrGluePointList* pGlueList = pConnObj->GetGluePointList();
     519           0 :                                                     if(pGlueList)
     520             :                                                     {
     521           0 :                                                         sal_uInt16 nInd = pGlueList->FindGluePoint(rConn0.GetConnectorId());
     522             : 
     523           0 :                                                         if(SDRGLUEPOINT_NOTFOUND != nInd)
     524             :                                                         {
     525           0 :                                                             const SdrGluePoint& rGluePoint = (*pGlueList)[nInd];
     526           0 :                                                             Point aPosition = rGluePoint.GetAbsolutePos(*pConnObj);
     527           0 :                                                             aPosition.X() += aVector.A();
     528           0 :                                                             aPosition.Y() += aVector.B();
     529           0 :                                                             pCloneEdge->SetTailPoint(sal_False, aPosition);
     530             :                                                         }
     531             :                                                     }
     532             :                                                 }
     533             :                                             }
     534             : 
     535             :                                             // test second connection
     536           0 :                                             SdrObjConnection& rConn1 = pOrigEdge->GetConnection(sal_True);
     537           0 :                                             pConnObj = rConn1.GetObject();
     538           0 :                                             if(pConnObj)
     539             :                                             {
     540           0 :                                                 SdrObject* pConnClone = ImpGetClone(aConnectorContainer, pConnObj);
     541           0 :                                                 if(pConnClone)
     542             :                                                 {
     543             :                                                     // if dest obj was cloned, too, re-establish connection
     544           0 :                                                     pCloneEdge->ConnectToNode(sal_True, pConnClone);
     545           0 :                                                     pCloneEdge->GetConnection(sal_True).SetConnectorId(rConn1.GetConnectorId());
     546             :                                                 }
     547             :                                                 else
     548             :                                                 {
     549             :                                                     // set position of connection point of original connected object
     550           0 :                                                     const SdrGluePointList* pGlueList = pConnObj->GetGluePointList();
     551           0 :                                                     if(pGlueList)
     552             :                                                     {
     553           0 :                                                         sal_uInt16 nInd = pGlueList->FindGluePoint(rConn1.GetConnectorId());
     554             : 
     555           0 :                                                         if(SDRGLUEPOINT_NOTFOUND != nInd)
     556             :                                                         {
     557           0 :                                                             const SdrGluePoint& rGluePoint = (*pGlueList)[nInd];
     558           0 :                                                             Point aPosition = rGluePoint.GetAbsolutePos(*pConnObj);
     559           0 :                                                             aPosition.X() += aVector.A();
     560           0 :                                                             aPosition.Y() += aVector.B();
     561           0 :                                                             pCloneEdge->SetTailPoint(sal_True, aPosition);
     562             :                                                         }
     563             :                                                     }
     564             :                                                 }
     565             :                                             }
     566             :                                         }
     567             :                                     }
     568             :                                 }
     569             : 
     570             :                                 // cleanup remember classes
     571           0 :                                 for(a = 0; a < aConnectorContainer.size(); a++)
     572           0 :                                     delete aConnectorContainer[a];
     573             : 
     574           0 :                                 if( pMarkList != mpDragSrcMarkList )
     575           0 :                                     delete pMarkList;
     576             : 
     577           0 :                                 bReturn = true;
     578             :                             }
     579             :                             else
     580             :                             {
     581           0 :                                 maDropErrorTimer.Start();
     582           0 :                                 bReturn = false;
     583             :                             }
     584           0 :                         }
     585             :                     }
     586             :                     else
     587             :                     {
     588           0 :                         pOwnData->SetInternalMove( sal_True );
     589           0 :                         MoveAllMarked( Size( maDropPos.X() - pOwnData->GetStartPos().X(),
     590           0 :                                              maDropPos.Y() - pOwnData->GetStartPos().Y() ), bCopy );
     591           0 :                         bReturn = true;
     592             :                     }
     593             :                 }
     594             :             }
     595             :             else
     596             :             {
     597             :                 // different views
     598           0 :                 if( !pSourceView->IsPresObjSelected() )
     599             :                 {
     600             :                     // model is owned by from AllocModel() created DocShell
     601           0 :                     SdDrawDocument* pSourceDoc = (SdDrawDocument*) pSourceView->GetModel();
     602           0 :                     pSourceDoc->CreatingDataObj( pOwnData );
     603           0 :                     SdDrawDocument* pModel = (SdDrawDocument*) pSourceView->GetMarkedObjModel();
     604           0 :                     bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
     605             : 
     606           0 :                     if( !pPage )
     607           0 :                         pPage = (SdPage*) GetSdrPageView()->GetPage();
     608             : 
     609           0 :                     String aLayout( pPage->GetLayoutName() );
     610           0 :                     aLayout.Erase( aLayout.SearchAscii( SD_LT_SEPARATOR ) );
     611           0 :                     pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
     612           0 :                     pSourceDoc->CreatingDataObj( NULL );
     613             :                 }
     614             :                 else
     615             :                 {
     616           0 :                     maDropErrorTimer.Start();
     617           0 :                     bReturn = false;
     618             :                 }
     619             :             }
     620             :         }
     621             :         else
     622             :         {
     623           0 :             SdDrawDocument* pWorkModel = (SdDrawDocument*) pOwnData->GetWorkDocument();
     624           0 :             SdPage*         pWorkPage = (SdPage*) pWorkModel->GetSdPage( 0, PK_STANDARD );
     625             : 
     626           0 :             pWorkPage->SetRectsDirty();
     627             : 
     628             :             // #i120393# Clipboard data uses full object geometry range
     629           0 :             const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
     630             : 
     631           0 :             maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
     632           0 :             maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
     633             : 
     634             :             // delete pages, that are not of any interest for us
     635           0 :             for( long i = ( pWorkModel->GetPageCount() - 1 ); i >= 0; i-- )
     636             :             {
     637           0 :                 SdPage* pP = static_cast< SdPage* >( pWorkModel->GetPage( (sal_uInt16) i ) );
     638             : 
     639           0 :                 if( pP->GetPageKind() != PK_STANDARD )
     640           0 :                     pWorkModel->DeletePage( (sal_uInt16) i );
     641             :             }
     642             : 
     643           0 :             bReturn = Paste( *pWorkModel, maDropPos, pPage, nPasteOptions );
     644             : 
     645           0 :             if( !pPage )
     646           0 :                 pPage = (SdPage*) GetSdrPageView()->GetPage();
     647             : 
     648           0 :             String aLayout(pPage->GetLayoutName());
     649           0 :             aLayout.Erase(aLayout.SearchAscii(SD_LT_SEPARATOR));
     650           0 :             pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
     651             :        }
     652             :     }
     653             : 
     654           0 :     if(!bReturn && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_DRAWING ))
     655             :     {
     656           0 :         SotStorageStreamRef xStm;
     657             : 
     658           0 :         if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStm ) )
     659             :         {
     660           0 :             sal_Bool bChanged = sal_False;
     661             : 
     662           0 :             DrawDocShellRef xShell = new DrawDocShell(SFX_CREATE_MODE_INTERNAL);
     663           0 :             xShell->DoInitNew(0);
     664             : 
     665           0 :             SdDrawDocument* pModel = xShell->GetDoc();
     666           0 :             pModel->InsertPage(pModel->AllocPage(false));
     667             : 
     668           0 :             Reference< XComponent > xComponent( xShell->GetModel(), UNO_QUERY );
     669           0 :             xStm->Seek( 0 );
     670             : 
     671           0 :             com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
     672           0 :             bReturn = SvxDrawingLayerImport( pModel, xInputStream, xComponent, "com.sun.star.comp.Impress.XMLOasisImporter" );
     673             : 
     674           0 :             if( pModel->GetPageCount() == 0 )
     675             :             {
     676             :                 OSL_FAIL("empty or invalid drawing xml document on clipboard!" );
     677             :             }
     678             :             else
     679             :             {
     680           0 :                 if( bReturn )
     681             :                 {
     682           0 :                     if( pModel->GetSdPage( 0, PK_STANDARD )->GetObjCount() == 1 )
     683             :                     {
     684             :                         // only one object
     685           0 :                         SdrObject*      pObj = pModel->GetSdPage( 0, PK_STANDARD )->GetObj( 0 );
     686           0 :                         SdrObject*      pPickObj2 = NULL;
     687           0 :                         SdrPageView*    pPV = NULL;
     688           0 :                         PickObj( rPos, getHitTolLog(), pPickObj2, pPV );
     689             : 
     690           0 :                         if( ( mnAction & DND_ACTION_MOVE ) && pPickObj2 && pObj )
     691             :                         {
     692             :                             // replace object
     693           0 :                             SdrObject*  pNewObj = pObj->Clone();
     694           0 :                             Rectangle   aPickObjRect( pPickObj2->GetCurrentBoundRect() );
     695           0 :                             Size        aPickObjSize( aPickObjRect.GetSize() );
     696           0 :                             Point       aVec( aPickObjRect.TopLeft() );
     697           0 :                             Rectangle   aObjRect( pNewObj->GetCurrentBoundRect() );
     698           0 :                             Size        aObjSize( aObjRect.GetSize() );
     699             : 
     700           0 :                             Fraction aScaleWidth( aPickObjSize.Width(), aObjSize.Width() );
     701           0 :                             Fraction aScaleHeight( aPickObjSize.Height(), aObjSize.Height() );
     702           0 :                             pNewObj->NbcResize( aObjRect.TopLeft(), aScaleWidth, aScaleHeight );
     703             : 
     704           0 :                             aVec -= aObjRect.TopLeft();
     705           0 :                             pNewObj->NbcMove( Size( aVec.X(), aVec.Y() ) );
     706             : 
     707           0 :                             const bool bUndo = IsUndoEnabled();
     708             : 
     709           0 :                             if( bUndo )
     710           0 :                                 BegUndo( String( SdResId(STR_UNDO_DRAGDROP ) ) );
     711           0 :                             pNewObj->NbcSetLayer( pPickObj->GetLayer() );
     712           0 :                             SdrPage* pWorkPage = GetSdrPageView()->GetPage();
     713           0 :                             pWorkPage->InsertObject( pNewObj );
     714           0 :                             if( bUndo )
     715             :                             {
     716           0 :                                 AddUndo( mrDoc.GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
     717           0 :                                 AddUndo( mrDoc.GetSdrUndoFactory().CreateUndoDeleteObject( *pPickObj2 ) );
     718             :                             }
     719           0 :                             pWorkPage->RemoveObject( pPickObj2->GetOrdNum() );
     720             : 
     721           0 :                             if( bUndo )
     722             :                             {
     723           0 :                                 EndUndo();
     724             :                             }
     725             :                             else
     726             :                             {
     727           0 :                                 SdrObject::Free(pPickObj2 );
     728             :                             }
     729           0 :                             bChanged = sal_True;
     730           0 :                             mnAction = DND_ACTION_COPY;
     731             :                         }
     732           0 :                         else if( ( mnAction & DND_ACTION_LINK ) && pPickObj && pObj && !pPickObj->ISA( SdrGrafObj ) && !pPickObj->ISA( SdrOle2Obj ) )
     733             :                         {
     734           0 :                             SfxItemSet aSet( mrDoc.GetPool() );
     735             : 
     736             :                             // set new attributes to object
     737           0 :                             const bool bUndo = IsUndoEnabled();
     738           0 :                             if( bUndo )
     739             :                             {
     740           0 :                                 BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
     741           0 :                                 AddUndo( mrDoc.GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
     742             :                             }
     743             : 
     744           0 :                             aSet.Put( pObj->GetMergedItemSet() );
     745             : 
     746             :                             /* Do not take over corner radius. There are
     747             :                                gradients (rectangles) in the gallery with corner
     748             :                                radius of 0. We should not use that on the
     749             :                                object. */
     750           0 :                             aSet.ClearItem( SDRATTR_ECKENRADIUS );
     751             : 
     752           0 :                             const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
     753             : 
     754           0 :                             if(pSdrGrafObj)
     755             :                             {
     756             :                                 // If we have a graphic as source object, use it's graphic
     757             :                                 // content as fill style
     758           0 :                                 aSet.Put(XFillStyleItem(XFILL_BITMAP));
     759           0 :                                 aSet.Put(XFillBitmapItem(&mrDoc.GetPool(), pSdrGrafObj->GetGraphic()));
     760             :                             }
     761             : 
     762           0 :                             pPickObj->SetMergedItemSetAndBroadcast( aSet );
     763             : 
     764           0 :                             if( pPickObj->ISA( E3dObject ) && pObj->ISA( E3dObject ) )
     765             :                             {
     766             :                                 // handle 3D attribute in addition
     767           0 :                                 SfxItemSet aNewSet( mrDoc.GetPool(), SID_ATTR_3D_START, SID_ATTR_3D_END, 0 );
     768           0 :                                 SfxItemSet aOldSet( mrDoc.GetPool(), SID_ATTR_3D_START, SID_ATTR_3D_END, 0 );
     769             : 
     770           0 :                                 aOldSet.Put(pPickObj->GetMergedItemSet());
     771           0 :                                 aNewSet.Put( pObj->GetMergedItemSet() );
     772             : 
     773           0 :                                 if( bUndo )
     774           0 :                                     AddUndo( new E3dAttributesUndoAction( mrDoc, (E3dObject*) pPickObj, aNewSet, aOldSet ) );
     775           0 :                                 pPickObj->SetMergedItemSetAndBroadcast( aNewSet );
     776             :                             }
     777             : 
     778           0 :                             if( bUndo )
     779           0 :                                 EndUndo();
     780           0 :                             bChanged = sal_True;
     781             :                         }
     782             :                     }
     783             :                 }
     784             : 
     785           0 :                 if( !bChanged )
     786             :                 {
     787           0 :                     SdrPage* pWorkPage = pModel->GetSdPage( 0, PK_STANDARD );
     788             : 
     789           0 :                     pWorkPage->SetRectsDirty();
     790             : 
     791           0 :                     if( pOwnData )
     792             :                     {
     793             :                         // #i120393# Clipboard data uses full object geometry range
     794           0 :                         const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
     795             : 
     796           0 :                         maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
     797           0 :                         maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
     798             :                     }
     799             : 
     800           0 :                     bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
     801             :                 }
     802             : 
     803           0 :                 xShell->DoClose();
     804           0 :             }
     805           0 :         }
     806             :     }
     807             : 
     808           0 :     if(!bReturn && CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE))
     809             :     {
     810           0 :         OUString aOUString;
     811             : 
     812           0 :         if( aDataHelper.GetString( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE, aOUString ) )
     813             :         {
     814           0 :             SdrObject* pObj = CreateFieldControl( aOUString );
     815             : 
     816           0 :             if( pObj )
     817             :             {
     818           0 :                 Rectangle   aRect( pObj->GetLogicRect() );
     819           0 :                 Size        aSize( aRect.GetSize() );
     820             : 
     821           0 :                 maDropPos.X() -= ( aSize.Width() >> 1 );
     822           0 :                 maDropPos.Y() -= ( aSize.Height() >> 1 );
     823             : 
     824           0 :                 aRect.SetPos( maDropPos );
     825           0 :                 pObj->SetLogicRect( aRect );
     826           0 :                 InsertObjectAtView( pObj, *GetSdrPageView(), SDRINSERT_SETDEFLAYER );
     827           0 :                 bReturn = true;
     828             :             }
     829           0 :         }
     830             :     }
     831             : 
     832           0 :     if(!bReturn &&
     833           0 :         !bLink &&
     834           0 :         (CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_EMBED_SOURCE) || CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_EMBEDDED_OBJ))  &&
     835           0 :         aDataHelper.HasFormat(SOT_FORMATSTR_ID_OBJECTDESCRIPTOR))
     836             :     {
     837             :         //TODO/LATER: is it possible that this format is binary?! (from old versions of SO)
     838           0 :         uno::Reference < io::XInputStream > xStm;
     839           0 :         TransferableObjectDescriptor    aObjDesc;
     840             : 
     841           0 :         if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) &&
     842           0 :             ( aDataHelper.GetInputStream( nFormat ? nFormat : SOT_FORMATSTR_ID_EMBED_SOURCE, xStm ) ||
     843           0 :               aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ, xStm ) ) )
     844             :         {
     845           0 :             if( mrDoc.GetDocSh() && ( mrDoc.GetDocSh()->GetClassName() == aObjDesc.maClassName ) )
     846             :             {
     847           0 :                 uno::Reference < embed::XStorage > xStore( ::comphelper::OStorageHelper::GetStorageFromInputStream( xStm ) );
     848           0 :                 ::sd::DrawDocShellRef xDocShRef( new ::sd::DrawDocShell( SFX_CREATE_MODE_EMBEDDED, sal_True, mrDoc.GetDocumentType() ) );
     849             : 
     850             :                 // mba: BaseURL doesn't make sense for clipboard functionality
     851           0 :                 SfxMedium *pMedium = new SfxMedium( xStore, String() );
     852           0 :                 if( xDocShRef->DoLoad( pMedium ) )
     853             :                 {
     854           0 :                     SdDrawDocument* pModel = (SdDrawDocument*) xDocShRef->GetDoc();
     855           0 :                     SdPage*         pWorkPage = (SdPage*) pModel->GetSdPage( 0, PK_STANDARD );
     856             : 
     857           0 :                     pWorkPage->SetRectsDirty();
     858             : 
     859           0 :                     if( pOwnData )
     860             :                     {
     861             :                         // #i120393# Clipboard data uses full object geometry range
     862           0 :                         const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
     863             : 
     864           0 :                         maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
     865           0 :                         maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
     866             :                     }
     867             : 
     868             :                     // delete pages, that are not of any interest for us
     869           0 :                     for( long i = ( pModel->GetPageCount() - 1 ); i >= 0; i-- )
     870             :                     {
     871           0 :                         SdPage* pP = static_cast< SdPage* >( pModel->GetPage( (sal_uInt16) i ) );
     872             : 
     873           0 :                         if( pP->GetPageKind() != PK_STANDARD )
     874           0 :                             pModel->DeletePage( (sal_uInt16) i );
     875             :                     }
     876             : 
     877           0 :                     bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
     878             : 
     879           0 :                     if( !pPage )
     880           0 :                         pPage = (SdPage*) GetSdrPageView()->GetPage();
     881             : 
     882           0 :                     String aLayout(pPage->GetLayoutName());
     883           0 :                     aLayout.Erase(aLayout.SearchAscii(SD_LT_SEPARATOR));
     884           0 :                     pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
     885             :                 }
     886             : 
     887           0 :                 xDocShRef->DoClose();
     888           0 :                 xDocShRef.Clear();
     889             : 
     890             :             }
     891             :             else
     892             :             {
     893           0 :                 OUString aName;
     894           0 :                 uno::Reference < embed::XEmbeddedObject > xObj = mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
     895           0 :                 if ( xObj.is() )
     896             :                 {
     897           0 :                     svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect );
     898             : 
     899             :                     // try to get the replacement image from the clipboard
     900           0 :                     Graphic aGraphic;
     901           0 :                     sal_uLong nGrFormat = 0;
     902             : 
     903             : 
     904             :                     // insert replacement image ( if there is one ) into the object helper
     905           0 :                     if ( nGrFormat )
     906             :                     {
     907           0 :                         datatransfer::DataFlavor aDataFlavor;
     908           0 :                         SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
     909           0 :                         aObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
     910             :                     }
     911             : 
     912           0 :                     Size aSize;
     913           0 :                     if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
     914             :                     {
     915           0 :                         if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
     916           0 :                             aSize = aObjDesc.maSize;
     917             :                         else
     918             :                         {
     919           0 :                             MapMode aMapMode( MAP_100TH_MM );
     920           0 :                             aSize = aObjRef.GetSize( &aMapMode );
     921             :                         }
     922             :                     }
     923             :                     else
     924             :                     {
     925           0 :                         awt::Size aSz;
     926           0 :                         MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
     927           0 :                         if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
     928             :                         {
     929           0 :                             Size aTmp( OutputDevice::LogicToLogic( aObjDesc.maSize, MAP_100TH_MM, aMapUnit ) );
     930           0 :                             aSz.Width = aTmp.Width();
     931           0 :                             aSz.Height = aTmp.Height();
     932           0 :                             xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
     933             :                         }
     934             : 
     935             :                         try
     936             :                         {
     937           0 :                             aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
     938             :                         }
     939           0 :                         catch( embed::NoVisualAreaSizeException& )
     940             :                         {
     941             :                             // if the size still was not set the default size will be set later
     942             :                         }
     943             : 
     944           0 :                         aSize = Size( aSz.Width, aSz.Height );
     945             : 
     946           0 :                         if( !aSize.Width() || !aSize.Height() )
     947             :                         {
     948           0 :                             aSize.Width()  = 14100;
     949           0 :                             aSize.Height() = 10000;
     950           0 :                             aSize = OutputDevice::LogicToLogic( Size(14100, 10000), MAP_100TH_MM, aMapUnit );
     951           0 :                             aSz.Width = aSize.Width();
     952           0 :                             aSz.Height = aSize.Height();
     953           0 :                             xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
     954             :                         }
     955             : 
     956           0 :                         aSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MAP_100TH_MM );
     957             :                     }
     958             : 
     959           0 :                     Size aMaxSize( mrDoc.GetMaxObjSize() );
     960             : 
     961           0 :                     maDropPos.X() -= std::min( aSize.Width(), aMaxSize.Width() ) >> 1;
     962           0 :                     maDropPos.Y() -= std::min( aSize.Height(), aMaxSize.Height() ) >> 1;
     963             : 
     964           0 :                     Rectangle       aRect( maDropPos, aSize );
     965           0 :                     SdrOle2Obj*     pObj = new SdrOle2Obj( aObjRef, aName, aRect );
     966           0 :                     SdrPageView*    pPV = GetSdrPageView();
     967           0 :                     sal_uLong           nOptions = SDRINSERT_SETDEFLAYER;
     968             : 
     969           0 :                     if (mpViewSh!=NULL)
     970             :                     {
     971             :                         OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
     972             :                         SfxInPlaceClient* pIpClient
     973           0 :                             = mpViewSh->GetViewShell()->GetIPClient();
     974           0 :                         if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
     975           0 :                             nOptions |= SDRINSERT_DONTMARK;
     976             :                     }
     977             : 
     978           0 :                     InsertObjectAtView( pObj, *pPV, nOptions );
     979             : 
     980           0 :                     if( pImageMap )
     981           0 :                         pObj->AppendUserData( new SdIMapInfo( *pImageMap ) );
     982             : 
     983           0 :                     if ( pObj && pObj->IsChart() )
     984             :                     {
     985           0 :                         bool bDisableDataTableDialog = false;
     986           0 :                         svt::EmbeddedObjectRef::TryRunningState( xObj );
     987           0 :                         uno::Reference< beans::XPropertySet > xProps( xObj->getComponent(), uno::UNO_QUERY );
     988           0 :                         if ( xProps.is() &&
     989           0 :                              ( xProps->getPropertyValue( "DisableDataTableDialog" ) >>= bDisableDataTableDialog ) &&
     990             :                              bDisableDataTableDialog )
     991             :                         {
     992           0 :                             xProps->setPropertyValue( "DisableDataTableDialog" , uno::makeAny( sal_False ) );
     993           0 :                             xProps->setPropertyValue( "DisableComplexChartTypes" , uno::makeAny( sal_False ) );
     994           0 :                             uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY );
     995           0 :                             if ( xModifiable.is() )
     996             :                             {
     997           0 :                                 xModifiable->setModified( sal_True );
     998           0 :                             }
     999           0 :                         }
    1000             :                     }
    1001             : 
    1002           0 :                     bReturn = true;
    1003           0 :                 }
    1004             :             }
    1005           0 :         }
    1006             :     }
    1007             : 
    1008           0 :     if(!bReturn &&
    1009           0 :         !bLink &&
    1010           0 :         (CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE) || CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_EMBED_SOURCE_OLE)) &&
    1011           0 :         aDataHelper.HasFormat(SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE))
    1012             :     {
    1013             :         // online insert ole if format is forced or no gdi metafile is available
    1014           0 :         if( (nFormat != 0) || !aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) )
    1015             :         {
    1016           0 :             uno::Reference < io::XInputStream > xStm;
    1017           0 :             TransferableObjectDescriptor    aObjDesc;
    1018             : 
    1019           0 :             if ( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE, aObjDesc ) )
    1020             :             {
    1021           0 :                 uno::Reference < embed::XEmbeddedObject > xObj;
    1022           0 :                 OUString aName;
    1023             : 
    1024           0 :                 if ( aDataHelper.GetInputStream( nFormat ? nFormat : SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, xStm ) ||
    1025           0 :                     aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, xStm ) )
    1026             :                 {
    1027           0 :                     xObj = mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
    1028             :                 }
    1029             :                 else
    1030             :                 {
    1031             :                     try
    1032             :                     {
    1033           0 :                         uno::Reference< embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
    1034             :                         uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator =
    1035           0 :                             embed::MSOLEObjectSystemCreator::create( ::comphelper::getProcessComponentContext() );
    1036             : 
    1037           0 :                         embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
    1038             :                                                                 xTmpStor,
    1039             :                                                                 "DummyName" ,
    1040           0 :                                                                 uno::Sequence< beans::PropertyValue >() );
    1041             : 
    1042             :                         // TODO/LATER: in future InsertedObjectInfo will be used to get container related information
    1043             :                         // for example whether the object should be an iconified one
    1044           0 :                         xObj = aInfo.Object;
    1045           0 :                         if ( xObj.is() )
    1046           0 :                             mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
    1047             :                     }
    1048           0 :                     catch( uno::Exception& )
    1049             :                     {}
    1050             :                 }
    1051             : 
    1052           0 :                 if ( xObj.is() )
    1053             :                 {
    1054           0 :                     svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect );
    1055             : 
    1056             :                     // try to get the replacement image from the clipboard
    1057           0 :                     Graphic aGraphic;
    1058           0 :                     sal_uLong nGrFormat = 0;
    1059             : 
    1060             : // (wg. Selection Manager bei Trustet Solaris)
    1061             : #ifndef SOLARIS
    1062           0 :                     if( aDataHelper.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
    1063           0 :                         nGrFormat = SOT_FORMATSTR_ID_SVXB;
    1064           0 :                     else if( aDataHelper.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
    1065           0 :                         nGrFormat = SOT_FORMAT_GDIMETAFILE;
    1066           0 :                     else if( aDataHelper.GetGraphic( FORMAT_BITMAP, aGraphic ) )
    1067           0 :                         nGrFormat = SOT_FORMAT_BITMAP;
    1068             : #endif
    1069             : 
    1070             :                     // insert replacement image ( if there is one ) into the object helper
    1071           0 :                     if ( nGrFormat )
    1072             :                     {
    1073           0 :                         datatransfer::DataFlavor aDataFlavor;
    1074           0 :                         SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
    1075           0 :                         aObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
    1076             :                     }
    1077             : 
    1078           0 :                     Size aSize;
    1079           0 :                     if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
    1080             :                     {
    1081           0 :                         if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
    1082           0 :                             aSize = aObjDesc.maSize;
    1083             :                         else
    1084             :                         {
    1085           0 :                             MapMode aMapMode( MAP_100TH_MM );
    1086           0 :                             aSize = aObjRef.GetSize( &aMapMode );
    1087             :                         }
    1088             :                     }
    1089             :                     else
    1090             :                     {
    1091           0 :                         MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
    1092             : 
    1093           0 :                         awt::Size aSz;
    1094             :                         try{
    1095           0 :                             aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
    1096             :                         }
    1097           0 :                         catch( embed::NoVisualAreaSizeException& )
    1098             :                         {
    1099             :                             // the default size will be set later
    1100             :                         }
    1101             : 
    1102           0 :                         if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
    1103             :                         {
    1104           0 :                             Size aTmp( OutputDevice::LogicToLogic( aObjDesc.maSize, MAP_100TH_MM, aMapUnit ) );
    1105           0 :                             if ( aSz.Width != aTmp.Width() || aSz.Height != aTmp.Height() )
    1106             :                             {
    1107           0 :                                 aSz.Width = aTmp.Width();
    1108           0 :                                 aSz.Height = aTmp.Height();
    1109           0 :                                 xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
    1110             :                             }
    1111             :                         }
    1112             : 
    1113           0 :                         aSize = Size( aSz.Width, aSz.Height );
    1114             : 
    1115           0 :                         if( !aSize.Width() || !aSize.Height() )
    1116             :                         {
    1117           0 :                             aSize = OutputDevice::LogicToLogic( Size(14100, 10000), MAP_100TH_MM, aMapUnit );
    1118           0 :                             aSz.Width = aSize.Width();
    1119           0 :                             aSz.Height = aSize.Height();
    1120           0 :                             xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
    1121             :                         }
    1122             : 
    1123           0 :                         aSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MAP_100TH_MM );
    1124             :                     }
    1125             : 
    1126           0 :                     Size aMaxSize( mrDoc.GetMaxObjSize() );
    1127             : 
    1128           0 :                     maDropPos.X() -= std::min( aSize.Width(), aMaxSize.Width() ) >> 1;
    1129           0 :                     maDropPos.Y() -= std::min( aSize.Height(), aMaxSize.Height() ) >> 1;
    1130             : 
    1131           0 :                     Rectangle       aRect( maDropPos, aSize );
    1132           0 :                     SdrOle2Obj*     pObj = new SdrOle2Obj( aObjRef, aName, aRect );
    1133           0 :                     SdrPageView*    pPV = GetSdrPageView();
    1134           0 :                     sal_uLong           nOptions = SDRINSERT_SETDEFLAYER;
    1135             : 
    1136           0 :                     if (mpViewSh!=NULL)
    1137             :                     {
    1138             :                         OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
    1139             :                         SfxInPlaceClient* pIpClient
    1140           0 :                             = mpViewSh->GetViewShell()->GetIPClient();
    1141           0 :                         if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
    1142           0 :                             nOptions |= SDRINSERT_DONTMARK;
    1143             :                     }
    1144             : 
    1145           0 :                     InsertObjectAtView( pObj, *pPV, nOptions );
    1146             : 
    1147           0 :                     if( pImageMap )
    1148           0 :                         pObj->AppendUserData( new SdIMapInfo( *pImageMap ) );
    1149             : 
    1150             :                     // let the object stay in loaded state after insertion
    1151           0 :                     pObj->Unload();
    1152           0 :                     bReturn = true;
    1153           0 :                 }
    1154           0 :             }
    1155             :         }
    1156             : 
    1157           0 :         if( !bReturn && aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) )
    1158             :         {
    1159             :             // if no object was inserted, insert a picture
    1160           0 :             InsertMetaFile( aDataHelper, rPos, pImageMap, true );
    1161           0 :             bReturn = true;
    1162             :         }
    1163             :     }
    1164             : 
    1165           0 :     if(!bReturn && (!bLink || pPickObj) && CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_SVXB))
    1166             :     {
    1167           0 :         SotStorageStreamRef xStm;
    1168             : 
    1169           0 :         if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm ) )
    1170             :         {
    1171           0 :             Point   aInsertPos( rPos );
    1172           0 :             Graphic aGraphic;
    1173             : 
    1174           0 :             *xStm >> aGraphic;
    1175             : 
    1176           0 :             if( pOwnData && pOwnData->GetWorkDocument() )
    1177             :             {
    1178           0 :                 const SdDrawDocument*   pWorkModel = pOwnData->GetWorkDocument();
    1179           0 :                 SdrPage*                pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
    1180             :                                                     pWorkModel->GetSdPage( 0, PK_STANDARD ) :
    1181           0 :                                                     pWorkModel->GetPage( 0 ) );
    1182             : 
    1183           0 :                 pWorkPage->SetRectsDirty();
    1184             : 
    1185             :                 // #i120393# Clipboard data uses full object geometry range
    1186           0 :                 const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
    1187             : 
    1188           0 :                 aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
    1189           0 :                 aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
    1190             :             }
    1191             : 
    1192             :             // restrict movement to WorkArea
    1193             :             Size aImageMapSize = OutputDevice::LogicToLogic(aGraphic.GetPrefSize(),
    1194           0 :                 aGraphic.GetPrefMapMode(), MapMode(MAP_100TH_MM));
    1195             : 
    1196           0 :             ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
    1197             : 
    1198           0 :             InsertGraphic( aGraphic, mnAction, aInsertPos, NULL, pImageMap );
    1199           0 :             bReturn = true;
    1200           0 :         }
    1201             :     }
    1202             : 
    1203           0 :     if(!bReturn && (!bLink || pPickObj) && CHECK_FORMAT_TRANS(FORMAT_GDIMETAFILE))
    1204             :     {
    1205           0 :         Point aInsertPos( rPos );
    1206             : 
    1207           0 :         if( pOwnData && pOwnData->GetWorkDocument() )
    1208             : 
    1209             :         {
    1210           0 :             const SdDrawDocument*   pWorkModel = pOwnData->GetWorkDocument();
    1211           0 :             SdrPage*                pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
    1212             :                                                 pWorkModel->GetSdPage( 0, PK_STANDARD ) :
    1213           0 :                                                 pWorkModel->GetPage( 0 ) );
    1214             : 
    1215           0 :             pWorkPage->SetRectsDirty();
    1216             : 
    1217             :             // #i120393# Clipboard data uses full object geometry range
    1218           0 :             const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
    1219             : 
    1220           0 :             aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
    1221           0 :             aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
    1222             :         }
    1223             : 
    1224           0 :         bReturn = InsertMetaFile( aDataHelper, aInsertPos, pImageMap, nFormat == 0 ? true : false ) ? sal_True : sal_False;
    1225             :     }
    1226             : 
    1227           0 :     if(!bReturn && (!bLink || pPickObj) && CHECK_FORMAT_TRANS(FORMAT_BITMAP))
    1228             :     {
    1229           0 :         BitmapEx aBmpEx;
    1230             : 
    1231             :         // get basic Bitmap data
    1232           0 :         aDataHelper.GetBitmapEx(FORMAT_BITMAP, aBmpEx);
    1233             : 
    1234           0 :         if(aBmpEx.IsEmpty())
    1235             :         {
    1236             :             // if this did not work, try to get graphic formats and convert these to bitmap
    1237           0 :             Graphic aGraphic;
    1238             : 
    1239           0 :             if(aDataHelper.GetGraphic(FORMAT_GDIMETAFILE, aGraphic))
    1240             :             {
    1241           0 :                 aBmpEx = aGraphic.GetBitmapEx();
    1242             :             }
    1243           0 :             else if(aDataHelper.GetGraphic(SOT_FORMATSTR_ID_SVXB, aGraphic))
    1244             :             {
    1245           0 :                 aBmpEx = aGraphic.GetBitmapEx();
    1246             :             }
    1247           0 :             else if(aDataHelper.GetGraphic(FORMAT_BITMAP, aGraphic))
    1248             :             {
    1249           0 :                 aBmpEx = aGraphic.GetBitmapEx();
    1250           0 :             }
    1251             :         }
    1252             : 
    1253           0 :         if(!aBmpEx.IsEmpty())
    1254             :         {
    1255           0 :             Point aInsertPos( rPos );
    1256             : 
    1257           0 :             if( pOwnData && pOwnData->GetWorkDocument() )
    1258             :             {
    1259           0 :                 const SdDrawDocument*   pWorkModel = pOwnData->GetWorkDocument();
    1260           0 :                 SdrPage*                pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
    1261             :                                                     pWorkModel->GetSdPage( 0, PK_STANDARD ) :
    1262           0 :                                                     pWorkModel->GetPage( 0 ) );
    1263             : 
    1264           0 :                 pWorkPage->SetRectsDirty();
    1265             : 
    1266             :                 // #i120393# Clipboard data uses full object geometry range
    1267           0 :                 const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() );
    1268             : 
    1269           0 :                 aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
    1270           0 :                 aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
    1271             :             }
    1272             : 
    1273             :             // restrict movement to WorkArea
    1274           0 :             Size aImageMapSize(aBmpEx.GetPrefSize());
    1275           0 :             ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
    1276             : 
    1277           0 :             InsertGraphic( aBmpEx, mnAction, aInsertPos, NULL, pImageMap );
    1278           0 :             bReturn = true;
    1279           0 :         }
    1280             :     }
    1281             : 
    1282           0 :     if(!bReturn && pPickObj && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_XFA ) )
    1283             :     {
    1284           0 :         SotStorageStreamRef xStm;
    1285             : 
    1286           0 :         if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_XFA, xStm ) )
    1287             :         {
    1288           0 :             XFillExchangeData aFillData( XFillAttrSetItem( &mrDoc.GetPool() ) );
    1289             : 
    1290           0 :             *xStm >> aFillData;
    1291             : 
    1292           0 :             if( IsUndoEnabled() )
    1293             :             {
    1294           0 :                 BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
    1295           0 :                 AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
    1296           0 :                 EndUndo();
    1297             :             }
    1298             : 
    1299           0 :             XFillAttrSetItem*   pSetItem = aFillData.GetXFillAttrSetItem();
    1300           0 :             SfxItemSet          rSet = pSetItem->GetItemSet();
    1301           0 :             XFillStyle          eFill= ( (XFillStyleItem&) rSet.Get( XATTR_FILLSTYLE ) ).GetValue();
    1302             : 
    1303           0 :             if( eFill == XFILL_SOLID || eFill == XFILL_NONE )
    1304             :             {
    1305           0 :                 const XFillColorItem&   rColItem = (XFillColorItem&) rSet.Get( XATTR_FILLCOLOR );
    1306           0 :                 Color                   aColor( rColItem.GetColorValue() );
    1307           0 :                 String                  aName( rColItem.GetName() );
    1308           0 :                 SfxItemSet              aSet( mrDoc.GetPool() );
    1309           0 :                 sal_Bool                    bClosed = pPickObj->IsClosedObj();
    1310           0 :                 ::sd::Window* pWin = mpViewSh->GetActiveWindow();
    1311             :                 sal_uInt16 nHitLog = (sal_uInt16) pWin->PixelToLogic(
    1312           0 :                     Size(FuPoor::HITPIX, 0 ) ).Width();
    1313           0 :                 const long              n2HitLog = nHitLog << 1;
    1314           0 :                 Point                   aHitPosR( rPos );
    1315           0 :                 Point                   aHitPosL( rPos );
    1316           0 :                 Point                   aHitPosT( rPos );
    1317           0 :                 Point                   aHitPosB( rPos );
    1318           0 :                 const SetOfByte*        pVisiLayer = &GetSdrPageView()->GetVisibleLayers();
    1319             : 
    1320           0 :                 aHitPosR.X() += n2HitLog;
    1321           0 :                 aHitPosL.X() -= n2HitLog;
    1322           0 :                 aHitPosT.Y() += n2HitLog;
    1323           0 :                 aHitPosB.Y() -= n2HitLog;
    1324             : 
    1325           0 :                 if( bClosed &&
    1326           0 :                     SdrObjectPrimitiveHit(*pPickObj, aHitPosR, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
    1327           0 :                     SdrObjectPrimitiveHit(*pPickObj, aHitPosL, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
    1328           0 :                     SdrObjectPrimitiveHit(*pPickObj, aHitPosT, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
    1329           0 :                     SdrObjectPrimitiveHit(*pPickObj, aHitPosB, nHitLog, *GetSdrPageView(), pVisiLayer, false) )
    1330             :                 {
    1331             :                     // area fill
    1332           0 :                     if(eFill == XFILL_SOLID )
    1333           0 :                         aSet.Put(XFillColorItem(aName, aColor));
    1334             : 
    1335           0 :                     aSet.Put( XFillStyleItem( eFill ) );
    1336             :                 }
    1337             :                 else
    1338           0 :                     aSet.Put( XLineColorItem( aName, aColor ) );
    1339             : 
    1340             :                 // add text color
    1341           0 :                 pPickObj->SetMergedItemSetAndBroadcast( aSet );
    1342           0 :             }
    1343           0 :         }
    1344             :     }
    1345             : 
    1346           0 :     if(!bReturn && !bLink && CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_HTML))
    1347             :     {
    1348           0 :         SotStorageStreamRef xStm;
    1349             : 
    1350           0 :         if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_HTML, xStm ) )
    1351             :         {
    1352           0 :             xStm->Seek( 0 );
    1353             :             // mba: clipboard always must contain absolute URLs (could be from alien source)
    1354           0 :             bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_HTML, maDropPos, pPage, nPasteOptions );
    1355           0 :         }
    1356             :     }
    1357             : 
    1358           0 :     if(!bReturn && !bLink && CHECK_FORMAT_TRANS(SOT_FORMATSTR_ID_EDITENGINE))
    1359             :     {
    1360           0 :         SotStorageStreamRef xStm;
    1361             : 
    1362           0 :         if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_EDITENGINE, xStm ) )
    1363             :         {
    1364           0 :             OutlinerView* pOLV = GetTextEditOutlinerView();
    1365             : 
    1366           0 :             xStm->Seek( 0 );
    1367             : 
    1368           0 :             if( pOLV )
    1369             :             {
    1370           0 :                 Rectangle   aRect( pOLV->GetOutputArea() );
    1371           0 :                    Point       aPos( pOLV->GetWindow()->PixelToLogic( maDropPos ) );
    1372             : 
    1373           0 :                 if( aRect.IsInside( aPos ) || ( !bDrag && IsTextEdit() ) )
    1374             :                 {
    1375             :                     // mba: clipboard always must contain absolute URLs (could be from alien source)
    1376           0 :                     pOLV->Read( *xStm, String(), EE_FORMAT_BIN, sal_False, mpDocSh->GetHeaderAttributes() );
    1377           0 :                     bReturn = true;
    1378             :                 }
    1379             :             }
    1380             : 
    1381           0 :             if( !bReturn )
    1382             :                 // mba: clipboard always must contain absolute URLs (could be from alien source)
    1383           0 :                 bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_BIN, maDropPos, pPage, nPasteOptions );
    1384           0 :         }
    1385             :     }
    1386             : 
    1387           0 :     if(!bReturn && !bLink && CHECK_FORMAT_TRANS(FORMAT_RTF))
    1388             :     {
    1389           0 :         SotStorageStreamRef xStm;
    1390             : 
    1391           0 :         if( aDataHelper.GetSotStorageStream( FORMAT_RTF, xStm ) )
    1392             :         {
    1393           0 :             xStm->Seek( 0 );
    1394             : 
    1395           0 :             if( bTable )
    1396             :             {
    1397           0 :                 bReturn = PasteRTFTable( xStm, pPage, nPasteOptions );
    1398             :             }
    1399             :             else
    1400             :             {
    1401           0 :                 OutlinerView* pOLV = GetTextEditOutlinerView();
    1402             : 
    1403           0 :                 if( pOLV )
    1404             :                 {
    1405           0 :                     Rectangle   aRect( pOLV->GetOutputArea() );
    1406           0 :                        Point       aPos( pOLV->GetWindow()->PixelToLogic( maDropPos ) );
    1407             : 
    1408           0 :                     if( aRect.IsInside( aPos ) || ( !bDrag && IsTextEdit() ) )
    1409             :                     {
    1410             :                         // mba: clipboard always must contain absolute URLs (could be from alien source)
    1411           0 :                         pOLV->Read( *xStm, String(), EE_FORMAT_RTF, sal_False, mpDocSh->GetHeaderAttributes() );
    1412           0 :                         bReturn = true;
    1413             :                     }
    1414             :                 }
    1415             : 
    1416           0 :                 if( !bReturn )
    1417             :                     // mba: clipboard always must contain absolute URLs (could be from alien source)
    1418           0 :                     bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_RTF, maDropPos, pPage, nPasteOptions );
    1419             :             }
    1420           0 :         }
    1421             :     }
    1422             : 
    1423           0 :     if(!bReturn && CHECK_FORMAT_TRANS(FORMAT_FILE_LIST))
    1424             :     {
    1425           0 :         FileList aDropFileList;
    1426             : 
    1427           0 :         if( aDataHelper.GetFileList( FORMAT_FILE_LIST, aDropFileList ) )
    1428             :         {
    1429           0 :             maDropFileVector.clear();
    1430             : 
    1431           0 :             for( sal_uLong i = 0, nCount = aDropFileList.Count(); i < nCount; i++ )
    1432           0 :                 maDropFileVector.push_back( aDropFileList.GetFile( i ) );
    1433             : 
    1434           0 :             maDropInsertFileTimer.Start();
    1435             :         }
    1436             : 
    1437           0 :         bReturn = true;
    1438             :     }
    1439             : 
    1440           0 :     if(!bReturn && CHECK_FORMAT_TRANS(FORMAT_FILE))
    1441             :     {
    1442           0 :         String aDropFile;
    1443             : 
    1444           0 :         if( aDataHelper.GetString( FORMAT_FILE, aDropFile ) )
    1445             :         {
    1446           0 :             maDropFileVector.clear();
    1447           0 :             maDropFileVector.push_back( aDropFile );
    1448           0 :             maDropInsertFileTimer.Start();
    1449             :         }
    1450             : 
    1451           0 :         bReturn = true;
    1452             :     }
    1453             : 
    1454           0 :     if(!bReturn && !bLink && CHECK_FORMAT_TRANS(FORMAT_STRING))
    1455             :     {
    1456           0 :         if( ( FORMAT_STRING == nFormat ) ||
    1457           0 :             ( !aDataHelper.HasFormat( SOT_FORMATSTR_ID_SOLK ) &&
    1458           0 :               !aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
    1459           0 :               !aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILENAME ) ) )
    1460             :         {
    1461           0 :             OUString aOUString;
    1462             : 
    1463           0 :             if( aDataHelper.GetString( FORMAT_STRING, aOUString ) )
    1464             :             {
    1465           0 :                 OutlinerView* pOLV = GetTextEditOutlinerView();
    1466             : 
    1467           0 :                 if( pOLV )
    1468             :                 {
    1469           0 :                     pOLV->InsertText( aOUString );
    1470           0 :                     bReturn = true;
    1471             :                 }
    1472             : 
    1473           0 :                 if( !bReturn )
    1474           0 :                     bReturn = SdrView::Paste( aOUString, maDropPos, pPage, nPasteOptions );
    1475           0 :             }
    1476             :         }
    1477             :     }
    1478             : 
    1479           0 :     MarkListHasChanged();
    1480           0 :     mbIsDropAllowed = sal_True;
    1481           0 :     rDnDAction = mnAction;
    1482           0 :     delete pImageMap;
    1483             : 
    1484           0 :     return bReturn;
    1485             : }
    1486             : 
    1487             : extern void CreateTableFromRTF( SvStream& rStream, SdDrawDocument* pModel  );
    1488             : 
    1489           0 : bool View::PasteRTFTable( SotStorageStreamRef xStm, SdrPage* pPage, sal_uLong nPasteOptions )
    1490             : {
    1491           0 :     SdDrawDocument* pModel = new SdDrawDocument( DOCUMENT_TYPE_IMPRESS, mpDocSh );
    1492           0 :     pModel->NewOrLoadCompleted(NEW_DOC);
    1493           0 :     pModel->GetItemPool().SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
    1494           0 :     pModel->InsertPage(pModel->AllocPage(false));
    1495             : 
    1496           0 :     Reference< XComponent > xComponent( new SdXImpressDocument( pModel, sal_True ) );
    1497           0 :     pModel->setUnoModel( Reference< XInterface >::query( xComponent ) );
    1498             : 
    1499           0 :     CreateTableFromRTF( *xStm, pModel );
    1500           0 :     bool bRet = Paste( *pModel, maDropPos, pPage, nPasteOptions );
    1501             : 
    1502           0 :     xComponent->dispose();
    1503           0 :     xComponent.clear();
    1504             : 
    1505           0 :     delete pModel;
    1506             : 
    1507           0 :     return bRet;
    1508             : }
    1509             : 
    1510          33 : } // end of namespace sd
    1511             : 
    1512             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10