Commit 42976085 authored by Ilya.Kirillov's avatar Ilya.Kirillov

Поправлена функция копирования для класс CFraction. Сделано, чтобы при...

Поправлена функция копирования для класс  CFraction. Сделано, чтобы при удалении последнего элемента в формуле сама формула удалялась. Поправлена функция копирования в ParaRun для формул.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58741 954022d7-b5bf-4e40-9824-e11837661b57
parent 74740a79
...@@ -102,6 +102,8 @@ ParaMath.prototype.Copy = function(Selected) ...@@ -102,6 +102,8 @@ ParaMath.prototype.Copy = function(Selected)
/// argSize, bDot и bRoot выставить на объединении контентов /// argSize, bDot и bRoot выставить на объединении контентов
NewMath.SetNeedResize();
return NewMath; return NewMath;
}; };
...@@ -112,7 +114,13 @@ ParaMath.prototype.Set_Paragraph = function(Paragraph) ...@@ -112,7 +114,13 @@ ParaMath.prototype.Set_Paragraph = function(Paragraph)
ParaMath.prototype.Is_Empty = function() ParaMath.prototype.Is_Empty = function()
{ {
return this.Root.content.length == 0; if (this.Root.content.length <= 0)
return true;
if (1 === this.Root.content.length)
return this.Root.content[0].Is_Empty({SkipPlcHldr : true});
return false;
}; };
ParaMath.prototype.Is_StartFromNewLine = function() ParaMath.prototype.Is_StartFromNewLine = function()
......
...@@ -2321,8 +2321,7 @@ Paragraph.prototype = ...@@ -2321,8 +2321,7 @@ Paragraph.prototype =
if ( true !== this.Content[this.CurPos.ContentPos].Selection_IsUse() ) if ( true !== this.Content[this.CurPos.ContentPos].Selection_IsUse() )
{ {
this.Selection_Remove(); this.Selection_Remove();
this.Correct_Content(StartPos, EndPos); this.Correct_Content();
} }
else else
{ {
...@@ -2332,7 +2331,7 @@ Paragraph.prototype = ...@@ -2332,7 +2331,7 @@ Paragraph.prototype =
this.Selection.StartPos = this.CurPos.ContentPos; this.Selection.StartPos = this.CurPos.ContentPos;
this.Selection.EndPos = this.CurPos.ContentPos; this.Selection.EndPos = this.CurPos.ContentPos;
this.Correct_Content(StartPos, EndPos); this.Correct_Content();
this.Document_SetThisElementCurrent(false); this.Document_SetThisElementCurrent(false);
...@@ -4813,7 +4812,7 @@ Paragraph.prototype = ...@@ -4813,7 +4812,7 @@ Paragraph.prototype =
{ {
// В данной функции мы корректируем содержимое параграфа: // В данной функции мы корректируем содержимое параграфа:
// 1. Спаренные пустые раны мы удаляем (удаляем 1 ран) // 1. Спаренные пустые раны мы удаляем (удаляем 1 ран)
// 2. Удаляем пустые гиперссылки // 2. Удаляем пустые гиперссылки и пустые формулы
// 3. Добавляем пустой ран в место, где нет рана (например, между двумя идущими подряд гиперссылками) // 3. Добавляем пустой ран в место, где нет рана (например, между двумя идущими подряд гиперссылками)
// 4. Удаляем пустые комментарии // 4. Удаляем пустые комментарии
...@@ -4825,7 +4824,7 @@ Paragraph.prototype = ...@@ -4825,7 +4824,7 @@ Paragraph.prototype =
{ {
var CurElement = this.Content[CurPos]; var CurElement = this.Content[CurPos];
if ( para_Hyperlink === CurElement.Type && true === CurElement.Is_Empty() ) if ((para_Hyperlink === CurElement.Type || para_Math === CurElement.Type) && true === CurElement.Is_Empty())
{ {
this.Internal_Content_Remove( CurPos ); this.Internal_Content_Remove( CurPos );
CurPos++; CurPos++;
...@@ -4865,7 +4864,7 @@ Paragraph.prototype = ...@@ -4865,7 +4864,7 @@ Paragraph.prototype =
else else
{ {
// TODO (Para_End): Предпоследний элемент мы не проверяем, т.к. на ран с Para_End мы не ориентируемся // TODO (Para_End): Предпоследний элемент мы не проверяем, т.к. на ран с Para_End мы не ориентируемся
if ( true === CurElement.Is_Empty() && CurPos < this.Content.length - 2 && para_Run === this.Content[CurPos + 1].Type ) if ( true === CurElement.Is_Empty() && CurPos < this.Content.length - 1 && para_Run === this.Content[CurPos + 1].Type )
this.Internal_Content_Remove( CurPos ); this.Internal_Content_Remove( CurPos );
} }
} }
...@@ -4876,6 +4875,13 @@ Paragraph.prototype = ...@@ -4876,6 +4875,13 @@ Paragraph.prototype =
this.LogicDocument.Remove_Comment( CommentsToDelete[CommentIndex], true, false ); this.LogicDocument.Remove_Comment( CommentsToDelete[CommentIndex], true, false );
} }
// Проверим, чтобы предпоследний элемент был Run
if (1 === this.Content.length || para_Run !== this.Content[this.Content.length - 2].Type)
{
var NewRun = new ParaRun(this);
this.Internal_Content_Add(this.Content.length - 1, NewRun);
}
this.Correct_ContentPos2(); this.Correct_ContentPos2();
}, },
......
...@@ -96,14 +96,14 @@ ParaRun.prototype.Save_StartState = function() ...@@ -96,14 +96,14 @@ ParaRun.prototype.Save_StartState = function()
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
ParaRun.prototype.Copy = function(Selected) ParaRun.prototype.Copy = function(Selected)
{ {
var NewRun = new ParaRun(this.Paragraph); var bMath = this.Type == para_Math_Run ? true : false;
var NewRun = new ParaRun(this.Paragraph, bMath);
NewRun.Set_Pr( this.Pr.Copy() ); NewRun.Set_Pr( this.Pr.Copy() );
if(this.Type == para_Math_Run) if(true === bMath)
{
NewRun.MathPrp = this.MathPrp.Copy(); NewRun.MathPrp = this.MathPrp.Copy();
}
var StartPos = 0; var StartPos = 0;
var EndPos = this.Content.length; var EndPos = this.Content.length;
...@@ -216,10 +216,11 @@ ParaRun.prototype.Is_Empty = function(Props) ...@@ -216,10 +216,11 @@ ParaRun.prototype.Is_Empty = function(Props)
{ {
var SkipAnchor = (undefined !== Props ? Props.SkipAnchor : false); var SkipAnchor = (undefined !== Props ? Props.SkipAnchor : false);
var SkipEnd = (undefined !== Props ? Props.SkipEnd : false); var SkipEnd = (undefined !== Props ? Props.SkipEnd : false);
var SkipPlcHldr= (undefined !== Props ? Props.SkipPlcHldr: false);
var Count = this.Content.length; var Count = this.Content.length;
if ( true !== SkipAnchor && true !== SkipEnd ) if (true !== SkipAnchor && true !== SkipEnd && true !== SkipPlcHldr)
{ {
if ( Count > 0 ) if ( Count > 0 )
return false; return false;
...@@ -233,7 +234,7 @@ ParaRun.prototype.Is_Empty = function(Props) ...@@ -233,7 +234,7 @@ ParaRun.prototype.Is_Empty = function(Props)
var Item = this.Content[CurPos]; var Item = this.Content[CurPos];
var ItemType = Item.Type; var ItemType = Item.Type;
if ( ( true !== SkipAnchor || para_Drawing !== ItemType || false !== Item.Is_Inline() ) && ( true !== SkipEnd || para_End !== ItemType ) ) if ((true !== SkipAnchor || para_Drawing !== ItemType || false !== Item.Is_Inline()) && (true !== SkipEnd || para_End !== ItemType) && (true !== SkipPlcHldr || true !== Item.IsPlaceholder()))
return false; return false;
} }
......
...@@ -395,6 +395,23 @@ CFraction.prototype.getPropsForWrite = function() ...@@ -395,6 +395,23 @@ CFraction.prototype.getPropsForWrite = function()
{ {
return this.Pr; return this.Pr;
} }
CFraction.prototype.Copy = function()
{
var oProps =
{
ctrPrp : this.CtrPrp.Copy(),
type : this.Pr.Type
};
var NewFraction = new CFraction(oProps);
this.Denominator.getElement().CopyTo(NewFraction.Denominator.getElement(), false);
this.Numerator.getElement().CopyTo(NewFraction.Numerator.getElement(), false);
NewFraction.fillContent();
return NewFraction;
};
CFraction.prototype.Refresh_RecalcData = function(Data) CFraction.prototype.Refresh_RecalcData = function(Data)
{ {
} }
......
...@@ -2262,9 +2262,23 @@ CMathContent.prototype = ...@@ -2262,9 +2262,23 @@ CMathContent.prototype =
if ( this.Selection.End >= Pos ) if ( this.Selection.End >= Pos )
this.Selection.End++; this.Selection.End++;
this.private_CorrectSelectionPos();
this.private_CorrectCurPos();
} }
}, },
private_CorrectSelectionPos : function()
{
this.Selection.Start = Math.max(0, Math.min(this.content.length - 1, this.Selection.Start));
this.Selection.End = Math.max(0, Math.min(this.content.length - 1, this.Selection.End));
},
private_CorrectCurPos : function()
{
this.CurPos = Math.max(0, Math.min(this.content.length - 1, this.CurPos));
},
Add_ToContent : function(Pos, Item) Add_ToContent : function(Pos, Item)
{ {
this.Internal_Content_Add(Pos, Item); this.Internal_Content_Add(Pos, Item);
...@@ -2288,6 +2302,8 @@ CMathContent.prototype = ...@@ -2288,6 +2302,8 @@ CMathContent.prototype =
this.CurPos -= Count; this.CurPos -= Count;
else else
this.CurPos = Pos; this.CurPos = Pos;
this.private_CorrectCurPos();
} }
if ( true === this.Selection.Use ) if ( true === this.Selection.Use )
...@@ -2307,6 +2323,8 @@ CMathContent.prototype = ...@@ -2307,6 +2323,8 @@ CMathContent.prototype =
else else
this.Selection.End = Pos; this.Selection.End = Pos;
} }
this.private_CorrectSelectionPos();
} }
}, },
...@@ -2546,9 +2564,10 @@ CMathContent.prototype = ...@@ -2546,9 +2564,10 @@ CMathContent.prototype =
else else
oElement = this.content[nPos].Copy(false); oElement = this.content[nPos].Copy(false);
OtherContent.Internal_Content_Add(OtherContent.length, oElement); OtherContent.Internal_Content_Add(OtherContent.content.length, oElement);
} }
}, },
Selection_Remove: function() Selection_Remove: function()
{ {
var start = this.Selection.Start, var start = this.Selection.Start,
......
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