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

1. Реализовала поиск текста в формулах

2. Поправила баг при смене любых текстовых настроек для математического текста менялся шрифт на Cambria Math (сейчас только при смене Font)
3. Реализовала заливку для формул (http://bugzserver/show_bug.cgi?id=26912), кроме случая с EqArray

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@59279 954022d7-b5bf-4e40-9824-e11837661b57
parent d3d24b98
......@@ -108,11 +108,11 @@ ParaMath.prototype.Set_Paragraph = function(Paragraph)
ParaMath.prototype.Is_Empty = function()
{
if (this.Root.content.length <= 0)
if (this.Root.Content.length <= 0)
return true;
if (1 === this.Root.content.length)
return this.Root.content[0].Is_Empty({SkipPlcHldr : true});
if (1 === this.Root.Content.length)
return this.Root.Content[0].Is_Empty({SkipPlcHldr : true});
return false;
};
......@@ -163,7 +163,7 @@ ParaMath.prototype.Add = function(Item)
var oContent = oSelectedContent.Content;
var StartPos = oSelectedContent.Start;
var Run = oContent.content[StartPos];
var Run = oContent.Content[StartPos];
// Мы вставляем только в Run
if (para_Math_Run !== Run.Type)
......@@ -207,10 +207,10 @@ ParaMath.prototype.Add = function(Item)
oContent.Internal_Content_Add(StartPos + 1, RightRun, false);
oContent.CurPos = StartPos;
var lng = oContent.content.length;
var lng = oContent.Content.length;
oContent.Load_FromMenu(Item.Menu, this.Paragraph);
var lng2 = oContent.content.length;
var lng2 = oContent.Content.length;
oContent.Set_MathTextPr2(MathTxtPr.TextPr, MathTxtPr.MathPr, false, StartPos + 1, lng2 - lng);
oContent.CurPos = StartPos + 2; // позиция RightRun
......@@ -245,7 +245,7 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText)
{
if (false === oElement.Remove(Direction) && true !== this.bSelectionUse)
{
if ((Direction > 0 && oContent.content.length - 1 === nStartPos) || (Direction < 0 && 0 === nStartPos))
if ((Direction > 0 && oContent.Content.length - 1 === nStartPos) || (Direction < 0 && 0 === nStartPos))
{
// Проверяем находимся ли мы на верхнем уровне
if (oContent.bRoot)
......@@ -324,8 +324,8 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText)
oContent.CurPos = nStartPos;
if (para_Math_Run === oContent.content[nStartPos].Type)
oContent.content[nStartPos].Cursor_MoveToStartPos();
if (para_Math_Run === oContent.Content[nStartPos].Type)
oContent.Content[nStartPos].Cursor_MoveToStartPos();
oContent.Correct_Content();
oContent.Correct_ContentPos(-1); // -1, потому что нам надо встать перед элементом, а не после
......@@ -688,7 +688,7 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
if ( true !== PRS.NewRange )
{
RangeEndPos = this.Root.content.length; // RangeEndPos = 1; to RangeEndPos = this.Content.length;
RangeEndPos = this.Root.Content.length; // RangeEndPos = 1; to RangeEndPos = this.Content.length;
// Обновляем метрику строки
if ( PRS.LineAscent < this.Ascent )
......@@ -1273,12 +1273,13 @@ ParaMath.prototype.Draw_HighLights = function(PDSH)
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
var X = PDSH.X;
if ( EndPos >= 1 )
{
PDSH.X += this.Width;
this.Root.Draw_HighLights(PDSH, false);
}
};
ParaMath.prototype.Draw_Elements = function(PDSE)
{
var CurLine = PDSE.Line - this.StartLine;
......@@ -1714,7 +1715,7 @@ ParaMath.prototype.Handle_AddNewLine = function()
var Run = CurrContent.getElem(0);
Run.Remove_FromContent(0, Run.Content.length, true);
CurrContent.Remove_FromContent(1, CurrContent.content.length);
CurrContent.Remove_FromContent(1, CurrContent.Content.length);
CurrContent.Add_ToContent(1, EqArray);
......@@ -1751,18 +1752,18 @@ ParaMath.prototype.Split = function (ContentPos, Depth)
//var Pos = ContentPos.Get(Depth);
/*if(this.Root.content[Pos].Type == para_Math_Run)
/*if(this.Root.Content[Pos].Type == para_Math_Run)
{
var NewRun = this.Root.content[Pos].Split(ContentPos, Depth+1);
var NewRun = this.Root.Content[Pos].Split(ContentPos, Depth+1);
NewParaMath.Root.Add_ToContent(0, NewRun);
var len = this.Root.content.length;
var len = this.Root.Content.length;
if(Pos < len - 1)
{
NewParaMath.Root.Concat_ToContent( this.Root.content.slice(Pos + 1) );
NewParaMath.Root.Concat_ToContent( this.Root.Content.slice(Pos + 1) );
this.Root.Remove_FromContent(Pos+1, len - Pos - 1);
}
......
......@@ -1126,7 +1126,7 @@ ParaRun.prototype.Get_NextRunElements = function(RunElements, UseContentPos, Dep
var Item = this.Content[CurPos];
var ItemType = Item.Type;
if ( para_Text === ItemType || para_Space === ItemType || para_Tab === ItemType )
if ( para_Text === ItemType || para_Space === ItemType || para_Tab === ItemType)
{
RunElements.Elements.push( Item );
RunElements.Count--;
......@@ -3235,6 +3235,8 @@ ParaRun.prototype.Draw_HighLights = function(PDSH)
case para_Drawing:
case para_Tab:
case para_Text:
case para_Math_Text:
case para_Math_Ampersand:
case para_Sym:
{
if ( para_Drawing === ItemType && drawing_Anchor === Item.DrawingType )
......@@ -5121,15 +5123,19 @@ ParaRun.prototype.Apply_Pr = function(TextPr)
if ( undefined != TextPr.RFonts )
{
if(this.Type == para_Math_Run && !this.IsNormalText()) // при смене Font в этом случае (даже на Cambria Math) cs, eastAsia не меняются
if(this.Type == para_Math_Run && !this.IsNormalText()) // при смене Font в этом случае (даже на Cambria Math) cs, eastAsia не меняются
{
var RFonts =
// делаем так для проверки действительно ли нужно сменить Font, чтобы при смене других текстовых настроек не выставился Cambria Math (TextPr.RFonts приходит всегда в виде объекта)
if(TextPr.RFonts.Ascii !== undefined || TextPr.RFonts.HAnsi !== undefined)
{
Ascii: {Name: "Cambria Math", Index: -1},
HAnsi: {Name: "Cambria Math", Index: -1}
};
var RFonts =
{
Ascii: {Name: "Cambria Math", Index: -1},
HAnsi: {Name: "Cambria Math", Index: -1}
};
this.Set_RFonts2(RFonts);
this.Set_RFonts2(RFonts);
}
}
else
this.Set_RFonts2(TextPr.RFonts);
......
......@@ -981,7 +981,7 @@ ParaRun.prototype.Search = function(ParaSearch, Depth)
ParaSearch.Reset();
}
if ( (" " === Str[ParaSearch.SearchIndex] && para_Space === Item.Type) || ( para_Text === Item.Type && ( ( true != MatchCase && (String.fromCharCode(Item.Value)).toLowerCase() === Str[ParaSearch.SearchIndex].toLowerCase() ) || ( true === MatchCase && Item.Value === Str.charCodeAt(ParaSearch.SearchIndex) ) ) ) )
if ( (" " === Str[ParaSearch.SearchIndex] && para_Space === Item.Type)|| (para_Math_Text == Item.Type && Item.value === Str.charCodeAt(ParaSearch.SearchIndex)) || ( para_Text === Item.Type && ( ( true != MatchCase && (String.fromCharCode(Item.Value)).toLowerCase() === Str[ParaSearch.SearchIndex].toLowerCase() ) || ( true === MatchCase && Item.Value === Str.charCodeAt(ParaSearch.SearchIndex) ) ) ) )
{
if ( 0 === ParaSearch.SearchIndex )
{
......@@ -1253,24 +1253,33 @@ ParaComment.prototype.Search_GetId = function(bNext, bUseContentPos, ContentPos,
ParaMath.prototype.Search = function(ParaSearch, Depth)
{
// Обнуляем поиск
ParaSearch.Reset();
//ParaSearch.Reset();
this.SearchMarks = [];
this.Root.Search(ParaSearch, Depth);
};
ParaMath.prototype.Add_SearchResult = function(SearchResult, Start, ContentPos, Depth)
{
this.Root.Add_SearchResult(SearchResult, Start, ContentPos, Depth);
};
ParaMath.prototype.Clear_SearchResults = function()
{
this.Root.Clear_SearchResults();
};
ParaMath.prototype.Remove_SearchResult = function(SearchResult)
{
this.Root.Remove_SearchResult(SearchResult);
};
ParaMath.prototype.Search_GetId = function(bNext, bUseContentPos, ContentPos, Depth)
{
return null;
return this.Root.Search_GetId(bNext, bUseContentPos, ContentPos, Depth);
//return null;
};
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -466,7 +466,6 @@ CAccent.prototype.fillContent = function()
{
this.setDimension(1, 1);
this.elements[0][0] = this.getBase();
this.elements[0][0].SetDot(true);
};
CAccent.prototype.IsAccent = function()
{
......
......@@ -368,9 +368,12 @@ CMathBase.prototype =
if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
for(var Pos = 0; Pos < this.Content.length; Pos++)
this.Content[Pos].SetParent(this, ParaMath);
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
this.elements[i][j].PreRecalc(this, ParaMath, ArgSize, RPI);
this.elements[i][j].PreRecalc(this, ParaMath, ArgSize, RPI);
},
recalculateSize: function(oMeasure, RPI)
......@@ -659,6 +662,8 @@ CMathBase.prototype =
{
if(TextPr.FontSize !== undefined)
this.Set_FontSizeCtrPrp(TextPr.FontSize);
else if(TextPr.Shd !== undefined)
this.Set_Shd(TextPr.Shd);
}
for(var i=0; i < this.nRow; i++)
......@@ -670,6 +675,7 @@ CMathBase.prototype =
}
}
},
GetMathTextPr: function(ContentPos, Depth)
{
var pos = ContentPos.Get(Depth);
......@@ -688,7 +694,26 @@ CMathBase.prototype =
History.Add(this, new CChangesMathFontSize(Value, this.CtrPrp.FontSize));
this.raw_SetFontSize(Value);
},
Set_Shd: function(Shd)
{
if ( (undefined === this.CtrPrp.Shd && undefined === Shd) || (undefined !== this.CtrPrp.Shd && undefined !== Shd && true === this.CtrPrp.Shd.Compare( Shd ) ) )
return;
//var OldShd = this.CtrPrp.Shd;
if ( undefined !== Shd )
{
this.CtrPrp.Shd = new CDocumentShd();
this.CtrPrp.Shd.Set_FromObject( Shd );
}
else
this.CtrPrp.Shd = undefined;
this.RecalcInfo.bCtrPrp = true;
if (null !== this.ParaMath)
this.ParaMath.SetNeedResize();
},
raw_SetFontSize : function(Value)
{
this.CtrPrp.FontSize = Value;
......@@ -975,13 +1000,33 @@ CMathBase.prototype.Select_MathContent = function(MathContent)
}
}
};
CMathBase.prototype.Test_Math_SetStyleNormal = function(Value, bAll)
CMathBase.prototype.Draw_HighLights = function(PDSH, bAll)
{
for(var i = 0; i < this.Content.length; i++)
{
this.Content[i].Test_Math_SetStyleNormal(Value, bAll);
}
}
var oShd = this.Get_CompiledCtrPrp().Shd;
var bDrawShd = ( oShd === undefined || shd_Nil === oShd.Value ? false : true );
var ShdColor = ( true === bDrawShd ? oShd.Get_Color( PDSH.Paragraph ) : null );
var X = PDSH.X,
Y0 = PDSH.Y0,
Y1 = PDSH.Y1;
var bAllCont = this.Selection.StartPos !== this.Selection.EndPos;
for (var CurPos = 0; CurPos < this.Content.length; CurPos++)
this.Content[CurPos].Draw_HighLights(PDSH, bAllCont);
if (true === bDrawShd)
PDSH.Shd.Add(Y0, Y1, X, X + this.size.width, 0, ShdColor.r, ShdColor.g, ShdColor.b );
PDSH.X = this.pos.x + this.ParaMath.X + this.size.width;
};
CMathBase.prototype.Search = ParaHyperlink.prototype.Search;
CMathBase.prototype.Add_SearchResult = ParaHyperlink.prototype.Add_SearchResult;
CMathBase.prototype.Clear_SearchResults = ParaHyperlink.prototype.Clear_SearchResults;
CMathBase.prototype.Remove_SearchResult = ParaHyperlink.prototype.Remove_SearchResult;
CMathBase.prototype.Search_GetId = ParaHyperlink.prototype.Search_GetId;
CMathBase.prototype.Set_SelectionContentPos = ParaHyperlink.prototype.Set_SelectionContentPos;
CMathBase.prototype.Get_LeftPos = ParaHyperlink.prototype.Get_LeftPos;
......
This diff is collapsed.
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