diff options
Diffstat (limited to 'starmath/source')
-rw-r--r-- | starmath/source/commands.src | 7 | ||||
-rw-r--r-- | starmath/source/node.cxx | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | starmath/source/parse.cxx | 73 | ||||
-rwxr-xr-x[-rw-r--r--] | starmath/source/smres.src | 2 |
4 files changed, 64 insertions, 23 deletions
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 { |