2001-01-19 12:09:07 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:29:28 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-01-19 12:09:07 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-01-19 12:09:07 -06:00
|
|
|
*
|
2008-04-10 13:29:28 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-01-19 12:09:07 -06:00
|
|
|
*
|
2008-04-10 13:29:28 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-01-19 12:09:07 -06:00
|
|
|
*
|
2008-04-10 13:29:28 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-01-19 12:09:07 -06:00
|
|
|
*
|
2008-04-10 13:29:28 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-01-19 12:09:07 -06:00
|
|
|
*
|
2008-04-10 13:29:28 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-01-19 12:09:07 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 12:32:35 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
2004-10-04 12:21:11 -05:00
|
|
|
#include <com/sun/star/embed/XTransactedObject.hpp>
|
2006-02-01 11:40:12 -06:00
|
|
|
#include <com/sun/star/embed/XEmbedPersist.hpp>
|
2004-10-04 12:21:11 -05:00
|
|
|
#include <com/sun/star/embed/ElementModes.hpp>
|
2001-11-09 03:46:49 -06:00
|
|
|
#include <com/sun/star/lang/XComponent.hpp>
|
2001-01-19 12:09:07 -06:00
|
|
|
#include <vos/mutex.hxx>
|
2001-03-14 05:55:54 -06:00
|
|
|
#include <unotools/ucbstreamhelper.hxx>
|
2002-01-15 06:33:14 -06:00
|
|
|
#ifndef _UNTOOLS_TEMPFILE_HXX
|
|
|
|
#include <unotools/tempfile.hxx>
|
|
|
|
#endif
|
2010-01-08 11:32:51 -06:00
|
|
|
#include <editeng/eeitem.hxx>
|
|
|
|
#include <editeng/flditem.hxx>
|
2001-01-19 12:09:07 -06:00
|
|
|
#include <svx/svdpagv.hxx>
|
|
|
|
#include <sfx2/app.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <svx/svdoole2.hxx>
|
|
|
|
#include <svx/svdograf.hxx>
|
|
|
|
#include <svx/svdotext.hxx>
|
2010-01-08 11:32:51 -06:00
|
|
|
#include <editeng/outlobj.hxx>
|
2004-10-04 12:21:11 -05:00
|
|
|
#include <sot/storage.hxx>
|
2009-10-15 17:05:16 -05:00
|
|
|
#include <svl/itempool.hxx>
|
2010-01-08 11:32:51 -06:00
|
|
|
#include <editeng/editobj.hxx>
|
2001-01-19 12:09:07 -06:00
|
|
|
#include <svx/fmglob.hxx>
|
|
|
|
#include <svx/svdouno.hxx>
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#include <sot/formats.hxx>
|
2009-10-15 17:05:16 -05:00
|
|
|
#include <svl/urlbmk.hxx>
|
2010-01-08 11:32:51 -06:00
|
|
|
#include <editeng/outliner.hxx>
|
2006-12-13 10:55:00 -06:00
|
|
|
|
|
|
|
//#ifndef _SVDETC_HXX //autogen
|
|
|
|
//#include <svx/svdetc.hxx>
|
|
|
|
//#endif
|
2001-01-19 12:09:07 -06:00
|
|
|
#include <com/sun/star/form/FormButtonType.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
2001-10-04 05:06:52 -05:00
|
|
|
#include <unotools/streamwrap.hxx>
|
|
|
|
|
2008-03-12 05:35:03 -05:00
|
|
|
#include <svx/svdotable.hxx>
|
2001-10-04 05:06:52 -05:00
|
|
|
#include <svx/unomodel.hxx>
|
2002-12-12 06:25:36 -06:00
|
|
|
#include <svx/svditer.hxx>
|
2004-10-04 12:21:11 -05:00
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#include <comphelper/storagehelper.hxx>
|
|
|
|
#include <svtools/embedtransfer.hxx>
|
2004-01-20 03:38:13 -06:00
|
|
|
#include "DrawDocShell.hxx"
|
|
|
|
#include "View.hxx"
|
2001-01-19 12:09:07 -06:00
|
|
|
#include "sdpage.hxx"
|
|
|
|
#include "drawview.hxx"
|
|
|
|
#include "drawdoc.hxx"
|
|
|
|
#include "stlpool.hxx"
|
|
|
|
#include "strings.hrc"
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "imapinfo.hxx"
|
|
|
|
#include "sdxfer.hxx"
|
2001-11-09 03:46:49 -06:00
|
|
|
#include "unomodel.hxx"
|
2006-11-14 07:25:22 -06:00
|
|
|
#include <vcl/virdev.hxx>
|
|
|
|
|
2001-01-19 12:09:07 -06:00
|
|
|
// --------------
|
|
|
|
// - Namespaces -
|
|
|
|
// --------------
|
|
|
|
|
2004-10-04 12:21:11 -05:00
|
|
|
using namespace ::com::sun::star;
|
2001-11-09 03:46:49 -06:00
|
|
|
using namespace ::com::sun::star::lang;
|
2001-01-19 12:09:07 -06:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::io;
|
|
|
|
using namespace ::com::sun::star::datatransfer;
|
|
|
|
using namespace ::com::sun::star::datatransfer::clipboard;
|
|
|
|
|
|
|
|
// -----------
|
|
|
|
// - Defines -
|
|
|
|
// -----------
|
|
|
|
|
|
|
|
#define SDTRANSFER_OBJECTTYPE_DRAWMODEL 0x00000001
|
|
|
|
#define SDTRANSFER_OBJECTTYPE_DRAWOLE 0x00000002
|
|
|
|
|
|
|
|
// ------------------
|
|
|
|
// - SdTransferable -
|
|
|
|
// ------------------
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
SdTransferable::SdTransferable( SdDrawDocument* pSrcDoc, ::sd::View* pWorkView, BOOL bInitOnGetData )
|
|
|
|
: mpPageDocShell( NULL )
|
|
|
|
, mpOLEDataHelper( NULL )
|
|
|
|
, mpObjDesc( NULL )
|
|
|
|
, mpSdView( pWorkView )
|
|
|
|
, mpSdViewIntern( pWorkView )
|
|
|
|
, mpSdDrawDocument( NULL )
|
|
|
|
, mpSdDrawDocumentIntern( NULL )
|
|
|
|
, mpSourceDoc( pSrcDoc )
|
|
|
|
, mpVDev( NULL )
|
|
|
|
, mpBookmark( NULL )
|
|
|
|
, mpGraphic( NULL )
|
|
|
|
, mpImageMap( NULL )
|
|
|
|
, mbInternalMove( FALSE )
|
|
|
|
, mbOwnDocument( FALSE )
|
|
|
|
, mbOwnView( FALSE )
|
|
|
|
, mbLateInit( bInitOnGetData )
|
|
|
|
, mbPageTransferable( FALSE )
|
|
|
|
, mbPageTransferablePersistent( FALSE )
|
|
|
|
, mbIsUnoObj( false )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSourceDoc )
|
|
|
|
StartListening( *mpSourceDoc );
|
2005-11-08 02:04:10 -06:00
|
|
|
|
2006-01-16 08:18:57 -06:00
|
|
|
if( pWorkView )
|
|
|
|
StartListening( *pWorkView );
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( !mbLateInit )
|
2001-08-21 09:28:23 -05:00
|
|
|
CreateData();
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SdTransferable::~SdTransferable()
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSourceDoc )
|
|
|
|
EndListening( *mpSourceDoc );
|
2005-11-08 02:04:10 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdView )
|
|
|
|
EndListening( *const_cast< sd::View *>( mpSdView) );
|
2006-01-16 08:18:57 -06:00
|
|
|
|
2001-02-19 05:49:33 -06:00
|
|
|
Application::GetSolarMutex().acquire();
|
|
|
|
|
2001-08-21 09:28:23 -05:00
|
|
|
ObjectReleased();
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
for( void* p = maPageBookmarks.First(); p; p = maPageBookmarks.Next() )
|
2001-09-24 07:20:01 -05:00
|
|
|
delete static_cast< String* >( p );
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mbOwnView )
|
|
|
|
delete mpSdViewIntern;
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
delete mpOLEDataHelper;
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( maDocShellRef.Is() )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
SfxObjectShell* pObj = maDocShellRef;
|
2004-01-20 03:38:13 -06:00
|
|
|
::sd::DrawDocShell* pDocSh = static_cast< ::sd::DrawDocShell*>(pObj);
|
2001-01-19 12:09:07 -06:00
|
|
|
pDocSh->DoClose();
|
|
|
|
}
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
maDocShellRef.Clear();
|
|
|
|
|
|
|
|
if( mbOwnDocument )
|
|
|
|
delete mpSdDrawDocumentIntern;
|
2001-06-08 02:02:54 -05:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
delete mpGraphic;
|
|
|
|
delete mpBookmark;
|
|
|
|
delete mpImageMap;
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
delete mpVDev;
|
|
|
|
delete mpObjDesc;
|
2001-02-19 05:49:33 -06:00
|
|
|
|
|
|
|
Application::GetSolarMutex().release();
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
|
|
|
|
{
|
|
|
|
if( pObj )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
delete mpOLEDataHelper, mpOLEDataHelper = NULL;
|
|
|
|
delete mpGraphic, mpGraphic = NULL;
|
|
|
|
delete mpBookmark, mpBookmark = NULL;
|
|
|
|
delete mpImageMap, mpImageMap = NULL;
|
2001-01-19 12:09:07 -06:00
|
|
|
|
|
|
|
if( pObj->ISA( SdrOle2Obj ) )
|
|
|
|
{
|
2006-02-01 11:40:12 -06:00
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference < embed::XEmbeddedObject > xObj = static_cast< SdrOle2Obj* >( pObj )->GetObjRef();
|
|
|
|
uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
|
|
|
|
if( xObj.is() && xPersist.is() && xPersist->hasEntry() )
|
2006-10-06 04:39:41 -05:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
mpOLEDataHelper = new TransferableDataHelper( new SvEmbedTransferHelper( xObj, static_cast< SdrOle2Obj* >( pObj )->GetGraphic(), static_cast< SdrOle2Obj* >( pObj )->GetAspect() ) );
|
2006-10-13 05:13:30 -05:00
|
|
|
|
|
|
|
// TODO/LATER: the standalone handling of the graphic should not be used any more in future
|
|
|
|
// The EmbedDataHelper should bring the graphic in future
|
2006-10-06 04:39:41 -05:00
|
|
|
Graphic* pObjGr = static_cast< SdrOle2Obj* >( pObj )->GetGraphic();
|
|
|
|
if ( pObjGr )
|
2006-12-13 10:55:00 -06:00
|
|
|
mpGraphic = new Graphic( *pObjGr );
|
2006-10-06 04:39:41 -05:00
|
|
|
}
|
2006-02-01 11:40:12 -06:00
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{}
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
2006-12-13 10:55:00 -06:00
|
|
|
else if( pObj->ISA( SdrGrafObj ) && (mpSourceDoc && !mpSourceDoc->GetAnimationInfo( pObj )) )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
mpGraphic = new Graphic( static_cast< SdrGrafObj* >( pObj )->GetTransformedGraphic() );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
2006-12-13 10:55:00 -06:00
|
|
|
else if( pObj->IsUnoObj() && FmFormInventor == pObj->GetObjInventor() && ( pObj->GetObjIdentifier() == (UINT16) OBJ_FM_BUTTON ) )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2001-09-26 08:18:46 -05:00
|
|
|
SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( pObj );
|
2001-01-19 12:09:07 -06:00
|
|
|
|
|
|
|
if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
|
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel() );
|
|
|
|
|
|
|
|
if( !xControlModel.is() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Reference< ::com::sun::star::beans::XPropertySet > xPropSet( xControlModel, UNO_QUERY );
|
|
|
|
|
|
|
|
if( !xPropSet.is() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
::com::sun::star::form::FormButtonType eButtonType;
|
|
|
|
Any aTmp( xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) ) ) );
|
|
|
|
|
|
|
|
if( aTmp >>= eButtonType )
|
|
|
|
{
|
|
|
|
::rtl::OUString aLabel, aURL;
|
|
|
|
|
|
|
|
xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" ) ) ) >>= aLabel;
|
|
|
|
xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TargetURL") ) ) >>= aURL;
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
mpBookmark = new INetBookmark( String( aURL ), String( aLabel ) );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( pObj->ISA( SdrTextObj ) )
|
|
|
|
{
|
|
|
|
const OutlinerParaObject* pPara;
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( (pPara = static_cast< SdrTextObj* >( pObj )->GetOutlinerParaObject()) != 0 )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
|
|
|
const SvxFieldItem* pField;
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( (pField = pPara->GetTextObject().GetField()) != 0 )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
|
|
|
const SvxFieldData* pData = pField->GetField();
|
|
|
|
|
|
|
|
if( pData && pData->ISA( SvxURLField ) )
|
|
|
|
{
|
2001-09-26 08:18:46 -05:00
|
|
|
const SvxURLField* pURL = (SvxURLField*) pData;
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
mpBookmark = new INetBookmark( pURL->GetURL(), pURL->GetRepresentation() );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-26 08:18:46 -05:00
|
|
|
SdIMapInfo* pInfo = static_cast< SdDrawDocument* >( pObj->GetModel() )->GetIMapInfo( static_cast< SdrObject* >( pObj ) );
|
2001-01-19 12:09:07 -06:00
|
|
|
|
|
|
|
if( pInfo )
|
2006-12-13 10:55:00 -06:00
|
|
|
mpImageMap = new ImageMap( pInfo->GetImageMap() );
|
2002-11-19 10:22:22 -06:00
|
|
|
|
|
|
|
mbIsUnoObj = pObj && pObj->IsUnoObj();
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SdTransferable::CreateData()
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdDrawDocument && !mpSdViewIntern )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
mbOwnView = TRUE;
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
SdPage* pPage = mpSdDrawDocument->GetSdPage(0, PK_STANDARD);
|
2001-01-19 12:09:07 -06:00
|
|
|
|
|
|
|
if( 1 == pPage->GetObjCount() )
|
|
|
|
CreateObjectReplacement( pPage->GetObj( 0 ) );
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
mpVDev = new VirtualDevice( *Application::GetDefaultDevice() );
|
|
|
|
mpVDev->SetMapMode( MapMode( mpSdDrawDocumentIntern->GetScaleUnit(), Point(), mpSdDrawDocumentIntern->GetScaleFraction(), mpSdDrawDocumentIntern->GetScaleFraction() ) );
|
|
|
|
mpSdViewIntern = new ::sd::View( mpSdDrawDocumentIntern, mpVDev );
|
|
|
|
mpSdViewIntern->EndListening(*mpSdDrawDocumentIntern );
|
|
|
|
mpSdViewIntern->hideMarkHandles();
|
|
|
|
SdrPageView* pPageView = mpSdViewIntern->ShowSdrPage(pPage);
|
|
|
|
((SdrMarkView*)mpSdViewIntern)->MarkAllObj(pPageView);
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
2006-12-13 10:55:00 -06:00
|
|
|
else if( mpSdView && !mpSdDrawDocumentIntern )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
const SdrMarkList& rMarkList = mpSdView->GetMarkedObjectList();
|
2001-01-19 12:09:07 -06:00
|
|
|
|
|
|
|
if( rMarkList.GetMarkCount() == 1 )
|
2006-07-25 05:28:52 -05:00
|
|
|
CreateObjectReplacement( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSourceDoc )
|
|
|
|
mpSourceDoc->CreatingDataObj(this);
|
|
|
|
mpSdDrawDocumentIntern = (SdDrawDocument*) mpSdView->GetAllMarkedModel();
|
|
|
|
if( mpSourceDoc )
|
|
|
|
mpSourceDoc->CreatingDataObj(0);
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( !maDocShellRef.Is() && mpSdDrawDocumentIntern->GetDocSh() )
|
|
|
|
maDocShellRef = mpSdDrawDocumentIntern->GetDocSh();
|
2005-07-14 05:28:37 -05:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( !maDocShellRef.Is() )
|
2005-07-14 05:28:37 -05:00
|
|
|
{
|
|
|
|
DBG_ERROR( "SdTransferable::CreateData(), failed to create a model with persist, clipboard operation will fail for OLE objects!" );
|
2006-12-13 10:55:00 -06:00
|
|
|
mbOwnDocument = TRUE;
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Groesse der Source-Seite uebernehmen
|
2006-12-13 10:55:00 -06:00
|
|
|
SdrPageView* pPgView = mpSdView->GetSdrPageView();
|
2001-01-19 12:09:07 -06:00
|
|
|
SdPage* pOldPage = (SdPage*) pPgView->GetPage();
|
2006-12-13 10:55:00 -06:00
|
|
|
SdrModel* pOldModel = mpSdView->GetModel();
|
2001-01-19 12:09:07 -06:00
|
|
|
SdStyleSheetPool* pOldStylePool = (SdStyleSheetPool*) pOldModel->GetStyleSheetPool();
|
2006-12-13 10:55:00 -06:00
|
|
|
SdStyleSheetPool* pNewStylePool = (SdStyleSheetPool*) mpSdDrawDocumentIntern->GetStyleSheetPool();
|
|
|
|
SdPage* pPage = mpSdDrawDocumentIntern->GetSdPage( 0, PK_STANDARD );
|
2001-01-19 12:09:07 -06:00
|
|
|
String aOldLayoutName( pOldPage->GetLayoutName() );
|
|
|
|
|
|
|
|
pPage->SetSize( pOldPage->GetSize() );
|
|
|
|
pPage->SetLayoutName( aOldLayoutName );
|
|
|
|
pNewStylePool->CopyGraphicSheets( *pOldStylePool );
|
2008-03-12 05:35:03 -05:00
|
|
|
pNewStylePool->CopyCellSheets( *pOldStylePool );
|
|
|
|
pNewStylePool->CopyTableStyles( *pOldStylePool );
|
2001-01-19 12:09:07 -06:00
|
|
|
aOldLayoutName.Erase( aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ) );
|
2008-03-12 05:35:03 -05:00
|
|
|
SdStyleSheetVector aCreatedSheets;
|
|
|
|
pNewStylePool->CopyLayoutSheets( aOldLayoutName, *pOldStylePool, aCreatedSheets );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// set VisArea and adjust objects if neccessary
|
2006-12-13 10:55:00 -06:00
|
|
|
if( maVisArea.IsEmpty() &&
|
|
|
|
mpSdDrawDocumentIntern && mpSdViewIntern &&
|
|
|
|
mpSdDrawDocumentIntern->GetPageCount() )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
SdPage* pPage = mpSdDrawDocumentIntern->GetSdPage( 0, PK_STANDARD );
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( 1 == mpSdDrawDocumentIntern->GetPageCount() )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
Point aOrigin( ( maVisArea = mpSdViewIntern->GetAllMarkedRect() ).TopLeft() );
|
2001-01-19 12:09:07 -06:00
|
|
|
Size aVector( -aOrigin.X(), -aOrigin.Y() );
|
|
|
|
|
|
|
|
for( ULONG nObj = 0, nObjCount = pPage->GetObjCount(); nObj < nObjCount; nObj++ )
|
|
|
|
{
|
|
|
|
SdrObject* pObj = pPage->GetObj( nObj );
|
|
|
|
pObj->NbcMove( aVector );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2006-12-13 10:55:00 -06:00
|
|
|
maVisArea.SetSize( pPage->GetSize() );
|
2001-01-19 12:09:07 -06:00
|
|
|
|
|
|
|
// Die Ausgabe soll am Nullpunkt erfolgen
|
2006-12-13 10:55:00 -06:00
|
|
|
maVisArea.SetPos( Point() );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2002-12-12 06:25:36 -06:00
|
|
|
BOOL lcl_HasOnlyControls( SdrModel* pModel )
|
|
|
|
{
|
|
|
|
BOOL bOnlyControls = FALSE; // default if there are no objects
|
|
|
|
|
|
|
|
if ( pModel )
|
|
|
|
{
|
|
|
|
SdrPage* pPage = pModel->GetPage(0);
|
|
|
|
if (pPage)
|
|
|
|
{
|
|
|
|
SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
|
|
|
|
SdrObject* pObj = aIter.Next();
|
|
|
|
if ( pObj )
|
|
|
|
{
|
|
|
|
bOnlyControls = TRUE; // only set if there are any objects at all
|
|
|
|
while ( pObj )
|
|
|
|
{
|
|
|
|
if (!pObj->ISA(SdrUnoObj))
|
|
|
|
{
|
|
|
|
bOnlyControls = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pObj = aIter.Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bOnlyControls;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2008-03-12 05:35:03 -05:00
|
|
|
bool lcl_HasOnlyOneTable( SdrModel* pModel )
|
|
|
|
{
|
|
|
|
if ( pModel )
|
|
|
|
{
|
|
|
|
SdrPage* pPage = pModel->GetPage(0);
|
|
|
|
if (pPage && pPage->GetObjCount() == 1 )
|
|
|
|
{
|
|
|
|
if( dynamic_cast< sdr::table::SdrTableObj* >( pPage->GetObj(0) ) != 0 )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2001-01-19 12:09:07 -06:00
|
|
|
void SdTransferable::AddSupportedFormats()
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( !mbPageTransferable || mbPageTransferablePersistent )
|
2001-03-30 03:33:43 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( !mbLateInit )
|
2001-09-26 08:18:46 -05:00
|
|
|
CreateData();
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpObjDesc )
|
2001-10-16 03:36:09 -05:00
|
|
|
AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpOLEDataHelper )
|
2001-09-24 07:20:01 -05:00
|
|
|
{
|
|
|
|
AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
DataFlavorExVector aVector( mpOLEDataHelper->GetDataFlavorExVector() );
|
2001-09-24 07:20:01 -05:00
|
|
|
DataFlavorExVector::iterator aIter( aVector.begin() ), aEnd( aVector.end() );
|
2001-03-30 03:33:43 -06:00
|
|
|
|
2001-09-24 07:20:01 -05:00
|
|
|
while( aIter != aEnd )
|
|
|
|
AddFormat( *aIter++ );
|
|
|
|
}
|
2006-12-13 10:55:00 -06:00
|
|
|
else if( mpGraphic )
|
2001-09-24 07:20:01 -05:00
|
|
|
{
|
2004-08-03 07:25:11 -05:00
|
|
|
// #i25616#
|
|
|
|
AddFormat( SOT_FORMATSTR_ID_DRAWING );
|
|
|
|
|
2001-09-24 07:20:01 -05:00
|
|
|
AddFormat( SOT_FORMATSTR_ID_SVXB );
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpGraphic->GetType() == GRAPHIC_BITMAP )
|
2001-09-24 07:20:01 -05:00
|
|
|
{
|
|
|
|
AddFormat( SOT_FORMAT_BITMAP );
|
|
|
|
AddFormat( SOT_FORMAT_GDIMETAFILE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AddFormat( SOT_FORMAT_GDIMETAFILE );
|
|
|
|
AddFormat( SOT_FORMAT_BITMAP );
|
|
|
|
}
|
|
|
|
}
|
2006-12-13 10:55:00 -06:00
|
|
|
else if( mpBookmark )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2001-09-24 07:20:01 -05:00
|
|
|
AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
|
|
|
|
AddFormat( FORMAT_STRING );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-24 07:20:01 -05:00
|
|
|
AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
|
|
|
|
AddFormat( SOT_FORMATSTR_ID_DRAWING );
|
2006-12-13 10:55:00 -06:00
|
|
|
if( !mpSdDrawDocument || !lcl_HasOnlyControls( mpSdDrawDocument ) )
|
2002-11-19 10:22:22 -06:00
|
|
|
{
|
|
|
|
AddFormat( SOT_FORMAT_GDIMETAFILE );
|
|
|
|
AddFormat( SOT_FORMAT_BITMAP );
|
|
|
|
}
|
2008-03-12 05:35:03 -05:00
|
|
|
|
|
|
|
if( lcl_HasOnlyOneTable( mpSdDrawDocument ) )
|
|
|
|
AddFormat( SOT_FORMAT_RTF );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpImageMap )
|
2001-09-24 07:20:01 -05:00
|
|
|
AddFormat( SOT_FORMATSTR_ID_SVIM );
|
|
|
|
}
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool SdTransferable::GetData( const DataFlavor& rFlavor )
|
|
|
|
{
|
2009-09-23 06:56:27 -05:00
|
|
|
if (SD_MOD()==NULL)
|
|
|
|
return sal_False;
|
|
|
|
|
2001-01-19 12:09:07 -06:00
|
|
|
sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
|
|
|
|
sal_Bool bOK = sal_False;
|
|
|
|
|
2001-03-30 03:33:43 -06:00
|
|
|
CreateData();
|
|
|
|
|
2008-03-12 05:35:03 -05:00
|
|
|
if( nFormat == SOT_FORMAT_RTF && lcl_HasOnlyOneTable( mpSdDrawDocument ) )
|
|
|
|
{
|
|
|
|
bOK = SetTableRTF( mpSdDrawDocument, rFlavor );
|
|
|
|
}
|
|
|
|
else if( mpOLEDataHelper && mpOLEDataHelper->HasFormat( rFlavor ) )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
ULONG nOldSwapMode = 0;
|
2001-03-30 03:33:43 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdDrawDocumentIntern )
|
2001-03-30 03:33:43 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
nOldSwapMode = mpSdDrawDocumentIntern->GetSwapGraphicsMode();
|
|
|
|
mpSdDrawDocumentIntern->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE );
|
2001-03-30 03:33:43 -06:00
|
|
|
}
|
|
|
|
|
2006-10-06 04:39:41 -05:00
|
|
|
// TODO/LATER: support all the graphical formats, the embedded object scenario should not have separated handling
|
2006-12-13 10:55:00 -06:00
|
|
|
if( nFormat == FORMAT_GDIMETAFILE && mpGraphic )
|
|
|
|
bOK = SetGDIMetaFile( mpGraphic->GetGDIMetaFile(), rFlavor );
|
2006-10-06 04:39:41 -05:00
|
|
|
else
|
2006-12-13 10:55:00 -06:00
|
|
|
bOK = SetAny( mpOLEDataHelper->GetAny( rFlavor ), rFlavor );
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdDrawDocumentIntern )
|
|
|
|
mpSdDrawDocumentIntern->SetSwapGraphicsMode( nOldSwapMode );
|
2001-03-30 03:33:43 -06:00
|
|
|
}
|
|
|
|
else if( HasFormat( nFormat ) )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( ( nFormat == SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR || nFormat == SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) && mpObjDesc )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
bOK = SetTransferableObjectDescriptor( *mpObjDesc, rFlavor );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
else if( nFormat == SOT_FORMATSTR_ID_DRAWING )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
SfxObjectShellRef aOldRef( maDocShellRef );
|
2005-07-18 07:05:19 -05:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
maDocShellRef.Clear();
|
2005-07-18 07:05:19 -05:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdViewIntern )
|
2006-01-16 08:18:57 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
SdDrawDocument* pInternDoc = mpSdViewIntern->GetDoc();
|
2006-01-16 08:18:57 -06:00
|
|
|
if( pInternDoc )
|
|
|
|
pInternDoc->CreatingDataObj(this);
|
2006-12-13 10:55:00 -06:00
|
|
|
SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( mpSdViewIntern->GetAllMarkedModel() );
|
2006-01-16 08:18:57 -06:00
|
|
|
if( pInternDoc )
|
|
|
|
pInternDoc->CreatingDataObj(0);
|
2005-07-18 07:05:19 -05:00
|
|
|
|
2006-01-16 08:18:57 -06:00
|
|
|
bOK = SetObject( pDoc, SDTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor );
|
2005-07-18 07:05:19 -05:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( maDocShellRef.Is() )
|
2006-01-16 08:18:57 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
maDocShellRef->DoClose();
|
2006-01-16 08:18:57 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete pDoc;
|
|
|
|
}
|
2005-10-19 06:24:42 -05:00
|
|
|
}
|
2005-07-18 07:05:19 -05:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
maDocShellRef = aOldRef;
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
else if( nFormat == FORMAT_GDIMETAFILE )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdViewIntern )
|
|
|
|
bOK = SetGDIMetaFile( mpSdViewIntern->GetAllMarkedMetaFile( TRUE ), rFlavor );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
else if( nFormat == FORMAT_BITMAP )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdViewIntern )
|
|
|
|
bOK = SetBitmap( mpSdViewIntern->GetAllMarkedBitmap( TRUE ), rFlavor );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
2006-12-13 10:55:00 -06:00
|
|
|
else if( ( nFormat == FORMAT_STRING ) && mpBookmark )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
bOK = SetString( mpBookmark->GetURL(), rFlavor );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
2006-12-13 10:55:00 -06:00
|
|
|
else if( ( nFormat == SOT_FORMATSTR_ID_SVXB ) && mpGraphic )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
bOK = SetGraphic( *mpGraphic, rFlavor );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
2006-12-13 10:55:00 -06:00
|
|
|
else if( ( nFormat == SOT_FORMATSTR_ID_SVIM ) && mpImageMap )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
bOK = SetImageMap( *mpImageMap, rFlavor );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
2006-12-13 10:55:00 -06:00
|
|
|
else if( mpBookmark )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
bOK = SetINetBookmark( *mpBookmark, rFlavor );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
2001-03-16 06:33:16 -06:00
|
|
|
else if( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
ULONG nOldSwapMode = 0;
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdDrawDocumentIntern )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
nOldSwapMode = mpSdDrawDocumentIntern->GetSwapGraphicsMode();
|
|
|
|
mpSdDrawDocumentIntern->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( !maDocShellRef.Is() )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
maDocShellRef = new ::sd::DrawDocShell(
|
|
|
|
mpSdDrawDocumentIntern,
|
2004-01-20 03:38:13 -06:00
|
|
|
SFX_CREATE_MODE_EMBEDDED,
|
|
|
|
TRUE,
|
2006-12-13 10:55:00 -06:00
|
|
|
mpSdDrawDocumentIntern->GetDocumentType());
|
|
|
|
mbOwnDocument = FALSE;
|
|
|
|
maDocShellRef->DoInitNew( NULL );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
maDocShellRef->SetVisArea( maVisArea );
|
|
|
|
bOK = SetObject( &maDocShellRef, SDTRANSFER_OBJECTTYPE_DRAWOLE, rFlavor );
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdDrawDocumentIntern )
|
|
|
|
mpSdDrawDocumentIntern->SetSwapGraphicsMode( nOldSwapMode );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bOK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2001-10-04 05:06:52 -05:00
|
|
|
/* testcode
|
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
*/
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
sal_Bool SdTransferable::WriteObject( SotStorageStreamRef& rxOStm, void* pObject, sal_uInt32 nObjectType, const DataFlavor& )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
|
|
|
|
switch( nObjectType )
|
|
|
|
{
|
|
|
|
case( SDTRANSFER_OBJECTTYPE_DRAWMODEL ):
|
|
|
|
{
|
2004-05-10 05:54:28 -05:00
|
|
|
try
|
|
|
|
{
|
2004-11-26 07:12:42 -06:00
|
|
|
static const BOOL bDontBurnInStyleSheet = ( getenv( "AVOID_BURN_IN_FOR_GALLERY_THEME" ) != NULL );
|
2004-05-10 05:54:28 -05:00
|
|
|
SdDrawDocument* pDoc = (SdDrawDocument*) pObject;
|
2004-11-26 07:12:42 -06:00
|
|
|
if ( !bDontBurnInStyleSheet )
|
|
|
|
pDoc->BurnInStyleSheetAttributes();
|
2004-05-10 05:54:28 -05:00
|
|
|
rxOStm->SetBufferSize( 16348 );
|
2001-11-09 03:46:49 -06:00
|
|
|
|
2004-05-10 05:54:28 -05:00
|
|
|
Reference< XComponent > xComponent( new SdXImpressDocument( pDoc, sal_True ) );
|
|
|
|
pDoc->setUnoModel( Reference< XInterface >::query( xComponent ) );
|
2001-11-09 03:46:49 -06:00
|
|
|
|
2004-05-10 05:54:28 -05:00
|
|
|
{
|
|
|
|
com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) );
|
|
|
|
if( SvxDrawingLayerExport( pDoc, xDocOut, xComponent, (pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) ? "com.sun.star.comp.Impress.XMLClipboardExporter" : "com.sun.star.comp.DrawingLayer.XMLExporter" ) )
|
|
|
|
rxOStm->Commit();
|
|
|
|
}
|
2001-10-04 05:06:52 -05:00
|
|
|
|
2004-05-10 05:54:28 -05:00
|
|
|
/* testcode
|
|
|
|
{
|
|
|
|
const rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "file:///e:/test.xml" ) );
|
|
|
|
SfxMedium aMedium( aURL, STREAM_WRITE | STREAM_TRUNC, TRUE );
|
|
|
|
aMedium.IsRemote();
|
|
|
|
com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *aMedium.GetOutStream() ) );
|
|
|
|
if( SvxDrawingLayerExport( pDoc, xDocOut, xComponent, (pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) ? "com.sun.star.comp.Impress.XMLClipboardExporter" : "com.sun.star.comp.DrawingLayer.XMLExporter" ) )
|
|
|
|
aMedium.Commit();
|
|
|
|
}
|
|
|
|
*/
|
2001-10-04 05:06:52 -05:00
|
|
|
|
2004-05-10 05:54:28 -05:00
|
|
|
xComponent->dispose();
|
|
|
|
bRet = ( rxOStm->GetError() == ERRCODE_NONE );
|
|
|
|
}
|
|
|
|
catch( Exception& )
|
|
|
|
{
|
|
|
|
DBG_ERROR( "sd::SdTransferable::WriteObject(), exception catched!" );
|
|
|
|
bRet = FALSE;
|
|
|
|
}
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( SDTRANSFER_OBJECTTYPE_DRAWOLE ):
|
|
|
|
{
|
2004-10-04 12:21:11 -05:00
|
|
|
SfxObjectShell* pEmbObj = (SfxObjectShell*) pObject;
|
2002-01-15 06:33:14 -06:00
|
|
|
::utl::TempFile aTempFile;
|
|
|
|
aTempFile.EnableKillingFile();
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2004-10-04 12:21:11 -05:00
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< embed::XStorage > xWorkStore =
|
|
|
|
::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
|
|
|
|
|
|
|
|
// write document storage
|
2005-02-07 07:41:17 -06:00
|
|
|
pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, sal_False );
|
2005-01-11 05:10:47 -06:00
|
|
|
// mba: no relative ULRs for clipboard!
|
|
|
|
SfxMedium aMedium( xWorkStore, String() );
|
|
|
|
bRet = pEmbObj->DoSaveObjectAs( aMedium, FALSE );
|
2004-10-04 12:21:11 -05:00
|
|
|
pEmbObj->DoSaveCompleted();
|
2001-03-14 05:55:54 -06:00
|
|
|
|
2004-10-04 12:21:11 -05:00
|
|
|
uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
|
|
|
|
if ( xTransact.is() )
|
|
|
|
xTransact->commit();
|
2001-03-14 05:55:54 -06:00
|
|
|
|
2004-10-04 12:21:11 -05:00
|
|
|
SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
|
|
|
|
if( pSrcStm )
|
|
|
|
{
|
|
|
|
rxOStm->SetBufferSize( 0xff00 );
|
|
|
|
*rxOStm << *pSrcStm;
|
|
|
|
delete pSrcStm;
|
|
|
|
}
|
|
|
|
|
|
|
|
bRet = TRUE;
|
2001-03-14 05:55:54 -06:00
|
|
|
rxOStm->Commit();
|
2004-10-04 12:21:11 -05:00
|
|
|
}
|
|
|
|
catch ( Exception& )
|
|
|
|
{}
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
2004-10-04 12:21:11 -05:00
|
|
|
|
2001-01-19 12:09:07 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2001-03-08 04:12:28 -06:00
|
|
|
void SdTransferable::DragFinished( sal_Int8 nDropAction )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdView )
|
|
|
|
( (::sd::View*) mpSdView )->DragFinished( nDropAction );
|
2001-03-08 04:12:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2001-01-19 12:09:07 -06:00
|
|
|
void SdTransferable::ObjectReleased()
|
|
|
|
{
|
|
|
|
if( this == SD_MOD()->pTransferClip )
|
|
|
|
SD_MOD()->pTransferClip = NULL;
|
|
|
|
|
|
|
|
if( this == SD_MOD()->pTransferDrag )
|
|
|
|
SD_MOD()->pTransferDrag = NULL;
|
2001-08-21 09:28:23 -05:00
|
|
|
|
2001-08-23 04:54:33 -05:00
|
|
|
if( this == SD_MOD()->pTransferSelection )
|
|
|
|
SD_MOD()->pTransferSelection = NULL;
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SdTransferable::SetObjectDescriptor( const TransferableObjectDescriptor& rObjDesc )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
delete mpObjDesc;
|
|
|
|
mpObjDesc = new TransferableObjectDescriptor( rObjDesc );
|
2009-01-29 04:50:15 -06:00
|
|
|
PrepareOLE( rObjDesc );
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2001-09-24 07:20:01 -05:00
|
|
|
void SdTransferable::SetPageBookmarks( const List& rPageBookmarks, BOOL bPersistent )
|
2001-01-19 12:09:07 -06:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSourceDoc )
|
2001-09-24 07:20:01 -05:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdViewIntern )
|
|
|
|
mpSdViewIntern->HideSdrPage();
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2004-05-10 08:37:00 -05:00
|
|
|
// #116168#
|
2006-12-13 10:55:00 -06:00
|
|
|
mpSdDrawDocument->ClearModel(sal_False);
|
2004-05-10 08:37:00 -05:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
mpPageDocShell = NULL;
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
for( void* p = maPageBookmarks.First(); p; p = maPageBookmarks.Next() )
|
2001-09-24 07:20:01 -05:00
|
|
|
delete static_cast< String* >( p );
|
|
|
|
|
|
|
|
if( bPersistent )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
mpSdDrawDocument->CreateFirstPages(mpSourceDoc);
|
|
|
|
mpSdDrawDocument->InsertBookmarkAsPage( const_cast< List* >( &rPageBookmarks ), NULL, FALSE, TRUE, 1, TRUE, mpSourceDoc->GetDocSh(), TRUE, TRUE, FALSE );
|
2001-09-24 07:20:01 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
mpPageDocShell = mpSourceDoc->GetDocSh();
|
2001-09-24 07:20:01 -05:00
|
|
|
|
|
|
|
for( ULONG i = 0; i < rPageBookmarks.Count(); i++ )
|
2006-12-13 10:55:00 -06:00
|
|
|
maPageBookmarks.Insert( new String( *static_cast< String* >( rPageBookmarks.GetObject( i ) ) ), LIST_APPEND );
|
2001-09-24 07:20:01 -05:00
|
|
|
}
|
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
if( mpSdViewIntern && mpSdDrawDocument )
|
2001-09-24 07:20:01 -05:00
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
SdPage* pPage = mpSdDrawDocument->GetSdPage( 0, PK_STANDARD );
|
2001-09-24 07:20:01 -05:00
|
|
|
|
|
|
|
if( pPage )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
( (SdrMarkView*) mpSdViewIntern )->MarkAllObj( (SdrPageView*) mpSdViewIntern->ShowSdrPage( pPage ) );
|
2001-09-24 07:20:01 -05:00
|
|
|
}
|
|
|
|
}
|
2001-01-19 12:09:07 -06:00
|
|
|
|
2006-12-13 10:55:00 -06:00
|
|
|
// set flags for page transferable; if ( mbPageTransferablePersistent == FALSE ),
|
2001-09-24 07:20:01 -05:00
|
|
|
// don't offer any formats => it's just for internal puposes
|
2006-12-13 10:55:00 -06:00
|
|
|
mbPageTransferable = TRUE;
|
|
|
|
mbPageTransferablePersistent = bPersistent;
|
2001-01-19 12:09:07 -06:00
|
|
|
}
|
|
|
|
}
|
2001-08-29 06:29:15 -05:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2002-12-11 07:54:59 -06:00
|
|
|
sal_Int64 SAL_CALL SdTransferable::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException )
|
|
|
|
{
|
|
|
|
sal_Int64 nRet;
|
|
|
|
|
|
|
|
if( ( rId.getLength() == 16 ) &&
|
|
|
|
( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
nRet = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
|
2002-12-11 07:54:59 -06:00
|
|
|
}
|
|
|
|
else
|
2006-12-13 10:55:00 -06:00
|
|
|
{
|
2002-12-11 07:54:59 -06:00
|
|
|
nRet = 0;
|
2006-12-13 10:55:00 -06:00
|
|
|
}
|
2002-12-11 07:54:59 -06:00
|
|
|
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
const ::com::sun::star::uno::Sequence< sal_Int8 >& SdTransferable::getUnoTunnelId()
|
|
|
|
{
|
|
|
|
static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
|
|
|
|
|
|
|
|
if( !aSeq.getLength() )
|
|
|
|
{
|
|
|
|
static osl::Mutex aCreateMutex;
|
|
|
|
osl::MutexGuard aGuard( aCreateMutex );
|
|
|
|
|
|
|
|
aSeq.realloc( 16 );
|
|
|
|
rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
|
|
|
|
}
|
|
|
|
|
|
|
|
return aSeq;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2001-08-29 06:29:15 -05:00
|
|
|
SdTransferable* SdTransferable::getImplementation( const Reference< XInterface >& rxData ) throw()
|
|
|
|
{
|
2001-09-04 08:38:20 -05:00
|
|
|
try
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( rxData, UNO_QUERY_THROW );
|
|
|
|
return reinterpret_cast<SdTransferable*>(sal::static_int_cast<sal_uIntPtr>(xUnoTunnel->getSomething( SdTransferable::getUnoTunnelId()) ) );
|
2001-09-04 08:38:20 -05:00
|
|
|
}
|
|
|
|
catch( const ::com::sun::star::uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
2006-12-13 10:55:00 -06:00
|
|
|
return NULL;
|
2001-08-29 06:29:15 -05:00
|
|
|
}
|
2005-11-08 02:04:10 -06:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// SfxListener
|
|
|
|
void SdTransferable::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
|
|
|
|
{
|
2006-01-16 08:18:57 -06:00
|
|
|
const SdrHint* pSdrHint = dynamic_cast< const SdrHint* >( &rHint );
|
2005-11-08 02:04:10 -06:00
|
|
|
if( pSdrHint )
|
|
|
|
{
|
|
|
|
if( HINT_MODELCLEARED == pSdrHint->GetKind() )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
EndListening(*mpSourceDoc);
|
|
|
|
mpSourceDoc = 0;
|
2005-11-08 02:04:10 -06:00
|
|
|
}
|
|
|
|
}
|
2006-01-16 08:18:57 -06:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const SfxSimpleHint* pSimpleHint = dynamic_cast< const SfxSimpleHint * >(&rHint);
|
|
|
|
if(pSimpleHint && (pSimpleHint->GetId() == SFX_HINT_DYING) )
|
|
|
|
{
|
2006-12-13 10:55:00 -06:00
|
|
|
if( &rBC == mpSourceDoc )
|
|
|
|
mpSourceDoc = 0;
|
|
|
|
if( &rBC == mpSdViewIntern )
|
|
|
|
mpSdViewIntern = 0;
|
|
|
|
if( &rBC == mpSdView )
|
|
|
|
mpSdView = 0;
|
2006-01-16 08:18:57 -06:00
|
|
|
}
|
|
|
|
}
|
2005-11-08 02:04:10 -06:00
|
|
|
}
|
2008-03-12 05:35:03 -05:00
|
|
|
|
|
|
|
sal_Bool SdTransferable::SetTableRTF( SdDrawDocument* pModel, const DataFlavor& rFlavor)
|
|
|
|
{
|
|
|
|
if ( pModel )
|
|
|
|
{
|
|
|
|
SdrPage* pPage = pModel->GetPage(0);
|
|
|
|
if (pPage && pPage->GetObjCount() == 1 )
|
|
|
|
{
|
|
|
|
sdr::table::SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( pPage->GetObj(0) );
|
|
|
|
if( pTableObj )
|
|
|
|
{
|
|
|
|
SvMemoryStream aMemStm( 65535, 65535 );
|
|
|
|
sdr::table::SdrTableObj::ExportAsRTF( aMemStm, *pTableObj );
|
|
|
|
return SetAny( Any( Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) ) ), rFlavor );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sal_False;
|
|
|
|
}
|