Issue 35830 - Save As truncates filename that contains a dot
Summary: Save As truncates filename that contains a dot
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: ui (show other issues)
Version: 680m92
Hardware: PC Linux, all
: P3 Trivial (vote)
Target Milestone: OOo 2.0.2
Assignee: thorsten.martens
QA Contact: issues@framework
URL:
Keywords: oooqa
: 21282 56758 56790 57881 (view as issue list)
Depends on:
Blocks:
 
Reported: 2004-10-19 22:10 UTC by grgustaf
Modified: 2006-02-16 14:13 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Automatic file name extension logic removed - do not change file name (3.07 KB, patch)
2005-05-06 11:12 UTC, rvojta
no flags Details | Diff
Solution c) - leave logic and check the extensions before modification (2.84 KB, patch)
2005-05-06 17:14 UTC, rvojta
no flags Details | Diff
Patch for the c) option (4.34 KB, patch)
2005-05-10 08:34 UTC, rvojta
no flags Details | Diff
ooo-build's fix for this issue (3.90 KB, patch)
2005-10-21 12:55 UTC, rvojta
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description grgustaf 2004-10-19 22:10:44 UTC
If you have a filename with more than one dot in it, such as myfile-v1.0.sxw,
and you open the Save As dialog, it displays only "myfile-v1.0" in the filename,
hiding the extension. Then if you switch to a different file type, such as RTF,
it misinterprets '.0' as the extension and removes it, making myfile-v1.rtf.
Once the extension is shown explicitly like that, you can change to other file
types without a problem.

Steps to reproduce:
1. In Word Processor, go to File | Save As...
2. Type a filename "a.b.c", click Save. File is saved as a.b.c.sxw
3. Go to File | Save As... again. Filename shown as 'a.b.c'
4. Choose RTF file type. Filename changes to a.b.rtf
5. Click Save. File is saved as a.b.rtf

Expected results:
Changing file type would preserve the base document name.

Found in RHEL3 Desktop openoffice.org-1.1.0-16.7.EL
Comment 1 stefan.baltzer 2004-10-20 09:55:51 UTC
SBA: Component changed to "framework". Reassigned to TM
Comment 2 mci 2004-10-22 12:38:05 UTC
Hi grgustaf,

thanks for using and supporting OpenOffice.org...

This is reproduceable here on Solaris, too...

mci -> mav:
Hi mav, I think this is something for you. Please ressign, if this nothing in
your area., thanks...
Comment 3 Mathias_Bauer 2004-10-22 16:42:27 UTC
mba: retargetted due to heavy workload
Comment 4 grgustaf 2004-10-22 17:22:40 UTC
I thought of a more exciting example of the bug:

1. Open Word Processor
2. File | Save As, type name: a.b.c.d, save.
3. Save As, change type to .stw, save.
4. Save As, change type to .doc, save.
5. Save As, change type to .txt, save. Etc.

The files created are: a.b.c.d.sxw, a.b.c.stw, a.b.doc, a.txt
Comment 5 ammadaleem 2005-02-04 20:37:15 UTC
I was able to replicate the bug with Open Office 1.1 on a Linux OS and with Open
Office 1.4 on a Windows XP OS.

The problem, it seems, is that Open Office, in some cases, interprets the
contents after the last dot in the filename as an extension. 

I did some follow-up testing and it appears that not all possible strings (after
the last dot in filename) are interpreted as extensions. For example 0, foo,
blah, 1, p … are not interpreted as extensions whereas c, x … are interpreted as
extensions. Thus if an attempt is made to save a text file under a name such as
someName.foo, no problems occur and the file is saved as someName.foo.sxw. But
if an attempt is made to save some text file under a name someName.c, c gets
interpreted as an extension and the file is saved under the name someName.c
instead of being saved under someName.c.sxw.

It also appears that the bug is not specific to just Text Documents but spills
over to Presentation, Spreadsheets and Drawings.
Comment 6 luc_khanh 2005-02-04 21:57:07 UTC
Reproduceable on the following system:
System: Linux 2.4.26 Intel Celeron 766MHz 128MB RAM
OpenOffice.org 1.1.0

Tried the following two additional tests:
1) If file names with more than one consecutive dot are used, e.g. a.b..c.d or
a.b.. , this will prevent the application from mistaking any part of the file
name before the consecutive dots as an extension.
2) It is even possible to use dots only as a file name, e.g. chosing ... as file
name results in ....sdw as the saved file for instance. Of course this file will
be hidden in the Unix directory and can be viewed with the "ls -a" command.

Until this bug is fixed one can work around the problem by selecting the full
name with the previously saved extension before switching extension, i.e. click
on a.b.c.sxw before switching to extension .rtf in the example of grgustaf
Comment 7 rvojta 2005-04-13 21:31:41 UTC
I'm working on the presentation in the m92 and the file name is
co-prinese-2.0.odp. I decided to save it in the sxi format, so
I did File -> Save As, file type change and the file name was
truncated to the co-prinese-2.sxi, should be co-prinese-2.0.sxi.

Changing Version and the Target milestone, because it's quite
important and this Issue should be solved in the final 2.0.
Comment 8 thorsten.martens 2005-04-14 09:06:27 UTC
TM->AS: Please have a look, thanks !
Comment 9 andreas.schluens 2005-04-14 10:27:41 UTC
AS->MVA: Please take over. THX.
Comment 10 rvojta 2005-04-24 09:10:14 UTC
I was wondering why this Issue is not listed in the OOo 2.0 Issues
and I got it, target milestone is back to the OOo Later :( I think
that this Issue should be solved in the OOo 2.0 and I'm ready to
fix this, I found where the problem is, but need small advice which
direction is better.

The problem is here - lcl_autoUpdateFileExtension function is
called each time when the filter is modified or when the
checkbox 'Automatic file name extension' has been toggled. This
function expects file name with extension, but the problem is,
that the file name is here without an extension even if there
is 'Automatic file name extension' (AFNE) checked.

Few ways how to fix it:

  a) add extension to the file name during file picker dialog
     initialization (if AFNE is checked), so the extension will
     be visible from the same beginning

  b) do not show the extension in the file name even if AFNE is
     checked (same behaviour like Microsoft Office)

  c) leave it as it is and add more logic to check the extension handling,
     it means, add function which will examine the file name and the
     possible extensions from the previous filter and if there will be
     match, modify extension in the filename otherwise leave the file
     name as it is even if there will be AFNE checked

Who is responsible for the UI behaviour?
Comment 11 rvojta 2005-04-27 12:38:29 UTC
rvojta @ ft: Please, can you review my last comment and tell me which
solution is the best one (or propose new) for the end users? Then
reassign this Issue back to me, I'll fix it. Should be fixed for the
2.0 even if there is OOo Later. Thanks!
Comment 12 rvojta 2005-05-05 12:45:49 UTC
*** Issue 21282 has been marked as a duplicate of this issue. ***
Comment 13 rvojta 2005-05-06 11:12:29 UTC
Created attachment 25854 [details]
Automatic file name extension logic removed - do not change file name
Comment 14 rvojta 2005-05-06 11:13:45 UTC
Attached patch changes the generic fpicker behaviour - do not change
file name even if the check box is checked -> behave in the same way
as Gnome, MS Office fpickers ...
Comment 15 rvojta 2005-05-06 17:14:59 UTC
Created attachment 25862 [details]
Solution c) - leave logic and check the extensions before modification
Comment 16 rvojta 2005-05-06 17:16:09 UTC
Attached patch doesn't modify the behaviour, it justs fixes the extension
handling - extension is changed only and only if the part after the file
name's last dot is same as the last filter extension.
Comment 17 Frank Schönheit 2005-05-10 08:31:04 UTC
fs->rvojta: I'm in charge of the file picker, so lemme add my comments to this

a) does sound bad. Though there never has been a full specification for the file
dialog, I remember that on various occasions, the User Experience (UE) Team
wanted wanted the extension not to be shown by default. I know that this is a
rather fuzzy argument :), but I suppose showing the extension always is not what
UE would support.
Furthermore, it would only move (though relax) the problem, since the user might
remove the extension explicitly, and then switch the filter -> same problem again.

I'm not sure if I like b) (even if a certain competitor does it this way :).
Finally, it means that the user only knows what's going on after it's too late.
Given that extensions have a rather high importance (we may like or dislike this
fact), I would not be happy with not telling the use which extension her file is
going to have.

c) sounds like the best solution - it's a comprehensive fix, and still leaves
the user with a glue what's going on.
Comment 18 Frank Schönheit 2005-05-10 08:33:12 UTC
fs->ft: If you agree to the argueing that c) is the best solution, I'd be
willing to give rvojta's fix a review (it looks goot at a first glance).
Somebody would still have to decide on a target milestone then.
Comment 19 rvojta 2005-05-10 08:34:34 UTC
Created attachment 25955 [details]
Patch for the c) option
Comment 20 rvojta 2005-05-10 08:36:07 UTC
rvojta->fs: I attached the last version of this patch (-c-2.diff), which
was already accepted by mmeeks in the ooo-build.
Comment 21 stefankalte 2005-07-14 17:11:59 UTC
hello,
i don't understand in this issue something,
first issue 21282 is older and is closed as resolved,
second the problem of saving in *.dot must be a litter problem as here discussed
and tried to be resolved,
When i have a file in *.doc i can renaime it in *.dot, so i ask me why it will
be so a long discussion about this, i don't understand from programming, but
including in writer as a saving option in *.dot will be so difficult because it
has the same format like *.doc.
Mybe i can help with this comment to solve the problem
grüsse stefan
Comment 22 meinsen 2005-07-25 11:39:06 UTC
Problem is still in OOo 1.9.113 on Win XP Pro.
Comment 23 mendebrock 2005-09-07 02:40:06 UTC
Has a decision about which of the patches for options a,b, or c been applied to
OO 2.0 beta 2?

