summaryrefslogtreecommitdiff
path: root/cui/source/dialogs/SpellDialog.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-05-29 22:27:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-05-29 22:34:49 +0100
commita3c47760e122baaf55f39107597aff2f5957aecd (patch)
tree37e9485e039053dea5fd71ff0de574b455c1d86b /cui/source/dialogs/SpellDialog.cxx
parent5713c054c569593e21d2d9db8680d5304f3063f9 (diff)
Resolves: fdo#50476 Dots inside quoted sentences get removed on "Correct All"
refactor the dodgy dot replacement code so that all the replacement paths go through the same logic so that "Change All" does the same thing as repeated "Change"s Change-Id: Id63968e03409f676200a9ac546f7baa398f2eff8
Diffstat (limited to 'cui/source/dialogs/SpellDialog.cxx')
-rw-r--r--cui/source/dialogs/SpellDialog.cxx51
1 files changed, 32 insertions, 19 deletions
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index 602289e71cc1..eec15d57a630 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -632,22 +632,39 @@ void SpellDialog::StartSpellOptDlg_Impl()
OfaTreeOptionsDialog::ApplyLanguageOptions(*pOutSet);
}
delete pDlg;
+}
+
+namespace
+{
+ String getDotReplacementString(const String &rErrorText, const String &rSuggestedReplacement)
+ {
+ String aString = rErrorText;
+
+ //dots are sometimes part of the spelled word but they are not necessarily part of the replacement
+ bool bDot = aString.Len() && aString.GetChar(aString.Len() - 1 ) == '.';
+ aString = rSuggestedReplacement;
+
+ if(bDot && (!aString.Len() || aString.GetChar(aString.Len() - 1 ) != '.'))
+ aString += '.';
+
+ return aString;
+ }
}
+
String SpellDialog::getReplacementString() const
{
- String aString = aSentenceED.GetErrorText();
- //dots are sometimes part of the spelled word but they are not necessarily part of the replacement
- bool bDot = aString.Len() && aString.GetChar(aString.Len() - 1 ) == '.';
+ String sOrigString = aSentenceED.GetErrorText();
+
+ String sReplacement(sOrigString);
+
if(aSuggestionLB.IsEnabled() &&
aSuggestionLB.GetSelectEntryCount()>0 &&
aNoSuggestionsST != aSuggestionLB.GetSelectEntry())
- aString = aSuggestionLB.GetSelectEntry();
- if(bDot && (!aString.Len() || aString.GetChar(aString.Len() - 1 ) != '.'))
- aString += '.';
+ sReplacement = aSuggestionLB.GetSelectEntry();
- return aString;
+ return getDotReplacementString(sOrigString, sReplacement);
}
// -----------------------------------------------------------------------
@@ -1304,20 +1321,13 @@ bool SpellDialog::ApplyChangeAllList_Impl(SpellPortions& rSentence, bool &bHasRe
{
if(aStart->xAlternatives.is())
{
- rtl::OUString &rString = aStart->sText;
+ const rtl::OUString &rString = aStart->sText;
- //dots are sometimes part of the spelled word but they are not necessarily part of the replacement
- bool bDot = !rString.isEmpty() && rString[rString.getLength() - 1] == '.';
-
- Reference<XDictionaryEntry> xEntry = xChangeAll->getEntry( rString );
+ Reference<XDictionaryEntry> xEntry = xChangeAll->getEntry(rString);
if(xEntry.is())
{
- rString = xEntry->getReplacementText();
-
- if(bDot && (rString.isEmpty() || rString[rString.getLength() - 1] != '.'))
- rString = rString + rtl::OUString(static_cast<sal_Unicode>('.'));
-
+ aStart->sText = getDotReplacementString(rString, xEntry->getReplacementText());
aStart->xAlternatives = 0;
bHasReplaced = true;
}
@@ -1731,8 +1741,11 @@ bool SentenceEditWindow_Impl::MarkNextError( bool bIgnoreCurrentError )
{
m_nErrorStart = pNextError->GetStart();
m_nErrorEnd = pNextError->GetEnd();
- ChangeMarkedWord(xEntry->getReplacementText(),
- SvxLocaleToLanguage( pSpellErrorDescription->aLocale ));
+
+ String sReplacement(getDotReplacementString(GetErrorText(), xEntry->getReplacementText()));
+
+ ChangeMarkedWord(sReplacement, SvxLocaleToLanguage( pSpellErrorDescription->aLocale ));
+
aCursor.GetIndex() = aCursor.GetIndex() + (sal_uInt16)(xEntry->getReplacementText().getLength());
}
else