diff options
-rw-r--r-- | cui/source/tabpages/autocdlg.cxx | 108 | ||||
-rw-r--r-- | editeng/qa/unit/core-test.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 6 | ||||
-rw-r--r-- | editeng/source/misc/acorrcfg.cxx | 64 | ||||
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 110 | ||||
-rw-r--r-- | include/editeng/svxacorr.hxx | 59 | ||||
-rw-r--r-- | sw/source/core/edit/acorrect.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/edit/autofmt.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/inc/acorrect.hxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 26 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh1.cxx | 6 |
12 files changed, 207 insertions, 197 deletions
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index 5c6357e519ca..97444eaec472 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -223,17 +223,17 @@ VclPtr<SfxTabPage> OfaAutocorrOptionsPage::Create( TabPageParent pParent, bool OfaAutocorrOptionsPage::FillItemSet( SfxItemSet* ) { SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); - long nFlags = pAutoCorrect->GetFlags(); + ACFlags nFlags = pAutoCorrect->GetFlags(); sal_uLong nPos = 0; - pAutoCorrect->SetAutoCorrFlag(Autocorrect, m_pCheckLB->IsChecked(nPos++)); - pAutoCorrect->SetAutoCorrFlag(CapitalStartWord, m_pCheckLB->IsChecked(nPos++)); - pAutoCorrect->SetAutoCorrFlag(CapitalStartSentence, m_pCheckLB->IsChecked(nPos++)); - pAutoCorrect->SetAutoCorrFlag(ChgWeightUnderl, m_pCheckLB->IsChecked(nPos++)); - pAutoCorrect->SetAutoCorrFlag(SetINetAttr, m_pCheckLB->IsChecked(nPos++)); - pAutoCorrect->SetAutoCorrFlag(ChgToEnEmDash, m_pCheckLB->IsChecked(nPos++)); - pAutoCorrect->SetAutoCorrFlag(IgnoreDoubleSpace, m_pCheckLB->IsChecked(nPos++)); - pAutoCorrect->SetAutoCorrFlag(CorrectCapsLock, m_pCheckLB->IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(ACFlags::Autocorrect, m_pCheckLB->IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(ACFlags::CapitalStartWord, m_pCheckLB->IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(ACFlags::CapitalStartSentence, m_pCheckLB->IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgWeightUnderl, m_pCheckLB->IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(ACFlags::SetINetAttr, m_pCheckLB->IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgToEnEmDash, m_pCheckLB->IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(ACFlags::IgnoreDoubleSpace, m_pCheckLB->IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(ACFlags::CorrectCapsLock, m_pCheckLB->IsChecked(nPos++)); bool bReturn = nFlags != pAutoCorrect->GetFlags(); if(bReturn ) @@ -253,7 +253,7 @@ void OfaAutocorrOptionsPage::ActivatePage( const SfxItemSet& ) void OfaAutocorrOptionsPage::Reset( const SfxItemSet* ) { SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); - const long nFlags = pAutoCorrect->GetFlags(); + const ACFlags nFlags = pAutoCorrect->GetFlags(); m_pCheckLB->SetUpdateMode(false); m_pCheckLB->Clear(); @@ -268,14 +268,14 @@ void OfaAutocorrOptionsPage::Reset( const SfxItemSet* ) m_pCheckLB->InsertEntry(m_sAccidentalCaps); sal_uLong nPos = 0; - m_pCheckLB->CheckEntryPos( nPos++, 0 != (nFlags & Autocorrect) ); - m_pCheckLB->CheckEntryPos( nPos++, 0 != (nFlags & CapitalStartWord) ); - m_pCheckLB->CheckEntryPos( nPos++, 0 != (nFlags & CapitalStartSentence) ); - m_pCheckLB->CheckEntryPos( nPos++, 0 != (nFlags & ChgWeightUnderl) ); - m_pCheckLB->CheckEntryPos( nPos++, 0 != (nFlags & SetINetAttr) ); - m_pCheckLB->CheckEntryPos( nPos++, 0 != (nFlags & ChgToEnEmDash) ); - m_pCheckLB->CheckEntryPos( nPos++, 0 != (nFlags & IgnoreDoubleSpace) ); - m_pCheckLB->CheckEntryPos( nPos++, 0 != (nFlags & CorrectCapsLock) ); + m_pCheckLB->CheckEntryPos( nPos++, bool(nFlags & ACFlags::Autocorrect) ); + m_pCheckLB->CheckEntryPos( nPos++, bool(nFlags & ACFlags::CapitalStartWord) ); + m_pCheckLB->CheckEntryPos( nPos++, bool(nFlags & ACFlags::CapitalStartSentence) ); + m_pCheckLB->CheckEntryPos( nPos++, bool(nFlags & ACFlags::ChgWeightUnderl) ); + m_pCheckLB->CheckEntryPos( nPos++, bool(nFlags & ACFlags::SetINetAttr) ); + m_pCheckLB->CheckEntryPos( nPos++, bool(nFlags & ACFlags::ChgToEnEmDash) ); + m_pCheckLB->CheckEntryPos( nPos++, bool(nFlags & ACFlags::IgnoreDoubleSpace) ); + m_pCheckLB->CheckEntryPos( nPos++, bool(nFlags & ACFlags::CorrectCapsLock) ); m_pCheckLB->SetUpdateMode(true); } @@ -513,42 +513,42 @@ bool OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet* ) bool bModified = false; SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags(); - long nFlags = pAutoCorrect->GetFlags(); + ACFlags nFlags = pAutoCorrect->GetFlags(); bool bCheck = m_pCheckLB->IsChecked(USE_REPLACE_TABLE); bModified |= pOpt->bAutoCorrect != bCheck; pOpt->bAutoCorrect = bCheck; - pAutoCorrect->SetAutoCorrFlag(Autocorrect, + pAutoCorrect->SetAutoCorrFlag(ACFlags::Autocorrect, m_pCheckLB->IsChecked(USE_REPLACE_TABLE, CBCOL_SECOND)); bCheck = m_pCheckLB->IsChecked(CORR_UPPER); bModified |= pOpt->bCapitalStartWord != bCheck; pOpt->bCapitalStartWord = bCheck; - pAutoCorrect->SetAutoCorrFlag(CapitalStartWord, + pAutoCorrect->SetAutoCorrFlag(ACFlags::CapitalStartWord, m_pCheckLB->IsChecked(CORR_UPPER, CBCOL_SECOND)); bCheck = m_pCheckLB->IsChecked(BEGIN_UPPER); bModified |= pOpt->bCapitalStartSentence != bCheck; pOpt->bCapitalStartSentence = bCheck; - pAutoCorrect->SetAutoCorrFlag(CapitalStartSentence, + pAutoCorrect->SetAutoCorrFlag(ACFlags::CapitalStartSentence, m_pCheckLB->IsChecked(BEGIN_UPPER, CBCOL_SECOND)); bCheck = m_pCheckLB->IsChecked(BOLD_UNDERLINE); bModified |= pOpt->bChgWeightUnderl != bCheck; pOpt->bChgWeightUnderl = bCheck; - pAutoCorrect->SetAutoCorrFlag(ChgWeightUnderl, + pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgWeightUnderl, m_pCheckLB->IsChecked(BOLD_UNDERLINE, CBCOL_SECOND)); - pAutoCorrect->SetAutoCorrFlag(IgnoreDoubleSpace, + pAutoCorrect->SetAutoCorrFlag(ACFlags::IgnoreDoubleSpace, m_pCheckLB->IsChecked(IGNORE_DBLSPACE, CBCOL_SECOND)); - pAutoCorrect->SetAutoCorrFlag(CorrectCapsLock, + pAutoCorrect->SetAutoCorrFlag(ACFlags::CorrectCapsLock, m_pCheckLB->IsChecked(CORRECT_CAPS_LOCK, CBCOL_SECOND)); bCheck = m_pCheckLB->IsChecked(DETECT_URL); bModified |= pOpt->bSetINetAttr != bCheck; pOpt->bSetINetAttr = bCheck; - pAutoCorrect->SetAutoCorrFlag(SetINetAttr, + pAutoCorrect->SetAutoCorrFlag(ACFlags::SetINetAttr, m_pCheckLB->IsChecked(DETECT_URL, CBCOL_SECOND)); bCheck = m_pCheckLB->IsChecked(DEL_EMPTY_NODE); @@ -597,7 +597,7 @@ bool OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet* ) bCheck = m_pCheckLB->IsChecked(REPLACE_DASHES); bModified |= pOpt->bChgToEnEmDash != bCheck; pOpt->bChgToEnEmDash = bCheck; - pAutoCorrect->SetAutoCorrFlag(ChgToEnEmDash, + pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgToEnEmDash, m_pCheckLB->IsChecked(REPLACE_DASHES, CBCOL_SECOND)); bCheck = m_pCheckLB->IsChecked(DEL_SPACES_AT_STT_END); @@ -633,7 +633,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) { SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags(); - const long nFlags = pAutoCorrect->GetFlags(); + const ACFlags nFlags = pAutoCorrect->GetFlags(); m_pCheckLB->SetUpdateMode(false); m_pCheckLB->Clear(); @@ -661,19 +661,19 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) m_pCheckLB->GetModel()->Insert(CreateEntry(sRightMargin, CBCOL_FIRST )); m_pCheckLB->CheckEntryPos( USE_REPLACE_TABLE, CBCOL_FIRST, pOpt->bAutoCorrect ); - m_pCheckLB->CheckEntryPos( USE_REPLACE_TABLE, CBCOL_SECOND, 0 != (nFlags & Autocorrect)); + m_pCheckLB->CheckEntryPos( USE_REPLACE_TABLE, CBCOL_SECOND, bool(nFlags & ACFlags::Autocorrect)); m_pCheckLB->CheckEntryPos( CORR_UPPER, CBCOL_FIRST, pOpt->bCapitalStartWord ); - m_pCheckLB->CheckEntryPos( CORR_UPPER, CBCOL_SECOND, 0 != (nFlags & CapitalStartWord) ); + m_pCheckLB->CheckEntryPos( CORR_UPPER, CBCOL_SECOND, bool(nFlags & ACFlags::CapitalStartWord) ); m_pCheckLB->CheckEntryPos( BEGIN_UPPER, CBCOL_FIRST, pOpt->bCapitalStartSentence ); - m_pCheckLB->CheckEntryPos( BEGIN_UPPER, CBCOL_SECOND, 0 != (nFlags & CapitalStartSentence) ); + m_pCheckLB->CheckEntryPos( BEGIN_UPPER, CBCOL_SECOND, bool(nFlags & ACFlags::CapitalStartSentence) ); m_pCheckLB->CheckEntryPos( BOLD_UNDERLINE, CBCOL_FIRST, pOpt->bChgWeightUnderl ); - m_pCheckLB->CheckEntryPos( BOLD_UNDERLINE, CBCOL_SECOND, 0 != (nFlags & ChgWeightUnderl) ); - m_pCheckLB->CheckEntryPos( IGNORE_DBLSPACE, CBCOL_SECOND, 0 != (nFlags & IgnoreDoubleSpace) ); - m_pCheckLB->CheckEntryPos( CORRECT_CAPS_LOCK, CBCOL_SECOND, 0 != (nFlags & CorrectCapsLock) ); + m_pCheckLB->CheckEntryPos( BOLD_UNDERLINE, CBCOL_SECOND, bool(nFlags & ACFlags::ChgWeightUnderl) ); + m_pCheckLB->CheckEntryPos( IGNORE_DBLSPACE, CBCOL_SECOND, bool(nFlags & ACFlags::IgnoreDoubleSpace) ); + m_pCheckLB->CheckEntryPos( CORRECT_CAPS_LOCK, CBCOL_SECOND, bool(nFlags & ACFlags::CorrectCapsLock) ); m_pCheckLB->CheckEntryPos( DETECT_URL, CBCOL_FIRST, pOpt->bSetINetAttr ); - m_pCheckLB->CheckEntryPos( DETECT_URL, CBCOL_SECOND, 0 != (nFlags & SetINetAttr) ); + m_pCheckLB->CheckEntryPos( DETECT_URL, CBCOL_SECOND, bool(nFlags & ACFlags::SetINetAttr) ); m_pCheckLB->CheckEntryPos( REPLACE_DASHES, CBCOL_FIRST, pOpt->bChgToEnEmDash ); - m_pCheckLB->CheckEntryPos( REPLACE_DASHES, CBCOL_SECOND, 0 != (nFlags & ChgToEnEmDash) ); + m_pCheckLB->CheckEntryPos( REPLACE_DASHES, CBCOL_SECOND, bool(nFlags & ACFlags::ChgToEnEmDash) ); m_pCheckLB->CheckEntryPos( DEL_SPACES_AT_STT_END, CBCOL_FIRST, pOpt->bAFormatDelSpacesAtSttEnd ); m_pCheckLB->CheckEntryPos( DEL_SPACES_AT_STT_END, CBCOL_SECOND, pOpt->bAFormatByInpDelSpacesAtSttEnd ); m_pCheckLB->CheckEntryPos( DEL_SPACES_BETWEEN_LINES, CBCOL_FIRST, pOpt->bAFormatDelSpacesBetweenLines ); @@ -1557,9 +1557,9 @@ bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet* ) pAutoCorrect->SaveCplSttExceptList(eLang); } if(m_pAutoAbbrevCB->IsValueChangedFromSaved()) - pAutoCorrect->SetAutoCorrFlag( SaveWordCplSttLst, m_pAutoAbbrevCB->IsChecked()); + pAutoCorrect->SetAutoCorrFlag( ACFlags::SaveWordCplSttLst, m_pAutoAbbrevCB->IsChecked()); if(m_pAutoCapsCB->IsValueChangedFromSaved()) - pAutoCorrect->SetAutoCorrFlag( SaveWordWrdSttLst, m_pAutoCapsCB->IsChecked()); + pAutoCorrect->SetAutoCorrFlag( ACFlags::SaveWordWrdSttLst, m_pAutoCapsCB->IsChecked()); return false; } @@ -1644,8 +1644,8 @@ void OfaAutocorrExceptPage::Reset( const SfxItemSet* ) { SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); RefillReplaceBoxes(true, eLang, eLang); - m_pAutoAbbrevCB-> Check( pAutoCorrect->IsAutoCorrFlag( SaveWordCplSttLst )); - m_pAutoCapsCB-> Check( pAutoCorrect->IsAutoCorrFlag( SaveWordWrdSttLst )); + m_pAutoAbbrevCB-> Check( pAutoCorrect->IsAutoCorrFlag( ACFlags::SaveWordCplSttLst )); + m_pAutoCapsCB-> Check( pAutoCorrect->IsAutoCorrFlag( ACFlags::SaveWordWrdSttLst )); m_pAutoAbbrevCB->SaveValue(); m_pAutoCapsCB->SaveValue(); } @@ -1903,13 +1903,13 @@ bool OfaQuoteTabPage::FillItemSet( SfxItemSet* ) { SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); - long nFlags = pAutoCorrect->GetFlags(); + ACFlags nFlags = pAutoCorrect->GetFlags(); if (m_pCheckLB->IsVisible()) { sal_uLong nPos = 0; - pAutoCorrect->SetAutoCorrFlag(AddNonBrkSpace, m_pCheckLB->IsChecked(nPos++)); - pAutoCorrect->SetAutoCorrFlag(ChgOrdinalNumber, m_pCheckLB->IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(ACFlags::AddNonBrkSpace, m_pCheckLB->IsChecked(nPos++)); + pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgOrdinalNumber, m_pCheckLB->IsChecked(nPos++)); } bool bModified = false; @@ -1920,18 +1920,18 @@ bool OfaQuoteTabPage::FillItemSet( SfxItemSet* ) bool bCheck = m_pSwCheckLB->IsChecked(ADD_NONBRK_SPACE); bModified |= pOpt->bAddNonBrkSpace != bCheck; pOpt->bAddNonBrkSpace = bCheck; - pAutoCorrect->SetAutoCorrFlag(AddNonBrkSpace, + pAutoCorrect->SetAutoCorrFlag(ACFlags::AddNonBrkSpace, m_pSwCheckLB->IsChecked(ADD_NONBRK_SPACE, CBCOL_SECOND)); bCheck = m_pSwCheckLB->IsChecked(REPLACE_1ST); bModified |= pOpt->bChgOrdinalNumber != bCheck; pOpt->bChgOrdinalNumber = bCheck; - pAutoCorrect->SetAutoCorrFlag(ChgOrdinalNumber, + pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgOrdinalNumber, m_pSwCheckLB->IsChecked(REPLACE_1ST, CBCOL_SECOND)); } - pAutoCorrect->SetAutoCorrFlag(ChgQuotes, m_pDoubleTypoCB->IsChecked()); - pAutoCorrect->SetAutoCorrFlag(ChgSglQuotes, m_pSingleTypoCB->IsChecked()); + pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgQuotes, m_pDoubleTypoCB->IsChecked()); + pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgSglQuotes, m_pSingleTypoCB->IsChecked()); bool bReturn = nFlags != pAutoCorrect->GetFlags(); if(cStartQuote != pAutoCorrect->GetStartDoubleQuote()) { @@ -1975,7 +1975,7 @@ void OfaQuoteTabPage::ActivatePage( const SfxItemSet& ) void OfaQuoteTabPage::Reset( const SfxItemSet* ) { SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); - const long nFlags = pAutoCorrect->GetFlags(); + const ACFlags nFlags = pAutoCorrect->GetFlags(); // Initialize the Sw options if (m_pSwCheckLB->IsVisible()) @@ -1989,9 +1989,9 @@ void OfaQuoteTabPage::Reset( const SfxItemSet* ) m_pSwCheckLB->GetModel()->Insert(CreateEntry(sOrdinal, CBCOL_BOTH )); m_pSwCheckLB->CheckEntryPos( ADD_NONBRK_SPACE, CBCOL_FIRST, pOpt->bAddNonBrkSpace ); - m_pSwCheckLB->CheckEntryPos( ADD_NONBRK_SPACE, CBCOL_SECOND, 0 != (nFlags & AddNonBrkSpace) ); + m_pSwCheckLB->CheckEntryPos( ADD_NONBRK_SPACE, CBCOL_SECOND, bool(nFlags & ACFlags::AddNonBrkSpace) ); m_pSwCheckLB->CheckEntryPos( REPLACE_1ST, CBCOL_FIRST, pOpt->bChgOrdinalNumber ); - m_pSwCheckLB->CheckEntryPos( REPLACE_1ST, CBCOL_SECOND, 0 != (nFlags & ChgOrdinalNumber) ); + m_pSwCheckLB->CheckEntryPos( REPLACE_1ST, CBCOL_SECOND, bool(nFlags & ACFlags::ChgOrdinalNumber) ); m_pSwCheckLB->SetUpdateMode( true ); } @@ -2006,15 +2006,15 @@ void OfaQuoteTabPage::Reset( const SfxItemSet* ) m_pCheckLB->InsertEntry( sOrdinal ); sal_uLong nPos = 0; - m_pCheckLB->CheckEntryPos( nPos++, 0 != (nFlags & AddNonBrkSpace) ); - m_pCheckLB->CheckEntryPos( nPos++, 0 != (nFlags & ChgOrdinalNumber) ); + m_pCheckLB->CheckEntryPos( nPos++, bool(nFlags & ACFlags::AddNonBrkSpace) ); + m_pCheckLB->CheckEntryPos( nPos++, bool(nFlags & ACFlags::ChgOrdinalNumber) ); m_pCheckLB->SetUpdateMode(true); } // Initialize the quote stuffs - m_pDoubleTypoCB->Check(0 != (nFlags & ChgQuotes)); - m_pSingleTypoCB->Check(0 != (nFlags & ChgSglQuotes)); + m_pDoubleTypoCB->Check(bool(nFlags & ACFlags::ChgQuotes)); + m_pSingleTypoCB->Check(bool(nFlags & ACFlags::ChgSglQuotes)); m_pDoubleTypoCB->SaveValue(); m_pSingleTypoCB->SaveValue(); diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index c6d3a86c44a0..9e882ad77b5c 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -507,7 +507,7 @@ void Test::testAutocorrect() bool bNbspRunNext = false; TestAutoCorrDoc aFoo(sInput, LANGUAGE_ENGLISH_US); - aAutoCorrect.SetAutoCorrFlag(ChgQuotes, true); + aAutoCorrect.SetAutoCorrFlag(ACFlags::ChgQuotes, true); aAutoCorrect.DoAutoCorrect(aFoo, sInput, sInput.getLength(), cNextChar, true, bNbspRunNext); fprintf(stderr, "text is %x\n", aFoo.getResult()[aFoo.getResult().getLength() - 1]); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 19e035fafccd..04a7c959278a 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -2512,7 +2512,7 @@ EditPaM ImpEditEngine::AutoCorrect( const EditSelection& rCurSel, sal_Unicode c, // #i78661 allow application to turn off capitalization of // start sentence explicitly. // (This is done by setting IsFirstWordCapitalization to sal_False.) - bool bOldCapitalStartSentence = pAutoCorrect->IsAutoCorrFlag( CapitalStartSentence ); + bool bOldCapitalStartSentence = pAutoCorrect->IsAutoCorrFlag( ACFlags::CapitalStartSentence ); if (!IsFirstWordCapitalization()) { ESelection aESel( CreateESel(aSel) ); @@ -2543,7 +2543,7 @@ EditPaM ImpEditEngine::AutoCorrect( const EditSelection& rCurSel, sal_Unicode c, aSel.Max().GetIndex() <= aSecondWordSel.Min().GetIndex(); if (bIsFirstWordInFirstPara) - pAutoCorrect->SetAutoCorrFlag( CapitalStartSentence, IsFirstWordCapitalization() ); + pAutoCorrect->SetAutoCorrFlag( ACFlags::CapitalStartSentence, IsFirstWordCapitalization() ); } ContentNode* pNode = aSel.Max().GetNode(); @@ -2557,7 +2557,7 @@ EditPaM ImpEditEngine::AutoCorrect( const EditSelection& rCurSel, sal_Unicode c, // #i78661 since the SvxAutoCorrect object used here is // shared we need to reset the value to its original state. - pAutoCorrect->SetAutoCorrFlag( CapitalStartSentence, bOldCapitalStartSentence ); + pAutoCorrect->SetAutoCorrFlag( ACFlags::CapitalStartSentence, bOldCapitalStartSentence ); } return aSel.Max(); } diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx index 5bd97c67a197..e2c45e1850b0 100644 --- a/editeng/source/misc/acorrcfg.cxx +++ b/editeng/source/misc/acorrcfg.cxx @@ -129,7 +129,7 @@ void SvxBaseAutoCorrCfg::Load(bool bInit) DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); if(aValues.getLength() == aNames.getLength()) { - long nFlags = 0; // default all off + ACFlags nFlags = ACFlags::NONE; // default all off sal_Int32 nTemp = 0; for(int nProp = 0; nProp < aNames.getLength(); nProp++) { @@ -139,51 +139,51 @@ void SvxBaseAutoCorrCfg::Load(bool bInit) { case 0: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= SaveWordCplSttLst; + nFlags |= ACFlags::SaveWordCplSttLst; break;//"Exceptions/TwoCapitalsAtStart", case 1: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= SaveWordWrdSttLst; + nFlags |= ACFlags::SaveWordWrdSttLst; break;//"Exceptions/CapitalAtStartSentence", case 2: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= Autocorrect; + nFlags |= ACFlags::Autocorrect; break;//"UseReplacementTable", case 3: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= CapitalStartWord; + nFlags |= ACFlags::CapitalStartWord; break;//"TwoCapitalsAtStart", case 4: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= CapitalStartSentence; + nFlags |= ACFlags::CapitalStartSentence; break;//"CapitalAtStartSentence", case 5: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= ChgWeightUnderl; + nFlags |= ACFlags::ChgWeightUnderl; break;//"ChangeUnderlineWeight", case 6: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= SetINetAttr; + nFlags |= ACFlags::SetINetAttr; break;//"SetInetAttribute", case 7: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= ChgOrdinalNumber; + nFlags |= ACFlags::ChgOrdinalNumber; break;//"ChangeOrdinalNumber", case 8: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= AddNonBrkSpace; + nFlags |= ACFlags::AddNonBrkSpace; break;//"AddNonBreakingSpace" case 9: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= ChgToEnEmDash; + nFlags |= ACFlags::ChgToEnEmDash; break;//"ChangeDash", case 10: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= IgnoreDoubleSpace; + nFlags |= ACFlags::IgnoreDoubleSpace; break;//"RemoveDoubleSpaces", case 11: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= ChgSglQuotes; + nFlags |= ACFlags::ChgSglQuotes; break;//"ReplaceSingleQuote", case 12: pValues[nProp] >>= nTemp; @@ -197,7 +197,7 @@ void SvxBaseAutoCorrCfg::Load(bool bInit) break;//"SingleQuoteAtEnd", case 14: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= ChgQuotes; + nFlags |= ACFlags::ChgQuotes; break;//"ReplaceDoubleQuote", case 15: pValues[nProp] >>= nTemp; @@ -211,14 +211,14 @@ void SvxBaseAutoCorrCfg::Load(bool bInit) break;//"DoubleQuoteAtEnd" case 17: if(*o3tl::doAccess<bool>(pValues[nProp])) - nFlags |= CorrectCapsLock; + nFlags |= ACFlags::CorrectCapsLock; break;//"CorrectAccidentalCapsLock" } } } - if( nFlags ) + if( nFlags != ACFlags::NONE ) rParent.pAutoCorrect->SetAutoCorrFlag( nFlags ); - rParent.pAutoCorrect->SetAutoCorrFlag( ( 0xffff & ~nFlags ), false ); + rParent.pAutoCorrect->SetAutoCorrFlag( ( static_cast<ACFlags>(0x3fff) & ~nFlags ), false ); } } @@ -235,38 +235,38 @@ SvxBaseAutoCorrCfg::~SvxBaseAutoCorrCfg() void SvxBaseAutoCorrCfg::ImplCommit() { - const long nFlags = rParent.pAutoCorrect->GetFlags(); + const ACFlags nFlags = rParent.pAutoCorrect->GetFlags(); PutProperties( GetPropertyNames(), - {css::uno::Any((nFlags & SaveWordCplSttLst) != 0), + {css::uno::Any(bool(nFlags & ACFlags::SaveWordCplSttLst)), // "Exceptions/TwoCapitalsAtStart" - css::uno::Any((nFlags & SaveWordWrdSttLst) != 0), + css::uno::Any(bool(nFlags & ACFlags::SaveWordWrdSttLst)), // "Exceptions/CapitalAtStartSentence" - css::uno::Any((nFlags & Autocorrect) != 0), // "UseReplacementTable" - css::uno::Any((nFlags & CapitalStartWord) != 0), + css::uno::Any(bool(nFlags & ACFlags::Autocorrect)), // "UseReplacementTable" + css::uno::Any(bool(nFlags & ACFlags::CapitalStartWord)), // "TwoCapitalsAtStart" - css::uno::Any((nFlags & CapitalStartSentence) != 0), + css::uno::Any(bool(nFlags & ACFlags::CapitalStartSentence)), // "CapitalAtStartSentence" - css::uno::Any((nFlags & ChgWeightUnderl) != 0), + css::uno::Any(bool(nFlags & ACFlags::ChgWeightUnderl)), // "ChangeUnderlineWeight" - css::uno::Any((nFlags & SetINetAttr) != 0), // "SetInetAttribute" - css::uno::Any((nFlags & ChgOrdinalNumber) != 0), + css::uno::Any(bool(nFlags & ACFlags::SetINetAttr)), // "SetInetAttribute" + css::uno::Any(bool(nFlags & ACFlags::ChgOrdinalNumber)), // "ChangeOrdinalNumber" - css::uno::Any((nFlags & AddNonBrkSpace) != 0), // "AddNonBreakingSpace" - css::uno::Any((nFlags & ChgToEnEmDash) != 0), // "ChangeDash" - css::uno::Any((nFlags & IgnoreDoubleSpace) != 0), + css::uno::Any(bool(nFlags & ACFlags::AddNonBrkSpace)), // "AddNonBreakingSpace" + css::uno::Any(bool(nFlags & ACFlags::ChgToEnEmDash)), // "ChangeDash" + css::uno::Any(bool(nFlags & ACFlags::IgnoreDoubleSpace)), // "RemoveDoubleSpaces" - css::uno::Any((nFlags & ChgSglQuotes) != 0), // "ReplaceSingleQuote" + css::uno::Any(bool(nFlags & ACFlags::ChgSglQuotes)), // "ReplaceSingleQuote" css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetStartSingleQuote())), // "SingleQuoteAtStart" css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetEndSingleQuote())), // "SingleQuoteAtEnd" - css::uno::Any((nFlags & ChgQuotes) != 0), // "ReplaceDoubleQuote" + css::uno::Any(bool(nFlags & ACFlags::ChgQuotes)), // "ReplaceDoubleQuote" css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetStartDoubleQuote())), // "DoubleQuoteAtStart" css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetEndDoubleQuote())), // "DoubleQuoteAtEnd" - css::uno::Any((nFlags & CorrectCapsLock) != 0)}); + css::uno::Any(bool(nFlags & ACFlags::CorrectCapsLock))}); // "CorrectAccidentalCapsLock" } diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 8d4d9d7cc0b0..bcc722e1f31a 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -188,7 +188,7 @@ SvxAutoCorrDoc::~SvxAutoCorrDoc() // - FnCapitalStartSentence // after the exchange of characters. Then the words, if necessary, can be inserted // into the exception list. -void SvxAutoCorrDoc::SaveCpltSttWord( sal_uLong, sal_Int32, const OUString&, +void SvxAutoCorrDoc::SaveCpltSttWord( ACFlags, sal_Int32, const OUString&, sal_Unicode ) { } @@ -270,20 +270,20 @@ bool SvxAutoCorrect::NeedsHardspaceAutocorr( sal_Unicode cChar ) cChar == '/' /*case for the urls exception*/; } -long SvxAutoCorrect::GetDefaultFlags() -{ - long nRet = Autocorrect - | CapitalStartSentence - | CapitalStartWord - | ChgOrdinalNumber - | ChgToEnEmDash - | AddNonBrkSpace - | ChgWeightUnderl - | SetINetAttr - | ChgQuotes - | SaveWordCplSttLst - | SaveWordWrdSttLst - | CorrectCapsLock; +ACFlags SvxAutoCorrect::GetDefaultFlags() +{ + ACFlags nRet = ACFlags::Autocorrect + | ACFlags::CapitalStartSentence + | ACFlags::CapitalStartWord + | ACFlags::ChgOrdinalNumber + | ACFlags::ChgToEnEmDash + | ACFlags::AddNonBrkSpace + | ACFlags::ChgWeightUnderl + | ACFlags::SetINetAttr + | ACFlags::ChgQuotes + | ACFlags::SaveWordCplSttLst + | ACFlags::SaveWordWrdSttLst + | ACFlags::CorrectCapsLock; LanguageType eLang = GetAppLang().getLanguageType(); if( eLang.anyOf( LANGUAGE_ENGLISH, @@ -296,7 +296,7 @@ long SvxAutoCorrect::GetDefaultFlags() LANGUAGE_ENGLISH_SAFRICA, LANGUAGE_ENGLISH_JAMAICA, LANGUAGE_ENGLISH_CARRIBEAN)) - nRet &= ~(ChgQuotes|ChgSglQuotes); + nRet &= ~ACFlags(ACFlags::ChgQuotes|ACFlags::ChgSglQuotes); return nRet; } @@ -321,7 +321,7 @@ SvxAutoCorrect::SvxAutoCorrect( const SvxAutoCorrect& rCpy ) , sUserAutoCorrFile( rCpy.sUserAutoCorrFile ) , aSwFlags( rCpy.aSwFlags ) , eCharClassLang(rCpy.eCharClassLang) - , nFlags( rCpy.nFlags & ~(ChgWordLstLoad|CplSttLstLoad|WrdSttLstLoad)) + , nFlags( rCpy.nFlags & ~ACFlags(ACFlags::ChgWordLstLoad|ACFlags::CplSttLstLoad|ACFlags::WrdSttLstLoad)) , cStartDQuote( rCpy.cStartDQuote ) , cEndDQuote( rCpy.cEndDQuote ) , cStartSQuote( rCpy.cStartSQuote ) @@ -342,20 +342,20 @@ void SvxAutoCorrect::GetCharClass_( LanguageType eLang ) eCharClassLang = eLang; } -void SvxAutoCorrect::SetAutoCorrFlag( long nFlag, bool bOn ) +void SvxAutoCorrect::SetAutoCorrFlag( ACFlags nFlag, bool bOn ) { - long nOld = nFlags; + ACFlags nOld = nFlags; nFlags = bOn ? nFlags | nFlag : nFlags & ~nFlag; if( !bOn ) { - if( (nOld & CapitalStartSentence) != (nFlags & CapitalStartSentence) ) - nFlags &= ~CplSttLstLoad; - if( (nOld & CapitalStartWord) != (nFlags & CapitalStartWord) ) - nFlags &= ~WrdSttLstLoad; - if( (nOld & Autocorrect) != (nFlags & Autocorrect) ) - nFlags &= ~ChgWordLstLoad; + if( (nOld & ACFlags::CapitalStartSentence) != (nFlags & ACFlags::CapitalStartSentence) ) + nFlags &= ~ACFlags::CplSttLstLoad; + if( (nOld & ACFlags::CapitalStartWord) != (nFlags & ACFlags::CapitalStartWord) ) + nFlags &= ~ACFlags::WrdSttLstLoad; + if( (nOld & ACFlags::Autocorrect) != (nFlags & ACFlags::Autocorrect) ) + nFlags &= ~ACFlags::ChgWordLstLoad; } } @@ -437,8 +437,8 @@ void SvxAutoCorrect::FnCapitalStartWord( SvxAutoCorrDoc& rDoc, const OUString& r sChar = rCC.lowercase( sChar ); if( sChar[0] != cSave && rDoc.ReplaceRange( nSttPos, 1, sChar )) { - if( SaveWordWrdSttLst & nFlags ) - rDoc.SaveCpltSttWord( CapitalStartWord, nSttPos, sWord, cSave ); + if( ACFlags::SaveWordWrdSttLst & nFlags ) + rDoc.SaveCpltSttWord( ACFlags::CapitalStartWord, nSttPos, sWord, cSave ); } } } @@ -1089,8 +1089,8 @@ void SvxAutoCorrect::FnCapitalStartSentence( SvxAutoCorrDoc& rDoc, bool bRet = sChar[0] != cSave && rDoc.ReplaceRange( nSttPos, 1, sChar ); // Perhaps someone wants to have the word - if( bRet && SaveWordCplSttLst & nFlags ) - rDoc.SaveCpltSttWord( CapitalStartSentence, nSttPos, sWord, cSave ); + if( bRet && ACFlags::SaveWordCplSttLst & nFlags ) + rDoc.SaveCpltSttWord( ACFlags::CapitalStartSentence, nSttPos, sWord, cSave ); } bool SvxAutoCorrect::FnCorrectCapsLock( SvxAutoCorrDoc& rDoc, const OUString& rTxt, @@ -1241,7 +1241,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, { // Prevent double space if( nInsPos && ' ' == cChar && - IsAutoCorrFlag( IgnoreDoubleSpace ) && + IsAutoCorrFlag( ACFlags::IgnoreDoubleSpace ) && ' ' == rTxt[ nInsPos - 1 ]) { break; @@ -1249,8 +1249,8 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, bool bSingle = '\'' == cChar; bool bIsReplaceQuote = - (IsAutoCorrFlag( ChgQuotes ) && ('\"' == cChar )) || - (IsAutoCorrFlag( ChgSglQuotes ) && bSingle ); + (IsAutoCorrFlag( ACFlags::ChgQuotes ) && ('\"' == cChar )) || + (IsAutoCorrFlag( ACFlags::ChgSglQuotes ) && bSingle ); if( bIsReplaceQuote ) { sal_Unicode cPrev; @@ -1270,7 +1270,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, rDoc.Replace( nInsPos, OUString(cChar) ); // Hardspaces autocorrection - if ( IsAutoCorrFlag( AddNonBrkSpace ) ) + if ( IsAutoCorrFlag( ACFlags::AddNonBrkSpace ) ) { if ( NeedsHardspaceAutocorr( cChar ) && FnAddNonBrkSpace( rDoc, rTxt, nInsPos, GetDocLanguage( rDoc, nInsPos ), io_bNbspRunNext ) ) @@ -1314,7 +1314,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, // Set bold or underline automatically? if (('*' == cChar || '_' == cChar || '/' == cChar || '-' == cChar) && (nPos+1 < rTxt.getLength())) { - if( IsAutoCorrFlag( ChgWeightUnderl ) ) + if( IsAutoCorrFlag( ACFlags::ChgWeightUnderl ) ) { FnChgWeightUnderl( rDoc, rTxt, nPos+1 ); } @@ -1337,13 +1337,13 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, if( lcl_IsSymbolChar( rCC, rTxt, nCapLttrPos, nInsPos )) break; - if( IsAutoCorrFlag( Autocorrect ) ) + if( IsAutoCorrFlag( ACFlags::Autocorrect ) ) { // WARNING ATTENTION: rTxt is an alias of the text node's OUString // and becomes INVALID if ChgAutoCorrWord returns true! // => use aPara/pPara to create a valid copy of the string! OUString aPara; - OUString* pPara = IsAutoCorrFlag(CapitalStartSentence) ? &aPara : nullptr; + OUString* pPara = IsAutoCorrFlag(ACFlags::CapitalStartSentence) ? &aPara : nullptr; bool bChgWord = rDoc.ChgAutoCorrWord( nCapLttrPos, nInsPos, *this, pPara ); @@ -1378,13 +1378,13 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, ++nEnd; // Capital letter at beginning of paragraph? - if( IsAutoCorrFlag( CapitalStartSentence ) ) + if( IsAutoCorrFlag( ACFlags::CapitalStartSentence ) ) { FnCapitalStartSentence( rDoc, aPara, false, nCapLttrPos, nEnd, eLang ); } - if( IsAutoCorrFlag( ChgToEnEmDash ) ) + if( IsAutoCorrFlag( ACFlags::ChgToEnEmDash ) ) { FnChgToEnEmDash( rDoc, aPara, nCapLttrPos, nEnd, eLang ); } @@ -1393,11 +1393,11 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, } } - if( ( IsAutoCorrFlag( ChgOrdinalNumber ) && + if( ( IsAutoCorrFlag( ACFlags::ChgOrdinalNumber ) && (nInsPos >= 2 ) && // fdo#69762 avoid autocorrect for 2e-3 ( '-' != cChar || 'E' != rtl::toAsciiUpperCase(rTxt[nInsPos-1]) || '0' > rTxt[nInsPos-2] || '9' < rTxt[nInsPos-2] ) && FnChgOrdinalNumber( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) || - ( IsAutoCorrFlag( SetINetAttr ) && + ( IsAutoCorrFlag( ACFlags::SetINetAttr ) && ( ' ' == cChar || '\t' == cChar || 0x0a == cChar || !cChar ) && FnSetINetAttr( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) ) ; @@ -1406,7 +1406,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, bool bLockKeyOn = pFrameWin && (pFrameWin->GetIndicatorState() & KeyIndicatorState::CAPSLOCK); bool bUnsupported = lcl_IsUnsupportedUnicodeChar( rCC, rTxt, nCapLttrPos, nInsPos ); - if ( bLockKeyOn && IsAutoCorrFlag( CorrectCapsLock ) && + if ( bLockKeyOn && IsAutoCorrFlag( ACFlags::CorrectCapsLock ) && FnCorrectCapsLock( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ) ) { // Correct accidental use of cAPS LOCK key (do this only when @@ -1417,19 +1417,19 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, // Capital letter at beginning of paragraph ? if( !bUnsupported && - IsAutoCorrFlag( CapitalStartSentence ) ) + IsAutoCorrFlag( ACFlags::CapitalStartSentence ) ) { FnCapitalStartSentence( rDoc, rTxt, true, nCapLttrPos, nInsPos, eLang ); } // Two capital letters at beginning of word ?? if( !bUnsupported && - IsAutoCorrFlag( CapitalStartWord ) ) + IsAutoCorrFlag( ACFlags::CapitalStartWord ) ) { FnCapitalStartWord( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ); } - if( IsAutoCorrFlag( ChgToEnEmDash ) ) + if( IsAutoCorrFlag( ACFlags::ChgToEnEmDash ) ) { FnChgToEnEmDash( rDoc, rTxt, nCapLttrPos, nInsPos, eLang ); } @@ -1918,7 +1918,7 @@ SvxAutoCorrectLanguageLists::SvxAutoCorrectLanguageLists( pWrdStt_ExcptLst( nullptr ), pAutocorr_List( nullptr ), rAutoCorrect(rParent), - nFlags(0) + nFlags(ACFlags::NONE) { } @@ -1943,19 +1943,19 @@ bool SvxAutoCorrectLanguageLists::IsFileChanged_Imp() { bRet = true; // then remove all the lists fast! - if( CplSttLstLoad & nFlags && pCplStt_ExcptLst ) + if( (ACFlags::CplSttLstLoad & nFlags) && pCplStt_ExcptLst ) { pCplStt_ExcptLst.reset(); } - if( WrdSttLstLoad & nFlags && pWrdStt_ExcptLst ) + if( (ACFlags::WrdSttLstLoad & nFlags) && pWrdStt_ExcptLst ) { pWrdStt_ExcptLst.reset(); } - if( ChgWordLstLoad & nFlags && pAutocorr_List ) + if( (ACFlags::ChgWordLstLoad & nFlags) && pAutocorr_List ) { pAutocorr_List.reset(); } - nFlags &= ~(CplSttLstLoad | WrdSttLstLoad | ChgWordLstLoad ); + nFlags &= ~ACFlags(ACFlags::CplSttLstLoad | ACFlags::WrdSttLstLoad | ACFlags::ChgWordLstLoad ); } aLastCheckTime = tools::Time( tools::Time::SYSTEM ); } @@ -2136,7 +2136,7 @@ SvxAutocorrWordList* SvxAutoCorrectLanguageLists::LoadAutocorrWordList() const SvxAutocorrWordList* SvxAutoCorrectLanguageLists::GetAutocorrWordList() { - if( !( ChgWordLstLoad & nFlags ) || IsFileChanged_Imp() ) + if( !( ACFlags::ChgWordLstLoad & nFlags ) || IsFileChanged_Imp() ) { LoadAutocorrWordList(); if( !pAutocorr_List ) @@ -2144,14 +2144,14 @@ const SvxAutocorrWordList* SvxAutoCorrectLanguageLists::GetAutocorrWordList() OSL_ENSURE( false, "No valid list" ); pAutocorr_List.reset( new SvxAutocorrWordList() ); } - nFlags |= ChgWordLstLoad; + nFlags |= ACFlags::ChgWordLstLoad; } return pAutocorr_List.get(); } SvStringsISortDtor* SvxAutoCorrectLanguageLists::GetCplSttExceptList() { - if( !( CplSttLstLoad & nFlags ) || IsFileChanged_Imp() ) + if( !( ACFlags::CplSttLstLoad & nFlags ) || IsFileChanged_Imp() ) { LoadCplSttExceptList(); if( !pCplStt_ExcptLst ) @@ -2159,7 +2159,7 @@ SvStringsISortDtor* SvxAutoCorrectLanguageLists::GetCplSttExceptList() OSL_ENSURE( false, "No valid list" ); pCplStt_ExcptLst.reset( new SvStringsISortDtor ); } - nFlags |= CplSttLstLoad; + nFlags |= ACFlags::CplSttLstLoad; } return pCplStt_ExcptLst.get(); } @@ -2267,7 +2267,7 @@ void SvxAutoCorrectLanguageLists::SaveWrdSttExceptList() SvStringsISortDtor* SvxAutoCorrectLanguageLists::GetWrdSttExceptList() { - if( !( WrdSttLstLoad & nFlags ) || IsFileChanged_Imp() ) + if( !( ACFlags::WrdSttLstLoad & nFlags ) || IsFileChanged_Imp() ) { LoadWrdSttExceptList(); if( !pWrdStt_ExcptLst ) @@ -2275,7 +2275,7 @@ SvStringsISortDtor* SvxAutoCorrectLanguageLists::GetWrdSttExceptList() OSL_ENSURE( false, "No valid list" ); pWrdStt_ExcptLst.reset( new SvStringsISortDtor ); } - nFlags |= WrdSttLstLoad; + nFlags |= ACFlags::WrdSttLstLoad; } return pWrdStt_ExcptLst.get(); } diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx index d54b6670762f..8d4b81fb1c9b 100644 --- a/include/editeng/svxacorr.hxx +++ b/include/editeng/svxacorr.hxx @@ -23,6 +23,7 @@ #include <com/sun/star/embed/XStorage.hpp> #include <o3tl/sorted_vector.hxx> +#include <o3tl/typed_flags_set.hxx> #include <tools/ref.hxx> #include <i18nlangtag/languagetag.hxx> #include <tools/time.hxx> @@ -54,24 +55,30 @@ class SvStringsISortDtor }; // Auto correct flags -const long CapitalStartSentence = 0x00000001; // Capital letters at the beginning of a sentence -const long CapitalStartWord = 0x00000002; // not two Capital letters at the beginning of a word -const long AddNonBrkSpace = 0x00000004; // Add non breaking space before :;?!% -const long ChgOrdinalNumber = 0x00000008; // Ordinal-Number 1st, 2nd,.. -const long ChgToEnEmDash = 0x00000010; // - -> Endash/Emdash -const long ChgWeightUnderl = 0x00000020; // * -> Bold, _ -> Underscore -const long SetINetAttr = 0x00000040; // Set INetAttribut -const long Autocorrect = 0x00000080; // Call AutoCorrect -const long ChgQuotes = 0x00000100; // replace double quotes -const long SaveWordCplSttLst= 0x00000200; // Save Auto correction of Capital letter at beginning of sentence. -const long SaveWordWrdSttLst= 0x00000400; // Save Auto correction of 2 Capital letter at beginning of word. -const long IgnoreDoubleSpace= 0x00000800; // Ignore 2 Spaces -const long ChgSglQuotes = 0x00001000; // Replace simple quotes -const long CorrectCapsLock = 0x00002000; // Correct accidental use of cAPS LOCK key - -const long ChgWordLstLoad = 0x20000000; // Replacement list loaded -const long CplSttLstLoad = 0x40000000; // Exception list for Capital letters Start loaded -const long WrdSttLstLoad = 0x80000000; // Exception list for Word Start loaded +enum class ACFlags : sal_uInt32 { + NONE = 0x00000000, + CapitalStartSentence = 0x00000001, // Capital letters at the beginning of a sentence + CapitalStartWord = 0x00000002, // not two Capital letters at the beginning of a word + AddNonBrkSpace = 0x00000004, // Add non breaking space before :,?!% + ChgOrdinalNumber = 0x00000008, // Ordinal-Number 1st, 2nd,.. + ChgToEnEmDash = 0x00000010, // - -> Endash/Emdash + ChgWeightUnderl = 0x00000020, // * -> Bold, _ -> Underscore + SetINetAttr = 0x00000040, // Set INetAttribut + Autocorrect = 0x00000080, // Call AutoCorrect + ChgQuotes = 0x00000100, // replace double quotes + SaveWordCplSttLst = 0x00000200, // Save Auto correction of Capital letter at beginning of sentence. + SaveWordWrdSttLst = 0x00000400, // Save Auto correction of 2 Capital letter at beginning of word. + IgnoreDoubleSpace = 0x00000800, // Ignore 2 Spaces + ChgSglQuotes = 0x00001000, // Replace simple quotes + CorrectCapsLock = 0x00002000, // Correct accidental use of cAPS LOCK key + + ChgWordLstLoad = 0x20000000, // Replacement list loaded + CplSttLstLoad = 0x40000000, // Exception list for Capital letters Start loaded + WrdSttLstLoad = 0x80000000, // Exception list for Word Start loaded +}; +namespace o3tl { + template<> struct typed_flags<ACFlags> : is_typed_flags<ACFlags, 0xe0003fff> {}; +} // TODO: handle code points > U+FFFF and check users of this class @@ -107,7 +114,7 @@ public: // - FnCapitalStartWord // - FnCapitalStartSentence // As an option, the words can then be inserted into the exception lists. - virtual void SaveCpltSttWord( sal_uLong nFlag, sal_Int32 nPos, + virtual void SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos, const OUString& rExceptWord, sal_Unicode cChar ); @@ -170,7 +177,7 @@ class EDITENG_DLLPUBLIC SvxAutoCorrectLanguageLists std::unique_ptr<SvxAutocorrWordList> pAutocorr_List; SvxAutoCorrect& rAutoCorrect; - long nFlags; + ACFlags nFlags; bool IsFileChanged_Imp(); void LoadXMLExceptList_Imp( std::unique_ptr<SvStringsISortDtor>& rpLst, @@ -235,7 +242,7 @@ class EDITENG_DLLPUBLIC SvxAutoCorrect LanguageType eCharClassLang; - long nFlags; + ACFlags nFlags; sal_Unicode cStartDQuote, cEndDQuote, cStartSQuote, cEndSQuote, cEmDash, cEnDash; @@ -323,11 +330,11 @@ public: bool bUnlocalized = false ) const; // Query/Set the current settings of AutoCorrect - long GetFlags() const { return nFlags; } + ACFlags GetFlags() const { return nFlags; } SvxSwAutoFormatFlags& GetSwFlags() { return aSwFlags;} - bool IsAutoCorrFlag( long nFlag ) const - { return (nFlags & nFlag) != 0; } - void SetAutoCorrFlag( long nFlag, bool bOn = true ); + bool IsAutoCorrFlag( ACFlags nFlag ) const + { return bool(nFlags & nFlag); } + void SetAutoCorrFlag( ACFlags nFlag, bool bOn = true ); // Load, Set, Get - the replacement list SvxAutocorrWordList* LoadAutocorrWordList( LanguageType eLang ) @@ -397,7 +404,7 @@ public: sal_Int32 nSttPos, sal_Int32 nEndPos, LanguageType eLang ); - static long GetDefaultFlags(); + static ACFlags GetDefaultFlags(); // returns sal_True for characters where the function // 'SvxAutoCorrect::AutoCorrect' should be called. diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index 709db86d2b76..e8f4a72e9e9b 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -410,7 +410,7 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, // - FnCapitalStartSentence // after the exchange of characters. Then the words, if necessary, can be inserted // into the exception list. -void SwAutoCorrDoc::SaveCpltSttWord( sal_uLong nFlag, sal_Int32 nPos, +void SwAutoCorrDoc::SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos, const OUString& rExceptWord, sal_Unicode cChar ) { @@ -443,9 +443,9 @@ void SwAutoCorrExceptWord::CheckChar( const SwPosition& rPos, sal_Unicode cChr ) SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect(); // then add to the list: - if (CapitalStartWord & m_nFlags) + if (ACFlags::CapitalStartWord & m_nFlags) pACorr->AddWrtSttException(m_sWord, m_eLanguage); - else if (CapitalStartSentence & m_nFlags) + else if (ACFlags::CapitalStartSentence & m_nFlags) pACorr->AddCplSttException(m_sWord, m_eLanguage); } } diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 5674124a266e..f80c39a0017b 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -1802,9 +1802,9 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl ) void SwAutoFormat::AutoCorrect( sal_Int32 nPos ) { SvxAutoCorrect* pATst = SvxAutoCorrCfg::Get().GetAutoCorrect(); - long aSvxFlags = pATst->GetFlags( ); - bool bReplaceQuote = ( aSvxFlags & ChgQuotes ) > 0; - bool bReplaceSglQuote = ( aSvxFlags & ChgSglQuotes ) > 0; + ACFlags aSvxFlags = pATst->GetFlags( ); + bool bReplaceQuote( aSvxFlags & ACFlags::ChgQuotes ); + bool bReplaceSglQuote( aSvxFlags & ACFlags::ChgSglQuotes ); if( m_aFlags.bAFormatByInput || (!m_aFlags.bAutoCorrect && !bReplaceQuote && !bReplaceSglQuote && diff --git a/sw/source/core/inc/acorrect.hxx b/sw/source/core/inc/acorrect.hxx index caae1184e99f..5cfcdb88425d 100644 --- a/sw/source/core/inc/acorrect.hxx +++ b/sw/source/core/inc/acorrect.hxx @@ -83,7 +83,7 @@ public: // - FnCapitalStartWord and // - FnCapitalStartSentence. // Afterwards the words can be added into exception list if needed. - virtual void SaveCpltSttWord( sal_uLong nFlag, sal_Int32 nPos, + virtual void SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos, const OUString& rExceptWord, sal_Unicode cChar ) override; virtual LanguageType GetLanguage( sal_Int32 nPos ) const override; }; @@ -91,14 +91,15 @@ public: class SwAutoCorrExceptWord { OUString m_sWord; - sal_uLong m_nFlags, m_nNode; + ACFlags m_nFlags; + sal_uLong m_nNode; sal_Int32 m_nContent; sal_Unicode m_cChar; LanguageType m_eLanguage; bool m_bDeleted; public: - SwAutoCorrExceptWord(sal_uLong nAFlags, sal_uLong nNd, sal_Int32 nContent, + SwAutoCorrExceptWord(ACFlags nAFlags, sal_uLong nNd, sal_Int32 nContent, const OUString& rWord, sal_Unicode cChr, LanguageType eLang) : m_sWord(rWord), m_nFlags(nAFlags), m_nNode(nNd), m_nContent(nContent), diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index a5a91f83f04e..5e509ee18ec3 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -2366,10 +2366,10 @@ KEYINPUT_CHECKTABLE: const bool bIsAutoCorrectChar = SvxAutoCorrect::IsAutoCorrectChar( aCh ); if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || rSh.IsNbspRunNext() ) && pACfg->IsAutoFormatByInput() && - (( pACorr->IsAutoCorrFlag( ChgWeightUnderl ) && + (( pACorr->IsAutoCorrFlag( ACFlags::ChgWeightUnderl ) && ( '*' == aCh || '_' == aCh ) ) || - ( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))|| - ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh)))) + ( pACorr->IsAutoCorrFlag( ACFlags::ChgQuotes ) && ('\"' == aCh ))|| + ( pACorr->IsAutoCorrFlag( ACFlags::ChgSglQuotes ) && ( '\'' == aCh)))) { FlushInBuffer(); rSh.AutoCorrect( *pACorr, aCh ); @@ -2378,10 +2378,10 @@ KEYINPUT_CHECKTABLE: } else if( !aKeyEvent.GetRepeat() && pACorr && ( bIsAutoCorrectChar || rSh.IsNbspRunNext() ) && pACfg->IsAutoFormatByInput() && - pACorr->IsAutoCorrFlag( CapitalStartSentence | CapitalStartWord | - ChgOrdinalNumber | AddNonBrkSpace | - ChgToEnEmDash | SetINetAttr | - Autocorrect ) && + pACorr->IsAutoCorrFlag( ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord | + ACFlags::ChgOrdinalNumber | ACFlags::AddNonBrkSpace | + ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | + ACFlags::Autocorrect ) && '\"' != aCh && '\'' != aCh && '*' != aCh && '_' != aCh ) { @@ -2412,10 +2412,10 @@ KEYINPUT_CHECKTABLE: case SwKeyState::CheckAutoCorrect: { if( pACorr && pACfg->IsAutoFormatByInput() && - pACorr->IsAutoCorrFlag( CapitalStartSentence | CapitalStartWord | - ChgOrdinalNumber | - ChgToEnEmDash | SetINetAttr | - Autocorrect ) && + pACorr->IsAutoCorrFlag( ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord | + ACFlags::ChgOrdinalNumber | + ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | + ACFlags::Autocorrect ) && !rSh.HasReadonlySel() ) { FlushInBuffer(); @@ -5293,8 +5293,8 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get(); SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect(); if(pACorr && - (( pACorr->IsAutoCorrFlag( ChgQuotes ) && ('\"' == aCh ))|| - ( pACorr->IsAutoCorrFlag( ChgSglQuotes ) && ( '\'' == aCh)))) + (( pACorr->IsAutoCorrFlag( ACFlags::ChgQuotes ) && ('\"' == aCh ))|| + ( pACorr->IsAutoCorrFlag( ACFlags::ChgSglQuotes ) && ( '\'' == aCh)))) { rSh.DelLeft(); rSh.AutoCorrect( *pACorr, aCh ); diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index 357d0483184e..b5dc483ebad5 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -161,7 +161,9 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect(); if( pACorr && rACfg.IsAutoFormatByInput() && pACorr->IsAutoCorrFlag( - CapitalStartSentence | CapitalStartWord | AddNonBrkSpace | ChgOrdinalNumber | ChgToEnEmDash | SetINetAttr | Autocorrect ) ) + ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord | + ACFlags::AddNonBrkSpace | ACFlags::ChgOrdinalNumber | + ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect ) ) { rSh.AutoCorrect( *pACorr, cIns ); } diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index 2ed8db43218f..720308feb756 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -135,9 +135,9 @@ using namespace com::sun::star; static SvxAutoCorrect* lcl_IsAutoCorr() { SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect(); - if( pACorr && !pACorr->IsAutoCorrFlag( CapitalStartSentence | CapitalStartWord | - AddNonBrkSpace | ChgOrdinalNumber | - ChgToEnEmDash | SetINetAttr | Autocorrect )) + if( pACorr && !pACorr->IsAutoCorrFlag( ACFlags::CapitalStartSentence | ACFlags::CapitalStartWord | + ACFlags::AddNonBrkSpace | ACFlags::ChgOrdinalNumber | + ACFlags::ChgToEnEmDash | ACFlags::SetINetAttr | ACFlags::Autocorrect )) pACorr = nullptr; return pACorr; } |