summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiagoSantos <tiagofsantos81@sapo.pt>2016-11-22 14:41:33 +0000
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-11-24 07:31:29 +0000
commit6bfe94a631b5c5029a1f96a52b000d25e33bad4a (patch)
tree747f9315f44ef7ee5139419903173815ff2d1afa
parent5af0071d42e5962ed849261134ef0630c7ec3b45 (diff)
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/31076 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--editeng/source/misc/svxacorr.cxx40
1 files changed, 29 insertions, 11 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index fafb4be81ebc..ccb6e26db2f2 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -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 ) )
{