[PATCH 1/2] Add the percent sign as a symbol that is inserted when % is pressed
Luke Dixon
6b8b4567 at gmail.com
Sun Dec 5 09:58:45 PST 2010
---
starmath/inc/cursor.hxx | 3 ++-
starmath/inc/types.hxx | 4 +++-
starmath/source/cursor.cxx | 9 +++++++++
starmath/source/view.cxx | 2 ++
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx
index 139d5c4..5c61d12 100644
--- a/starmath/inc/cursor.hxx
+++ b/starmath/inc/cursor.hxx
@@ -52,7 +52,8 @@ enum SmFormulaElement{
CDotElement,
EqualElement,
LessThanElement,
- GreaterThanElement
+ GreaterThanElement,
+ PercentElement
};
/** Bracket types that can be inserted */
diff --git a/starmath/inc/types.hxx b/starmath/inc/types.hxx
index 833c88c..d72df24 100644
--- a/starmath/inc/types.hxx
+++ b/starmath/inc/types.hxx
@@ -198,7 +198,9 @@ enum MathSymbol
MS_SETZ = (sal_Unicode) 0x2124,
MS_SETQ = (sal_Unicode) 0x211A,
MS_SETR = (sal_Unicode) 0x211D,
- MS_SETC = (sal_Unicode) 0x2102
+ MS_SETC = (sal_Unicode) 0x2102,
+
+ MS_PERCENT = (sal_Unicode) 0x0025
};
#endif
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 94b9e38..249d6a4 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -1058,6 +1058,15 @@ void SmCursor::InsertElement(SmFormulaElement element){
token.aText.AssignAscii(">");
pNewNode = new SmMathSymbolNode(token);
}break;
+ case PercentElement:
+ {
+ SmToken token;
+ token.eType = TTEXT;
+ token.cMathChar = MS_PERCENT;
+ token.nGroup = 0;
+ token.aText.AssignAscii("\"%\"");
+ pNewNode = new SmMathSymbolNode(token);
+ }break;
default:
j_assert(false, "Element unknown!");
}
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 97a9035..810ddd7 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -513,6 +513,8 @@ void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt)
rCursor.InsertBrackets(CurlyBrackets);
}else if(code == '!') {
rCursor.InsertElement(FactorialElement);
+ }else if(code == '%') {
+ rCursor.InsertElement(PercentElement);
}else{
if(code != 0){
rCursor.InsertText(code);
--
1.7.3.2
--=-3Fb++cBq1pDlt5wkBnR1--
More information about the LibreOffice
mailing list