summaryrefslogtreecommitdiff
path: root/unoxml/source/rdf
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-26 12:01:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-27 09:05:39 +0200
commit467724410dc470ec259131f97abd836fe9b021a1 (patch)
treec4af76c0132cc6a4638eace0ccebe5ae1bd9e305 /unoxml/source/rdf
parente827d227c92c338fb75f076b6d3f3a7b52b9f767 (diff)
loplugin:flatten in toolkit..vbahelper
Change-Id: I6d4be3e1cc29b2b91d5c39b757ff3b903c47112d Reviewed-on: https://gerrit.libreoffice.org/42794 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unoxml/source/rdf')
-rw-r--r--unoxml/source/rdf/CBlankNode.cxx5
-rw-r--r--unoxml/source/rdf/CLiteral.cxx15
-rw-r--r--unoxml/source/rdf/CURI.cxx29
-rw-r--r--unoxml/source/rdf/librdf_repository.cxx130
4 files changed, 84 insertions, 95 deletions
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