summaryrefslogtreecommitdiff
path: root/svtools
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 /svtools
parent2538e30ccc2e98de92de5157ca523fdb347eb537 (diff)
fdo#71076, fdo#71767: Preserve number formats when charts are copied.
Change-Id: If5ae8852152012483237e7602e56a0c46ea8748a
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/contnr/treelistbox.cxx5
-rw-r--r--svtools/source/dialogs/insdlg.cxx2
-rw-r--r--svtools/source/misc/embedtransfer.cxx13
-rw-r--r--svtools/source/misc/stringtransfer.cxx2
-rw-r--r--svtools/source/misc/transfer.cxx110
-rw-r--r--svtools/source/misc/transfer2.cxx4
6 files changed, 83 insertions, 53 deletions
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 269259198dc4..f27e41990591 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -1243,9 +1243,8 @@ sal_Int8 SvTreeListBox::ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox
TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
if( aData.HasFormat( SOT_FORMATSTR_ID_TREELISTBOX ))
{
- ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
- if( aData.GetSequence( SOT_FORMATSTR_ID_TREELISTBOX, aSeq ) &&
- sizeof(SvLBoxDDInfo) == aSeq.getLength() )
+ css::uno::Sequence<sal_Int8> aSeq = aData.GetSequence(SOT_FORMATSTR_ID_TREELISTBOX, OUString());
+ if (sizeof(SvLBoxDDInfo) == aSeq.getLength())
{
memcpy( &aDDInfo, aSeq.getConstArray(), sizeof(SvLBoxDDInfo) );
nRet = rEvt.mnAction;
diff --git a/svtools/source/dialogs/insdlg.cxx b/svtools/source/dialogs/insdlg.cxx
index 767ab0e57c58..c7d9aa09719d 100644
--- a/svtools/source/dialogs/insdlg.cxx
+++ b/svtools/source/dialogs/insdlg.cxx
@@ -293,7 +293,7 @@ bool SvPasteObjectHelper::GetEmbeddedName(const TransferableDataHelper& rData, O
uno::Any aAny;
if( rData.HasFormat( aFlavor ) &&
- ( aAny = rData.GetAny( aFlavor ) ).hasValue() )
+ ( aAny = rData.GetAny(aFlavor, OUString()) ).hasValue() )
{
uno::Sequence< sal_Int8 > anySequence;
aAny >>= anySequence;
diff --git a/svtools/source/misc/embedtransfer.cxx b/svtools/source/misc/embedtransfer.cxx
index aa2375ba5317..7792f84032b0 100644
--- a/svtools/source/misc/embedtransfer.cxx
+++ b/svtools/source/misc/embedtransfer.cxx
@@ -65,6 +65,10 @@ SvEmbedTransferHelper::~SvEmbedTransferHelper()
}
}
+void SvEmbedTransferHelper::SetParentShellID( const OUString& rShellID )
+{
+ maParentShellID = rShellID;
+}
void SvEmbedTransferHelper::AddSupportedFormats()
@@ -76,7 +80,7 @@ void SvEmbedTransferHelper::AddSupportedFormats()
-bool SvEmbedTransferHelper::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+bool SvEmbedTransferHelper::GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc )
{
bool bRet = false;
@@ -109,7 +113,12 @@ bool SvEmbedTransferHelper::GetData( const ::com::sun::star::datatransfer::DataF
SvStream* pStream = NULL;
bool bDeleteStream = false;
uno::Sequence < beans::PropertyValue > aEmpty;
- xPers->storeToEntry( xStg, aName, aEmpty, aEmpty );
+ uno::Sequence<beans::PropertyValue> aObjArgs(2);
+ aObjArgs[0].Name = "SourceShellID";
+ aObjArgs[0].Value <<= maParentShellID;
+ aObjArgs[1].Name = "DestinationShellID";
+ aObjArgs[1].Value <<= rDestDoc;
+ xPers->storeToEntry(xStg, aName, aEmpty, aObjArgs);
if ( xStg->isStreamElement( aName ) )
{
uno::Reference < io::XStream > xStm = xStg->cloneStreamElement( aName );
diff --git a/svtools/source/misc/stringtransfer.cxx b/svtools/source/misc/stringtransfer.cxx
index 44349ae3e2e3..f6f614e8095b 100644
--- a/svtools/source/misc/stringtransfer.cxx
+++ b/svtools/source/misc/stringtransfer.cxx
@@ -44,7 +44,7 @@ namespace svt
}
- bool OStringTransferable::GetData( const DataFlavor& _rFlavor )
+ bool OStringTransferable::GetData( const DataFlavor& _rFlavor, const OUString& /*rDestDoc*/ )
{
sal_uInt32 nFormat = SotExchange::GetFormat( _rFlavor );
if (SOT_FORMAT_STRING == nFormat)
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index c210cc78efa2..5a916b6ad4de 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -45,6 +45,7 @@
#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
#include <com/sun/star/datatransfer/MimeContentTypeFactory.hpp>
#include <com/sun/star/datatransfer/XMimeContentType.hpp>
+#include <com/sun/star/datatransfer/XTransferable2.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
@@ -299,8 +300,14 @@ TransferableHelper::~TransferableHelper()
}
+Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor )
+ throw (UnsupportedFlavorException, IOException, RuntimeException, std::exception)
+{
+ return getTransferData2(rFlavor, OUString());
+}
-Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) throw( UnsupportedFlavorException, IOException, RuntimeException, std::exception )
+Any SAL_CALL TransferableHelper::getTransferData2( const DataFlavor& rFlavor, const OUString& rDestDoc )
+ throw (UnsupportedFlavorException, IOException, RuntimeException, std::exception)
{
if( !maAny.hasValue() || !mpFormats->size() || ( maLastFormat != rFlavor.MimeType ) )
{
@@ -322,21 +329,21 @@ Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) th
if( SotExchange::GetFormatDataFlavor( FORMAT_STRING, aSubstFlavor ) &&
TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) )
{
- GetData( aSubstFlavor );
+ GetData(aSubstFlavor, rDestDoc);
bDone = maAny.hasValue();
}
else if(SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_BMP, aSubstFlavor )
&& TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor )
&& SotExchange::GetFormatDataFlavor(FORMAT_BITMAP, aSubstFlavor))
{
- GetData( aSubstFlavor );
+ GetData(aSubstFlavor, rDestDoc);
bDone = true;
}
else if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_EMF, aSubstFlavor ) &&
TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) &&
SotExchange::GetFormatDataFlavor( FORMAT_GDIMETAFILE, aSubstFlavor ) )
{
- GetData( aSubstFlavor );
+ GetData(aSubstFlavor, rDestDoc);
if( maAny.hasValue() )
{
@@ -366,7 +373,7 @@ Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) th
TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) &&
SotExchange::GetFormatDataFlavor( FORMAT_GDIMETAFILE, aSubstFlavor ) )
{
- GetData( aSubstFlavor );
+ GetData(aSubstFlavor, rDestDoc);
if( maAny.hasValue() )
{
@@ -399,7 +406,7 @@ Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) th
// if any is not yet filled, use standard format
if( !maAny.hasValue() )
- GetData( rFlavor );
+ GetData(rFlavor, rDestDoc);
#ifdef DEBUG
if( maAny.hasValue() && ::com::sun::star::uno::TypeClass_STRING != maAny.getValueType().getTypeClass() )
@@ -1537,13 +1544,13 @@ Reference< XTransferable > TransferableDataHelper::GetXTransferable() const
-Any TransferableDataHelper::GetAny( SotFormatStringId nFormat ) const
+Any TransferableDataHelper::GetAny( SotFormatStringId nFormat, const OUString& rDestDoc ) const
{
Any aReturn;
DataFlavor aFlavor;
if ( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) )
- aReturn = GetAny( aFlavor );
+ aReturn = GetAny(aFlavor, rDestDoc);
return aReturn;
}
@@ -1551,7 +1558,7 @@ Any TransferableDataHelper::GetAny( SotFormatStringId nFormat ) const
-Any TransferableDataHelper::GetAny( const DataFlavor& rFlavor ) const
+Any TransferableDataHelper::GetAny( const DataFlavor& rFlavor, const OUString& rDestDoc ) const
{
::osl::MutexGuard aGuard( mpImpl->maMutex );
Any aRet;
@@ -1562,13 +1569,20 @@ Any TransferableDataHelper::GetAny( const DataFlavor& rFlavor ) const
{
const SotFormatStringId nRequestFormat = SotExchange::GetFormat( rFlavor );
+ Reference<css::datatransfer::XTransferable2> xTransfer2(mxTransfer, UNO_QUERY);
+
if( nRequestFormat )
{
// try to get alien format first
for (DataFlavorExVector::const_iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() ); aIter != aEnd ; ++aIter)
{
if( ( nRequestFormat == (*aIter).mnSotId ) && !rFlavor.MimeType.equalsIgnoreAsciiCase( (*aIter).MimeType ) )
- aRet = mxTransfer->getTransferData( *aIter );
+ {
+ if (xTransfer2.is())
+ aRet = xTransfer2->getTransferData2(*aIter, rDestDoc);
+ else
+ aRet = mxTransfer->getTransferData(*aIter);
+ }
if( aRet.hasValue() )
break;
@@ -1576,7 +1590,12 @@ Any TransferableDataHelper::GetAny( const DataFlavor& rFlavor ) const
}
if( !aRet.hasValue() )
- aRet = mxTransfer->getTransferData( rFlavor );
+ {
+ if (xTransfer2.is())
+ aRet = xTransfer2->getTransferData2(rFlavor, rDestDoc);
+ else
+ aRet = mxTransfer->getTransferData(rFlavor);
+ }
}
}
catch( const ::com::sun::star::uno::Exception& )
@@ -1598,7 +1617,7 @@ bool TransferableDataHelper::GetString( SotFormatStringId nFormat, OUString& rSt
bool TransferableDataHelper::GetString( const DataFlavor& rFlavor, OUString& rStr )
{
- Any aAny( GetAny( rFlavor ) );
+ Any aAny = GetAny(rFlavor, OUString());
bool bRet = false;
if( aAny.hasValue() )
@@ -1969,9 +1988,9 @@ bool TransferableDataHelper::GetINetBookmark( const ::com::sun::star::datatransf
case( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ):
{
- Sequence< sal_Int8 > aSeq;
+ Sequence<sal_Int8> aSeq = GetSequence(rFlavor, OUString());
- if( GetSequence( rFlavor, aSeq ) && ( 2048 == aSeq.getLength() ) )
+ if (2048 == aSeq.getLength())
{
const sal_Char* p1 = reinterpret_cast< const sal_Char* >( aSeq.getConstArray() );
const sal_Char* p2 = reinterpret_cast< const sal_Char* >( aSeq.getConstArray() ) + 1024;
@@ -1985,9 +2004,9 @@ bool TransferableDataHelper::GetINetBookmark( const ::com::sun::star::datatransf
#ifdef WNT
case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
{
- Sequence< sal_Int8 > aSeq;
+ Sequence<sal_Int8> aSeq = GetSequence(rFlavor, OUString());
- if( GetSequence( rFlavor, aSeq ) && aSeq.getLength() )
+ if (aSeq.getLength())
{
FILEGROUPDESCRIPTOR* pFDesc = (FILEGROUPDESCRIPTOR*) aSeq.getConstArray();
@@ -2007,14 +2026,14 @@ bool TransferableDataHelper::GetINetBookmark( const ::com::sun::star::datatransf
aSeq.realloc( 0 );
delete pStream;
+ pStream = NULL;
- if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_FILECONTENT, aFileContentFlavor ) &&
- GetSequence( aFileContentFlavor, aSeq ) && aSeq.getLength() )
+ if (SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_FILECONTENT, aFileContentFlavor))
{
- pStream = new SvMemoryStream( (sal_Char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_STD_READ );
+ aSeq = GetSequence(aFileContentFlavor, OUString());
+ if (aSeq.getLength())
+ pStream = new SvMemoryStream( (sal_Char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_STD_READ );
}
- else
- pStream = NULL;
}
if( pStream )
@@ -2119,22 +2138,27 @@ bool TransferableDataHelper::GetFileList(
-bool TransferableDataHelper::GetSequence( SotFormatStringId nFormat, Sequence< sal_Int8 >& rSeq )
+Sequence<sal_Int8> TransferableDataHelper::GetSequence( SotFormatStringId nFormat, const OUString& rDestDoc )
{
DataFlavor aFlavor;
- return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetSequence( aFlavor, rSeq ) );
-}
-
+ if (!SotExchange::GetFormatDataFlavor(nFormat, aFlavor))
+ return Sequence<sal_Int8>();
+ return GetSequence(aFlavor, rDestDoc);
+}
-bool TransferableDataHelper::GetSequence( const DataFlavor& rFlavor, Sequence< sal_Int8 >& rSeq )
+Sequence<sal_Int8> TransferableDataHelper::GetSequence( const DataFlavor& rFlavor, const OUString& rDestDoc )
{
#ifdef DEBUG
fprintf( stderr, "TransferableDataHelper requests sequence of data\n" );
#endif
- const Any aAny( GetAny( rFlavor ) );
- return( aAny.hasValue() && ( aAny >>= rSeq ) );
+ const Any aAny = GetAny(rFlavor, rDestDoc);
+ Sequence<sal_Int8> aSeq;
+ if (aAny.hasValue())
+ aAny >>= aSeq;
+
+ return aSeq;
}
@@ -2149,40 +2173,38 @@ bool TransferableDataHelper::GetSotStorageStream( SotFormatStringId nFormat, Sot
bool TransferableDataHelper::GetSotStorageStream( const DataFlavor& rFlavor, SotStorageStreamRef& rxStream )
{
- Sequence< sal_Int8 > aSeq;
- bool bRet = GetSequence( rFlavor, aSeq );
+ Sequence<sal_Int8> aSeq = GetSequence(rFlavor, OUString());
- if( bRet )
+ if (aSeq.getLength())
{
rxStream = new SotStorageStream( "" );
rxStream->Write( aSeq.getConstArray(), aSeq.getLength() );
rxStream->Seek( 0 );
}
- return bRet;
+ return aSeq.getLength();
}
-bool TransferableDataHelper::GetInputStream( SotFormatStringId nFormat, Reference < XInputStream >& rxStream )
+Reference<XInputStream> TransferableDataHelper::GetInputStream( SotFormatStringId nFormat, const OUString& rDestDoc )
{
DataFlavor aFlavor;
- return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetInputStream( aFlavor, rxStream ) );
-}
-
+ if (!SotExchange::GetFormatDataFlavor(nFormat, aFlavor))
+ return Reference<XInputStream>();
+ return GetInputStream(aFlavor, rDestDoc);
+}
-bool TransferableDataHelper::GetInputStream( const DataFlavor& rFlavor, Reference < XInputStream >& rxStream )
+Reference<XInputStream> TransferableDataHelper::GetInputStream( const DataFlavor& rFlavor, const OUString& rDestDoc )
{
- Sequence< sal_Int8 > aSeq;
- bool bRet = GetSequence( rFlavor, aSeq );
+ Sequence<sal_Int8> aSeq = GetSequence(rFlavor, rDestDoc);
- if( bRet )
- rxStream = new ::comphelper::SequenceInputStream( aSeq );
+ if (!aSeq.getLength())
+ return Reference<XInputStream>();
- return bRet;
+ Reference<XInputStream> xStream(new comphelper::SequenceInputStream(aSeq));
+ return xStream;
}
-
-
void TransferableDataHelper::Rebind( const Reference< XTransferable >& _rxNewContent )
{
mxTransfer = _rxNewContent;
diff --git a/svtools/source/misc/transfer2.cxx b/svtools/source/misc/transfer2.cxx
index 541571fdea97..c79ddbf8bfc9 100644
--- a/svtools/source/misc/transfer2.cxx
+++ b/svtools/source/misc/transfer2.cxx
@@ -415,8 +415,8 @@ void TransferDataContainer::AddSupportedFormats()
-bool TransferDataContainer::GetData( const
- ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+bool TransferDataContainer::GetData(
+ const css::datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ )
{
TDataCntnrEntryList::iterator aIter( pImpl->aFmtList.begin() ),
aEnd( pImpl->aFmtList.end() );