Bug 56562 - Wrong filename in title bar
Summary: Wrong filename in title bar
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected) release
Hardware: Other macOS (All)
: medium normal
Assignee: Not Assigned
Whiteboard: target:4.4.0
Depends on:
Reported: 2012-10-30 02:03 UTC by Matthew Francis
Modified: 2014-09-28 02:50 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:

Workaround patch (648 bytes, patch)
2014-08-11 11:22 UTC, Matthew Francis

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Francis 2012-10-30 02:03:39 UTC
The title bar icon of a window (of a saved file) in OSX is a useful shortcut to the file itself - for instance, it can be dragged to a gmail browser window to attach the file.
Unfortunately LO can get confused about which file should be dragged from the title.

Steps to reproduce:

1. Create a new Writer file

2. Save as "AAAA.doc", with type Microsoft Word 97/2000/XP/2003 (.doc)
(* This bug does not appear to occur when saving as ODT. Unsure about other file types)

3. Close the file

4. Reopen the file

5. Save as "BBBB.doc"

Expected result:
* Cmd-click / right click on the filename in the title bar should show the directory path of "BBBB.doc"
* Dragging the icon from the title bar should yield the file "BBBB.doc"

Actual result:
* Cmd-click / right click on the filename in the title bar actually shows the directory path of "AAAA.doc" (although the title bar itself reads "BBBB.doc" when not clicked on)
* Dragging the icon from the title bar actually yields the file "AAAA.doc"

Side effects:
Attaching wrong files to emails, embarrassment

Reproduced in release and a recent build of
Comment 1 Emir Sarı 2012-11-23 03:06:53 UTC
Confirmed on OS X 10.7.5 LO 

Note: Closing BBBB.doc after seeing the error and reopening it does not reproduce this issue.
Comment 2 Matthew Francis 2014-08-08 04:05:15 UTC
Bug is still present in
Comment 3 Matthew Francis 2014-08-09 14:43:37 UTC
Dug into this one a little further. The issue is in platform independent code, although quite possibly only OSX consumes the information in question.

When saving an ODF, this happens during the process:

        getDocProperties()->setGenerator( ::utl::DocInfoHelper::GetGeneratorString() );
        xModel->attachResource( aURL, aMediaDescr );

Because setGenerator() is first called beneath SvXMLExport::exportDoc(), the later call to setGenerator() with the same string in SfxObjectShell::DoSaveCompleted() has no effect, and the window title isn't actually changed until the call to InvalidateName(), after the file URL has been set by the call to xModel->attachResource().

In contrast, when saving (exporting) a .doc, nothing calls setGenerator() before SfxObjectShell::DoSaveCompleted(), so the following happens:

        getDocProperties()->setGenerator( ::utl::DocInfoHelper::GetGeneratorString() );
                                    Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) );
        xModel->attachResource( aURL, aMediaDescr );

Because setGenerator() actually changes the generator string within DoSaveCompleted() this time, the window title ends up being set early, before the file URL is set. Later in DoSaveCompleted(), when the call to InvalidateName() is reached, nothing happens because the window title hasn't actually changed again, and the fact that the URL has changed isn't considered

(In the ODF case, the earlier setGenerator() does not result in a title change broadcast because SetModified() decides not to call ModifyChanged())

As yet I have no idea which strand of yarn to pull in order to untangle this.
Comment 4 Matthew Francis 2014-08-11 11:22:00 UTC
Created attachment 104431 [details]
Workaround patch

Attached is a minimal workaround that is quite possibly completely wrong structurally, but does happen to fix the wrong URL in the titlebar
Comment 5 Commit Notification 2014-09-06 20:31:58 UTC
Matthew J. Francis committed a patch related to this issue.
It has been pushed to "master":


fdo#56562 OSX: Update URL in Writer title bar when saving .doc

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:
Affected users are encouraged to test the fix and report feedback.
Comment 6 Adolfo Jayme Barrientos 2014-09-06 21:23:14 UTC
Thanks for the patch!
Comment 7 Matthew Francis 2014-09-28 02:50:42 UTC
*** Bug 84301 has been marked as a duplicate of this bug. ***