toolkit/source/controls/controlmodelcontainerbase.cxx | 67 ++++----- toolkit/source/controls/tabpagecontainer.cxx | 33 ++-- toolkit/source/controls/unocontrolmodel.cxx | 7 ucb/source/ucp/file/prov.cxx | 6 ucb/source/ucp/ftp/ftpcontentprovider.cxx | 5 ucb/source/ucp/tdoc/tdoc_provider.cxx | 78 +++++----- ucb/source/ucp/webdav-neon/NeonInputStream.cxx | 6 ucb/source/ucp/webdav-neon/webdavcontent.cxx | 71 ++++----- unoxml/source/rdf/CBlankNode.cxx | 5 unoxml/source/rdf/CLiteral.cxx | 15 -- unoxml/source/rdf/CURI.cxx | 29 +--- unoxml/source/rdf/librdf_repository.cxx | 130 ++++++++---------- vbahelper/source/msforms/vbacontrols.cxx | 22 +-- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 40 ++--- vbahelper/source/vbahelper/vbacommandbarcontrols.cxx | 8 - vbahelper/source/vbahelper/vbacommandbars.cxx | 30 +--- vbahelper/source/vbahelper/vbahelper.cxx | 6 17 files changed, 265 insertions(+), 293 deletions(-)
New commits: commit 467724410dc470ec259131f97abd836fe9b021a1 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Sep 26 12:01:53 2017 +0200 loplugin:flatten in toolkit..vbahelper Change-Id: I6d4be3e1cc29b2b91d5c39b757ff3b903c47112d Reviewed-on: https://gerrit.libreoffice.org/42794 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx index 551dda47a63c..291894605b49 100644 --- a/toolkit/source/controls/controlmodelcontainerbase.cxx +++ b/toolkit/source/controls/controlmodelcontainerbase.cxx @@ -1827,48 +1827,47 @@ ControlModelContainerBase::updateUserFormChildren( const Reference< XNameContain if ( Operation < Insert || Operation > Remove ) throw IllegalArgumentException(); - if ( xAllChildren.is() ) + if ( !xAllChildren.is() ) + throw IllegalArgumentException(); + + if ( Operation == Remove ) { - if ( Operation == Remove ) - { - Reference< XControlModel > xOldModel( xAllChildren->getByName( aName ), UNO_QUERY ); - xAllChildren->removeByName( aName ); + Reference< XControlModel > xOldModel( xAllChildren->getByName( aName ), UNO_QUERY ); + xAllChildren->removeByName( aName ); - Reference< XNameContainer > xChildContainer( xOldModel, UNO_QUERY ); - if ( xChildContainer.is() ) - { - Reference< XPropertySet > xProps( xChildContainer, UNO_QUERY ); - // container control is being removed from this container, reset the - // global list of containees - if ( xProps.is() ) - xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( uno::Reference< XNameContainer >() ) ); - Sequence< OUString > aChildNames = xChildContainer->getElementNames(); - for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index ) - updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, Reference< XControlModel > () ); - } + Reference< XNameContainer > xChildContainer( xOldModel, UNO_QUERY ); + if ( xChildContainer.is() ) + { + Reference< XPropertySet > xProps( xChildContainer, UNO_QUERY ); + // container control is being removed from this container, reset the + // global list of containees + if ( xProps.is() ) + xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( uno::Reference< XNameContainer >() ) ); + Sequence< OUString > aChildNames = xChildContainer->getElementNames(); + for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index ) + updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, Reference< XControlModel > () ); } - else if ( Operation == Insert ) + } + else if ( Operation == Insert ) + { + xAllChildren->insertByName( aName, uno::makeAny( xTarget ) ); + Reference< XNameContainer > xChildContainer( xTarget, UNO_QUERY ); + if ( xChildContainer.is() ) { - xAllChildren->insertByName( aName, uno::makeAny( xTarget ) ); - Reference< XNameContainer > xChildContainer( xTarget, UNO_QUERY ); - if ( xChildContainer.is() ) + // container control is being added from this container, reset the + // global list of containees to point to the correct global list + Reference< XPropertySet > xProps( xChildContainer, UNO_QUERY ); + if ( xProps.is() ) + xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( xAllChildren ) ); + Sequence< OUString > aChildNames = xChildContainer->getElementNames(); + for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index ) { - // container control is being added from this container, reset the - // global list of containees to point to the correct global list - Reference< XPropertySet > xProps( xChildContainer, UNO_QUERY ); - if ( xProps.is() ) - xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( xAllChildren ) ); - Sequence< OUString > aChildNames = xChildContainer->getElementNames(); - for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index ) - { - Reference< XControlModel > xChildTarget( xChildContainer->getByName( aChildNames[ index ] ), UNO_QUERY ); - updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, xChildTarget ); - } + Reference< XControlModel > xChildTarget( xChildContainer->getByName( aChildNames[ index ] ), UNO_QUERY ); + updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, xChildTarget ); } } } - else - throw IllegalArgumentException(); + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/controls/tabpagecontainer.cxx b/toolkit/source/controls/tabpagecontainer.cxx index 72e6f8a1c279..5a1fe1a6adc3 100644 --- a/toolkit/source/controls/tabpagecontainer.cxx +++ b/toolkit/source/controls/tabpagecontainer.cxx @@ -148,26 +148,25 @@ void SAL_CALL UnoControlTabPageContainerModel::insertByIndex( ::sal_Int32 nIndex { SolarMutexGuard aSolarGuard; uno::Reference < XTabPageModel > xTabPageModel; - if(aElement >>= xTabPageModel) + if(!(aElement >>= xTabPageModel)) + throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 ); + + if ( sal_Int32( m_aTabPageVector.size()) ==nIndex ) + m_aTabPageVector.push_back( xTabPageModel ); + else if ( sal_Int32( m_aTabPageVector.size()) > nIndex ) { - if ( sal_Int32( m_aTabPageVector.size()) ==nIndex ) - m_aTabPageVector.push_back( xTabPageModel ); - else if ( sal_Int32( m_aTabPageVector.size()) > nIndex ) - { - std::vector< uno::Reference< XTabPageModel > >::iterator aIter = m_aTabPageVector.begin(); - aIter += nIndex; - m_aTabPageVector.insert( aIter, xTabPageModel ); - } - else - throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); - ContainerEvent aEvent; - aEvent.Source = *this; - aEvent.Element = aElement; - aEvent.Accessor <<= OUString::number(nIndex); - maContainerListeners.elementInserted( aEvent ); + std::vector< uno::Reference< XTabPageModel > >::iterator aIter = m_aTabPageVector.begin(); + aIter += nIndex; + m_aTabPageVector.insert( aIter, xTabPageModel ); } else - throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 ); + throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Element = aElement; + aEvent.Accessor <<= OUString::number(nIndex); + maContainerListeners.elementInserted( aEvent ); + } void SAL_CALL UnoControlTabPageContainerModel::removeByIndex( ::sal_Int32 /*Index*/ ) diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx index 5697e1034d6d..e28a6d8aa2c4 100644 --- a/toolkit/source/controls/unocontrolmodel.cxx +++ b/toolkit/source/controls/unocontrolmodel.cxx @@ -1239,10 +1239,11 @@ void UnoControlModel::setPropertyValue( const OUString& rPropertyName, const css nPropId = (sal_Int32) GetPropertyId( rPropertyName ); DBG_ASSERT( nPropId, "Invalid ID in UnoControlModel::setPropertyValue" ); } - if( nPropId ) - setFastPropertyValue( nPropId, rValue ); - else + if( !nPropId ) throw css::beans::UnknownPropertyException(); + + setFastPropertyValue( nPropId, rValue ); + } // css::beans::XFastPropertySet diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx index f2f888ed8d31..c0ce411df4e0 100644 --- a/ucb/source/ucp/file/prov.cxx +++ b/ucb/source/ucp/file/prov.cxx @@ -394,11 +394,9 @@ void SAL_CALL FileProvider::setPropertyValue( const OUString& aPropertyName, const Any& ) { - if( aPropertyName == "FileSystemNotation" || + if( !(aPropertyName == "FileSystemNotation" || aPropertyName == "HomeDirectory" || - aPropertyName == "HostName" ) - return; - else + aPropertyName == "HostName") ) throw UnknownPropertyException( THROW_WHERE ); } diff --git a/ucb/source/ucp/ftp/ftpcontentprovider.cxx b/ucb/source/ucp/ftp/ftpcontentprovider.cxx index 9b5f1a8e308a..9eac0b3acdce 100644 --- a/ucb/source/ucp/ftp/ftpcontentprovider.cxx +++ b/ucb/source/ucp/ftp/ftpcontentprovider.cxx @@ -187,10 +187,9 @@ Reference<XContent> SAL_CALL FTPContentProvider::queryContent( } else { Reference<XContentProvider> xProvider(UniversalContentBroker::create( m_xContext )->queryContentProvider("http:")); - if(xProvider.is()) - return xProvider->queryContent(xCanonicId); - else + if(!xProvider.is()) throw RuntimeException(); + return xProvider->queryContent(xCanonicId); } } catch(const malformed_exception&) { throw IllegalIdentifierException(); diff --git a/ucb/source/ucp/tdoc/tdoc_provider.cxx b/ucb/source/ucp/tdoc/tdoc_provider.cxx index dbcd58851012..4d972b4a6425 100644 --- a/ucb/source/ucp/tdoc/tdoc_provider.cxx +++ b/ucb/source/ucp/tdoc/tdoc_provider.cxx @@ -170,54 +170,50 @@ ContentProvider::createDocumentContent( const uno::Reference< frame::XModel >& Model ) { // model -> id -> content identifier -> queryContent - if ( m_xDocsMgr.is() ) + if ( !m_xDocsMgr.is() ) + { + throw lang::IllegalArgumentException( + "No Document Manager!", + static_cast< cppu::OWeakObject * >( this ), + 1 ); + } + + OUString aDocId = tdoc_ucp::OfficeDocumentsManager::queryDocumentId( Model ); + if ( aDocId.isEmpty() ) { - OUString aDocId = tdoc_ucp::OfficeDocumentsManager::queryDocumentId( Model ); - if ( !aDocId.isEmpty() ) - { - OUStringBuffer aBuffer; - aBuffer.append( TDOC_URL_SCHEME ":/" ); - aBuffer.append( aDocId ); + throw lang::IllegalArgumentException( + "Unable to obtain document id from model!", + static_cast< cppu::OWeakObject * >( this ), + 1 ); + } - uno::Reference< ucb::XContentIdentifier > xId - = new ::ucbhelper::ContentIdentifier( aBuffer.makeStringAndClear() ); + OUStringBuffer aBuffer; + aBuffer.append( TDOC_URL_SCHEME ":/" ); + aBuffer.append( aDocId ); - osl::MutexGuard aGuard( m_aMutex ); + uno::Reference< ucb::XContentIdentifier > xId + = new ::ucbhelper::ContentIdentifier( aBuffer.makeStringAndClear() ); - // Check, if a content with given id already exists... - uno::Reference< ucb::XContent > xContent - = queryExistingContent( xId ).get(); + osl::MutexGuard aGuard( m_aMutex ); - if ( !xContent.is() ) - { - // Create a new content. - xContent = Content::create( m_xContext, this, xId ); - } + // Check, if a content with given id already exists... + uno::Reference< ucb::XContent > xContent + = queryExistingContent( xId ).get(); - if ( xContent.is() ) - return xContent; + if ( !xContent.is() ) + { + // Create a new content. + xContent = Content::create( m_xContext, this, xId ); + } - // no content. - throw lang::IllegalArgumentException( - "Illegal Content Identifier!", - static_cast< cppu::OWeakObject * >( this ), - 1 ); - } - else - { - throw lang::IllegalArgumentException( - "Unable to obtain document id from model!", - static_cast< cppu::OWeakObject * >( this ), - 1 ); - } - } - else - { - throw lang::IllegalArgumentException( - "No Document Manager!", - static_cast< cppu::OWeakObject * >( this ), - 1 ); - } + if ( xContent.is() ) + return xContent; + + // no content. + throw lang::IllegalArgumentException( + "Illegal Content Identifier!", + static_cast< cppu::OWeakObject * >( this ), + 1 ); } diff --git a/ucb/source/ucp/webdav-neon/NeonInputStream.cxx b/ucb/source/ucp/webdav-neon/NeonInputStream.cxx index 6958ad90ea3c..3e43456a1838 100644 --- a/ucb/source/ucp/webdav-neon/NeonInputStream.cxx +++ b/ucb/source/ucp/webdav-neon/NeonInputStream.cxx @@ -117,10 +117,10 @@ void SAL_CALL NeonInputStream::seek( sal_Int64 location ) if ( location < 0 ) throw css::lang::IllegalArgumentException(); - if ( location <= mLen ) - mPos = location; - else + if ( location > mLen ) throw css::lang::IllegalArgumentException(); + + mPos = location; } sal_Int64 SAL_CALL NeonInputStream::getPosition() diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx index cc381283dd98..c49caa3d8367 100644 --- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx @@ -2553,53 +2553,52 @@ void Content::insert( if ( Environment.is() ) xIH = Environment->getInteractionHandler(); - if ( xIH.is() ) + if ( !xIH.is() ) { - uno::Any aExAsAny( uno::makeAny( aEx ) ); + // No IH; throw. + throw aEx; + } - rtl::Reference< ucbhelper::SimpleInteractionRequest > xRequest - = new ucbhelper::SimpleInteractionRequest( - aExAsAny, - ContinuationFlags::Approve | ContinuationFlags::Disapprove ); - xIH->handle( xRequest.get() ); + uno::Any aExAsAny( uno::makeAny( aEx ) ); - const ContinuationFlags nResp = xRequest->getResponse(); + rtl::Reference< ucbhelper::SimpleInteractionRequest > xRequest + = new ucbhelper::SimpleInteractionRequest( + aExAsAny, + ContinuationFlags::Approve | ContinuationFlags::Disapprove ); + xIH->handle( xRequest.get() ); - switch ( nResp ) - { - case ContinuationFlags::NONE: - // Not handled; throw. - throw aEx; + const ContinuationFlags nResp = xRequest->getResponse(); + + switch ( nResp ) + { + case ContinuationFlags::NONE: + // Not handled; throw. + throw aEx; // break; - case ContinuationFlags::Approve: - // Continue -> Overwrite. - bReplaceExisting = true; - break; + case ContinuationFlags::Approve: + // Continue -> Overwrite. + bReplaceExisting = true; + break; - case ContinuationFlags::Disapprove: - // Abort. - throw ucb::CommandFailedException( - OUString(), - uno::Reference< uno::XInterface >(), - aExAsAny ); + case ContinuationFlags::Disapprove: + // Abort. + throw ucb::CommandFailedException( + OUString(), + uno::Reference< uno::XInterface >(), + aExAsAny ); // break; - default: - SAL_WARN( "ucb.ucp.webdav", "Content::insert - " - "Unknown interaction selection!" ); - throw ucb::CommandFailedException( - "Unknown interaction selection!", - uno::Reference< uno::XInterface >(), - aExAsAny ); + default: + SAL_WARN( "ucb.ucp.webdav", "Content::insert - " + "Unknown interaction selection!" ); + throw ucb::CommandFailedException( + "Unknown interaction selection!", + uno::Reference< uno::XInterface >(), + aExAsAny ); // break; - } - } - else - { - // No IH; throw. - throw aEx; } + } } diff --git a/unoxml/source/rdf/CBlankNode.cxx b/unoxml/source/rdf/CBlankNode.cxx index b9a41668fdc8..500057c73824 100644 --- a/unoxml/source/rdf/CBlankNode.cxx +++ b/unoxml/source/rdf/CBlankNode.cxx @@ -93,12 +93,11 @@ void SAL_CALL CBlankNode::initialize(const css::uno::Sequence< css::uno::Any > & } //FIXME: what is legal? - if (!arg.isEmpty()) { - m_NodeID = arg; - } else { + if (arg.isEmpty()) { throw css::lang::IllegalArgumentException( "CBlankNode::initialize: argument is not valid blank node ID", *this, 0); } + m_NodeID = arg; } // css::rdf::XNode: diff --git a/unoxml/source/rdf/CLiteral.cxx b/unoxml/source/rdf/CLiteral.cxx index e1ffabccfc94..4aa81fcf5f51 100644 --- a/unoxml/source/rdf/CLiteral.cxx +++ b/unoxml/source/rdf/CLiteral.cxx @@ -102,30 +102,27 @@ void SAL_CALL CLiteral::initialize(const css::uno::Sequence< css::uno::Any > & a "CLiteral::initialize: argument must be string", *this, 0); } //FIXME: what is legal? - if ((true)) { - m_Value = arg0; - } else { + if (!(true)) { throw css::lang::IllegalArgumentException( "CLiteral::initialize: argument is not valid literal value", *this, 0); } + m_Value = arg0; if (len > 1) { OUString arg1; css::uno::Reference< css::rdf::XURI > xURI; if (aArguments[1] >>= arg1) { - if (!arg1.isEmpty()) { - m_Language = arg1; - } else { + if (arg1.isEmpty()) { throw css::lang::IllegalArgumentException( "CLiteral::initialize: argument is not valid language", *this, 1); } + m_Language = arg1; } else if (aArguments[1] >>= xURI) { - if (xURI.is()) { - m_xDatatype = xURI; - } else { + if (!xURI.is()) { throw css::lang::IllegalArgumentException( "CLiteral::initialize: argument is null", *this, 1); } + m_xDatatype = xURI; } else { throw css::lang::IllegalArgumentException( "CLiteral::initialize: argument must be string or URI", *this, 1); diff --git a/unoxml/source/rdf/CURI.cxx b/unoxml/source/rdf/CURI.cxx index 4ce0741f5cda..7392d44e9a89 100644 --- a/unoxml/source/rdf/CURI.cxx +++ b/unoxml/source/rdf/CURI.cxx @@ -743,34 +743,31 @@ void SAL_CALL CURI::initialize(const css::uno::Sequence< css::uno::Any > & aArgu // split parameter sal_Int32 idx; - if ( ((idx = arg0.indexOf ('#')) >= 0) - || ((idx = arg0.lastIndexOf('/')) >= 0) - || ((idx = arg0.lastIndexOf(':')) >= 0)) - { - - if (idx < arg0.getLength() - 1) { - arg1 = arg0.copy(idx+1); - arg0 = arg0.copy(0, idx+1); - } - } else { + if ( ((idx = arg0.indexOf ('#')) < 0) + && ((idx = arg0.lastIndexOf('/')) < 0) + && ((idx = arg0.lastIndexOf(':')) < 0) ) + { throw css::lang::IllegalArgumentException( "CURI::initialize: argument not splittable: no separator [#/:]", *this, 0); } + if (idx < arg0.getLength() - 1) { + arg1 = arg0.copy(idx+1); + arg0 = arg0.copy(0, idx+1); + } //FIXME: what is legal? - if (!arg0.isEmpty()) { - m_Namespace = arg0; - } else { + if (arg0.isEmpty()) { throw css::lang::IllegalArgumentException( "CURI::initialize: argument is not valid namespace", *this, 0); } + m_Namespace = arg0; + //FIXME: what is legal? - if ((true)) { - m_LocalName = arg1; - } else { + if ((false)) { throw css::lang::IllegalArgumentException( "CURI::initialize: argument is not valid local name", *this, 1); } + m_LocalName = arg1; } // css::rdf::XNode: diff --git a/unoxml/source/rdf/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx index 1b2fa29c2fe5..d2325543e6d3 100644 --- a/unoxml/source/rdf/librdf_repository.cxx +++ b/unoxml/source/rdf/librdf_repository.cxx @@ -493,31 +493,30 @@ css::uno::Any SAL_CALL librdf_GraphResult::nextElement() { ::osl::MutexGuard g(m_rMutex); - if (!m_pStream.get() || !librdf_stream_end(m_pStream.get())) { - librdf_node * pCtxt = getContext_Lock(); - - librdf_statement *pStmt( librdf_stream_get_object(m_pStream.get()) ); - if (!pStmt) { - rdf::QueryException e( - "librdf_GraphResult::nextElement: " - "librdf_stream_get_object failed", *this); - throw lang::WrappedTargetException( - "librdf_GraphResult::nextElement: " - "librdf_stream_get_object failed", *this, - uno::makeAny(e)); - } - // NB: pCtxt may be null here if this is result of a graph query - if (pCtxt && isInternalContext(pCtxt)) { - pCtxt = nullptr; // XML ID context is implementation detail! - } - rdf::Statement Stmt( - m_xRep->getTypeConverter().convertToStatement(pStmt, pCtxt) ); - // NB: this will invalidate current item. - librdf_stream_next(m_pStream.get()); - return uno::makeAny(Stmt); - } else { + if (m_pStream.get() && librdf_stream_end(m_pStream.get())) { throw container::NoSuchElementException(); } + librdf_node * pCtxt = getContext_Lock(); + + librdf_statement *pStmt( librdf_stream_get_object(m_pStream.get()) ); + if (!pStmt) { + rdf::QueryException e( + "librdf_GraphResult::nextElement: " + "librdf_stream_get_object failed", *this); + throw lang::WrappedTargetException( + "librdf_GraphResult::nextElement: " + "librdf_stream_get_object failed", *this, + uno::makeAny(e)); + } + // NB: pCtxt may be null here if this is result of a graph query + if (pCtxt && isInternalContext(pCtxt)) { + pCtxt = nullptr; // XML ID context is implementation detail! + } + rdf::Statement Stmt( + m_xRep->getTypeConverter().convertToStatement(pStmt, pCtxt) ); + // NB: this will invalidate current item. + librdf_stream_next(m_pStream.get()); + return uno::makeAny(Stmt); } @@ -601,35 +600,34 @@ css::uno::Any SAL_CALL librdf_QuerySelectResult::nextElement() { ::osl::MutexGuard g(m_rMutex); - if (!librdf_query_results_finished(m_pQueryResult.get())) { - sal_Int32 count(m_BindingNames.getLength()); - OSL_ENSURE(count >= 0, "negative length?"); - std::shared_ptr<librdf_node*> const pNodes(new librdf_node*[count], - NodeArrayDeleter(count)); - for (int i = 0; i < count; ++i) { - pNodes.get()[i] = nullptr; - } - if (librdf_query_results_get_bindings(m_pQueryResult.get(), nullptr, - pNodes.get())) - { - rdf::QueryException e( - "librdf_QuerySelectResult::nextElement: " - "librdf_query_results_get_bindings failed", *this); - throw lang::WrappedTargetException( - "librdf_QuerySelectResult::nextElement: " - "librdf_query_results_get_bindings failed", *this, - uno::makeAny(e)); - } - uno::Sequence< uno::Reference< rdf::XNode > > ret(count); - for (int i = 0; i < count; ++i) { - ret[i] = m_xRep->getTypeConverter().convertToXNode(pNodes.get()[i]); - } - // NB: this will invalidate current item. - librdf_query_results_next(m_pQueryResult.get()); - return uno::makeAny(ret); - } else { + if (librdf_query_results_finished(m_pQueryResult.get())) { throw container::NoSuchElementException(); } + sal_Int32 count(m_BindingNames.getLength()); + OSL_ENSURE(count >= 0, "negative length?"); + std::shared_ptr<librdf_node*> const pNodes(new librdf_node*[count], + NodeArrayDeleter(count)); + for (int i = 0; i < count; ++i) { + pNodes.get()[i] = nullptr; + } + if (librdf_query_results_get_bindings(m_pQueryResult.get(), nullptr, + pNodes.get())) + { + rdf::QueryException e( + "librdf_QuerySelectResult::nextElement: " + "librdf_query_results_get_bindings failed", *this); + throw lang::WrappedTargetException( + "librdf_QuerySelectResult::nextElement: " + "librdf_query_results_get_bindings failed", *this, + uno::makeAny(e)); + } + uno::Sequence< uno::Reference< rdf::XNode > > ret(count); + for (int i = 0; i < count; ++i) { + ret[i] = m_xRep->getTypeConverter().convertToXNode(pNodes.get()[i]); + } + // NB: this will invalidate current item. + librdf_query_results_next(m_pQueryResult.get()); + return uno::makeAny(ret); } // css::rdf::XQuerySelectResult: @@ -1302,27 +1300,25 @@ librdf_Repository::querySelect(const OUString & i_rQuery) } const int count( librdf_query_results_get_bindings_count(pResults.get()) ); - if (count >= 0) { - uno::Sequence< OUString > names(count); - for (int i = 0; i < count; ++i) { - const char* name( librdf_query_results_get_binding_name( - pResults.get(), i) ); - if (!name) { - throw rdf::QueryException( - "librdf_Repository::querySelect: binding is null", *this); - } - - names[i] = OUString::createFromAscii(name); - } - - return new librdf_QuerySelectResult(this, m_aMutex, - pQuery, pResults, names); - - } else { + if (count < 0) { throw rdf::QueryException( "librdf_Repository::querySelect: " "librdf_query_results_get_bindings_count failed", *this); } + uno::Sequence< OUString > names(count); + for (int i = 0; i < count; ++i) { + const char* name( librdf_query_results_get_binding_name( + pResults.get(), i) ); + if (!name) { + throw rdf::QueryException( + "librdf_Repository::querySelect: binding is null", *this); + } + + names[i] = OUString::createFromAscii(name); + } + + return new librdf_QuerySelectResult(this, m_aMutex, + pQuery, pResults, names); } uno::Reference< container::XEnumeration > SAL_CALL diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index 2bf5e9adfb2a..3bf6a5549f29 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -408,19 +408,17 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St } } - if ( xNewControl.is() ) - { - UpdateCollectionIndex( lcl_controlsWrapper( mxDialog ) ); - aResult <<= xNewControl; - aResult = createCollectionObject( aResult ); - uno::Reference< msforms::XControl > xVBAControl( aResult, uno::UNO_QUERY_THROW ); - if( fDefWidth > 0.0 ) - xVBAControl->setWidth( fDefWidth ); - if( fDefHeight > 0.0 ) - xVBAControl->setHeight( fDefHeight ); - } - else + if ( !xNewControl.is() ) throw uno::RuntimeException(); + + UpdateCollectionIndex( lcl_controlsWrapper( mxDialog ) ); + aResult <<= xNewControl; + aResult = createCollectionObject( aResult ); + uno::Reference< msforms::XControl > xVBAControl( aResult, uno::UNO_QUERY_THROW ); + if( fDefWidth > 0.0 ) + xVBAControl->setWidth( fDefWidth ); + if( fDefHeight > 0.0 ) + xVBAControl->setHeight( fDefHeight ); } catch (const uno::RuntimeException&) { diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index da33cbcaf673..b3a53214295e 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -319,35 +319,33 @@ uno::Any SAL_CALL VbaApplicationBase::Run( const OUString& MacroName, const uno: xModel = getCurrentDocument(); MacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( xModel ), aMacroName ); - if( aMacroInfo.mbFound ) + if( !aMacroInfo.mbFound ) { - // handle the arguments - const uno::Any* aArgsPtrArray[] = { &varg1, &varg2, &varg3, &varg4, &varg5, &varg6, &varg7, &varg8, &varg9, &varg10, &varg11, &varg12, &varg13, &varg14, &varg15, &varg16, &varg17, &varg18, &varg19, &varg20, &varg21, &varg22, &varg23, &varg24, &varg25, &varg26, &varg27, &varg28, &varg29, &varg30 }; + throw uno::RuntimeException( "The macro doesn't exist" ); + } - int nArg = SAL_N_ELEMENTS( aArgsPtrArray ); - uno::Sequence< uno::Any > aArgs( nArg ); + // handle the arguments + const uno::Any* aArgsPtrArray[] = { &varg1, &varg2, &varg3, &varg4, &varg5, &varg6, &varg7, &varg8, &varg9, &varg10, &varg11, &varg12, &varg13, &varg14, &varg15, &varg16, &varg17, &varg18, &varg19, &varg20, &varg21, &varg22, &varg23, &varg24, &varg25, &varg26, &varg27, &varg28, &varg29, &varg30 }; - const uno::Any** pArg = aArgsPtrArray; - const uno::Any** pArgEnd = ( aArgsPtrArray + nArg ); + int nArg = SAL_N_ELEMENTS( aArgsPtrArray ); + uno::Sequence< uno::Any > aArgs( nArg ); - sal_Int32 nArgProcessed = 0; + const uno::Any** pArg = aArgsPtrArray; + const uno::Any** pArgEnd = ( aArgsPtrArray + nArg ); - for ( ; pArg != pArgEnd; ++pArg, ++nArgProcessed ) - aArgs[ nArgProcessed ] = **pArg; + sal_Int32 nArgProcessed = 0; - // resize array to position of last param with value - aArgs.realloc( nArgProcessed + 1 ); + for ( ; pArg != pArgEnd; ++pArg, ++nArgProcessed ) + aArgs[ nArgProcessed ] = **pArg; - uno::Any aRet; - uno::Any aDummyCaller; - executeMacro( aMacroInfo.mpDocContext, aMacroInfo.msResolvedMacro, aArgs, aRet, aDummyCaller ); + // resize array to position of last param with value + aArgs.realloc( nArgProcessed + 1 ); - return aRet; - } - else - { - throw uno::RuntimeException( "The macro doesn't exist" ); - } + uno::Any aRet; + uno::Any aDummyCaller; + executeMacro( aMacroInfo.mpDocContext, aMacroInfo.msResolvedMacro, aArgs, aRet, aDummyCaller ); + + return aRet; } void SAL_CALL VbaApplicationBase::OnTime( const uno::Any& aEarliestTime, const OUString& aFunction, const uno::Any& aLatestTime, const uno::Any& aSchedule ) diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx index 915913586798..cded9f7c309e 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrols.cxx @@ -38,12 +38,10 @@ public: } virtual uno::Any SAL_CALL nextElement() override { - if( hasMoreElements() ) - { - return m_pCommandBarControls->createCollectionObject( uno::makeAny( m_nCurrentPosition++ ) ); - } - else + if( !hasMoreElements() ) throw container::NoSuchElementException(); + + return m_pCommandBarControls->createCollectionObject( uno::makeAny( m_nCurrentPosition++ ) ); } }; diff --git a/vbahelper/source/vbahelper/vbacommandbars.cxx b/vbahelper/source/vbahelper/vbacommandbars.cxx index 27340c9e4873..dfd0f2fa565e 100644 --- a/vbahelper/source/vbahelper/vbacommandbars.cxx +++ b/vbahelper/source/vbahelper/vbacommandbars.cxx @@ -55,23 +55,21 @@ public: virtual uno::Any SAL_CALL nextElement() override { // FIXME: should be add menubar - if( hasMoreElements() ) - { - OUString sResourceUrl( m_sNames[ m_nCurrentPosition++ ] ); - if( sResourceUrl.indexOf( "private:resource/toolbar/" ) != -1 ) - { - uno::Reference< container::XIndexAccess > xCBarSetting = m_pCBarHelper->getSettings( sResourceUrl ); - uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( m_xParent, m_xContext, m_pCBarHelper, xCBarSetting, sResourceUrl, false ) ); - // Strange, shouldn't the Enumeration support match/share the - // iteration code? ( e.g. ScVbaCommandBars::Item(...) ) - // and we at least should return here ( something ) it seems - return uno::makeAny( xCommandBar ); - } - else - return nextElement(); - } - else + if( !hasMoreElements() ) throw container::NoSuchElementException(); + + OUString sResourceUrl( m_sNames[ m_nCurrentPosition++ ] ); + if( sResourceUrl.indexOf( "private:resource/toolbar/" ) != -1 ) + { + uno::Reference< container::XIndexAccess > xCBarSetting = m_pCBarHelper->getSettings( sResourceUrl ); + uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( m_xParent, m_xContext, m_pCBarHelper, xCBarSetting, sResourceUrl, false ) ); + // Strange, shouldn't the Enumeration support match/share the + // iteration code? ( e.g. ScVbaCommandBars::Item(...) ) + // and we at least should return here ( something ) it seems + return uno::makeAny( xCommandBar ); + } + else + return nextElement(); } }; diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index e313088635e2..ff0c5f591cba 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -741,10 +741,10 @@ void setDefaultPropByIntrospection( const uno::Any& aObj, const uno::Any& aValue if ( xUnoAccess.is() ) xPropSet.set( xUnoAccess->queryAdapter( cppu::UnoType<beans::XPropertySet>::get()), uno::UNO_QUERY); - if ( xPropSet.is() ) - xPropSet->setPropertyValue( xDflt->getDefaultPropertyName(), aValue ); - else + if ( !xPropSet.is() ) throw uno::RuntimeException(); + + xPropSet->setPropertyValue( xDflt->getDefaultPropertyName(), aValue ); } uno::Any getPropertyValue( const uno::Sequence< beans::PropertyValue >& aProp, const OUString& aName ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits