1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _SCRIPTING_XML_ELEMENT_HXX_ 28 #define _SCRIPTING_XML_ELEMENT_HXX_ 29 30 #include <vector> 31 32 #include <cppuhelper/implbase1.hxx> 33 34 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> 35 36 namespace scripting_impl 37 { 38 // for simplification 39 #define css ::com::sun::star 40 #define dcsssf ::drafts::com::sun::star::script::framework 41 42 /*################################################################################################## 43 44 EXPORTING 45 46 ##################################################################################################*/ 47 48 //================================================================================================== 49 class XMLElement : public ::cppu::WeakImplHelper1< css::xml::sax::XAttributeList > 50 { 51 public: 52 inline XMLElement( ::rtl::OUString const & name, ::rtl::OUString const & chars ) 53 SAL_THROW( () ) 54 : _name( name ), _chars( chars ) 55 { 56 } 57 58 inline XMLElement( ::rtl::OUString const & name ) 59 SAL_THROW( () ) 60 : _name( name ) 61 { 62 } 63 64 /** Adds a sub element of element. 65 66 @param xElem element reference 67 */ 68 void SAL_CALL addSubElement( 69 css::uno::Reference< css::xml::sax::XAttributeList > const & xElem ) 70 SAL_THROW( () ); 71 72 /** Gets sub element of given index. The index follows order in which sub elements were added. 73 74 @param nIndex index of sub element 75 */ 76 css::uno::Reference< css::xml::sax::XAttributeList > SAL_CALL getSubElement( 77 sal_Int32 nIndex ) 78 SAL_THROW( () ); 79 80 /** Adds an attribute to elements. 81 82 @param rAttrName qname of attribute 83 @param rValue value string of element 84 */ 85 void SAL_CALL addAttribute( ::rtl::OUString const & rAttrName, 86 ::rtl::OUString const & rValue ) 87 SAL_THROW( () ); 88 89 /** Gets the tag name (qname) of element. 90 91 @return 92 qname of element 93 */ 94 inline ::rtl::OUString SAL_CALL getName() SAL_THROW( () ) 95 { 96 return _name; 97 } 98 99 /** Dumps out element (and all sub elements). 100 101 @param xOut document handler to be written to 102 */ 103 void SAL_CALL dump( 104 css::uno::Reference< css::xml::sax::XExtendedDocumentHandler > const & xOut ); 105 /** Dumps out sub elements (and all further sub elements). 106 107 @param xOut document handler to be written to 108 */ 109 void SAL_CALL dumpSubElements( 110 css::uno::Reference< css::xml::sax::XExtendedDocumentHandler > const & xOut ); 111 112 // XAttributeList 113 virtual sal_Int16 SAL_CALL getLength() 114 throw ( css::uno::RuntimeException ); 115 virtual ::rtl::OUString SAL_CALL getNameByIndex( sal_Int16 nPos ) 116 throw ( css::uno::RuntimeException ); 117 virtual ::rtl::OUString SAL_CALL getTypeByIndex( sal_Int16 nPos ) 118 throw ( css::uno::RuntimeException ); 119 virtual ::rtl::OUString SAL_CALL getTypeByName( ::rtl::OUString const & rName ) 120 throw ( css::uno::RuntimeException ); 121 virtual ::rtl::OUString SAL_CALL getValueByIndex( sal_Int16 nPos ) 122 throw ( css::uno::RuntimeException ); 123 virtual ::rtl::OUString SAL_CALL getValueByName( ::rtl::OUString const & rName ) 124 throw ( css::uno::RuntimeException ); 125 126 protected: 127 ::rtl::OUString _name; 128 129 ::rtl::OUString _chars; 130 131 ::std::vector< ::rtl::OUString > _attrNames; 132 ::std::vector< ::rtl::OUString > _attrValues; 133 134 ::std::vector< css::uno::Reference< 135 css::xml::sax::XAttributeList > > _subElems; 136 }; 137 138 } 139 140 #endif 141