Commit a45a9e79 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

1. Поправила CreateElem для ParagraphContent (в связи с тем, что нужно учесть...

1. Поправила CreateElem для ParagraphContent (в связи с тем, что нужно учесть дефолтные настройки из settings и свойства прокинуть позднее при добавлении в формулу)
2. Поправила для степени с верхним/нижнем индексом расположение итератора ( для случая с верхним, чтобы не уезжал, когда основание текст, более правильное позиционирование, когда идет формула; для случая  нижнем итератором все итераторы выровнены по baseline, текст при этом в основании мб различный)
3. Gaps for "±"
4. Убрала gaps для argSize < 0

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54298 954022d7-b5bf-4e40-9824-e11837661b57
parent ff9f5801
......@@ -131,7 +131,12 @@ CDegree.prototype.recalculateSup = function(oMeasure)
if(bBaseOnlyText)
{
var UpBaseline = 1.786*shCenter; // baseline итератора
if(UpBaseline + iter.ascent> base.ascent)
// iter.height - UpBaseline - iter.ascent + base.ascent > 2/3 * base.height
if(iter.height - UpBaseline - iter.ascent + base.ascent > 2/3 * base.ascent)
this.upBase = iter.height - 2/3*base.ascent;
else if(UpBaseline + iter.ascent > base.ascent)
this.upBase = UpBaseline + iter.ascent - base.ascent;
else
this.upIter = base.ascent - UpBaseline - iter.ascent;
......@@ -139,9 +144,9 @@ CDegree.prototype.recalculateSup = function(oMeasure)
else
{
this.upBase = iter.ascent - 1.2*shCenter;
if(iter.height - this.upBase > 0.5*base.ascent)
this.upBase = iter.height - 0.5*base.ascent;
var ascBase = base.ascent - shCenter > 0.27*mgCtrPrp.FontSize ? base.ascent - shCenter : 2/3*base.ascent;
if(iter.height - this.upBase > ascBase)
this.upBase = iter.height - ascBase;
}
var height = this.upBase + base.height;
......@@ -157,6 +162,7 @@ CDegree.prototype.recalculateSup = function(oMeasure)
this.size = {width: width, height: height, ascent: ascent};
}
CDegree.prototype.recalculateSubScript = function(oMeasure)
{
var base = this.elements[0][0].size,
......@@ -171,10 +177,15 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
if(bBaseOnlyText)
{
this.upIter = base.ascent + 0.9*shCenter - iter.ascent;
var DownBaseline = 0.9*shCenter;
if(iter.ascent - DownBaseline > 3/4*base.ascent)
this.upIter = 1/4*base.ascent;
else
this.upIter = base.ascent + DownBaseline - iter.ascent;
if(base.ascent/2 > this.upIter)
this.upIter = base.ascent/2;
/*if(base.ascent/2 > this.upIter)
this.upIter = base.ascent/2;*/
}
else
{
......
......@@ -4843,218 +4843,227 @@ CMathContent.prototype =
right = null;
var curr = this.content[posCurr].value;
var EQUAL = 0x3D,
PLUS = 0x2B,
MINUS = 0x2212,
MULT = 0x2217,
LESS = 0x3C,
GREATER = 0x3E;
if(this.argSize < 0)
{
// выставим нулевые gaps для случая, если при копировании/вставки часть контента добавили в итератор
this.content[posCurr].gaps.left = 0;
this.content[posCurr].gaps.right = 0;
}
else
{
var EQUAL = 0x3D,
PLUS = 0x2B,
MINUS = 0x2212,
MULT = 0x2217,
LESS = 0x3C,
GREATER = 0x3E;
var t = posCurr - 1;
while( t > 0 )
{
if(this.content[t].value.typeObj == MATH_TEXT || this.content[t].value.typeObj == MATH_COMP)
var t = posCurr - 1;
while( t > 0 )
{
left = this.content[t].value;
break;
if(this.content[t].value.typeObj == MATH_TEXT || this.content[t].value.typeObj == MATH_COMP)
{
left = this.content[t].value;
break;
}
t--;
}
t--;
}
t = posCurr + 1;
while( t < this.content.length )
{
if(this.content[t].value.typeObj == MATH_TEXT || this.content[t].value.typeObj == MATH_COMP)
t = posCurr + 1;
while( t < this.content.length )
{
right = this.content[t].value;
break;
if(this.content[t].value.typeObj == MATH_TEXT || this.content[t].value.typeObj == MATH_COMP)
{
right = this.content[t].value;
break;
}
t++;
}
t++;
}
var coeffLeft = 0,
coeffRight = 0;
var bLeft = left !== null,
bRight = right !== null;
var coeffLeft = 0,
coeffRight = 0;
var txtPrp = this.getTxtPrp(posCurr);
var wTextRPrp = this.mergeTxtPrp(txtPrp);
var bLeft = left !== null,
bRight = right !== null;
var bLeftComp = bLeft ? left.typeObj == MATH_COMP : false,
bRightComp = bRight ? right.typeObj == MATH_COMP : false,
bLeftText = bLeft ? left.typeObj == MATH_TEXT : false,
bRightText = bRight ? right.typeObj == MATH_TEXT : false;
var txtPrp = this.getTxtPrp(posCurr);
var wTextRPrp = this.mergeTxtPrp(txtPrp);
var currCode = curr.typeObj == MATH_TEXT ? curr.getCodeChr() : null,
leftCode = bLeftText ? left.getCodeChr() : null,
rightCode = bRightText ? right.getCodeChr() : null;
var bLeftComp = bLeft ? left.typeObj == MATH_COMP : false,
bRightComp = bRight ? right.typeObj == MATH_COMP : false,
bLeftText = bLeft ? left.typeObj == MATH_TEXT : false,
bRightText = bRight ? right.typeObj == MATH_TEXT : false;
var gapLeftComp = 0,
gapRightComp = 0;
var currCode = curr.typeObj == MATH_TEXT ? curr.getCodeChr() : null,
leftCode = bLeftText ? left.getCodeChr() : null,
rightCode = bRightText ? right.getCodeChr() : null;
if(bLeftComp)
gapLeftComp = this.getGapsMComp(left).right;
var gapLeftComp = 0,
gapRightComp = 0;
if(bRightComp)
gapRightComp = this.getGapsMComp(right).left;
if(bLeftComp)
gapLeftComp = this.getGapsMComp(left).right;
if(curr.typeObj == MATH_TEXT)
{
var bSign = false;
if(bRightComp)
gapRightComp = this.getGapsMComp(right).left;
if(this.checkOperSign(currCode)) // plus, minus, greater, less
if(curr.typeObj == MATH_TEXT)
{
bSign = true;
var bSign = false;
if(bLeft)
if(this.checkOperSign(currCode)) // plus, minus, greater, less
{
if(this.checkZEROSign(leftCode))
coeffLeft = 0;
else if(leftCode == EQUAL)
coeffLeft = 0.26;
else
coeffLeft = 0.52;
}
bSign = true;
if(bRight)
{
var bZero = this.checkZEROSign(rightCode);
if(rightCode == EQUAL || bZero)
coeffRight = 0;
else
coeffRight = 0.49;
}
}
else if(currCode === MULT) // multiplication
{
bSign = true;
if(bLeft)
{
if(this.checkZEROSign(leftCode))
coeffLeft = 0;
else if(leftCode == EQUAL)
coeffLeft = 0.26;
else
coeffLeft = 0.52;
}
if(bLeft)
if(bRight)
{
var bZero = this.checkZEROSign(rightCode);
if(rightCode == EQUAL || bZero)
coeffRight = 0;
else
coeffRight = 0.49;
}
}
else if(currCode === MULT) // multiplication
{
var bZeroLeft = this.checkZEROSign(leftCode),
bOperLeft = this.checkOperSign(leftCode);
bSign = true;
if(leftCode == EQUAL || bOperLeft || bZeroLeft)
coeffLeft = 0;
else if(bLeft)
coeffLeft = 0.46;
}
if(bLeft)
{
var bZeroLeft = this.checkZEROSign(leftCode),
bOperLeft = this.checkOperSign(leftCode);
if(bRight)
{
var bZeroRight = this.checkZEROSign(rightCode),
bOperRight = this.checkOperSign(rightCode);
if(leftCode == EQUAL || bOperLeft || bZeroLeft)
coeffLeft = 0;
else if(bLeft)
coeffLeft = 0.46;
}
if(rightCode == EQUAL || bOperRight || bZeroRight)
coeffRight = 0;
else if(bRight)
coeffRight = 0.49;
}
if(bRight)
{
var bZeroRight = this.checkZEROSign(rightCode),
bOperRight = this.checkOperSign(rightCode);
}
else if(currCode === EQUAL) // equal
{
bSign = true;
if(rightCode == EQUAL || bOperRight || bZeroRight)
coeffRight = 0;
else if(bRight)
coeffRight = 0.49;
}
if(bLeft)
{
var bZero = this.checkZEROSign(leftCode);
if(leftCode == EQUAL || bZero)
coeffLeft = 0;
else if(this.checkOperSign(leftCode))
coeffLeft = 0.35;
else
coeffLeft = 0.7;
}
if(bRight)
else if(currCode === EQUAL) // equal
{
var bZero = this.checkZEROSign(rightCode);
if(rightCode == EQUAL || bZero)
coeffRight = 0;
else if(this.checkOperSign(rightCode))
coeffRight = 0.25;
else
coeffRight = 0.5;
}
}
bSign = true;
if(bLeft)
{
var bZero = this.checkZEROSign(leftCode);
if(leftCode == EQUAL || bZero)
coeffLeft = 0;
else if(this.checkOperSign(leftCode))
coeffLeft = 0.35;
else
coeffLeft = 0.7;
}
if(bSign && bLeftComp)
coeffLeft = coeffLeft - gapLeftComp;
if(bRight)
{
var bZero = this.checkZEROSign(rightCode);
if(rightCode == EQUAL || bZero)
coeffRight = 0;
else if(this.checkOperSign(rightCode))
coeffRight = 0.25;
else
coeffRight = 0.5;
}
}
if(bSign && bRightComp)
coeffRight = coeffRight - gapRightComp;
if(bSign && bLeftComp)
coeffLeft = coeffLeft - gapLeftComp;
coeffLeft = Math.ceil(coeffLeft*10)/10;
coeffRight = Math.ceil(coeffRight*10)/10;
if(bSign && bRightComp)
coeffRight = coeffRight - gapRightComp;
}
else if(curr.typeObj == MATH_COMP)
{
var currGaps = this.getGapsMComp(curr);
if(bLeft)
{
coeffLeft = currGaps.left;
coeffLeft = Math.ceil(coeffLeft*10)/10;
coeffRight = Math.ceil(coeffRight*10)/10;
if(bLeftComp)
{
if(gapLeftComp/2 < coeffLeft)
coeffLeft = gapLeftComp/2;
}
}
if(bRight)
else if(curr.typeObj == MATH_COMP)
{
coeffRight = currGaps.right;
var currGaps = this.getGapsMComp(curr);
if(bLeft)
{
coeffLeft = currGaps.left;
if(bRightComp)
if(bLeftComp)
{
if(gapLeftComp/2 < coeffLeft)
coeffLeft = gapLeftComp/2;
}
}
if(bRight)
{
if(coeffRight/2 > gapRightComp )
coeffRight -= gapRightComp;
else
coeffRight /=2;
coeffRight = currGaps.right;
if(bRightComp)
{
if(coeffRight/2 > gapRightComp )
coeffRight -= gapRightComp;
else
coeffRight /=2;
}
}
}
}
if(bLeftText)
{
if(leftCode == 0x28 || leftCode == 0x5B || leftCode == 0x7B)
coeffLeft = 0;
}
if(bLeftText)
{
if(leftCode == 0x28 || leftCode == 0x5B || leftCode == 0x7B)
coeffLeft = 0;
}
if(bRightText)
{
if(rightCode == 0x29 || rightCode == 0x5D || rightCode == 0x7D)
coeffRight = 0;
}
if(bRightText)
{
if(rightCode == 0x29 || rightCode == 0x5D || rightCode == 0x7D)
coeffRight = 0;
}
var gapSign = 0.1513*wTextRPrp.FontSize;
var gapSign = 0.1513*wTextRPrp.FontSize;
this.content[posCurr].gaps.left = Math.ceil(coeffLeft*gapSign*10)/10; // если ни один случай не выполнился, выставляем "нулевые" gaps (default): необходимо, если что-то удалили и объект стал первый или последним в контенте
this.content[posCurr].gaps.right = Math.ceil(coeffRight*gapSign*10)/10;
this.content[posCurr].gaps.left = Math.ceil(coeffLeft*gapSign*10)/10; // если ни один случай не выполнился, выставляем "нулевые" gaps (default): необходимо, если что-то удалили и объект стал первый или последним в контенте
this.content[posCurr].gaps.right = Math.ceil(coeffRight*gapSign*10)/10;
/*if(this.bRoot)
{
if(bSign)
{
var code = this.content[posCurr].value.getCodeChr();
console.log(" " + String.fromCharCode(code));
}
else if(curr.typeObj == MATH_COMP)
{
console.log(curr.constructor.name + " :")
}
/*if(this.bRoot)
{
if(bSign)
{
var code = this.content[posCurr].value.getCodeChr();
console.log(" " + String.fromCharCode(code));
}
else if(curr.typeObj == MATH_COMP)
{
console.log(curr.constructor.name + " :")
}
if(bSign || curr.typeObj == MATH_COMP)
{
console.log("coeff left " + coeffLeft + ", coeff right " + coeffRight );
console.log("gap left : " + this.content[posCurr].gaps.left + ", gap right : " + this.content[posCurr].gaps.right);
console.log("");
}
}*/
if(bSign || curr.typeObj == MATH_COMP)
{
console.log("coeff left " + coeffLeft + ", coeff right " + coeffRight );
console.log("gap left : " + this.content[posCurr].gaps.left + ", gap right : " + this.content[posCurr].gaps.right);
console.log("");
}
}*/
}
},
getGapsMComp: function(MComp)
......@@ -5153,12 +5162,13 @@ CMathContent.prototype =
return code == MULT || code == DIVISION || code == B_SLASH;
},
checkOperSign: function(code) // "+", "-", "<", ">"
checkOperSign: function(code) // "+", "-", "<", ">", "±"
{
var PLUS = 0x2B,
MINUS = 0x2212,
LESS = 0x3C,
GREATER = 0x3E;
var PLUS = 0x2B,
MINUS = 0x2212,
LESS = 0x3C,
GREATER = 0x3E,
PLUS_MINUS = 0xB1;
return code == PLUS || code == MINUS || code == LESS || code == GREATER;
},
......@@ -6586,120 +6596,9 @@ CMathContent.prototype =
}
},
Save_Changes: function(Data, Writer)
{
Writer.WriteLong( historyitem_type_Math );
var Type = Data.Type;
// Пишем тип
Writer.WriteLong( Type );
var Math = this.Composition.Parent;
switch ( Type )
{
case historyitem_Math_AddItem:
{
var bArray = Data.UseArray;
var Count = Data.Items.length;
Writer.WriteLong( Count );
for ( var Index = 0; Index < Count; Index++ )
{
if ( true === bArray )
Writer.WriteLong( Data.PosArray[Index] );
else
Writer.WriteLong( Data.Pos + Index );
Math.Write_MathElemToBinary(Writer, Data.Items[Index]);
}
break;
}
case historyitem_Math_RemoveItem:
{
/*var bArray = Data.UseArray;
var Count = Data.Items.length;
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var RealCount = Count;
for ( var Index = 0; Index < Count; Index++ )
{
if ( true === bArray )
{
if ( false === Data.PosArray[Index] )
RealCount--;
else
Writer.WriteLong( Data.PosArray[Index] );
}
else
Writer.WriteLong( Data.Pos );
}
var EndPos = Writer.GetCurPosition();
Writer.Seek( StartPos );
Writer.WriteLong( RealCount );
Writer.Seek( EndPos );
break;*/
}
}
/*var oThis = this;
this.bs = new BinaryCommonWriter(Writer);
this.boMaths = new Binary_oMathWriter(Writer);
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteArgNodes(oThis.Data);});
*/
},
Load_Changes : function(Reader)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( historyitem_type_Math != ClassType )
return;
var paraMath = this.Composition.Parent;
var Type = Reader.GetLong();
switch ( Type )
{
case historyitem_Math_AddItem:
{
var Count = Reader.GetLong();
//var oMathComp = new CMathComposition;
for ( var Index = 0; Index < Count; Index++ )
{
var Pos = Reader.GetLong()
var elem = paraMath.Read_MathElemFromBinary(Reader);
if ( null != elem )
{
//paraMath.Math.AddToComposition(Item.Math.Root);
// TODO: Подумать над тем как по минимуму вставлять отметки совместного редактирования
var Element = new mathElem(elem);
this.content.splice( Pos, 0, new ParaCollaborativeChangesEnd() );
this.content.splice( Pos, 0, Element );
this.content.splice( Pos, 0, new ParaCollaborativeChangesStart() );
CollaborativeEditing.Add_ChangedClass(this);
}
}
this.DeleteCollaborativeMarks = false;
break;
}
}
},
{
},
Refresh_RecalcData: function()
{
this.Composition.Refresh_RecalcData2(); // Refresh_RecalcData сообщает родительскому классу, что у него произошли изменения, нужно пересчитать
......@@ -7091,14 +6990,6 @@ CMathContent.prototype =
this.setEndPos_Selection(1);
//this.setEnd_Selection(1);
//this.selection.active = false;
},
Get_Id : function()
{
return this.GetId();
},
GetId : function()
{
return this.Id;
}
/////////////////////////////////////////////////////////////////
......@@ -7154,10 +7045,6 @@ function CMathComposition()
};
this.Init();
//для совместного редактирования каждый элемент записываем в глобальную таблицу
//this.Id = g_oIdCounter.Get_NewId();
//g_oTableId.Add( this, this.Id );
}
CMathComposition.prototype =
{
......@@ -7907,8 +7794,6 @@ CMathComposition.prototype =
var Pos = this.SelectContent.CurPos,
EndPos = this.SelectContent.CurPos + 1;
//для совместного редактирования
this.CurrentContent.Id = this.Id;
History.Add(this.CurrentContent, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: EndPos});
},
CreateEquation: function(indef)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment