summaryrefslogtreecommitdiff
path: root/xmlscript/source/xmlmod_imexp
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2001-05-04 08:14:58 +0000
committerDaniel Boelzle <dbo@openoffice.org>2001-05-04 08:14:58 +0000
commit30bcabf7f2e84decb2805af40a42a8967278b2c8 (patch)
treefe7e4bcf55e214e6c03069e7d16c5e9d4685c5ee /xmlscript/source/xmlmod_imexp
parent77e9bfde69fe23d9644eecec69529bb30ea36659 (diff)
separated xmllib/xmlmod from xmldlg, prepared im/export for scrollbar, progressmeter, fixed-line
Diffstat (limited to 'xmlscript/source/xmlmod_imexp')
-rw-r--r--xmlscript/source/xmlmod_imexp/imp_share.hxx228
-rw-r--r--xmlscript/source/xmlmod_imexp/makefile.mk84
-rw-r--r--xmlscript/source/xmlmod_imexp/xmlmod_export.cxx102
-rw-r--r--xmlscript/source/xmlmod_imexp/xmlmod_import.cxx249
4 files changed, 663 insertions, 0 deletions
diff --git a/xmlscript/source/xmlmod_imexp/imp_share.hxx b/xmlscript/source/xmlmod_imexp/imp_share.hxx
new file mode 100644
index 000000000000..9797ea6a370a
--- /dev/null
+++ b/xmlscript/source/xmlmod_imexp/imp_share.hxx
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * $RCSfile: imp_share.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2001-05-04 09:14:57 $
+ *
+ * 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 <vector>
+
+#include <xmlscript/xmldlg_imexp.hxx>
+#include <xmlscript/xmllib_imexp.hxx>
+#include <xmlscript/xmlmod_imexp.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+
+#include <com/sun/star/xml/sax2/XExtendedAttributes.hpp>
+#include <com/sun/star/xml/XImportContext.hpp>
+#include <com/sun/star/xml/XImporter.hpp>
+
+
+using namespace ::rtl;
+using namespace ::std;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace xmlscript
+{
+//
+inline sal_Int32 toInt32( OUString const & rStr ) SAL_THROW( () )
+{
+ sal_Int32 nVal;
+ if (rStr.getLength() > 2 && rStr[ 0 ] == '0' && rStr[ 1 ] == 'x')
+ {
+ nVal = rStr.copy( 2 ).toInt32( 16 );
+ }
+ else
+ {
+ nVal = rStr.toInt32();
+ }
+ return nVal;
+}
+inline bool getBoolAttr(
+ sal_Bool * pRet, OUString const & rAttrName,
+ Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
+{
+ OUString aValue( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aValue.getLength())
+ {
+ if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("true") ))
+ {
+ *pRet = sal_True;
+ return true;
+ }
+ else if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("false") ))
+ {
+ *pRet = sal_False;
+ return true;
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ rAttrName + OUString( RTL_CONSTASCII_USTRINGPARAM(": no boolean value (true|false)!") ),
+ Reference< XInterface >(), Any() );
+ }
+ }
+ return false;
+}
+inline bool getStringAttr(
+ OUString * pRet, OUString const & rAttrName,
+ Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
+{
+ *pRet = xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName );
+ return (pRet->getLength() > 0);
+}
+inline bool getLongAttr(
+ sal_Int32 * pRet, OUString const & rAttrName,
+ Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
+{
+ OUString aValue( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) );
+ if (aValue.getLength())
+ {
+ *pRet = toInt32( aValue );
+ return true;
+ }
+ return false;
+}
+
+
+//==================================================================================================
+// Script module import
+
+//==================================================================================================
+struct ModuleImport
+ : public ::cppu::WeakImplHelper1< xml::XImporter >
+{
+ friend class ModuleElement;
+
+ ModuleDescriptor& mrModuleDesc;
+
+public:
+ inline ModuleImport( ModuleDescriptor& rModuleDesc )
+ SAL_THROW( () )
+ : mrModuleDesc( rModuleDesc ) {}
+ virtual ~ModuleImport()
+ SAL_THROW( () );
+
+ // XImporter
+ virtual void SAL_CALL startDocument()
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endDocument()
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL processingInstruction(
+ OUString const & rTarget, OUString const & rData )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL setDocumentLocator(
+ Reference< xml::sax::XLocator > const & xLocator )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual Reference< xml::XImportContext > SAL_CALL createRootContext(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException);
+};
+
+//==================================================================================================
+class ModuleElement
+ : public ::cppu::WeakImplHelper1< xml::XImportContext >
+{
+protected:
+ ModuleImport * _pImport;
+ ModuleElement * _pParent;
+
+ OUString _aLocalName;
+ Reference< xml::sax2::XExtendedAttributes > _xAttributes;
+
+public:
+ ModuleElement(
+ OUString const & rLocalName,
+ Reference< xml::sax2::XExtendedAttributes > const & xAttributes,
+ ModuleElement * pParent, ModuleImport * pImport )
+ SAL_THROW( () );
+ virtual ~ModuleElement()
+ SAL_THROW( () );
+
+ // XImportContext
+ virtual Reference< xml::XImportContext > SAL_CALL getParent()
+ throw (RuntimeException);
+ virtual OUString SAL_CALL getLocalName()
+ throw (RuntimeException);
+ virtual sal_Int32 SAL_CALL getUid()
+ throw (RuntimeException);
+ virtual Reference< xml::sax2::XExtendedAttributes > SAL_CALL getAttributes()
+ throw (RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace(
+ OUString const & rWhitespaces )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL characters( OUString const & rChars )
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual void SAL_CALL endElement()
+ throw (xml::sax::SAXException, RuntimeException);
+ virtual Reference< xml::XImportContext > SAL_CALL createChildContext(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException);
+};
+
+//==================================================================================================
+
+};
diff --git a/xmlscript/source/xmlmod_imexp/makefile.mk b/xmlscript/source/xmlmod_imexp/makefile.mk
new file mode 100644
index 000000000000..d901e502ea7a
--- /dev/null
+++ b/xmlscript/source/xmlmod_imexp/makefile.mk
@@ -0,0 +1,84 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: dbo $ $Date: 2001-05-04 09:14:57 $
+#
+# 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=xmlscript
+TARGET=xmlmod_imexp
+NO_BSYMBOLIC=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+#-----------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/xmlmod_import.obj \
+ $(SLO)$/xmlmod_export.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/target.pmk
+.INCLUDE : target.mk
diff --git a/xmlscript/source/xmlmod_imexp/xmlmod_export.cxx b/xmlscript/source/xmlmod_imexp/xmlmod_export.cxx
new file mode 100644
index 000000000000..fbad35434a2c
--- /dev/null
+++ b/xmlscript/source/xmlmod_imexp/xmlmod_export.cxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlmod_export.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2001-05-04 09:14:57 $
+ *
+ * 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 <xmlscript/xmlmod_imexp.hxx>
+#include <xmlscript/xml_helper.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star;
+using namespace rtl;
+
+namespace xmlscript
+{
+
+//==================================================================================================
+
+SAL_DLLEXPORT void
+SAL_CALL exportScriptModule(
+ Reference< xml::sax::XExtendedDocumentHandler > const & xOut,
+ const ModuleDescriptor& rMod )
+ SAL_THROW( (Exception) )
+{
+ xOut->startDocument();
+
+ OUString aModuleName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":module") );
+ XMLElement* pModElement = new XMLElement( aModuleName );
+ Reference< xml::sax::XAttributeList > xAttributes( pModElement );
+
+ pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_SCRIPT_PREFIX) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ) );
+
+ pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":name") ),
+ rMod.aName );
+ pModElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ),
+ rMod.aLanguage );
+
+ xOut->ignorableWhitespace( OUString() );
+ xOut->startElement( aModuleName, xAttributes );
+ xOut->characters( rMod.aCode );
+ xOut->endElement( aModuleName );
+ xOut->endDocument();
+}
+
+};
+
diff --git a/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx
new file mode 100644
index 000000000000..58e179957c86
--- /dev/null
+++ b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx
@@ -0,0 +1,249 @@
+/*************************************************************************
+ *
+ * $RCSfile: xmlmod_import.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2001-05-04 09:14:57 $
+ *
+ * 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 "imp_share.hxx"
+
+#include <osl/diagnose.h>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <xmlscript/xml_import.hxx>
+#include <comphelper/processfactory.hxx>
+
+
+namespace xmlscript
+{
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+Reference< xml::XImportContext > ModuleElement::getParent()
+ throw (RuntimeException)
+{
+ return static_cast< xml::XImportContext * >( _pParent );
+}
+//__________________________________________________________________________________________________
+OUString ModuleElement::getLocalName()
+ throw (RuntimeException)
+{
+ return _aLocalName;
+}
+//__________________________________________________________________________________________________
+sal_Int32 ModuleElement::getUid()
+ throw (RuntimeException)
+{
+ return XMLNS_DIALOGS_UID;
+}
+//__________________________________________________________________________________________________
+Reference< xml::sax2::XExtendedAttributes > ModuleElement::getAttributes()
+ throw (RuntimeException)
+{
+ return _xAttributes;
+}
+//__________________________________________________________________________________________________
+void ModuleElement::ignorableWhitespace(
+ OUString const & rWhitespaces )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // not used
+}
+//__________________________________________________________________________________________________
+void ModuleElement::characters( OUString const & rChars )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ _pImport->mrModuleDesc.aCode += rChars;
+}
+//__________________________________________________________________________________________________
+void ModuleElement::endElement()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+}
+//__________________________________________________________________________________________________
+Reference< xml::XImportContext > ModuleElement::createChildContext(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("unexpected element!") ),
+ Reference< XInterface >(), Any() );
+}
+
+//__________________________________________________________________________________________________
+ModuleElement::ModuleElement(
+ OUString const & rLocalName,
+ Reference< xml::sax2::XExtendedAttributes > const & xAttributes,
+ ModuleElement * pParent, ModuleImport * pImport )
+ SAL_THROW( () )
+ : _pImport( pImport )
+ , _pParent( pParent )
+ , _aLocalName( rLocalName )
+ , _xAttributes( xAttributes )
+{
+ _pImport->acquire();
+
+ if (_pParent)
+ {
+ _pParent->acquire();
+ }
+}
+//__________________________________________________________________________________________________
+ModuleElement::~ModuleElement()
+ SAL_THROW( () )
+{
+ _pImport->release();
+
+ if (_pParent)
+ {
+ _pParent->release();
+ }
+
+#ifdef DEBUG
+ OString aStr( OUStringToOString( _aLocalName, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "ModuleElement::~ModuleElement(): %s\n", aStr.getStr() );
+#endif
+}
+
+//##################################################################################################
+
+// XImporter
+//__________________________________________________________________________________________________
+void ModuleImport::startDocument()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // ignored
+}
+//__________________________________________________________________________________________________
+void ModuleImport::endDocument()
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // ignored
+}
+//__________________________________________________________________________________________________
+void ModuleImport::processingInstruction(
+ OUString const & rTarget, OUString const & rData )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // ignored for now: xxx todo
+}
+//__________________________________________________________________________________________________
+void ModuleImport::setDocumentLocator(
+ Reference< xml::sax::XLocator > const & xLocator )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ // ignored for now: xxx todo
+}
+//__________________________________________________________________________________________________
+Reference< xml::XImportContext > ModuleImport::createRootContext(
+ sal_Int32 nUid, OUString const & rLocalName,
+ Reference< xml::sax2::XExtendedAttributes > const & xAttributes )
+ throw (xml::sax::SAXException, RuntimeException)
+{
+ if (XMLNS_SCRIPT_UID != nUid)
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ),
+ Reference< XInterface >(), Any() );
+ }
+ // window
+ else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("module") ))
+ {
+ mrModuleDesc.aName = xAttributes->getValueByUidName(
+ XMLNS_LIBRARY_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("name") ) );
+ mrModuleDesc.aLanguage = xAttributes->getValueByUidName(
+ XMLNS_XLINK_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("language") ) );
+
+ return new ModuleElement( rLocalName, xAttributes, 0, this );
+ }
+ else
+ {
+ throw xml::sax::SAXException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("illegal root element (expected module) given: ") ) +
+ rLocalName, Reference< XInterface >(), Any() );
+ }
+}
+//__________________________________________________________________________________________________
+ModuleImport::~ModuleImport()
+ SAL_THROW( () )
+{
+#ifdef DEBUG
+ OSL_TRACE( "ModuleImport::~ModuleImport().\n" );
+#endif
+}
+
+//##################################################################################################
+
+SAL_DLLEXPORT Reference< xml::sax::XDocumentHandler >
+SAL_CALL importScriptModule( ModuleDescriptor& rMod )
+ SAL_THROW( (Exception) )
+{
+ NameSpaceUid arNamespaceUids[] = {
+ NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ), XMLNS_SCRIPT_UID ),
+ };
+
+ return ::xmlscript::createDocumentHandler(
+ arNamespaceUids, sizeof(arNamespaceUids) / sizeof(NameSpaceUid),
+ -1 /* unknown namespace id */,
+ static_cast< xml::XImporter * >( new ModuleImport( rMod ) ) );
+}
+
+};
+
+