2002-09-20 13:37:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: ScriptMetadataImporter.cxx,v $
|
|
|
|
*
|
2002-10-30 15:12:44 +00:00
|
|
|
* $Revision: 1.6 $
|
2002-09-20 13:37:46 +00:00
|
|
|
*
|
2002-10-30 15:12:44 +00:00
|
|
|
* last change: $Author: dfoster $ $Date: 2002-10-30 16:12:44 $
|
2002-09-20 13:37:46 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library 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 for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2002-10-24 09:37:53 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
#include "ScriptMetadataImporter.hxx"
|
2002-10-24 09:37:53 +00:00
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
#include <osl/mutex.hxx>
|
2002-10-24 09:37:53 +00:00
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
#include <com/sun/star/xml/sax/XParser.hpp>
|
2002-10-24 09:37:53 +00:00
|
|
|
#include <rtl/string.h>
|
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
#include <util/util.hxx>
|
|
|
|
|
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
|
|
|
|
namespace scripting_impl
|
|
|
|
{
|
|
|
|
//*************************************************************************
|
2002-09-24 12:20:47 +00:00
|
|
|
ScriptMetadataImporter::ScriptMetadataImporter(
|
|
|
|
const Reference< XComponentContext > & xContext )
|
|
|
|
: m_xContext( xContext )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
OSL_TRACE( "< ScriptMetadataImporter ctor called >\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
ScriptMetadataImporter::~ScriptMetadataImporter() SAL_THROW( () )
|
|
|
|
{
|
|
|
|
OSL_TRACE( "< ScriptMetadataImporter dtor called >\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//*************************************************************************
|
2002-10-17 09:04:15 +00:00
|
|
|
void ScriptMetadataImporter::parseMetaData(
|
2002-09-24 12:20:47 +00:00
|
|
|
Reference< io::XInputStream > const & xInput,
|
2002-10-17 09:04:15 +00:00
|
|
|
const ::rtl::OUString & parcelURI,
|
2002-10-23 13:22:05 +00:00
|
|
|
InfoImpls_vec & io_ScriptDatas )
|
2002-09-24 12:20:47 +00:00
|
|
|
throw ( xml::sax::SAXException, io::IOException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-23 13:22:05 +00:00
|
|
|
|
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
|
|
|
|
|
|
|
mpv_ScriptDatas = &io_ScriptDatas;
|
|
|
|
InfoImpls_vec & ms_ScriptDatas = *mpv_ScriptDatas;
|
2002-09-20 13:37:46 +00:00
|
|
|
//Clear the vector of parsed information
|
2002-10-23 13:22:05 +00:00
|
|
|
ms_ScriptDatas.clear();
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
//Set the placeholder for the parcel URI
|
|
|
|
ms_parcelURI = parcelURI;
|
|
|
|
|
|
|
|
//Get the parser service
|
2002-10-24 09:37:53 +00:00
|
|
|
validateXRef( m_xContext,
|
|
|
|
"ScriptMetadataImporter::parseMetaData: No context available" );
|
2002-09-24 12:20:47 +00:00
|
|
|
|
|
|
|
Reference< lang::XMultiComponentFactory > xMgr =
|
|
|
|
m_xContext->getServiceManager();
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-10-24 09:37:53 +00:00
|
|
|
validateXRef( xMgr,
|
|
|
|
"ScriptMetadataImporter::parseMetaData: No service manager available" );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
Reference< XInterface > xx = xMgr->createInstanceWithContext(
|
2002-10-24 09:37:53 +00:00
|
|
|
OUString::createFromAscii( "com.sun.star.xml.sax.Parser" ), m_xContext );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-10-24 09:37:53 +00:00
|
|
|
validateXRef( xMgr, "ScriptMetadataImporter::parseMetaData: cannot get SAX Parser" );
|
|
|
|
Reference< xml::sax::XParser > xParser( xx,UNO_QUERY_THROW );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
// xxx todo: error handler, entity resolver omitted
|
|
|
|
// This class is the document handler for the parser
|
|
|
|
Reference< xml::sax::XDocumentHandler > t_smI( this );
|
|
|
|
xParser->setDocumentHandler( t_smI );
|
|
|
|
|
|
|
|
//Set up the input for the parser, the XInputStream
|
|
|
|
xml::sax::InputSource source;
|
|
|
|
source.aInputStream = xInput;
|
2002-10-24 09:37:53 +00:00
|
|
|
source.sSystemId = OUSTR( "virtual file" );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: Start the parser\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xParser->parseStream( source );
|
|
|
|
}
|
|
|
|
catch ( xml::sax::SAXException & saxe )
|
|
|
|
{
|
2002-09-24 12:20:47 +00:00
|
|
|
OUString msg = OUString::createFromAscii(
|
2002-10-24 09:37:53 +00:00
|
|
|
"ScriptMetadata:Importer::parserMetaData SAXException" );
|
|
|
|
msg.concat( saxe.Message );
|
2002-09-24 12:20:47 +00:00
|
|
|
throw xml::sax::SAXException( msg, Reference< XInterface > (),
|
2002-10-24 09:37:53 +00:00
|
|
|
saxe.WrappedException );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
catch ( io::IOException & ioe )
|
|
|
|
{
|
|
|
|
throw io::IOException( OUString::createFromAscii(
|
2002-10-24 09:37:53 +00:00
|
|
|
"ScriptMetadataImporter::parseMetaData IOException: " ) + ioe.Message,
|
|
|
|
Reference< XInterface > () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-24 12:20:47 +00:00
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
catch ( ... )
|
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
throw RuntimeException( OUString::createFromAscii(
|
|
|
|
"ScriptMetadataImporter::parseMetadata UnknownException: " ),
|
|
|
|
Reference< XInterface > () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
2002-09-24 12:20:47 +00:00
|
|
|
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: Parser finished\n ");
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-24 12:20:47 +00:00
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "ScriptMetadataImporter: vector size is %d\n",
|
|
|
|
ms_ScriptDatas.size() );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
// XExtendedDocumentHandler impl
|
|
|
|
void ScriptMetadataImporter::startCDATA()
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: startCDATA()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::endCDATA()
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: endDATA()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::comment( const ::rtl::OUString & sComment )
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: comment()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::allowLineBreak()
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: allowLineBreak()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::unknown( const ::rtl::OUString & sString )
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: unknown()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
// XDocumentHandler impl
|
|
|
|
void ScriptMetadataImporter::startDocument()
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
// Ignore for now
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: startDocument()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::endDocument()
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
// Ignore for now
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: endDocument()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::startElement(
|
|
|
|
const ::rtl::OUString& tagName,
|
|
|
|
const Reference< xml::sax::XAttributeList >& xAttribs )
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-24 12:20:47 +00:00
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "Trace Message : ScriptMetadataImporter: startElement() %s\n",
|
|
|
|
::rtl::OUStringToOString( tagName,
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
|
|
|
|
|
|
|
//Set the state of the state machine
|
2002-10-24 09:37:53 +00:00
|
|
|
setState( tagName );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
//Processing the elements
|
2002-10-24 09:37:53 +00:00
|
|
|
switch( m_state )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-23 13:22:05 +00:00
|
|
|
case SCRIPT:
|
2002-10-30 15:12:44 +00:00
|
|
|
m_ScriptData = ScriptData();
|
2002-10-23 13:22:05 +00:00
|
|
|
m_ScriptData.parcelURI = ms_parcelURI;
|
|
|
|
m_ScriptData.language = xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "language" ));
|
2002-10-17 09:04:15 +00:00
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "Trace Message: language is %s\n",
|
|
|
|
::rtl::OUStringToOString( m_ScriptData.language,
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-10-17 09:04:15 +00:00
|
|
|
#endif
|
2002-10-23 13:22:05 +00:00
|
|
|
break;
|
|
|
|
case LOCALE:
|
|
|
|
ms_localeLang = xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "lang" ) );
|
2002-10-17 09:04:15 +00:00
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "Trace Message: Locale is %s\n",
|
|
|
|
::rtl::OUStringToOString( ms_localeLang,
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-10-17 09:04:15 +00:00
|
|
|
#endif
|
|
|
|
break;
|
2002-10-23 13:22:05 +00:00
|
|
|
case DISPLAYNAME:
|
|
|
|
ms_localeDisName = xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "value" ));
|
2002-09-24 12:20:47 +00:00
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "Trace Message: Displyaname is %s\n",
|
|
|
|
::rtl::OUStringToOString( ms_localeDisName,
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
2002-10-23 13:22:05 +00:00
|
|
|
break;
|
|
|
|
case FUNCTIONNAME:
|
|
|
|
m_ScriptData.functionname = xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "value" ) );
|
2002-09-24 12:20:47 +00:00
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "Trace Message: Functionname is %s\n",
|
|
|
|
::rtl::OUStringToOString( m_ScriptData.functionname,
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
2002-10-23 13:22:05 +00:00
|
|
|
break;
|
|
|
|
case LOGICALNAME:
|
|
|
|
m_ScriptData.logicalname = xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "value" ));
|
2002-10-23 13:22:05 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
fprintf(stderr, "Trace Message: logicalname is %s\n",
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUStringToOString( m_ScriptData.logicalname,
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-10-23 13:22:05 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case LANGDEPPROPS:
|
|
|
|
m_ScriptData.languagedepprops.push_back(
|
|
|
|
::std::make_pair( xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "name" ) ),
|
2002-10-23 13:22:05 +00:00
|
|
|
xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "value" ) )
|
2002-10-23 13:22:05 +00:00
|
|
|
));
|
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "Trace Message: Langdepprops is %s\t%s\n",
|
2002-10-23 13:22:05 +00:00
|
|
|
::rtl::OUStringToOString( xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "name" ) ),
|
2002-10-23 13:22:05 +00:00
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer,
|
|
|
|
::rtl::OUStringToOString( xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "value" ) ),
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-10-23 13:22:05 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case FILESET:
|
|
|
|
ms_filesetname = xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "name" ) );
|
2002-10-23 13:22:05 +00:00
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "Trace Message: filesetname is %s\n",
|
2002-10-23 13:22:05 +00:00
|
|
|
::rtl::OUStringToOString(ms_filesetname,
|
2002-10-24 09:37:53 +00:00
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-10-23 13:22:05 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case FILESETPROPS:
|
|
|
|
mv_filesetprops.push_back( ::std::make_pair(
|
2002-10-17 09:04:15 +00:00
|
|
|
xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "name" ) ),
|
2002-10-17 09:04:15 +00:00
|
|
|
xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "value" ) )
|
2002-10-23 13:22:05 +00:00
|
|
|
));
|
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "Trace Message: filesetprops is %s\t%s\n",
|
2002-10-23 13:22:05 +00:00
|
|
|
::rtl::OUStringToOString( xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "name" ) ),
|
2002-10-23 13:22:05 +00:00
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer,
|
|
|
|
::rtl::OUStringToOString( xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "value" ) ),
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-10-23 13:22:05 +00:00
|
|
|
#endif
|
2002-10-17 09:04:15 +00:00
|
|
|
break;
|
2002-10-23 13:22:05 +00:00
|
|
|
case FILES:
|
|
|
|
ms_filename = xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "name" ) );
|
2002-10-23 13:22:05 +00:00
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "Trace Message: filename is %s\n",
|
|
|
|
::rtl::OUStringToOString( ms_filename,
|
|
|
|
RTL_TEXTENCODING_ASCII_US).pData->buffer );
|
2002-10-23 13:22:05 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case FILEPROPS:
|
|
|
|
/**
|
2002-10-24 09:37:53 +00:00
|
|
|
mm_files.insert( strpair_pair( ms_filename,
|
2002-10-23 13:22:05 +00:00
|
|
|
str_pair( xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "name" ) ),
|
2002-10-17 09:04:15 +00:00
|
|
|
xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "value") ) )
|
2002-10-23 13:22:05 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
*/
|
|
|
|
mv_fileprops.push_back(str_pair( xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "name" ) ),
|
2002-10-23 13:22:05 +00:00
|
|
|
xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "value") ) ) );
|
2002-09-20 13:37:46 +00:00
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "Trace Message: fileprops is %s\t%s\n",
|
2002-10-17 09:04:15 +00:00
|
|
|
::rtl::OUStringToOString( xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "name" ) ),
|
2002-10-23 13:22:05 +00:00
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer,
|
|
|
|
::rtl::OUStringToOString( xAttribs->getValueByName(
|
2002-10-24 09:37:53 +00:00
|
|
|
::rtl::OUString::createFromAscii( "value" ) ),
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
2002-10-17 09:04:15 +00:00
|
|
|
break;
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::endElement( const ::rtl::OUString & aName )
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
//The end tag of an element
|
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "ScriptMetadataImporter: endElement() %s\n",
|
|
|
|
::rtl::OUStringToOString( aName,
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
|
|
|
|
|
|
|
//Set the state
|
2002-10-24 09:37:53 +00:00
|
|
|
setState( aName );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
|
2002-10-24 09:37:53 +00:00
|
|
|
switch ( m_state )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-23 13:22:05 +00:00
|
|
|
case PARCEL:
|
|
|
|
break;
|
|
|
|
case SCRIPT:
|
|
|
|
mpv_ScriptDatas->push_back( m_ScriptData );
|
|
|
|
//Clear all templates used in preparation for next script
|
|
|
|
mv_filesetprops.clear();
|
|
|
|
mm_files.clear();
|
|
|
|
break;
|
|
|
|
case LOCALE:
|
2002-10-24 09:37:53 +00:00
|
|
|
m_ScriptData.locales[ ms_localeLang ] = ::std::make_pair(
|
2002-10-23 13:22:05 +00:00
|
|
|
ms_localeDisName, ms_localeDesc );
|
|
|
|
break;
|
|
|
|
case FILESET:
|
2002-10-30 15:12:44 +00:00
|
|
|
OSL_TRACE("adding fileset %s to filesets map",
|
|
|
|
::rtl::OUStringToOString( ms_filesetname,
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-10-24 09:37:53 +00:00
|
|
|
m_ScriptData.filesets[ ms_filesetname ] = ::std::make_pair(
|
2002-10-23 13:22:05 +00:00
|
|
|
mv_filesetprops, mm_files );
|
2002-10-30 15:12:44 +00:00
|
|
|
mm_files.clear();
|
2002-10-23 13:22:05 +00:00
|
|
|
case FILES:
|
2002-10-30 15:12:44 +00:00
|
|
|
OSL_TRACE("adding files %s to files map",
|
|
|
|
::rtl::OUStringToOString( ms_filename,
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-10-24 09:37:53 +00:00
|
|
|
mm_files[ ms_filename ] = mv_fileprops;
|
2002-10-23 13:22:05 +00:00
|
|
|
mv_fileprops.clear();
|
|
|
|
break;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::characters( const ::rtl::OUString & aChars )
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: characters()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
|
|
|
|
2002-10-24 09:37:53 +00:00
|
|
|
switch ( m_state )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
case DESCRIPTION:
|
|
|
|
//Put description into the struct
|
2002-10-23 13:22:05 +00:00
|
|
|
ms_localeDesc = aChars;
|
2002-09-20 13:37:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::ignorableWhitespace(
|
|
|
|
const ::rtl::OUString & aWhitespaces )
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: ignorableWhiteSpace()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::processingInstruction(
|
|
|
|
const ::rtl::OUString & aTarget, const ::rtl::OUString & aData )
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: processingInstruction()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
void ScriptMetadataImporter::setDocumentLocator(
|
|
|
|
const Reference< xml::sax::XLocator >& xLocator )
|
2002-10-24 09:37:53 +00:00
|
|
|
throw ( xml::sax::SAXException, RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
OSL_TRACE( "ScriptMetadataImporter: setDocumentLocator()\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
2002-10-24 09:37:53 +00:00
|
|
|
void ScriptMetadataImporter::setState( const ::rtl::OUString & tagName )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
//Set the state depending on the tag name of the current
|
|
|
|
//element the parser has arrived at
|
|
|
|
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
|
|
|
|
2002-10-24 09:37:53 +00:00
|
|
|
if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "parcel" ) ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
//Parcel tag
|
|
|
|
m_state = PARCEL;
|
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "script" ) ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
m_state = SCRIPT;
|
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "locale" ) ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-23 13:22:05 +00:00
|
|
|
m_state = LOCALE;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "displayname" ) ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-23 13:22:05 +00:00
|
|
|
m_state = DISPLAYNAME;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "description" ) ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-23 13:22:05 +00:00
|
|
|
m_state = DESCRIPTION;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "functionname" ) ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-23 13:22:05 +00:00
|
|
|
m_state = FUNCTIONNAME;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "logicalname" ) ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-23 13:22:05 +00:00
|
|
|
m_state = LOGICALNAME;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "languagedepprops" ) ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-23 13:22:05 +00:00
|
|
|
m_state = LANGUAGEDEPPROPS;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "prop" ) ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-10-24 09:37:53 +00:00
|
|
|
if( m_state == LANGUAGEDEPPROPS )
|
2002-10-23 13:22:05 +00:00
|
|
|
{
|
|
|
|
m_state = LANGDEPPROPS;
|
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( m_state == FILESET )
|
2002-10-23 13:22:05 +00:00
|
|
|
{
|
|
|
|
m_state = FILESETPROPS;
|
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( m_state == FILES )
|
2002-10-23 13:22:05 +00:00
|
|
|
{
|
|
|
|
m_state = FILEPROPS;
|
|
|
|
}
|
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "fileset" ) ) )
|
2002-10-23 13:22:05 +00:00
|
|
|
{
|
|
|
|
m_state = FILESET;
|
|
|
|
}
|
2002-10-24 09:37:53 +00:00
|
|
|
else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "file" ) ) )
|
2002-10-23 13:22:05 +00:00
|
|
|
{
|
|
|
|
m_state = FILES;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-10-17 09:04:15 +00:00
|
|
|
//If there is a tag we don't know about, throw a exception (wobbler) :)
|
2002-09-20 13:37:46 +00:00
|
|
|
::rtl::OUString str_sax = ::rtl::OUString::createFromAscii( "No Such Tag" );
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2002-10-24 09:37:53 +00:00
|
|
|
fprintf( stderr, "ScriptMetadataImporter: No Such Tag: %s\n",
|
2002-09-24 12:20:47 +00:00
|
|
|
::rtl::OUStringToOString(
|
2002-10-24 09:37:53 +00:00
|
|
|
tagName, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
throw xml::sax::SAXException(
|
|
|
|
str_sax, Reference< XInterface >(), Any() );
|
|
|
|
}
|
|
|
|
}
|
2002-10-23 13:22:05 +00:00
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|