Commit 9c3f8d32 authored by Anna.Pavlova's avatar Anna.Pavlova

Реализованы добавление, удаление Forced Break для Break Operator через контекстное меню

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@68326 954022d7-b5bf-4e40-9824-e11837661b57
parent 8903b14d
......@@ -954,6 +954,7 @@ var historyitem_ParaRun_ContentReviewInfo = 39; // Изменение инфор
var historyitem_ParaRun_OnStartSplit = 40; // Специальное измненение для контролля позиции курсора и селекта
var historyitem_ParaRun_OnEndSplit = 41; // Специальное измненение для контролля позиции курсора и селекта
var historyitem_ParaRun_MathAlnAt = 42; // меняем alnAt в математических свойствах Run
var historyitem_ParaRun_MathForcedBreak = 43; // добавляем/удаляем Forced Break
// Типы изменений в классе ParaTextPr
......
......@@ -425,7 +425,7 @@ ParaRun.prototype.Add = function(Item, bMath)
NewRun.Make_ThisElementCurrent();
}
else if(this.Type == para_Math_Run && this.State.ContentPos == 0 && true === this.IsStartForcedBreakOperator()) // если в начале текущего Run идет принудительный перенос => создаем новый Run
else if(this.Type == para_Math_Run && this.State.ContentPos == 0 && true === this.Is_StartForcedBreakOperator()) // если в начале текущего Run идет принудительный перенос => создаем новый Run
{
var NewRun = new ParaRun(this.Paragraph, bMath);
NewRun.Set_Pr(this.Pr.Copy());
......@@ -7441,6 +7441,19 @@ ParaRun.prototype.Undo = function(Data)
this.MathPrp.Apply_AlnAt(Data.Old);
break;
}
case historyitem_ParaRun_MathForcedBreak:
{
if(Data.bInsert)
{
this.MathPrp.Delete_ForcedBreak();
}
else
{
this.MathPrp.Insert_ForcedBreak(Data.alnAt);
}
break;
}
}
};
......@@ -7869,9 +7882,21 @@ ParaRun.prototype.Redo = function(Data)
this.MathPrp.Apply_AlnAt(Data.New);
break;
}
case historyitem_ParaRun_MathForcedBreak:
{
if(Data.bInsert)
{
this.MathPrp.Insert_ForcedBreak(Data.alnAt);
}
else
{
this.MathPrp.Delete_ForcedBreak();
}
break;
}
}
};
ParaRun.prototype.Check_HistoryUninon = function(Data1, Data2)
{
var Type1 = Data1.Type;
......@@ -8479,6 +8504,20 @@ ParaRun.prototype.Save_Changes = function(Data, Writer)
break;
}
case historyitem_ParaRun_MathForcedBreak:
{
if(Data.bInsert)
{
Writer.WriteBool( true );
}
else
{
Writer.WriteBool( false );
}
break;
}
}
return Writer;
......@@ -9209,6 +9248,19 @@ ParaRun.prototype.Load_Changes = function(Reader, Reader2, Color)
else
this.MathPrp.brk.Apply_AlnAt(undefined);
break;
}
case historyitem_ParaRun_MathForcedBreak:
{
if ( true === Reader.GetBool() )
{
this.MathPrp.brk = new CMathBreak();
}
else
{
this.MathPrp.brk = undefined;
}
break;
}
}
......@@ -10004,6 +10056,107 @@ ParaRun.prototype.Math_UpdateGaps = function(_CurLine, _CurRange, GapsInfo)
}
};
ParaRun.prototype.Math_Can_ModidyForcedBreak = function(Pr, bStart, bEnd)
{
var Pos = this.Math_GetPosForcedBreak(bStart, bEnd);
if(Pos !== null)
{
if(this.MathPrp.IsBreak())
{
Pr.Set_DeleteForcedBreak();
}
else
{
Pr.Set_InsertForcedBreak();
}
}
};
ParaRun.prototype.Math_GetPosForcedBreak = function(bStart, bEnd)
{
var ResultPos = null;
if(this.Content.length > 0)
{
var StartPos = this.Selection.StartPos,
EndPos = this.Selection.EndPos,
bSelect = this.Selection.Use;
if(StartPos > EndPos)
{
StartPos = this.Selection.EndPos;
EndPos = this.Selection.StartPos;
}
var bCheckTwoItem = bSelect == false || (bSelect == true && EndPos == StartPos),
bCheckOneItem = bSelect == true && EndPos - StartPos == 1;
if(bStart)
{
ResultPos = this.Content[0].Type == para_Math_BreakOperator ? 0 : ResultPos;
}
else if(bEnd)
{
var lastPos = this.Content.length - 1;
ResultPos = this.Content[lastPos].Type == para_Math_BreakOperator ? lastPos : ResultPos;
}
else if(bCheckTwoItem)
{
var Pos = bSelect == false ? this.State.ContentPos : StartPos;
var bPrevBreakOperator = Pos > 0 ? this.Content[Pos - 1].Type == para_Math_BreakOperator : false,
bCurrBreakOperator = Pos < this.Content.length ? this.Content[Pos].Type == para_Math_BreakOperator : false;
if(bCurrBreakOperator)
{
ResultPos = Pos
}
else if(bPrevBreakOperator)
{
ResultPos = Pos - 1;
}
}
else if(bCheckOneItem)
{
if(this.Content[StartPos].Type == para_Math_BreakOperator)
{
ResultPos = StartPos;
}
}
}
return ResultPos;
};
ParaRun.prototype.Check_ForcedBreak = function(bStart, bEnd)
{
return this.Math_GetPosForcedBreak(bStart, bEnd) !== null;
};
ParaRun.prototype.Set_MathForcedBreak = function(bInsert)
{
if(bInsert == true && false == this.MathPrp.IsBreak())
{
History.Add(this, {Type: historyitem_ParaRun_MathForcedBreak, bInsert: true, alnAt: undefined });
this.MathPrp.Insert_ForcedBreak();
}
else if(bInsert == false && true == this.MathPrp.IsBreak())
{
History.Add(this, {Type: historyitem_ParaRun_MathForcedBreak, bInsert: false, alnAt: this.MathPrp.Get_AlnAt()});
this.MathPrp.Delete_ForcedBreak();
}
};
ParaRun.prototype.Math_SplitRunForcedBreak = function()
{
var Pos = this.Math_GetPosForcedBreak();
var NewRun = null;
if(Pos != null && Pos > 0) // разбиваем Run на два
{
NewRun = this.Split_Run(Pos);
}
return NewRun;
};
ParaRun.prototype.UpdLastElementForGaps = function(_CurLine, _CurRange, GapsInfo)
{
var CurLine = _CurLine - this.StartLine;
......@@ -10069,16 +10222,17 @@ ParaRun.prototype.IsForcedBreak = function()
{
return this.MathPrp.IsBreak();
};
ParaRun.prototype.IsStartForcedBreakOperator = function()
ParaRun.prototype.Is_StartForcedBreakOperator = function()
{
var BreakPr = true == this.IsForcedBreak();
var StartOperator = this.Content.length > 0 && this.Content[0].Type == para_Math_BreakOperator;
return BreakPr && StartOperator;
return true == this.IsForcedBreak() && true == this.Is_StartBreakOperator();
};
ParaRun.prototype.Is_StartBreakOperator = function()
{
return this.Content.length > 0 && this.Content[0].Type == para_Math_BreakOperator;
};
ParaRun.prototype.Get_AlignBrk = function()
{
return true == this.IsStartForcedBreakOperator() ? this.MathPrp.Get_AlignBrk() : 0;
return true == this.Is_StartForcedBreakOperator() ? this.MathPrp.Get_AlignBrk() : 0;
};
ParaRun.prototype.Math_Is_InclineLetter = function()
{
......@@ -10614,7 +10768,7 @@ ParaRun.prototype.Is_UseInParagraph = function()
};
ParaRun.prototype.Displace_BreakOperator = function(_CurLine, _CurRange, isForward, CountOperators)
{
if(true === this.IsStartForcedBreakOperator())
if(true === this.Is_StartForcedBreakOperator())
{
var AlnAt = this.MathPrp.Get_AlnAt();
......@@ -10633,7 +10787,6 @@ ParaRun.prototype.Displace_BreakOperator = function(_CurLine, _CurRange, isForwa
}
}
};
ParaRun.prototype.Math_UpdateLineMetrics = function(PRS, ParaPr)
{
var LineRule = ParaPr.Spacing.LineRule;
......@@ -10667,6 +10820,7 @@ ParaRun.prototype.Math_UpdateLineMetrics = function(PRS, ParaPr)
}
};
function CParaRunStartState(Run)
{
this.Paragraph = Run.Paragraph;
......
......@@ -2588,6 +2588,8 @@ CMathBase.prototype.Reject_RevisionChanges = function(Type, bAll)
};
CMathBase.prototype.Set_MenuProps = function(Props)
{
this.Apply_ForcedBreak(Props);
if(this.Selection.Use == false)
{
this.Content[this.CurPos].Set_MenuProps(Props);
......@@ -2628,9 +2630,18 @@ CMathBase.prototype.Get_MenuProps = function()
Pos = this.Selection.StartPos;
}
if(Pos !== null && true == this.Content[Pos].Check_Composition())
var bOutsideComposition = Pos !== null && true == this.Content[Pos].Check_Composition(),
bSelectAllComposition = Pos == null;
if(bOutsideComposition)
{
Pr = this.Content[Pos].Get_MenuProps();
this.Can_ModifyForcedBreak(Pr);
}
else if(bSelectAllComposition == false)
{
Pr = this.Get_InterfaceProps();
this.Content[Pos].Can_ModifyForcedBreak(Pr);
}
else
{
......@@ -2641,6 +2652,12 @@ CMathBase.prototype.Get_MenuProps = function()
};
CMathBase.prototype.Apply_MenuProps = function()
{};
CMathBase.prototype.Can_ModifyForcedBreak = function(Pr)
{
};
CMathBase.prototype.Apply_ForcedBreak = function()
{
};
CMathBase.prototype.Get_DeletedItemsThroughInterface = function()
{
var baseContent = this.getBase();
......@@ -3150,6 +3167,16 @@ CMathMenuBase.prototype.remove_Radical = function()
{
this.Action |= c_oMathMenuAction.RemoveRadical;
};
CMathMenuBase.prototype.Set_InsertForcedBreak = function()
{
this.CanInsertForcedBreak = true;
this.CanDeleteForcedBreak = false;
};
CMathMenuBase.prototype.Set_DeleteForcedBreak = function()
{
this.CanInsertForcedBreak = false;
this.CanDeleteForcedBreak = true;
};
window["CMathMenuBase"] = CMathMenuBase;
CMathMenuBase.prototype["get_Type"] = CMathMenuBase.prototype.get_Type;
......
......@@ -823,19 +823,19 @@ CBox.prototype.Can_ModifyArgSize = function()
};
CBox.prototype.Apply_MenuProps = function(Props)
{
if(Props.Type === c_oAscMathInterfaceType.Box)
// не проверяем изменения на тип !
// потому что может прийти свойства из другого (вложенного в Box) мат объекта, но при этом есть возможность вставить/удалить принудительный перенос для Box
if(Props.Action & c_oMathMenuAction.InsertForcedBreak && true == this.Can_InsertForcedBreak())
{
if(Props.Action & c_oMathMenuAction.InsertForcedBreak && true == this.Can_InsertForcedBreak())
{
History.Add(this, new CChangesMathBoxForcedBreak(true, false));
this.raw_ForcedBreak(true);
}
History.Add(this, new CChangesMathBoxForcedBreak(true, false));
this.raw_ForcedBreak(true);
}
if(Props.Action & c_oMathMenuAction.DeleteForcedBreak && true == this.Can_DeleteForcedBreak())
{
History.Add(this, new CChangesMathBoxForcedBreak(false, true));
this.raw_ForcedBreak(false);
}
if(Props.Action & c_oMathMenuAction.DeleteForcedBreak && true == this.Can_DeleteForcedBreak())
{
History.Add(this, new CChangesMathBoxForcedBreak(false, true));
this.raw_ForcedBreak(false);
}
};
CBox.prototype.Get_InterfaceProps = function()
......@@ -861,6 +861,29 @@ CBox.prototype.raw_ForcedBreak = function(InsertBreak)
this.Pr.Delete_ForcedBreak();
}
};
CBox.prototype.Can_ModifyForcedBreak = function(Pr)
{
if(true == this.Can_InsertForcedBreak())
{
Pr.Set_InsertForcedBreak();
}
else
{
Pr.Set_DeleteForcedBreak();
}
};
CBox.prototype.Apply_ForcedBreak = function(Props)
{
this.Apply_MenuProps(Props);
// исключаем из Props, чтобы не применить к операторам внути Box
// иначе при Drag'n'Drop оператора получим неочевидный результат : принудительный перенос
if(Props.Action & c_oMathMenuAction.InsertForcedBreak)
Props.Action ^= c_oMathMenuAction.InsertForcedBreak;
if(Props.Action & c_oMathMenuAction.DeleteForcedBreak)
Props.Action ^= c_oMathMenuAction.DeleteForcedBreak;
};
/**
*
......
......@@ -193,6 +193,7 @@ AmperWidths.prototype.SetDefault = function()
this.Widths.length = 0;
};
function CGeneralObjectGaps(Left, Right)
{
this.left = Left;
......@@ -716,6 +717,17 @@ CMPrp.prototype =
{
this.brk.Apply_AlnAt(alnAt);
}
},
Insert_ForcedBreak: function(AlnAt)
{
if(this.brk == undefined)
this.brk = new CMathBreak();
this.brk.Apply_AlnAt(AlnAt);
},
Delete_ForcedBreak: function()
{
this.brk = undefined;
}
};
......@@ -3959,7 +3971,7 @@ CMathContent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
if(Type == para_Math_Run)
{
if(true === Item.IsStartForcedBreakOperator())
if(true === Item.Is_StartForcedBreakOperator())
{
Item.Recalculate_Range(PRS, ParaPr, Depth + 1);
}
......@@ -4716,6 +4728,67 @@ CMathContent.prototype.Check_Composition = function()
return Pos !== null && this.Content[Pos].Type == para_Math_Composition;
};
CMathContent.prototype.Can_ModifyForcedBreak = function(Pr)
{
var Pos = null;
var CurPos;
if(true === this.Selection.Use)
{
var StartPos = this.Selection.StartPos,
EndPos = this.Selection.EndPos;
if ( StartPos > EndPos )
{
StartPos = this.Selection.EndPos;
EndPos = this.Selection.StartPos;
}
var bFirstItem = false;
for(CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
if(true !== this.Content[CurPos].Selection_IsEmpty())
{
if(bFirstItem == true)
break;
bFirstItem = true;
Pos = CurPos;
}
}
}
else
{
Pos = this.CurPos;
}
if(Pos !== null && this.bOneLine == false)
{
var bBreakOperator = this.Content[Pos].Check_ForcedBreak();
var CurrentRun = this.Content[Pos];
var bCanCheckNearsRun = bBreakOperator == false && false == CurrentRun.Is_SelectionUse();
var bPrevItem = bCanCheckNearsRun && Pos > 0 && true == CurrentRun.Cursor_Is_Start(),
bNextItem = bCanCheckNearsRun && Pos < this.Content.length && true == CurrentRun.Cursor_Is_End();
var bPrevRun = bPrevItem && this.Content[Pos - 1].Type == para_Math_Run,
bNextRun = bNextItem && this.Content[Pos + 1].Type == para_Math_Run;
if(bBreakOperator)
{
this.Content[Pos].Math_Can_ModidyForcedBreak(Pr);
}
else if(bPrevRun)
{
this.Content[Pos - 1].Math_Can_ModidyForcedBreak(Pr, true, false);
}
else if(bNextRun)
{
this.Content[Pos + 1].Math_Can_ModidyForcedBreak(Pr, false, true);
}
}
};
CMathContent.prototype.private_FindCurrentPosInContent = function()
{
var Pos = null;
......@@ -4725,6 +4798,12 @@ CMathContent.prototype.private_FindCurrentPosInContent = function()
var StartPos = this.Selection.StartPos,
EndPos = this.Selection.EndPos;
if ( StartPos > EndPos )
{
StartPos = this.Selection.EndPos;
EndPos = this.Selection.StartPos;
}
var bComposition = false;
for(var CurPos = StartPos; CurPos <= EndPos; CurPos++)
......@@ -4770,10 +4849,13 @@ CMathContent.prototype.Set_MenuProps = function(Props)
if(true == this.Is_CurrentContent())
{
this.Apply_MenuProps(Props);
this.Apply_MenuProps(Props, Pos);
}
else if(false == this.private_IsMenuPropsForContent(Props.Action) && true == this.Content[Pos].Can_ApplyMenuPropsToObject())
{
// не нужно проходиться по вложенным элементам
// 1. уже применили изменения, продожать нет необходимости
// 2. потому что могут совпать типы текущего элемента и вложенного и тогда изменения применятся к обоим элементам
if(false === this.Delete_ItemToContentThroughInterface(Props, Pos)) // try to delete
{
this.Content[Pos].Apply_MenuProps(Props);
......@@ -4784,7 +4866,7 @@ CMathContent.prototype.Set_MenuProps = function(Props)
this.Content[Pos].Set_MenuProps(Props);
}
};
CMathContent.prototype.Apply_MenuProps = function(Props)
CMathContent.prototype.Apply_MenuProps = function(Props, Pos)
{
var ArgSize, NewArgSize;
......@@ -4799,8 +4881,7 @@ CMathContent.prototype.Apply_MenuProps = function(Props)
this.Recalc_RunsCompiledPr();
}
}
if(Props.Action & c_oMathMenuAction.DecreaseArgumentSize)
else if(Props.Action & c_oMathMenuAction.DecreaseArgumentSize)
{
if(true === this.Parent.Can_ModifyArgSize() && true == this.Compiled_ArgSz.Can_Decrease() && true == this.ArgSize.Can_Decrease())
{
......@@ -4812,6 +4893,53 @@ CMathContent.prototype.Apply_MenuProps = function(Props)
}
}
var Run;
if(Pos !== null && Props.Action & c_oMathMenuAction.InsertForcedBreak)
{
Run = this.private_Get_RunForForcedBreak(Pos);
Run.Set_MathForcedBreak(true);
}
else if(Pos !== null && Props.Action & c_oMathMenuAction.DeleteForcedBreak)
{
Run = this.private_Get_RunForForcedBreak(Pos);
Run.Set_MathForcedBreak(false);
}
};
CMathContent.prototype.private_Get_RunForForcedBreak = function(Pos)
{
var CurrentRun = this.Content[Pos];
var bCurrentForcedBreak = this.Content[Pos].Type == para_Math_Run && true == CurrentRun.Check_ForcedBreak(),
bPrevForcedBreak = Pos > 0 && true == CurrentRun.Cursor_Is_Start(),
bNextForcedBreak = Pos < this.Content.length && true == CurrentRun.Cursor_Is_End();
var Run = null;
if(bCurrentForcedBreak)
{
Run = this.Content[Pos];
var NewRun = Run.Math_SplitRunForcedBreak();
if(NewRun !== null)
{
this.Internal_Content_Add(Pos+1, NewRun, true);
Run = NewRun;
}
}
else if(bPrevForcedBreak)
{
Run = this.Content[Pos - 1];
}
else if(bNextForcedBreak)
{
Run = this.Content[Pos + 1];
}
return Run;
};
CMathContent.prototype.Delete_ItemToContentThroughInterface = function(Props, Pos)
{
......@@ -4884,19 +5012,26 @@ CMathContent.prototype.Get_MenuProps = function()
var Pos = this.private_FindCurrentPosInContent();
if(Pos !== null)
if(Pos !== null && this.Content[Pos].Type == para_Math_Composition)
{
if(this.Content[Pos].Type == para_Math_Composition)
{
Pr = this.Content[Pos].Get_MenuProps();
}
Pr = this.Content[Pos].Get_MenuProps();
}
else
{
this.Can_ModifyForcedBreak(Pr);
}
return Pr;
};
CMathContent.prototype.private_IsMenuPropsForContent = function(Action)
{
return Action & c_oMathMenuAction.IncreaseArgumentSize || Action & c_oMathMenuAction.DecreaseArgumentSize;
// данные изменения могут прийти для любого типа изменений
var bInsertForcedBreak = Action & c_oMathMenuAction.InsertForcedBreak,
bDeleteForcedBreak = Action & c_oMathMenuAction.DeleteForcedBreak,
bIncreaseArgSize = Action & c_oMathMenuAction.IncreaseArgumentSize,
bDecreaseArgSize = Action & c_oMathMenuAction.DecreaseArgumentSize;
return bDecreaseArgSize || bIncreaseArgSize || bInsertForcedBreak || bDeleteForcedBreak;
};
CMathContent.prototype.Process_AutoCorrect = function(ActionElement)
{
......
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