diff options
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/expatwrap/sax_expat.cxx | 18 | ||||
-rw-r--r-- | sax/source/expatwrap/saxwriter.cxx | 21 |
2 files changed, 38 insertions, 1 deletions
diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx index d9553113c759..662d58d3f28a 100644 --- a/sax/source/expatwrap/sax_expat.cxx +++ b/sax/source/expatwrap/sax_expat.cxx @@ -39,6 +39,7 @@ #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> #include <com/sun/star/xml/sax/XParser.hpp> #include <com/sun/star/xml/sax/SAXParseException.hpp> +#include <com/sun/star/io/XSeekable.hpp> #include <cppuhelper/factory.hxx> #include <cppuhelper/weak.hxx> @@ -374,7 +375,8 @@ extern "C" // LocatorImpl //--------------------------------------------- class LocatorImpl : - public WeakImplHelper1< XLocator > + public WeakImplHelper2< XLocator, com::sun::star::io::XSeekable > + // should use a different interface for stream positions! { public: LocatorImpl( SaxExpatParser_Impl *p ) @@ -400,6 +402,20 @@ public: //XLocator return m_pParser->getEntity().structSource.sSystemId; } + // XSeekable (only for getPosition) + + virtual void SAL_CALL seek( sal_Int64 ) throw() + { + } + virtual sal_Int64 SAL_CALL getPosition() throw() + { + return XML_GetCurrentByteIndex( m_pParser->getEntity().pParser ); + } + virtual ::sal_Int64 SAL_CALL getLength() throw() + { + return 0; + } + private: SaxExpatParser_Impl *m_pParser; diff --git a/sax/source/expatwrap/saxwriter.cxx b/sax/source/expatwrap/saxwriter.cxx index 9be52cdd24c3..b3fba10cc911 100644 --- a/sax/source/expatwrap/saxwriter.cxx +++ b/sax/source/expatwrap/saxwriter.cxx @@ -208,6 +208,8 @@ public: // If there are invalid characters in the string it returns sal_False. // Than the calling method has to throw the needed Exception. inline sal_Bool comment(const rtl::OUString& rComment) throw( SAXException ); + + inline void clearBuffer() throw( SAXException ); }; const sal_Bool g_bValidCharsBelow32[32] = @@ -693,6 +695,17 @@ inline void SaxWriterHelper::endDocument() throw( SAXException ) } } +inline void SaxWriterHelper::clearBuffer() throw( SAXException ) +{ + FinishStartElement(); + if (nCurrentPos > 0) + { + m_Sequence.realloc(nCurrentPos); + nCurrentPos = writeSequence(); + m_Sequence.realloc(SEQUENCESIZE); + } +} + inline sal_Bool SaxWriterHelper::processingInstruction(const rtl::OUString& rTarget, const rtl::OUString& rData) throw( SAXException ) { FinishStartElement(); @@ -927,12 +940,20 @@ public: // XActiveDataSource virtual void SAL_CALL setOutputStream(const Reference< XOutputStream > & aStream) throw (RuntimeException) { + // temporary: set same stream again to clear buffer + if ( m_out == aStream && mp_SaxWriterHelper && m_bDocStarted ) + mp_SaxWriterHelper->clearBuffer(); + else + { + m_out = aStream; delete mp_SaxWriterHelper; mp_SaxWriterHelper = new SaxWriterHelper(m_out); m_bDocStarted = sal_False; m_nLevel = 0; m_bIsCDATA = sal_False; + + } } virtual Reference< XOutputStream > SAL_CALL getOutputStream(void) throw(RuntimeException) |