22#include <com/sun/star/embed/ElementModes.hpp>
23#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
24#include <com/sun/star/xml/sax/Parser.hpp>
25#include <com/sun/star/xml/sax/Writer.hpp>
33 using ::com::sun::star::uno::Reference;
34 using ::com::sun::star::uno::UNO_QUERY_THROW;
35 using ::com::sun::star::uno::XComponentContext;
36 using ::com::sun::star::embed::XStorage;
37 using ::com::sun::star::xml::sax::XDocumentHandler;
38 using ::com::sun::star::xml::sax::XWriter;
39 using ::com::sun::star::xml::sax::Writer;
40 using ::com::sun::star::xml::sax::Parser;
41 using ::com::sun::star::xml::sax::InputSource;
45 const Reference< XStorage >& i_rParentStorage,
46 const OUString& i_rStreamName )
47 :StorageOutputStream( i_rParentStorage, i_rStreamName )
49 const Reference< XWriter > xSaxWriter = Writer::create( i_rContext );
52 mxHandler.set( xSaxWriter, UNO_QUERY_THROW );
58 StorageXMLOutputStream::~StorageXMLOutputStream()
62 void StorageXMLOutputStream::close()
70 void StorageXMLOutputStream::addAttribute(
const OUString& i_rName,
const OUString& i_rValue )
const
72 mxAttributes->AddAttribute( i_rName, i_rValue );
75 void StorageXMLOutputStream::startElement(
const OUString& i_rElementName )
79 mxHandler->startElement( i_rElementName, mxAttributes );
81 maElements.push( i_rElementName );
84 void StorageXMLOutputStream::endElement()
89 const OUString sElementName( maElements.top() );
94 void StorageXMLOutputStream::ignorableWhitespace(
const OUString& i_rWhitespace )
const
98 mxHandler->ignorableWhitespace( i_rWhitespace );
101 void StorageXMLOutputStream::characters(
const OUString& i_rCharacters )
const
109 StorageXMLInputStream::StorageXMLInputStream(
const Reference<XComponentContext>& i_rContext,
110 const Reference< XStorage >& i_rParentStorage,
111 const OUString& i_rStreamName )
115 const Reference< css::io::XStream >
xStream(
116 i_rParentStorage->openStreamElement( i_rStreamName, css::embed::ElementModes::READ ), css::uno::UNO_SET_THROW );
117 m_xInputStream.set(
xStream->getInputStream(), css::uno::UNO_SET_THROW );
119 m_xParser.set( Parser::create(i_rContext) );
122 void StorageXMLInputStream::import(
const Reference< XDocumentHandler >& i_rHandler )
126 InputSource aInputSource;
127 aInputSource.aInputStream = m_xInputStream;
129 m_xParser->setDocumentHandler( i_rHandler );
133 StorageXMLInputStream::~StorageXMLInputStream()
StorageXMLOutputStream(const css::uno::Reference< css::uno::XComponentContext > &i_rContext, const css::uno::Reference< css::embed::XStorage > &i_rParentStorage, const OUString &i_rStreamName)
#define ENSURE_OR_THROW(c, m)
#define ENSURE_OR_RETURN_VOID(c, m)
rtl::Reference< ParserThread > m_xParser
bool getOutputStream(ProgramOptions const &options, OString const &extension, std::ostream **ppOutputStream, OString &targetSourceFileName, OString &tmpSourceFileName)
rtl::Reference< FragmentHandler > mxHandler