include/svtools/brwbox.hxx | 4 - include/svtools/transfer.hxx | 12 +--- reportdesign/source/ui/report/ReportSection.cxx | 2 svtools/source/brwbox/brwbox2.cxx | 6 +- svtools/source/misc/transfer.cxx | 69 ++++++++++-------------- svtools/source/misc/transfer2.cxx | 15 ++--- sw/source/uibase/dochdl/swdtflvr.cxx | 2 sw/source/uibase/utlui/condedit.cxx | 2 8 files changed, 50 insertions(+), 62 deletions(-)
New commits: commit 5ee57cabb40fefbba401cbcf8b181e02ad4f1f5d Author: Jochen Nitschke <j.nitschke+loger...@ok.de> Date: Tue Feb 28 23:48:06 2017 +0100 no need to use smart pointers for DataFlavorExVector DataFlavorExVector is a std::vector<..> typedef. remove odd void pointer in BrowseBox. return const references to keep getter const qualified. Change-Id: Iafd529a46b7511941c1dffc86d2066fdc4f07e28 Reviewed-on: https://gerrit.libreoffice.org/34767 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svtools/brwbox.hxx b/include/svtools/brwbox.hxx index ae950f5..266491a 100644 --- a/include/svtools/brwbox.hxx +++ b/include/svtools/brwbox.hxx @@ -378,7 +378,7 @@ protected: bool IsDropFormatSupported( SotClipboardFormatId nFormat ); // need this because the base class' IsDropFormatSupported is not const ... private: - void* implGetDataFlavors() const; + const DataFlavorExVector& implGetDataFlavors() const; // with this we can make GetDataFlavors() inline, which is strongly needed as SVTOOLS does not export // any sysmbol containing an "_STL", so a non-inlined method would not be exported .... @@ -787,7 +787,7 @@ private: inline const DataFlavorExVector& BrowseBox::GetDataFlavors() const { - return *static_cast<DataFlavorExVector*>(implGetDataFlavors()); + return implGetDataFlavors(); } #endif // INCLUDED_SVTOOLS_BRWBOX_HXX diff --git a/include/svtools/transfer.hxx b/include/svtools/transfer.hxx index 4cfa475..8cf82f4 100644 --- a/include/svtools/transfer.hxx +++ b/include/svtools/transfer.hxx @@ -158,7 +158,7 @@ private: OUString maLastFormat; mutable css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard; css::uno::Reference< css::frame::XTerminateListener > mxTerminateListener; - std::unique_ptr<DataFlavorExVector> mxFormats; + DataFlavorExVector maFormats; std::unique_ptr<TransferableObjectDescriptor> mxObjDesc; protected: @@ -238,8 +238,6 @@ protected: public: - TransferableHelper(); - void PrepareOLE( const TransferableObjectDescriptor& rObjDesc ); void CopyToClipboard( vcl::Window *pWindow ) const; @@ -267,7 +265,7 @@ private: css::uno::Reference< css::datatransfer::XTransferable > mxTransfer; css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard; - std::unique_ptr<DataFlavorExVector> mxFormats; + DataFlavorExVector maFormats; std::unique_ptr<TransferableObjectDescriptor> mxObjDesc; std::unique_ptr<TransferableDataHelper_Impl> mxImpl; @@ -299,7 +297,7 @@ public: SotClipboardFormatId GetFormat( sal_uInt32 nFormat ) const; css::datatransfer::DataFlavor GetFormatDataFlavor( sal_uInt32 nFormat ) const; - DataFlavorExVector& GetDataFlavorExVector() const {return *mxFormats; } + const DataFlavorExVector& GetDataFlavorExVector() const {return maFormats; } bool StartClipboardListening( ); void StopClipboardListening( ); @@ -444,7 +442,7 @@ private: css::uno::Reference< css::datatransfer::dnd::XDropTarget > mxDropTarget; css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > mxDropTargetListener; - DataFlavorExVector* mpFormats; + DataFlavorExVector maFormats; DropTargetHelper() = delete; DropTargetHelper& operator=( const DropTargetHelper& rDropTargetHelper ) = delete; @@ -471,7 +469,7 @@ public: // typically called by the application in ::AcceptDrop and ::ExecuteDrop and (see above) bool IsDropFormatSupported( SotClipboardFormatId nFormat ); - DataFlavorExVector& GetDataFlavorExVector() const {return *mpFormats; } + const DataFlavorExVector& GetDataFlavorExVector() const {return maFormats; } }; diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index 4dbcf32..8693298 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -742,7 +742,7 @@ sal_Int8 OReportSection::ExecuteDrop( const ExecuteDropEvent& _rEvt ) sal_Int8 nDropOption = DND_ACTION_NONE; const TransferableDataHelper aDropped(_rEvt.maDropEvent.Transferable); - DataFlavorExVector& rFlavors = aDropped.GetDataFlavorExVector(); + const DataFlavorExVector& rFlavors = aDropped.GetDataFlavorExVector(); bool bMultipleFormat = svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors); if ( OReportExchange::canExtract(rFlavors) ) { diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx index 6704672..8346f0f 100644 --- a/svtools/source/brwbox/brwbox2.cxx +++ b/svtools/source/brwbox/brwbox2.cxx @@ -67,11 +67,11 @@ sal_Int8 BrowseBox::ExecuteDrop( const BrowserExecuteDropEvent& ) } -void* BrowseBox::implGetDataFlavors() const +const DataFlavorExVector& BrowseBox::implGetDataFlavors() const { if (pDataWin->bCallingDropCallback) - return &pDataWin->GetDataFlavorExVector(); - return &GetDataFlavorExVector(); + return pDataWin->GetDataFlavorExVector(); + return GetDataFlavorExVector(); } diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx index a5a6f23..3337c22 100644 --- a/svtools/source/misc/transfer.cxx +++ b/svtools/source/misc/transfer.cxx @@ -254,11 +254,6 @@ void SAL_CALL TransferableHelper::TerminateListener::notifyTermination( const Ev } -TransferableHelper::TransferableHelper() - : mxFormats(new DataFlavorExVector) -{ -} - Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) { return getTransferData2(rFlavor, OUString()); @@ -266,7 +261,7 @@ Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) Any SAL_CALL TransferableHelper::getTransferData2( const DataFlavor& rFlavor, const OUString& rDestDoc ) { - if( !maAny.hasValue() || mxFormats->empty() || ( maLastFormat != rFlavor.MimeType ) ) + if( !maAny.hasValue() || maFormats.empty() || ( maLastFormat != rFlavor.MimeType ) ) { const SolarMutexGuard aGuard; @@ -279,7 +274,7 @@ Any SAL_CALL TransferableHelper::getTransferData2( const DataFlavor& rFlavor, co bool bDone = false; // add formats if not already done - if (mxFormats->empty()) + if (maFormats.empty()) AddSupportedFormats(); // check alien formats first and try to get a substitution format @@ -383,14 +378,14 @@ Sequence< DataFlavor > SAL_CALL TransferableHelper::getTransferDataFlavors() try { - if(mxFormats->empty()) + if(maFormats.empty()) AddSupportedFormats(); } catch( const css::uno::Exception& ) { } - return comphelper::containerToSequence<DataFlavor>(*mxFormats); + return comphelper::containerToSequence<DataFlavor>(maFormats); } @@ -401,14 +396,14 @@ sal_Bool SAL_CALL TransferableHelper::isDataFlavorSupported( const DataFlavor& r try { - if (mxFormats->empty()) + if (maFormats.empty()) AddSupportedFormats(); } catch( const css::uno::Exception& ) { } - for (DataFlavorExVector::const_iterator aIter(mxFormats->begin() ), aEnd(mxFormats->end()); aIter != aEnd ; ++aIter) + for (DataFlavorExVector::const_iterator aIter(maFormats.begin() ), aEnd(maFormats.end()); aIter != aEnd ; ++aIter) { if( TransferableDataHelper::IsEqual( *aIter, rFlavor ) ) { @@ -532,7 +527,7 @@ void TransferableHelper::AddFormat( const DataFlavor& rFlavor ) { bool bAdd = true; - for (DataFlavorExVector::iterator aIter(mxFormats->begin()), aEnd(mxFormats->end()); aIter != aEnd ; ++aIter) + for (DataFlavorExVector::iterator aIter(maFormats.begin()), aEnd(maFormats.end()); aIter != aEnd ; ++aIter) { if( TransferableDataHelper::IsEqual( *aIter, rFlavor ) ) { @@ -563,7 +558,7 @@ void TransferableHelper::AddFormat( const DataFlavor& rFlavor ) if ((SotClipboardFormatId::OBJECTDESCRIPTOR == aFlavorEx.mnSotId) && mxObjDesc) aFlavorEx.MimeType += ::ImplGetParameterString(*mxObjDesc); - mxFormats->push_back(aFlavorEx); + maFormats.push_back(aFlavorEx); if( SotClipboardFormatId::BITMAP == aFlavorEx.mnSotId ) { @@ -590,12 +585,12 @@ void TransferableHelper::RemoveFormat( SotClipboardFormatId nFormat ) void TransferableHelper::RemoveFormat( const DataFlavor& rFlavor ) { - DataFlavorExVector::iterator aIter(mxFormats->begin()); + DataFlavorExVector::iterator aIter(maFormats.begin()); - while (aIter != mxFormats->end()) + while (aIter != maFormats.end()) { if( TransferableDataHelper::IsEqual( *aIter, rFlavor ) ) - aIter = mxFormats->erase(aIter); + aIter = maFormats.erase(aIter); else ++aIter; } @@ -606,7 +601,7 @@ bool TransferableHelper::HasFormat( SotClipboardFormatId nFormat ) { bool bRet = false; - for (DataFlavorExVector::const_iterator aIter(mxFormats->begin()), aEnd(mxFormats->end()); aIter != aEnd; ++aIter) + for (DataFlavorExVector::const_iterator aIter(maFormats.begin()), aEnd(maFormats.end()); aIter != aEnd; ++aIter) { if( nFormat == (*aIter).mnSotId ) { @@ -621,7 +616,7 @@ bool TransferableHelper::HasFormat( SotClipboardFormatId nFormat ) void TransferableHelper::ClearFormats() { - mxFormats->clear(); + maFormats.clear(); maAny.clear(); } @@ -1111,15 +1106,13 @@ struct TransferableDataHelper_Impl }; TransferableDataHelper::TransferableDataHelper() - : mxFormats(new DataFlavorExVector) - , mxObjDesc(new TransferableObjectDescriptor) + : mxObjDesc(new TransferableObjectDescriptor) , mxImpl(new TransferableDataHelper_Impl) { } TransferableDataHelper::TransferableDataHelper(const Reference< css::datatransfer::XTransferable >& rxTransferable) : mxTransfer(rxTransferable) - , mxFormats(new DataFlavorExVector) , mxObjDesc(new TransferableObjectDescriptor) , mxImpl(new TransferableDataHelper_Impl) { @@ -1129,7 +1122,7 @@ TransferableDataHelper::TransferableDataHelper(const Reference< css::datatransfe TransferableDataHelper::TransferableDataHelper(const TransferableDataHelper& rDataHelper) : mxTransfer(rDataHelper.mxTransfer) , mxClipboard(rDataHelper.mxClipboard) - , mxFormats(new DataFlavorExVector(*rDataHelper.mxFormats)) + , maFormats(rDataHelper.maFormats) , mxObjDesc(new TransferableObjectDescriptor(*rDataHelper.mxObjDesc)) , mxImpl(new TransferableDataHelper_Impl) { @@ -1138,7 +1131,7 @@ TransferableDataHelper::TransferableDataHelper(const TransferableDataHelper& rDa TransferableDataHelper::TransferableDataHelper(TransferableDataHelper&& rDataHelper) : mxTransfer(std::move(rDataHelper.mxTransfer)) , mxClipboard(std::move(rDataHelper.mxClipboard)) - , mxFormats(std::move(rDataHelper.mxFormats)) + , maFormats(std::move(rDataHelper.maFormats)) , mxObjDesc(std::move(rDataHelper.mxObjDesc)) , mxImpl(new TransferableDataHelper_Impl) { @@ -1156,7 +1149,7 @@ TransferableDataHelper& TransferableDataHelper::operator=( const TransferableDat StopClipboardListening(); mxTransfer = rDataHelper.mxTransfer; - mxFormats.reset(new DataFlavorExVector(*rDataHelper.mxFormats)); + maFormats = rDataHelper.maFormats; mxObjDesc.reset(new TransferableObjectDescriptor(*rDataHelper.mxObjDesc)); mxClipboard = rDataHelper.mxClipboard; @@ -1177,7 +1170,7 @@ TransferableDataHelper& TransferableDataHelper::operator=(TransferableDataHelper StopClipboardListening(); mxTransfer = std::move(rDataHelper.mxTransfer); - mxFormats = std::move(rDataHelper.mxFormats); + maFormats = std::move(rDataHelper.maFormats); mxObjDesc = std::move(rDataHelper.mxObjDesc); mxClipboard = std::move(rDataHelper.mxClipboard); @@ -1192,7 +1185,7 @@ TransferableDataHelper::~TransferableDataHelper() StopClipboardListening( ); { ::osl::MutexGuard aGuard(mxImpl->maMutex); - mxFormats.reset(); + maFormats.clear(); mxObjDesc.reset(); } } @@ -1298,14 +1291,14 @@ void TransferableDataHelper::InitFormats() SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard(mxImpl->maMutex); - mxFormats->clear(); + maFormats.clear(); mxObjDesc.reset(new TransferableObjectDescriptor); if( mxTransfer.is() ) { - TransferableDataHelper::FillDataFlavorExVector(mxTransfer->getTransferDataFlavors(), *mxFormats); + TransferableDataHelper::FillDataFlavorExVector(mxTransfer->getTransferDataFlavors(), maFormats); - for (DataFlavorExVector::const_iterator aIter(mxFormats->begin()), aEnd(mxFormats->end()); aIter != aEnd; ++aIter) + for (DataFlavorExVector::const_iterator aIter(maFormats.begin()), aEnd(maFormats.end()); aIter != aEnd; ++aIter) { if( SotClipboardFormatId::OBJECTDESCRIPTOR == aIter->mnSotId ) { @@ -1321,7 +1314,7 @@ bool TransferableDataHelper::HasFormat( SotClipboardFormatId nFormat ) const { ::osl::MutexGuard aGuard(mxImpl->maMutex); - DataFlavorExVector::iterator aIter(mxFormats->begin()), aEnd(mxFormats->end()); + DataFlavorExVector::const_iterator aIter(maFormats.cbegin()), aEnd(maFormats.cend()); bool bRet = false; while( aIter != aEnd ) @@ -1340,7 +1333,7 @@ bool TransferableDataHelper::HasFormat( const DataFlavor& rFlavor ) const { ::osl::MutexGuard aGuard(mxImpl->maMutex); - DataFlavorExVector::iterator aIter(mxFormats->begin()), aEnd(mxFormats->end()); + DataFlavorExVector::const_iterator aIter(maFormats.cbegin()), aEnd(maFormats.cend()); bool bRet = false; while( aIter != aEnd ) @@ -1358,25 +1351,25 @@ bool TransferableDataHelper::HasFormat( const DataFlavor& rFlavor ) const sal_uInt32 TransferableDataHelper::GetFormatCount() const { ::osl::MutexGuard aGuard(mxImpl->maMutex); - return mxFormats->size(); + return maFormats.size(); } SotClipboardFormatId TransferableDataHelper::GetFormat( sal_uInt32 nFormat ) const { ::osl::MutexGuard aGuard(mxImpl->maMutex); - DBG_ASSERT(nFormat < mxFormats->size(), "TransferableDataHelper::GetFormat: invalid format index"); - return( ( nFormat < mxFormats->size() ) ? (*mxFormats)[ nFormat ].mnSotId : SotClipboardFormatId::NONE ); + DBG_ASSERT(nFormat < maFormats.size(), "TransferableDataHelper::GetFormat: invalid format index"); + return( ( nFormat < maFormats.size() ) ? (maFormats)[ nFormat ].mnSotId : SotClipboardFormatId::NONE ); } DataFlavor TransferableDataHelper::GetFormatDataFlavor( sal_uInt32 nFormat ) const { ::osl::MutexGuard aGuard(mxImpl->maMutex); - DBG_ASSERT(nFormat < mxFormats->size(), "TransferableDataHelper::GetFormat: invalid format index"); + DBG_ASSERT(nFormat < maFormats.size(), "TransferableDataHelper::GetFormat: invalid format index"); DataFlavor aRet; - if (nFormat < mxFormats->size()) - aRet = (*mxFormats)[nFormat]; + if (nFormat < maFormats.size()) + aRet = maFormats[nFormat]; return aRet; } @@ -1433,7 +1426,7 @@ Any TransferableDataHelper::GetAny( const DataFlavor& rFlavor, const OUString& r if( nRequestFormat != SotClipboardFormatId::NONE ) { // try to get alien format first - for (DataFlavorExVector::const_iterator aIter(mxFormats->begin()), aEnd(mxFormats->end()); aIter != aEnd; ++aIter) + for (DataFlavorExVector::const_iterator aIter(maFormats.begin()), aEnd(maFormats.end()); aIter != aEnd; ++aIter) { if( ( nRequestFormat == (*aIter).mnSotId ) && !rFlavor.MimeType.equalsIgnoreAsciiCase( (*aIter).MimeType ) ) { diff --git a/svtools/source/misc/transfer2.cxx b/svtools/source/misc/transfer2.cxx index 4d3e61c..49da3de 100644 --- a/svtools/source/misc/transfer2.cxx +++ b/svtools/source/misc/transfer2.cxx @@ -228,16 +228,14 @@ void SAL_CALL DropTargetHelper::DropTargetListener::dropActionChanged( const Dro DropTargetHelper::DropTargetHelper( vcl::Window* pWindow ) : - mxDropTarget( pWindow->GetDropTarget() ), - mpFormats( new DataFlavorExVector ) + mxDropTarget( pWindow->GetDropTarget() ) { ImplConstruct(); } DropTargetHelper::DropTargetHelper( const Reference< XDropTarget >& rxDropTarget ) : - mxDropTarget( rxDropTarget ), - mpFormats( new DataFlavorExVector ) + mxDropTarget( rxDropTarget ) { ImplConstruct(); } @@ -258,7 +256,6 @@ void DropTargetHelper::dispose() DropTargetHelper::~DropTargetHelper() { dispose(); - delete mpFormats; } @@ -275,14 +272,14 @@ void DropTargetHelper::ImplConstruct() void DropTargetHelper::ImplBeginDrag( const Sequence< DataFlavor >& rSupportedDataFlavors ) { - mpFormats->clear(); - TransferableDataHelper::FillDataFlavorExVector( rSupportedDataFlavors, *mpFormats ); + maFormats.clear(); + TransferableDataHelper::FillDataFlavorExVector( rSupportedDataFlavors, maFormats ); } void DropTargetHelper::ImplEndDrag() { - mpFormats->clear(); + maFormats.clear(); } @@ -300,7 +297,7 @@ sal_Int8 DropTargetHelper::ExecuteDrop( const ExecuteDropEvent& ) bool DropTargetHelper::IsDropFormatSupported( SotClipboardFormatId nFormat ) { - DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() ); + DataFlavorExVector::iterator aIter( maFormats.begin() ), aEnd( maFormats.end() ); bool bRet = false; while( aIter != aEnd ) diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 9af2f2b..938c47c 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -2643,7 +2643,7 @@ bool SwTransferable::PasteDBData( TransferableDataHelper& rData, : (bLink ? 0 : FN_QRY_INSERT_FIELD ); - DataFlavorExVector& rVector = rData.GetDataFlavorExVector(); + const DataFlavorExVector& rVector = rData.GetDataFlavorExVector(); bool bHaveColumnDescriptor = OColumnTransferable::canExtractColumnDescriptor(rVector, ColumnTransferFormatFlags::COLUMN_DESCRIPTOR | ColumnTransferFormatFlags::CONTROL_EXCHANGE); if ( SotClipboardFormatId::XFORMS == nFormat ) { diff --git a/sw/source/uibase/utlui/condedit.cxx b/sw/source/uibase/utlui/condedit.cxx index 4dffb1b..5b910de 100644 --- a/sw/source/uibase/utlui/condedit.cxx +++ b/sw/source/uibase/utlui/condedit.cxx @@ -58,7 +58,7 @@ sal_Int8 ConditionEdit::ExecuteDrop( const ExecuteDropEvent& rEvt ) { TransferableDataHelper aData( rEvt.maDropEvent.Transferable ); - DataFlavorExVector& rVector = aData.GetDataFlavorExVector(); + const DataFlavorExVector& rVector = aData.GetDataFlavorExVector(); if(OColumnTransferable::canExtractColumnDescriptor(rVector, ColumnTransferFormatFlags::COLUMN_DESCRIPTOR)) { ODataAccessDescriptor aColDesc = OColumnTransferable::extractColumnDescriptor( _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits