Author: orw
Date: Mon Jun 10 11:11:00 2013
New Revision: 1491415
URL: http://svn.apache.org/r1491415
Log:
Correct the XML document handler which is used to parse Microsoft Word OOXML
documents in case of unknown XML elements
Modified:
openoffice/trunk/main/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
openoffice/trunk/main/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx
openoffice/trunk/main/writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx
Modified: openoffice/trunk/main/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx?rev=1491415&r1=1491414&r2=1491415&view=diff
==============================================================================
--- openoffice/trunk/main/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
(original)
+++ openoffice/trunk/main/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx Mon
Jun 10 11:11:00 2013
@@ -68,10 +68,8 @@ void OOXMLDocumentImpl::resolveFastSubSt
{
uno::Reference<uno::XComponentContext>
xContext(mpStream->getContext());
OOXMLFastDocumentHandler * pDocHandler =
- new OOXMLFastDocumentHandler(xContext);
- pDocHandler->setStream(&rStreamHandler);
- pDocHandler->setDocument(this);
- pDocHandler->setXNoteId(msXNoteId);
+ new OOXMLFastDocumentHandler(
+ xContext, &rStreamHandler, this, msXNoteId );
uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler
(pDocHandler);
@@ -317,10 +315,8 @@ void OOXMLDocumentImpl::resolve(Stream &
uno::Reference<uno::XComponentContext>
xContext(mpStream->getContext());
OOXMLFastDocumentHandler * pDocHandler =
- new OOXMLFastDocumentHandler(xContext);
- pDocHandler->setStream(&rStream);
- pDocHandler->setDocument(this);
- pDocHandler->setXNoteId(msXNoteId);
+ new OOXMLFastDocumentHandler(
+ xContext, &rStream, this, msXNoteId );
pDocHandler->setIsSubstream( mbIsSubstream );
uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler
(pDocHandler);
Modified:
openoffice/trunk/main/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx?rev=1491415&r1=1491414&r2=1491415&view=diff
==============================================================================
---
openoffice/trunk/main/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx
(original)
+++
openoffice/trunk/main/writerfilter/source/ooxml/OOXMLFastDocumentHandler.cxx
Mon Jun 10 11:11:00 2013
@@ -39,10 +39,28 @@ using namespace ::com::sun::star;
using namespace ::std;
-OOXMLFastDocumentHandler::OOXMLFastDocumentHandler
-(uno::Reference< uno::XComponentContext > const & context)
-: m_xContext(context)
-{}
+OOXMLFastDocumentHandler::OOXMLFastDocumentHandler(
+ uno::Reference< uno::XComponentContext > const & 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:
void SAL_CALL OOXMLFastDocumentHandler::startFastElement
@@ -144,7 +162,14 @@ uno::Reference< xml::sax::XFastContextHa
<< fastTokenToId(Element)
<< endl;
#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);
}
@@ -171,13 +196,12 @@ Name
#endif
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*/)
throw (uno::RuntimeException, xml::sax::SAXException)
{
- // TODO: Insert your implementation for "characters" here.
}
// ::com::sun::star::xml::sax::XFastDocumentHandler:
@@ -195,32 +219,14 @@ void SAL_CALL OOXMLFastDocumentHandler::
(const uno::Reference< xml::sax::XLocator > & /*xLocator*/)
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 )
{
- getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream );
+ if ( mpStream != 0 && mpDocument != 0 )
+ {
+ getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream
);
+ }
}
}}
Modified:
openoffice/trunk/main/writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx?rev=1491415&r1=1491414&r2=1491415&view=diff
==============================================================================
---
openoffice/trunk/main/writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx
(original)
+++
openoffice/trunk/main/writerfilter/source/ooxml/OOXMLFastDocumentHandler.hxx
Mon Jun 10 11:11:00 2013
@@ -44,8 +44,11 @@ class OOXMLFastDocumentHandler:
xml::sax::XFastDocumentHandler>
{
public:
- OOXMLFastDocumentHandler
- (uno::Reference< uno::XComponentContext > const & context);
+ OOXMLFastDocumentHandler(
+ uno::Reference< uno::XComponentContext > const & context,
+ Stream* pStream,
+ OOXMLDocument* pDocument,
+ const ::rtl::OUString& rXNoteId );
virtual ~OOXMLFastDocumentHandler() {}
// ::com::sun::star::xml::sax::XFastDocumentHandler:
@@ -86,11 +89,7 @@ public:
throw (uno::RuntimeException, xml::sax::SAXException);
virtual void SAL_CALL characters(const ::rtl::OUString & aChars)
throw (uno::RuntimeException, xml::sax::SAXException);
-
- void setStream(Stream * pStream);
- void setDocument(OOXMLDocument * pDocument);
- void setXNoteId(const ::rtl::OUString & rXNoteId);
-
+
void setIsSubstream( bool bSubstream );
private: