sfx2/source/doc/docfile.cxx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
New commits: commit a199cad8376a5470c50125def2738b44b55ec018 Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Apr 27 11:35:55 2015 +0200 tdf#65498, tdf#87545: Don't confuse logically r/o doc with physically r/o b9ecec7c74687ed5a9470cffb7d02e0e6e83107e "Allow for editing of read-only documents" introduced "A new state of 'IsOriginallyReadOnly' needed to be added to the medium, to keep track whether the medium was originally opened r/o (and is thus assumed to be physically r/o), as toggling SID_EDITDOC in the view also changes the open mode of the underlying medium. Instead of trying to fully understand and disentangle that horrible mess, I just added yet another state to the mess..." But that heuristic is apparently too simplistic, as it treats documents originally opened "logically r/o" (via --view command line argument, or by checking the corresponding checkbox in the Open dialog) as "physically r/o" too, which leads to unexpected behavior when such documents are later switched into r/w Edit mode. An approach that hopefully works better overall is to set IsOriginallyReadOnly only if the document originally is r/o as reported by OSL (for a document with a file URL). Change-Id: I32d5ec655d7556a70680aee55feda4c6eea7795f diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 8fff9b0..b7a1f6f 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -1001,9 +1001,6 @@ void SfxMedium::LockOrigFileOnDemand( bool bLoading, bool bNoUI ) bContentReadonly = IsReadonlyAccordingACL( aPhysPath.getStr() ); } #endif - - if ( bContentReadonly ) - pImp->m_bOriginallyReadOnly = true; } // do further checks only if the file not readonly in fs @@ -2466,6 +2463,18 @@ void SfxMedium::Init_Impl() } SetIsRemote_Impl(); + + osl::DirectoryItem item; + if (osl::DirectoryItem::get(GetName(), item) == osl::FileBase::E_None) { + osl::FileStatus stat(osl_FileStatus_Mask_Attributes); + if (item.getFileStatus(stat) == osl::FileBase::E_None + && stat.isValid(osl_FileStatus_Mask_Attributes)) + { + if ((stat.getAttributes() & osl_File_Attribute_ReadOnly) != 0) { + pImp->m_bOriginallyReadOnly = true; + } + } + } } @@ -2859,14 +2868,15 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : } } + bool readOnly = false; SFX_ITEMSET_ARG( pImp->m_pSet, pReadOnlyItem, SfxBoolItem, SID_DOC_READONLY, false ); if ( pReadOnlyItem && pReadOnlyItem->GetValue() ) - pImp->m_bOriginallyReadOnly = true; + readOnly = true; SFX_ITEMSET_ARG( pImp->m_pSet, pFileNameItem, SfxStringItem, SID_FILE_NAME, false ); if (!pFileNameItem) throw uno::RuntimeException(); pImp->m_aLogicName = pFileNameItem->GetValue(); - pImp->m_nStorOpenMode = pImp->m_bOriginallyReadOnly ? SFX_STREAM_READONLY : SFX_STREAM_READWRITE; + pImp->m_nStorOpenMode = readOnly ? SFX_STREAM_READONLY : SFX_STREAM_READWRITE; Init_Impl(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits