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

1. Ускорила перерасчет формул при добавление букв

2. Поправила баг : неправильно брались ctrPrp для дроби, когда из не inline формулы делали inline, а потом снова inline

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58651 954022d7-b5bf-4e40-9824-e11837661b57
parent cb944de1
"use strict"; "use strict";
/*var Math_Draw_Time = false;
var Math_Date = 0;
var Math_NeedResize = true;
var Math_Date_Draw = 0;*/
/** /**
* Created by Ilja.Kirillov on 18.03.14. * Created by Ilja.Kirillov on 18.03.14.
*/ */
...@@ -40,6 +45,7 @@ function ParaMath() ...@@ -40,6 +45,7 @@ function ParaMath()
//this.CurrentContent = this.RootComposition; //this.CurrentContent = this.RootComposition;
//this.SelectContent = this.RootComposition; //this.SelectContent = this.RootComposition;
this.NeedResize = true;
this.bSelectionUse = false; this.bSelectionUse = false;
...@@ -155,6 +161,8 @@ ParaMath.prototype.Get_CompiledTextPr = function(Copy) ...@@ -155,6 +161,8 @@ ParaMath.prototype.Get_CompiledTextPr = function(Copy)
ParaMath.prototype.Add = function(Item) ParaMath.prototype.Add = function(Item)
{ {
this.NeedResize = true;
var Type = Item.Type; var Type = Item.Type;
var oContent = this.GetSelectContent(); var oContent = this.GetSelectContent();
var oStartContent = oContent.Content.content[oContent.Start]; var oStartContent = oContent.Content.content[oContent.Start];
...@@ -226,6 +234,7 @@ ParaMath.prototype.Add = function(Item) ...@@ -226,6 +234,7 @@ ParaMath.prototype.Add = function(Item)
ParaMath.prototype.Remove = function(Direction, bOnAddText) ParaMath.prototype.Remove = function(Direction, bOnAddText)
{ {
this.NeedResize = true;
var oSelectedContent = this.GetSelectContent(); var oSelectedContent = this.GetSelectContent();
var nStartPos = oSelectedContent.Start; var nStartPos = oSelectedContent.Start;
...@@ -534,29 +543,37 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -534,29 +543,37 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
var ParaLine = PRS.Line; var ParaLine = PRS.Line;
var ParaRange = PRS.Range; var ParaRange = PRS.Range;
var TextPr = new CTextPr();
TextPr.Init_Default();
var RPI = new CRPI(); var RPI = new CRPI();
RPI.bInline = this.MathPara === false; RPI.bInline = this.MathPara === false;
RPI.bChangeInline = this.MathPara != this.OldMathPara; RPI.bChangeInline = this.MathPara != this.OldMathPara;
RPI.NeedResize = this.NeedResize;
var ArgSize = new CMathArgSize(); var ArgSize = new CMathArgSize();
if(PRS.NewRange == false) if(PRS.NewRange == false)
this.Root.Recalculate_Reset(PRS.Range, PRS.Line); this.Root.Recalculate_Reset(PRS.Range, PRS.Line);
this.Root.Resize(g_oTextMeasurer, null, this, RPI/*recalculate properties info*/, ArgSize, TextPr); if(RPI.NeedResize)
{
this.Root.Resize(g_oTextMeasurer, null, this, RPI/*recalculate properties info*/, ArgSize);
// когда формула будеат разбиваться на строки, Position придется перерасчитывать
var pos = new CMathPosition();
pos.x = 0;
pos.y = 0;
//this.Root.Resize(null, this, g_oTextMeasurer, RPI/*recalculate properties info*/, TextPr); this.Root.setPosition(pos);
this.OldMathPara = this.MathPara; }
else
this.Root.Resize_2(g_oTextMeasurer, null, this, RPI/*recalculate properties info*/, ArgSize);
var pos = new CMathPosition(); this.NeedResize = false;
pos.x = 0;
pos.y = 0; this.OldMathPara = this.MathPara;
//this.Root.Resize(null, this, g_oTextMeasurer, RPI/*recalculate properties info*/, TextPr);
this.Root.setPosition(pos);
this.Width = this.Root.size.width; this.Width = this.Root.size.width;
this.Height = this.Root.size.height; this.Height = this.Root.size.height;
...@@ -662,6 +679,7 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -662,6 +679,7 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
} }
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos); this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
}; };
...@@ -908,6 +926,11 @@ ParaMath.prototype.Shift_Range = function(Dx, Dy, _CurLine, _CurRange) ...@@ -908,6 +926,11 @@ ParaMath.prototype.Shift_Range = function(Dx, Dy, _CurLine, _CurRange)
// Функция для работы с формулой // Функция для работы с формулой
// в тч с дефолтными текстовыми настройками и argSize // в тч с дефолтными текстовыми настройками и argSize
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
ParaMath.prototype.SetInline = function(value)
{
this.bInline = value;
this.NeedResize = true;
};
ParaMath.prototype.MathToImageConverter= function() ParaMath.prototype.MathToImageConverter= function()
{ {
window.IsShapeToImageConverter = true; window.IsShapeToImageConverter = true;
...@@ -975,23 +998,23 @@ ParaMath.prototype.ApplyArgSize = function(oWPrp, argSize) ...@@ -975,23 +998,23 @@ ParaMath.prototype.ApplyArgSize = function(oWPrp, argSize)
oWPrp.Merge(tPrp); oWPrp.Merge(tPrp);
}; };
ParaMath.prototype.ApplyArgSize_2 = function(oWPrp, argSize)
{
if(argSize == -1)
{
//FSize = 0.0009*FSize*FSize + 0.68*FSize + 0.26;
oWPrp.FontSize = 0.76*oWPrp.FontSize;
oWPrp.FontSizeCS = 0.76*oWPrp.FontSizeCS;
}
else if(argSize == -2)
{
//FSize = -0.0004*FSize*FSize + 0.66*FSize + 0.87;
oWPrp.FontSize = 0.76*0.855*oWPrp.FontSize;
oWPrp.FontSizeCS = 0.76*0.855*oWPrp.FontSizeCS;
}
/*ParaMath.prototype.GetDefaultTxtPrp= function()
{
var txtPrp = new CTextPr();
var defaultTxtPr =
{
FontFamily: {Name : "Cambria Math", Index : -1 },
FontSize: 11,
Italic: true,
Bold: false
};
txtPrp.Set_FromObject(defaultTxtPr);
return txtPrp; };
};*/
ParaMath.prototype.GetFirstRPrp = function() ParaMath.prototype.GetFirstRPrp = function()
{ {
...@@ -1596,4 +1619,5 @@ ParaMath.prototype.Get_ContentSelection = function() ...@@ -1596,4 +1619,5 @@ ParaMath.prototype.Get_ContentSelection = function()
return null; return null;
return {X : oContent.pos.x + this.X, Y : oContent.pos.y + this.Y, W : oContent.size.width, H : oContent.size.height}; return {X : oContent.pos.x + this.X, Y : oContent.pos.y + this.Y, W : oContent.size.width, H : oContent.size.height};
}; };
\ No newline at end of file
This diff is collapsed.
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
function CMathBase(bInside) function CMathBase(bInside)
{ {
//this.typeObj = MATH_COMP;
this.Type = para_Math_Composition; this.Type = para_Math_Composition;
this.pos = new CMathPosition(); this.pos = new CMathPosition();
...@@ -37,7 +36,6 @@ function CMathBase(bInside) ...@@ -37,7 +36,6 @@ function CMathBase(bInside)
}; };
this.bSelectionUse = false; this.bSelectionUse = false;
this.bInsideUpperSelect = false;
this.nRow = 0; this.nRow = 0;
this.nCol = 0; this.nCol = 0;
...@@ -384,6 +382,13 @@ CMathBase.prototype = ...@@ -384,6 +382,13 @@ CMathBase.prototype =
this.recalculateSize(oMeasure, RPI); this.recalculateSize(oMeasure, RPI);
}, },
Resize_2: function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
if(!this.elements[i][j].IsJustDraw())
this.elements[i][j].Resize_2(oMeasure, this, ParaMath, RPI, ArgSize);
},
Set_CompiledCtrPrp: function(ParaMath) Set_CompiledCtrPrp: function(ParaMath)
{ {
if(this.RecalcInfo.bCtrPrp == true) if(this.RecalcInfo.bCtrPrp == true)
......
...@@ -456,17 +456,6 @@ CBox.prototype.fillContent = function() ...@@ -456,17 +456,6 @@ CBox.prototype.fillContent = function()
this.setDimension(1, 1); this.setDimension(1, 1);
this.setContent(); this.setContent();
} }
CBox.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{
//this.Set_CompiledCtrPrp(ParaMath);
var ArgSizeBox = ArgSize.Copy();
/*if(this.Pr.opEmu)
ArgSizeBox.decrease();*/
CBox.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSizeBox);
}
CBox.prototype.setProperties = function(props) CBox.prototype.setProperties = function(props)
{ {
if(props.opEmu === true || props.opEmu === false) if(props.opEmu === true || props.opEmu === false)
......
...@@ -225,6 +225,10 @@ CFraction.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -225,6 +225,10 @@ CFraction.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{ {
this.ArgSize.SetValue(-1); // для CtrPrp this.ArgSize.SetValue(-1); // для CtrPrp
} }
else
{
this.ArgSize.SetValue(0);
}
if(this.Pr.type == NO_BAR_FRACTION) if(this.Pr.type == NO_BAR_FRACTION)
{ {
......
...@@ -37,6 +37,8 @@ var historyitem_Math_CtrPrpFSize = 3; // CtrPrp ...@@ -37,6 +37,8 @@ var historyitem_Math_CtrPrpFSize = 3; // CtrPrp
function CRPI() function CRPI()
{ {
//this.UpdateMathPr = true;
this.NeedResize = true;
this.bInsideFraction = false; this.bInsideFraction = false;
this.bInline = false; this.bInline = false;
this.bChangeInline = false; this.bChangeInline = false;
...@@ -4030,6 +4032,17 @@ CMathContent.prototype = ...@@ -4030,6 +4032,17 @@ CMathContent.prototype =
this.size.height = SizeDescent < oDescent ? oDescent + this.size.ascent : SizeDescent + this.size.ascent; this.size.height = SizeDescent < oDescent ? oDescent + this.size.ascent : SizeDescent + this.size.ascent;
} }
}, },
Resize_2: function(oMeasure, Parent, ParaMath, RPI, ArgSize) // особый случай: вызываем, когда пересчет всей формулы не нужен, а нужно выставить только Lines (Реализована, чтобы не править Resize у каждого элемента)
{
var lng = this.content.length;
for(var i = 0; i < lng; i++)
{
if(this.content[i].Type == para_Math_Composition)
this.content[i].Resize_2(oMeasure, this, ParaMath, RPI, ArgSize);
else
this.content[i].Math_Recalculate(oMeasure, this, ParaMath.Paragraph, RPI, ArgSize, null);
}
},
M_Resize: function(oMeasure, Parent, ParaMath, RPI, ArgSize) // если делать один цикл for для Resize, то надо избавиться от WidthToElement, M_Resize: function(oMeasure, Parent, ParaMath, RPI, ArgSize) // если делать один цикл for для Resize, то надо избавиться от WidthToElement,
// т.к. корректно рассчитывать не получается, либо выставлять WidthToElement для пустыx Run (которые идут после мат объекта) на recalculateSize_2 мат объекта // т.к. корректно рассчитывать не получается, либо выставлять WidthToElement для пустыx Run (которые идут после мат объекта) на recalculateSize_2 мат объекта
{ {
...@@ -5062,7 +5075,6 @@ CMathContent.prototype = ...@@ -5062,7 +5075,6 @@ CMathContent.prototype =
var len = this.content.length - 1; var len = this.content.length - 1;
this.CurPos = len; this.CurPos = len;
this.content[len].Cursor_MoveToEndPos(SelectFromEnd); this.content[len].Cursor_MoveToEndPos(SelectFromEnd);
} }
}, },
......
...@@ -38,15 +38,30 @@ CMathSize.prototype.SetZero = function() ...@@ -38,15 +38,30 @@ CMathSize.prototype.SetZero = function()
this.ascent = 0; this.ascent = 0;
} }
function CMathRecalcTextInfo()
{
this.StyleCode = null;
this.bAccentIJ = false;
}
function CMathText(bJDraw) function CMathText(bJDraw)
{ {
// для Para_Run // для Para_Run
this.Type = para_Math_Text; this.Type = para_Math_Text;
this.bJDraw = bJDraw; this.bJDraw = bJDraw;
this.size = new CMathSize();
this.value = null; this.value = null;
this.RecalcInfo =
{
//NewLetter: true,
StyleCode: null,
bAccentIJ: false
};
this.Parent = null; this.Parent = null;
this.size = new CMathSize();
this.pos = new CMathPosition(); this.pos = new CMathPosition();
this.rasterOffsetX = 0; this.rasterOffsetX = 0;
...@@ -547,10 +562,19 @@ CMathText.prototype = ...@@ -547,10 +562,19 @@ CMathText.prototype =
var letter = this.getCode(); var letter = this.getCode();
var bAccentIJ = this.bJDraw ? false : this.Parent.IsAccent(); /*if(this.bJDraw)
letter = this.code;
else if(RPI.UpdateMathPr || Math_NeedResize == false || this.RecalcInfo.NewLetter == true)
letter = this.getCode();
else
letter = this.RecalcInfo.StyleCode;*/
var bAccentIJ = this.bJDraw ? false : this.Parent.IsAccent();
bAccentIJ = bAccentIJ && (this.value == 0x69 || this.value == 0x6A); bAccentIJ = bAccentIJ && (this.value == 0x69 || this.value == 0x6A);
this.RecalcInfo.StyleCode = letter;
this.RecalcInfo.bAccentIJ = bAccentIJ;
if(bAccentIJ) if(bAccentIJ)
oMeasure.SetStringGid(true); oMeasure.SetStringGid(true);
...@@ -576,17 +600,14 @@ CMathText.prototype = ...@@ -576,17 +600,14 @@ CMathText.prototype =
if(this.bJDraw) if(this.bJDraw)
width = metricsTxt.WidthG; width = metricsTxt.WidthG;
//width = metricsTxt.WidthG + this.GapLeft + this.GapRight;
else else
width = metricsTxt.Width; width = metricsTxt.Width;
//width = metricsTxt.Width + this.GapLeft + this.GapRight;
this.size.width = this.GapLeft + this.GapRight + width; this.size.width = this.GapLeft + this.GapRight + width;
this.size.height = height; this.size.height = height;
this.size.ascent = ascent; this.size.ascent = ascent;
//this.RecalcInfo.NewLetter = false;
//this.size = {width: width, widthG: width, height: height, ascent: ascent};
}, },
Get_WidthVisible: function() Get_WidthVisible: function()
{ {
...@@ -622,12 +643,12 @@ CMathText.prototype = ...@@ -622,12 +643,12 @@ CMathText.prototype =
pGraphics.transform(sx, shy, shx, sy, 0, 0);*/ pGraphics.transform(sx, shy, shx, sy, 0, 0);*/
var bAccent = this.bJDraw ? false : this.Parent.IsAccent();
if(bAccent && (this.value == 0x69 || this.value == 0x6A)) if(this.RecalcInfo.bAccentIJ)
pGraphics.tg(this.getCode(), X, Y); pGraphics.tg(this.RecalcInfo.StyleCode, X, Y);
else else
pGraphics.FillTextCode(X, Y, this.getCode()); //на отрисовку символа отправляем положение baseLine pGraphics.FillTextCode(X, Y, this.RecalcInfo.StyleCode); //на отрисовку символа отправляем положение baseLine
}, },
setPosition: function(pos) setPosition: function(pos)
......
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