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