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_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // INCLUDE --------------------------------------------------------------- 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <com/sun/star/embed/XTransactedObject.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/embed/XEmbedPersist.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp> 41*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 42*cdf0e10cSrcweir #include <unotools/streamwrap.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <svx/unomodel.hxx> 45*cdf0e10cSrcweir #include <unotools/tempfile.hxx> 46*cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 47*cdf0e10cSrcweir #include <comphelper/storagehelper.hxx> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include <svtools/embedtransfer.hxx> 50*cdf0e10cSrcweir #include <sot/storage.hxx> 51*cdf0e10cSrcweir #include <vcl/virdev.hxx> 52*cdf0e10cSrcweir #include <svx/fmglob.hxx> 53*cdf0e10cSrcweir #include <svx/svditer.hxx> 54*cdf0e10cSrcweir #include <svx/svdograf.hxx> 55*cdf0e10cSrcweir #include <svx/svdoole2.hxx> 56*cdf0e10cSrcweir #include <svx/svdouno.hxx> 57*cdf0e10cSrcweir #include <svx/svdpage.hxx> 58*cdf0e10cSrcweir #include <svx/svdxcgv.hxx> 59*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 60*cdf0e10cSrcweir #include <svl/itempool.hxx> 61*cdf0e10cSrcweir #include <svl/urlbmk.hxx> 62*cdf0e10cSrcweir #include <tools/urlobj.hxx> 63*cdf0e10cSrcweir #include <vos/mutex.hxx> 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir #include "drwtrans.hxx" 66*cdf0e10cSrcweir #include "docsh.hxx" 67*cdf0e10cSrcweir #include "drwlayer.hxx" 68*cdf0e10cSrcweir #include "drawview.hxx" 69*cdf0e10cSrcweir #include "viewdata.hxx" 70*cdf0e10cSrcweir #include "scmod.hxx" 71*cdf0e10cSrcweir #include "chartlis.hxx" 72*cdf0e10cSrcweir #include "rangeutl.hxx" 73*cdf0e10cSrcweir #include "formula/grammar.hxx" 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir // #108584# 76*cdf0e10cSrcweir #include "scitems.hxx" 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir // #108584# 79*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir // #108584# 82*cdf0e10cSrcweir #include <editeng/fhgtitem.hxx> 83*cdf0e10cSrcweir #include <vcl/svapp.hxx> 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir using namespace com::sun::star; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // ----------------------------------------------------------------------- 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir #define SCDRAWTRANS_TYPE_EMBOBJ 1 91*cdf0e10cSrcweir #define SCDRAWTRANS_TYPE_DRAWMODEL 2 92*cdf0e10cSrcweir #define SCDRAWTRANS_TYPE_DOCUMENT 3 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir // ----------------------------------------------------------------------- 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir // ----------------------------------------------------------------------- 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir ScDrawTransferObj::ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContainerShell, 99*cdf0e10cSrcweir const TransferableObjectDescriptor& rDesc ) : 100*cdf0e10cSrcweir pModel( pClipModel ), 101*cdf0e10cSrcweir aObjDesc( rDesc ), 102*cdf0e10cSrcweir pBookmark( NULL ), 103*cdf0e10cSrcweir bGraphic( sal_False ), 104*cdf0e10cSrcweir bGrIsBit( sal_False ), 105*cdf0e10cSrcweir bOleObj( sal_False ), 106*cdf0e10cSrcweir pDragSourceView( NULL ), 107*cdf0e10cSrcweir nDragSourceFlags( 0 ), 108*cdf0e10cSrcweir bDragWasInternal( sal_False ), 109*cdf0e10cSrcweir nSourceDocID( 0 ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir // 112*cdf0e10cSrcweir // check what kind of objects are contained 113*cdf0e10cSrcweir // 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(0); 116*cdf0e10cSrcweir if (pPage) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_FLAT ); 119*cdf0e10cSrcweir SdrObject* pObject = aIter.Next(); 120*cdf0e10cSrcweir if (pObject && !aIter.Next()) // exactly one object? 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir // 123*cdf0e10cSrcweir // OLE object 124*cdf0e10cSrcweir // 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir sal_uInt16 nSdrObjKind = pObject->GetObjIdentifier(); 127*cdf0e10cSrcweir if (nSdrObjKind == OBJ_OLE2) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir // if object has no persistence it must be copied as a part of document 130*cdf0e10cSrcweir try 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir uno::Reference< embed::XEmbedPersist > xPersObj( ((SdrOle2Obj*)pObject)->GetObjRef(), uno::UNO_QUERY ); 133*cdf0e10cSrcweir if ( xPersObj.is() && xPersObj->hasEntry() ) 134*cdf0e10cSrcweir bOleObj = sal_True; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir catch( uno::Exception& ) 137*cdf0e10cSrcweir {} 138*cdf0e10cSrcweir // aOleData is initialized later 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir // 142*cdf0e10cSrcweir // Graphic object 143*cdf0e10cSrcweir // 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir if (nSdrObjKind == OBJ_GRAF) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir bGraphic = sal_True; 148*cdf0e10cSrcweir if ( ((SdrGrafObj*)pObject)->GetGraphic().GetType() == GRAPHIC_BITMAP ) 149*cdf0e10cSrcweir bGrIsBit = sal_True; 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir // 153*cdf0e10cSrcweir // URL button 154*cdf0e10cSrcweir // 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObject); 157*cdf0e10cSrcweir if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor()) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel(); 160*cdf0e10cSrcweir DBG_ASSERT( xControlModel.is(), "uno control without model" ); 161*cdf0e10cSrcweir if ( xControlModel.is() ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY ); 164*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo(); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir rtl::OUString sPropButtonType = rtl::OUString::createFromAscii( "ButtonType" ); 167*cdf0e10cSrcweir rtl::OUString sPropTargetURL = rtl::OUString::createFromAscii( "TargetURL" ); 168*cdf0e10cSrcweir rtl::OUString sPropLabel = rtl::OUString::createFromAscii( "Label" ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir if(xInfo->hasPropertyByName( sPropButtonType )) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType ); 173*cdf0e10cSrcweir form::FormButtonType eTmp; 174*cdf0e10cSrcweir if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir // URL 177*cdf0e10cSrcweir if(xInfo->hasPropertyByName( sPropTargetURL )) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir aAny = xPropSet->getPropertyValue( sPropTargetURL ); 180*cdf0e10cSrcweir rtl::OUString sTmp; 181*cdf0e10cSrcweir if ( (aAny >>= sTmp) && sTmp.getLength() ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir String aUrl = sTmp; 184*cdf0e10cSrcweir String aAbs; 185*cdf0e10cSrcweir const SfxMedium* pMedium; 186*cdf0e10cSrcweir if (pContainerShell && (pMedium = pContainerShell->GetMedium()) != NULL) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir bool bWasAbs = true; 189*cdf0e10cSrcweir aAbs = pMedium->GetURLObject().smartRel2Abs( aUrl, bWasAbs ). 190*cdf0e10cSrcweir GetMainURL(INetURLObject::NO_DECODE); 191*cdf0e10cSrcweir // full path as stored INetBookmark must be encoded 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir else 194*cdf0e10cSrcweir aAbs = aUrl; 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir // Label 197*cdf0e10cSrcweir String aLabel; 198*cdf0e10cSrcweir if(xInfo->hasPropertyByName( sPropLabel )) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir aAny = xPropSet->getPropertyValue( sPropLabel ); 201*cdf0e10cSrcweir if ( (aAny >>= sTmp) && sTmp.getLength() ) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir aLabel = String(sTmp); 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir pBookmark = new INetBookmark( aAbs, aLabel ); 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir // 217*cdf0e10cSrcweir // get size for object descriptor 218*cdf0e10cSrcweir // 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir // #i71538# use complete SdrViews 221*cdf0e10cSrcweir // SdrExchangeView aView(pModel); 222*cdf0e10cSrcweir SdrView aView(pModel); 223*cdf0e10cSrcweir SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel()->GetPage(0)); 224*cdf0e10cSrcweir aView.MarkAllObj(pPv); 225*cdf0e10cSrcweir aSrcSize = aView.GetAllMarkedRect().GetSize(); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir if ( bOleObj ) // single OLE object 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir SdrOle2Obj* pObj = GetSingleObject(); 230*cdf0e10cSrcweir if ( pObj && pObj->GetObjRef().is() ) 231*cdf0e10cSrcweir SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() ); 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir aObjDesc.maSize = aSrcSize; 235*cdf0e10cSrcweir PrepareOLE( aObjDesc ); 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir // 238*cdf0e10cSrcweir // remember a unique ID of the source document 239*cdf0e10cSrcweir // 240*cdf0e10cSrcweir if ( pContainerShell ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir ScDocument* pDoc = pContainerShell->GetDocument(); 243*cdf0e10cSrcweir if ( pDoc ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir nSourceDocID = pDoc->GetDocumentID(); 246*cdf0e10cSrcweir if ( pPage ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir ScChartHelper::FillProtectedChartRangesVector( m_aProtectedChartRangesVector, pDoc, pPage ); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir ScDrawTransferObj::~ScDrawTransferObj() 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir Application::GetSolarMutex().acquire(); //! ??? 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 259*cdf0e10cSrcweir if ( pScMod->GetClipData().pDrawClipboard == this ) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir DBG_ERROR("ScDrawTransferObj wasn't released"); 262*cdf0e10cSrcweir pScMod->SetClipObject( NULL, NULL ); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir if ( pScMod->GetDragData().pDrawTransfer == this ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir DBG_ERROR("ScDrawTransferObj wasn't released"); 267*cdf0e10cSrcweir pScMod->ResetDragObject(); 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir aOleData = TransferableDataHelper(); // clear before releasing the mutex 271*cdf0e10cSrcweir aDocShellRef.Clear(); 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir delete pModel; 274*cdf0e10cSrcweir aDrawPersistRef.Clear(); // after the model 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir delete pBookmark; 277*cdf0e10cSrcweir delete pDragSourceView; 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir Application::GetSolarMutex().release(); //! ??? 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir // static 283*cdf0e10cSrcweir ScDrawTransferObj* ScDrawTransferObj::GetOwnClipboard( Window* ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir ScDrawTransferObj* pObj = SC_MOD()->GetClipData().pDrawClipboard; 286*cdf0e10cSrcweir return pObj; 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir sal_Bool lcl_HasOnlyControls( SdrModel* pModel ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir sal_Bool bOnlyControls = sal_False; // default if there are no objects 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir if ( pModel ) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(0); 296*cdf0e10cSrcweir if (pPage) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS ); 299*cdf0e10cSrcweir SdrObject* pObj = aIter.Next(); 300*cdf0e10cSrcweir if ( pObj ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir bOnlyControls = sal_True; // only set if there are any objects at all 303*cdf0e10cSrcweir while ( pObj ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir if (!pObj->ISA(SdrUnoObj)) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir bOnlyControls = sal_False; 308*cdf0e10cSrcweir break; 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir pObj = aIter.Next(); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir return bOnlyControls; 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir void ScDrawTransferObj::AddSupportedFormats() 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir if ( bGrIsBit ) // single bitmap graphic 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 324*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_SVXB ); 325*cdf0e10cSrcweir AddFormat( SOT_FORMAT_BITMAP ); 326*cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE ); 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir else if ( bGraphic ) // other graphic 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir // #i25616# 331*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_DRAWING ); 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 334*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_SVXB ); 335*cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE ); 336*cdf0e10cSrcweir AddFormat( SOT_FORMAT_BITMAP ); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir else if ( pBookmark ) // url button 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir // AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ); 341*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 342*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_SOLK ); 343*cdf0e10cSrcweir AddFormat( SOT_FORMAT_STRING ); 344*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ); 345*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ); 346*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_DRAWING ); 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir else if ( bOleObj ) // single OLE object 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ); 351*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 352*cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE ); 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir if ( !aOleData.GetTransferable().is() ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir SdrOle2Obj* pObj = GetSingleObject(); 357*cdf0e10cSrcweir if ( pObj && pObj->GetObjRef().is() ) 358*cdf0e10cSrcweir aOleData = TransferableDataHelper( new SvEmbedTransferHelper( pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() ) ) ; 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir if ( aOleData.GetTransferable().is() ) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir // get format list from object snapshot 363*cdf0e10cSrcweir // (this must be after inserting the default formats!) 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir DataFlavorExVector aVector( aOleData.GetDataFlavorExVector() ); 366*cdf0e10cSrcweir DataFlavorExVector::iterator aIter( aVector.begin() ), aEnd( aVector.end() ); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir while( aIter != aEnd ) 369*cdf0e10cSrcweir AddFormat( *aIter++ ); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir else // any drawing objects 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ); 375*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 376*cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_DRAWING ); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir // #103556# leave out bitmap and metafile if there are only controls 379*cdf0e10cSrcweir if ( !lcl_HasOnlyControls( pModel ) ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir AddFormat( SOT_FORMAT_BITMAP ); 382*cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE ); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir // if( pImageMap ) 387*cdf0e10cSrcweir // AddFormat( SOT_FORMATSTR_ID_SVIM ); 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir sal_Bool ScDrawTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir sal_Bool bOK = sal_False; 393*cdf0e10cSrcweir sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor ); 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir if ( bOleObj && nFormat != SOT_FORMAT_GDIMETAFILE ) 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir if ( !aOleData.GetTransferable().is() ) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir SdrOle2Obj* pObj = GetSingleObject(); 400*cdf0e10cSrcweir if ( pObj && pObj->GetObjRef().is() ) 401*cdf0e10cSrcweir aOleData = TransferableDataHelper( new SvEmbedTransferHelper( pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() ) ) ; 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir if( aOleData.GetTransferable().is() && aOleData.HasFormat( rFlavor ) ) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir sal_uLong nOldSwapMode = 0; 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir if( pModel ) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir nOldSwapMode = pModel->GetSwapGraphicsMode(); 411*cdf0e10cSrcweir pModel->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE ); 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir bOK = SetAny( aOleData.GetAny( rFlavor ), rFlavor ); 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir if( pModel ) 417*cdf0e10cSrcweir pModel->SetSwapGraphicsMode( nOldSwapMode ); 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir return bOK; 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir if( HasFormat( nFormat ) ) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir if ( nFormat == SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR || nFormat == SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir bOK = SetTransferableObjectDescriptor( aObjDesc, rFlavor ); 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir else if ( nFormat == SOT_FORMATSTR_ID_DRAWING ) 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir bOK = SetObject( pModel, SCDRAWTRANS_TYPE_DRAWMODEL, rFlavor ); 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir else if ( nFormat == SOT_FORMAT_BITMAP || nFormat == SOT_FORMAT_GDIMETAFILE ) 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir // #i71538# use complete SdrViews 436*cdf0e10cSrcweir // SdrExchangeView aView( pModel ); 437*cdf0e10cSrcweir SdrView aView( pModel ); 438*cdf0e10cSrcweir SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel()->GetPage(0)); 439*cdf0e10cSrcweir DBG_ASSERT( pPv, "pPv not there..." ); 440*cdf0e10cSrcweir aView.MarkAllObj( pPv ); 441*cdf0e10cSrcweir if ( nFormat == SOT_FORMAT_GDIMETAFILE ) 442*cdf0e10cSrcweir bOK = SetGDIMetaFile( aView.GetAllMarkedMetaFile( sal_True ), rFlavor ); 443*cdf0e10cSrcweir else 444*cdf0e10cSrcweir bOK = SetBitmap( aView.GetAllMarkedBitmap( sal_True ), rFlavor ); 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir else if ( nFormat == SOT_FORMATSTR_ID_SVXB ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir // only enabled for single graphics object 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(0); 451*cdf0e10cSrcweir if (pPage) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_FLAT ); 454*cdf0e10cSrcweir SdrObject* pObject = aIter.Next(); 455*cdf0e10cSrcweir if (pObject && pObject->GetObjIdentifier() == OBJ_GRAF) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir SdrGrafObj* pGraphObj = (SdrGrafObj*) pObject; 458*cdf0e10cSrcweir bOK = SetGraphic( pGraphObj->GetGraphic(), rFlavor ); 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir else if ( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE ) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir if ( bOleObj ) // single OLE object 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir SdrOle2Obj* pObj = GetSingleObject(); 467*cdf0e10cSrcweir if ( pObj && pObj->GetObjRef().is() ) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir bOK = SetObject( pObj->GetObjRef().get(), SCDRAWTRANS_TYPE_EMBOBJ, rFlavor ); 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir else // create object from contents 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir //TODO/LATER: needs new Format, because now single OLE and "this" are different 475*cdf0e10cSrcweir InitDocShell(); // set aDocShellRef 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir SfxObjectShell* pEmbObj = aDocShellRef; 478*cdf0e10cSrcweir bOK = SetObject( pEmbObj, SCDRAWTRANS_TYPE_DOCUMENT, rFlavor ); 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir else if( pBookmark ) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir bOK = SetINetBookmark( *pBookmark, rFlavor ); 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir return bOK; 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir sal_Bool ScDrawTransferObj::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, 490*cdf0e10cSrcweir const ::com::sun::star::datatransfer::DataFlavor& /* rFlavor */ ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir // called from SetObject, put data into stream 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir sal_Bool bRet = sal_False; 495*cdf0e10cSrcweir switch (nUserObjectId) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir case SCDRAWTRANS_TYPE_DRAWMODEL: 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir SdrModel* pDrawModel = (SdrModel*)pUserObject; 500*cdf0e10cSrcweir rxOStm->SetBufferSize( 0xff00 ); 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir // #108584# 503*cdf0e10cSrcweir // for the changed pool defaults from drawing layer pool set those 504*cdf0e10cSrcweir // attributes as hard attributes to preserve them for saving 505*cdf0e10cSrcweir const SfxItemPool& rItemPool = pModel->GetItemPool(); 506*cdf0e10cSrcweir const SvxFontHeightItem& rDefaultFontHeight = (const SvxFontHeightItem&)rItemPool.GetDefaultItem(EE_CHAR_FONTHEIGHT); 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir // SW should have no MasterPages 509*cdf0e10cSrcweir DBG_ASSERT(0L == pModel->GetMasterPageCount(), "SW with MasterPages (!)"); 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir for(sal_uInt16 a(0); a < pModel->GetPageCount(); a++) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir const SdrPage* pPage = pModel->GetPage(a); 514*cdf0e10cSrcweir SdrObjListIter aIter(*pPage, IM_DEEPNOGROUPS); 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir while(aIter.IsMore()) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir SdrObject* pObj = aIter.Next(); 519*cdf0e10cSrcweir const SvxFontHeightItem& rItem = (const SvxFontHeightItem&)pObj->GetMergedItem(EE_CHAR_FONTHEIGHT); 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir if(rItem.GetHeight() == rDefaultFontHeight.GetHeight()) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir pObj->SetMergedItem(rDefaultFontHeight); 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) ); 530*cdf0e10cSrcweir if( SvxDrawingLayerExport( pDrawModel, xDocOut ) ) 531*cdf0e10cSrcweir rxOStm->Commit(); 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir bRet = ( rxOStm->GetError() == ERRCODE_NONE ); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir break; 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir case SCDRAWTRANS_TYPE_EMBOBJ: 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir // impl. for "single OLE" 541*cdf0e10cSrcweir embed::XEmbeddedObject* pEmbObj = (embed::XEmbeddedObject*) pUserObject; 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir ::utl::TempFile aTempFile; 544*cdf0e10cSrcweir aTempFile.EnableKillingFile(); 545*cdf0e10cSrcweir uno::Reference< embed::XStorage > xWorkStore = 546*cdf0e10cSrcweir ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE ); 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir uno::Reference < embed::XEmbedPersist > xPers( (embed::XVisualObject*)pEmbObj, uno::UNO_QUERY ); 549*cdf0e10cSrcweir if ( xPers.is() ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir try 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir uno::Sequence < beans::PropertyValue > aSeq; 554*cdf0e10cSrcweir ::rtl::OUString aDummyName = ::rtl::OUString::createFromAscii("Dummy"); 555*cdf0e10cSrcweir xPers->storeToEntry( xWorkStore, aDummyName, aSeq, aSeq ); 556*cdf0e10cSrcweir if ( xWorkStore->isStreamElement( aDummyName ) ) 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir uno::Reference < io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) ); 559*cdf0e10cSrcweir uno::Reference < io::XStream > xNewStream = xWorkStore->openStreamElement( aDummyName, embed::ElementModes::READ ); 560*cdf0e10cSrcweir ::comphelper::OStorageHelper::CopyInputToOutput( xNewStream->getInputStream(), xDocOut ); 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir else 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir uno::Reference < io::XStream > xDocStr( new utl::OStreamWrapper( *rxOStm ) ); 565*cdf0e10cSrcweir uno::Reference< embed::XStorage > xDocStg = ::comphelper::OStorageHelper::GetStorageFromStream( xDocStr ); 566*cdf0e10cSrcweir uno::Reference < embed::XStorage > xNewStg = xWorkStore->openStorageElement( aDummyName, embed::ElementModes::READ ); 567*cdf0e10cSrcweir xNewStg->copyToStorage( xDocStg ); 568*cdf0e10cSrcweir uno::Reference < embed::XTransactedObject > xTrans( xDocStg, uno::UNO_QUERY ); 569*cdf0e10cSrcweir if ( xTrans.is() ) 570*cdf0e10cSrcweir xTrans->commit(); 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir rxOStm->Commit(); 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir catch ( uno::Exception& ) 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir } 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir break; 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir case SCDRAWTRANS_TYPE_DOCUMENT: 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir // impl. for "DocShell" 585*cdf0e10cSrcweir SfxObjectShell* pEmbObj = (SfxObjectShell*) pUserObject; 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir try 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir ::utl::TempFile aTempFile; 590*cdf0e10cSrcweir aTempFile.EnableKillingFile(); 591*cdf0e10cSrcweir uno::Reference< embed::XStorage > xWorkStore = 592*cdf0e10cSrcweir ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE ); 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir // write document storage 595*cdf0e10cSrcweir pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, sal_False ); 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir // mba: no relative ULRs for clipboard! 598*cdf0e10cSrcweir SfxMedium aMedium( xWorkStore, String() ); 599*cdf0e10cSrcweir bRet = pEmbObj->DoSaveObjectAs( aMedium, sal_False ); 600*cdf0e10cSrcweir pEmbObj->DoSaveCompleted(); 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY ); 603*cdf0e10cSrcweir if ( xTransact.is() ) 604*cdf0e10cSrcweir xTransact->commit(); 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ ); 607*cdf0e10cSrcweir if( pSrcStm ) 608*cdf0e10cSrcweir { 609*cdf0e10cSrcweir rxOStm->SetBufferSize( 0xff00 ); 610*cdf0e10cSrcweir *rxOStm << *pSrcStm; 611*cdf0e10cSrcweir delete pSrcStm; 612*cdf0e10cSrcweir } 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir bRet = sal_True; 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir xWorkStore->dispose(); 617*cdf0e10cSrcweir xWorkStore = uno::Reference < embed::XStorage >(); 618*cdf0e10cSrcweir rxOStm->Commit(); 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir catch ( uno::Exception& ) 621*cdf0e10cSrcweir {} 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir bRet = ( rxOStm->GetError() == ERRCODE_NONE ); 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir break; 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir default: 628*cdf0e10cSrcweir DBG_ERROR("unknown object id"); 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir return bRet; 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir void ScDrawTransferObj::ObjectReleased() 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 636*cdf0e10cSrcweir if ( pScMod->GetClipData().pDrawClipboard == this ) 637*cdf0e10cSrcweir pScMod->SetClipObject( NULL, NULL ); 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir TransferableHelper::ObjectReleased(); 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir void ScDrawTransferObj::DragFinished( sal_Int8 nDropAction ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & SC_DROP_NAVIGATOR) ) 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir // move: delete source objects 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir if ( pDragSourceView ) 649*cdf0e10cSrcweir pDragSourceView->DeleteMarked(); 650*cdf0e10cSrcweir } 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 653*cdf0e10cSrcweir if ( pScMod->GetDragData().pDrawTransfer == this ) 654*cdf0e10cSrcweir pScMod->ResetDragObject(); 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir DELETEZ( pDragSourceView ); 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir TransferableHelper::DragFinished( nDropAction ); 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir void ScDrawTransferObj::SetDrawPersist( const SfxObjectShellRef& rRef ) 662*cdf0e10cSrcweir { 663*cdf0e10cSrcweir aDrawPersistRef = rRef; 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir void lcl_InitMarks( SdrMarkView& rDest, const SdrMarkView& rSource, SCTAB nTab ) 667*cdf0e10cSrcweir { 668*cdf0e10cSrcweir rDest.ShowSdrPage(rDest.GetModel()->GetPage(nTab)); 669*cdf0e10cSrcweir SdrPageView* pDestPV = rDest.GetSdrPageView(); 670*cdf0e10cSrcweir DBG_ASSERT(pDestPV,"PageView ?"); 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir const SdrMarkList& rMarkList = rSource.GetMarkedObjectList(); 673*cdf0e10cSrcweir sal_uLong nCount = rMarkList.GetMarkCount(); 674*cdf0e10cSrcweir for (sal_uLong i=0; i<nCount; i++) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir SdrMark* pMark = rMarkList.GetMark(i); 677*cdf0e10cSrcweir SdrObject* pObj = pMark->GetMarkedSdrObj(); 678*cdf0e10cSrcweir 679*cdf0e10cSrcweir rDest.MarkObj(pObj, pDestPV); 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir void ScDrawTransferObj::SetDragSource( ScDrawView* pView ) 684*cdf0e10cSrcweir { 685*cdf0e10cSrcweir DELETEZ( pDragSourceView ); 686*cdf0e10cSrcweir pDragSourceView = new SdrView( pView->GetModel() ); 687*cdf0e10cSrcweir lcl_InitMarks( *pDragSourceView, *pView, pView->GetTab() ); 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir //! add as listener with document, delete pDragSourceView if document gone 690*cdf0e10cSrcweir } 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir void ScDrawTransferObj::SetDragSourceObj( SdrObject* pObj, SCTAB nTab ) 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir DELETEZ( pDragSourceView ); 695*cdf0e10cSrcweir pDragSourceView = new SdrView( pObj->GetModel() ); 696*cdf0e10cSrcweir pDragSourceView->ShowSdrPage(pDragSourceView->GetModel()->GetPage(nTab)); 697*cdf0e10cSrcweir SdrPageView* pPV = pDragSourceView->GetSdrPageView(); 698*cdf0e10cSrcweir pDragSourceView->MarkObj(pObj, pPV); 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir //! add as listener with document, delete pDragSourceView if document gone 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir void ScDrawTransferObj::SetDragSourceFlags( sal_uInt16 nFlags ) 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir nDragSourceFlags = nFlags; 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir void ScDrawTransferObj::SetDragWasInternal() 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir bDragWasInternal = sal_True; 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir SdrOle2Obj* ScDrawTransferObj::GetSingleObject() 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir // if single OLE object was copied, get its object 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(0); 718*cdf0e10cSrcweir if (pPage) 719*cdf0e10cSrcweir { 720*cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_FLAT ); 721*cdf0e10cSrcweir SdrObject* pObject = aIter.Next(); 722*cdf0e10cSrcweir if (pObject && pObject->GetObjIdentifier() == OBJ_OLE2) 723*cdf0e10cSrcweir { 724*cdf0e10cSrcweir return (SdrOle2Obj*) pObject; 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir return NULL; 729*cdf0e10cSrcweir } 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir // 732*cdf0e10cSrcweir // initialize aDocShellRef with a live document from the ClipDoc 733*cdf0e10cSrcweir // 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir void ScDrawTransferObj::InitDocShell() 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir if ( !aDocShellRef.Is() ) 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir ScDocShell* pDocSh = new ScDocShell; 740*cdf0e10cSrcweir aDocShellRef = pDocSh; // ref must be there before InitNew 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir pDocSh->DoInitNew(NULL); 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir ScDocument* pDestDoc = pDocSh->GetDocument(); 745*cdf0e10cSrcweir pDestDoc->InitDrawLayer( pDocSh ); 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir SdrModel* pDestModel = pDestDoc->GetDrawLayer(); 748*cdf0e10cSrcweir // #i71538# use complete SdrViews 749*cdf0e10cSrcweir // SdrExchangeView aDestView( pDestModel ); 750*cdf0e10cSrcweir SdrView aDestView( pDestModel ); 751*cdf0e10cSrcweir aDestView.ShowSdrPage(aDestView.GetModel()->GetPage(0)); 752*cdf0e10cSrcweir aDestView.Paste( *pModel, Point( aSrcSize.Width()/2, aSrcSize.Height()/2 ) ); 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir // put objects to right layer (see ScViewFunc::PasteDataFormat for SOT_FORMATSTR_ID_DRAWING) 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir SdrPage* pPage = pDestModel->GetPage(0); 757*cdf0e10cSrcweir if (pPage) 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); 760*cdf0e10cSrcweir SdrObject* pObject = aIter.Next(); 761*cdf0e10cSrcweir while (pObject) 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir if ( pObject->ISA(SdrUnoObj) ) 764*cdf0e10cSrcweir pObject->NbcSetLayer(SC_LAYER_CONTROLS); 765*cdf0e10cSrcweir else 766*cdf0e10cSrcweir pObject->NbcSetLayer(SC_LAYER_FRONT); 767*cdf0e10cSrcweir pObject = aIter.Next(); 768*cdf0e10cSrcweir } 769*cdf0e10cSrcweir } 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir Point aTmpPoint; 772*cdf0e10cSrcweir Rectangle aDestArea( aTmpPoint, aSrcSize ); 773*cdf0e10cSrcweir pDocSh->SetVisArea( aDestArea ); 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir ScViewOptions aViewOpt( pDestDoc->GetViewOptions() ); 776*cdf0e10cSrcweir aViewOpt.SetOption( VOPT_GRID, sal_False ); 777*cdf0e10cSrcweir pDestDoc->SetViewOptions( aViewOpt ); 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir ScViewData aViewData( pDocSh, NULL ); 780*cdf0e10cSrcweir aViewData.SetTabNo( 0 ); 781*cdf0e10cSrcweir aViewData.SetScreen( aDestArea ); 782*cdf0e10cSrcweir aViewData.SetCurX( 0 ); 783*cdf0e10cSrcweir aViewData.SetCurY( 0 ); 784*cdf0e10cSrcweir pDocSh->UpdateOle(&aViewData, sal_True); 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir const com::sun::star::uno::Sequence< sal_Int8 >& ScDrawTransferObj::getUnoTunnelId() 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir static com::sun::star::uno::Sequence< sal_Int8 > aSeq; 791*cdf0e10cSrcweir if( !aSeq.getLength() ) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir static osl::Mutex aCreateMutex; 794*cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( aCreateMutex ); 795*cdf0e10cSrcweir aSeq.realloc( 16 ); 796*cdf0e10cSrcweir rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True ); 797*cdf0e10cSrcweir } 798*cdf0e10cSrcweir return aSeq; 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir sal_Int64 SAL_CALL ScDrawTransferObj::getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( com::sun::star::uno::RuntimeException ) 802*cdf0e10cSrcweir { 803*cdf0e10cSrcweir sal_Int64 nRet; 804*cdf0e10cSrcweir if( ( rId.getLength() == 16 ) && 805*cdf0e10cSrcweir ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) ) 806*cdf0e10cSrcweir { 807*cdf0e10cSrcweir nRet = reinterpret_cast< sal_Int64 >( this ); 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir else 810*cdf0e10cSrcweir nRet = TransferableHelper::getSomething(rId); 811*cdf0e10cSrcweir return nRet; 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir 815