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

Перемещение по словам : Get_WordStartPos, Get_WordEndPos

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56730 954022d7-b5bf-4e40-9824-e11837661b57
parent 180462b3
......@@ -1304,13 +1304,13 @@ ParaMath.prototype =
Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos)
{
// TODO: ParaMath.Get_StartEndPos
this.Root.Get_WordStartPos(SearchPos, ContentPos, Depth, UseContentPos);
this.Root.Get_WordStartPos(SearchPos, ContentPos, Depth, UseContentPos, false);
},
Get_WordEndPos : function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd)
{
// TODO: ParaMath.Get_WordEndPos
this.Root.Get_WordEndPos(SearchPos, ContentPos, Depth, UseContentPos, StepEnd);
this.Root.Get_WordEndPos(SearchPos, ContentPos, Depth, UseContentPos, StepEnd, false);
},
Get_EndRangePos : function(_CurLine, _CurRange, SearchPos, Depth)
......
......@@ -3747,7 +3747,7 @@ ParaRun.prototype =
else
{
// Если мы остановились на нетекстовом элементе, тогда его и возвращаем
if ( para_Text !== this.Content[CurPos].Type )
if ( para_Text !== this.Content[CurPos].Type && para_Math_Text !== this.Content[CurPos].Type)
{
SearchPos.Pos.Update( CurPos, Depth );
SearchPos.Found = true;
......@@ -3775,10 +3775,10 @@ ParaRun.prototype =
while ( CurPos > 0 )
{
CurPos--;
var Item = this.Content[CurPos]
var Item = this.Content[CurPos];
var TempType = Item.Type;
if ( para_Text !== TempType || true === Item.Is_NBSP() || ( true === SearchPos.Punctuation && true !== Item.Is_Punctuation() ) || ( false === SearchPos.Punctuation && false !== Item.Is_Punctuation() ) )
if ( (para_Text !== TempType && para_Math_Text !== TempType) || true === Item.Is_NBSP() || ( true === SearchPos.Punctuation && true !== Item.Is_Punctuation() ) || ( false === SearchPos.Punctuation && false !== Item.Is_Punctuation() ) )
{
SearchPos.Found = true;
break;
......@@ -3812,7 +3812,7 @@ ParaRun.prototype =
var Type = Item.Type;
var bText = false;
if ( para_Text === Type && true != Item.Is_NBSP() && ( true === SearchPos.First || ( SearchPos.Punctuation === Item.Is_Punctuation() ) ) )
if ( (para_Text === Type || para_Math_Text === Type) && true != Item.Is_NBSP() && ( true === SearchPos.First || ( SearchPos.Punctuation === Item.Is_Punctuation() ) ) )
bText = true;
if ( true === bText )
......
......@@ -1575,7 +1575,7 @@ CMathBase.prototype =
return result;
},
Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos)
old_Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos)
{
var CurPos_X, CurPos_Y;
......@@ -1620,9 +1620,101 @@ CMathBase.prototype =
}
},
Get_WordEndPos : function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd)
Get_WordStartPos: function(SearchPos, ContentPos, Depth, UseContentPos, EndRun)
{
var CurPos_X, CurPos_Y;
if(UseContentPos === true)
{
CurPos_X = ContentPos.Get(Depth);
CurPos_Y = ContentPos.Get(Depth + 1);
}
else
{
CurPos_X = this.nRow - 1;
CurPos_Y = this.nCol - 1;
}
var bUseContent = UseContentPos;
while(CurPos_X >= 0)
{
while(CurPos_Y >= 0)
{
var bJDraw = this.elements[CurPos_X][CurPos_Y].IsJustDraw(),
usePlh = !bJDraw && bUseContent && this.elements[CurPos_X][CurPos_Y].IsPlaceholder();
if(!bJDraw && !usePlh)
{
this.elements[CurPos_X][CurPos_Y].Get_WordStartPos(SearchPos, ContentPos, Depth + 2, bUseContent, EndRun);
SearchPos.Pos.Update(CurPos_X, Depth);
SearchPos.Pos.Update(CurPos_Y, Depth+1);
}
if(SearchPos.Found === true)
break;
CurPos_Y--;
bUseContent = false;
EndRun = true;
}
if(SearchPos.Found === true)
break;
CurPos_X--;
CurPos_Y = this.nCol - 1;
}
},
Get_WordEndPos : function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd, BegRun)
{
var CurPos_X, CurPos_Y;
if(UseContentPos === true)
{
CurPos_X = ContentPos.Get(Depth);
CurPos_Y = ContentPos.Get(Depth + 1);
}
else
{
CurPos_X = 0;
CurPos_Y = 0;
}
var bUseContent = UseContentPos;
while(CurPos_X < this.nRow)
{
while(CurPos_Y < this.nCol)
{
var bJDraw = this.elements[CurPos_X][CurPos_Y].IsJustDraw(),
usePlh = !bJDraw && bUseContent && this.elements[CurPos_X][CurPos_Y].IsPlaceholder();
if(!bJDraw && !usePlh)
{
this.elements[CurPos_X][CurPos_Y].Get_WordEndPos(SearchPos, ContentPos, Depth + 2, bUseContent, StepEnd, BegRun);
SearchPos.Pos.Update(CurPos_X, Depth);
SearchPos.Pos.Update(CurPos_Y, Depth+1);
}
if(SearchPos.Found === true)
break;
CurPos_Y++;
bUseContent = false;
BegRun = true;
}
if(SearchPos.Found === true)
break;
CurPos_X++;
CurPos_Y = 0;
}
},
//////////////////////////////////
IsPlaceholder: function()
......
......@@ -6464,7 +6464,7 @@ CMathContent.prototype =
return result;
},
Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos)
old_Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos)
{
var CurPos = ( true === UseContentPos ? ContentPos.Get(Depth) : this.content.length - 1 );
......@@ -6508,9 +6508,104 @@ CMathContent.prototype =
}
},
Get_WordEndPos : function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd)
Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos, EndRun)
{
var CurPos = UseContentPos ? ContentPos.Get(Depth) : this.content.length-1;
var bUseContent = UseContentPos;
while(CurPos >= 0 && SearchPos.Found == false)
{
var curType = this.content[CurPos].typeObj,
prevType = CurPos > 0 ? this.content[CurPos - 1].typeObj : null;
if(curType == MATH_PLACEHOLDER)
{
SearchPos.Pos.Update(0, Depth + 1);
SearchPos.Found = true;
}
else if(curType == MATH_COMP)
{
this.content[CurPos].Get_WordStartPos(SearchPos, ContentPos, Depth + 1, bUseContent, EndRun);
}
else if(EndRun)
{
SearchPos.Pos.Update(this.content[CurPos].Content.length, Depth + 1);
SearchPos.Found = true;
}
else
{
this.content[CurPos].Get_WordStartPos(SearchPos, ContentPos, Depth + 1, bUseContent);
if(SearchPos.Found == false && SearchPos.Shift == true)
{
this.content[CurPos].Get_StartPos(SearchPos.Pos, Depth + 1);
SearchPos.Found = true;
}
}
SearchPos.Pos.Update(CurPos, Depth);
if(curType == MATH_PARA_RUN && prevType == MATH_PARA_RUN)
EndRun = false;
else
EndRun = true;
CurPos--;
bUseContent = false;
}
},
Get_WordEndPos : function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd, BegRun)
{
var CurPos = UseContentPos ? ContentPos.Get(Depth) : 0;
var bUseContent = UseContentPos;
while(CurPos < this.content.length && SearchPos.Found == false)
{
var curType = this.content[CurPos].typeObj,
nextType = CurPos < this.content.length - 1 ? this.content[CurPos + 1].typeObj : null;
if(curType == MATH_PLACEHOLDER)
{
SearchPos.Pos.Update(0, Depth + 1);
SearchPos.Found = true;
}
else if(curType == MATH_COMP)
{
this.content[CurPos].Get_WordEndPos(SearchPos, ContentPos, Depth + 1, bUseContent, StepEnd, BegRun);
}
else if(BegRun)
{
SearchPos.Pos.Update(0, Depth + 1);
SearchPos.Found = true;
}
else
{
this.content[CurPos].Get_WordEndPos(SearchPos, ContentPos, Depth + 1, bUseContent, StepEnd);
if(SearchPos.Found == false && SearchPos.Shift == true)
{
this.content[CurPos].Get_EndPos(false, SearchPos.Pos, Depth + 1);
SearchPos.Found = true;
}
}
SearchPos.Pos.Update(CurPos, Depth);
if(curType == MATH_PARA_RUN && nextType == MATH_PARA_RUN)
BegRun = false;
else
BegRun = true;
CurPos++;
bUseContent = false;
}
},
/////////////////////////
getContent: function(stack, bCurrent)
......
......@@ -398,6 +398,20 @@ CMathText.prototype =
this.type = type;
},
// For ParaRun
Is_Punctuation: function()
{
var bPunc = 1 === g_aPunctuation[this.value],
bMathSign = this.value == 0x2217 || this.value == 0x2212;
return bPunc || bMathSign;
},
Is_NBSP: function()
{
return false;
},
////
// for Para Math
// for placeholder
Set_SelectionContentPos: function(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag)
......
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