Bug 32935 - CSV import dialog doesn't get focus if libreoffice is already running
Summary: CSV import dialog doesn't get focus if libreoffice is already running
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All Windows (All)
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:6.1.0 target:6.0.1
Keywords:
: 41706 54765 57931 61799 74871 87306 109027 115316 (view as bug list)
Depends on:
Blocks: CSV-Dialog
  Show dependency treegraph
 
Reported: 2011-01-09 05:06 UTC by Nicolò Chieffo
Modified: 2018-02-15 20:43 UTC (History)
27 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample, see Comment 3 (105 bytes, text/csv)
2011-06-20 11:08 UTC, Rainer Bielefeld Retired
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolò Chieffo 2011-01-09 05:06:02 UTC
WINDOWS 7 & VISTA ONLY (maybe xp)

When I open a .csv file, the popup dialog does not appear to the front if any program (calc, draw, writer, ...) IS ALREADY RUNNING.

When you switch to the libreoffice window, the modal popup appears.

If instead libreoffice is closed, the popup appears to the front.
Comment 1 Kohei Yoshida 2011-03-03 17:59:47 UTC
I'm confused.  Are you running libreoffice and openoffice at the same time?

>If instead libreoffice is closed, the popup appears to the front.

If libreoffice is closed, how can any of its dialogs appear!?
Comment 2 Nicolò Chieffo 2011-03-04 02:22:47 UTC
I only have libreoffice installed.

> If libreoffice is closed, how can any of its dialogs appear!?
because when you double click on an associated file libreoffice starts :)
So if libreoffice is closed, after you double click on the .csv file the modal popup appears to the front.
Instead if you were already running libreoffice (because you were working with other documents) the modal popup does not appear to the front.

So this bug can be summarized as: when opening a .csv file the popup should always appear to the front
Comment 3 Rainer Bielefeld Retired 2011-06-20 10:51:32 UTC
[Reproducible] with "LibreOffice 3.4.1RC1  – WIN7  Home Premium  (64bit) German UI [OOO340m1 (Build:101)]".

Steps to reproduce:
0. download attached "sample.csv" and save it in your default LibO Folder
1. close LibO, if it's running
2. Start LibO Start Center from WIN start center
3. Switch WIN Explorer to folder where "sample.csv" has been saved
   If necessary, make CALC default program for .csv and restart from 1.
4. Couble click "sample.csv"
   Expected: CALC Text Import should appear in focus
   Actual: Nothing! A LibO button will flash in the WIN Task Bar, but no
           dialog will appear

@Kohei:
Please feel free to reassign if it’s not your area or if provided information is not sufficient.
Comment 4 Rainer Bielefeld Retired 2011-06-20 11:08:26 UTC
Created attachment 48201 [details]
Sample, see Comment 3
Comment 5 Rmax 2011-06-23 19:55:37 UTC
This bug is a stumbling block to acceptance of LibreOffice by my co-workers. I should be assigned a higher priority. When a csv file is double-clicked, the csv dialog should always be on top(i.e., it should immediately be given focus).

Thanks,

Rmax
Comment 6 Kohei Yoshida 2011-07-07 16:32:23 UTC
I presume this is a Windows-only issue?  I'd like to give this to Tor who I believe has worked on similar Windows focus issues in the past.

BTW please don't mess with the priority and importance field.  Those fields are for the implementer use only. (I personally ignore these fields precisely because so many reporters abuse them.)
Comment 7 Don't use this account, use tml@iki.fi 2011-07-08 01:12:05 UTC
Note: Many developers, me included, tend to take claims "this is the only thing stopping me from starting to use this software" pretty lightly. People always say so. And if that one thing is fixed, then there is another thing. Etc.

Anyway, yes, there was a similar issue in the past. I don't remember exactly how similar it was, and can't guess at this stage whether the same "fix" (or more like workaround) can be applied to this problem, too.

