Commit 37a3900a authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented function for finding and selecting the next/previous filling form.

parent 653fabca
......@@ -15145,55 +15145,25 @@ CDocument.prototype.IsFormFieldEditing = function()
return false;
};
CDocument.prototype.MoveToFillingForm = function(bNext)
CDocument.prototype.MoveToFillingForm = function(isNext)
{
var arrAllFields = this.GetAllFormTextFields();
if (arrAllFields.length <= 0)
return;
var oRes = this.FindNextFillingForm(isNext, true, true);
this.RemoveSelection();
if (!oRes)
oRes = this.FindNextFillingForm(isNext, true, false);
var oInfo = this.GetSelectedElementsInfo();
var oField = oInfo.Get_Field();
var oForm = null;
if (!oField || !oField.IsFillingForm())
if (oRes)
{
oForm = arrAllFields[0];
}
else
{
for (var nIndex = 0, nCount = arrAllFields.length; nIndex < nCount; ++nIndex)
{
if (oField === arrAllFields[nIndex])
{
if (bNext)
{
if (nIndex < nCount - 1)
oForm = arrAllFields[nIndex + 1];
else
oForm = arrAllFields[0];
}
else
{
if (nIndex > 0)
oForm = arrAllFields[0];
else
oForm = arrAllFields[nCount - 1];
}
this.RemoveSelection();
break;
}
if (oRes instanceof CBlockLevelSdt || oRes instanceof CInlineLevelSdt)
{
oRes.SelectContentControl();
}
else if (oRes instanceof ParaField)
{
oRes.SelectThisElement();
}
}
if (oForm)
{
oForm.MoveCursorToStartPos();
if (oForm.Content.length >= 0 && para_Run === oForm.Content[0].Type)
oForm.Content[0].Make_ThisElementCurrent();
this.Document_UpdateInterfaceState();
this.Document_UpdateSelectionState();
}
};
CDocument.prototype.SelectContentControl = function(Id)
......
......@@ -760,4 +760,60 @@ CDocumentContentBase.prototype.GetLastRangeVisibleBounds = function()
};
return this.Content[this.Content.length - 1].GetLastRangeVisibleBounds();
};
CDocumentContentBase.prototype.FindNextFillingForm = function(isNext, isCurrent, isStart)
{
var nCurPos = this.Selection.Use === true ? this.Selection.StartPos : this.CurPos.ContentPos;
var nStartPos = 0;
var nEndPos = this.Content.length - 1;
if (isCurrent)
{
if (isStart)
{
nStartPos = nCurPos;
nEndPos = isNext ? this.Content.length - 1 : 0;
}
else
{
nStartPos = isNext ? 0 : this.Content.length - 1;
nEndPos = nCurPos;
}
}
else
{
if (isNext)
{
nStartPos = 0;
nEndPos = this.Content.length - 1;
}
else
{
nStartPos = this.Content.length - 1;
nEndPos = 0;
}
}
if (isNext)
{
for (var nIndex = nStartPos; nIndex <= nEndPos; ++nIndex)
{
var oRes = this.Content[nIndex].FindNextFillingForm(true, isCurrent && nIndex === nCurPos ? true : false, isStart);
if (oRes)
return oRes;
}
}
else
{
for (var nIndex = nStartPos; nIndex >= nEndPos; --nIndex)
{
var oRes = this.Content[nIndex].FindNextFillingForm(false, isCurrent && nIndex === nCurPos ? true : false, isStart);
if (oRes)
return oRes;
}
}
return null;
};
\ No newline at end of file
......@@ -654,6 +654,10 @@ CDocumentContentElementBase.prototype.GetLastRangeVisibleBounds = function()
XLimit : 0
};
};
CDocumentContentElementBase.prototype.FindNextFillingForm = function(isNext, isCurrent, isStart)
{
return null;
};
//----------------------------------------------------------------------------------------------------------------------
// Функции для работы с номерами страниц
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -467,6 +467,28 @@ ParaField.prototype.IsFillingForm = function()
return false;
};
ParaField.prototype.FindNextFillingForm = function(isNext, isCurrent, isStart)
{
if (!this.IsFillingForm())
return CParagraphContentWithParagraphLikeContent.prototype.FindNextFillingForm.apply(this, arguments);
if (isCurrent && true === this.IsSelectedAll())
{
if (isNext)
return CParagraphContentWithParagraphLikeContent.prototype.FindNextFillingForm.apply(this, arguments);
return null;
}
if (!isCurrent && isNext)
return this;
var oRes = CParagraphContentWithParagraphLikeContent.prototype.FindNextFillingForm.apply(this, arguments);
if (!oRes && !isNext)
return this;
return null;
};
//----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -5214,7 +5214,7 @@ Paragraph.prototype.Correct_Content = function(_StartPos, _EndPos, bDoNotDeleteE
{
var CurElement = this.Content[CurPos];
if ((para_Hyperlink === CurElement.Type || para_Math === CurElement.Type || para_Field === CurElement.Type) && true === CurElement.Is_Empty() && true !== CurElement.Is_CheckingNearestPos())
if ((para_Hyperlink === CurElement.Type || para_Math === CurElement.Type || para_Field === CurElement.Type || para_InlineLevelSdt === CurElement.Type) && true === CurElement.Is_Empty() && true !== CurElement.Is_CheckingNearestPos())
{
this.Internal_Content_Remove(CurPos);
}
......@@ -10857,6 +10857,65 @@ Paragraph.prototype.GetLastRangeVisibleBounds = function()
return {X : X, Y : Y, W : W, H : H, BaseLine : B, XLimit : XLimit};
};
Paragraph.prototype.FindNextFillingForm = function(isNext, isCurrent, isStart)
{
var nCurPos = this.Selection.Use === true ? this.Selection.StartPos : this.CurPos.ContentPos;
var nStartPos = 0, nEndPos = 0;
if (isCurrent)
{
if (isStart)
{
nStartPos = nCurPos;
nEndPos = isNext ? this.Content.length - 1 : 0;
}
else
{
nStartPos = isNext ? 0 : this.Content.length - 1;
nEndPos = nCurPos;
}
}
else
{
if (isNext)
{
nStartPos = 0;
nEndPos = this.Content.length - 1;
}
else
{
nStartPos = this.Content.length - 1;
nEndPos = 0;
}
}
if (isNext)
{
for (var nIndex = nStartPos; nIndex <= nEndPos; ++nIndex)
{
if (this.Content[nIndex].FindNextFillingForm)
{
var oRes = this.Content[nIndex].FindNextFillingForm(true, isCurrent && nIndex === nCurPos ? true : false, isStart);
if (oRes)
return oRes;
}
}
}
else
{
for (var nIndex = nStartPos; nIndex >= nEndPos; --nIndex)
{
if (this.Content[nIndex].FindNextFillingForm)
{
var oRes = this.Content[nIndex].FindNextFillingForm(false, isCurrent && nIndex === nCurPos ? true : false, isStart);
if (oRes)
return oRes;
}
}
}
return null;
};
//----------------------------------------------------------------------------------------------------------------------
Paragraph.prototype.private_ResetSelection = function()
{
......
......@@ -2230,6 +2230,9 @@ CParagraphContentWithParagraphLikeContent.prototype.Selection_DrawRange = functi
};
CParagraphContentWithParagraphLikeContent.prototype.IsSelectionEmpty = function(CheckEnd)
{
if (this.Content.length <= 0)
return true;
var StartPos = this.State.Selection.StartPos;
var EndPos = this.State.Selection.EndPos;
......@@ -2753,6 +2756,7 @@ CParagraphContentWithParagraphLikeContent.prototype.SelectThisElement = function
this.Paragraph.Selection.Use = true;
this.Paragraph.Selection.Start = false;
this.Paragraph.Set_ParaContentPos(StartPos, true, -1, -1);
this.Paragraph.Set_SelectionContentPos(StartPos, EndPos, false);
this.Paragraph.Document_SetThisElementCurrent(false);
......@@ -2807,6 +2811,65 @@ CParagraphContentWithParagraphLikeContent.prototype.ReplaceAllWithText = functio
this.Add_ToContent(0, oRun);
this.MoveCursorToStartPos();
};
CParagraphContentWithParagraphLikeContent.prototype.FindNextFillingForm = function(isNext, isCurrent, isStart)
{
var nCurPos = this.Selection.Use === true ? this.Selection.EndPos : this.State.ContentPos;
var nStartPos = 0, nEndPos = 0;
if (isCurrent)
{
if (isStart)
{
nStartPos = nCurPos;
nEndPos = isNext ? this.Content.length - 1 : 0;
}
else
{
nStartPos = isNext ? 0 : this.Content.length - 1;
nEndPos = nCurPos;
}
}
else
{
if (isNext)
{
nStartPos = 0;
nEndPos = this.Content.length - 1;
}
else
{
nStartPos = this.Content.length - 1;
nEndPos = 0;
}
}
if (isNext)
{
for (var nIndex = nStartPos; nIndex <= nEndPos; ++nIndex)
{
if (this.Content[nIndex].FindNextFillingForm)
{
var oRes = this.Content[nIndex].FindNextFillingForm(true, isCurrent && nIndex === nCurPos ? true : false, isStart);
if (oRes)
return oRes;
}
}
}
else
{
for (var nIndex = nStartPos; nIndex >= nEndPos; --nIndex)
{
if (this.Content[nIndex].FindNextFillingForm)
{
var oRes = this.Content[nIndex].FindNextFillingForm(false, isCurrent && nIndex === nCurPos ? true : false, isStart);
if (oRes)
return oRes;
}
}
}
return null;
};
//----------------------------------------------------------------------------------------------------------------------
// Функции, которые должны быть реализованы в классах наследниках
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -711,6 +711,28 @@ CBlockLevelSdt.prototype.GetLastRangeVisibleBounds = function()
{
return this.Content.GetLastRangeVisibleBounds();
};
CBlockLevelSdt.prototype.FindNextFillingForm = function(isNext, isCurrent, isStart)
{
if (isCurrent && true === this.IsSelectedAll())
{
if (isNext)
return this.Content.FindNextFillingForm(isNext, isCurrent, isStart);
return null;
}
if (!isCurrent && isNext)
return this;
var oRes = this.Content.FindNextFillingForm(isNext, isCurrent, isStart);
if (oRes)
return oRes;
if (!isNext)
return this;
return null;
};
//----------------------------------------------------------------------------------------------------------------------
CBlockLevelSdt.prototype.Is_HdrFtr = function(bReturnHdrFtr)
{
......
......@@ -301,6 +301,25 @@ CInlineLevelSdt.prototype.RemoveContentControlWrapper = function()
this.Remove_FromContent(0, this.Content.length);
};
CInlineLevelSdt.prototype.FindNextFillingForm = function(isNext, isCurrent, isStart)
{
if (isCurrent && true === this.IsSelectedAll())
{
if (isNext)
return CParagraphContentWithParagraphLikeContent.prototype.FindNextFillingForm.apply(this, arguments);
return null;
}
if (!isCurrent && isNext)
return this;
var oRes = CParagraphContentWithParagraphLikeContent.prototype.FindNextFillingForm.apply(this, arguments);
if (!oRes && !isNext)
return this;
return null;
};
//----------------------------------------------------------------------------------------------------------------------
// Выставление настроек
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -2968,6 +2968,83 @@ CTable.prototype.GetLastRangeVisibleBounds = function()
return {X : X_start, Y : Y, W : X_end - X_start, H : H, BaseLine : H, XLimit : Page.XLimit};
};
CTable.prototype.FindNextFillingForm = function(isNext, isCurrent, isStart)
{
var nCurRow = this.Selection.Use === true ? this.Selection.StartPos.Pos.Row : this.CurCell.Row.Index;
var nCurCell = this.Selection.Use === true ? this.Selection.StartPos.Pos.Cell : this.CurCell.Index;
var nStartRow = 0, nStartCell = 0, nEndRow = 0, nEndCell = 0;
if (isCurrent)
{
if (isStart)
{
nStartRow = nCurRow;
nStartCell = nCurCell;
nEndRow = isNext ? this.Content.length - 1 : 0;
nEndCell = isNext ? this.Content[nEndRow].Get_CellsCount() - 1 : 0;
}
else
{
nStartRow = isNext ? 0 : this.Content.length - 1;
nStartCell = isNext ? 0 : this.Content[nStartRow].Get_CellsCount() - 1;
nEndRow = nCurRow;
nEndCell = nCurCell;
}
}
else
{
if (isNext)
{
nStartRow = 0;
nStartCell = 0;
nEndRow = this.Content.length - 1;
nEndCell = this.Content[nEndRow].Get_CellsCount() - 1;
}
else
{
nStartRow = this.Content.length - 1;
nStartCell = this.Content[nEndRow].Get_CellsCount() - 1;
nEndRow = 0;
nEndCell = 0;
}
}
if (isNext)
{
for (var nRowIndex = nStartRow; nRowIndex <= nEndRow; ++nRowIndex)
{
var _nStartCell = nRowIndex === nStartRow ? nStartCell : 0;
var _nEndCell = nRowIndex === nEndRow ? nEndCell : this.Content[nRowIndex].Get_CellsCount() - 1;
for (var nCellIndex = _nStartCell; nCellIndex <= _nEndCell; ++nCellIndex)
{
var oCell = this.Content[nRowIndex].Get_Cell(nCellIndex);
var oRes = oCell.Content.FindNextFillingForm(true, isCurrent && nCellIndex === nCurCell && nRowIndex === nCurRow ? true : false, isStart);
if (oRes)
return oRes;
}
}
}
else
{
for (var nRowIndex = nStartRow; nRowIndex >= nEndRow; --nRowIndex)
{
var _nStartCell = nRowIndex === nStartRow ? nStartCell : this.Content[nRowIndex].Get_CellsCount() - 1;
var _nEndCell = nRowIndex === nEndRow ? nEndCell : 0;
for (var nCellIndex = _nStartCell; nCellIndex >= _nEndCell; --nCellIndex)
{
var oCell = this.Content[nRowIndex].Get_Cell(nCellIndex);
var oRes = oCell.Content.FindNextFillingForm(false, isCurrent && nCellIndex === nCurCell && nRowIndex === nCurRow ? true : false, isStart);
if (oRes)
return oRes;
}
}
}
return null;
};
CTable.prototype.Get_NearestPos = function(CurPage, X, Y, bAnchor, Drawing)
{
var Pos = this.Internal_GetCellByXY(X, Y, CurPage);
......
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