merge the formfield patch from ooo-build
[ooovba.git] / scripting / source / storage / XMLElement.cxx
blobf6dcf3b4b3a7b9db4b8d62a26e9ef8dc9276b9e1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLElement.cxx,v $
10 * $Revision: 1.6 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_scripting.hxx"
33 #include "XMLElement.hxx"
34 #include <osl/diagnose.h>
36 using namespace rtl;
37 using namespace com::sun::star;
38 using namespace com::sun::star::uno;
40 namespace scripting_impl
43 //*************************************************************************
44 void XMLElement::addAttribute( OUString const & rAttrName, OUString const & rValue )
45 SAL_THROW( () )
47 OSL_TRACE( "XMLElement::addAttribute\n" );
49 _attrNames.push_back( rAttrName );
50 _attrValues.push_back( rValue );
53 //*************************************************************************
54 void XMLElement::addSubElement( Reference< xml::sax::XAttributeList > const & xElem )
55 SAL_THROW( () )
57 OSL_TRACE( "XMLElement::addSubElement\n" );
59 _subElems.push_back( xElem );
62 //*************************************************************************
63 Reference< xml::sax::XAttributeList > XMLElement::getSubElement( sal_Int32 nIndex )
64 SAL_THROW( () )
66 OSL_TRACE( "XMLElement::getSubElement\n" );
68 return _subElems[ ( size_t )nIndex ];
71 //*************************************************************************
72 void XMLElement::dumpSubElements( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
74 OSL_TRACE( "+++++ XMLElement::dumpSubElement\n" );
76 for ( size_t nPos = 0; nPos < _subElems.size(); ++nPos )
78 XMLElement * pElem = static_cast< XMLElement * >( _subElems[ nPos ].get() );
79 pElem->dump( xOut );
83 //*************************************************************************
84 void XMLElement::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
86 OSL_TRACE( "XMLElement::dump" );
88 xOut->ignorableWhitespace( OUString() );
89 OSL_TRACE( "XMLElement::dump starting %s",::rtl::OUStringToOString(
90 _name, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
91 xOut->startElement( _name, static_cast< xml::sax::XAttributeList * >( this ) );
92 // Write out CDATA
93 if( _chars.getLength() > 0 )
95 xOut->ignorableWhitespace( OUString() );
96 xOut->characters( _chars );
98 // write sub elements
99 dumpSubElements( xOut );
100 xOut->ignorableWhitespace( OUString() );
101 xOut->endElement( _name );
102 OSL_TRACE( "XMLElement::dump ending %s",::rtl::OUStringToOString(
103 _name, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
106 //*************************************************************************
107 // XAttributeList
108 sal_Int16 XMLElement::getLength()
109 throw ( RuntimeException )
111 OSL_TRACE( "XMLElement::getLength\n" );
113 return _attrNames.size();
116 //*************************************************************************
117 OUString XMLElement::getNameByIndex( sal_Int16 nPos )
118 throw ( RuntimeException )
120 OSL_TRACE( "XMLElement::getNameByIndex\n" );
121 OSL_ASSERT( ( size_t )nPos < _attrNames.size() );
123 return _attrNames[ nPos ];
126 //*************************************************************************
127 OUString XMLElement::getTypeByIndex( sal_Int16 nPos )
128 throw ( RuntimeException )
130 OSL_TRACE( "XMLElement::getTypeByIndex\n" );
131 OSL_ASSERT( (size_t)nPos < _attrNames.size() );
133 // xxx todo
134 return OUString();
137 //*************************************************************************
138 OUString XMLElement::getTypeByName( OUString const & rName )
139 throw ( RuntimeException )
141 OSL_TRACE( "XMLElement::getTypeByName\n" );
142 // xxx todo
143 return OUString();
146 //*************************************************************************
147 OUString XMLElement::getValueByIndex( sal_Int16 nPos )
148 throw ( RuntimeException )
150 OSL_TRACE( "XMLElement::getValueByIndex\n" );
151 OSL_ASSERT( ( size_t )nPos < _attrNames.size() );
153 return _attrValues[ nPos ];
156 //*************************************************************************
157 OUString XMLElement::getValueByName( OUString const & rName )
158 throw ( RuntimeException )
160 OSL_TRACE( "XMLElement::getValueByName\n" );
162 for ( size_t nPos = 0; nPos < _attrNames.size(); ++nPos )
164 if (_attrNames[ nPos ] == rName)
166 return _attrValues[ nPos ];
169 return OUString();