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

1. Написала тестовый пример (для чтения)

2. Для чтении из файла при добавлении мат. объекта в контент добавила CEmpty (для корректной работы)
2. Исправила баг для n-арных операторов (для чтения)
3. Выставила для accent, matrix, limit значение по умолчанию

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@51992 954022d7-b5bf-4e40-9824-e11837661b57
parent e7019bc2
...@@ -855,8 +855,14 @@ CAccent.prototype.init = function(props) ...@@ -855,8 +855,14 @@ CAccent.prototype.init = function(props)
var code, accent; var code, accent;
var type = props.chrType; var type = props.chrType;
var bCode = false,
bType = typeof(type) !== "undefined" && type !== null;
if(typeof(props.chr) === "string") if(typeof(props.chr) === "string")
{
bCode = true;
code = props.chr.charCodeAt(0); code = props.chr.charCodeAt(0);
}
/*var bDot = code === 0x307 || props.chr.type === ACCENT_ONE_DOT, /*var bDot = code === 0x307 || props.chr.type === ACCENT_ONE_DOT,
b2Dots = code === 0x308 || props.chr.type === ACCENT_TWO_DOTS, b2Dots = code === 0x308 || props.chr.type === ACCENT_TWO_DOTS,
...@@ -1057,9 +1063,10 @@ CAccent.prototype.init = function(props) ...@@ -1057,9 +1063,10 @@ CAccent.prototype.init = function(props)
glyph.init(props); glyph.init(props);
} }
///// /////
else else if(bCode || bType)
{ {
this.type = ACCENT_SIGN; this.type = ACCENT_SIGN;
accent = new CSign(); accent = new CSign();
var props = var props =
{ {
...@@ -1068,6 +1075,13 @@ CAccent.prototype.init = function(props) ...@@ -1068,6 +1075,13 @@ CAccent.prototype.init = function(props)
}; };
accent.setSign(props); accent.setSign(props);
} }
else
{
this.type = ACCENT_COMB_CARON;
accent = new CCircumflex();
accent.setTurn(TURN_MIRROR_0);
}
this.setOperator(accent); this.setOperator(accent);
this.elements[0][0].SetDot(true); this.elements[0][0].SetDot(true);
......
...@@ -133,13 +133,13 @@ CMathBase.prototype = ...@@ -133,13 +133,13 @@ CMathBase.prototype =
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
this.elements[i][j].setComposition(composition); this.elements[i][j].setComposition(composition);
}, },
setReferenceComp: function(Comp) setReferenceComposition: function(Comp)
{ {
this.Composition = Comp; this.Composition = Comp;
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
this.elements[i][j].setReferenceComp(Comp); this.elements[i][j].setReferenceComposition(Comp);
}, },
/*old_getTxtPrp: function() /*old_getTxtPrp: function()
{ {
......
...@@ -48,12 +48,15 @@ old_CLogarithm.prototype.getArgument = function() ...@@ -48,12 +48,15 @@ old_CLogarithm.prototype.getArgument = function()
function CLimit() function CLimit()
{ {
this.type = LIMIT_LOW;
CMathBase.call(this); CMathBase.call(this);
} }
extend(CLimit, CMathBase); extend(CLimit, CMathBase);
CLimit.prototype.init = function(props) CLimit.prototype.init = function(props)
{ {
if( typeof(props.type) !== "undefined" && props.type !== null)
this.type = props.type; this.type = props.type;
this.setDimension(2, 1); this.setDimension(2, 1);
var oBase = new CMathContent(); var oBase = new CMathContent();
......
...@@ -12,7 +12,15 @@ ...@@ -12,7 +12,15 @@
//Bugs //Bugs
//При добавлении в началло контента элемента , он вставляется с размером шрифта 11, пос мотреть getCurrRunPrp //При добавлении в началло контента элемента , он вставляется с размером шрифта 11, посмотреть getCurrRunPrp
// При удаление из начала контента элемента, у всех остальных автоматом 11 размер шрифта
/// TODO (tomorrow)
// 1. Посмотреть стрелки и прочее для delimiters (которые используются для accent), при необходимости привести к одному типу
// 2. Дефолтовые значения для delimiters
// 3. Дописать тестовый пример(добавить операторы)
var historyitem_Math_AddItem = 1; // Добавляем элемент var historyitem_Math_AddItem = 1; // Добавляем элемент
var historyitem_Math_RemoveItem = 2; // Удаляем элемент var historyitem_Math_RemoveItem = 2; // Удаляем элемент
...@@ -501,6 +509,11 @@ CMathContent.prototype = ...@@ -501,6 +509,11 @@ CMathContent.prototype =
this.content.push(element); this.content.push(element);
this.CurPos++; this.CurPos++;
if(obj.typeObj === MATH_COMP)
this.addElementToContent( new CEmpty() );
//this.setStart_Selection(this.CurPos); //this.setStart_Selection(this.CurPos);
//this.selection.active = false; //this.selection.active = false;
}, },
...@@ -537,13 +550,13 @@ CMathContent.prototype = ...@@ -537,13 +550,13 @@ CMathContent.prototype =
{ {
this.Composition = Composition; this.Composition = Composition;
}, },
setReferenceComp: function(Comp) // отличие от setComposition: ссылка на общую формулу передается всем элементам контента setReferenceComposition: function(Comp) // отличие от setComposition: ссылка на общую формулу передается всем элементам контента
{ {
this.Composition = Comp; this.Composition = Comp;
for(var i = 1; i < this.content.length; i++) for(var i = 1; i < this.content.length; i++)
{ {
if(this.content[i].value.typeObj == MATH_COMP) if(this.content[i].value.typeObj == MATH_COMP)
this.content[i].value.setReferenceComp(Comp); this.content[i].value.setReferenceComposition(Comp);
} }
}, },
createEquation: function(ind) createEquation: function(ind)
...@@ -6465,7 +6478,7 @@ CMathComposition.prototype = ...@@ -6465,7 +6478,7 @@ CMathComposition.prototype =
}, },
SetReferenceComposition: function() SetReferenceComposition: function()
{ {
this.Root.setReferenceComp(this); this.Root.setReferenceComposition(this);
} }
} }
...@@ -6499,3 +6512,6 @@ function CEmpty() ...@@ -6499,3 +6512,6 @@ function CEmpty()
this.relate = function() {}; this.relate = function() {};
} }
...@@ -43,6 +43,12 @@ CMathMatrix.prototype.old_init = function(countRow, countCol) ...@@ -43,6 +43,12 @@ CMathMatrix.prototype.old_init = function(countRow, countCol)
} }
CMathMatrix.prototype.init = function(props) CMathMatrix.prototype.init = function(props)
{ {
if(typeof(props.row) === "undefined" || props.row === null)
props.row = 1;
if(typeof(props.column) === "undefined" || props.column === null)
props.column = 1;
this.setDimension(props.row, props.column); this.setDimension(props.row, props.column);
this.setContent(); this.setContent();
......
...@@ -503,6 +503,10 @@ CNaryOperator.prototype.getCtrPrp = function() ...@@ -503,6 +503,10 @@ CNaryOperator.prototype.getCtrPrp = function()
{ {
return this.Parent.getCtrPrp(); return this.Parent.getCtrPrp();
} }
CNaryOperator.prototype.setReferenceComposition = function(Compos)
{
this.Composition = Compos;
}
function CSigma() function CSigma()
{ {
......
...@@ -3840,6 +3840,8 @@ CDelimiter.prototype.init = function(props) ...@@ -3840,6 +3840,8 @@ CDelimiter.prototype.init = function(props)
else if(props.shape == DELIMITER_SHAPE_CENTERED || props.shp == DELIMITER_SHAPE_CENTERED) else if(props.shape == DELIMITER_SHAPE_CENTERED || props.shp == DELIMITER_SHAPE_CENTERED)
this.shape = DELIMITER_SHAPE_CENTERED; this.shape = DELIMITER_SHAPE_CENTERED;
if(props.column === null || typeof(props.column) === "undefined" )
props.column = 1;
this.setDimension(1, props.column); this.setDimension(1, props.column);
this.setContent(); this.setContent();
......
...@@ -174,7 +174,7 @@ function CRadical() ...@@ -174,7 +174,7 @@ function CRadical()
extend(CRadical, CMathBase); extend(CRadical, CMathBase);
CRadical.prototype.init = function(props) CRadical.prototype.init = function(props)
{ {
if( typeof(props.type) !== "undefined" && props.type !== null) if(typeof(props.type) !== "undefined" && props.type !== null)
this.type = props.type; this.type = props.type;
this.setDimension(1, 1); this.setDimension(1, 1);
......
function simulatorRead()
{
//////// accent -> bar fraction -> skewed fraction (for numerator)
var props =
{
chrType: ACCENT_ONE_DOT
};
var accent = new CAccent();
var ctrPrp = new CTextPr();
ctrPrp.FontSize = 36;
addToContent_ForRead( MathComposition.Root, accent, props, ctrPrp );
props =
{
type: BAR_FRACTION
};
var fract = new CFraction();
addToContent_ForRead( accent.getBase(), fract, props );
fract.getDenominator().fillPlaceholders();
var content = fract.getNumerator();
var fract2 = new CFraction();
props =
{
type: SKEWED_FRACTION
};
addToContent_ForRead( content, fract2, props );
var num1 = fract2.getNumerator();
var den1 = fract2.getDenominator();
num1.addTxt("a");
den1.addTxt("b");
//////////////////////////////////////////////////////////////////
var space = new CMathText();
space.add(0x20);
addToContent_ForRead(MathComposition.Root, space);
//////// delimiter (with separator) -> two bar fraction -> accent caron
var delim = new CDelimiter();
props =
{
begChrType: PARENTHESIS_LEFT,
endChrType: PARENTHESIS_RIGHT,
sepChrType: DELIMITER_LINE,
column: 2
};
addToContent_ForRead(MathComposition.Root, delim, props);
delim.getBase(1).addTxt("l");
fract = new CFraction();
props =
{
type: BAR_FRACTION
};
addToContent_ForRead(delim.getBase(0), fract, props);
var num = fract.getNumerator();
accent = new CAccent();
props =
{
chrType: ACCENT_COMB_CARON
};
addToContent_ForRead(num, accent, props);
accent.getBase().addTxt("i");
var den = fract.getDenominator();
fract = new CFraction();
props =
{
type: BAR_FRACTION
};
addToContent_ForRead(den, fract, props);
fract.getNumerator().addTxt("t");
fract.getDenominator().addTxt("b");
////// radical -> integral -> (delimiter -> degree -> tilde accent), box
var root = new CRadical();
props =
{
type: DEGREE_RADICAL
};
addToContent_ForRead(MathComposition.Root, root, props);
root.getDegree().addTxt("3");
base = root.getBase();
base.addTxt("F");
var integral = new CNary();
props =
{
signType: NARY_INTEGRAL,
limLoc: NARY_SubSup
};
integral.init(props);
addToContent_ForRead(base, integral, props);
integral.getUpperIterator().addTxt("a");
integral.getLowerIterator().addTxt("b");
base = integral.getBase();
delim = new CDelimiter();
props =
{
begChrType: BRACKET_CURLY_LEFT,
endChrType: BRACKET_CURLY_RIGHT,
column: 1
};
addToContent_ForRead(base, delim, props);
var degree = new CDegree();
props =
{
type: DEGREE_SUPERSCRIPT
};
addToContent_ForRead(delim.getBase(), degree, props);
degree.getIterator().addTxt("n");
var tilde = new CAccent();
props =
{
chrType: ACCENT_TILDE
};
addToContent_ForRead(degree.getBase(), tilde, props);
tilde.getBase().addTxt("g");
var box = new CBox();
props =
{
diff: true
};
addToContent_ForRead(base, box, props);
box.getBase().addTxt("dx");
//////////////////////////////////////////////////////////////////
////// matrix (4 rows) -> limit, arrow operator
var matrix = new CMathMatrix();
props =
{
column: 1,
row: 4
};
addToContent_ForRead(MathComposition.Root, matrix, props);
var mathFunc = new CMathFunc();
props =
{
};
addToContent_ForRead(matrix.getElement(0,0), mathFunc, props);
var limit = new CLimit();
props =
{
};
addToContent_ForRead( mathFunc.getFName(), limit, props);
limit.getIterator().addTxt("x→0");
limit.getFName().addTxt("lim");
fract = new CFraction();
props =
{
};
addToContent_ForRead( mathFunc.getArgument(), fract, props);
fract.getDenominator().addTxt("x");
var mFunc = new CMathFunc();
props =
{
};
addToContent_ForRead( fract.getNumerator(), mFunc, props);
mFunc.getFName().addTxt("sin");
mFunc.getArgument().addTxt("x");
matrix.getElement(1,0).fillPlaceholders();
matrix.getElement(2,0).fillPlaceholders();
//////////////////////////////////////////////////////////////////
MathComposition.RecalculateComposition();
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, { Width : Page_Width, Height : Page_Height, Margins : {
Left : X_Left_Field,
Right : X_Right_Field,
Top : Y_Top_Field,
Bottom : Y_Bottom_Field
} } );
}
function addToContent_ForRead(content, elem, props, ctrPrp)
{
try
{
if(elem.typeObj == MATH_COMP)
elem.init(props);
}
catch(e)
{
console.log( "Init of " + '\"' + elem.constructor.name + '\"' + " don't work" );
}
try
{
if(typeof(ctrPrp)!=="undefined" && ctrPrp !== null)
if(elem.typeObj == MATH_COMP)
{
elem.setCtrPrp(ctrPrp);
}
}
catch(e)
{
console.log( "CtrPrp for " + '\"' + elem.constructor.name + '\"' + " don't work" );
}
try
{
content.addElementToContent(elem);
}
catch(e)
{
console.log( "Add to content for " + '\"' + elem.constructor.name + '\"' + " don't work" );
}
try
{
if(elem.typeObj == MATH_COMP)
{
elem.Resize();
}
}
catch(e)
{
console.log( "Recalculate for " + '\"' + elem.constructor.name + '\"' + " don't work" );
}
}
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