Commit 2dee4b6b authored by Ilya.Kirillov's avatar Ilya.Kirillov

В CDocument добавлена функция Get_SelectionBounds для получения границ...

В CDocument добавлена функция Get_SelectionBounds для получения границ селекта. В формулах функция Correct_Content реализована через Content.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58852 954022d7-b5bf-4e40-9824-e11837661b57
parent 6ce3fb99
...@@ -8035,6 +8035,46 @@ CDocument.prototype = ...@@ -8035,6 +8035,46 @@ CDocument.prototype =
} }
}, },
Get_SelectionBounds : function()
{
// Работаем с колонтитулом
if ( docpostype_HdrFtr === this.CurPos.Type )
{
return this.HdrFtr.CurHdrFtr.Content.Get_SelectionBounds();
}
else if ( docpostype_DrawingObjects === this.CurPos.Type )
{
return this.DrawingObjects.Get_SelectionBounds();
}
else
{
if (true === this.Selection.Use && selectionflag_Common === this.Selection.Flag)
{
var Start = this.Selection.StartPos;
var End = this.Selection.EndPos;
if ( Start > End )
{
Start = this.Selection.EndPos;
End = this.Selection.StartPos;
}
if (Start === End)
return this.Content[Start].Get_SelectionBounds();
else
{
var Result = {};
Result.Start = this.Content[Start].Get_SelectionBounds().Start;
Result.End = this.Content[End].Get_SelectionBounds().End;
return Result;
}
}
}
return this.Content[0].Get_SelectionBounds();
},
Selection_Clear : function() Selection_Clear : function()
{ {
if ( true === this.Selection.Use ) if ( true === this.Selection.Use )
......
...@@ -9053,6 +9053,33 @@ CDocumentContent.prototype = ...@@ -9053,6 +9053,33 @@ CDocumentContent.prototype =
return false; return false;
}, },
Get_SelectionBounds : function()
{
if (true === this.Selection.Use)
{
var Start = this.Selection.StartPos;
var End = this.Selection.EndPos;
if (Start > End)
{
Start = this.Selection.EndPos;
End = this.Selection.StartPos;
}
if (Start === End)
return this.Content[Start].Get_SelectionBounds();
else
{
var Result = {};
Result.Start = this.Content[Start].Get_SelectionBounds().Start;
Result.End = this.Content[End].Get_SelectionBounds().End;
return Result;
}
}
return this.Content[0].Get_SelectionBounds();
},
Get_SelectionAnchorPos : function() Get_SelectionAnchorPos : function()
{ {
var Pos = ( true === this.Selection.Use ? ( this.Selection.StartPos < this.Selection.EndPos ? this.Selection.StartPos : this.Selection.EndPos ) : this.CurPos.ContentPos ); var Pos = ( true === this.Selection.Use ? ( this.Selection.StartPos < this.Selection.EndPos ? this.Selection.StartPos : this.Selection.EndPos ) : this.CurPos.ContentPos );
......
...@@ -5989,6 +5989,129 @@ Paragraph.prototype = ...@@ -5989,6 +5989,129 @@ Paragraph.prototype =
this.Set_SelectionContentPos( StartPos, EndPos ); this.Set_SelectionContentPos( StartPos, EndPos );
}, },
Get_SelectionBounds : function()
{
var X0 = this.X, X1 = this.XLimit, Y = this.Y, Page = this.Get_StartPage_Absolute();
var BeginRect = null;
var EndRect = null;
var StartPage_abs = this.Get_StartPage_Absolute();
if (true === this.Selection.Use)
{
var StartPos = this.Selection.StartPos;
var EndPos = this.Selection.EndPos;
if ( StartPos > EndPos )
{
StartPos = this.Selection.EndPos;
EndPos = this.Selection.StartPos;
}
var LinesCount = this.Lines.length;
var StartLine = -1;
var EndLine = -1;
for (var CurLine = 0; CurLine < LinesCount; CurLine++ )
{
if ( -1 === StartLine && StartPos >= this.Lines[CurLine].Get_StartPos() && StartPos <= this.Lines[CurLine].Get_EndPos() )
StartLine = CurLine;
if ( EndPos >= this.Lines[CurLine].Get_StartPos() && EndPos <= this.Lines[CurLine].Get_EndPos() )
EndLine = CurLine;
}
StartLine = Math.min( Math.max( 0, StartLine ), LinesCount - 1 );
EndLine = Math.min( Math.max( 0, EndLine ), LinesCount - 1 );
var PagesCount = this.Pages.length;
var DrawSelection = new CParagraphDrawSelectionRange();
DrawSelection.Draw = false;
for ( var CurLine = StartLine; CurLine <= EndLine; CurLine++ )
{
var Line = this.Lines[CurLine];
var RangesCount = Line.Ranges.length;
// Определим номер страницы
var CurPage = 0;
for (; CurPage < PagesCount; CurPage++ )
{
if ( CurLine >= this.Pages[CurPage].StartLine && CurLine <= this.Pages[CurPage].EndLine )
break;
}
CurPage = Math.min( PagesCount - 1, CurPage );
// Определяем позицию и высоту строки
DrawSelection.StartY = this.Pages[CurPage].Y + this.Lines[CurLine].Top;
DrawSelection.H = this.Lines[CurLine].Bottom - this.Lines[CurLine].Top;
var Result = null;
for ( var CurRange = 0; CurRange < RangesCount; CurRange++ )
{
var Range = Line.Ranges[CurRange];
var RStartPos = Range.StartPos;
var REndPos = Range.EndPos;
// Если пересечение пустое с селектом, тогда пропускаем данный отрезок
if ( StartPos > REndPos || EndPos < RStartPos )
continue;
DrawSelection.StartX = this.Lines[CurLine].Ranges[CurRange].XVisible;
DrawSelection.W = 0;
DrawSelection.FindStart = true;
if ( CurLine === this.Numbering.Line && CurRange === this.Numbering.Range )
DrawSelection.StartX += this.Numbering.WidthVisible;
for ( var CurPos = RStartPos; CurPos <= REndPos; CurPos++ )
{
var Item = this.Content[CurPos];
Item.Selection_DrawRange( CurLine, CurRange, DrawSelection );
}
var StartX = DrawSelection.StartX;
var W = DrawSelection.W;
var StartY = DrawSelection.StartY;
var H = DrawSelection.H;
var StartX = DrawSelection.StartX;
var W = DrawSelection.W;
var StartY = DrawSelection.StartY;
var H = DrawSelection.H;
if ( W > 0.001 )
{
X0 = StartX;
X1 = StartX + W;
Y = StartY;
Page = CurPage + StartPage_abs;
if (null === BeginRect)
BeginRect = { X : StartX, Y : StartY, W : W, H : H, Page : Page };
EndRect = { X : StartX, Y : StartY, W : W, H : H, Page : Page };
}
}
}
}
if (null === BeginRect)
BeginRect = { X : this.X, Y : this.Y, W : 0, H : 0, Page : StartPage_abs };
if (null === EndRect)
EndRect = { X : this.X, Y : this.Y, W : 0, H : 0, Page : StartPage_abs };
return { Start : BeginRect, End : EndRect };
},
Get_SelectionAnchorPos : function() Get_SelectionAnchorPos : function()
{ {
var X0 = this.X, X1 = this.XLimit, Y = this.Y, Page = this.Get_StartPage_Absolute(); var X0 = this.X, X1 = this.XLimit, Y = this.Y, Page = this.Get_StartPage_Absolute();
......
...@@ -7518,6 +7518,50 @@ CTable.prototype = ...@@ -7518,6 +7518,50 @@ CTable.prototype =
} }
}, },
Get_SelectionBounds : function()
{
if ( true === this.ApplyToAll || ( true === this.Selection.Use && table_Selection_Cell === this.Selection.Type && this.Selection.Data.length > 0 ) )
{
var Cells_array = this.Internal_Get_SelectionArray();
var StartPos = Cells_array[0];
var Row = this.Content[StartPos.Row];
var Cell = Row.Get_Cell(StartPos.Cell);
var X0 = Cell.Metrics.X_cell_start;
var X1 = Cell.Metrics.X_cell_end;
var CurPage = this.RowsInfo[StartPos.Row].StartPage;
var Y = this.RowsInfo[StartPos.Row].Y[CurPage];
var H = this.RowsInfo[StartPos.Row].H[CurPage];
var BeginRect = { X : X0, Y : Y, W : X1 - X0, H : H, Page : CurPage + this.Get_StartPage_Absolute() };
var EndPos = Cells_array[Cells_array.length - 1];
Row = this.Content[EndPos.Row];
Cell = Row.Get_Cell(EndPos.Cell);
X0 = Cell.Metrics.X_cell_start;
X1 = Cell.Metrics.X_cell_end;
CurPage = this.RowsInfo[EndPos.Row].StartPage + this.RowsInfo[EndPos.Row].Pages - 1;
Y = this.RowsInfo[EndPos.Row].Y[CurPage];
H = this.RowsInfo[EndPos.Row].H[CurPage];
var EndRect = { X : X0, Y : Y, W : X1 - X0, H : H, Page : CurPage + this.Get_StartPage_Absolute() };
return { Start : BeginRect, End : EndRect };
}
else
{
return this.CurCell.Content.Get_SelectionBounds();
}
},
Get_SelectionAnchorPos : function() Get_SelectionAnchorPos : function()
{ {
if ( true === this.ApplyToAll || ( true === this.Selection.Use && table_Selection_Cell === this.Selection.Type && this.Selection.Data.length > 0 ) ) if ( true === this.ApplyToAll || ( true === this.Selection.Use && table_Selection_Cell === this.Selection.Type && this.Selection.Data.length > 0 ) )
......
...@@ -787,13 +787,6 @@ CMathBase.prototype = ...@@ -787,13 +787,6 @@ CMathBase.prototype =
if(!this.elements[i][j].IsJustDraw()) if(!this.elements[i][j].IsJustDraw())
this.elements[i][j].SetRunEmptyToContent(bAll); this.elements[i][j].SetRunEmptyToContent(bAll);
}, },
Correct_Content: function(bInnerCorrection)
{
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
if(!this.elements[i][j].IsJustDraw())
this.elements[i][j].Correct_Content(bInnerCorrection);
},
Selection_Remove: function() Selection_Remove: function()
{ {
var start_X = this.SelectStart.X, var start_X = this.SelectStart.X,
...@@ -1325,6 +1318,15 @@ CMathBase.prototype.setProperties = function(oProps) ...@@ -1325,6 +1318,15 @@ CMathBase.prototype.setProperties = function(oProps)
this.RecalcInfo.bProps = true; this.RecalcInfo.bProps = true;
} }
CMathBase.prototype.Correct_Content = function(bInnerCorrection)
{
var nCount = this.Content.length;
for (var nIndex = 0; nIndex < nCount; nIndex++)
{
this.Content[nIndex].Correct_Content(bInnerCorrection);
}
};
function CMathBasePr() function CMathBasePr()
{ {
......
...@@ -181,11 +181,6 @@ CLimit.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -181,11 +181,6 @@ CLimit.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
} }
} }
CLimit.prototype.Correct_Content = function(bInnerCorrection)
{
this.Content[0].Correct_Content(bInnerCorrection);
this.Content[1].Correct_Content(bInnerCorrection);
};
function CMathFunc(props) function CMathFunc(props)
{ {
......
...@@ -433,12 +433,6 @@ CNary.prototype.getLowerIterator = function() ...@@ -433,12 +433,6 @@ CNary.prototype.getLowerIterator = function()
if (!this.Pr.subHide) if (!this.Pr.subHide)
return this.LowerIterator; return this.LowerIterator;
} }
CNary.prototype.Correct_Content = function(bInnerCorrection)
{
this.Content[0].Correct_Content(bInnerCorrection);
this.Content[1].Correct_Content(bInnerCorrection);
this.Content[2].Correct_Content(bInnerCorrection);
};
function CNaryUnd(bInside) function CNaryUnd(bInside)
{ {
......
...@@ -689,9 +689,4 @@ CRadical.prototype.getBase = function() ...@@ -689,9 +689,4 @@ CRadical.prototype.getBase = function()
CRadical.prototype.getDegree = function() CRadical.prototype.getDegree = function()
{ {
return this.Content[0]; return this.Content[0];
} }
CRadical.prototype.Correct_Content = function(bInnerCorrection) \ No newline at end of file
{
this.Content[0].Correct_Content(bInnerCorrection);
this.Content[1].Correct_Content(bInnerCorrection);
};
\ No newline at end of file
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