tdf#117651 Add AutoCorrect support for italic and strikethrough
The AutoCorrect "Apply" command calls SwAutoFormat::AutoCorrect in sw/source/core/edit/autofmt.cxx, as mentioned in the bug comments. This change just adds new cases for "/" (italic) and "-" (strikethrough), so that when "Tools" -> "AutoCorrect" -> "Apply" is invoked it changes any text between 2 "/"s or 2 "-"s (assuming your AutoCorrect options enable the setting for this). The new code is just mostly copied from the case statement above it (for bold and underline), and the only additional changes that were needed were to add the comment strings for the 2 new cases. Change-Id: I02238690a40fd0113e3e9acbecf93ef5c34e0785 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154207 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
parent
cfa70002e5
commit
2fa88bfbfa
3 changed files with 46 additions and 2 deletions
|
@ -45,8 +45,10 @@
|
|||
#define STR_AUTOFMTREDL_NON_BREAK_SPACE 21
|
||||
#define STR_AUTOFMTREDL_TRANSLITERATE_RTL 22
|
||||
#define STR_AUTOFMTREDL_DETECT_DOI 23
|
||||
#define STR_AUTOFMTREDL_ITALIC 24
|
||||
#define STR_AUTOFMTREDL_STRIKETHROUGH 25
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!! always set the correct end !!!!!!!!!!!!
|
||||
#define STR_AUTOFMTREDL_END 24
|
||||
#define STR_AUTOFMTREDL_END 26
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -50,7 +50,9 @@ const TranslateId RID_SHELLRES_AUTOFMTSTRS[] =
|
|||
NC_("RID_SHELLRES_AUTOFMTSTRS", "Combine paragraphs"),
|
||||
NC_("RID_SHELLRES_AUTOFMTSTRS", "Add non breaking space"),
|
||||
NC_("RID_SHELLRES_AUTOFMTSTRS", "Transliterates RTL Hungarian text to Old Hungarian script"),
|
||||
NC_("RID_SHELLRES_AUTOFMTSTRS", "DOI citation recognition")
|
||||
NC_("RID_SHELLRES_AUTOFMTSTRS", "DOI citation recognition"),
|
||||
NC_("RID_SHELLRES_AUTOFMTSTRS", "Automatic /italic/"),
|
||||
NC_("RID_SHELLRES_AUTOFMTSTRS", "Automatic -strikethrough-"),
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -282,6 +282,8 @@ void SwAutoFormat::SetRedlineText_( sal_uInt16 nActionId )
|
|||
case STR_AUTOFMTREDL_ORDINAL:
|
||||
case STR_AUTOFMTREDL_NON_BREAK_SPACE:
|
||||
case STR_AUTOFMTREDL_TRANSLITERATE_RTL:
|
||||
case STR_AUTOFMTREDL_ITALIC:
|
||||
case STR_AUTOFMTREDL_STRIKETHROUGH:
|
||||
nSeqNo = ++m_nRedlAutoFormatSeqId;
|
||||
break;
|
||||
}
|
||||
|
@ -2109,6 +2111,44 @@ void SwAutoFormat::AutoCorrect(TextFrameIndex nPos)
|
|||
SetRedlineText( STR_AUTOFMTREDL_NON_BREAK_SPACE );
|
||||
if (pATst->FnAddNonBrkSpace(aACorrDoc, *pText, sal_Int32(nPos), eLang, bNbspRunNext))
|
||||
--nPos;
|
||||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
case '-':
|
||||
if (m_aFlags.bChgWeightUnderl)
|
||||
{
|
||||
// consider Symbolfonts!
|
||||
if (!aFInfo.GetFrame())
|
||||
aFInfo.SetFrame(GetFrame(*m_pCurTextNd));
|
||||
if (!aFInfo.IsBullet(nPos))
|
||||
{
|
||||
SetRedlineText('/' == cChar ? STR_AUTOFMTREDL_ITALIC : STR_AUTOFMTREDL_STRIKETHROUGH);
|
||||
|
||||
sal_Unicode cBlank = nSttPos ? (*pText)[sal_Int32(nSttPos) - 1] : 0;
|
||||
*m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nPos);
|
||||
|
||||
if (pATst->FnChgWeightUnderl(aACorrDoc, *pText, sal_Int32(nPos)))
|
||||
{
|
||||
if (m_aFlags.bWithRedlining)
|
||||
{
|
||||
m_aNdIdx = m_aDelPam.GetPoint()->GetNode();
|
||||
m_pCurTextNd = m_aNdIdx.GetNode().GetTextNode();
|
||||
m_pCurTextFrame = GetFrame(*m_pCurTextNd);
|
||||
pText = &m_pCurTextFrame->GetText();
|
||||
m_aDelPam.SetMark();
|
||||
m_aDelPam.DeleteMark();
|
||||
aFInfo.SetFrame(nullptr);
|
||||
}
|
||||
//#125102# in case of the mode RedlineFlags::ShowDelete the ** are still contained in pText
|
||||
if (!(m_pDoc->getIDocumentRedlineAccess().GetRedlineFlags()
|
||||
& RedlineFlags::ShowDelete))
|
||||
nPos = m_pCurTextFrame->MapModelToViewPos(*m_aDelPam.GetPoint())
|
||||
- TextFrameIndex(1);
|
||||
// Was a character deleted before starting?
|
||||
if (cBlank && cBlank != (*pText)[sal_Int32(nSttPos) - 1])
|
||||
--nSttPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue