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

select for Editor

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52420 954022d7-b5bf-4e40-9824-e11837661b57
parent ba805154
......@@ -12,6 +12,11 @@ function CMathBase()
this.CurPos_X = 0;
this.CurPos_Y = 0;
this.selectPos =
{
startX: 0,
startY: 0
};
this.reduct = 1;
this.nRow = 0;
......@@ -19,8 +24,6 @@ function CMathBase()
this.Parent = null;
this.Composition = null; // ссылка на общую формулу
/*this.TxtPrp = new CMathTextPrp();
this.OwnTPrp = new CMathTextPrp();*/
this.CtrPrp = new CTextPr();
......@@ -973,13 +976,68 @@ CMathBase.prototype =
var content = this.elements[pos.X][pos.Y].getContent(stack, bCurrent);
return content;
},
setTypeElement: function(type)
{
this.typeElement = type;
},
getTypeElement: function()
//// For Edit /////
/*getSelectContent: function(x, y)
{
var state = true, SelectContent = null;
var elem = this.findDisposition({x: x, y: y});
var X = elem.mCoord.x,
Y = elem.mCoord.y;
if(elem.pos.x == this.CurPos_X && elem.pos.y == this.CurPos_Y && elem.inside_flag === -1 )
{
var movement = this.elements[this.CurPos_X][this.CurPos_Y].getSelectContent(X, Y);
SelectContent = movement.SelectContent;
state = true;
}
else
state = false;
return {state: state, SelectContent: SelectContent};
}*/
selection_Start: function(x, y)
{
var elem = this.findDisposition({x: x, y: y});
var X = elem.mCoord.x,
Y = elem.mCoord.y,
Pos_X = elem.pos.x,
Pos_Y = elem.pos.y;
this.selectPos.startX = Pos_X;
this.selectPos.startY = Pos_Y;
var result = this.elements[Pos_X][Pos_Y].selection_Start(X, Y);
return result;
},
selection_End: function(x, y)
{
return this.typeElement;
var state = true, SelectContent = null;
var elem = this.findDisposition({x: x, y: y});
var X = elem.mCoord.x,
Y = elem.mCoord.y,
bInside = elem.inside_flag;
var endX = elem.pos.x,
endY = elem.pos.y,
startX = this.selectPos.startX,
startY = this.selectPos.startY;
if(startX == endX && startY == endY && bInside === -1)
{
var movement = this.elements[endX][endY].selection_End(X, Y);
SelectContent = movement.SelectContent;
state = true;
}
else
state = false;
return {state: state, SelectContent: SelectContent};
}
}
......@@ -5698,16 +5698,106 @@ CMathContent.prototype =
/////// selection for Edit ////////
selection_Start: function(x, y)
{
return this.getSelectContent(x, y);
var SelectContent = null;
if(this.IsPlaceholder())
{
SelectContent = this;
}
else
{
var msCoord = this.coordWOGaps({x: x, y: y});
var pos = this.findPosition( msCoord);
this.setStartPos_Selection(pos);
if(this.content[pos].value.typeObj === MATH_COMP)
{
var coord = this.getCoordElem(pos, msCoord);
var movement = this.content[pos].value.selection_Start(coord.x, coord.y);
SelectContent = movement.SelectContent;
}
else
{
/*if ( this.content[pos].value.typeObj === MATH_COMP )
{
if( direction == 1 )
this.setStartPos_Selection( this.CurPos - 1);
else if( direction == -1 )
this.setStartPos_Selection( this.CurPos + 1);
}
else
this.setStartPos_Selection( this.CurPos );*/
SelectContent = this;
}
}
return {SelectContent: SelectContent};
},
/////////////////////
selection_End: function(x, y, MouseEvent)
{
// реализовано через две ф-ии, т.к. впоследствии нужно будет учитывать MouseEvent
// впоследствии нужно будет учитывать MouseEvent
var state = true; // вышли / не вышли за переделы контента
var SelectContent = null;
if(this.IsPlaceholder())
{
SelectContent = this;
}
else
{
var msCoord = this.coordWOGaps({x: x, y: y});
var posEnd = this.findPosition(msCoord),
posStart = this.selection.startPos - 1;
//селект внутри элемента (дроби и пр.)
if(posStart === posEnd && this.content[posEnd].value.typeObj === MATH_COMP)
{
var coord = this.getCoordElem(posEnd, msCoord );
var movement = this.content[posEnd].value.selection_End(coord.x, coord.y);
if( ! movement.state )
{
this.setEnd_Selection(posEnd + 1);
SelectContent = this;
}
else
SelectContent = movement.SelectContent;
}
//селект элементов контента
else
{
SelectContent = this;
return this.getSelectContent(x, y);
var direction = (posStart < posEnd) ? 1 : -1;
if(this.content[posStart].value.typeObj === MATH_COMP)
{
if( direction == 1 )
this.setStartPos_Selection( posStart - 1); // переопределяем
else if( direction == -1 )
this.setStartPos_Selection( posStart + 1); // переопределяем
}
if( this.content[posEnd].value.typeObj === MATH_COMP )
{
if( direction == 1 )
this.setEndPos_Selection(posEnd + 1);
else if( direction == -1 )
this.setEndPos_Selection(posEnd - 1);
}
else
this.setEndPos_Selection(posEnd);
}
}
return {state: state, SelectContent: SelectContent};
},
getSelectContent: function(x, y)
/*getSelectContent: function(x, y)
{
var state = true; // вышли / не вышли за переделы контента
var SelectContent = null;
......@@ -5767,7 +5857,7 @@ CMathContent.prototype =
}
return {state: state, SelectContent: SelectContent }; //для CMathContent state всегда true
},
},*/
setStartPos_Selection: function( StartIndSelect )
{
if( this.content.length != 1)
......@@ -5881,6 +5971,7 @@ CMathComposition.prototype =
{
if(this.Root.content.length > 1)
{
this.pos = {x: x, y: y - this.Root.size.center};
this.Root.setPosition({x: x, y: y - this.Root.size.center});
this.Root.draw(pGraphics);
this.UpdateCursor();
......@@ -6487,18 +6578,24 @@ CMathComposition.prototype =
},
Selection_SetStart: function(X, Y, PageNum)
{
var result = this.Root.selection_Start(X, Y);
var x = X - this.pos.x,
y = Y - this.pos.y;
var result = this.Root.selection_Start(x, y);
//this.SelectContent = result.SelectContent; // если SetEnd придет раньше
},
Selection_SetEnd: function(X, Y, PageNum, MouseEvent)
{
var result = this.Root.selection_End(X, Y, MouseEvent);
var x = X - this.pos.x,
y = Y - this.pos.y;
var result = this.Root.selection_End(x, y, MouseEvent);
this.SelectContent = result.SelectContent;
},
Selection_Draw: function()
{
this.SelectContent.drawSelect();
this.SelectContent.drawSelect2();
},
Selection_Beginning: function()
{
......
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