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

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

parent afa5f819
...@@ -9099,576 +9099,579 @@ CDocument.prototype.Interface_Update_HdrFtrPr = function() ...@@ -9099,576 +9099,579 @@ CDocument.prototype.Interface_Update_HdrFtrPr = function()
} }
}; };
CDocument.prototype.Internal_GetContentPosByXY = function(X, Y, PageNum, ColumnsInfo) CDocument.prototype.Internal_GetContentPosByXY = function(X, Y, PageNum, ColumnsInfo)
{ {
if (!ColumnsInfo) if (!ColumnsInfo)
ColumnsInfo = {Column : 0, ColumnsCount : 1}; ColumnsInfo = {Column : 0, ColumnsCount : 1};
if (undefined === PageNum || null === PageNum) if (undefined === PageNum || null === PageNum)
PageNum = this.CurPage; PageNum = this.CurPage;
// Сначала проверим Flow-таблицы // Сначала проверим Flow-таблицы
var FlowTable = this.DrawingObjects.getTableByXY(X, Y, PageNum, this); var FlowTable = this.DrawingObjects.getTableByXY(X, Y, PageNum, this);
if (null != FlowTable) if (null != FlowTable)
{
var ElementPos;
if (flowobject_Table === FlowTable.Get_Type())
{ {
var ElementPos; ElementPos = FlowTable.Table.Index;
if (flowobject_Table === FlowTable.Get_Type()) }
{ else
ElementPos = FlowTable.Table.Index; {
} var Frame = FlowTable;
else
{
var Frame = FlowTable;
var StartPos = Frame.StartIndex;
var FlowCount = Frame.FlowCount;
for (var Pos = StartPos; Pos < StartPos + FlowCount; ++Pos) var StartPos = Frame.StartIndex;
{ var FlowCount = Frame.FlowCount;
var Item = this.Content[Pos];
if (Y < Item.Pages[0].Bounds.Bottom) for (var Pos = StartPos; Pos < StartPos + FlowCount; ++Pos)
return Pos; {
} var Item = this.Content[Pos];
ElementPos = StartPos + FlowCount - 1; if (Y < Item.Pages[0].Bounds.Bottom)
return Pos;
} }
var Element = this.Content[ElementPos]; ElementPos = StartPos + FlowCount - 1;
ColumnsInfo.Column = Element.Get_StartColumn();
ColumnsInfo.ColumnsCount = Element.Get_ColumnsCount();
return ElementPos;
} }
// Теперь проверим пустые параграфы с окончанием секций var Element = this.Content[ElementPos];
var SectCount = this.Pages[PageNum].EndSectionParas.length; ColumnsInfo.Column = Element.Get_StartColumn();
for (var Index = 0; Index < SectCount; ++Index) ColumnsInfo.ColumnsCount = Element.Get_ColumnsCount();
{ return ElementPos;
var Item = this.Pages[PageNum].EndSectionParas[Index]; }
var Bounds = Item.Pages[0].Bounds;
if (Y < Bounds.Bottom && Y > Bounds.Top && X > Bounds.Left && X < Bounds.Right)
{
var Element = this.Content[Item.Index];
ColumnsInfo.Column = Element.Get_StartColumn();
ColumnsInfo.ColumnsCount = Element.Get_ColumnsCount();
return Item.Index;
}
}
// Сначала мы определим секцию и колонку, в которую попали // Теперь проверим пустые параграфы с окончанием секций
var Page = this.Pages[PageNum]; var SectCount = this.Pages[PageNum].EndSectionParas.length;
for (var Index = 0; Index < SectCount; ++Index)
{
var Item = this.Pages[PageNum].EndSectionParas[Index];
var Bounds = Item.Pages[0].Bounds;
var SectionIndex = 0; if (Y < Bounds.Bottom && Y > Bounds.Top && X > Bounds.Left && X < Bounds.Right)
for (var SectionsCount = Page.Sections.length; SectionIndex < SectionsCount - 1; ++SectionIndex)
{ {
if (Y < Page.Sections[SectionIndex + 1].Y) var Element = this.Content[Item.Index];
break; ColumnsInfo.Column = Element.Get_StartColumn();
ColumnsInfo.ColumnsCount = Element.Get_ColumnsCount();
return Item.Index;
} }
}
var PageSection = this.Pages[PageNum].Sections[SectionIndex]; // Сначала мы определим секцию и колонку, в которую попали
var ColumnsCount = PageSection.Columns.length; var Page = this.Pages[PageNum];
var ColumnIndex = 0;
for (; ColumnIndex < ColumnsCount - 1; ++ColumnIndex) var SectionIndex = 0;
{ for (var SectionsCount = Page.Sections.length; SectionIndex < SectionsCount - 1; ++SectionIndex)
if (X < (PageSection.Columns[ColumnIndex].XLimit + PageSection.Columns[ColumnIndex + 1].X) / 2) {
break; if (Y < Page.Sections[SectionIndex + 1].Y)
} break;
}
// TODO: Разобраться с ситуацией, когда пустые колонки стоят не только в конце var PageSection = this.Pages[PageNum].Sections[SectionIndex];
while (ColumnIndex > 0 && true === PageSection.Columns[ColumnIndex].Empty) var ColumnsCount = PageSection.Columns.length;
ColumnIndex--; var ColumnIndex = 0;
for (; ColumnIndex < ColumnsCount - 1; ++ColumnIndex)
{
if (X < (PageSection.Columns[ColumnIndex].XLimit + PageSection.Columns[ColumnIndex + 1].X) / 2)
break;
}
ColumnsInfo.Column = ColumnIndex; // TODO: Разобраться с ситуацией, когда пустые колонки стоят не только в конце
ColumnsInfo.ColumnsCount = ColumnsCount; while (ColumnIndex > 0 && true === PageSection.Columns[ColumnIndex].Empty)
ColumnIndex--;
var Column = PageSection.Columns[ColumnIndex]; ColumnsInfo.Column = ColumnIndex;
var StartPos = Column.Pos; ColumnsInfo.ColumnsCount = ColumnsCount;
var EndPos = Column.EndPos;
// Сохраним позиции всех Inline элементов на данной странице var Column = PageSection.Columns[ColumnIndex];
var InlineElements = []; var StartPos = Column.Pos;
for ( var Index = StartPos; Index <= EndPos; Index++ ) var EndPos = Column.EndPos;
{
var Item = this.Content[Index];
var PrevItem = Item.Get_DocumentPrev(); // Сохраним позиции всех Inline элементов на данной странице
var bEmptySectPara = (type_Paragraph === Item.GetType() && undefined !== Item.Get_SectionPr() && true === Item.IsEmpty() && null !== PrevItem && (type_Table === PrevItem.GetType() || undefined === PrevItem.Get_SectionPr())) ? true : false; var InlineElements = [];
for (var Index = StartPos; Index <= EndPos; Index++)
{
var Item = this.Content[Index];
if (false != Item.Is_Inline() && (type_Table === Item.GetType() || false === bEmptySectPara)) var PrevItem = Item.Get_DocumentPrev();
InlineElements.push(Index); var bEmptySectPara = (type_Paragraph === Item.GetType() && undefined !== Item.Get_SectionPr() && true === Item.IsEmpty() && null !== PrevItem && (type_Table === PrevItem.GetType() || undefined === PrevItem.Get_SectionPr())) ? true : false;
}
var Count = InlineElements.length; if (false != Item.Is_Inline() && (type_Table === Item.GetType() || false === bEmptySectPara))
if (Count <= 0) InlineElements.push(Index);
return Math.min(Math.max(0, Page.EndPos), this.Content.length - 1); }
for (var Pos = 0; Pos < Count - 1; ++Pos) var Count = InlineElements.length;
{ if (Count <= 0)
var Item = this.Content[InlineElements[Pos + 1]]; return Math.min(Math.max(0, Page.EndPos), this.Content.length - 1);
var PageBounds = Item.Get_PageBounds(0); for (var Pos = 0; Pos < Count - 1; ++Pos)
if (Y < PageBounds.Top) {
return InlineElements[Pos]; var Item = this.Content[InlineElements[Pos + 1]];
if (Item.Pages.length > 1) var PageBounds = Item.Get_PageBounds(0);
{ if (Y < PageBounds.Top)
if (true !== Item.Is_StartFromNewPage()) return InlineElements[Pos];
return InlineElements[Pos + 1];
return InlineElements[Pos]; if (Item.Pages.length > 1)
} {
if (true !== Item.Is_StartFromNewPage())
return InlineElements[Pos + 1];
if (Pos === Count - 2) return InlineElements[Pos];
{
// Такое возможно, если страница заканчивается Flow-таблицей
return InlineElements[Count - 1];
}
} }
return InlineElements[0]; if (Pos === Count - 2)
};
CDocument.prototype.Selection_Remove = function(bNoCheckDrawing)
{
if ( docpostype_HdrFtr === this.CurPos.Type )
{ {
return this.HdrFtr.Selection_Remove(bNoCheckDrawing); // Такое возможно, если страница заканчивается Flow-таблицей
return InlineElements[Count - 1];
} }
else if ( docpostype_DrawingObjects === this.CurPos.Type ) }
return InlineElements[0];
};
CDocument.prototype.Selection_Remove = function(bNoCheckDrawing)
{
if (docpostype_HdrFtr === this.CurPos.Type)
{
return this.HdrFtr.Selection_Remove(bNoCheckDrawing);
}
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
var ParaDrawing = this.DrawingObjects.getMajorParaDrawing();
if (ParaDrawing)
{ {
var ParaDrawing = this.DrawingObjects.getMajorParaDrawing(); ParaDrawing.GoTo_Text(undefined, false);
if(ParaDrawing)
{
ParaDrawing.GoTo_Text(undefined, false);
}
return this.DrawingObjects.resetSelection(undefined, bNoCheckDrawing);
} }
else if ( docpostype_Content === this.CurPos.Type ) return this.DrawingObjects.resetSelection(undefined, bNoCheckDrawing);
}
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:
{ {
case selectionflag_Common: var Start = this.Selection.StartPos;
{ var End = this.Selection.EndPos;
var Start = this.Selection.StartPos;
var End = this.Selection.EndPos;
if ( Start > End ) if (Start > End)
{ {
var Temp = Start; var Temp = Start;
Start = End; Start = End;
End = Temp; End = Temp;
} }
Start = Math.max( 0, Start ); Start = Math.max(0, Start);
End = Math.min( this.Content.length - 1, End ); 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(); this.Content[Index].Selection_Remove();
} }
this.Selection.Use = false; this.Selection.Use = false;
this.Selection.Start = false; this.Selection.Start = false;
this.Selection.StartPos = 0; this.Selection.StartPos = 0;
this.Selection.EndPos = 0; this.Selection.EndPos = 0;
// Убираем селект и возвращаем курсор // Убираем селект и возвращаем курсор
this.DrawingDocument.SelectEnabled(false); this.DrawingDocument.SelectEnabled(false);
this.DrawingDocument.TargetStart(); this.DrawingDocument.TargetStart();
this.DrawingDocument.TargetShow(); this.DrawingDocument.TargetShow();
break;
}
case selectionflag_Numbering:
{
if (null == this.Selection.Data)
break; break;
}
case selectionflag_Numbering:
{
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(); this.Content[this.Selection.Data[Index]].Selection_Remove();
} }
this.Selection.Use = false; this.Selection.Use = false;
this.Selection.Start = false; this.Selection.Start = false;
this.Selection.Flag = selectionflag_Common; this.Selection.Flag = selectionflag_Common;
// Убираем селект и возвращаем курсор // Убираем селект и возвращаем курсор
this.DrawingDocument.SelectEnabled(false); this.DrawingDocument.SelectEnabled(false);
this.DrawingDocument.TargetStart(); this.DrawingDocument.TargetStart();
this.DrawingDocument.TargetShow(); this.DrawingDocument.TargetShow();
break; break;
}
} }
} }
} }
}; }
CDocument.prototype.Selection_IsEmpty = function(bCheckHidden) };
CDocument.prototype.Selection_IsEmpty = function(bCheckHidden)
{
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
{ {
// Работаем с колонтитулом return this.HdrFtr.Selection_IsEmpty(bCheckHidden);
if ( docpostype_HdrFtr === this.CurPos.Type ) }
{ else if (docpostype_DrawingObjects === this.CurPos.Type)
return this.HdrFtr.Selection_IsEmpty(bCheckHidden); return false;
} else //if ( docpostype_Content === this.CurPos.Type )
else if ( docpostype_DrawingObjects === this.CurPos.Type ) {
return false; if (true === this.Selection.Use)
else //if ( docpostype_Content === this.CurPos.Type )
{ {
if ( true === this.Selection.Use ) // Выделение нумерации
if (selectionflag_Numbering == this.Selection.Flag)
return false;
// Обрабатываем движение границы у таблиц
else if (true === this.Selection_Is_TableBorderMove())
return false;
else
{ {
// Выделение нумерации if (this.Selection.StartPos === this.Selection.EndPos)
if ( selectionflag_Numbering == this.Selection.Flag ) return this.Content[this.Selection.StartPos].Selection_IsEmpty(bCheckHidden);
return false;
// Обрабатываем движение границы у таблиц
else if ( true === this.Selection_Is_TableBorderMove() )
return false;
else else
{ return false;
if ( this.Selection.StartPos === this.Selection.EndPos )
return this.Content[this.Selection.StartPos].Selection_IsEmpty(bCheckHidden);
else
return false;
}
} }
return true;
} }
};
CDocument.prototype.Selection_Draw_Page = function(Page_abs) return true;
}
};
CDocument.prototype.Selection_Draw_Page = function(Page_abs)
{
this.DrawingDocument.UpdateTargetTransform(null);
this.DrawingDocument.SetTextSelectionOutline(false);
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
{
this.HdrFtr.Selection_Draw_Page(Page_abs);
}
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
this.DrawingDocument.SetTextSelectionOutline(true);
this.DrawingObjects.drawSelectionPage(Page_abs);
}
else
{ {
this.DrawingDocument.UpdateTargetTransform(null); if (true !== this.Selection.Use)
this.DrawingDocument.SetTextSelectionOutline(false); return;
// Работаем с колонтитулом var Page = this.Pages[Page_abs];
if ( docpostype_HdrFtr === this.CurPos.Type ) for (var SectionIndex = 0, SectionsCount = Page.Sections.length; SectionIndex < SectionsCount; ++SectionIndex)
{
this.HdrFtr.Selection_Draw_Page(Page_abs);
}
else if ( docpostype_DrawingObjects === this.CurPos.Type )
{ {
this.DrawingDocument.SetTextSelectionOutline(true); var PageSection = Page.Sections[SectionIndex];
this.DrawingObjects.drawSelectionPage(Page_abs); for (var ColumnIndex = 0, ColumnsCount = PageSection.Columns.length; ColumnIndex < ColumnsCount; ++ColumnIndex)
}
else
{
if (true !== this.Selection.Use)
return;
var Page = this.Pages[Page_abs];
for (var SectionIndex = 0, SectionsCount = Page.Sections.length; SectionIndex < SectionsCount; ++SectionIndex)
{ {
var PageSection = Page.Sections[SectionIndex]; var Pos_start = this.Pages[Page_abs].Pos;
for (var ColumnIndex = 0, ColumnsCount = PageSection.Columns.length; ColumnIndex < ColumnsCount; ++ColumnIndex) var Pos_end = this.Pages[Page_abs].EndPos;
{
var Pos_start = this.Pages[Page_abs].Pos;
var Pos_end = this.Pages[Page_abs].EndPos;
switch (this.Selection.Flag) switch (this.Selection.Flag)
{
case selectionflag_Common:
{ {
case selectionflag_Common: var Start = this.Selection.StartPos;
{ var End = this.Selection.EndPos;
var Start = this.Selection.StartPos;
var End = this.Selection.EndPos;
if (Start > End)
{
Start = this.Selection.EndPos;
End = this.Selection.StartPos;
}
var Start = Math.max(Start, Pos_start);
var End = Math.min(End, Pos_end);
for (var Index = Start; Index <= End; ++Index) if (Start > End)
{ {
var ElementPage = this.private_GetElementPageIndex(Index, Page_abs, ColumnIndex, ColumnsCount); Start = this.Selection.EndPos;
this.Content[Index].Selection_Draw_Page(ElementPage); End = this.Selection.StartPos;
} }
if (Page_abs >= 2 && End < this.Pages[Page_abs - 2].EndPos) var Start = Math.max(Start, Pos_start);
{ var End = Math.min(End, Pos_end);
this.Selection.UpdateOnRecalc = false;
this.DrawingDocument.OnSelectEnd();
}
break; for (var Index = Start; Index <= End; ++Index)
{
var ElementPage = this.private_GetElementPageIndex(Index, Page_abs, ColumnIndex, ColumnsCount);
this.Content[Index].Selection_Draw_Page(ElementPage);
} }
case selectionflag_Numbering:
if (Page_abs >= 2 && End < this.Pages[Page_abs - 2].EndPos)
{ {
if (null == this.Selection.Data) this.Selection.UpdateOnRecalc = false;
break; this.DrawingDocument.OnSelectEnd();
}
var Count = this.Selection.Data.length; break;
for (var Index = 0; Index < Count; ++Index) }
{ case selectionflag_Numbering:
var ElementPos = this.Selection.Data[Index]; {
if (Pos_start <= ElementPos && ElementPos <= Pos_end) if (null == this.Selection.Data)
{ break;
var ElementPage = this.private_GetElementPageIndex(ElementPos, Page_abs, ColumnIndex, ColumnsCount);
this.Content[ElementPos].Selection_Draw_Page(ElementPage);
}
}
if (Page_abs >= 2 && this.Selection.Data[this.Selection.Data.length - 1] < this.Pages[Page_abs - 2].EndPos) var Count = this.Selection.Data.length;
for (var Index = 0; Index < Count; ++Index)
{
var ElementPos = this.Selection.Data[Index];
if (Pos_start <= ElementPos && ElementPos <= Pos_end)
{ {
this.Selection.UpdateOnRecalc = false; var ElementPage = this.private_GetElementPageIndex(ElementPos, Page_abs, ColumnIndex, ColumnsCount);
this.DrawingDocument.OnSelectEnd(); this.Content[ElementPos].Selection_Draw_Page(ElementPage);
} }
}
break; if (Page_abs >= 2 && this.Selection.Data[this.Selection.Data.length - 1] < this.Pages[Page_abs - 2].EndPos)
{
this.Selection.UpdateOnRecalc = false;
this.DrawingDocument.OnSelectEnd();
} }
break;
} }
} }
} }
} }
}; }
CDocument.prototype.Get_SelectionBounds = function() };
CDocument.prototype.Get_SelectionBounds = function()
{
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
{ {
// Работаем с колонтитулом return this.HdrFtr.Get_SelectionBounds();
if ( docpostype_HdrFtr === this.CurPos.Type ) }
{ else if (docpostype_DrawingObjects === this.CurPos.Type)
return this.HdrFtr.Get_SelectionBounds(); {
} return this.DrawingObjects.Get_SelectionBounds();
else if ( docpostype_DrawingObjects === this.CurPos.Type ) }
else
{
if (true === this.Selection.Use && selectionflag_Common === this.Selection.Flag)
{ {
return this.DrawingObjects.Get_SelectionBounds(); 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;
Result.Direction = (this.Selection.StartPos > this.Selection.EndPos ? -1 : 1);
return Result;
}
} }
else }
return null;
};
CDocument.prototype.Selection_Clear = function()
{
if (true === this.Selection.Use)
{
switch (this.Selection.Flag)
{ {
if (true === this.Selection.Use && selectionflag_Common === this.Selection.Flag) case selectionflag_Common:
{ {
var Start = this.Selection.StartPos; var Start = this.Selection.StartPos;
var End = this.Selection.EndPos; var End = this.Selection.EndPos;
if ( Start > End ) if (Start > End)
{ {
Start = this.Selection.EndPos; var Temp = Start;
End = this.Selection.StartPos; Start = End;
End = Temp;
} }
if (Start === End) for (var Index = Start; Index <= End; Index++)
return this.Content[Start].Get_SelectionBounds(); {
else this.Content[Index].Selection_Clear();
}
break;
}
case selectionflag_Numbering:
{
if (null == this.Selection.Data)
break;
for (var Index = 0; Index < this.Selection.Data.length; Index++)
{ {
var Result = {}; this.Content[this.Selection.Data[Index]].Selection_Clear();
Result.Start = this.Content[Start].Get_SelectionBounds().Start;
Result.End = this.Content[End].Get_SelectionBounds().End;
Result.Direction = (this.Selection.StartPos > this.Selection.EndPos ? -1 : 1);
return Result;
} }
break;
} }
} }
}
return null; this.DrawingDocument.SelectClear();
}; };
CDocument.prototype.Selection_Clear = function() 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);
// Сначала посмотрим, попалили мы в текстовый селект (но при этом не в границу таблицы и не более чем одинарным кликом)
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))
{ {
if ( true === this.Selection.Use ) // Здесь мы сразу не начинаем перемещение текста. Его мы начинаем, курсор хотя бы немного изменит свою позицию,
{ // это проверяется на MouseMove.
switch( this.Selection.Flag ) // TODO: В ворде кроме изменения положения мыши, также запускается таймер для стартования drag-n-drop по времени,
{ // его можно здесь вставить.
case selectionflag_Common:
{
var Start = this.Selection.StartPos; this.Selection.DragDrop.Flag = 1;
var End = this.Selection.EndPos; this.Selection.DragDrop.Data = {X : X, Y : Y, PageNum : this.CurPage};
return;
}
if ( Start > End ) var bCheckHdrFtr = true;
{
var Temp = Start;
Start = End;
End = Temp;
}
for ( var Index = Start; Index <= End; Index++ ) if (docpostype_HdrFtr === this.CurPos.Type)
{ {
this.Content[Index].Selection_Clear(); bCheckHdrFtr = false;
} this.Selection.Start = true;
this.Selection.Use = true;
if (false != this.HdrFtr.Selection_SetStart(X, Y, this.CurPage, MouseEvent, false))
return;
break; this.Selection.Start = false;
} this.Selection.Use = false;
case selectionflag_Numbering: this.DrawingDocument.ClearCachePages();
{ this.DrawingDocument.FirePaint();
if ( null == this.Selection.Data ) this.DrawingDocument.EndTrackTable(null, true);
break; }
for ( var Index = 0; Index < this.Selection.Data.length; Index++ ) var PageMetrics = this.Get_PageContentStartPos(this.CurPage, this.Pages[this.CurPage].Pos);
{
this.Content[this.Selection.Data[Index]].Selection_Clear();
}
break; // Проверяем, не попали ли мы в колонтитул (если мы попадаем в Flow-объект, то попадание в колонтитул не проверяем)
} if (true != bFlowTable && nInDrawing < 0 && true === bCheckHdrFtr && MouseEvent.ClickCount >= 2 && ( Y <= PageMetrics.Y || Y > PageMetrics.YLimit ))
} {
} // Если был селект, тогда убираем его
if (true === this.Selection.Use)
this.Selection_Remove();
this.DrawingDocument.SelectClear(); this.CurPos.Type = docpostype_HdrFtr;
};
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);
// Сначала посмотрим, попалили мы в текстовый селект (но при этом не в границу таблицы и не более чем одинарным кликом)
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 ) )
{
// Здесь мы сразу не начинаем перемещение текста. Его мы начинаем, курсор хотя бы немного изменит свою позицию,
// это проверяется на MouseMove.
// TODO: В ворде кроме изменения положения мыши, также запускается таймер для стартования drag-n-drop по времени,
// его можно здесь вставить.
this.Selection.DragDrop.Flag = 1;
this.Selection.DragDrop.Data = { X : X, Y : Y, PageNum : this.CurPage };
return;
}
var bCheckHdrFtr = true; // Переходим к работе с колонтитулами
MouseEvent.ClickCount = 1;
this.HdrFtr.Selection_SetStart(X, Y, this.CurPage, MouseEvent, true);
this.Interface_Update_HdrFtrPr();
if ( docpostype_HdrFtr === this.CurPos.Type ) this.DrawingDocument.ClearCachePages();
{ this.DrawingDocument.FirePaint();
bCheckHdrFtr = false; this.DrawingDocument.EndTrackTable(null, true);
this.Selection.Start = true; }
this.Selection.Use = true; else if (nInDrawing === DRAWING_ARRAY_TYPE_BEFORE || nInDrawing === DRAWING_ARRAY_TYPE_INLINE || ( false === bTableBorder && false === bInText && nInDrawing >= 0 ))
if ( false != this.HdrFtr.Selection_SetStart( X, Y, this.CurPage, MouseEvent, false ) ) {
return; if (docpostype_DrawingObjects != this.CurPos.Type)
this.Selection_Remove();
this.Selection.Start = false; // Прячем курсор
this.Selection.Use = false; this.DrawingDocument.TargetEnd();
this.DrawingDocument.ClearCachePages(); this.DrawingDocument.SetCurrentPage(this.CurPage);
this.DrawingDocument.FirePaint();
this.DrawingDocument.EndTrackTable( null, true ); this.Selection.Use = true;
this.Selection.Start = true;
this.Selection.Flag = selectionflag_Common;
this.CurPos.Type = docpostype_DrawingObjects;
this.DrawingObjects.OnMouseDown(MouseEvent, X, Y, this.CurPage);
}
else
{
var bOldSelectionIsCommon = true;
if (docpostype_DrawingObjects === this.CurPos.Type && true != this.Is_InDrawing(X, Y, this.CurPage))
{
this.DrawingObjects.resetSelection();
bOldSelectionIsCommon = false;
} }
var PageMetrics = this.Get_PageContentStartPos( this.CurPage, this.Pages[this.CurPage].Pos ); var ContentPos = this.Internal_GetContentPosByXY(X, Y);
// Проверяем, не попали ли мы в колонтитул (если мы попадаем в Flow-объект, то попадание в колонтитул не проверяем) if (docpostype_Content != this.CurPos.Type)
if ( true != bFlowTable && nInDrawing < 0 && true === bCheckHdrFtr && MouseEvent.ClickCount >= 2 && ( Y <= PageMetrics.Y || Y > PageMetrics.YLimit ) )
{ {
// Если был селект, тогда убираем его this.CurPos.Type = docpostype_Content;
if ( true === this.Selection.Use ) this.CurPos.ContentPos = ContentPos;
this.Selection_Remove(); bOldSelectionIsCommon = false;
}
this.CurPos.Type = docpostype_HdrFtr; var SelectionUse_old = this.Selection.Use;
var Item = this.Content[ContentPos];
// Переходим к работе с колонтитулами var bTableBorder = false;
MouseEvent.ClickCount = 1; if (type_Table == Item.GetType())
this.HdrFtr.Selection_SetStart( X, Y, this.CurPage, MouseEvent, true ); {
this.Interface_Update_HdrFtrPr(); var ElementPageIndex = this.private_GetElementPageIndexByXY(ContentPos, X, Y, this.CurPage);
bTableBorder = null === Item.Is_TableBorder(X, Y, ElementPageIndex) ? false : true;
this.DrawingDocument.ClearCachePages();
this.DrawingDocument.FirePaint();
this.DrawingDocument.EndTrackTable( null, true );
} }
else if ( nInDrawing === DRAWING_ARRAY_TYPE_BEFORE || nInDrawing === DRAWING_ARRAY_TYPE_INLINE || ( false === bTableBorder && false === bInText && nInDrawing >= 0 ) )
// Убираем селект, кроме случаев либо текущего параграфа, либо при движении границ внутри таблицы
if (!(true === SelectionUse_old && true === MouseEvent.ShiftKey && true === bOldSelectionIsCommon))
{ {
if ( docpostype_DrawingObjects != this.CurPos.Type ) if ((selectionflag_Common != this.Selection.Flag) || ( true === this.Selection.Use && MouseEvent.ClickCount <= 1 && true != bTableBorder ))
this.Selection_Remove(); this.Selection_Remove();
}
// Прячем курсор this.Selection.Use = true;
this.DrawingDocument.TargetEnd(); this.Selection.Start = true;
this.DrawingDocument.SetCurrentPage( this.CurPage ); this.Selection.Flag = selectionflag_Common;
this.Selection.Use = true; if (true === SelectionUse_old && true === MouseEvent.ShiftKey && true === bOldSelectionIsCommon)
this.Selection.Start = true; {
this.Selection.Flag = selectionflag_Common; this.Selection_SetEnd(X, Y, {Type : AscCommon.g_mouse_event_type_up, ClickCount : 1});
this.CurPos.Type = docpostype_DrawingObjects; this.Selection.Use = true;
this.DrawingObjects.OnMouseDown(MouseEvent, X, Y, this.CurPage); this.Selection.Start = true;
this.Selection.EndPos = ContentPos;
this.Selection.Data = null;
} }
else else
{ {
var bOldSelectionIsCommon = true; var ElementPageIndex = this.private_GetElementPageIndexByXY(ContentPos, X, Y, this.CurPage);
Item.Selection_SetStart(X, Y, ElementPageIndex, MouseEvent, bTableBorder);
if ( docpostype_DrawingObjects === this.CurPos.Type && true != this.Is_InDrawing( X, Y, this.CurPage ) ) Item.Selection_SetEnd(X, Y, ElementPageIndex, {
{ Type : AscCommon.g_mouse_event_type_move,
this.DrawingObjects.resetSelection(); ClickCount : 1
bOldSelectionIsCommon = false; }, bTableBorder);
}
var ContentPos = this.Internal_GetContentPosByXY(X, Y);
if ( docpostype_Content != this.CurPos.Type )
{
this.CurPos.Type = docpostype_Content;
this.CurPos.ContentPos = ContentPos;
bOldSelectionIsCommon = false;
}
var SelectionUse_old = this.Selection.Use;
var Item = this.Content[ContentPos];
var bTableBorder = false;
if (type_Table == Item.GetType())
{
var ElementPageIndex = this.private_GetElementPageIndexByXY(ContentPos, X, Y, this.CurPage);
bTableBorder = null === Item.Is_TableBorder(X, Y, ElementPageIndex) ? false : true;
}
// Убираем селект, кроме случаев либо текущего параграфа, либо при движении границ внутри таблицы
if ( !(true === SelectionUse_old && true === MouseEvent.ShiftKey && true === bOldSelectionIsCommon) )
{
if ( (selectionflag_Common != this.Selection.Flag) || ( true === this.Selection.Use && MouseEvent.ClickCount <= 1 && true != bTableBorder ) )
this.Selection_Remove();
}
this.Selection.Use = true;
this.Selection.Start = true;
this.Selection.Flag = selectionflag_Common;
if ( true === SelectionUse_old && true === MouseEvent.ShiftKey && true === bOldSelectionIsCommon ) if (!(type_Table == Item.GetType() && true == bTableBorder))
{ {
this.Selection_SetEnd( X, Y, {Type : AscCommon.g_mouse_event_type_up, ClickCount : 1} );
this.Selection.Use = true; this.Selection.Use = true;
this.Selection.Start = true; this.Selection.StartPos = ContentPos;
this.Selection.EndPos = ContentPos; this.Selection.EndPos = ContentPos;
this.Selection.Data = null; this.Selection.Data = null;
}
else
{
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);
if ( !(type_Table == Item.GetType() && true == bTableBorder) )
{
this.Selection.Use = true;
this.Selection.StartPos = ContentPos;
this.Selection.EndPos = ContentPos;
this.Selection.Data = null;
this.CurPos.ContentPos = ContentPos; 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)
{ {
var Hyperlink = Item.Check_Hyperlink(X, Y, ElementPageIndex); this.Selection.Data =
if ( null != Hyperlink )
{ {
this.Selection.Data = Hyperlink : true,
{ Value : Hyperlink
Hyperlink : true, };
Value : Hyperlink
};
}
} }
} }
else }
else
{
this.Selection.Data =
{ {
this.Selection.Data = TableBorder : true,
{ Pos : ContentPos,
TableBorder : true, Selection : SelectionUse_old
Pos : ContentPos, };
Selection : SelectionUse_old
};
}
} }
} }
}; }
};
/** /**
* Данная функция может использоваться как при движении, так и при окончательном выставлении селекта. * Данная функция может использоваться как при движении, так и при окончательном выставлении селекта.
* Если bEnd = true, тогда это конец селекта. * Если bEnd = true, тогда это конец селекта.
......
...@@ -7411,8 +7411,9 @@ CDocumentContent.prototype.Selection_SetStart = function(X, Y, CurPage, MouseEve ...@@ -7411,8 +7411,9 @@ CDocumentContent.prototype.Selection_SetStart = function(X, Y, CurPage, MouseEve
} }
else else
{ {
Item.Selection_SetStart(X, Y, this.CurPage, MouseEvent); var ElementPageIndex = this.private_GetElementPageIndexByXY(ContentPos, X, Y, this.CurPage);
Item.Selection_SetEnd(X, Y, this.CurPage, {Type : AscCommon.g_mouse_event_type_move, ClickCount : 1}); 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)) if (!(type_Table == Item.GetType() && true == bTableBorder))
{ {
...@@ -7479,8 +7480,9 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, M ...@@ -7479,8 +7480,9 @@ 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()) 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]; 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) if (AscCommon.g_mouse_event_type_up == MouseEvent.Type)
{ {
...@@ -7552,9 +7554,9 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, M ...@@ -7552,9 +7554,9 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, M
var Start, End; var Start, End;
if (0 == Direction) if (0 == Direction)
{ {
var Item = this.Content[this.Selection.StartPos]; var Item = this.Content[this.Selection.StartPos];
var ItemType = Item.GetType(); var ElementPageIndex = this.private_GetElementPageIndexByXY(this.Selection.StartPos, X, Y, this.CurPage);
Item.Selection_SetEnd(X, Y, this.CurPage, MouseEvent); Item.Selection_SetEnd(X, Y, ElementPageIndex, MouseEvent);
if (false === Item.Selection.Use) if (false === Item.Selection.Use)
{ {
...@@ -7605,7 +7607,8 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, M ...@@ -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[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++) 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