Commit 0be0f71b authored by Ilya Kirillov's avatar Ilya Kirillov

Fix bug #32477 Исправлен баг с селектом внутри таблиц, разбитых на несколько страниц.

parent afa5f819
......@@ -9099,7 +9099,7 @@ CDocument.prototype.Interface_Update_HdrFtrPr = function()
}
};
CDocument.prototype.Internal_GetContentPosByXY = function(X, Y, PageNum, ColumnsInfo)
{
{
if (!ColumnsInfo)
ColumnsInfo = {Column : 0, ColumnsCount : 1};
......@@ -9187,7 +9187,7 @@ CDocument.prototype.Internal_GetContentPosByXY = function(X, Y, PageNum, Columns
// Сохраним позиции всех Inline элементов на данной странице
var InlineElements = [];
for ( var Index = StartPos; Index <= EndPos; Index++ )
for (var Index = StartPos; Index <= EndPos; Index++)
{
var Item = this.Content[Index];
......@@ -9226,44 +9226,44 @@ CDocument.prototype.Internal_GetContentPosByXY = function(X, Y, PageNum, Columns
}
return InlineElements[0];
};
};
CDocument.prototype.Selection_Remove = function(bNoCheckDrawing)
{
if ( docpostype_HdrFtr === this.CurPos.Type )
{
if (docpostype_HdrFtr === this.CurPos.Type)
{
return this.HdrFtr.Selection_Remove(bNoCheckDrawing);
}
else if ( docpostype_DrawingObjects === this.CurPos.Type )
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
var ParaDrawing = this.DrawingObjects.getMajorParaDrawing();
if(ParaDrawing)
if (ParaDrawing)
{
ParaDrawing.GoTo_Text(undefined, false);
}
return this.DrawingObjects.resetSelection(undefined, bNoCheckDrawing);
}
else if ( docpostype_Content === this.CurPos.Type )
else if (docpostype_Content === this.CurPos.Type)
{
if ( true === this.Selection.Use )
if (true === this.Selection.Use)
{
switch( this.Selection.Flag )
switch (this.Selection.Flag)
{
case selectionflag_Common:
{
var Start = this.Selection.StartPos;
var End = this.Selection.EndPos;
if ( Start > End )
if (Start > End)
{
var Temp = Start;
Start = End;
End = Temp;
}
Start = Math.max( 0, Start );
End = Math.min( this.Content.length - 1, End );
Start = Math.max(0, Start);
End = Math.min(this.Content.length - 1, End);
for ( var Index = Start; Index <= End; Index++ )
for (var Index = Start; Index <= End; Index++)
{
this.Content[Index].Selection_Remove();
}
......@@ -9283,10 +9283,10 @@ CDocument.prototype.Selection_Remove = function(bNoCheckDrawing)
}
case selectionflag_Numbering:
{
if ( null == this.Selection.Data )
if (null == this.Selection.Data)
break;
for ( var Index = 0; Index < this.Selection.Data.length; Index++ )
for (var Index = 0; Index < this.Selection.Data.length; Index++)
{
this.Content[this.Selection.Data[Index]].Selection_Remove();
}
......@@ -9305,29 +9305,29 @@ CDocument.prototype.Selection_Remove = function(bNoCheckDrawing)
}
}
}
};
};
CDocument.prototype.Selection_IsEmpty = function(bCheckHidden)
{
{
// Работаем с колонтитулом
if ( docpostype_HdrFtr === this.CurPos.Type )
if (docpostype_HdrFtr === this.CurPos.Type)
{
return this.HdrFtr.Selection_IsEmpty(bCheckHidden);
}
else if ( docpostype_DrawingObjects === this.CurPos.Type )
else if (docpostype_DrawingObjects === this.CurPos.Type)
return false;
else //if ( docpostype_Content === this.CurPos.Type )
{
if ( true === this.Selection.Use )
if (true === this.Selection.Use)
{
// Выделение нумерации
if ( selectionflag_Numbering == this.Selection.Flag )
if (selectionflag_Numbering == this.Selection.Flag)
return false;
// Обрабатываем движение границы у таблиц
else if ( true === this.Selection_Is_TableBorderMove() )
else if (true === this.Selection_Is_TableBorderMove())
return false;
else
{
if ( this.Selection.StartPos === this.Selection.EndPos )
if (this.Selection.StartPos === this.Selection.EndPos)
return this.Content[this.Selection.StartPos].Selection_IsEmpty(bCheckHidden);
else
return false;
......@@ -9336,18 +9336,18 @@ CDocument.prototype.Selection_IsEmpty = function(bCheckHidden)
return true;
}
};
};
CDocument.prototype.Selection_Draw_Page = function(Page_abs)
{
{
this.DrawingDocument.UpdateTargetTransform(null);
this.DrawingDocument.SetTextSelectionOutline(false);
// Работаем с колонтитулом
if ( docpostype_HdrFtr === this.CurPos.Type )
if (docpostype_HdrFtr === this.CurPos.Type)
{
this.HdrFtr.Selection_Draw_Page(Page_abs);
}
else if ( docpostype_DrawingObjects === this.CurPos.Type )
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
this.DrawingDocument.SetTextSelectionOutline(true);
this.DrawingObjects.drawSelectionPage(Page_abs);
......@@ -9424,15 +9424,15 @@ CDocument.prototype.Selection_Draw_Page = function(Page_abs)
}
}
}
};
};
CDocument.prototype.Get_SelectionBounds = function()
{
{
// Работаем с колонтитулом
if ( docpostype_HdrFtr === this.CurPos.Type )
if (docpostype_HdrFtr === this.CurPos.Type)
{
return this.HdrFtr.Get_SelectionBounds();
}
else if ( docpostype_DrawingObjects === this.CurPos.Type )
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
return this.DrawingObjects.Get_SelectionBounds();
}
......@@ -9443,7 +9443,7 @@ CDocument.prototype.Get_SelectionBounds = function()
var Start = this.Selection.StartPos;
var End = this.Selection.EndPos;
if ( Start > End )
if (Start > End)
{
Start = this.Selection.EndPos;
End = this.Selection.StartPos;
......@@ -9463,12 +9463,12 @@ CDocument.prototype.Get_SelectionBounds = function()
}
return null;
};
};
CDocument.prototype.Selection_Clear = function()
{
if (true === this.Selection.Use)
{
if ( true === this.Selection.Use )
{
switch( this.Selection.Flag )
switch (this.Selection.Flag)
{
case selectionflag_Common:
{
......@@ -9476,14 +9476,14 @@ CDocument.prototype.Selection_Clear = function()
var Start = this.Selection.StartPos;
var End = this.Selection.EndPos;
if ( Start > End )
if (Start > End)
{
var Temp = Start;
Start = End;
End = Temp;
}
for ( var Index = Start; Index <= End; Index++ )
for (var Index = Start; Index <= End; Index++)
{
this.Content[Index].Selection_Clear();
}
......@@ -9492,10 +9492,10 @@ CDocument.prototype.Selection_Clear = function()
}
case selectionflag_Numbering:
{
if ( null == this.Selection.Data )
if (null == this.Selection.Data)
break;
for ( var Index = 0; Index < this.Selection.Data.length; Index++ )
for (var Index = 0; Index < this.Selection.Data.length; Index++)
{
this.Content[this.Selection.Data[Index]].Selection_Clear();
}
......@@ -9506,18 +9506,18 @@ CDocument.prototype.Selection_Clear = function()
}
this.DrawingDocument.SelectClear();
};
};
CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
{
{
var bInText = (null === this.Is_InText(X, Y, this.CurPage) ? false : true);
var bTableBorder = (null === this.Is_TableBorder(X, Y, this.CurPage) ? false : true);
var nInDrawing = this.DrawingObjects.isPointInDrawingObjects( X, Y, this.CurPage, this );
var bFlowTable = (null === this.DrawingObjects.getTableByXY( X, Y, this.CurPage, this ) ? false : true);
var nInDrawing = this.DrawingObjects.isPointInDrawingObjects(X, Y, this.CurPage, this);
var bFlowTable = (null === this.DrawingObjects.getTableByXY(X, Y, this.CurPage, this) ? false : true);
// Сначала посмотрим, попалили мы в текстовый селект (но при этом не в границу таблицы и не более чем одинарным кликом)
if ( -1 !== this.Selection.DragDrop.Flag && MouseEvent.ClickCount <= 1 && false === bTableBorder &&
if (-1 !== this.Selection.DragDrop.Flag && MouseEvent.ClickCount <= 1 && false === bTableBorder &&
( nInDrawing < 0 || ( nInDrawing === DRAWING_ARRAY_TYPE_BEHIND && true === bInText ) || ( nInDrawing > -1 && ( docpostype_DrawingObjects === this.CurPos.Type || ( docpostype_HdrFtr === this.CurPos.Type && docpostype_DrawingObjects === this.HdrFtr.CurHdrFtr.Content.CurPos.Type ) ) && true === this.DrawingObjects.isSelectedText() && null !== this.DrawingObjects.getMajorParaDrawing() && this.DrawingObjects.getGraphicInfoUnderCursor(this.CurPage, X, Y).cursorType === "text" ) ) &&
true === this.Selection_Check( X, Y, this.CurPage, undefined ) )
true === this.Selection_Check(X, Y, this.CurPage, undefined))
{
// Здесь мы сразу не начинаем перемещение текста. Его мы начинаем, курсор хотя бы немного изменит свою позицию,
// это проверяется на MouseMove.
......@@ -9525,55 +9525,55 @@ CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
// его можно здесь вставить.
this.Selection.DragDrop.Flag = 1;
this.Selection.DragDrop.Data = { X : X, Y : Y, PageNum : this.CurPage };
this.Selection.DragDrop.Data = {X : X, Y : Y, PageNum : this.CurPage};
return;
}
var bCheckHdrFtr = true;
if ( docpostype_HdrFtr === this.CurPos.Type )
if (docpostype_HdrFtr === this.CurPos.Type)
{
bCheckHdrFtr = false;
this.Selection.Start = true;
this.Selection.Use = true;
if ( false != this.HdrFtr.Selection_SetStart( X, Y, this.CurPage, MouseEvent, false ) )
if (false != this.HdrFtr.Selection_SetStart(X, Y, this.CurPage, MouseEvent, false))
return;
this.Selection.Start = false;
this.Selection.Use = false;
this.DrawingDocument.ClearCachePages();
this.DrawingDocument.FirePaint();
this.DrawingDocument.EndTrackTable( null, true );
this.DrawingDocument.EndTrackTable(null, true);
}
var PageMetrics = this.Get_PageContentStartPos( this.CurPage, this.Pages[this.CurPage].Pos );
var PageMetrics = this.Get_PageContentStartPos(this.CurPage, this.Pages[this.CurPage].Pos);
// Проверяем, не попали ли мы в колонтитул (если мы попадаем в Flow-объект, то попадание в колонтитул не проверяем)
if ( true != bFlowTable && nInDrawing < 0 && true === bCheckHdrFtr && MouseEvent.ClickCount >= 2 && ( Y <= PageMetrics.Y || Y > PageMetrics.YLimit ) )
if (true != bFlowTable && nInDrawing < 0 && true === bCheckHdrFtr && MouseEvent.ClickCount >= 2 && ( Y <= PageMetrics.Y || Y > PageMetrics.YLimit ))
{
// Если был селект, тогда убираем его
if ( true === this.Selection.Use )
if (true === this.Selection.Use)
this.Selection_Remove();
this.CurPos.Type = docpostype_HdrFtr;
// Переходим к работе с колонтитулами
MouseEvent.ClickCount = 1;
this.HdrFtr.Selection_SetStart( X, Y, this.CurPage, MouseEvent, true );
this.HdrFtr.Selection_SetStart(X, Y, this.CurPage, MouseEvent, true);
this.Interface_Update_HdrFtrPr();
this.DrawingDocument.ClearCachePages();
this.DrawingDocument.FirePaint();
this.DrawingDocument.EndTrackTable( null, true );
this.DrawingDocument.EndTrackTable(null, true);
}
else if ( nInDrawing === DRAWING_ARRAY_TYPE_BEFORE || nInDrawing === DRAWING_ARRAY_TYPE_INLINE || ( false === bTableBorder && false === bInText && nInDrawing >= 0 ) )
else if (nInDrawing === DRAWING_ARRAY_TYPE_BEFORE || nInDrawing === DRAWING_ARRAY_TYPE_INLINE || ( false === bTableBorder && false === bInText && nInDrawing >= 0 ))
{
if ( docpostype_DrawingObjects != this.CurPos.Type )
if (docpostype_DrawingObjects != this.CurPos.Type)
this.Selection_Remove();
// Прячем курсор
this.DrawingDocument.TargetEnd();
this.DrawingDocument.SetCurrentPage( this.CurPage );
this.DrawingDocument.SetCurrentPage(this.CurPage);
this.Selection.Use = true;
this.Selection.Start = true;
......@@ -9585,7 +9585,7 @@ CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
{
var bOldSelectionIsCommon = true;
if ( docpostype_DrawingObjects === this.CurPos.Type && true != this.Is_InDrawing( X, Y, this.CurPage ) )
if (docpostype_DrawingObjects === this.CurPos.Type && true != this.Is_InDrawing(X, Y, this.CurPage))
{
this.DrawingObjects.resetSelection();
bOldSelectionIsCommon = false;
......@@ -9593,7 +9593,7 @@ CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
var ContentPos = this.Internal_GetContentPosByXY(X, Y);
if ( docpostype_Content != this.CurPos.Type )
if (docpostype_Content != this.CurPos.Type)
{
this.CurPos.Type = docpostype_Content;
this.CurPos.ContentPos = ContentPos;
......@@ -9611,9 +9611,9 @@ CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
}
// Убираем селект, кроме случаев либо текущего параграфа, либо при движении границ внутри таблицы
if ( !(true === SelectionUse_old && true === MouseEvent.ShiftKey && true === bOldSelectionIsCommon) )
if (!(true === SelectionUse_old && true === MouseEvent.ShiftKey && true === bOldSelectionIsCommon))
{
if ( (selectionflag_Common != this.Selection.Flag) || ( true === this.Selection.Use && MouseEvent.ClickCount <= 1 && true != bTableBorder ) )
if ((selectionflag_Common != this.Selection.Flag) || ( true === this.Selection.Use && MouseEvent.ClickCount <= 1 && true != bTableBorder ))
this.Selection_Remove();
}
......@@ -9621,9 +9621,9 @@ CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
this.Selection.Start = true;
this.Selection.Flag = selectionflag_Common;
if ( true === SelectionUse_old && true === MouseEvent.ShiftKey && true === bOldSelectionIsCommon )
if (true === SelectionUse_old && true === MouseEvent.ShiftKey && true === bOldSelectionIsCommon)
{
this.Selection_SetEnd( X, Y, {Type : AscCommon.g_mouse_event_type_up, ClickCount : 1} );
this.Selection_SetEnd(X, Y, {Type : AscCommon.g_mouse_event_type_up, ClickCount : 1});
this.Selection.Use = true;
this.Selection.Start = true;
this.Selection.EndPos = ContentPos;
......@@ -9633,9 +9633,12 @@ CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
{
var ElementPageIndex = this.private_GetElementPageIndexByXY(ContentPos, X, Y, this.CurPage);
Item.Selection_SetStart(X, Y, ElementPageIndex, MouseEvent, bTableBorder);
Item.Selection_SetEnd(X, Y, ElementPageIndex, {Type : AscCommon.g_mouse_event_type_move, ClickCount : 1}, bTableBorder);
Item.Selection_SetEnd(X, Y, ElementPageIndex, {
Type : AscCommon.g_mouse_event_type_move,
ClickCount : 1
}, bTableBorder);
if ( !(type_Table == Item.GetType() && true == bTableBorder) )
if (!(type_Table == Item.GetType() && true == bTableBorder))
{
this.Selection.Use = true;
this.Selection.StartPos = ContentPos;
......@@ -9644,10 +9647,10 @@ CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
this.CurPos.ContentPos = ContentPos;
if ( type_Paragraph === Item.GetType() && true === MouseEvent.CtrlKey )
if (type_Paragraph === Item.GetType() && true === MouseEvent.CtrlKey)
{
var Hyperlink = Item.Check_Hyperlink(X, Y, ElementPageIndex);
if ( null != Hyperlink )
if (null != Hyperlink)
{
this.Selection.Data =
{
......@@ -9668,7 +9671,7 @@ CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
}
}
}
};
};
/**
* Данная функция может использоваться как при движении, так и при окончательном выставлении селекта.
* Если bEnd = true, тогда это конец селекта.
......
......@@ -7411,8 +7411,9 @@ CDocumentContent.prototype.Selection_SetStart = function(X, Y, CurPage, MouseEve
}
else
{
Item.Selection_SetStart(X, Y, this.CurPage, MouseEvent);
Item.Selection_SetEnd(X, Y, this.CurPage, {Type : AscCommon.g_mouse_event_type_move, ClickCount : 1});
var ElementPageIndex = this.private_GetElementPageIndexByXY(ContentPos, X, Y, this.CurPage);
Item.Selection_SetStart(X, Y, ElementPageIndex, MouseEvent);
Item.Selection_SetEnd(X, Y, ElementPageIndex, {Type : AscCommon.g_mouse_event_type_move, ClickCount : 1});
if (!(type_Table == Item.GetType() && true == bTableBorder))
{
......@@ -7480,7 +7481,8 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, M
if (null != this.Selection.Data && true === this.Selection.Data.TableBorder && type_Table == this.Content[this.Selection.Data.Pos].GetType())
{
var Item = this.Content[this.Selection.Data.Pos];
Item.Selection_SetEnd(X, Y, this.CurPage, MouseEvent);
var ElementPageIndex = this.private_GetElementPageIndexByXY(this.Selection.Data.Pos, X, Y, this.CurPage);
Item.Selection_SetEnd(X, Y, ElementPageIndex, MouseEvent);
if (AscCommon.g_mouse_event_type_up == MouseEvent.Type)
{
......@@ -7553,8 +7555,8 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, M
if (0 == Direction)
{
var Item = this.Content[this.Selection.StartPos];
var ItemType = Item.GetType();
Item.Selection_SetEnd(X, Y, this.CurPage, MouseEvent);
var ElementPageIndex = this.private_GetElementPageIndexByXY(this.Selection.StartPos, X, Y, this.CurPage);
Item.Selection_SetEnd(X, Y, ElementPageIndex, MouseEvent);
if (false === Item.Selection.Use)
{
......@@ -7605,7 +7607,8 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, M
this.Content[Start].Selection.EndPos = this.Content[Start].Content.length - 1;
}
this.Content[ContentPos].Selection_SetEnd(X, Y, this.CurPage, MouseEvent);
var ElementPageIndex = this.private_GetElementPageIndexByXY(ContentPos, X, Y, this.CurPage);
this.Content[ContentPos].Selection_SetEnd(X, Y, ElementPageIndex, MouseEvent);
for (var Index = Start; Index <= End; Index++)
{
......
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