1*2c696243SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2c696243SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2c696243SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2c696243SAndrew Rist * distributed with this work for additional information 6*2c696243SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2c696243SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2c696243SAndrew Rist * "License"); you may not use this file except in compliance 9*2c696243SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2c696243SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2c696243SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2c696243SAndrew Rist * software distributed under the License is distributed on an 15*2c696243SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2c696243SAndrew Rist * KIND, either express or implied. See the License for the 17*2c696243SAndrew Rist * specific language governing permissions and limitations 18*2c696243SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2c696243SAndrew Rist *************************************************************/ 21*2c696243SAndrew Rist 22*2c696243SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_scripting.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifdef _DEBUG 28cdf0e10cSrcweir #include <stdio.h> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "ScriptMetadataImporter.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <osl/mutex.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <com/sun/star/xml/sax/XParser.hpp> 36cdf0e10cSrcweir #include <rtl/string.h> 37cdf0e10cSrcweir #include <tools/diagnose_ex.h> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <util/util.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir using namespace ::rtl; 42cdf0e10cSrcweir using namespace ::com::sun::star; 43cdf0e10cSrcweir using namespace ::com::sun::star::uno; 44cdf0e10cSrcweir 45cdf0e10cSrcweir namespace scripting_impl 46cdf0e10cSrcweir { 47cdf0e10cSrcweir //************************************************************************* 48cdf0e10cSrcweir ScriptMetadataImporter::ScriptMetadataImporter( 49cdf0e10cSrcweir const Reference< XComponentContext > & xContext ) 50cdf0e10cSrcweir : m_xContext( xContext ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir OSL_TRACE( "< ScriptMetadataImporter ctor called >\n" ); 53cdf0e10cSrcweir ms_localeDesc = new OUStringBuffer(); 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir //************************************************************************* 57cdf0e10cSrcweir ScriptMetadataImporter::~ScriptMetadataImporter() SAL_THROW( () ) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir OSL_TRACE( "< ScriptMetadataImporter dtor called >\n" ); 60cdf0e10cSrcweir delete ms_localeDesc; 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir 64cdf0e10cSrcweir //************************************************************************* 65cdf0e10cSrcweir void ScriptMetadataImporter::parseMetaData( 66cdf0e10cSrcweir Reference< io::XInputStream > const & xInput, 67cdf0e10cSrcweir const ::rtl::OUString & parcelURI, 68cdf0e10cSrcweir InfoImpls_vec & io_ScriptDatas ) 69cdf0e10cSrcweir throw ( xml::sax::SAXException, io::IOException, RuntimeException ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir 72cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( m_mutex ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir mpv_ScriptDatas = &io_ScriptDatas; 75cdf0e10cSrcweir mpv_ScriptDatas->clear(); 76cdf0e10cSrcweir 77cdf0e10cSrcweir //Set the placeholder for the parcel URI 78cdf0e10cSrcweir ms_parcelURI = parcelURI; 79cdf0e10cSrcweir 80cdf0e10cSrcweir //Get the parser service 81cdf0e10cSrcweir ENSURE_OR_THROW( m_xContext.is(), 82cdf0e10cSrcweir "ScriptMetadataImporter::parseMetaData: No context available" ); 83cdf0e10cSrcweir 84cdf0e10cSrcweir Reference< lang::XMultiComponentFactory > xMgr( m_xContext->getServiceManager(), UNO_SET_THROW ); 85cdf0e10cSrcweir 86cdf0e10cSrcweir Reference< xml::sax::XParser > xParser( 87cdf0e10cSrcweir xMgr->createInstanceWithContext( OUString::createFromAscii( "com.sun.star.xml.sax.Parser" ), m_xContext ), 88cdf0e10cSrcweir UNO_QUERY_THROW ); 89cdf0e10cSrcweir 90cdf0e10cSrcweir // xxx todo: error handler, entity resolver omitted 91cdf0e10cSrcweir // This class is the document handler for the parser 92cdf0e10cSrcweir Reference< xml::sax::XDocumentHandler > t_smI( this ); 93cdf0e10cSrcweir xParser->setDocumentHandler( t_smI ); 94cdf0e10cSrcweir 95cdf0e10cSrcweir //Set up the input for the parser, the XInputStream 96cdf0e10cSrcweir xml::sax::InputSource source; 97cdf0e10cSrcweir source.aInputStream = xInput; 98cdf0e10cSrcweir source.sSystemId = OUSTR( "virtual file" ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: Start the parser\n" ); 101cdf0e10cSrcweir 102cdf0e10cSrcweir try 103cdf0e10cSrcweir { 104cdf0e10cSrcweir xParser->parseStream( source ); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir catch ( xml::sax::SAXException & saxe ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir OUString msg = OUString::createFromAscii( 109cdf0e10cSrcweir "ScriptMetadata:Importer::parserMetaData SAXException" ); 110cdf0e10cSrcweir msg.concat( saxe.Message ); 111cdf0e10cSrcweir throw xml::sax::SAXException( msg, Reference< XInterface > (), 112cdf0e10cSrcweir saxe.WrappedException ); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir catch ( io::IOException & ioe ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir throw io::IOException( OUString::createFromAscii( 117cdf0e10cSrcweir "ScriptMetadataImporter::parseMetaData IOException: " ) + ioe.Message, 118cdf0e10cSrcweir Reference< XInterface > () ); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir #ifdef _DEBUG 122cdf0e10cSrcweir catch ( ... ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir throw RuntimeException( OUString::createFromAscii( 125cdf0e10cSrcweir "ScriptMetadataImporter::parseMetadata UnknownException: " ), 126cdf0e10cSrcweir Reference< XInterface > () ); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir #endif 129cdf0e10cSrcweir 130cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: Parser finished\n "); 131cdf0e10cSrcweir 132cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: vector size is %d\n", 133cdf0e10cSrcweir mpv_ScriptDatas->size() ); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir //************************************************************************* 137cdf0e10cSrcweir // XExtendedDocumentHandler impl 138cdf0e10cSrcweir void ScriptMetadataImporter::startCDATA() 139cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: startCDATA()\n" ); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir //************************************************************************* 145cdf0e10cSrcweir void ScriptMetadataImporter::endCDATA() 146cdf0e10cSrcweir throw ( RuntimeException ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: endDATA()\n" ); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir //************************************************************************* 152cdf0e10cSrcweir void ScriptMetadataImporter::comment( const ::rtl::OUString & sComment ) 153cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: comment()\n" ); 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir //************************************************************************* 159cdf0e10cSrcweir void ScriptMetadataImporter::allowLineBreak() 160cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 161cdf0e10cSrcweir { 162cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: allowLineBreak()\n" ); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir //************************************************************************* 166cdf0e10cSrcweir void ScriptMetadataImporter::unknown( const ::rtl::OUString & sString ) 167cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: unknown()\n" ); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir //************************************************************************* 173cdf0e10cSrcweir // XDocumentHandler impl 174cdf0e10cSrcweir void ScriptMetadataImporter::startDocument() 175cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir // Ignore for now 178cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: startDocument()\n" ); 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir //************************************************************************* 182cdf0e10cSrcweir void ScriptMetadataImporter::endDocument() 183cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir // Ignore for now 186cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: endDocument()\n" ); 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir //************************************************************************* 190cdf0e10cSrcweir void ScriptMetadataImporter::startElement( 191cdf0e10cSrcweir const ::rtl::OUString& tagName, 192cdf0e10cSrcweir const Reference< xml::sax::XAttributeList >& xAttribs ) 193cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir 196cdf0e10cSrcweir OSL_TRACE( "Trace Message : ScriptMetadataImporter: startElement() %s\n", 197cdf0e10cSrcweir ::rtl::OUStringToOString( tagName, 198cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 199cdf0e10cSrcweir 200cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( m_mutex ); 201cdf0e10cSrcweir 202cdf0e10cSrcweir //Set the state of the state machine 203cdf0e10cSrcweir setState( tagName ); 204cdf0e10cSrcweir 205cdf0e10cSrcweir //Processing the elements 206cdf0e10cSrcweir switch( m_state ) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir case SCRIPT: 209cdf0e10cSrcweir m_ScriptData.parcelURI = ms_parcelURI; 210cdf0e10cSrcweir m_ScriptData.language = xAttribs->getValueByName( 211cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "language" )); 212cdf0e10cSrcweir OSL_TRACE( "Trace Message: language is %s\n", 213cdf0e10cSrcweir ::rtl::OUStringToOString( m_ScriptData.language, 214cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 215cdf0e10cSrcweir break; 216cdf0e10cSrcweir case LOCALE: 217cdf0e10cSrcweir ms_localeLang = xAttribs->getValueByName( 218cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "lang" ) ); 219cdf0e10cSrcweir OSL_TRACE( "Trace Message: Locale is %s\n", 220cdf0e10cSrcweir ::rtl::OUStringToOString( ms_localeLang, 221cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 222cdf0e10cSrcweir break; 223cdf0e10cSrcweir case DISPLAYNAME: 224cdf0e10cSrcweir ms_localeDisName = xAttribs->getValueByName( 225cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "value" )); 226cdf0e10cSrcweir OSL_TRACE( "Trace Message: Displyaname is %s\n", 227cdf0e10cSrcweir ::rtl::OUStringToOString( ms_localeDisName, 228cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 229cdf0e10cSrcweir break; 230cdf0e10cSrcweir case FUNCTIONNAME: 231cdf0e10cSrcweir m_ScriptData.functionname = xAttribs->getValueByName( 232cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "value" ) ); 233cdf0e10cSrcweir OSL_TRACE( "Trace Message: Functionname is %s\n", 234cdf0e10cSrcweir ::rtl::OUStringToOString( m_ScriptData.functionname, 235cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 236cdf0e10cSrcweir break; 237cdf0e10cSrcweir case LOGICALNAME: 238cdf0e10cSrcweir m_ScriptData.logicalname = xAttribs->getValueByName( 239cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "value" )); 240cdf0e10cSrcweir #ifdef _DEBUG 241cdf0e10cSrcweir fprintf(stderr, "Trace Message: logicalname is %s\n", 242cdf0e10cSrcweir ::rtl::OUStringToOString( m_ScriptData.logicalname, 243cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 244cdf0e10cSrcweir #endif 245cdf0e10cSrcweir break; 246cdf0e10cSrcweir case LANGDEPPROPS: 247cdf0e10cSrcweir m_ScriptData.languagedepprops.push_back( 248cdf0e10cSrcweir ::std::make_pair( xAttribs->getValueByName( 249cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "name" ) ), 250cdf0e10cSrcweir xAttribs->getValueByName( 251cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "value" ) ) 252cdf0e10cSrcweir )); 253cdf0e10cSrcweir OSL_TRACE( "Trace Message: Langdepprops is %s\t%s\n", 254cdf0e10cSrcweir ::rtl::OUStringToOString( xAttribs->getValueByName( 255cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "name" ) ), 256cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer, 257cdf0e10cSrcweir ::rtl::OUStringToOString( xAttribs->getValueByName( 258cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "value" ) ), 259cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 260cdf0e10cSrcweir break; 261cdf0e10cSrcweir case FILESET: 262cdf0e10cSrcweir ms_filesetname = xAttribs->getValueByName( 263cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "name" ) ); 264cdf0e10cSrcweir OSL_TRACE( "Trace Message: filesetname is %s\n", 265cdf0e10cSrcweir ::rtl::OUStringToOString(ms_filesetname, 266cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 267cdf0e10cSrcweir break; 268cdf0e10cSrcweir case FILESETPROPS: 269cdf0e10cSrcweir mv_filesetprops.push_back( ::std::make_pair( 270cdf0e10cSrcweir xAttribs->getValueByName( 271cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "name" ) ), 272cdf0e10cSrcweir xAttribs->getValueByName( 273cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "value" ) ) 274cdf0e10cSrcweir )); 275cdf0e10cSrcweir OSL_TRACE( "Trace Message: filesetprops is %s\t%s\n", 276cdf0e10cSrcweir ::rtl::OUStringToOString( xAttribs->getValueByName( 277cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "name" ) ), 278cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer, 279cdf0e10cSrcweir ::rtl::OUStringToOString( xAttribs->getValueByName( 280cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "value" ) ), 281cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 282cdf0e10cSrcweir break; 283cdf0e10cSrcweir case FILES: 284cdf0e10cSrcweir ms_filename = xAttribs->getValueByName( 285cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "name" ) ); 286cdf0e10cSrcweir OSL_TRACE( "Trace Message: filename is %s\n", 287cdf0e10cSrcweir ::rtl::OUStringToOString( ms_filename, 288cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US).pData->buffer ); 289cdf0e10cSrcweir break; 290cdf0e10cSrcweir case FILEPROPS: 291cdf0e10cSrcweir /** 292cdf0e10cSrcweir mm_files.insert( strpair_pair( ms_filename, 293cdf0e10cSrcweir str_pair( xAttribs->getValueByName( 294cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "name" ) ), 295cdf0e10cSrcweir xAttribs->getValueByName( 296cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "value") ) ) 297cdf0e10cSrcweir ) 298cdf0e10cSrcweir ); 299cdf0e10cSrcweir */ 300cdf0e10cSrcweir mv_fileprops.push_back(str_pair( xAttribs->getValueByName( 301cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "name" ) ), 302cdf0e10cSrcweir xAttribs->getValueByName( 303cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "value") ) ) ); 304cdf0e10cSrcweir OSL_TRACE( "Trace Message: fileprops is %s\t%s\n", 305cdf0e10cSrcweir ::rtl::OUStringToOString( xAttribs->getValueByName( 306cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "name" ) ), 307cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer, 308cdf0e10cSrcweir ::rtl::OUStringToOString( xAttribs->getValueByName( 309cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "value" ) ), 310cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 311cdf0e10cSrcweir break; 312cdf0e10cSrcweir 313cdf0e10cSrcweir // to prevent compiler warnings 314cdf0e10cSrcweir case PARCEL: 315cdf0e10cSrcweir case DESCRIPTION: 316cdf0e10cSrcweir case LANGUAGEDEPPROPS: 317cdf0e10cSrcweir break; 318cdf0e10cSrcweir } 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir //************************************************************************* 322cdf0e10cSrcweir void ScriptMetadataImporter::endElement( const ::rtl::OUString & aName ) 323cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir 326cdf0e10cSrcweir //The end tag of an element 327cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: endElement() %s\n", 328cdf0e10cSrcweir ::rtl::OUStringToOString( aName, 329cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 330cdf0e10cSrcweir 331cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( m_mutex ); 332cdf0e10cSrcweir 333cdf0e10cSrcweir //Set the state 334cdf0e10cSrcweir setState( aName ); 335cdf0e10cSrcweir 336cdf0e10cSrcweir 337cdf0e10cSrcweir switch ( m_state ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir case PARCEL: 340cdf0e10cSrcweir break; 341cdf0e10cSrcweir case SCRIPT: 342cdf0e10cSrcweir // np adjust logicalName to be equal to function name 343cdf0e10cSrcweir // as logical name concept has been removed 344cdf0e10cSrcweir m_ScriptData.logicalname = m_ScriptData.functionname; 345cdf0e10cSrcweir mpv_ScriptDatas->push_back( m_ScriptData ); 346cdf0e10cSrcweir m_ScriptData = ScriptData(); 347cdf0e10cSrcweir break; 348cdf0e10cSrcweir case LOCALE: 349cdf0e10cSrcweir m_ScriptData.locales[ ms_localeLang ] = ::std::make_pair( 350cdf0e10cSrcweir ms_localeDisName, ms_localeDesc->makeStringAndClear().trim() ); 351cdf0e10cSrcweir break; 352cdf0e10cSrcweir case FILESET: 353cdf0e10cSrcweir OSL_TRACE("adding fileset %s to filesets map", 354cdf0e10cSrcweir ::rtl::OUStringToOString( ms_filesetname, 355cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 356cdf0e10cSrcweir m_ScriptData.filesets[ ms_filesetname ] = ::std::make_pair( 357cdf0e10cSrcweir mv_filesetprops, mm_files ); 358cdf0e10cSrcweir mm_files.clear(); 359cdf0e10cSrcweir mv_filesetprops.clear(); 360cdf0e10cSrcweir break; 361cdf0e10cSrcweir case FILES: 362cdf0e10cSrcweir OSL_TRACE("adding files %s to files map", 363cdf0e10cSrcweir ::rtl::OUStringToOString( ms_filename, 364cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 365cdf0e10cSrcweir mm_files[ ms_filename ] = mv_fileprops; 366cdf0e10cSrcweir mv_fileprops.clear(); 367cdf0e10cSrcweir break; 368cdf0e10cSrcweir // 369cdf0e10cSrcweir // to prevent compiler warnings 370cdf0e10cSrcweir case DISPLAYNAME: 371cdf0e10cSrcweir case DESCRIPTION: 372cdf0e10cSrcweir case FUNCTIONNAME: 373cdf0e10cSrcweir case LOGICALNAME: 374cdf0e10cSrcweir case LANGUAGEDEPPROPS: 375cdf0e10cSrcweir case LANGDEPPROPS: 376cdf0e10cSrcweir case FILESETPROPS: 377cdf0e10cSrcweir case FILEPROPS: 378cdf0e10cSrcweir break; 379cdf0e10cSrcweir } 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir //************************************************************************* 383cdf0e10cSrcweir void ScriptMetadataImporter::characters( const ::rtl::OUString & aChars ) 384cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: characters()\n"); 387cdf0e10cSrcweir 388cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( m_mutex ); 389cdf0e10cSrcweir 390cdf0e10cSrcweir switch ( m_state ) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir case DESCRIPTION: 393cdf0e10cSrcweir //Put description into the struct 394cdf0e10cSrcweir ms_localeDesc->append(aChars); 395cdf0e10cSrcweir break; 396cdf0e10cSrcweir case PARCEL: 397cdf0e10cSrcweir case SCRIPT: 398cdf0e10cSrcweir case LOCALE: 399cdf0e10cSrcweir case DISPLAYNAME: 400cdf0e10cSrcweir case FUNCTIONNAME: 401cdf0e10cSrcweir case LOGICALNAME: 402cdf0e10cSrcweir case LANGUAGEDEPPROPS: 403cdf0e10cSrcweir case LANGDEPPROPS: 404cdf0e10cSrcweir case FILESETPROPS: 405cdf0e10cSrcweir case FILEPROPS: 406cdf0e10cSrcweir break; 407cdf0e10cSrcweir } 408cdf0e10cSrcweir } 409cdf0e10cSrcweir 410cdf0e10cSrcweir //************************************************************************* 411cdf0e10cSrcweir void ScriptMetadataImporter::ignorableWhitespace( 412cdf0e10cSrcweir const ::rtl::OUString & aWhitespaces ) 413cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: ignorableWhiteSpace()\n" ); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir //************************************************************************* 419cdf0e10cSrcweir void ScriptMetadataImporter::processingInstruction( 420cdf0e10cSrcweir const ::rtl::OUString & aTarget, const ::rtl::OUString & aData ) 421cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 422cdf0e10cSrcweir { 423cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: processingInstruction()\n" ); 424cdf0e10cSrcweir } 425cdf0e10cSrcweir 426cdf0e10cSrcweir //************************************************************************* 427cdf0e10cSrcweir void ScriptMetadataImporter::setDocumentLocator( 428cdf0e10cSrcweir const Reference< xml::sax::XLocator >& xLocator ) 429cdf0e10cSrcweir throw ( xml::sax::SAXException, RuntimeException ) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: setDocumentLocator()\n" ); 432cdf0e10cSrcweir } 433cdf0e10cSrcweir 434cdf0e10cSrcweir //************************************************************************* 435cdf0e10cSrcweir void ScriptMetadataImporter::setState( const ::rtl::OUString & tagName ) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir //Set the state depending on the tag name of the current 438cdf0e10cSrcweir //element the parser has arrived at 439cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( m_mutex ); 440cdf0e10cSrcweir 441cdf0e10cSrcweir if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "parcel" ) ) ) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir //Parcel tag 444cdf0e10cSrcweir m_state = PARCEL; 445cdf0e10cSrcweir } 446cdf0e10cSrcweir else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "script" ) ) ) 447cdf0e10cSrcweir { 448cdf0e10cSrcweir m_state = SCRIPT; 449cdf0e10cSrcweir } 450cdf0e10cSrcweir else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "locale" ) ) ) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir m_state = LOCALE; 453cdf0e10cSrcweir } 454cdf0e10cSrcweir else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "displayname" ) ) ) 455cdf0e10cSrcweir { 456cdf0e10cSrcweir m_state = DISPLAYNAME; 457cdf0e10cSrcweir } 458cdf0e10cSrcweir else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "description" ) ) ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir m_state = DESCRIPTION; 461cdf0e10cSrcweir } 462cdf0e10cSrcweir else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "functionname" ) ) ) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir m_state = FUNCTIONNAME; 465cdf0e10cSrcweir } 466cdf0e10cSrcweir else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "logicalname" ) ) ) 467cdf0e10cSrcweir { 468cdf0e10cSrcweir m_state = LOGICALNAME; 469cdf0e10cSrcweir } 470cdf0e10cSrcweir else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "languagedepprops" ) ) ) 471cdf0e10cSrcweir { 472cdf0e10cSrcweir m_state = LANGUAGEDEPPROPS; 473cdf0e10cSrcweir } 474cdf0e10cSrcweir else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "prop" ) ) ) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir if( m_state == LANGUAGEDEPPROPS ) 477cdf0e10cSrcweir { 478cdf0e10cSrcweir m_state = LANGDEPPROPS; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir else if( m_state == FILESET ) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir m_state = FILESETPROPS; 483cdf0e10cSrcweir } 484cdf0e10cSrcweir else if( m_state == FILES ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir m_state = FILEPROPS; 487cdf0e10cSrcweir } 488cdf0e10cSrcweir } 489cdf0e10cSrcweir else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "fileset" ) ) ) 490cdf0e10cSrcweir { 491cdf0e10cSrcweir m_state = FILESET; 492cdf0e10cSrcweir } 493cdf0e10cSrcweir else if( tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "file" ) ) ) 494cdf0e10cSrcweir { 495cdf0e10cSrcweir m_state = FILES; 496cdf0e10cSrcweir } 497cdf0e10cSrcweir else 498cdf0e10cSrcweir { 499cdf0e10cSrcweir //If there is a tag we don't know about, throw a exception (wobbler) :) 500cdf0e10cSrcweir ::rtl::OUString str_sax = ::rtl::OUString::createFromAscii( "No Such Tag" ); 501cdf0e10cSrcweir 502cdf0e10cSrcweir OSL_TRACE( "ScriptMetadataImporter: No Such Tag: %s\n", 503cdf0e10cSrcweir ::rtl::OUStringToOString( 504cdf0e10cSrcweir tagName, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); 505cdf0e10cSrcweir 506cdf0e10cSrcweir throw xml::sax::SAXException( 507cdf0e10cSrcweir str_sax, Reference< XInterface >(), Any() ); 508cdf0e10cSrcweir } 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir } 512