summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/node.hxx13
-rw-r--r--starmath/inc/parse.hxx2
-rw-r--r--starmath/inc/starmath.hrc2
-rw-r--r--starmath/source/commands.src7
-rw-r--r--starmath/source/node.cxx5
-rwxr-xr-x[-rw-r--r--]starmath/source/parse.cxx73
-rwxr-xr-x[-rw-r--r--]starmath/source/smres.src2
7 files changed, 78 insertions, 26 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index f9fed9c9602a..6ef89ea5ec1b 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -484,15 +484,24 @@ public:
class SmLineNode : public SmStructureNode
{
+ BOOL bUseExtraSpaces;
+
protected:
SmLineNode(SmNodeType eNodeType, const SmToken &rNodeToken)
: SmStructureNode(eNodeType, rNodeToken)
- {}
+ {
+ bUseExtraSpaces = TRUE;
+ }
public:
SmLineNode(const SmToken &rNodeToken)
: SmStructureNode(NLINE, rNodeToken)
- {}
+ {
+ bUseExtraSpaces = TRUE;
+ }
+
+ void SetUseExtraSpaces(BOOL bVal) { bUseExtraSpaces = bVal; }
+ BOOL IsUseExtraSpaces() const { return bUseExtraSpaces; };
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx
index b3ad5ef5bdc3..facf17d561e2 100644
--- a/starmath/inc/parse.hxx
+++ b/starmath/inc/parse.hxx
@@ -106,7 +106,7 @@ enum SmTokenType
TLEFTARROW, TRIGHTARROW, TUPARROW, TDOWNARROW, TDIVIDES,
TNDIBVIDES, TSETN, TSETZ, TSETQ, TSETR,
TSETC, TWIDEVEC, TWIDETILDE, TWIDEHAT, TWIDESLASH,
- TWIDEBACKSLASH, TLDBRACKET, TRDBRACKET,
+ TWIDEBACKSLASH, TLDBRACKET, TRDBRACKET, TNOSPACE,
TUNKNOWN, TDEBUG
};
diff --git a/starmath/inc/starmath.hrc b/starmath/inc/starmath.hrc
index 2fbc7b4066d1..d73ea27a0d45 100644
--- a/starmath/inc/starmath.hrc
+++ b/starmath/inc/starmath.hrc
@@ -379,6 +379,7 @@
#define RID_LSUPX (RID_APP_START + 1916)
#define RID_CSUBX (RID_APP_START + 1917)
#define RID_CSUPX (RID_APP_START + 1918)
+#define RID_NOSPACE (RID_APP_START + 1919)
#define RID_ALEPH (RID_APP_START + 2001)
#define RID_EMPTYSET (RID_APP_START + 2002)
@@ -694,6 +695,7 @@
#define HID_SMA_DOTSDOWN (HID_SMA_START + 240)
#define HID_SMA_DOTSLOW (HID_SMA_START + 241)
#define HID_SMA_DOTSVERT (HID_SMA_START + 242)
+#define HID_SMA_NOSPACE (HID_SMA_START + 243)
#define HID_SMA_SETN (HID_SMA2_START + 1)
#define HID_SMA_SETZ (HID_SMA2_START + 2)
diff --git a/starmath/source/commands.src b/starmath/source/commands.src
index 75c00cb819a6..9d618bbd0cf3 100644
--- a/starmath/source/commands.src
+++ b/starmath/source/commands.src
@@ -223,6 +223,7 @@ String RID_LEFTARROW { Text = "leftarrow " ; };
String RID_RIGHTARROW { Text = "rightarrow " ; };
String RID_UPARROW { Text = "uparrow " ; };
String RID_DOWNARROW { Text = "downarrow " ; };
+String RID_NOSPACE { Text = "nospace {<?>} " ; };
//////////////////////////////////////////
@@ -1327,6 +1328,12 @@ Menu RID_COMMANDMENU
};
MenuItem
{
+ Identifier = RID_NOSPACE;
+ HelpId = HID_SMA_NOSPACE;
+ Text [ en-US ] = "nospace {...}";
+ };
+ MenuItem
+ {
Identifier = RID_BINOMXY;
HelpId = HID_SMA_BINOMXY;
Text = "binom x y";
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 722df5a1d502..30b8768d1570 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -831,8 +831,9 @@ void SmLineNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
return;
// make distance depend on font size
- long nDist = +(rFormat.GetDistance(DIS_HORIZONTAL)
- * GetFont().GetSize().Height()) / 100L;
+ long nDist = (rFormat.GetDistance(DIS_HORIZONTAL) * GetFont().GetSize().Height()) / 100L;
+ if (!IsUseExtraSpaces())
+ nDist = 0;
Point aPos;
for (i = 0; i < nSize; i++)
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 1955b0553b62..0efe0e0ed6b1 100644..100755
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -242,12 +242,13 @@ static const SmTokenTableEntry aTokenTable[] =
{ "ni", TNI, MS_NI, TGRELATION, 0},
{ "nitalic", TNITALIC, '\0', TGFONTATTR, 5},
{ "none", TNONE, '\0', TGLBRACES | TGRBRACES, 0},
+ { "nospace", TNOSPACE, '\0', TGSTANDALONE, 5},
{ "notin", TNOTIN, MS_NOTIN, TGRELATION, 0},
+ { "nroot", TNROOT, MS_SQRT, TGUNOPER, 5},
{ "nsubset", TNSUBSET, MS_NSUBSET, TGRELATION, 0 },
{ "nsupset", TNSUPSET, MS_NSUPSET, TGRELATION, 0 },
{ "nsubseteq", TNSUBSETEQ, MS_NSUBSETEQ, TGRELATION, 0 },
{ "nsupseteq", TNSUPSETEQ, MS_NSUPSETEQ, TGRELATION, 0 },
- { "nroot", TNROOT, MS_SQRT, TGUNOPER, 5},
{ "odivide", TODIVIDE, MS_ODIVIDE, TGPRODUCT, 0},
{ "odot", TODOT, MS_ODOT, TGPRODUCT, 0},
{ "ominus", TOMINUS, MS_OMINUS, TGSUM, 0},
@@ -731,7 +732,7 @@ void SmParser::NextToken()
xub_StrLen nTmpStart = sal::static_int_cast< xub_StrLen >(rnEndPos +
aTmpRes.LeadingWhiteSpace);
- // default setting fo the case that no identifier
+ // default setting for the case that no identifier
// i.e. a valid symbol-name is following the '%'
// character
CurToken.eType = TTEXT;
@@ -1132,6 +1133,16 @@ void SmParser::Line()
void SmParser::Expression()
{
+ BOOL bUseExtraSpaces = TRUE;
+ SmNode *pNode = NodeStack.Pop();
+ if (pNode)
+ {
+ if (pNode->GetToken().eType == TNOSPACE)
+ bUseExtraSpaces = FALSE;
+ else
+ NodeStack.Push(pNode); // push the node from above again (now to be used as argument to this current 'nospace' node)
+ }
+
USHORT n = 0;
SmNodeArray RelationArray;
@@ -1147,8 +1158,9 @@ void SmParser::Expression()
RelationArray[n - 1] = NodeStack.Pop();
}
- SmStructureNode *pSNode = new SmExpressionNode(CurToken);
+ SmExpressionNode *pSNode = new SmExpressionNode(CurToken);
pSNode->SetSubNodes(RelationArray);
+ pSNode->SetUseExtraSpaces(bUseExtraSpaces);
NodeStack.Push(pSNode);
}
@@ -1270,7 +1282,7 @@ void SmParser::SubSup(ULONG nActiveGroup)
return;
SmSubSupNode *pNode = new SmSubSupNode(CurToken);
- //! Of course 'CurToken' ist just the first sub-/supscript token.
+ //! Of course 'CurToken' is just the first sub-/supscript token.
//! It should be of no further interest. The positions of the
//! sub-/supscripts will be identified by the corresponding subnodes
//! index in the 'aSubNodes' array (enum value from 'SmSubSup').
@@ -1374,30 +1386,51 @@ void SmParser::Blank()
void SmParser::Term()
{
switch (CurToken.eType)
- { case TESCAPE :
+ {
+ case TESCAPE :
Escape();
break;
+ case TNOSPACE :
case TLGROUP :
- NextToken();
-
- // allow for empty group
- if (CurToken.eType == TRGROUP)
- { SmStructureNode *pSNode = new SmExpressionNode(CurToken);
- pSNode->SetSubNodes(NULL, NULL);
- NodeStack.Push(pSNode);
-
+ {
+ bool bNoSpace = CurToken.eType == TNOSPACE;
+ if (bNoSpace) // push 'no space' node and continue to parse expression
+ {
+ NodeStack.Push(new SmExpressionNode(CurToken));
NextToken();
}
- else // go as usual
- { Align();
- if (CurToken.eType != TRGROUP)
- Error(PE_RGROUP_EXPECTED);
- else
- { NextToken();
+ if (CurToken.eType != TLGROUP)
+ {
+ NodeStack.Pop(); // get rid of the 'no space' node pushed above
+ Term();
+ }
+ else
+ {
+ NextToken();
+
+ // allow for empty group
+ if (CurToken.eType == TRGROUP)
+ {
+ if (bNoSpace) // get rid of the 'no space' node pushed above
+ NodeStack.Pop();
+ SmStructureNode *pSNode = new SmExpressionNode(CurToken);
+ pSNode->SetSubNodes(NULL, NULL);
+ NodeStack.Push(pSNode);
+
+ NextToken();
+ }
+ else // go as usual
+ {
+ Align();
+ if (CurToken.eType != TRGROUP)
+ Error(PE_RGROUP_EXPECTED);
+ else
+ NextToken();
}
}
- break;
+ }
+ break;
case TLEFT :
Brace();
diff --git a/starmath/source/smres.src b/starmath/source/smres.src
index ec6d8114759b..7d3525bd2a29 100644..100755
--- a/starmath/source/smres.src
+++ b/starmath/source/smres.src
@@ -1556,7 +1556,7 @@ FloatingWindow RID_TOOLBOXWINDOW
OutputSize = TRUE ;
SVLook = TRUE ;
Size = MAP_APPFONT ( 0 , 0 ) ;
- Text [ en-US ] = "Formula Elements" ;
+ Text [ en-US ] = "Elements" ;
ToolBox 1
{