[Libreoffice-commits] core.git: unoxml/qa unoxml/source
unoxml/qa/unit/domtest.cxx | 15 --- unoxml/source/rdf/librdf_repository.cxx |6 -- 2 files changed, 12 insertions(+), 9 deletions(-) New commits: commit 359a17d0215d36a441688ac3261af04f20a03c6c Author: Mike Kaganski AuthorDate: Fri Oct 29 10:22:53 2021 +0300 Commit: Mike Kaganski CommitDate: Sun Oct 31 21:36:50 2021 +0100 Prepare for removal of non-const operator[] from Sequence in unoxml Change-Id: Ie7738eb599ac2ae98618e258786b2a0d956cb9dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124408 Tested-by: Jenkins Reviewed-by: Mike Kaganski diff --git a/unoxml/qa/unit/domtest.cxx b/unoxml/qa/unit/domtest.cxx index c6501547183c..3a715a9ed314 100644 --- a/unoxml/qa/unit/domtest.cxx +++ b/unoxml/qa/unit/domtest.cxx @@ -293,13 +293,14 @@ struct SerializerTest : public test::BootstrapFixture mxHandler.set( new DocumentHandler ); mxTokHandler.set( new TokenHandler ); -maRegisteredNamespaces.realloc(2); -maRegisteredNamespaces[0] = beans::make_Pair( -OUString( "urn:oasis:names:tc:opendocument:xmlns:office:1.0" ), -xml::sax::FastToken::NAMESPACE); -maRegisteredNamespaces[1] = beans::make_Pair( -OUString( "http://www.w3.org/1999/xlink"; ), -2*xml::sax::FastToken::NAMESPACE); +maRegisteredNamespaces = { +beans::make_Pair( +OUString( "urn:oasis:names:tc:opendocument:xmlns:office:1.0" ), +xml::sax::FastToken::NAMESPACE), +beans::make_Pair( +OUString( "http://www.w3.org/1999/xlink"; ), +2*xml::sax::FastToken::NAMESPACE) +}; } void serializerTest () diff --git a/unoxml/source/rdf/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx index f9e918aff168..176a871fa872 100644 --- a/unoxml/source/rdf/librdf_repository.cxx +++ b/unoxml/source/rdf/librdf_repository.cxx @@ -670,8 +670,9 @@ librdf_QuerySelectResult::nextElement() uno::makeAny(e)); } uno::Sequence< uno::Reference< rdf::XNode > > ret(count); +auto retRange = asNonConstRange(ret); for (int i = 0; i < count; ++i) { -ret[i] = m_xRep->getTypeConverter().convertToXNode(aNodes[i]); +retRange[i] = m_xRep->getTypeConverter().convertToXNode(aNodes[i]); } // NB: this will invalidate current item. librdf_query_results_next(m_pQueryResult.get()); @@ -1403,6 +1404,7 @@ librdf_Repository::querySelect(const OUString & i_rQuery) "librdf_query_results_get_bindings_count failed", *this); } uno::Sequence< OUString > names(count); +auto namesRange = asNonConstRange(names); for (int i = 0; i < count; ++i) { const char* name( librdf_query_results_get_binding_name( pResults.get(), i) ); @@ -1411,7 +1413,7 @@ librdf_Repository::querySelect(const OUString & i_rQuery) "librdf_Repository::querySelect: binding is null", *this); } -names[i] = OUString::createFromAscii(name); +namesRange[i] = OUString::createFromAscii(name); } return new librdf_QuerySelectResult(this, m_aMutex,
[Libreoffice-commits] core.git: unoxml/qa unoxml/source
unoxml/qa/unit/domtest.cxx|6 +++--- unoxml/source/rdf/librdf_services.cxx |2 +- 2 files changed, 4 insertions(+), 4 deletions(-) New commits: commit fdab50022519d8d794a00a3693e66bd8f3fad303 Author: Stephan Bergmann AuthorDate: Thu Jul 2 11:30:35 2020 +0200 Commit: Stephan Bergmann CommitDate: Thu Jul 2 13:44:51 2020 +0200 Upcoming improved loplugin:staticanonymous -> redundantstatic: unoxml Change-Id: I755d70b8aeadf8946dacb20292e97797a51aa44a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97738 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/unoxml/qa/unit/domtest.cxx b/unoxml/qa/unit/domtest.cxx index b6e468defdb5..67afde99d3a0 100644 --- a/unoxml/qa/unit/domtest.cxx +++ b/unoxml/qa/unit/domtest.cxx @@ -40,7 +40,7 @@ using css::xml::dom::XDocumentBuilder; namespace { // valid xml -static const char validTestFile[] = +const char validTestFile[] = " \ \ \ https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: unoxml/qa unoxml/source
unoxml/qa/unit/domtest.cxx |2 +- unoxml/source/dom/document.cxx | 24 +--- unoxml/source/dom/saxbuilder.cxx|9 - unoxml/source/rdf/librdf_repository.cxx | 10 -- 4 files changed, 18 insertions(+), 27 deletions(-) New commits: commit 9a2fbfa3cc1da8bd9388d5b4c780e86f0dccc791 Author: Arkadiy Illarionov AuthorDate: Sun Jun 23 16:10:50 2019 +0300 Commit: Arkadiy Illarionov CommitDate: Tue Jun 25 21:42:40 2019 +0200 Simplify Sequence iterations in unoxml Use range-based loops or replace with STL functions Change-Id: Ib1c49834a2c5c67a73ec05ba8f30c1d39a5c019c Reviewed-on: https://gerrit.libreoffice.org/74600 Reviewed-by: Michael Stahl Tested-by: Jenkins diff --git a/unoxml/qa/unit/domtest.cxx b/unoxml/qa/unit/domtest.cxx index 15e337772314..0a80d2a4cadc 100644 --- a/unoxml/qa/unit/domtest.cxx +++ b/unoxml/qa/unit/domtest.cxx @@ -181,7 +181,7 @@ struct TokenHandler { virtual ::sal_Int32 SAL_CALL getTokenFromUTF8( const uno::Sequence< ::sal_Int8 >& Identifier ) override { -return Identifier.getLength() ? Identifier[0] : 0; +return Identifier.hasElements() ? Identifier[0] : 0; } virtual uno::Sequence< ::sal_Int8 > SAL_CALL getUTF8Identifier( ::sal_Int32 ) override diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx index 94dce24255ac..fc89b8aa4980 100644 --- a/unoxml/source/dom/document.cxx +++ b/unoxml/source/dom/document.cxx @@ -965,12 +965,10 @@ namespace DOM // add new namespaces to root node xmlNodePtr const pRoot = lcl_getDocumentRootPtr(m_aDocPtr); if (nullptr != pRoot) { -const beans::StringPair * pSeq = i_rNamespaces.getConstArray(); -for (const beans::StringPair *pNsDef = pSeq; - pNsDef < pSeq + i_rNamespaces.getLength(); ++pNsDef) { -OString prefix = OUStringToOString(pNsDef->First, +for (const beans::StringPair& rNsDef : i_rNamespaces) { +OString prefix = OUStringToOString(rNsDef.First, RTL_TEXTENCODING_UTF8); -OString href = OUStringToOString(pNsDef->Second, +OString href = OUStringToOString(rNsDef.Second, RTL_TEXTENCODING_UTF8); // this will only add the ns if it does not exist already xmlNewNs(pRoot, reinterpret_cast(href.getStr()), @@ -993,12 +991,10 @@ namespace DOM // add new namespaces to root node xmlNodePtr const pRoot = lcl_getDocumentRootPtr(m_aDocPtr); if (nullptr != pRoot) { -const beans::StringPair * pSeq = i_rNamespaces.getConstArray(); -for (const beans::StringPair *pNsDef = pSeq; - pNsDef < pSeq + i_rNamespaces.getLength(); ++pNsDef) { -OString prefix = OUStringToOString(pNsDef->First, +for (const beans::StringPair& rNsDef : i_rNamespaces) { +OString prefix = OUStringToOString(rNsDef.First, RTL_TEXTENCODING_UTF8); -OString href = OUStringToOString(pNsDef->Second, +OString href = OUStringToOString(rNsDef.Second, RTL_TEXTENCODING_UTF8); // this will only add the ns if it does not exist already xmlNewNs(pRoot, reinterpret_cast(href.getStr()), @@ -1012,13 +1008,11 @@ namespace DOM i_xTokenHandler); // register namespace ids -const beans::Pair* pSeq = i_rRegisterNamespaces.getConstArray(); -for (const beans::Pair* pNs = pSeq; - pNs < pSeq + i_rRegisterNamespaces.getLength(); ++pNs) +for (const beans::Pair& rNs : i_rRegisterNamespaces) { -OSL_ENSURE(pNs->Second >= FastToken::NAMESPACE, +OSL_ENSURE(rNs.Second >= FastToken::NAMESPACE, "CDocument::fastSerialize(): invalid NS token id"); -aContext.maNamespaceMap[ pNs->First ] = pNs->Second; +aContext.maNamespaceMap[ rNs.First ] = rNs.Second; } fastSaxify(aContext); diff --git a/unoxml/source/dom/saxbuilder.cxx b/unoxml/source/dom/saxbuilder.cxx index 994a6c0392f6..968971f29d2c 100644 --- a/unoxml/source/dom/saxbuilder.cxx +++ b/unoxml/source/dom/saxbuilder.cxx @@ -254,12 +254,11 @@ namespace DOM { setElementFastAttributes(aElement, xAttribs); Sequence< css::xml::Attribute > unknownAttribs = xAttribs->getUnknownAttributes(); -sal_Int32 len = unknownAttribs.getLength(); -for ( sal_Int32 i = 0; i < len; i++ ) +for ( const auto& rUnknownAttrib : unknownAttribs ) { -const OUString& rAttrValue = unknownAttribs[i].Value; -const OUString& rAttrName = unknownAttribs[i].Name; -
[Libreoffice-commits] core.git: unoxml/qa unoxml/source
unoxml/qa/unit/domtest.cxx| 161 +++--- unoxml/source/dom/documentbuilder.cxx | 68 -- unoxml/source/dom/documentbuilder.hxx | 11 ++ 3 files changed, 162 insertions(+), 78 deletions(-) New commits: commit d181d8acbf49e2fe87c8cf53a9431e503ccced55 Author: Fyodor Yemelyanenko Date: Mon Aug 21 16:11:14 2017 +1000 tdf#84237 use XErrorHandler in CDocumentBuilder In documentbuilder.cxx added code to call XErrorHandler::warning and XErrorHandler::error functions (from DOM::warning_func and DOM::error_func) In domtest.cxx added try {} catch () block to BasicTest::validInputTest, BasicTest::warningInputTest and BasicTest::errorInputTest and to SerializerTest::serializerTest. Also uncommented lines CPPUNIT_TEST(warningInputTest); and CPPUNIT_TEST(errorInputTest); Unit tests are now working (FatalError test removed, as lib2xml doesn't distinguish between error and fatal error and counts everything as error). Change-Id: I27c5036df6a1cc5bef5dbb8171c201d81bae2ccd Reviewed-on: https://gerrit.libreoffice.org/41376 Reviewed-by: Michael Stahl Tested-by: Michael Stahl diff --git a/unoxml/qa/unit/domtest.cxx b/unoxml/qa/unit/domtest.cxx index 6080020e7647..18e37a8fa297 100644 --- a/unoxml/qa/unit/domtest.cxx +++ b/unoxml/qa/unit/domtest.cxx @@ -37,6 +37,7 @@ #include #include #include +#include using namespace ::comphelper; using namespace ::com::sun::star; @@ -61,16 +62,20 @@ static const char validTestFile[] = \ "; -// generates a warning: unsupported xml version, unknown xml:space +// generates a warning: unknown xml:space // value static const char warningTestFile[] = -" \ +" \ http://www.w3.org/1999/xlink\"; \ office:version=\"1.0\"> \ \ -\ +\ +\ +\ +some text \303\266\303\244\303\274 \ \ "; @@ -85,19 +90,17 @@ static const char errorTestFile[] = \ "; -// plain empty -static const char fatalTestFile[] = ""; - struct ErrorHandler : public ::cppu::WeakImplHelper< xml::sax::XErrorHandler > { sal_uInt32 mnErrCount; -sal_uInt32 mnFatalCount; +//sal_uInt32 mnFatalCount; // No fatal error counter, as lib2xml doesn't distinguish between error and fatal error +// (see See xmlFatalErrMsg from lib2xml/parse.c and __xmlRaiseError from lib2xml/error.c) sal_uInt32 mnWarnCount; -bool noErrors() const { return !mnErrCount && !mnFatalCount && !mnWarnCount; } +bool noErrors() const { return !mnErrCount /*&& !mnFatalCount*/ && !mnWarnCount; } -ErrorHandler() : mnErrCount(0), mnFatalCount(0), mnWarnCount(0) +ErrorHandler() : mnErrCount(0), /*mnFatalCount(0),*/ mnWarnCount(0) {} virtual void SAL_CALL error( const uno::Any& ) override @@ -105,9 +108,11 @@ struct ErrorHandler ++mnErrCount; } +// Just implement FatalError function as it is in XErrorHandler +// This function is never used, as lib2xml doesn't distinguish between error and fatalerror and calls error functions in both cases virtual void SAL_CALL fatalError( const uno::Any& ) override { -++mnFatalCount; +//++mnFatalCount; } virtual void SAL_CALL warning( const uno::Any& ) override @@ -195,7 +200,6 @@ struct BasicTest : public test::BootstrapFixture rtl::Reference mxValidInStream; rtl::Reference mxWarningInStream; rtl::Reference mxErrorInStream; -rtl::Reference mxFatalInStream; virtual void setUp() override { @@ -207,58 +211,70 @@ struct BasicTest : public test::BootstrapFixture mxValidInStream.set( new SequenceInputStream(css::uno::Sequence(reinterpret_cast(validTestFile), SAL_N_ELEMENTS(validTestFile))) ); mxWarningInStream.set( new SequenceInputStream(css::uno::Sequence(reinterpret_cast(warningTestFile), SAL_N_ELEMENTS(warningTestFile))) ); mxErrorInStream.set( new SequenceInputStream(css::uno::Sequence(reinterpret_cast(errorTestFile), SAL_N_ELEMENTS(errorTestFile))) ); -mxFatalInStream.set( new SequenceInputStream(css::uno::Sequence(reinterpret_cast(fatalTestFile), SAL_N_ELEMENTS(fatalTestFile))) ); mxDomBuilder->setErrorHandler(mxErrHandler.get()); } void validInputTest() { -CPPUNIT_ASSERT_MESSAGE( "Valid input file did not result in XDocument #1", -mxDomBuilder->parse( -uno::Reference( -mxValidInStream.get())).is() ); -CPPUNIT_ASSERT_MESSAGE( "Valid input file resulted in parse errors", -mxErrHandler->noErrors() ); +try +{ +CPPUNIT_ASSERT_MESSAGE("Valid input file did not result in XDocument #1", +mxDomBuilder->parse( +uno::Reference( +mxValidInStream.get())).is()); +CPPUNIT_ASSERT_MESSAGE("Valid
[Libreoffice-commits] core.git: unoxml/qa unoxml/source
unoxml/qa/complex/unoxml/DOMTest.java | 18 +++ unoxml/source/dom/document.cxx |2 - unoxml/source/rdf/librdf_repository.cxx | 38 3 files changed, 29 insertions(+), 29 deletions(-) New commits: commit d952ba2a7505021066d7fe5a01f14a02135edb65 Author: Alexander Wilms Date: Tue Feb 25 22:47:02 2014 +0100 Remove visual noise from unoxml Change-Id: I405f2df6621197effd7e2b19844fe4d0bf7f58aa Reviewed-on: https://gerrit.libreoffice.org/8335 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara diff --git a/unoxml/qa/complex/unoxml/DOMTest.java b/unoxml/qa/complex/unoxml/DOMTest.java index ed4374c..3a44eaf 100644 --- a/unoxml/qa/complex/unoxml/DOMTest.java +++ b/unoxml/qa/complex/unoxml/DOMTest.java @@ -386,7 +386,7 @@ public class DOMTest } } -// XNode +// XNode { XNode xDocCloneN = xDoc.cloneNode(false); @@ -579,7 +579,7 @@ public class DOMTest xDF.appendChild(xElemFoo); -// XNode +// XNode XText xText = xDoc.createTextNode("foo"); XComment xComment = xDoc.createComment("foo"); @@ -933,7 +933,7 @@ public class DOMTest assertNull("XElement.removeAttributeNS", xElemFooNs.getAttributeNodeNS(ns, "foo")); -// XNode +// XNode XText xText = xDoc.createTextNode("foo"); XComment xComment = xDoc.createComment("foo"); @@ -1182,7 +1182,7 @@ public class DOMTest xAttr.setValue("bar"); assertEquals("XAttr.setValue()", "bar", xAttr.getValue()); -// XNode +// XNode { XNode xAttrCloneN = xAttr.cloneNode(false); @@ -1438,7 +1438,7 @@ public class DOMTest } assertEquals("XText.subStringData", "x", xText.subStringData(3, 1)); -// XNode +// XNode { XNode xTextCloneN = xText.cloneNode(false); @@ -1622,7 +1622,7 @@ public class DOMTest assertEquals("XCDATASection.subStringData", "x", xCDS.subStringData(3, 1)); -// XNode +// XNode { XNode xCDSCloneN = xCDS.cloneNode(false); @@ -1796,7 +1796,7 @@ public class DOMTest assertEquals("XComment.subStringData", "x", xComment.subStringData(3, 1)); -// XNode +// XNode { XNode xCommentCloneN = xComment.cloneNode(false); @@ -1923,7 +1923,7 @@ public class DOMTest xER.appendChild(xERChild); -// XNode +// XNode XText xText = xDoc.createTextNode("foo"); XComment xComment = xDoc.createComment("foo"); @@ -2130,7 +2130,7 @@ public class DOMTest xPI.setData("baz"); assertEquals("XProcessingInstruction.setData", "baz", xPI.getData()); -// XNode +// XNode { XNode xPICloneN = xPI.cloneNode(false); diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx index 779b4c5..ff0306c 100644 --- a/unoxml/source/dom/document.cxx +++ b/unoxml/source/dom/document.cxx @@ -137,7 +137,7 @@ namespace DOM // 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) { diff --git a/unoxml/source/rdf/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx index d56cfad..acaefb5 100644 --- a/unoxml/source/rdf/librdf_repository.cxx +++ b/unoxml/source/rdf/librdf_repository.cxx @@ -92,7 +92,7 @@ typedef std::map< OUString, ::rtl::Reference > const char s_sparql [] = "sparql"; const char s_nsOOo [] = "http://openoffice.org/2004/office/rdfa/";; - + //FIXME: this approach is not ideal. can we use blank nodes instead? bool isInternalContext(librdf_node *i_pNode) throw () @@ -119,7 +119,7 @@ bool isInternalContext(librdf_node *i_pNode) throw () } - + // n.b.: librdf destructor functions dereference null pointers! // so they need to be wrapped to be usable with boost::shared_ptr. @@ -170,7 +170,7 @@ static void safe_librdf