diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-08-24 15:14:38 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-08-24 15:14:38 +0200 |
commit | 191c0a9e7719b777146430486d703641aaff43bf (patch) | |
tree | ca2afff9832f58fcbab4fc6d0582d776bd54602e | |
parent | 057ae1cfcac518e5693e75aca87d307ce90ba6fb (diff) |
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
-rw-r--r-- | include/sfx2/docfile.hxx | 12 | ||||
-rw-r--r-- | include/sfx2/objsh.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 3 |
5 files changed, 26 insertions, 7 deletions
diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx index a08c22b7bdb7..37576d1bf1a8 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 b4fecfe3921b..5a145dfb0fe9 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 366a2f377310..301a0263206a 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 57551b7524d5..201664b1c705 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 a98f8912616f..f1c93d81243e 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 |