1*b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b3f79822SAndrew Rist * distributed with this work for additional information 6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b3f79822SAndrew Rist * software distributed under the License is distributed on an 15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17*b3f79822SAndrew Rist * specific language governing permissions and limitations 18*b3f79822SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b3f79822SAndrew Rist *************************************************************/ 21*b3f79822SAndrew Rist 22*b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir // INCLUDE --------------------------------------------------------------- 28cdf0e10cSrcweir 29cdf0e10cSrcweir 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 32cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp> 33cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <tools/urlobj.hxx> 36cdf0e10cSrcweir #include <sfx2/docfile.hxx> 37cdf0e10cSrcweir #include <svx/fmglob.hxx> 38cdf0e10cSrcweir #include <svx/svdograf.hxx> 39cdf0e10cSrcweir #include <svx/svdouno.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include "seltrans.hxx" 42cdf0e10cSrcweir #include "transobj.hxx" 43cdf0e10cSrcweir #include "drwtrans.hxx" 44cdf0e10cSrcweir #include "scmod.hxx" 45cdf0e10cSrcweir #include "dbfunc.hxx" // for CopyToClip 46cdf0e10cSrcweir #include "docsh.hxx" 47cdf0e10cSrcweir #include "drawview.hxx" 48cdf0e10cSrcweir #include "drwlayer.hxx" 49cdf0e10cSrcweir 50cdf0e10cSrcweir using namespace com::sun::star; 51cdf0e10cSrcweir 52cdf0e10cSrcweir // ----------------------------------------------------------------------- 53cdf0e10cSrcweir 54cdf0e10cSrcweir sal_Bool lcl_IsURLButton( SdrObject* pObject ) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir sal_Bool bRet = sal_False; 57cdf0e10cSrcweir 58cdf0e10cSrcweir SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObject); 59cdf0e10cSrcweir if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor()) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel(); 62cdf0e10cSrcweir DBG_ASSERT( xControlModel.is(), "uno control without model" ); 63cdf0e10cSrcweir if ( xControlModel.is() ) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY ); 66cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo(); 67cdf0e10cSrcweir 68cdf0e10cSrcweir rtl::OUString sPropButtonType = rtl::OUString::createFromAscii( "ButtonType" ); 69cdf0e10cSrcweir if(xInfo->hasPropertyByName( sPropButtonType )) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType ); 72cdf0e10cSrcweir form::FormButtonType eTmp; 73cdf0e10cSrcweir if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL ) 74cdf0e10cSrcweir bRet = sal_True; 75cdf0e10cSrcweir } 76cdf0e10cSrcweir } 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir return bRet; 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir // static 83cdf0e10cSrcweir 84cdf0e10cSrcweir ScSelectionTransferObj* ScSelectionTransferObj::CreateFromView( ScTabView* pView ) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir ScSelectionTransferObj* pRet = NULL; 87cdf0e10cSrcweir 88cdf0e10cSrcweir if ( pView ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir ScSelectionTransferMode eMode = SC_SELTRANS_INVALID; 91cdf0e10cSrcweir 92cdf0e10cSrcweir SdrView* pSdrView = pView->GetSdrView(); 93cdf0e10cSrcweir if ( pSdrView ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir // handle selection on drawing layer 96cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); 97cdf0e10cSrcweir sal_uLong nMarkCount = rMarkList.GetMarkCount(); 98cdf0e10cSrcweir if ( nMarkCount ) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir if ( nMarkCount == 1 ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 103cdf0e10cSrcweir sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier(); 104cdf0e10cSrcweir 105cdf0e10cSrcweir if ( nSdrObjKind == OBJ_GRAF ) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir if ( ((SdrGrafObj*)pObj)->GetGraphic().GetType() == GRAPHIC_BITMAP ) 108cdf0e10cSrcweir eMode = SC_SELTRANS_DRAW_BITMAP; 109cdf0e10cSrcweir else 110cdf0e10cSrcweir eMode = SC_SELTRANS_DRAW_GRAPHIC; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir else if ( nSdrObjKind == OBJ_OLE2 ) 113cdf0e10cSrcweir eMode = SC_SELTRANS_DRAW_OLE; 114cdf0e10cSrcweir else if ( lcl_IsURLButton( pObj ) ) 115cdf0e10cSrcweir eMode = SC_SELTRANS_DRAW_BOOKMARK; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir if ( eMode == SC_SELTRANS_INVALID ) 119cdf0e10cSrcweir eMode = SC_SELTRANS_DRAW_OTHER; // something selected but no special selection 120cdf0e10cSrcweir } 121cdf0e10cSrcweir } 122cdf0e10cSrcweir if ( eMode == SC_SELTRANS_INVALID ) // no drawing object selected 123cdf0e10cSrcweir { 124cdf0e10cSrcweir ScRange aRange; 125cdf0e10cSrcweir ScViewData* pViewData = pView->GetViewData(); 126cdf0e10cSrcweir const ScMarkData& rMark = pViewData->GetMarkData(); 127cdf0e10cSrcweir // allow MultiMarked because GetSimpleArea may be able to merge into a simple range 128cdf0e10cSrcweir // (GetSimpleArea modifies a local copy of MarkData) 129cdf0e10cSrcweir // Also allow simple filtered area. 130cdf0e10cSrcweir ScMarkType eMarkType; 131cdf0e10cSrcweir if ( ( rMark.IsMarked() || rMark.IsMultiMarked() ) && 132cdf0e10cSrcweir (((eMarkType = pViewData->GetSimpleArea( aRange )) == SC_MARK_SIMPLE) || 133cdf0e10cSrcweir (eMarkType == SC_MARK_SIMPLE_FILTERED)) ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir // only for "real" selection, cursor alone isn't used 136cdf0e10cSrcweir if ( aRange.aStart == aRange.aEnd ) 137cdf0e10cSrcweir eMode = SC_SELTRANS_CELL; 138cdf0e10cSrcweir else 139cdf0e10cSrcweir eMode = SC_SELTRANS_CELLS; 140cdf0e10cSrcweir } 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir if ( eMode != SC_SELTRANS_INVALID ) 144cdf0e10cSrcweir pRet = new ScSelectionTransferObj( pView, eMode ); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir return pRet; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir 151cdf0e10cSrcweir ScSelectionTransferObj::ScSelectionTransferObj( ScTabView* pSource, ScSelectionTransferMode eNewMode ) : 152cdf0e10cSrcweir pView( pSource ), 153cdf0e10cSrcweir eMode( eNewMode ), 154cdf0e10cSrcweir pCellData( NULL ), 155cdf0e10cSrcweir pDrawData( NULL ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir //! store range for StillValid 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir ScSelectionTransferObj::~ScSelectionTransferObj() 161cdf0e10cSrcweir { 162cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 163cdf0e10cSrcweir if ( pScMod->GetSelectionTransfer() == this ) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir // this is reached when the object wasn't really copied to the selection 166cdf0e10cSrcweir // (CopyToSelection has no effect under Windows) 167cdf0e10cSrcweir 168cdf0e10cSrcweir ForgetView(); 169cdf0e10cSrcweir pScMod->SetSelectionTransfer( NULL ); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir DBG_ASSERT( !pView, "ScSelectionTransferObj dtor: ForgetView not called" ); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir sal_Bool ScSelectionTransferObj::StillValid() 176cdf0e10cSrcweir { 177cdf0e10cSrcweir //! check if view still has same cell selection 178cdf0e10cSrcweir //! (but return sal_False if data has changed inbetween) 179cdf0e10cSrcweir return sal_False; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir void ScSelectionTransferObj::ForgetView() 183cdf0e10cSrcweir { 184cdf0e10cSrcweir pView = NULL; 185cdf0e10cSrcweir eMode = SC_SELTRANS_INVALID; 186cdf0e10cSrcweir 187cdf0e10cSrcweir if (pCellData) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir pCellData->release(); 190cdf0e10cSrcweir pCellData = NULL; 191cdf0e10cSrcweir } 192cdf0e10cSrcweir if (pDrawData) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir pDrawData->release(); 195cdf0e10cSrcweir pDrawData = NULL; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir void ScSelectionTransferObj::AddSupportedFormats() 200cdf0e10cSrcweir { 201cdf0e10cSrcweir // AddSupportedFormats must work without actually creating the 202cdf0e10cSrcweir // "real" transfer object 203cdf0e10cSrcweir 204cdf0e10cSrcweir switch (eMode) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir case SC_SELTRANS_CELL: 207cdf0e10cSrcweir case SC_SELTRANS_CELLS: 208cdf0e10cSrcweir // same formats as in ScTransferObj::AddSupportedFormats 209cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ); 210cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 211cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE ); 212cdf0e10cSrcweir AddFormat( SOT_FORMAT_BITMAP ); 213cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_HTML ); 214cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_SYLK ); 215cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_LINK ); 216cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_DIF ); 217cdf0e10cSrcweir AddFormat( SOT_FORMAT_STRING ); 218cdf0e10cSrcweir AddFormat( SOT_FORMAT_RTF ); 219cdf0e10cSrcweir if ( eMode == SC_SELTRANS_CELL ) 220cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_EDITENGINE ); 221cdf0e10cSrcweir break; 222cdf0e10cSrcweir 223cdf0e10cSrcweir // different graphic formats as in ScDrawTransferObj::AddSupportedFormats: 224cdf0e10cSrcweir 225cdf0e10cSrcweir case SC_SELTRANS_DRAW_BITMAP: 226cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 227cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_SVXB ); 228cdf0e10cSrcweir AddFormat( SOT_FORMAT_BITMAP ); 229cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE ); 230cdf0e10cSrcweir break; 231cdf0e10cSrcweir 232cdf0e10cSrcweir case SC_SELTRANS_DRAW_GRAPHIC: 233cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 234cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_SVXB ); 235cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE ); 236cdf0e10cSrcweir AddFormat( SOT_FORMAT_BITMAP ); 237cdf0e10cSrcweir break; 238cdf0e10cSrcweir 239cdf0e10cSrcweir case SC_SELTRANS_DRAW_BOOKMARK: 240cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 241cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_SOLK ); 242cdf0e10cSrcweir AddFormat( SOT_FORMAT_STRING ); 243cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ); 244cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ); 245cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_DRAWING ); 246cdf0e10cSrcweir break; 247cdf0e10cSrcweir 248cdf0e10cSrcweir case SC_SELTRANS_DRAW_OLE: 249cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ); 250cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 251cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE ); 252cdf0e10cSrcweir break; 253cdf0e10cSrcweir 254cdf0e10cSrcweir case SC_SELTRANS_DRAW_OTHER: 255cdf0e10cSrcweir // other drawing objects 256cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ); 257cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); 258cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_DRAWING ); 259cdf0e10cSrcweir AddFormat( SOT_FORMAT_BITMAP ); 260cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE ); 261cdf0e10cSrcweir break; 262cdf0e10cSrcweir 263cdf0e10cSrcweir default: 264cdf0e10cSrcweir { 265cdf0e10cSrcweir // added to avoid warnings 266cdf0e10cSrcweir } 267cdf0e10cSrcweir } 268cdf0e10cSrcweir } 269cdf0e10cSrcweir 270cdf0e10cSrcweir void ScSelectionTransferObj::CreateCellData() 271cdf0e10cSrcweir { 272cdf0e10cSrcweir DBG_ASSERT( !pCellData, "CreateCellData twice" ); 273cdf0e10cSrcweir if ( pView ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir ScViewData* pViewData = pView->GetViewData(); 276cdf0e10cSrcweir ScMarkData aNewMark( pViewData->GetMarkData() ); // use local copy for MarkToSimple 277cdf0e10cSrcweir aNewMark.MarkToSimple(); 278cdf0e10cSrcweir 279cdf0e10cSrcweir // similar to ScViewFunctionSet::BeginDrag 280cdf0e10cSrcweir if ( aNewMark.IsMarked() && !aNewMark.IsMultiMarked() ) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir ScDocShell* pDocSh = pViewData->GetDocShell(); 283cdf0e10cSrcweir 284cdf0e10cSrcweir ScRange aSelRange; 285cdf0e10cSrcweir aNewMark.GetMarkArea( aSelRange ); 286cdf0e10cSrcweir ScDocShellRef aDragShellRef; 287cdf0e10cSrcweir if ( pDocSh->GetDocument()->HasOLEObjectsInArea( aSelRange, &aNewMark ) ) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir aDragShellRef = new ScDocShell; // DocShell needs a Ref immediately 290cdf0e10cSrcweir aDragShellRef->DoInitNew(NULL); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir ScDrawLayer::SetGlobalDrawPersist(aDragShellRef); 293cdf0e10cSrcweir 294cdf0e10cSrcweir ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP ); 295cdf0e10cSrcweir // bApi = sal_True -> no error mesages 296cdf0e10cSrcweir // #i18364# bStopEdit = sal_False -> don't end edit mode 297cdf0e10cSrcweir // (this may be called from pasting into the edit line) 298cdf0e10cSrcweir sal_Bool bCopied = pViewData->GetView()->CopyToClip( pClipDoc, sal_False, sal_True, sal_True, sal_False ); 299cdf0e10cSrcweir 300cdf0e10cSrcweir ScDrawLayer::SetGlobalDrawPersist(NULL); 301cdf0e10cSrcweir 302cdf0e10cSrcweir if ( bCopied ) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir TransferableObjectDescriptor aObjDesc; 305cdf0e10cSrcweir pDocSh->FillTransferableObjectDescriptor( aObjDesc ); 306cdf0e10cSrcweir aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); 307cdf0e10cSrcweir // maSize is set in ScTransferObj ctor 308cdf0e10cSrcweir 309cdf0e10cSrcweir ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc ); 310cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj ); 311cdf0e10cSrcweir 312cdf0e10cSrcweir // SetDragHandlePos is not used - there is no mouse position 313cdf0e10cSrcweir //? pTransferObj->SetVisibleTab( nTab ); 314cdf0e10cSrcweir 315cdf0e10cSrcweir SfxObjectShellRef aPersistRef( aDragShellRef ); 316cdf0e10cSrcweir pTransferObj->SetDrawPersist( aPersistRef ); // keep persist for ole objects alive 317cdf0e10cSrcweir 318cdf0e10cSrcweir pTransferObj->SetDragSource( pDocSh, aNewMark ); 319cdf0e10cSrcweir 320cdf0e10cSrcweir pCellData = pTransferObj; 321cdf0e10cSrcweir pCellData->acquire(); // keep ref count up - released in ForgetView 322cdf0e10cSrcweir } 323cdf0e10cSrcweir else 324cdf0e10cSrcweir delete pClipDoc; 325cdf0e10cSrcweir } 326cdf0e10cSrcweir } 327cdf0e10cSrcweir DBG_ASSERT( pCellData, "can't create CellData" ); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir //! make static member of ScDrawView 331cdf0e10cSrcweir extern void lcl_CheckOle( const SdrMarkList& rMarkList, sal_Bool& rAnyOle, sal_Bool& rOneOle ); 332cdf0e10cSrcweir 333cdf0e10cSrcweir void ScSelectionTransferObj::CreateDrawData() 334cdf0e10cSrcweir { 335cdf0e10cSrcweir DBG_ASSERT( !pDrawData, "CreateDrawData twice" ); 336cdf0e10cSrcweir if ( pView ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir // similar to ScDrawView::BeginDrag 339cdf0e10cSrcweir 340cdf0e10cSrcweir ScDrawView* pDrawView = pView->GetScDrawView(); 341cdf0e10cSrcweir if ( pDrawView ) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir sal_Bool bAnyOle, bOneOle; 344cdf0e10cSrcweir const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList(); 345cdf0e10cSrcweir lcl_CheckOle( rMarkList, bAnyOle, bOneOle ); 346cdf0e10cSrcweir 347cdf0e10cSrcweir //--------------------------------------------------------- 348cdf0e10cSrcweir ScDocShellRef aDragShellRef; 349cdf0e10cSrcweir if (bAnyOle) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir aDragShellRef = new ScDocShell; // ohne Ref lebt die DocShell nicht !!! 352cdf0e10cSrcweir aDragShellRef->DoInitNew(NULL); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir //--------------------------------------------------------- 355cdf0e10cSrcweir 356cdf0e10cSrcweir ScDrawLayer::SetGlobalDrawPersist(aDragShellRef); 357cdf0e10cSrcweir SdrModel* pModel = pDrawView->GetAllMarkedModel(); 358cdf0e10cSrcweir ScDrawLayer::SetGlobalDrawPersist(NULL); 359cdf0e10cSrcweir 360cdf0e10cSrcweir ScViewData* pViewData = pView->GetViewData(); 361cdf0e10cSrcweir ScDocShell* pDocSh = pViewData->GetDocShell(); 362cdf0e10cSrcweir 363cdf0e10cSrcweir TransferableObjectDescriptor aObjDesc; 364cdf0e10cSrcweir pDocSh->FillTransferableObjectDescriptor( aObjDesc ); 365cdf0e10cSrcweir aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); 366cdf0e10cSrcweir // maSize is set in ScDrawTransferObj ctor 367cdf0e10cSrcweir 368cdf0e10cSrcweir ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc ); 369cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj ); 370cdf0e10cSrcweir 371cdf0e10cSrcweir SfxObjectShellRef aPersistRef( aDragShellRef ); 372cdf0e10cSrcweir pTransferObj->SetDrawPersist( aPersistRef ); // keep persist for ole objects alive 373cdf0e10cSrcweir pTransferObj->SetDragSource( pDrawView ); // copies selection 374cdf0e10cSrcweir 375cdf0e10cSrcweir pDrawData = pTransferObj; 376cdf0e10cSrcweir pDrawData->acquire(); // keep ref count up - released in ForgetView 377cdf0e10cSrcweir } 378cdf0e10cSrcweir } 379cdf0e10cSrcweir DBG_ASSERT( pDrawData, "can't create DrawData" ); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir ScTransferObj* ScSelectionTransferObj::GetCellData() 383cdf0e10cSrcweir { 384cdf0e10cSrcweir if ( !pCellData && ( eMode == SC_SELTRANS_CELL || eMode == SC_SELTRANS_CELLS ) ) 385cdf0e10cSrcweir CreateCellData(); 386cdf0e10cSrcweir return pCellData; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir ScDrawTransferObj* ScSelectionTransferObj::GetDrawData() 390cdf0e10cSrcweir { 391cdf0e10cSrcweir if ( !pDrawData && ( eMode == SC_SELTRANS_DRAW_BITMAP || eMode == SC_SELTRANS_DRAW_GRAPHIC || 392cdf0e10cSrcweir eMode == SC_SELTRANS_DRAW_BOOKMARK || eMode == SC_SELTRANS_DRAW_OLE || 393cdf0e10cSrcweir eMode == SC_SELTRANS_DRAW_OTHER ) ) 394cdf0e10cSrcweir CreateDrawData(); 395cdf0e10cSrcweir return pDrawData; 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir sal_Bool ScSelectionTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir sal_Bool bOK = sal_False; 401cdf0e10cSrcweir 402cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> xSource; 403cdf0e10cSrcweir switch (eMode) 404cdf0e10cSrcweir { 405cdf0e10cSrcweir case SC_SELTRANS_CELL: 406cdf0e10cSrcweir case SC_SELTRANS_CELLS: 407cdf0e10cSrcweir xSource = GetCellData(); 408cdf0e10cSrcweir break; 409cdf0e10cSrcweir case SC_SELTRANS_DRAW_BITMAP: 410cdf0e10cSrcweir case SC_SELTRANS_DRAW_GRAPHIC: 411cdf0e10cSrcweir case SC_SELTRANS_DRAW_BOOKMARK: 412cdf0e10cSrcweir case SC_SELTRANS_DRAW_OLE: 413cdf0e10cSrcweir case SC_SELTRANS_DRAW_OTHER: 414cdf0e10cSrcweir xSource = GetDrawData(); 415cdf0e10cSrcweir break; 416cdf0e10cSrcweir default: 417cdf0e10cSrcweir { 418cdf0e10cSrcweir // added to avoid warnings 419cdf0e10cSrcweir } 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir if ( xSource.is() ) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir TransferableDataHelper aHelper( xSource ); 425cdf0e10cSrcweir uno::Any aAny = aHelper.GetAny( rFlavor ); 426cdf0e10cSrcweir bOK = SetAny( aAny, rFlavor ); 427cdf0e10cSrcweir } 428cdf0e10cSrcweir 429cdf0e10cSrcweir return bOK; 430cdf0e10cSrcweir } 431cdf0e10cSrcweir 432cdf0e10cSrcweir void ScSelectionTransferObj::ObjectReleased() 433cdf0e10cSrcweir { 434cdf0e10cSrcweir // called when another selection is set from outside 435cdf0e10cSrcweir 436cdf0e10cSrcweir ForgetView(); 437cdf0e10cSrcweir 438cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 439cdf0e10cSrcweir if ( pScMod->GetSelectionTransfer() == this ) 440cdf0e10cSrcweir pScMod->SetSelectionTransfer( NULL ); 441cdf0e10cSrcweir 442cdf0e10cSrcweir TransferableHelper::ObjectReleased(); 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir 446