Bug 89683 - delimited text files ('csv', 'tsv', etc.) are opened as text documents if Writer is the active window
Summary: delimited text files ('csv', 'tsv', etc.) are opened as text documents if Wr...
Status: RESOLVED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
3.6.0.4 release
Hardware: Other Windows (All)
: medium enhancement
Assignee: Not Assigned
URL: http://nabble.documentfoundation.org/...
Whiteboard:
Keywords:
Depends on:
Blocks: CSV-Import
  Show dependency treegraph
 
Reported: 2015-02-26 14:26 UTC by Harald Koester
Modified: 2018-10-07 21:16 UTC (History)
10 users (show)

See Also:
Crash report or crash signature:


Attachments
extension to open csv always in calc (1.79 KB, application/vnd.openofficeorg.extension)
2017-01-01 08:21 UTC, Maxim Monastirsky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Koester 2015-02-26 14:26:07 UTC
A csv file is generally used to store structured data which can be represented in a spreadsheet. Hence to my opinion csv files should be opened with Calc by default. Only if a user explicitly selects “Text document” a csv file should be opened with Writer. Currently a csv file is not opened as spreadsheet if a text document is displayed in Writer.
Steps in order to reproduce the bug:

Case A:
(1) Start LO and create new text document.
(2) Open a file with the extension 'csv' from the menu: File > Open... The open file dialogue of Windows is displayed. In the status line the filter “All files (*.*)” is selected.
(3) Select “Spreadsheets (…;*.csv)” as filter.
(4) Select a csv file and click “Open”... The csv file is loaded as text document. Expected: csv file should be opened as spreadsheet. In this case even if the user explicitly selects the option spreadsheet the file is opened as text document.

Case B:
(1) Start LO and create new text document.
(2) Open a file with the extension 'csv' from the menu: File > Open... The open file dialogue of Windows is displayed. In the status line the filter “All files (*.*)” is selected.
(3) Select a csv file and click “Open”. The csv file is loaded as text document. Expected: csv file should be opened as spreadsheet by default even it is opened from a text document.

Hint: This Bug has already been described in Bug 89312 together with other problems.
Comment 1 Julien Nabet 2015-02-26 21:55:21 UTC
Code pointer: http://opengrok.libreoffice.org/xref/core/filter/source/textfilterdetect/filterdetect.cxx#150 ?
    150         // Decide which filter to use based on the document service first,
    151         // then on extension if that's not available.
    152         if (aDocService == CALC_DOCSERVICE)
    153             aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(CALC_TEXT_FILTER);
    154         else if (aDocService == WRITER_DOCSERVICE)
    155             aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(WRITER_TEXT_FILTER);
    156         else if (aExt == "csv" || aExt == "tsv" || aExt == "tab" || aExt == "xls")
    157             aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(CALC_TEXT_FILTER);
    158         else
    159             aMediaDesc[MediaDescriptor::PROP_FILTERNAME()] <<= OUString(WRITER_TEXT_FILTER);
Comment 2 tommy27 2016-04-16 07:22:38 UTC Comment hidden (obsolete)
Comment 3 Harald Koester 2016-08-26 13:35:40 UTC
Checked with version 5.2.0. Bug still exists.
Checked with version 4.0.5. Bug already exists.
Checked with version 3.6.7. Bug already exists.
Checekd with version 3.6.0. Bug already exists.
Checked with version 3.5.7. Works as expected.
Checked with version 3.3.0. Works as expected.

