Commit 58bf5513 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander.Trofimov

Переделаны поиск и замена для нового варианта параграфа.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54761 954022d7-b5bf-4e40-9824-e11837661b57
parent 6fca9f40
......@@ -948,6 +948,14 @@ ParaComment.prototype =
Get_Layout : function(DrawingLayout, UseContentPos, ContentPos, Depth)
{
},
Get_NextRunElements : function(RunElements, UseContentPos, Depth)
{
},
Get_PrevRunElements : function(RunElements, UseContentPos, Depth)
{
},
//-----------------------------------------------------------------------------------
// Функции пересчета
//-----------------------------------------------------------------------------------
......
......@@ -26,6 +26,7 @@ function ParaHyperlink()
this.Range = this.Lines[0].Ranges[0];
this.NearPosArray = new Array();
this.SearchMarks = new Array();
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
......@@ -211,6 +212,18 @@ ParaHyperlink.prototype =
if ( ContentPos.Data[Depth] >= Pos )
ContentPos.Data[Depth]++;
}
// Обновляем позиции в поиске
var SearchMarksCount = this.SearchMarks.length;
for ( var Index = 0; Index < SearchMarksCount; Index++ )
{
var Mark = this.SearchMarks[Index];
var ContentPos = ( true === Mark.Start ? Mark.SearchResult.StartPos : Mark.SearchResult.EndPos );
var Depth = Mark.Depth;
if ( ContentPos.Data[Depth] >= Pos )
ContentPos.Data[Depth]++;
}
},
Remove_FromContent : function(Pos, Count, UpdatePosition)
......@@ -294,6 +307,20 @@ ParaHyperlink.prototype =
else if ( ContentPos.Data[Depth] > Pos )
ContentPos.Data[Depth] = Math.max( 0 , Pos );
}
// Обновляем позиции в поиске
var SearchMarksCount = this.SearchMarks.length;
for ( var Index = 0; Index < SearchMarksCount; Index++ )
{
var Mark = this.SearchMarks[Index];
var ContentPos = ( true === Mark.Start ? Mark.SearchResult.StartPos : Mark.SearchResult.EndPos );
var Depth = Mark.Depth;
if ( ContentPos.Data[Depth] > Pos + Count )
ContentPos.Data[Depth] -= Count;
else if ( ContentPos.Data[Depth] > Pos )
ContentPos.Data[Depth] = Math.max( 0 , Pos );
}
},
Add : function(Item)
......@@ -570,6 +597,51 @@ ParaHyperlink.prototype =
return;
}
},
Get_NextRunElements : function(RunElements, UseContentPos, Depth)
{
var CurPos = ( true === UseContentPos ? RunElements.ContentPos.Get(Depth) : 0 );
var ContentLen = this.Content.length;
this.Content[CurPos].Get_NextRunElements( RunElements, UseContentPos, Depth + 1 );
if ( RunElements.Count <= 0 )
return;
CurPos++;
while ( CurPos < ContentLen )
{
this.Content[CurPos].Get_NextRunElements( RunElements, false, Depth + 1 );
if ( RunElements.Count <= 0 )
break;
CurPos++;
}
},
Get_PrevRunElements : function(RunElements, UseContentPos, Depth)
{
var CurPos = ( true === UseContentPos ? RunElements.ContentPos.Get(Depth) : this.Content.length - 1 );
this.Content[CurPos].Get_PrevRunElements( RunElements, UseContentPos, Depth + 1 );
if ( RunElements.Count <= 0 )
return;
CurPos--;
while ( CurPos >= 0 )
{
this.Content[CurPos].Get_PrevRunElements( RunElements, false, Depth + 1 );
if ( RunElements.Count <= 0 )
break;
CurPos--;
}
},
//-----------------------------------------------------------------------------------
// Функции пересчета
//-----------------------------------------------------------------------------------
......
......@@ -474,6 +474,20 @@ Paragraph.prototype =
ParaContentPos.Data[0]++;
}
// Обновляем позиции в SearchResults
for ( var Id in this.SearchResults )
{
var ContentPos = this.SearchResults[Id].StartPos;
if ( ContentPos.Data[0] >= Pos )
ContentPos.Data[0]++;
ContentPos = this.SearchResults[Id].EndPos;
if ( ContentPos.Data[0] >= Pos )
ContentPos.Data[0]++;
}
Item.Set_Paragraph( this );
}
},
......@@ -676,6 +690,20 @@ Paragraph.prototype =
ParaContentPos.Data[0]--;
}
// Обновляем позиции в SearchResults
for ( var Id in this.SearchResults )
{
var ContentPos = this.SearchResults[Id].StartPos;
if ( ContentPos.Data[0] > Pos )
ContentPos.Data[0]--;
ContentPos = this.SearchResults[Id].EndPos;
if ( ContentPos.Data[0] > Pos )
ContentPos.Data[0]--;
}
// Удаляем комментарий, если это необходимо
if ( true === this.DeleteCommentOnRemove && para_Comment === Item.Type )
this.LogicDocument.Remove_Comment( Item.Id, true );
......@@ -9989,6 +10017,53 @@ Paragraph.prototype =
return ContentPos;
},
Get_NextRunElements : function(RunElements)
{
var ContentPos = RunElements.ContentPos;
var CurPos = ContentPos.Get(0);
var ContentLen = this.Content.length;
this.Content[CurPos].Get_NextRunElements( RunElements, true, 1 );
if ( RunElements.Count <= 0 )
return;
CurPos++;
while ( CurPos < ContentLen )
{
this.Content[CurPos].Get_NextRunElements( RunElements, false, 1 );
if ( RunElements.Count <= 0 )
break;
CurPos++;
}
},
Get_PrevRunElements : function(RunElements)
{
var ContentPos = RunElements.ContentPos;
var CurPos = ContentPos.Get(0);
this.Content[CurPos].Get_PrevRunElements( RunElements, true, 1 );
if ( RunElements.Count <= 0 )
return;
CurPos--;
while ( CurPos >= 0 )
{
this.Content[CurPos].Get_PrevRunElements( RunElements, false, 1 );
if ( RunElements.Count <= 0 )
break;
CurPos--;
}
},
Cursor_MoveUp : function(Count, AddToSelect)
{
if ( true !== Debug_ParaRunMode )
......@@ -21336,7 +21411,6 @@ function CParagraphDrawStateHightlights()
this.CurPos = new CParagraphContentPos();
this.DrawColl = false;
this.DrawFind = false;
this.High = new CParaDrawingRangeLines();
this.Coll = new CParaDrawingRangeLines();
......@@ -21346,6 +21420,8 @@ function CParagraphDrawStateHightlights()
this.Comments = new Array();
this.CommentsFlag = comments_NoComment;
this.SearchCounter = 0;
this.Paragraph = undefined;
this.Graphics = undefined;
......@@ -21368,6 +21444,8 @@ CParagraphDrawStateHightlights.prototype =
this.CurPos = new CParagraphContentPos();
this.SearchCounter = 0;
if ( null !== PageEndInfo )
this.Comments = PageEndInfo.Comments;
else
......@@ -21690,4 +21768,11 @@ CParagraphLinesInfo.prototype =
return true;
}
};
\ No newline at end of file
};
function CParagraphRunElements(ContentPos, Count)
{
this.ContentPos = ContentPos;
this.Elements = new Array();
this.Count = Count;
}
\ No newline at end of file
......@@ -39,6 +39,7 @@ function ParaRun(Paragraph)
this.CollaborativeMarks = new Array(); // Массив CParaRunCollaborativeMark
this.NearPosArray = new Array();
this.SearchMarks = new Array();
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
......@@ -349,6 +350,18 @@ ParaRun.prototype =
ContentPos.Data[Depth]++;
}
// Обновляем позиции в поиске
var SearchMarksCount = this.SearchMarks.length;
for ( var Index = 0; Index < SearchMarksCount; Index++ )
{
var Mark = this.SearchMarks[Index];
var ContentPos = ( true === Mark.Start ? Mark.SearchResult.StartPos : Mark.SearchResult.EndPos );
var Depth = Mark.Depth;
if ( ContentPos.Data[Depth] >= Pos )
ContentPos.Data[Depth]++;
}
// Отмечаем, что надо перемерить элементы в данном ране
this.RecalcInfo.Measure = true;
},
......@@ -440,6 +453,20 @@ ParaRun.prototype =
ContentPos.Data[Depth] = Math.max( 0 , Pos );
}
// Обновляем позиции в поиске
var SearchMarksCount = this.SearchMarks.length;
for ( var Index = 0; Index < SearchMarksCount; Index++ )
{
var Mark = this.SearchMarks[Index];
var ContentPos = ( true === Mark.Start ? Mark.SearchResult.StartPos : Mark.SearchResult.EndPos );
var Depth = Mark.Depth;
if ( ContentPos.Data[Depth] > Pos + Count )
ContentPos.Data[Depth] -= Count;
else if ( ContentPos.Data[Depth] > Pos )
ContentPos.Data[Depth] = Math.max( 0 , Pos );
}
// Отмечаем, что надо перемерить элементы в данном ране
this.RecalcInfo.Measure = true;
},
......@@ -858,6 +885,48 @@ ParaRun.prototype =
DrawingLayout.Limits = PageLimits;
}
},
Get_NextRunElements : function(RunElements, UseContentPos, Depth)
{
var StartPos = ( true === UseContentPos ? RunElements.ContentPos.Get(Depth) : 0 );
var ContentLen = this.Content.length;
for ( var CurPos = StartPos; CurPos < ContentLen; CurPos++ )
{
var Item = this.Content[CurPos];
var ItemType = Item.Type;
if ( para_Text === ItemType || para_Space === ItemType || para_Tab === ItemType )
{
RunElements.Elements.push( Item );
RunElements.Count--;
if ( RunElements.Count <= 0 )
return;
}
}
},
Get_PrevRunElements : function(RunElements, UseContentPos, Depth)
{
var StartPos = ( true === UseContentPos ? RunElements.ContentPos.Get(Depth) - 1 : this.Content.length - 1 );
var ContentLen = this.Content.length;
for ( var CurPos = StartPos; CurPos >= 0; CurPos-- )
{
var Item = this.Content[CurPos];
var ItemType = Item.Type;
if ( para_Text === ItemType || para_Space === ItemType || para_Tab === ItemType )
{
RunElements.Elements.push( Item );
RunElements.Count--;
if ( RunElements.Count <= 0 )
return;
}
}
},
//-----------------------------------------------------------------------------------
// Функции пересчета
//-----------------------------------------------------------------------------------
......@@ -2181,6 +2250,8 @@ ParaRun.prototype =
var HighLight = this.Get_CompiledPr(false).HighLight;
var SearchMarksCount = this.SearchMarks.length;
for ( var Pos = StartPos; Pos < EndPos; Pos++ )
{
var Item = this.Content[Pos];
......@@ -2188,21 +2259,16 @@ ParaRun.prototype =
// Определим попадание в поиск и совместное редактирование. Попадание в комментарий определять не надо,
// т.к. класс CParaRun попадает или не попадает в комментарий целиком.
var bDrawSearch = false;
for ( var SPos = 0; SPos < SearchMarksCount; SPos++)
{
var Mark = this.SearchMarks[SPos];
var MarkPos = Mark.SearchResult.StartPos.Get(Mark.Depth);
// TODO: Переделать поиск
// if ( true === bDrawSearch )
// {
// for ( var SId in SearchResults )
// {
// var SResult = SearchResults[SId];
// if ( CurParaPos.Compare( SResult.StartPos ) >= 0 && CurParaPos.Compare( SResult.EndPos ) <= 0 )
// {
// bDrawSearch = true;
// break;
// }
// }
// }
if ( Pos === MarkPos && true === Mark.Start )
PDSH.SearchCounter++;
}
var DrawSearch = ( PDSH.SearchCounter > 0 ? true : false );
var nCollaborativeChanges = 0;
if ( true === bDrawColl )
......@@ -2234,7 +2300,7 @@ ParaRun.prototype =
else if ( highlight_None != HighLight )
aHigh.Add( Y0, Y1, X, X + Item.WidthVisible, 0, HighLight.r, HighLight.g, HighLight.b );
if ( true === bDrawSearch )
if ( true === DrawSearch )
aFind.Add( Y0, Y1, X, X + Item.WidthVisible, 0, 0, 0, 0 );
else if ( nCollaborativeChanges > 0 )
aColl.Add( Y0, Y1, X, X + Item.WidthVisible, 0, 0, 0, 0 );
......@@ -2257,7 +2323,7 @@ ParaRun.prototype =
PDSH.Spaces--;
}
if ( true === bDrawSearch )
if ( true === DrawSearch )
aFind.Add( Y0, Y1, X, X + Item.WidthVisible, 0, 0, 0, 0 );
else if ( nCollaborativeChanges > 0 )
aColl.Add( Y0, Y1, X, X + Item.WidthVisible, 0, 0, 0, 0 );
......@@ -2280,6 +2346,15 @@ ParaRun.prototype =
break;
}
}
for ( var SPos = 0; SPos < SearchMarksCount; SPos++)
{
var Mark = this.SearchMarks[SPos];
var MarkPos = Mark.SearchResult.EndPos.Get(Mark.Depth);
if ( Pos + 1 === MarkPos && true !== Mark.Start )
PDSH.SearchCounter--;
}
}
// Обновим позицию X
......
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