Presumably this is a farily generic problem, not specific to the dialog for .csv files.
Comment 8 Björn Michaelsen 2011-12-23 13:26:33 UTC
Since all new unconfirmed bugs start in state UNCONFIRMED now and old unconfirmed bugs were moved to NEEDINFO with a explanatory comment, all bugs promoted above those bug states to NEW and later are automatically confirmed making the CONFIRMED whiteboard status redundant. Thus it will be removed.
Comment 9 Christian Lohmaier 2011-12-28 08:16:05 UTC
*** Bug 41706 has been marked as a duplicate of this bug. ***
Comment 10 Muthu 2013-03-01 08:07:46 UTC
*** Bug 54765 has been marked as a duplicate of this bug. ***
Comment 11 bfoman (inactive) 2013-05-16 10:55:42 UTC
This bug has not been touched by its owner for a long time. To make it clearer which bugs should be fixed by someone else please take following action:
- If you are the owner, and you are actively working on the bug, please give it an update. 
- If you are the owner, and you do not plan to work on it in the near future,
please reassign it to the default assignee and change its status to NEW.
Comment 12 Ben 2013-06-29 15:06:54 UTC
*** Bug 57931 has been marked as a duplicate of this bug. ***
Comment 13 ign_christian 2013-07-26 07:46:59 UTC
*** Bug 61799 has been marked as a duplicate of this bug. ***
Comment 14 Bernard du Toit 2013-12-03 08:08:27 UTC
When I double click a file in Windows, I expect some application to appear that opens the file. 

This bug creates the experience that "nothing happened" and I would double click again (Thinking that my mouse button is malfunctioning). Then I would think that the associated application is hanging if nothing still happens. 

Then I would switch to my currently open LibreOffice window to see if it is "Not Responding" just to suddenly notice the stack of "Text Import" dialogs waiting for user input.

Really annoying, and seems so easy to fix. The dialog should just take focus when it opens.

