[Libreoffice-bugs] [Bug 84237] Method setErrorHandler in DOM::CDocumentBuilder not working
https://bugs.documentfoundation.org/show_bug.cgi?id=84237 Fyodorchanged: What|Removed |Added Assignee|libreoffice-b...@lists.free |fyodo...@hotmail.com |desktop.org | -- You are receiving this mail because: You are the assignee for the bug.___ Libreoffice-bugs mailing list Libreoffice-bugs@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs
[Libreoffice-bugs] [Bug 84237] Method setErrorHandler in DOM::CDocumentBuilder not working
https://bugs.documentfoundation.org/show_bug.cgi?id=84237 --- Comment #5 from Fyodor--- In brief, this bug relates to UnitTests for unoxml module which are failing with unhanded exception. In unittests we want to override this behavior by calling setErrorHandler, which really doesn't work, as it not implemented. In UnitTests there is custom struct ErrorHandler defined, which has warning, error and fatalerror member functions. It's expected that these function called in place of exception and if so, unittests will complete correctly. But I think that such behaiviuor (calling error handler's functions in plase of throwing exception) is not correct. Code in CDocumentBuilder class relates to exceptions in it methods. For example, this is part from CDocumentBuilder::parse method (starting from line 337 in file unoxml/source/dom/documentbuilder.cxx) // --- C++ code starts -- xmlDocPtr const pDoc = xmlCtxtReadIO(pContext.get(), xmlIO_read_func, xmlIO_close_func, , nullptr, nullptr, 0); // Previous line calls xmlCtxtReadIO from libxml2 to parse xml // If there is error in parsed xml, pDoc == nullptr - this means some error if (pDoc == nullptr) { // In case of error we throw exception and PASS CONTROL to first catch statement throwEx(pContext.get()); } // If there is no error - we init XDocument and return it Reference< XDocument > const xRet(CDocument::CreateCDocument(pDoc).get()); return xRet; // --- C++ code ends -- As seen, if we will not throw an exception, we should at least modify CDocumentBuilder::parse to return nullptr and not try to init XDocument. Also this can lead to modification of other code which is call CDocumentBuilder::parse AND code which calls throwEx as it not throw exception if custom error handler is set. As a result may be we'll should modify many lines of code, and produce even more errors... I suggest to remove setErrorHandler and catch exceptions in UnitTests. As a result, unittests should complete as desired. I'm novice in LO dev, so my suggestion can be wrong. I'll appreciate any advice. -- You are receiving this mail because: You are the assignee for the bug.___ Libreoffice-bugs mailing list Libreoffice-bugs@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs
[Libreoffice-bugs] [Bug 84237] Method setErrorHandler in DOM::CDocumentBuilder not working
https://bugs.documentfoundation.org/show_bug.cgi?id=84237 Xisco Faulíchanged: What|Removed |Added Assignee|fyodo...@hotmail.com|libreoffice-b...@lists.free ||desktop.org -- You are receiving this mail because: You are the assignee for the bug.___ Libreoffice-bugs mailing list Libreoffice-bugs@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs
[Libreoffice-bugs] [Bug 84237] Method setErrorHandler in DOM::CDocumentBuilder not working
https://bugs.documentfoundation.org/show_bug.cgi?id=84237 Fyodorchanged: What|Removed |Added Assignee|libreoffice-b...@lists.free |fyodo...@hotmail.com |desktop.org | -- You are receiving this mail because: You are the assignee for the bug.___ Libreoffice-bugs mailing list Libreoffice-bugs@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs
[Libreoffice-bugs] [Bug 84237] Method setErrorHandler in DOM::CDocumentBuilder not working
https://bugs.documentfoundation.org/show_bug.cgi?id=84237 Michael Stahlchanged: What|Removed |Added Keywords||difficultyBeginner, ||easyHack, skillCpp Summary|Method setErrorHandler in |Method setErrorHandler in |documentbuilder not working |DOM::CDocumentBuilder not ||working --- Comment #4 from Michael Stahl --- this should be quite easy to fix, in unoxml/source/dom/documentbuilder.cxx there are already error callbacks set before invoking libxml2, namely warning_func() and error_func(), and i guess the pContext->_private = this; will cause the void* parameter of these *_func() to refer to the CDocumentBuilder instance. so this basically means to modify warning_func() and error_func() to invoke the corresponding m_xErrorHandler methods from com.sun.star.xml.sax.XErrorHandler interface. care must be taken to catch any exceptions thrown, because they must not pass through libxml2 C code. -- You are receiving this mail because: You are the assignee for the bug. ___ Libreoffice-bugs mailing list Libreoffice-bugs@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs