From b143e7642f93e83f4f3c4df56c3e1e8e64e36ce0 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 9 Feb 2019 15:57:25 +0300 Subject: tdf#120703 PVS: V560 A part of conditional expression is always true/false Change-Id: Ib9ad5b874a210ef3862c668158fcc5d18eeab363 Reviewed-on: https://gerrit.libreoffice.org/67579 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- package/source/xstor/xstorage.cxx | 92 ++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 49 deletions(-) (limited to 'package/source') diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index a7cdc1de4d9e..a07d06cbaa20 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -1674,69 +1674,63 @@ void OStorage_Impl::CommitRelInfo( const uno::Reference< container::XNameContain if ( m_nRelInfoStatus == RELINFO_BROKEN || m_nRelInfoStatus == RELINFO_CHANGED_BROKEN ) throw io::IOException( THROW_WHERE ); - if ( m_nRelInfoStatus == RELINFO_CHANGED - || m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ - || m_nRelInfoStatus == RELINFO_CHANGED_STREAM ) + if (m_nRelInfoStatus == RELINFO_CHANGED) { - if ( m_nRelInfoStatus == RELINFO_CHANGED ) + if (m_aRelInfo.getLength()) { - if ( m_aRelInfo.getLength() ) - { - CreateRelStorage(); + CreateRelStorage(); - uno::Reference< io::XStream > xRelsStream = - m_xRelStorage->openStreamElement( ".rels" , - embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE ); + uno::Reference xRelsStream = m_xRelStorage->openStreamElement( + ".rels", embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE); - uno::Reference< io::XOutputStream > xOutStream = xRelsStream->getOutputStream(); - if ( !xOutStream.is() ) - throw uno::RuntimeException( THROW_WHERE ); + uno::Reference xOutStream = xRelsStream->getOutputStream(); + if (!xOutStream.is()) + throw uno::RuntimeException(THROW_WHERE); - ::comphelper::OFOPXMLHelper::WriteRelationsInfoSequence( xOutStream, m_aRelInfo, m_xContext ); + ::comphelper::OFOPXMLHelper::WriteRelationsInfoSequence(xOutStream, m_aRelInfo, + m_xContext); - // set the mediatype - uno::Reference< beans::XPropertySet > xPropSet( xRelsStream, uno::UNO_QUERY_THROW ); - xPropSet->setPropertyValue( - "MediaType", - uno::makeAny( OUString( "application/vnd.openxmlformats-package.relationships+xml" ) ) ); + // set the mediatype + uno::Reference xPropSet(xRelsStream, uno::UNO_QUERY_THROW); + xPropSet->setPropertyValue( + "MediaType", uno::makeAny(OUString( + "application/vnd.openxmlformats-package.relationships+xml"))); - m_nRelInfoStatus = RELINFO_READ; - } - else if ( m_xRelStorage.is() ) - RemoveStreamRelInfo( OUString() ); // remove own rel info + m_nRelInfoStatus = RELINFO_READ; } - else if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ - || m_nRelInfoStatus == RELINFO_CHANGED_STREAM ) - { - CreateRelStorage(); + else if (m_xRelStorage.is()) + RemoveStreamRelInfo(OUString()); // remove own rel info + } + else if (m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ + || m_nRelInfoStatus == RELINFO_CHANGED_STREAM) + { + CreateRelStorage(); - uno::Reference< io::XStream > xRelsStream = - m_xRelStorage->openStreamElement( ".rels", - embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE ); + uno::Reference xRelsStream = m_xRelStorage->openStreamElement( + ".rels", embed::ElementModes::TRUNCATE | embed::ElementModes::READWRITE); - uno::Reference< io::XOutputStream > xOutputStream = xRelsStream->getOutputStream(); - if ( !xOutputStream.is() ) - throw uno::RuntimeException( THROW_WHERE ); + uno::Reference xOutputStream = xRelsStream->getOutputStream(); + if (!xOutputStream.is()) + throw uno::RuntimeException(THROW_WHERE); - uno::Reference< io::XSeekable > xSeek( m_xNewRelInfoStream, uno::UNO_QUERY_THROW ); - xSeek->seek( 0 ); - ::comphelper::OStorageHelper::CopyInputToOutput( m_xNewRelInfoStream, xOutputStream ); + uno::Reference xSeek(m_xNewRelInfoStream, uno::UNO_QUERY_THROW); + xSeek->seek(0); + ::comphelper::OStorageHelper::CopyInputToOutput(m_xNewRelInfoStream, xOutputStream); - // set the mediatype - uno::Reference< beans::XPropertySet > xPropSet( xRelsStream, uno::UNO_QUERY_THROW ); - xPropSet->setPropertyValue( - "MediaType", - uno::makeAny( OUString( "application/vnd.openxmlformats-package.relationships+xml" ) ) ); + // set the mediatype + uno::Reference xPropSet(xRelsStream, uno::UNO_QUERY_THROW); + xPropSet->setPropertyValue( + "MediaType", + uno::makeAny(OUString("application/vnd.openxmlformats-package.relationships+xml"))); - m_xNewRelInfoStream.clear(); - if ( m_nRelInfoStatus == RELINFO_CHANGED_STREAM ) - { - m_aRelInfo = uno::Sequence< uno::Sequence< beans::StringPair > >(); - m_nRelInfoStatus = RELINFO_NO_INIT; - } - else - m_nRelInfoStatus = RELINFO_READ; + m_xNewRelInfoStream.clear(); + if (m_nRelInfoStatus == RELINFO_CHANGED_STREAM) + { + m_aRelInfo = uno::Sequence>(); + m_nRelInfoStatus = RELINFO_NO_INIT; } + else + m_nRelInfoStatus = RELINFO_READ; } if ( m_xRelStorage.is() ) -- cgit