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

text Math Run Properties

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54643 954022d7-b5bf-4e40-9824-e11837661b57
parent b34b1848
......@@ -118,13 +118,11 @@ CMathRunPrp.prototype =
getMergedWPrp: function()
{
var oWPrp = new CTextPr();
var mPrp = new CTextPr();
mPrp.italic = this.mathPrp.italic;
mPrp.bold = this.mathPrp.bold;
// смержить c MRunPrp
if(!this.mathPrp.nor)
if(!this.mathPrp.nor) // math text, style: plain
{
var mPrp = this.mathPrp.getTxtPrp();
oWPrp.Merge(this.textPrp); // FontFamily, FontSize etc
oWPrp.Merge(mPrp); // bold, italic
}
......@@ -145,7 +143,7 @@ CMathRunPrp.prototype =
},
setMathRunPrp: function(oMPrp)
{
this.mathPrp.Merge(oMPrp);
this.mathPrp.setMathProps(oMPrp);
},
draw: function() {},
setPosition: function() {},
......@@ -158,60 +156,38 @@ CMathRunPrp.prototype =
props.mathRunPrp = this.mathPrp.getPropsForWrite();
return props;
},
getTypeText: function()
{
return this.mathPrp.getTypeText();
}
}
function CMPrp()
{
this.aln = false;
this.brk = false;
this.lit = false;
this.nor = false; // если normal = false, то берем TextPrp отсюда (в wRunPrp bold/italic не учитываем, выставляем отсюда)
this.aln = false;
this.brk = false;
this.lit = false;
this.nor = false; // если normal = false, то берем TextPrp отсюда (в wRunPrp bold/italic не учитываем, выставляем отсюда)
// если normal = true, то их Word не учитывает и берет TextPr из wRunPrp
this.scr = SCR_ROMAN;
this.italic = true;
this.bold = false;
this.plain = false; // plain тоже самое, что и normal, только нельзя поставить другой шрифт, другой размер шрифта и тп
this.typeText = TXT_ROMAN;
this.italic = true;
this.bold = false;
this.plain = false;
}
CMPrp.prototype =
{
Merge: function(mPrp)
{
this.SetBProp(this.aln, mPrp.aln);
this.SetBProp(this.brk, mPrp.brk);
this.SetBProp(this.lit, mPrp.lit);
this.SetBProp(this.nor, mPrp.nor);
// если приходит несколько параметров style из xml, то запоминается последний
if(mPrp.sty === "i")
this.italic = true;
else if(mPrp.sty === "bi")
{
this.italic = true;
this.bold = true;
}
else if(mPrp.sty === "b")
{
this.italic = false;
this.bold = true;
}
else if(mPrp.sty === "p")
{
this.plain = true;
}
if(mPrp.scr === "double-struck")
this.scr = SCR_DOUBLE_STRUCK;
else if(mPrp.scr === "monospace")
this.scr = SCR_MONOSPACE;
else if(mPrp.scr === "fraktur")
this.scr = SCR_FRAKTUR;
else if(mPrp.scr === "sans-serif")
this.scr = SCR_SANS_SERIF;
else if(mPrp.scr === "script")
this.scr = SCR_SCRIPT;
this.aln = mPrp.aln;
this.brk = mPrp.brk;
this.lit = mPrp.lit;
this.nor = mPrp.nor;
this.typeText = mPrp.typeText;
this.italic = mPrp.italic;
this.bold = mPrp.bold;
this.plain = mPrp.plain;
},
SetBProp: function(obj, prp)
{
......@@ -227,11 +203,11 @@ CMPrp.prototype =
align: this.aln,
brk: this.brk,
literal: this.lit,
normal: this.nor,
script: this.src,
italic: this.italic,
bold: this.bold,
plain: this.plain
plain: this.plain,
typeText: this.typeText
};
return props;
......@@ -245,7 +221,7 @@ CMPrp.prototype =
Bold = this.bold && !this.italic,
Plain = this.plain;
if(this.nor)
if(this.typeText == TXT_NORMAL)
{
props.nor = 1;
}
......@@ -259,7 +235,6 @@ CMPrp.prototype =
props.sty = "i";
else if(Plain)
props.sty = "p";
}
if(this.aln)
......@@ -272,25 +247,86 @@ CMPrp.prototype =
props.lit = 1;
if( this.scr === SCR_DOUBLE_STRUCK)
if(this.typeText === TXT_DOUBLE_STRUCK)
props.scr = "double-struck";
else if(this.scr === SCR_MONOSPACE)
else if(this.typeText === TXT_MONOSPACE)
props.scr = "monospace";
else if(this.scr === SCR_FRAKTUR)
else if(this.typeText === TXT_FRAKTUR)
props.scr = "fraktur";
else if(this.scr === SCR_SANS_SERIF)
else if(this.typeText === TXT_SANS_SERIF)
props.scr = "sans-serif";
else if(this.scr === SCR_SCRIPT)
else if(this.typeText === TXT_SCRIPT)
props.scr = "script";
return props;
},
setMathProps: function(props)
{
this.SetBProp(this.aln, props.aln);
this.SetBProp(this.brk, props.brk);
this.SetBProp(this.lit, props.lit);
//this.SetBProp(this.nor, props.nor);
// если приходит несколько параметров style из xml, то запоминается последний
if(props.sty === "i")
this.italic = true;
else if(props.sty === "bi")
{
this.italic = true;
this.bold = true;
}
else if(props.sty === "b")
{
this.italic = false;
this.bold = true;
}
else if(props.sty === "p")
{
// plain text ?!
this.plain = true;
}
if(props.scr === "double-struck") // U+1D538 - U+1D56B
this.typeText = TXT_DOUBLE_STRUCK;
else if(props.scr === "monospace") // U+1D670 - U+1D6A3
this.typeText = TXT_MONOSPACE;
else if(props.scr === "fraktur") // U+1D504 - U+1D537
this.typeText = TXT_FRAKTUR;
else if(props.scr === "sans-serif") // U+1D608 - U+1D63B
this.typeText = TXT_SANS_SERIF;
else if(props.scr === "script") // U+1D49C - U+1D4CF
this.typeText = TXT_SCRIPT;
if(props.nor)
this.typeText = TXT_NORMAL;
},
getTypeText: function()
{
var type= this.typeText;
if(type == TXT_ROMAN && this.italic == false) // если MATH TEXT и не курсив, то подменяем на NORMAL TEXT
type = TXT_NORMAL;
return type;
},
getTxtPrp: function()
{
var textPrp = new CTextPr();
textPrp.italic = this.mathPrp.italic;
textPrp.bold = this.mathPrp.bold;
if(this.typeText == TXT_ROMAN)
textPrp.Italic = false;
return textPrp;
}
}
//TODO
// доделать GroupCharacter / Delimiter в качестве cheracter может быть любой символ
// доделать GroupCharacter / Delimiter в качестве character может быть любой символ
//TODO
//переделать/продумать DotIndef, т.к. при перетаскивании из одного места в другое флаг DotIndef может измениться для другого контента
......@@ -4695,7 +4731,7 @@ CMathContent.prototype =
},
Resize: function(oMeasure) // пересчитываем всю формулу
{
var bItalic = true;
var typeTxt = TXT_ROMAN; // default MATH Text
//var posPrev = -1;
for(var i = 0; i < this.content.length; i++)
......@@ -4704,19 +4740,16 @@ CMathContent.prototype =
if(type == MATH_TEXT)
{
this.content[i].value.setMText(bItalic);
this.content[i].value.setMText(typeTxt);
this.content[i].value.Resize(oMeasure);
this.checkGapsSign(oMeasure, i);
//posPrev = i;
}
else if(type == MATH_COMP)
{
this.content[i].value.Resize(oMeasure);
this.checkGapsSign(oMeasure, i);
//posPrev = i;
}
else if(type == MATH_RUN_PRP)
{
......@@ -4724,13 +4757,13 @@ CMathContent.prototype =
var oWPrp = new CTextPr();
oWPrp.Merge(mergedWPrp);
/*var txtPrp = new CMathTextPrp();
txtPrp.Merge(this.Composition.DEFAULT_RUN_PRP);
txtPrp.Merge(runPrp);*/
this.applyArgSize(oWPrp); // здесь мержим с DEFAULT_RUN_PRP
typeTxt = oWPrp.getTypeText();
/*if(typeTxt == TXT_ROMAN) // MATH TEXT, наклон не меняем, если italic
oWPrp.Italic = false;*/
this.applyArgSize(oWPrp);
bItalic = oWPrp.Italic;
oWPrp.Italic = false;
oMeasure.SetFont(oWPrp);
}
......@@ -5240,15 +5273,12 @@ CMathContent.prototype =
if(this.content[i].value.typeObj == MATH_RUN_PRP)
{
pGraphics.b_color1(0,0,0,255);
/*var rPrp = new CMathTextPrp();
rPrp.Merge(this.Composition.DEFAULT_RUN_PRP);
rPrp.Merge( this.content[i].value.getWRunPrp() );*/
var mgWPrp = this.content[i].value.getMergedWPrp();
var oWPrp = new CTextPr();
oWPrp.Merge(mgWPrp);
this.applyArgSize(oWPrp);
oWPrp.Italic = false;
pGraphics.SetFont(oWPrp);
}
else if(this.content[i].value.typeObj == MATH_PLACEHOLDER)
......
......@@ -56,7 +56,7 @@ function CMathText()
this.value = null;
this.bJDraw = false;
this.bMText = false;
this.type = TXT_ROMAN;
//this.Parent = null;
......@@ -94,14 +94,15 @@ CMathText.prototype =
{
var code = this.value;
if( this.bMText )
var bCapitale = (code > 0x0040 && code < 0x005B),
bSmall = (code > 0x0060 && code < 0x007b);
if(this.type == TXT_ROMAN )
{
if(code == 0x0068) // h
code = 0x210E;
var bCapitale = (code > 0x0040 && code < 0x005B),
bSmall = (code > 0x0060 && code < 0x007b),
bDigit = (code > 0x002F && code < 0x003A),
var bDigit = (code > 0x002F && code < 0x003A),
bCapGreek = (code > 0x0390 && code < 0x03AA ),
bSmallGreek = (code > 0x03B0 && code < 0x03CA);
......@@ -119,28 +120,41 @@ CMathText.prototype =
else if(code == 0x237) // "j" without dot
code = 0x1D6A5;
}
/*else
{
if(code == 0x210E) // h
code = 0x0068;
var bCapitale = (code >= 0x1D434 && code <= 0x1D44D),
bSmall = (code >= 0x1D44E && code <= 0x1D467);
if(bCapitale)
code = code - 0x1D3F3;
else if(bSmall)
code = code - 0x1D3ED;
else if(bCapGreek)
code = code - 0x1D351;
else if(bSmallGreek)
code = code - 0x1D34B;
if(code == 0x1D6A4) // "i" without dot
code = 0x131;
else if(code == 0x1D6A5) // "j" without dot
code = 0x237;
}*/
else if(this.type == TXT_DOUBLE_STRUCK)
{
if(bCapitale)
code = code + 0x1D4F8;
else if(bSmall)
code = code + 0x1D4F2;
}
else if(this.type == TXT_MONOSPACE)
{
if(bCapitale)
code = code + 0x1D630;
else if(bSmall)
code = code + 0x1D62A;
}
else if(this.type == TXT_FRAKTUR)
{
if(bCapitale)
code = code + 0x1D4C4;
else if(bSmall)
code = code + 0x1D4BE;
}
else if(this.type == TXT_SANS_SERIF)
{
if(bCapitale)
code = code + 0x1D5CB;
else if(bSmall)
code = code + 0x1D5C5;
}
else if(this.type == TXT_SCRIPT)
{
if(bCapitale)
code = code + 0x1D45C;
else if(bSmall)
code = code + 0x1D456;
}
return code;
},
......@@ -395,9 +409,9 @@ CMathText.prototype =
{
this.bJDraw = bJustDraw;
},
setMText: function(flag)
setMText: function(type)
{
this.bMText = flag;
this.type = type;
},
// заглушка для текста (для n-арных операторов, когда выставляется текст вместо оператора)
setComposition: function() // заглушка
......
......@@ -87,12 +87,20 @@ var ACCENT_ARROW_LR = 28;
var ACCENT_HALF_ARROW_LEFT = 29;
var ACCENT_HALF_ARROW_RIGHT = 30;
var SCR_ROMAN = 0;
var TXT_NORMAL = 0;
var TXT_ROMAN = 1; // math roman
var TXT_SCRIPT = 2;
var TXT_FRAKTUR = 2;
var TXT_DOUBLE_STRUCK = 3;
var TXT_SANS_SERIF = 4;
var TXT_MONOSPACE = 5;
/*var SCR_ROMAN = 0;
var SCR_SCRIPT = 1;
var SCR_FRAKTUR = 2;
var SCR_DOUBLE_STRUCK = 3;
var SCR_SANS_SERIF = 4;
var SCR_MONOSPACE = 5;
var SCR_MONOSPACE = 5;*/
var OPER_DELIMITER = 0;
var OPER_SEPARATOR = 1;
......
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