25#include <rtl/strbuf.hxx>
26#include <osl/diagnose.h>
27#include <com/sun/star/xml/sax/SAXException.hpp>
30#if OSL_DEBUG_LEVEL > 0
31#include <osl/file.hxx>
44 OSL_PRECOND(
m_xDocHdl.is(),
"SaxEmitter(): invalid doc handler");
45 if (SvXMLImport *pFastHandler =
dynamic_cast<SvXMLImport*
>(
m_xDocHdl.get()))
51 catch( xml::sax::SAXException& )
54#if OSL_DEBUG_LEVEL > 0
55 static const char* pDir = getenv(
"DBG_PDFIMPORT_DIR" );
58 OUString
aStr( OStringToOUString( pDir, RTL_TEXTENCODING_UTF8 ) );
60 osl_getFileURLFromSystemPath(
aStr.pData, &aFileURL.pData );
61 pStream =
new osl::File( aFileURL +
"/pdfimport.xml" );
62 if(
pStream->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ) )
64 pStream->open( osl_File_OpenFlag_Write );
79 catch( xml::sax::SAXException& )
82#if OSL_DEBUG_LEVEL > 0
94 OUString aTag = OUString::createFromAscii( pTag );
95 uno::Reference< xml::sax::XAttributeList > xAttr(
101 catch( xml::sax::SAXException& )
104#if OSL_DEBUG_LEVEL > 0
108 sal_uInt64 nWritten = 0;
110 pStream->write(
" ", 4, nWritten );
112 OStringBuffer
aBuf( 1024 );
113 aBuf.append( OString::Concat(
"<") + pTag );
114 for(
const auto& rProperty : rProperties )
122 aBuf.append(
">\n" );
134 catch( xml::sax::SAXException& )
137#if OSL_DEBUG_LEVEL > 0
141 sal_uInt64 nWritten = 0;
149 OUString aTag = OUString::createFromAscii( pTag );
154 catch( xml::sax::SAXException& )
157#if OSL_DEBUG_LEVEL > 0
161 sal_uInt64 nWritten = 0;
163 pStream->write(
" ", 4, nWritten );
165 OString
aBuf = OString::Concat(
"</") + pTag +
">\n";
173 return std::make_shared<SaxEmitter>(xDocHdl);
css::uno::Reference< css::xml::sax::XDocumentHandler > m_xDocHdl
virtual void write(const OUString &rString) override
Write PCTEXT as-is to output.
virtual void endTag(const char *pTag) override
Close previously opened tag.
virtual ~SaxEmitter() override
virtual void beginTag(const char *pTag, const PropertyMap &rProperties) override
Open up a tag with the given properties.
SaxEmitter(const css::uno::Reference< css::xml::sax::XDocumentHandler > &xDocHdl)
static osl::File * pStream
XmlEmitterSharedPtr createSaxEmitter(const css::uno::Reference< css::xml::sax::XDocumentHandler > &xDocHdl)
std::unordered_map< OUString, OUString > PropertyMap
std::shared_ptr< XmlEmitter > XmlEmitterSharedPtr
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)