tdf#163962 Enable spell checking in editable sections in read-only mode

Change-Id: I1464cb229cc77748a07003e76d0d009c7a95ca66
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181000
Reviewed-by: Nagy Tibor <tibor.nagy.extern@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Tibor Nagy
2025-02-01 23:12:15 +01:00
committed by Nagy Tibor
parent 6802590b3a
commit 08e40accb3
5 changed files with 22 additions and 6 deletions
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -7939,7 +7939,7 @@ SfxBoolItem SpellingAndGrammarDialog FN_SPELL_GRAMMAR_DIALOG
[
AutoUpdate = TRUE,
FastCall = FALSE,
ReadOnlyDoc = FALSE,
ReadOnlyDoc = TRUE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
+7 -2
View File
@@ -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 )
+12 -2
View File
@@ -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())
{
+1
View File
@@ -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 )