include/sfx2/docfile.hxx | 12 +++++++++--- include/sfx2/objsh.hxx | 1 + sfx2/source/doc/docfile.cxx | 12 +++++++++--- sfx2/source/doc/objmisc.cxx | 5 +++++ sfx2/source/view/viewfrm.cxx | 3 ++- 5 files changed, 26 insertions(+), 7 deletions(-)
New commits: commit 191c0a9e7719b777146430486d703641aaff43bf Author: Stephan Bergmann <[email protected]> Date: Wed Aug 24 15:14:38 2016 +0200 tdf#93630: Remember whether a doc was originally requested to be opened r/o ...so it'll be opened r/o again on SID_RELOAD. Needs addition of yet another m_bOriginallyLoadedReadOnly state, after a199cad8376a5470c50125def2738b44b55ec018 "tdf#65498, tdf#87545: Don't confuse logically r/o doc with physically r/o" already added m_bOriginallyReadOnly. Change-Id: I9c7129a6f1b0e7618be616d5897ee6ef29e0abb7 diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx index a08c22b..37576d1 100644 --- a/include/sfx2/docfile.hxx +++ b/include/sfx2/docfile.hxx @@ -178,11 +178,17 @@ public: GetVersionList( bool _bNoReload = false ); SAL_WARN_UNUSED_RESULT bool IsReadOnly() const; - // Whether the medium had originally been opened r/o, independent of later - // changes via SetOpenMode; used to keep track of the "true" state of the - // medium across toggles via SID_EDITDOC (which do change SetOpenMode): + // Whether the medium had originally been opened r/o (either because it is + // "physically" r/o, or because it was requested to be opended r/o, + // independent of later changes via SetOpenMode; used to keep track of the + // "true" state of the medium across toggles via SID_EDITDOC (which do + // change SetOpenMode): SAL_WARN_UNUSED_RESULT bool IsOriginallyReadOnly() const; + // Whether the medium had originally been requested to be opened r/o, + // independent of later changes via SetOpenMode; used for SID_RELOAD: + SAL_WARN_UNUSED_RESULT bool IsOriginallyLoadedReadOnly() const; + css::uno::Reference< css::io::XInputStream > GetInputStream(); void CreateTempFile( bool bReplace = true ); diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index b4fecfe..5a145df 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -283,6 +283,7 @@ public: bool IsReadOnly() const; bool IsReadOnlyMedium() const; bool IsOriginallyReadOnlyMedium() const; + bool IsOriginallyLoadedReadOnlyMedium() const; void SetReadOnlyUI( bool bReadOnly = true ); bool IsReadOnlyUI() const; void SetNoName(); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 366a2f3..301a026 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -188,6 +188,7 @@ public: bool m_bGotDateTime:1; bool m_bRemoveBackup:1; bool m_bOriginallyReadOnly:1; + bool m_bOriginallyLoadedReadOnly:1; bool m_bTriedStorage:1; bool m_bRemote:1; bool m_bInputStreamIsReadOnly:1; @@ -266,6 +267,7 @@ SfxMedium_Impl::SfxMedium_Impl() : m_bGotDateTime( false ), m_bRemoveBackup( false ), m_bOriginallyReadOnly(false), + m_bOriginallyLoadedReadOnly(false), m_bTriedStorage(false), m_bRemote(false), m_bInputStreamIsReadOnly(false), @@ -3019,15 +3021,15 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : } } - bool readOnly = false; const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem<SfxBoolItem>(pImpl->m_pSet, SID_DOC_READONLY, false); if ( pReadOnlyItem && pReadOnlyItem->GetValue() ) - readOnly = true; + pImpl->m_bOriginallyLoadedReadOnly = true; const SfxStringItem* pFileNameItem = SfxItemSet::GetItem<SfxStringItem>(pImpl->m_pSet, SID_FILE_NAME, false); if (!pFileNameItem) throw uno::RuntimeException(); pImpl->m_aLogicName = pFileNameItem->GetValue(); - pImpl->m_nStorOpenMode = readOnly ? SFX_STREAM_READONLY : SFX_STREAM_READWRITE; + pImpl->m_nStorOpenMode = pImpl->m_bOriginallyLoadedReadOnly + ? SFX_STREAM_READONLY : SFX_STREAM_READWRITE; Init_Impl(); } @@ -3334,6 +3336,10 @@ bool SfxMedium::IsOriginallyReadOnly() const return pImpl->m_bOriginallyReadOnly; } +bool SfxMedium::IsOriginallyLoadedReadOnly() const +{ + return pImpl->m_bOriginallyLoadedReadOnly; +} bool SfxMedium::SetWritableForUserOnly( const OUString& aURL ) { diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 57551b7..201664b 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -382,6 +382,11 @@ bool SfxObjectShell::IsOriginallyReadOnlyMedium() const return pMedium == nullptr || pMedium->IsOriginallyReadOnly(); } +bool SfxObjectShell::IsOriginallyLoadedReadOnlyMedium() const +{ + return pMedium != nullptr && pMedium->IsOriginallyLoadedReadOnly(); +} + void SfxObjectShell::SetReadOnlyUI( bool bReadOnly ) diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index a98f891..f1c93d8 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -615,7 +615,8 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // let the current security settings be checked again pNewSet->Put( SfxUInt16Item( SID_MACROEXECMODE, document::MacroExecMode::USE_CONFIG ) ); - if ( pSh->IsOriginallyReadOnlyMedium() ) + if ( pSh->IsOriginallyReadOnlyMedium() + || pSh->IsOriginallyLoadedReadOnlyMedium() ) // edit mode is switched or reload of readonly document pNewSet->Put( SfxBoolItem( SID_DOC_READONLY, true ) ); else _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
