summaryrefslogtreecommitdiff
path: root/sc/source/ui/app
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-06-13 11:12:50 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-06-19 14:46:56 -0400
commit1d38cb365543924f9c50014e6b2227e77de1d0c9 (patch)
tree1e77d0d2f82330f16c09cda60864824397d132c4 /sc/source/ui/app
parent2538e30ccc2e98de92de5157ca523fdb347eb537 (diff)
fdo#71076, fdo#71767: Preserve number formats when charts are copied.
Change-Id: If5ae8852152012483237e7602e56a0c46ea8748a
Diffstat (limited to 'sc/source/ui/app')
-rw-r--r--sc/source/ui/app/drwtrans.cxx52
-rw-r--r--sc/source/ui/app/lnktrans.cxx3
-rw-r--r--sc/source/ui/app/seltrans.cxx5
-rw-r--r--sc/source/ui/app/transobj.cxx2
4 files changed, 42 insertions, 20 deletions
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;