Hi Thomas,

thanks for your quick response.

On Tue, Feb 2, 2010 at 2:09 PM, Thomas Lange - Sun Microsystems
<[email protected]> wrote:
>
> Hi Konstantinos,
...
> This leaves us with 2).
> Basically there are two possible choices for a syntax to choose from for
> implementation
>  - int xy + b nospace { d x }
>  - int xy + b d nospace x
> the first working like brackets the latter like a binary operator.
> I'm fine with either one but I think we should not implement both of them.
> The somewhat easier one to implement will be the last one.
>
>
> Regards,
> Thomas

I have finally implemented the first of the two variants, that you
have suggested for method 2). Attached you can find the corresponding
patch for everyone who would like to try it. I have also attached a
screenshot demonstrating some tests. If anyone could suggest any
further tests, I can provide the corresponding results.

In the following days I will try to add a corresponding button into
the selection toolbar. In which group of this toolbar should it be
added?

Are there other places in OOo Math except node.cxx and parse.cxx where
the new nospace feature should be taken into account?

Best Regards

Kostas
diff -rup OpenOffice_3_1_0/starmath/inc/node.hxx OpenOffice_3_1_0_test/starmath/inc/node.hxx
--- OpenOffice_3_1_0/starmath/inc/node.hxx	2010-01-29 19:17:29.000000000 +0100
+++ OpenOffice_3_1_0_test/starmath/inc/node.hxx	2010-02-01 01:41:49.000000000 +0100
@@ -488,15 +488,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 -rup OpenOffice_3_1_0/starmath/inc/parse.hxx OpenOffice_3_1_0_test/starmath/inc/parse.hxx
--- OpenOffice_3_1_0/starmath/inc/parse.hxx	2010-01-29 19:17:29.000000000 +0100
+++ OpenOffice_3_1_0_test/starmath/inc/parse.hxx	2010-02-01 10:46:24.000000000 +0100
@@ -109,7 +109,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 -rup OpenOffice_3_1_0/starmath/source/node.cxx OpenOffice_3_1_0_test/starmath/source/node.cxx
--- OpenOffice_3_1_0/starmath/source/node.cxx	2010-01-29 19:17:28.000000000 +0100
+++ OpenOffice_3_1_0_test/starmath/source/node.cxx	2010-02-01 01:48:19.000000000 +0100
@@ -831,8 +831,10 @@ void SmLineNode::Arrange(const OutputDev
 	if (nSize < 1)
 		return;
 
-	// make distance depend on font size
-	long  nDist = +(rFormat.GetDistance(DIS_HORIZONTAL)
+	long  nDist = 0;
+	if (IsUseExtraSpaces())
+		// make distance depend on font size
+		nDist = +(rFormat.GetDistance(DIS_HORIZONTAL)
 					* GetFont().GetSize().Height()) / 100L;
 
 	Point   aPos;
diff -rup OpenOffice_3_1_0/starmath/source/parse.cxx OpenOffice_3_1_0_test/starmath/source/parse.cxx
--- OpenOffice_3_1_0/starmath/source/parse.cxx	2010-01-29 19:17:28.000000000 +0100
+++ OpenOffice_3_1_0_test/starmath/source/parse.cxx	2010-02-02 21:52:11.000000000 +0100
@@ -245,12 +245,13 @@ static const SmTokenTableEntry aTokenTab
 	{ "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},
@@ -734,7 +735,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;
@@ -1135,6 +1136,14 @@ 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);
+
 	USHORT		 n = 0;
 	SmNodeArray  RelationArray;
 
@@ -1150,8 +1159,9 @@ void SmParser::Expression()
 		RelationArray.Put(n - 1, NodeStack.Pop());
 	}
 
-	SmStructureNode *pSNode = new SmExpressionNode(CurToken);
+	SmExpressionNode *pSNode = new SmExpressionNode(CurToken);
 	pSNode->SetSubNodes(RelationArray);
+	pSNode->SetUseExtraSpaces(bUseExtraSpaces);
 	NodeStack.Push(pSNode);
 }
 
@@ -1273,7 +1283,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').
@@ -1409,6 +1419,35 @@ void SmParser::Term()
 			Blank();
 			break;
 
+		case TNOSPACE :
+			NodeStack.Push(new SmExpressionNode(CurToken));
+			NextToken();
+			if (CurToken.eType != TLGROUP)
+			{	NodeStack.Pop();
+				Term();
+			}
+			else	// _almost_ the same as in TLGROUP
+			{	NextToken();
+				// allow for empty group
+				if (CurToken.eType == TRGROUP)
+				{	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;
+
 		case TTEXT :
 			NodeStack.Push(new SmTextNode(CurToken, FNT_TEXT));
 			NextToken();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to