diff options
author | Armin Le Grand <alg@apache.org> | 2013-07-27 11:40:32 +0000 |
---|---|---|
committer | Armin Le Grand <alg@apache.org> | 2013-07-27 11:40:32 +0000 |
commit | 8a6f84ce896f41a7a1f97b06d1e053c51cbba95e (patch) | |
tree | 0865afbfa9eb147e0a5be9759f932954cfb59e32 /scripting | |
parent | 59ee09f905e86724a2ba5cdccab9210d16686820 (diff) |
resync to trunk (close to AOO400)
Diffstat (limited to 'scripting')
19 files changed, 146 insertions, 134 deletions
diff --git a/scripting/examples/beanshell/Highlight/ShowDialog.bsh b/scripting/examples/beanshell/Highlight/ShowDialog.bsh index b224cc99de3c..b1226eb8b7bf 100644 --- a/scripting/examples/beanshell/Highlight/ShowDialog.bsh +++ b/scripting/examples/beanshell/Highlight/ShowDialog.bsh @@ -58,7 +58,7 @@ boolean tryLoadingLibrary( xmcf, context, name ) } libURL = xme.expandMacros( - "${$BRAND_BASE_DIR/program/" + bootstrapName + "::BaseInstallation}" + + "${$OOO_BASE_DIR/program/" + bootstrapName + "::BaseInstallation}" + "/share/basic/ScriptBindingLibrary/" + name.toLowerCase() + ".xlb/"); diff --git a/scripting/examples/java/Highlight/HighlightText.java b/scripting/examples/java/Highlight/HighlightText.java index a60204531fc5..e277140b0e65 100644 --- a/scripting/examples/java/Highlight/HighlightText.java +++ b/scripting/examples/java/Highlight/HighlightText.java @@ -224,7 +224,7 @@ public class HighlightText implements com.sun.star.awt.XActionListener { } String libURL = xme.expandMacros( - "${$BRAND_BASE_DIR/program/" + bootstrapName + "::BaseInstallation}" + + "${$OOO_BASE_DIR/program/" + bootstrapName + "::BaseInstallation}" + "/share/basic/ScriptBindingLibrary/" + name.toLowerCase() + ".xlb/"); diff --git a/scripting/examples/java/build.xml b/scripting/examples/java/build.xml index 3a4a69837fd0..b2cfeaccfdc0 100644 --- a/scripting/examples/java/build.xml +++ b/scripting/examples/java/build.xml @@ -42,7 +42,7 @@ <mkdir dir="${outdir}/HelloWorld"/> <javac srcdir="HelloWorld" destdir="${outdir}/HelloWorld" - includes="**/*.java" classpathref="idlclasspath" + includes="**/*.java" classpathref="idlclasspath" includeantruntime="false" debug="${debug}" optimize="${optimize}" deprecation="on"/> <copy file="HelloWorld/HelloWorld.java" todir="${outdir}/HelloWorld"/> @@ -64,7 +64,7 @@ <mkdir dir="${outdir}/Highlight"/> <javac srcdir="Highlight" destdir="${outdir}/Highlight" - includes="**/*.java" classpathref="idlclasspath" + includes="**/*.java" classpathref="idlclasspath" includeantruntime="false" debug="${debug}" optimize="${optimize}" deprecation="on"/> <copy file="Highlight/HighlightText.java" todir="${outdir}/Highlight"/> @@ -86,7 +86,7 @@ <mkdir dir="${outdir}/MemoryUsage"/> <javac srcdir="MemoryUsage" destdir="${outdir}/MemoryUsage" - includes="**/*.java" classpathref="idlclasspath" + includes="**/*.java" classpathref="idlclasspath" includeantruntime="false" debug="${debug}" optimize="${optimize}" deprecation="on"/> <copy file="MemoryUsage/MemoryUsage.java" todir="${outdir}/MemoryUsage"/> diff --git a/scripting/examples/javascript/Highlight/ShowDialog.js b/scripting/examples/javascript/Highlight/ShowDialog.js index 2e4793b70dd4..5a6ca1f0f81e 100644 --- a/scripting/examples/javascript/Highlight/ShowDialog.js +++ b/scripting/examples/javascript/Highlight/ShowDialog.js @@ -52,7 +52,7 @@ function tryLoadingLibrary( xmcf, context, name ) } libURL = xme.expandMacros( - "${$BRAND_BASE_DIR/program/" + bootstrapName + "::BaseInstallation}" + + "${$OOO_BASE_DIR/program/" + bootstrapName + "::BaseInstallation}" + "/share/basic/ScriptBindingLibrary/" + name.toLowerCase() + ".xlb/"); diff --git a/scripting/java/build.xml b/scripting/java/build.xml index 05f7e77866e3..161cef88bea1 100644 --- a/scripting/java/build.xml +++ b/scripting/java/build.xml @@ -25,7 +25,7 @@ <!-- =================== Environmental Properties ======================= --> <property name="prj" value=".."/> - <property name="build.compiler" value="classic"/> + <property name="build.compiler" value="modern"/> <property name="optimize" value="off"/> <property name="debug" value="on"/> <property name="jardir" value="${out}/class"/> @@ -102,7 +102,7 @@ <!-- ======================== Compile Classes ========================== --> <target name="compile" depends="prepare, eval_environment"> <javac srcdir="com" destdir="${jardir}" - includes="**/*.java" classpathref="idlclasspath" + includes="**/*.java" classpathref="idlclasspath" includeantruntime="false" debug="${debug}" optimize="${optimize}" deprecation="off"> <exclude name="**/provider/javascript/*.java" unless="with_rhino" /> <exclude name="**/provider/beanshell/*.java" unless="with_beanshell" /> @@ -110,7 +110,7 @@ </javac> <javac srcdir="Framework/" destdir="${jardir}" includes="**/*.java" classpathref="idlclasspath" debug="${debug}" - optimize="${optimize}" deprecation="off"> + optimize="${optimize}" deprecation="off" includeantruntime="false"> <compilerarg value="-Xbootclasspath:${toString:my.bootstrap.classpath}"/> </javac> </target> diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java b/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java index 9dd2d611c4db..eb23796abf40 100644 --- a/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java +++ b/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java @@ -240,8 +240,7 @@ public class ParcelContainer implements XNameAccess * @param language language for which entries are stored * @param loadParcels set to <tt>true</tt> if parcels are to be loaded * on construction. - * @return name of <tt>ParcelContainer</tt> - * @throws IllegalArgumentException + * @throws com.sun.star.lang.IllegalArgumentException * @throws WrappedTargetException */ public ParcelContainer( XComponentContext xCtx, String containerUrl, String language, boolean loadParcels ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java index 0008b0de6fbe..72884702da18 100644 --- a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java +++ b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java @@ -130,12 +130,12 @@ public class ScriptMetaData extends ScriptEntry implements Cloneable { // to be exposed at all private static final String SHARE = - "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + + "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::BaseInstallation}/share"; private static final String USER = - "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + + "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java index a7b35d26ff02..f8e3912f83b3 100644 --- a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java +++ b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java @@ -138,7 +138,7 @@ public abstract class ScriptProvider new Type(XMacroExpander.class), serviceObj); XMLParserFactory.setOfficeDTDURL(me.expandMacros( - "${$BRAND_BASE_DIR/program/bootstraprc::BaseInstallation}/share/dtd/officedocument/1_0/")); + "${$OOO_BASE_DIR/program/bootstraprc::BaseInstallation}/share/dtd/officedocument/1_0/")); } catch ( Exception e ) @@ -214,20 +214,20 @@ public abstract class ScriptProvider if ( originalContextURL.startsWith( "bundled" ) ) { contextUrl = "vnd.sun.star.expand:$BUNDLED_EXTENSIONS"; - extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; + extensionDb = "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; extensionRepository = "bundled"; } if ( originalContextURL.startsWith( "share" ) ) { - contextUrl = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::BaseInstallation}/share"; - extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; + contextUrl = "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::BaseInstallation}/share"; + extensionDb = "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; extensionRepository = "shared"; } else if ( originalContextURL.startsWith( "user" ) ) { - contextUrl = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; - extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; + contextUrl = "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; + extensionDb = "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user"; extensionRepository = "user"; } diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java index e27dd84c8627..2b0d15176008 100644 --- a/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java +++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java @@ -240,4 +240,4 @@ class GlyphGutter extends JComponent { g.setColor(Color.black); g.drawPolygon(arrow); } -}; +} diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java index 6dd8f692b913..4dee4d21f281 100644 --- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java +++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java @@ -189,9 +189,8 @@ public class ScriptEditorForBeanShell * If an editor window is already open for that data it will be * moved to the front. * - * @param metadata The metadata describing the script * @param context The context in which to execute the script - * + * @param entry The metadata describing the script */ public void edit(final XScriptContext context, ScriptMetaData entry) { if (entry != null ) { diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java index 3d374aa8dd6a..bad84288a759 100644 --- a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java +++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java @@ -165,7 +165,7 @@ class ScriptImpl implements XScript * Invoke * * - * @param aParams All parameters; pure, out params are undefined in + * @param params All parameters; pure, out params are undefined in * sequence, i.e., the value has to be ignored by the callee * @param aOutParamIndex Out indices * @param aOutParam Out parameters @@ -173,7 +173,7 @@ class ScriptImpl implements XScript * @throws IllegalArgumentException If there is no matching script name * @throws CannotConvertException If args do not match or cannot be converted * the those of the invokee - * @throws InvocationTargetException If the running script throws an exception + * @throws com.sun.star.reflection.InvocationTargetException If the running script throws an exception * this information is captured and rethrown as this exception type. */ diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java index c461db5edfd6..0bbdbc89acc5 100644 --- a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java +++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java @@ -172,9 +172,8 @@ public class ScriptEditorForJavaScript implements ScriptEditor * If an editor window is already open for that data it will be * moved to the front. * - * @param metadata The metadata describing the script * @param context The context in which to execute the script - * + * @param entry The metadata describing the script */ public void edit(final XScriptContext context, ScriptMetaData entry) { diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java index cfb09770fba9..1027c9e085dd 100644 --- a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java +++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java @@ -154,7 +154,7 @@ class ScriptImpl implements XScript * * * - * @param aParams All parameters; pure, out params are + * @param params All parameters; pure, out params are * undefined in sequence, i.e., the value * has to be ignored by the callee * diff --git a/scripting/source/provider/URIHelper.cxx b/scripting/source/provider/URIHelper.cxx index c664e2a4ac15..6d64a1bd27e6 100644 --- a/scripting/source/provider/URIHelper.cxx +++ b/scripting/source/provider/URIHelper.cxx @@ -42,7 +42,8 @@ namespace script = ::com::sun::star::script; static const char SHARE[] = "share"; static const char SHARE_URI[] = - "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::BaseInstallation}"; + "vnd.sun.star.expand:$$OOO_BASE_DIR"; +// "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::BaseInstallation}"; static const char SHARE_UNO_PACKAGES[] = "share:uno_packages"; static const char SHARE_UNO_PACKAGES_URI[] = @@ -50,7 +51,7 @@ static const char SHARE_UNO_PACKAGES_URI[] = static const char USER[] = "user"; static const char USER_URI[] = - "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}"; + "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}"; static const char USER_UNO_PACKAGES[] = "user:uno_packages"; static const char USER_UNO_PACKAGES_DIR[] = diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py index 3c33702204ff..08b51d965196 100644 --- a/scripting/source/pyprov/mailmerge.py +++ b/scripting/source/pyprov/mailmerge.py @@ -66,6 +66,7 @@ from socket import _GLOBAL_DEFAULT_TIMEOUT import sys, smtplib, imaplib, poplib dbg = False +out = sys.stderr class PyMailSMTPService(unohelper.Base, XSmtpService): def __init__( self, ctx ): @@ -76,39 +77,39 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): self.connectioncontext = None self.notify = EventObject(self) if dbg: - print >> sys.stderr, "PyMailSMPTService init" + out.write("PyMailSMPTService init\n") def addConnectionListener(self, xListener): if dbg: - print >> sys.stderr, "PyMailSMPTService addConnectionListener" + out.write("PyMailSMPTService addConnectionListener\n") self.listeners.append(xListener) def removeConnectionListener(self, xListener): if dbg: - print >> sys.stderr, "PyMailSMPTService removeConnectionListener" + out.write("PyMailSMPTService removeConnectionListener\n") self.listeners.remove(xListener) def getSupportedConnectionTypes(self): if dbg: - print >> sys.stderr, "PyMailSMPTService getSupportedConnectionTypes" + out.write("PyMailSMPTService getSupportedConnectionTypes\n") return self.supportedtypes def connect(self, xConnectionContext, xAuthenticator): self.connectioncontext = xConnectionContext if dbg: - print >> sys.stderr, "PyMailSMPTService connect" + out.write("PyMailSMPTService connect\n") server = xConnectionContext.getValueByName("ServerName") if dbg: - print >> sys.stderr, "ServerName: %s" % server + out.write("ServerName: %s\n" % server) port = xConnectionContext.getValueByName("Port") if dbg: - print >> sys.stderr, "Port: %d" % port + out.write("Port: %d\n" % port) tout = xConnectionContext.getValueByName("Timeout") if dbg: - print >> sys.stderr, isinstance(tout,int) + out.write("Timeout is instance of int? %s\n" % isinstance(tout,int)) if not isinstance(tout,int): tout = _GLOBAL_DEFAULT_TIMEOUT if dbg: - print >> sys.stderr, "Timeout: %s" % str(tout) + out.write("Timeout: %s\n" % str(tout)) self.server = smtplib.SMTP(server, port,timeout=tout) if dbg: @@ -116,7 +117,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): connectiontype = xConnectionContext.getValueByName("ConnectionType") if dbg: - print >> sys.stderr, "ConnectionType: %s" % connectiontype + out.write("ConnectionType: %s\n" % str(connectiontype)) if connectiontype.upper() == 'SSL': self.server.ehlo() @@ -127,14 +128,14 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): password = xAuthenticator.getPassword().encode('ascii') if user != '': if dbg: - print >> sys.stderr, 'Logging in, username of', user + out.write('Logging in, username of %s\n' % user) self.server.login(user, password) for listener in self.listeners: listener.connected(self.notify) def disconnect(self): if dbg: - print >> sys.stderr, "PyMailSMPTService disconnect" + out.write("PyMailSMPTService disconnect\n") if self.server: self.server.quit() self.server = None @@ -142,17 +143,17 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): listener.disconnected(self.notify) def isConnected(self): if dbg: - print >> sys.stderr, "PyMailSMPTService isConnected" + out.write("PyMailSMPTService isConnected\n") return self.server != None def getCurrentConnectionContext(self): if dbg: - print >> sys.stderr, "PyMailSMPTService getCurrentConnectionContext" + out.write("PyMailSMPTService getCurrentConnectionContext\n") return self.connectioncontext def sendMailMessage(self, xMailMessage): COMMASPACE = ', ' if dbg: - print >> sys.stderr, "PyMailSMPTService sendMailMessage" + out.write("PyMailSMPTService sendMailMessage\n") recipients = xMailMessage.getRecipients() sendermail = xMailMessage.SenderAddress sendername = xMailMessage.SenderName @@ -160,10 +161,10 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): ccrecipients = xMailMessage.getCcRecipients() bccrecipients = xMailMessage.getBccRecipients() if dbg: - print >> sys.stderr, "PyMailSMPTService subject", subject - print >> sys.stderr, "PyMailSMPTService from", sendername.encode('utf-8') - print >> sys.stderr, "PyMailSMTPService from", sendermail - print >> sys.stderr, "PyMailSMPTService send to", recipients + out.write("PyMailSMPTService subject %s\n" % subject) + out.write("PyMailSMPTService from %s\n" % sendername.encode('utf-8')) + out.write("PyMailSMTPService from %s\n" % sendermail) + out.write("PyMailSMPTService send to %s\n" % str(recipients)) attachments = xMailMessage.getAttachments() @@ -172,13 +173,13 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): content = xMailMessage.Body flavors = content.getTransferDataFlavors() if dbg: - print >> sys.stderr, "PyMailSMPTService flavors len", len(flavors) + out.write("PyMailSMPTService flavors len %d\n" % len(flavors)) #Use first flavor that's sane for an email body for flavor in flavors: if flavor.MimeType.find('text/html') != -1 or flavor.MimeType.find('text/plain') != -1: if dbg: - print >> sys.stderr, "PyMailSMPTService mimetype is", flavor.MimeType + out.write("PyMailSMPTService mimetype is %s\n" % flavor.MimeType) textbody = content.getTransferData(flavor) try: textbody = textbody.value @@ -258,10 +259,10 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): if len(bccrecipients): for key in bccrecipients: uniquer[key] = True - truerecipients = uniquer.keys() + truerecipients = list(uniquer.keys()) if dbg: - print >> sys.stderr, "PyMailSMPTService recipients are", truerecipients + out.write("PyMailSMPTService recipients are %s\n" % str(truerecipients)) self.server.sendmail(sendermail, truerecipients, msg.as_string()) @@ -274,52 +275,52 @@ class PyMailIMAPService(unohelper.Base, XMailService): self.connectioncontext = None self.notify = EventObject(self) if dbg: - print >> sys.stderr, "PyMailIMAPService init" + out.write("PyMailIMAPService init\n") def addConnectionListener(self, xListener): if dbg: - print >> sys.stderr, "PyMailIMAPService addConnectionListener" + out.write("PyMailIMAPService addConnectionListener\n") self.listeners.append(xListener) def removeConnectionListener(self, xListener): if dbg: - print >> sys.stderr, "PyMailIMAPService removeConnectionListener" + out.write("PyMailIMAPService removeConnectionListener\n") self.listeners.remove(xListener) def getSupportedConnectionTypes(self): if dbg: - print >> sys.stderr, "PyMailIMAPService getSupportedConnectionTypes" + out.write("PyMailIMAPService getSupportedConnectionTypes\n") return self.supportedtypes def connect(self, xConnectionContext, xAuthenticator): if dbg: - print >> sys.stderr, "PyMailIMAPService connect" + out.write("PyMailIMAPService connect\n") self.connectioncontext = xConnectionContext server = xConnectionContext.getValueByName("ServerName") if dbg: - print >> sys.stderr, server + out.write("Server: %s\n" % server) port = xConnectionContext.getValueByName("Port") if dbg: - print >> sys.stderr, port + out.write("Port: %d\n" % port) connectiontype = xConnectionContext.getValueByName("ConnectionType") if dbg: - print >> sys.stderr, connectiontype - print >> sys.stderr, "BEFORE" + out.write("Connection type: %s\n" % connectiontype) + out.write("BEFORE\n") if connectiontype.upper() == 'SSL': self.server = imaplib.IMAP4_SSL(server, port) else: self.server = imaplib.IMAP4(server, port) - print >> sys.stderr, "AFTER" + out.write("AFTER\n") user = xAuthenticator.getUserName().encode('ascii') password = xAuthenticator.getPassword().encode('ascii') if user != '': if dbg: - print >> sys.stderr, 'Logging in, username of', user + out.write('Logging in, username of %s\n' % user) self.server.login(user, password) for listener in self.listeners: listener.connected(self.notify) def disconnect(self): if dbg: - print >> sys.stderr, "PyMailIMAPService disconnect" + out.write("PyMailIMAPService disconnect\n") if self.server: self.server.logout() self.server = None @@ -327,11 +328,11 @@ class PyMailIMAPService(unohelper.Base, XMailService): listener.disconnected(self.notify) def isConnected(self): if dbg: - print >> sys.stderr, "PyMailIMAPService isConnected" + out.write("PyMailIMAPService isConnected\n") return self.server != None def getCurrentConnectionContext(self): if dbg: - print >> sys.stderr, "PyMailIMAPService getCurrentConnectionContext" + out.write("PyMailIMAPService getCurrentConnectionContext\n") return self.connectioncontext class PyMailPOP3Service(unohelper.Base, XMailService): @@ -343,51 +344,51 @@ class PyMailPOP3Service(unohelper.Base, XMailService): self.connectioncontext = None self.notify = EventObject(self) if dbg: - print >> sys.stderr, "PyMailPOP3Service init" + out.write("PyMailPOP3Service init\n") def addConnectionListener(self, xListener): if dbg: - print >> sys.stderr, "PyMailPOP3Service addConnectionListener" + out.write("PyMailPOP3Service addConnectionListener\n") self.listeners.append(xListener) def removeConnectionListener(self, xListener): if dbg: - print >> sys.stderr, "PyMailPOP3Service removeConnectionListener" + out.write("PyMailPOP3Service removeConnectionListener\n") self.listeners.remove(xListener) def getSupportedConnectionTypes(self): if dbg: - print >> sys.stderr, "PyMailPOP3Service getSupportedConnectionTypes" + out.write("PyMailPOP3Service getSupportedConnectionTypes\n") return self.supportedtypes def connect(self, xConnectionContext, xAuthenticator): if dbg: - print >> sys.stderr, "PyMailPOP3Service connect" + out.write("PyMailPOP3Service connect\n") self.connectioncontext = xConnectionContext server = xConnectionContext.getValueByName("ServerName") if dbg: - print >> sys.stderr, server + out.write("Server: %s\n" % server) port = xConnectionContext.getValueByName("Port") if dbg: - print >> sys.stderr, port + out.write("Port: %s\n" % port) connectiontype = xConnectionContext.getValueByName("ConnectionType") if dbg: - print >> sys.stderr, connectiontype - print >> sys.stderr, "BEFORE" + out.write("Connection type: %s\n" % str(connectiontype)) + out.write("BEFORE\n") if connectiontype.upper() == 'SSL': self.server = poplib.POP3_SSL(server, port) else: tout = xConnectionContext.getValueByName("Timeout") if dbg: - print >> sys.stderr, isinstance(tout,int) + out.write("Timeout is instance of int? %s\n" % isinstance(tout,int)) if not isinstance(tout,int): tout = _GLOBAL_DEFAULT_TIMEOUT if dbg: - print >> sys.stderr, "Timeout: %s" % str(tout) + out.write("Timeout: %s\n" % str(tout)) self.server = poplib.POP3(server, port, timeout=tout) - print >> sys.stderr, "AFTER" + out.write("AFTER\n") user = xAuthenticator.getUserName().encode('ascii') password = xAuthenticator.getPassword().encode('ascii') if dbg: - print >> sys.stderr, 'Logging in, username of', user + out.write('Logging in, username of %s\n' % user) self.server.user(user) self.server.pass_(password) @@ -395,7 +396,7 @@ class PyMailPOP3Service(unohelper.Base, XMailService): listener.connected(self.notify) def disconnect(self): if dbg: - print >> sys.stderr, "PyMailPOP3Service disconnect" + out.write("PyMailPOP3Service disconnect\n") if self.server: self.server.quit() self.server = None @@ -403,21 +404,21 @@ class PyMailPOP3Service(unohelper.Base, XMailService): listener.disconnected(self.notify) def isConnected(self): if dbg: - print >> sys.stderr, "PyMailPOP3Service isConnected" + out.write("PyMailPOP3Service isConnected\n") return self.server != None def getCurrentConnectionContext(self): if dbg: - print >> sys.stderr, "PyMailPOP3Service getCurrentConnectionContext" + out.write("PyMailPOP3Service getCurrentConnectionContext\n") return self.connectioncontext class PyMailServiceProvider(unohelper.Base, XMailServiceProvider): def __init__( self, ctx ): if dbg: - print >> sys.stderr, "PyMailServiceProvider init" + out.write("PyMailServiceProvider init\n") self.ctx = ctx def create(self, aType): if dbg: - print >> sys.stderr, "PyMailServiceProvider create with", aType + out.write("PyMailServiceProvider create with %s\n" % aType) if aType == SMTP: return PyMailSMTPService(self.ctx); elif aType == POP3: @@ -425,12 +426,12 @@ class PyMailServiceProvider(unohelper.Base, XMailServiceProvider): elif aType == IMAP: return PyMailIMAPService(self.ctx); else: - print >> sys.stderr, "PyMailServiceProvider, unknown TYPE", aType + out.write("PyMailServiceProvider, unknown TYPE %s\n" % aType) class PyMailMessage(unohelper.Base, XMailMessage): def __init__( self, ctx, sTo='', sFrom='', Subject='', Body=None, aMailAttachment=None ): if dbg: - print >> sys.stderr, "PyMailMessage init" + out.write("PyMailMessage init\n") self.ctx = ctx self.recipients = [sTo] @@ -445,38 +446,38 @@ class PyMailMessage(unohelper.Base, XMailMessage): self.Subject = Subject self.Body = Body if dbg: - print >> sys.stderr, "post PyMailMessage init" + out.write("post PyMailMessage init\n") def addRecipient( self, recipient ): if dbg: - print >> sys.stderr, "PyMailMessage.addRecipient", recipient + out.write("PyMailMessage.addRecipient%s\n" % recipient) self.recipients.append(recipient) def addCcRecipient( self, ccrecipient ): if dbg: - print >> sys.stderr, "PyMailMessage.addCcRecipient", ccrecipient + out.write("PyMailMessage.addCcRecipient%s\n" % ccrecipient) self.ccrecipients.append(ccrecipient) def addBccRecipient( self, bccrecipient ): if dbg: - print >> sys.stderr, "PyMailMessage.addBccRecipient", bccrecipient + out.write("PyMailMessage.addBccRecipient%s\n" % bccrecipient) self.bccrecipients.append(bccrecipient) def getRecipients( self ): if dbg: - print >> sys.stderr, "PyMailMessage.getRecipients", self.recipients + out.write("PyMailMessage.getRecipients%s\n" % self.recipients) return tuple(self.recipients) def getCcRecipients( self ): if dbg: - print >> sys.stderr, "PyMailMessage.getCcRecipients", self.ccrecipients + out.write("PyMailMessage.getCcRecipients%s\n" % self.ccrecipients) return tuple(self.ccrecipients) def getBccRecipients( self ): if dbg: - print >> sys.stderr, "PyMailMessage.getBccRecipients", self.bccrecipients + out.write("PyMailMessage.getBccRecipients%s\n" % self.bccrecipients) return tuple(self.bccrecipients) def addAttachment( self, aMailAttachment ): if dbg: - print >> sys.stderr, "PyMailMessage.addAttachment" + out.write("PyMailMessage.addAttachment\n") self.aMailAttachments.append(aMailAttachment) def getAttachments( self ): if dbg: - print >> sys.stderr, "PyMailMessage.getAttachments" + out.write("PyMailMessage.getAttachments\n") return tuple(self.aMailAttachments) diff --git a/scripting/source/pyprov/officehelper.py b/scripting/source/pyprov/officehelper.py index d17fdf5af66d..0e915a6b792b 100644 --- a/scripting/source/pyprov/officehelper.py +++ b/scripting/source/pyprov/officehelper.py @@ -81,7 +81,7 @@ def bootstrap(): except BootstrapException: raise - except Exception, e: # Any other exception + except Exception as e: # Any other exception raise BootstrapException("Caught exception " + str(e), None) return xContext diff --git a/scripting/source/pyprov/pythonscript.py b/scripting/source/pyprov/pythonscript.py index b47eb7f11651..23e82b558dcd 100644 --- a/scripting/source/pyprov/pythonscript.py +++ b/scripting/source/pyprov/pythonscript.py @@ -28,17 +28,30 @@ import imp import time import ast +try: + unicode +except NameError: + unicode = str + class LogLevel: - NONE = 0 - ERROR = 1 - DEBUG = 2 + NONE = 0 # production level + ERROR = 1 # for script developers + DEBUG = 2 # for script framework developers + +PYSCRIPT_LOG_ENV = "PYSCRIPT_LOG_LEVEL" +PYSCRIPT_LOG_STDOUT_ENV = "PYSCRIPT_LOG_STDOUT" # Configuration ---------------------------------------------------- -LogLevel.use = LogLevel.NONE # production level -#LogLevel.use = LogLevel.ERROR # for script developers -#LogLevel.use = LogLevel.DEBUG # for script framework developers -LOG_STDOUT = True # True, writes to stdout (difficult on windows) - # False, writes to user/Scripts/python/log.txt +LogLevel.use = LogLevel.NONE +if os.environ.get(PYSCRIPT_LOG_ENV) == "ERROR": + LogLevel.use = LogLevel.ERROR +elif os.environ.get(PYSCRIPT_LOG_ENV) == "DEBUG": + LogLevel.use = LogLevel.DEBUG + +# True, writes to stdout (difficult on windows) +# False, writes to user/Scripts/python/log.txt +LOG_STDOUT = os.environ.get(PYSCRIPT_LOG_STDOUT_ENV, "1") != "0" + ENABLE_EDIT_DIALOG=False # offers a minimal editor for editing. #------------------------------------------------------------------- @@ -69,8 +82,8 @@ def getLogTarget(): if len( userInstallation ) > 0: systemPath = uno.fileUrlToSystemPath( userInstallation + "/Scripts/python/log.txt" ) ret = file( systemPath , "a" ) - except Exception,e: - print "Exception during creation of pythonscript logfile: "+ lastException2String() + "\n, delagating log to stdout\n" + except Exception as e: + print("Exception during creation of pythonscript logfile: "+ lastException2String() + "\n, delagating log to stdout\n") return ret class Logger(LogLevel): @@ -102,8 +115,8 @@ class Logger(LogLevel): encfile(msg) + "\n" ) self.target.flush() - except Exception,e: - print "Error during writing to stdout: " +lastException2String() + "\n" + except Exception as e: + print("Error during writing to stdout: " +lastException2String() + "\n") log = Logger( getLogTarget() ) @@ -162,9 +175,9 @@ class MyUriHelper: def __init__( self, ctx, location ): self.s_UriMap = \ - { "share" : "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + toIniName( "bootstrap") + "::BaseInstallation}/share/Scripts/python" , \ + { "share" : "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" + toIniName( "bootstrap") + "::BaseInstallation}/share/Scripts/python" , \ "share:uno_packages" : "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages", \ - "user" : "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + toIniName( "bootstrap") + "::UserInstallation}/user/Scripts/python" , \ + "user" : "vnd.sun.star.expand:${$OOO_BASE_DIR/program/" + toIniName( "bootstrap") + "::UserInstallation}/user/Scripts/python" , \ "user:uno_packages" : "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages" } self.m_uriRefFac = ctx.ServiceManager.createInstanceWithContext("com.sun.star.uri.UriReferenceFactory",ctx) if location.startswith( "vnd.sun.star.tdoc" ): @@ -202,10 +215,10 @@ class MyUriHelper: ret = self.m_baseUri + "/" + myUri.getName().replace( "|", "/" ) log.debug( "converting scriptURI="+scriptURI + " to storageURI=" + ret ) return ret - except UnoException, e: + except UnoException as e: log.error( "error during converting scriptURI="+scriptURI + ": " + e.Message) raise RuntimeException( "pythonscript:scriptURI2StorageUri: " +e.getMessage(), None ) - except Exception, e: + except Exception as e: log.error( "error during converting scriptURI="+scriptURI + ": " + str(e)) raise RuntimeException( "pythonscript:scriptURI2StorageUri: " + str(e), None ) @@ -320,7 +333,7 @@ class ProviderContext: def removePackageByUrl( self, url ): - items = self.mapPackageName2Path.items() + items = list(self.mapPackageName2Path.items()) for i in items: if url in i[1].pathes: self.mapPackageName2Path.pop(i[0]) @@ -330,7 +343,7 @@ class ProviderContext: packageName = self.getPackageNameFromUrl( url ) transientPart = self.getTransientPartFromUrl( url ) log.debug( "addPackageByUrl : " + packageName + ", " + transientPart + "("+url+")" + ", rootUrl="+self.rootUrl ) - if self.mapPackageName2Path.has_key( packageName ): + if packageName in self.mapPackageName2Path: package = self.mapPackageName2Path[ packageName ] package.pathes = package.pathes + (url, ) else: @@ -338,7 +351,7 @@ class ProviderContext: self.mapPackageName2Path[ packageName ] = package def isUrlInPackage( self, url ): - values = self.mapPackageName2Path.values() + values = list(self.mapPackageName2Path.values()) for i in values: # print "checking " + url + " in " + str(i.pathes) if url in i.pathes: @@ -432,7 +445,7 @@ class ProviderContext: code = compile( src, encfile(uno.fileUrlToSystemPath( url ) ), "exec" ) else: code = compile( src, url, "exec" ) - exec code in entry.module.__dict__ + exec(code, entry.module.__dict__) entry.module.__file__ = url self.modules[ url ] = entry log.debug( "mapped " + url + " to " + str( entry.module ) ) @@ -475,7 +488,7 @@ class ScriptBrowseNode( unohelper.Base, XBrowseNode , XPropertySet, XInvocation, ret = not self.provCtx.sfa.isReadOnly( self.uri ) log.debug( "ScriptBrowseNode.getPropertyValue called for " + name + ", returning " + str(ret) ) - except Exception,e: + except Exception as e: log.error( "ScriptBrowseNode.getPropertyValue error " + lastException2String()) raise @@ -520,10 +533,10 @@ class ScriptBrowseNode( unohelper.Base, XBrowseNode , XPropertySet, XInvocation, code = ensureSourceState( code ) mod = imp.new_module("ooo_script_framework") mod.__dict__[GLOBAL_SCRIPTCONTEXT_NAME] = self.provCtx.scriptContext - exec code in mod.__dict__ + exec(code, mod.__dict__) values = mod.__dict__.get( CALLABLE_CONTAINER_NAME , None ) if not values: - values = mod.__dict__.values() + values = list(mod.__dict__.values()) for i in values: if isScript( i ): @@ -544,7 +557,7 @@ class ScriptBrowseNode( unohelper.Base, XBrowseNode , XPropertySet, XInvocation, # log.debug("Save is not implemented yet") # text = self.editor.getControl("EditorTextField").getText() # log.debug("Would save: " + text) - except Exception,e: + except Exception as e: # TODO: add an error box here ! log.error( lastException2String() ) @@ -585,7 +598,7 @@ class FileBrowseNode( unohelper.Base, XBrowseNode ): self.provCtx, self.uri, self.name, i )) ret = tuple( scriptNodeList ) log.debug( "returning " +str(len(ret)) + " ScriptChildNodes on " + self.uri ) - except Exception, e: + except Exception as e: text = lastException2String() log.error( "Error while evaluating " + self.uri + ":" + text ) raise @@ -594,7 +607,7 @@ class FileBrowseNode( unohelper.Base, XBrowseNode ): def hasChildNodes(self): try: return len(self.getChildNodes()) > 0 - except Exception, e: + except Exception as e: return False def getType( self): @@ -625,7 +638,7 @@ class DirBrowseNode( unohelper.Base, XBrowseNode ): log.debug( "adding DirBrowseNode " + i ) browseNodeList.append( DirBrowseNode( self.provCtx, i[i.rfind("/")+1:len(i)],i)) return tuple( browseNodeList ) - except Exception, e: + except Exception as e: text = lastException2String() log.error( "DirBrowseNode error: " + str(e) + " while evaluating " + self.rootUrl) log.error( text) @@ -697,7 +710,7 @@ def getPathesFromPackage( rootUrl, sfa ): if not isPyFileInPath( sfa, i ): handler.urlList.remove(i) ret = tuple( handler.urlList ) - except UnoException, e: + except UnoException as e: text = lastException2String() log.debug( "getPathesFromPackage " + fileUrl + " Exception: " +text ) pass @@ -765,7 +778,7 @@ def getModelFromDocUrl(ctx, url): try: ret = content.execute(c, 0, env) doc = ret.getObject(1, None) - except Exception, e: + except Exception as e: log.isErrorLevel() and log.error("getModelFromDocUrl: %s" % url) return doc @@ -818,7 +831,7 @@ class PackageBrowseNode( unohelper.Base, XBrowseNode ): return self.name def getChildNodes( self ): - items = self.provCtx.mapPackageName2Path.items() + items = list(self.provCtx.mapPackageName2Path.items()) browseNodeList = [] for i in items: if len( i[1].pathes ) == 1: @@ -851,7 +864,7 @@ class PythonScript( unohelper.Base, XScript ): log.debug( "PythonScript.invoke " + str( args ) ) try: ret = self.func( *args ) - except UnoException,e: + except UnoException as e: # UNO Exception continue to fly ... text = lastException2String() complete = "Error during invoking function " + \ @@ -864,7 +877,7 @@ class PythonScript( unohelper.Base, XScript ): # this is really bad for most users. e.Message = e.Message + " (" + complete + ")" raise - except Exception,e: + except Exception as e: # General python exception are converted to uno RuntimeException text = lastException2String() complete = "Error during invoking function " + \ @@ -911,7 +924,7 @@ class PythonScriptProvider( unohelper.Base, XBrowseNode, XScriptProvider, XNameC "com.sun.star.frame.TransientDocumentsDocumentContentFactory", ctx).createDocumentContent(doc) storageType = content.getIdentifier().getContentIdentifier() - except Exception, e: + except Exception as e: text = lastException2String() log.error( text ) @@ -941,7 +954,7 @@ class PythonScriptProvider( unohelper.Base, XBrowseNode, XScriptProvider, XNameC else: self.dirBrowseNode = DirBrowseNode( self.provCtx, LANGUAGENAME, rootUrl ) - except Exception, e: + except Exception as e: text = lastException2String() log.debug( "PythonScriptProvider could not be instantiated because of : " + text ) raise e @@ -980,7 +993,7 @@ class PythonScriptProvider( unohelper.Base, XBrowseNode, XScriptProvider, XNameC log.debug( "got func " + str( func ) ) return PythonScript( func, mod ) - except Exception, e: + except Exception as e: text = lastException2String() log.error( text ) raise ScriptFrameworkErrorException( text, self, scriptUri, LANGUAGENAME, 0 ) @@ -1012,7 +1025,7 @@ class PythonScriptProvider( unohelper.Base, XBrowseNode, XScriptProvider, XNameC ret = self.provCtx.isUrlInPackage( uri ) log.debug( "hasByName " + uri + " " +str( ret ) ) return ret - except Exception, e: + except Exception as e: text = lastException2String() log.debug( "Error in hasByName:" + text ) return False diff --git a/scripting/source/storage/ScriptStorageManager.cxx b/scripting/source/storage/ScriptStorageManager.cxx index 623591cefbec..3b0d3f350df1 100644 --- a/scripting/source/storage/ScriptStorageManager.cxx +++ b/scripting/source/storage/ScriptStorageManager.cxx @@ -82,7 +82,7 @@ ScriptStorageManager::ScriptStorageManager( const Reference< "/singletons/com.sun.star.util.theMacroExpander" ) ), UNO_QUERY_THROW ); OUString base = OUString::createFromAscii( - SAL_CONFIGFILE( "${$BRAND_BASE_DIR/program/bootstrap" ) ); + SAL_CONFIGFILE( "${$OOO_BASE_DIR/program/bootstrap" ) ); setupAppStorage( xME, base.concat( OUString::createFromAscii( "::BaseInstallation}/share" ) ), diff --git a/scripting/workben/build.xml b/scripting/workben/build.xml index 37281d31ef69..d41690a519ee 100644 --- a/scripting/workben/build.xml +++ b/scripting/workben/build.xml @@ -26,7 +26,7 @@ <property name="prj" value=".."/> <property file="${prj}/java/build.env"/> - <property name="build.compiler" value="classic"/> + <property name="build.compiler" value="modern"/> <property name="optimize" value="on"/> <property name="debug" value="on"/> <property name="installerclasses" value="${out}/class/sframeworkinstall"/> |