You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openoffice.apache.org by bu...@apache.org on 2013/10/24 18:25:50 UTC

[Bug 123544] New: XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

https://issues.apache.org/ooo/show_bug.cgi?id=123544

            Bug ID: 123544
        Issue Type: DEFECT
           Summary: XFilePicker's setDisplayDirectory and setDefaultName
                    do not work in Windows
           Product: App Dev
           Version: 4.0.1
          Hardware: PC
                OS: Windows 7
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: api
          Assignee: issues@openoffice.apache.org
          Reporter: ardamose123@gmail.com
                CC: issues@openoffice.apache.org

When a file picker is created using the following code, the directory and
filename are not set when the file picker is shown. This happens in Windows 7;
in Ubuntu 12.10 (using OpenOffice 4) it works as expected.

Here, "originalUrl" is the URL taken from the currently open document;
"Environment" is just a helper class to retrieve some information about the
opened document.

Object oFilePicker =
component_factory.createInstanceWithContext("com.sun.star.ui.dialogs.FilePicker",
Environment.getContext());
XFilePicker xFilePicker = (XFilePicker)
UnoRuntime.queryInterface(XFilePicker.class, oFilePicker);

xFilePicker.setMultiSelectionMode(false);
if (originalUrl == null) {
    xFilePicker.setDisplayDirectory(Environment.getHomeDir());
    xFilePicker.setDefaultName("");
}
else {
    int idx = originalUrl.lastIndexOf('/');
    if (idx >= 0) {
        xFilePicker.setDisplayDirectory(originalUrl.substring(0, idx));
        xFilePicker.setDefaultName(originalUrl.substring(idx+1));
    }
}

Steps to reproduce:
1. Create a new extension which shows a file picker using the code mentioned
above.
2. Install the extension in LibreOffice in Windows.
2. Run LibreOffice in Windows.
3. Open an LibreOffice-compatible document.
4. Run the extension.

Current behavior:
The file picker doesn't start where the opened document is saved nor the
filename of the document is set as default filename.

Expected behavior:
The default directory and filename of the file picker is the same as the opened
document.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

Ariel Constenla-Haile <ar...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |CONFIRMED

--- Comment #8 from Ariel Constenla-Haile <ar...@apache.org> ---
This bug can be confirmed, independently of the API, just in the user
interface:

- New Writer document
- type anything
- press the Save button

The default display directory will be set to "file://C:/Users/ariel/Documents",
the default file name will be set to "Untitled 1" (in the debugger, watch
m_sDirectory and m_sFilename).

Bug: the file picker opens in the last used directory (C:\User\ariel\Downloads
in my case), not the one set.

This can be reproduced also with the macro in attachment 81818 (once fixed the
crash).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

Ariel Constenla-Haile <ar...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |crash, regression
                 CC|                            |hdu@apache.org

--- Comment #9 from Ariel Constenla-Haile <ar...@apache.org> ---
Setting hdu on CC for the crash described in comment 6

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

Oliver-Rainer Wittmann <or...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.1.0                       |---

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #4 from Ariel Constenla-Haile <ar...@apache.org> ---
Created attachment 81818
  --> https://issues.apache.org/ooo/attachment.cgi?id=81818&action=edit
Writer document with a macro to test

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #6 from Ariel Constenla-Haile <ar...@apache.org> ---
(In reply to Ariel Constenla-Haile from comment #4)
> Created attachment 81818 [details]
> Writer document with a macro to test

This one crashes on Windows 7, it isn't setting any filter, so the following
code tries to access element 0 of an empty vector:

http://svn.apache.org/viewvc/openoffice/trunk/main/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx?diff_format=h&revision=1497691&view=markup#l922

On 3.4.1 it does not crash (but the dialog does not show up). The crash is
likely a regression introduced by stlport removal.

hResult = iDialog->GetFileTypeIndex(&nFileType);

will return S_OK but nFileType will be 0 when no filters were specified.
So the check should be:

if ( SUCCEEDED(hResult) && nFileType > 0 )

this would already prevent accessing an empty vector, any way it would be safer
to check nRealIndex against the vector actual size.
Altogether:

if ( bValue )
{
    ::rtl::OUString aExt;
    UINT nFileType;
    hResult = iDialog->GetFileTypeIndex(&nFileType);
    if ( SUCCEEDED(hResult) && nFileType > 0 )
    {
        ::sal_Int32 nRealIndex = (nFileType-1); // COM dialog base on 1 ...
filter container on 0 .-)
        ::std::vector< COMDLG_FILTERSPEC > lFilters =
lcl_buildFilterList(m_lFilters);
        if ( nRealIndex < lFilters.size() )
        {
            LPCWSTR lpFilterExt = lFilters[nRealIndex].pszSpec;

            lpFilterExt = wcsrchr( lpFilterExt, '.' );
            if ( lpFilterExt )
                aFileURL += reinterpret_cast<const sal_Unicode*>(lpFilterExt);
        }
    }
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #2 from Ariel D. Moya Sequeira <ar...@gmail.com> ---
1) I filed the bug in LibreOffice first, then here. However, the issue exist in
both applications. I reproduced the issue using OpenOffice 4.0.1 (in Windows).
2) I just use the file picker made available by the UNO interface. Apart from
that, I do not use SWT/Swing file pickers.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Issue 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

eberlein <pe...@refofd.verwalt-berlin.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pet.ebe@refofd.verwalt-berl
                   |                            |in.de

--- Comment #19 from eberlein <pe...@refofd.verwalt-berlin.de> ---
Can confirm, with initializing it works.

-- 
You are receiving this mail because:
You are on the CC list for the issue.
You are the assignee for the issue.
You are watching all issue changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

Ariel Constenla-Haile <ar...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|NOTABUG                     |---
     Ever confirmed|0                           |1

--- Comment #7 from Ariel Constenla-Haile <ar...@apache.org> ---
(In reply to Ariel D. Moya Sequeira from comment #5)
> Thanks for the support.
> 
> Indeed, when I switched to the OpenOffice's save dialog, the code now
> behaves as expected. It works as expected on Windows and Linux after the
> switch.
> 
> Anyone may change the status of this ticket as NOTABUG or WONTFIX if the
> behavior using system's dialogs won't be fixed at all.

There is a bug, besides the crash.
The API should work even when using the system dialog.

In the meantime, while this bug gets fixed, try not using in your code the
system file picker. You can force this (even if the user interface is using the
system file picker) with the service name:

"com.sun.star.ui.dialogs.OfficeFilePicker"

instead of 

"com.sun.star.ui.dialogs.FilePicker"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Issue 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #21 from eberlein <pe...@refofd.verwalt-berlin.de> ---
you're right, I have to stand corrected.
So the only solution seems to be to switch to the OpenOffice dialogs with Basic
temporarily.

-- 
You are receiving this mail because:
You are on the CC list for the issue.
You are the assignee for the issue.
You are watching all issue changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

Ariel D. Moya Sequeira <ar...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |NOTABUG

--- Comment #5 from Ariel D. Moya Sequeira <ar...@gmail.com> ---
Thanks for the support.

Indeed, when I switched to the OpenOffice's save dialog, the code now behaves
as expected. It works as expected on Windows and Linux after the switch.

Anyone may change the status of this ticket as NOTABUG or WONTFIX if the
behavior using system's dialogs won't be fixed at all.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #1 from Ariel Constenla-Haile <ar...@apache.org> ---
(In reply to Ariel D. Moya Sequeira from comment #0)
> Steps to reproduce:
> 1. Create a new extension which shows a file picker using the code mentioned
> above.
> 2. Install the extension in LibreOffice in Windows.

Some comments:
- This is OpenOffice bugzilla, did you reproduce the bug with OpenOffice?
- are you using the system file dialog?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #12 from hdu@apache.org <hd...@apache.org> ---
Thanks for analyzing the problem! The fix suggested in comment 6 looks good to
me, please commit it. If this isn't possible for whatever reasons 'll be happy
to do it.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Issue 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #18 from brinzing <ol...@gmx.de> ---
it seems setting the directory works, if the filpicker is initialized:

REM  *****  BASIC  *****
OPTION EXPLICIT

Sub Main
    Dim dlg as Object

    dlg = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" )

    Dim Dialogtyp(0)
    DialogTyp(0) =
com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION

    dlg.initialize(DialogTyp())
    dlg.Title = "Test"
'    dlg.DisplayDirectory = "file:///c:/users"
    dlg.DisplayDirectory = "file:///c:/"

' this will crash aoo401:
' dlg.DefaultName = "xxx"

    If dlg.Execute = 1 Then MsgBox dlg.SelectedFiles(0)
End Sub

could someone please confirm?


btw: issue "Issue 110141 - FilePicker Dialog "setDisplayDirectory" ignored" 
       seems a dupe of this issue

-- 
You are receiving this mail because:
You are on the CC list for the issue.
You are the assignee for the issue.
You are watching all issue changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

Ariel D. Moya Sequeira <ar...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ardamose123@gmail.com
           See Also|                            |https://issues.apache.org/o
                   |                            |oo/show_bug.cgi?id=96720

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

brinzing <ol...@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |oliver.brinzing@gmx.de

--- Comment #11 from brinzing <ol...@gmx.de> ---
.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

Ariel Constenla-Haile <ar...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #15 from Ariel Constenla-Haile <ar...@apache.org> ---
revision 1535717 only fixes the crash. The problem reported here is still there
(not only using the API, but in the user interface).

The whole code in 
http://svn.apache.org/viewvc/openoffice/trunk/main/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx?revision=1535717&view=markup&pathrev=1535717#l888
has a wrong approach:

if there is a default directory and a file name, the code generates a file URL
(directory + / + filename + extension), and the default directory is only set
if this file exists (ll. 933 ss.); this is a nonsense, because when you are
saving a file, this file does not exist yet, so FindFirstFile fails.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

hdu@apache.org <hd...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CONFIRMED                   |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.1.0

--- Comment #14 from hdu@apache.org <hd...@apache.org> ---
Fixed with Ariel's commit above. Thanks!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Issue 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #20 from brinzing <ol...@gmx.de> ---
> Can confirm, with initializing it works.

no, i mistakenly thought it will work, but it will only work the *first* time. 
after a file has been saved, the display directory will always point to the
last save path. run macro twice, second time change "dlg.DisplayDirectory"
to a different directory.

Sub Main
    Dim dlg as Object
    Dim oDoc as Object
    Dim mNoArgs()
    Dim sURL as String

    dlg = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" )

    Dim Dialogtyp(0)
    DialogTyp(0) =
com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION

    dlg.initialize(DialogTyp())
    dlg.Title = "Test"

    sURL = "private:factory/swriter"
    oDoc = StarDesktop.loadComponentFromURL(sURL, "_blank", 0, mNoArgs)

'    dlg.DisplayDirectory = "file:///c:/users"
    dlg.DisplayDirectory = "file:///c:/temp"

    If dlg.Execute = 1 Then 
        sURL = dlg.SelectedFiles(0)
        oDoc.storeToURL(sURL, mNoArgs)
    EndIf
End Sub

-- 
You are receiving this mail because:
You are on the CC list for the issue.
You are the assignee for the issue.
You are watching all issue changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

Oliver-Rainer Wittmann <or...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|regression                  |

--- Comment #17 from Oliver-Rainer Wittmann <or...@apache.org> ---
removing keyword 'regression'

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

Oliver-Rainer Wittmann <or...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|crash                       |

--- Comment #16 from Oliver-Rainer Wittmann <or...@apache.org> ---
>From my point of view the crash is fixed. Right? Thus, I am removing keyword
'crash'

I also does not look like as the described defect is a regression. Right?
If yes, please remove keyword 'regression'. Thx in advance.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #10 from Ariel Constenla-Haile <ar...@apache.org> ---
(In reply to Ariel Constenla-Haile from comment #6)
> This one crashes on Windows 7, it isn't setting any filter, so the following
> code tries to access element 0 of an empty vector:

the index is negative: after

hResult = iDialog->GetFileTypeIndex(&nFileType);

nFileType is 0. Then

::sal_Int32 nRealIndex = (nFileType-1);

nRealIndex is -1.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #3 from Ariel Constenla-Haile <ar...@apache.org> ---
(In reply to Ariel D. Moya Sequeira from comment #2)
> 2) I just use the file picker made available by the UNO interface. Apart
> from that, I do not use SWT/Swing file pickers.

If you go to the menu Tools - Options..., in the Options dialogue go to
OpenOffice - General, there is an option to use OpenOffice dialogues instead of
the system one.
IIRC this option is off by default, so you might be using the system dialogue.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.

[Bug 123544] XFilePicker's setDisplayDirectory and setDefaultName do not work in Windows

Posted by bu...@apache.org.
https://issues.apache.org/ooo/show_bug.cgi?id=123544

--- Comment #13 from SVN Robot <sv...@dev.null.org> ---
"arielch" committed SVN revision 1535717 into trunk:
i123544 - Prevent accessing empty filters' vector
svnbz message delay caused by perl problems after Bugzilla 4.4.1 update

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
You are watching all bug changes.