diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-03-24 12:26:59 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-11-27 12:55:08 +0000 |
commit | 2884799ea8c635ea5849fed3bea77b099a541de0 (patch) | |
tree | 6f33bdeca00380c348b692502dc4353a13612cf5 /forms/source | |
parent | 0c696c1628a0271242f4a89d343c7e125f493726 (diff) |
fs34b: added some diagnostics, so next time a bug like #i117507# happens
we will not - at least in a non-product build - silently ignore it
Conflicts:
forms/source/xforms/submission/serialization_app_xml.cxx
Diffstat (limited to 'forms/source')
-rw-r--r-- | forms/source/xforms/submission/serialization_app_xml.cxx | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/forms/source/xforms/submission/serialization_app_xml.cxx b/forms/source/xforms/submission/serialization_app_xml.cxx index 7c783bf8adaa..dc0a990695fb 100644 --- a/forms/source/xforms/submission/serialization_app_xml.cxx +++ b/forms/source/xforms/submission/serialization_app_xml.cxx @@ -30,7 +30,6 @@ #include "serialization.hxx" #include "serialization_app_xml.hxx" -#include <comphelper/processfactory.hxx> #include <com/sun/star/io/Pipe.hpp> #include <com/sun/star/xml/dom/XNode.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> @@ -39,8 +38,13 @@ #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/xml/xpath/XPathObjectType.hpp> +#include <tools/diagnose_ex.h> +#include <comphelper/processfactory.hxx> + #include <libxml/tree.h> +#include <limits> + CSerializationAppXML::CSerializationAppXML() : m_aFactory(comphelper::getProcessServiceFactory()) , m_aPipe(CSS::io::Pipe::create(comphelper::getProcessComponentContext())) @@ -63,33 +67,39 @@ CSerializationAppXML::serialize_node(const CSS::uno::Reference< CSS::xml::dom::X CSS::uno::Reference< CSS::xml::dom::XDocument > aDoc(rNode, CSS::uno::UNO_QUERY_THROW); aNode = CSS::uno::Reference< CSS::xml::dom::XNode >(aDoc->getDocumentElement(), CSS::uno::UNO_QUERY_THROW); } - if (aNode->getNodeType() != CSS::xml::dom::NodeType_ELEMENT_NODE) - return; + ENSURE_OR_RETURN_VOID( aNode->getNodeType() == CSS::xml::dom::NodeType_ELEMENT_NODE, + "CSerializationAppXML::serialize_node: invalid node type!" ); // clone the node to a new document and serialize that document - CSS::uno::Reference< CSS::lang::XUnoTunnel > aTunnel(aNode, CSS::uno::UNO_QUERY); - if (aTunnel.is()) + CSS::uno::Reference< CSS::lang::XUnoTunnel > xTunnel( aNode, CSS::uno::UNO_QUERY ); + ENSURE_OR_RETURN_VOID( xTunnel.is(), "CSerializationAppXML::serialize_node: unknown implementation, cannot serialize!" ); + + xmlNodePtr aNodePtr = reinterpret_cast< xmlNodePtr >( xTunnel->getSomething(CSS::uno::Sequence< sal_Int8 >()) ); + ENSURE_OR_RETURN_VOID( aNodePtr != NULL, "CSerializationAppXML::serialize_node: unable to obtain the xmlNodePtr!" ); + + xmlDocPtr aDocPtr = xmlNewDoc((xmlChar*)"1.0"); + ENSURE_OR_RETURN_VOID( aDocPtr != NULL, "CSerializationAppXML::serialize_node: unable to create a temporary doc!" ); + + xmlNodePtr aDocNodePtr = xmlDocCopyNode(aNodePtr, aDocPtr, 1); + if (aDocNodePtr != NULL) { - xmlNodePtr aNodePtr = reinterpret_cast< xmlNodePtr >( aTunnel->getSomething(CSS::uno::Sequence< sal_Int8 >()) ); - xmlDocPtr aDocPtr = xmlNewDoc((xmlChar*)"1.0"); - xmlNodePtr aDocNodePtr = xmlDocCopyNode(aNodePtr, aDocPtr, 1); - if (aDocNodePtr != NULL) { - xmlAddChild((xmlNodePtr)aDocPtr, aDocNodePtr); - xmlChar *buffer = NULL; - sal_Int32 size = 0; - xmlDocDumpMemory(aDocPtr, &buffer, (int*)&size); - - // write the xml into the pipe through it's XOutputStream interface - m_aPipe->writeBytes(CSS::uno::Sequence< sal_Int8 >((sal_Int8*)buffer, size)); - xmlFree(buffer); + xmlAddChild( (xmlNodePtr)aDocPtr, aDocNodePtr ); + + xmlChar *buffer = NULL; + int size = 0; + xmlDocDumpMemory( aDocPtr, &buffer, &size ); + + if ( size > ::std::numeric_limits< sal_Int32 >::max() ) + { + OSL_ENSURE( false, "CSerializationAppXML::serialize_node: document too large, doesn't fit into a UNO sequence!" ); + size = ::std::numeric_limits< sal_Int32 >::max(); } - } else { - // can't get tunnel to native backend - // logic for generic implementation could be implemented here... - OSL_FAIL("unkown dom implementation, cannot serialize"); - return; + // write the xml into the pipe through it's XOutputStream interface + m_aPipe->writeBytes(CSS::uno::Sequence< sal_Int8 >((sal_Int8*)buffer, size)); + xmlFree(buffer); } + xmlFreeDoc( aDocPtr ); } void |