LibreOffice Module xmlscript (master) 1
xml_helper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#pragma once
20
21#include <utility>
22#include <vector>
24#include <com/sun/star/xml/sax/XAttributeList.hpp>
25
27
28namespace com::sun::star::xml::sax { class XDocumentHandler; }
29namespace com::sun::star::io { class XInputStream; }
30namespace com::sun::star::io { class XOutputStream; }
31
32namespace xmlscript
33{
34
35/*##################################################################################################
36
37 EXPORTING
38
39##################################################################################################*/
40
41
43 : public cppu::WeakImplHelper< css::xml::sax::XAttributeList >
44{
45public:
46 XMLElement( OUString name )
47 : _name(std::move( name ))
48 {}
49
54 void addSubElement(
55 css::uno::Reference< css::xml::sax::XAttributeList > const & xElem );
56
61 css::uno::Reference< css::xml::sax::XAttributeList > const & getSubElement( sal_Int32 nIndex );
62
68 void addAttribute( OUString const & rAttrName, OUString const & rValue );
69
74 void dump(
75 css::uno::Reference< css::xml::sax::XDocumentHandler > const & xOut );
80 void dumpSubElements(
81 css::uno::Reference< css::xml::sax::XDocumentHandler > const & xOut );
82
83 // XAttributeList
84 virtual sal_Int16 SAL_CALL getLength() override;
85 virtual OUString SAL_CALL getNameByIndex( sal_Int16 nPos ) override;
86 virtual OUString SAL_CALL getTypeByIndex( sal_Int16 nPos ) override;
87 virtual OUString SAL_CALL getTypeByName( OUString const & rName ) override;
88 virtual OUString SAL_CALL getValueByIndex( sal_Int16 nPos ) override;
89 virtual OUString SAL_CALL getValueByName( OUString const & rName ) override;
90
91private:
92 ::std::vector< css::uno::Reference<
93 css::xml::sax::XAttributeList > > _subElems;
94 OUString const _name;
95 ::std::vector< OUString > _attrNames;
96 ::std::vector< OUString > _attrValues;
97
98};
99
100
101/*##################################################################################################
102
103 STREAMING
104
105##################################################################################################*/
106
107XMLSCRIPT_DLLPUBLIC css::uno::Reference< css::io::XInputStream >
109 std::vector<sal_Int8>&& rInData );
110
111XMLSCRIPT_DLLPUBLIC css::uno::Reference< css::io::XInputStream >
113 const sal_Int8* pData, int len );
114
115XMLSCRIPT_DLLPUBLIC css::uno::Reference< css::io::XOutputStream >
117 std::vector<sal_Int8> * pOutData );
118
119}
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::xml::sax::XAttributeList > const & getSubElement(sal_Int32 nIndex)
Gets sub element of given index.
Definition: xml_element.cxx:42
XMLElement(OUString name)
Definition: xml_helper.hxx:46
void dumpSubElements(css::uno::Reference< css::xml::sax::XDocumentHandler > const &xOut)
Dumps out sub elements (and all further sub elements).
Definition: xml_element.cxx:47
void dump(css::uno::Reference< css::xml::sax::XDocumentHandler > const &xOut)
Dumps out element (and all sub elements).
Definition: xml_element.cxx:56
virtual OUString SAL_CALL getTypeByIndex(sal_Int16 nPos) override
Definition: xml_element.cxx:78
void addAttribute(OUString const &rAttrName, OUString const &rValue)
Adds an attribute to elements.
Definition: xml_element.cxx:31
::std::vector< OUString > _attrNames
Definition: xml_helper.hxx:95
void addSubElement(css::uno::Reference< css::xml::sax::XAttributeList > const &xElem)
Adds a sub element of element.
Definition: xml_element.cxx:37
virtual sal_Int16 SAL_CALL getLength() override
Definition: xml_element.cxx:67
virtual OUString SAL_CALL getNameByIndex(sal_Int16 nPos) override
Definition: xml_element.cxx:72
::std::vector< OUString > _attrValues
Definition: xml_helper.hxx:96
OUString const _name
Definition: xml_helper.hxx:94
virtual OUString SAL_CALL getValueByName(OUString const &rName) override
Definition: xml_element.cxx:97
virtual OUString SAL_CALL getTypeByName(OUString const &rName) override
Definition: xml_element.cxx:85
virtual OUString SAL_CALL getValueByIndex(sal_Int16 nPos) override
Definition: xml_element.cxx:91
::std::vector< css::uno::Reference< css::xml::sax::XAttributeList > > _subElems
Definition: xml_helper.hxx:93
const char * name
Reference< io::XInputStream > createInputStream(std::vector< sal_Int8 > &&rInData)
Reference< io::XOutputStream > createOutputStream(std::vector< sal_Int8 > *pOutData)
signed char sal_Int8
#define XMLSCRIPT_DLLPUBLIC