diff options
author | Noel Grandin <noel@peralex.com> | 2016-04-04 15:01:55 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-04-05 06:26:22 +0000 |
commit | b9372f0e909c32d143540bf0ce7b79003d9b26e9 (patch) | |
tree | 9c8ecd561d296b66427974d0daebe726ab0f4f20 /comphelper | |
parent | 50bb5eddaac2b16f387ba610cdcfd934269dc73c (diff) |
loplugin:constantparam in comphelper
Change-Id: I81e6af1ee869caa3b40d2d00604e8e22517d92d7
Reviewed-on: https://gerrit.libreoffice.org/23808
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/container/embeddedobjectcontainer.cxx | 116 | ||||
-rw-r--r-- | comphelper/source/misc/SelectionMultiplex.cxx | 9 | ||||
-rw-r--r-- | comphelper/source/streaming/seqstream.cxx | 19 | ||||
-rw-r--r-- | comphelper/source/streaming/streamsection.cxx | 25 |
4 files changed, 52 insertions, 117 deletions
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx index a37b2f0da85e..6604be32ee0b 100644 --- a/comphelper/source/container/embeddedobjectcontainer.cxx +++ b/comphelper/source/container/embeddedobjectcontainer.cxx @@ -899,12 +899,11 @@ bool EmbeddedObjectContainer::MoveEmbeddedObject( EmbeddedObjectContainer& rSrc, } // #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage+ -bool EmbeddedObjectContainer::RemoveEmbeddedObject( const OUString& rName, bool bClose, bool bKeepToTempStorage ) +bool EmbeddedObjectContainer::RemoveEmbeddedObject( const OUString& rName, bool bKeepToTempStorage ) { uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObject( rName ); if ( xObj.is() ) - //return RemoveEmbeddedObject( xObj, bClose ); - return RemoveEmbeddedObject( xObj, bClose, bKeepToTempStorage ); + return RemoveEmbeddedObject( xObj, bKeepToTempStorage ); else return false; } @@ -960,9 +959,8 @@ bool EmbeddedObjectContainer::MoveEmbeddedObject( const OUString& rName, Embedde return false; } -//sal_Bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj, sal_Bool bClose ) // #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage+ -bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj, bool bClose, bool bKeepToTempStorage ) +bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj, bool bKeepToTempStorage ) { uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY ); OUString aName; @@ -978,86 +976,54 @@ bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < embed OSL_ENSURE( bIsNotEmbedded || xAccess->hasByName(aName), "Removing element not present in storage!" ); #endif - // try to close it if permitted - if ( bClose ) + // somebody still needs the object, so we must assign a temporary persistence + try { - uno::Reference < ::util::XCloseable > xClose( xObj, uno::UNO_QUERY ); - try - { - xClose->close( sal_True ); - } - catch (const util::CloseVetoException&) + if ( xPersist.is() && bKeepToTempStorage ) // #i119941 { - bClose = false; - } - } - if ( !bClose ) - { - // somebody still needs the object, so we must assign a temporary persistence - try - { - // if ( xPersist.is() ) - if ( xPersist.is() && bKeepToTempStorage ) // #i119941 + if ( !pImpl->mpTempObjectContainer ) { - /* - //TODO/LATER: needs storage handling! Why not letting the object do it?! - if ( !pImpl->mxTempStorage.is() ) - pImpl->mxTempStorage = ::comphelper::OStorageHelper::GetTemporaryStorage(); - uno::Sequence < beans::PropertyValue > aSeq; - - OUString aTmpPersistName = "Object "; - aTmpPersistName += OUString::valueOf( (sal_Int32) pImpl->maTempObjectContainer.size() ); - - xPersist->storeAsEntry( pImpl->mxTempStorage, aTmpPersistName, aSeq, aSeq ); - xPersist->saveCompleted( sal_True ); - - pImpl->maTempObjectContainer[ aTmpPersistName ].clear(); - */ - - if ( !pImpl->mpTempObjectContainer ) + pImpl->mpTempObjectContainer = new EmbeddedObjectContainer(); + try { - pImpl->mpTempObjectContainer = new EmbeddedObjectContainer(); - try - { - // TODO/LATER: in future probably the temporary container will have two storages ( of two formats ) - // the media type will be provided with object insertion - OUString aOrigStorMediaType; - uno::Reference< beans::XPropertySet > xStorProps( pImpl->mxStorage, uno::UNO_QUERY_THROW ); - static const OUString s_sMediaType("MediaType"); - xStorProps->getPropertyValue( s_sMediaType ) >>= aOrigStorMediaType; - - SAL_WARN_IF( aOrigStorMediaType.isEmpty(), "comphelper.container", "No valuable media type in the storage!\n" ); - - uno::Reference< beans::XPropertySet > xTargetStorProps( - pImpl->mpTempObjectContainer->pImpl->mxStorage, - uno::UNO_QUERY_THROW ); - xTargetStorProps->setPropertyValue( s_sMediaType,uno::makeAny( aOrigStorMediaType ) ); - } - catch (const uno::Exception&) - { - SAL_WARN( "comphelper.container", "Can not set the new media type to a storage!\n" ); - } + // TODO/LATER: in future probably the temporary container will have two storages ( of two formats ) + // the media type will be provided with object insertion + OUString aOrigStorMediaType; + uno::Reference< beans::XPropertySet > xStorProps( pImpl->mxStorage, uno::UNO_QUERY_THROW ); + static const OUString s_sMediaType("MediaType"); + xStorProps->getPropertyValue( s_sMediaType ) >>= aOrigStorMediaType; + + SAL_WARN_IF( aOrigStorMediaType.isEmpty(), "comphelper.container", "No valuable media type in the storage!\n" ); + + uno::Reference< beans::XPropertySet > xTargetStorProps( + pImpl->mpTempObjectContainer->pImpl->mxStorage, + uno::UNO_QUERY_THROW ); + xTargetStorProps->setPropertyValue( s_sMediaType,uno::makeAny( aOrigStorMediaType ) ); + } + catch (const uno::Exception&) + { + SAL_WARN( "comphelper.container", "Can not set the new media type to a storage!\n" ); } + } - OUString aTempName, aMediaType; - pImpl->mpTempObjectContainer->InsertEmbeddedObject( xObj, aTempName ); + OUString aTempName, aMediaType; + pImpl->mpTempObjectContainer->InsertEmbeddedObject( xObj, aTempName ); - uno::Reference < io::XInputStream > xStream = GetGraphicStream( xObj, &aMediaType ); - if ( xStream.is() ) - pImpl->mpTempObjectContainer->InsertGraphicStream( xStream, aTempName, aMediaType ); + uno::Reference < io::XInputStream > xStream = GetGraphicStream( xObj, &aMediaType ); + if ( xStream.is() ) + pImpl->mpTempObjectContainer->InsertGraphicStream( xStream, aTempName, aMediaType ); - // object is stored, so at least it can be set to loaded state - xObj->changeState( embed::EmbedStates::LOADED ); - } - else - // objects without persistence need to stay in running state if they shall not be closed - xObj->changeState( embed::EmbedStates::RUNNING ); - } - catch (const uno::Exception&) - { - return false; + // object is stored, so at least it can be set to loaded state + xObj->changeState( embed::EmbedStates::LOADED ); } + else + // objects without persistence need to stay in running state if they shall not be closed + xObj->changeState( embed::EmbedStates::RUNNING ); + } + catch (const uno::Exception&) + { + return false; } bool bFound = false; diff --git a/comphelper/source/misc/SelectionMultiplex.cxx b/comphelper/source/misc/SelectionMultiplex.cxx index 26a191c21f30..9f853ed28b05 100644 --- a/comphelper/source/misc/SelectionMultiplex.cxx +++ b/comphelper/source/misc/SelectionMultiplex.cxx @@ -61,12 +61,11 @@ void OSelectionChangeListener::setAdapter(OSelectionChangeMultiplexer* pAdapter) } } -OSelectionChangeMultiplexer::OSelectionChangeMultiplexer(OSelectionChangeListener* _pListener, const Reference< XSelectionSupplier>& _rxSet, bool _bAutoReleaseSet) +OSelectionChangeMultiplexer::OSelectionChangeMultiplexer(OSelectionChangeListener* _pListener, const Reference< XSelectionSupplier>& _rxSet) :m_xSet(_rxSet) ,m_pListener(_pListener) ,m_nLockCount(0) ,m_bListening(false) - ,m_bAutoSetRelease(_bAutoReleaseSet) { m_pListener->setAdapter(this); osl_atomic_increment(&m_refCount); @@ -108,8 +107,7 @@ void OSelectionChangeMultiplexer::dispose() m_pListener = nullptr; m_bListening = false; - if (m_bAutoSetRelease) - m_xSet = nullptr; + m_xSet = nullptr; } } @@ -130,8 +128,7 @@ void SAL_CALL OSelectionChangeMultiplexer::disposing( const EventObject& _rSour m_pListener = nullptr; m_bListening = false; - if (m_bAutoSetRelease) - m_xSet = nullptr; + m_xSet = nullptr; } // XSelectionChangeListener diff --git a/comphelper/source/streaming/seqstream.cxx b/comphelper/source/streaming/seqstream.cxx index 2cc98da1bd7d..d4672f602bfe 100644 --- a/comphelper/source/streaming/seqstream.cxx +++ b/comphelper/source/streaming/seqstream.cxx @@ -138,23 +138,17 @@ sal_Int64 SAL_CALL SequenceInputStream::getLength( ) throw (IOException, Runtim } -OSequenceOutputStream::OSequenceOutputStream(Sequence< sal_Int8 >& _rSeq, double _nResizeFactor, sal_Int32 _nMinimumResize, sal_Int32 _nMaximumResize) +OSequenceOutputStream::OSequenceOutputStream(Sequence< sal_Int8 >& _rSeq, double _nResizeFactor, sal_Int32 _nMinimumResize) :m_rSequence(_rSeq) ,m_nResizeFactor(_nResizeFactor) ,m_nMinimumResize(_nMinimumResize) - ,m_nMaximumResize(_nMaximumResize) ,m_nSize(0) // starting at position 0 ,m_bConnected(true) { OSL_ENSURE(m_nResizeFactor > 1, "OSequenceOutputStream::OSequenceOutputStream : invalid resize factor !"); - OSL_ENSURE((m_nMaximumResize < 0) || (m_nMaximumResize > m_nMinimumResize), - "OSequenceOutputStream::OSequenceOutputStream : these limits don't make any sense !"); if (m_nResizeFactor <= 1) m_nResizeFactor = 1.3; - if ((m_nMaximumResize >= 0) && (m_nMaximumResize <= m_nMinimumResize)) - m_nMaximumResize = m_nMinimumResize * 2; - // this heuristic is as good as any other ... supply better parameters if you don't like it :) } @@ -175,23 +169,12 @@ void SAL_CALL OSequenceOutputStream::writeBytes( const Sequence< sal_Int8 >& _rD // we have a minimum so it's not too inefficient for small sequences and small write requests nNewLength = nCurrentLength + m_nMinimumResize; - if ((m_nMaximumResize > 0) && (nNewLength - nCurrentLength > m_nMaximumResize)) - // such a large step is not allowed - nNewLength = nCurrentLength + m_nMaximumResize; - if (nNewLength < m_nSize + _rData.getLength()) { // it's not enough .... the data would not fit // let's take the double amount of the length of the data to be written, as the next write // request could be as large as this one sal_Int32 nNewGrowth = _rData.getLength() * 2; - if ((m_nMaximumResize > 0) && (nNewGrowth > m_nMaximumResize)) - { // we came to the limit, again ... - nNewGrowth = m_nMaximumResize; - if (nNewGrowth + nCurrentLength < m_nSize + _rData.getLength()) - // but it would not fit if we respect the limit - nNewGrowth = m_nSize + _rData.getLength() - nCurrentLength; - } nNewLength = nCurrentLength + nNewGrowth; } diff --git a/comphelper/source/streaming/streamsection.cxx b/comphelper/source/streaming/streamsection.cxx index 4ff71da0dfa5..f6165c7b059d 100644 --- a/comphelper/source/streaming/streamsection.cxx +++ b/comphelper/source/streaming/streamsection.cxx @@ -39,7 +39,7 @@ OStreamSection::OStreamSection(const css::uno::Reference< css::io::XDataInputStr } -OStreamSection::OStreamSection(const css::uno::Reference< css::io::XDataOutputStream >& _rxOutput, sal_Int32 _nPresumedLength) +OStreamSection::OStreamSection(const css::uno::Reference< css::io::XDataOutputStream >& _rxOutput) :m_xMarkStream(_rxOutput, css::uno::UNO_QUERY) ,m_xOutStream(_rxOutput) ,m_nBlockStart(-1) @@ -49,12 +49,7 @@ OStreamSection::OStreamSection(const css::uno::Reference< css::io::XDataOutputSt if (m_xOutStream.is() && m_xMarkStream.is()) { m_nBlockStart = m_xMarkStream->createMark(); - // a placeholder where we will write the overall length (within the destructor) - if (_nPresumedLength > 0) - m_nBlockLen = _nPresumedLength + sizeof(m_nBlockLen); - // as the caller did not consider - of course - the placeholder we are going to write - else - m_nBlockLen = 0; + m_nBlockLen = 0; m_xOutStream->writeLong(m_nBlockLen); } } @@ -74,17 +69,11 @@ OStreamSection::~OStreamSection() else if (m_xOutStream.is() && m_xMarkStream.is()) { sal_Int32 nRealBlockLength = m_xMarkStream->offsetToMark(m_nBlockStart) - sizeof(m_nBlockLen); - if (m_nBlockLen && (m_nBlockLen == nRealBlockLength)) - // nothing to do : the estimation the caller gave us (in the ctor) was correct - m_xMarkStream->deleteMark(m_nBlockStart); - else - { // the estimation was wrong (or we didn't get one) - m_nBlockLen = nRealBlockLength; - m_xMarkStream->jumpToMark(m_nBlockStart); - m_xOutStream->writeLong(m_nBlockLen); - m_xMarkStream->jumpToFurthest(); - m_xMarkStream->deleteMark(m_nBlockStart); - } + m_nBlockLen = nRealBlockLength; + m_xMarkStream->jumpToMark(m_nBlockStart); + m_xOutStream->writeLong(m_nBlockLen); + m_xMarkStream->jumpToFurthest(); + m_xMarkStream->deleteMark(m_nBlockStart); } } catch(const css::uno::Exception&) |