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

Сделано, чтобы при выделении параграфа целиком выделялись и плавающие объекты...

Сделано, чтобы при выделении параграфа целиком выделялись и плавающие объекты привязанные к параграфу (баг 22830).

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55068 954022d7-b5bf-4e40-9824-e11837661b57
parent d182791d
...@@ -1207,6 +1207,16 @@ ParaComment.prototype = ...@@ -1207,6 +1207,16 @@ ParaComment.prototype =
{ {
return false; return false;
}, },
Is_SelectedAll : function(Props)
{
return true;
},
Selection_CorrectLeftPos : function(Direction)
{
return true;
},
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования // Функции совместного редактирования
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
......
...@@ -1539,6 +1539,70 @@ ParaHyperlink.prototype = ...@@ -1539,6 +1539,70 @@ ParaHyperlink.prototype =
return false; return false;
}, },
Is_SelectedAll : function(Props)
{
var Selection = this.State.Selection;
if ( false === Selection.Use && true !== this.Is_Empty( Props ) )
return false;
var StartPos = Selection.StartPos;
var EndPos = Selection.EndPos;
if ( EndPos < StartPos )
{
StartPos = Selection.EndPos;
EndPos = Selection.StartPos;
}
for ( var Pos = 0; Pos <= StartPos; Pos++ )
{
if ( false === this.Content[Pos].Is_SelectedAll( Props ) )
return false;
}
var Count = this.Content.length;
for ( var Pos = EndPos; Pos < Count; Pos++ )
{
if ( false === this.Content[Pos].Is_SelectedAll( Props ) )
return false;
}
return true;
},
Selection_CorrectLeftPos : function(Direction)
{
if ( false === this.Selection.Use || true === this.Is_Empty( { SkipAnchor : true } ) )
return true;
var Selection = this.State.Selection;
var StartPos = Math.min( Selection.StartPos, Selection.EndPos );
var EndPos = Math.max( Selection.StartPos, Selection.EndPos );
for ( var Pos = 0; Pos < StartPos; Pos++ )
{
if ( true !== this.Content[Pos].Is_Empty( { SkipAnchor : true } ) )
return false;
}
for ( var Pos = StartPos; Pos <= EndPos; Pos++ )
{
if ( true === this.Content[Pos].Selection_CorrectLeftPos(Direction) )
{
if ( 1 === Direction )
this.Selection.StartPos = Pos + 1;
else
this.Selection.EndPos = Pos + 1;
this.Content[Pos].Selection_Remove();
}
else
return false;
}
return true;
},
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// Работаем со значениями // Работаем со значениями
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
......
...@@ -913,6 +913,17 @@ ParaMath.prototype = ...@@ -913,6 +913,17 @@ ParaMath.prototype =
{ {
return false; return false;
}, },
Is_SelectedAll : function(Props)
{
// TODO: ParaMath.Is_SelectedAll
return false;
},
Selection_CorrectLeftPos : function(Direction)
{
return false;
},
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования // Функции совместного редактирования
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
......
...@@ -9394,6 +9394,10 @@ Paragraph.prototype = ...@@ -9394,6 +9394,10 @@ Paragraph.prototype =
{ {
var Depth = 0; var Depth = 0;
var Direction = 1;
if ( StartContentPos.Compare( EndContentPos ) > 0 )
Direction = -1;
var OldStartPos = Math.min( this.Selection.StartPos, this.Content.length - 1 ); var OldStartPos = Math.min( this.Selection.StartPos, this.Content.length - 1 );
var OldEndPos = Math.min( this.Selection.EndPos, this.Content.length - 1 ); var OldEndPos = Math.min( this.Selection.EndPos, this.Content.length - 1 );
...@@ -9461,6 +9465,78 @@ Paragraph.prototype = ...@@ -9461,6 +9465,78 @@ Paragraph.prototype =
// if ( para_Hyperlink === this.Content[EndPos].Type && true !== this.Content[EndPos].Selection_IsEmpty(true) ) // if ( para_Hyperlink === this.Content[EndPos].Type && true !== this.Content[EndPos].Selection_IsEmpty(true) )
// this.Content[EndPos].Select_All( StartPos > EndPos ? -1 : 1 ); // this.Content[EndPos].Select_All( StartPos > EndPos ? -1 : 1 );
} }
// Дополнительная проверка. Если у нас визуально выделен весь параграф (т.е. весь текст и знак параграфа
// обязательно!), тогда выделяем весь параграф целиком, чтобы в селект попадали и все привязанные объекты.
// Но если у нас выделен параграф не целиком, тогда мы снимаем выделение с привязанных объектов, стоящих в
// начале параграфа.
if ( true === this.Selection_CheckParaEnd() )
{
// Эта ветка нужна для выделения плавающих объектов, стоящих в начале параграфа, когда параграф выделен весь
var bNeedSelectAll = true;
var StartPos = Math.min( this.Selection.StartPos, this.Selection.EndPos );
for ( var Pos = 0; Pos <= StartPos; Pos++ )
{
if ( false === this.Content[Pos].Is_SelectedAll( { SkipAnchor : true } ) )
{
bNeedSelectAll = false;
break;
}
}
if ( true === bNeedSelectAll )
{
if ( 1 === Direction )
this.Selection.StartPos = 0;
else
this.Selection.EndPos = 0;
for ( var Pos = 0; Pos <= StartPos; Pos++ )
{
this.Content[Pos].Select_All( Direction );
}
}
}
else if ( true !== this.Selection_IsEmpty(true) )
{
// Эта ветка нужна для снятие выделения с плавающих объектов, стоящих в начале параграфа, когда параграф
// выделен не весь. Заметим, что это ветка имеет смысл, только при direction = 1, поэтому выделен весь
// параграф или нет, проверяется попаданием para_End в селект. Кроме того, ничего не делаем с селектом,
// если он пустой.
var bNeedCorrectLeftPos = true;
var _StartPos = Math.min( StartPos, EndPos );
var _EndPos = Math.max( StartPos, EndPos );
for ( var Pos = 0; Pos < StartPos; Pos++ )
{
if ( true !== this.Content[Pos].Is_Empty( { SkipAnchor : true } ) )
{
bNeedCorrectLeftPos = false;
break;
}
}
if ( true === bNeedCorrectLeftPos )
{
for ( var Pos = _StartPos; Pos <= EndPos; Pos++ )
{
if ( true === this.Content[Pos].Selection_CorrectLeftPos(Direction) )
{
if ( 1 === Direction )
this.Selection.StartPos = Pos + 1;
else
this.Selection.EndPos = Pos + 1;
this.Content[Pos].Selection_Remove();
}
else
break;
}
}
}
}, },
Get_ParaContentPosByXY : function(X, Y, PageNum, bYLine, StepEnd) Get_ParaContentPosByXY : function(X, Y, PageNum, bYLine, StepEnd)
...@@ -16315,7 +16391,7 @@ Paragraph.prototype = ...@@ -16315,7 +16391,7 @@ Paragraph.prototype =
var CurContentPos = ContentPos.Get(0); var CurContentPos = ContentPos.Get(0);
for ( var CurPos = StartPos; CurPos < EndPos; CurPos++ ) for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{ {
this.Content[CurPos].Get_Layout(DrawingLayout, ( CurPos === CurContentPos ? true : false ), ContentPos, 1); this.Content[CurPos].Get_Layout(DrawingLayout, ( CurPos === CurContentPos ? true : false ), ContentPos, 1);
......
...@@ -3502,6 +3502,77 @@ ParaRun.prototype = ...@@ -3502,6 +3502,77 @@ ParaRun.prototype =
return this.State.Selection.Use; return this.State.Selection.Use;
}, },
Is_SelectedAll : function(Props)
{
var Selection = this.State.Selection;
if ( false === Selection.Use && true !== this.Is_Empty( Props ) )
return false;
var SkipAnchor = Props.SkipAnchor;
var SkipEnd = Props.SkipEnd;
var StartPos = Selection.StartPos;
var EndPos = Selection.EndPos;
if ( EndPos < StartPos )
{
StartPos = Selection.EndPos;
EndPos = Selection.StartPos;
}
for ( var Pos = 0; Pos < StartPos; Pos++ )
{
var Item = this.Content[Pos];
if ( !( ( true === SkipAnchor && ( para_Drawing === Item.Type && true !== Item.Is_Inline() ) ) || ( true === SkipEnd && para_End === Item.Type ) ) )
return false;
}
var Count = this.Content.length;
for ( var Pos = EndPos; Pos < Count; Pos++ )
{
var Item = this.Content[Pos];
if ( !( ( true === SkipAnchor && ( para_Drawing === Item.Type && true !== Item.Is_Inline() ) ) || ( true === SkipEnd && para_End === Item.Type ) ) )
return false;
}
return true;
},
Selection_CorrectLeftPos : function(Direction)
{
if ( false === this.Selection.Use || true === this.Is_Empty( { SkipAnchor : true } ) )
return true;
var Selection = this.State.Selection;
var StartPos = Math.min( Selection.StartPos, Selection.EndPos );
var EndPos = Math.max( Selection.StartPos, Selection.EndPos );
for ( var Pos = 0; Pos < StartPos; Pos++ )
{
var Item = this.Content[Pos];
if ( para_Drawing !== Item.Type || true === Item.Is_Inline() )
return false;
}
for ( var Pos = StartPos; Pos < EndPos; Pos++ )
{
var Item = this.Content[Pos];
if ( para_Drawing === Item.Type && true !== Item.Is_Inline() )
{
if ( 1 === Direction )
Selection.StartPos = Pos + 1;
else
Selection.EndPos = Pos + 1;
}
else
return false;
}
return true;
},
Selection_Stop : function() Selection_Stop : function()
{ {
}, },
......
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