Commit d124d726 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander.Trofimov

Переделана работа с настройками текста в формулах, переделана компиляция настроек.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58753 954022d7-b5bf-4e40-9824-e11837661b57
parent a784ae8d
...@@ -8,6 +8,10 @@ var Math_Date_Draw = 0;*/ ...@@ -8,6 +8,10 @@ var Math_Date_Draw = 0;*/
/** /**
* Created by Ilja.Kirillov on 18.03.14. * Created by Ilja.Kirillov on 18.03.14.
*/ */
var g_dMathArgSizeKoeff_1 = 0.76;
var g_dMathArgSizeKoeff_2 = 0.76 * 0.855;
var g_oMathSettings = {}; var g_oMathSettings = {};
function MathMenu (type) function MathMenu (type)
{ {
...@@ -103,6 +107,7 @@ ParaMath.prototype.Copy = function(Selected) ...@@ -103,6 +107,7 @@ ParaMath.prototype.Copy = function(Selected)
/// argSize, bDot и bRoot выставить на объединении контентов /// argSize, bDot и bRoot выставить на объединении контентов
NewMath.SetNeedResize(); NewMath.SetNeedResize();
NewMath.Root.Correct_Content(true);
return NewMath; return NewMath;
}; };
...@@ -984,49 +989,19 @@ ParaMath.prototype.MathToImageConverter= function() ...@@ -984,49 +989,19 @@ ParaMath.prototype.MathToImageConverter= function()
return _ret; return _ret;
}; };
ParaMath.prototype.ApplyArgSize = function(oWPrp, argSize) ParaMath.prototype.ApplyArgSize = function(FontSize, argSize)
{
var tPrp = new CTextPr();
tPrp.Merge(this.DefaultTextPr);
tPrp.Merge(oWPrp);
//var FSize = tPrp.FontSize;
if(argSize == -1)
{
//FSize = 0.0009*FSize*FSize + 0.68*FSize + 0.26;
tPrp.FontSize = 0.76*tPrp.FontSize;
tPrp.FontSizeCS = 0.76*tPrp.FontSizeCS;
}
else if(argSize == -2)
{
//FSize = -0.0004*FSize*FSize + 0.66*FSize + 0.87;
tPrp.FontSize = 0.76*0.855*tPrp.FontSize;
tPrp.FontSizeCS = 0.76*0.855*tPrp.FontSizeCS;
}
//tPrp.FontSize = FSize;
oWPrp.Merge(tPrp);
};
ParaMath.prototype.ApplyArgSize_2 = function(oWPrp, argSize)
{ {
var ResultFontSize = FontSize;
if(argSize == -1) if(argSize == -1)
{ {
//FSize = 0.0009*FSize*FSize + 0.68*FSize + 0.26; ResultFontSize *= g_dMathArgSizeKoeff_1;
oWPrp.FontSize = 0.76*oWPrp.FontSize;
oWPrp.FontSizeCS = 0.76*oWPrp.FontSizeCS;
} }
else if(argSize == -2) else if(argSize == -2)
{ {
//FSize = -0.0004*FSize*FSize + 0.66*FSize + 0.87; ResultFontSize *= g_dMathArgSizeKoeff_2;
oWPrp.FontSize = 0.76*0.855*oWPrp.FontSize;
oWPrp.FontSizeCS = 0.76*0.855*oWPrp.FontSizeCS;
} }
return ResultFontSize;
}; };
ParaMath.prototype.GetFirstRPrp = function() ParaMath.prototype.GetFirstRPrp = function()
...@@ -1143,45 +1118,7 @@ ParaMath.prototype.GetMathPr = function() ...@@ -1143,45 +1118,7 @@ ParaMath.prototype.GetMathPr = function()
ParaMath.prototype.Get_Default_TPrp = function() ParaMath.prototype.Get_Default_TPrp = function()
{ {
/*var TextPrp = new CTextPr(); return this.DefaultTextPr;
TextPrp.Init_Default();
var mathFont = new CTextPr();
var obj =
{
FontFamily: {Name : "Cambria Math", Index : -1 },
RFonts:
{
Ascii: {Name : "Cambria Math", Index : -1 }
}
};
mathFont.Set_FromObject(obj);
TextPrp.Merge(mathFont);*/
/*var DefaultPrp =
{
FontFamily: {Name : "Cambria Math", Index : -1 },
RFonts:
{
Ascii: {Name : "Cambria Math", Index : -1 }
},
FontSize: 11,
FontSizeCS: 11,
Italic: true,
Bold: false
};
TextPrp.Set_FromObject(DefaultPrp);*/
var DefaultTextPrp = this.DefaultTextPr.Copy();
DefaultTextPrp.Italic = false;
return DefaultTextPrp;
}; };
ParaMath.prototype.Set_Select_ToMComp = function(Direction) ParaMath.prototype.Set_Select_ToMComp = function(Direction)
......
...@@ -40,6 +40,7 @@ function ParaRun(Paragraph, bMathRun) ...@@ -40,6 +40,7 @@ function ParaRun(Paragraph, bMathRun)
{ {
this.Type = para_Math_Run; this.Type = para_Math_Run;
this.ParaMath = null;
this.Parent = null; this.Parent = null;
this.ArgSize = 0; this.ArgSize = 0;
this.bEqqArray = false; this.bEqqArray = false;
...@@ -1175,16 +1176,16 @@ ParaRun.prototype.Create_FontMap = function(Map, ArgSize) ...@@ -1175,16 +1176,16 @@ ParaRun.prototype.Create_FontMap = function(Map, ArgSize)
if(this.Type === para_Math_Run) if(this.Type === para_Math_Run)
{ {
TextPr = this.Get_CompiledPr(false); TextPr = this.Get_CompiledPr(false);
FontSize = TextPr.FontSize; FontSize = TextPr.FontSize;
FontSizeCS = TextPr.FontSizeCS;
if(this.Parent !== null) if(this.Parent !== null)
this.Parent.ParaMath.ApplyArgSize_2(TextPr, ArgSize.value); TextPr.FontSize = this.Parent.ParaMath.ApplyArgSize(TextPr.FontSize, ArgSize.value);
} }
else else
TextPr = this.Get_CompiledPr(false); TextPr = this.Get_CompiledPr(false);
TextPr.Document_CreateFontMap( Map, this.Paragraph.Get_Theme().themeElements.fontScheme); TextPr.Document_CreateFontMap(Map, this.Paragraph.Get_Theme().themeElements.fontScheme);
var Count = this.Content.length; var Count = this.Content.length;
for (var Index = 0; Index < Count; Index++) for (var Index = 0; Index < Count; Index++)
{ {
...@@ -4604,6 +4605,15 @@ ParaRun.prototype.Internal_Compile_Pr = function () ...@@ -4604,6 +4605,15 @@ ParaRun.prototype.Internal_Compile_Pr = function ()
if(this.Type == para_Math_Run) if(this.Type == para_Math_Run)
{ {
if (undefined === this.Parent || null === this.Parent)
{
// Сюда мы никогда не должны попадать, но на всякий случай,
// чтобы не выпадало ошибок сгенерим дефолтовые настройки
var TextPr = new CTextPr();
TextPr.Init_Default();
return new CTextPr();
}
// Not Apply ArgSize ! // Not Apply ArgSize !
var oWPrp = this.Parent.Get_Default_TPrp(); var oWPrp = this.Parent.Get_Default_TPrp();
TextPr.Merge(oWPrp); TextPr.Merge(oWPrp);
...@@ -7731,44 +7741,30 @@ ParaRun.prototype.Math_Draw = function(x, y, pGraphics) ...@@ -7731,44 +7741,30 @@ ParaRun.prototype.Math_Draw = function(x, y, pGraphics)
var Y = y + this.size.ascent; var Y = y + this.size.ascent;
var oWPrp = this.Get_CompiledPr(false); var oWPrp = this.Get_CompiledPr(false);
var Bold = oWPrp.Bold,
Italic = oWPrp.Italic;
var FontFamily = oWPrp.FontFamily,
FontSize = oWPrp.FontSize,
FontSizeCS = oWPrp.FontSizeCS,
RFonts = oWPrp.RFonts.Copy();
this.Parent.ParaMath.ApplyArgSize_2(oWPrp, this.Parent.Compiled_ArgSz.value); var Font =
{
Bold : oWPrp.Bold,
Italic : oWPrp.Italic,
FontFamily : {Name : oWPrp.FontFamily.Name, Index : oWPrp.FontFamily.Index},
FontSize : this.Parent.ParaMath.ApplyArgSize(oWPrp.FontSize, this.Parent.Compiled_ArgSz.value)
};
if(!this.IsNormalText()) // выставляем false, чтобы не применился наклон к спец символам if(!this.IsNormalText()) // выставляем false, чтобы не применился наклон к спец символам
{ {
oWPrp.Italic = false; Font.Italic = false;
oWPrp.Bold = false; Font.Bold = false;
// TO DO
// реализовать получше
// пока так
var defaultTxtPrp = this.Parent.ParaMath.Get_Default_TPrp(); var defaultTxtPrp = this.Parent.ParaMath.Get_Default_TPrp();
Font.FontFamily.Name = defaultTxtPrp.FontFamily.Name;
oWPrp.FontFamily = defaultTxtPrp.FontFamily; Font.FontFamily.Index = defaultTxtPrp.FontFamily.Index;
oWPrp.RFonts.Set_All(defaultTxtPrp.FontFamily.Name, defaultTxtPrp.FontFamily.Index);
} }
pGraphics.SetFont(oWPrp); pGraphics.SetFont(Font);
pGraphics.b_color1(0,0,0,255); pGraphics.b_color1(0,0,0,255);
for(var i=0; i < this.Content.length;i++) for(var i=0; i < this.Content.length;i++)
this.Content[i].draw(X, Y, pGraphics); this.Content[i].draw(X, Y, pGraphics);
oWPrp.RFonts = RFonts;
oWPrp.FontFamily = FontFamily;
oWPrp.Bold = Bold;
oWPrp.Italic = Italic;
oWPrp.FontSize = FontSize;
oWPrp.FontSizeCS = FontSizeCS;
} }
ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI, ArgSize, WidthPoints) ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI, ArgSize, WidthPoints)
{ {
...@@ -7797,34 +7793,28 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI, ...@@ -7797,34 +7793,28 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI,
if(RPI.NeedResize) if(RPI.NeedResize)
{ {
//RPI.UpdateMathPr = this.UpdateMathPr;
var oWPrp = this.Get_CompiledPr(false); var oWPrp = this.Get_CompiledPr(false);
var Bold = oWPrp.Bold;
var Italic = oWPrp.Italic;
var FontFamily = oWPrp.FontFamily,
FontSize = oWPrp.FontSize,
FontSizeCS = oWPrp.FontSizeCS,
RFonts = oWPrp.RFonts.Copy();
this.Parent.ParaMath.ApplyArgSize_2(oWPrp, this.Parent.Compiled_ArgSz.value); var Font =
{
Bold : oWPrp.Bold,
Italic : oWPrp.Italic,
FontFamily : {Name : oWPrp.FontFamily.Name, Index : oWPrp.FontFamily.Index},
FontSize : this.Parent.ParaMath.ApplyArgSize(oWPrp.FontSize, this.Parent.Compiled_ArgSz.value)
};
if(!this.IsNormalText()) // выставляем false, чтобы не применился наклон к спец символам if(!this.IsNormalText()) // выставляем false, чтобы не применился наклон к спец символам
{ {
oWPrp.Italic = false; Font.Italic = false;
oWPrp.Bold = false; Font.Bold = false;
var defaultTxtPrp = this.Parent.ParaMath.Get_Default_TPrp(); var defaultTxtPrp = this.Parent.ParaMath.Get_Default_TPrp();
Font.FontFamily.Name = defaultTxtPrp.FontFamily.Name;
oWPrp.FontFamily = defaultTxtPrp.FontFamily; Font.FontFamily.Index = defaultTxtPrp.FontFamily.Index;
oWPrp.RFonts.Set_All(defaultTxtPrp.FontFamily.Name, defaultTxtPrp.FontFamily.Index);
} }
g_oTextMeasurer.SetFont(oWPrp); g_oTextMeasurer.SetFont(Font);
this.bEqqArray = RPI.bEqqArray; this.bEqqArray = RPI.bEqqArray;
...@@ -7863,17 +7853,6 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI, ...@@ -7863,17 +7853,6 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI,
this.size.ascent = ascent; this.size.ascent = ascent;
this.size.height = ascent + descent; this.size.height = ascent + descent;
oWPrp.RFonts = RFonts;
oWPrp.FontFamily = FontFamily;
oWPrp.Bold = Bold;
oWPrp.Italic = Italic;
oWPrp.FontSize = FontSize;
oWPrp.FontSizeCS = FontSizeCS;
//this.UpdateMathPr = false;
} }
} }
ParaRun.prototype.Math_Update_Cursor = function(X, Y, CurPage, UpdateTarget) ParaRun.prototype.Math_Update_Cursor = function(X, Y, CurPage, UpdateTarget)
......
...@@ -131,6 +131,8 @@ CMathBase.prototype = ...@@ -131,6 +131,8 @@ CMathBase.prototype =
},*/ },*/
Get_CompiledCtrPrp: function() Get_CompiledCtrPrp: function()
{ {
this.Set_CompiledCtrPrp(this.ParaMath);
var CompiledCtrPrp; var CompiledCtrPrp;
if(this.bInside === true) if(this.bInside === true)
...@@ -140,15 +142,17 @@ CMathBase.prototype = ...@@ -140,15 +142,17 @@ CMathBase.prototype =
else else
{ {
CompiledCtrPrp = this.Get_CompiledCtrPrp_2(); CompiledCtrPrp = this.Get_CompiledCtrPrp_2();
this.ParaMath.ApplyArgSize(CompiledCtrPrp, this.Parent.Get_CompiledArgSize().value); CompiledCtrPrp.FontSize = this.ParaMath.ApplyArgSize(CompiledCtrPrp.FontSize, this.Parent.Get_CompiledArgSize().value);
} }
this.ParaMath.ApplyArgSize(CompiledCtrPrp, this.ArgSize.value); // для настроек inline формул CompiledCtrPrp.FontSize = this.ParaMath.ApplyArgSize(CompiledCtrPrp.FontSize, this.ArgSize.value);// для настроек inline формул
return CompiledCtrPrp; return CompiledCtrPrp;
}, },
Get_CompiledCtrPrp_2: function() // without arg Size Get_CompiledCtrPrp_2: function() // without arg Size
{ {
this.Set_CompiledCtrPrp(this.ParaMath);
var CompiledCtrPrp; var CompiledCtrPrp;
if(this.bInside === true) if(this.bInside === true)
...@@ -396,15 +400,9 @@ CMathBase.prototype = ...@@ -396,15 +400,9 @@ CMathBase.prototype =
{ {
if(this.RecalcInfo.bCtrPrp == true) if(this.RecalcInfo.bCtrPrp == true)
{ {
var defaultRPrp = ParaMath.GetFirstRPrp(); this.CompiledCtrPrp = ParaMath.GetFirstRPrp();
this.CompiledCtrPrp.Merge(defaultRPrp);
this.CompiledCtrPrp.Merge(this.CtrPrp); this.CompiledCtrPrp.Merge(this.CtrPrp);
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
if(this.elements[i][j].Type === para_Math_Composition)
this.elements[i][j].Set_CompiledCtrPrp(ParaMath);
this.RecalcInfo.bCtrPrp = false; this.RecalcInfo.bCtrPrp = false;
} }
}, },
......
...@@ -45,7 +45,7 @@ CFraction.prototype.drawBarFraction = function(x, y, pGraphics) ...@@ -45,7 +45,7 @@ CFraction.prototype.drawBarFraction = function(x, y, pGraphics)
{ {
//var mgCtrPrp = this.Get_CompiledCtrPrp(); //var mgCtrPrp = this.Get_CompiledCtrPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp_2(); var mgCtrPrp = this.Get_CompiledCtrPrp_2();
this.ParaMath.ApplyArgSize(mgCtrPrp, this.Parent.Get_CompiledArgSize().value); mgCtrPrp.FontSize = this.ParaMath.ApplyArgSize(mgCtrPrp.FontSize, this.Parent.Get_CompiledArgSize().value);
var penW = mgCtrPrp.FontSize* 25.4/96 * 0.08; var penW = mgCtrPrp.FontSize* 25.4/96 * 0.08;
......
...@@ -1010,9 +1010,10 @@ CMathContent.prototype = ...@@ -1010,9 +1010,10 @@ CMathContent.prototype =
for(var pos = 0; pos < lng; pos++) for(var pos = 0; pos < lng; pos++)
{ {
this.content[pos].ParaMath = ParaMath;
if(this.content[pos].Type == para_Math_Composition) if(this.content[pos].Type == para_Math_Composition)
{ {
this.content[pos].Set_CompiledCtrPrp(this.ParaMath);
this.content[pos].SetGaps(GapsInfo); this.content[pos].SetGaps(GapsInfo);
} }
else if(this.content[pos].Type == para_Math_Run) else if(this.content[pos].Type == para_Math_Run)
...@@ -1106,7 +1107,6 @@ CMathContent.prototype = ...@@ -1106,7 +1107,6 @@ CMathContent.prototype =
if(this.content[pos].Type == para_Math_Composition) if(this.content[pos].Type == para_Math_Composition)
{ {
this.content[pos].Set_CompiledCtrPrp(this.ParaMath);
this.content[pos].SetGaps(GapsInfo); this.content[pos].SetGaps(GapsInfo);
} }
else if(this.content[pos].Type == para_Math_Run) else if(this.content[pos].Type == para_Math_Run)
......
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