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

Generated by: LCOV version 1.11