Commit 826df54a authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander.Trofimov

Сделана обработка Drag-n-drop текста/inline автофигур/float автофигур в новом...

Сделана обработка Drag-n-drop текста/inline автофигур/float автофигур в новом варианте параграфа. Исправлены баг с неправильным позиционированием inlinе автофигуры с ненулевым position в текстовых настройках. Исправлен баг с удалением.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54681 954022d7-b5bf-4e40-9824-e11837661b57
parent 85fee1a6
......@@ -934,6 +934,20 @@ ParaComment.prototype =
{
return false;
},
Get_DrawingObjectRun : function(Id)
{
return null;
},
Get_DrawingObjectContentPos : function(Id, ContentPos, Depth)
{
return false;
},
Get_Layout : function(DrawingLayout, UseContentPos, ContentPos, Depth)
{
},
//-----------------------------------------------------------------------------------
// Функции пересчета
//-----------------------------------------------------------------------------------
......
......@@ -8236,6 +8236,8 @@ CDocument.prototype =
if ( true === this.Selection_Check( 0, 0, 0, NearPos ) )
{
this.Selection_Remove();
// Нам надо снять селект и поставить курсор в то место, где была ближайшая позиция
var Paragraph = NearPos.Paragraph;
Paragraph.Cursor_MoveToNearPos( NearPos );
......@@ -8270,9 +8272,13 @@ CDocument.prototype =
{
History.Create_NewPoint();
// Если надо удаляем выделенную часть
// Если надо удаляем выделенную часть (пересчет отключаем на время удаления)
if ( true !== bCopy )
{
this.TurnOffRecalc = true;
this.Remove(1, false, false, false);
this.TurnOffRecalc = false;
}
this.Selection_Remove();
......@@ -8346,34 +8352,83 @@ CDocument.prototype =
var FirstElement = SelectedContent.Elements[0];
if ( 1 === ElementsCount && true !== FirstElement.SelectedAll && type_Paragraph === FirstElement.Element.GetType() )
{
// Нам нужно в заданный параграф вставить выделенный текст
var NewPara = FirstElement.Element;
var NewElementsCount = NewPara.Content.length;
var InsertedCount = 0;
if ( true !== Debug_ParaRunMode )
{
// Нам нужно в заданный параграф вставить выделенный текст
var NewPara = FirstElement.Element;
var NewElementsCount = NewPara.Content.length;
var InsertedCount = 0;
var OldTextPr = Para.Internal_GetTextPr( NearContentPos );
var OldTextPr = Para.Internal_GetTextPr( NearContentPos );
for ( var Index = 0; Index < NewElementsCount; Index++ )
{
var Item = NewPara.Content[Index];
var ItemType = Item.Type;
if ( para_Empty !== ItemType && para_End !== ItemType )
for ( var Index = 0; Index < NewElementsCount; Index++ )
{
Para.Internal_Content_Add( NearContentPos + InsertedCount, Item, false );
InsertedCount++;
var Item = NewPara.Content[Index];
var ItemType = Item.Type;
if ( para_Empty !== ItemType && para_End !== ItemType )
{
Para.Internal_Content_Add( NearContentPos + InsertedCount, Item, false );
InsertedCount++;
}
}
Para.Internal_Content_Add( NearContentPos + InsertedCount, new ParaTextPr(OldTextPr), false );
InsertedCount++;
Para.Selection.Use = true;
Para.Selection.StartPos = NearContentPos;
Para.Selection.EndPos = NearContentPos + InsertedCount;
this.Selection.Use = true;
this.Selection.StartPos = DstIndex;
this.Selection.EndPos = DstIndex;
}
else
{
// Нам нужно в заданный параграф вставить выделенный текст
var NewPara = FirstElement.Element;
var NewElementsCount = NewPara.Content.length - 1; // Последний ран с para_End не добавляем
Para.Internal_Content_Add( NearContentPos + InsertedCount, new ParaTextPr(OldTextPr), false );
InsertedCount++;
var ParaNearPos = Para.Get_ParaNearestPos( NearPos );
if ( null === ParaNearPos || ParaNearPos.Classes.length < 2 )
return;
Para.Selection.Use = true;
Para.Selection.StartPos = NearContentPos;
Para.Selection.EndPos = NearContentPos + InsertedCount;
var LastClass = ParaNearPos.Classes[ParaNearPos.Classes.length - 1];
if ( para_Run !== LastClass.Type )
return;
this.Selection.Use = true;
this.Selection.StartPos = DstIndex;
this.Selection.EndPos = DstIndex;
var NewElement = LastClass.Split( ParaNearPos.NearPos.ContentPos, ParaNearPos.Classes.length - 1 );
var PrevClass = ParaNearPos.Classes[ParaNearPos.Classes.length - 2];
var PrevPos = ParaNearPos.NearPos.ContentPos.Data[ParaNearPos.Classes.length - 2];
PrevClass.Add_ToContent( PrevPos + 1, NewElement );
for ( var Index = 0; Index < NewElementsCount; Index++ )
{
var Item = NewPara.Content[Index];
PrevClass.Add_ToContent( PrevPos + 1 + Index, Item );
Item.Select_All();
}
PrevClass.Selection.Use = true;
PrevClass.Selection.StartPos = PrevPos + 1;
PrevClass.Selection.EndPos = PrevPos + 1 + NewElementsCount - 1;
for ( var Index = 0; Index < ParaNearPos.Classes.length - 2; Index++ )
{
var Class = ParaNearPos.Classes[Index];
var ClassPos = ParaNearPos.NearPos.ContentPos.Data[Index];
Class.Selection.Use = true;
Class.Selection.StartPos = ClassPos;
Class.Selection.EndPos = ClassPos;
}
this.Selection.Use = true;
this.Selection.StartPos = DstIndex;
this.Selection.EndPos = DstIndex;
}
}
else
{
......@@ -8415,9 +8470,23 @@ CDocument.prototype =
StartIndex++;
ParaS.Selection.Use = true;
ParaS.Selection.StartPos = NearContentPos;
ParaS.Selection.EndPos = ParaS.Content.length - 1;
if ( true !== Debug_ParaRunMode )
{
ParaS.Selection.Use = true;
ParaS.Selection.StartPos = NearContentPos;
ParaS.Selection.EndPos = ParaS.Content.length - 1;
}
else
{
var TempPara = Elements[0].Element;
// Вызываем так, чтобы выделить все внутренние элементы
TempPara.Select_All();
ParaS.Selection.Use = true;
ParaS.Selection.StartPos = ParaS.Content.length - TempPara.Content.length;
ParaS.Selection.EndPos = ParaS.Content.length - 1;
}
}
var EndIndex = ElementsCount - 1;
......@@ -8425,7 +8494,12 @@ CDocument.prototype =
{
var _ParaE = Elements[ElementsCount - 1].Element;
var TempCount = _ParaE.Internal_GetEndPos();
var TempCount = ( true !== Debug_ParaRunMode ? _ParaE.Internal_GetEndPos() : _ParaE.Content.length - 1 );
if ( true === Debug_ParaRunMode )
{
_ParaE.Select_All();
}
_ParaE.Concat( ParaE );
_ParaE.Set_Pr( ParaE.Pr );
......@@ -8452,7 +8526,8 @@ CDocument.prototype =
this.Selection.EndPos = DstIndex + ElementsCount - 1;
}
this.CurPos.Type = docpostype_Content;
if ( docpostype_DrawingObjects !== this.CurPos.Type )
this.CurPos.Type = docpostype_Content;
},
Document_SelectNumbering : function(NumPr)
......
......@@ -3586,35 +3586,84 @@ CDocumentContent.prototype =
var FirstElement = SelectedContent.Elements[0];
if ( 1 === ElementsCount && true !== FirstElement.SelectedAll && type_Paragraph === FirstElement.Element.GetType() )
{
// Нам нужно в заданный параграф вставить выделенный текст
var NewPara = FirstElement.Element;
var NewElementsCount = NewPara.Content.length;
var InsertedCount = 0;
if ( true !== Debug_ParaRunMode )
{
// Нам нужно в заданный параграф вставить выделенный текст
var NewPara = FirstElement.Element;
var NewElementsCount = NewPara.Content.length;
var InsertedCount = 0;
var OldTextPr = Para.Internal_GetTextPr( NearContentPos );
var OldTextPr = Para.Internal_GetTextPr( NearContentPos );
for ( var Index = 0; Index < NewElementsCount; Index++ )
{
var Item = NewPara.Content[Index];
var ItemType = Item.Type;
if ( para_Empty !== ItemType && para_End !== ItemType )
for ( var Index = 0; Index < NewElementsCount; Index++ )
{
Para.Internal_Content_Add( NearContentPos + InsertedCount, Item, false );
InsertedCount++;
var Item = NewPara.Content[Index];
var ItemType = Item.Type;
if ( para_Empty !== ItemType && para_End !== ItemType )
{
Para.Internal_Content_Add( NearContentPos + InsertedCount, Item, false );
InsertedCount++;
}
}
Para.Internal_Content_Add( NearContentPos + InsertedCount, new ParaTextPr(OldTextPr), false );
InsertedCount++;
Para.Selection.Use = true;
Para.Selection.StartPos = NearContentPos;
Para.Selection.EndPos = NearContentPos + InsertedCount;
this.Selection.Start = false;
this.Selection.Use = true;
this.Selection.StartPos = DstIndex;
this.Selection.EndPos = DstIndex;
}
else
{
// Нам нужно в заданный параграф вставить выделенный текст
var NewPara = FirstElement.Element;
var NewElementsCount = NewPara.Content.length - 1; // Последний ран с para_End не добавляем
Para.Internal_Content_Add( NearContentPos + InsertedCount, new ParaTextPr(OldTextPr), false );
InsertedCount++;
var ParaNearPos = Para.Get_ParaNearestPos( NearPos );
if ( null === ParaNearPos || ParaNearPos.Classes.length < 2 )
return;
Para.Selection.Use = true;
Para.Selection.StartPos = NearContentPos;
Para.Selection.EndPos = NearContentPos + InsertedCount;
var LastClass = ParaNearPos.Classes[ParaNearPos.Classes.length - 1];
if ( para_Run !== LastClass.Type )
return;
this.Selection.Start = false;
this.Selection.Use = true;
this.Selection.StartPos = DstIndex;
this.Selection.EndPos = DstIndex;
var NewElement = LastClass.Split( ParaNearPos.NearPos.ContentPos, ParaNearPos.Classes.length - 1 );
var PrevClass = ParaNearPos.Classes[ParaNearPos.Classes.length - 2];
var PrevPos = ParaNearPos.NearPos.ContentPos.Data[ParaNearPos.Classes.length - 2];
PrevClass.Add_ToContent( PrevPos + 1, NewElement );
for ( var Index = 0; Index < NewElementsCount; Index++ )
{
var Item = NewPara.Content[Index];
PrevClass.Add_ToContent( PrevPos + 1 + Index, Item );
Item.Select_All();
}
PrevClass.Selection.Use = true;
PrevClass.Selection.StartPos = PrevPos + 1;
PrevClass.Selection.EndPos = PrevPos + 1 + NewElementsCount - 1;
for ( var Index = 0; Index < ParaNearPos.Classes.length - 2; Index++ )
{
var Class = ParaNearPos.Classes[Index];
var ClassPos = ParaNearPos.NearPos.ContentPos.Data[Index];
Class.Selection.Use = true;
Class.Selection.StartPos = ClassPos;
Class.Selection.EndPos = ClassPos;
}
this.Selection.Use = true;
this.Selection.StartPos = DstIndex;
this.Selection.EndPos = DstIndex;
}
}
else
{
......@@ -3656,9 +3705,23 @@ CDocumentContent.prototype =
StartIndex++;
ParaS.Selection.Use = true;
ParaS.Selection.StartPos = NearContentPos;
ParaS.Selection.EndPos = ParaS.Content.length - 1;
if ( true !== Debug_ParaRunMode )
{
ParaS.Selection.Use = true;
ParaS.Selection.StartPos = NearContentPos;
ParaS.Selection.EndPos = ParaS.Content.length - 1;
}
else
{
var TempPara = Elements[0].Element;
// Вызываем так, чтобы выделить все внутренние элементы
TempPara.Select_All();
ParaS.Selection.Use = true;
ParaS.Selection.StartPos = ParaS.Content.length - TempPara.Content.length;
ParaS.Selection.EndPos = ParaS.Content.length - 1;
}
}
var EndIndex = ElementsCount - 1;
......@@ -3666,7 +3729,12 @@ CDocumentContent.prototype =
{
var _ParaE = Elements[ElementsCount - 1].Element;
var TempCount = _ParaE.Internal_GetEndPos();
var TempCount = ( true !== Debug_ParaRunMode ? _ParaE.Internal_GetEndPos() : _ParaE.Content.length - 1 );
if ( true === Debug_ParaRunMode )
{
_ParaE.Select_All();
}
_ParaE.Concat( ParaE );
_ParaE.Set_Pr( ParaE.Pr );
......
......@@ -12,6 +12,7 @@ function ParaHyperlink()
this.ToolTip = "";
this.State = new CParaRunState();
this.Selection = this.State.Selection;
this.Content = new Array();
......@@ -24,6 +25,8 @@ function ParaHyperlink()
this.Range = this.Lines[0].Ranges[0];
this.NearPosArray = new Array();
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
......@@ -35,6 +38,41 @@ ParaHyperlink.prototype =
return this.Id;
},
Copy : function(Selected)
{
var NewHyperlink = new ParaHyperlink();
NewHyperlink.Set_Value( this.Value );
NewHyperlink.Set_ToolTip( this.ToolTip );
var StartPos = 0;
var EndPos = this.Content.length - 1;
if ( true === Selected && true === this.State.Selection.Use )
{
StartPos = this.State.Selection.StartPos;
EndPos = this.State.Selection.EndPos;
if ( StartPos > EndPos )
{
StartPos = this.State.Selection.EndPos;
EndPos = this.State.Selection.StartPos;
}
}
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
var Item = this.Content[CurPos];
if ( StartPos === CurPos || EndPos === CurPos )
NewHyperlink.Add_ToContent( CurPos - StartPos, Item.Copy(Selected) );
else
NewHyperlink.Add_ToContent( CurPos - StartPos, Item.Copy(false) );
}
return NewHyperlink;
},
Set_Paragraph : function(Paragraph)
{
this.Paragraph = Paragraph;
......@@ -161,6 +199,18 @@ ParaHyperlink.prototype =
}
}
}
// Обновляем позиции в NearestPos
var NearPosLen = this.NearPosArray.length;
for ( var Index = 0; Index < NearPosLen; Index++ )
{
var HyperNearPos = this.NearPosArray[Index];
var ContentPos = HyperNearPos.NearPos.ContentPos;
var Depth = HyperNearPos.Depth;
if ( ContentPos.Data[Depth] >= Pos )
ContentPos.Data[Depth]++;
}
},
Remove_FromContent : function(Pos, Count, UpdatePosition)
......@@ -230,6 +280,20 @@ ParaHyperlink.prototype =
}
}
}
// Обновляем позиции в NearestPos
var NearPosLen = this.NearPosArray.length;
for ( var Index = 0; Index < NearPosLen; Index++ )
{
var HyperNearPos = this.NearPosArray[Index];
var ContentPos = HyperNearPos.NearPos.ContentPos;
var Depth = HyperNearPos.Depth;
if ( ContentPos.Data[Depth] > Pos + Count )
ContentPos.Data[Depth] -= Count;
else if ( ContentPos.Data[Depth] > Pos )
ContentPos.Data[Depth] = Math.max( 0 , Pos );
}
},
Add : function(Item)
......@@ -441,6 +505,71 @@ ParaHyperlink.prototype =
return CenterRunPos;
},
Check_NearestPos : function(ParaNearPos, Depth)
{
var HyperNearPos = new CParagraphElementNearPos();
HyperNearPos.NearPos = ParaNearPos.NearPos;
HyperNearPos.Depth = Depth;
this.NearPosArray.push( HyperNearPos );
ParaNearPos.Classes.push( this );
var CurPos = ParaNearPos.NearPos.ContentPos.Get(Depth);
this.Content[CurPos].Check_NearestPos( ParaNearPos, Depth + 1 );
},
Get_DrawingObjectRun : function(Id)
{
var Run = null;
var ContentLen = this.Content.length;
for ( var CurPos = 0; CurPos < ContentLen; CurPos++ )
{
var Element = this.Content[CurPos];
Run = Element.Get_DrawingObjectRun( Id );
if ( null !== Run )
return Run;
}
return Run;
},
Get_DrawingObjectContentPos : function(Id, ContentPos, Depth)
{
var ContentLen = this.Content.length;
for ( var Index = 0; Index < ContentLen; Index++ )
{
var Element = this.Content[Index];
if ( true === Element.Get_DrawingObjectContentPos(Id, ContentPos, Depth + 1) )
{
ContentPos.Update2( Index, Depth );
return true;
}
}
return false;
},
Get_Layout : function(DrawingLayout, UseContentPos, ContentPos, Depth)
{
var CurLine = DrawingLayout.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? DrawingLayout.Range - this.StartRange : DrawingLayout.Range );
var StartPos = this.Lines[CurLine].Ranges[CurRange].StartPos;
var EndPos = this.Lines[CurLine].Ranges[CurRange].EndPos;
var CurContentPos = ( true === UseContentPos ? ContentPos.Get(Depth) : -1 );
for ( var CurPos = StartPos; CurPos < EndPos; CurPos++ )
{
this.Content[CurPos].Get_Layout(DrawingLayout, ( CurPos === CurContentPos ? true : false ), ContentPos, Depth + 1 );
if ( null !== DrawingLayout.Layout )
return;
}
},
//-----------------------------------------------------------------------------------
// Функции пересчета
//-----------------------------------------------------------------------------------
......@@ -1281,17 +1410,6 @@ ParaHyperlink.prototype =
this.Value = Value;
},
Copy : function()
{
var Hyperlink_new = new ParaHyperlinkStart();
Hyperlink_new.Value = this.Value;
Hyperlink_new.Visited = this.Visited;
Hyperlink_new.ToolTip = this.ToolTip;
return Hyperlink_new;
},
//-----------------------------------------------------------------------------------
// Undo/Redo функции
//-----------------------------------------------------------------------------------
......
This diff is collapsed.
......@@ -4618,13 +4618,23 @@ ParaDrawing.prototype =
{
LogicDocument.Create_NewHistoryPoint();
var bCorrectIndex = this.Parent === NearPos.Paragraph ? true : false;
var Index = this.Remove_FromDocument( false );
if ( true !== Debug_ParaRunMode )
{
var bCorrectIndex = this.Parent === NearPos.Paragraph ? true : false;
var Index = this.Remove_FromDocument( false );
if ( true === bCorrectIndex && Index < NearPos.ContentPos )
NearPos.ContentPos--;
if ( true === bCorrectIndex && Index < NearPos.ContentPos )
NearPos.ContentPos--;
this.Add_ToDocument( NearPos, true );
}
else
{
NearPos.Paragraph.Check_NearestPos( NearPos );
this.Add_ToDocument( NearPos, true );
var RunPr = this.Remove_FromDocument( false );
this.Add_ToDocument( NearPos, true, RunPr );
}
}
else
{
......@@ -4682,6 +4692,8 @@ ParaDrawing.prototype =
// На всякий случай пересчитаем заново координату
this.Y = this.Internal_Position.Calculate_Y(false, this.PositionV.RelativeFrom, this.PositionV.Align, this.PositionV.Value);
NearPos.Paragraph.Check_NearestPos( NearPos );
this.Remove_FromDocument( false );
this.Add_ToDocument( NearPos, false );
}
......@@ -4701,27 +4713,81 @@ ParaDrawing.prototype =
Remove_FromDocument : function(bRecalculate)
{
var Res = this.Parent.Remove_DrawingObject( this.Id );
if ( true !== Debug_ParaRunMode )
{
var Res = this.Parent.Remove_DrawingObject( this.Id );
if ( false != bRecalculate )
editor.WordControl.m_oLogicDocument.Recalculate();
if ( false != bRecalculate )
editor.WordControl.m_oLogicDocument.Recalculate();
return Res;
return Res;
}
else
{
var Result = null;
var Run = this.Parent.Get_DrawingObjectRun( this.Id );
if ( null !== Run )
{
Run.Remove_DrawingObject( this.Id );
Result = Run.Get_TextPr();
}
if ( false != bRecalculate )
editor.WordControl.m_oLogicDocument.Recalculate();
return Result;
}
},
Add_ToDocument : function(NearPos, bRecalculate)
Add_ToDocument : function(NearPos, bRecalculate, RunPr)
{
this.Parent = NearPos.Paragraph;
NearPos.Paragraph.Internal_Content_Add( Math.min( NearPos.ContentPos, NearPos.Paragraph.Content.length - 2 ), this );
if ( true !== Debug_ParaRunMode )
{
this.Parent = NearPos.Paragraph;
NearPos.Paragraph.Internal_Content_Add( Math.min( NearPos.ContentPos, NearPos.Paragraph.Content.length - 2 ), this );
if ( false != bRecalculate )
editor.WordControl.m_oLogicDocument.Recalculate();
if ( false != bRecalculate )
editor.WordControl.m_oLogicDocument.Recalculate();
}
else
{
var LogicDocument = this.DrawingDocument.m_oLogicDocument;
var Para = new Paragraph(this.DrawingDocument, LogicDocument);
var DrawingRun = new ParaRun( Para );
DrawingRun.Add_ToContent( 0, this );
if ( undefined !== RunPr )
DrawingRun.Set_Pr( RunPr.Copy() );
Para.Add_ToContent( 0, DrawingRun );
var SelectedElement = new CSelectedElement(Para, false)
var SelectedContent = new CSelectedContent();
SelectedContent.Add( SelectedElement );
NearPos.Paragraph.Parent.Insert_Content( SelectedContent, NearPos );
if ( false != bRecalculate )
LogicDocument.Recalculate();
}
},
Add_ToDocument2 : function(Paragraph)
{
this.Parent = Paragraph;
Paragraph.Internal_Content_Add( Paragraph.Internal_GetStartPos(), this );
if ( true !== Debug_ParaRunMode )
{
this.Parent = Paragraph;
Paragraph.Internal_Content_Add( Paragraph.Internal_GetStartPos(), this );
}
else
{
var DrawingRun = new ParaRun( Paragraph );
DrawingRun.Add_ToContent( 0, this );
Paragraph.Add_ToContent( 0, DrawingRun );
}
},
Update_CursorType : function(X, Y, PageIndex)
......
This diff is collapsed.
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