2002-09-20 13:37:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 09:45:41 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2002-09-20 13:37:46 +00:00
|
|
|
*
|
2008-04-11 09:45:41 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2002-09-20 13:37:46 +00:00
|
|
|
*
|
2008-04-11 09:45:41 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2002-09-20 13:37:46 +00:00
|
|
|
*
|
2008-04-11 09:45:41 +00:00
|
|
|
* $RCSfile: ScriptStorage.hxx,v $
|
|
|
|
* $Revision: 1.17 $
|
2002-09-20 13:37:46 +00:00
|
|
|
*
|
2008-04-11 09:45:41 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2002-09-20 13:37:46 +00:00
|
|
|
*
|
2008-04-11 09:45:41 +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-09-20 13:37:46 +00:00
|
|
|
*
|
2008-04-11 09:45:41 +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-09-20 13:37:46 +00:00
|
|
|
*
|
2008-04-11 09:45:41 +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-09-20 13:37:46 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef __SCRIPTING_STORAGE_SCRIPTSTORAGE_HXX_
|
|
|
|
#define __SCRIPTING_STORAGE_SCRIPTSTORAGE_HXX_
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <hash_map>
|
|
|
|
|
|
|
|
#include <osl/mutex.hxx>
|
2002-11-01 12:58:33 +00:00
|
|
|
#include <cppuhelper/implbase5.hxx> // helper for component factory
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
|
|
|
#include <com/sun/star/lang/XInitialization.hpp>
|
2002-09-27 11:16:30 +00:00
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
|
|
|
#include <com/sun/star/io/XOutputStream.hpp>
|
|
|
|
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
|
|
|
|
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
|
|
|
|
|
2002-10-23 13:22:05 +00:00
|
|
|
#include <drafts/com/sun/star/script/framework/storage/XScriptInfoAccess.hpp>
|
2002-09-20 13:37:46 +00:00
|
|
|
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageExport.hpp>
|
2002-11-01 12:58:33 +00:00
|
|
|
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageRefresh.hpp>
|
2002-09-20 13:37:46 +00:00
|
|
|
#include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
|
|
|
|
|
|
|
|
namespace scripting_impl
|
|
|
|
{
|
2002-10-01 09:45:14 +00:00
|
|
|
// for simplification
|
|
|
|
#define css ::com::sun::star
|
|
|
|
#define dcsssf ::drafts::com::sun::star::script::framework
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
//Typedefs
|
|
|
|
//=============================================================================
|
2002-10-17 09:04:15 +00:00
|
|
|
typedef ::std::vector< ScriptData > Datas_vec;
|
2002-09-20 13:37:46 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2003-08-19 08:51:53 +00:00
|
|
|
// function name -> ScriptData
|
|
|
|
typedef ::std::hash_map < ::rtl::OUString, ScriptData, ::rtl::OUStringHash,
|
|
|
|
::std::equal_to< ::rtl::OUString > > ScriptFunction_hash;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// language -> hash of function name -> ScriptData
|
|
|
|
typedef ::std::hash_map < ::rtl::OUString, ScriptFunction_hash,
|
|
|
|
::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
|
|
|
|
ScriptData_hash;
|
2002-09-20 13:37:46 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
typedef ::std::hash_map < ::rtl::OUString,
|
2002-10-01 09:45:14 +00:00
|
|
|
css::uno::Reference< css::xml::sax::XExtendedDocumentHandler >,
|
2002-09-20 13:37:46 +00:00
|
|
|
::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
|
|
|
|
ScriptOutput_hash;
|
2003-05-16 09:14:24 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
typedef ::std::hash_map < ::rtl::OUString,
|
|
|
|
::rtl::OUString, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
|
|
|
|
ScriptLanguages_hash;
|
2002-10-01 09:45:14 +00:00
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
//=============================================================================
|
|
|
|
|
2002-10-01 09:45:14 +00:00
|
|
|
class ScriptStorage : public
|
2002-11-01 12:58:33 +00:00
|
|
|
::cppu::WeakImplHelper5<
|
2002-10-01 09:45:14 +00:00
|
|
|
css::lang::XServiceInfo,
|
|
|
|
css::lang::XInitialization,
|
2002-10-23 13:22:05 +00:00
|
|
|
dcsssf::storage::XScriptInfoAccess,
|
2002-11-01 12:58:33 +00:00
|
|
|
dcsssf::storage::XScriptStorageExport,
|
|
|
|
dcsssf::storage::XScriptStorageRefresh >
|
2002-09-20 13:37:46 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
//Constructors and Destructors
|
|
|
|
//=========================================================================
|
2002-10-01 09:45:14 +00:00
|
|
|
explicit ScriptStorage(
|
2003-05-29 13:17:56 +00:00
|
|
|
const css::uno::Reference< css::uno::XComponentContext > & xContext )
|
|
|
|
throw ( css::uno::RuntimeException );
|
2002-09-20 13:37:46 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
virtual ~ScriptStorage() SAL_THROW( () );
|
|
|
|
//=========================================================================
|
|
|
|
|
|
|
|
// XServiceInfo impl
|
|
|
|
//=========================================================================
|
2002-10-01 09:45:14 +00:00
|
|
|
virtual ::rtl::OUString SAL_CALL getImplementationName()
|
2002-10-24 11:00:40 +00:00
|
|
|
throw ( css::uno::RuntimeException );
|
2002-09-20 13:37:46 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2002-10-01 09:45:14 +00:00
|
|
|
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString & ServiceName )
|
2002-10-24 11:00:40 +00:00
|
|
|
throw ( css::uno::RuntimeException );
|
2002-09-20 13:37:46 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2002-10-01 09:45:14 +00:00
|
|
|
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
|
2002-10-24 11:00:40 +00:00
|
|
|
throw ( css::uno::RuntimeException );
|
2002-09-20 13:37:46 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2002-10-01 09:45:14 +00:00
|
|
|
static css::uno::Sequence< ::rtl::OUString > SAL_CALL
|
2002-09-27 11:16:30 +00:00
|
|
|
getSupportedServiceNames_Static();
|
2002-09-20 13:37:46 +00:00
|
|
|
//=========================================================================
|
|
|
|
|
|
|
|
// XInitialization impl
|
|
|
|
//=========================================================================
|
2002-09-27 11:16:30 +00:00
|
|
|
virtual void SAL_CALL
|
2002-10-01 09:45:14 +00:00
|
|
|
initialize( css::uno::Sequence< css::uno::Any > const & args )
|
2002-10-24 11:00:40 +00:00
|
|
|
throw ( css::uno::RuntimeException, css::uno::Exception );
|
2002-09-20 13:37:46 +00:00
|
|
|
//=========================================================================
|
|
|
|
|
2002-10-23 13:22:05 +00:00
|
|
|
//XScriptInfoAccess
|
2002-10-16 07:33:27 +00:00
|
|
|
//=========================================================================
|
|
|
|
/**
|
|
|
|
* Get the logical names for this storage
|
|
|
|
*
|
|
|
|
* @return sequence < ::rtl::OUString >
|
|
|
|
* The logical names
|
|
|
|
*/
|
|
|
|
virtual css::uno::Sequence< ::rtl::OUString >
|
|
|
|
SAL_CALL getScriptLogicalNames()
|
2003-03-12 14:54:18 +00:00
|
|
|
throw ( css::uno::RuntimeException );
|
2002-10-16 07:33:27 +00:00
|
|
|
|
2002-09-20 13:37:46 +00:00
|
|
|
//=========================================================================
|
|
|
|
/**
|
|
|
|
* Get the implementations for a given URI
|
|
|
|
*
|
|
|
|
* @param queryURI
|
|
|
|
* The URI to get the implementations for
|
|
|
|
*
|
2002-10-23 13:22:05 +00:00
|
|
|
* @return sequence < XScriptInfo >
|
2002-09-20 13:37:46 +00:00
|
|
|
* The URIs of the implementations
|
|
|
|
*/
|
2002-10-23 13:22:05 +00:00
|
|
|
virtual css::uno::Sequence< css::uno::Reference< dcsssf::storage::XScriptInfo > >
|
2002-10-01 09:45:14 +00:00
|
|
|
SAL_CALL getImplementations(
|
2002-10-23 13:22:05 +00:00
|
|
|
const ::rtl::OUString& queryURI )
|
2002-10-24 11:00:40 +00:00
|
|
|
throw ( css::lang::IllegalArgumentException, css::uno::RuntimeException );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2003-02-12 15:21:43 +00:00
|
|
|
//=========================================================================
|
|
|
|
/**
|
|
|
|
* Get all script implementations
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return sequence < XScriptInfo >
|
|
|
|
* script implementations
|
|
|
|
*/
|
|
|
|
virtual css::uno::Sequence< css::uno::Reference< dcsssf::storage::XScriptInfo > >
|
|
|
|
SAL_CALL getAllImplementations()
|
|
|
|
throw ( css::uno::RuntimeException );
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
|
2002-11-01 12:58:33 +00:00
|
|
|
/**
|
|
|
|
* Save the scripts stored in the ScriptStorage into the corresponding
|
|
|
|
* area (document or application)
|
|
|
|
*/
|
2002-10-01 09:45:14 +00:00
|
|
|
void SAL_CALL save()
|
2002-10-24 11:00:40 +00:00
|
|
|
throw ( css::uno::RuntimeException );
|
2002-09-20 13:37:46 +00:00
|
|
|
//=========================================================================
|
|
|
|
|
2002-11-01 12:58:33 +00:00
|
|
|
/**
|
|
|
|
* Refresh the ScriptStorage from the data stored in the corresponding area
|
|
|
|
* (document or application).
|
|
|
|
*/
|
|
|
|
void SAL_CALL refresh()
|
|
|
|
throw ( css::uno::RuntimeException );
|
|
|
|
//=========================================================================
|
|
|
|
|
2003-05-16 09:14:24 +00:00
|
|
|
private:
|
2002-09-27 11:16:30 +00:00
|
|
|
|
2002-10-01 09:45:14 +00:00
|
|
|
css::uno::Reference< css::uno::XComponentContext > m_xContext;
|
|
|
|
css::uno::Reference< css::ucb::XSimpleFileAccess > m_xSimpleFileAccess;
|
|
|
|
css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
|
2002-09-27 11:16:30 +00:00
|
|
|
|
|
|
|
::std::vector < ::rtl::OUString > mv_logicalNames;
|
2003-05-23 13:59:52 +00:00
|
|
|
static ScriptLanguages_hash* mh_scriptLangs;
|
2003-08-19 08:51:53 +00:00
|
|
|
ScriptData_hash mh_implementations;
|
2002-09-27 11:16:30 +00:00
|
|
|
ScriptOutput_hash mh_parcels;
|
2002-10-17 09:04:15 +00:00
|
|
|
sal_Int32 m_scriptStorageID;
|
2002-11-01 12:58:33 +00:00
|
|
|
::rtl::OUString m_stringUri;
|
2002-09-27 11:16:30 +00:00
|
|
|
|
2002-10-01 09:45:14 +00:00
|
|
|
osl::Mutex m_mutex;
|
2002-09-27 11:16:30 +00:00
|
|
|
bool m_bInitialised;
|
|
|
|
|
2002-10-24 11:00:40 +00:00
|
|
|
void updateMaps( const Datas_vec & vScriptDatas );
|
2002-09-27 11:16:30 +00:00
|
|
|
void writeMetadataHeader(
|
2002-10-24 11:00:40 +00:00
|
|
|
css::uno::Reference < css::xml::sax::XExtendedDocumentHandler > & xExDocHandler );
|
2002-11-01 12:58:33 +00:00
|
|
|
void create ()
|
|
|
|
throw (css::uno::RuntimeException, css::uno::Exception);
|
2003-05-16 09:14:24 +00:00
|
|
|
void createForFilesystem ( const ::rtl::OUString & scriptLanguage )
|
|
|
|
throw (css::uno::RuntimeException, css::uno::Exception);
|
|
|
|
::rtl::OUString getFileExtension ( const ::rtl::OUString & stringUri );
|
2002-09-27 11:16:30 +00:00
|
|
|
|
2002-10-24 11:00:40 +00:00
|
|
|
}; // class ScriptingStorage
|
2002-09-20 13:37:46 +00:00
|
|
|
|
2002-10-24 11:00:40 +00:00
|
|
|
} // namespace scripting_impl
|
2002-09-20 13:37:46 +00:00
|
|
|
|
|
|
|
#endif
|