Files
libreoffice/sd/source/ui/app/sdxfer.cxx

812 lines
26 KiB
C++
Raw Normal View History

2001-01-19 18:09:07 +00:00
/*************************************************************************
*
* $RCSfile: sdxfer.cxx,v $
*
* $Revision: 1.30 $
2001-01-19 18:09:07 +00:00
*
* last change: $Author: obo $ $Date: 2004-01-20 10:38:13 $
2001-01-19 18:09:07 +00:00
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#define ITEMID_FIELD EE_FEATURE_FIELD
#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
#include <com/sun/star/lang/XComponent.hpp>
#endif
2001-01-19 18:09:07 +00:00
#ifndef _VOS_MUTEX_HXX_ //autogen
#include <vos/mutex.hxx>
#endif
2001-03-14 11:55:54 +00:00
#ifndef _UNTOOLS_UCBSTREAMHELPER_HXX
#include <unotools/ucbstreamhelper.hxx>
#endif
#ifndef _UNTOOLS_TEMPFILE_HXX
#include <unotools/tempfile.hxx>
#endif
2001-01-19 18:09:07 +00:00
#ifndef _EEITEM_HXX //autogen
#include <svx/eeitem.hxx>
#endif
#ifndef _SVX_FLDITEM_HXX //autogen
#include <svx/flditem.hxx>
#endif
#ifndef _SVDPAGV_HXX //autogen
#include <svx/svdpagv.hxx>
#endif
#ifndef _SFXAPP_HXX //autogen
#include <sfx2/app.hxx>
#endif
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SVDOOLE2_HXX //autogen
#include <svx/svdoole2.hxx>
#endif
#ifndef _SVDOGRAF_HXX //autogen
#include <svx/svdograf.hxx>
#endif
#ifndef _SVDOTEXT_HXX //autogen
#include <svx/svdotext.hxx>
#endif
#ifndef _OUTLOBJ_HXX //autogen
#include <svx/outlobj.hxx>
#endif
#ifndef _SVSTOR_HXX //autogen
#include <so3/svstor.hxx>
#endif
#ifndef _SFXITEMPOOL_HXX //autogen
#include <svtools/itempool.hxx>
#endif
#ifndef _EDITOBJ_HXX //autogen
#include <svx/editobj.hxx>
#endif
#ifndef _SVX_FMGLOB_HXX
#include <svx/fmglob.hxx>
#endif
#ifndef _SVDOUNO_HXX //autogen
#include <svx/svdouno.hxx>
#endif
#ifndef _URLOBJ_HXX //autogen
#include <tools/urlobj.hxx>
#endif
#ifndef _SOT_FORMATS_HXX //autogen
#include <sot/formats.hxx>
#endif
#ifndef _URLBMK_HXX //autogen
#include <svtools/urlbmk.hxx>
#endif
#ifndef _OUTLINER_HXX //autogen
#include <svx/outliner.hxx>
#endif
#ifndef _SVDETC_HXX //autogen
#include <svx/svdetc.hxx>
#endif
#ifndef _COM_SUN_STAR_FORM_FORMBUTTONTYPE_HPP_
#include <com/sun/star/form/FormButtonType.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _UTL_STREAM_WRAPPER_HXX_
#include <unotools/streamwrap.hxx>
#endif
2001-01-19 18:09:07 +00:00
#include <so3/outplace.hxx>
#include <svx/unomodel.hxx>
#include <svx/svditer.hxx>
2001-01-19 18:09:07 +00:00
#ifndef SD_DRAW_DOC_SHELL_HXX
#include "DrawDocShell.hxx"
#endif
#ifndef SD_VIEW_HXX
#include "View.hxx"
#endif
2001-01-19 18:09:07 +00:00
#include "sdpage.hxx"
#ifndef SD_DRAW_VIEW_HXX
2001-01-19 18:09:07 +00:00
#include "drawview.hxx"
#endif
2001-01-19 18:09:07 +00:00
#include "drawdoc.hxx"
#include "stlpool.hxx"
#include "strings.hrc"
#include "sdresid.hxx"
#include "imapinfo.hxx"
#include "sdxfer.hxx"
#include "unomodel.hxx"
2001-01-19 18:09:07 +00:00
// --------------
// - Namespaces -
// --------------
using namespace ::com::sun::star::lang;
2001-01-19 18:09:07 +00: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 -
// ------------------
SdTransferable::SdTransferable( SdDrawDocument* pSrcDoc, ::sd::View* pWorkView, BOOL bInitOnGetData ) :
2001-01-19 18:09:07 +00:00
pObjDesc( NULL ),
pPageDocShell( NULL ),
2001-01-19 18:09:07 +00:00
pSourceDoc( pSrcDoc ),
pSdViewIntern( pWorkView ),
pSdView( pWorkView ),
pSdDrawDocumentIntern( NULL ),
pSdDrawDocument( NULL ),
pVDev( NULL ),
bInternalMove( FALSE ),
bOwnView( FALSE ),
bOwnDocument( FALSE ),
pOLEDataHelper( NULL ),
2001-01-19 18:09:07 +00:00
pBookmark( NULL ),
pGraphic( NULL ),
pImageMap( NULL ),
bLateInit( bInitOnGetData ),
bPageTransferable( FALSE ),
bPageTransferablePersistent( FALSE ),
mbIsUnoObj( false )
2001-01-19 18:09:07 +00:00
{
if( !bLateInit )
CreateData();
2001-01-19 18:09:07 +00:00
}
// -----------------------------------------------------------------------------
SdTransferable::~SdTransferable()
{
Application::GetSolarMutex().acquire();
ObjectReleased();
for( void* p = aPageBookmarks.First(); p; p = aPageBookmarks.Next() )
delete static_cast< String* >( p );
2001-01-19 18:09:07 +00:00
if( bOwnView )
delete pSdViewIntern;
if( bOwnDocument )
delete pSdDrawDocumentIntern;
delete pOLEDataHelper;
2001-01-19 18:09:07 +00:00
if( aDocShellRef.Is() )
{
SvEmbeddedObject* pObj = aDocShellRef;
::sd::DrawDocShell* pDocSh = static_cast< ::sd::DrawDocShell*>(pObj);
2001-01-19 18:09:07 +00:00
pDocSh->DoClose();
}
aDocShellRef.Clear();
2001-01-19 18:09:07 +00:00
delete pGraphic;
delete pBookmark;
delete pImageMap;
delete pVDev;
delete pObjDesc;
Application::GetSolarMutex().release();
2001-01-19 18:09:07 +00:00
}
// -----------------------------------------------------------------------------
void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
{
if( pObj )
{
UINT32 nInv = pObj->GetObjInventor();
UINT16 nIdent = pObj->GetObjIdentifier();
delete pOLEDataHelper, pOLEDataHelper = NULL;
2001-01-19 18:09:07 +00:00
delete pGraphic, pGraphic = NULL;
delete pBookmark, pBookmark = NULL;
delete pImageMap, pImageMap = NULL;
if( pObj->ISA( SdrOle2Obj ) )
{
const SvInPlaceObjectRef& rOldObjRef = static_cast< SdrOle2Obj* >( pObj )->GetObjRef();
2001-01-19 18:09:07 +00:00
if( rOldObjRef.Is() )
pOLEDataHelper = new TransferableDataHelper( rOldObjRef->CreateTransferableSnapshot() );
2001-01-19 18:09:07 +00:00
}
else if( pObj->ISA( SdrGrafObj ) && !pSourceDoc->GetAnimationInfo( pObj ) )
{
pGraphic = new Graphic( static_cast< SdrGrafObj* >( pObj )->GetTransformedGraphic() );
2001-01-19 18:09:07 +00:00
}
else if( pObj->IsUnoObj() && FmFormInventor == pObj->GetObjInventor() && ( nIdent == (UINT16) OBJ_FM_BUTTON ) )
{
SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( pObj );
2001-01-19 18:09:07 +00: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;
pBookmark = new INetBookmark( String( aURL ), String( aLabel ) );
}
}
}
else if( pObj->ISA( SdrTextObj ) )
{
const OutlinerParaObject* pPara;
if( pPara = static_cast< SdrTextObj* >( pObj )->GetOutlinerParaObject() )
2001-01-19 18:09:07 +00:00
{
const SvxFieldItem* pField;
if( pField = pPara->GetTextObject().GetField() )
{
const SvxFieldData* pData = pField->GetField();
if( pData && pData->ISA( SvxURLField ) )
{
const SvxURLField* pURL = (SvxURLField*) pData;
2001-01-19 18:09:07 +00:00
pBookmark = new INetBookmark( pURL->GetURL(), pURL->GetRepresentation() );
}
}
}
}
SdIMapInfo* pInfo = static_cast< SdDrawDocument* >( pObj->GetModel() )->GetIMapInfo( static_cast< SdrObject* >( pObj ) );
2001-01-19 18:09:07 +00:00
if( pInfo )
pImageMap = new ImageMap( pInfo->GetImageMap() );
mbIsUnoObj = pObj && pObj->IsUnoObj();
2001-01-19 18:09:07 +00:00
}
}
// -----------------------------------------------------------------------------
void SdTransferable::CreateData()
{
if( pSdDrawDocument && !pSdViewIntern )
{
bOwnView = TRUE;
SdPage* pPage = pSdDrawDocument->GetSdPage(0, PK_STANDARD);
if( 1 == pPage->GetObjCount() )
CreateObjectReplacement( pPage->GetObj( 0 ) );
pVDev = new VirtualDevice( *Application::GetDefaultDevice() );
pVDev->SetMapMode( MapMode( pSdDrawDocumentIntern->GetScaleUnit(), Point(), pSdDrawDocumentIntern->GetScaleFraction(), pSdDrawDocumentIntern->GetScaleFraction() ) );
pSdViewIntern = new ::sd::View( pSdDrawDocumentIntern, pVDev );
2001-01-19 18:09:07 +00:00
pSdViewIntern->EndListening(*pSdDrawDocumentIntern );
pSdViewIntern->SetMarkHdlHidden( TRUE );
SdrPageView* pPageView = pSdViewIntern->ShowPage(pPage, Point());
((SdrMarkView*)pSdViewIntern)->MarkAll(pPageView);
}
else if( pSdView && !pSdDrawDocumentIntern )
{
bOwnDocument = TRUE;
const SdrMarkList& rMarkList = pSdView->GetMarkList();
if( rMarkList.GetMarkCount() == 1 )
CreateObjectReplacement( rMarkList.GetMark( 0 )->GetObj() );
pSdDrawDocumentIntern = (SdDrawDocument*) pSdView->GetAllMarkedModel();
if( !aDocShellRef.Is() && pSdDrawDocumentIntern->GetDocSh() )
{
// DocShell schon vorhanden ( AllocModel() )
aDocShellRef = pSdDrawDocumentIntern->GetDocSh();
bOwnDocument = FALSE;
}
// Groesse der Source-Seite uebernehmen
SdrPageView* pPgView = pSdView->GetPageViewPvNum( 0 );
SdPage* pOldPage = (SdPage*) pPgView->GetPage();
SdrModel* pOldModel = pSdView->GetModel();
SdStyleSheetPool* pOldStylePool = (SdStyleSheetPool*) pOldModel->GetStyleSheetPool();
SdStyleSheetPool* pNewStylePool = (SdStyleSheetPool*) pSdDrawDocumentIntern->GetStyleSheetPool();
SdPage* pPage = pSdDrawDocumentIntern->GetSdPage( 0, PK_STANDARD );
String aOldLayoutName( pOldPage->GetLayoutName() );
pPage->SetSize( pOldPage->GetSize() );
pPage->SetLayoutName( aOldLayoutName );
pNewStylePool->CopyGraphicSheets( *pOldStylePool );
aOldLayoutName.Erase( aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ) );
pNewStylePool->CopyLayoutSheets( aOldLayoutName, *pOldStylePool );
}
// set VisArea and adjust objects if neccessary
if( aVisArea.IsEmpty() &&
pSdDrawDocumentIntern && pSdViewIntern &&
pSdDrawDocumentIntern->GetPageCount() )
{
SdPage* pPage = pSdDrawDocumentIntern->GetSdPage( 0, PK_STANDARD );
if( 1 == pSdDrawDocumentIntern->GetPageCount() )
{
Point aOrigin( ( aVisArea = pSdViewIntern->GetAllMarkedRect() ).TopLeft() );
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
aVisArea.SetSize( pPage->GetSize() );
// Die Ausgabe soll am Nullpunkt erfolgen
aVisArea.SetPos( Point() );
}
}
// -----------------------------------------------------------------------------
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;
}
// -----------------------------------------------------------------------------
2001-01-19 18:09:07 +00:00
void SdTransferable::AddSupportedFormats()
{
if( !bPageTransferable || bPageTransferablePersistent )
2001-03-30 09:33:43 +00:00
{
if( !bLateInit )
CreateData();
if( pObjDesc )
AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
if( pOLEDataHelper )
{
AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
2001-01-19 18:09:07 +00:00
DataFlavorExVector aVector( pOLEDataHelper->GetDataFlavorExVector() );
DataFlavorExVector::iterator aIter( aVector.begin() ), aEnd( aVector.end() );
2001-03-30 09:33:43 +00:00
while( aIter != aEnd )
AddFormat( *aIter++ );
}
else if( pGraphic )
{
AddFormat( SOT_FORMATSTR_ID_SVXB );
2001-01-19 18:09:07 +00:00
if( pGraphic->GetType() == GRAPHIC_BITMAP )
{
AddFormat( SOT_FORMAT_BITMAP );
AddFormat( SOT_FORMAT_GDIMETAFILE );
}
else
{
AddFormat( SOT_FORMAT_GDIMETAFILE );
AddFormat( SOT_FORMAT_BITMAP );
}
}
else if( pBookmark )
2001-01-19 18:09:07 +00:00
{
AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
AddFormat( FORMAT_STRING );
2001-01-19 18:09:07 +00:00
}
else
{
AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
AddFormat( SOT_FORMATSTR_ID_DRAWING );
if( !pSdDrawDocument || !lcl_HasOnlyControls( pSdDrawDocument ) )
{
AddFormat( SOT_FORMAT_GDIMETAFILE );
AddFormat( SOT_FORMAT_BITMAP );
}
2001-01-19 18:09:07 +00:00
}
if( pImageMap )
AddFormat( SOT_FORMATSTR_ID_SVIM );
}
2001-01-19 18:09:07 +00:00
}
// -----------------------------------------------------------------------------
sal_Bool SdTransferable::GetData( const DataFlavor& rFlavor )
{
sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
sal_Bool bOK = sal_False;
2001-03-30 09:33:43 +00:00
CreateData();
if( pOLEDataHelper && pOLEDataHelper->HasFormat( rFlavor ) )
2001-01-19 18:09:07 +00:00
{
2001-03-30 09:33:43 +00:00
ULONG nOldSwapMode;
if( pSdDrawDocumentIntern )
{
nOldSwapMode = pSdDrawDocumentIntern->GetSwapGraphicsMode();
pSdDrawDocumentIntern->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE );
}
bOK = SetAny( pOLEDataHelper->GetAny( rFlavor ), rFlavor );
2001-01-19 18:09:07 +00:00
2001-03-30 09:33:43 +00:00
if( pSdDrawDocumentIntern )
pSdDrawDocumentIntern->SetSwapGraphicsMode( nOldSwapMode );
}
else if( HasFormat( nFormat ) )
{
2001-01-19 18:09:07 +00:00
if( ( nFormat == SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR || nFormat == SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) && pObjDesc )
{
bOK = SetTransferableObjectDescriptor( *pObjDesc, rFlavor );
}
else if( nFormat == SOT_FORMATSTR_ID_DRAWING )
{
SdDrawDocument* pDoc = (SdDrawDocument*) pSdViewIntern->GetAllMarkedModel();
bOK = SetObject( pDoc, SDTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor );
delete pDoc;
}
else if( nFormat == FORMAT_GDIMETAFILE )
{
bOK = SetGDIMetaFile( pSdViewIntern->GetAllMarkedMetaFile( TRUE ), rFlavor );
}
else if( nFormat == FORMAT_BITMAP )
{
bOK = SetBitmap( pSdViewIntern->GetAllMarkedBitmap( TRUE ), rFlavor );
}
2001-08-03 13:43:08 +00:00
else if( ( nFormat == FORMAT_STRING ) && pBookmark )
2001-01-19 18:09:07 +00:00
{
2001-08-03 13:43:08 +00:00
bOK = SetString( pBookmark->GetURL(), rFlavor );
2001-01-19 18:09:07 +00:00
}
else if( ( nFormat == SOT_FORMATSTR_ID_SVXB ) && pGraphic )
{
bOK = SetGraphic( *pGraphic, rFlavor );
}
else if( ( nFormat == SOT_FORMATSTR_ID_SVIM ) && pImageMap )
{
bOK = SetImageMap( *pImageMap, rFlavor );
}
else if( pBookmark )
{
bOK = SetINetBookmark( *pBookmark, rFlavor );
}
2001-03-16 12:33:16 +00:00
else if( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
2001-01-19 18:09:07 +00:00
{
ULONG nOldSwapMode;
if( pSdDrawDocumentIntern )
{
nOldSwapMode = pSdDrawDocumentIntern->GetSwapGraphicsMode();
pSdDrawDocumentIntern->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE );
}
if( !aDocShellRef.Is() )
{
aDocShellRef = new ::sd::DrawDocShell(
pSdDrawDocumentIntern,
SFX_CREATE_MODE_EMBEDDED,
TRUE,
pSdDrawDocumentIntern->GetDocumentType());
2001-01-19 18:09:07 +00:00
bOwnDocument = FALSE;
aDocShellRef->DoInitNew( NULL );
}
aDocShellRef->SetVisArea( aVisArea );
bOK = SetObject( &aDocShellRef, SDTRANSFER_OBJECTTYPE_DRAWOLE, rFlavor );
if( pSdDrawDocumentIntern )
pSdDrawDocumentIntern->SetSwapGraphicsMode( nOldSwapMode );
}
}
return bOK;
}
// -----------------------------------------------------------------------------
/* testcode
#ifndef _SFXDOCFILE_HXX
#include <sfx2/docfile.hxx>
#endif
*/
2001-01-19 18:09:07 +00:00
sal_Bool SdTransferable::WriteObject( SotStorageStreamRef& rxOStm, void* pObject, sal_uInt32 nObjectType, const DataFlavor& rFlavor )
{
sal_Bool bRet = sal_False;
switch( nObjectType )
{
case( SDTRANSFER_OBJECTTYPE_DRAWMODEL ):
{
SdDrawDocument* pDoc = (SdDrawDocument*) pObject;
pDoc->BurnInStyleSheetAttributes();
pDoc->SetStreamingSdrModel( TRUE );
pDoc->RemoveNotPersistentObjects( TRUE );
rxOStm->SetBufferSize( 16348 );
Reference< XComponent > xComponent( new SdXImpressDocument( pDoc, sal_True ) );
pDoc->setUnoModel( Reference< XInterface >::query( xComponent ) );
{
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();
}
/* 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-01-19 18:09:07 +00:00
pDoc->SetStreamingSdrModel( FALSE );
bRet = ( rxOStm->GetError() == ERRCODE_NONE );
}
break;
case( SDTRANSFER_OBJECTTYPE_DRAWOLE ):
{
SvEmbeddedObject* pEmbObj = (SvEmbeddedObject*) pObject;
::utl::TempFile aTempFile;
SvStorageRef xWorkStore( new SvStorage( TRUE, aTempFile.GetURL() ) );
aTempFile.EnableKillingFile();
2001-01-19 18:09:07 +00:00
// write document storage
2001-03-30 09:33:43 +00:00
xWorkStore->SetVersion( SOFFICE_FILEFORMAT_60 );
2001-01-19 18:09:07 +00:00
pEmbObj->SetupStorage( xWorkStore );
bRet = pEmbObj->DoSaveAs( xWorkStore );
pEmbObj->DoSaveCompleted();
xWorkStore->Commit();
2001-03-14 11:55:54 +00:00
xWorkStore.Clear();
SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
2001-03-14 11:55:54 +00:00
if( pSrcStm )
{
rxOStm->SetBufferSize( 0xff00 );
*rxOStm << *pSrcStm;
rxOStm->Commit();
delete pSrcStm;
}
2001-01-19 18:09:07 +00:00
bRet = ( rxOStm->GetError() == ERRCODE_NONE );
}
break;
default:
break;
}
return bRet;
}
// -----------------------------------------------------------------------------
2001-03-08 10:12:28 +00:00
void SdTransferable::DragFinished( sal_Int8 nDropAction )
{
if( pSdView )
( (::sd::View*) pSdView )->DragFinished( nDropAction );
2001-03-08 10:12:28 +00:00
}
// -----------------------------------------------------------------------------
2001-01-19 18:09:07 +00:00
void SdTransferable::ObjectReleased()
{
if( this == SD_MOD()->pTransferClip )
SD_MOD()->pTransferClip = NULL;
if( this == SD_MOD()->pTransferDrag )
SD_MOD()->pTransferDrag = NULL;
if( this == SD_MOD()->pTransferSelection )
SD_MOD()->pTransferSelection = NULL;
2001-01-19 18:09:07 +00:00
}
// -----------------------------------------------------------------------------
void SdTransferable::SetObjectDescriptor( const TransferableObjectDescriptor& rObjDesc )
{
delete pObjDesc;
pObjDesc = new TransferableObjectDescriptor( rObjDesc );
}
// -----------------------------------------------------------------------------
void SdTransferable::SetPageBookmarks( const List& rPageBookmarks, BOOL bPersistent )
2001-01-19 18:09:07 +00:00
{
if( pSourceDoc )
{
if( pSdViewIntern )
pSdViewIntern->HideAllPages();
2001-01-19 18:09:07 +00:00
pSdDrawDocument->Clear();
pPageDocShell = NULL;
2001-01-19 18:09:07 +00:00
for( void* p = aPageBookmarks.First(); p; p = aPageBookmarks.Next() )
delete static_cast< String* >( p );
if( bPersistent )
{
pSdDrawDocument->CreateFirstPages();
pSdDrawDocument->InsertBookmarkAsPage( const_cast< List* >( &rPageBookmarks ), NULL, FALSE, TRUE, 1, TRUE, pSourceDoc->GetDocSh(), TRUE, TRUE, FALSE );
}
else
{
pPageDocShell = pSourceDoc->GetDocSh();
for( ULONG i = 0; i < rPageBookmarks.Count(); i++ )
aPageBookmarks.Insert( new String( *static_cast< String* >( rPageBookmarks.GetObject( i ) ) ), LIST_APPEND );
}
if( pSdViewIntern && pSdDrawDocument )
{
SdPage* pPage = pSdDrawDocument->GetSdPage( 0, PK_STANDARD );
if( pPage )
{
( (SdrMarkView*) pSdViewIntern )->MarkAll( (SdrPageView*) pSdViewIntern->ShowPage( pPage, Point() ) );
}
}
2001-01-19 18:09:07 +00:00
// set flags for page transferable; if ( bPageTransferablePersistent == FALSE ),
// don't offer any formats => it's just for internal puposes
bPageTransferable = TRUE;
bPageTransferablePersistent = bPersistent;
2001-01-19 18:09:07 +00: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 ) ) )
{
nRet = (sal_Int64) this;
}
else
nRet = 0;
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;
}
// -----------------------------------------------------------------------------
SdTransferable* SdTransferable::getImplementation( const Reference< XInterface >& rxData ) throw()
{
2001-09-04 13:38:20 +00:00
try
{
Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( rxData, UNO_QUERY );
2001-09-04 13:38:20 +00:00
return( xUnoTunnel.is() ?
( (SdTransferable*)(void*) xUnoTunnel->getSomething( SdTransferable::getUnoTunnelId() ) ) :
NULL );
}
catch( const ::com::sun::star::uno::Exception& )
{
return NULL;
}
}