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