Branch data Line data Source code
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 : : #ifndef _XMLSCRIPT_XML_HELPER_HXX_
20 : : #define _XMLSCRIPT_XML_HELPER_HXX_
21 : :
22 : : #include <vector>
23 : : #include <rtl/byteseq.hxx>
24 : : #include <cppuhelper/implbase1.hxx>
25 : : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
26 : : #include <com/sun/star/io/XInputStream.hpp>
27 : : #include <com/sun/star/io/XOutputStream.hpp>
28 : :
29 : : #include "xmlscript/xmlscriptdllapi.h"
30 : :
31 : : namespace xmlscript
32 : : {
33 : :
34 : : /*##################################################################################################
35 : :
36 : : EXPORTING
37 : :
38 : : ##################################################################################################*/
39 : :
40 : : //==================================================================================================
41 [ - + ]: 504 : class XMLSCRIPT_DLLPUBLIC XMLElement
42 : : : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XAttributeList >
43 : : {
44 : : public:
45 : 252 : inline XMLElement( ::rtl::OUString const & name )
46 : : SAL_THROW(())
47 [ + - ][ + - ]: 252 : : _name( name )
[ + - ]
48 : 252 : {}
49 : :
50 : : /** Adds a sub element of element.
51 : :
52 : : @param xElem element reference
53 : : */
54 : : void SAL_CALL addSubElement(
55 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > const & xElem )
56 : : SAL_THROW(());
57 : :
58 : : /** Gets sub element of given index. The index follows order in which sub elements were added.
59 : :
60 : : @param nIndex index of sub element
61 : : */
62 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > SAL_CALL getSubElement( sal_Int32 nIndex )
63 : : SAL_THROW(());
64 : :
65 : : /** Adds an attribute to elements.
66 : :
67 : : @param rAttrName qname of attribute
68 : : @param rValue value string of element
69 : : */
70 : : void SAL_CALL addAttribute( ::rtl::OUString const & rAttrName, ::rtl::OUString const & rValue )
71 : : SAL_THROW(());
72 : :
73 : : /** Gets the tag name (qname) of element.
74 : :
75 : : @return
76 : : qname of element
77 : : */
78 : : inline ::rtl::OUString SAL_CALL getName() SAL_THROW(())
79 : : { return _name; }
80 : :
81 : : /** Dumps out element (and all sub elements).
82 : :
83 : : @param xOut document handler to be written to
84 : : */
85 : : void SAL_CALL dump(
86 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > const & xOut );
87 : : /** Dumps out sub elements (and all further sub elements).
88 : :
89 : : @param xOut document handler to be written to
90 : : */
91 : : void SAL_CALL dumpSubElements(
92 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > const & xOut );
93 : :
94 : : // XAttributeList
95 : : virtual sal_Int16 SAL_CALL getLength()
96 : : throw (::com::sun::star::uno::RuntimeException);
97 : : virtual ::rtl::OUString SAL_CALL getNameByIndex( sal_Int16 nPos )
98 : : throw (::com::sun::star::uno::RuntimeException);
99 : : virtual ::rtl::OUString SAL_CALL getTypeByIndex( sal_Int16 nPos )
100 : : throw (::com::sun::star::uno::RuntimeException);
101 : : virtual ::rtl::OUString SAL_CALL getTypeByName( ::rtl::OUString const & rName )
102 : : throw (::com::sun::star::uno::RuntimeException);
103 : : virtual ::rtl::OUString SAL_CALL getValueByIndex( sal_Int16 nPos )
104 : : throw (::com::sun::star::uno::RuntimeException);
105 : : virtual ::rtl::OUString SAL_CALL getValueByName( ::rtl::OUString const & rName )
106 : : throw (::com::sun::star::uno::RuntimeException);
107 : :
108 : : protected:
109 : : ::rtl::OUString _name;
110 : :
111 : : ::std::vector< ::rtl::OUString > _attrNames;
112 : : ::std::vector< ::rtl::OUString > _attrValues;
113 : :
114 : : ::std::vector< ::com::sun::star::uno::Reference<
115 : : ::com::sun::star::xml::sax::XAttributeList > > _subElems;
116 : : };
117 : :
118 : :
119 : : /*##################################################################################################
120 : :
121 : : STREAMING
122 : :
123 : : ##################################################################################################*/
124 : :
125 : : XMLSCRIPT_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
126 : : SAL_CALL createInputStream(
127 : : ::rtl::ByteSequence const & rInData )
128 : : SAL_THROW(());
129 : :
130 : : XMLSCRIPT_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
131 : : SAL_CALL createOutputStream(
132 : : ::rtl::ByteSequence * pOutData )
133 : : SAL_THROW(());
134 : :
135 : : }
136 : :
137 : : #endif
138 : :
139 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|