Kaydet (Commit) 6bfe94a6 authored tarafından TiagoSantos's avatar TiagoSantos Kaydeden (comit) Noel Grandin

extend markup support (/italic/ and -strikeout-)

* adds to LibreOffice markup support for /italics/ and -strikeout-
* TODO update strings in the Options dialog (they only refer *bold* and
_underline_)
* TODO update documentation with new feature

Change-Id: I6fd7bbd036bf406a9e24500d316e7f28a848faab
Reviewed-on: https://gerrit.libreoffice.org/31076Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 5af0071d
......@@ -44,6 +44,8 @@
#include <sot/storage.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/postitem.hxx>
#include <editeng/crossedoutitem.hxx>
#include <editeng/escapementitem.hxx>
#include <editeng/svxacorr.hxx>
#include <editeng/unolingu.hxx>
......@@ -237,7 +239,7 @@ bool SvxAutoCorrect::IsAutoCorrectChar( sal_Unicode cChar )
cChar == '*' || cChar == '_' || cChar == '%' ||
cChar == '.' || cChar == ',' || cChar == ';' ||
cChar == ':' || cChar == '?' || cChar == '!' ||
cChar == '/';
cChar == '/' || cChar == '-';
}
namespace
......@@ -735,10 +737,10 @@ bool SvxAutoCorrect::FnChgWeightUnderl( SvxAutoCorrDoc& rDoc, const OUString& rT
sal_Int32 , sal_Int32 nEndPos )
{
// Condition:
// at the beginning: _ or * after Space with the following !Space
// at the end: _ or * before Space (word delimiter?)
// at the beginning: _, *, / or ~ after Space with the following !Space
// at the end: _, *, / or ~ before Space (word delimiter?)
sal_Unicode cInsChar = rTxt[ nEndPos ]; // underline or bold
sal_Unicode cInsChar = rTxt[ nEndPos ]; // underline, bold, italic or strikeout
if( ++nEndPos != rTxt.getLength() &&
!IsWordDelim( rTxt[ nEndPos ] ) )
return false;
......@@ -755,6 +757,8 @@ bool SvxAutoCorrect::FnChgWeightUnderl( SvxAutoCorrDoc& rDoc, const OUString& rT
switch( sal_Unicode c = rTxt[ --nPos ] )
{
case '_':
case '-':
case '/':
case '*':
if( c == cInsChar )
{
......@@ -787,17 +791,31 @@ bool SvxAutoCorrect::FnChgWeightUnderl( SvxAutoCorrDoc& rDoc, const OUString& rT
{
SvxWeightItem aSvxWeightItem( WEIGHT_BOLD, SID_ATTR_CHAR_WEIGHT );
rDoc.SetAttr( nFndPos, nEndPos - 1,
SID_ATTR_CHAR_WEIGHT,
aSvxWeightItem);
SID_ATTR_CHAR_WEIGHT,
aSvxWeightItem);
}
else // underline
else if( '/' == cInsChar ) // Italic
{
SvxPostureItem aSvxPostureItem( ITALIC_NORMAL, SID_ATTR_CHAR_POSTURE );
rDoc.SetAttr( nFndPos, nEndPos - 1,
SID_ATTR_CHAR_POSTURE,
aSvxPostureItem);
}
else if( '-' == cInsChar ) // Strikeout
{
SvxCrossedOutItem aSvxCrossedOutItem( STRIKEOUT_SINGLE, SID_ATTR_CHAR_STRIKEOUT );
rDoc.SetAttr( nFndPos, nEndPos - 1,
SID_ATTR_CHAR_STRIKEOUT,
aSvxCrossedOutItem);
}
else // Underline
{
SvxUnderlineItem aSvxUnderlineItem( LINESTYLE_SINGLE, SID_ATTR_CHAR_UNDERLINE );
rDoc.SetAttr( nFndPos, nEndPos - 1,
SID_ATTR_CHAR_UNDERLINE,
aSvxUnderlineItem);
SID_ATTR_CHAR_UNDERLINE,
aSvxUnderlineItem);
}
}
}
return -1 != nFndPos;
}
......@@ -1304,7 +1322,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
break;
// Set bold or underline automatically?
if (('*' == cChar || '_' == cChar) && (nPos+1 < rTxt.getLength()))
if (('*' == cChar || '_' == cChar || '/' == cChar || '-' == cChar) && (nPos+1 < rTxt.getLength()))
{
if( IsAutoCorrFlag( ChgWeightUnderl ) )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment