1*6998d047SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6998d047SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6998d047SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6998d047SAndrew Rist * distributed with this work for additional information 6*6998d047SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6998d047SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6998d047SAndrew Rist * "License"); you may not use this file except in compliance 9*6998d047SAndrew Rist * with the License. You may obtain a copy of the License at 10*6998d047SAndrew Rist * 11*6998d047SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*6998d047SAndrew Rist * 13*6998d047SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6998d047SAndrew Rist * software distributed under the License is distributed on an 15*6998d047SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6998d047SAndrew Rist * KIND, either express or implied. See the License for the 17*6998d047SAndrew Rist * specific language governing permissions and limitations 18*6998d047SAndrew Rist * under the License. 19*6998d047SAndrew Rist * 20*6998d047SAndrew Rist *************************************************************/ 21*6998d047SAndrew Rist 22*6998d047SAndrew Rist 23cdf0e10cSrcweir #ifndef _SCRIPTING_XML_ELEMENT_HXX_ 24cdf0e10cSrcweir #define _SCRIPTING_XML_ELEMENT_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <vector> 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir namespace scripting_impl 33cdf0e10cSrcweir { 34cdf0e10cSrcweir // for simplification 35cdf0e10cSrcweir #define css ::com::sun::star 36cdf0e10cSrcweir #define dcsssf ::drafts::com::sun::star::script::framework 37cdf0e10cSrcweir 38cdf0e10cSrcweir /*################################################################################################## 39cdf0e10cSrcweir 40cdf0e10cSrcweir EXPORTING 41cdf0e10cSrcweir 42cdf0e10cSrcweir ##################################################################################################*/ 43cdf0e10cSrcweir 44cdf0e10cSrcweir //================================================================================================== 45cdf0e10cSrcweir class XMLElement : public ::cppu::WeakImplHelper1< css::xml::sax::XAttributeList > 46cdf0e10cSrcweir { 47cdf0e10cSrcweir public: XMLElement(::rtl::OUString const & name,::rtl::OUString const & chars)48cdf0e10cSrcweir inline XMLElement( ::rtl::OUString const & name, ::rtl::OUString const & chars ) 49cdf0e10cSrcweir SAL_THROW( () ) 50cdf0e10cSrcweir : _name( name ), _chars( chars ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir } 53cdf0e10cSrcweir 54cdf0e10cSrcweir inline XMLElement( ::rtl::OUString const & name ) 55cdf0e10cSrcweir SAL_THROW( () ) 56cdf0e10cSrcweir : _name( name ) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir /** Adds a sub element of element. 61cdf0e10cSrcweir 62cdf0e10cSrcweir @param xElem element reference 63cdf0e10cSrcweir */ 64cdf0e10cSrcweir void SAL_CALL addSubElement( 65cdf0e10cSrcweir css::uno::Reference< css::xml::sax::XAttributeList > const & xElem ) 66cdf0e10cSrcweir SAL_THROW( () ); 67cdf0e10cSrcweir 68cdf0e10cSrcweir /** Gets sub element of given index. The index follows order in which sub elements were added. 69cdf0e10cSrcweir 70cdf0e10cSrcweir @param nIndex index of sub element 71cdf0e10cSrcweir */ 72cdf0e10cSrcweir css::uno::Reference< css::xml::sax::XAttributeList > SAL_CALL getSubElement( 73cdf0e10cSrcweir sal_Int32 nIndex ) 74cdf0e10cSrcweir SAL_THROW( () ); 75cdf0e10cSrcweir 76cdf0e10cSrcweir /** Adds an attribute to elements. 77cdf0e10cSrcweir 78cdf0e10cSrcweir @param rAttrName qname of attribute 79cdf0e10cSrcweir @param rValue value string of element 80cdf0e10cSrcweir */ 81cdf0e10cSrcweir void SAL_CALL addAttribute( ::rtl::OUString const & rAttrName, 82cdf0e10cSrcweir ::rtl::OUString const & rValue ) 83cdf0e10cSrcweir SAL_THROW( () ); 84cdf0e10cSrcweir 85cdf0e10cSrcweir /** Gets the tag name (qname) of element. 86cdf0e10cSrcweir 87cdf0e10cSrcweir @return 88cdf0e10cSrcweir qname of element 89cdf0e10cSrcweir */ getName()90cdf0e10cSrcweir inline ::rtl::OUString SAL_CALL getName() SAL_THROW( () ) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir return _name; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir /** Dumps out element (and all sub elements). 96cdf0e10cSrcweir 97cdf0e10cSrcweir @param xOut document handler to be written to 98cdf0e10cSrcweir */ 99cdf0e10cSrcweir void SAL_CALL dump( 100cdf0e10cSrcweir css::uno::Reference< css::xml::sax::XExtendedDocumentHandler > const & xOut ); 101cdf0e10cSrcweir /** Dumps out sub elements (and all further sub elements). 102cdf0e10cSrcweir 103cdf0e10cSrcweir @param xOut document handler to be written to 104cdf0e10cSrcweir */ 105cdf0e10cSrcweir void SAL_CALL dumpSubElements( 106cdf0e10cSrcweir css::uno::Reference< css::xml::sax::XExtendedDocumentHandler > const & xOut ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir // XAttributeList 109cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getLength() 110cdf0e10cSrcweir throw ( css::uno::RuntimeException ); 111cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getNameByIndex( sal_Int16 nPos ) 112cdf0e10cSrcweir throw ( css::uno::RuntimeException ); 113cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getTypeByIndex( sal_Int16 nPos ) 114cdf0e10cSrcweir throw ( css::uno::RuntimeException ); 115cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getTypeByName( ::rtl::OUString const & rName ) 116cdf0e10cSrcweir throw ( css::uno::RuntimeException ); 117cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getValueByIndex( sal_Int16 nPos ) 118cdf0e10cSrcweir throw ( css::uno::RuntimeException ); 119cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getValueByName( ::rtl::OUString const & rName ) 120cdf0e10cSrcweir throw ( css::uno::RuntimeException ); 121cdf0e10cSrcweir 122cdf0e10cSrcweir protected: 123cdf0e10cSrcweir ::rtl::OUString _name; 124cdf0e10cSrcweir 125cdf0e10cSrcweir ::rtl::OUString _chars; 126cdf0e10cSrcweir 127cdf0e10cSrcweir ::std::vector< ::rtl::OUString > _attrNames; 128cdf0e10cSrcweir ::std::vector< ::rtl::OUString > _attrValues; 129cdf0e10cSrcweir 130cdf0e10cSrcweir ::std::vector< css::uno::Reference< 131cdf0e10cSrcweir css::xml::sax::XAttributeList > > _subElems; 132cdf0e10cSrcweir }; 133cdf0e10cSrcweir 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir #endif 137