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 17:38:23 GMT
https://issues.apache.org/ooo/show_bug.cgi?id=120273

--- Comment #6 from Ariel Constenla-Haile <arielch@apache.org> ---
(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");

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

Mime
View raw message