I believe this is a problem with all Text files and not just csv. But since I use LibreOffice (alongside (company's) Ms Office) just because it is so nice in displaying and importing CSVs, it is a daily irritation.
Comment 15 bfoman (inactive) 2014-01-08 22:47:53 UTC
Marking as NEW per duplicates and bug is unowned.
Comment 16 Maxim Monastirsky 2014-02-12 09:16:47 UTC
*** Bug 74871 has been marked as a duplicate of this bug. ***
Comment 17 Bill Robertson 2014-08-01 02:25:45 UTC
1/ Can confirm this issue for LibreOffice 4.2.4.2 on Ubuntu 14.04

2/ Its a really annoying bug!

3/ We are willing to help sponsor a bug fix.
Comment 18 Bill Robertson 2014-08-01 02:37:53 UTC
We have just sponsored this issue for USD 300.00 on FreedomSponsors to the first person who fixes it:

http://www.freedomsponsors.org/issue/527/csv-import-dialog-doesnt-get-focus-if-libreoffice-is-already-running

If you want to add a few dollars to this issue we'll all get it fixed faster :)

If you solve it (according to the acceptance criteria described there), please register on FreedomSponsors and mark it as resolved there. We will then check it out and gladly pay.
Comment 19 Christoph Schultz 2014-08-04 16:43:28 UTC
LO4.3.0.4 Win 7 x86 32bit,

1. I downloaded sample.csv
2. closed LO 
3. I opened the windows explorer and saw that sample.csv was registered to open with LO-calc,
4a. I double clicked sample.csv and LO appeared with the text-import dialog to import the csv-File
4b. I opend LO-Startcenter (Startmenu->Libreoffice4.3->Libreoffice) and doubleclicked sample.csv in the win-explorer . the import-dialog appeared
4c. I tried to open with the Opendialog of LO and the import-dialog appeared also.
4d. I opened LO-calc (an empty document) and did the same as in 4b and all is fine. also when i tried to do this with the open-dialog of LO.

my guess. this is fixed.
Comment 20 fornar 2014-08-08 00:38:27 UTC
Reproducible on Windows 7 Pro 64bit with LO 4.3.0.4

Downloaded sample CSV file. Made a second copy so i had 2 CSV files.

1. Closed all LO windows.
2. Opened first CSV file from windows Explorer, import dialogue opened and was in focus. Click ok on import. Minimised this document.
3. Opened second CSV file from Windows explorer, no import dialogue came into focus.
4. Clicked on already opened LO file. The import dialogue then appeared.


Have also tried it on Ubuntu 14.04 64 Bit with LO 4.3.0.4 with the same result, that once you have one document already open and try to open another CSV file the import dialogue does not come into focus. I have to click on the already open LO document in order to complete the import of the CSV file.
Comment 21 Bill Robertson 2014-08-08 03:13:49 UTC
(In reply to comment #19)
> LO4.3.0.4 Win 7 x86 32bit,
> 
> 1. I downloaded sample.csv
> 2. closed LO 
> 3. I opened the windows explorer and saw that sample.csv was registered to
> open with LO-calc,
> 4a. I double clicked sample.csv and LO appeared with the text-import dialog
> to import the csv-File
> 4b. I opend LO-Startcenter (Startmenu->Libreoffice4.3->Libreoffice) and
> doubleclicked sample.csv in the win-explorer . the import-dialog appeared
> 4c. I tried to open with the Opendialog of LO and the import-dialog appeared
> also.
> 4d. I opened LO-calc (an empty document) and did the same as in 4b and all
> is fine. also when i tried to do this with the open-dialog of LO.
> 
> my guess. this is fixed.

Hi Christoph,

Yes, your use case is OK.

This specific issue occurs when a csv is opened in LO via an application or file manager (such as Dolphin or Windows Explorer) & a copy of LO is already opened (ALSO from a file manager or application such as FireFox) and minimised.

Regards
Bill
Comment 22 Sheline 2014-08-25 22:36:45 UTC
This happens to me too and it is very frustrating.
Comment 23 Janine 2014-08-25 22:44:03 UTC
Still happening with us, have a few fustrated users, complaining the time spent looking for window, that continually hides!!!!

When opening a .csv file, the popup dialog does not appear to the front if any program (calc, draw, writer, ...) IS ALREADY RUNNING.

When you switch to the libreoffice window, the modal popup appears.

If instead libreoffice is closed, the popup appears to the front.
Comment 24 Bernard Gray 2014-08-26 01:26:14 UTC
This is _still_ reproducible, almost 4 years on:

Kubuntu 14.04 LTS
LibreOffice 4.3.0.4 from the PPA

Open a libreoffice document, and minimise it, or hide it behind another focussed (non-libreoffice) application window
Using a file manager (in my case dolphin), or any non-libreoffice application that will honour file associations (eg email client), open a csv file

The csv import dialog is opened as a child of the existing hidden/minimised libreoffice window, and it remains hidden/minimised.

The perceived outcome of this for the user is one or more of the following:
* nothing happened, so they try double clicking again (and nothing happens)
* they assume libreoffice has crashed
* further libreoffice launch attempts from non-libreoffice applications fail because they are being blocked by the hidden dialog, so...
* they assume the computer has crashed, and reboot only to have the same behaviour occur

None of these outcomes are desirable for a functional user experience.
Comment 25 ign_christian 2014-08-26 04:43:00 UTC
I wonder if some users can reproduce this in linux. 

But I can't reproduce in:
- Ubuntu 12.04 gnome/unity x86 with LO 4.2.6.2 (from PPA)
- Kubuntu 12.04 (kde 4.13.2) x86 with LO 4.0.4.2 (from PPA)
Comment 26 Bernard Gray 2014-08-27 00:53:13 UTC
(In reply to comment #25)
> I wonder if some users can reproduce this in linux. 
> 
> But I can't reproduce in:
> - Ubuntu 12.04 gnome/unity x86 with LO 4.2.6.2 (from PPA)
> - Kubuntu 12.04 (kde 4.13.2) x86 with LO 4.0.4.2 (from PPA)

I made two videos - based on:

Ubuntu 12.04, bog standard install. Add kde via:
  sudo apt-get install kubuntu-desktop

add this ppa: https://launchpad.net/~libreoffice/+archive/ubuntu/libreoffice-4-3 
upgrade all libreoffice packages to 4.3.0.4:
  sudo apt-get install $(dpkg -l | grep libreoffice | awk '{print $2}')

Video 1: Unity Desktop, expected (correct) behaviour
https://drive.google.com/file/d/0BxhtBAYzjZj5V1V1NjRTRVRKZ0E/edit?usp=sharing

Video 2: Logged out of Unity, logged into KDE Desktop - unexpected behaviour, as described by this bug:
https://drive.google.com/file/d/0BxhtBAYzjZj5ODZ2RG1GZHZtUEE/edit?usp=sharing
Comment 27 ign_christian 2014-08-27 03:38:22 UTC
Thanks for your videos Bernard. Seems I forgot to minimize existing opened window while testing on previous comment.

Confirm reproduced in LO 4.0.4.2 with Kubuntu 12.04 x86. It seems only reproduced in Linux within KDE environment.

But I think this bug only for Windows, possibly different cause in linux. How about filing this bug in launchpad or kde?
Comment 28 Rene' Fiby 2014-08-29 04:15:37 UTC Comment hidden (me-too)
Comment 29 Bernard Gray 2014-09-15 07:25:24 UTC
(In reply to comment #27)
> Thanks for your videos Bernard. Seems I forgot to minimize existing opened
> window while testing on previous comment.
> 
> Confirm reproduced in LO 4.0.4.2 with Kubuntu 12.04 x86. It seems only
> reproduced in Linux within KDE environment.
> 
> But I think this bug only for Windows, possibly different cause in linux.
> How about filing this bug in launchpad or kde?

Logged against qt-x11 in ubuntu/launchpad. I can replicate on the razorqt wm/de so the problem is bigger than kde.

https://bugs.launchpad.net/ubuntu/+source/qt4-x11/+bug/1369424
Comment 30 Cristian Pârvu 2014-09-23 22:04:31 UTC
I can confirm this bug in Windows 7 Professional with LibreOffice 4.3.1.2. It is very frustrating working with CSV files in LibreOffice Calc.
Comment 31 Bernard Gray 2014-10-03 01:51:09 UTC
(In reply to Bernard Gray from comment #29)
> (In reply to comment #27)
> > Thanks for your videos Bernard. Seems I forgot to minimize existing opened
> > window while testing on previous comment.
> > 
> > Confirm reproduced in LO 4.0.4.2 with Kubuntu 12.04 x86. It seems only
> > reproduced in Linux within KDE environment.
> > 
> > But I think this bug only for Windows, possibly different cause in linux.
> > How about filing this bug in launchpad or kde?
> 
> Logged against qt-x11 in ubuntu/launchpad. I can replicate on the razorqt
> wm/de so the problem is bigger than kde.
> 
> https://bugs.launchpad.net/ubuntu/+source/qt4-x11/+bug/1369424

After some discussion with qt guys, I've redirected the bug (which affects KDE/Linux users) to the KDE kwin team, I'm cleaning up the extraneous bugs I've created.

https://bugs.kde.org/show_bug.cgi?id=339621

This comment does not relate to this windows specific bug.
Comment 32 Gareth 2014-10-26 13:21:38 UTC
Added a link to bug/feature request 74580, which involves a closely related use case and has in my view wrongly been marked resolved.

Please see my comment on that bug for explanation.
Comment 33 Gareth 2014-10-26 14:17:31 UTC
Exactly same happens with HTML imports.

Should another bug be raised for that?
Comment 34 tommy27 2014-12-14 19:47:10 UTC
*** Bug 87306 has been marked as a duplicate of this bug. ***
Comment 35 QA Administrators 2015-12-20 16:20:23 UTC Comment hidden (obsolete)
Comment 36 Gareth 2015-12-21 02:38:37 UTC
The essence of the bug (or misfeature) is that the dialog is attached to the wrong window.

When any CSV or HTML file is right clicked in Windows Explorer and 'Open with... LibreOffice Calc' selected

(a) if LibreOffice is not running:

 (i) The Import Dialog opens with no parent window, at the top of the Z order, i.e. on top of the Explorer window from which it was called.
 (ii) If OK is clicked on the Import Dialog, a Calc window opens.
 (iii) If Cancel is selected, LibreOffice quits.

In other words, correct behaviour.

(b) if LibreOffice is running

 (i) the Import Dialog opens with some existing LibreOffice window as its parent. This need not be a Calc window: it will attach to e.g. a Writer window if any is open.
 (ii) In no case does the Import Dialog or its parent window come to the top of the Z-order. Even if its parent is the topmost window other than the calling Explorer window, the dialog remains underneath the Explorer window. If the parent window happens to be deeper in the Z-order, the dialog is completely hidden, with no clue to the user that it is there.

In other words, the bug/misfeature is exercised.

It looks like potentially a very simple fix. The Import Dialog just needs to open with no parent even if LibreOffice is already running. I would expect it to involve no more than changing a parent window reference to null for both kinds of import dialog.

If you wish me to raise a separate bug report for the HTML Import Dialog, please let me know.
Comment 37 Matt W 2016-03-24 03:08:36 UTC
I spent some time diving through the libreoffice source, and I can see how to fix this but I don't really have time to get libreoffice compiling, and get this through the development process.

There are two options to fix this:
1) Easy option:
Add the Dialog::InitFlag::NoParent flag to the ModalDialog constructor for imports (as far as I can tell this is, ScImportOptionsDlg and ScImportAsciiDlg):
line 240 of sc/source/ui/dbgui/scuiasciiopt.cxx:
ScImportAsciiDlg::ScImportAsciiDlg( vcl::Window* pParent, const OUString& aDatName,
                                    SvStream* pInStream, ScImportAsciiCall eCall ) :
        ModalDialog (pParent, "TextImportCsvDialog",
            "modules/scalc/ui/textimportcsv.ui"),

becomes:

ScImportAsciiDlg::ScImportAsciiDlg( vcl::Window* pParent, const OUString& aDatName,
                                    SvStream* pInStream, ScImportAsciiCall eCall ) :
        ModalDialog (pParent, "TextImportCsvDialog",
            "modules/scalc/ui/textimportcsv.ui", Dialog::InitFlag::NoParent),


and line 101 of core/sc/source/ui/dbgui/scuiimoptdlg.cxx:
ScImportOptionsDlg::ScImportOptionsDlg(
        vcl::Window*                 pParent,
        bool                    bAscii,
        const ScImportOptions*  pOptions,
        const OUString*         pStrTitle,
        bool                    bMultiByte,
        bool                    bOnlyDbtoolsEncodings,
        bool                    bImport )
    :   ModalDialog ( pParent, "ImOptDialog",
            "modules/scalc/ui/imoptdialog.ui" )

becomes:
ScImportOptionsDlg::ScImportOptionsDlg(
        vcl::Window*                 pParent,
        bool                    bAscii,
        const ScImportOptions*  pOptions,
        const OUString*         pStrTitle,
        bool                    bMultiByte,
        bool                    bOnlyDbtoolsEncodings,
        bool                    bImport )
    :   ModalDialog ( pParent, "ImOptDialog",
            "modules/scalc/ui/imoptdialog.ui", Dialog::InitFlag::NoParent)


This will make the dialog always have a window tab - even when you're pasting ascii into calc.  I think this is probably acceptable.  Main issue will be that the dialog won't be modal in these cases.


2) Harder option:
So the issue with option 1 is that the dialog will always be a new window.  What we really need is another dialog flag added like Dialog::InitFlag::NoParentIfNull or something - so it takes a parent if there is one, but otherwise doesn't set one.
This would be easy enough to add to dialog.cxx, but I think the things that call ScImportOptionsDlg and ScImportAsciiDlg don't bother to pass the window in and rely on the default window-finding behaviour of ModalDialog.  Still not super hard to fix - just have to track down the places that reference the dialogs and pass the window context in.
Comment 38 Gareth 2016-03-24 23:45:00 UTC
Many thanks for your work, Matt. I may have a go at it if I get time, but don't let me stop you or anyone else who gets there first.

There are actually three distinct use cases...

(1) open csv from outside LibreOffice (e.g. from Windows Explorer)
(2) open csv from Calc window with no spreadsheet loaded (loads in same window)
(3) open csv from Calc window with spreadsheet loaded (loads in new window)

...possibly more, but those are what I have spotted. Please Matt or anyone comment if you think of more.

Preliminary thought is that the dialog only really needs to be modal in case (2).

I'll mull it some more if I actually make a start on it.
Comment 39 Matt W 2016-03-28 21:36:27 UTC
There's also a forth case:
4) Copy/paste text into calc (should be modal)
Comment 40 John Griessen 2017-02-10 19:52:18 UTC
Another case is a makefile driven design setup where a script starts LibreOffice 5.2.4.2.1 20m0(Build:2):

libreoffice --calc  filename.tsv

Starts the program, but does not give it focus, so the new dialogbox is under the window of the terminal emulator, which usually is fairly large so I do not see it until I lower it, or tab through windows overlapping each other to find it.

So, it stops automation.  Well, not for too long -- I can maybe use gnumeric...
Comment 41 John Griessen 2017-02-10 20:07:12 UTC
For my use case, makefile automation, I discovered a workaround:

openofc --calc --infilter=generic_Text kvboard.bom.tsv

opens the file kvboard.bom.tsv immediately!
Comment 42 brodders 2017-03-14 13:41:01 UTC Comment hidden (no-value)
Comment 43 brodders 2017-03-14 13:45:59 UTC Comment hidden (no-value)
Comment 44 brodders 2017-03-14 13:48:19 UTC Comment hidden (no-value, obsolete)
Comment 45 brodders 2017-03-14 13:57:12 UTC Comment hidden (no-value, obsolete)
Comment 46 Gitsy 2017-03-29 18:59:00 UTC
still present in 5.3.1.2
Comment 47 Harold 2017-04-13 12:23:26 UTC
Still present in 5.3.0.3 (x64)
Comment 48 Adolfo Jayme 2017-07-15 13:47:20 UTC
*** Bug 109027 has been marked as a duplicate of this bug. ***
Comment 49 Commit Notification 2018-01-29 14:19:12 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3b57cb72ec8b47f033be5a516617ed8c752517b0

tdf#32935 tdf#49134 tdf#114466 Activate newly opened modal dialogs

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 50 V Stuart Foote 2018-01-30 06:03:28 UTC
(In reply to Commit Notification from comment #49)
> 
> http://cgit.freedesktop.org/libreoffice/core/commit/
> ?id=3b57cb72ec8b47f033be5a516617ed8c752517b0
> 
> tdf#32935 tdf#49134 tdf#114466 Activate newly opened modal dialogs
> 

Functions correctly in Windows builds...
Comment 51 Alex Thurgood 2018-02-02 08:09:13 UTC
*** Bug 115316 has been marked as a duplicate of this bug. ***
Comment 52 Commit Notification 2018-02-04 21:11:29 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3f4b0788ba688dbdf7d4487b7ef83edc7e81c1e8&h=libreoffice-6-0

tdf#32935 tdf#49134 tdf#114466 Activate newly opened modal dialogs

It will be available in 6.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 53 Alex Thurgood 2018-02-13 13:36:26 UTC
*** Bug 115683 has been marked as a duplicate of this bug. ***
Comment 54 Telesto 2018-02-15 19:25:23 UTC
@Mike
Please close this as fixed :-)
Comment 55 Mike Kaganski 2018-02-15 20:43:13 UTC
Reset OS back to Windows (as it was reported initially).

macOS-specific *still-not-fixed* problem is tracked in bug 115683.
I cannot reproduce the problem on my Ubuntu, but in case it still exists, it should have a dedicated issue.