diff options
-rw-r--r-- | xmlscript/dtd/dialog.dtd | 58 | ||||
-rw-r--r-- | xmlscript/inc/xmlscript/xmldlg_imexp.hxx | 13 | ||||
-rw-r--r-- | xmlscript/inc/xmlscript/xmllib_imexp.hxx | 16 | ||||
-rw-r--r-- | xmlscript/inc/xmlscript/xmlmod_imexp.hxx | 12 | ||||
-rw-r--r-- | xmlscript/inc/xmlscript/xmlns.h | 80 | ||||
-rw-r--r-- | xmlscript/prj/d.lst | 1 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/imp_share.hxx | 38 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx | 6 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_export.cxx | 106 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx | 208 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_import.cxx | 210 | ||||
-rw-r--r-- | xmlscript/test/imexp.cxx | 85 | ||||
-rw-r--r-- | xmlscript/test/test.xml | 6 |
13 files changed, 538 insertions, 301 deletions
diff --git a/xmlscript/dtd/dialog.dtd b/xmlscript/dtd/dialog.dtd index 1a67e03d18a4..485382935f45 100644 --- a/xmlscript/dtd/dialog.dtd +++ b/xmlscript/dtd/dialog.dtd @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - $Id: dialog.dtd,v 1.15 2001-07-30 17:18:41 dbo Exp $ + $Id: dialog.dtd,v 1.16 2001-08-07 10:55:46 dbo Exp $ The Contents of this file are made available subject to the terms of either of the following licenses @@ -72,6 +72,11 @@ dlg:help-url CDATA #IMPLIED "> +<!ENTITY % event "(script:event| + script:listener-event| + dlg:event + )"> + <!ENTITY % control "(dlg:bulletinboard| dlg:button| dlg:checkbox| @@ -93,7 +98,7 @@ dlg:scrollbar )"> -<!ELEMENT dlg:window (dlg:styles*, dlg:event*, dlg:bulletinboard*)> +<!ELEMENT dlg:window (dlg:styles*, (%event;)*, dlg:bulletinboard*)> <!ATTLIST dlg:window dlg:id CDATA #REQUIRED dlg:left %numeric; #IMPLIED dlg:top %numeric; #IMPLIED @@ -106,6 +111,7 @@ dlg:help-text CDATA #IMPLIED dlg:help-url CDATA #IMPLIED xmlns:dlg CDATA #FIXED "http://openoffice.org/2000/dialog" + xmlns:script CDATA #FIXED "http://openoffice.org/2000/script" > <!ELEMENT dlg:styles (dlg:style+)> @@ -134,6 +140,21 @@ dlg:font-type (raster|device|scalable) #IMPLIED > +<!ELEMENT script:event EMPTY> +<!ATTLIST script:event script:location CDATA #IMPLIED + script:language CDATA #REQUIRED + script:macro-name CDATA #REQUIRED + script:event-name CDATA #REQUIRED + > +<!ELEMENT script:listener-event EMPTY> +<!ATTLIST script:listener-event script:location CDATA #IMPLIED + script:language CDATA #REQUIRED + script:macro-name CDATA #REQUIRED + script:listener-type CDATA #REQUIRED + script:listener-method CDATA #REQUIRED + script:listener-param CDATA #IMPLIED + > +<!-- deprecated --> <!ELEMENT dlg:event EMPTY> <!ATTLIST dlg:event dlg:listener-type CDATA #REQUIRED dlg:event-method CDATA #REQUIRED @@ -141,20 +162,21 @@ dlg:script-code CDATA #IMPLIED dlg:param CDATA #IMPLIED > +<!-- /deprecated --> <!ELEMENT dlg:bulletinboard ((%control;)*)> <!ATTLIST dlg:bulletinboard dlg:left %numeric; #IMPLIED dlg:top %numeric; #IMPLIED > -<!ELEMENT dlg:button (dlg:event*)> +<!ELEMENT dlg:button ((%event;)*)> <!ATTLIST dlg:button %default-attributes; dlg:value CDATA #IMPLIED dlg:default %boolean; #IMPLIED dlg:tabstop %boolean; #IMPLIED > -<!ELEMENT dlg:checkbox (dlg:event*)> +<!ELEMENT dlg:checkbox ((%event;)*)> <!ATTLIST dlg:checkbox %default-attributes; dlg:value CDATA #IMPLIED dlg:checked %boolean; #IMPLIED @@ -162,7 +184,7 @@ dlg:tabstop %boolean; #IMPLIED > -<!ELEMENT dlg:combobox (dlg:menupopup?, dlg:event*)> +<!ELEMENT dlg:combobox (dlg:menupopup?, (%event;)*)> <!ATTLIST dlg:combobox %default-attributes; dlg:tabstop %boolean; #IMPLIED dlg:readonly %boolean; #IMPLIED @@ -173,7 +195,7 @@ dlg:value CDATA #IMPLIED > -<!ELEMENT dlg:menulist (dlg:menupopup?, dlg:event*)> +<!ELEMENT dlg:menulist (dlg:menupopup?, (%event;)*)> <!ATTLIST dlg:menulist %default-attributes; dlg:tabstop %boolean; #IMPLIED dlg:spin %boolean; #IMPLIED @@ -188,7 +210,7 @@ > <!ELEMENT dlg:radiogroup (dlg:radio+)> -<!ELEMENT dlg:radio (dlg:event*)> +<!ELEMENT dlg:radio ((%event;)*)> <!ATTLIST dlg:radio %default-attributes; dlg:value CDATA #IMPLIED dlg:checked %boolean; #IMPLIED @@ -210,7 +232,7 @@ dlg:value CDATA #IMPLIED > -<!ELEMENT dlg:textfield (dlg:event*)> +<!ELEMENT dlg:textfield ((%event;)*)> <!ATTLIST dlg:textfield %default-attributes; dlg:tabstop %boolean; #IMPLIED dlg:align (left|center|right|none) #IMPLIED @@ -224,18 +246,18 @@ dlg:value CDATA #IMPLIED > -<!ELEMENT dlg:img (dlg:event*)> +<!ELEMENT dlg:img ((%event;)*)> <!ATTLIST dlg:img %default-attributes; dlg:src CDATA #IMPLIED > -<!ELEMENT dlg:filecontrol (dlg:event*)> +<!ELEMENT dlg:filecontrol ((%event;)*)> <!ATTLIST dlg:filecontrol %default-attributes; dlg:tabstop %boolean; #IMPLIED dlg:value CDATA #IMPLIED > -<!ELEMENT dlg:currencyfield (dlg:event*)> +<!ELEMENT dlg:currencyfield ((%event;)*)> <!ATTLIST dlg:currencyfield %default-attributes; dlg:tabstop %boolean; #IMPLIED dlg:readonly %boolean; #IMPLIED @@ -250,7 +272,7 @@ dlg:spin %boolean; #IMPLIED > -<!ELEMENT dlg:datefield (dlg:event*)> +<!ELEMENT dlg:datefield ((%event;)*)> <!ATTLIST dlg:datefield %default-attributes; dlg:tabstop %boolean; #IMPLIED dlg:readonly %boolean; #IMPLIED @@ -262,7 +284,7 @@ dlg:spin %boolean; #IMPLIED > -<!ELEMENT dlg:numericfield (dlg:event*)> +<!ELEMENT dlg:numericfield ((%event;)*)> <!ATTLIST dlg:numericfield %default-attributes; dlg:tabstop %boolean; #IMPLIED dlg:readonly %boolean; #IMPLIED @@ -276,7 +298,7 @@ dlg:spin %boolean; #IMPLIED > -<!ELEMENT dlg:timefield (dlg:event*)> +<!ELEMENT dlg:timefield ((%event;)*)> <!ATTLIST dlg:timefield %default-attributes; dlg:tabstop %boolean; #IMPLIED dlg:readonly %boolean; #IMPLIED @@ -288,7 +310,7 @@ dlg:spin %boolean; #IMPLIED > -<!ELEMENT dlg:patternfield (dlg:event*)> +<!ELEMENT dlg:patternfield ((%event;)*)> <!ATTLIST dlg:patternfield %default-attributes; dlg:tabstop %boolean; #IMPLIED dlg:readonly %boolean; #IMPLIED @@ -298,13 +320,13 @@ dlg:literal-mask CDATA #IMPLIED > -<!ELEMENT dlg:fixedline (dlg:event*)> +<!ELEMENT dlg:fixedline ((%event;)*)> <!ATTLIST dlg:fixedline %default-attributes; dlg:align (horizontal|vertical) #IMPLIED dlg:value CDATA #IMPLIED > -<!ELEMENT dlg:scrollbar (dlg:event*)> +<!ELEMENT dlg:scrollbar ((%event;)*)> <!ATTLIST dlg:scrollbar %default-attributes; dlg:align (horizontal|vertical) #IMPLIED dlg:curpos %numeric; #IMPLIED @@ -314,7 +336,7 @@ dlg:visible-size %numeric; #IMPLIED > -<!ELEMENT dlg:progressmeter (dlg:event*)> +<!ELEMENT dlg:progressmeter ((%event;)*)> <!ATTLIST dlg:progressmeter %default-attributes; dlg:value %numeric; #IMPLIED dlg:value-min %numeric; #IMPLIED diff --git a/xmlscript/inc/xmlscript/xmldlg_imexp.hxx b/xmlscript/inc/xmlscript/xmldlg_imexp.hxx index 625074dfd42b..c3bab32c2b4e 100644 --- a/xmlscript/inc/xmlscript/xmldlg_imexp.hxx +++ b/xmlscript/inc/xmlscript/xmldlg_imexp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_imexp.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: dbo $ $Date: 2001-03-28 10:50:35 $ + * last change: $Author: dbo $ $Date: 2001-08-07 10:55:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,15 +71,14 @@ #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> #endif +#ifndef _XMLSCRIPT_XMLNS_H_ +#include <xmlscript/xmlns.h> +#endif + namespace xmlscript { -#define XMLNS_DIALOGS_URI "http://openoffice.org/2000/dialog" -#define XMLNS_DIALOGS_UID 1 -#define XMLNS_DIALOGS_PREFIX "dlg" - - //================================================================================================== void SAL_CALL exportDialogModel( ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut, diff --git a/xmlscript/inc/xmlscript/xmllib_imexp.hxx b/xmlscript/inc/xmlscript/xmllib_imexp.hxx index f5f0bb8306b5..7cf7dc9051b1 100644 --- a/xmlscript/inc/xmlscript/xmllib_imexp.hxx +++ b/xmlscript/inc/xmlscript/xmllib_imexp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmllib_imexp.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: ab $ $Date: 2001-07-02 12:00:13 $ + * last change: $Author: dbo $ $Date: 2001-08-07 10:55:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,18 +68,14 @@ #include <com/sun/star/uno/Sequence.hxx> #endif +#ifndef _XMLSCRIPT_XMLNS_H_ +#include <xmlscript/xmlns.h> +#endif + namespace xmlscript { -#define XMLNS_LIBRARY_URI "http://openoffice.org/2000/library" -#define XMLNS_LIBRARY_UID 1 -#define XMLNS_LIBRARY_PREFIX "library" - -#define XMLNS_XLINK_URI "http://www.w3.org/1999/xlink" -#define XMLNS_XLINK_UID 2 -#define XMLNS_XLINK_PREFIX "xlink" - //================================================================================================== // Library container export diff --git a/xmlscript/inc/xmlscript/xmlmod_imexp.hxx b/xmlscript/inc/xmlscript/xmlmod_imexp.hxx index a57d855ecaf3..897f19257485 100644 --- a/xmlscript/inc/xmlscript/xmlmod_imexp.hxx +++ b/xmlscript/inc/xmlscript/xmlmod_imexp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlmod_imexp.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: dbo $ $Date: 2001-04-04 14:35:07 $ + * last change: $Author: dbo $ $Date: 2001-08-07 10:55:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,14 +68,14 @@ #include <com/sun/star/uno/Sequence.hxx> #endif +#ifndef _XMLSCRIPT_XMLNS_H_ +#include <xmlscript/xmlns.h> +#endif + namespace xmlscript { -#define XMLNS_SCRIPT_URI "http://openoffice.org/2000/script" -#define XMLNS_SCRIPT_UID 1 -#define XMLNS_SCRIPT_PREFIX "script" - //================================================================================================== // Script module import/export diff --git a/xmlscript/inc/xmlscript/xmlns.h b/xmlscript/inc/xmlscript/xmlns.h new file mode 100644 index 000000000000..a40afd98af25 --- /dev/null +++ b/xmlscript/inc/xmlscript/xmlns.h @@ -0,0 +1,80 @@ +/************************************************************************* + * + * $RCSfile: xmlns.h,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dbo $ $Date: 2001-08-07 10:55:46 $ + * + * 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 _XMLSCRIPT_XMLNS_H_ +#define _XMLSCRIPT_XMLNS_H_ + +#define XMLNS_DIALOGS_URI "http://openoffice.org/2000/dialog" +#define XMLNS_DIALOGS_UID 1 +#define XMLNS_DIALOGS_PREFIX "dlg" + +#define XMLNS_SCRIPT_URI "http://openoffice.org/2000/script" +#define XMLNS_SCRIPT_UID 2 +#define XMLNS_SCRIPT_PREFIX "script" + +#define XMLNS_LIBRARY_URI "http://openoffice.org/2000/library" +#define XMLNS_LIBRARY_UID 3 +#define XMLNS_LIBRARY_PREFIX "library" + +#define XMLNS_XLINK_URI "http://www.w3.org/1999/xlink" +#define XMLNS_XLINK_UID 4 +#define XMLNS_XLINK_PREFIX "xlink" + +#endif diff --git a/xmlscript/prj/d.lst b/xmlscript/prj/d.lst index 8c6ef69be368..c3fb0ec9a4c9 100644 --- a/xmlscript/prj/d.lst +++ b/xmlscript/prj/d.lst @@ -8,6 +8,7 @@ mkdir: %_DEST%\inc\xmlscript ..\inc\xmlscript\xmldlg_imexp.hxx %_DEST%\inc%_EXT%\xmlscript\xmldlg_imexp.hxx ..\inc\xmlscript\xmllib_imexp.hxx %_DEST%\inc%_EXT%\xmlscript\xmllib_imexp.hxx ..\inc\xmlscript\xmlmod_imexp.hxx %_DEST%\inc%_EXT%\xmlscript\xmlmod_imexp.hxx +..\inc\xmlscript\xmlns.h %_DEST%\inc%_EXT%\xmlscript\xmlns.h ..\dtd\*.dtd %_DEST%\bin%_EXT%\*.dtd diff --git a/xmlscript/source/xmldlg_imexp/imp_share.hxx b/xmlscript/source/xmldlg_imexp/imp_share.hxx index 62f06bc9f629..c10d9a541490 100644 --- a/xmlscript/source/xmldlg_imexp/imp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx @@ -2,9 +2,9 @@ * * $RCSfile: imp_share.hxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: dbo $ $Date: 2001-05-04 13:17:40 $ + * last change: $Author: dbo $ $Date: 2001-08-07 10:55:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,9 +101,10 @@ inline sal_Int32 toInt32( OUString const & rStr ) SAL_THROW( () ) } inline bool getBoolAttr( sal_Bool * pRet, OUString const & rAttrName, - Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + sal_Int32 nUid = XMLNS_DIALOGS_UID ) { - OUString aValue( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) ); + OUString aValue( xAttributes->getValueByUidName( nUid, rAttrName ) ); if (aValue.getLength()) { if (aValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("true") )) @@ -127,16 +128,18 @@ inline bool getBoolAttr( } inline bool getStringAttr( OUString * pRet, OUString const & rAttrName, - Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + sal_Int32 nUid = XMLNS_DIALOGS_UID ) { - *pRet = xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ); + *pRet = xAttributes->getValueByUidName( nUid, rAttrName ); return (pRet->getLength() > 0); } inline bool getLongAttr( sal_Int32 * pRet, OUString const & rAttrName, - Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) + Reference< xml::sax2::XExtendedAttributes > const & xAttributes, + sal_Int32 nUid = XMLNS_DIALOGS_UID ) { - OUString aValue( xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, rAttrName ) ); + OUString aValue( xAttributes->getValueByUidName( nUid, rAttrName ) ); if (aValue.getLength()) { *pRet = toInt32( aValue ); @@ -201,12 +204,13 @@ protected: DialogImport * _pImport; ElementBase * _pParent; + sal_Int32 _nUid; OUString _aLocalName; Reference< xml::sax2::XExtendedAttributes > _xAttributes; public: ElementBase( - OUString const & rLocalName, + sal_Int32 nUid, OUString const & rLocalName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes, ElementBase * pParent, DialogImport * pImport ) SAL_THROW( () ); @@ -250,7 +254,7 @@ public: Reference< xml::sax2::XExtendedAttributes > const & xAttributes, ElementBase * pParent, DialogImport * pImport ) SAL_THROW( () ) - : ElementBase( rLocalName, xAttributes, pParent, pImport ) + : ElementBase( XMLNS_DIALOGS_UID, rLocalName, xAttributes, pParent, pImport ) {} }; //================================================================================================== @@ -289,7 +293,7 @@ public: Reference< xml::sax2::XExtendedAttributes > const & xAttributes, ElementBase * pParent, DialogImport * pImport ) SAL_THROW( () ) - : ElementBase( rLocalName, xAttributes, pParent, pImport ) + : ElementBase( XMLNS_DIALOGS_UID, rLocalName, xAttributes, pParent, pImport ) , _inited( 0 ) , _hasValue( 0 ) {} @@ -314,7 +318,7 @@ public: Reference< xml::sax2::XExtendedAttributes > const & xAttributes, ElementBase * pParent, DialogImport * pImport ) SAL_THROW( () ) - : ElementBase( rLocalName, xAttributes, pParent, pImport ) + : ElementBase( XMLNS_DIALOGS_UID, rLocalName, xAttributes, pParent, pImport ) {} }; @@ -327,14 +331,14 @@ class ControlElement protected: sal_Int32 _nBasePosX, _nBasePosY; - vector< Reference< xml::sax2::XExtendedAttributes > > _events; + vector< Reference< xml::XImportContext > > _events; OUString getControlId( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); Reference< xml::XImportContext > getStyle( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); public: - vector< Reference< xml::sax2::XExtendedAttributes > > const * getEvents() SAL_THROW( () ) + vector< Reference< xml::XImportContext > > const * getEvents() SAL_THROW( () ) { return &_events; } ControlElement( @@ -358,7 +362,7 @@ public: { return _xControlModel; } void importEvents( - vector< Reference< xml::sax2::XExtendedAttributes > > const & rEvents ); + vector< Reference< xml::XImportContext > > const & rEvents ); bool importStringProperty( OUString const & rPropName, OUString const & rAttrName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes ); @@ -441,11 +445,11 @@ public: throw (xml::sax::SAXException, RuntimeException); inline EventElement( - OUString const & rLocalName, + sal_Int32 nUid, OUString const & rLocalName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes, ElementBase * pParent, DialogImport * pImport ) SAL_THROW( () ) - : ElementBase( rLocalName, xAttributes, pParent, pImport ) + : ElementBase( nUid, rLocalName, xAttributes, pParent, pImport ) {} }; //================================================================================================== diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx index 265fd7239bf5..24102557fd88 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_expmodels.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: tbe $ $Date: 2001-05-08 11:48:13 $ + * last change: $Author: dbo $ $Date: 2001-08-07 10:55:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -769,6 +769,8 @@ void ElementDescriptor::readDialogModel( StyleBag * all_styles ) // collect elements addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_DIALOGS_PREFIX) ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_URI) ) ); + addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_SCRIPT_PREFIX) ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ) ); readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":id") ) ); diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx index b3131895baa5..b28b35006ec3 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_export.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: ab $ $Date: 2001-05-22 14:04:41 $ + * last change: $Author: dbo $ $Date: 2001-08-07 10:55:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -722,6 +722,15 @@ void ElementDescriptor::readDefaults() readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("HelpURL") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":help-url") ) ); } + +struct StringTriple +{ + char const * first; + char const * second; + char const * third; +}; +extern StringTriple const * const g_pEventTranslations; + //__________________________________________________________________________________________________ void ElementDescriptor::readEvents() SAL_THROW( (Exception) ) @@ -739,37 +748,88 @@ void ElementDescriptor::readEvents() script::ScriptEventDescriptor descr; if (xEvents->getByName( pNames[ nPos ] ) >>= descr) { - ElementDescriptor * pElem = new ElementDescriptor( - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":event") ) ); - Reference< xml::sax::XAttributeList > xElem( pElem ); - OSL_ENSURE( descr.ListenerType.getLength() > 0 && - descr.EventMethod.getLength() > 0, - "### invalid listener/ event method descr!" ); - pElem->addAttribute( - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":listener-type") ), - descr.ListenerType ); - pElem->addAttribute( - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":event-method") ), - descr.EventMethod ); - if (descr.ScriptType.getLength()) + descr.EventMethod.getLength() > 0 && + descr.ScriptCode.getLength() > 0 && + descr.ScriptType.getLength() > 0, + "### invalid event descr!" ); + + OUString aEventName; + + if (! descr.AddListenerParam.getLength()) + { + // detection of event-name + OString listenerType( OUStringToOString( descr.ListenerType, RTL_TEXTENCODING_ASCII_US ) ); + OString eventMethod( OUStringToOString( descr.EventMethod, RTL_TEXTENCODING_ASCII_US ) ); + StringTriple const * p = g_pEventTranslations; + while (p->first) + { + if (0 == ::rtl_str_compare( p->second, eventMethod.getStr() ) && + 0 == ::rtl_str_compare( p->first, listenerType.getStr() )) + { + aEventName = OUString( p->third, ::rtl_str_getLength( p->third ), RTL_TEXTENCODING_ASCII_US ); + break; + } + ++p; + } + } + + ElementDescriptor * pElem; + Reference< xml::sax::XAttributeList > xElem; + + if (aEventName.getLength()) // script:event { + pElem = new ElementDescriptor( + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event") ) ); + xElem = pElem; + pElem->addAttribute( - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":script-type") ), - descr.ScriptType ); + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":event-name") ), + aEventName ); } - if (descr.ScriptCode.getLength()) + else // script:listener-event { + pElem = new ElementDescriptor( + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-event") ) ); + xElem = pElem; + pElem->addAttribute( - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":script-code") ), - descr.ScriptCode ); + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-type") ), + descr.ListenerType ); + pElem->addAttribute( + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-method") ), + descr.EventMethod ); + + if (descr.AddListenerParam.getLength()) + { + pElem->addAttribute( + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":listener-param") ), + descr.AddListenerParam ); + } } - if (descr.AddListenerParam.getLength()) + + // separate optional location + sal_Int32 nIndex = descr.ScriptCode.indexOf( (sal_Unicode)':' ); + if (nIndex >= 0) { pElem->addAttribute( - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":param") ), - descr.AddListenerParam ); + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":location") ), + descr.ScriptCode.copy( 0, nIndex ) ); + pElem->addAttribute( + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ), + descr.ScriptCode.copy( nIndex +1 ) ); } + else + { + pElem->addAttribute( + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":macro-name") ), + descr.ScriptCode ); + } + + // language + pElem->addAttribute( + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_PREFIX ":language") ), + descr.ScriptType ); addSubElement( xElem ); } diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx index 561c4dd06403..e78898bb9d10 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_impmodels.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: tbe $ $Date: 2001-05-08 11:48:31 $ + * last change: $Author: dbo $ $Date: 2001-08-07 10:55:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,6 +70,16 @@ using namespace ::com::sun::star::uno; namespace xmlscript { +//-------------------------------------------------------------------------------------------------- +static inline bool isEventElement( sal_Int32 nUid, OUString const & rLocalName ) throw () +{ + return ((XMLNS_SCRIPT_UID == nUid && + (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ) || + rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("listener-event") ))) || + (XMLNS_DIALOGS_UID == nUid && + rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ))); +} + // progessmeter //__________________________________________________________________________________________________ Reference< xml::XImportContext > ProgressBarElement::createChildContext( @@ -77,16 +87,10 @@ Reference< xml::XImportContext > ProgressBarElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -135,16 +139,10 @@ Reference< xml::XImportContext > ScrollBarElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -200,16 +198,10 @@ Reference< xml::XImportContext > FixedLineElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -254,16 +246,10 @@ Reference< xml::XImportContext > PatternFieldElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -322,16 +308,10 @@ Reference< xml::XImportContext > TimeFieldElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -396,16 +376,10 @@ Reference< xml::XImportContext > NumericFieldElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -476,16 +450,10 @@ Reference< xml::XImportContext > DateFieldElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -550,16 +518,10 @@ Reference< xml::XImportContext > CurrencyFieldElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -633,16 +595,10 @@ Reference< xml::XImportContext > FileControlElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -689,16 +645,10 @@ Reference< xml::XImportContext > ImageControlElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -740,16 +690,10 @@ Reference< xml::XImportContext > TextElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -799,16 +743,10 @@ Reference< xml::XImportContext > TextFieldElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -886,7 +824,12 @@ Reference< xml::XImportContext > TitledBoxElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) + // event + if (isEventElement( nUid, rLocalName )) + { + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); + } + else if (XMLNS_DIALOGS_UID != nUid) { throw xml::sax::SAXException( OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), @@ -897,7 +840,7 @@ Reference< xml::XImportContext > TitledBoxElement::createChildContext( { getStringAttr( &_label, OUString( RTL_CONSTASCII_USTRINGPARAM("value") ), xAttributes ); - return new ElementBase( rLocalName, xAttributes, this, _pImport ); + return new ElementBase( XMLNS_DIALOGS_UID, rLocalName, xAttributes, this, _pImport ); } // radio else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("radio") )) @@ -909,11 +852,6 @@ Reference< xml::XImportContext > TitledBoxElement::createChildContext( _radios.push_back( xRet ); return xRet; } - // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) - { - return new EventElement( rLocalName, xAttributes, this, _pImport ); - } else { return BulletinBoardElement::createChildContext( nUid, rLocalName, xAttributes ); @@ -996,16 +934,10 @@ Reference< xml::XImportContext > RadioElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -1123,7 +1055,7 @@ Reference< xml::XImportContext > MenuPopupElement::createChildContext( _itemSelected.push_back( _itemValues.size() -1 ); } } - return new ElementBase( rLocalName, xAttributes, this, _pImport ); + return new ElementBase( XMLNS_DIALOGS_UID, rLocalName, xAttributes, this, _pImport ); } else { @@ -1164,7 +1096,12 @@ Reference< xml::XImportContext > MenuListElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) + // event + if (isEventElement( nUid, rLocalName )) + { + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); + } + else if (XMLNS_DIALOGS_UID != nUid) { throw xml::sax::SAXException( OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), @@ -1176,15 +1113,10 @@ Reference< xml::XImportContext > MenuListElement::createChildContext( _popup = new MenuPopupElement( rLocalName, xAttributes, this, _pImport ); return _popup; } - // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) - { - return new EventElement( rLocalName, xAttributes, this, _pImport ); - } else { throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("expected event or menupopup element!") ), Reference< XInterface >(), Any() ); } } @@ -1241,7 +1173,12 @@ Reference< xml::XImportContext > ComboBoxElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) + // event + if (isEventElement( nUid, rLocalName )) + { + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); + } + else if (XMLNS_DIALOGS_UID != nUid) { throw xml::sax::SAXException( OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), @@ -1253,15 +1190,10 @@ Reference< xml::XImportContext > ComboBoxElement::createChildContext( _popup = new MenuPopupElement( rLocalName, xAttributes, this, _pImport ); return _popup; } - // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) - { - return new EventElement( rLocalName, xAttributes, this, _pImport ); - } else { throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("expected event element!") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("expected event or menupopup element!") ), Reference< XInterface >(), Any() ); } } @@ -1326,16 +1258,10 @@ Reference< xml::XImportContext > CheckBoxElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { @@ -1402,16 +1328,10 @@ Reference< xml::XImportContext > ButtonElement::createChildContext( Reference< xml::sax2::XExtendedAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException) { - if (XMLNS_DIALOGS_UID != nUid) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("illegal namespace!") ), - Reference< XInterface >(), Any() ); - } // event - else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + if (isEventElement( nUid, rLocalName )) { - return new EventElement( rLocalName, xAttributes, this, _pImport ); + return new EventElement( nUid, rLocalName, xAttributes, this, _pImport ); } else { diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx index 70fd8bc8c9e5..5e8b1c45ccc0 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_import.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: dbo $ $Date: 2001-05-04 13:17:40 $ + * last change: $Author: dbo $ $Date: 2001-08-07 10:55:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,7 +89,7 @@ namespace xmlscript void EventElement::endElement() throw (xml::sax::SAXException, RuntimeException) { - static_cast< ControlElement * >( _pParent )->_events.push_back( _xAttributes ); + static_cast< ControlElement * >( _pParent )->_events.push_back( this ); } //__________________________________________________________________________________________________ ControlElement::ControlElement( @@ -97,7 +97,7 @@ ControlElement::ControlElement( Reference< xml::sax2::XExtendedAttributes > const & xAttributes, ElementBase * pParent, DialogImport * pImport ) SAL_THROW( () ) - : ElementBase( rLocalName, xAttributes, pParent, pImport ) + : ElementBase( XMLNS_DIALOGS_UID, rLocalName, xAttributes, pParent, pImport ) { if (_pParent) { @@ -866,9 +866,57 @@ bool ImportContext::importOrientationProperty( } return false; } + +//================================================================================================== +struct StringTriple +{ + char const * first; + char const * second; + char const * third; +}; +static StringTriple const s_aEventTranslations[] = +{ + // from xmloff/source/forms/formevents.cxx + { "com.sun.star.form.XApproveActionListener", "approveAction", "on-approveaction" }, + { "com.sun.star.awt.XActionListener", "actionPerformed", "on-performaction" }, + { "com.sun.star.form.XChangeListener", "changed", "on-change" }, + { "com.sun.star.awt.XTextListener", "textChanged", "on-textchange" }, + { "com.sun.star.awt.XItemListener", "itemStateChanged", "on-itemstatechange" }, + { "com.sun.star.awt.XFocusListener", "focusGained", "on-focus" }, + { "com.sun.star.awt.XFocusListener", "focusLost", "on-blur" }, + { "com.sun.star.awt.XKeyListener", "keyPressed", "on-keydown" }, + { "com.sun.star.awt.XKeyListener", "keyReleased", "on-keyup" }, + { "com.sun.star.awt.XMouseListener", "mouseEntered", "on-mouseover" }, + { "com.sun.star.awt.XMouseMotionListener", "mouseDragged", "on-mousedrag" }, + { "com.sun.star.awt.XMouseMotionListener", "mouseMoved", "on-mousemove" }, + { "com.sun.star.awt.XMouseListener", "mousePressed", "on-mousedown" }, + { "com.sun.star.awt.XMouseListener", "mouseReleased", "on-mouseup" }, + { "com.sun.star.awt.XMouseListener", "mouseExited", "on-mouseout" }, + { "com.sun.star.form.XResetListener", "approveReset", "on-approvereset" }, + { "com.sun.star.form.XResetListener", "resetted", "on-reset" }, + { "com.sun.star.form.XSubmitListener", "approveSubmit", "on-submit" }, + { "com.sun.star.form.XUpdateListener", "approveUpdate", "on-approveupdate" }, + { "com.sun.star.form.XUpdateListener", "updated", "on-update" }, + { "com.sun.star.form.XLoadListener", "loaded", "on-load" }, + { "com.sun.star.form.XLoadListener", "reloading", "on-startreload" }, + { "com.sun.star.form.XLoadListener", "reloaded", "on-reload" }, + { "com.sun.star.form.XLoadListener", "unloading", "on-startunload" }, + { "com.sun.star.form.XLoadListener", "unloaded", "on-unload" }, + { "com.sun.star.form.XConfirmDeleteListener", "confirmDelete", "on-confirmdelete" }, + { "com.sun.star.sdb.XRowSetApproveListener", "approveRowChange", "on-approverowchange" }, + { "com.sun.star.sdbc.XRowSetListener", "rowChanged", "on-rowchange" }, + { "com.sun.star.sdb.XRowSetApproveListener", "approveCursorMove", "on-approvecursormove" }, + { "com.sun.star.sdbc.XRowSetListener", "cursorMoved", "on-cursormove" }, + { "com.sun.star.form.XDatabaseParameterListener", "approveParameter", "on-supplyparameter" }, + { "com.sun.star.sdb.XSQLErrorListener", "errorOccured", "on-error" }, + { 0, 0, 0 } +}; +extern StringTriple const * const g_pEventTranslations; +StringTriple const * const g_pEventTranslations = s_aEventTranslations; + //__________________________________________________________________________________________________ void ImportContext::importEvents( - vector< Reference< xml::sax2::XExtendedAttributes > > const & rEvents ) + vector< Reference< xml::XImportContext > > const & rEvents ) { Reference< script::XScriptEventsSupplier > xSupplier( _xControlModel, UNO_QUERY ); if (xSupplier.is()) @@ -879,35 +927,129 @@ void ImportContext::importEvents( for ( size_t nPos = 0; nPos < rEvents.size(); ++nPos ) { script::ScriptEventDescriptor descr; - Reference< xml::sax2::XExtendedAttributes > xEvent( rEvents[ nPos ] ); - - if (!getStringAttr( &descr.ListenerType, - OUString( RTL_CONSTASCII_USTRINGPARAM("listener-type") ), - xEvent ) || - !getStringAttr( &descr.EventMethod, - OUString( RTL_CONSTASCII_USTRINGPARAM("event-method") ), - xEvent )) + + EventElement * pEventElement = static_cast< EventElement * >( rEvents[ nPos ].get() ); + sal_Int32 nUid = pEventElement->getUid(); + OUString aLocalName( pEventElement->getLocalName() ); + Reference< xml::sax2::XExtendedAttributes > xAttributes( pEventElement->getAttributes() ); + + // nowadays script events + if (XMLNS_SCRIPT_UID == nUid) { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type | event attribute(s)!") ), - Reference< XInterface >(), Any() ); + if (!getStringAttr( &descr.ScriptType, + OUString( RTL_CONSTASCII_USTRINGPARAM("language") ), + xAttributes, XMLNS_SCRIPT_UID ) || + !getStringAttr( &descr.ScriptCode, + OUString( RTL_CONSTASCII_USTRINGPARAM("macro-name") ), + xAttributes, XMLNS_SCRIPT_UID )) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("missing language or macro-name attribute(s) of event!") ), + Reference< XInterface >(), Any() ); + } + + OUString aLocation; + if (getStringAttr( &aLocation, OUString( RTL_CONSTASCII_USTRINGPARAM("location") ), + xAttributes, XMLNS_SCRIPT_UID )) + { + // prepend location + OUStringBuffer buf( 48 ); + buf.append( aLocation ); + buf.append( (sal_Unicode)':' ); + buf.append( descr.ScriptCode ); + descr.ScriptCode = buf.makeStringAndClear(); + } + + // script:event element + if (aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") )) + { + OUString aEventName; + if (! getStringAttr( &aEventName, + OUString( RTL_CONSTASCII_USTRINGPARAM("event-name") ), + xAttributes, XMLNS_SCRIPT_UID )) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("missing event-name attribute!") ), + Reference< XInterface >(), Any() ); + } + + // lookup in table + OString str( OUStringToOString( aEventName, RTL_TEXTENCODING_ASCII_US ) ); + StringTriple const * p = g_pEventTranslations; + while (p->first) + { + if (0 == ::rtl_str_compare( p->third, str.getStr() )) + { + descr.ListenerType = OUString( p->first, ::rtl_str_getLength( p->first ), RTL_TEXTENCODING_ASCII_US ); + descr.EventMethod = OUString( p->second, ::rtl_str_getLength( p->second ), RTL_TEXTENCODING_ASCII_US ); + break; + } + ++p; + } + + if (! p->first) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("no matching event-name found!") ), + Reference< XInterface >(), Any() ); + } + } + else // script:listener-event element + { + OSL_ASSERT( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("listener-event") ) ); + + if (!getStringAttr( &descr.ListenerType, + OUString( RTL_CONSTASCII_USTRINGPARAM("listener-type") ), + xAttributes, XMLNS_SCRIPT_UID ) || + !getStringAttr( &descr.EventMethod, + OUString( RTL_CONSTASCII_USTRINGPARAM("listener-method") ), + xAttributes, XMLNS_SCRIPT_UID )) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type or listener-method attribute(s)!") ), + Reference< XInterface >(), Any() ); + } + // optional listener param + getStringAttr( + &descr.AddListenerParam, + OUString( RTL_CONSTASCII_USTRINGPARAM("listener-param") ), + xAttributes, XMLNS_SCRIPT_UID ); + } + } + else // deprecated dlg:event element + { + OSL_ASSERT( XMLNS_DIALOGS_UID == nUid && aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("event") ) ); + + if (!getStringAttr( &descr.ListenerType, + OUString( RTL_CONSTASCII_USTRINGPARAM("listener-type") ), + xAttributes, XMLNS_DIALOGS_UID ) || + !getStringAttr( &descr.EventMethod, + OUString( RTL_CONSTASCII_USTRINGPARAM("event-method") ), + xAttributes, XMLNS_DIALOGS_UID )) + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("missing listener-type or event-method attribute(s)!") ), + Reference< XInterface >(), Any() ); + } + + getStringAttr( + &descr.ScriptType, + OUString( RTL_CONSTASCII_USTRINGPARAM("script-type") ), + xAttributes, XMLNS_DIALOGS_UID ); + getStringAttr( + &descr.ScriptCode, + OUString( RTL_CONSTASCII_USTRINGPARAM("script-code") ), + xAttributes, XMLNS_DIALOGS_UID ); + getStringAttr( + &descr.AddListenerParam, + OUString( RTL_CONSTASCII_USTRINGPARAM("param") ), + xAttributes, XMLNS_DIALOGS_UID ); } - getStringAttr( &descr.ScriptType, - OUString( RTL_CONSTASCII_USTRINGPARAM("script-type") ), - xEvent ); - getStringAttr( &descr.ScriptCode, - OUString( RTL_CONSTASCII_USTRINGPARAM("script-code") ), - xEvent ); - getStringAttr( &descr.AddListenerParam, - OUString( RTL_CONSTASCII_USTRINGPARAM("param") ), - xEvent ); - - OUStringBuffer buf( 32 ); + OUStringBuffer buf( 48 ); buf.append( descr.ListenerType ); buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("::") ); buf.append( descr.EventMethod ); - xEvents->insertByName( buf.makeStringAndClear(), makeAny( descr ) ); } } @@ -996,7 +1138,7 @@ OUString ElementBase::getLocalName() sal_Int32 ElementBase::getUid() throw (RuntimeException) { - return XMLNS_DIALOGS_UID; + return _nUid; } //__________________________________________________________________________________________________ Reference< xml::sax2::XExtendedAttributes > ElementBase::getAttributes() @@ -1035,12 +1177,13 @@ Reference< xml::XImportContext > ElementBase::createChildContext( //__________________________________________________________________________________________________ ElementBase::ElementBase( - OUString const & rLocalName, + sal_Int32 nUid, OUString const & rLocalName, Reference< xml::sax2::XExtendedAttributes > const & xAttributes, ElementBase * pParent, DialogImport * pImport ) SAL_THROW( () ) : _pImport( pImport ) , _pParent( pParent ) + , _nUid( nUid ) , _aLocalName( rLocalName ) , _xAttributes( xAttributes ) { @@ -1162,7 +1305,12 @@ Reference< xml::sax::XDocumentHandler > SAL_CALL importDialogModel( SAL_THROW( (Exception) ) { NameSpaceUid arNamespaceUids[] = { - NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_URI) ), XMLNS_DIALOGS_UID ) + NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_URI) ), XMLNS_DIALOGS_UID ), + NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_SCRIPT_URI) ), XMLNS_SCRIPT_UID ) +/* , + NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_URI) ), XMLNS_LIBRARY_UID ), + NameSpaceUid( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_XLINK_URI) ), XMLNS_XLINK_UID ) +*/ }; return ::xmlscript::createDocumentHandler( diff --git a/xmlscript/test/imexp.cxx b/xmlscript/test/imexp.cxx index d3bc4cd125dc..e1c056786659 100644 --- a/xmlscript/test/imexp.cxx +++ b/xmlscript/test/imexp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: imexp.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: dbo $ $Date: 2001-05-11 13:53:34 $ + * last change: $Author: dbo $ $Date: 2001-08-07 10:55:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,9 +86,6 @@ #include <com/sun/star/registry/XImplementationRegistration.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/xml/sax/XParser.hpp> -#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> - #include <com/sun/star/awt/XToolkit.hpp> #include <com/sun/star/awt/XControlModel.hpp> @@ -108,7 +105,7 @@ Reference< lang::XMultiServiceFactory > createApplicationServiceManager() try { - ::rtl::OUString localRegistry = ::comphelper::getPathToUserRegistry(); + ::rtl::OUString localRegistry = OUString::createFromAscii( "xmlscript.rdb" ); //"::comphelper::getPathToUserRegistry(); ::rtl::OUString systemRegistry = ::comphelper::getPathToSystemRegistry(); Reference< registry::XSimpleRegistry > xLocalRegistry( ::cppu::createSimpleRegistry() ); @@ -149,55 +146,59 @@ Reference< lang::XMultiServiceFactory > createApplicationServiceManager() Reference< XInterface >() ); } - Reference < registry::XImplementationRegistration > xReg( - xContext->getServiceManager()->createInstanceWithContext( - OUString::createFromAscii( "com.sun.star.registry.ImplementationRegistration" ), xContext ), UNO_QUERY ); + Reference< XInterface > x( xContext->getServiceManager()->createInstanceWithContext( + OUString::createFromAscii( "com.sun.star.xml.sax.Parser" ), xContext ) ); + if (! x.is()) // register only once + { + Reference < registry::XImplementationRegistration > xReg( + xContext->getServiceManager()->createInstanceWithContext( + OUString::createFromAscii( "com.sun.star.registry.ImplementationRegistration" ), xContext ), UNO_QUERY ); #ifdef SAL_W32 - OUString aDllName = OUString::createFromAscii( "sax.dll" ); + OUString aDllName = OUString::createFromAscii( "sax.dll" ); #else - OUString aDllName = OUString::createFromAscii( "libsax.so" ); + OUString aDllName = OUString::createFromAscii( "libsax.so" ); #endif - xReg->registerImplementation( - OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), - aDllName, Reference< registry::XSimpleRegistry > () ); + xReg->registerImplementation( + OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), + aDllName, Reference< registry::XSimpleRegistry > () ); #ifdef SAL_W32 - aDllName = OUString::createFromAscii( "tk" ); - aDllName += OUString::valueOf( (sal_Int32)SUPD ); - aDllName += OUString::createFromAscii( "mi.dll" ); + aDllName = OUString::createFromAscii( "tk" ); + aDllName += OUString::valueOf( (sal_Int32)SUPD ); + aDllName += OUString::createFromAscii( "mi.dll" ); #else - aDllName = OUString::createFromAscii( "libtk" ); - aDllName += OUString::valueOf( (sal_Int32)SUPD ); - aDllName += OUString::createFromAscii( ".so" ); + aDllName = OUString::createFromAscii( "libtk" ); + aDllName += OUString::valueOf( (sal_Int32)SUPD ); + aDllName += OUString::createFromAscii( ".so" ); #endif - xReg->registerImplementation( - OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), - aDllName, Reference< registry::XSimpleRegistry > () ); + xReg->registerImplementation( + OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), + aDllName, Reference< registry::XSimpleRegistry > () ); #ifdef SAL_W32 - aDllName = OUString::createFromAscii( "svt" ); - aDllName += OUString::valueOf( (sal_Int32)SUPD ); - aDllName += OUString::createFromAscii( "mi.dll" ); + aDllName = OUString::createFromAscii( "svt" ); + aDllName += OUString::valueOf( (sal_Int32)SUPD ); + aDllName += OUString::createFromAscii( "mi.dll" ); #else - aDllName = OUString::createFromAscii( "libsvt" ); - aDllName += OUString::valueOf( (sal_Int32)SUPD ); - aDllName += OUString::createFromAscii( ".so" ); + aDllName = OUString::createFromAscii( "libsvt" ); + aDllName += OUString::valueOf( (sal_Int32)SUPD ); + aDllName += OUString::createFromAscii( ".so" ); #endif - xReg->registerImplementation( - OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), - aDllName, Reference< registry::XSimpleRegistry > () ); + xReg->registerImplementation( + OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), + aDllName, Reference< registry::XSimpleRegistry > () ); #ifdef SAL_W32 - aDllName = OUString::createFromAscii( "i18n" ); - aDllName += OUString::valueOf( (sal_Int32)SUPD ); - aDllName += OUString::createFromAscii( "mi.dll" ); + aDllName = OUString::createFromAscii( "i18n" ); + aDllName += OUString::valueOf( (sal_Int32)SUPD ); + aDllName += OUString::createFromAscii( "mi.dll" ); #else - aDllName = OUString::createFromAscii( "libi18n" ); - aDllName += OUString::valueOf( (sal_Int32)SUPD ); - aDllName += OUString::createFromAscii( ".so" ); + aDllName = OUString::createFromAscii( "libi18n" ); + aDllName += OUString::valueOf( (sal_Int32)SUPD ); + aDllName += OUString::createFromAscii( ".so" ); #endif - xReg->registerImplementation( - OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), - aDllName, Reference< registry::XSimpleRegistry > () ); - + xReg->registerImplementation( + OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), + aDllName, Reference< registry::XSimpleRegistry > () ); + } } catch( Exception& rExc ) diff --git a/xmlscript/test/test.xml b/xmlscript/test/test.xml index ad32e10997fa..6ac6d7dcc06b 100644 --- a/xmlscript/test/test.xml +++ b/xmlscript/test/test.xml @@ -3,6 +3,7 @@ <window xmlns="http://openoffice.org/2000/dialog" xmlns:dlg="http://openoffice.org/2000/dialog" + xmlns:script="http://openoffice.org/2000/script" style-id="dialog" id="window1" title="Test-Dialog" left="50" top="50" height="690" width="400"> @@ -16,7 +17,10 @@ <dlg:bulletinboard xmlns:ns="http://www.fake" xmlns:dlg="http://openoffice.org/2000/dialog"> <button dlg:id="button1" ns:value="hallo" dlg:left="50" ns:top="50" width="50" height="50" style-id="bla3" xmlns:ns="http://openoffice.org/2000/dialog"> - <event listener-type="type" event-method="clicked" script-type="basic" script-code="code" param="testi"/> + <dlg:event listener-type="com.sun.star.awt.XKeyListener" event-method="keyReleased" script-type="StarBasic" script-code="application:ExecutingMacro"/> + <script:event script:event-name="on-rowchange" script:macro-name="ExecutingMacro" script:location="application" script:language="StarBasic"/> + <script:listener-event script:macro-name="ExecutingMacro" script:location="application" script:language="StarBasic" script:listener-type="com.sun.star.awt.XMouseListener" script:listener-method="mouseEntered"/> + <script:listener-event script:macro-name="ExecutingMacro" script:location="application" script:language="StarBasic" script:listener-type="com.sun.star.awt.XMouseListener" script:listener-method="mousePressed" script:listener-param="parameter0, so this will never ever be a script:event, but always a script:listener-event element!"/> </button> <button dlg:id="button3" ns:value="hallo2" dlg:left="250" ns:top="50" width="50" height="50" style-id="bla" xmlns:ns="http://openoffice.org/2000/dialog"/> |