summaryrefslogtreecommitdiff
path: root/scripting/source/storage
diff options
context:
space:
mode:
authorDuncan Foster <dfoster@openoffice.org>2002-09-20 13:37:46 +0000
committerDuncan Foster <dfoster@openoffice.org>2002-09-20 13:37:46 +0000
commit2be6e073b1f13b1d2554e13fedf025103e89cb3b (patch)
tree25093ebd4b0f167cb65108bad461318aed023f45 /scripting/source/storage
parentbf1f075d2b18798790c06a48e2e2020404a4df28 (diff)
Initial commit of Scripting Framework code.
The Scripting Framework Team: Duncan Foster Alexis Ledoux Laszlo Kovacs Misha Krivoruchko Neil Montgomery Tomas O'Connor Noel Power John Rice Darragh Sherwin
Diffstat (limited to 'scripting/source/storage')
-rw-r--r--scripting/source/storage/ScriptElement.cxx159
-rw-r--r--scripting/source/storage/ScriptElement.hxx85
-rw-r--r--scripting/source/storage/ScriptInfo.cxx328
-rw-r--r--scripting/source/storage/ScriptInfo.hxx123
-rw-r--r--scripting/source/storage/ScriptMetadataImporter.cxx562
-rw-r--r--scripting/source/storage/ScriptMetadataImporter.hxx279
-rw-r--r--scripting/source/storage/ScriptStorage.cxx691
-rw-r--r--scripting/source/storage/ScriptStorage.hxx246
-rw-r--r--scripting/source/storage/ScriptStorageManager.cxx354
-rw-r--r--scripting/source/storage/ScriptStorageManager.hxx155
-rw-r--r--scripting/source/storage/XMLElement.cxx196
-rw-r--r--scripting/source/storage/XMLElement.hxx170
-rw-r--r--scripting/source/storage/exports.dxp3
-rw-r--r--scripting/source/storage/makefile.mk105
-rw-r--r--scripting/source/storage/storage.xml54
15 files changed, 3510 insertions, 0 deletions
diff --git a/scripting/source/storage/ScriptElement.cxx b/scripting/source/storage/ScriptElement.cxx
new file mode 100644
index 000000000000..06d4e86d2e1b
--- /dev/null
+++ b/scripting/source/storage/ScriptElement.cxx
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptElement.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:48 $
+ *
+ * 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 "ScriptElement.hxx"
+#include <util/util.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::drafts::com::sun::star::script::framework;
+
+namespace scripting_impl
+{
+
+//*************************************************************************
+ScriptElement::ScriptElement(storage::ScriptImplInfo & sII) :
+ m_sII( sII ),
+ XMLElement(OUSTR("script"))
+{
+ OSL_TRACE("ScriptElement ctor called\n");
+
+ addAttribute(OUSTR("language"), sII.scriptLanguage);
+ addAttribute(OUSTR("deploymentdir"), sII.scriptRoot);
+
+ {
+ XMLElement* xel = new XMLElement(OUSTR("logicalname"));
+ xel->addAttribute(OUSTR("value"), sII.logicalName);
+ Reference <xml::sax::XAttributeList> xal(xel);
+ addSubElement(xal);
+ }
+
+ {
+ XMLElement* xel = new XMLElement(OUSTR("languagename"));
+ xel->addAttribute(OUSTR("value"), sII.functionName);
+ xel->addAttribute(OUSTR("location"), sII.scriptLocation);
+ Reference <xml::sax::XAttributeList> xal(xel);
+ addSubElement(xal);
+ }
+
+ storage::ScriptDepFile *pArray = sII.scriptDependencies.getArray();
+ sal_Int32 len = sII.scriptDependencies.getLength();
+
+ if (len > 0)
+ {
+ XMLElement* xel = new XMLElement(OUSTR("dependencies"));
+
+ for(sal_Int32 i = 0; i < len; i++)
+ {
+ XMLElement* subxel = new XMLElement(OUSTR("dependfile"));
+ subxel->addAttribute(OUSTR("name"), pArray[i].fileName);
+ if(pArray[i].isDeliverable)
+ {
+ subxel->addAttribute(OUSTR("isdeliverable"), OUSTR("yes"));
+ }
+ else
+ {
+ subxel->addAttribute(OUSTR("isdeliverable"), OUSTR("no"));
+ }
+ Reference <xml::sax::XAttributeList> subxal(subxel);
+ xel->addSubElement(subxal);
+ }
+
+ Reference <xml::sax::XAttributeList> xal(xel);
+ addSubElement(xal);
+ }
+
+ if(sII.scriptDescription.getLength() > 0)
+ {
+ XMLElement* xel = new XMLElement(OUSTR("description"),
+ sII.scriptDescription);
+ Reference< xml::sax::XAttributeList > xal(xel);
+ addSubElement(xal);
+ }
+
+ storage::ScriptDeliverFile *pt_Array = sII.parcelDelivers.getArray();
+ sal_Int32 len_d = sII.parcelDelivers.getLength();
+
+ if(len_d > 0)
+ {
+ XMLElement* xel = new XMLElement(OUSTR("delivery"));
+
+ for(sal_Int32 i = 0; i < len_d; i++)
+ {
+ XMLElement* subxel = new XMLElement(OUSTR("deliverfile"));
+ subxel->addAttribute(OUSTR("name"), pt_Array[i].fileName);
+ subxel->addAttribute(OUSTR("type"), pt_Array[i].fileType);
+ Reference < xml::sax::XAttributeList > subxal(subxel);
+ xel->addSubElement(subxal);
+ }
+
+ Reference <xml::sax::XAttributeList> xal(xel);
+ addSubElement(xal);
+ }
+}
+
+//*************************************************************************
+ScriptElement::~ScriptElement() SAL_THROW(())
+{
+}
+
+}
diff --git a/scripting/source/storage/ScriptElement.hxx b/scripting/source/storage/ScriptElement.hxx
new file mode 100644
index 000000000000..7777b8746806
--- /dev/null
+++ b/scripting/source/storage/ScriptElement.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptElement.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:48 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _SCRIPTING_STORAGE_METADATA_ELEMENT_HXX_
+#define _SCRIPTING_STORAGE_METADATA_ELEMENT_HXX_
+
+#include <osl/mutex.hxx>
+
+#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp>
+
+#include "XMLElement.hxx"
+
+namespace scripting_impl
+{
+
+class ScriptElement : public ::scripting_impl::XMLElement
+{
+private:
+ drafts::com::sun::star::script::framework::storage::ScriptImplInfo m_sII;
+
+public:
+ explicit ScriptElement(drafts::com::sun::star::script::framework::storage::ScriptImplInfo &);
+ ~ScriptElement() SAL_THROW (());
+};
+
+}
+
+#endif
diff --git a/scripting/source/storage/ScriptInfo.cxx b/scripting/source/storage/ScriptInfo.cxx
new file mode 100644
index 000000000000..3a2080306b4d
--- /dev/null
+++ b/scripting/source/storage/ScriptInfo.cxx
@@ -0,0 +1,328 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptInfo.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:49 $
+ *
+ * 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 <stdio.h>
+
+#include <cppuhelper/implementationentry.hxx>
+
+#include <util/util.hxx>
+#include <ScriptInfo.hxx>
+
+#include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp>
+#include <drafts/com/sun/star/script/framework/storage/XParcelInvocationPrep.hpp>
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace ::drafts::com::sun::star::script::framework;
+
+namespace scripting_impl
+{
+
+const sal_Char* const SI_SERVICE_NAME="drafts.com.sun.star.script.framework.storage.ScriptInfo";
+const sal_Char* const SI_IMPL_NAME="drafts.com.sun.star.script.framework.storage.ScriptInfo";
+
+static OUString si_implName = OUString::createFromAscii(SI_IMPL_NAME);
+static OUString si_serviceName = OUString::createFromAscii(SI_SERVICE_NAME);
+static Sequence< OUString > si_serviceNames = Sequence< OUString >( &si_serviceName, 1 );
+
+extern ::rtl_StandardModuleCount s_moduleCount;
+
+static sal_Char docUriPrefix [] = "vnd.sun.star.pkg";
+
+//*************************************************************************
+ScriptInfo::ScriptInfo( const Reference< XComponentContext > & xContext )
+ : m_xContext( xContext )
+{
+ OSL_TRACE( "< ScriptInfo ctor called >\n" );
+ s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
+}
+
+//*************************************************************************
+ScriptInfo::~ScriptInfo()
+{
+ OSL_TRACE( "< ScriptInfo dtor called >\n" );
+ s_moduleCount.modCnt.release( &s_moduleCount.modCnt );
+}
+
+//*************************************************************************
+void ScriptInfo::initialize(Sequence <Any> const & args)
+throw (RuntimeException, Exception)
+{
+ try
+ {
+ if (((args[0] >>= m_scriptImplInfo) == sal_False) ||
+ ((args[1] >>= m_storageID) == sal_False))
+ {
+ throw RuntimeException(OUSTR("ScriptInfo: initialize(): "), Reference< XInterface >());
+ }
+ }
+ catch (Exception &e)
+ {
+ throw RuntimeException(OUSTR("ScriptInfo: initialize(): ") + e.Message, Reference< XInterface >());
+ }
+}
+
+//*************************************************************************
+OUString SAL_CALL ScriptInfo::getLogicalName( ) throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+ return m_scriptImplInfo.logicalName;
+}
+
+//*************************************************************************
+void SAL_CALL ScriptInfo::setLogicalName( const OUString& name ) throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+ m_scriptImplInfo.logicalName = name;
+}
+
+//*************************************************************************
+OUString SAL_CALL ScriptInfo::getDescription( ) throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+ return m_scriptImplInfo.scriptDescription;
+}
+
+//*************************************************************************
+void SAL_CALL ScriptInfo::setDescription( const OUString& desc ) throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+ m_scriptImplInfo.scriptDescription = desc;
+}
+
+//*************************************************************************
+OUString SAL_CALL ScriptInfo::getLanguage( ) throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+ return m_scriptImplInfo.scriptLanguage;
+}
+
+//*************************************************************************
+void SAL_CALL ScriptInfo::setLanguage( const OUString& language ) throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+ m_scriptImplInfo.scriptLanguage = language;
+}
+
+//*************************************************************************
+OUString SAL_CALL ScriptInfo::getScriptLocation()
+throw ( RuntimeException )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+ return m_scriptImplInfo.scriptLocation;
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL ScriptInfo::hasSource( ) throw (RuntimeException)
+{
+ return m_scriptImplInfo.scriptSource;
+}
+
+//*************************************************************************
+OUString SAL_CALL ScriptInfo::getLanguageSpecificName( ) throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+ return m_scriptImplInfo.functionName;
+}
+
+//*************************************************************************
+void SAL_CALL ScriptInfo::setLanguageSpecificName( const OUString& langName ) throw (RuntimeException)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+ m_scriptImplInfo.functionName = langName;
+}
+
+//*************************************************************************
+OUString SAL_CALL ScriptInfo::getRoot( ) throw (RuntimeException)
+{
+ return m_scriptImplInfo.scriptRoot;
+}
+
+//*************************************************************************
+Sequence< OUString > SAL_CALL ScriptInfo::getDependencies( ) throw (RuntimeException)
+{
+ storage::ScriptDepFile *pArray = m_scriptImplInfo.scriptDependencies.getArray();
+ int len = m_scriptImplInfo.scriptDependencies.getLength();
+ Sequence< OUString > r_deps(len);
+ for(int i = 0; i < len; i++)
+ {
+ r_deps[i] = pArray[i].fileName;
+ }
+
+ return r_deps;
+}
+
+//*************************************************************************
+OUString SAL_CALL ScriptInfo::getLocation( ) throw (RuntimeException)
+{
+ OUString location = OUString::createFromAscii("need to be done");
+
+ return location;
+}
+
+//*************************************************************************
+Reference< XPropertySet > SAL_CALL ScriptInfo::extraProperties( ) throw (RuntimeException)
+{
+ Reference <XPropertySet> x;
+
+ return x;
+}
+
+//*************************************************************************
+OUString SAL_CALL ScriptInfo::getImplementationName( )
+throw(RuntimeException)
+{
+ return si_implName;
+}
+
+//*************************************************************************
+/**
+ * This function prepares the script for invocation and returns the full path
+ * to the prepared parcel folder
+ *
+ */
+::rtl::OUString SAL_CALL ScriptInfo::prepareForInvocation() throw(RuntimeException)
+{
+ try
+ {
+ if (m_scriptImplInfo.parcelURI.compareToAscii(docUriPrefix, 16) != 0)
+ {
+ return m_scriptImplInfo.parcelURI;
+ }
+
+ validateXRef(m_xContext, "ScriptInfo::prepareForInvocation(): invalid context");
+ Any aAny=m_xContext->getValueByName(
+ OUString::createFromAscii(
+ "/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager"));
+ Reference <XInterface> xx;
+ if ((aAny >>= xx) == sal_False)
+ {
+ throw RuntimeException(OUSTR("ScriptInfo::prepareForInvocation(): could not get ScriptStorageManager"), Reference< XInterface >());
+ }
+
+ validateXRef(xx, "ScriptInfo::prepareForInvocation(): could not get XInterface");
+ Reference<storage::XScriptStorageManager> xSSM(xx,UNO_QUERY_THROW);
+ validateXRef(xSSM, "ScriptInfo::prepareForInvocation(): could not get XScriptStorageManager");
+ xx = xSSM->getScriptStorage(m_storageID);
+ validateXRef(xx, "ScriptInfo::prepareForInvocation(): could not get XInterface");
+ Reference <storage::XParcelInvocationPrep> xPIP(xx, UNO_QUERY_THROW);
+ validateXRef(xPIP, "ScriptInfo::prepareForInvocation(): could not get XParcelInvocationPrep");
+ return xPIP->prepareForInvocation(m_scriptImplInfo.parcelURI);
+ }
+ catch(RuntimeException &e)
+ {
+ OUString temp = OUSTR(
+ "ScriptInfo::prepareForInvocation RuntimeException: ");
+ throw RuntimeException(temp.concat(e.Message),
+ Reference<XInterface> ());
+ }
+#ifdef _DEBUG
+ catch ( ... )
+ {
+ throw RuntimeException(OUSTR(
+ "ScriptInfo::prepareForInvocation UnknownException: "),
+ Reference<XInterface> ());
+ }
+#endif
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL ScriptInfo::supportsService( const OUString& serviceName )
+throw(RuntimeException)
+{
+ OUString const * pNames = si_serviceNames.getConstArray();
+ for ( sal_Int32 nPos = si_serviceNames.getLength(); nPos--; )
+ {
+ if (serviceName.equals( pNames[ nPos ] ))
+ {
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ScriptInfo::getSupportedServiceNames( )
+throw(RuntimeException)
+{
+ return si_serviceNames;
+}
+//*************************************************************************
+Reference<XInterface> SAL_CALL si_create(
+ const Reference< XComponentContext > & xCompC )
+{
+ return (cppu::OWeakObject *)new ScriptInfo( xCompC );
+}
+
+//*************************************************************************
+Sequence<OUString> si_getSupportedServiceNames( )
+SAL_THROW( () )
+{
+ return si_serviceNames;
+}
+
+//*************************************************************************
+OUString si_getImplementationName( )
+SAL_THROW( () )
+{
+ return si_implName;
+}
+}
diff --git a/scripting/source/storage/ScriptInfo.hxx b/scripting/source/storage/ScriptInfo.hxx
new file mode 100644
index 000000000000..f5b8c845e199
--- /dev/null
+++ b/scripting/source/storage/ScriptInfo.hxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptInfo.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:50 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef __SCRIPTING_STORAGE_SCRIPTINFO_HXX_
+#define __SCRIPTING_STORAGE_SCRIPTINFO_HXX_
+
+#include <cppuhelper/implbase4.hxx> // helper for component factory
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
+#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp>
+#include <drafts/com/sun/star/script/framework/storage/XScriptInvocationPrep.hpp>
+
+namespace scripting_impl {
+
+class ScriptInfo : public ::cppu::WeakImplHelper4< ::com::sun::star::lang::XServiceInfo, ::com::sun::star::lang::XInitialization, ::drafts::com::sun::star::script::framework::storage::XScriptInfo, ::drafts::com::sun::star::script::framework::storage::XScriptInvocationPrep >
+{
+ // private member
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext;
+
+ ::osl::Mutex m_mutex;
+
+ ::drafts::com::sun::star::script::framework::storage::ScriptImplInfo m_scriptImplInfo;
+ sal_uInt16 m_storageID;
+
+ // public interface
+public:
+ explicit ScriptInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& );
+ virtual ~ScriptInfo();
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL initialize(::com::sun::star::uno::Sequence < ::com::sun::star::uno::Any > const & args) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
+
+ // XScriptInfo
+ virtual ::rtl::OUString SAL_CALL getLogicalName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLogicalName( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDescription( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDescription( const ::rtl::OUString& desc ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getLanguage( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getScriptLocation( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLanguage( const ::rtl::OUString& language ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasSource( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getLanguageSpecificName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLanguageSpecificName( const ::rtl::OUString& langName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getRoot( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getDependencies( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL extraProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ /**
+ * This function prepares the script for invocation and returns the full path
+ * to the prepared parcel folder
+ */
+ virtual ::rtl::OUString SAL_CALL prepareForInvocation() throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+}
+#endif // define __SCRIPTING_STORAGE...
diff --git a/scripting/source/storage/ScriptMetadataImporter.cxx b/scripting/source/storage/ScriptMetadataImporter.cxx
new file mode 100644
index 000000000000..41b897a8eaa1
--- /dev/null
+++ b/scripting/source/storage/ScriptMetadataImporter.cxx
@@ -0,0 +1,562 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptMetadataImporter.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:50 $
+ *
+ * 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 "ScriptMetadataImporter.hxx"
+#include <osl/mutex.hxx>
+#include <com/sun/star/xml/sax/XParser.hpp>
+
+#include <stdio.h>
+#include <util/util.hxx>
+#include <rtl/string.h>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::drafts::com::sun::star::script::framework;
+
+namespace scripting_impl
+{
+
+//*************************************************************************
+ScriptMetadataImporter::ScriptMetadataImporter( const Reference< XComponentContext > & xContext ) : m_xContext( xContext )
+{
+ OSL_TRACE( "< ScriptMetadataImporter ctor called >\n" );
+}
+
+//*************************************************************************
+ScriptMetadataImporter::~ScriptMetadataImporter() SAL_THROW( () )
+{
+ OSL_TRACE( "< ScriptMetadataImporter dtor called >\n" );
+}
+
+
+//*************************************************************************
+Impls_vec ScriptMetadataImporter::parseMetaData(
+ Reference< io::XInputStream > const & xInput, const ::rtl::OUString & parcelURI )
+throw ( xml::sax::SAXException, io::IOException, RuntimeException )
+{
+ //Clear the vector of parsed information
+ ms_scriptInfos.clear();
+
+ //Set the placeholder for the parcel URI
+ ms_parcelURI = parcelURI;
+
+ //Get the parser service
+ validateXRef(m_xContext,
+ "ScriptMetadataImporter::parseMetaData: No context available");
+
+ Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
+ validateXRef(xMgr,
+ "ScriptMetadataImporter::parseMetaData: No service manager available");
+
+ Reference< XInterface > xx = xMgr->createInstanceWithContext(
+ OUString::createFromAscii("com.sun.star.xml.sax.Parser"), m_xContext );
+
+ validateXRef(xMgr, "ScriptMetadataImporter::parseMetaData: cannot get SAX Parser");
+ Reference< xml::sax::XParser > xParser(xx,UNO_QUERY_THROW);
+
+ // 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;
+ source.sSystemId = OUSTR("virtual file");
+
+ OSL_TRACE("ScriptMetadataImporter: Start the parser\n");
+
+ try
+ {
+ xParser->parseStream( source );
+ }
+ catch ( xml::sax::SAXException & saxe )
+ {
+ throw xml::sax::SAXException(
+ OUString::createFromAscii(
+ "ScriptMetadataImporter::parseMetaData SAXException: ") +saxe.Message,
+ Reference< XInterface > (), saxe.WrappedException);
+ }
+ catch ( io::IOException & ioe )
+ {
+ throw io::IOException( OUString::createFromAscii(
+ "ScriptMetadataImporter::parseMetaData IOException: ")+ioe.Message,
+ Reference< XInterface > ());
+ }
+#ifdef _DEBUG
+ catch ( ... )
+ {
+ throw RuntimeException(OUString::createFromAscii(
+ "ScriptMetadataImporter::parseMetadata UnknownException: "),
+ Reference< XInterface > ());
+ }
+#endif
+ OSL_TRACE("ScriptMetadataImporter: Parser finished\n");
+#ifdef _DEBUG
+
+ printf("ScriptMetadataImporter: vector size is %d\n", ms_scriptInfos.size());
+#endif
+ //return the vector of ScriptImplInfos
+ return ms_scriptInfos;
+}
+
+//*************************************************************************
+// XExtendedDocumentHandler impl
+void ScriptMetadataImporter::startCDATA()
+throw (xml::sax::SAXException, RuntimeException)
+{
+ OSL_TRACE("ScriptMetadataImporter: startCDATA()\n");
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::endCDATA()
+throw (RuntimeException)
+{
+ OSL_TRACE("ScriptMetadataImporter: endDATA()\n");
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::comment( const ::rtl::OUString & sComment )
+throw (xml::sax::SAXException, RuntimeException)
+{
+ OSL_TRACE("ScriptMetadataImporter: comment()\n");
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::allowLineBreak()
+throw (xml::sax::SAXException, RuntimeException)
+{
+ OSL_TRACE("ScriptMetadataImporter: allowLineBreak()\n");
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::unknown( const ::rtl::OUString & sString )
+throw (xml::sax::SAXException, RuntimeException)
+{
+ OSL_TRACE("ScriptMetadataImporter: unknown()\n");
+}
+
+//*************************************************************************
+// XDocumentHandler impl
+void ScriptMetadataImporter::startDocument()
+throw (xml::sax::SAXException, RuntimeException)
+{
+ // Ignore for now
+ OSL_TRACE("ScriptMetadataImporter: startDocument()\n");
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::endDocument()
+throw (xml::sax::SAXException, RuntimeException)
+{
+ // Ignore for now
+ OSL_TRACE("ScriptMetadataImporter: endDocument()\n");
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::startElement(
+ const ::rtl::OUString& tagName,
+ const Reference< xml::sax::XAttributeList >& xAttribs )
+throw (xml::sax::SAXException, RuntimeException)
+{
+#ifdef _DEBUG
+ printf("ScriptMetadataImporter: startElement() %s\n",
+ ::rtl::OUStringToOString(tagName,
+ RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+
+ //Set the state of the state machine
+ setState(tagName);
+
+ //Temporay variables
+ ::rtl::OUString t_delivered = ::rtl::OUString::createFromAscii("false");
+
+ //Processing the elements
+ switch(m_state)
+ {
+ case PARCEL:
+ break;
+
+
+ case LOGICALNAME:
+ //logical name
+ m_scriptImplInfo.logicalName =
+ xAttribs->getValueByName(
+ ::rtl::OUString::createFromAscii("value"));
+#ifdef _DEBUG
+
+ printf("ScriptMetadataImporter: Got logicalname: %s\n",
+ ::rtl::OUStringToOString(m_scriptImplInfo.logicalName,
+ RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ break;
+
+ case LANGUAGENAME:
+ //language(function) name
+ m_scriptImplInfo.functionName =
+ xAttribs->getValueByName(
+ ::rtl::OUString::createFromAscii("value"));
+ m_scriptImplInfo.scriptLocation =
+ xAttribs->getValueByName(
+ ::rtl::OUString::createFromAscii("location"));
+#ifdef _DEBUG
+
+ printf("ScriptMetadataImporter: Got language: %s\n",
+ ::rtl::OUStringToOString(m_scriptImplInfo.functionName,
+ RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ break;
+
+ case DELIVERFILE:
+ //Get Info about delivered files
+ mv_delivFile.push_back( xAttribs->getValueByName(
+ ::rtl::OUString::createFromAscii("name")));
+ mv_deliverType.push_back( xAttribs->getValueByName(
+ ::rtl::OUString::createFromAscii("type")));
+
+ break;
+
+ case DEPENDFILE:
+ //push the dependency into the the vector
+ mv_deps.push_back( xAttribs->getValueByName(
+ ::rtl::OUString::createFromAscii("name")));
+
+ t_delivered = xAttribs->getValueByName(
+ ::rtl::OUString::createFromAscii("isdeliverable"));
+
+ if( t_delivered.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("yes")) )
+ {
+ mv_depsDelivered.push_back( true );
+ }
+ else
+ {
+ mv_depsDelivered.push_back( false );
+ }
+
+#ifdef _DEBUG
+ printf("ScriptMetadataImporter: Got dependency: %s\n",
+ ::rtl::OUStringToOString( xAttribs->getValueByName(
+ ::rtl::OUString::createFromAscii("name")),
+ RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ break;
+
+ //Needs to be here to circumvent bypassing of initialization of
+ //local(global) variables affecting other cases
+ case SCRIPT:
+ //Assign a new empty struct to the member struct to clear
+ //all values in the struct
+ storage::ScriptImplInfo t_implInfo;
+ m_scriptImplInfo = t_implInfo;
+ m_scriptImplInfo.parcelURI = ms_parcelURI;
+ if(xAttribs->getLength() == 2)
+ {
+ //Get the script tag attributes
+ OSL_TRACE("ScriptMetadataImporter: Get language and deployment dir\n");
+
+ //script language
+ m_scriptImplInfo.scriptLanguage = xAttribs->getValueByName(
+ ::rtl::OUString::createFromAscii("language"));
+
+#ifdef _DEBUG
+
+ printf("ScriptMetadataImporter: Got language: %s\n",
+ ::rtl::OUStringToOString(m_scriptImplInfo.scriptLanguage,
+ RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+ //script root directory
+ m_scriptImplInfo.scriptRoot = xAttribs->getValueByName(
+ ::rtl::OUString::createFromAscii( "deploymentdir" ));
+
+#ifdef _DEBUG
+
+ printf("ScriptMetadataImporter: Got dir: %s\n",
+ ::rtl::OUStringToOString(m_scriptImplInfo.scriptRoot,
+ RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ }
+ break;
+ }
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::endElement( const ::rtl::OUString & aName )
+throw (xml::sax::SAXException, RuntimeException)
+{
+
+ //The end tag of an element
+#ifdef _DEBUG
+ printf("ScriptMetadataImporter: endElement() %s\n", ::rtl::OUStringToOString(aName,
+ RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+
+ //Set the state
+ setState(aName);
+
+ //Temporary variables
+ int t_delSize = 0;
+
+ switch (m_state)
+ {
+ case PARCEL:
+ break;
+ case SCRIPT:
+#ifdef _DEBUG
+
+ OSL_TRACE("ScriptMetadataImporter: Got a scriptImplInfo\n");
+
+ printf("ScriptMetadataImporter: \t %s\n", ::rtl::OUStringToOString(
+ m_scriptImplInfo.scriptLanguage, RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+ //Push the struct into the vector
+ ms_scriptInfos.push_back(m_scriptImplInfo);
+ break;
+
+ case LOGICALNAME:
+ break;
+
+ case LANGUAGENAME:
+ break;
+
+ case DELIVERY:
+ t_delSize = mv_delivFile.size();
+ if(t_delSize > 0)
+ {
+ Sequence< storage::ScriptDeliverFile > t_delivers(t_delSize);
+ Deps_vec::const_iterator it = mv_delivFile.begin();
+ Deps_vec::const_iterator it_end = mv_delivFile.end();
+ Deps_vec::const_iterator itType = mv_deliverType.begin();
+ Deps_vec::const_iterator itType_end = mv_deliverType.end();
+ for(int cnt = 0; (it!=it_end)&&(itType!=itType_end); ++it)
+ {
+ t_delivers[cnt].fileName = *it;
+ t_delivers[cnt].fileType = *itType;
+ cnt++;
+ ++itType;
+ }
+ m_scriptImplInfo.parcelDelivers = t_delivers;
+ mv_delivFile.clear();
+ mv_deliverType.clear();
+ }
+ break;
+
+ case DEPENDENCIES:
+ //Iterator through the vector of dependencies
+ //and put them into a sequence
+ int t_depsSize = mv_deps.size();
+ //Check if there is any dependencies, no need
+ //to bother doing anything
+ if(t_depsSize > 0)
+ {
+ Sequence< storage::ScriptDepFile > t_deps(t_depsSize);
+ Deps_vec::const_iterator it = mv_deps.begin();
+ Bool_vec::const_iterator itDel = mv_depsDelivered.begin();
+ Deps_vec::const_iterator it_end = mv_deps.end();
+ Bool_vec::const_iterator itDel_end = mv_depsDelivered.end();
+ for( int cnt = 0; (it!=it_end)&&(itDel!=itDel_end); ++it)
+ {
+ t_deps[cnt].fileName = *it;
+ t_deps[cnt].isDeliverable = *itDel;
+ cnt++;
+ ++itDel;
+ }
+ m_scriptImplInfo.scriptDependencies = t_deps;
+ //Clear the dependencies vector
+ mv_deps.clear();
+ mv_depsDelivered.clear();
+ }
+ break;
+ }
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::characters( const ::rtl::OUString & aChars )
+throw (xml::sax::SAXException, RuntimeException)
+{
+ OSL_TRACE("ScriptMetadataImporter: characters()\n");
+
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+
+ switch (m_state)
+ {
+ case PARCEL:
+ break;
+ case SCRIPT:
+ break;
+ case LANGUAGENAME:
+ break;
+ case LOGICALNAME:
+ break;
+ case DEPENDENCIES:
+ break;
+ case DESCRIPTION:
+ //Put description into the struct
+ m_scriptImplInfo.scriptDescription = aChars;
+ break;
+ case DELIVERY:
+ break;
+ case DELIVERFILE:
+ break;
+ case DEPENDFILE:
+ break;
+ }
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::ignorableWhitespace(
+ const ::rtl::OUString & aWhitespaces )
+throw (xml::sax::SAXException, RuntimeException)
+{
+ OSL_TRACE("ScriptMetadataImporter: ignorableWhiteSpace()\n");
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::processingInstruction(
+ const ::rtl::OUString & aTarget, const ::rtl::OUString & aData )
+throw (xml::sax::SAXException, RuntimeException)
+{
+ OSL_TRACE("ScriptMetadataImporter: processingInstruction()\n");
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::setDocumentLocator(
+ const Reference< xml::sax::XLocator >& xLocator )
+throw (xml::sax::SAXException, RuntimeException)
+{
+ OSL_TRACE("ScriptMetadataImporter: setDocumentLocator()\n");
+}
+
+//*************************************************************************
+void ScriptMetadataImporter::setState(const ::rtl::OUString & tagName)
+{
+ //Set the state depending on the tag name of the current
+ //element the parser has arrived at
+ ::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
+
+ if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("parcel") ))
+ {
+ //Parcel tag
+ m_state = PARCEL;
+ }
+ else if (tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("script") ))
+ {
+ //Script tag
+ m_state = SCRIPT;
+ }
+ else if (tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("logicalname") ))
+ {
+ //logicalname tag
+ m_state = LOGICALNAME;
+ }
+ else if (tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("languagename") ))
+ {
+ //languagename tag
+ m_state = LANGUAGENAME;
+ }
+ else if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dependencies") ))
+ {
+ //dependencies tag
+ m_state = DEPENDENCIES;
+ }
+ else if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("description") ))
+ {
+ //Description tag
+ m_state = DESCRIPTION;
+ }
+ else if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("delivery") ))
+ {
+ //delivery tag, nothing to be done here
+ m_state = DELIVERY;
+ }
+ else if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("deliverfile") ))
+ {
+ //deliverfile tag, nothing to be done here
+ m_state = DELIVERFILE;
+ }
+ else if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dependfile") ))
+ {
+ m_state = DEPENDFILE;
+ }
+ else
+ {
+ //If there is a tag we don't know about, throw a expcetion (woobler) :)
+ ::rtl::OUString str_sax = ::rtl::OUString::createFromAscii( "No Such Tag" );
+
+#ifdef _DEBUG
+
+ printf("ScriptMetadataImporter: No Such Tag: %s\n", ::rtl::OUStringToOString(
+ tagName, RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ throw xml::sax::SAXException(
+ str_sax, Reference< XInterface >(), Any() );
+ }
+}
+}
diff --git a/scripting/source/storage/ScriptMetadataImporter.hxx b/scripting/source/storage/ScriptMetadataImporter.hxx
new file mode 100644
index 000000000000..389274f7b4fd
--- /dev/null
+++ b/scripting/source/storage/ScriptMetadataImporter.hxx
@@ -0,0 +1,279 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptMetadataImporter.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:50 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _SCRIPTING_STORAGE_SCRIPTMETADATAIMPORTER_HXX_
+#define _SCRIPTING_STORAGE_SCRIPTMETADATAIMPORTER_HXX_
+
+#include <vector>
+
+#include <rtl/ustring.h>
+#include <osl/mutex.hxx>
+#include <cppuhelper/implbase1.hxx> // helper for component factory
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp>
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+
+
+namespace scripting_impl
+{
+
+typedef ::std::vector< ::drafts::com::sun::star::script::framework::storage::ScriptImplInfo > Impls_vec;
+typedef ::std::vector< ::rtl::OUString > Deps_vec;
+typedef ::std::vector< bool > Bool_vec;
+
+/**
+ * Script Meta Data Importer
+ */
+class ScriptMetadataImporter
+ : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XExtendedDocumentHandler >
+{
+ // private member
+private:
+
+ /** Vector contains the ScriptImplInfo structs */
+ Impls_vec ms_scriptInfos;
+
+ /** @internal */
+ Deps_vec mv_deps;
+
+ /** @internal */
+ Deps_vec mv_delivFile;
+
+ /** @internal */
+ Deps_vec mv_deliverType;
+
+ /** @internal */
+ Bool_vec mv_depsDelivered;
+
+ /** @internal */
+ osl::Mutex m_mutex;
+
+ /** @internal */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+
+ //Placeholder for the parcel URI
+ ::rtl::OUString ms_parcelURI;
+
+ /** States for state machine during parsing */
+ enum { PARCEL, SCRIPT, LANGUAGE_NAME, LOGICALNAME, LANGUAGENAME,
+ DEPENDENCIES, DESCRIPTION, DELIVERY, DELIVERFILE, DEPENDFILE } m_state;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > ms_dependFiles;
+
+ //Build up the struct during parsing the meta data
+ ::drafts::com::sun::star::script::framework::storage::ScriptImplInfo m_scriptImplInfo;
+
+ //Helper function to set the state
+ void setState(const ::rtl::OUString & tagName);
+
+ // public interface
+public:
+
+ /**
+ * This function will begin the parser and parse the meta data
+ *
+ * @param xInput The XInputStream for the parser which contains the XML
+ * @param parcelURI The parcel's URI in the document or the application
+ *
+ * @see ::com::sun::star::io::XInputStream
+ */
+ Impls_vec parseMetaData(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::io::XInputStream >
+ const & xInput, const ::rtl::OUString & parcelURI )
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::uno::RuntimeException);
+
+ explicit ScriptMetadataImporter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& );
+ virtual ~ScriptMetadataImporter() SAL_THROW( () );
+
+ // XExtendedDocumentHandler impl
+ /**
+ * Function to handle the start of CDATA in XML
+ *
+ * @see com::sun::star::xml::sax::XExtendedDocumentHandler
+ */
+ virtual void SAL_CALL startCDATA()
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle the end of CDATA in XML
+ *
+ * @see com::sun::star::xml::sax::XExtendedDocumentHandler
+ */
+ virtual void SAL_CALL endCDATA()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle comments in XML
+ *
+ * @see com::sun::star::xml::sax::XExtendedDocumentHandler
+ */
+ virtual void SAL_CALL comment( const ::rtl::OUString & sComment )
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle line breaks in XML
+ *
+ * @see com::sun::star::xml::sax::XExtendedDocumentHandler
+ */
+ virtual void SAL_CALL allowLineBreak()
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle unknowns in XML
+ *
+ * @see com::sun::star::xml::sax::XExtendedDocumentHandler
+ */
+ virtual void SAL_CALL unknown( const ::rtl::OUString & sString )
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle the start of XML document
+ *
+ * @see com::sun::star::xml::sax::XExtendedDocumentHandler
+ */
+ // XDocumentHandler impl
+ virtual void SAL_CALL startDocument()
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle the end of the XML document
+ *
+ * @see com::sun::star::xml::sax::XDocumentHandler
+ */
+ virtual void SAL_CALL endDocument()
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle the start of an element
+ *
+ * @see com::sun::star::xml::sax::XDocumentHandler
+ */
+ virtual void SAL_CALL startElement(
+ const ::rtl::OUString& aName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttribs )
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle the end of an element
+ *
+ * @see com::sun::star::xml::sax::XDocumentHandler
+ */
+ virtual void SAL_CALL endElement( const ::rtl::OUString & aName )
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle characters in elements
+ *
+ * @see com::sun::star::xml::sax::XDocumentHandler
+ */
+ virtual void SAL_CALL characters( const ::rtl::OUString & aChars )
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle whitespace
+ *
+ * @see com::sun::star::xml::sax::XDocumentHandler
+ */
+ virtual void SAL_CALL ignorableWhitespace(
+ const ::rtl::OUString & aWhitespaces )
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to handle XML processing instructions
+ *
+ * @see com::sun::star::xml::sax::XDocumentHandler
+ */
+ virtual void SAL_CALL processingInstruction(
+ const ::rtl::OUString & aTarget, const ::rtl::OUString & aData )
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ /**
+ * Function to set the document locator
+ *
+ * @see com::sun::star::xml::sax::XDocumentHandler
+ */
+ virtual void SAL_CALL setDocumentLocator(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator )
+ throw ( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+}
+; // class ScriptMetadataImporter
+
+}
+
+#endif
diff --git a/scripting/source/storage/ScriptStorage.cxx b/scripting/source/storage/ScriptStorage.cxx
new file mode 100644
index 000000000000..4df664672ba0
--- /dev/null
+++ b/scripting/source/storage/ScriptStorage.cxx
@@ -0,0 +1,691 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptStorage.cxx,v $
+ *
+ * $Revision: 1.1 $
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:51 $
+ *
+ * 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 <stdio.h>
+
+#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>
+#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp>
+
+#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
+{
+
+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";
+
+static OUString ss_implName = OUString::createFromAscii(IMPL_NAME);
+static OUString ss_serviceName = OUString::createFromAscii(SERVICE_NAME);
+static Sequence< OUString > ss_serviceNames = Sequence< OUString >( &ss_serviceName, 1 );
+
+extern ::rtl_StandardModuleCount s_moduleCount;
+
+//*************************************************************************
+ScriptStorage::ScriptStorage( const Reference<
+ XComponentContext > & xContext )
+ : m_xContext( xContext )
+{
+ OSL_TRACE( "< ScriptStorage ctor called >\n" );
+ s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
+}
+
+//*************************************************************************
+ScriptStorage::~ScriptStorage() SAL_THROW( () )
+{
+ OSL_TRACE( "< ScriptStorage dtor called >\n" );
+ s_moduleCount.modCnt.release( &s_moduleCount.modCnt );
+}
+
+//*************************************************************************
+void ScriptStorage::initialize(
+ const Sequence <Any> & args )
+throw (Exception)
+{
+ OSL_TRACE("Entering ScriptStorage::initialize\n");
+ // work in progress.
+ // what might we expect to get?
+ // at the moment only consider 3 possibilities
+ // 1. an XInputStream - [deprecated!!]
+ // 2. an XSimpleFileAccess
+ // 3. an OUString containing a URI
+
+ ::osl::Guard< osl::Mutex > aGuard( m_mutex );
+
+ Reference< io::XInputStream > xInput;
+ ::rtl::OUString xStringUri;
+
+ // need to replace this with a proper call to getService...
+ ScriptMetadataImporter* SMI = new ScriptMetadataImporter(m_xContext);
+ Reference<xml::sax::XExtendedDocumentHandler> xSMI(SMI);
+ if (args.getLength())
+ {
+ if((sal_False != (args[0] >>= m_xSimpleFileAccess)) &&
+ (sal_False != (args[1]>>=m_scriptStorageID)))
+ {
+ if(args.getLength()>2 && (sal_False == (args[2] >>= xStringUri)))
+ {
+ xStringUri=::rtl::OUString::createFromAscii("");
+ }
+ }
+ /* deprecated?
+ else if((sal_False != (args[1]>>=m_scriptStorageID)) &&
+ (sal_False != (args[0] >>= xStringUri)))
+ {
+ //probably need some check for type of URI????
+ validateXRef(m_xContext, "ScriptStorage::initialize: No context available");
+ Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
+ validateXRef(xMgr, "ScriptStorage::initialize: No service manager available");
+ Reference< XInterface > xx = xMgr->createInstanceWithContext(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess"), m_xContext );
+ validateXRef(xMgr, "ScriptStorage::initialize: cannot get XSimpleFileAccess");
+ m_xSimpleFileAccess.set(xx, UNO_QUERY_THROW);
+ } */
+ else
+ {
+ OSL_TRACE("ScriptStorage::initialize: got some unknown type of arg\n");
+ throw lang::IllegalArgumentException(
+ OUSTR("unexpected argument type provided!"),
+ static_cast< OWeakObject * >( this ), 0 );
+ }
+ }
+ else //no args provided
+ {
+ OSL_TRACE("ScriptStorage::initialize: got no args\n");
+ throw lang::IllegalArgumentException(
+ OUSTR("No arguments provided!"),
+ static_cast< OWeakObject * >( this ), 0 );
+ }
+#ifdef _DEBUG
+ fprintf(stderr,"uri: %s\n",::rtl::OUStringToOString(xStringUri,RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ try
+ {
+ xStringUri=xStringUri.concat(::rtl::OUString::createFromAscii("/Scripts"));
+
+ // get the list of files/folders under the Scripts directory
+ Sequence< ::rtl::OUString > results=m_xSimpleFileAccess->getFolderContents(xStringUri,true);
+ for(int i=0;i<results.getLength();i++)
+ {
+#ifdef _DEBUG
+ fprintf(stderr,"contains: %s\n",::rtl::OUStringToOString(results[i],RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ if(m_xSimpleFileAccess->isFolder(results[i]))
+ {
+ //get the list of files/folders for each folder
+ // under Scripts/
+ Sequence< ::rtl::OUString > subresults=m_xSimpleFileAccess->getFolderContents(results[i],true);
+ for(int j=0;j<subresults.getLength();j++)
+ {
+#ifdef _DEBUG
+ fprintf(stderr,"contains: %s\n",::rtl::OUStringToOString(subresults[j],RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ OUString parcelFile=subresults[j].concat(::rtl::OUString::createFromAscii("/parcel.xml"));
+ //if the subfolder Scripts/*/ has a file
+ //called parcel.xml
+ if(m_xSimpleFileAccess->isFolder(subresults[j]) && m_xSimpleFileAccess->exists(parcelFile) && !m_xSimpleFileAccess->isFolder(parcelFile))
+ {
+#ifdef _DEBUG
+ fprintf(stderr,"parcel file: %s\n",::rtl::OUStringToOString(parcelFile,RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ xInput = m_xSimpleFileAccess->openFileRead(parcelFile);
+ if (xInput.is())
+ {
+ // should I aquire the stream??
+ OSL_TRACE("Parse the metadata \n");
+#ifndef TEST_ONLY
+
+ Impls_vec vSII = SMI->parseMetaData( xInput, subresults[j] );
+ xInput->closeInput();
+#else
+
+ Impls_vec vSII;
+ storage::ScriptImplInfo m,m2,m3;
+ m.scriptLanguage=rtl::OUString::createFromAscii("java");
+ ;
+ m.functionName=rtl::OUString::createFromAscii("com.sun.star.foo");
+ ;
+ m.logicalName=rtl::OUString::createFromAscii("my.foo");
+ ;
+ m2.scriptLanguage=rtl::OUString::createFromAscii("java");
+ ;
+ m2.functionName=rtl::OUString::createFromAscii("com.sun.star.foo2");
+ ;
+ m2.logicalName=rtl::OUString::createFromAscii("my.foo");
+ ;
+ m3.scriptLanguage=rtl::OUString::createFromAscii("java");
+ ;
+ m3.functionName=rtl::OUString::createFromAscii("com.sun.star.bar");
+ ;
+ m3.logicalName=rtl::OUString::createFromAscii("my.bar");
+ ;
+ vSII.push_back(m);
+ vSII.push_back(m2);
+ vSII.push_back(m3);
+
+#endif
+ // should I now release the stream??
+ updateMaps(vSII);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch(xml::sax::SAXException saxe)
+ {
+ //From ScriptMetadata Importer
+ OSL_TRACE("caught com::sun::star::xml::sax::SAXException in ScriptStorage::initalize");
+ throw RuntimeException(OUSTR("ScriptStorage::initalize SAXException: ")+saxe.Message,
+ Reference<XInterface> ());
+ }
+ catch(io::IOException ioe)
+ {
+ //From ScriptMetadata Importer
+ OSL_TRACE("caught com::sun::star::io::IOException in ScriptStorage::initalize");
+ throw RuntimeException(OUSTR("ScriptStorage::initalize IOException: ")+ioe.Message,
+ Reference<XInterface> ());
+
+ }
+ catch(ucb::CommandAbortedException cae)
+ {
+ OSL_TRACE("caught com::sun::star::ucb::CommandAbortedException in ScriptStorage::initialize");
+ throw RuntimeException(OUSTR("ScriptStorage::initalize CommandAbortedException: ")+cae.Message,
+ Reference<XInterface> ());
+ }
+ catch(Exception ue)
+ {
+ OSL_TRACE("caught com::sun::star::uno::Exception in ScriptStorage::initialize");
+ throw RuntimeException(OUSTR("ScriptStorage::initalize Exception: ")+ue.Message,
+ Reference<XInterface> ());
+ }
+ OSL_TRACE("Parsed the XML\n");
+}
+
+//*************************************************************************
+// private method for updating hashmaps
+void ScriptStorage::updateMaps(Impls_vec vScriptII)
+{
+ ::osl::Guard< osl::Mutex > aGuard( m_mutex );
+
+ Impls_vec::iterator it = vScriptII.begin();
+ Impls_vec::iterator it_end = vScriptII.end();
+ // step through the vector of ScripImplInfos returned from parse
+ for(sal_Int32 count=0;it!=it_end;++it)
+ {
+ //find the Impls_vec for this logical name
+ ScriptInfo_hash::iterator h_it = mh_implementations.find(it->logicalName);
+
+ if(h_it==mh_implementations.end())
+ {
+ //if it's null, need to create a new Impls_vec
+#ifdef _DEBUG
+ 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);
+#endif
+
+ Impls_vec v;
+ v.push_back(*it);
+ mh_implementations[it->logicalName]=v;
+ }
+ else
+ {
+#ifdef _DEBUG
+ 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);
+#endif
+
+ h_it->second.push_back(*it);
+ }
+ }
+}
+
+//*************************************************************************
+// Not part of the interface yet, ie. not in the idl, and it should be!!
+void ScriptStorage::save()
+throw (RuntimeException)
+{
+ ::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;
+
+ OUString parcel_suffix = OUString::createFromAscii("/parcel.xml");
+
+ validateXRef(m_xContext, "ScriptStorage::save: No context available");
+ Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
+ validateXRef(xMgr, "ScriptStorage::save: No service manager available");
+
+ OUString ou_parcel = OUString( RTL_CONSTASCII_USTRINGPARAM("parcel"));
+
+ ScriptInfo_hash::iterator it = mh_implementations.begin();
+ ScriptInfo_hash::iterator it_end = mh_implementations.end();
+ for(sal_Int32 count=0;it!=it_end;++it)
+ {
+ ::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)
+ {
+ ScriptOutput_hash::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);
+#ifdef _DEBUG
+
+ fprintf(stderr,"saving: %s\n",rtl::OUStringToOString(it_impls->parcelURI.concat(OUString::createFromAscii("/parcel.xml")),RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ Reference< XInterface > xx = xMgr->createInstanceWithContext(OUString::createFromAscii("com.sun.star.xml.sax.Writer"), m_xContext );
+ validateXRef(xMgr, "ScriptStorage::save: cannot get sax.Writer");
+ xHandler = Reference<xml::sax::XExtendedDocumentHandler>(xx, UNO_QUERY_THROW);
+ xSource = Reference< io::XActiveDataSource >( xHandler, UNO_QUERY_THROW );
+ xSource->setOutputStream( xOS );
+
+ writeMetadataHeader(xHandler);
+
+ xHandler->startElement( ou_parcel, Reference< xml::sax::XAttributeList >() );
+
+ mh_parcels[it_impls->parcelURI]=xHandler;
+ }
+ else
+ {
+ xHandler=it_parcels->second;
+ }
+
+ ScriptElement* pSE = new ScriptElement(*it_impls);
+ // this is to get pSE released correctly
+ Reference <xml::sax::XAttributeList> xal(pSE);
+ pSE->dump(xHandler);
+ }
+ }
+
+ ScriptOutput_hash::const_iterator out_it_end = mh_parcels.end();
+
+ 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();
+
+ }
+}
+
+//*************************************************************************
+void ScriptStorage::writeMetadataHeader(Reference <xml::sax::XExtendedDocumentHandler> & xHandler)
+{
+ 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 > >
+ScriptStorage::getScriptInfoService(const OUString & name)
+throw (RuntimeException)
+{
+ ::osl::Guard< osl::Mutex > aGuard( m_mutex );
+
+ //Get iterator over the hash_map
+ ScriptInfo_hash::const_iterator h_iter = mh_implementations.find(name);
+ Impls_vec::const_iterator it =
+ h_iter->second.begin(), end_iter = h_iter->second.end();
+
+ Sequence< Reference< storage::XScriptInfo > > sr_xScriptInfo(
+ h_iter->second.size() );
+
+ //Get array of XScriptInfos
+ Reference< storage::XScriptInfo >* pScriptInfo = sr_xScriptInfo.getArray();
+
+ validateXRef(m_xContext, "ScriptStorage::getScriptInfoService: No context available");
+ Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
+ validateXRef(xMgr, "ScriptStorage::getScriptInfoService: No service manager available");
+
+ for(sal_Int32 count = 0; it != end_iter; ++it)
+ {
+#ifdef _DEBUG
+ fprintf(stderr,"in for cycle, count is %d\n", count);
+#endif
+
+ Any a( makeAny( *it ) );
+ Reference< XInterface > xx = xMgr->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.storage.ScriptInfo"), Sequence< Any >( &a, 1 ), m_xContext );
+ validateXRef(xMgr, "ScriptStorage::getScriptInfoService: cannot get drafts.com.sun.star.script.framework.storage.ScriptInfo");
+ pScriptInfo[ count ] = Reference< storage::XScriptInfo >(xx, UNO_QUERY_THROW );
+ sr_xScriptInfo[ count ] = Reference< storage::XScriptInfo >(xx, UNO_QUERY_THROW );
+ count++;
+ }
+
+ return sr_xScriptInfo;
+}
+
+//XNamingAccess
+/**
+Reference<XInterface> ScriptStorage::getView(
+ const ::rtl::OUString& viewName )
+ throw (storage::NoSuchView,
+ RuntimeException)
+{
+}
+*/
+
+//*************************************************************************
+Sequence< Reference< scripturi::XScriptURI > >
+ScriptStorage::getImplementations( const Reference<
+ scripturi::XScriptURI >& queryURI )
+throw (lang::IllegalArgumentException,
+ RuntimeException)
+{
+ ::osl::Guard< osl::Mutex > aGuard( m_mutex );
+ Sequence< Reference< scripturi::XScriptURI > > results;
+ try
+ {
+ //find the implementations for the given logical name
+ ScriptInfo_hash::iterator h_it = mh_implementations.find(queryURI->getLogicalName());
+ if(h_it!=mh_implementations.end())
+ {
+ Impls_vec::iterator it_impls =h_it->second.begin();
+ Impls_vec::iterator it_impls_end =h_it->second.end();
+ for(sal_Int32 count=0;it_impls!=it_impls_end;++it_impls)
+ {
+ //should we do any resolution here?????
+ // or leave it completely up to the resolver?
+ //construct new Reference<scripturi::ScriptURI>
+ Sequence<Any> aArgs(2);
+ aArgs[0]<<=*it_impls;
+ aArgs[1]<<=m_scriptStorageID;
+
+ validateXRef(m_xContext, "ScriptStorage::getImplementations: No context available");
+ Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
+ validateXRef(xMgr, "ScriptStorage::getImplementations: No service manager available");
+ Reference< XInterface > xx = xMgr->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.scripturi.ScriptURI"), aArgs, m_xContext );
+ validateXRef(xMgr, "ScriptStorage::getImplementations: cannot get drafts.com.sun.star.script.framework.storage.ScriptInfo");
+ Reference<scripturi::XScriptURI> uri(xx,UNO_QUERY_THROW);
+ //add to the sequence
+ //assuming that we'll usually only get 1 elt returned
+ //first realloc if we get 2 elts...
+ if(count>=results.getLength())
+ {
+ results.realloc(results.getLength()+1);
+ }
+ results[count++]=uri;
+ }
+ }
+ }
+ catch(Exception e)
+ {
+ throw RuntimeException(OUSTR("ScriptStorage::getImplementations Exception: ")+e.Message,
+ Reference<XInterface> ());
+ }
+ return results;
+}
+
+//*************************************************************************
+OUString SAL_CALL ScriptStorage::prepareForInvocation( const OUString& parcelURI ) throw (RuntimeException)
+{
+ try
+ {
+ validateXRef(m_xSimpleFileAccess,
+ "ScriptStorage::prepareForInvocation(): no SimpleFileAccess");
+
+ if ((m_xSimpleFileAccess->exists(parcelURI) != sal_True) ||
+ (m_xSimpleFileAccess->isFolder(parcelURI) != sal_True))
+ {
+ throw RuntimeException(
+ OUSTR("ScriptStorage::prepareForInvocation(): parcel URI is not valid"),
+ Reference<XInterface> ());
+ }
+
+ OUString dest = OUString::createFromAscii("file:///tmp");
+ sal_Int32 idx = parcelURI.lastIndexOf('/');
+ sal_Int32 len = parcelURI.getLength();
+ if (idx == (len-1))
+ {
+ // deal with the trailing separator
+ idx = parcelURI.lastIndexOf('/', len-2);
+ OUString parcel_base = parcelURI.copy(idx, len-idx-1);
+ dest = dest.concat(parcel_base);
+ }
+ else
+ {
+ dest = dest.concat(parcelURI.copy(idx));
+ }
+ dest = dest.concat(OUString::valueOf((sal_Int32)m_scriptStorageID));
+
+ fprintf(stderr,"dest is: %s\n",rtl::OUStringToOString(dest, RTL_TEXTENCODING_ASCII_US).pData->buffer);
+
+ copyFolder(parcelURI, dest);
+
+ return dest;
+ }
+ catch(RuntimeException &e)
+ {
+ OUString temp = OUSTR(
+ "ScriptStorage::prepareForInvocation RuntimeException: ");
+ throw RuntimeException(temp.concat(e.Message),
+ Reference<XInterface> ());
+ }
+#ifdef _DEBUG
+ catch ( ... )
+ {
+ throw RuntimeException(OUSTR(
+ "ScriptStorage::prepareForInvocation UnknownException: "),
+ Reference<XInterface> ());
+ }
+#endif
+}
+
+//*************************************************************************
+/**
+ * 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.
+ */
+void ScriptStorage::copyFolder(const OUString &src, const OUString &dest) throw (RuntimeException)
+{
+ try
+ {
+ OUString new_dest;
+ sal_Int32 idx;
+
+ /* 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 );
+
+ if (m_xSimpleFileAccess->isFolder(dest) == sal_True)
+ {
+ m_xSimpleFileAccess->kill(dest);
+ }
+ m_xSimpleFileAccess->createFolder(dest);
+
+ Sequence <OUString> seq = m_xSimpleFileAccess->getFolderContents(
+ src, sal_True);
+ sal_Int32 len = seq.getLength();
+ for(int i = 0; i < len; i++)
+ {
+ new_dest = dest;
+ idx = seq[i].lastIndexOf('/');
+ new_dest = new_dest.concat(seq[i].copy(idx));
+
+ if (m_xSimpleFileAccess->isFolder(seq[i]) == sal_True)
+ {
+ copyFolder(seq[i], new_dest);
+ }
+ else
+ {
+ m_xSimpleFileAccess->copy(seq[i], new_dest);
+ }
+ }
+ }
+ catch(ucb::CommandAbortedException &e)
+ {
+ OUString temp = OUSTR(
+ "ScriptStorage::copyFolder CommandAbortedException: ");
+ throw RuntimeException(temp.concat(e.Message),
+ Reference<XInterface> ());
+ }
+ catch(RuntimeException &e)
+ {
+ OUString temp = OUSTR("ScriptStorage::copyFolder RuntimeException: ");
+ throw RuntimeException(temp.concat(e.Message),
+ Reference<XInterface> ());
+ }
+ catch(Exception &e)
+ {
+ OUString temp = OUSTR("ScriptStorage::copyFolder Exception: ");
+ throw RuntimeException(temp.concat(e.Message),
+ Reference<XInterface> ());
+ }
+#ifdef _DEBUG
+ catch ( ... )
+ {
+ throw RuntimeException(OUSTR(
+ "ScriptStorage::copyFolder UnknownException: "),
+ Reference<XInterface> ());
+ }
+#endif
+}
+
+
+//*************************************************************************
+OUString SAL_CALL ScriptStorage::getImplementationName( )
+throw(RuntimeException)
+{
+ return ss_implName;
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL ScriptStorage::supportsService( const OUString& serviceName )
+throw(RuntimeException)
+{
+ OUString const * pNames = ss_serviceNames.getConstArray();
+ for ( sal_Int32 nPos = ss_serviceNames.getLength(); nPos--; )
+ {
+ if (serviceName.equals( pNames[ nPos ] ))
+ {
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ScriptStorage::getSupportedServiceNames( )
+throw(RuntimeException)
+{
+ return ss_serviceNames;
+}
+//*************************************************************************
+Reference<XInterface> SAL_CALL ss_create(
+ const Reference< XComponentContext > & xCompC )
+{
+ return ( cppu::OWeakObject * ) new ScriptStorage( xCompC );
+}
+
+//*************************************************************************
+Sequence<OUString> ss_getSupportedServiceNames( )
+SAL_THROW( () )
+{
+ return ss_serviceNames;
+}
+
+//*************************************************************************
+OUString ss_getImplementationName( )
+SAL_THROW( () )
+{
+ return ss_implName;
+}
+}
diff --git a/scripting/source/storage/ScriptStorage.hxx b/scripting/source/storage/ScriptStorage.hxx
new file mode 100644
index 000000000000..d1b50f83a52b
--- /dev/null
+++ b/scripting/source/storage/ScriptStorage.hxx
@@ -0,0 +1,246 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptStorage.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:52 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef __SCRIPTING_STORAGE_SCRIPTSTORAGE_HXX_
+#define __SCRIPTING_STORAGE_SCRIPTSTORAGE_HXX_
+
+#include <vector>
+#include <hash_map>
+
+#include <osl/mutex.hxx>
+#include <cppuhelper/implbase6.hxx> // helper for component factory
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <drafts/com/sun/star/script/framework/storage/XScriptAccessManager.hpp>
+#include <drafts/com/sun/star/script/framework/storage/XScriptImplAccess.hpp>
+#include <drafts/com/sun/star/script/framework/storage/XScriptStorageExport.hpp>
+#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp>
+#include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
+#include <drafts/com/sun/star/script/framework/storage/NoSuchView.hpp>
+#include <drafts/com/sun/star/script/framework/scripturi/XScriptURI.hpp>
+#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>
+#include <drafts/com/sun/star/script/framework/storage/XParcelInvocationPrep.hpp>
+
+namespace scripting_impl
+{
+
+//Typedefs
+//=============================================================================
+typedef ::std::vector< ::drafts::com::sun::star::script::framework::storage::ScriptImplInfo >
+Impls_vec;
+//-----------------------------------------------------------------------------
+typedef ::std::hash_map < ::rtl::OUString, Impls_vec,
+::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
+ScriptInfo_hash;
+//-----------------------------------------------------------------------------
+typedef ::std::hash_map < ::rtl::OUString,
+::com::sun::star::uno::Reference<
+::com::sun::star::xml::sax::XExtendedDocumentHandler >,
+::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
+ScriptOutput_hash;
+//=============================================================================
+
+class ScriptStorage
+ : public ::cppu::WeakImplHelper6<
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XInitialization,
+ ::drafts::com::sun::star::script::framework::storage::XScriptImplAccess,
+ ::drafts::com::sun::star::script::framework::storage::XScriptStorageExport,
+ ::drafts::com::sun::star::script::framework::storage::XScriptAccessManager,
+ ::drafts::com::sun::star::script::framework::storage::XParcelInvocationPrep >
+{
+ // private member
+private:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xSimpleFileAccess;
+
+ ::std::vector < ::rtl::OUString > mv_logicalNames;
+ ScriptInfo_hash mh_implementations;
+ ScriptOutput_hash mh_parcels;
+ sal_uInt16 m_scriptStorageID;
+
+ osl::Mutex m_mutex;
+
+ void updateMaps(Impls_vec vScriptII);
+ void writeMetadataHeader(::com::sun::star::uno::Reference < ::com::sun::star::xml::sax::XExtendedDocumentHandler > & );
+ void copyFolder(const ::rtl::OUString & src, const ::rtl::OUString & dest) throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ //Constructors and Destructors
+ //=========================================================================
+ explicit ScriptStorage( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >& );
+ //-------------------------------------------------------------------------
+ virtual ~ScriptStorage() SAL_THROW( () );
+ //=========================================================================
+
+ // XServiceInfo impl
+ //=========================================================================
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw (::com::sun::star::uno::RuntimeException);
+ //-------------------------------------------------------------------------
+ virtual sal_Bool SAL_CALL supportsService(
+ const ::rtl::OUString & ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ //-------------------------------------------------------------------------
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupportedServiceNames()
+ throw (::com::sun::star::uno::RuntimeException);
+ //-------------------------------------------------------------------------
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupportedServiceNames_Static();
+ //=========================================================================
+
+ // XInitialization impl
+ //=========================================================================
+ virtual void SAL_CALL initialize( ::com::sun::star::uno::Sequence
+ < ::com::sun::star::uno::Any > const & args )
+ throw (::com::sun::star::uno::Exception);
+ //=========================================================================
+
+ // XScriptAccessManager impl
+ //=========================================================================
+ /**
+ * Gets the sequence of XScriptInfo interfaces for the corresponding
+ * logical name that is passed in
+ *
+ * @param name
+ * The logical name of the script
+ *
+ * @return Sequence< XScriptInfo >
+ * A sequence of XScriptInfos which represent the implementations
+ * of the passed in logical name
+ */
+ virtual ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::script::framework::storage::XScriptInfo > >
+ SAL_CALL getScriptInfoService( const ::rtl::OUString & name )
+ throw (::com::sun::star::uno::RuntimeException);
+ //=========================================================================
+
+ //XScriptImplAccess
+ //=========================================================================
+ /**
+ * Get the implementations for a given URI
+ *
+ * @param queryURI
+ * The URI to get the implementations for
+ *
+ * @return XScriptURI
+ * The URIs of the implementations
+ */
+ virtual ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::script::framework::scripturi::XScriptURI > >
+ SAL_CALL getImplementations( const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::script::framework::scripturi::XScriptURI >& queryURI )
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+ //=========================================================================
+
+
+ //XNamingAccess
+ //=========================================================================
+ /**
+ * Get a certain type of view of the naming heirarchy
+ *
+ * @param viewName
+ * The view name
+ *
+ * @return XInterface
+ * The view of the hierarchy
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ ScriptStorage::getView( const ::rtl::OUString& viewName )
+ throw (::drafts::com::sun::star::script::framework::storage::NoSuchView,
+ ::com::sun::star::uno::RuntimeException);
+ //=========================================================================
+
+ // XScriptStorageExport
+ void SAL_CALL save()
+ throw (::com::sun::star::uno::RuntimeException);
+ //=========================================================================
+
+ //XParcelInvocationPrep
+ //=========================================================================
+ /**
+ * Prepare a pracel for invocation
+ * @param parcelURI
+ * URI to the parcel to be prepared
+ *
+ * @return ::rtl::OUString
+ * URI to the prepared parcel
+ */
+
+ ::rtl::OUString SAL_CALL prepareForInvocation( const ::rtl::OUString& parcelURI )
+ throw (::com::sun::star::uno::RuntimeException);
+ //=========================================================================
+}
+; // class ScriptingStorage
+
+}
+
+#endif
diff --git a/scripting/source/storage/ScriptStorageManager.cxx b/scripting/source/storage/ScriptStorageManager.cxx
new file mode 100644
index 000000000000..d79dc6046ee8
--- /dev/null
+++ b/scripting/source/storage/ScriptStorageManager.cxx
@@ -0,0 +1,354 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptStorageManager.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:52 $
+ *
+ * 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 <stdio.h>
+
+#include <cppuhelper/implementationentry.hxx>
+#include <sal/config.h>
+#include <util/util.hxx>
+
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/util/XMacroExpander.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+
+#include "ScriptStorageManager.hxx"
+#include <util/util.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::drafts::com::sun::star::script::framework;
+
+namespace scripting_impl
+{
+
+static const sal_Char* const SERVICENAME="drafts.com.sun.star.script.framework.storage.ScriptStorageManager";
+static const sal_Char* const IMPLNAME="drafts.com.sun.star.script.framework.storage.ScriptStorageManager";
+
+static OUString s_implName = ::rtl::OUString::createFromAscii(IMPLNAME);
+static OUString s_serviceName = ::rtl::OUString::createFromAscii(SERVICENAME);
+static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 );
+
+::rtl_StandardModuleCount s_moduleCount = MODULE_COUNT_INIT;
+
+//*************************************************************************
+// ScriptStorageManager Constructor
+ScriptStorageManager::ScriptStorageManager(const Reference< XComponentContext > & xContext)
+ : m_xContext( xContext )
+{
+ OSL_TRACE( "< ScriptStorageManager ctor called >\n" );
+ s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
+ try
+ {
+ count=0;
+ // obtain the macro expander singleton to use in determining the
+ // location of the application script storage
+ Any aAny = m_xContext->getValueByName(OUString::createFromAscii("/singletons/com.sun.star.util.theMacroExpander"));
+ Reference<util::XMacroExpander> xME;
+ OSL_ASSERT(sal_False!=(aAny>>=xME));
+ OSL_ASSERT(xME.is());
+ validateXRef(xME,"ScriptStorageManager constructor: Can't get MacroExpander");
+
+ // get the MultiComponentFactory and use it to create a
+ // SimpleFileAccess component
+ Reference<lang::XMultiComponentFactory> xMCF = m_xContext->getServiceManager();
+ validateXRef(xMCF,"ScriptStorageManager::ScriptStorageManager : cannot get service manager");
+ Reference<XInterface> xx = xMCF->createInstanceWithContext(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess"), m_xContext);
+ Reference<ucb::XSimpleFileAccess> xSFA(xx,UNO_QUERY);
+
+ // create a ScriptingStorage using the SimpleFileAccess, the storageID // (from the count), and the URL to the application's shared area
+ Sequence <Any> aArgs(3);
+ OUString base=OUString::createFromAscii( SAL_CONFIGFILE("${$SYSBINDIR/bootstrap"));
+ aArgs[0] <<= xSFA;
+ aArgs[1] <<= count;
+ aArgs[2] <<= xME->expandMacros(base.concat(OUString::createFromAscii("::BaseInstallation}/share")));
+#ifdef _DEBUG
+
+ fprintf(stderr,"creating storage for: %s\n",::rtl::OUStringToOString(xME->expandMacros(base.concat(OUString::createFromAscii("::BaseInstallation}/share"))),RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ xx = xMCF->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.storage.ScriptStorage"), aArgs, m_xContext);
+ OSL_ASSERT(xx.is());
+ xx->acquire();
+ validateXRef(xx,"ScriptStorageManager constructor: Can't create ScriptStorage for share");
+ // and place it in the hash_map. Increment the counter
+ m_ScriptStorageHash[count++]=xx;
+#ifdef _DEBUG
+
+ fprintf(stderr,"\tcreated with ID=%d\n",count-1);
+#endif
+ //Repeat the procedure with the application user area
+ aArgs[1] <<= count;
+ aArgs[2] <<= xME->expandMacros(base.concat(OUString::createFromAscii("::UserInstallation}/user")));
+#ifdef _DEBUG
+
+ fprintf(stderr,"creating storage for: %s\n",::rtl::OUStringToOString(xME->expandMacros(base.concat(OUString::createFromAscii("::UserInstallation}/user"))),RTL_TEXTENCODING_ASCII_US).pData->buffer);
+#endif
+
+ xx = xMCF->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.storage.ScriptStorage"), aArgs, m_xContext);
+ OSL_ASSERT(xx.is());
+ xx->acquire();
+ validateXRef(xx,"ScriptStorageManager constructor: Can't create ScriptStorage for share");
+ m_ScriptStorageHash[count++]=xx;
+#ifdef _DEBUG
+
+ fprintf(stderr,"\tcreated with ID=%d\n",count-1);
+#endif
+
+ }
+ catch (Exception &e)
+ {
+ throw RuntimeException(OUSTR("ScriptStorageManager::ScriptStorageManager: ") + e.Message, Reference< XInterface >());
+ }
+}
+
+//*************************************************************************
+// ScriptStorageManager Destructor
+ScriptStorageManager::~ScriptStorageManager()
+{
+ OSL_TRACE( "< ScriptStorageManager dtor called >\n" );
+ s_moduleCount.modCnt.release( &s_moduleCount.modCnt );
+}
+
+//*************************************************************************
+// This method assumes that the XSimpleFileAccess knows it's on root URL
+// and can be used with relative URLs
+sal_uInt16 SAL_CALL ScriptStorageManager::createScriptStorage( const Reference< ucb::XSimpleFileAccess >& xSFA ) throw (RuntimeException)
+{
+ OSL_TRACE("** ==> ScriptStorageManager in createScriptingStorage\n");
+ validateXRef(xSFA, "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid");
+ Sequence <Any> aArgs(2);
+ aArgs[0] <<= xSFA;
+ aArgs[1] <<= count;
+ Reference<lang::XMultiComponentFactory> xMCF = m_xContext->getServiceManager();
+ validateXRef(xMCF,"ScriptStorageManager::createScriptStorage");
+ Reference<XInterface>xx = xMCF->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.storage.ScriptStorage"), aArgs, m_xContext);
+ OSL_ASSERT(xx.is());
+ m_ScriptStorageHash[count++]=xx;
+#ifdef _DEBUG
+
+ fprintf(stderr,"\tcreated with ID=%d\n",count-1);
+#endif
+
+ return count-1;
+}
+
+//*************************************************************************
+sal_uInt16 SAL_CALL ScriptStorageManager::createScriptStorageWithURI( const Reference< ucb::XSimpleFileAccess >& xSFA, const OUString & stringURI ) throw (RuntimeException)
+{
+ OSL_TRACE("** ==> ScriptStorageManager in createScriptingStorageWithURI\n");
+ validateXRef(xSFA, "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid");
+ Sequence <Any> aArgs(3);
+ aArgs[0] <<= xSFA;
+ aArgs[1] <<= count;
+ aArgs[2] <<= stringURI;
+ Reference<lang::XMultiComponentFactory> xMCF = m_xContext->getServiceManager();
+ validateXRef(xMCF,"ScriptStorageManager::createScriptStorageWithURI");
+ Reference<XInterface> xx = xMCF->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.storage.ScriptStorage"), aArgs, m_xContext);
+ OSL_ASSERT(xx.is());
+ m_ScriptStorageHash[count++]=xx;
+#ifdef _DEBUG
+
+ fprintf(stderr,"\tcreated with ID=%d\n",count-1);
+#endif
+
+ return count-1;
+}
+
+//*************************************************************************
+Reference <XInterface> SAL_CALL ScriptStorageManager::getScriptStorage(sal_uInt16 scriptStorageID)
+throw(RuntimeException)
+{
+ OSL_TRACE("** ==> ScriptStorageManager in getStorageInstance\n");
+ Reference<XInterface> result=m_ScriptStorageHash[scriptStorageID];
+ validateXRef(result, "ScriptStorageManager::getScriptStorage: Cannot get ScriptStorage from ScriptStorageHash");
+ return result;
+}
+
+//*************************************************************************
+OUString SAL_CALL ScriptStorageManager::getImplementationName( )
+throw(RuntimeException)
+{
+ return s_implName;
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL ScriptStorageManager::supportsService( const OUString& serviceName )
+throw(RuntimeException)
+{
+ OUString const * pNames = s_serviceNames.getConstArray();
+ for ( sal_Int32 nPos = s_serviceNames.getLength(); nPos--; )
+ {
+ if (serviceName.equals( pNames[ nPos ] ))
+ {
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ScriptStorageManager::getSupportedServiceNames( )
+throw(RuntimeException)
+{
+ return s_serviceNames;
+}
+
+//*************************************************************************
+void SAL_CALL ScriptStorageManager::disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
+{
+ OSL_TRACE("ScriptStorageManager::disposing started");
+}
+
+//*************************************************************************
+static Reference<XInterface> SAL_CALL ssm_create(
+ const Reference< XComponentContext > & xCompC )
+{
+ return (cppu::OWeakObject *)new ScriptStorageManager( xCompC );
+}
+
+//*************************************************************************
+static Sequence<OUString> ssm_getSupportedServiceNames( )
+SAL_THROW( () )
+{
+ return s_serviceNames;
+}
+
+//*************************************************************************
+static OUString ssm_getImplementationName( )
+SAL_THROW( () )
+{
+ return s_implName;
+}
+//*************************************************************************
+Reference<XInterface> SAL_CALL ss_create( const Reference< XComponentContext > & xCompC );
+//*************************************************************************
+Sequence<OUString> ss_getSupportedServiceNames( ) SAL_THROW( () );
+//*************************************************************************
+OUString ss_getImplementationName( ) SAL_THROW( () );
+//*************************************************************************
+Reference<XInterface> SAL_CALL si_create( const Reference< XComponentContext > & xCompC );
+//*************************************************************************
+Sequence<OUString> si_getSupportedServiceNames( ) SAL_THROW( () );
+//*************************************************************************
+OUString si_getImplementationName( ) SAL_THROW( () );
+//*************************************************************************
+static struct cppu::ImplementationEntry s_entries [] =
+ {
+ {
+ ssm_create, ssm_getImplementationName,
+ ssm_getSupportedServiceNames, cppu::createSingleComponentFactory,
+ &s_moduleCount.modCnt, 0
+ },
+ {
+ ss_create, ss_getImplementationName,
+ ss_getSupportedServiceNames, cppu::createSingleComponentFactory,
+ &s_moduleCount.modCnt, 0
+ },
+ {
+ si_create, si_getImplementationName,
+ si_getSupportedServiceNames, cppu::createSingleComponentFactory,
+ &s_moduleCount.modCnt, 0
+ },
+ { 0, 0, 0, 0, 0, 0 }
+ };
+} // Namespace
+
+//##################################################################################################
+//#### EXPORTED ####################################################################################
+//##################################################################################################
+
+/**
+ * Gives the environment this component belongs to.
+ */
+extern "C"
+{
+ void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv)
+ {
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+
+ /**
+ * This function creates an implementation section in the registry and another subkey
+ *
+ * for each supported service.
+ * @param pServiceManager the service manager
+ * @param pRegistryKey the registry key
+ */
+ sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey)
+ {
+ return ::cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, ::scripting_impl::s_entries);
+ }
+
+ /**
+ * This function is called to get service factories for an implementation.
+ *
+ * @param pImplName name of implementation
+ * @param pServiceManager a service manager, need for component creation
+ * @param pRegistryKey the registry key for this component, need for persistent data
+ * @return a component factory
+ */
+ void * SAL_CALL component_getFactory(const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey)
+ {
+ return ::cppu::component_getFactoryHelper(pImplName, pServiceManager, pRegistryKey, ::scripting_impl::s_entries);
+ }
+}
diff --git a/scripting/source/storage/ScriptStorageManager.hxx b/scripting/source/storage/ScriptStorageManager.hxx
new file mode 100644
index 000000000000..928ad025c8c4
--- /dev/null
+++ b/scripting/source/storage/ScriptStorageManager.hxx
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * $RCSfile: ScriptStorageManager.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:54 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGE_SCRIPTSTORAGEMANAGER_HXX_
+#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGE_SCRIPTSTORAGEMANAGER_HXX_
+
+#include <osl/mutex.hxx>
+#include <hash_map>
+
+#include <cppuhelper/implbase3.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <drafts/com/sun/star/script/framework/scripturi/XScriptURI.hpp>
+#include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp>
+
+namespace scripting_impl
+{
+
+// Define a hash_map used to store the ScriptingStorages key;d by ID
+typedef ::std::hash_map < sal_Int16, ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > > ScriptStorage_hash;
+
+class ScriptStorageManager : public ::cppu::WeakImplHelper3< ::drafts::com::sun::star::script::framework::storage::XScriptStorageManager, ::com::sun::star::lang::XServiceInfo, ::com::sun::star::lang::XEventListener>
+{
+ // to obtain other services if needed
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::osl::Mutex m_mutex;
+ ScriptStorage_hash m_ScriptStorageHash;
+ sal_Int16 count;
+public:
+ ScriptStorageManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext );
+ ~ScriptStorageManager();
+
+
+ // XServiceInfo implementation
+ //======================================================================
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ //----------------------------------------------------------------------
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ //----------------------------------------------------------------------
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+ //======================================================================
+
+ //XScriptStorageManager
+ //======================================================================
+ /**
+ create a ScriptStorage using the XSimpleFileAccess passed as an
+ argument, and return a ID for getting the associated ScriptStorage
+
+ @params xSFA
+ an implementation of XSimpleFileAccess that knows its own base URL
+ and can thus take URLs relative to that base.
+
+ @returns an unsigned short ScriptStorage ID, which can be used in the
+ getScriptStorage method
+ */
+ virtual sal_uInt16 SAL_CALL createScriptStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFA ) throw (::com::sun::star::uno::RuntimeException);
+ //----------------------------------------------------------------------
+ /**
+ create a ScriptStorage using the XSimpleFileAccess, and a string URL
+ and return a ID for getting the associated ScriptStorage
+
+ @params xSFA
+ a standard implementation of XSimpleFileAccess
+
+ @params stringURI
+ a string URI to the head of the script storage
+
+ @returns an unsigned short ScriptStorage ID, which can be used in the
+ getScriptStorage method
+ */
+ virtual sal_uInt16 SAL_CALL createScriptStorageWithURI( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFA, const ::rtl::OUString& stringURI ) throw (::com::sun::star::uno::RuntimeException);
+ //----------------------------------------------------------------------
+ /**
+ get a ScriptStorage component using its scriptStorageID
+
+ @params scriptStorageID
+ the usigned short returned by one of the methods above. ID=0 is
+ reserved for the application/share scripts, and ID=1 is reserved
+ for the application/user scripts
+
+ @returns an XInterface to a component that implements the ScriptStorage
+ service
+ */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getScriptStorage( sal_uInt16 scriptStorageID ) throw (::com::sun::star::uno::RuntimeException);
+ //======================================================================
+
+
+ //XEventListener
+ //======================================================================
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+};
+} // scripting_impl
+
+#endif //_COM_SUN_STAR_SCRIPTING_STORAGE_SCRIPTSTORAGEMANAGER_HXX_
diff --git a/scripting/source/storage/XMLElement.cxx b/scripting/source/storage/XMLElement.cxx
new file mode 100644
index 000000000000..72e4025913d5
--- /dev/null
+++ b/scripting/source/storage/XMLElement.cxx
@@ -0,0 +1,196 @@
+/*************************************************************************
+ *
+ * $RCSfile: XMLElement.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:54 $
+ *
+ * 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 "XMLElement.hxx"
+#include <osl/diagnose.h>
+
+using namespace rtl;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace scripting_impl
+{
+
+//*************************************************************************
+void XMLElement::addAttribute( OUString const & rAttrName, OUString const & rValue )
+SAL_THROW( () )
+{
+ OSL_TRACE("XMLElement::addAttribute\n");
+
+ _attrNames.push_back( rAttrName );
+ _attrValues.push_back( rValue );
+}
+
+//*************************************************************************
+void XMLElement::addSubElement( Reference< xml::sax::XAttributeList > const & xElem )
+SAL_THROW( () )
+{
+ OSL_TRACE("XMLElement::addSubElement\n");
+
+ _subElems.push_back( xElem );
+}
+
+//*************************************************************************
+Reference< xml::sax::XAttributeList > XMLElement::getSubElement( sal_Int32 nIndex )
+SAL_THROW( () )
+{
+ OSL_TRACE("XMLElement::getSubElement\n");
+
+ return _subElems[ (size_t)nIndex ];
+}
+
+//*************************************************************************
+void XMLElement::dumpSubElements( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
+{
+ OSL_TRACE("+++++ XMLElement::dumpSubElement\n");
+
+ for ( size_t nPos = 0; nPos < _subElems.size(); ++nPos )
+ {
+ XMLElement * pElem = static_cast< XMLElement * >( _subElems[ nPos ].get() );
+ pElem->dump( xOut );
+ }
+}
+
+//*************************************************************************
+void XMLElement::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut )
+{
+ OSL_TRACE("XMLElement::dump\n");
+
+ xOut->ignorableWhitespace( OUString() );
+ xOut->startElement( _name, static_cast< xml::sax::XAttributeList * >( this ) );
+ // Write out CDATA
+ if(_chars.getLength() > 0)
+ {
+ xOut->ignorableWhitespace( OUString() );
+ xOut->characters( _chars );
+ }
+ // write sub elements
+ dumpSubElements( xOut );
+ xOut->ignorableWhitespace( OUString() );
+ xOut->endElement( _name );
+}
+
+//*************************************************************************
+// XAttributeList
+sal_Int16 XMLElement::getLength()
+throw (RuntimeException)
+{
+ OSL_TRACE("XMLElement::getLength\n");
+
+ return _attrNames.size();
+}
+
+//*************************************************************************
+OUString XMLElement::getNameByIndex( sal_Int16 nPos )
+throw (RuntimeException)
+{
+ OSL_TRACE("XMLElement::getNameByIndex\n");
+ OSL_ASSERT( (size_t)nPos < _attrNames.size() );
+
+ return _attrNames[ nPos ];
+}
+
+//*************************************************************************
+OUString XMLElement::getTypeByIndex( sal_Int16 nPos )
+throw (RuntimeException)
+{
+ OSL_TRACE("XMLElement::getTypeByIndex\n");
+ OSL_ASSERT( (size_t)nPos < _attrNames.size() );
+
+ // xxx todo
+ return OUString();
+}
+
+//*************************************************************************
+OUString XMLElement::getTypeByName( OUString const & rName )
+throw (RuntimeException)
+{
+ OSL_TRACE("XMLElement::getTypeByName\n");
+ // xxx todo
+ return OUString();
+}
+
+//*************************************************************************
+OUString XMLElement::getValueByIndex( sal_Int16 nPos )
+throw (RuntimeException)
+{
+ OSL_TRACE("XMLElement::getValueByIndex\n");
+ OSL_ASSERT( (size_t)nPos < _attrNames.size() );
+
+ return _attrValues[ nPos ];
+}
+
+//*************************************************************************
+OUString XMLElement::getValueByName( OUString const & rName )
+throw (RuntimeException)
+{
+ OSL_TRACE("XMLElement::getValueByName\n");
+
+ for ( size_t nPos = 0; nPos < _attrNames.size(); ++nPos )
+ {
+ if (_attrNames[ nPos ] == rName)
+ {
+ return _attrValues[ nPos ];
+ }
+ }
+ return OUString();
+}
+
+}
diff --git a/scripting/source/storage/XMLElement.hxx b/scripting/source/storage/XMLElement.hxx
new file mode 100644
index 000000000000..dbee95bd8a8c
--- /dev/null
+++ b/scripting/source/storage/XMLElement.hxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * $RCSfile: XMLElement.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:55 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _SCRIPTING_XML_ELEMENT_HXX_
+#define _SCRIPTING_XML_ELEMENT_HXX_
+
+#include <vector>
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+
+namespace scripting_impl
+{
+
+/*##################################################################################################
+
+ EXPORTING
+
+##################################################################################################*/
+
+//==================================================================================================
+class XMLElement
+ : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XAttributeList >
+{
+public:
+ inline XMLElement( ::rtl::OUString const & name, ::rtl::OUString const & chars )
+ SAL_THROW( () )
+ : _name( name ), _chars( chars )
+ {
+ }
+
+ inline XMLElement( ::rtl::OUString const & name )
+ SAL_THROW( () )
+ : _name( name )
+ {
+ }
+
+ /** Adds a sub element of element.
+
+ @param xElem element reference
+ */
+ void SAL_CALL addSubElement(
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > const & xElem )
+ SAL_THROW( () );
+
+ /** Gets sub element of given index. The index follows order in which sub elements were added.
+
+ @param nIndex index of sub element
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > SAL_CALL getSubElement( sal_Int32 nIndex )
+ SAL_THROW( () );
+
+ /** Adds an attribute to elements.
+
+ @param rAttrName qname of attribute
+ @param rValue value string of element
+ */
+ void SAL_CALL addAttribute( ::rtl::OUString const & rAttrName, ::rtl::OUString const & rValue )
+ SAL_THROW( () );
+
+ /** Gets the tag name (qname) of element.
+
+ @return
+ qname of element
+ */
+ inline ::rtl::OUString SAL_CALL getName() SAL_THROW( () )
+ {
+ return _name;
+ }
+
+ /** Dumps out element (and all sub elements).
+
+ @param xOut document handler to be written to
+ */
+ void SAL_CALL dump(
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut );
+ /** Dumps out sub elements (and all further sub elements).
+
+ @param xOut document handler to be written to
+ */
+ void SAL_CALL dumpSubElements(
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut );
+
+ // XAttributeList
+ virtual sal_Int16 SAL_CALL getLength()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNameByIndex( sal_Int16 nPos )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTypeByIndex( sal_Int16 nPos )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTypeByName( ::rtl::OUString const & rName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getValueByIndex( sal_Int16 nPos )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getValueByName( ::rtl::OUString const & rName )
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ ::rtl::OUString _name;
+
+ ::rtl::OUString _chars;
+
+ ::std::vector< ::rtl::OUString > _attrNames;
+ ::std::vector< ::rtl::OUString > _attrValues;
+
+ ::std::vector< ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > > _subElems;
+};
+
+}
+
+#endif
diff --git a/scripting/source/storage/exports.dxp b/scripting/source/storage/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/scripting/source/storage/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/scripting/source/storage/makefile.mk b/scripting/source/storage/makefile.mk
new file mode 100644
index 000000000000..d09232137efc
--- /dev/null
+++ b/scripting/source/storage/makefile.mk
@@ -0,0 +1,105 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: dfoster $ $Date: 2002-09-20 14:33:56 $
+#
+# 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): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= scripting
+TARGET= storage
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# ------------------------------------------------------------------
+
+.INCLUDE : ..$/cppumaker.mk
+
+SLOFILES=\
+ $(SLO)$/ScriptStorage.obj\
+ $(SLO)$/ScriptInfo.obj\
+ $(SLO)$/ScriptMetadataImporter.obj\
+ $(SLO)$/ScriptElement.obj\
+ $(SLO)$/XMLElement.obj\
+ $(SLO)$/ScriptStorageManager.obj\
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/scripting/source/storage/storage.xml b/scripting/source/storage/storage.xml
new file mode 100644
index 000000000000..1f818ffe158e
--- /dev/null
+++ b/scripting/source/storage/storage.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> storage </module-name>
+ <component-description>
+ <author> </author>
+ <name> drafts.com.sun.star.script.framework.storage.ScriptStorage </name>
+ <description>
+ </description>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> c++ </language>
+ <status value="draft"/>
+ <supported-service> drafts.com.sun.star.script.framework.storage.ScriptingStorage </supported-service>
+ <type> com.sun.star.beans.XPropertySet </type>
+ <type> com.sun.star.uno.Exception </type>
+ <type> com.sun.star.uno.XComponentContext </type>
+ <type> com.sun.star.io.IOException </type>
+ <type> com.sun.star.io.XStream </type>
+ <type> com.sun.star.io.XOutputStream </type>
+ <type> com.sun.star.registry.XRegistryKey </type>
+ <type> drafts.com.sun.star.script.framework.storage.XParcelStore </type>
+ <type> drafts.com.sun.star.script.framework.storage.NoSuchView </type>
+ <type> drafts.com.sun.star.script.framework.storage.ScriptInfoAccessException </type>
+ <type> drafts.com.sun.star.script.framework.storage.XBinding </type>
+ <type> drafts.com.sun.star.script.framework.storage.XBindingStore </type>
+ <type> drafts.com.sun.star.script.framework.storage.XScriptInfo </type>
+ <type> drafts.com.sun.star.script.framework.storage.XNameNode </type>
+ <type> drafts.com.sun.star.script.framework.storage.XNamingAccess </type>
+ <type> drafts.com.sun.star.script.framework.storage.XScriptAccessManager </type>
+ <type> drafts.com.sun.star.script.framework.storage.XScriptImplAccess </type>
+ <type> drafts.com.sun.star.script.framework.storage.XScriptStorageExport </type>
+ <type> drafts.com.sun.star.script.framework.storage.XScriptStore </type>
+ <type> drafts.com.sun.star.script.framework.storage.XParcel </type>
+ <type> com.sun.star.lang.XInitialization </type>
+ <type> drafts.com.sun.star.script.framework.storage.ScriptImplInfo </type>
+ <type> drafts.com.sun.star.script.framework.storage.XScriptInvocationPrep </type>
+ <type> drafts.com.sun.star.script.framework.storage.XParcelInvocationPrep </type>
+ <type> drafts.com.sun.star.script.framework.storage.XScriptStorageManager </type>
+ <type> com.sun.star.xml.sax.XExtendedDocumentHandler </type>
+ <type> com.sun.star.xml.sax.XParser </type>
+ <type> com.sun.star.io.XInputStream </type>
+ <type> com.sun.star.ucb.XSimpleFileAccess2 </type>
+ <type> com.sun.star.xml.sax.SAXException </type>
+ <type> com.sun.star.xml.sax.XAttributeList </type>
+ <type> com.sun.star.io.XActiveDataSource </type>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <runtime-module-dependency> cppuhelper2$(COM) </runtime-module-dependency>
+ <runtime-module-dependency> cppu2 </runtime-module-dependency>
+ <runtime-module-dependency> sal2 </runtime-module-dependency>
+ <runtime-module-dependency> ucb </runtime-module-dependency>
+</module-description>