Commits

Anonymous committed a5fdfb6

CWS-TOOLING: integrate CWS jl119_DEV300
2009-03-13 08:14:58 +0100 jl r269453 : CWS-TOOLING: rebase CWS jl119 to branches/OOO310@269350 (milestone: OOO310:m5)
2009-03-10 16:01:33 +0100 jl r269280 : #i98990# apply patch by jbu: fixing the python script provider
2009-03-10 13:25:02 +0100 jl r269268 : #i93939#
2009-03-10 11:44:07 +0100 jl r269261 : #i93939#
2009-03-09 17:14:58 +0100 jl r269205 : #i93939# choose a different JRE when the selected one was uninstalled
2009-03-09 16:34:34 +0100 jl r269201 : #i93939# choose a different JRE when the selected one was uninstalled
2009-03-05 16:40:16 +0100 jl r268924 : #99618# Do not migrate java settings
2009-02-25 14:29:53 +0100 jl r268439 : #i99618# do not invalidate existing javasettings by using a new date in the update element

Comments (0)

Files changed (12)

jvmfwk/distributions/OpenOfficeorg/javavendors_linux.xml

 <javaSelection xmlns="http://openoffice.org/2004/java/framework/1.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  
- <updated>2008-01-16</updated>
+ <updated>2004-01-30</updated>
  
  <vendorInfos> 
   <vendor name="Sun Microsystems Inc.">

jvmfwk/distributions/OpenOfficeorg/javavendors_macosx.xml

 <javaSelection xmlns="http://openoffice.org/2004/java/framework/1.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
- <updated>2008-01-16</updated>
+ <updated>2006-05-02</updated>
 
  <vendorInfos>
   <vendor name="Apple Computer, Inc.">

jvmfwk/distributions/OpenOfficeorg/javavendors_os2.xml

 <javaSelection xmlns="http://openoffice.org/2004/java/framework/1.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  
- <updated>2008-01-16</updated>
+ <updated>2004-01-30</updated>
  
  <vendorInfos> 
   <vendor name="Sun Microsystems Inc.">

jvmfwk/distributions/OpenOfficeorg/javavendors_unx.xml

 <javaSelection xmlns="http://openoffice.org/2004/java/framework/1.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  
- <updated>2008-01-16</updated>
+ <updated>2004-01-30</updated>
  
  <vendorInfos> 
   <vendor name="Sun Microsystems Inc.">
  <plugins>
   <library vendor="Sun Microsystems Inc.">vnd.sun.star.expand:$URE_INTERNAL_LIB_DIR/sunjavaplugin.so</library>
  </plugins>
-</javaSelection>
+</javaSelection>

jvmfwk/distributions/OpenOfficeorg/javavendors_wnt.xml

 <javaSelection xmlns="http://openoffice.org/2004/java/framework/1.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  
- <updated>2008-01-16</updated>
+ <updated>2004-01-30</updated>
  
  <vendorInfos> 
   <vendor name="Sun Microsystems Inc.">

jvmfwk/inc/jvmfwk/framework.h

 javaFrameworkError SAL_CALL jfw_getJRELocations(
     rtl_uString *** parLocations, sal_Int32 * pSize);
 
