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