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