+
+/** checks if the installation of the jre still exists.
+
+    This function checks if the JRE described by pInfo still
+    exists. The check must be very quick because it is called by javaldx
+    (Linux, Solaris) at start up.
+
+    @param pInfo
+        [in]  the JavaInfo object with information about the JRE.
+    @param pp_exist
+        [out] the parameter is set to either sal_True or sal_False. The value is
+        only valid if the function returns JFW_E_NONE.
+    
+   @return
+    JFW_E_NONE the function ran successfully.</br>
+    JFW_E_ERROR an error occurred during execution.</br>
+    JFW_E_INVALID_ARG pInfo contains invalid data</br>
+ */
+javaFrameworkError SAL_CALL jfw_existJRE(const JavaInfo *pInfo, sal_Bool *exist);
+
+
 /** locks this API so that it cannot be used by other threads.
 
     <p>If a different thread called this function before then the

jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx

 
 static sal_Bool hasOption(char const * szOption, int argc, char** argv);
 static rtl::OString getLD_LIBRARY_PATH(const rtl::ByteSequence & vendorData);
+static bool findAndSelect(JavaInfo**);
 //static sal_Bool printPaths(const OUString& sPathFile);
 
 #define HELP_TEXT    \
         fprintf(stderr,"javaldx failed! \n");
         return -1;
     }
-
+    
     if (pInfo == NULL)
     {
-        errcode = jfw_findAndSelectJRE( & pInfo);
-        if (errcode == JFW_E_NO_JAVA_FOUND)
+        if (false == findAndSelect(&pInfo))
+            return -1;
+    }
+    else
+    {
+        //check if the JRE was not uninstalled
+        sal_Bool bExist = sal_False;
+        errcode = jfw_existJRE(pInfo, &bExist);
+        if (errcode == JFW_E_NONE)
         {
-            fprintf(stderr,"javaldx: Could not find a Java Runtime Environment! \n");
-            return 0;
+            if (false == findAndSelect(&pInfo))
+                return -1;
         }
-        else if (errcode != JFW_E_NONE && errcode != JFW_E_DIRECT_MODE)
+        else
         {
-            fprintf(stderr,"javaldx failed!\n");
+            fprintf(stderr, "javaldx: Could not determine if JRE still exist\n");
             return -1;
         }
     }
-
+    
     //Only do something if the sunjavaplugin created this JavaInfo
     rtl::OUString sVendor1(RTL_CONSTASCII_USTRINGPARAM("Sun Microsystems Inc."));
     rtl::OUString sVendor2(RTL_CONSTASCII_USTRINGPARAM("IBM Corporation"));
     return retVal;
 }
 
+static bool findAndSelect(JavaInfo ** ppInfo)
+{
+    javaFrameworkError errcode = jfw_findAndSelectJRE(ppInfo);
+    if (errcode == JFW_E_NO_JAVA_FOUND)
+    {
+        fprintf(stderr,"javaldx: Could not find a Java Runtime Environment! \n");
+        return false;
+    }
+    else if (errcode != JFW_E_NONE && errcode != JFW_E_DIRECT_MODE)
+    {
+        fprintf(stderr,"javaldx failed!\n");
+        return false;
+    }
+    return true;
+}
 
 
 
-

jvmfwk/source/framework.cxx

 #include "rtl/ustring.hxx"
 #include "rtl/bootstrap.hxx"
 #include "osl/thread.hxx"
+#include "osl/file.hxx"
 #include "osl/module.hxx"
 #include "jvmfwk/framework.h"
 #include "jvmfwk/vendorplugin.h"
     return errcode;    
 }
 
+
+javaFrameworkError jfw_existJRE(const JavaInfo *pInfo, sal_Bool *exist)
+{
+    javaFrameworkError ret = JFW_E_NONE;
+    if (!pInfo || !exist)
+        return JFW_E_INVALID_ARG;
+    ::rtl::OUString sLocation(pInfo->sLocation);
+
+    if (sLocation.getLength() == 0)
+        return JFW_E_INVALID_ARG;
+
+    ::osl::DirectoryItem item;
+    ::osl::File::RC rc_item = ::osl::DirectoryItem::get(sLocation, item);
+    if (::osl::File::E_None == rc_item)
+    {
+        *exist = sal_True;
+    }
+    else if (::osl::File::E_NOENT == rc_item)
+    {
+        *exist = sal_False;
+    }
+    else
+    {
+        ret = JFW_E_ERROR;
+    }
+
+    return ret;
+}
+
 void SAL_CALL jfw_lock()
 {
     jfw::FwkMutex::get().acquire();

jvmfwk/source/framework.map

     local:
         *;
 };
+
+UDK_3.1 { # OOo 3.1.0
+    global:
+	jfw_existJRE;
+} UDK_3_0_0;

officecfg/registry/data/org/openoffice/Setup.xcu

 					</value>
 				</prop>
 			</node>
-			<node oor:name="Java" oor:op="replace">
-        <prop oor:name="IncludedFiles">
-          <value>.*/config/javasettings_.*\.xml</value>
-        </prop>
-			</node>
 			<node oor:name="Basic" oor:op="replace">
 				<prop oor:name="MigrationService">
 					<value>com.sun.star.migration.Basic</value>
 					<value>
             .*/autotext/.*
             .*/autocorr/.*
-			<node oor:name="Java" oor:op="replace">
-        <prop oor:name="IncludedFiles">
-          <value>.*/config/javasettings_.*\.xml</value>
-        </prop>
-			</node>
             .*/config/.*\.so[bcdegh]
             .*/config/soffice.cfg/modules/.*/toolbar/custom.*\.xml
             .*/config/soffice.cfg/modules/.*/images/.*

scripting/source/pyprov/pythonscript.py

 from com.sun.star.uno import RuntimeException
 from com.sun.star.lang import XServiceInfo
 from com.sun.star.io import IOException
-from com.sun.star.ucb import CommandAbortedException
+from com.sun.star.ucb import CommandAbortedException, XCommandEnvironment, XProgressHandler
+from com.sun.star.task import XInteractionHandler
 from com.sun.star.beans import XPropertySet
 from com.sun.star.container import XNameContainer
 from com.sun.star.xml.sax import XDocumentHandler, InputSource
 from com.sun.star.script.provider import XScriptProvider, XScript, XScriptContext, ScriptFrameworkErrorException
 from com.sun.star.script.browse import XBrowseNode
 from com.sun.star.script.browse.BrowseNodeTypes import SCRIPT, CONTAINER, ROOT
+from com.sun.star.util import XModifyListener
 
 LANGUAGENAME = "Python"
 GLOBAL_SCRIPTCONTEXT_NAME = "XSCRIPTCONTEXT"
     def addPackageByUrl( self, url ):
         packageName = self.getPackageNameFromUrl( url )
         transientPart = self.getTransientPartFromUrl( url )
-        log.isDebugLevel() and log.debug( "addPackageByUrl : " + packageName + ", " + transientPart )
+        log.isDebugLevel() and log.debug( "addPackageByUrl : " + packageName + ", " + transientPart + "("+url+")" + ", rootUrl="+self.rootUrl )
         if self.mapPackageName2Path.has_key( packageName ):
             package = self.mapPackageName2Path[ packageName ]
             package.pathes = package.pathes + (url, )
     def isUrlInPackage( self, url ):
         values = self.mapPackageName2Path.values()
         for i in values:
+#	    print "checking " + url + " in " + str(i.pathes)
             if url in i.pathes:
                return True
+#        print "false"
         return False
             
     def setPackageAttributes( self, mapPackageName2Path, rootUrl ):
     def setDocumentLocator( self, locator ):
         pass
 
+def isPyFileInPath( sfa, path ):
+    ret = False
+    contents = sfa.getFolderContents( path, True )
+    for i in contents:
+        if sfa.isFolder(i):
+            ret = isPyFileInPath(sfa,i)
+        else:
+            if i.endswith(".py"):
+                ret = True
+        if ret:
+            break
+    return ret
 
 # extracts META-INF directory from 
 def getPathesFromPackage( rootUrl, sfa ):
         handler = ManifestHandler( rootUrl )
         parser.setDocumentHandler( handler )
         parser.parseStream( InputSource( inputStream , "", fileUrl, fileUrl ) )
+        for i in tuple(handler.urlList):
+            if not isPyFileInPath( sfa, i ):
+                handler.urlList.remove(i)
         ret = tuple( handler.urlList )
     except UnoException, e:
         text = lastException2String()
         self.pathes = pathes
         self.transientPathElement = transientPathElement
 
-def getPackageName2PathMap( sfa, rootUrl ):
+class DummyInteractionHandler( unohelper.Base, XInteractionHandler ):
+    def __init__( self ):
+        pass
+    def handle( self, event):
+        log.isDebugLevel() and log.debug( "pythonscript: DummyInteractionHandler.handle " + str( event ) )
+
+class DummyProgressHandler( unohelper.Base, XProgressHandler ):
+    def __init__( self ):
+        pass
+    
+    def push( self,status ): 
+        log.isDebugLevel() and log.debug( "pythonscript: DummyProgressHandler.push " + str( status ) )
+    def update( self,status ): 
+        log.isDebugLevel() and log.debug( "pythonscript: DummyProgressHandler.update " + str( status ) )
+    def pop( self ): 
+        log.isDebugLevel() and log.debug( "pythonscript: DummyProgressHandler.push " + str( event ) )
+
+class CommandEnvironment(unohelper.Base, XCommandEnvironment):
+    def __init__( self ):
+        self.progressHandler = DummyProgressHandler()
+        self.interactionHandler = DummyInteractionHandler()
+    def getInteractionHandler( self ):
+        return self.interactionHandler
+    def getProgressHandler( self ):
+        return self.progressHandler
+
+#maybe useful for debugging purposes
+#class ModifyListener( unohelper.Base, XModifyListener ):
+#    def __init__( self ):
+#        pass
+#    def modified( self, event ):
+#        log.isDebugLevel() and log.debug( "pythonscript: ModifyListener.modified " + str( event ) )
+#    def disposing( self, event ):
+#        log.isDebugLevel() and log.debug( "pythonscript: ModifyListener.disposing " + str( event ) )
+    
+def mapStorageType2PackageContext( storageType ):
+    ret = storageType
+    if( storageType == "share:uno_packages" ):
+        ret = "shared"
+    if( storageType == "user:uno_packages" ):
+        ret = "user"
+    return ret
+
+def getPackageName2PathMap( sfa, storageType ):
     ret = {}
-    contents = sfa.getFolderContents( rootUrl, True )
-    for i in contents:
-        if sfa.isFolder( i ):
-            transientPathElement = lastElement( i )
-            subcontents = sfa.getFolderContents( i , True )
-            for j in subcontents:
-                if sfa.isFolder( j ):
-                    # ok, found a package. Now let's have a look, if
-                    # it contains scripts
-                    pathes = getPathesFromPackage( j, sfa )
-                    if len( pathes ) > 0:
-                        # map package name to url, we need this later
-                        log.isErrorLevel() and log.error( "adding Package " + transientPathElement + " " + str( pathes ) )
-                        ret[ lastElement( j ) ] = Package( pathes, transientPathElement )
+    packageManagerFactory = uno.getComponentContext().getValueByName(
+        "/singletons/com.sun.star.deployment.thePackageManagerFactory" )
+    packageManager = packageManagerFactory.getPackageManager(
+        mapStorageType2PackageContext(storageType))
+#    packageManager.addModifyListener( ModifyListener() )
+    log.isDebugLevel() and log.debug( "pythonscript: getPackageName2PathMap start getDeployedPackages" )
+    packages = packageManager.getDeployedPackages(
+        packageManager.createAbortChannel(), CommandEnvironment( ) )
+    log.isDebugLevel() and log.debug( "pythonscript: getPackageName2PathMap end getDeployedPackages (" + str(len(packages))+")" )
+
+    for i in packages:
+        log.isDebugLevel() and log.debug( "inspecting package " + i.Name + "("+i.Identifier.Value+")" )
+        transientPathElement = penultimateElement( i.URL )
+        j = expandUri( i.URL )
+        pathes = getPathesFromPackage( j, sfa )
+        if len( pathes ) > 0:
+            # map package name to url, we need this later
+            log.isErrorLevel() and log.error( "adding Package " + transientPathElement + " " + str( pathes ) )
+            ret[ lastElement( j ) ] = Package( pathes, transientPathElement )
     return ret
 
+def penultimateElement( aStr ):
+    lastSlash = aStr.rindex("/")
+    penultimateSlash = aStr.rindex("/",0,lastSlash-1)
+    return  aStr[ penultimateSlash+1:lastSlash ]
+
 def lastElement( aStr):
     return aStr[ aStr.rfind( "/" )+1:len(aStr)]
 
             
             log.isDebugLevel() and log.debug( "got urlHelper " + str( urlHelper ) )
         
-            rootUrl = urlHelper.getRootStorageURI()
+            rootUrl = expandUri( urlHelper.getRootStorageURI() )
             log.isDebugLevel() and log.debug( storageType + " transformed to " + rootUrl )
 
             ucbService = "com.sun.star.ucb.SimpleFileAccess"
             self.provCtx = ProviderContext(
                 storageType, sfa, urlHelper, ScriptContext( uno.getComponentContext(), None ) )
             if isPackage:
-                mapPackageName2Path = getPackageName2PathMap( sfa, rootUrl )
+                mapPackageName2Path = getPackageName2PathMap( sfa, storageType )
                 self.provCtx.setPackageAttributes( mapPackageName2Path , rootUrl )
                 self.dirBrowseNode = PackageBrowseNode( self.provCtx, LANGUAGENAME, rootUrl )
             else:
     def removeByName( self, name ):
         log.debug( "removeByName called" + str( name ))
         uri = expandUri( name )
-        self.provCtx.removePackageByUrl( uri )
+        if self.provCtx.isUrlInPackage( uri ):
+            self.provCtx.removePackageByUrl( uri )
+        else:
+            log.debug( "removeByName unknown uri " + str( name ) + ", ignoring" )
+            raise NoSuchElementException( uri + "is not in package" , self )
         log.debug( "removeByName called" + str( uri ) + " successful" )
         
     def insertByName( self, name, value ):
         log.debug( "insertByName called " + str( name ) + " " + str( value ))
         uri = expandUri( name )
-        self.provCtx.addPackageByUrl( uri )
-        log.debug( "insertByName called" + str( uri ) + " successful" )
+        if isPyFileInPath( self.provCtx.sfa, uri ):
+            self.provCtx.addPackageByUrl( uri )
+        else:
+            # package is no python package ...
+            log.debug( "insertByName: no python files in " + str( uri ) + ", ignoring" )
+            raise IllegalArgumentException( uri + " does not contain .py files", self, 1 )
+        log.debug( "insertByName called " + str( uri ) + " successful" )
 
     def replaceByName( self, name, value ):
         log.debug( "replaceByName called " + str( name ) + " " + str( value ))

stoc/source/javavm/javavm.cxx

         }
         case JFW_E_VM_CREATION_FAILED:
         {
-            //Error:
-            //%PRODUCTNAME requires a Java runtime environment (JRE) to perform
-            //this task. The selected JRE is defective. Please select another
-            //version or install a new JRE and select  it under Tools - Options -
-            //%PRODUCTNAME - Java.
+            //If the creation failed because the JRE has been uninstalled then
+            //we search another one. As long as there is a javaldx, we should
+            //never come into this situation. javaldx checks alway if the JRE
+            //still exist.
+            JavaInfo * pJavaInfo = NULL;
+            if (JFW_E_NONE == jfw_getSelectedJRE(&pJavaInfo))
+            {
+                sal_Bool bExist = sal_False;
+                if (JFW_E_NONE == jfw_existJRE(pJavaInfo, &bExist))
+                {
+                    if (bExist == sal_False
+                        && ! (pJavaInfo->nRequirements & JFW_REQUIRE_NEEDRESTART))
+                    {
+                        javaFrameworkError errFind = jfw_findAndSelectJRE( NULL );
+                        if (errFind == JFW_E_NONE)
+                        {
+                            continue;
+                        }
+                    }
+                }
+            }
+
+            jfw_freeJavaInfo(pJavaInfo);
+            //
+            //Error: %PRODUCTNAME requires a Java
+            //runtime environment (JRE) to perform this task. The selected JRE
+            //is defective. Please select another version or install a new JRE
+            //and select it under Tools - Options - %PRODUCTNAME - Java.
             css::java::JavaVMCreationFailureException exc(
                 rtl::OUString(
                     RTL_CONSTASCII_USTRINGPARAM(
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.