Kaydet (Commit) 22e33484 authored tarafından Oliver-Rainer Wittmann's avatar Oliver-Rainer Wittmann

Correct the XML document handler which is used to parse Microsoft Word OOXML…

Correct the XML document handler which is used to parse Microsoft Word OOXML documents in case of unknown XML elements
üst 7fb9e99f
...@@ -68,10 +68,8 @@ void OOXMLDocumentImpl::resolveFastSubStream(Stream & rStreamHandler, ...@@ -68,10 +68,8 @@ void OOXMLDocumentImpl::resolveFastSubStream(Stream & rStreamHandler,
{ {
uno::Reference<uno::XComponentContext> xContext(mpStream->getContext()); uno::Reference<uno::XComponentContext> xContext(mpStream->getContext());
OOXMLFastDocumentHandler * pDocHandler = OOXMLFastDocumentHandler * pDocHandler =
new OOXMLFastDocumentHandler(xContext); new OOXMLFastDocumentHandler(
pDocHandler->setStream(&rStreamHandler); xContext, &rStreamHandler, this, msXNoteId );
pDocHandler->setDocument(this);
pDocHandler->setXNoteId(msXNoteId);
uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler
(pDocHandler); (pDocHandler);
...@@ -317,10 +315,8 @@ void OOXMLDocumentImpl::resolve(Stream & rStream) ...@@ -317,10 +315,8 @@ void OOXMLDocumentImpl::resolve(Stream & rStream)
uno::Reference<uno::XComponentContext> xContext(mpStream->getContext()); uno::Reference<uno::XComponentContext> xContext(mpStream->getContext());
OOXMLFastDocumentHandler * pDocHandler = OOXMLFastDocumentHandler * pDocHandler =
new OOXMLFastDocumentHandler(xContext); new OOXMLFastDocumentHandler(
pDocHandler->setStream(&rStream); xContext, &rStream, this, msXNoteId );
pDocHandler->setDocument(this);
pDocHandler->setXNoteId(msXNoteId);
pDocHandler->setIsSubstream( mbIsSubstream ); pDocHandler->setIsSubstream( mbIsSubstream );
uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler
(pDocHandler); (pDocHandler);
......
...@@ -39,10 +39,28 @@ using namespace ::com::sun::star; ...@@ -39,10 +39,28 @@ using namespace ::com::sun::star;
using namespace ::std; using namespace ::std;
OOXMLFastDocumentHandler::OOXMLFastDocumentHandler OOXMLFastDocumentHandler::OOXMLFastDocumentHandler(
(uno::Reference< uno::XComponentContext > const & context) uno::Reference< uno::XComponentContext > const & context,
: m_xContext(context) Stream* pStream,
{} OOXMLDocument* pDocument,
const ::rtl::OUString& rXNoteId )
: m_xContext(context)
, mpStream( pStream )
#ifdef DEBUG_ELEMENT
, mpTmpStream()
#endif
, mpDocument( pDocument )
, msXNoteId( rXNoteId )
, mpContextHandler()
{
#ifdef DEBUG_PROTOCOL
if ( pStream )
{
mpTmpStream.reset( new StreamProtocol( pStream, debug_logger ) );
mpStream = mpTmpStream.get();
}
#endif
}
// ::com::sun::star::xml::sax::XFastContextHandler: // ::com::sun::star::xml::sax::XFastContextHandler:
void SAL_CALL OOXMLFastDocumentHandler::startFastElement void SAL_CALL OOXMLFastDocumentHandler::startFastElement
...@@ -145,6 +163,13 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ...@@ -145,6 +163,13 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
<< endl; << endl;
#endif #endif
if ( mpStream == 0 && mpDocument == 0 )
{
// document handler has been created as unknown child - see <OOXMLFastDocumentHandler::createUnknownChildContext(..)>
// --> do not provide a child context
return NULL;
}
return OOXMLFactory::getInstance()->createFastChildContextFromStart(getContextHandler().get(), Element); return OOXMLFactory::getInstance()->createFastChildContextFromStart(getContextHandler().get(), Element);
} }
...@@ -171,13 +196,12 @@ Name ...@@ -171,13 +196,12 @@ Name
#endif #endif
return uno::Reference< xml::sax::XFastContextHandler > return uno::Reference< xml::sax::XFastContextHandler >
(new OOXMLFastDocumentHandler(m_xContext)); ( new OOXMLFastDocumentHandler( m_xContext, 0, 0, ::rtl::OUString() ) );
} }
void SAL_CALL OOXMLFastDocumentHandler::characters(const ::rtl::OUString & /*aChars*/) void SAL_CALL OOXMLFastDocumentHandler::characters(const ::rtl::OUString & /*aChars*/)
throw (uno::RuntimeException, xml::sax::SAXException) throw (uno::RuntimeException, xml::sax::SAXException)
{ {
// TODO: Insert your implementation for "characters" here.
} }
// ::com::sun::star::xml::sax::XFastDocumentHandler: // ::com::sun::star::xml::sax::XFastDocumentHandler:
...@@ -195,32 +219,14 @@ void SAL_CALL OOXMLFastDocumentHandler::setDocumentLocator ...@@ -195,32 +219,14 @@ void SAL_CALL OOXMLFastDocumentHandler::setDocumentLocator
(const uno::Reference< xml::sax::XLocator > & /*xLocator*/) (const uno::Reference< xml::sax::XLocator > & /*xLocator*/)
throw (uno::RuntimeException, xml::sax::SAXException) throw (uno::RuntimeException, xml::sax::SAXException)
{ {
// TODO: Insert your implementation for "setDocumentLocator" here.
}
void OOXMLFastDocumentHandler::setStream(Stream * pStream)
{
#ifdef DEBUG_PROTOCOL
mpTmpStream.reset(new StreamProtocol(pStream, debug_logger));
mpStream = mpTmpStream.get();
#else
mpStream = pStream;
#endif
}
void OOXMLFastDocumentHandler::setDocument(OOXMLDocument * pDocument)
{
mpDocument = pDocument;
}
void OOXMLFastDocumentHandler::setXNoteId(const ::rtl::OUString & rXNoteId)
{
msXNoteId = rXNoteId;
} }
void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream ) void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream )
{ {
getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream ); if ( mpStream != 0 && mpDocument != 0 )
{
getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream );
}
} }
}} }}
...@@ -44,8 +44,11 @@ class OOXMLFastDocumentHandler: ...@@ -44,8 +44,11 @@ class OOXMLFastDocumentHandler:
xml::sax::XFastDocumentHandler> xml::sax::XFastDocumentHandler>
{ {
public: public:
OOXMLFastDocumentHandler OOXMLFastDocumentHandler(
(uno::Reference< uno::XComponentContext > const & context); uno::Reference< uno::XComponentContext > const & context,
Stream* pStream,
OOXMLDocument* pDocument,
const ::rtl::OUString& rXNoteId );
virtual ~OOXMLFastDocumentHandler() {} virtual ~OOXMLFastDocumentHandler() {}
// ::com::sun::star::xml::sax::XFastDocumentHandler: // ::com::sun::star::xml::sax::XFastDocumentHandler:
...@@ -87,10 +90,6 @@ public: ...@@ -87,10 +90,6 @@ public:
virtual void SAL_CALL characters(const ::rtl::OUString & aChars) virtual void SAL_CALL characters(const ::rtl::OUString & aChars)
throw (uno::RuntimeException, xml::sax::SAXException); throw (uno::RuntimeException, xml::sax::SAXException);
void setStream(Stream * pStream);
void setDocument(OOXMLDocument * pDocument);
void setXNoteId(const ::rtl::OUString & rXNoteId);
void setIsSubstream( bool bSubstream ); void setIsSubstream( bool bSubstream );
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment