23#include <rtl/ustrbuf.hxx>
24#include <osl/diagnose.h>
25#include <com/sun/star/io/XOutputStream.hpp>
37class OdfEmitter :
public XmlEmitter
45 explicit OdfEmitter( uno::Reference<io::XOutputStream> xOutput );
47 virtual void beginTag(
const char* pTag,
const PropertyMap& rProperties )
override;
48 virtual void write(
const OUString& rString )
override;
49 virtual void endTag(
const char* pTag )
override;
54OdfEmitter::OdfEmitter( uno::Reference<io::XOutputStream> xOutput ) :
58 OSL_PRECOND(
m_xOutput.is(),
"OdfEmitter(): invalid output stream");
60 write(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
63void OdfEmitter::beginTag(
const char* pTag,
const PropertyMap& rProperties )
65 OSL_PRECOND(pTag,
"Invalid tag string");
67 OUStringBuffer aElement(
"<");
68 aElement.appendAscii(pTag);
71 std::vector<OUString> aAttributes;
72 for(
const auto& rCurr : rProperties )
79 aAttributes.push_back(aAttribute);
85 std::sort(aAttributes.begin(), aAttributes.end());
86 std::copy(aAttributes.begin(), aAttributes.end(),
90 write(aElement.makeStringAndClear());
93void OdfEmitter::write(
const OUString& rText )
96 const sal_Int32 nLen(
aStr.getLength() );
98 const char* pStr =
aStr.getStr();
99 std::copy(pStr,pStr+nLen,
m_aBuf.getArray());
105void OdfEmitter::endTag(
const char* pTag )
107 OUStringBuffer aElement(
"</");
108 aElement.appendAscii(pTag);
109 aElement.append(
">");
110 write(aElement.makeStringAndClear());
115 return std::make_shared<OdfEmitter>(xOut);
std::shared_ptr< XmlEmitter > XmlEmitterSharedPtr
XmlEmitterSharedPtr createOdfEmitter(const uno::Reference< io::XOutputStream > &xOut)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::map< sal_Int32, STLPropertyMapEntry > PropertyMap
uno::Sequence< sal_Int8 > m_aBuf
uno::Reference< io::XOutputStream > m_xOutput
uno::Sequence< sal_Int8 > m_aLineFeed