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

git-svn-id:...

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52382 954022d7-b5bf-4e40-9824-e11837661b57
parent cd6d5e65
...@@ -7276,8 +7276,6 @@ CDocument.prototype = ...@@ -7276,8 +7276,6 @@ CDocument.prototype =
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 );
for ( var Index = Start; Index <= End; Index++ ) for ( var Index = Start; Index <= End; Index++ )
{ {
var Item = this.Content[Index]; var Item = this.Content[Index];
...@@ -7294,6 +7292,8 @@ CDocument.prototype = ...@@ -7294,6 +7292,8 @@ CDocument.prototype =
Item.Selection.EndPos = Item.Content.length - 1; Item.Selection.EndPos = Item.Content.length - 1;
else else
Item.Selection.StartPos = Item.Content.length - 1; Item.Selection.StartPos = Item.Content.length - 1;
Item.Selection_Internal_Update();
} }
else //if ( type_Table === ItemType ) else //if ( type_Table === ItemType )
{ {
...@@ -7319,6 +7319,8 @@ CDocument.prototype = ...@@ -7319,6 +7319,8 @@ CDocument.prototype =
Item.Selection.StartPos = Item.Internal_GetStartPos(); Item.Selection.StartPos = Item.Internal_GetStartPos();
else else
Item.Selection.EndPos = Item.Internal_GetStartPos(); Item.Selection.EndPos = Item.Internal_GetStartPos();
Item.Selection_Internal_Update();
} }
else //if ( type_Table === ItemType ) else //if ( type_Table === ItemType )
{ {
...@@ -7348,6 +7350,8 @@ CDocument.prototype = ...@@ -7348,6 +7350,8 @@ CDocument.prototype =
Item.Selection.EndPos = Item.Internal_GetStartPos(); Item.Selection.EndPos = Item.Internal_GetStartPos();
Item.Selection.StartPos = Item.Content.length - 1; Item.Selection.StartPos = Item.Content.length - 1;
} }
Item.Selection_Internal_Update();
} }
else //if ( type_Table === ItemType ) else //if ( type_Table === ItemType )
{ {
...@@ -7374,6 +7378,8 @@ CDocument.prototype = ...@@ -7374,6 +7378,8 @@ CDocument.prototype =
} }
} }
this.Content[ContentPos].Selection_SetEnd( X, Y, this.CurPage, MouseEvent );
// Проверяем, чтобы у нас в селект не попали элементы, в которых не выделено ничего // Проверяем, чтобы у нас в селект не попали элементы, в которых не выделено ничего
if ( true === this.Content[End].Selection_IsEmpty() ) if ( true === this.Content[End].Selection_IsEmpty() )
{ {
......
...@@ -77,15 +77,7 @@ function Paragraph(DrawingDocument, Parent, PageNum, X, Y, XLimit, YLimit) ...@@ -77,15 +77,7 @@ function Paragraph(DrawingDocument, Parent, PageNum, X, Y, XLimit, YLimit)
PagesPos : 0 // позиция в массиве this.Pages PagesPos : 0 // позиция в массиве this.Pages
}; };
this.Selection = this.Selection = new CParagraphSelection();
{
Start : false,
Use : false,
StartPos : 0,
EndPos : 0,
Flag : selectionflag_Common
};
this.NeedReDraw = true; this.NeedReDraw = true;
this.DrawingDocument = DrawingDocument; this.DrawingDocument = DrawingDocument;
...@@ -860,22 +852,41 @@ Paragraph.prototype = ...@@ -860,22 +852,41 @@ Paragraph.prototype =
Item.Measure( g_oTextMeasurer, FirstTextPr ); Item.Measure( g_oTextMeasurer, FirstTextPr );
} }
var PrevMathPos = -1;
for ( var Pos = 0; Pos < ContentLength; Pos++ ) for ( var Pos = 0; Pos < ContentLength; Pos++ )
{ {
var Item = this.Content[Pos]; var Item = this.Content[Pos];
switch( Item.Type ) switch( Item.Type )
{ {
case para_Math:
case para_Text: case para_Text:
case para_Space: case para_Space:
case para_PageNum: case para_PageNum:
{ {
PrevMathPos = -1;
Item.Measure( g_oTextMeasurer, CurTextPr); Item.Measure( g_oTextMeasurer, CurTextPr);
break; break;
} }
case para_Math:
{
if ( -1 != PrevMathPos )
{
// TODO: нужно реализовать объединение формул
}
Item.Measure( g_oTextMeasurer, CurTextPr);
PrevMathPos = Pos;
// Проверим, является ли данная формула внутристроковой или нет
var Prev = this.Internal_FindBackward( Pos - 1, [para_Text, para_Space] );
break;
}
case para_Drawing: case para_Drawing:
{ {
PrevMathPos = -1;
Item.Parent = this; Item.Parent = this;
Item.DocumentContent = this.Parent; Item.DocumentContent = this.Parent;
Item.DrawingDocument = this.Parent.DrawingDocument; Item.DrawingDocument = this.Parent.DrawingDocument;
...@@ -886,6 +897,7 @@ Paragraph.prototype = ...@@ -886,6 +897,7 @@ Paragraph.prototype =
case para_Tab: case para_Tab:
case para_NewLine: case para_NewLine:
{ {
PrevMathPos = -1;
Item.Measure( g_oTextMeasurer); Item.Measure( g_oTextMeasurer);
break; break;
...@@ -7694,8 +7706,9 @@ Paragraph.prototype = ...@@ -7694,8 +7706,9 @@ Paragraph.prototype =
var StartPos = this.Lines[CurLine].StartPos; var StartPos = this.Lines[CurLine].StartPos;
var ResultLine = -1; var ResultLine = -1;
var Pos2 = StartPos;
for ( var ItemNum = StartPos; ItemNum < this.Content.length; ItemNum++ ) var ItemNum = StartPos;
for ( ; ItemNum < this.Content.length; ItemNum++ )
{ {
var Item = this.Content[ItemNum]; var Item = this.Content[ItemNum];
...@@ -7849,7 +7862,10 @@ Paragraph.prototype = ...@@ -7849,7 +7862,10 @@ Paragraph.prototype =
} }
if ( X >= CurX - 0.001 && X <= CurX + TempDx + 0.001 ) if ( X >= CurX - 0.001 && X <= CurX + TempDx + 0.001 )
{
bInText = true; bInText = true;
Pos2 = ItemNum;
}
CurX += TempDx; CurX += TempDx;
} }
...@@ -7858,14 +7874,18 @@ Paragraph.prototype = ...@@ -7858,14 +7874,18 @@ Paragraph.prototype =
if ( true === bInText && Y >= this.Pages[PNum].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent - 0.01 && Y <= this.Pages[PNum].Y + this.Lines[CurLine].Y + this.Lines[CurLine].Metrics.Descent + this.Lines[CurLine].Metrics.LineGap + 0.01 ) if ( true === bInText && Y >= this.Pages[PNum].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent - 0.01 && Y <= this.Pages[PNum].Y + this.Lines[CurLine].Y + this.Lines[CurLine].Metrics.Descent + this.Lines[CurLine].Metrics.LineGap + 0.01 )
Result.InText = true; Result.InText = true;
else else
{
Result.InText = false; Result.InText = false;
Pos2 = ItemNum - 1;
}
if ( NumberingDiffX <= DiffX ) if ( NumberingDiffX <= DiffX )
Result.Numbering = true; Result.Numbering = true;
else else
Result.Numbering = false; Result.Numbering = false;
Result.Pos = DiffPos; Result.Pos = DiffPos; // Позиция ближайшего элемента (по его начальной точке)
Result.Pos2 = Pos2; // Позиция элемента в который мы попали точно
Result.Line = ResultLine; Result.Line = ResultLine;
return Result; return Result;
...@@ -8300,9 +8320,13 @@ Paragraph.prototype = ...@@ -8300,9 +8320,13 @@ Paragraph.prototype =
if ( -1 != Pos.Pos ) if ( -1 != Pos.Pos )
{ {
if ( true === Pos.End ) if ( true === Pos.End )
this.Selection.StartPos = Pos.Pos + 1; this.Selection.Set_StartPos( Pos.Pos + 1, Pos.Pos2 );
else else
this.Selection.StartPos = Pos.Pos; this.Selection.Set_StartPos( Pos.Pos, Pos.Pos2 );
// Если мы начинаем с математического элемента, тогда у него выставляем начало селекта
if ( undefined !== this.Content[Pos.Pos2] && para_Math === this.Content[Pos.Pos2].Type )
this.Content[Pos.Pos2].Selection_SetStart(X, Y, PageNum);
this.Set_ContentPos( Pos.Pos, true , Pos.Line ); this.Set_ContentPos( Pos.Pos, true , Pos.Line );
...@@ -8346,12 +8370,28 @@ Paragraph.prototype = ...@@ -8346,12 +8370,28 @@ Paragraph.prototype =
} }
} }
this.Selection.EndPos = Pos + 1; this.Selection.Set_EndPos(Pos + 1, Temp.Pos2);
} }
else else
this.Selection.EndPos = Pos; this.Selection.Set_EndPos(Pos, Temp.Pos2);
// Если мы заканчиваем на математическом элементе, тогда у него выставляем конец селекта
if ( undefined !== this.Content[Temp.Pos2] && para_Math === this.Content[Temp.Pos2].Type )
{
// Если у нас совпали начальная и конечная позиции, тогда не нужно указывать начало селекта, т.к. оно
// было определено в Selection_SetStart
if ( this.Selection.StartPos2 != this.Selection.EndPos2 )
{
if ( this.Selection.StartPos2 < this.Selection.EndPos2 )
this.Content[Temp.Pos2].Selection_Beginning();
else
this.Content[Temp.Pos2].Selection_Ending();
}
this.Content[Temp.Pos2].Selection_SetEnd(X, Y, PageNum, MouseEvent);
}
if ( this.Selection.EndPos == this.Selection.StartPos && g_mouse_event_type_up === MouseEvent.Type ) if ( this.Selection.EndPos == this.Selection.StartPos && g_mouse_event_type_up === MouseEvent.Type && ( this.Selection.EndPos2 != this.Selection.StartPos2 || undefined === this.Content[this.Selection.StartPos2] || para_Math !== this.Content[this.Selection.StartPos2].Type ) )
{ {
var NumPr = this.Numbering_Get(); var NumPr = this.Numbering_Get();
if ( true === Temp.Numbering && undefined != NumPr ) if ( true === Temp.Numbering && undefined != NumPr )
...@@ -8444,6 +8484,11 @@ Paragraph.prototype = ...@@ -8444,6 +8484,11 @@ Paragraph.prototype =
} }
}, },
Selection_Internal_Update : function()
{
},
Selection_Stop : function(X,Y,PageNum, MouseEvent) Selection_Stop : function(X,Y,PageNum, MouseEvent)
{ {
this.Selection.Start = false; this.Selection.Start = false;
...@@ -8498,7 +8543,6 @@ Paragraph.prototype = ...@@ -8498,7 +8543,6 @@ Paragraph.prototype =
EndPos = Math.min( EndPos, ( _EndLine != this.Lines.length - 1 ? this.Lines[_EndLine].EndPos + 1 : this.Content.length - 1 ) ); EndPos = Math.min( EndPos, ( _EndLine != this.Lines.length - 1 ? this.Lines[_EndLine].EndPos + 1 : this.Content.length - 1 ) );
} }
// Найдем линию, с которой начинается селект // Найдем линию, с которой начинается селект
var StartParaPos = this.Internal_Get_ParaPos_By_Pos( StartPos ); var StartParaPos = this.Internal_Get_ParaPos_By_Pos( StartPos );
var CurLine = StartParaPos.Line; var CurLine = StartParaPos.Line;
...@@ -8533,6 +8577,31 @@ Paragraph.prototype = ...@@ -8533,6 +8577,31 @@ Paragraph.prototype =
var W = 0; var W = 0;
// Отдельная отрисовка селекта для формул (используется только, если селект начинается с формулы
// или заканчивается формулой, во всех остальных случаях )
if ( undefined != this.Content[this.Selection.StartPos2] && para_Math === this.Content[this.Selection.StartPos2].Type )
{
this.Content[this.Selection.StartPos2].Selection_Draw();
if ( this.Selection.StartPos2 === StartPos )
StartPos++;
else if( this.Selection.StartPos2 === EndPos )
EndPos--;
}
if ( undefined != this.Content[this.Selection.EndPos2] && para_Math === this.Content[this.Selection.EndPos2].Type && this.Selection.EndPos2 !== this.Selection.StartPos2 )
{
this.Content[this.Selection.EndPos2].Selection_Draw();
if ( this.Selection.EndPos2 === StartPos )
StartPos++;
else if( this.Selection.EndPos2 === EndPos )
EndPos--;
}
// Рисуем остальной селект
for ( Pos = StartPos; Pos < EndPos; Pos++ ) for ( Pos = StartPos; Pos < EndPos; Pos++ )
{ {
Item = this.Content[Pos]; Item = this.Content[Pos];
...@@ -9572,9 +9641,9 @@ Paragraph.prototype = ...@@ -9572,9 +9641,9 @@ Paragraph.prototype =
End = this.Selection.StartPos; End = this.Selection.StartPos;
} }
if ( true === this.Internal_FindForward( End, [para_PageNum, para_Drawing, para_Tab, para_Text, para_Space, para_NewLine, para_End]).Found ) if ( true === this.Internal_FindForward( End, [para_PageNum, para_Drawing, para_Tab, para_Text, para_Space, para_NewLine, para_End, para_Math]).Found )
_ApplyPara = false; _ApplyPara = false;
else if ( true === this.Internal_FindBackward( Start - 1, [para_PageNum, para_Drawing, para_Tab, para_Text, para_Space, para_NewLine, para_End]).Found ) else if ( true === this.Internal_FindBackward( Start - 1, [para_PageNum, para_Drawing, para_Tab, para_Text, para_Space, para_NewLine, para_End, para_Math]).Found )
_ApplyPara = false; _ApplyPara = false;
} }
else else
...@@ -9729,7 +9798,7 @@ Paragraph.prototype = ...@@ -9729,7 +9798,7 @@ Paragraph.prototype =
if ( undefined === ContentPos ) if ( undefined === ContentPos )
ContentPos = this.CurPos.ContentPos; ContentPos = this.CurPos.ContentPos;
var oPos = this.Internal_FindForward( ContentPos, [para_PageNum, para_Drawing, para_Tab, para_Text, para_Space, para_NewLine] ); var oPos = this.Internal_FindForward( ContentPos, [para_PageNum, para_Drawing, para_Tab, para_Text, para_Space, para_NewLine, para_Math] );
if ( true === oPos.Found ) if ( true === oPos.Found )
return false; return false;
...@@ -9743,7 +9812,7 @@ Paragraph.prototype = ...@@ -9743,7 +9812,7 @@ Paragraph.prototype =
if ( undefined === ContentPos ) if ( undefined === ContentPos )
ContentPos = this.CurPos.ContentPos; ContentPos = this.CurPos.ContentPos;
var oPos = this.Internal_FindBackward( ContentPos - 1, [para_PageNum, para_Drawing, para_Tab, para_Text, para_Space, para_NewLine] ); var oPos = this.Internal_FindBackward( ContentPos - 1, [para_PageNum, para_Drawing, para_Tab, para_Text, para_Space, para_NewLine, para_Math] );
if ( true === oPos.Found ) if ( true === oPos.Found )
return false; return false;
else else
...@@ -14456,7 +14525,6 @@ CParaLine.prototype = ...@@ -14456,7 +14525,6 @@ CParaLine.prototype =
this.StartPos = StartPos; this.StartPos = StartPos;
}, },
Set_EndPos : function(EndPos, Paragraph) Set_EndPos : function(EndPos, Paragraph)
{ {
this.EndPos = EndPos; this.EndPos = EndPos;
...@@ -14492,6 +14560,7 @@ CParaLine.prototype = ...@@ -14492,6 +14560,7 @@ CParaLine.prototype =
switch( Item.Type ) switch( Item.Type )
{ {
case para_Math:
case para_Text: case para_Text:
{ {
if ( true != bWord ) if ( true != bWord )
...@@ -14812,3 +14881,29 @@ CParaDrawingRangeLines.prototype = ...@@ -14812,3 +14881,29 @@ CParaDrawingRangeLines.prototype =
} }
}; };
function CParagraphSelection()
{
this.Start = false;
this.Use = false;
this.StartPos = 0;
this.EndPos = 0;
this.StartPos2 = 0;
this.EndPos2 = 0,
this.Flag = selectionflag_Common;
}
CParagraphSelection.prototype =
{
Set_StartPos : function(Pos1, Pos2)
{
this.StartPos = Pos1;
this.StartPos2 = ( undefined != Pos2 ? Pos2 : Pos1 );
},
Set_EndPos : function(Pos1, Pos2)
{
this.EndPos = Pos1;
this.EndPos2 = ( undefined != Pos2 ? Pos2 : Pos1 );
}
};
...@@ -7491,8 +7491,11 @@ function ParaMath() ...@@ -7491,8 +7491,11 @@ function ParaMath()
this.Type = para_Math; this.Type = para_Math;
this.Jc = undefined;
this.Math = new CMathComposition(); this.Math = new CMathComposition();
this.Inline = false; // внутристроковая формула или нет (проверяемся внутри Internal_Recalculate_0)
this.Width = 0; this.Width = 0;
this.Height = 0; this.Height = 0;
this.WidthVisible = 0; this.WidthVisible = 0;
...@@ -7549,6 +7552,34 @@ ParaMath.prototype = ...@@ -7549,6 +7552,34 @@ ParaMath.prototype =
return true; return true;
}, },
Selection_SetStart : function(X, Y, PageNum)
{
this.Math.Selection_SetStart( X, Y, PageNum );
console.log( "Start x=" + X +" y=" + Y );
},
Selection_SetEnd : function(X, Y, PageNum, MouseEvent)
{
this.Math.Selection_SetEnd( X, Y, PageNum, MouseEvent );
console.log( "End x=" + X +" y=" + Y );
},
Selection_Beginning : function()
{
this.Math.Selection_Beginning();
},
Selection_Ending : function()
{
this.Math.Selection_Ending();
},
Selection_Draw : function()
{
this.Math.Selection_Draw();
console.log( "Selection draw" );
},
Copy : function() Copy : function()
{ {
var Math = new ParaMath(); var Math = new ParaMath();
......
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