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

1. Поправила search позиции

2. Позиции для селекта
3. Поправила параметр на загрузке документов для ранов

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55588 954022d7-b5bf-4e40-9824-e11837661b57
parent 15ea580d
...@@ -74,6 +74,8 @@ ParaMath.prototype = ...@@ -74,6 +74,8 @@ ParaMath.prototype =
{ {
// TODO: ParaMath.Get_TextPr // TODO: ParaMath.Get_TextPr
return new CTextPr(); return new CTextPr();
}, },
...@@ -288,6 +290,25 @@ ParaMath.prototype = ...@@ -288,6 +290,25 @@ ParaMath.prototype =
return new CParaPos( this.StartRange, this.StartLine, 0, 0 ); return new CParaPos( this.StartRange, this.StartLine, 0, 0 );
}, },
Get_Default_TPrp: function()
{
var TextPrp = new CTextPr();
var DefaultPrp =
{
FontFamily: {Name : "Cambria Math", Index : -1 },
FontSize: 11,
FontSizeCS: 11,
Italic: true,
Bold: false
};
TextPrp.Set_FromObject(DefaultPrp);
return TextPrp;
},
Apply_TextPr : function(TextPr, IncFontSize, ApplyToAll) Apply_TextPr : function(TextPr, IncFontSize, ApplyToAll)
{ {
// TODO: ParaMath.Apply_TextPr // TODO: ParaMath.Apply_TextPr
...@@ -458,7 +479,7 @@ ParaMath.prototype = ...@@ -458,7 +479,7 @@ ParaMath.prototype =
else else
{ {
PRS.EmptyLine = false; PRS.EmptyLine = false;
PRS.X += WordLen; //PRS.X += WordLen;
// Слово не убирается в отрезке, но, поскольку, слово 1 на строке и отрезок тоже 1, // Слово не убирается в отрезке, но, поскольку, слово 1 на строке и отрезок тоже 1,
// делим слово в данном месте // делим слово в данном месте
...@@ -833,30 +854,31 @@ ParaMath.prototype = ...@@ -833,30 +854,31 @@ ParaMath.prototype =
var Dx = this.Root.size.width; var Dx = this.Root.size.width;
var D = SearchPos.X - SearchPos.CurX; var D = SearchPos.X - SearchPos.CurX;
var Diff = Math.abs(D) < Math.abs(D + Dx) ? Math.abs(D) : Math.abs(D + Dx);
var startDx = Math.abs(D),
endDx = Math.abs(D - Dx);
var Diff = startDx < endDx ? startDx : endDx;
var CurX = SearchPos.CurX; var CurX = SearchPos.CurX;
if(Math.abs(Diff) < SearchPos.DiffX + 0.001 ) if(Math.abs(Diff) < SearchPos.DiffX + 0.001)
{ {
if ( D >= - 0.001 && D <= Dx + 0.001 ) if ( D >= - 0.001 && D <= Dx + 0.001 )
{ {
var X = SearchPos.X, var X = SearchPos.X,
Y = SearchPos.Y; Y = SearchPos.Y;
SearchPos.X -= this.Math.absPos.x; SearchPos.X -= this.Math.absPos.x;
SearchPos.Y -= this.Math.absPos.y; SearchPos.Y -= this.Math.absPos.y;
SearchPos.DiffX = Diff;
this.Root.Get_ParaContentPosByXY(SearchPos, Depth); this.Root.Get_ParaContentPosByXY(SearchPos, Depth);
SearchPos.X = X; SearchPos.X = X;
SearchPos.Y = Y; SearchPos.Y = Y;
Result = true;
////////// //////////
...@@ -864,6 +886,27 @@ ParaMath.prototype = ...@@ -864,6 +886,27 @@ ParaMath.prototype =
SearchPos.DiffX = 0.001; // сравниваем расстояние до ближайшего элемента SearchPos.DiffX = 0.001; // сравниваем расстояние до ближайшего элемента
} }
else if(startDx < endDx)
{
this.Get_StartPos(SearchPos.Pos, Depth);
SearchPos.DiffX = Diff;
}
else
{
this.Get_EndPos(false, SearchPos.Pos, Depth);
SearchPos.DiffX = Diff - 0.0015;
/*var str = "";
for(var i = 0; i < SearchPos.Pos.Data.length; i++)
{
str += SearchPos.Pos.Data[i] + " ";
}
console.log("Get_EndPos : " + str);*/
}
Result = true;
} }
...@@ -956,8 +999,35 @@ ParaMath.prototype = ...@@ -956,8 +999,35 @@ ParaMath.prototype =
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
Set_SelectionContentPos : function(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag) Set_SelectionContentPos : function(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag)
{ {
/*var startStr = "";
if(StartContentPos !== null)
{
for(var i = 0; i < StartContentPos.Data.length; i++)
{
startStr += StartContentPos.Data[i] + " ";
}
console.log("StartContent : " + startStr);
}
var endStr = "";
if(EndContentPos !== null)
{
for(var i = 0; i < EndContentPos.Data.length; i++)
{
endStr += EndContentPos.Data[i] + " ";
}
console.log("EndContent : " + endStr);
}*/
// TODO: ParaMath.Set_SelectionContentPos // TODO: ParaMath.Set_SelectionContentPos
this.Root.Set_SelectionContentPos(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag); this.Root.Set_SelectionContentPos(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag);
this.bSelectionUse = true; this.bSelectionUse = true;
......
...@@ -3966,8 +3966,18 @@ ParaRun.prototype = ...@@ -3966,8 +3966,18 @@ ParaRun.prototype =
TextPr.Merge( StyleTextPr ); TextPr.Merge( StyleTextPr );
} }
// Мержим прямые настройки данного рана if(this.typeObj == MATH_PARA_RUN)
TextPr.Merge( this.Pr ); {
var oWPrp = this.Parent.Get_Default_TPrp();
TextPr.Merge(oWPrp);
TextPr.Merge( this.Pr ); // Мержим прямые настройки данного рана
this.Parent.applyArgSize(TextPr);
}
else
TextPr.Merge( this.Pr ); // Мержим прямые настройки данного рана
// Для совместимости со старыми версиями запишем FontFamily // Для совместимости со старыми версиями запишем FontFamily
TextPr.FontFamily.Name = TextPr.RFonts.Ascii.Name; TextPr.FontFamily.Name = TextPr.RFonts.Ascii.Name;
...@@ -6588,6 +6598,7 @@ ParaRun.prototype.Math_Recalculate = function(RecalcInfo) ...@@ -6588,6 +6598,7 @@ ParaRun.prototype.Math_Recalculate = function(RecalcInfo)
g_oTextMeasurer.SetFont(oWPrp); g_oTextMeasurer.SetFont(oWPrp);
for (var Pos = 0 ; Pos < this.Content.length; Pos++ ) for (var Pos = 0 ; Pos < this.Content.length; Pos++ )
{ {
RecalcInfo.leftRunPrp = RecalcInfo.currRunPrp; RecalcInfo.leftRunPrp = RecalcInfo.currRunPrp;
...@@ -6597,6 +6608,8 @@ ParaRun.prototype.Math_Recalculate = function(RecalcInfo) ...@@ -6597,6 +6608,8 @@ ParaRun.prototype.Math_Recalculate = function(RecalcInfo)
RecalcInfo.Current = this.Content[Pos]; RecalcInfo.Current = this.Content[Pos];
RecalcInfo.setGaps(); RecalcInfo.setGaps();
var compiledTPrp = this.Get_CompiledPr(true);
this.Content[Pos].Resize(g_oTextMeasurer); this.Content[Pos].Resize(g_oTextMeasurer);
var oSize = this.Content[Pos].size; var oSize = this.Content[Pos].size;
......
...@@ -7166,7 +7166,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow ...@@ -7166,7 +7166,7 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
var oCurContainer = oParStruct.cur.elem; var oCurContainer = oParStruct.cur.elem;
if (c_oSerParType.Run === type) if (c_oSerParType.Run === type)
{ {
var oNewRun = new ParaRun(oParStruct.paragraph, true); var oNewRun = new ParaRun(oParStruct.paragraph);
var oRes = { bRes: true }; var oRes = { bRes: true };
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadRun(t, l, oNewRun, oParStruct, oRes); return oThis.ReadRun(t, l, oNewRun, oParStruct, oRes);
......
...@@ -1289,7 +1289,7 @@ CMathBase.prototype = ...@@ -1289,7 +1289,7 @@ CMathBase.prototype =
ContentPos.Add(SelectX); ContentPos.Add(SelectX);
ContentPos.Add(SelectY); ContentPos.Add(SelectY);
if(SelectX !== -1 && SelectY !== -1) if(SelectX !== -1 && SelectY !== -1 && !this.elements[SelectX][SelectY].IsJustDraw())
this.elements[SelectX][SelectY].Get_ParaContentPos(bSelection, bStart, ContentPos); this.elements[SelectX][SelectY].Get_ParaContentPos(bSelection, bStart, ContentPos);
} }
...@@ -1337,8 +1337,8 @@ CMathBase.prototype = ...@@ -1337,8 +1337,8 @@ CMathBase.prototype =
} }
else else
{ {
startX = -2; startX = -1;
startY = -2; startY = -1;
} }
this.SelectStart_X = startX; this.SelectStart_X = startX;
...@@ -1366,7 +1366,7 @@ CMathBase.prototype = ...@@ -1366,7 +1366,7 @@ CMathBase.prototype =
{ {
this.elements[startX][startY].Set_SelectionContentPos(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag); this.elements[startX][startY].Set_SelectionContentPos(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag);
} }
else if(startX !== -2 && startY !== -2) else if(startX !== -1 && startY !== -1)
{ {
this.elements[startX][startY].Set_SelectionContentPos(StartContentPos, null, Depth, StartFlag, -1); this.elements[startX][startY].Set_SelectionContentPos(StartContentPos, null, Depth, StartFlag, -1);
} }
......
...@@ -597,9 +597,9 @@ CMathRunPrp.prototype = ...@@ -597,9 +597,9 @@ CMathRunPrp.prototype =
if(!this.mathPrp.nor) // math text, style: plain if(!this.mathPrp.nor) // math text, style: plain
{ {
var mPrp = this.mathPrp.getTxtPrp();
oWPrp.Merge(this.textPrp); // FontFamily, FontSize etc oWPrp.Merge(this.textPrp); // FontFamily, FontSize etc
var mPrp = this.mathPrp.getTxtPrp();
oWPrp.Merge(mPrp); // bold, italic oWPrp.Merge(mPrp); // bold, italic
} }
else else
...@@ -656,11 +656,16 @@ CMPrp.prototype = ...@@ -656,11 +656,16 @@ CMPrp.prototype =
{ {
Merge: function(mPrp) Merge: function(mPrp)
{ {
// выравнивание
this.aln = mPrp.aln; this.aln = mPrp.aln;
this.brk = mPrp.brk; this.brk = mPrp.brk;
// настройки для букв в контенте
this.lit = mPrp.lit; this.lit = mPrp.lit;
this.nor = mPrp.nor; this.nor = mPrp.nor;
this.typeText = mPrp.typeText; this.typeText = mPrp.typeText;
// настройки bold, italic
this.italic = mPrp.italic; this.italic = mPrp.italic;
this.bold = mPrp.bold; this.bold = mPrp.bold;
this.plain = mPrp.plain; this.plain = mPrp.plain;
...@@ -758,8 +763,9 @@ CMPrp.prototype = ...@@ -758,8 +763,9 @@ CMPrp.prototype =
} }
else if(props.sty === "p") else if(props.sty === "p")
{ {
// plain text ?! // plain text ?! // default
this.plain = true; this.plain = true; // italic = true
// bold = false
} }
if(props.scr === "double-struck") // U+1D538 - U+1D56B if(props.scr === "double-struck") // U+1D538 - U+1D56B
...@@ -5340,28 +5346,7 @@ CMathContent.prototype = ...@@ -5340,28 +5346,7 @@ CMathContent.prototype =
}, },
Resize: function(oMeasure) // пересчитываем всю формулу Resize: function(oMeasure) // пересчитываем всю формулу
{ {
// default для случая с плейсхолдером, RunPrp в контенте отсутствуют var RecalcInfo = new CRecalculateInfo(oMeasure, this);
/*var TxtSettings =
{
type: TXT_ROMAN,
lit: false
};*/
var RecalcInfo = new CRecalculateInfo(oMeasure, this, this.argSize, this.Composition);
/*if(this.content.length > 1)
{
if(this.IsEmptyRun(0))
{
RecalcInfo.Current = this.content[1];
if(this.IsEmptyRun(2))
RecalcInfo.Right = this.content[2];
}
else
RecalcInfo.Current = this.content[0]; // right не прописываем
}*/
for(var pos = 0; pos < this.content.length; pos++) for(var pos = 0; pos < this.content.length; pos++)
{ {
...@@ -5400,25 +5385,9 @@ CMathContent.prototype = ...@@ -5400,25 +5385,9 @@ CMathContent.prototype =
} }
else else
{ {
// to do убрать
this.content[pos].Set_Paragraph(this.Composition.Parent.Paragraph); this.content[pos].Set_Paragraph(this.Composition.Parent.Paragraph);
this.content[pos].Math_Recalculate(RecalcInfo); this.content[pos].Math_Recalculate(RecalcInfo);
} }
/*RecalcInfo.Left = RecalcInfo.Сurrent;
RecalcInfo.Сurrent = RecalcInfo.Right;*/
/*if( pos+1 == this.content.length )
RecalcInfo.Right = null;
else if(this.IsEmptyRun(pos+1))
{
if(pos+2 == this.content.length)
RecalcInfo.Right = null;
else
RecalcInfo.Right = this.content[pos+2];
}
else
pos++;*/
} }
if(RecalcInfo.Current !== null) if(RecalcInfo.Current !== null)
...@@ -5517,28 +5486,6 @@ CMathContent.prototype = ...@@ -5517,28 +5486,6 @@ CMathContent.prototype =
{ {
var bHidePlh = this.plhHide && this.IsPlaceholder(); var bHidePlh = this.plhHide && this.IsPlaceholder();
///// test //////
/*if(!this.bRoot)
{
var xx = x + this.pos.x,
yy = y + this.pos.y,
w = this.size.width,
h = this.size.height;
pGraphics.p_width(1000);
pGraphics.b_color1(0,0,250, 255);
pGraphics._s();
pGraphics._m(xx, yy);
pGraphics._l(xx + w, yy);
pGraphics._l(xx + w, yy + h);
pGraphics._l(xx, yy + h);
pGraphics._l(xx, yy);
pGraphics.df();
}*/
//////////////////////
if( !bHidePlh ) if( !bHidePlh )
{ {
for(var i=0; i < this.content.length;i++) for(var i=0; i < this.content.length;i++)
...@@ -5558,13 +5505,7 @@ CMathContent.prototype = ...@@ -5558,13 +5505,7 @@ CMathContent.prototype =
{ {
pGraphics.b_color1(0,0,0,255); pGraphics.b_color1(0,0,0,255);
var ctrPrp = this.Parent.getCtrPrp(); var oWPrp = this.Parent.getCtrPrp();
/*var rPrp = new CMathTextPrp();
rPrp.Merge(this.Composition.DEFAULT_RUN_PRP);
rPrp.Merge(ctrPrp);*/
var oWPrp = new CTextPr();
oWPrp.Merge(ctrPrp);
this.applyArgSize(oWPrp); this.applyArgSize(oWPrp);
oWPrp.Italic = false; oWPrp.Italic = false;
...@@ -5577,48 +5518,9 @@ CMathContent.prototype = ...@@ -5577,48 +5518,9 @@ CMathContent.prototype =
else else
this.content[i].draw(x, y, pGraphics); this.content[i].draw(x, y, pGraphics);
/*if(this.content[i].value.typeObj == MATH_COMP)
{
var penW = 25.4/96;
var x1 = this.pos.x + x - penW + this.content[i-1].widthToEl,
y1 = this.pos.y + y + penW,
x2 = this.pos.x + x + penW + this.content[i].widthToEl,
y2 = this.pos.y + y + this.size.height - penW;
pGraphics.p_color(0,0,255, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
pGraphics.drawVerLine(0, x2, y1, y2, penW);
}*/
} }
} }
/// TEST
/*if(!this.IsOnlyText())
{
var penW = 25.4/96;
var x1 = this.pos.x + x - penW,
y1 = this.pos.y + y + penW,
x2 = this.pos.x + x + this.size.width + penW,
y2 = this.pos.y + y + this.size.height - penW;
pGraphics.p_color(0,0,255, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
pGraphics.drawVerLine(0, x2, y1, y2, penW);
}*/
/*if(this.bRoot)
{
var penW = 25.4/96;
var x1 = this.pos.x + x - penW,
y1 = this.pos.y + y + penW,
x2 = this.pos.x + x + this.size.width + penW,
y2 = this.pos.y + y + this.size.height - penW;
pGraphics.p_color(0,0,255, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
pGraphics.drawVerLine(0, x2, y1, y2, penW);
}*/
}, },
update_widthContent: function() update_widthContent: function()
{ {
...@@ -7493,6 +7395,18 @@ CMathContent.prototype = ...@@ -7493,6 +7395,18 @@ CMathContent.prototype =
} }
} }
/*if(this.bRoot)
{
var str = "";
for(var i = 0; i < SearchPos.Pos.Data.length; i++)
{
str += SearchPos.Pos.Data[i] + " ";
}
console.log(str);
}*/
}, },
Get_ParaContentPos: function(bSelection, bStart, ContentPos) Get_ParaContentPos: function(bSelection, bStart, ContentPos)
{ {
...@@ -7502,6 +7416,11 @@ CMathContent.prototype = ...@@ -7502,6 +7416,11 @@ CMathContent.prototype =
ContentPos.Add(pos); ContentPos.Add(pos);
this.content[pos].Get_ParaContentPos(bSelection, bStart, ContentPos); this.content[pos].Get_ParaContentPos(bSelection, bStart, ContentPos);
/*if(this.bRoot)
{
console.log("SelectStartPos : " + this.SelectStartPos + " ; SelectEndPos : " + this.SelectEndPos);
}*/
} }
else else
{ {
...@@ -7782,6 +7701,30 @@ CMathContent.prototype = ...@@ -7782,6 +7701,30 @@ CMathContent.prototype =
return result; return result;
}, },
Get_TextPr: function(ContentPos, Depth)
{
var pos = ContentPos.Get(Depth);
Depth++;
if(this.content[pos].typeObj == MATH_PLACEHOLDER)
{
}
else
{
this.content[pos].Get_TextPr(ContentPos, Depth);
}
},
Get_Default_TPrp: function()
{
return this.Composition.Parent.Get_Default_TPrp();
},
////////////////////////// //////////////////////////
//////////////// Test function for test_math ////////////////// //////////////// Test function for test_math //////////////////
......
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