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