Bug 90837 - re-base: Can't "Save As" file opened in view mode on top of the original file
Summary: re-base: Can't "Save As" file opened in view mode on top of the original file
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.0.0.0 beta1
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.5.0 target:7.4.0.0.beta2
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2015-04-24 15:21 UTC by Matthew Francis
Modified: 2022-07-06 18:36 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Francis 2015-04-24 15:21:54 UTC
"Save As" can't be used on a file opened in view mode to overwrite the original file.

This is related to bug 65498, but was introduced by a different commit.
(This one is specific to "Save As")

Steps to reproduce:
- Open any LO document (Writer, Calc, ...) with the --view option
- Enable editing
- Save As... and accept the original filename

Expected result
- The file is saved

Actual result
- Error dialog
Comment 1 Matthew Francis 2015-04-24 15:31:26 UTC
Taking the liberty of setting this to NEW myself as a commit has been identified.

Bisection narrowed this down to e70c4a279c2a8f93d917c0a43fc39ac017ecc463^1..e2799d253b1dc62967693aa5bccd7360a9520967
but ignoring the irrelevant and/or broken commits in that range, it's e2799d253b1dc62967693aa5bccd7360a9520967 which looks like it has changes relevant to read-only mode

Adding Cc: to michael.meeks@collabora.com; In the unlikely event you have time to take a look at this one...


commit e2799d253b1dc62967693aa5bccd7360a9520967
Author: Michael Meeks <michael.meeks@suse.com>
Date:   Thu Jul 5 20:18:35 2012 +0100

    re-base on ALv2 code. Includes:
    
        Patches contributed by Mathias Bauer:
        cws mba34issues01: #i117713#: remove superfluous assertions about field unit fallbacks
        http://svn.apache.org/viewvc?view=revision&revision=1172341
        cws mba34issues01: #i117718#: provide filter name in case
        storage of medium does not allow to detect one
        cws mba34issues01: #i117712#: fix several resource errors introduced by IAccessible2 implementation
        http://svn.apache.org/viewvc?view=revision&revision=1172343
        http://svn.apache.org/viewvc?view=revision&revision=1172350
        cws mba34issues01: #i117708#: status indicator for inactive documents
        http://svn.apache.org/viewvc?view=revision&revision=1172358
        cws mba34issues01: #i116025#: fix typo and add missing treatment of new parameter
        http://svn.apache.org/viewvc?view=revision&revision=1172359
        cws mba34issues01: #i117024#: rework parameter conversion for load/save slots
        http://svn.apache.org/viewvc?view=revision&revision=1172360
        cws mba34issues01: #i116803#: possible crash on Linux when
        dispatch.cxx is compiled with optimization
        http://svn.apache.org/viewvc?view=revision&revision=1172367
        cws mba34issues01: #i114600#: fix compiler warning for name clash found on Solaris
        http://svn.apache.org/viewvc?view=revision&revision=1172371
Comment 2 Robinson Tryon (qubit) 2015-12-13 11:12:18 UTC Comment hidden (noise)
Comment 3 Xisco Faulí 2016-09-26 15:29:08 UTC
Adding Cc: to Michael Meeks
Comment 4 QA Administrators 2017-10-23 14:10:51 UTC Comment hidden (noise, obsolete)
Comment 5 QA Administrators 2019-12-03 14:37:06 UTC Comment hidden (noise)
Comment 6 QA Administrators 2021-12-03 04:37:14 UTC Comment hidden (noise)
Comment 7 Justin L 2021-12-21 09:53:49 UTC
This hits objserv.cxx "Fatal IO error during save" exception
p aErrorEx
$2 = (const com::sun::star::task::ErrorCodeIOException &) @0x555559be99a0: {<com::sun::star::io::IOException> = {<com::sun::star::uno::Exception> = {
      Message = "SfxBaseModel::storeSelf: 0x507 /persistent/git/libreoffice2/sfx2/source/doc/sfxbasemodel.cxx:1685", Context = empty uno::Reference}, <No data fields>}, ErrCode = 1287}

This comes from sfx2/source/doc/docfile.cxx
The document is still considered read only because
                bReadOnly = !( GetOpenMode() & StreamMode::WRITE );  


Ultimately, the error is set by
            if ( !bLoading || (pReadOnlyItem && !pReadOnlyItem->GetValue()) )
                SetError(ERRCODE_IO_ACCESSDENIED);
since it is not bLoading.
Comment 8 Justin L 2021-12-21 09:55:57 UTC
I'm not sure I would classify this as an bug/regression. With the view flag, you are effectively flagging the file as a read-only medium.

In any case, this will be an extremely dangerous working area. Not for me.
Comment 9 Michael Meeks 2022-07-05 14:30:33 UTC
Hmm -I get this:

--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2639,6 +2639,7 @@ bool SfxObjectShell::Save_Impl( const SfxItemSet* pSet )
 {
     if ( IsReadOnly() )
     {
+        SAL_DEBUG("SAVE_Impl at the top");
         SetError(ERRCODE_SFX_DOCUMENTREADONLY);
         return false;
     }

triggering the error for me - it seems we switch to 'Save_Impl' if the destination file is the same as the source file - and it seems rather a reasonable error that we give; and a reasonably safe behavior.

Will push a patch to clarify the error message =)
Comment 10 Commit Notification 2022-07-06 08:30:27 UTC
Michael Meeks committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/170a2b9da7848b66d93e10aed29f7f5ac2c8ebca

tdf#90837 - clarify the error message re: over-writing readonly files.

It will be available in 7.5.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2022-07-06 18:36:28 UTC
Michael Meeks committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/3f578443d92b0c56f8f2c1fb6c6bb5be8ab4ea54

tdf#90837 - clarify the error message re: over-writing readonly files.

It will be available in 7.4.0.0.beta2.

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

Affected users are encouraged to test the fix and report feedback.