2002-09-20 13:37:46 +00:00
|
|
|
/*************************************************************************
|
2002-09-27 11:16:30 +00:00
|
|
|
*
|
|
|
|
* $RCSfile: ScriptStorage.cxx,v $
|
|
|
|
*
|
2002-09-30 11:57:03 +00:00
|
|
|
* $Revision: 1.6 $
|
|
|
|
* last change: $Author: jmrice $ $Date: 2002-09-30 12:57:02 $
|
2002-09-27 11:16:30 +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): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#include <osl/file.hxx>
|
|
|
|
#include <osl/time.h>
|
2002-09-20 13:37:46 +00:00
|
|
|
#include <cppuhelper/implementationentry.hxx>
|
|
|
|
#include <com/sun/star/lang/IllegalArgumentException.hpp>
|
|
|
|
#include <com/sun/star/ucb/CommandAbortedException.hpp>
|
|
|
|
#include <com/sun/star/io/XActiveDataSource.hpp>
|
|
|
|
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
|
2002-09-24 14:50:28 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp>
|
2002-09-20 13:37:46 +00:00
|
|
|
#include <util/util.hxx>
|
|
|
|
|
|
|
|
#include "ScriptInfo.hxx"
|
|
|
|
#include "ScriptStorage.hxx"
|
|
|
|
#include "ScriptMetadataImporter.hxx"
|
|
|
|
#include "ScriptElement.hxx"
|
|
|
|
|
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::cppu;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::drafts::com::sun::star::script::framework;
|
|
|
|
|
|
|
|
namespace scripting_impl
|
|
|
|
{
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
const sal_Char* const SERVICE_NAME = "drafts.com.sun.star.script.framework.storage.ScriptStorage";
|
|
|
|
const sal_Char* const IMPL_NAME = "drafts.com.sun.star.script.framework.storage.ScriptStorage";
|
|
|
|
|
|
|
|
const sal_Char * const SCRIPT_DIR = "/Scripts";
|
|
|
|
const sal_Char * const SCRIPT_PARCEL = "/parcel.xml";
|
|
|
|
const sal_Char * const SCRIPT_PARCEL_NAME_ONLY = "parcel";
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
static OUString ss_implName = OUString::createFromAscii( IMPL_NAME );
|
|
|
|
static OUString ss_serviceName = OUString::createFromAscii( SERVICE_NAME );
|
2002-09-20 13:37:46 +00:00
|
|
|
static Sequence< OUString > ss_serviceNames = Sequence< OUString >( &ss_serviceName, 1 );
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
const sal_uInt16 NUMBER_STORAGE_INITIALIZE_ARGS = 3;
|
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
extern ::rtl_StandardModuleCount s_moduleCount;
|
|
|
|
|
|
|
|
//*************************************************************************
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptStorage::ScriptStorage( const Reference <
|
2002-09-20 13:37:46 +00:00
|
|
|
XComponentContext > & xContext )
|
2002-09-27 11:16:30 +00:00
|
|
|
: m_xContext( xContext ), m_bInitialised( false )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
OSL_TRACE( "< ScriptStorage ctor called >\n" );
|
|
|
|
s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
|
2002-09-27 11:16:30 +00:00
|
|
|
|
|
|
|
validateXRef( m_xContext, "ScriptStorage::ScriptStorage : cannot get component context" );
|
|
|
|
|
|
|
|
m_xMgr = m_xContext->getServiceManager();
|
|
|
|
validateXRef( m_xMgr, "ScriptStorage::ScriptStorage : cannot get service manager" );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
ScriptStorage::~ScriptStorage() SAL_THROW( () )
|
|
|
|
{
|
|
|
|
OSL_TRACE( "< ScriptStorage dtor called >\n" );
|
|
|
|
s_moduleCount.modCnt.release( &s_moduleCount.modCnt );
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
2002-09-27 11:16:30 +00:00
|
|
|
void
|
|
|
|
ScriptStorage::initialize(
|
2002-09-20 13:37:46 +00:00
|
|
|
const Sequence <Any> & args )
|
2002-09-27 11:16:30 +00:00
|
|
|
throw ( RuntimeException, Exception )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
OSL_TRACE( "Entering ScriptStorage::initialize\n" );
|
2002-09-20 13:37:46 +00:00
|
|
|
::rtl::OUString xStringUri;
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
// Should not be renitialised
|
|
|
|
if ( m_bInitialised )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
throw RuntimeException( OUSTR( "ScriptStorage::initalize already initialized" ),
|
|
|
|
Reference<XInterface> () );
|
|
|
|
}
|
|
|
|
|
|
|
|
{ // Protect member variable writes
|
|
|
|
::osl::Guard< osl::Mutex > aGuard( m_mutex );
|
|
|
|
|
|
|
|
// Check args
|
|
|
|
if ( args.getLength() != NUMBER_STORAGE_INITIALIZE_ARGS )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
OSL_TRACE( "ScriptStorage::initialize: got no args\n" );
|
|
|
|
throw lang::IllegalArgumentException(
|
|
|
|
OUSTR( "Invalid number of arguments provided!" ),
|
|
|
|
Reference< XInterface >(), 0 );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
|
|
|
|
if ( sal_False == ( args[ 0 ] >>= m_xSimpleFileAccess ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
throw lang::IllegalArgumentException(
|
2002-09-27 11:16:30 +00:00
|
|
|
OUSTR( "Invalid XSimpleFileAccess argument provided!" ),
|
|
|
|
Reference< XInterface >(), 0 );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
|
|
|
|
if ( sal_False == ( args[ 1 ] >>= m_scriptStorageID ) )
|
|
|
|
{
|
|
|
|
throw lang::IllegalArgumentException(
|
|
|
|
OUSTR( "Invalid ScriptStorage ID argument provided!" ),
|
|
|
|
Reference< XInterface >(), 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( sal_False == ( args[ 2 ] >>= xStringUri ) )
|
|
|
|
{
|
|
|
|
throw lang::IllegalArgumentException(
|
|
|
|
OUSTR( "Invalid String Uri argument provided!" ),
|
|
|
|
Reference< XInterface >(), 0 );
|
|
|
|
}
|
|
|
|
} // End - Protect member variable writes
|
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
#ifdef _DEBUG
|
2002-09-27 11:16:30 +00:00
|
|
|
fprintf( stderr, "uri: %s\n", ::rtl::OUStringToOString( xStringUri, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptMetadataImporter* SMI = new ScriptMetadataImporter( m_xContext );
|
|
|
|
Reference<xml::sax::XExtendedDocumentHandler> xSMI( SMI );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
|
|
|
|
xStringUri = xStringUri.concat( ::rtl::OUString::createFromAscii( SCRIPT_DIR ) );
|
|
|
|
|
|
|
|
// get the list of language folders under the Scripts directory
|
|
|
|
Sequence< ::rtl::OUString > languageDirs =
|
|
|
|
m_xSimpleFileAccess->getFolderContents( xStringUri, true );
|
|
|
|
|
|
|
|
Reference< io::XInputStream > xInput;
|
|
|
|
sal_Int32 languageDirsLength = languageDirs.getLength();
|
2002-09-30 11:57:03 +00:00
|
|
|
for ( sal_Int32 i = 0; i < languageDirsLength ; ++i )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
2002-09-27 11:16:30 +00:00
|
|
|
fprintf( stderr, "contains: %s\n", ::rtl::OUStringToOString( languageDirs[ i ],
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
if ( ! m_xSimpleFileAccess->isFolder( languageDirs[ i ] ) )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//get the list of parcel folders for each language folder
|
|
|
|
// under Scripts
|
|
|
|
Sequence< ::rtl::OUString > parcelDirs =
|
|
|
|
m_xSimpleFileAccess->getFolderContents( languageDirs[ i ], true );
|
|
|
|
|
|
|
|
sal_Int32 parcelDirsLength = parcelDirs.getLength();
|
2002-09-30 11:57:03 +00:00
|
|
|
for ( sal_Int32 j = 0; j < parcelDirsLength ; ++j )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
2002-09-27 11:16:30 +00:00
|
|
|
fprintf( stderr, "contains: %s\n",
|
|
|
|
::rtl::OUStringToOString( parcelDirs[ j ],
|
|
|
|
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
OUString parcelFile = parcelDirs[ j ].concat(
|
|
|
|
::rtl::OUString::createFromAscii( SCRIPT_PARCEL ) );
|
|
|
|
|
|
|
|
// Do not have a valid parcel.xml
|
|
|
|
if ( !m_xSimpleFileAccess->exists( parcelFile ) ||
|
|
|
|
m_xSimpleFileAccess->isFolder( parcelFile ) )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2002-09-20 13:37:46 +00:00
|
|
|
#ifdef _DEBUG
|
2002-09-27 11:16:30 +00:00
|
|
|
fprintf( stderr,
|
|
|
|
"parcel file: %s\n",
|
|
|
|
::rtl::OUStringToOString( parcelFile, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
xInput = m_xSimpleFileAccess->openFileRead( parcelFile );
|
|
|
|
// Failed to get input stream
|
|
|
|
if ( !xInput.is() )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
OSL_TRACE( "Parse the metadata \n" );
|
|
|
|
Impls_vec vScriptImplInfos;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
vScriptImplInfos = SMI->parseMetaData( xInput, parcelDirs[ j ] );
|
|
|
|
}
|
|
|
|
catch ( xml::sax::SAXException saxe )
|
|
|
|
{
|
|
|
|
if ( xInput.is() )
|
|
|
|
{
|
|
|
|
xInput->closeInput();
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
OSL_TRACE( "caught com::sun::star::xml::sax::SAXException in ScriptStorage::initalize" );
|
|
|
|
continue;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
catch ( io::IOException ioe )
|
|
|
|
{
|
|
|
|
if ( xInput.is() )
|
|
|
|
{
|
|
|
|
xInput->closeInput();
|
|
|
|
}
|
|
|
|
OSL_TRACE( "caught com::sun::star::io::IOException in ScriptStorage::initalize" );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
xInput->closeInput();
|
|
|
|
|
|
|
|
updateMaps( vScriptImplInfos );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
catch ( io::IOException ioe )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
//From ScriptMetadata Importer
|
2002-09-27 11:16:30 +00:00
|
|
|
OSL_TRACE( "caught com::sun::star::io::IOException in ScriptStorage::initalize" );
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "ScriptStorage::initalize IOException: " ).concat( ioe.Message ),
|
|
|
|
Reference<XInterface> () );
|
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
catch ( ucb::CommandAbortedException cae )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
OSL_TRACE( "caught com::sun::star::ucb::CommandAbortedException in ScriptStorage::initialize" );
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR(
|
|
|
|
"ScriptStorage::initalize CommandAbortedException: " ).concat( cae.Message ),
|
|
|
|
Reference<XInterface> () );
|
|
|
|
}
|
|
|
|
catch ( RuntimeException re )
|
|
|
|
{
|
|
|
|
OSL_TRACE( "caught com::sun::star::uno::RuntimeException in ScriptStorage::initialize" );
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "ScriptStorage::initalize RuntimeException: " ).concat( re.Message ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
catch ( Exception ue )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
OSL_TRACE( "caught com::sun::star::uno::Exception in ScriptStorage::initialize" );
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "ScriptStorage::initalize Exception: " ).concat( ue.Message ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
catch ( ... )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
OSL_TRACE( "caught com::sun::star::uno::Exception in ScriptStorage::initialize" );
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "ScriptStorage::initalize unknown exception: " ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
OSL_TRACE( "Parsed the XML\n" );
|
|
|
|
|
|
|
|
m_bInitialised = true;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
// private method for updating hashmaps
|
2002-09-27 11:16:30 +00:00
|
|
|
void
|
|
|
|
ScriptStorage::updateMaps( const Impls_vec & vScriptImplInfos )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
::osl::Guard< osl::Mutex > aGuard( m_mutex );
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
Impls_vec::const_iterator it_end = vScriptImplInfos.end();
|
2002-09-20 13:37:46 +00:00
|
|
|
// step through the vector of ScripImplInfos returned from parse
|
2002-09-27 11:16:30 +00:00
|
|
|
for ( Impls_vec::const_iterator it = vScriptImplInfos.begin() ; it != it_end; ++it )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
//find the Impls_vec for this logical name
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptInfo_hash::iterator h_it = mh_implementations.find( it->logicalName );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
if ( h_it == mh_implementations.end() )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
//if it's null, need to create a new Impls_vec
|
|
|
|
#ifdef _DEBUG
|
2002-09-27 11:16:30 +00:00
|
|
|
fprintf( stderr,
|
|
|
|
"updateMaps: new logical name: %s\n", rtl::OUStringToOString(
|
|
|
|
it->logicalName, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
|
|
|
fprintf( stderr, "language name: %s\n",
|
|
|
|
rtl::OUStringToOString(
|
|
|
|
it->functionName, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
Impls_vec v;
|
2002-09-27 11:16:30 +00:00
|
|
|
v.push_back( *it );
|
|
|
|
mh_implementations[ it->logicalName ] = v;
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
2002-09-27 11:16:30 +00:00
|
|
|
fprintf( stderr, "updateMaps: existing logical name: %s\n", rtl::OUStringToOString( it->logicalName, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
|
|
|
fprintf( stderr, " language name: %s\n", rtl::OUStringToOString( it->functionName, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
h_it->second.push_back( *it );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
// Not part of the interface yet, ie. not in the idl, and it should be!!
|
2002-09-27 11:16:30 +00:00
|
|
|
void
|
|
|
|
ScriptStorage::save()
|
|
|
|
throw ( RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
::osl::Guard< osl::Mutex > aGuard( m_mutex );
|
|
|
|
Reference< io::XActiveDataSource > xSource;
|
|
|
|
Reference<io::XOutputStream> xOS;
|
|
|
|
// xScriptInvocation = Reference<XScriptInvocation>(xx, UNO_QUERY_THROW);
|
|
|
|
Reference<xml::sax::XExtendedDocumentHandler> xHandler;
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
OUString parcel_suffix = OUString::createFromAscii( SCRIPT_PARCEL );
|
|
|
|
OUString ou_parcel = OUString( RTL_CONSTASCII_USTRINGPARAM( SCRIPT_PARCEL_NAME_ONLY ) );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
try
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptInfo_hash::iterator it_end = mh_implementations.end();
|
|
|
|
for ( ScriptInfo_hash::iterator it = mh_implementations.begin() ; it != it_end; ++it )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
::rtl::OUString logName = it->first;
|
|
|
|
Impls_vec::iterator it_impls_end = it->second.end();
|
|
|
|
for ( Impls_vec::iterator it_impls = it->second.begin();
|
|
|
|
it_impls != it_impls_end ; ++it_impls )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptOutput_hash::const_iterator it_parcels =
|
|
|
|
mh_parcels.find( it_impls->parcelURI );
|
|
|
|
if ( it_parcels == mh_parcels.end() )
|
|
|
|
{
|
|
|
|
//create new outputstream
|
|
|
|
OUString parcel_xml_path = it_impls->parcelURI.concat( parcel_suffix );
|
|
|
|
m_xSimpleFileAccess->kill( parcel_xml_path );
|
|
|
|
xOS = m_xSimpleFileAccess->openFileWrite( parcel_xml_path );
|
2002-09-20 13:37:46 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
fprintf( stderr, "saving: %s\n", rtl::OUStringToOString( it_impls->parcelURI.concat( OUString::createFromAscii( "/parcel.xml" ) ), RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-20 13:37:46 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
Reference< XInterface > xInterface =
|
|
|
|
m_xMgr->createInstanceWithContext(
|
|
|
|
OUString::createFromAscii( "com.sun.star.xml.sax.Writer" ),
|
|
|
|
m_xContext );
|
|
|
|
validateXRef( xInterface, "ScriptStorage::save: cannot get sax.Writer" );
|
|
|
|
xHandler =
|
|
|
|
Reference<xml::sax::XExtendedDocumentHandler>( xInterface,
|
|
|
|
UNO_QUERY_THROW );
|
|
|
|
xSource = Reference< io::XActiveDataSource >( xHandler, UNO_QUERY_THROW );
|
|
|
|
xSource->setOutputStream( xOS );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
writeMetadataHeader( xHandler );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
xHandler->startElement( ou_parcel,
|
|
|
|
Reference< xml::sax::XAttributeList >() );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
mh_parcels[ it_impls->parcelURI ] = xHandler;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xHandler = it_parcels->second;
|
|
|
|
}
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptElement* pSE = new ScriptElement( *it_impls );
|
|
|
|
// this is to get pSE released correctly
|
|
|
|
Reference <xml::sax::XAttributeList> xal( pSE );
|
|
|
|
pSE->dump( xHandler );
|
|
|
|
}
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptOutput_hash::const_iterator out_it_end = mh_parcels.end();
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
for ( ScriptOutput_hash::const_iterator out_it = mh_parcels.begin();
|
|
|
|
out_it != out_it_end;
|
|
|
|
++out_it )
|
|
|
|
{
|
|
|
|
out_it->second->ignorableWhitespace( ::rtl::OUString() );
|
|
|
|
out_it->second->endElement( ou_parcel );
|
|
|
|
out_it->second->endDocument();
|
|
|
|
xSource.set( out_it->second, UNO_QUERY );
|
|
|
|
Reference<io::XOutputStream> xOS = xSource->getOutputStream();
|
|
|
|
xOS->closeOutput();
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// *** TODO - other exception handling IO etc.
|
|
|
|
catch ( RuntimeException re )
|
|
|
|
{
|
|
|
|
OSL_TRACE( "caught com::sun::star::uno::RuntimeException in ScriptStorage::save" );
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "ScriptStorage::save RuntimeException: " ).concat( re.Message ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
2002-09-27 11:16:30 +00:00
|
|
|
void
|
|
|
|
ScriptStorage::writeMetadataHeader( Reference <xml::sax::XExtendedDocumentHandler> & xHandler )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
xHandler->startDocument();
|
|
|
|
OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM(
|
|
|
|
"<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\""
|
|
|
|
" \"parcel.dtd\">" ) );
|
|
|
|
xHandler->unknown( aDocTypeStr );
|
|
|
|
xHandler->ignorableWhitespace( OUString() );
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
//Returns a sequence of XScriptInfo interfaces
|
|
|
|
//to give access to info on scripts
|
|
|
|
//Eh, method name is not initiutive, maybe it
|
|
|
|
//should be getScriptInfoInterfaces? (Need to change IDL)
|
|
|
|
Sequence < Reference< storage::XScriptInfo > >
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptStorage::getScriptInfoService( const OUString & name )
|
|
|
|
throw ( RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
::osl::Guard< osl::Mutex > aGuard( m_mutex );
|
|
|
|
|
2002-09-30 11:57:03 +00:00
|
|
|
Sequence< Reference< storage::XScriptInfo > > sr_xScriptInfo;
|
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
//Get iterator over the hash_map
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptInfo_hash::const_iterator h_iter = mh_implementations.find( name );
|
2002-09-30 11:57:03 +00:00
|
|
|
|
|
|
|
if ( h_iter == mh_implementations.end() )
|
|
|
|
{
|
|
|
|
OSL_TRACE("ScriptStorage::getScriptInfoService: EMPTY STORAGE");
|
|
|
|
return sr_xScriptInfo;
|
|
|
|
}
|
|
|
|
sr_xScriptInfo.realloc( h_iter->second.size() );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
try
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
//Get array of XScriptInfos
|
|
|
|
// Reference< storage::XScriptInfo >* pScriptInfo = sr_xScriptInfo.getArray();
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
Impls_vec::const_iterator end_iter = h_iter->second.end();
|
|
|
|
sal_Int32 count = 0;
|
|
|
|
for ( Impls_vec::const_iterator it = h_iter->second.begin(); it != end_iter; ++it )
|
|
|
|
{
|
|
|
|
Any a( makeAny( *it ) );
|
|
|
|
Reference< XInterface > xInterface =
|
|
|
|
m_xMgr->createInstanceWithArgumentsAndContext(
|
|
|
|
OUString::createFromAscii(
|
|
|
|
"drafts.com.sun.star.script.framework.storage.ScriptInfo" ),
|
|
|
|
Sequence< Any >( &a, 1 ), m_xContext );
|
|
|
|
validateXRef( xInterface,
|
|
|
|
"ScriptStorage::getScriptInfoService: cannot get drafts.com.sun.star.script.framework.storage.ScriptInfo" );
|
|
|
|
// pScriptInfo[ count ] = Reference< storage::XScriptInfo >(xInterface,
|
|
|
|
// UNO_QUERY_THROW );
|
|
|
|
sr_xScriptInfo[ count ] = Reference< storage::XScriptInfo >( xInterface,
|
|
|
|
UNO_QUERY_THROW );
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch ( RuntimeException re )
|
|
|
|
{
|
|
|
|
OSL_TRACE( "caught com::sun::star::uno::RuntimeException in ScriptStorage::getScriptInfoService" );
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "ScriptStorage::getScriptInfoService RuntimeException: " ).concat( re.Message ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
return sr_xScriptInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
//XNamingAccess
|
|
|
|
/**
|
|
|
|
Reference<XInterface> ScriptStorage::getView(
|
|
|
|
const ::rtl::OUString& viewName )
|
|
|
|
throw (storage::NoSuchView,
|
|
|
|
RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
Sequence< Reference< scripturi::XScriptURI > >
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptStorage::getImplementations( const Reference <
|
|
|
|
scripturi::XScriptURI > & queryURI )
|
|
|
|
throw ( lang::IllegalArgumentException,
|
|
|
|
RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-30 09:59:39 +00:00
|
|
|
|
|
|
|
Sequence< Reference< scripturi::XScriptURI > > results;
|
|
|
|
ScriptInfo_hash::iterator h_it =
|
|
|
|
mh_implementations.find( queryURI->getLogicalName() );
|
|
|
|
|
|
|
|
if ( h_it == mh_implementations.end() )
|
|
|
|
{
|
|
|
|
OSL_TRACE("ScriptStorage::getImplementations: EMPTY STORAGE");
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
results.realloc( h_it->second.size() );
|
|
|
|
|
|
|
|
//find the implementations for the given logical name
|
2002-09-20 13:37:46 +00:00
|
|
|
try
|
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
|
|
|
|
::osl::Guard< osl::Mutex > aGuard( m_mutex );
|
|
|
|
|
|
|
|
Impls_vec::const_iterator it_impls = h_it->second.begin();
|
|
|
|
Impls_vec::const_iterator it_impls_end = h_it->second.end();
|
|
|
|
for ( sal_Int32 count = 0; it_impls != it_impls_end ; ++it_impls )
|
|
|
|
{
|
|
|
|
Sequence<Any> aArgs( 2 );
|
|
|
|
aArgs[ 0 ] <<= *it_impls;
|
|
|
|
aArgs[ 1 ] <<= m_scriptStorageID;
|
|
|
|
|
|
|
|
Reference< XInterface > xInterface =
|
|
|
|
m_xMgr->createInstanceWithArgumentsAndContext(
|
|
|
|
OUString::createFromAscii(
|
|
|
|
"drafts.com.sun.star.script.framework.scripturi.ScriptURI" ), aArgs,
|
|
|
|
m_xContext );
|
|
|
|
validateXRef( xInterface,
|
|
|
|
"ScriptStorage::getImplementations: cannot get drafts.com.sun.star.script.framework.storage.ScriptURI" );
|
|
|
|
Reference<scripturi::XScriptURI> uri( xInterface, UNO_QUERY_THROW );
|
|
|
|
|
|
|
|
results[ count++ ] = uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch ( RuntimeException re )
|
|
|
|
{
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "ScriptStorage::getImplementations RuntimeException: " ).concat( re.Message ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
catch ( Exception e )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
throw RuntimeException( OUSTR( "ScriptStorage::getImplementations Exception: " ).concat( e.Message ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
2002-09-27 11:16:30 +00:00
|
|
|
/**
|
|
|
|
copies a parcel to a temporary location
|
|
|
|
|
|
|
|
@params parcelURI
|
|
|
|
the location of the parcel (file URI) to be copied
|
|
|
|
|
|
|
|
@return
|
|
|
|
<type>::rtl::OUString</type> the new location of the parcel (file URI)
|
|
|
|
*/
|
|
|
|
OUString SAL_CALL
|
|
|
|
ScriptStorage::prepareForInvocation( const OUString& parcelURI )
|
|
|
|
throw ( RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
if ( ( m_xSimpleFileAccess->exists( parcelURI ) != sal_True ) ||
|
|
|
|
( m_xSimpleFileAccess->isFolder( parcelURI ) != sal_True ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
throw RuntimeException(
|
2002-09-27 11:16:30 +00:00
|
|
|
OUSTR( "Parcel URI is not valid" ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
|
2002-09-24 14:50:28 +00:00
|
|
|
OUString dest;
|
2002-09-27 11:16:30 +00:00
|
|
|
if ( ::osl::FileBase::E_None != ::osl::FileBase::getTempDirURL( dest ) )
|
|
|
|
{
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "getTempDirURL failed" ),
|
|
|
|
Reference<XInterface> () );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add time value to tmp dir name to prvent name clashes
|
|
|
|
TimeValue timeVal;
|
|
|
|
OUString sTime;
|
|
|
|
if ( sal_False != osl_getSystemTime( &timeVal ) )
|
|
|
|
{
|
|
|
|
sTime = sTime.valueOf( static_cast<sal_Int32>( timeVal.Seconds ) );
|
|
|
|
}
|
|
|
|
OSL_TRACE( ::rtl::OUStringToOString(
|
|
|
|
sTime.concat( OUString::createFromAscii( " Time to add to parcel name." ) ), RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2002-09-24 14:50:28 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
sal_Int32 idx = parcelURI.lastIndexOf( '/' );
|
2002-09-20 13:37:46 +00:00
|
|
|
sal_Int32 len = parcelURI.getLength();
|
2002-09-27 11:16:30 +00:00
|
|
|
if ( idx == ( len - 1 ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
// deal with the trailing separator
|
2002-09-27 11:16:30 +00:00
|
|
|
idx = parcelURI.lastIndexOf( '/', len - 2 );
|
|
|
|
OUString parcel_base = parcelURI.copy( idx, len - idx - 1 );
|
|
|
|
dest = dest.concat( parcel_base );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
dest = dest.concat( parcelURI.copy( idx ) );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
dest = dest.concat( OUString::valueOf( ( sal_Int32 ) m_scriptStorageID ) );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
dest = dest.concat( sTime );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
|
|
fprintf( stderr, "dest is: %s\n",
|
|
|
|
rtl::OUStringToOString( dest, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
copyFolder( parcelURI, dest );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
catch ( RuntimeException & e )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "ScriptStorage::prepareForInvocation RuntimeException: " ).concat( e.Message ),
|
|
|
|
Reference<XInterface> () );
|
|
|
|
}
|
|
|
|
catch ( Exception & e )
|
|
|
|
{
|
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "ScriptStorage::prepareForInvocation Exception: " ).concat( e.Message ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
#ifdef _DEBUG
|
|
|
|
catch ( ... )
|
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
throw RuntimeException(
|
|
|
|
OUSTR( "ScriptStorage::prepareForInvocation UnknownException: " ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
/**
|
2002-09-27 11:16:30 +00:00
|
|
|
This function copies the contents of the source folder into the
|
|
|
|
destination folder. If the destination folder does not exist, it
|
|
|
|
is created. If the destination folder exists, it is deleted and then
|
|
|
|
created. All URIs supported by the relevant XSimpleFileAccess
|
|
|
|
implementation are supported.
|
|
|
|
|
|
|
|
@params src
|
|
|
|
the source folder (file URI)
|
|
|
|
|
|
|
|
@params dest
|
|
|
|
the destination folder (file URI)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ScriptStorage::copyFolder( const OUString &src, const OUString &dest )
|
|
|
|
throw ( RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
/* A mutex guard is needed to not write later into
|
|
|
|
* a folder that has been deleted by an incoming thread.
|
|
|
|
* Note that this calls into the SimpleFileAccess service
|
|
|
|
* with a locked mutex, but the implementation of this method
|
|
|
|
* will probably change soon.
|
|
|
|
*/
|
|
|
|
::osl::Guard< osl::Mutex > aGuard( m_mutex );
|
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
if ( m_xSimpleFileAccess->isFolder( dest ) == sal_True )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
m_xSimpleFileAccess->kill( dest );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
m_xSimpleFileAccess->createFolder( dest );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
Sequence <OUString> seq = m_xSimpleFileAccess->getFolderContents(
|
|
|
|
src, sal_True );
|
|
|
|
OUString new_dest;
|
|
|
|
sal_Int32 idx;
|
2002-09-20 13:37:46 +00:00
|
|
|
sal_Int32 len = seq.getLength();
|
2002-09-30 11:57:03 +00:00
|
|
|
for ( sal_Int32 i = 0; i < len; i++ )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
new_dest = dest;
|
2002-09-27 11:16:30 +00:00
|
|
|
idx = seq[ i ].lastIndexOf( '/' );
|
|
|
|
new_dest = new_dest.concat( seq[ i ].copy( idx ) );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-09-27 11:16:30 +00:00
|
|
|
if ( m_xSimpleFileAccess->isFolder( seq[ i ] ) == sal_True )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
copyFolder( seq[ i ], new_dest );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
m_xSimpleFileAccess->copy( seq[ i ], new_dest );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
catch ( ucb::CommandAbortedException & e )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
OUString temp = OUSTR(
|
2002-09-27 11:16:30 +00:00
|
|
|
"ScriptStorage::copyFolder CommandAbortedException: " );
|
|
|
|
throw RuntimeException( temp.concat( e.Message ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
catch ( RuntimeException & e )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
OUString temp = OUSTR( "ScriptStorage::copyFolder RuntimeException: " );
|
|
|
|
throw RuntimeException( temp.concat( e.Message ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
2002-09-27 11:16:30 +00:00
|
|
|
catch ( Exception & e )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
OUString temp = OUSTR( "ScriptStorage::copyFolder Exception: " );
|
|
|
|
throw RuntimeException( temp.concat( e.Message ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
#ifdef _DEBUG
|
|
|
|
catch ( ... )
|
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
throw RuntimeException( OUSTR(
|
|
|
|
"ScriptStorage::copyFolder UnknownException: " ),
|
|
|
|
Reference<XInterface> () );
|
2002-09-20 13:37:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//*************************************************************************
|
2002-09-27 11:16:30 +00:00
|
|
|
OUString SAL_CALL ScriptStorage::getImplementationName( )
|
|
|
|
throw( RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
return ss_implName;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
|
|
|
sal_Bool SAL_CALL ScriptStorage::supportsService( const OUString& serviceName )
|
2002-09-27 11:16:30 +00:00
|
|
|
throw( RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
OUString const * pNames = ss_serviceNames.getConstArray();
|
|
|
|
for ( sal_Int32 nPos = ss_serviceNames.getLength(); nPos--; )
|
|
|
|
{
|
2002-09-27 11:16:30 +00:00
|
|
|
if ( serviceName.equals( pNames[ nPos ] ) )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
2002-09-27 11:16:30 +00:00
|
|
|
Sequence<OUString> SAL_CALL ScriptStorage::getSupportedServiceNames( )
|
|
|
|
throw( RuntimeException )
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
return ss_serviceNames;
|
|
|
|
}
|
|
|
|
//*************************************************************************
|
|
|
|
Reference<XInterface> SAL_CALL ss_create(
|
|
|
|
const Reference< XComponentContext > & xCompC )
|
|
|
|
{
|
|
|
|
return ( cppu::OWeakObject * ) new ScriptStorage( xCompC );
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
2002-09-27 11:16:30 +00:00
|
|
|
Sequence<OUString> ss_getSupportedServiceNames( )
|
2002-09-20 13:37:46 +00:00
|
|
|
SAL_THROW( () )
|
|
|
|
{
|
|
|
|
return ss_serviceNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************************************************************************
|
2002-09-27 11:16:30 +00:00
|
|
|
OUString ss_getImplementationName( )
|
2002-09-20 13:37:46 +00:00
|
|
|
SAL_THROW( () )
|
|
|
|
{
|
|
|
|
return ss_implName;
|
|
|
|
}
|
|
|
|
}
|