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