Henced Bug is a regresseion and has been introduced with version 3.6.0.
Comment 4 V Stuart Foote 2016-08-26 15:19:50 UTC
As can be seen in the code pointer comment 1 (have been some minor changes for support of compressed csv since--so http://opengrok.libreoffice.org/xref/core/filter/source/textfilterdetect/filterdetect.cxx#175 )

// Decide which filter to use based on the document service first,
// then on extension if that's not available.

Document service will be WRITER_DOCSERVICE if Writer is open with focus. CALC_DOCSERVICE if Calc is open--where the Text Import filter dialog will assert for files with extensions: csv, tsv, tab, xls, csv.gz

A comma, tab, semicolon, space or user defined delimiter text file will open by default into Calc -- that was done for bug 68903

Meaning if the StartCenter is present, the Open button opening a comma separated (.CSV/.XLS/.CSV.GZ) or tab separated (.TSV/.TAB/.XLS) labeled file (semicolon, space or user selected dlimiters would need one of the established extensions) will all present the "Text Import" filter dialog and the delimited fields will be opened into the Calc module.

If Draw, Impress, or Math module is active and has focus the File -> Open .uno:Open action will call the "Text Import" filter dialog for import into a Calc session based on file extension.

If the File -> Open comes when an active Calc module has focus--the CALC_DOCSERVICE is active and the CSV/TSV/TAB/XLS delimited file will call the "Text Import" filter dialog and be parsed into a Calc sheet.

Only if the File -> Open comes when an active Writer module has focus--and the WRITER_DOCSERVICE is active and the CSV/TSV/TAB/XLS/CSV.GZ delimited file will all open as text in Writer.

This behavior is consistent and not unexpected. No reason to change.
Comment 5 Harald Koester 2016-08-31 10:18:04 UTC
(In reply to V Stuart Foote from comment #4)
Hi Stuart,
> 
> Only if the File -> Open comes when an active Writer module has focus--and
> the WRITER_DOCSERVICE is active and the CSV/TSV/TAB/XLS/CSV.GZ delimited
> file will all open as text in Writer.
> 
> This behavior is consistent and not unexpected. No reason to change.

I'm sorry I don't agree. To my opinion generally the 'character' separated value files should be opened with calc by default. Usually only Calc is able to interpret these kind of files and to display them in a convenient way. This should be done independently from where (Start Center, Writer, Calc, ...) these files are opened. A different treatment only irritates the user like I was.

It may be possible that in some rare cases a user likes to open these kinds of files with Writer. But then to my opinion a user should explicitly select this option. I see two ways to do this. First it can be done by selecting text documents ["Text documents (*.oth, *odt, ...)] in the Open dialogue or secondly with a check box "Open with Writer" in the Text Import dialogue. But also in these cases this should always be done independently from where these files are opened.

Hence Status set back to NEW.

Best
Comment 6 V Stuart Foote 2016-08-31 12:31:20 UTC
The textfilterdetect source could be reworked to eliminate WRITER_DOCSERVICE from the filter process--and adding specific filter type for opening with Writer on occasion a user really prefers that. 

But not clear there is much demand for adjusting what is presently a consistent and rational default behavior.

UX-advise, and see if any dev has an interest.
Comment 7 Yousuf Philips (jay) (retired) 2016-09-01 15:38:08 UTC
As .csv files arent displayed when "Text document" is selected, not sure how it can be opened in writer in that manner.

But back to the point, i would have .csv file exclusively open in calc, as users who want to edit it otherwise would open it in gedit rather than writer.
Comment 8 V Stuart Foote 2016-09-01 15:58:28 UTC
(In reply to Yousuf Philips (jay) from comment #7)
> As .csv files arent displayed when "Text document" is selected, not sure how
> it can be opened in writer in that manner.
> 
> But back to the point, i would have .csv file exclusively open in calc, as
> users who want to edit it otherwise would open it in gedit rather than
> writer.

Believe that's the point of OP, it can't. Internally if the Writer module is running the WRITER_DOCSERVICE takes precedence over the file extension in selecting the text filter to open the comma separated value .CSV file (a.k.a "character" separated value).

With WRITER_DOCSERVICE set (because the call to open comes from a Writer session) the document is not passed to the Text import filter for opening into Calc.

Meaning--if you want to open it in Writer, launch Writer and open it there--regardless of handling for the file extension. Otherwise the file extension will trigger the text import filter from any other launch scenario. And why I don't see much need to change anything.
Comment 9 Yousuf Philips (jay) (retired) 2016-09-03 13:55:39 UTC
(In reply to V Stuart Foote from comment #8)
> Believe that's the point of OP, it can't. Internally if the Writer module is
> running the WRITER_DOCSERVICE takes precedence over the file extension in
> selecting the text filter to open the comma separated value .CSV file (a.k.a
> "character" separated value).

Harald stated in comment 3 that the issue was a regression, so it used to work in 3.3.0 and is broken presently. So i would be in favour of returning the old behaviour of it always opening in calc and not reply on what module is currently open.
Comment 10 V Stuart Foote 2016-09-03 14:53:13 UTC
OK, but the filter for being able to open in Writer will need to be added or we actually will end up with issue of bug 89684.

Also if doing this, as in bug 89685 for "Spreadsheets", the filter group for "Text documents" as well as the Writer and Calc filter segments will need entries.
Comment 11 Maxim Monastirsky 2016-09-03 19:14:57 UTC
Formats that can be opened by more than one app, such as html rtf and plain text (which is what a csv file is, as there is no way to "detect" csv files by content) are opened in the currently active app. That's an intentional change made in LO, as noted by Kohei at https://lists.freedesktop.org/archives/libreoffice/2014-July/062540.html

To me it is understandable and consistent behavior, as if you open a .csv file from inside gedit, you don't expect it to open in Calc, because that's a separate app. So the same should apply to Writer (which isn't exactly a separate app technically, but it is for the end user). That's a way to open the file in Writer for someone who need it, instead of telling him to scroll a long list of formats. And open Calc to be able to open the file from there is just one click away.

I however do understand why some people prefer that a plain text files with a .csv extension would always open in Calc. But instead of fighting endlessly on what the default behavior should be, I suggest to make this configurable, so hopefully everyone will be happy.
Comment 12 Xisco Faulí 2016-09-13 09:58:10 UTC
According to comment 3, it was first reproduced in 3.6.0.4, thus updating version accordently.
Comment 13 Heiko Tietze 2016-12-29 08:37:17 UTC
Removing needsUXEval since we have more or less an agreement to load CSV by default into Calc regardless of where it is being opened. But I disagree with Maxim's suggestion in comment 11 to have an option, at least not in the configuration dialog.
Comment 14 V Stuart Foote 2016-12-29 13:36:00 UTC
(In reply to Heiko Tietze from comment #13)
> Removing needsUXEval since we have more or less an agreement to load CSV by
> default into Calc regardless of where it is being opened. But I disagree
> with Maxim's suggestion in comment 11 to have an option, at least not in the
> configuration dialog.

I don't agree to a change from current behavior. It is not necessary.  

Placement of configuration setting to modify behavior of the WRITER_DOCSERVICE could be either the Options dialog, or as and Expert configuration stanza. Or alternatively do what was suggested (comment 6) eliminate/override the document service and open CSV by default to Calc, but provide specific filter entry to open in Writer.

It all depends on what we see as correct default behavior for opening a CSV when a Writer session is open and has focus. To me, and as currently implemented we have the correct defaults in place and honoring the document service.

Deciding a default, and where to place configuration needed to change it, remains a UX issue.
Comment 15 Heiko Tietze 2016-12-29 17:37:59 UTC
(In reply to V Stuart Foote from comment #14)
> I don't agree to a change from current behavior. It is not necessary.  

Looks like I misunderstood:

(Yousuf Philips (jay) from comment #9)
> Harald stated in comment 3 that the issue was a regression, so it used to
> work in 3.3.0 and is broken presently. So i would be in favour of returning
> the old behaviour of it always opening in calc and not reply on what module
> is currently open.

(V Stuart Foote from comment #10)
> OK, but the filter for being able to open in Writer will need to be added or
> we actually will end up with issue of bug 89684.

And as you say with
 
> Placement of configuration setting to modify behavior of the
> WRITER_DOCSERVICE could be either the Options dialog, or as and Expert
> configuration stanza. Or alternatively do what was suggested (comment 6)
> eliminate/override the document service and open CSV by default to Calc, but
> provide specific filter entry to open in Writer.

you accept to open Calc by default but provide specific filter in Writer. As a side note many confusion comes from the module agnostic approach to open files with the module that is linked with the extension.
 
What do you expect from UX now? Where a configuration should be stored? My take on this is

(In reply to Heiko Tietze from comment #13)
> ... I disagree with Maxim's suggestion in comment 11 to have an option, 
> at least not in the configuration dialog.

Tickets will not go into production unless UX is removed, that's what has been agreed lately in the ESC.
Comment 16 Maxim Monastirsky 2016-12-29 19:15:10 UTC
It's worth mentioning that the behavior can be changed via extensions. Just override the "DetectService" property of the "generic_Text" type with your own service, and implement it the way you want (with a possible fallback to the default one for cases you don't want to handle). I tried it, and it seems to work. So there is no real need for additional config in LO core.
Comment 17 V Stuart Foote 2016-12-29 22:50:55 UTC
These fall through generic_Text filter behaviors are as designed [1], and current order of CALC_DOCSERVICE -> WRITER_DOCSERVICE -> file "extension", or fall through to Writer is intentional [2].  

As in the see also bug 65017 for RTF handling it is a feature introduced at 3.6, removing "regression".

Again, if you want a CSV (of any flavor delimiter (comma, tab, space, etc.) to open into Calc--do not have a Writer session open with canvas focus! Writer can be open, but not have focus--and the Text Import dialog for import to Calc will launch.

**And if you want to open CSV into Writer--open it from a Writer session**

This is the way the generic_Text filter was implemented. Again see no need to change our handling--no need to change filter order--and there is nothing incorrect as implemented!

The otherwise valid enhancement of adding missing filter(s) to the Writer module and Calc module type lists (e.g. bug 89685) is not bound to generic_Text filter handling of the CSVs.

If UX needs to drive this a different direction (the Writer_DOCSERVICE filter could be removed)--please just be aware that what we have was intentional and well reasoned and works. 

=-refs-=

[1] Kohei's initial PlainTextFilterDetect for CSV & TXT by DOC_SERVICE first and then by extension, subsequently expanded to more formats...  https://cgit.freedesktop.org/libreoffice/core/commit/?id=8b8e24544793f4ec6f61edb7ce8ac10bf6bb0981

[2] Current support for open into Calc for file extensions "csv", "tsv", "tab", "xls" and ".csv.gz" file extensions when Writer service is not active.
http://opengrok.libreoffice.org/xref/core/filter/source/textfilterdetect/filterdetect.cxx?a=true#181
Comment 18 Maxim Monastirsky 2017-01-01 08:21:43 UTC
Created attachment 130066 [details]
extension to open csv always in calc

Following my last comment, attached a simple extension that will make csv open always in Calc.

In addition, I forgot that the current behavior is actually controlled by the special .uno:OpenFromWriter command. Making csv open always in Calc is only a matter of customizing the toolbar/menubar and swapping .uno:OpenFromWriter with a plain .uno:Open.
Comment 19 Cor Nouws 2017-11-02 10:18:15 UTC
I think Stuart explains clear why the current behavior is not a bug, designed and consistent.
One would expect that users working with csv files will understand this fast enough and do what is needed to open such files in the module they prefer.
Using the extension that Maxim kindly attached, can be done too of course.
Comment 20 Thomas Lendo 2017-11-09 12:23:51 UTC
Having the changes in the past in mind, I support Stuart's and Maxim's point of view.

(In reply to Maxim Monastirsky from comment #18)
> In addition, I forgot that the current behavior is actually controlled by
> the special .uno:OpenFromWriter command. Making csv open always in Calc is
> only a matter of customizing the toolbar/menubar and swapping
> .uno:OpenFromWriter with a plain .uno:Open.
Very interesting. Didn't know that there exists 2 ways for opening a document. In the function list of the Customize dialog are 2 "Open" items but it's not obvious for the user what they do or what's the difference between them. (Hopefully fixing bug 108458 will improve that.)
Comment 21 Heiko Tietze 2017-11-09 20:42:55 UTC
We had a hot discussion during the design meeting. There are arguments for both options and people are split. The safest way is to keep the current behavior, so WF.