1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLElement.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SCRIPTING_XML_ELEMENT_HXX_
31 #define _SCRIPTING_XML_ELEMENT_HXX_
35 #include <cppuhelper/implbase1.hxx>
37 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
39 namespace scripting_impl
42 #define css ::com::sun::star
43 #define dcsssf ::drafts::com::sun::star::script::framework
45 /*##################################################################################################
49 ##################################################################################################*/
51 //==================================================================================================
52 class XMLElement
: public ::cppu::WeakImplHelper1
< css::xml::sax::XAttributeList
>
55 inline XMLElement( ::rtl::OUString
const & name
, ::rtl::OUString
const & chars
)
57 : _name( name
), _chars( chars
)
61 inline XMLElement( ::rtl::OUString
const & name
)
67 /** Adds a sub element of element.
69 @param xElem element reference
71 void SAL_CALL
addSubElement(
72 css::uno::Reference
< css::xml::sax::XAttributeList
> const & xElem
)
75 /** Gets sub element of given index. The index follows order in which sub elements were added.
77 @param nIndex index of sub element
79 css::uno::Reference
< css::xml::sax::XAttributeList
> SAL_CALL
getSubElement(
83 /** Adds an attribute to elements.
85 @param rAttrName qname of attribute
86 @param rValue value string of element
88 void SAL_CALL
addAttribute( ::rtl::OUString
const & rAttrName
,
89 ::rtl::OUString
const & rValue
)
92 /** Gets the tag name (qname) of element.
97 inline ::rtl::OUString SAL_CALL
getName() SAL_THROW( () )
102 /** Dumps out element (and all sub elements).
104 @param xOut document handler to be written to
107 css::uno::Reference
< css::xml::sax::XExtendedDocumentHandler
> const & xOut
);
108 /** Dumps out sub elements (and all further sub elements).
110 @param xOut document handler to be written to
112 void SAL_CALL
dumpSubElements(
113 css::uno::Reference
< css::xml::sax::XExtendedDocumentHandler
> const & xOut
);
116 virtual sal_Int16 SAL_CALL
getLength()
117 throw ( css::uno::RuntimeException
);
118 virtual ::rtl::OUString SAL_CALL
getNameByIndex( sal_Int16 nPos
)
119 throw ( css::uno::RuntimeException
);
120 virtual ::rtl::OUString SAL_CALL
getTypeByIndex( sal_Int16 nPos
)
121 throw ( css::uno::RuntimeException
);
122 virtual ::rtl::OUString SAL_CALL
getTypeByName( ::rtl::OUString
const & rName
)
123 throw ( css::uno::RuntimeException
);
124 virtual ::rtl::OUString SAL_CALL
getValueByIndex( sal_Int16 nPos
)
125 throw ( css::uno::RuntimeException
);
126 virtual ::rtl::OUString SAL_CALL
getValueByName( ::rtl::OUString
const & rName
)
127 throw ( css::uno::RuntimeException
);
130 ::rtl::OUString _name
;
132 ::rtl::OUString _chars
;
134 ::std::vector
< ::rtl::OUString
> _attrNames
;
135 ::std::vector
< ::rtl::OUString
> _attrValues
;
137 ::std::vector
< css::uno::Reference
<
138 css::xml::sax::XAttributeList
> > _subElems
;