ImproveMathEquationEditor/Baseline AlignmentEquations/LineNode Arrange Bug

Back to Baseline alignment for equations

Description
The SmLineNode::Arrange tryies to provide a way to arrange {}^2 as blank space with 2 as power in proper hight, by which is meant the hight for standard characters. The problem is that the implementation is designed so that firstly the line node is being assigned rectangle for letter "a" which is shrunk afterwards not to be displayed (which makes it have the proper hight in case it's empty). Then the line node is extended by subnodes. The trouble is, that extending this fictional node leads to different alignment information then the subnodes together should have (eg the line node can get baseline from this fictional node although it shouldn't have it).

Fix description
The fix is simple, we divide the implementation to two cases. If the LineNode has no subnodes it gets assigned the fictional node. If the LineNode has subnodes, there will be no fictional node and the line node will be assigned the first subnode and extanded by the rest.

patch preview
Index: starmath/source/node.cxx

=
====================================================== --- starmath/source/node.cxx	(revision 658) +++ starmath/source/node.cxx	(working copy) @@ -816,27 +816,32 @@    SmTmpDevice  aTmpDev ((OutputDevice &) rDev, TRUE); aTmpDev.SetFont(GetFont); -	// provide an empty rectangle with alignment parameters for the "current" -	// font (in order to make "a^1 {}_2^3 a_4" work correct, that is, have the -	// same sub-/supscript positions.) -	//! be sure to use a character that has explicitly defined HiAttribut -	//! line in rect.cxx such as 'a' in order to make 'vec a' look same to -	//! 'vec {a}'. -	SmRect::operator = (SmRect(aTmpDev, &rFormat, C2S("a"), -							  GetFont.GetBorderWidth)); -	// make sure that the rectangle occupies (almost) no space -	SetWidth(1); -	SetItalicSpaces(0, 0); +   if (nSize < 1) +   { +	    // provide an empty rectangle with alignment parameters for the "current" +   	// font (in order to make "a^1 {}_2^3 a_4" work correct, that is, have the +    	// same sub-/supscript positions.) +   	//! be sure to use a character that has explicitly defined HiAttribut +   	//! line in rect.cxx such as 'a' in order to make 'vec a' look same to +    	//! 'vec {a}'. +   	SmRect::operator = (SmRect(aTmpDev, &rFormat, C2S("a"), +   	                       GetFont.GetBorderWidth)); +	   // make sure that the rectangle occupies (almost) no space +	   SetWidth(1); +	   SetItalicSpaces(0, 0); +       return; +   } -	if (nSize < 1) -		return; - 	// make distance depend on font size long nDist = +(rFormat.GetDistance(DIS_HORIZONTAL) 					* GetFont.GetSize.Height) / 100L; Point  aPos; -	for (i = 0; i < nSize;  i++) +	// copy the first node into LineNode and extend by the others +	if (NULL != (pNode = GetSubNode(0))) +	   SmRect::operator = (pNode->GetRect); +	+	for (i = 1; i < nSize;  i++) if (NULL != (pNode = GetSubNode(i))) { 			aPos = pNode->AlignTo(*this, RP_RIGHT, RHA_CENTER, RVA_BASELINE);

patch download
the patch is made using svn diff in OOo4Kids (will be uploaded)

Description
To correctly handle arranging the table node the maximum width of all line nodes has to be calculated first (table node consists of line nodes 'as lines' under each other). Then rectangle with this maximum width is created (with the smallest hight) and extended by all the subnodes (line nodes). The problem is that the hight of the rectangle is set to be 0 and in function SmRect::Union rectangle with zero dimension is neglected, therefore the width is not counted with. In fact this makes no difference because italic spaces are set outside of SmRect::Union and it cancels out the error. But in case of changing the SmRect::Union in future to count with the italic spaces, we should change it.

Fix Description
The fix is basically changing the hight from 0 to 1.

patch preview
Index: starmath/source/node.cxx

=
====================================================== --- starmath/source/node.cxx	(revision 658) +++ starmath/source/node.cxx	(working copy) @@ -760,7 +760,7 @@ 		} 	Point aPos; -	SmRect::operator = (SmRect(nMaxWidth, 0)); +	SmRect::operator = (SmRect(nMaxWidth, 1)); for (i = 0; i < nSize;  i++) {  if (NULL != (pNode = GetSubNode(i))) {	const SmRect &rNodeRect = pNode->GetRect;