diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-06-13 11:12:50 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-06-19 14:46:56 -0400 |
commit | 1d38cb365543924f9c50014e6b2227e77de1d0c9 (patch) | |
tree | 1e77d0d2f82330f16c09cda60864824397d132c4 /sc | |
parent | 2538e30ccc2e98de92de5157ca523fdb347eb537 (diff) |
fdo#71076, fdo#71767: Preserve number formats when charts are copied.
Change-Id: If5ae8852152012483237e7602e56a0c46ea8748a
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 | 52 | ||||
-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, 115 insertions, 49 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index e4e956b104bb..3c636eb80098 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> @@ -232,7 +233,10 @@ public: 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 9d032d545263..700086dae7f1 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -40,6 +40,7 @@ #include "calcconfig.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 14bdbe5614d5..3d70c4936549 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 0bc27bb0f464..0f5bc92f5291 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1040,7 +1040,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; @@ -1149,6 +1150,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 4df3001cecf9..fa71aa0d3c66 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -2157,8 +2157,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 b16aaa245d71..4c75534b5970 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -556,7 +556,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; @@ -565,7 +566,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 40d48088b8dc..5288b1d7ac5f 100644 --- a/sc/source/ui/app/drwtrans.cxx +++ b/sc/source/ui/app/drwtrans.cxx @@ -91,7 +91,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 @@ -335,12 +336,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 @@ -372,19 +369,14 @@ void ScDrawTransferObj::AddSupportedFormats() // AddFormat( SOT_FORMATSTR_ID_SVIM ); } -bool ScDrawTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +bool ScDrawTransferObj::GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) { 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 ) ) { @@ -396,7 +388,7 @@ bool ScDrawTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavo pModel->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE ); } - bOK = SetAny( aOleData.GetAny( rFlavor ), rFlavor ); + bOK = SetAny( aOleData.GetAny(rFlavor, rDestDoc), rFlavor ); if( pModel ) pModel->SetSwapGraphicsMode( nOldSwapMode ); @@ -697,6 +689,11 @@ void ScDrawTransferObj::SetDragWasInternal() bDragWasInternal = true; } +OUString ScDrawTransferObj::GetShellID() const +{ + return maShellID; +} + SdrOle2Obj* ScDrawTransferObj::GetSingleObject() { // if single OLE object was copied, get its object @@ -715,6 +712,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 @@ -736,7 +753,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 734d9b718a5c..69a5cbe1d4a8 100644 --- a/sc/source/ui/app/lnktrans.cxx +++ b/sc/source/ui/app/lnktrans.cxx @@ -53,7 +53,8 @@ void ScLinkTransferObj::AddSupportedFormats() } } -bool ScLinkTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +bool ScLinkTransferObj::GetData( + const css::datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ ) { bool bOK = false; if ( !aLinkURL.isEmpty() ) diff --git a/sc/source/ui/app/seltrans.cxx b/sc/source/ui/app/seltrans.cxx index 0140ab587e7f..2008695ecf53 100644 --- a/sc/source/ui/app/seltrans.cxx +++ b/sc/source/ui/app/seltrans.cxx @@ -389,7 +389,8 @@ ScDrawTransferObj* ScSelectionTransferObj::GetDrawData() return pDrawData; } -bool ScSelectionTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +bool ScSelectionTransferObj::GetData( + const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) { bool bOK = false; @@ -416,7 +417,7 @@ bool ScSelectionTransferObj::GetData( const ::com::sun::star::datatransfer::Data 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 a538cd30afed..1d3bb94e2906 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -241,7 +241,7 @@ void ScTransferObj::AddSupportedFormats() AddFormat( SOT_FORMATSTR_ID_EDITENGINE ); } -bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor ) +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 5b71558c655a..efca06767e1c 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() SAL_OVERRIDE; - virtual bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) SAL_OVERRIDE; virtual bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE; virtual void ObjectReleased() SAL_OVERRIDE; @@ -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 2e47e41649e8..033da1b9ebbe 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() SAL_OVERRIDE; - virtual bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) SAL_OVERRIDE; virtual void ObjectReleased() SAL_OVERRIDE; virtual void DragFinished( sal_Int8 nDropAction ) SAL_OVERRIDE; }; diff --git a/sc/source/ui/inc/seltrans.hxx b/sc/source/ui/inc/seltrans.hxx index e7eb1ed92bee..3abfd11a8873 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() SAL_OVERRIDE; - virtual bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) SAL_OVERRIDE; virtual void ObjectReleased() SAL_OVERRIDE; }; diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx index debff33d5b93..6ee2855b7d0c 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() SAL_OVERRIDE; - virtual bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) SAL_OVERRIDE; virtual bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE; virtual void ObjectReleased() SAL_OVERRIDE; diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index e686a0118d5b..6cf382509c19 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -119,8 +119,8 @@ public: ::com::sun::star::datatransfer::XTransferable >& rxTransferable ); void PasteDraw(); - void PasteDraw( const Point& rLogicPos, SdrModel* pModel, - bool bGroup = false, bool bSameDocClipboard = false ); + void PasteDraw( const Point& rLogicPos, SdrModel* pModel, bool bGroup, + const OUString& rSrcShellID, const OUString& rDestShellID ); bool PasteOnDrawObjectLinked( 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 d6730ae3917b..219f79442a1c 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -4433,7 +4433,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(); @@ -4536,8 +4537,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 d82e72558612..be5d96c68218 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -447,8 +447,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() @@ -584,7 +587,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 dc708e0e96b4..9d398119e296 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -117,8 +117,10 @@ 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 ) ) { @@ -209,9 +211,11 @@ 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 ); } @@ -518,7 +522,7 @@ bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId, nObjCount += pPage->GetObjCount(); // count group object only once } - PasteDraw( aPos, pModel.get(), (nObjCount > 1) ); // grouped if more than 1 object + PasteDraw(aPos, pModel.get(), (nObjCount > 1), "A", "B"); // grouped if more than 1 object pModel.reset(); aDragShellRef->DoClose(); bRet = true; @@ -528,8 +532,8 @@ 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 @@ -629,8 +633,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 4cf39cf8a205..8799d59c191d 100644 --- a/sc/source/ui/view/viewfun7.cxx +++ b/sc/source/ui/view/viewfun7.cxx @@ -74,8 +74,10 @@ static void lcl_AdjustInsertPos( ScViewData* pData, Point& rPos, Size& rSize ) } void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, - bool bGroup, bool bSameDocClipboard ) + bool bGroup, const OUString& rSrcShellID, const OUString& rDestShellID ) { + bool bSameDocClipboard = rSrcShellID == rDestShellID; + MakeDrawLayer(); Point aPos( rLogicPos ); @@ -221,7 +223,7 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, if ( !bSameDocClipboard ) GetViewData()->GetDocument()->SetPastingDrawFromOtherDoc( true ); - pScDrawView->Paste( *pModel, aPos, NULL, nOptions ); + pScDrawView->Paste(*pModel, aPos, NULL, nOptions, rSrcShellID, rDestShellID); if ( !bSameDocClipboard ) GetViewData()->GetDocument()->SetPastingDrawFromOtherDoc( false ); |