105236b1aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 305236b1aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 405236b1aSAndrew Rist * or more contributor license agreements. See the NOTICE file 505236b1aSAndrew Rist * distributed with this work for additional information 605236b1aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 705236b1aSAndrew Rist * to you under the Apache License, Version 2.0 (the 805236b1aSAndrew Rist * "License"); you may not use this file except in compliance 905236b1aSAndrew Rist * with the License. You may obtain a copy of the License at 1005236b1aSAndrew Rist * 1105236b1aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 1205236b1aSAndrew Rist * 1305236b1aSAndrew Rist * Unless required by applicable law or agreed to in writing, 1405236b1aSAndrew Rist * software distributed under the License is distributed on an 1505236b1aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1605236b1aSAndrew Rist * KIND, either express or implied. See the License for the 1705236b1aSAndrew Rist * specific language governing permissions and limitations 1805236b1aSAndrew Rist * under the License. 1905236b1aSAndrew Rist * 2005236b1aSAndrew Rist *************************************************************/ 2105236b1aSAndrew Rist 2205236b1aSAndrew Rist 23cdf0e10cSrcweir #ifndef _XMLSCRIPT_XML_HELPER_HXX_ 24cdf0e10cSrcweir #define _XMLSCRIPT_XML_HELPER_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <vector> 27cdf0e10cSrcweir #include <rtl/byteseq.hxx> 28cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 29cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 30cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 31cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 32cdf0e10cSrcweir 33*b63233d8Sdamjan #include "xmlscript/xcrdllapi.h" 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace xmlscript 36cdf0e10cSrcweir { 37cdf0e10cSrcweir 38cdf0e10cSrcweir /*################################################################################################## 39cdf0e10cSrcweir 40cdf0e10cSrcweir EXPORTING 41cdf0e10cSrcweir 42cdf0e10cSrcweir ##################################################################################################*/ 43cdf0e10cSrcweir 44cdf0e10cSrcweir //================================================================================================== 45*b63233d8Sdamjan class XCR_DLLPUBLIC XMLElement 46cdf0e10cSrcweir : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XAttributeList > 47cdf0e10cSrcweir { 48cdf0e10cSrcweir public: 49cdf0e10cSrcweir inline XMLElement( ::rtl::OUString const & name ) 50cdf0e10cSrcweir SAL_THROW( () ) 51cdf0e10cSrcweir : _name( name ) 52cdf0e10cSrcweir {} 53cdf0e10cSrcweir 54cdf0e10cSrcweir /** Adds a sub element of element. 55cdf0e10cSrcweir 56cdf0e10cSrcweir @param xElem element reference 57cdf0e10cSrcweir */ 58cdf0e10cSrcweir void SAL_CALL addSubElement( 59cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > const & xElem ) 60cdf0e10cSrcweir SAL_THROW( () ); 61cdf0e10cSrcweir 62cdf0e10cSrcweir /** Gets sub element of given index. The index follows order in which sub elements were added. 63cdf0e10cSrcweir 64cdf0e10cSrcweir @param nIndex index of sub element 65cdf0e10cSrcweir */ 66cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > SAL_CALL getSubElement( sal_Int32 nIndex ) 67cdf0e10cSrcweir SAL_THROW( () ); 68cdf0e10cSrcweir 69cdf0e10cSrcweir /** Adds an attribute to elements. 70cdf0e10cSrcweir 71cdf0e10cSrcweir @param rAttrName qname of attribute 72cdf0e10cSrcweir @param rValue value string of element 73cdf0e10cSrcweir */ 74cdf0e10cSrcweir void SAL_CALL addAttribute( ::rtl::OUString const & rAttrName, ::rtl::OUString const & rValue ) 75cdf0e10cSrcweir SAL_THROW( () ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir /** Gets the tag name (qname) of element. 78cdf0e10cSrcweir 79cdf0e10cSrcweir @return 80cdf0e10cSrcweir qname of element 81cdf0e10cSrcweir */ getName()82cdf0e10cSrcweir inline ::rtl::OUString SAL_CALL getName() SAL_THROW( () ) 83cdf0e10cSrcweir { return _name; } 84cdf0e10cSrcweir 85cdf0e10cSrcweir /** Dumps out element (and all sub elements). 86cdf0e10cSrcweir 87cdf0e10cSrcweir @param xOut document handler to be written to 88cdf0e10cSrcweir */ 89cdf0e10cSrcweir void SAL_CALL dump( 90cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > const & xOut ); 91cdf0e10cSrcweir /** Dumps out sub elements (and all further sub elements). 92cdf0e10cSrcweir 93cdf0e10cSrcweir @param xOut document handler to be written to 94cdf0e10cSrcweir */ 95cdf0e10cSrcweir void SAL_CALL dumpSubElements( 96cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > const & xOut ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir // XAttributeList 99cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getLength() 100cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 101cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getNameByIndex( sal_Int16 nPos ) 102cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 103cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getTypeByIndex( sal_Int16 nPos ) 104cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 105cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getTypeByName( ::rtl::OUString const & rName ) 106cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 107cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getValueByIndex( sal_Int16 nPos ) 108cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 109cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getValueByName( ::rtl::OUString const & rName ) 110cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 111cdf0e10cSrcweir 112cdf0e10cSrcweir protected: 113cdf0e10cSrcweir ::rtl::OUString _name; 114cdf0e10cSrcweir 115cdf0e10cSrcweir ::std::vector< ::rtl::OUString > _attrNames; 116cdf0e10cSrcweir ::std::vector< ::rtl::OUString > _attrValues; 117cdf0e10cSrcweir 118cdf0e10cSrcweir ::std::vector< ::com::sun::star::uno::Reference< 119cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > > _subElems; 120cdf0e10cSrcweir }; 121cdf0e10cSrcweir 122cdf0e10cSrcweir 123cdf0e10cSrcweir /*################################################################################################## 124cdf0e10cSrcweir 125cdf0e10cSrcweir STREAMING 126cdf0e10cSrcweir 127cdf0e10cSrcweir ##################################################################################################*/ 128cdf0e10cSrcweir 129cdf0e10cSrcweir //================================================================================================== 130*b63233d8Sdamjan XCR_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > 131cdf0e10cSrcweir SAL_CALL createInputStream( 132cdf0e10cSrcweir ::rtl::ByteSequence const & rInData ) 133cdf0e10cSrcweir SAL_THROW( () ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir //================================================================================================== 136*b63233d8Sdamjan XCR_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > 137cdf0e10cSrcweir SAL_CALL createOutputStream( 138cdf0e10cSrcweir ::rtl::ByteSequence * pOutData ) 139cdf0e10cSrcweir SAL_THROW( () ); 140cdf0e10cSrcweir 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir #endif 144