diff options
Diffstat (limited to 'scripting')
12 files changed, 187 insertions, 25 deletions
diff --git a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java index 3b9e04a27210..edf6a2d806b7 100644 --- a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java +++ b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java @@ -44,15 +44,21 @@ import com.sun.star.io.XOutputStream; import com.sun.star.io.XTruncate; import com.sun.star.deployment.XPackage; +import com.sun.star.deployment.ExtensionRemovedException; public class UnoPkgContainer extends ParcelContainer { private Map registeredPackages = new HashMap(); + protected String extensionDb; + protected String extensionRepository; - public UnoPkgContainer( XComponentContext xCtx, String locationURL, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException + public UnoPkgContainer( XComponentContext xCtx, String locationURL, + String _extensionDb, String _extensionRepository, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException { super( xCtx, locationURL, language, false ); + extensionDb = _extensionDb; + extensionRepository = _extensionRepository; init(); } @@ -217,8 +223,8 @@ public class UnoPkgContainer extends ParcelContainer DeployedUnoPackagesDB dp = null; try { - String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") ); - String packagesUrl = PathUtils.make_url( path, "Scripts/unopkg-desc.xml" ); +// String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") ); + String packagesUrl = PathUtils.make_url( extensionDb, "/Scripts/" + extensionRepository + "-extension-desc.xml" ); LogUtils.DEBUG("getUnoPackagesDB() looking for existing db in " + packagesUrl ); if ( m_xSFA.exists( packagesUrl ) ) { @@ -276,8 +282,8 @@ public class UnoPkgContainer extends ParcelContainer OutputStream os = null; try { - String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") ); - String packagesUrl = PathUtils.make_url( path, "Scripts/unopkg-desc.xml" ); +// String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") ); + String packagesUrl = PathUtils.make_url( extensionDb, "/Scripts/" + extensionRepository + "-extension-desc.xml" ); xos = m_xSFA.openFileWrite( packagesUrl ); XTruncate xTrc = (XTruncate) UnoRuntime.queryInterface( XTruncate.class, xos ); if ( xTrc != null ) @@ -336,7 +342,15 @@ public class UnoPkgContainer extends ParcelContainer LogUtils.DEBUG("** processUnoPackage getURL() -> " + uri ); LogUtils.DEBUG("** processUnoPackage getName() -> " + dPackage.getName() ); LogUtils.DEBUG("** processUnoPackage getMediaType() -> " + dPackage.getPackageType().getMediaType() ); - LogUtils.DEBUG("** processUnoPackage getDisplayName() -> " + dPackage.getDisplayName() ); + try + { + LogUtils.DEBUG("** processUnoPackage getDisplayName() -> " + dPackage.getDisplayName() ); + } + catch (com.sun.star.deployment.ExtensionRemovedException e) + { + throw new com.sun.star.lang.WrappedTargetException(e.toString(), this, e); + } + processUnoPackage( uri, language ); db = getUnoPackagesDB(); @@ -366,7 +380,10 @@ public class UnoPkgContainer extends ParcelContainer String parentUrl = uri; if ( uri.indexOf( "%2Funo_packages%2F" ) > -1 || - uri.indexOf( "/uno_packages/" ) > -1 ) + uri.indexOf( "/uno_packages/" ) > -1 || + uri.indexOf("$UNO_USER_PACKAGES_CACHE/") > -1 || + uri.indexOf("$UNO_SHARED_PACKAGES_CACHE/") > -1 || + uri.indexOf("$BUNDLED_EXTENSIONS/") > -1 ) { //its in a bundle need to determine the uno-package file its in LogUtils.DEBUG("processUnoPackage - is part of a uno bundle"); 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 c43756072ba3..e83410f3f35c 100755 --- a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java +++ b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java @@ -213,26 +213,40 @@ public abstract class ScriptProvider } else { + String extensionDb = null; + String extensionRepository = null; + 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"; + 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"; + 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"; + extensionRepository = "user"; } if ( originalContextURL.endsWith( "uno_packages") ) { isPkgProvider = true; } - if ( originalContextURL.endsWith( "uno_packages") && !originalContextURL.equals( contextUrl ) ) + if ( originalContextURL.endsWith( "uno_packages") && !originalContextURL.equals( contextUrl ) + && !extensionRepository.equals("bundled")) { contextUrl = PathUtils.make_url( contextUrl, "uno_packages" ); } if ( isPkgProvider ) { - m_container = new UnoPkgContainer( m_xContext, contextUrl, language ); + m_container = new UnoPkgContainer( m_xContext, contextUrl, extensionDb, extensionRepository, language ); } else { diff --git a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties index 3137b89dde94..f776ff9e7933 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/Bundle.properties @@ -1,5 +1,6 @@ # Filesystems API # {0} - root path +# x-no-translate LAB_invalid_file_system=invalid OpenOffice.org document {0} # {0} - root path LAB_valid_file_system={0} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties index a3bf47447607..eab2fa1f3fbc 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/Bundle.properties @@ -3,6 +3,7 @@ #HINT_myProp=<description of my property> #LBL_DataNode_exec_sheet=Execution #HINT_DataNode_exec_sheet=Properties pertaining to compiling, running, and debugging. +# x-no-translate LBL_loaderName=<display name of the data loader> # Datasystems API #PROP_myProp=<name of my property> diff --git a/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties index b823204cb227..6a9112e8c768 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/options/Bundle.properties @@ -1,4 +1,5 @@ # Options API +# x-no-translate LBL_settings=Office Settings PROP_OfficeDirectory=Path to Office installation HINT_OfficeDirectory=Path to the Office installation diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties index 58989c2506b7..22aea6525f3d 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/Bundle.properties @@ -1,3 +1,4 @@ +# x-no-translate Templates/OfficeScripting=Office Scripting Templates/OfficeScripting/parcel.xml=Script Parcel Descriptor Services/MIMEResolver/org-netbeans-modules-office-mime-resolver.xml=Script Parcel Descriptor File diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties index 0e4f2bd100c7..a40b4b373959 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties @@ -1,4 +1,5 @@ # Window System API +# x-no-translate # TopComponent LBL_component_name=<name of component> diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx index aa6c6cfb966a..0fc0778c71d9 100644 --- a/scripting/source/dlgprov/dlgprov.cxx +++ b/scripting/source/dlgprov/dlgprov.cxx @@ -766,6 +766,31 @@ static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAs return xDialog; } + Reference < XDialog > DialogProviderImpl::createDialogWithArguments( + const ::rtl::OUString& URL, const Sequence< NamedValue >& Arguments ) + throw (IllegalArgumentException, RuntimeException) + { + ::comphelper::NamedValueCollection aArguments( Arguments ); + + Reference< XWindowPeer > xParentPeer; + if ( aArguments.has( "ParentWindow" ) ) + { + const Any aParentWindow( aArguments.get( "ParentWindow" ) ); + if ( !( aParentWindow >>= xParentPeer ) ) + { + const Reference< XControl > xParentControl( aParentWindow, UNO_QUERY ); + if ( xParentControl.is() ) + xParentPeer = xParentControl->getPeer(); + } + } + + const Reference< XInterface > xHandler( aArguments.get( "EventHandler" ), UNO_QUERY ); + + Reference < XControl > xControl = DialogProviderImpl::createDialogImpl( URL, xHandler, xParentPeer, true ); + Reference< XDialog > xDialog( xControl, UNO_QUERY ); + return xDialog; + } + Reference< XWindow > DialogProviderImpl::createContainerWindow( const ::rtl::OUString& URL, const ::rtl::OUString& WindowType, const Reference< XWindowPeer >& xParent, const Reference< XInterface >& xHandler ) diff --git a/scripting/source/dlgprov/dlgprov.hxx b/scripting/source/dlgprov/dlgprov.hxx index f55239ff13e8..bc15831d2ff1 100644 --- a/scripting/source/dlgprov/dlgprov.hxx +++ b/scripting/source/dlgprov/dlgprov.hxx @@ -138,6 +138,11 @@ namespace dlgprov const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xHandler ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference < ::com::sun::star::awt::XDialog > SAL_CALL createDialogWithArguments( + const ::rtl::OUString& URL, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createContainerWindow( const ::rtl::OUString& URL, const ::rtl::OUString& WindowType, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent, diff --git a/scripting/source/provider/ActiveMSPList.cxx b/scripting/source/provider/ActiveMSPList.cxx index f8400ed77950..3c6206d8d051 100644 --- a/scripting/source/provider/ActiveMSPList.cxx +++ b/scripting/source/provider/ActiveMSPList.cxx @@ -59,6 +59,7 @@ ActiveMSPList::ActiveMSPList( const Reference< XComponentContext > & xContext ) { userDirString = ::rtl::OUString::createFromAscii("user"); shareDirString = ::rtl::OUString::createFromAscii("share"); + bundledDirString = ::rtl::OUString::createFromAscii("bundled"); } ActiveMSPList::~ActiveMSPList() @@ -307,6 +308,12 @@ ActiveMSPList::createNonDocMSPs() Reference< provider::XScriptProvider > shareMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY ); // should check if provider reference is valid m_hMsps[ shareDirString ] = shareMsp; + + args[ 0 ] <<= bundledDirString; + Reference< provider::XScriptProvider > bundledMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY ); + // should check if provider reference is valid + m_hMsps[ bundledDirString ] = bundledMsp; + created = true; } diff --git a/scripting/source/provider/ActiveMSPList.hxx b/scripting/source/provider/ActiveMSPList.hxx index 5adf2fc5a961..b127f3c41b16 100644 --- a/scripting/source/provider/ActiveMSPList.hxx +++ b/scripting/source/provider/ActiveMSPList.hxx @@ -107,6 +107,7 @@ private: osl::Mutex m_mutex; ::rtl::OUString userDirString; ::rtl::OUString shareDirString; + ::rtl::OUString bundledDirString; css::uno::Reference< css::uno::XComponentContext > m_xContext; }; } // func_provider diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py index f9c2f0f70b09..6592a59d1843 100644 --- a/scripting/source/pyprov/mailmerge.py +++ b/scripting/source/pyprov/mailmerge.py @@ -16,6 +16,8 @@ import uno import re #to implement com::sun::star::mail::XMailServiceProvider +#and +#to implement com.sun.star.mail.XMailMessage from com.sun.star.mail import XMailServiceProvider from com.sun.star.mail import XMailService @@ -37,7 +39,7 @@ from email import Encoders from email.Header import Header from email.MIMEMultipart import MIMEMultipart from email.Utils import formatdate -from email.Utils import formataddr +from email.Utils import parseaddr import sys, smtplib, imaplib, poplib @@ -118,30 +120,46 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): print >> sys.stderr, "PyMailSMPTService sendMailMessage" recipients = xMailMessage.getRecipients() sendermail = xMailMessage.SenderAddress - sendername = xMailMessage.SenderName + sendername = xMailMessage.SenderName subject = xMailMessage.Subject ccrecipients = xMailMessage.getCcRecipients() bccrecipients = xMailMessage.getBccRecipients() if dbg: print >> sys.stderr, "PyMailSMPTService subject", subject - print >> sys.stderr, "PyMailSMPTService from", sendername.encode('utf-8'), sendermail - print >> sys.stderr, "PyMailSMTPService from", formataddr((sendername.encode('utf-8'), sendermail)) + print >> sys.stderr, "PyMailSMPTService from", sendername.encode('utf-8') + print >> sys.stderr, "PyMailSMTPService from", sendermail print >> sys.stderr, "PyMailSMPTService send to", recipients attachments = xMailMessage.getAttachments() + textmsg = Message() + content = xMailMessage.Body flavors = content.getTransferDataFlavors() - flavor = flavors[0] if dbg: - print >> sys.stderr, "PyMailSMPTService mimetype is", flavor.MimeType - textbody = content.getTransferData(flavor) + print >> sys.stderr, "PyMailSMPTService flavors len", len(flavors) - textmsg = Message() - mimeEncoding = re.sub("charset=.*", "charset=UTF-8", flavor.MimeType) - textmsg['Content-Type'] = mimeEncoding - textmsg['MIME-Version'] = '1.0' - textmsg.set_payload(textbody.encode('utf-8')) + #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 + textbody = content.getTransferData(flavor) + try: + textbody = textbody.value + except: + pass + textbody = textbody.encode('utf-8') + + if len(textbody): + mimeEncoding = re.sub("charset=.*", "charset=UTF-8", flavor.MimeType) + if mimeEncoding.find('charset=UTF-8') == -1: + mimeEncoding = mimeEncoding + "; charset=UTF-8" + textmsg['Content-Type'] = mimeEncoding + textmsg['MIME-Version'] = '1.0' + textmsg.set_payload(textbody) + + break if (len(attachments)): msg = MIMEMultipart() @@ -150,15 +168,31 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): else: msg = textmsg - msg['Subject'] = subject - msg['From'] = formataddr((sendername.encode('utf-8'), sendermail)) + hdr = Header(sendername, 'utf-8') + hdr.append('<'+sendermail+'>','us-ascii') + msg['Subject'] = subject + msg['From'] = hdr msg['To'] = COMMASPACE.join(recipients) if len(ccrecipients): msg['Cc'] = COMMASPACE.join(ccrecipients) if xMailMessage.ReplyToAddress != '': msg['Reply-To'] = xMailMessage.ReplyToAddress - msg['X-Mailer'] = "OpenOffice.org 2.0 via Caolan's mailmerge component" + mailerstring = "OpenOffice.org 2.0 via Caolan's mailmerge component" + try: + ctx = uno.getComponentContext() + aConfigProvider = ctx.ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider") + prop = uno.createUnoStruct('com.sun.star.beans.PropertyValue') + prop.Name = "nodepath" + prop.Value = "/org.openoffice.Setup/Product" + aSettings = aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", + (prop,)) + mailerstring = aSettings.getByName("ooName") + " " + \ + aSettings.getByName("ooSetupVersion") + " via Caolan's mailmerge component" + except: + pass + + msg['X-Mailer'] = mailerstring msg['Date'] = formatdate(localtime=True) for attachment in attachments: @@ -344,9 +378,63 @@ class PyMailServiceProvider(unohelper.Base, XMailServiceProvider): else: print >> sys.stderr, "PyMailServiceProvider, unknown TYPE", aType +class PyMailMessage(unohelper.Base, XMailMessage): + def __init__( self, ctx, sTo='', sFrom='', Subject='', Body=None, aMailAttachment=None ): + if dbg: + print >> sys.stderr, "PyMailMessage init" + self.ctx = ctx + + self.recipients = sTo, + self.ccrecipients = () + self.bccrecipients = () + self.aMailAttachments = () + if aMailAttachment != None: + self.aMailAttachments = aMailAttachment, + + self.SenderName, self.SenderAddress = parseaddr(sFrom) + self.ReplyToAddress = sFrom + self.Subject = Subject + self.Body = Body + if dbg: + print >> sys.stderr, "post PyMailMessage init" + def addRecipient( self, recipient ): + if dbg: + print >> sys.stderr, "PyMailMessage.addRecipient", recipient + self.recipients = self.recipients, recipient + def addCcRecipient( self, ccrecipient ): + if dbg: + print >> sys.stderr, "PyMailMessage.addCcRecipient", ccrecipient + self.ccrecipients = self.ccrecipients, ccrecipient + def addBccRecipient( self, bccrecipient ): + if dbg: + print >> sys.stderr, "PyMailMessage.addBccRecipient", bccrecipient + self.bccrecipients = self.bccrecipients, bccrecipient + def getRecipients( self ): + if dbg: + print >> sys.stderr, "PyMailMessage.getRecipients", self.recipients + return self.recipients + def getCcRecipients( self ): + if dbg: + print >> sys.stderr, "PyMailMessage.getCcRecipients", self.ccrecipients + return self.ccrecipients + def getBccRecipients( self ): + if dbg: + print >> sys.stderr, "PyMailMessage.getBccRecipients", self.bccrecipients + return self.bccrecipients + def addAttachment( self, aMailAttachment ): + if dbg: + print >> sys.stderr, "PyMailMessage.addAttachment" + self.aMailAttachments = self.aMailAttachments, aMailAttachment + def getAttachments( self ): + if dbg: + print >> sys.stderr, "PyMailMessage.getAttachments" + return self.aMailAttachments + # pythonloader looks for a static g_ImplementationHelper variable g_ImplementationHelper = unohelper.ImplementationHelper() g_ImplementationHelper.addImplementation( \ PyMailServiceProvider, "org.openoffice.pyuno.MailServiceProvider", ("com.sun.star.mail.MailServiceProvider",),) - +g_ImplementationHelper.addImplementation( \ + PyMailMessage, "org.openoffice.pyuno.MailMessage", + ("com.sun.star.mail.MailMessage",),) |