diff options
-rw-r--r-- | sw/inc/ndtxt.hxx | 2 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docedt.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtedt.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 1 |
5 files changed, 22 insertions, 6 deletions
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index db42d937ef18..5a435a793b21 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -468,7 +468,7 @@ public: const sal_Int32 nIndex, ::sw::GetTextAttrMode const eMode = ::sw::GetTextAttrMode::Expand) const; - bool Spell(SwSpellArgs*); + bool Spell(SwSpellArgs* , bool bIsReadOnly); bool Convert( SwConversionArgs & ); inline SwTextFormatColl *GetTextColl() const; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index dd7c1668d8b3..c7bfa5b9ad22 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -7939,7 +7939,7 @@ SfxBoolItem SpellingAndGrammarDialog FN_SPELL_GRAMMAR_DIALOG [ AutoUpdate = TRUE, FastCall = FALSE, - ReadOnlyDoc = FALSE, + ReadOnlyDoc = TRUE, Toggle = FALSE, Container = FALSE, RecordAbsolute = FALSE, diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 92acd2a45fb0..57896c9c0fd7 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -538,6 +538,11 @@ uno::Any SwDoc::Spell( SwPaM& rPaM, SwNodeOffset nCurrNd = pSttPos->GetNodeIndex(); SwNodeOffset nEndNd = pEndPos->GetNodeIndex(); + bool bIsReadOnly = false; + const SfxObjectShell* pObjShell = GetDocShell(); + if (pObjShell && pObjShell->IsReadOnly()) + bIsReadOnly = true; + uno::Any aRet; if( nCurrNd <= nEndNd ) { @@ -600,8 +605,8 @@ uno::Any SwDoc::Spell( SwPaM& rPaM, } sal_Int32 nSpellErrorPosition = pNd->GetTextNode()->GetText().getLength(); - if( (!pConvArgs && pNd->GetTextNode()->Spell( pSpellArgs.get() )) || - ( pConvArgs && pNd->GetTextNode()->Convert( *pConvArgs ))) + if ((!pConvArgs && pNd->GetTextNode()->Spell(pSpellArgs.get(), bIsReadOnly)) + || (pConvArgs && pNd->GetTextNode()->Convert(*pConvArgs))) { // Cancel and remember position if( pSpellArgs ) diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 55837fd52e60..94f914289fd2 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -993,7 +993,7 @@ bool SwScanner::NextWord() } // Note: this is a clone of SwTextFrame::AutoSpell_, so keep them in sync when fixing things! -bool SwTextNode::Spell(SwSpellArgs* pArgs) +bool SwTextNode::Spell(SwSpellArgs* pArgs, bool bIsReadOnly) { // modify string according to redline information and hidden text const OUString aOldText( m_Text ); @@ -1016,6 +1016,16 @@ bool SwTextNode::Spell(SwSpellArgs* pArgs) pArgs->xSpellAlt = nullptr; + bool bIsEditableSect = false; + if (bIsReadOnly) + { + // Enable spell checking in editable sections in read-only mode. + if (SwSectionNode* pSectNode = GetTextNode()->FindSectionNode()) + { + bIsEditableSect = pSectNode->GetSection().IsEditInReadonly(); + } + } + // 4 cases: // 1. IsWrongDirty = 0 and GetWrong = 0 @@ -1028,7 +1038,7 @@ bool SwTextNode::Spell(SwSpellArgs* pArgs) // Text has been checked but there is an invalid range in the wrong list // Nothing has to be done for case 1. - if ( ( IsWrongDirty() || GetWrong() ) && m_Text.getLength() ) + if ((IsWrongDirty() || GetWrong()) && (!bIsReadOnly || bIsEditableSect) && m_Text.getLength()) { if (nBegin > m_Text.getLength()) { diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index c4fbbd4afac4..dc3a12d21a7a 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -684,6 +684,7 @@ void SwView::CheckReadonlyState() 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; if ( bFirst ) |