From cc0595e5598dd9bc0dac3f8815a2dabddf932b76 Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Thu, 18 Apr 2024 11:24:50 +0200 Subject: tdf#146553 Enable additonal functions in editable section while in r/o mode Insert/Edit table, insert lists, insert AutoText automatic spell checking Change-Id: Iccef3965316dc6079ea56a0283023c5a658512cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165031 Tested-by: Jenkins Tested-by: Gabor Kelemen Reviewed-by: Thorsten Behrens (cherry picked from commit 40436e1dfdad42690cc0cfc4781c38e5419e0dc5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181001 Tested-by: allotropia jenkins --- sw/inc/viewopt.hxx | 2 +- sw/source/core/text/inftxt.cxx | 36 +++++++++++++++++++++++++++++++++++- sw/source/uibase/uiview/view.cxx | 4 ++++ sw/source/uibase/uiview/view0.cxx | 2 +- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx index 3a2148c7911c..a78cfb0aada8 100644 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -343,7 +343,7 @@ public: { SetCoreOption(b, ViewOptFlags1::GridVisible); } bool IsOnlineSpell() const - { return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::OnlineSpell); } + { return bool(m_nCoreOptions & ViewOptFlags1::OnlineSpell); } void SetOnlineSpell( bool b ); bool IsViewMetaChars() const diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index c79567a33c7b..fd7093e7b8d7 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -49,14 +49,17 @@ #include #include #include +#include #include #include #include #include +#include #include #include "inftxt.hxx" #include #include +#include #include "porftn.hxx" #include "porrst.hxx" #include "itratr.hxx" @@ -561,6 +564,30 @@ static bool lcl_IsDarkBackground( const SwTextPaintInfo& rInf ) return pCol->IsDark(); } +static bool lcl_IsFrameReadonly(SwTextFrame* pFrame) +{ + const SwFlyFrame* pFly; + const SwSection* pSection; + + if( pFrame && pFrame->IsInFly() && + (pFly = pFrame->FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() && + pFly->Lower() && + !pFly->Lower()->IsNoTextFrame() ) + { + return false; + } + // edit in readonly sections + else if ( pFrame && pFrame->IsInSct() && + nullptr != ( pSection = pFrame->FindSctFrame()->GetSection() ) && + pSection->IsEditInReadonlyFlag() ) + { + return false; + } + + return true; +} + + void SwTextPaintInfo::DrawText_( const OUString &rText, const SwLinePortion &rPor, TextFrameIndex const nStart, TextFrameIndex const nLength, const bool bKern, const bool bWrong, @@ -617,7 +644,14 @@ void SwTextPaintInfo::DrawText_( const OUString &rText, const SwLinePortion &rPo bool bCfgIsAutoGrammar = false; SvtLinguConfig().GetProperty( UPN_IS_GRAMMAR_AUTO ) >>= bCfgIsAutoGrammar; const bool bBullet = OnWin() && GetOpt().IsBlank() && IsNoSymbol(); - const bool bTmpWrong = bWrong && OnWin() && GetOpt().IsOnlineSpell(); + bool bTmpWrong = bWrong && OnWin() && GetOpt().IsOnlineSpell(); + SfxObjectShell* pObjShell = m_pFrame->GetDoc().GetDocShell(); + if (bTmpWrong && pObjShell) + { + if (pObjShell->IsReadOnly() && lcl_IsFrameReadonly(m_pFrame)) + bTmpWrong = false; + } + const bool bTmpGrammarCheck = bGrammarCheck && OnWin() && bCfgIsAutoGrammar && GetOpt().IsOnlineSpell(); const bool bTmpSmart = bSmartTag && OnWin() && !GetOpt().IsPagePreview() && SwSmartTagMgr::Get().IsSmartTagsEnabled(); diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index aee84c09aa3b..8703285ae7f3 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -438,6 +438,7 @@ void SwView::SelectShell() rDispatcher.Push( *m_pShell ); } m_pShell = new SwTextShell(*this); + rDispatcher.Push( *m_pShell ); if ( m_nSelectionType & SelectionType::Table ) { @@ -637,6 +638,9 @@ void SwView::CheckReadonlyState() SID_ATTR_PARA_MODEL, SID_PARA_DLG, FN_SELECT_PARA, SID_DEC_INDENT, SID_INC_INDENT, + FN_INSERT_TABLE, FN_FORMAT_TABLE_DLG, FN_EXPAND_GLOSSARY, + FN_NUM_BULLET_ON, FN_NUM_NUMBERING_ON, FN_SVX_SET_NUMBER, + FN_SVX_SET_BULLET, FN_SVX_SET_OUTLINE, SID_AUTOSPELL_CHECK, FN_SPELL_GRAMMAR_DIALOG }; static bool bFirst = true; diff --git a/sw/source/uibase/uiview/view0.cxx b/sw/source/uibase/uiview/view0.cxx index 79783e138496..a5a4f6306c94 100644 --- a/sw/source/uibase/uiview/view0.cxx +++ b/sw/source/uibase/uiview/view0.cxx @@ -227,7 +227,7 @@ void SwView::StateViewOptions(SfxItemSet &rSet) while(nWhich) { bool bReadonly = GetDocShell()->IsReadOnly(); - if ( bReadonly && nWhich != FN_VIEW_GRAPHIC ) + if ( bReadonly && nWhich != FN_VIEW_GRAPHIC && nWhich != SID_AUTOSPELL_CHECK ) { rSet.DisableItem(nWhich); nWhich = 0; -- cgit