[Libreoffice-commits] core.git: unoxml/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 6 07:27:54 UTC 2020
unoxml/source/dom/document.cxx | 27 +++++-----
unoxml/source/dom/saxbuilder.cxx | 26 ++++-----
unoxml/source/events/eventdispatcher.cxx | 83 +++++++++++++++----------------
unoxml/source/rdf/CLiteral.cxx | 35 ++++++-------
unoxml/source/rdf/librdf_repository.cxx | 33 ++++++------
5 files changed, 104 insertions(+), 100 deletions(-)
New commits:
commit febc581c30fe22eb133d5c1e355fc12fe3c0dc39
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 5 20:28:37 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Aug 6 09:27:18 2020 +0200
loplugin:flatten in unoxml
Change-Id: I7c85b3618450ea6914c3076b0dca67ef4847be51
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100187
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx
index 68f88442e4f5..c753f37c6054 100644
--- a/unoxml/source/dom/document.cxx
+++ b/unoxml/source/dom/document.cxx
@@ -137,19 +137,20 @@ namespace DOM
CDocument::RemoveCNode(xmlNodePtr const pNode, CNode const*const pCNode)
{
nodemap_t::iterator const i = m_NodeMap.find(pNode);
- if (i != m_NodeMap.end()) {
- // #i113681# consider this scenario:
- // T1 calls ~CNode
- // T2 calls getCNode: lookup will find i->second->first invalid
- // so a new CNode is created and inserted
- // T1 calls removeCNode: i->second->second now points to a
- // different CNode instance!
-
- // check that the CNode is the right one
- CNode *const pCurrent = i->second.second;
- if (pCurrent == pCNode) {
- m_NodeMap.erase(i);
- }
+ if (i == m_NodeMap.end())
+ return;
+
+ // #i113681# consider this scenario:
+ // T1 calls ~CNode
+ // T2 calls getCNode: lookup will find i->second->first invalid
+ // so a new CNode is created and inserted
+ // T1 calls removeCNode: i->second->second now points to a
+ // different CNode instance!
+
+ // check that the CNode is the right one
+ CNode *const pCurrent = i->second.second;
+ if (pCurrent == pCNode) {
+ m_NodeMap.erase(i);
}
}
diff --git a/unoxml/source/dom/saxbuilder.cxx b/unoxml/source/dom/saxbuilder.cxx
index 25686b21c4de..b0e521f033e4 100644
--- a/unoxml/source/dom/saxbuilder.cxx
+++ b/unoxml/source/dom/saxbuilder.cxx
@@ -225,20 +225,20 @@ namespace DOM
aElement.set( m_aNodeStack.top()->appendChild(aElement), UNO_QUERY);
m_aNodeStack.push(aElement);
- if (xAttribs.is())
+ if (!xAttribs.is())
+ return;
+
+ setElementFastAttributes(aElement, xAttribs);
+ const Sequence< css::xml::Attribute > unknownAttribs = xAttribs->getUnknownAttributes();
+ for ( const auto& rUnknownAttrib : unknownAttribs )
{
- setElementFastAttributes(aElement, xAttribs);
- const Sequence< css::xml::Attribute > unknownAttribs = xAttribs->getUnknownAttributes();
- for ( const auto& rUnknownAttrib : unknownAttribs )
- {
- const OUString& rAttrValue = rUnknownAttrib.Value;
- const OUString& rAttrName = rUnknownAttrib.Name;
- const OUString& rAttrNamespace = rUnknownAttrib.NamespaceURL;
- if ( !rAttrNamespace.isEmpty() )
- aElement->setAttributeNS( rAttrNamespace, rAttrName, rAttrValue );
- else
- aElement->setAttribute( rAttrName, rAttrValue );
- }
+ const OUString& rAttrValue = rUnknownAttrib.Value;
+ const OUString& rAttrName = rUnknownAttrib.Name;
+ const OUString& rAttrNamespace = rUnknownAttrib.NamespaceURL;
+ if ( !rAttrNamespace.isEmpty() )
+ aElement->setAttributeNS( rAttrNamespace, rAttrName, rAttrValue );
+ else
+ aElement->setAttribute( rAttrName, rAttrValue );
}
}
diff --git a/unoxml/source/events/eventdispatcher.cxx b/unoxml/source/events/eventdispatcher.cxx
index ef07dff5ad2d..cc5fb159d3c8 100644
--- a/unoxml/source/events/eventdispatcher.cxx
+++ b/unoxml/source/events/eventdispatcher.cxx
@@ -60,20 +60,21 @@ namespace DOM::events {
// get the multimap for the specified type
auto tIter = pTMap->find(aType);
- if (tIter != pTMap->end()) {
- ListenerMap & rMap = tIter->second;
- // find listeners of specified type for specified node
- ListenerMap::iterator iter = rMap.find(pNode);
- while (iter != rMap.end() && iter->first == pNode)
+ if (tIter == pTMap->end())
+ return;
+
+ ListenerMap & rMap = tIter->second;
+ // find listeners of specified type for specified node
+ ListenerMap::iterator iter = rMap.find(pNode);
+ while (iter != rMap.end() && iter->first == pNode)
+ {
+ // erase all references to specified listener
+ if (iter->second.is() && iter->second == aListener)
{
- // erase all references to specified listener
- if (iter->second.is() && iter->second == aListener)
- {
- iter = rMap.erase(iter);
- }
- else
- ++iter;
+ iter = rMap.erase(iter);
}
+ else
+ ++iter;
}
}
@@ -210,38 +211,38 @@ namespace DOM::events {
// start at the root
NodeVector_t::const_reverse_iterator rinode =
const_cast<NodeVector_t const&>(captureVector).rbegin();
- if (rinode != const_cast<NodeVector_t const&>(captureVector).rend())
+ if (rinode == const_cast<NodeVector_t const&>(captureVector).rend())
+ return;
+
+ // capturing phase:
+ pEvent->m_phase = PhaseType_CAPTURING_PHASE;
+ while (rinode !=
+ const_cast<NodeVector_t const&>(captureVector).rend())
{
- // capturing phase:
- pEvent->m_phase = PhaseType_CAPTURING_PHASE;
- while (rinode !=
- const_cast<NodeVector_t const&>(captureVector).rend())
+ pEvent->m_currentTarget = rinode->first;
+ callListeners(captureListeners, rinode->second, aType, xEvent);
+ if (pEvent->m_canceled) return;
+ ++rinode;
+ }
+
+ NodeVector_t::const_iterator inode = captureVector.begin();
+
+ // target phase
+ pEvent->m_phase = PhaseType_AT_TARGET;
+ pEvent->m_currentTarget = inode->first;
+ callListeners(targetListeners, inode->second, aType, xEvent);
+ if (pEvent->m_canceled) return;
+ // bubbeling phase
+ ++inode;
+ if (i_xEvent->getBubbles()) {
+ pEvent->m_phase = PhaseType_BUBBLING_PHASE;
+ while (inode != captureVector.end())
{
- pEvent->m_currentTarget = rinode->first;
- callListeners(captureListeners, rinode->second, aType, xEvent);
+ pEvent->m_currentTarget = inode->first;
+ callListeners(targetListeners,
+ inode->second, aType, xEvent);
if (pEvent->m_canceled) return;
- ++rinode;
- }
-
- NodeVector_t::const_iterator inode = captureVector.begin();
-
- // target phase
- pEvent->m_phase = PhaseType_AT_TARGET;
- pEvent->m_currentTarget = inode->first;
- callListeners(targetListeners, inode->second, aType, xEvent);
- if (pEvent->m_canceled) return;
- // bubbeling phase
- ++inode;
- if (i_xEvent->getBubbles()) {
- pEvent->m_phase = PhaseType_BUBBLING_PHASE;
- while (inode != captureVector.end())
- {
- pEvent->m_currentTarget = inode->first;
- callListeners(targetListeners,
- inode->second, aType, xEvent);
- if (pEvent->m_canceled) return;
- ++inode;
- }
+ ++inode;
}
}
}
diff --git a/unoxml/source/rdf/CLiteral.cxx b/unoxml/source/rdf/CLiteral.cxx
index 1b7297169cee..ac0eadcd6985 100644
--- a/unoxml/source/rdf/CLiteral.cxx
+++ b/unoxml/source/rdf/CLiteral.cxx
@@ -105,25 +105,26 @@ void SAL_CALL CLiteral::initialize(const css::uno::Sequence< css::uno::Any > & a
}
m_Value = arg0;
- if (len > 1) {
- OUString arg1;
- css::uno::Reference< css::rdf::XURI > xURI;
- if (aArguments[1] >>= arg1) {
- 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()) {
- throw css::lang::IllegalArgumentException(
- "CLiteral::initialize: argument is null", *this, 1);
- }
- m_xDatatype = xURI;
- } else {
+ if (len <= 1)
+ return;
+
+ OUString arg1;
+ css::uno::Reference< css::rdf::XURI > xURI;
+ if (aArguments[1] >>= arg1) {
+ 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()) {
throw css::lang::IllegalArgumentException(
- "CLiteral::initialize: argument must be string or URI", *this, 1);
+ "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/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx
index 519ec4a5fd26..9ebd7217b24f 100644
--- a/unoxml/source/rdf/librdf_repository.cxx
+++ b/unoxml/source/rdf/librdf_repository.cxx
@@ -1916,22 +1916,23 @@ void librdf_Repository::removeStatementsGraph_NoLock(
"librdf_model_find_statements_in_context failed", *this);
}
- if (!librdf_stream_end(pStream.get())) {
- do {
- librdf_statement *pStmt( librdf_stream_get_object(pStream.get()) );
- if (!pStmt) {
- throw rdf::RepositoryException(
- "librdf_Repository::removeStatements: "
- "librdf_stream_get_object failed", *this);
- }
- if (librdf_model_context_remove_statement(m_pModel.get(),
- pContext.get(), pStmt)) {
- throw rdf::RepositoryException(
- "librdf_Repository::removeStatements: "
- "librdf_model_context_remove_statement failed", *this);
- }
- } while (!librdf_stream_next(pStream.get()));
- }
+ if (librdf_stream_end(pStream.get()))
+ return;
+
+ do {
+ librdf_statement *pStmt( librdf_stream_get_object(pStream.get()) );
+ if (!pStmt) {
+ throw rdf::RepositoryException(
+ "librdf_Repository::removeStatements: "
+ "librdf_stream_get_object failed", *this);
+ }
+ if (librdf_model_context_remove_statement(m_pModel.get(),
+ pContext.get(), pStmt)) {
+ throw rdf::RepositoryException(
+ "librdf_Repository::removeStatements: "
+ "librdf_model_context_remove_statement failed", *this);
+ }
+ } while (!librdf_stream_next(pStream.get()));
}
std::vector<rdf::Statement>
More information about the Libreoffice-commits
mailing list