I'm guessing not. Defect verified present in 2.0 beta 2
Comment 24 falko.tesch 2005-10-20 15:59:41 UTC
FT: Patches will not go into 2.0. They need to get evaluated by the correct
engineer.
Comment 25 falko.tesch 2005-10-21 09:23:47 UTC
FT: Please check patch based on solution c) from rvojta posted on Sun Apr 24
01:10:00. Thx a lot.
Comment 26 rvojta 2005-10-21 12:55:20 UTC
Created attachment 30698 [details]
ooo-build's fix for this issue
Comment 27 rvojta 2005-10-21 12:56:53 UTC
I've created "different" patch for this issue. It was accepted by Mikael Meeks
and is part of the ooo-build patch set for a long time .

It's a last attachment - fpicker-generic-extn.diff
Comment 28 Frank Schönheit 2005-10-24 09:30:37 UTC
Thanks for providing this patch! Looking at it, there's one real issue and two nits:
- it has the potential to crash in FilterSelectHdl_Impl:
    const String& rLastFilterExt = pThis->_pImp->GetCurFilter()->GetExtension();
  Since GetExtension returns a String, not a reference to a String, this means that
  rLastFilterExt potentially points to dead memory as soon as it's assigned.
Depending
  on your compiler, this might or might not be a problem.
- in GetFsysExtension_Impl, it's probably better to not ignore the case. Other
places in
  the file make ignoring the case dependent on the platform, see for instance
  FindFilter_Impl.
  However, given that case handling is incorrect, anyway (normally it should depend
  on the case-sensitiveness of the concrete folder, not on the case-sensitiveness
  of the platform where you compiled the product), this probably doesn't really
hurt ...
- In
    if ( rFile.Copy( p1 - p0 + 1).EqualsIgnoreCaseAscii( rLastFilterExt ) )
      return String( rFile.Copy( p1 - p0 + 1 ) );
  the second Copy seems superfluous - returning rLastFilterExt directly would be
  better (and slightly and unnoticable faster :)

I addressed the first and the third item above, and checked the fix into CWS
dba202a. Again, thanks for the patch!
Comment 29 lohmaier 2005-10-31 23:33:57 UTC
*** Issue 56790 has been marked as a duplicate of this issue. ***
Comment 30 lohmaier 2005-10-31 23:36:42 UTC
*** Issue 56758 has been marked as a duplicate of this issue. ***
Comment 31 ooo 2005-11-01 11:29:24 UTC
First of all - I am not a programmer so I don't understand half of the 
comments :v( 
 
When you open the document/file sometthing.xxx.yyy.zzz it has the filename 
extension (.zzz) then the program should split the filename in two parts: 
- Part one - the filename without extension (sometthing.xxx.yyy) 
- Part two - the filename extension (.zzz). 
 
Everytime you will Save As then it only has to change the filename extension 
and not the filename without extension. 
 
If you create a document then the filename extension would be the default 
which should be shown in the Save As dialogbox - don't hide any part of the 
filename for the user. 
 
You could use these filenames as test examples: 
 
filename-test-file.odt select .ott should give filename-test-file.ott 
filename-test-file.odt.odt select .ott should give filename-test-file.odt.ott 
filename-test-file-1.2.3.odt select .ott should give 
filename-test-file-1.2.3.ott 
filename-test-file....odt select .ott should give filename-test-file....ott 
Comment 32 lohmaier 2005-11-14 23:55:08 UTC
*** Issue 57881 has been marked as a duplicate of this issue. ***
Comment 33 Frank Schönheit 2005-12-02 09:33:17 UTC
fs->tm: please verify in CWS dba202a

re-open issue and reassign to tm@openoffice.org
Comment 34 Frank Schönheit 2005-12-02 09:35:17 UTC
reassign to tm
Comment 35 Frank Schönheit 2005-12-02 09:40:46 UTC
reset resolution to FIXED
Comment 36 thorsten.martens 2005-12-15 13:32:47 UTC
Checked and verified in cws dba202a -> OK !
Comment 37 thorsten.martens 2006-02-16 14:13:58 UTC
closed