[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/qa/unit/domtest.cxx |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) New commits: commit 04f1af50c5a10e98c8af0da6fd51e03b6b7e668f Author: Julien NabetDate: Wed Sep 6 20:49:21 2017 +0200 Typo exeption->exception (domtest.cxx) Change-Id: Id8a6b33a643defff82fa9b5e55ebf8c0d3e9c48d Reviewed-on: https://gerrit.libreoffice.org/42023 Reviewed-by: Julien Nabet Tested-by: Julien Nabet diff --git a/unoxml/qa/unit/domtest.cxx b/unoxml/qa/unit/domtest.cxx index 18e37a8fa297..5126164091dd 100644 --- a/unoxml/qa/unit/domtest.cxx +++ b/unoxml/qa/unit/domtest.cxx @@ -235,7 +235,7 @@ struct BasicTest : public test::BootstrapFixture { try { -// We DONT expect exeption here, as mxWarningInStream is valid XML Doc +// We DONT expect exception here, as mxWarningInStream is valid XML Doc CPPUNIT_ASSERT_MESSAGE("Valid input file did not result in XDocument #2", mxDomBuilder->parse( uno::Reference( @@ -253,7 +253,7 @@ struct BasicTest : public test::BootstrapFixture { try { -// We expect exeption here, as mxErrorInStream is invalid XML Doc +// We expect exception here, as mxErrorInStream is invalid XML Doc CPPUNIT_ASSERT_MESSAGE("Invalid input file result in XDocument #2!", !mxDomBuilder->parse( uno::Reference( @@ -262,7 +262,7 @@ struct BasicTest : public test::BootstrapFixture } catch (const css::xml::sax::SAXParseException&) { -// It's OK to catch an exeption here as we parse incorrect XML file +// It's OK to catch an exception here as we parse incorrect XML file } CPPUNIT_ASSERT_MESSAGE("No parse errors in unclean input file", !mxErrHandler->mnWarnCount && mxErrHandler->mnErrCount /*&& !mxErrHandler->mnFatalCount*/); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[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 YemelyanenkoDate: 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( +
[Libreoffice-commits] core.git: unoxml/qa
unoxml/qa/unit/domtest.cxx |1 - 1 file changed, 1 deletion(-) New commits: commit d752b1682307008d3e08a9f11e50ddc506d5f6ab Author: Stephan BergmannDate: Tue Dec 6 16:38:31 2016 +0100 Remove broken SAL_INFO Identifier apparently is not null terminated; caused CppunitTest_unoxml_domtest to fail with out-of-bounds read under -fsanitize=address. Change-Id: Id7c6ef6323d41d16b559488604e1c1feb725d608 diff --git a/unoxml/qa/unit/domtest.cxx b/unoxml/qa/unit/domtest.cxx index f6b940b..bc7ff57 100644 --- a/unoxml/qa/unit/domtest.cxx +++ b/unoxml/qa/unit/domtest.cxx @@ -173,7 +173,6 @@ struct TokenHandler { virtual ::sal_Int32 SAL_CALL getTokenFromUTF8( const uno::Sequence< ::sal_Int8 >& Identifier ) throw (uno::RuntimeException) override { -SAL_INFO("unoxml", "getTokenFromUTF8() " << reinterpret_cast(Identifier.getConstArray())); return Identifier.getLength() ? Identifier[0] : 0; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[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 f.alexander.wi...@gmail.com 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 caol...@redhat.com Tested-by: Caolán McNamara caol...@redhat.com 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::Referencelibrdf_NamedGraph 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
[Libreoffice-commits] core.git: unoxml/qa
unoxml/qa/complex/unoxml/DOMTest.java | 53 ++ 1 file changed, 53 insertions(+) New commits: commit 028a9096406eba26f823211b1f6a957ebc6b3a7b Author: Miguel Gomez mago...@igalia.com Date: Wed Sep 18 11:18:54 2013 +0200 New unit test to the DOMTree test suite Ensure that a parsed document that contains a malformed xmlns tag doesn't cause a segfault when serializing it through the XSAXSerializable interface. Change-Id: I00811494b37a307711c1a7a86403a56da8b23776 Reviewed-on: https://gerrit.libreoffice.org/6004 Tested-by: Miklos Vajna vmik...@collabora.co.uk Reviewed-by: Miklos Vajna vmik...@collabora.co.uk diff --git a/unoxml/qa/complex/unoxml/DOMTest.java b/unoxml/qa/complex/unoxml/DOMTest.java index 91a754f..9191781 100644 --- a/unoxml/qa/complex/unoxml/DOMTest.java +++ b/unoxml/qa/complex/unoxml/DOMTest.java @@ -25,8 +25,15 @@ import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.StringPair; import com.sun.star.io.XInputStream; +import com.sun.star.io.SequenceInputStream; import com.sun.star.xml.dom.*; +import com.sun.star.xml.sax.XDocumentHandler; +import com.sun.star.xml.sax.XSAXSerializable; +import com.sun.star.xml.sax.SAXException; +import com.sun.star.xml.sax.XAttributeList; +import com.sun.star.xml.sax.XLocator; import static com.sun.star.xml.dom.DOMExceptionType.*; import static com.sun.star.xml.dom.NodeType.*; import com.sun.star.xml.xpath.*; @@ -2686,6 +2693,52 @@ public class DOMTest } } +@Test public void testXSAXSerialize() throws Exception +{ +String file = +?xml version=\1.0\ encoding=\UTF-8\? + +office:document-content + +xmlns:office=\urn:oasis:names:tc:opendocument:xmlns:office:1.0\ + +xmlns:xlink=\http://www.w3.org/1999/xlink\; + +xmlns=\\ + +office:version=\1.0\ + +office:scripts/ + +xlink:test/ + +office:automatic-styles teststyle=\test\/ + +moretest/ + +some text \303\266\303\244\303\274 + +/office:document-content; + +XDocumentBuilder xBuilder = +UnoRuntime.queryInterface(XDocumentBuilder.class, +m_xMSF.createInstance(com.sun.star.xml.dom.DocumentBuilder)); + +XInputStream xIn = +SequenceInputStream.createStreamFromSequence(m_xContext, file.getBytes()); + +XDocument xDoc = +xBuilder.parse(xIn); + +XDocumentHandler xHandler = +UnoRuntime.queryInterface(XDocumentHandler.class, new DummyDocumentHandler()); + +XSAXSerializable serializable = +UnoRuntime.queryInterface(XSAXSerializable.class, xDoc); + +serializable.serialize(xHandler, new StringPair[0]); +} + +class DummyDocumentHandler implements XDocumentHandler +{ +public void startDocument() throws SAXException {} +public void endDocument() throws SAXException {} +public void startElement(String s, XAttributeList a) throws SAXException {} +public void endElement(String s) throws SAXException {} +public void characters(String s) throws SAXException {} +public void ignorableWhitespace(String s) throws SAXException {} +public void processingInstruction(String s1, String s2) throws SAXException {} +public void setDocumentLocator(XLocator l) throws SAXException {} +} // just for importNode... abstract class MockNode implements XNode ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: unoxml/qa
unoxml/qa/complex/unoxml/DOMTest.java |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 89e5ef948564d4bcea02c845d6f95999129c Author: Stephan Bergmann sberg...@redhat.com Date: Fri Sep 20 14:13:49 2013 +0200 java.lang.String.getBytes() has platform-dependent semantics Change-Id: Ia36e73215f666a26e5898310aabefb68d3f695c2 diff --git a/unoxml/qa/complex/unoxml/DOMTest.java b/unoxml/qa/complex/unoxml/DOMTest.java index 9191781..8cd93da 100644 --- a/unoxml/qa/complex/unoxml/DOMTest.java +++ b/unoxml/qa/complex/unoxml/DOMTest.java @@ -2706,7 +2706,7 @@ public class DOMTest xlink:test/ + office:automatic-styles teststyle=\test\/ + moretest/ + -some text \303\266\303\244\303\274 + +some text \uC3B6\uC3A4\uC3BC + /office:document-content; XDocumentBuilder xBuilder = @@ -2714,7 +2714,7 @@ public class DOMTest m_xMSF.createInstance(com.sun.star.xml.dom.DocumentBuilder)); XInputStream xIn = -SequenceInputStream.createStreamFromSequence(m_xContext, file.getBytes()); +SequenceInputStream.createStreamFromSequence(m_xContext, file.getBytes(UTF-8)); XDocument xDoc = xBuilder.parse(xIn); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: unoxml/qa
unoxml/qa/complex/unoxml/DOMTest.java |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 0b8abbf1924a5c2262df50cc95c8e9200890f6f6 Author: Stephan Bergmann sberg...@redhat.com Date: Fri Sep 20 23:46:11 2013 +0200 The original bytes were probably meant as UTF-8, not UTF-16 ...not that it matters much /what/ characters are used in the sample text, of course. And no-argument java.lang.String.getBytes() appears to indeed use the legacy Mac OS Roman encoding on Mac OS X... Change-Id: I51cd8c16f14e2df8b75d9961150518c8a03d53ca diff --git a/unoxml/qa/complex/unoxml/DOMTest.java b/unoxml/qa/complex/unoxml/DOMTest.java index 8cd93da..ed4374c 100644 --- a/unoxml/qa/complex/unoxml/DOMTest.java +++ b/unoxml/qa/complex/unoxml/DOMTest.java @@ -2706,7 +2706,7 @@ public class DOMTest xlink:test/ + office:automatic-styles teststyle=\test\/ + moretest/ + -some text \uC3B6\uC3A4\uC3BC + +some text \u00F6\u00E4\u00FC + /office:document-content; XDocumentBuilder xBuilder = ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits