Kaydet (Commit) 0b3b907e authored tarafından rbuj's avatar rbuj Kaydeden (comit) Noel Grandin

bean: encode(String) in URLEncoder has been deprecated

Change-Id: Ib2be5d3369d6568056d47ad1da59bfa08c8ecd77
Reviewed-on: https://gerrit.libreoffice.org/11442Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 6c341fa8
...@@ -20,6 +20,7 @@ package com.sun.star.comp.beans; ...@@ -20,6 +20,7 @@ package com.sun.star.comp.beans;
import java.awt.Container; import java.awt.Container;
import java.io.File; import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -131,7 +132,17 @@ public class LocalOfficeConnection ...@@ -131,7 +132,17 @@ public class LocalOfficeConnection
setUnoUrl( "uno:pipe,name=" + getPipeName() + ";urp;StarOffice.ServiceManager" ); setUnoUrl( "uno:pipe,name=" + getPipeName() + ";urp;StarOffice.ServiceManager" );
} }
catch ( java.net.MalformedURLException e ) catch ( java.net.MalformedURLException e )
{} {
com.sun.star.uno.RuntimeException e2 = new com.sun.star.uno.RuntimeException();
e2.initCause(e);
throw e2;
}
catch ( UnsupportedEncodingException e)
{
com.sun.star.uno.RuntimeException e2 = new com.sun.star.uno.RuntimeException();
e2.initCause(e);
throw e2;
}
} }
/** /**
...@@ -632,12 +643,12 @@ public class LocalOfficeConnection ...@@ -632,12 +643,12 @@ public class LocalOfficeConnection
/** creates a unique pipe name. /** creates a unique pipe name.
*/ */
private static String getPipeName() private static String getPipeName() throws UnsupportedEncodingException
{ {
// turn user name into a URL and file system safe name (% chars will not work) // turn user name into a URL and file system safe name (% chars will not work)
String aPipeName = System.getProperty("user.name") + OFFICE_ID_SUFFIX; String aPipeName = System.getProperty("user.name") + OFFICE_ID_SUFFIX;
aPipeName = aPipeName.replace( "_", "%B7" ); aPipeName = aPipeName.replace( "_", "%B7" );
return java.net.URLEncoder.encode(aPipeName).replace( "+", "%20" ).replace( "%", "_" ); return java.net.URLEncoder.encode( aPipeName, "UTF-8" ).replace( "+", "%20" ).replace( "%", "_" );
} }
/** /**
...@@ -653,10 +664,18 @@ public class LocalOfficeConnection ...@@ -653,10 +664,18 @@ public class LocalOfficeConnection
*/ */
public String getIdentifier() public String getIdentifier()
{ {
if ( mPipe == null) String identifier = null;
return getPipeName(); try
else {
return mPipe; identifier = ( mPipe == null) ? getPipeName() : mPipe;
}
catch (UnsupportedEncodingException e)
{
com.sun.star.uno.RuntimeException e2 = new com.sun.star.uno.RuntimeException();
e2.initCause(e);
throw e2;
}
return identifier;
} }
/** /**
...@@ -706,7 +725,7 @@ public class LocalOfficeConnection ...@@ -706,7 +725,7 @@ public class LocalOfficeConnection
// start process // start process
mProcess = Runtime.getRuntime().exec(cmdArray); mProcess = Runtime.getRuntime().exec(cmdArray);
if ( mProcess == null ) if ( mProcess == null )
throw new RuntimeException( "cannot start soffice: " + cmdArray ); throw new com.sun.star.uno.RuntimeException( "cannot start soffice: " + cmdArray );
new StreamProcessor(mProcess.getInputStream(), System.out); new StreamProcessor(mProcess.getInputStream(), System.out);
new StreamProcessor(mProcess.getErrorStream(), System.err); new StreamProcessor(mProcess.getErrorStream(), System.err);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment