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

1. mathPr for ParaMath (свойства для формулы)

2. Функция копирования (для Math Para Run, MathContent, MathBase)
3. Поправила баг на открытии для N-арных опереаторов (в связи с удалением CMathComposition, возникал из-за отсутствия свойств у Composition)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55994 954022d7-b5bf-4e40-9824-e11837661b57
parent 7f0d887b
......@@ -41,6 +41,17 @@ function ParaMath(bAddMenu)
this.Ascent = 0;
this.Descent = 0;
this.MathPr =
{
naryLim: NARY_UndOvr,
intLim: NARY_SubSup,
brkBin: BREAK_BEFORE,
brkSubBin: BREAK_MIN_MIN,
wrapIndent: 0,
smallFrac: false,
wrapRight: false
};
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
if (!bAddMenu)
g_oTableId.Add( this, this.Id );
......@@ -58,18 +69,20 @@ ParaMath.prototype =
// TODO: ParaMath.Copy
var NewMath = new ParaMath();
var NewRoot;
/*if(Selected)
{
var Content = this.GetSelectContent();
NewRoot = Content.Copy(Selected, this);
NewMath.Root = Content.Copy(Selected, NewMath);
}
else
{
NewRoot = this.Root.Copy(Selected, this);
NewMath.Root = this.Root.Copy(Selected, NewMath);
}*/
/// argSize, bDot и bRoot выставить на объединении контентов
return NewMath;
},
......@@ -805,7 +818,8 @@ ParaMath.prototype =
}
},
//-----------------------------------------------------------------------------------
// Функция для работы с дефолтными текстовыми настройками и argSize для формулы
// Функция для работы с формулой
// в тч с дефолтными текстовыми настройками и argSize
//-----------------------------------------------------------------------------------
ApplyArgSize : function(oWPrp)
{
......@@ -875,6 +889,103 @@ ParaMath.prototype =
return 0.6*metrics.Height;
},
SetMathProperties: function(props)
{
//***** FOR FORMULA *****//
// В документации везде, где нет примера использования свояства, означает, что Word не поддерживает это свойство !
if(props.naryLim == NARY_UndOvr || props.naryLim == NARY_SubSup)
this.MathPr.naryLim = props.naryLim;
if(props.intLim == NARY_UndOvr || props.intLim == NARY_SubSup)
this.MathPr.intLim = props.intLim;
if(props.brkBin == BREAK_BEFORE || props.brkBin == BREAK_AFTER || props.brkBin == BREAK_REPEAT)
this.MathPr.brkBin = props.brkBin;
// for minus operator
// when brkBin is set to repeat
if(props.brkSubBin == BREAK_MIN_MIN || props.brkSubBin == BREAK_PLUS_MIN || props.brkSubBin == BREAK_MIN_PLUS)
this.MathPr.brkSubBin = props.brkSubBin;
// в случае если smallFrac = true,
if(props.smallFrac == true || props.smallFrac == false)
this.MathPr.smallFrac = props.smallFrac;
if(props.wrapIndent + 0 == props.wrapIndent && isNaN(props.wrapIndent)) // проверка на число
this.MathPr.wrapIndent = props.wrapIndent/1440;
//******** check for element 0x1FFD - 0xA721 *******//
// This element specifies the right justification of the wrapped line of an instance of mathematical text
// Instance : Arrows 0x2190-0x21B3, 0x21B6, 0x21B7, 0x21BA-0x21E9, 0x21F4-0x21FF,
// 0x3D, 0x2234 - 0x2237, 0x2239, 0x223B - 0x228B, 0x228F - 0x2292, 0x22A2 - 0x22B9,
// 0x22C8-0x22CD, 0x22D0, 0x22D1, 0x22D5 - 0x22EE,0x22F0-0x22FF, 0x27F0 - 0x297F (arrows and fishes), 0x29CE - 0x29D5
// 0x2A66 - 0x2AF0 (equals), 0x2AF2-0x2AF3, 0x2AF7 - 0x2AFA
if(props.wrapRight == true || props.wrapRight == false)
this.MathPr.wrapRight = props.wrapRight;
//***** FOR DOCUMENT *****//
// defaultJc
// выравнивание формулы в документе
this.MathPr.defJc = props.defJc;
// dispDef
// свойство: применять/ не применять paragraph settings (в тч defaultJc)
this.MathPr.dispDef = props.dispDef;
// added to paragraph settings for margins
// rMargin
// lMargin
this.MathPr.lMargin = props.lMargin;
this.MathPr.rMargin = props.rMargin;
//***** НЕПОДДЕРЖИВАЕМЫЕ Вордом свойства *****//
// mathFont: в качестве font поддерживается только Cambria Math
// остальные шрифты возможно будут поддержаны MS в будущем
this.MathPr.mathFont = props.mathFont;
// Default font for math zones
// Gives a drop-down list of math fonts that can be used as the default math font to be used in the document.
// Currently only Cambria Math has thorough math support, but others such as the STIX fonts are coming soon.
// http://blogs.msdn.com/b/murrays/archive/2008/10/27/default-document-math-properties.aspx
//***** FOR FORMULA *****//
// http://msdn.microsoft.com/en-us/library/ff529906(v=office.12).aspx
// Word ignores the interSp attribute and fails to write it back out.
this.MathPr.interSp = props.interSp;
// http://msdn.microsoft.com/en-us/library/ff529301(v=office.12).aspx
// Word does not implement this feature and does not write the intraSp element.
this.MathPr.intraSp = intraSp;
//***** FOR DOCUMENT *****//
// http://msdn.microsoft.com/en-us/library/ff533406(v=office.12).aspx
// Word ignores and discards postSp
this.MathPr.postSp = props.postSp;
this.MathPr.preSp = props.preSp;
// RichEdit Hot Keys
// http://blogs.msdn.com/b/murrays/archive/2013/10/30/richedit-hot-keys.aspx
},
GetMathPr: function()
{
return this.MathPr;
},
//-----------------------------------------------------------------------------------
// Функции отрисовки
//-----------------------------------------------------------------------------------
......
......@@ -60,7 +60,6 @@ function ParaRun(Paragraph, bMathRun)
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
ParaRun.prototype =
{
//-----------------------------------------------------------------------------------
......@@ -95,6 +94,12 @@ ParaRun.prototype =
NewRun.Set_Pr( this.Pr.Copy() );
if(this.typeObj == MATH_PARA_RUN)
{
NewRun.MathPrp = this.MathPrp.Copy();
}
var StartPos = 0;
var EndPos = this.Content.length;
......@@ -7126,48 +7131,6 @@ ParaRun.prototype.Math_Update_Cursor = function(X, Y, CurPage, UpdateTarget)
return {X: X, Y: Y, Height: sizeCursor};
}
ParaRun.prototype.Math_applyArgSize = function(oWPrp)
{
var tPrp = new CTextPr();
var defaultRPrp = this.Parent.Composition.Get_Default_TPrp();
//var gWPrp = defaultRPrp.getMergedWPrp();
tPrp.Merge(defaultRPrp);
tPrp.Merge(oWPrp);
var FSize = tPrp.FontSize;
if(this.argSize == -1)
{
//aa: 0.0013 bb: 0.66 cc: 0.5
//aa: 0.0009 bb: 0.68 cc: 0.26
FSize = 0.0009*FSize*FSize + 0.68*FSize + 0.26;
//FSize = 0.001*FSize*FSize + 0.723*FSize - 1.318;
//FSize = 0.0006*FSize*FSize + 0.743*FSize - 1.53;
}
else if(this.argSize == -2)
{
// aa: -0.0004 bb: 0.66 cc: 0.87
// aa: -0.0014 bb: 0.71 cc: 0.39
// aa: 0 bb: 0.63 cc: 1.11
//FSize = 0.63*FSize + 1.11;
FSize = -0.0004*FSize*FSize + 0.66*FSize + 0.87;
//tPrp.FontSize *= 0.473;
}
tPrp.FontSize = FSize;
oWPrp.Merge(tPrp);
/*
if(this.argSize == -1)
//tPrp.FontSize *= 0.8;
tPrp.FontSize *= 0.728;
//tPrp.FontSize *= 0.65;
else if(this.argSize == -2)
//tPrp.FontSize *= 0.65;
tPrp.FontSize *= 0.53;
//tPrp.FontSize *= 0.473;*/
}
ParaRun.prototype.Set_MathPrp = function(props)
{
this.MathPrp.setMathProps(props);
......
......@@ -1682,4 +1682,14 @@ CAccent.prototype.findDisposition = function(pos)
posCurs = {x: curs_X, y: curs_Y};
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
CAccent.prototype.Copy = function(Selected, Composition)
{
var props = this.getPropsForWrite();
var NewAccent = new CAccent();
NewAccent.init(props);
this.Copy_2(Selected, Composition, NewAccent);
return NewAccent;
}
\ No newline at end of file
......@@ -8,7 +8,16 @@ function CMathBase()
this.pos = null;
this.size = null;
// Properties
this.argSize = 0;
this.Parent = null;
this.Composition = null; // ссылка на общую формулу
this.CtrPrp = new CTextPr();
/////////////////
//this.RunPrp = new CMathRunPrp();
this.CurPos_X = 0;
this.CurPos_Y = 0;
......@@ -28,20 +37,9 @@ function CMathBase()
this.bSelectionUse = false;
this.nRow = 0;
this.nCol = 0;
this.Parent = null;
this.Composition = null; // ссылка на общую формулу
this.CtrPrp = new CTextPr();
//this.RunPrp = new CMathRunPrp();
//this.textPrp = new CMathTextPrp(); // для рассчета размера расстояний
//this.RunPrp = new CMathTextPrp(); // запоминаем, если передаются спец. настройки для контента
// todo
// убрать !!!
this.bMObjs = false;
......@@ -1553,6 +1551,25 @@ CMathBase.prototype =
Get_TxtPrp: function()
{
return this.getCtrPrp();
},
Copy_2: function(Selected, Composition, NewObj)
{
NewObj.Composition = Composition;
var CtrPrp = this.CtrPrp.Copy();
NewObj.setCtrPrp(CtrPrp);
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
{
NewObj.elements[i][j] = this.elements[i][j].Copy(Selected, Composition);
var argSize = this.elements[i][j].argSize;
NewObj.elements[i][j].setArgSize(argSize);
NewObj.elements[i][j].relate(NewObj);
}
}
//////////////////////////
......
......@@ -3,7 +3,7 @@ function CFraction()
this.kind = MATH_FRACTION;
this.type = BAR_FRACTION;
this.bHideBar = false
this.bHideBar = false;
CMathBase.call(this);
......@@ -425,6 +425,16 @@ CFraction.prototype.getPropsForWrite = function()
};
return props;
}
CFraction.prototype.Copy = function(Selected, Composition)
{
var props = this.getPropsForWrite();
var NewFraction = new CFraction();
NewFraction.init(props);
this.Copy_2(Selected, Composition, NewFraction);
return NewFraction;
}
function CNumerator()
......
......@@ -524,7 +524,8 @@ CRecalculateInfo.prototype =
}
}
// TO DO
// убрать
function dist(_left, _right, _top, _bottom)
{
this.left = _left;
......@@ -794,6 +795,21 @@ CMPrp.prototype =
textPrp.Italic = false;
return textPrp;
},
Copy: function()
{
var NewMPrp = new CMPrp();
NewMPrp.aln = this.aln;
NewMPrp.brk = this.brk;
NewMPrp.lit = this.lit;
NewMPrp.nor = this.nor;
NewMPrp.typeText = this.typeText;
NewMPrp.italic = this.italic;
NewMPrp.bold = this.bold;
NewMPrp.plain = this.plain;
return NewMPrp;
}
}
......@@ -826,21 +842,22 @@ CMPrp.prototype =
function CMathContent()
{
this.Id = g_oIdCounter.Get_NewId();
this.bDot = false;
this.plhHide = false;
this.bRoot = false;
this.content = new Array(); // array of mathElem
//this.length = 0;
this.WidthToElement = [];
this.CurPos = 0;
this.WidthToElement = [];
this.pos = {x:0, y:0}; // относительная позиция
// Properties
this.Composition = null; // ссылка на общую формулу
this.argSize = 0;
this.bDot = false;
this.plhHide = false;
this.bRoot = false;
//////////////////
////** real select **////
......@@ -866,7 +883,6 @@ function CMathContent()
this.SelectStartPos = 0;
this.SelectEndPos = 0;
this.size =
{
width: 0,
......@@ -6350,7 +6366,7 @@ CMathContent.prototype =
{
return this.content.length == 1;
},
Copy: function(Selected)
Copy: function(Selected, Composition)
{
var start, end;
......@@ -6365,16 +6381,27 @@ CMathContent.prototype =
end = this.content.length - 1;
}
var content = new CMathContent();
var NewContent = new CMathContent();
NewContent.setComposition(Composition);
NewContent.plHide = this.plHide;
for(var i = start; i < end; i++)
{
var element = this.content[i].Copy(Selected);
content.Copy(element);
}
var element;
if(this.content[i].typeObj == MATH_PARA_RUN)
{
element = this.content[i].Copy(Selected);
}
else
{
element = this.content[i].Copy(false, Composition);
element.relate(this);
}
NewContent.push(element);
}
return NewContent;
},
Selection_Remove: function()
{
......
......@@ -405,7 +405,12 @@ CMathText.prototype =
SearchPos.Pos.Update(0, Depth);
SearchPos.Pos.bPlaceholder = true;
},
Copy: function()
{
var NewLetter = new CMathText(this.bJDraw);
},
// заглушка для текста (для n-арных операторов, когда выставляется текст вместо оператора)
setComposition: function() // заглушка
......
......@@ -53,10 +53,12 @@ CNary.prototype.init = function(props)
{
var bIntegral = signCode > 0x222A && signCode < 0x2231;
var MPrp = this.Parent.Composition.GetMathPr();
if(bIntegral)
this.limLoc = this.Parent.Composition.props.intLim;
this.limLoc = MPrp.intLim;
else
this.limLoc = this.Parent.Composition.props.naryLim;
this.limLoc = MPrp.naryLim;
}
......
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