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 /svtools | |
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 'svtools')
-rw-r--r-- | svtools/source/contnr/treelistbox.cxx | 5 | ||||
-rw-r--r-- | svtools/source/dialogs/insdlg.cxx | 2 | ||||
-rw-r--r-- | svtools/source/misc/embedtransfer.cxx | 15 | ||||
-rw-r--r-- | svtools/source/misc/stringtransfer.cxx | 3 | ||||
-rw-r--r-- | svtools/source/misc/transfer.cxx | 121 | ||||
-rw-r--r-- | svtools/source/misc/transfer2.cxx | 4 |
6 files changed, 88 insertions, 62 deletions
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index ec2960850fe6..7729ae28541f 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -1301,9 +1301,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 a9e441a6b319..4f33480a01b1 100644 --- a/svtools/source/dialogs/insdlg.cxx +++ b/svtools/source/dialogs/insdlg.cxx @@ -294,7 +294,7 @@ sal_Bool SvPasteObjectHelper::GetEmbeddedName(const TransferableDataHelper& rDat 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 7ccbfe5c274c..e7a572e053c7 100644 --- a/svtools/source/misc/embedtransfer.cxx +++ b/svtools/source/misc/embedtransfer.cxx @@ -65,7 +65,10 @@ SvEmbedTransferHelper::~SvEmbedTransferHelper() } } -// ----------------------------------------------------------------------------- +void SvEmbedTransferHelper::SetParentShellID( const OUString& rShellID ) +{ + maParentShellID = rShellID; +} void SvEmbedTransferHelper::AddSupportedFormats() { @@ -76,7 +79,8 @@ void SvEmbedTransferHelper::AddSupportedFormats() // ----------------------------------------------------------------------------- -sal_Bool SvEmbedTransferHelper::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +sal_Bool SvEmbedTransferHelper::GetData( + const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) { sal_Bool bRet = sal_False; @@ -109,7 +113,12 @@ sal_Bool SvEmbedTransferHelper::GetData( const ::com::sun::star::datatransfer::D SvStream* pStream = NULL; sal_Bool bDeleteStream = sal_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 579a9998d2e7..687b1a9225df 100644 --- a/svtools/source/misc/stringtransfer.cxx +++ b/svtools/source/misc/stringtransfer.cxx @@ -43,8 +43,7 @@ namespace svt AddFormat(SOT_FORMAT_STRING); } - //-------------------------------------------------------------------- - sal_Bool OStringTransferable::GetData( const DataFlavor& _rFlavor ) + sal_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 73537b636cb8..dd5e54c4163a 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> @@ -338,6 +339,12 @@ TransferableHelper::~TransferableHelper() Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) throw( UnsupportedFlavorException, IOException, RuntimeException ) { + return getTransferData2(rFlavor, OUString()); +} + +Any SAL_CALL TransferableHelper::getTransferData2( const DataFlavor& rFlavor, const OUString& rDestDoc ) + throw (UnsupportedFlavorException, IOException, RuntimeException) +{ if( !maAny.hasValue() || !mpFormats->size() || ( maLastFormat != rFlavor.MimeType ) ) { const SolarMutexGuard aGuard; @@ -358,21 +365,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 ); - bDone = sal_True; + 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() ) { @@ -402,7 +409,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() ) { @@ -435,7 +442,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() ) @@ -1573,13 +1580,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; } @@ -1587,7 +1594,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; @@ -1598,13 +1605,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; @@ -1612,7 +1626,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& ) @@ -1634,8 +1653,8 @@ sal_Bool TransferableDataHelper::GetString( SotFormatStringId nFormat, OUString& sal_Bool TransferableDataHelper::GetString( const DataFlavor& rFlavor, OUString& rStr ) { - Any aAny( GetAny( rFlavor ) ); - sal_Bool bRet = sal_False; + Any aAny = GetAny(rFlavor, OUString()); + bool bRet = false; if( aAny.hasValue() ) { @@ -2003,9 +2022,9 @@ sal_Bool TransferableDataHelper::GetINetBookmark( const ::com::sun::star::datatr 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; @@ -2019,9 +2038,9 @@ sal_Bool TransferableDataHelper::GetINetBookmark( const ::com::sun::star::datatr #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(); @@ -2041,14 +2060,14 @@ sal_Bool TransferableDataHelper::GetINetBookmark( const ::com::sun::star::datatr 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 ) @@ -2153,70 +2172,70 @@ sal_Bool TransferableDataHelper::GetFileList( // ----------------------------------------------------------------------------- -sal_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); +} -sal_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; +} -sal_Bool TransferableDataHelper::GetSotStorageStream( SotFormatStringId nFormat, SotStorageStreamRef& rxStream ) +bool TransferableDataHelper::GetSotStorageStream( SotFormatStringId nFormat, SotStorageStreamRef& rxStream ) { DataFlavor aFlavor; return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetSotStorageStream( aFlavor, rxStream ) ); } -// ----------------------------------------------------------------------------- - -sal_Bool TransferableDataHelper::GetSotStorageStream( const DataFlavor& rFlavor, SotStorageStreamRef& rxStream ) +bool TransferableDataHelper::GetSotStorageStream( const DataFlavor& rFlavor, SotStorageStreamRef& rxStream ) { - Sequence< sal_Int8 > aSeq; - sal_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(); } -sal_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); +} -sal_Bool TransferableDataHelper::GetInputStream( const DataFlavor& rFlavor, Reference < XInputStream >& rxStream ) +Reference<XInputStream> TransferableDataHelper::GetInputStream( const DataFlavor& rFlavor, const OUString& rDestDoc ) { - Sequence< sal_Int8 > aSeq; - sal_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 eb282c13f6b6..9c4cc6823712 100644 --- a/svtools/source/misc/transfer2.cxx +++ b/svtools/source/misc/transfer2.cxx @@ -415,8 +415,8 @@ void TransferDataContainer::AddSupportedFormats() // ----------------------------------------------------------------------------- -sal_Bool TransferDataContainer::GetData( const - ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +sal_Bool TransferDataContainer::GetData( + const ::com::sun::star::datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ ) { TDataCntnrEntryList::iterator aIter( pImpl->aFmtList.begin() ), aEnd( pImpl->aFmtList.end() ); |