Commit afced9bd authored by Anna.Pavlova's avatar Anna.Pavlova

1. Сделала для спец символов (для математического текста) отрисовку всегда в Cambria Marh

2. Поправила заливку в формулах для случаев, когда находимся в верхнем контенте, также возвращаю Y0, Y1 (границы заливки) такие же, которые пришли формулу (http://bugzserver/show_bug.cgi?id=27638)
3. Поправила баг с пересчетом ctrPrp для дроби при смене инлайновости (http://bugzserver/show_bug.cgi?id=27644)
4. Убрала отрисовку лишнего символа (http://bugzserver/show_bug.cgi?id=26877)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@59794 954022d7-b5bf-4e40-9824-e11837661b57
parent 5217ef10
...@@ -1308,6 +1308,8 @@ ParaMath.prototype.Draw_HighLights = function(PDSH) ...@@ -1308,6 +1308,8 @@ ParaMath.prototype.Draw_HighLights = function(PDSH)
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange); var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
var X = PDSH.X; var X = PDSH.X;
var Y0 = PDSH.Y0;
var Y1 = PDSH.Y1;
if ( EndPos >= 1 ) if ( EndPos >= 1 )
{ {
...@@ -1338,6 +1340,9 @@ ParaMath.prototype.Draw_HighLights = function(PDSH) ...@@ -1338,6 +1340,9 @@ ParaMath.prototype.Draw_HighLights = function(PDSH)
Coll.Add(Bounds.Y, Bounds.Y + Bounds.H, Bounds.X, Bounds.X + Bounds.W, 0, CollFirst.r, CollFirst.g, CollFirst.b); Coll.Add(Bounds.Y, Bounds.Y + Bounds.H, Bounds.X, Bounds.X + Bounds.W, 0, CollFirst.r, CollFirst.g, CollFirst.b);
} }
} }
PDSH.Y0 = Y0;
PDSH.Y1 = Y1;
}; };
ParaMath.prototype.Draw_Elements = function(PDSE) ParaMath.prototype.Draw_Elements = function(PDSE)
{ {
...@@ -1983,6 +1988,8 @@ var historyitem_Math_CtrPrpUnifill = 9; ...@@ -1983,6 +1988,8 @@ var historyitem_Math_CtrPrpUnifill = 9;
var historyitem_Math_CtrPrpUnderline = 10; var historyitem_Math_CtrPrpUnderline = 10;
var historyitem_Math_CtrPrpStrikeout = 11; var historyitem_Math_CtrPrpStrikeout = 11;
var historyitem_Math_CtrPrpDoubleStrikeout = 12; var historyitem_Math_CtrPrpDoubleStrikeout = 12;
var historyitem_Math_CtrPrpItalic = 13;
var historyitem_Math_CtrPrpBold = 14;
function ReadChanges_FromBinary(Reader, Class) function ReadChanges_FromBinary(Reader, Class)
...@@ -2001,6 +2008,8 @@ function ReadChanges_FromBinary(Reader, Class) ...@@ -2001,6 +2008,8 @@ function ReadChanges_FromBinary(Reader, Class)
case historyitem_Math_CtrPrpUnderline : Changes = new CChangesMathUnderline(); break; case historyitem_Math_CtrPrpUnderline : Changes = new CChangesMathUnderline(); break;
case historyitem_Math_CtrPrpStrikeout : Changes = new CChangesMathStrikeout(); break; case historyitem_Math_CtrPrpStrikeout : Changes = new CChangesMathStrikeout(); break;
case historyitem_Math_CtrPrpDoubleStrikeout : Changes = new CChangesMath_DoubleStrikeout(); break; case historyitem_Math_CtrPrpDoubleStrikeout : Changes = new CChangesMath_DoubleStrikeout(); break;
case historyitem_Math_CtrPrpItalic : Changes = new CChangesMathItalic(); break;
case historyitem_Math_CtrPrpBold : Changes = new CChangesMathBold(); break;
} }
if (null !== Changes) if (null !== Changes)
...@@ -2311,6 +2320,91 @@ CChangesMath_DoubleStrikeout.prototype.Load_Changes = function(Reader, Class) ...@@ -2311,6 +2320,91 @@ CChangesMath_DoubleStrikeout.prototype.Load_Changes = function(Reader, Class)
this.Redo(Class); this.Redo(Class);
}; };
function CChangesMathItalic(NewValue, OldValue)
{
this.New = NewValue;
this.Old = OldValue;
}
CChangesMathItalic.prototype.Type = historyitem_Math_CtrPrpItalic;
CChangesMathItalic.prototype.Undo = function(Class)
{
Class.raw_SetItalic(this.Old);
};
CChangesMathItalic.prototype.Redo = function(Class)
{
Class.raw_SetItalic(this.New);
};
CChangesMathItalic.prototype.Save_Changes = function(Writer)
{
// Bool : IsUndefined
// Bool : IsItalic
if (undefined === this.New)
Writer.WriteBool(true);
else
{
Writer.WriteBool(false);
Writer.WriteBool(this.New);
}
};
CChangesMathItalic.prototype.Load_Changes = function(Reader, Class)
{
// Bool : IsUndefined
// Bool : IsItalic
if(true === Reader.GetBool())
this.New = undefined;
else
this.New = Reader.GetBool();
this.Redo(Class);
};
function CChangesMathBold(NewValue, OldValue)
{
this.New = NewValue;
this.Old = OldValue;
}
CChangesMathBold.prototype.Type = historyitem_Math_CtrPrpBold;
CChangesMathBold.prototype.Undo = function(Class)
{
Class.raw_SetBold(this.Old);
};
CChangesMathBold.prototype.Redo = function(Class)
{
Class.raw_SetBold(this.New);
};
CChangesMathBold.prototype.Save_Changes = function(Writer)
{
// Bool : IsUndefined
// Bool : IsBold
if (undefined === this.New)
Writer.WriteBool(true);
else
{
Writer.WriteBool(false);
Writer.WriteBool(this.New);
}
};
CChangesMathBold.prototype.Load_Changes = function(Reader, Class)
{
// Bool : IsUndefined
// Bool : IsBold
if(true === Reader.GetBool())
this.New = undefined;
else
this.New = Reader.GetBool();
this.Redo(Class);
};
function CChangesMathAddItems(Pos, Items) function CChangesMathAddItems(Pos, Items)
{ {
this.Pos = Pos; this.Pos = Pos;
......
...@@ -3177,6 +3177,9 @@ ParaRun.prototype.Draw_HighLights = function(PDSH) ...@@ -3177,6 +3177,9 @@ ParaRun.prototype.Draw_HighLights = function(PDSH)
var bDrawShd = ( oShd === undefined || shd_Nil === oShd.Value ? false : true ); var bDrawShd = ( oShd === undefined || shd_Nil === oShd.Value ? false : true );
var ShdColor = ( true === bDrawShd ? oShd.Get_Color( PDSH.Paragraph ) : null ); var ShdColor = ( true === bDrawShd ? oShd.Get_Color( PDSH.Paragraph ) : null );
if(this.Type == para_Math_Run && this.IsPlaceholder())
bDrawShd = false;
var X = PDSH.X; var X = PDSH.X;
var Y0 = PDSH.Y0; var Y0 = PDSH.Y0;
var Y1 = PDSH.Y1; var Y1 = PDSH.Y1;
...@@ -3316,11 +3319,12 @@ ParaRun.prototype.Draw_Elements = function(PDSE) ...@@ -3316,11 +3319,12 @@ ParaRun.prototype.Draw_Elements = function(PDSE)
var CurTextPr = this.Get_CompiledPr( false ); var CurTextPr = this.Get_CompiledPr( false );
pGraphics.SetTextPr( CurTextPr, Theme ); pGraphics.SetTextPr( CurTextPr, Theme );
var Font;
if(this.Type == para_Math_Run) if(this.Type == para_Math_Run)
{ {
Y += this.size.ascent; Y += this.size.ascent;
var Font = Font =
{ {
Bold : CurTextPr.Bold, Bold : CurTextPr.Bold,
Italic : CurTextPr.Italic, Italic : CurTextPr.Italic,
...@@ -3500,7 +3504,28 @@ ParaRun.prototype.Draw_Elements = function(PDSE) ...@@ -3500,7 +3504,28 @@ ParaRun.prototype.Draw_Elements = function(PDSE)
case para_Math_Text: case para_Math_Text:
case para_Math_Placeholder: case para_Math_Placeholder:
{ {
var bChangeFont = Item.Is_SpecilalOperator() && !this.IsNormalText() && Font.FontFamily.Name !== "Cambria Math",
FFont = {};
// опред набор символов, если Font не Cambria Math, рисуется все равно Font Cambria Math
if(bChangeFont) // для математического текста
{
FFont.FontFamily = {Name : "Cambria Math", Index : -1};
FFont.FontSize = Font.FontSize;
FFont.Bold = false;
FFont.Italic = false;
pGraphics.SetFont(FFont);
}
Item.draw(X, Y, pGraphics ); Item.draw(X, Y, pGraphics );
if(bChangeFont)
{
pGraphics.SetFont(Font);
}
break; break;
} }
} }
...@@ -3909,6 +3934,8 @@ ParaRun.prototype.Set_ParaContentPos = function(ContentPos, Depth) ...@@ -3909,6 +3934,8 @@ ParaRun.prototype.Set_ParaContentPos = function(ContentPos, Depth)
Pos = 0; Pos = 0;
this.State.ContentPos = Pos; this.State.ContentPos = Pos;
TEST_MATH_RUN = this;
}; };
ParaRun.prototype.Get_PosByElement = function(Class, ContentPos, Depth, UseRange, Range, Line) ParaRun.prototype.Get_PosByElement = function(Class, ContentPos, Depth, UseRange, Range, Line)
...@@ -7879,11 +7906,29 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, RPI, WidthPoints) ...@@ -7879,11 +7906,29 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, RPI, WidthPoints)
var Lng = this.Content.length; var Lng = this.Content.length;
var FontFamily;
for (var i = 0 ; i < Lng; i++) for (var i = 0 ; i < Lng; i++)
{ {
var bChangeFont = this.Content[i].Is_SpecilalOperator() && Font.FontFamily.Name !== "Cambria Math";
if(bChangeFont)
{
FontFamily = Font.FontFamily;
Font.FontFamily = {Name : "Cambria Math", Index : -1};
g_oTextMeasurer.SetFont(Font);
}
this.Content[i].Resize(oMeasure, RPI); this.Content[i].Resize(oMeasure, RPI);
if(bChangeFont)
{
Font.FontFamily = FontFamily;
g_oTextMeasurer.SetFont(Font);
}
var oSize = this.Content[i].size; var oSize = this.Content[i].size;
widthCurr = oSize.width; widthCurr = oSize.width;
...@@ -8086,6 +8131,11 @@ ParaRun.prototype.Get_TextForAutoCorrect = function(AutoCorrectEngine, RunPos) ...@@ -8086,6 +8131,11 @@ ParaRun.prototype.Get_TextForAutoCorrect = function(AutoCorrectEngine, RunPos)
if (null == AutoCorrectEngine.MathPr) if (null == AutoCorrectEngine.MathPr)
AutoCorrectEngine.MathPr = this.MathPrp.Copy(); AutoCorrectEngine.MathPr = this.MathPrp.Copy();
}; };
ParaRun.prototype.IsShade = function()
{
var oShd = this.Get_CompiledPr(false).Shd;
return !(oShd === undefined || shd_Nil === oShd.Value);
};
ParaRun.prototype.Get_RangesByPos = function(Pos) ParaRun.prototype.Get_RangesByPos = function(Pos)
{ {
...@@ -8116,4 +8166,60 @@ function CParaRunStartState(Run) ...@@ -8116,4 +8166,60 @@ function CParaRunStartState(Run)
{ {
this.Content.push(Run.Content[i]); this.Content.push(Run.Content[i]);
} }
}
var TEST_MATH_RUN = null;
function TEST_SYMBOLS()
{
//var Arr = [0x2398, 0x23CF, 0x23DC, 0x23E0, 0x2460, 0x2473, 0x24EA, 0x24F4, 0x24FF, 0x2500];
var Arr = [0x2776, 0x277F, 0x27D0, 0x27EB, 0x27F0, 0x27FF, 0x2900, 0x2AFF];
for(var k = 0; k < Arr.length; k += 2)
{
for(var i = Arr[k]; i <= Arr[k+1]; i++ )
{
AddItemToRun(TEST_MATH_RUN, i);
}
}
/*for(var i = 0x239B; i <= 0x23E0; i++)
{
AddItemToRun(Run, i);
}
//0x2C77
AddItemToRun(Run, 0x2E17);
for(var i = 0x3014; i <= 0x3017; i++)
{
AddItemToRun(Run, i);
}
for(var i = 0xFB00; i <= 0xFB04; i++)
{
AddItemToRun(Run, i);
}
AddItemToRun(Run, 0xFE00);*/
}
function AddItemToRun(Run, code)
{
var NewText = null;
var bMath = Run.Type == para_Math_Run;
if(bMath)
{
NewText = new CMathText(false);
NewText.add(code);
}
else
{
NewText = new ParaText();
NewText.Set_CharCode(code);
}
Run.Add(NewText, bMath);
} }
\ No newline at end of file
...@@ -776,6 +776,38 @@ CMathBase.prototype = ...@@ -776,6 +776,38 @@ CMathBase.prototype =
this.raw_Set_DoubleStrikeout(Value); this.raw_Set_DoubleStrikeout(Value);
} }
}, },
Set_Bold: function(Value)
{
if(Value !== this.CtrPrp.Bold)
{
History.Add(this, new CChangesMathBold(Value, this.CtrPrp.Bold));
this.raw_SetBold(Value);
}
},
Set_Italic: function(Value)
{
if(Value !== this.CtrPrp.Italic)
{
History.Add(this, new CChangesMathItalic(Value, this.CtrPrp.Italic));
this.raw_SetItalic(Value);
}
},
raw_SetBold: function(Value)
{
this.CtrPrp.Bold = Value;
this.RecalcInfo.bCtrPrp = true;
if (null !== this.ParaMath)
this.ParaMath.SetNeedResize();
},
raw_SetItalic: function(Value)
{
this.CtrPrp.Italic = Value;
this.RecalcInfo.bCtrPrp = true;
if (null !== this.ParaMath)
this.ParaMath.SetNeedResize();
},
raw_SetUnderline : function(Value) raw_SetUnderline : function(Value)
{ {
this.CtrPrp.Underline = Value; this.CtrPrp.Underline = Value;
......
...@@ -266,6 +266,8 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf ...@@ -266,6 +266,8 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf
this.ArgSize.SetValue(0); this.ArgSize.SetValue(0);
} }
this.RecalcInfo.bCtrPrp = true;
this.Set_CompiledCtrPrp(Parent, ParaMath); this.Set_CompiledCtrPrp(Parent, ParaMath);
this.ApplyProperties(RPI); this.ApplyProperties(RPI);
......
...@@ -3591,11 +3591,23 @@ CMathContent.prototype.Draw_HighLights = function(PDSH, bAll) ...@@ -3591,11 +3591,23 @@ CMathContent.prototype.Draw_HighLights = function(PDSH, bAll)
var len = this.Content.length; var len = this.Content.length;
for ( var CurPos = 0; CurPos < len; CurPos++ ) var H = 0;
var Y0 = PDSH.Y0,
Y1 = PDSH.Y1;
var FirstRootRunNotShd = this.bRoot && this.Content.length > 0 && !this.Content[0].IsShade();
if( FirstRootRunNotShd || !this.bRoot)
{ {
PDSH.Y0 = this.ParaMath.Y + this.pos.y; Y0 = this.ParaMath.Y + this.pos.y;
PDSH.Y1 = this.ParaMath.Y + this.pos.y + this.size.height; Y1 = this.ParaMath.Y + this.pos.y + this.size.height;
}
for ( var CurPos = 0; CurPos < len; CurPos++ )
{
PDSH.Y0 = Y0;
PDSH.Y1 = Y1;
if(bAll && this.Content[CurPos].Type == para_Math_Run) if(bAll && this.Content[CurPos].Type == para_Math_Run)
this.Content[CurPos].Select_All(); this.Content[CurPos].Select_All();
......
...@@ -42,8 +42,10 @@ function CMathText(bJDraw) ...@@ -42,8 +42,10 @@ function CMathText(bJDraw)
this.RecalcInfo = this.RecalcInfo =
{ {
//NewLetter: true, //NewLetter: true,
StyleCode: null, StyleCode: null,
bAccentIJ: false bAccentIJ: false,
SpaceSpecial: false,
bApostrophe: false
}; };
this.Parent = null; this.Parent = null;
...@@ -524,6 +526,12 @@ CMathText.prototype = ...@@ -524,6 +526,12 @@ CMathText.prototype =
} }
} }
/*if(bMathText && code == 0x27)
{
code = 0x7F0;
this.RecalcInfo.bApostrophe = true;
}*/
return code; return code;
}, },
getCodeChr: function() getCodeChr: function()
...@@ -556,28 +564,42 @@ CMathText.prototype = ...@@ -556,28 +564,42 @@ CMathText.prototype =
var metricsTxt; var metricsTxt;
if(this.bJDraw) var ascent, width, height, descent;
metricsTxt = oMeasure.Measure2Code(letter);
if(letter == 0x2061)
{
width = 0;
height = 0;
ascent = 0;
this.RecalcInfo.SpaceSpecial = true;
}
else else
metricsTxt = oMeasure.MeasureCode(letter); {
if(bAccentIJ) if(this.bJDraw)
oMeasure.SetStringGid(false); metricsTxt = oMeasure.Measure2Code(letter);
else
metricsTxt = oMeasure.MeasureCode(letter);
// смещения if(bAccentIJ)
this.rasterOffsetX = metricsTxt.rasterOffsetX; oMeasure.SetStringGid(false);
this.rasterOffsetY = metricsTxt.rasterOffsetY;
var ascent = metricsTxt.Ascent; // смещения
var descent = (metricsTxt.Height - metricsTxt.Ascent); this.rasterOffsetX = metricsTxt.rasterOffsetX;
var height = ascent + descent; this.rasterOffsetY = metricsTxt.rasterOffsetY;
var width; ascent = metricsTxt.Ascent;
descent = (metricsTxt.Height - metricsTxt.Ascent);
height = ascent + descent;
if(this.bJDraw)
width = metricsTxt.WidthG;
else
width = metricsTxt.Width;
}
if(this.bJDraw)
width = metricsTxt.WidthG;
else
width = metricsTxt.Width;
this.size.width = this.GapLeft + this.GapRight + width; this.size.width = this.GapLeft + this.GapRight + width;
this.size.height = height; this.size.height = height;
...@@ -626,11 +648,13 @@ CMathText.prototype = ...@@ -626,11 +648,13 @@ CMathText.prototype =
pGraphics.transform(sx, shy, shx, sy, 0, 0);*/ pGraphics.transform(sx, shy, shx, sy, 0, 0);*/
if(this.RecalcInfo.bAccentIJ) if(this.RecalcInfo.SpaceSpecial == false)
pGraphics.tg(this.RecalcInfo.StyleCode, X, Y); {
else if(this.RecalcInfo.bAccentIJ || this.RecalcInfo.bApostrophe)
pGraphics.FillTextCode(X, Y, this.RecalcInfo.StyleCode); //на отрисовку символа отправляем положение baseLine pGraphics.tg(this.RecalcInfo.StyleCode, X, Y);
else
pGraphics.FillTextCode(X, Y, this.RecalcInfo.StyleCode); //на отрисовку символа отправляем положение baseLine
}
}, },
setPosition: function(pos) setPosition: function(pos)
...@@ -742,6 +766,19 @@ CMathText.prototype = ...@@ -742,6 +766,19 @@ CMathText.prototype =
{ {
return false; return false;
}, },
Is_SpecilalOperator: function()
{
var val = this.value,
bSpecialOperator = val == 0x21 || val == 0x23 || (val >= 0x28 && val <= 0x2F) || (val >= 0x3A && val <= 0x3F) || (val >=0x5B && val <= 0x5F) || (val >= 0x7B && val <= 0xA1) || val == 0xAC || val == 0xB1 || val == 0xB7 || val == 0xBF || val == 0xD7 || val == 0xF7 || (val >= 0x2010 && val <= 0x2014) || val == 0x2016 || (val >= 0x2020 && val <= 0x2022) || val == 0x2026 /*|| (val >= 0x2153 && val <= 0xA64D)*/,
bSpecialArrow = val >= 0x2190 && val <= 0x21FF,
bSpecialSymbols = val == 0x2200 || val == 0x2201 || val == 0x2203 || val == 0x2204 || val == 0x2206|| (val >= 0x2208 && val <= 0x220D) || (val >= 0x220F && val <= 0x221E) || (val >= 0x2223 && val <= 0x223E) || (val >= 0x223F && val <= 0x22BD) || (val >= 0x22C0 && val <= 0x22FF) || val == 0x2305 || val == 0x2306 || (val >= 0x2308 && val <= 0x230B) || (val >= 0x231C && val <= 0x231F) || val == 0x2322 || val == 0x2323 || val == 0x2329 || val == 0x232A ||val == 0x233F || val == 0x23B0 || val == 0x23B1,
bOtherArrows = (val >= 0x27D1 && val <= 0x2980) || (val >= 0x2982 && val <= 0x299A) || (val >= 0x29B6 && val <= 0x29B9) || val == 0x29C0 || val == 0x29C1 || (val >= 0x29C4 && val <= 0x29C8) || (val >= 0x29CE && val <= 0x29DB) || val == 0x29DF || (val >= 0x29E1 && val <= 0x29E6) || val == 0x29EB || (val >= 0x29F4 && val <= 0x2AFF && val !== 0x2AE1 && val !== 0x2AF1) || (val >= 0x3014 && val <= 0x3017);
// apostrophe
// отдельно Cambria Math 0x27
return bSpecialOperator || bSpecialArrow || bSpecialSymbols || bOtherArrows;
},
//// ////
Copy: function() Copy: function()
{ {
...@@ -861,11 +898,10 @@ CMathAmp.prototype = ...@@ -861,11 +898,10 @@ CMathAmp.prototype =
{ {
return false; return false;
}, },
/*ApplyGaps: function() Is_SpecilalOperator: function()
{ {
if(this.bEqqArray==false) return false;
this.AmpText.ApplyGaps(); },
},*/
GetCompiled_ScrStyles: function() GetCompiled_ScrStyles: function()
{ {
return this.Parent.GetCompiled_ScrStyles(); return this.Parent.GetCompiled_ScrStyles();
......
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