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

Прокинула props в конструктор мат объекта

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56079 954022d7-b5bf-4e40-9824-e11837661b57
parent d09cf42e
......@@ -104,9 +104,14 @@ ParaMath.prototype =
{
// TODO: ParaMath.Get_TextPr
return new CTextPr();
},
var TextPr = new CTextPr();
var mTextPr = this.Root.Get_TextPr(_ContentPos, Depth);
TextPr.Merge( mTextPr );
return TextPr;
},
Get_CompiledTextPr : function(Copy)
{
// TODO: ParaMath.Get_CompiledTextPr
......@@ -114,9 +119,12 @@ ParaMath.prototype =
var TextPr = new CTextPr();
TextPr.Init_Default();
var oContent = this.GetSelectContent();
var mTextPr = oContent.Content.Get_CompiledTextPr(Copy);
TextPr.Merge( mTextPr );
return TextPr;
},
Add : function(Item)
{
var Type = Item.Type;
......@@ -311,49 +319,13 @@ ParaMath.prototype =
return new CParaPos( this.StartRange, this.StartLine, 0, 0 );
},
Get_Default_TPrp: function()
{
var TextPrp = new CTextPr();
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:
Apply_TextPr : function(TextPr, IncFontSize, ApplyToAll)
{
Ascii: {Name : "Cambria Math", Index : -1 }
},
FontSize: 11,
FontSizeCS: 11,
Italic: true,
Bold: false
};
// TODO: ParaMath.Apply_TextPr
TextPrp.Set_FromObject(DefaultPrp);*/
return TextPrp;
},
Apply_TextPr : function(TextPr, IncFontSize, ApplyToAll)
{
// TODO: ParaMath.Apply_TextPr
},
Clear_TextPr : function()
......@@ -1003,6 +975,45 @@ ParaMath.prototype =
{
return this.MathPr;
},
Get_Default_TPrp: function()
{
var TextPrp = new CTextPr();
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);*/
return TextPrp;
},
//-----------------------------------------------------------------------------------
// Функции отрисовки
//-----------------------------------------------------------------------------------
......
......@@ -7118,8 +7118,6 @@ ParaRun.prototype.Math_Recalculate = function(RecalcInfo)
ParaRun.prototype.Math_Update_Cursor = function(X, Y, CurPage, UpdateTarget)
{
var runPrp = this.Get_CompiledPr(true);
this.Parent.applyArgSize(runPrp);
var sizeCursor = runPrp.FontSize*g_dKoef_pt_to_mm;
......
......@@ -1001,7 +1001,7 @@ CSign.prototype.getCodeCharacter = function()
return this.sign.value;
}
function CAccent()
function CAccent(props)
{
this.kind = MATH_ACCENT;
......@@ -1009,7 +1009,10 @@ function CAccent()
//this.code = null; // храним код буквы и тип здесь
//this.typeOper = null; // т.к в класах, которые вызываем, не учитываем случаи, когда элементы (стрелки/скобки) переворачиваются
this.loc = LOCATION_TOP;
CMathBase.call(this);
this.init(props);
}
extend(CAccent, CMathBase);
CAccent.prototype.init = function(props)
......
......@@ -1385,6 +1385,8 @@ CMathBase.prototype =
this.elements[startX][startY].Set_SelectionContentPos(StartContentPos, null, Depth, StartFlag, -1);
}
this.bSelectionUse = true;
},
Selection_IsEmpty: function()
{
......@@ -1574,6 +1576,52 @@ CMathBase.prototype =
}
return NewObj;
},
Get_TextPr: function(ContentPos, Depth)
{
var row = ContentPos.Get(Depth),
col = ContentPos.Get(Depth+1);
var TextPr = this.elements[row][col].Get_TextPr(ContentPos, Depth + 2);
return TextPr;
},
Get_CompiledTextPr : function(Copy)
{
var start_x = 0,
start_y = 0;
var TextPr = null;
while(start_x < this.nCol && start_y < this.nRow && (TextPr == null || this.elements[start_x][start_y].IsJustDraw() ))
{
if(!this.elements[start_x][start_y].IsJustDraw())
TextPr = this.elements[start_x][start_y].Get_CompiledTextPr(Copy);
start_y++;
if(start_x >= this.nCol)
{
start_x++;
start_y = 0;
}
}
for(var i=start_y; i < this.nRow; i++)
{
for(var j = start_x; j < this.nCol; j++)
{
if(!this.elements[i][j].IsJustDraw())
{
var CurTextPr = this.elements[i][j].Get_CompiledPr(false);
if ( null !== CurTextPr )
TextPr = TextPr.Compare( CurTextPr );
}
}
}
return TextPr;
}
//////////////////////////
......
function CBorderBox()
function CBorderBox(props)
{
this.kind = MATH_BORDER_BOX;
......@@ -28,6 +28,8 @@ function CBorderBox()
this.bVert = true;*/
CMathBase.call(this);
this.init(props);
}
extend(CBorderBox, CMathBase);
CBorderBox.prototype.init = function(props)
......@@ -300,7 +302,7 @@ CBorderBox.prototype.getPropsForWrite = function()
return props;
}
function CBox()
function CBox(props)
{
this.kind = MATH_BOX;
......@@ -311,6 +313,8 @@ function CBox()
this.brk = false;
CMathBase.call(this);
this.init(props);
}
extend(CBox, CMathBase);
CBox.prototype.init = function(props)
......@@ -357,7 +361,7 @@ CBox.prototype.getPropsForWrite = function()
return props;
}
function CBar()
function CBar(props)
{
this.kind = MATH_BAR;
......@@ -365,6 +369,8 @@ function CBar()
this.operator = new COperator(OPER_BAR);
CCharacter.call(this);
this.init(props);
}
extend(CBar, CCharacter);
CBar.prototype.init = function(props)
......@@ -422,10 +428,12 @@ CBar.prototype.getPropsForWrite = function()
return props;
}
function CPhantom()
function CPhantom(props)
{
this.props = null;
CMathBase.call(this);
this.init(props);
}
extend(CPhantom, CMathBase);
CPhantom.prototype.init = function(props)
......
function CDegree()
function CDegree(props)
{
this.kind = MATH_DEGREE;
......@@ -8,6 +8,8 @@ function CDegree()
this.alnScr = false; // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта
CMathBase.call(this);
this.init(props);
}
extend(CDegree, CMathBase);
CDegree.prototype.init = function(props)
......@@ -17,10 +19,11 @@ CDegree.prototype.init = function(props)
else if(props.alnScr === false || props.alnScr === 0)
this.alnScr = false;
this.init_2( props, new CMathContent() );
}
CDegree.prototype.init_2 = function(props, oBase)
{
var oBase = new CMathContent();
if(props.indef == 2) /// props include Base for CNary
oBase = props.oBase;
if(props.type === DEGREE_SUPERSCRIPT)
this.type = DEGREE_SUPERSCRIPT;
else if(props.type === DEGREE_SUBSCRIPT)
......@@ -36,6 +39,20 @@ CDegree.prototype.init_2 = function(props, oBase)
/// вызов этой функции обязательно в конце
this.WriteContentsToHistory();
}
/*CDegree.prototype.init_2 = function(props, oBase)
{
if(props.type === DEGREE_SUPERSCRIPT)
this.type = DEGREE_SUPERSCRIPT;
else if(props.type === DEGREE_SUBSCRIPT)
this.type = DEGREE_SUBSCRIPT;
this.setDimension(1, 2);
var oDegree = new CMathContent();
oDegree.decreaseArgSize();
this.addMCToContent(oBase, oDegree);
}*/
CDegree.prototype.recalculateSize = function(oMeasure)
{
if(this.type === DEGREE_SUPERSCRIPT)
......@@ -598,7 +615,7 @@ CIterators.prototype.getCtrPrp = function()
return this.Parent.getCtrPrp();
}
function CDegreeSubSup()
function CDegreeSubSup(props)
{
this.kind = MATH_DEGREESubSup;
......@@ -606,6 +623,8 @@ function CDegreeSubSup()
this.type = DEGREE_SubSup;
this.alnScr = false; // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта
CMathBase.call(this);
this.init(props);
}
extend(CDegreeSubSup, CMathBase);
CDegreeSubSup.prototype.init = function(props)
......@@ -616,9 +635,40 @@ CDegreeSubSup.prototype.init = function(props)
this.alnScr = false;
var oBase = new CMathContent();
this.init_2(props, oBase);
if(props.indef == 2) /// props include Base for CNary
oBase = props.oBase;
if(props.type === DEGREE_SubSup)
this.type = DEGREE_SubSup;
else if(props.type === DEGREE_PreSubSup)
this.type = DEGREE_PreSubSup;
this.setDimension(1, 2);
var oIters = new CIterators();
oIters.init();
oIters.decreaseArgSize();
oIters.lUp = 0;
oIters.lD = 0;
if(this.type == DEGREE_SubSup)
{
oIters.alignHor(-1, 0);
this.addMCToContent(oBase, oIters);
}
else if(this.type == DEGREE_PreSubSup)
{
oIters.alignHor(-1, 1);
this.addMCToContent(oIters, oBase);
}
/// вызов этой функции обязательно в конце
this.WriteContentsToHistory();
}
CDegreeSubSup.prototype.init_2 = function(props, oBase)
/*CDegreeSubSup.prototype.init_2 = function(props, oBase)
{
if(props.type === DEGREE_SubSup)
this.type = DEGREE_SubSup;
......@@ -648,7 +698,7 @@ CDegreeSubSup.prototype.init_2 = function(props, oBase)
/// вызов этой функции обязательно в конце
this.WriteContentsToHistory();
}
}*/
CDegreeSubSup.prototype.old_old_recalculateSize = function(oMeasure)
{
var mgCtrPrp = this.mergeCtrTPrp();
......
function CFraction()
function CFraction(props)
{
this.kind = MATH_FRACTION;
this.type = BAR_FRACTION;
this.bHideBar = false;
CMathBase.call(this);
this.init(props);
}
extend(CFraction, CMathBase);
CFraction.prototype.init = function(props)
......@@ -26,10 +27,10 @@ CFraction.prototype.init = function(props)
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{
var num = new CNumerator();
num.init();
//num.init();
var den = new CDenominator();
den.init();
//den.init();
this.setDimension(2, 1);
......@@ -418,10 +419,14 @@ CFraction.prototype.getPropsForWrite = function()
}
function CNumerator()
{
this.gap = 0;
CMathBase.call(this);
this.init();
}
extend(CNumerator, CMathBase);
CNumerator.prototype.init = function()
......@@ -492,7 +497,10 @@ CNumerator.prototype.getPropsForWrite = function()
function CDenominator()
{
this.gap = 0;
CMathBase.call(this);
this.init();
}
extend(CDenominator, CMathBase);
CDenominator.prototype.init = function()
......
function CLimit()
function CLimit(props)
{
this.kind = MATH_LIMIT;
this.type = LIMIT_LOW;
CMathBase.call(this);
this.init(props);
}
extend(CLimit, CMathBase);
CLimit.prototype.init = function(props)
......
......@@ -791,9 +791,6 @@ CMPrp.prototype =
textPrp.Italic = this.italic;
textPrp.Bold = this.bold;
if(this.typeText == TXT_ROMAN)
textPrp.Italic = false;
return textPrp;
},
Copy: function()
......@@ -6222,28 +6219,73 @@ CMathContent.prototype =
return result;
},
///////////////////
/////////////////////////
// Text Properties
///////////////
Get_TextPr: function(ContentPos, Depth)
{
var pos = ContentPos.Get(Depth);
Depth++;
var TextPr;
if(this.IsPlaceholder())
TextPr = this.Parent.getCtrPrp();
else
TextPr = this.content[pos].Get_TextPr(ContentPos, Depth + 1);
if(this.content[pos].typeObj == MATH_PLACEHOLDER)
return TextPr;
},
Get_CompiledTextPr : function(Copy)
{
var TextPr = null;
if(this.IsPlaceholder())
{
TextPr = this.Parent.getCtrPrp();
}
else if ( true === this.bSelectionUse )
{
var StartPos = this.SelectStartPos;
var EndPos = this.SelectEndPos;
if ( StartPos > EndPos )
{
StartPos = this.SelectEndPos;
EndPos = this.SelectStartPos;
}
while ( null === TextPr && StartPos <= EndPos )
{
TextPr = this.content[StartPos].Get_CompiledTextPr(Copy);
StartPos++;
}
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
var CurTextPr = this.content[CurPos].Get_CompiledPr(false);
if ( null !== CurTextPr )
TextPr = TextPr.Compare( CurTextPr );
}
}
else
{
this.content[pos].Get_TextPr(ContentPos, Depth);
var CurPos = this.CurPos;
if ( CurPos >= 0 && CurPos < this.content.length )
TextPr = this.content[CurPos].Get_CompiledTextPr(Copy);
}
return TextPr;
},
Get_Default_TPrp: function()
{
return this.Composition.Get_Default_TPrp();
},
// перемещение по стрелкам
//////////////////////////////
// Перемещение по стрелкам
////////////////////
Get_LeftPos: function(SearchPos, ContentPos, Depth, UseContentPos, EndRun)
{
var result = false;
......
function CMathMatrix()
function CMathMatrix(props)
{
this.kind = MATH_MATRIX;
......@@ -37,6 +37,8 @@ function CMathMatrix()
CMathBase.call(this);
this.init(props);
}
extend(CMathMatrix, CMathBase);
CMathMatrix.prototype.init = function(props)
......
......@@ -11,7 +11,7 @@
// 0 - итраторы по прямой линии
// 1 - итераторы расположены также, как у степени
function CNary()
function CNary(props)
{
this.kind = MATH_NARY;
......@@ -21,6 +21,8 @@ function CNary()
this.supHide = false;
this.subHide = false;
CMathBase.call(this);
this.init(props);
}
extend(CNary, CMathBase);
CNary.prototype.init = function(props)
......@@ -185,20 +187,20 @@ CNary.prototype.init = function(props)
if( this.supHide && !this.subHide )
{
base = new CDegree();
var prp = {type: DEGREE_SUBSCRIPT};
base.init_2(prp, sign);
var prp = {type: DEGREE_SUBSCRIPT, indef: 2, oBase: sign};
//base.init_2(prp, sign);
}
else if( !this.supHide && this.subHide )
{
base = new CDegree();
var prp = {type: DEGREE_SUPERSCRIPT};
base.init_2(prp, sign);
var prp = {type: DEGREE_SUPERSCRIPT, indef: 2, oBase: sign};
//base.init_2(prp, sign);
}
else
{
base = new CDegreeSubSup();
var prp = {type: DEGREE_SubSup};
base.init_2(prp, sign);
var prp = {type: DEGREE_SubSup, indef: 2, oBase: sign};
//base.init_2(prp, sign);
}
}
......
......@@ -2267,7 +2267,7 @@ COperator.prototype.init = function(properties, defaultProps) // props (c
var prp = this.getProps(properties, defaultProps);
this.init_2(prp);
}
COperator.prototype.init_2 = function(props) // для копирования
COperator.prototype.init_2 = function(props)
{
var operator = null,
typeOper = null,
......@@ -3283,7 +3283,7 @@ old_CSeparator.prototype.setPosition = function(pos)
this.positions = pos;
}
function CDelimiter()
function CDelimiter(props)
{
this.kind = MATH_DELIMITER;
......@@ -3303,6 +3303,8 @@ function CDelimiter()
////
CMathBase.call(this);
this.init(props);
}
extend(CDelimiter, CMathBase);
CDelimiter.prototype.init = function(props)
......
......@@ -881,7 +881,7 @@ CSignRadical.prototype.relate = function(parent)
//context.fill() для заливки
//Graphics : df()
function CRadical()
function CRadical(props)
{
this.kind = MATH_RADICAL;
......@@ -892,8 +892,9 @@ function CRadical()
this.gapDegree = 0;
this.gapWidth = 0; // в случае со степенью, если ширина степени не нулевая, добавляется расстояние для ширины
CMathBase.call(this);
this.init(props);
}
extend(CRadical, CMathBase);
CRadical.prototype.init = function(props)
......
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