Files
libreoffice/automation/source/server/XMLParser.cxx

696 lines
29 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2002-11-18 14:29:33 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2002-11-18 14:29:33 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2002-11-18 14:29:33 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2002-11-18 14:29:33 +00:00
*
* This file is part of OpenOffice.org.
2002-11-18 14:29:33 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2002-11-18 14:29:33 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2002-11-18 14:29:33 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2002-11-18 14:29:33 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_automation.hxx"
2002-11-18 14:29:33 +00:00
#include <tools/stream.hxx>
#include "statemnt.hxx"
#include "rcontrol.hxx"
#include "retstrm.hxx"
#include <basic/svtmsg.hrc>
2002-11-18 14:29:33 +00:00
#include <basic/ttstrhlp.hxx>
#include <com/sun/star/xml/sax/XParser.hpp>
#include <com/sun/star/xml/sax/SAXException.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/util/XCloneable.hpp>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase1.hxx>
#include <com/sun/star/xml/sax/SAXParseException.hpp>
using namespace com::sun::star::xml::sax;
using namespace com::sun::star::io;
using namespace com::sun::star::uno;
using namespace com::sun::star::util;
2011-02-26 01:14:41 +01:00
using ::rtl::OUString;
2002-11-18 14:29:33 +00:00
class SVInputStream : public cppu::WeakImplHelper1< XInputStream >
{
SvStream* pStream;
public:
SVInputStream( SvStream* pSt ):pStream( pSt ){};
~SVInputStream(){ delete pStream; pStream=NULL; }
// Methods XInputStream
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);
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);
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);
virtual sal_Int32 SAL_CALL available( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL closeInput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
};
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)
{
aData.realloc( nBytesToRead );
sal_Int32 nRead = pStream->Read( aData.getArray(), nBytesToRead );
aData.realloc( nRead );
return nRead;
}
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)
{
return readBytes( aData, nMaxBytesToRead );
}
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)
{
if ( nBytesToSkip > 0 )
pStream->SeekRel( nBytesToSkip );
}
sal_Int32 SAL_CALL SVInputStream::available( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
sal_uLong nCurrent = pStream->Tell();
sal_uLong nSize = pStream->Seek( STREAM_SEEK_TO_END );
sal_uLong nAvailable = nSize - nCurrent;
2002-11-18 14:29:33 +00:00
pStream->Seek( nCurrent );
return nAvailable;
}
void SAL_CALL SVInputStream::closeInput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
// pStream->Close(); // automatically done in destructor
delete pStream;
pStream = NULL;
}
class Node;
SV_DECL_REF(Node)
enum NodeType { NODE_CHARACTER = CONST_NodeTypeCharacter,
NODE_ELEMENT = CONST_NodeTypeElement,
NODE_COMMENT = CONST_NodeTypeComment };
class Node : public SvRefBase
{
NodeType aNodeType;
Node* pParent; // Use pointer to prevent cyclic references resulting in undeleted objects
protected:
Node( NodeType aType ): aNodeType( aType ), pParent( NULL ){};
virtual ~Node();
public:
NodeType GetNodeType() { return aNodeType; }
void SetParent( NodeRef xNewParent );
NodeRef GetParent();
};
SV_IMPL_REF(Node)
// generate NodeRefMemberList
SV_DECL_IMPL_REF_LIST( NodeRef, Node* )
Node::~Node()
{
}
void Node::SetParent( NodeRef xNewParent )
{
pParent = &xNewParent;
}
NodeRef Node::GetParent()
{
return NodeRef( pParent );
}
class CharacterNode : public Node
{
String aCharacters;
public:
CharacterNode( const String& aChars ): Node( NODE_CHARACTER ), aCharacters( aChars ){};
String GetCharacters() { return aCharacters; }
};
class ElementNode : public Node
{
String aNodeName;
Reference < XAttributeList > xAttributeList;
NodeRefMemberList aDocumentNodeList;
public:
ElementNode( const String& aName, Reference < XAttributeList > xAttributes );
void AppendNode( NodeRef xNewNode );
sal_uLong GetChildCount(){ return aDocumentNodeList.Count(); }
NodeRef GetChild( sal_uInt16 nIndex ){ return aDocumentNodeList.GetObject( nIndex ); }
2002-11-18 14:29:33 +00:00
Reference < XAttributeList > GetAttributes(){ return xAttributeList; }
String GetNodeName() { return aNodeName; }
};
ElementNode::ElementNode( const String& aName, Reference < XAttributeList > xAttributes )
: Node( NODE_ELEMENT )
, aNodeName( aName )
{
if ( xAttributes.is() )
{
Reference < XCloneable > xAttributeCloner( xAttributes, UNO_QUERY );
if ( xAttributeCloner.is() )
xAttributeList = Reference < XAttributeList > ( xAttributeCloner->createClone() , UNO_QUERY );
else
{
2011-03-01 17:55:09 +01:00
OSL_FAIL("Unable to clone AttributeList");
2002-11-18 14:29:33 +00:00
}
}
};
void ElementNode::AppendNode( NodeRef xNewNode )
{
aDocumentNodeList.Insert ( xNewNode, LIST_APPEND );
xNewNode->SetParent( this );
}
// XIndexAccess
enum ParseAction { COLLECT_DATA, COLLECT_DATA_IGNORE_WHITESPACE, PARSE_ONLY };
class SAXParser : public cppu::WeakImplHelper2< XErrorHandler, XDocumentHandler >
{
String aFilename;
Reference < XParser > xParser;
// XErrorHandler
void AddToList( const sal_Char* cuType, const ::com::sun::star::uno::Any& aSAXParseException );
2002-11-18 14:29:33 +00:00
String aErrors;
NodeRef xTreeRoot;
NodeRef xCurrentNode;
sal_uLong nTimestamp;
2002-11-18 14:29:33 +00:00
ParseAction aAction;
public:
SAXParser( const String &rFilename );
~SAXParser();
// Access Methods
NodeRef GetCurrentNode(){ return xCurrentNode; }
void SetCurrentNode( NodeRef xCurrent ){ xCurrentNode = xCurrent; }
NodeRef GetRootNode(){ return xTreeRoot; }
sal_uLong GetTimestamp(){ return nTimestamp; }
2002-11-18 14:29:33 +00:00
void Touch(){ nTimestamp = Time::GetSystemTicks(); }
// Methods SAXParser
sal_Bool Parse( ParseAction aAct );
2002-11-18 14:29:33 +00:00
String GetErrors(){ return aErrors; }
// Methods XErrorHandler
virtual void SAL_CALL error( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL fatalError( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL warning( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
// Methods XDocumentHandler
virtual void SAL_CALL startDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
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);
virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
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);
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);
};
SAXParser::SAXParser( const String &rFilename )
: aFilename( rFilename )
{
Touch();
}
SAXParser::~SAXParser()
{
xParser.clear();
}
sal_Bool SAXParser::Parse( ParseAction aAct )
2002-11-18 14:29:33 +00:00
{
aAction = aAct;
Touch();
SvStream* pStream = new SvFileStream( aFilename, STREAM_STD_READ );
if ( pStream->GetError() )
return sal_False;
2002-11-18 14:29:33 +00:00
InputSource sSource;
sSource.aInputStream = new SVInputStream( pStream ); // is refcounted and hence deletet appropriately
sSource.sPublicId = OUString( aFilename );
xParser = Reference < XParser > ( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.xml.sax.Parser") ), UNO_QUERY );
if ( xParser.is() )
{
xParser->setErrorHandler( ( XErrorHandler*) this );
if ( aAction == COLLECT_DATA || aAction == COLLECT_DATA_IGNORE_WHITESPACE )
xParser->setDocumentHandler( ( XDocumentHandler*) this );
try
{
xParser->parseStream ( sSource );
}
catch( class SAXParseException & rPEx)
{
#ifdef DBG_ERROR
String aMemo( rPEx.Message );
aMemo = String( aMemo );
#endif
}
catch( class Exception & rEx)
{
#ifdef DBG_ERROR
String aMemo( rEx.Message );
aMemo = String( aMemo );
#endif
}
xParser->setErrorHandler( NULL ); // otherwile Object holds itself
if ( aAction == COLLECT_DATA || aAction == COLLECT_DATA_IGNORE_WHITESPACE )
xParser->setDocumentHandler( NULL ); // otherwile Object holds itself
}
else
return sal_False;
return sal_True;
2002-11-18 14:29:33 +00:00
}
// Helper Methods XErrorHandler
void SAXParser::AddToList( const sal_Char* cuType, const ::com::sun::star::uno::Any& aSAXParseException )
2002-11-18 14:29:33 +00:00
{
SAXParseException aException;
aSAXParseException >>= aException;
aErrors.Append( String( aException.PublicId ) );
aErrors.AppendAscii( "(" );
aErrors.Append( String::CreateFromInt64( aException.LineNumber ) );
aErrors.AppendAscii( ":" );
aErrors.Append( String::CreateFromInt64( aException.ColumnNumber ) );
aErrors.AppendAscii( ") : " );
aErrors.AppendAscii( cuType );
aErrors.AppendAscii( ": " );
aErrors.Append( String( aException.Message ) );
aErrors.AppendAscii( "\n" );
}
// Methods XErrorHandler
void SAL_CALL SAXParser::error( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
{
AddToList( "error", aSAXParseException );
}
void SAL_CALL SAXParser::fatalError( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
{
AddToList( "fatal error", aSAXParseException );
}
void SAL_CALL SAXParser::warning( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
{
AddToList( "warning", aSAXParseException );
}
// Methods XDocumentHandler
void SAXParser::startDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
{
xTreeRoot = new ElementNode( CUniString("/"), Reference < XAttributeList > (NULL) );
xCurrentNode = xTreeRoot;
Touch();
}
void SAXParser::endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
{
}
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)
{
NodeRef xNewNode = new ElementNode ( String(aName), xAttribs );
((ElementNode*)(&xCurrentNode))->AppendNode( xNewNode );
xCurrentNode = xNewNode;
}
void SAXParser::endElement( const ::rtl::OUString& aName ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
{
(void) aName; /* avoid warning about unused parameter */
2002-11-18 14:29:33 +00:00
xCurrentNode = xCurrentNode->GetParent();
}
void SAXParser::characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
{
if ( aAction == COLLECT_DATA_IGNORE_WHITESPACE )
{ // check for whitespace
sal_Bool bAllWhitespace = sal_True;
2002-11-18 14:29:33 +00:00
for ( int i = 0 ; bAllWhitespace && i < aChars.getLength() ; i++ )
if ( aChars[i] != 10 // LF
&& aChars[i] != 13 // CR
&& aChars[i] != ' ' // Blank
&& aChars[i] != '\t' ) // Tab
bAllWhitespace = sal_False;
2002-11-18 14:29:33 +00:00
if ( bAllWhitespace )
return;
}
NodeRef xNewNode = new CharacterNode ( String(aChars) );
((ElementNode*)(&xCurrentNode))->AppendNode( xNewNode );
}
void SAXParser::ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
{
(void) aWhitespaces; /* avoid warning about unused parameter */
2002-11-18 14:29:33 +00:00
}
void SAXParser::processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
{
(void) aTarget; /* avoid warning about unused parameter */
(void) aData; /* avoid warning about unused parameter */
2002-11-18 14:29:33 +00:00
}
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)
{
(void) xLocator; /* avoid warning about unused parameter */
#if OSL_DEBUG_LEVEL > 1
2002-11-18 14:29:33 +00:00
::rtl::OUString aTester;
aTester = xLocator->getPublicId();
aTester = xLocator->getSystemId();
#endif
}
void StatementCommand::HandleSAXParser()
{
static Reference < XReference > xParserKeepaliveReference; // this is to keep the Object alive only
static SAXParser* pSAXParser;
// We need spechial prerequisites for these!
ElementNode* pElementNode = NULL;
switch ( nMethodId )
{
case RC_SAXGetNodeType:
case RC_SAXGetAttributeCount:
case RC_SAXGetAttributeName:
case RC_SAXGetAttributeValue:
case RC_SAXGetChildCount:
case RC_SAXGetElementName:
case RC_SAXGetChars:
case RC_SAXSeekElement:
case RC_SAXHasElement:
case RC_SAXGetElementPath:
{
if ( xParserKeepaliveReference.is() && pSAXParser->GetCurrentNode().Is() )
{
if ( pSAXParser->GetCurrentNode()->GetNodeType() == NODE_ELEMENT )
{
NodeRef xNode=pSAXParser->GetCurrentNode();
pElementNode = (ElementNode*)(&xNode);
}
}
else
{
ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) );
return;
}
}
}
switch ( nMethodId )
{
case RC_SAXCheckWellformed:
{
if( (nParams & PARAM_STR_1) )
{
xParserKeepaliveReference.clear();
pSAXParser = new SAXParser( aString1 );
xParserKeepaliveReference = ( XReference* )pSAXParser;
if ( !xParserKeepaliveReference.is() )
ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) );
else
{
if ( !pSAXParser->Parse( PARSE_ONLY ) )
ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) );
pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetErrors() );
2002-11-18 14:29:33 +00:00
}
xParserKeepaliveReference.clear();
}
else
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
}
break;
case RC_SAXReadFile:
{
if( (nParams & PARAM_STR_1) )
{
ParseAction aAction;
if( (nParams & PARAM_BOOL_1) && bBool1 )
aAction = COLLECT_DATA;
else
aAction = COLLECT_DATA_IGNORE_WHITESPACE;
xParserKeepaliveReference.clear();
pSAXParser = new SAXParser( aString1 );
xParserKeepaliveReference = ( XReference* )pSAXParser;
if ( !xParserKeepaliveReference.is() )
ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) );
else
{
if ( !pSAXParser->Parse( aAction ) )
ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) );
pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetErrors() );
2002-11-18 14:29:33 +00:00
}
}
else
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
}
break;
case RC_SAXGetNodeType:
{
2011-05-24 10:10:13 +01:00
pRet->GenReturn ( RET_Value, nMethodId, (comm_UINT32)pSAXParser->GetCurrentNode()->GetNodeType() );
2002-11-18 14:29:33 +00:00
}
break;
case RC_SAXGetAttributeCount:
case RC_SAXGetAttributeName:
case RC_SAXGetAttributeValue:
case RC_SAXGetChildCount:
case RC_SAXGetElementName:
{
if ( pElementNode )
{
Reference < XAttributeList > xAttributeList = pElementNode->GetAttributes();
switch ( nMethodId )
{
case RC_SAXGetElementName:
pRet->GenReturn ( RET_Value, nMethodId, pElementNode->GetNodeName() );
2002-11-18 14:29:33 +00:00
break;
case RC_SAXGetChildCount:
2011-05-24 10:10:13 +01:00
pRet->GenReturn ( RET_Value, nMethodId, (comm_UINT32)pElementNode->GetChildCount() );
2002-11-18 14:29:33 +00:00
break;
case RC_SAXGetAttributeCount:
if ( xAttributeList.is() )
2011-05-24 10:10:13 +01:00
pRet->GenReturn ( RET_Value, nMethodId, (comm_UINT32)xAttributeList->getLength() );
2002-11-18 14:29:33 +00:00
else
2011-05-24 10:10:13 +01:00
pRet->GenReturn ( RET_Value, nMethodId, (comm_UINT32)0 );
2002-11-18 14:29:33 +00:00
break;
case RC_SAXGetAttributeName:
{
if( (nParams & PARAM_USHORT_1) && ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, xAttributeList.is()?xAttributeList->getLength():0 ) )
2002-11-18 14:29:33 +00:00
{
String aRet( xAttributeList->getNameByIndex( nNr1-1 ) );
pRet->GenReturn ( RET_Value, nMethodId, aRet );
2002-11-18 14:29:33 +00:00
}
else
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
}
break;
case RC_SAXGetAttributeValue:
// Number or String
{
if( (nParams & PARAM_USHORT_1) && ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, xAttributeList.is()?xAttributeList->getLength():0 ) )
2002-11-18 14:29:33 +00:00
{
String aRet( xAttributeList->getValueByIndex( nNr1-1 ) );
pRet->GenReturn ( RET_Value, nMethodId, aRet );
2002-11-18 14:29:33 +00:00
}
else if( (nParams & PARAM_STR_1) && xAttributeList.is() )
{
String aRet( xAttributeList->getValueByName( aString1 ) );
pRet->GenReturn ( RET_Value, nMethodId, aRet );
2002-11-18 14:29:33 +00:00
}
else
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
}
break;
default:
ReportError( GEN_RES_STR1( S_INTERNAL_ERROR, RcString( nMethodId ) ) );
}
}
else
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
}
break;
case RC_SAXGetChars:
{
if ( pSAXParser->GetCurrentNode()->GetNodeType() == NODE_CHARACTER )
{
NodeRef xNode=pSAXParser->GetCurrentNode();
CharacterNode* aCharacterNode = (CharacterNode*)(&xNode);
pRet->GenReturn ( RET_Value, nMethodId, aCharacterNode->GetCharacters() );
2002-11-18 14:29:33 +00:00
}
else
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
}
break;
case RC_SAXSeekElement:
case RC_SAXHasElement:
// Number or String
{
sal_Bool bCheckOnly = nMethodId == RC_SAXHasElement;
2002-11-18 14:29:33 +00:00
if( (nParams & PARAM_USHORT_1) && !(nParams & PARAM_STR_1) )
{
if ( nNr1 == 0 )
{
if ( bCheckOnly )
pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetCurrentNode()->GetParent().Is() );
2002-11-18 14:29:33 +00:00
else if ( pSAXParser->GetCurrentNode()->GetParent().Is() )
pSAXParser->SetCurrentNode( pSAXParser->GetCurrentNode()->GetParent() );
}
else if ( !pElementNode )
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
else if ( bCheckOnly )
pRet->GenReturn ( RET_Value, nMethodId, ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, pElementNode->GetChildCount() ) );
else if ( ValueOK( rtl::OString(), RcString( nMethodId ), nNr1, pElementNode->GetChildCount() ) )
2002-11-18 14:29:33 +00:00
pSAXParser->SetCurrentNode( pElementNode->GetChild( nNr1-1 ) );
}
else if( (nParams & PARAM_STR_1) )
{
if ( aString1.EqualsAscii( "/" ) )
{
if ( bCheckOnly )
pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)sal_True );
2002-11-18 14:29:33 +00:00
else
pSAXParser->SetCurrentNode( pSAXParser->GetRootNode() );
}
else if ( aString1.Copy(0,2).EqualsAscii( "*:" ) )
{
sal_uLong nTimestamp = (sal_uLong)aString1.GetToken( 1, ':' ).ToInt64();
sal_uLong nPointer = (sal_uLong)aString1.GetToken( 2, ':' ).ToInt64();
2002-11-18 14:29:33 +00:00
if ( bCheckOnly )
pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)(pSAXParser->GetTimestamp() == nTimestamp) );
2002-11-18 14:29:33 +00:00
else
if ( pSAXParser->GetTimestamp() == nTimestamp )
{
{
Node* pNode = (Node*)nPointer;
pSAXParser->SetCurrentNode( NodeRef( pNode ) );
}
}
else
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
}
else if ( pElementNode )
{
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101 * commit 'ooo/DEV300_m101': (185 commits) masterfix DEV300: #i10000# usage of L10N build_type masterfix: #i10000# INT16 -> sal_Int16 fixed compile errors after resync to m100, part2 gridsort: post-rebase fixes CWS gnumake3: found another tools integer type removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw native359: #i114398# changing mac langpack icon native359: #i115669# fixing package description for solaris packages gnumake3: remove comphelper version; fix including extract.hxx locales34: #i106785# add Haitian_Haiti [ht-HT] to language list and locale data; locale data contributed by <jcpoulard> sb138: #i116659# timely termination of OnLogRotateThread accfixes: removed include of obsolete header file accfixes: removed obsolete file removetooltypes01: #i112600# Fix build problems on non-pro accfixes: moved some shared strings to svx part2 accfixes: moved some shared strings to svx accfixes: added more accessibility information and fixed tab orders in multiple dialogs (cui module) removetooltypes01: #i112600# Remove tools types for Mac specific parts fixed tab order in BasicIDE, Library dialog tab page added some accessible names in BasicIDE ... Conflicts: UnoControls/source/base/registercontrols.cxx accessibility/inc/accessibility/standard/vclxaccessiblelistboxlist.hxx automation/inc/automation/communi.hxx automation/inc/automation/simplecm.hxx automation/source/communi/communi.cxx automation/source/inc/rcontrol.hxx automation/source/miniapp/servuid.hxx automation/source/server/XMLParser.cxx automation/source/server/cmdbasestream.cxx automation/source/server/profiler.hxx automation/source/server/recorder.cxx automation/source/server/retstrm.hxx automation/source/server/server.cxx automation/source/server/sta_list.cxx automation/source/server/statemnt.cxx automation/source/server/statemnt.hxx automation/source/simplecm/packethandler.cxx automation/source/simplecm/simplecm.cxx automation/source/simplecm/tcpio.cxx automation/source/simplecm/tcpio.hxx automation/source/testtool/comm_bas.hxx automation/source/testtool/cretstrm.hxx automation/source/testtool/httprequest.cxx automation/source/testtool/httprequest.hxx automation/source/testtool/objtest.cxx automation/source/testtool/objtest.hxx basctl/source/basicide/baside2.cxx basctl/source/basicide/baside2.hxx basctl/source/basicide/baside2b.cxx basctl/source/basicide/baside3.cxx basctl/source/basicide/basides1.cxx basctl/source/basicide/basides2.cxx basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.src basctl/source/basicide/basobj3.cxx basctl/source/basicide/bastype2.cxx basctl/source/basicide/bastype3.cxx basctl/source/basicide/bastypes.cxx basctl/source/basicide/brkdlg.cxx basctl/source/basicide/iderdll.cxx basctl/source/basicide/macrodlg.cxx basctl/source/basicide/moduldl2.cxx basctl/source/basicide/moduldlg.cxx basctl/source/basicide/objdlg.cxx basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/tbxctl.cxx basctl/source/basicide/tbxctl.hxx basctl/source/basicide/tbxctl.src basctl/source/dlged/dlged.cxx basctl/source/dlged/dlgedfunc.cxx basctl/source/dlged/dlgedobj.cxx basctl/source/inc/basidesh.hxx basctl/source/inc/bastypes.hxx basctl/source/inc/dlgedmod.hxx basctl/source/inc/dlgedpage.hxx crashrep/prj/build.lst cui/inc/pch/precompiled_cui.hxx cui/source/customize/acccfg.cxx cui/source/customize/acccfg.hrc cui/source/customize/acccfg.src cui/source/customize/cfg.cxx cui/source/customize/cfgutil.cxx cui/source/customize/macropg.cxx cui/source/customize/macropg.src cui/source/customize/selector.cxx cui/source/dialogs/SpellDialog.cxx cui/source/dialogs/commonlingui.cxx cui/source/dialogs/cuicharmap.cxx cui/source/dialogs/cuifmsearch.cxx cui/source/dialogs/cuigaldlg.cxx cui/source/dialogs/cuigrfflt.cxx cui/source/dialogs/hldocntp.cxx cui/source/dialogs/hldoctp.cxx cui/source/dialogs/hlinettp.cxx cui/source/dialogs/hlmailtp.cxx cui/source/dialogs/hlmarkwn.cxx cui/source/dialogs/hlmarkwn.src cui/source/dialogs/hltpbase.cxx cui/source/dialogs/iconcdlg.cxx cui/source/dialogs/passwdomdlg.cxx cui/source/dialogs/pastedlg.cxx cui/source/dialogs/scriptdlg.cxx cui/source/dialogs/thesdlg.cxx cui/source/dialogs/zoom.cxx cui/source/factory/dlgfact.hxx cui/source/inc/SpellDialog.hxx cui/source/inc/autocdlg.hxx cui/source/inc/backgrnd.hxx cui/source/inc/bbdlg.hxx cui/source/inc/cfg.hxx cui/source/inc/cfgutil.hxx cui/source/inc/cuigaldlg.hxx cui/source/inc/cuigrfflt.hxx cui/source/inc/cuitabarea.hxx cui/source/inc/cuitabline.hxx cui/source/inc/hldocntp.hxx cui/source/inc/hltpbase.hxx cui/source/inc/iconcdlg.hxx cui/source/inc/numpages.hxx cui/source/inc/page.hxx cui/source/inc/postdlg.hxx cui/source/inc/scriptdlg.hxx cui/source/inc/transfrm.hxx cui/source/inc/zoom.hxx cui/source/options/cfgchart.cxx cui/source/options/cuisrchdlg.cxx cui/source/options/dbregister.cxx cui/source/options/dbregister.src cui/source/options/fontsubs.cxx cui/source/options/internationaloptions.cxx cui/source/options/optasian.cxx cui/source/options/optchart.cxx cui/source/options/optcolor.cxx cui/source/options/optcolor.src cui/source/options/optfltr.cxx cui/source/options/optfltr.src cui/source/options/optgdlg.cxx cui/source/options/optgdlg.src cui/source/options/optgenrl.cxx cui/source/options/opthtml.cxx cui/source/options/optimprove.cxx cui/source/options/optinet2.cxx cui/source/options/optinet2.hxx cui/source/options/optjava.cxx cui/source/options/optlingu.cxx cui/source/options/optsave.cxx cui/source/options/optsave.hxx cui/source/options/treeopt.cxx cui/source/options/webconninfo.cxx cui/source/tabpages/autocdlg.cxx cui/source/tabpages/backgrnd.cxx cui/source/tabpages/border.cxx cui/source/tabpages/chardlg.cxx cui/source/tabpages/dstribut.cxx cui/source/tabpages/grfpage.cxx cui/source/tabpages/macroass.cxx cui/source/tabpages/measure.cxx cui/source/tabpages/numfmt.cxx cui/source/tabpages/numpages.cxx cui/source/tabpages/page.cxx cui/source/tabpages/paragrph.cxx cui/source/tabpages/swpossizetabpage.cxx cui/source/tabpages/tabarea.src cui/source/tabpages/textanim.cxx cui/source/tabpages/textattr.cxx cui/source/tabpages/tparea.cxx cui/source/tabpages/tpbitmap.cxx cui/source/tabpages/tpcolor.cxx cui/source/tabpages/tpgradnt.cxx cui/source/tabpages/tphatch.cxx cui/source/tabpages/tpline.cxx cui/source/tabpages/tplnedef.cxx cui/source/tabpages/tplneend.cxx cui/source/tabpages/tpshadow.cxx cui/source/tabpages/transfrm.cxx embedserv/source/embed/register.cxx extensions/inc/pch/precompiled_extensions.hxx extensions/inc/propctrlr.hrc extensions/source/abpilot/abpservices.cxx extensions/source/bibliography/bibload.cxx extensions/source/bibliography/datman.cxx extensions/source/bibliography/general.cxx extensions/source/dbpilots/dbpservices.cxx extensions/source/inc/componentmodule.cxx extensions/source/nsplugin/source/so_env.cxx extensions/source/ole/oleobjw.cxx extensions/source/ole/oleobjw.hxx extensions/source/oooimprovement/invite_job.cxx extensions/source/oooimprovement/onlogrotate_job.cxx extensions/source/plugin/base/service.cxx extensions/source/plugin/inc/plugin/unx/mediator.hxx extensions/source/plugin/inc/plugin/unx/plugcon.hxx extensions/source/plugin/unx/mediator.cxx extensions/source/plugin/unx/nppapi.cxx extensions/source/plugin/unx/plugcon.cxx extensions/source/preload/services.cxx extensions/source/propctrlr/formmetadata.cxx extensions/source/propctrlr/pcrservices.cxx extensions/source/resource/resource.cxx extensions/source/scanner/sane.hxx extensions/source/scanner/sanedlg.cxx extensions/source/scanner/scanunx.cxx extensions/source/scanner/scanwin.cxx extensions/source/scanner/twain.cxx extensions/source/scanner/twain.hxx extensions/source/update/check/updatecheckconfig.cxx extensions/test/stm/datatest.cxx extensions/test/stm/marktest.cxx extensions/test/stm/pipetest.cxx extensions/test/stm/testfactreg.cxx extensions/workben/testpgp.cxx forms/qa/complex/forms/CheckOGroupBoxModel.java forms/qa/makefile.mk forms/source/component/Button.cxx forms/source/component/Button.hxx forms/source/component/ListBox.cxx forms/source/inc/forms_module_impl.hxx forms/source/misc/services.cxx forms/source/solar/control/navtoolbar.cxx javainstaller2/prj/build.lst javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java lingucomponent/prj/build.lst lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx lingucomponent/source/spellcheck/spell/sreg.cxx lingucomponent/source/spellcheck/spell/sspellimp.cxx package/source/manifest/ManifestExport.cxx package/source/manifest/UnoRegister.cxx package/source/xstor/owriteablestream.cxx package/source/xstor/owriteablestream.hxx package/source/xstor/xstorage.hxx package/source/zippackage/ZipPackageFolder.cxx package/source/zippackage/ZipPackageStream.cxx setup_native/source/mac/ooo/DS_Store setup_native/source/win32/customactions/shellextensions/registerextensions.cxx xmlsecurity/prj/build.lst xmlsecurity/source/component/registerservices.cxx xmlsecurity/source/dialogs/stbcontrl.cxx xmlsecurity/source/framework/xsec_framework.cxx xmlsecurity/source/xmlsec/xsec_xmlsec.cxx xmlsecurity/tools/demo/util.hxx xmlsecurity/workben/signaturetest.cxx
2011-03-09 16:20:50 -06:00
sal_uInt16 nNthOccurrence;
2002-11-18 14:29:33 +00:00
if( (nParams & PARAM_USHORT_1) )
2010-12-04 12:56:38 +09:00
nNthOccurrence = nNr1;
2002-11-18 14:29:33 +00:00
else
2010-12-04 12:56:38 +09:00
nNthOccurrence = 1;
2002-11-18 14:29:33 +00:00
sal_uInt16 i;
2002-11-18 14:29:33 +00:00
NodeRef xNew;
for ( i = 0 ; i < pElementNode->GetChildCount() && !xNew.Is() ; i++ )
{
xNew = pElementNode->GetChild( i );
if ( xNew->GetNodeType() == NODE_ELEMENT )
{
ElementNode* pNewElement = (ElementNode*)(&xNew);
if ( aString1.Equals( pNewElement->GetNodeName() ) )
{
2010-12-04 12:56:38 +09:00
if ( nNthOccurrence > 1 )
2002-11-18 14:29:33 +00:00
{
xNew.Clear();
2010-12-04 12:56:38 +09:00
nNthOccurrence--;
2002-11-18 14:29:33 +00:00
}
}
else
xNew.Clear();
}
else
xNew.Clear();
}
if ( bCheckOnly )
pRet->GenReturn ( RET_Value, nMethodId, xNew.Is() );
2002-11-18 14:29:33 +00:00
else
if ( xNew.Is() )
pSAXParser->SetCurrentNode( xNew );
else
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
}
else
if ( bCheckOnly )
pRet->GenReturn ( RET_Value, nMethodId, (comm_BOOL)sal_False );
2002-11-18 14:29:33 +00:00
else
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
}
else
ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) );
}
break;
case RC_SAXGetElementPath:
{
DBG_ASSERT( sizeof( sal_uIntPtr ) == sizeof ( void* ), "Pointertype has different size than sal_uIntPtr");
2002-11-18 14:29:33 +00:00
String aPath;
aPath.AppendAscii( "*:" );
aPath.Append( String::CreateFromInt64( pSAXParser->GetTimestamp() ) );
aPath.AppendAscii( ":" );
NodeRef xNode=pSAXParser->GetCurrentNode();
Node* pNode = (Node*)(&xNode);
aPath.Append( String::CreateFromInt64( (sal_uIntPtr)pNode ) );
pRet->GenReturn ( RET_Value, nMethodId, aPath );
2002-11-18 14:29:33 +00:00
}
break;
case RC_SAXRelease:
{
xParserKeepaliveReference.clear();
}
break;
default:
ReportError( GEN_RES_STR1( S_INTERNAL_ERROR, RcString( nMethodId ) ) );
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */