2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: viewfun5.cxx,v $
|
|
|
|
*
|
2005-03-15 10:44:11 +00:00
|
|
|
* $Revision: 1.35 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-03-15 10:44:11 +00:00
|
|
|
* last change: $Author: obo $ $Date: 2005-03-15 11:44:11 $
|
2000-09-18 16:07: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): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2005-03-15 10:44:11 +00:00
|
|
|
#ifndef _COM_SUN_STAR_EMBED_XEMBEDOBJECTCLIPBOARDCREATOR_HPP_
|
|
|
|
#include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifdef PCH
|
|
|
|
#include "ui_pch.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#pragma hdrstop
|
|
|
|
|
2001-10-04 10:35:12 +00:00
|
|
|
#ifndef SVX_UNOMODEL_HXX
|
|
|
|
#include <svx/unomodel.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _UTL_STREAM_WRAPPER_HXX_
|
|
|
|
#include <unotools/streamwrap.hxx>
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <svx/dbexch.hrc>
|
|
|
|
#include <svx/fmmodel.hxx>
|
|
|
|
#include <svx/svdetc.hxx>
|
|
|
|
#include <svx/svditer.hxx>
|
|
|
|
#include <svx/svdobj.hxx>
|
|
|
|
#include <svx/svdogrp.hxx>
|
|
|
|
#include <svx/svdouno.hxx>
|
|
|
|
#include <svx/svdpage.hxx>
|
|
|
|
#include <sfx2/dispatch.hxx>
|
|
|
|
#include <sfx2/docfile.hxx>
|
2004-10-04 19:28:03 +00:00
|
|
|
#include <sot/clsids.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sot/formats.hxx>
|
2000-09-29 09:21:10 +00:00
|
|
|
#include <svtools/pathoptions.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svtools/ptitem.hxx>
|
|
|
|
#include <svtools/stritem.hxx>
|
2001-02-14 18:30:56 +00:00
|
|
|
#include <svtools/transfer.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <vcl/graph.hxx>
|
|
|
|
|
2004-10-04 19:28:03 +00:00
|
|
|
#include <comphelper/storagehelper.hxx>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sot/formats.hxx>
|
|
|
|
#define SOT_FORMATSTR_ID_STARCALC_CURRENT SOT_FORMATSTR_ID_STARCALC_50
|
|
|
|
|
|
|
|
#include "viewfunc.hxx"
|
|
|
|
#include "docsh.hxx"
|
|
|
|
#include "drawview.hxx"
|
|
|
|
#include "impex.hxx"
|
|
|
|
#include "dbfunc.hxx"
|
|
|
|
#include "dbcolect.hxx"
|
|
|
|
#include "sc.hrc"
|
|
|
|
#include "filter.hxx"
|
|
|
|
#include "scextopt.hxx"
|
|
|
|
#include "tabvwsh.hxx" // wegen GetViewFrame
|
|
|
|
#include "compiler.hxx"
|
|
|
|
|
|
|
|
#ifndef _SFXVIEWFRM_HXX //autogen
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#endif
|
2001-08-09 08:47:41 +00:00
|
|
|
#ifndef _SVX_DBAEXCHANGE_HXX_
|
|
|
|
#include <svx/dbaexchange.hxx>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-02-14 18:30:56 +00:00
|
|
|
using namespace com::sun::star;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-02-14 18:30:56 +00:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScViewFunc::PasteDataFormat( ULONG nFormatId,
|
|
|
|
const uno::Reference<datatransfer::XTransferable>& rxTransferable,
|
2004-06-04 11:10:24 +00:00
|
|
|
SCCOL nPosX, SCROW nPosY, Point* pLogicPos, BOOL bLink, BOOL bAllowDialogs )
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
2001-10-25 16:46:44 +00:00
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
pDoc->SetPastingDrawFromOtherDoc( TRUE );
|
|
|
|
|
2001-02-14 18:30:56 +00:00
|
|
|
Point aPos; // inserting position (1/100 mm)
|
|
|
|
if (pLogicPos)
|
|
|
|
aPos = *pLogicPos;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// inserting position isn't needed for text formats
|
|
|
|
BOOL bIsTextFormat = ( ScImportExport::IsFormatSupported( nFormatId ) ||
|
|
|
|
nFormatId == FORMAT_RTF );
|
|
|
|
if ( !bIsTextFormat )
|
|
|
|
{
|
|
|
|
// Window MapMode isn't drawing MapMode if DrawingLayer hasn't been created yet
|
|
|
|
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
2004-06-04 11:10:24 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2001-02-14 18:30:56 +00:00
|
|
|
long nXT = 0;
|
2004-06-04 11:10:24 +00:00
|
|
|
for (SCCOL i=0; i<nPosX; i++)
|
2001-02-14 18:30:56 +00:00
|
|
|
nXT += pDoc->GetColWidth(i,nTab);
|
2004-02-03 12:07:19 +00:00
|
|
|
if (pDoc->IsNegativePage(nTab))
|
|
|
|
nXT = -nXT;
|
2004-08-20 08:19:11 +00:00
|
|
|
ULONG nYT = pDoc->FastGetRowHeight( 0, nPosY-1, nTab);
|
2001-02-14 18:30:56 +00:00
|
|
|
aPos = Point( (long)(nXT * HMM_PER_TWIPS), (long)(nYT * HMM_PER_TWIPS) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TransferableDataHelper aDataHelper( rxTransferable );
|
|
|
|
BOOL bRet = FALSE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// handle individual formats
|
|
|
|
//
|
|
|
|
|
|
|
|
if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE ||
|
|
|
|
nFormatId == SOT_FORMATSTR_ID_LINK_SOURCE ||
|
|
|
|
nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ||
|
|
|
|
nFormatId == SOT_FORMATSTR_ID_LINK_SOURCE_OLE )
|
|
|
|
{
|
2004-10-04 19:28:03 +00:00
|
|
|
uno::Reference < io::XInputStream > xStm;
|
|
|
|
TransferableObjectDescriptor aObjDesc;
|
2001-02-14 18:30:56 +00:00
|
|
|
|
|
|
|
if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) &&
|
2004-10-04 19:28:03 +00:00
|
|
|
aDataHelper.GetInputStream( nFormatId, xStm ) )
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
2004-10-04 19:28:03 +00:00
|
|
|
if ( aObjDesc.maClassName == SvGlobalName( SO3_SC_CLASSID_60 ) )
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
2005-01-11 12:22:09 +00:00
|
|
|
uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromInputStream( xStm );
|
|
|
|
|
|
|
|
// mba: BaseURL doesn't make sense for clipboard
|
|
|
|
SfxMedium aMedium( xStore, String() );
|
|
|
|
|
2004-10-04 19:28:03 +00:00
|
|
|
// TODO/LATER: is it a problem that we don't support binary formats here?
|
2001-02-14 18:30:56 +00:00
|
|
|
ScDocShellRef xDocShRef = new ScDocShell(SFX_CREATE_MODE_EMBEDDED);
|
2005-01-11 12:22:09 +00:00
|
|
|
if (xDocShRef->DoLoad(&aMedium))
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
|
|
|
ScDocument* pSrcDoc = xDocShRef->GetDocument();
|
2004-06-04 11:10:24 +00:00
|
|
|
SCTAB nSrcTab = pSrcDoc->GetVisibleTab();
|
2001-02-14 18:30:56 +00:00
|
|
|
if (!pSrcDoc->HasTable(nSrcTab))
|
|
|
|
nSrcTab = 0;
|
|
|
|
|
|
|
|
ScMarkData aSrcMark;
|
|
|
|
aSrcMark.SelectOneTable( nSrcTab ); // for CopyToClip
|
|
|
|
ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
|
|
|
|
|
2004-06-04 11:10:24 +00:00
|
|
|
SCCOL nFirstCol, nLastCol;
|
|
|
|
SCROW nFirstRow, nLastRow;
|
2001-03-23 18:26:39 +00:00
|
|
|
if ( pSrcDoc->GetDataStart( nSrcTab, nFirstCol, nFirstRow ) )
|
|
|
|
pSrcDoc->GetCellArea( nSrcTab, nLastCol, nLastRow );
|
|
|
|
else
|
2004-06-04 11:10:24 +00:00
|
|
|
{
|
|
|
|
nFirstCol = nLastCol = 0;
|
|
|
|
nFirstRow = nLastRow = 0;
|
|
|
|
}
|
2001-02-14 18:30:56 +00:00
|
|
|
pSrcDoc->CopyToClip( nFirstCol, nFirstRow, nLastCol, nLastRow,
|
|
|
|
FALSE, pClipDoc, FALSE, &aSrcMark );
|
|
|
|
ScGlobal::SetClipDocName( xDocShRef->GetTitle( SFX_TITLE_FULLNAME ) );
|
|
|
|
|
|
|
|
SetCursor( nPosX, nPosY );
|
|
|
|
Unmark();
|
2002-07-16 14:17:55 +00:00
|
|
|
PasteFromClip( IDF_ALL, pClipDoc,
|
|
|
|
PASTE_NOFUNC, FALSE, FALSE, FALSE, INS_NONE, IDF_NONE,
|
|
|
|
bAllowDialogs );
|
2001-02-14 18:30:56 +00:00
|
|
|
delete pClipDoc;
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
2005-01-11 12:22:09 +00:00
|
|
|
|
2004-10-04 19:28:03 +00:00
|
|
|
xDocShRef->DoClose();
|
2001-02-14 18:30:56 +00:00
|
|
|
xDocShRef.Clear();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-04 19:28:03 +00:00
|
|
|
::rtl::OUString aName;
|
|
|
|
uno::Reference < embed::XEmbeddedObject > xObj = GetViewData()->GetViewShell()->GetObjectShell()->
|
|
|
|
GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
|
|
|
|
if ( xObj.is() )
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
2004-10-04 19:28:03 +00:00
|
|
|
PasteObject( aPos, xObj, &aObjDesc.maSize );
|
2001-02-14 18:30:56 +00:00
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DBG_ERROR("Error in CreateAndLoad");
|
|
|
|
}
|
|
|
|
}
|
2001-08-16 07:44:22 +00:00
|
|
|
else
|
|
|
|
{
|
2004-10-04 19:28:03 +00:00
|
|
|
uno::Reference < io::XInputStream > xStm;
|
|
|
|
TransferableObjectDescriptor aObjDesc;
|
|
|
|
|
2005-03-15 10:44:11 +00:00
|
|
|
if ( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE, aObjDesc ) )
|
2004-10-04 19:28:03 +00:00
|
|
|
{
|
|
|
|
::rtl::OUString aName;
|
2005-03-15 10:44:11 +00:00
|
|
|
uno::Reference < embed::XEmbeddedObject > xObj;
|
|
|
|
|
|
|
|
if ( aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, xStm )
|
|
|
|
|| aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, xStm ) )
|
|
|
|
{
|
|
|
|
xObj = GetViewData()->GetDocShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
|
|
|
|
uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator(
|
|
|
|
::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(
|
|
|
|
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator") ) ),
|
|
|
|
uno::UNO_QUERY_THROW );
|
|
|
|
|
|
|
|
embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
|
|
|
|
xTmpStor,
|
|
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "DummyName" ) ),
|
|
|
|
uno::Sequence< beans::PropertyValue >() );
|
|
|
|
|
|
|
|
// TODO/LATER: in future InsertedObjectInfo will be used to get container related information
|
|
|
|
// for example whether the object should be an iconified one
|
|
|
|
xObj = aInfo.Object;
|
|
|
|
if ( xObj.is() )
|
|
|
|
GetViewData()->GetDocShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
|
2004-10-04 19:28:03 +00:00
|
|
|
if ( xObj.is() )
|
2001-08-16 07:44:22 +00:00
|
|
|
{
|
2004-10-04 19:28:03 +00:00
|
|
|
PasteObject( aPos, xObj, &aObjDesc.maSize );
|
2001-08-16 07:44:22 +00:00
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
else
|
2004-10-04 19:28:03 +00:00
|
|
|
DBG_ERROR("Error creating external OLE object");
|
2001-08-16 07:44:22 +00:00
|
|
|
}
|
2004-10-04 19:28:03 +00:00
|
|
|
//TODO/LATER: if format is not available, create picture
|
2001-08-16 07:44:22 +00:00
|
|
|
}
|
2001-02-14 18:30:56 +00:00
|
|
|
}
|
|
|
|
else if ( nFormatId == SOT_FORMATSTR_ID_LINK ) // LINK is also in ScImportExport
|
|
|
|
{
|
|
|
|
bRet = PasteDDE( rxTransferable );
|
|
|
|
}
|
|
|
|
else if ( ScImportExport::IsFormatSupported( nFormatId ) || nFormatId == SOT_FORMAT_RTF )
|
|
|
|
{
|
|
|
|
if ( nFormatId == SOT_FORMAT_RTF && aDataHelper.HasFormat( SOT_FORMATSTR_ID_EDITENGINE ) )
|
|
|
|
{
|
2001-03-30 18:14:44 +00:00
|
|
|
// use EditView's PasteSpecial / Drop
|
|
|
|
PasteRTF( nPosX, nPosY, rxTransferable );
|
|
|
|
bRet = TRUE;
|
2001-02-14 18:30:56 +00:00
|
|
|
}
|
2001-03-30 18:14:44 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ScAddress aPos( nPosX, nPosY, GetViewData()->GetTabNo() );
|
|
|
|
ScImportExport aObj( GetViewData()->GetDocument(), aPos );
|
2001-02-14 18:30:56 +00:00
|
|
|
|
2001-09-07 18:37:38 +00:00
|
|
|
::rtl::OUString aStr;
|
2001-03-30 18:14:44 +00:00
|
|
|
SotStorageStreamRef xStream;
|
|
|
|
if ( aDataHelper.GetSotStorageStream( nFormatId, xStream ) && xStream.Is() )
|
2005-01-11 12:22:09 +00:00
|
|
|
// mba: clipboard always must contain absolute URLs (could be from alien source)
|
|
|
|
bRet = aObj.ImportStream( *xStream, String(), nFormatId );
|
2001-03-30 18:14:44 +00:00
|
|
|
else if ( aDataHelper.GetString( nFormatId, aStr ) )
|
|
|
|
bRet = aObj.ImportString( aStr, nFormatId );
|
2001-02-14 18:30:56 +00:00
|
|
|
|
2001-03-30 18:14:44 +00:00
|
|
|
InvalidateAttribs();
|
|
|
|
GetViewData()->UpdateInputHandler();
|
|
|
|
}
|
2001-02-14 18:30:56 +00:00
|
|
|
}
|
|
|
|
else if (nFormatId == SOT_FORMATSTR_ID_SBA_DATAEXCHANGE)
|
|
|
|
{
|
|
|
|
// import of database data into table
|
|
|
|
|
|
|
|
String sDataDesc;
|
|
|
|
if ( aDataHelper.GetString( nFormatId, sDataDesc ) )
|
|
|
|
{
|
|
|
|
SfxStringItem aDataDesc(SID_SBA_IMPORT, sDataDesc);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-02-14 18:30:56 +00:00
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2004-06-04 11:10:24 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2001-02-14 18:30:56 +00:00
|
|
|
|
|
|
|
ClickCursor(nPosX, nPosY, FALSE); // set cursor position
|
|
|
|
|
|
|
|
// Creation of database area "Import1" isn't here, but in the DocShell
|
|
|
|
// slot execute, so it can be added to the undo action
|
|
|
|
|
|
|
|
ScDBData* pDBData = pDocSh->GetDBData( ScRange(nPosX,nPosY,nTab), SC_DB_OLD, FALSE );
|
|
|
|
String sTarget;
|
|
|
|
if (pDBData)
|
|
|
|
sTarget = pDBData->GetName();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ScAddress aPos( nPosX,nPosY,nTab );
|
|
|
|
aPos.Format( sTarget, SCA_ABS_3D, pDoc );
|
|
|
|
}
|
|
|
|
SfxStringItem aTarget(FN_PARAM_1, sTarget);
|
|
|
|
|
|
|
|
BOOL bAreaIsNew = !pDBData;
|
|
|
|
SfxBoolItem aAreaNew(FN_PARAM_2, bAreaIsNew);
|
|
|
|
|
2004-08-02 15:33:35 +00:00
|
|
|
::svx::ODataAccessDescriptor aDesc;
|
|
|
|
DataFlavorExVector& rVector = aDataHelper.GetDataFlavorExVector();
|
|
|
|
::std::auto_ptr<SfxUsrAnyItem> pCursorItem;
|
|
|
|
if ( ::svx::ODataAccessObjectTransferable::canExtractObjectDescriptor(rVector) )
|
|
|
|
{
|
|
|
|
aDesc = ::svx::ODataAccessObjectTransferable::extractObjectDescriptor(aDataHelper);
|
|
|
|
if ( aDesc.has(::svx::daCursor) )
|
|
|
|
pCursorItem.reset(new SfxUsrAnyItem(FN_PARAM_3, aDesc[::svx::daCursor]));
|
|
|
|
}
|
|
|
|
|
2001-02-14 18:30:56 +00:00
|
|
|
// asynchronous, to avoid doing the whole import in drop handler
|
|
|
|
SfxDispatcher& rDisp = GetViewData()->GetDispatcher();
|
|
|
|
rDisp.Execute(SID_SBA_IMPORT, SFX_CALLMODE_ASYNCHRON,
|
2004-10-22 07:02:03 +00:00
|
|
|
&aDataDesc, &aTarget, &aAreaNew, pCursorItem.get(), (void*)0 );
|
2001-02-14 18:30:56 +00:00
|
|
|
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nFormatId == SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE)
|
|
|
|
{
|
|
|
|
// insert database field control
|
|
|
|
|
2002-05-23 16:26:41 +00:00
|
|
|
if ( ::svx::OColumnTransferable::canExtractColumnDescriptor( aDataHelper.GetDataFlavorExVector(), CTF_COLUMN_DESCRIPTOR | CTF_CONTROL_EXCHANGE ) )
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
|
|
|
MakeDrawLayer();
|
|
|
|
ScDrawView* pDrawView = GetScDrawView();
|
2001-08-09 08:47:41 +00:00
|
|
|
SdrObject* pObj = pDrawView->CreateFieldControl( ::svx::OColumnTransferable::extractColumnDescriptor( aDataHelper ) );
|
2001-02-14 18:30:56 +00:00
|
|
|
if (pObj)
|
|
|
|
{
|
|
|
|
Point aInsPos = aPos;
|
|
|
|
Rectangle aRect(pObj->GetLogicRect());
|
|
|
|
aInsPos.X() -= aRect.GetSize().Width() / 2;
|
|
|
|
aInsPos.Y() -= aRect.GetSize().Height() / 2;
|
|
|
|
if ( aInsPos.X() < 0 ) aInsPos.X() = 0;
|
|
|
|
if ( aInsPos.Y() < 0 ) aInsPos.Y() = 0;
|
|
|
|
aRect.SetPos(aInsPos);
|
|
|
|
pObj->SetLogicRect(aRect);
|
|
|
|
|
|
|
|
if ( pObj->ISA(SdrUnoObj) )
|
|
|
|
pObj->NbcSetLayer(SC_LAYER_CONTROLS);
|
|
|
|
else
|
|
|
|
pObj->NbcSetLayer(SC_LAYER_FRONT);
|
|
|
|
if (pObj->ISA(SdrObjGroup))
|
|
|
|
{
|
|
|
|
SdrObjListIter aIter( *pObj, IM_DEEPWITHGROUPS );
|
|
|
|
SdrObject* pSubObj = aIter.Next();
|
|
|
|
while (pSubObj)
|
|
|
|
{
|
|
|
|
if ( pSubObj->ISA(SdrUnoObj) )
|
|
|
|
pSubObj->NbcSetLayer(SC_LAYER_CONTROLS);
|
|
|
|
else
|
|
|
|
pSubObj->NbcSetLayer(SC_LAYER_FRONT);
|
|
|
|
pSubObj = aIter.Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pDrawView->InsertObjectSafe(pObj, *pDrawView->GetPageViewPvNum(0));
|
|
|
|
|
|
|
|
GetViewData()->GetViewShell()->SetDrawShell( TRUE );
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nFormatId == SOT_FORMAT_BITMAP)
|
|
|
|
{
|
|
|
|
Bitmap aBmp;
|
|
|
|
if( aDataHelper.GetBitmap( FORMAT_BITMAP, aBmp ) )
|
|
|
|
bRet = PasteBitmap( aPos, aBmp );
|
|
|
|
}
|
|
|
|
else if (nFormatId == SOT_FORMAT_GDIMETAFILE)
|
|
|
|
{
|
|
|
|
GDIMetaFile aMtf;
|
|
|
|
if( aDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE, aMtf ) )
|
|
|
|
bRet = PasteMetaFile( aPos, aMtf );
|
|
|
|
}
|
|
|
|
else if (nFormatId == SOT_FORMATSTR_ID_SVXB)
|
|
|
|
{
|
|
|
|
SotStorageStreamRef xStm;
|
|
|
|
if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm ) )
|
|
|
|
{
|
|
|
|
Graphic aGraphic;
|
|
|
|
*xStm >> aGraphic;
|
|
|
|
bRet = PasteGraphic( aPos, aGraphic, EMPTY_STRING, EMPTY_STRING );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( nFormatId == SOT_FORMATSTR_ID_DRAWING )
|
|
|
|
{
|
|
|
|
SotStorageStreamRef xStm;
|
|
|
|
if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStm ) )
|
|
|
|
{
|
|
|
|
MakeDrawLayer(); // before loading model, so 3D factory has been created
|
|
|
|
|
|
|
|
SvtPathOptions aPathOpt;
|
|
|
|
String aPath = aPathOpt.GetPalettePath();
|
|
|
|
FmFormModel* pModel = new FmFormModel(
|
|
|
|
aPath, NULL, GetViewData()->GetDocShell() );
|
|
|
|
pModel->GetItemPool().FreezeIdRanges();
|
|
|
|
xStm->Seek(0);
|
|
|
|
|
2001-10-04 10:35:12 +00:00
|
|
|
com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
|
|
|
|
SvxDrawingLayerImport( pModel, xInputStream );
|
2001-02-14 18:30:56 +00:00
|
|
|
|
2004-11-03 08:22:11 +00:00
|
|
|
//BFS04 pModel->SetStreamingSdrModel(FALSE);
|
2001-02-14 18:30:56 +00:00
|
|
|
|
|
|
|
// set everything to right layer:
|
|
|
|
ULONG nObjCount = 0;
|
|
|
|
USHORT nPages = pModel->GetPageCount();
|
|
|
|
for (USHORT i=0; i<nPages; i++)
|
|
|
|
{
|
|
|
|
SdrPage* pPage = pModel->GetPage(i);
|
|
|
|
SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
|
|
|
|
SdrObject* pObject = aIter.Next();
|
|
|
|
while (pObject)
|
|
|
|
{
|
|
|
|
if ( pObject->ISA(SdrUnoObj) )
|
|
|
|
pObject->NbcSetLayer(SC_LAYER_CONTROLS);
|
|
|
|
else
|
|
|
|
pObject->NbcSetLayer(SC_LAYER_FRONT);
|
|
|
|
pObject = aIter.Next();
|
|
|
|
}
|
2002-12-04 09:08:52 +00:00
|
|
|
|
|
|
|
nObjCount += pPage->GetObjCount(); // #105888# count group object only once
|
2001-02-14 18:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PasteDraw( aPos, pModel, (nObjCount > 1) ); // grouped if more than 1 object
|
|
|
|
delete pModel;
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2002-11-04 14:57:14 +00:00
|
|
|
else if ( (nFormatId == SOT_FORMATSTR_ID_BIFF_5) || (nFormatId == SOT_FORMATSTR_ID_BIFF_8) )
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
|
|
|
// do excel import into a clipboard document
|
2004-10-04 19:28:03 +00:00
|
|
|
//TODO/MBA: testing
|
|
|
|
uno::Reference < io::XInputStream > xStm;
|
|
|
|
if( aDataHelper.GetInputStream( nFormatId, xStm ) )
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
|
|
|
#if 0
|
2004-10-04 19:28:03 +00:00
|
|
|
SotStorage aDest( "d:\\test.xls" ); // to see the file
|
2001-02-14 18:30:56 +00:00
|
|
|
pStor->CopyTo( &aDest );
|
|
|
|
#endif
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
ScDocument* pInsDoc = new ScDocument( SCDOCMODE_CLIP );
|
2004-06-04 11:10:24 +00:00
|
|
|
SCTAB nSrcTab = 0; // Biff5 in clipboard: always sheet 0
|
2001-02-14 18:30:56 +00:00
|
|
|
pInsDoc->ResetClip( pDoc, nSrcTab );
|
|
|
|
|
2004-10-04 19:28:03 +00:00
|
|
|
SfxMedium aMed;
|
|
|
|
aMed.GetItemSet()->Put( SfxUsrAnyItem( SID_INPUTSTREAM, uno::makeAny( xStm ) ) );
|
2001-02-14 18:30:56 +00:00
|
|
|
FltError eErr = ScImportExcel( aMed, pInsDoc, EIF_AUTO );
|
|
|
|
if ( eErr == eERR_OK )
|
|
|
|
{
|
|
|
|
ScRange aSource;
|
|
|
|
const ScExtDocOptions* pExtOpt = pInsDoc->GetExtDocOptions();
|
2005-02-21 12:55:45 +00:00
|
|
|
const ScExtTabSettings* pTabSett = pExtOpt ? pExtOpt->GetTabSettings( nSrcTab ) : 0;
|
|
|
|
if( pTabSett && (pTabSett->maUsedArea.aStart.Col() >= 0) )
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
2005-02-21 12:55:45 +00:00
|
|
|
aSource = pTabSett->maUsedArea;
|
|
|
|
// ensure correct sheet indexes
|
|
|
|
aSource.aStart.SetTab( nSrcTab );
|
|
|
|
aSource.aEnd.SetTab( nSrcTab );
|
2001-11-07 11:49:49 +00:00
|
|
|
// #92240# don't use selection area: if cursor is moved in Excel after Copy, selection
|
|
|
|
// represents the new cursor position and not the copied area
|
2001-02-14 18:30:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERROR("no dimension"); //! possible?
|
2004-06-04 11:10:24 +00:00
|
|
|
SCCOL nFirstCol, nLastCol;
|
|
|
|
SCROW nFirstRow, nLastRow;
|
2001-03-23 18:26:39 +00:00
|
|
|
if ( pInsDoc->GetDataStart( nSrcTab, nFirstCol, nFirstRow ) )
|
|
|
|
pInsDoc->GetCellArea( nSrcTab, nLastCol, nLastRow );
|
|
|
|
else
|
2004-06-04 11:10:24 +00:00
|
|
|
{
|
|
|
|
nFirstCol = nLastCol = 0;
|
|
|
|
nFirstRow = nLastRow = 0;
|
|
|
|
}
|
2001-02-14 18:30:56 +00:00
|
|
|
aSource = ScRange( nFirstCol, nFirstRow, nSrcTab,
|
|
|
|
nLastCol, nLastRow, nSrcTab );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pLogicPos )
|
|
|
|
{
|
|
|
|
// position specified (Drag&Drop) - change selection
|
|
|
|
MoveCursorAbs( nPosX, nPosY, SC_FOLLOW_NONE, FALSE, FALSE );
|
|
|
|
Unmark();
|
|
|
|
}
|
|
|
|
|
|
|
|
pInsDoc->SetClipArea( aSource );
|
2002-07-16 14:17:55 +00:00
|
|
|
PasteFromClip( IDF_ALL, pInsDoc,
|
|
|
|
PASTE_NOFUNC, FALSE, FALSE, FALSE, INS_NONE, IDF_NONE,
|
|
|
|
bAllowDialogs );
|
2001-02-14 18:30:56 +00:00
|
|
|
delete pInsDoc;
|
|
|
|
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( nFormatId == SOT_FORMAT_FILE )
|
|
|
|
{
|
2001-06-29 19:28:09 +00:00
|
|
|
//! multiple files?
|
|
|
|
//USHORT nCount = DragServer::GetItemCount();
|
|
|
|
//if (nCount == 0) // normal handling (not D&D)
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
|
|
|
String aFile;
|
|
|
|
if ( aDataHelper.GetString( nFormatId, aFile ) )
|
2001-10-26 17:16:21 +00:00
|
|
|
bRet = PasteFile( aPos, aFile, bLink );
|
2001-02-14 18:30:56 +00:00
|
|
|
}
|
2001-06-29 19:28:09 +00:00
|
|
|
#if 0
|
2001-02-14 18:30:56 +00:00
|
|
|
else // use multiple items from drag server
|
|
|
|
{
|
|
|
|
for( USHORT i = 0; i < nCount ; i++ )
|
|
|
|
{
|
|
|
|
String aFile = DragServer::PasteFile( i );
|
|
|
|
SfxStringItem aNameItem( FID_INSERT_FILE, aFile );
|
|
|
|
SfxPointItem aPosItem( FN_PARAM_1, aPos );
|
|
|
|
SfxDispatcher* pDisp =
|
|
|
|
GetViewData()->GetViewShell()->GetViewFrame()->GetDispatcher();
|
|
|
|
if (pDisp)
|
|
|
|
pDisp->Execute( FID_INSERT_FILE, SFX_CALLMODE_ASYNCHRON,
|
|
|
|
&aNameItem, &aPosItem, (void*)0 );
|
|
|
|
|
|
|
|
aPos.X() += 400;
|
|
|
|
aPos.Y() += 400;
|
|
|
|
}
|
|
|
|
bRet = TRUE;
|
|
|
|
}
|
2001-06-29 19:28:09 +00:00
|
|
|
#endif
|
2001-02-14 18:30:56 +00:00
|
|
|
}
|
2001-03-30 18:14:44 +00:00
|
|
|
else if ( nFormatId == SOT_FORMATSTR_ID_SOLK ||
|
|
|
|
nFormatId == SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ||
|
|
|
|
nFormatId == SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ||
|
|
|
|
nFormatId == SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR )
|
|
|
|
{
|
|
|
|
bRet = PasteBookmark( nFormatId, rxTransferable, nPosX, nPosY );
|
|
|
|
}
|
2001-02-14 18:30:56 +00:00
|
|
|
|
2001-10-25 16:46:44 +00:00
|
|
|
pDoc->SetPastingDrawFromOtherDoc( FALSE );
|
|
|
|
|
2001-02-14 18:30:56 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2004-09-08 14:56:30 +00:00
|
|
|
ByteString lcl_GetSubString( sal_Char* pData, long nStart, long nDataSize )
|
2001-02-14 18:30:56 +00:00
|
|
|
{
|
|
|
|
if ( nDataSize <= nStart /* || pData[nDataSize] != 0 */ )
|
|
|
|
{
|
|
|
|
DBG_ERROR("DDE Data: invalid data");
|
2004-09-08 14:56:30 +00:00
|
|
|
return ByteString();
|
2001-02-14 18:30:56 +00:00
|
|
|
}
|
2004-09-08 14:56:30 +00:00
|
|
|
return ByteString( pData + nStart );
|
2001-02-14 18:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL ScViewFunc::PasteDDE( const uno::Reference<datatransfer::XTransferable>& rxTransferable )
|
|
|
|
{
|
|
|
|
TransferableDataHelper aDataHelper( rxTransferable );
|
|
|
|
|
2001-10-19 11:11:59 +00:00
|
|
|
// get link data from transferable before string data,
|
|
|
|
// so the source knows it will be used for a link
|
|
|
|
|
|
|
|
uno::Sequence<sal_Int8> aSequence;
|
|
|
|
if ( !aDataHelper.GetSequence( SOT_FORMATSTR_ID_LINK, aSequence ) )
|
|
|
|
{
|
|
|
|
DBG_ERROR("DDE Data not found.");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-02-14 18:30:56 +00:00
|
|
|
// check size (only if string is available in transferable)
|
|
|
|
|
|
|
|
USHORT nCols = 1;
|
|
|
|
USHORT nRows = 1;
|
|
|
|
if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
|
|
|
|
{
|
|
|
|
String aDataStr;
|
|
|
|
if ( aDataHelper.GetString( SOT_FORMAT_STRING, aDataStr ) )
|
|
|
|
{
|
|
|
|
// get size from string the same way as in ScDdeLink::DataChanged
|
|
|
|
|
|
|
|
aDataStr.ConvertLineEnd(LINEEND_LF);
|
|
|
|
xub_StrLen nLen = aDataStr.Len();
|
|
|
|
if (nLen && aDataStr.GetChar(nLen-1) == '\n')
|
|
|
|
aDataStr.Erase(nLen-1);
|
|
|
|
|
|
|
|
if (aDataStr.Len())
|
|
|
|
{
|
|
|
|
nRows = aDataStr.GetTokenCount( '\n' );
|
|
|
|
String aLine = aDataStr.GetToken( 0, '\n' );
|
|
|
|
if (aLine.Len())
|
|
|
|
nCols = aLine.GetTokenCount( '\t' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// create formula
|
|
|
|
|
|
|
|
long nSeqLen = aSequence.getLength();
|
|
|
|
sal_Char* pData = (sal_Char*)aSequence.getConstArray();
|
|
|
|
|
|
|
|
rtl_TextEncoding eSysEnc = gsl_getSystemTextEncoding();
|
|
|
|
|
2004-09-08 14:56:30 +00:00
|
|
|
ByteString aByteApp = lcl_GetSubString( pData, 0, nSeqLen );
|
|
|
|
ByteString aByteTopic = lcl_GetSubString( pData, aByteApp.Len() + 1, nSeqLen );
|
|
|
|
ByteString aByteItem = lcl_GetSubString( pData, aByteApp.Len() + aByteTopic.Len() + 2, nSeqLen );
|
|
|
|
|
|
|
|
String aApp( aByteApp, eSysEnc );
|
|
|
|
String aTopic( aByteTopic, eSysEnc );
|
|
|
|
String aItem( aByteItem, eSysEnc );
|
2001-02-14 18:30:56 +00:00
|
|
|
|
|
|
|
if (!ScCompiler::pSymbolTableNative)
|
|
|
|
{
|
|
|
|
DBG_ERROR("ScCompiler::pSymbolTableNative missing");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! use tokens
|
|
|
|
String aFormula( '=' );
|
|
|
|
aFormula += ScCompiler::pSymbolTableNative[SC_OPCODE_DDE];
|
|
|
|
aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("(\""));
|
|
|
|
aFormula += aApp;
|
|
|
|
aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("\";\""));
|
|
|
|
aFormula += aTopic;
|
|
|
|
aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("\";\""));
|
|
|
|
aFormula += aItem;
|
|
|
|
aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM("\")"));
|
|
|
|
|
|
|
|
// mark range
|
|
|
|
|
2004-06-04 11:10:24 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
|
|
|
SCCOL nCurX = GetViewData()->GetCurX();
|
|
|
|
SCROW nCurY = GetViewData()->GetCurY();
|
2001-02-14 18:30:56 +00:00
|
|
|
HideAllCursors();
|
|
|
|
DoneBlockMode();
|
|
|
|
InitBlockMode( nCurX, nCurY, nTab );
|
2004-06-04 11:10:24 +00:00
|
|
|
MarkCursor( nCurX+static_cast<SCCOL>(nCols)-1, nCurY+static_cast<SCROW>(nRows)-1, nTab );
|
2001-02-14 18:30:56 +00:00
|
|
|
ShowAllCursors();
|
|
|
|
|
|
|
|
// enter formula
|
|
|
|
|
|
|
|
EnterMatrix( aFormula );
|
|
|
|
CursorPosChanged();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|