21#include <com/sun/star/beans/StringPair.hpp>
22#include <com/sun/star/xml/sax/Parser.hpp>
23#include <com/sun/star/xml/sax/SAXException.hpp>
24#include <com/sun/star/xml/sax/Writer.hpp>
25#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
38constexpr OUStringLiteral g_sGroupListElement(u
"groupuinames:template-group-list");
39constexpr OUStringLiteral g_sGroupElement(u
"groupuinames:template-group");
40constexpr OUStringLiteral g_sNameAttr(u
"groupuinames:name");
41constexpr OUStringLiteral g_sUINameAttr(u
"groupuinames:default-ui-name");
53 if ( !xOutStream.is() )
54 throw uno::RuntimeException();
56 uno::Reference< xml::sax::XWriter > xWriterHandler(
57 xml::sax::Writer::create(xContext) );
59 xWriterHandler->setOutputStream( xOutStream );
61 static constexpr OUStringLiteral aWhiteSpace(
u" " );
65 pRootAttrList->AddAttribute(
67 "http://openoffice.org/2006/groupuinames" );
69 xWriterHandler->startDocument();
70 xWriterHandler->startElement( g_sGroupListElement, pRootAttrList );
72 for (
const auto &
i : aSequence)
75 pAttrList->AddAttribute( g_sNameAttr,
i.First );
76 pAttrList->AddAttribute( g_sUINameAttr,
i.Second );
78 xWriterHandler->startElement( g_sGroupElement, pAttrList );
79 xWriterHandler->ignorableWhitespace( aWhiteSpace );
80 xWriterHandler->endElement( g_sGroupElement );
83 xWriterHandler->ignorableWhitespace( aWhiteSpace );
84 xWriterHandler->endElement( g_sGroupListElement );
85 xWriterHandler->endDocument();
91 if ( !xContext.is() || !xInStream.is() )
92 throw uno::RuntimeException();
94 uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( xContext );
97 xml::sax::InputSource aParserInput;
98 aParserInput.aInputStream = xInStream;
99 aParserInput.sSystemId = aStringID;
100 xParser->setDocumentHandler( pHelper );
101 xParser->parseStream( aParserInput );
102 xParser->setDocumentHandler( uno::Reference < xml::sax::XDocumentHandler > () );
104 return pHelper->GetParsingResult();
121 throw uno::RuntimeException(
"The parsing has still not finished!");
139 if (
aName == g_sGroupListElement )
142 throw xml::sax::SAXException();
148 else if (
aName == g_sGroupElement )
151 throw xml::sax::SAXException();
158 const OUString aNameValue = xAttribs->getValueByName( g_sNameAttr );
159 if ( aNameValue.isEmpty() )
160 throw xml::sax::SAXException();
162 const OUString aUINameValue = xAttribs->getValueByName( g_sUINameAttr );
163 if ( aUINameValue.isEmpty() )
164 throw xml::sax::SAXException();
173 throw xml::sax::SAXException();
183 throw xml::sax::SAXException();
186 throw xml::sax::SAXException();
std::vector< css::beans::StringPair > m_aResultSeq
std::vector< OUString > m_aElementsSeq
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
virtual void SAL_CALL endElement(const OUString &aName) override
static std::vector< css::beans::StringPair > ReadGroupLocalizationSequence(const css::uno::Reference< css::io::XInputStream > &xInStream, const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual void SAL_CALL characters(const OUString &aChars) override
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
static std::vector< css::beans::StringPair > ReadLocalizationSequence_Impl(const css::uno::Reference< css::io::XInputStream > &xInStream, const OUString &aStringID, const css::uno::Reference< css::uno::XComponentContext > &xContext)
std::vector< css::beans::StringPair > const & GetParsingResult() const
virtual void SAL_CALL ignorableWhitespace(const OUString &aWhitespaces) override
virtual void SAL_CALL endDocument() override
virtual void SAL_CALL startDocument() override
static void WriteGroupLocalizationSequence(const css::uno::Reference< css::io::XOutputStream > &xOutStream, const std::vector< css::beans::StringPair > &aSequence, const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
virtual ~DocTemplLocaleHelper() override