1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_automation.hxx" 30*cdf0e10cSrcweir #include <tools/stream.hxx> 31*cdf0e10cSrcweir #include "statemnt.hxx" 32*cdf0e10cSrcweir #include "rcontrol.hxx" 33*cdf0e10cSrcweir #include "retstrm.hxx" 34*cdf0e10cSrcweir #include <basic/svtmsg.hrc> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #ifndef _BASIC_TTRESHLP_HXX 37*cdf0e10cSrcweir #include <basic/ttstrhlp.hxx> 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XParser.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXException.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/util/XCloneable.hpp> 45*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 46*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> 47*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 48*cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXParseException.hpp> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir using namespace com::sun::star::xml::sax; 51*cdf0e10cSrcweir using namespace com::sun::star::io; 52*cdf0e10cSrcweir using namespace com::sun::star::uno; 53*cdf0e10cSrcweir using namespace com::sun::star::util; 54*cdf0e10cSrcweir using namespace rtl; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir class SVInputStream : public cppu::WeakImplHelper1< XInputStream > 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir SvStream* pStream; 59*cdf0e10cSrcweir public: 60*cdf0e10cSrcweir SVInputStream( SvStream* pSt ):pStream( pSt ){}; 61*cdf0e10cSrcweir ~SVInputStream(){ delete pStream; pStream=NULL; } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir // Methods XInputStream 64*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 65*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 66*cdf0e10cSrcweir virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 67*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL available( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 68*cdf0e10cSrcweir virtual void SAL_CALL closeInput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 69*cdf0e10cSrcweir }; 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir sal_Int32 SAL_CALL SVInputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir aData.realloc( nBytesToRead ); 75*cdf0e10cSrcweir sal_Int32 nRead = pStream->Read( aData.getArray(), nBytesToRead ); 76*cdf0e10cSrcweir aData.realloc( nRead ); 77*cdf0e10cSrcweir return nRead; 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir sal_Int32 SAL_CALL SVInputStream::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir return readBytes( aData, nMaxBytesToRead ); 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir void SAL_CALL SVInputStream::skipBytes( sal_Int32 nBytesToSkip ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir if ( nBytesToSkip > 0 ) 88*cdf0e10cSrcweir pStream->SeekRel( nBytesToSkip ); 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir sal_Int32 SAL_CALL SVInputStream::available( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir sal_uLong nCurrent = pStream->Tell(); 94*cdf0e10cSrcweir sal_uLong nSize = pStream->Seek( STREAM_SEEK_TO_END ); 95*cdf0e10cSrcweir sal_uLong nAvailable = nSize - nCurrent; 96*cdf0e10cSrcweir pStream->Seek( nCurrent ); 97*cdf0e10cSrcweir return nAvailable; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir void SAL_CALL SVInputStream::closeInput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir // pStream->Close(); // automatically done in destructor 103*cdf0e10cSrcweir delete pStream; 104*cdf0e10cSrcweir pStream = NULL; 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir class Node; 108*cdf0e10cSrcweir SV_DECL_REF(Node) 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir enum NodeType { NODE_CHARACTER = CONST_NodeTypeCharacter, 111*cdf0e10cSrcweir NODE_ELEMENT = CONST_NodeTypeElement, 112*cdf0e10cSrcweir NODE_COMMENT = CONST_NodeTypeComment }; 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir class Node : public SvRefBase 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir NodeType aNodeType; 117*cdf0e10cSrcweir Node* pParent; // Use pointer to prevent cyclic references resulting in undeleted objects 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir protected: 120*cdf0e10cSrcweir Node( NodeType aType ): aNodeType( aType ), pParent( NULL ){}; 121*cdf0e10cSrcweir virtual ~Node(); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir public: 124*cdf0e10cSrcweir NodeType GetNodeType() { return aNodeType; } 125*cdf0e10cSrcweir void SetParent( NodeRef xNewParent ); 126*cdf0e10cSrcweir NodeRef GetParent(); 127*cdf0e10cSrcweir }; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir SV_IMPL_REF(Node) 130*cdf0e10cSrcweir // generate NodeRefMemberList 131*cdf0e10cSrcweir SV_DECL_IMPL_REF_LIST( NodeRef, Node* ) 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir Node::~Node() 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir void Node::SetParent( NodeRef xNewParent ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir pParent = &xNewParent; 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir NodeRef Node::GetParent() 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir return NodeRef( pParent ); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir class CharacterNode : public Node 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir String aCharacters; 150*cdf0e10cSrcweir public: 151*cdf0e10cSrcweir CharacterNode( const String& aChars ): Node( NODE_CHARACTER ), aCharacters( aChars ){}; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir String GetCharacters() { return aCharacters; } 154*cdf0e10cSrcweir }; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir class ElementNode : public Node 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir String aNodeName; 159*cdf0e10cSrcweir Reference < XAttributeList > xAttributeList; 160*cdf0e10cSrcweir NodeRefMemberList aDocumentNodeList; 161*cdf0e10cSrcweir public: 162*cdf0e10cSrcweir ElementNode( const String& aName, Reference < XAttributeList > xAttributes ); 163*cdf0e10cSrcweir void AppendNode( NodeRef xNewNode ); 164*cdf0e10cSrcweir sal_uLong GetChildCount(){ return aDocumentNodeList.Count(); } 165*cdf0e10cSrcweir NodeRef GetChild( sal_uInt16 nIndex ){ return aDocumentNodeList.GetObject( nIndex ); } 166*cdf0e10cSrcweir Reference < XAttributeList > GetAttributes(){ return xAttributeList; } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir String GetNodeName() { return aNodeName; } 169*cdf0e10cSrcweir }; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir ElementNode::ElementNode( const String& aName, Reference < XAttributeList > xAttributes ) 172*cdf0e10cSrcweir : Node( NODE_ELEMENT ) 173*cdf0e10cSrcweir , aNodeName( aName ) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir if ( xAttributes.is() ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir Reference < XCloneable > xAttributeCloner( xAttributes, UNO_QUERY ); 178*cdf0e10cSrcweir if ( xAttributeCloner.is() ) 179*cdf0e10cSrcweir xAttributeList = Reference < XAttributeList > ( xAttributeCloner->createClone() , UNO_QUERY ); 180*cdf0e10cSrcweir else 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir DBG_ERROR("Unable to clone AttributeList"); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir }; 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir void ElementNode::AppendNode( NodeRef xNewNode ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir aDocumentNodeList.Insert ( xNewNode, LIST_APPEND ); 190*cdf0e10cSrcweir xNewNode->SetParent( this ); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir // XIndexAccess 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir enum ParseAction { COLLECT_DATA, COLLECT_DATA_IGNORE_WHITESPACE, PARSE_ONLY }; 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir class SAXParser : public cppu::WeakImplHelper2< XErrorHandler, XDocumentHandler > 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir String aFilename; 204*cdf0e10cSrcweir Reference < XParser > xParser; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir // XErrorHandler 207*cdf0e10cSrcweir void AddToList( const sal_Char* cuType, const ::com::sun::star::uno::Any& aSAXParseException ); 208*cdf0e10cSrcweir String aErrors; 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir NodeRef xTreeRoot; 211*cdf0e10cSrcweir NodeRef xCurrentNode; 212*cdf0e10cSrcweir sal_uLong nTimestamp; 213*cdf0e10cSrcweir ParseAction aAction; 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir public: 216*cdf0e10cSrcweir SAXParser( const String &rFilename ); 217*cdf0e10cSrcweir ~SAXParser(); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // Access Methods 220*cdf0e10cSrcweir NodeRef GetCurrentNode(){ return xCurrentNode; } 221*cdf0e10cSrcweir void SetCurrentNode( NodeRef xCurrent ){ xCurrentNode = xCurrent; } 222*cdf0e10cSrcweir NodeRef GetRootNode(){ return xTreeRoot; } 223*cdf0e10cSrcweir sal_uLong GetTimestamp(){ return nTimestamp; } 224*cdf0e10cSrcweir void Touch(){ nTimestamp = Time::GetSystemTicks(); } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir // Methods SAXParser 227*cdf0e10cSrcweir sal_Bool Parse( ParseAction aAct ); 228*cdf0e10cSrcweir String GetErrors(){ return aErrors; } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir // Methods XErrorHandler 231*cdf0e10cSrcweir virtual void SAL_CALL error( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 232*cdf0e10cSrcweir virtual void SAL_CALL fatalError( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 233*cdf0e10cSrcweir virtual void SAL_CALL warning( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir // Methods XDocumentHandler 236*cdf0e10cSrcweir virtual void SAL_CALL startDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 237*cdf0e10cSrcweir virtual void SAL_CALL endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 238*cdf0e10cSrcweir virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 239*cdf0e10cSrcweir virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 240*cdf0e10cSrcweir virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 241*cdf0e10cSrcweir virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 242*cdf0e10cSrcweir virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 243*cdf0e10cSrcweir virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 244*cdf0e10cSrcweir }; 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir SAXParser::SAXParser( const String &rFilename ) 248*cdf0e10cSrcweir : aFilename( rFilename ) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir Touch(); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir SAXParser::~SAXParser() 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir xParser.clear(); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir sal_Bool SAXParser::Parse( ParseAction aAct ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir aAction = aAct; 261*cdf0e10cSrcweir Touch(); 262*cdf0e10cSrcweir SvStream* pStream = new SvFileStream( aFilename, STREAM_STD_READ ); 263*cdf0e10cSrcweir if ( pStream->GetError() ) 264*cdf0e10cSrcweir return sal_False; 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir InputSource sSource; 267*cdf0e10cSrcweir sSource.aInputStream = new SVInputStream( pStream ); // is refcounted and hence deletet appropriately 268*cdf0e10cSrcweir sSource.sPublicId = OUString( aFilename ); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir xParser = Reference < XParser > ( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.xml.sax.Parser") ), UNO_QUERY ); 271*cdf0e10cSrcweir if ( xParser.is() ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir xParser->setErrorHandler( ( XErrorHandler*) this ); 274*cdf0e10cSrcweir if ( aAction == COLLECT_DATA || aAction == COLLECT_DATA_IGNORE_WHITESPACE ) 275*cdf0e10cSrcweir xParser->setDocumentHandler( ( XDocumentHandler*) this ); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir try 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir xParser->parseStream ( sSource ); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir catch( class SAXParseException & rPEx) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir #ifdef DBG_ERROR 284*cdf0e10cSrcweir String aMemo( rPEx.Message ); 285*cdf0e10cSrcweir aMemo = String( aMemo ); 286*cdf0e10cSrcweir #endif 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir catch( class Exception & rEx) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir #ifdef DBG_ERROR 291*cdf0e10cSrcweir String aMemo( rEx.Message ); 292*cdf0e10cSrcweir aMemo = String( aMemo ); 293*cdf0e10cSrcweir #endif 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir xParser->setErrorHandler( NULL ); // otherwile Object holds itself 296*cdf0e10cSrcweir if ( aAction == COLLECT_DATA || aAction == COLLECT_DATA_IGNORE_WHITESPACE ) 297*cdf0e10cSrcweir xParser->setDocumentHandler( NULL ); // otherwile Object holds itself 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir else 300*cdf0e10cSrcweir return sal_False; 301*cdf0e10cSrcweir return sal_True; 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir // Helper Methods XErrorHandler 306*cdf0e10cSrcweir void SAXParser::AddToList( const sal_Char* cuType, const ::com::sun::star::uno::Any& aSAXParseException ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir SAXParseException aException; 309*cdf0e10cSrcweir aSAXParseException >>= aException; 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir aErrors.Append( String( aException.PublicId ) ); 312*cdf0e10cSrcweir aErrors.AppendAscii( "(" ); 313*cdf0e10cSrcweir aErrors.Append( String::CreateFromInt64( aException.LineNumber ) ); 314*cdf0e10cSrcweir aErrors.AppendAscii( ":" ); 315*cdf0e10cSrcweir aErrors.Append( String::CreateFromInt64( aException.ColumnNumber ) ); 316*cdf0e10cSrcweir aErrors.AppendAscii( ") : " ); 317*cdf0e10cSrcweir aErrors.AppendAscii( cuType ); 318*cdf0e10cSrcweir aErrors.AppendAscii( ": " ); 319*cdf0e10cSrcweir aErrors.Append( String( aException.Message ) ); 320*cdf0e10cSrcweir aErrors.AppendAscii( "\n" ); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir // Methods XErrorHandler 324*cdf0e10cSrcweir void SAL_CALL SAXParser::error( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir AddToList( "error", aSAXParseException ); 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir void SAL_CALL SAXParser::fatalError( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir AddToList( "fatal error", aSAXParseException ); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir void SAL_CALL SAXParser::warning( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir AddToList( "warning", aSAXParseException ); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir // Methods XDocumentHandler 341*cdf0e10cSrcweir void SAXParser::startDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir xTreeRoot = new ElementNode( CUniString("/"), Reference < XAttributeList > (NULL) ); 344*cdf0e10cSrcweir xCurrentNode = xTreeRoot; 345*cdf0e10cSrcweir Touch(); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir void SAXParser::endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir void SAXParser::startElement( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir NodeRef xNewNode = new ElementNode ( String(aName), xAttribs ); 355*cdf0e10cSrcweir ((ElementNode*)(&xCurrentNode))->AppendNode( xNewNode ); 356*cdf0e10cSrcweir xCurrentNode = xNewNode; 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir void SAXParser::endElement( const ::rtl::OUString& aName ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir (void) aName; /* avoid warning about unused parameter */ 362*cdf0e10cSrcweir xCurrentNode = xCurrentNode->GetParent(); 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir void SAXParser::characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir if ( aAction == COLLECT_DATA_IGNORE_WHITESPACE ) 368*cdf0e10cSrcweir { // check for whitespace 369*cdf0e10cSrcweir sal_Bool bAllWhitespace = sal_True; 370*cdf0e10cSrcweir for ( int i = 0 ; bAllWhitespace && i < aChars.getLength() ; i++ ) 371*cdf0e10cSrcweir if ( aChars[i] != 10 // LF 372*cdf0e10cSrcweir && aChars[i] != 13 // CR 373*cdf0e10cSrcweir && aChars[i] != ' ' // Blank 374*cdf0e10cSrcweir && aChars[i] != '\t' ) // Tab 375*cdf0e10cSrcweir bAllWhitespace = sal_False; 376*cdf0e10cSrcweir if ( bAllWhitespace ) 377*cdf0e10cSrcweir return; 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir NodeRef xNewNode = new CharacterNode ( String(aChars) ); 380*cdf0e10cSrcweir ((ElementNode*)(&xCurrentNode))->AppendNode( xNewNode ); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir void SAXParser::ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir (void) aWhitespaces; /* avoid warning about unused parameter */ 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir void SAXParser::processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir (void) aTarget; /* avoid warning about unused parameter */ 391*cdf0e10cSrcweir (void) aData; /* avoid warning about unused parameter */ 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir void SAXParser::setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir (void) xLocator; /* avoid warning about unused parameter */ 397*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 398*cdf0e10cSrcweir ::rtl::OUString aTester; 399*cdf0e10cSrcweir aTester = xLocator->getPublicId(); 400*cdf0e10cSrcweir aTester = xLocator->getSystemId(); 401*cdf0e10cSrcweir #endif 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir void StatementCommand::HandleSAXParser() 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir static Reference < XReference > xParserKeepaliveReference; // this is to keep the Object alive only 410*cdf0e10cSrcweir static SAXParser* pSAXParser; 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir // We need spechial prerequisites for these! 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir ElementNode* pElementNode = NULL; 415*cdf0e10cSrcweir switch ( nMethodId ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir case RC_SAXGetNodeType: 418*cdf0e10cSrcweir case RC_SAXGetAttributeCount: 419*cdf0e10cSrcweir case RC_SAXGetAttributeName: 420*cdf0e10cSrcweir case RC_SAXGetAttributeValue: 421*cdf0e10cSrcweir case RC_SAXGetChildCount: 422*cdf0e10cSrcweir case RC_SAXGetElementName: 423*cdf0e10cSrcweir case RC_SAXGetChars: 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir case RC_SAXSeekElement: 426*cdf0e10cSrcweir case RC_SAXHasElement: 427*cdf0e10cSrcweir case RC_SAXGetElementPath: 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir if ( xParserKeepaliveReference.is() && pSAXParser->GetCurrentNode().Is() ) 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir if ( pSAXParser->GetCurrentNode()->GetNodeType() == NODE_ELEMENT ) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir NodeRef xNode=pSAXParser->GetCurrentNode(); 434*cdf0e10cSrcweir pElementNode = (ElementNode*)(&xNode); 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir else 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) ); 440*cdf0e10cSrcweir return; 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir switch ( nMethodId ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir case RC_SAXCheckWellformed: 449*cdf0e10cSrcweir { 450*cdf0e10cSrcweir if( (nParams & PARAM_STR_1) ) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir xParserKeepaliveReference.clear(); 453*cdf0e10cSrcweir pSAXParser = new SAXParser( aString1 ); 454*cdf0e10cSrcweir xParserKeepaliveReference = ( XReference* )pSAXParser; 455*cdf0e10cSrcweir if ( !xParserKeepaliveReference.is() ) 456*cdf0e10cSrcweir ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) ); 457*cdf0e10cSrcweir else 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir if ( !pSAXParser->Parse( PARSE_ONLY ) ) 460*cdf0e10cSrcweir ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) ); 461*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetErrors() ); 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir xParserKeepaliveReference.clear(); 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir else 467*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir break; 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir case RC_SAXReadFile: 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir if( (nParams & PARAM_STR_1) ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir ParseAction aAction; 476*cdf0e10cSrcweir if( (nParams & PARAM_BOOL_1) && bBool1 ) 477*cdf0e10cSrcweir aAction = COLLECT_DATA; 478*cdf0e10cSrcweir else 479*cdf0e10cSrcweir aAction = COLLECT_DATA_IGNORE_WHITESPACE; 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir xParserKeepaliveReference.clear(); 482*cdf0e10cSrcweir pSAXParser = new SAXParser( aString1 ); 483*cdf0e10cSrcweir xParserKeepaliveReference = ( XReference* )pSAXParser; 484*cdf0e10cSrcweir if ( !xParserKeepaliveReference.is() ) 485*cdf0e10cSrcweir ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) ); 486*cdf0e10cSrcweir else 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir if ( !pSAXParser->Parse( aAction ) ) 490*cdf0e10cSrcweir ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) ); 491*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetErrors() ); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir else 495*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir break; 498*cdf0e10cSrcweir case RC_SAXGetNodeType: 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)pSAXParser->GetCurrentNode()->GetNodeType() ); 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir break; 503*cdf0e10cSrcweir case RC_SAXGetAttributeCount: 504*cdf0e10cSrcweir case RC_SAXGetAttributeName: 505*cdf0e10cSrcweir case RC_SAXGetAttributeValue: 506*cdf0e10cSrcweir case RC_SAXGetChildCount: 507*cdf0e10cSrcweir case RC_SAXGetElementName: 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir if ( pElementNode ) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir Reference < XAttributeList > xAttributeList = pElementNode->GetAttributes(); 512*cdf0e10cSrcweir switch ( nMethodId ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir case RC_SAXGetElementName: 515*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, pElementNode->GetNodeName() ); 516*cdf0e10cSrcweir break; 517*cdf0e10cSrcweir case RC_SAXGetChildCount: 518*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)pElementNode->GetChildCount() ); 519*cdf0e10cSrcweir break; 520*cdf0e10cSrcweir case RC_SAXGetAttributeCount: 521*cdf0e10cSrcweir if ( xAttributeList.is() ) 522*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)xAttributeList->getLength() ); 523*cdf0e10cSrcweir else 524*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, (comm_ULONG)0 ); 525*cdf0e10cSrcweir break; 526*cdf0e10cSrcweir case RC_SAXGetAttributeName: 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir if( (nParams & PARAM_USHORT_1) && ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, xAttributeList.is()?xAttributeList->getLength():0 ) ) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir String aRet( xAttributeList->getNameByIndex( nNr1-1 ) ); 531*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, aRet ); 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir else 534*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir break; 537*cdf0e10cSrcweir case RC_SAXGetAttributeValue: 538*cdf0e10cSrcweir // Number or String 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir if( (nParams & PARAM_USHORT_1) && ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, xAttributeList.is()?xAttributeList->getLength():0 ) ) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir String aRet( xAttributeList->getValueByIndex( nNr1-1 ) ); 543*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, aRet ); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir else if( (nParams & PARAM_STR_1) && xAttributeList.is() ) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir String aRet( xAttributeList->getValueByName( aString1 ) ); 548*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, aRet ); 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir else 551*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir break; 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir default: 556*cdf0e10cSrcweir ReportError( GEN_RES_STR1( S_INTERNAL_ERROR, RcString( nMethodId ) ) ); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir else 560*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir break; 563*cdf0e10cSrcweir case RC_SAXGetChars: 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir if ( pSAXParser->GetCurrentNode()->GetNodeType() == NODE_CHARACTER ) 566*cdf0e10cSrcweir { 567*cdf0e10cSrcweir NodeRef xNode=pSAXParser->GetCurrentNode(); 568*cdf0e10cSrcweir CharacterNode* aCharacterNode = (CharacterNode*)(&xNode); 569*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, aCharacterNode->GetCharacters() ); 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir else 572*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir break; 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir case RC_SAXSeekElement: 577*cdf0e10cSrcweir case RC_SAXHasElement: 578*cdf0e10cSrcweir // Number or String 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir sal_Bool bCheckOnly = nMethodId == RC_SAXHasElement; 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir if( (nParams & PARAM_USHORT_1) && !(nParams & PARAM_STR_1) ) 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir if ( nNr1 == 0 ) 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir if ( bCheckOnly ) 587*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetCurrentNode()->GetParent().Is() ); 588*cdf0e10cSrcweir else if ( pSAXParser->GetCurrentNode()->GetParent().Is() ) 589*cdf0e10cSrcweir pSAXParser->SetCurrentNode( pSAXParser->GetCurrentNode()->GetParent() ); 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir else if ( !pElementNode ) 592*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 593*cdf0e10cSrcweir else if ( bCheckOnly ) 594*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, pElementNode->GetChildCount() ) ); 595*cdf0e10cSrcweir else if ( ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, pElementNode->GetChildCount() ) ) 596*cdf0e10cSrcweir pSAXParser->SetCurrentNode( pElementNode->GetChild( nNr1-1 ) ); 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir else if( (nParams & PARAM_STR_1) ) 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir if ( aString1.EqualsAscii( "/" ) ) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir if ( bCheckOnly ) 603*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)sal_True ); 604*cdf0e10cSrcweir else 605*cdf0e10cSrcweir pSAXParser->SetCurrentNode( pSAXParser->GetRootNode() ); 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir else if ( aString1.Copy(0,2).EqualsAscii( "*:" ) ) 608*cdf0e10cSrcweir { 609*cdf0e10cSrcweir sal_uLong nTimestamp = (sal_uLong)aString1.GetToken( 1, ':' ).ToInt64(); 610*cdf0e10cSrcweir sal_uLong nPointer = (sal_uLong)aString1.GetToken( 2, ':' ).ToInt64(); 611*cdf0e10cSrcweir if ( bCheckOnly ) 612*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)(pSAXParser->GetTimestamp() == nTimestamp) ); 613*cdf0e10cSrcweir else 614*cdf0e10cSrcweir if ( pSAXParser->GetTimestamp() == nTimestamp ) 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir Node* pNode = (Node*)nPointer; 618*cdf0e10cSrcweir pSAXParser->SetCurrentNode( NodeRef( pNode ) ); 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir else 622*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir else if ( pElementNode ) 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir sal_uInt16 nNthOccurance; 627*cdf0e10cSrcweir if( (nParams & PARAM_USHORT_1) ) 628*cdf0e10cSrcweir nNthOccurance = nNr1; 629*cdf0e10cSrcweir else 630*cdf0e10cSrcweir nNthOccurance = 1; 631*cdf0e10cSrcweir 632*cdf0e10cSrcweir sal_uInt16 i; 633*cdf0e10cSrcweir NodeRef xNew; 634*cdf0e10cSrcweir for ( i = 0 ; i < pElementNode->GetChildCount() && !xNew.Is() ; i++ ) 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir xNew = pElementNode->GetChild( i ); 637*cdf0e10cSrcweir if ( xNew->GetNodeType() == NODE_ELEMENT ) 638*cdf0e10cSrcweir { 639*cdf0e10cSrcweir ElementNode* pNewElement = (ElementNode*)(&xNew); 640*cdf0e10cSrcweir if ( aString1.Equals( pNewElement->GetNodeName() ) ) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir if ( nNthOccurance > 1 ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir xNew.Clear(); 645*cdf0e10cSrcweir nNthOccurance--; 646*cdf0e10cSrcweir } 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir else 649*cdf0e10cSrcweir xNew.Clear(); 650*cdf0e10cSrcweir } 651*cdf0e10cSrcweir else 652*cdf0e10cSrcweir xNew.Clear(); 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir if ( bCheckOnly ) 655*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, xNew.Is() ); 656*cdf0e10cSrcweir else 657*cdf0e10cSrcweir if ( xNew.Is() ) 658*cdf0e10cSrcweir pSAXParser->SetCurrentNode( xNew ); 659*cdf0e10cSrcweir else 660*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir else 663*cdf0e10cSrcweir if ( bCheckOnly ) 664*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)sal_False ); 665*cdf0e10cSrcweir else 666*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir else 669*cdf0e10cSrcweir ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir break; 672*cdf0e10cSrcweir case RC_SAXGetElementPath: 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir DBG_ASSERT( sizeof( sal_uIntPtr ) == sizeof ( void* ), "Pointertype has different size than sal_uIntPtr"); 675*cdf0e10cSrcweir String aPath; 676*cdf0e10cSrcweir aPath.AppendAscii( "*:" ); 677*cdf0e10cSrcweir aPath.Append( String::CreateFromInt64( pSAXParser->GetTimestamp() ) ); 678*cdf0e10cSrcweir aPath.AppendAscii( ":" ); 679*cdf0e10cSrcweir NodeRef xNode=pSAXParser->GetCurrentNode(); 680*cdf0e10cSrcweir Node* pNode = (Node*)(&xNode); 681*cdf0e10cSrcweir aPath.Append( String::CreateFromInt64( (sal_uIntPtr)pNode ) ); 682*cdf0e10cSrcweir pRet->GenReturn ( RET_Value, nMethodId, aPath ); 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir break; 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir case RC_SAXRelease: 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir xParserKeepaliveReference.clear(); 689*cdf0e10cSrcweir } 690*cdf0e10cSrcweir break; 691*cdf0e10cSrcweir default: 692*cdf0e10cSrcweir ReportError( GEN_RES_STR1( S_INTERNAL_ERROR, RcString( nMethodId ) ) ); 693*cdf0e10cSrcweir } 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir 696