incubator-ooo-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 120273] Can not open a file in UNO mode, if there is a "%" in file name
Date Fri, 13 Jul 2012 18:04:29 GMT
https://issues.apache.org/ooo/show_bug.cgi?id=120273

--- Comment #7 from ChaoHuang <chao.dev.h@gmail.com> ---
(In reply to comment #6)
> (In reply to comment #4)
> > My question is that how can I convert "file:///d:/convert/h%e%l%l%o.odt"
> > into "file:///D:/convert /h%25e%25l%25l%25o.odt". I have hundreds of files
> > which hold "%" in the name. It is impossible for me to correct the name
> > manually one by one. Any suggestion? Thanks!
> 
> 
> You can use
> http://www.openoffice.org/api/docs/common/ref/com/sun/star/ucb/
> XFileIdentifierConverter.html#getFileURLFromSystemPath
> 
> 
> 
>     public static String convertToURL(
>                                         XComponentContext xContext,
>                                         String sBase,
>                                         String sSystemPath) {
>         String sURL = null;
>         try {
>             com.sun.star.ucb.XFileIdentifierConverter xFileConverter =
>                     (com.sun.star.ucb.XFileIdentifierConverter)
> UnoRuntime.queryInterface(
>                     com.sun.star.ucb.XFileIdentifierConverter.class,
>                     xContext.getServiceManager().createInstanceWithContext(
>                     "com.sun.star.ucb.FileContentProvider", xContext));
>             sURL = xFileConverter.getFileURLFromSystemPath(
>                     sBase, sSystemPath);
>         } catch (java.lang.Exception e) {
>             e.printStackTrace();
>         } finally {
>             return sURL;
>         }
>     }
> 
> Usage:
> 
> String sURL = convertToURL(xContext, "", "D:\convert\h%25e%25l%25l%25o.odt");

hi, Ariel

Thanks for your guidance. A system path "d:/convert/h%e%l%l%o.odt" can be
converted to URL "file:///D:/convert/h%25e%25l%25l%25o.odt" by function
"convertToURL" in my local env.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Mime
View raw message