diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-06-13 11:12:50 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-07-15 23:44:08 +0200 |
commit | 388f2fa9fcabe1b2adaff282fa9509216f3af6de (patch) | |
tree | 7f3f9bf662aaafbdcf8ed80c29cbeed8418042f5 /sc | |
parent | 1c269727b470c03f0ea538cad7e1331fd569a579 (diff) |
fdo#71076, fdo#71767: Preserve number formats when charts are copied.
(cherry picked from commit 1d38cb365543924f9c50014e6b2227e77de1d0c9)
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Conflicts:
xmloff/source/chart/SchXMLExport.cxx
sd/source/ui/view/sdview3.cxx
chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx
chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
chart2/source/controller/main/ChartTransferable.cxx
chart2/source/controller/main/ChartTransferable.hxx
chart2/source/model/main/Axis.cxx
chart2/source/model/template/ChartTypeTemplate.cxx
chart2/source/tools/AxisHelper.cxx
chart2/source/view/main/ChartView.cxx
comphelper/source/container/embeddedobjectcontainer.cxx
dbaccess/source/ui/browser/dbexchange.cxx
dbaccess/source/ui/inc/JoinExchange.hxx
dbaccess/source/ui/inc/TableRowExchange.hxx
dbaccess/source/ui/inc/dbexchange.hxx
dbaccess/source/ui/querydesign/JoinExchange.cxx
dbaccess/source/ui/tabledesign/TableRowExchange.cxx
embeddedobj/source/commonembedding/persistence.cxx
embeddedobj/source/inc/commonembobj.hxx
include/comphelper/embeddedobjectcontainer.hxx
include/svtools/embedtransfer.hxx
include/svtools/stringtransfer.hxx
include/svtools/transfer.hxx
include/svx/dbaexchange.hxx
include/svx/dbaobjectex.hxx
include/svx/fmview.hxx
include/svx/galmisc.hxx
include/svx/svdobj.hxx
include/svx/svdoole2.hxx
include/svx/svdxcgv.hxx
include/svx/view3d.hxx
include/svx/xmlexchg.hxx
include/xmloff/xmlexp.hxx
reportdesign/source/ui/dlg/GroupExchange.cxx
reportdesign/source/ui/dlg/GroupExchange.hxx
reportdesign/source/ui/inc/dlgedclip.hxx
reportdesign/source/ui/report/dlgedclip.cxx
sc/inc/column.hxx
sc/source/ui/app/drwtrans.cxx
sc/source/ui/app/lnktrans.cxx
sc/source/ui/app/seltrans.cxx
sc/source/ui/app/transobj.cxx
sc/source/ui/inc/drwtrans.hxx
sc/source/ui/inc/lnktrans.hxx
sc/source/ui/inc/seltrans.hxx
sc/source/ui/inc/transobj.hxx
sc/source/ui/inc/viewfunc.hxx
sc/source/ui/view/viewfun5.cxx
sc/source/ui/view/viewfun7.cxx
sd/source/ui/app/sdxfer.cxx
sd/source/ui/dlg/sdtreelb.cxx
sd/source/ui/inc/TabControl.hxx
sd/source/ui/inc/View.hxx
sd/source/ui/inc/sdtreelb.hxx
sd/source/ui/inc/sdxfer.hxx
sd/source/ui/view/sdview2.cxx
sd/source/ui/view/tabcontr.cxx
sfx2/source/doc/objxtor.cxx
svtools/source/misc/embedtransfer.cxx
svtools/source/misc/stringtransfer.cxx
svtools/source/misc/transfer.cxx
svtools/source/misc/transfer2.cxx
svx/source/engine3d/view3d.cxx
svx/source/fmcomp/dbaexchange.cxx
svx/source/fmcomp/dbaobjectex.cxx
svx/source/fmcomp/xmlexchg.cxx
svx/source/form/fmexch.cxx
svx/source/form/fmview.cxx
svx/source/gallery2/galmisc.cxx
svx/source/inc/fmexch.hxx
svx/source/svdraw/svdoole2.cxx
svx/source/svdraw/svdxcgv.cxx
svx/source/tbxctrls/colrctrl.cxx
sw/source/core/uibase/dochdl/swdtflvr.cxx
sw/source/core/uibase/inc/swdtflvr.hxx
sw/source/core/undo/unins.cxx
Change-Id: If5ae8852152012483237e7602e56a0c46ea8748a
(cherry picked from commit 4ee53683df4beda260aff26d2c9e56fe643f45bb)
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/column.hxx | 6 | ||||
-rw-r--r-- | sc/inc/document.hxx | 1 | ||||
-rw-r--r-- | sc/inc/table.hxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 14 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/app/drwtrans.cxx | 54 | ||||
-rw-r--r-- | sc/source/ui/app/lnktrans.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/app/seltrans.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/drwtrans.hxx | 7 | ||||
-rw-r--r-- | sc/source/ui/inc/lnktrans.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/seltrans.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/transobj.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/viewfunc.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun5.cxx | 22 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun7.cxx | 6 |
19 files changed, 116 insertions, 50 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index bfc7a54598de..1cac0446f5f2 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -27,6 +27,7 @@ #include "types.hxx" #include "mtvelements.hxx" #include "formula/types.hxx" +#include <svl/zforlist.hxx> #include <set> #include <vector> @@ -226,7 +227,10 @@ public: SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag, bool bBroadcast = true ); void CopyToClip( sc::CopyToClipContext& rCxt, SCROW nRow1, SCROW nRow2, ScColumn& rColumn ) const; - void CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol); + + void CopyStaticToDocument( + SCROW nRow1, SCROW nRow2, const SvNumberFormatterMergeMap& rMap, ScColumn& rDestCol ); + void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol ); bool InitBlockPosition( sc::ColumnBlockPosition& rBlockPos ); bool InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 339bbb00c047..a2aea94fa79a 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -39,6 +39,7 @@ #include "calcmacros.hxx" #include <tools/fract.hxx> #include <tools/gen.hxx> +#include <svl/zforlist.hxx> #include <memory> #include <map> diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index ba7745d21555..fe8adb6a6446 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -412,7 +412,11 @@ public: void DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal_uInt16 nDelFlag); void CopyToClip( sc::CopyToClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable ); void CopyToClip( sc::CopyToClipContext& rCxt, const ScRangeList& rRanges, ScTable* pTable ); - void CopyStaticToDocument(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab); + + void CopyStaticToDocument( + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const SvNumberFormatterMergeMap& rMap, + ScTable* pDestTab ); + void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, SCROW nDestRow, ScTable& rDestTab ); bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol ); diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 5e5cf430f0b2..2d0a01872303 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1061,7 +1061,8 @@ void ScColumn::CopyToClip( rColumn.CellStorageModified(); } -void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol) +void ScColumn::CopyStaticToDocument( + SCROW nRow1, SCROW nRow2, const SvNumberFormatterMergeMap& rMap, ScColumn& rDestCol ) { if (nRow1 > nRow2) return; @@ -1170,6 +1171,17 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol break; } + // Dont' forget to copy the number formats over. Charts may reference them. + for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow) + { + sal_uInt32 nNumFmt = GetNumberFormat(nRow); + SvNumberFormatterMergeMap::const_iterator itNum = rMap.find(nNumFmt); + if (itNum != rMap.end()) + nNumFmt = itNum->second; + + rDestCol.SetNumberFormat(nRow, nNumFmt); + } + rDestCol.CellStorageModified(); } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 2ec7d6838b35..b739df779a3d 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -2148,8 +2148,12 @@ void ScDocument::CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab, if (!pSrcTab || !pDestTab) return; + pDestDoc->GetFormatTable()->MergeFormatter(*GetFormatTable()); + SvNumberFormatterMergeMap aMap = pDestDoc->GetFormatTable()->ConvertMergeTableToMap(); + pSrcTab->CopyStaticToDocument( - rSrcRange.aStart.Col(), rSrcRange.aStart.Row(), rSrcRange.aEnd.Col(), rSrcRange.aEnd.Row(), pDestTab); + rSrcRange.aStart.Col(), rSrcRange.aStart.Row(), rSrcRange.aEnd.Col(), rSrcRange.aEnd.Row(), + aMap, pDestTab); } void ScDocument::CopyCellToDocument( const ScAddress& rSrcPos, const ScAddress& rDestPos, ScDocument& rDestDoc ) diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index b858a1c7404a..3f0d190be7bd 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -554,7 +554,8 @@ void ScTable::CopyToClip( } } -void ScTable::CopyStaticToDocument(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab) +void ScTable::CopyStaticToDocument( + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const SvNumberFormatterMergeMap& rMap, ScTable* pDestTab ) { if (nCol1 > nCol2) return; @@ -563,7 +564,7 @@ void ScTable::CopyStaticToDocument(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW { ScColumn& rSrcCol = aCol[i]; ScColumn& rDestCol = pDestTab->aCol[i]; - rSrcCol.CopyStaticToDocument(nRow1, nRow2, rDestCol); + rSrcCol.CopyStaticToDocument(nRow1, nRow2, rMap, rDestCol); } } diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx index 63a81c04ef13..9cb5a22fe784 100644 --- a/sc/source/ui/app/drwtrans.cxx +++ b/sc/source/ui/app/drwtrans.cxx @@ -95,7 +95,8 @@ ScDrawTransferObj::ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContain pDragSourceView( NULL ), nDragSourceFlags( 0 ), bDragWasInternal( false ), - nSourceDocID( 0 ) + nSourceDocID( 0 ), + maShellID(SfxObjectShell::CreateShellID(pContainerShell)) { // // check what kind of objects are contained @@ -339,12 +340,8 @@ void ScDrawTransferObj::AddSupportedFormats() AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); AddFormat( SOT_FORMAT_GDIMETAFILE ); - if ( !aOleData.GetTransferable().is() ) - { - SdrOle2Obj* pObj = GetSingleObject(); - if ( pObj && pObj->GetObjRef().is() ) - aOleData = TransferableDataHelper( new SvEmbedTransferHelper( pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() ) ) ; - } + CreateOLEData(); + if ( aOleData.GetTransferable().is() ) { // get format list from object snapshot @@ -376,19 +373,15 @@ void ScDrawTransferObj::AddSupportedFormats() // AddFormat( SOT_FORMATSTR_ID_SVIM ); } -sal_Bool ScDrawTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +sal_Bool ScDrawTransferObj::GetData( + const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) { sal_Bool bOK = false; sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor ); if ( bOleObj && nFormat != SOT_FORMAT_GDIMETAFILE ) { - if ( !aOleData.GetTransferable().is() ) - { - SdrOle2Obj* pObj = GetSingleObject(); - if ( pObj && pObj->GetObjRef().is() ) - aOleData = TransferableDataHelper( new SvEmbedTransferHelper( pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() ) ) ; - } + CreateOLEData(); if( aOleData.GetTransferable().is() && aOleData.HasFormat( rFlavor ) ) { @@ -400,7 +393,7 @@ sal_Bool ScDrawTransferObj::GetData( const ::com::sun::star::datatransfer::DataF pModel->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE ); } - bOK = SetAny( aOleData.GetAny( rFlavor ), rFlavor ); + bOK = SetAny( aOleData.GetAny(rFlavor, rDestDoc), rFlavor ); if( pModel ) pModel->SetSwapGraphicsMode( nOldSwapMode ); @@ -701,6 +694,11 @@ void ScDrawTransferObj::SetDragWasInternal() bDragWasInternal = sal_True; } +OUString ScDrawTransferObj::GetShellID() const +{ + return maShellID; +} + SdrOle2Obj* ScDrawTransferObj::GetSingleObject() { // if single OLE object was copied, get its object @@ -719,7 +717,26 @@ SdrOle2Obj* ScDrawTransferObj::GetSingleObject() return NULL; } -// +void ScDrawTransferObj::CreateOLEData() +{ + if (aOleData.GetTransferable().is()) + // Already created. + return; + + SdrOle2Obj* pObj = GetSingleObject(); + if (!pObj || !pObj->GetObjRef().is()) + // No OLE object present. + return; + + SvEmbedTransferHelper* pEmbedTransfer = + new SvEmbedTransferHelper( + pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect()); + + pEmbedTransfer->SetParentShellID(maShellID); + + aOleData = TransferableDataHelper(pEmbedTransfer); +} + // initialize aDocShellRef with a live document from the ClipDoc // @@ -740,7 +757,10 @@ void ScDrawTransferObj::InitDocShell() // SdrExchangeView aDestView( pDestModel ); SdrView aDestView( pDestModel ); aDestView.ShowSdrPage(aDestView.GetModel()->GetPage(0)); - aDestView.Paste( *pModel, Point( aSrcSize.Width()/2, aSrcSize.Height()/2 ) ); + aDestView.Paste( + *pModel, + Point(aSrcSize.Width()/2, aSrcSize.Height()/2), + NULL, 0, OUString(), OUString()); // put objects to right layer (see ScViewFunc::PasteDataFormat for SOT_FORMATSTR_ID_DRAWING) diff --git a/sc/source/ui/app/lnktrans.cxx b/sc/source/ui/app/lnktrans.cxx index 5733b14523c0..d830e42c3e6e 100644 --- a/sc/source/ui/app/lnktrans.cxx +++ b/sc/source/ui/app/lnktrans.cxx @@ -55,7 +55,8 @@ void ScLinkTransferObj::AddSupportedFormats() } } -sal_Bool ScLinkTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +sal_Bool ScLinkTransferObj::GetData( + const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ ) { sal_Bool bOK = false; if ( !aLinkURL.isEmpty() ) diff --git a/sc/source/ui/app/seltrans.cxx b/sc/source/ui/app/seltrans.cxx index 679a21e9e0c3..9bedf0cca06b 100644 --- a/sc/source/ui/app/seltrans.cxx +++ b/sc/source/ui/app/seltrans.cxx @@ -385,7 +385,8 @@ ScDrawTransferObj* ScSelectionTransferObj::GetDrawData() return pDrawData; } -sal_Bool ScSelectionTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +sal_Bool ScSelectionTransferObj::GetData( + const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) { sal_Bool bOK = false; @@ -412,7 +413,7 @@ sal_Bool ScSelectionTransferObj::GetData( const ::com::sun::star::datatransfer:: if ( xSource.is() ) { TransferableDataHelper aHelper( xSource ); - uno::Any aAny = aHelper.GetAny( rFlavor ); + uno::Any aAny = aHelper.GetAny(rFlavor, rDestDoc); bOK = SetAny( aAny, rFlavor ); } diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index ec6bb4a211f1..ba1aec8524c4 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -246,7 +246,7 @@ void ScTransferObj::AddSupportedFormats() AddFormat( SOT_FORMATSTR_ID_EDITENGINE ); } -sal_Bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor ) +sal_Bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ ) { sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor ); bool bOK = false; diff --git a/sc/source/ui/inc/drwtrans.hxx b/sc/source/ui/inc/drwtrans.hxx index 81b7b9060e77..7f4a2c6e045f 100644 --- a/sc/source/ui/inc/drwtrans.hxx +++ b/sc/source/ui/inc/drwtrans.hxx @@ -63,17 +63,20 @@ private: ScRangeListVector m_aProtectedChartRangesVector; + OUString maShellID; void InitDocShell(); SdrOle2Obj* GetSingleObject(); + void CreateOLEData(); + public: ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContainerShell, const TransferableObjectDescriptor& rDesc ); virtual ~ScDrawTransferObj(); virtual void AddSupportedFormats(); - virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); + virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); virtual void ObjectReleased(); @@ -87,6 +90,8 @@ public: void SetDragSourceFlags( sal_uInt16 nFlags ); void SetDragWasInternal(); + OUString GetShellID() const; + SdrView* GetDragSourceView() { return pDragSourceView; } sal_uInt16 GetDragSourceFlags() const { return nDragSourceFlags; } diff --git a/sc/source/ui/inc/lnktrans.hxx b/sc/source/ui/inc/lnktrans.hxx index d9ccdebd06aa..1f13e8a72bf0 100644 --- a/sc/source/ui/inc/lnktrans.hxx +++ b/sc/source/ui/inc/lnktrans.hxx @@ -36,7 +36,7 @@ public: void SetLinkURL( const OUString& rURL, const OUString& rText ); virtual void AddSupportedFormats(); - virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); + virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); virtual void ObjectReleased(); virtual void DragFinished( sal_Int8 nDropAction ); }; diff --git a/sc/source/ui/inc/seltrans.hxx b/sc/source/ui/inc/seltrans.hxx index ba4e184a5086..ec2b6ac52382 100644 --- a/sc/source/ui/inc/seltrans.hxx +++ b/sc/source/ui/inc/seltrans.hxx @@ -65,7 +65,7 @@ public: ScDrawTransferObj* GetDrawData(); virtual void AddSupportedFormats(); - virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); + virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); virtual void ObjectReleased(); }; diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx index 9bd0d12afa1d..5ae33d069eff 100644 --- a/sc/source/ui/inc/transobj.hxx +++ b/sc/source/ui/inc/transobj.hxx @@ -72,7 +72,7 @@ public: virtual ~ScTransferObj(); virtual void AddSupportedFormats(); - virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); + virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); virtual void ObjectReleased(); diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index 0e28bb5fd992..c59888467e52 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -115,8 +115,8 @@ public: ::com::sun::star::datatransfer::XTransferable >& rxTransferable ); void PasteDraw(); - void PasteDraw( const Point& rLogicPos, SdrModel* pModel, - sal_Bool bGroup = false, sal_Bool bSameDocClipboard = false ); + void PasteDraw( const Point& rLogicPos, SdrModel* pModel, bool bGroup, + const OUString& rSrcShellID, const OUString& rDestShellID ); sal_Bool PasteOnDrawObject( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable, diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 1fa83c563e6e..cd38c6d24783 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -4412,7 +4412,8 @@ sal_Int8 ScGridWindow::ExecuteDrop( const ExecuteDropEvent& rEvt ) bPasteIsMove = bIsMove; - pViewData->GetView()->PasteDraw( aLogicPos, rData.pDrawTransfer->GetModel() ); + pViewData->GetView()->PasteDraw( + aLogicPos, rData.pDrawTransfer->GetModel(), false, "A", "B"); if (bPasteIsMove) rData.pDrawTransfer->SetDragWasInternal(); @@ -4517,8 +4518,9 @@ void ScGridWindow::PasteSelection( const Point& rPosPixel ) // bSameDocClipboard argument for PasteDraw is needed // because only DragData is checked directly inside PasteDraw - pViewData->GetView()->PasteDraw( aLogicPos, pDrawTransfer->GetModel(), false, - pDrawTransfer->GetSourceDocID() == pViewData->GetDocument()->GetDocumentID() ); + pViewData->GetView()->PasteDraw( + aLogicPos, pDrawTransfer->GetModel(), false, + pDrawTransfer->GetShellID(), SfxObjectShell::CreateShellID(pViewData->GetDocShell())); } } } diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index f8454d3570c5..5cb568d5298e 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -449,8 +449,11 @@ void ScViewFunc::PasteDraw() pViewData->GetActivePart() ) ); ScDrawTransferObj* pDrawClip = ScDrawTransferObj::GetOwnClipboard( pWin ); if (pDrawClip) - PasteDraw( aPos, pDrawClip->GetModel(), false, - pDrawClip->GetSourceDocID() == pViewData->GetDocument()->GetDocumentID() ); + { + OUString aSrcShellID = pDrawClip->GetShellID(); + OUString aDestShellID = SfxObjectShell::CreateShellID(pViewData->GetDocShell()); + PasteDraw(aPos, pDrawClip->GetModel(), false, aSrcShellID, aDestShellID); + } } void ScViewFunc::PasteFromSystem() @@ -586,7 +589,9 @@ void ScViewFunc::PasteFromTransferable( const uno::Reference<datatransfer::XTran SCROW nPosY = pViewData->GetCurY(); Window* pWin = GetActiveWin(); Point aPos = pWin->PixelToLogic( pViewData->GetScrPos( nPosX, nPosY, pViewData->GetActivePart() ) ); - PasteDraw( aPos, pDrawClip->GetModel(), false, pDrawClip->GetSourceDocID() == pViewData->GetDocument()->GetDocumentID() ); + PasteDraw( + aPos, pDrawClip->GetModel(), false, + pDrawClip->GetShellID(), SfxObjectShell::CreateShellID(pViewData->GetDocShell())); } else { diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx index 9319bd6d5126..d5c32980f2a2 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -120,8 +120,10 @@ sal_Bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId, uno::Reference < io::XInputStream > xStm; TransferableObjectDescriptor aObjDesc; - if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) && - aDataHelper.GetInputStream( nFormatId, xStm ) ) + if (aDataHelper.GetTransferableObjectDescriptor(SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc)) + xStm = aDataHelper.GetInputStream(nFormatId, OUString()); + + if (xStm.is()) { if ( aObjDesc.maClassName == SvGlobalName( SO3_SC_CLASSID_60 ) ) { @@ -205,9 +207,11 @@ sal_Bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId, { OUString aName; uno::Reference < embed::XEmbeddedObject > xObj; + xStm = aDataHelper.GetInputStream(SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, OUString()); + if (!xStm.is()) + aDataHelper.GetInputStream(SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, OUString()); - if ( aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, xStm ) - || aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, xStm ) ) + if (xStm.is()) { xObj = GetViewData()->GetDocShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName ); } @@ -515,7 +519,7 @@ sal_Bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId, nObjCount += pPage->GetObjCount(); // count group object only once } - PasteDraw( aPos, pModel, (nObjCount > 1) ); // grouped if more than 1 object + PasteDraw(aPos, pModel, (nObjCount > 1), "A", "B"); // grouped if more than 1 object delete pModel; aDragShellRef->DoClose(); bRet = sal_True; @@ -525,8 +529,8 @@ sal_Bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId, { // do excel import into a clipboard document //TODO/MBA: testing - uno::Reference < io::XInputStream > xStm; - if( aDataHelper.GetInputStream( nFormatId, xStm ) ) + uno::Reference <io::XInputStream> xStm = aDataHelper.GetInputStream(nFormatId, OUString()); + if (xStm.is()) { ScDocument* pInsDoc = new ScDocument( SCDOCMODE_CLIP ); SCTAB nSrcTab = 0; // Biff5 in clipboard: always sheet 0 @@ -626,8 +630,8 @@ bool ScViewFunc::PasteLink( const uno::Reference<datatransfer::XTransferable>& r // 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 ) ) + uno::Sequence<sal_Int8> aSequence = aDataHelper.GetSequence(SOT_FORMATSTR_ID_LINK, OUString()); + if (!aSequence.getLength()) { OSL_FAIL("DDE Data not found."); return false; diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx index 1904bcec5c77..7506f029cc2f 100644 --- a/sc/source/ui/view/viewfun7.cxx +++ b/sc/source/ui/view/viewfun7.cxx @@ -73,8 +73,10 @@ static void lcl_AdjustInsertPos( ScViewData* pData, Point& rPos, Size& rSize ) } void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, - sal_Bool bGroup, sal_Bool bSameDocClipboard ) + bool bGroup, const OUString& rSrcShellID, const OUString& rDestShellID ) { + bool bSameDocClipboard = rSrcShellID == rDestShellID; + MakeDrawLayer(); Point aPos( rLogicPos ); @@ -219,7 +221,7 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, if ( !bSameDocClipboard ) GetViewData()->GetDocument()->SetPastingDrawFromOtherDoc( sal_True ); - pScDrawView->Paste( *pModel, aPos, NULL, nOptions ); + pScDrawView->Paste(*pModel, aPos, NULL, nOptions, rSrcShellID, rDestShellID); if ( !bSameDocClipboard ) GetViewData()->GetDocument()->SetPastingDrawFromOtherDoc( false ); |