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

Переделана схема с переносом "плавающих" объектов (баг 21557).

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@51123 954022d7-b5bf-4e40-9824-e11837661b57
parent a5d34de1
...@@ -1632,8 +1632,6 @@ Paragraph.prototype = ...@@ -1632,8 +1632,6 @@ Paragraph.prototype =
} }
} }
this.Internal_Content_Add( StartPos, new ParaPageBreakRenderer() );
this.Pages[CurPage].Set_EndLine( -1 ); this.Pages[CurPage].Set_EndLine( -1 );
if ( 0 === CurLine ) if ( 0 === CurLine )
{ {
...@@ -1648,8 +1646,6 @@ Paragraph.prototype = ...@@ -1648,8 +1646,6 @@ Paragraph.prototype =
{ {
if ( CurLine != this.Pages[CurPage].FirstLine ) if ( CurLine != this.Pages[CurPage].FirstLine )
{ {
this.Internal_Content_Add( LineStart_Pos, new ParaPageBreakRenderer() );
this.Pages[CurPage].Set_EndLine( CurLine - 1 ); this.Pages[CurPage].Set_EndLine( CurLine - 1 );
if ( 0 === CurLine ) if ( 0 === CurLine )
{ {
...@@ -3200,7 +3196,7 @@ Paragraph.prototype = ...@@ -3200,7 +3196,7 @@ Paragraph.prototype =
if ( true === Item.Is_Inline() || true === this.Parent.Is_DrawingShape() ) if ( true === Item.Is_Inline() || true === this.Parent.Is_DrawingShape() )
{ {
Item.Update_Position( X, Y , this.Get_StartPage_Absolute() + CurPage, LastW, ColumnStartX, ColumnEndX, X_Left_Margin, X_Right_Margin, Page_Width, Top_Margin, Bottom_Margin, Page_H, PageFields.X, PageFields.Y, this.Pages[CurPage].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent, this.Pages[CurPage].Y, PageLimits ); Item.Update_Position( new CParagraphLayout(X, Y , this.Get_StartPage_Absolute() + CurPage, LastW, ColumnStartX, ColumnEndX, X_Left_Margin, X_Right_Margin, Page_Width, Top_Margin, Bottom_Margin, Page_H, PageFields.X, PageFields.Y, this.Pages[CurPage].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent, this.Pages[CurPage].Y), PageLimits );
Item.Reset_SavedPosition(); Item.Reset_SavedPosition();
bFirstLineItem = false; bFirstLineItem = false;
...@@ -3222,7 +3218,7 @@ Paragraph.prototype = ...@@ -3222,7 +3218,7 @@ Paragraph.prototype =
if ( true === LDRecalcInfo.Can_RecalcObject() ) if ( true === LDRecalcInfo.Can_RecalcObject() )
{ {
// Обновляем позицию объекта // Обновляем позицию объекта
Item.Update_Position( X, Y , this.Get_StartPage_Absolute() + CurPage, LastW, ColumnStartX, ColumnEndX, X_Left_Margin, X_Right_Margin, Page_Width, Top_Margin, Bottom_Margin, Page_H, PageFields.X, PageFields.Y, this.Pages[CurPage].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent, this.Pages[CurPage].Y, PageLimits); Item.Update_Position( new CParagraphLayout(X, Y , this.Get_StartPage_Absolute() + CurPage, LastW, ColumnStartX, ColumnEndX, X_Left_Margin, X_Right_Margin, Page_Width, Top_Margin, Bottom_Margin, Page_H, PageFields.X, PageFields.Y, this.Pages[CurPage].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent, this.Pages[CurPage].Y), PageLimits);
LDRecalcInfo.Set_FlowObject( Item, 0, recalcresult_NextElement ); LDRecalcInfo.Set_FlowObject( Item, 0, recalcresult_NextElement );
return recalcresult_CurPage; return recalcresult_CurPage;
} }
...@@ -3246,7 +3242,7 @@ Paragraph.prototype = ...@@ -3246,7 +3242,7 @@ Paragraph.prototype =
// мы не персчитываем заново текущую страницу, а не предыдущую // мы не персчитываем заново текущую страницу, а не предыдущую
// Обновляем позицию объекта // Обновляем позицию объекта
Item.Update_Position( X, Y , this.Get_StartPage_Absolute() + CurPage, LastW, ColumnStartX, ColumnEndX, X_Left_Margin, X_Right_Margin, Page_Width, Top_Margin, Bottom_Margin, Page_H, PageFields.X, PageFields.Y, this.Pages[CurPage].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent, this.Pages[CurPage].Y, PageLimits); Item.Update_Position( new CParagraphLayout(X, Y , this.Get_StartPage_Absolute() + CurPage, LastW, ColumnStartX, ColumnEndX, X_Left_Margin, X_Right_Margin, Page_Width, Top_Margin, Bottom_Margin, Page_H, PageFields.X, PageFields.Y, this.Pages[CurPage].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent, this.Pages[CurPage].Y), PageLimits);
LDRecalcInfo.Set_FlowObject( Item, 0, recalcresult_NextElement ); LDRecalcInfo.Set_FlowObject( Item, 0, recalcresult_NextElement );
LDRecalcInfo.Set_PageBreakBefore( false ); LDRecalcInfo.Set_PageBreakBefore( false );
...@@ -3269,7 +3265,7 @@ Paragraph.prototype = ...@@ -3269,7 +3265,7 @@ Paragraph.prototype =
else else
{ {
// Картинка ложится на или под текст, в данном случае пересчет можно спокойно продолжать // Картинка ложится на или под текст, в данном случае пересчет можно спокойно продолжать
Item.Update_Position( X, Y , this.Get_StartPage_Absolute() + CurPage, LastW, ColumnStartX, ColumnEndX, X_Left_Margin, X_Right_Margin, Page_Width, Top_Margin, Bottom_Margin, Page_H, PageFields.X, PageFields.Y, this.Pages[CurPage].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent, this.Pages[CurPage].Y, PageLimits); Item.Update_Position( new CParagraphLayout(X, Y , this.Get_StartPage_Absolute() + CurPage, LastW, ColumnStartX, ColumnEndX, X_Left_Margin, X_Right_Margin, Page_Width, Top_Margin, Bottom_Margin, Page_H, PageFields.X, PageFields.Y, this.Pages[CurPage].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent, this.Pages[CurPage].Y), PageLimits);
Item.Reset_SavedPosition(); Item.Reset_SavedPosition();
continue; continue;
} }
...@@ -10018,6 +10014,89 @@ Paragraph.prototype = ...@@ -10018,6 +10014,89 @@ Paragraph.prototype =
return Result; return Result;
}, },
Get_Layout : function(ContentPos, Drawing)
{
var LinePos = this.Internal_Get_ParaPos_By_Pos( ContentPos );
var CurLine = LinePos.Line;
var CurRange = LinePos.Range;
var CurPage = LinePos.Page;
var X = this.Lines[CurLine].Ranges[CurRange].XVisible;
var Y = this.Pages[CurPage].Y + this.Lines[CurLine].Y;
var StartPos = this.Lines[CurLine].Ranges[CurRange].StartPos;
if ( StartPos < this.Numbering.Pos )
X += this.Numbering.WidthVisible;
var LastW = 0;
for ( var ItemNum = StartPos; ItemNum < this.Content.length; ItemNum++ )
{
var Item = this.Content[ItemNum];
if ( ItemNum === ContentPos )
{
var DrawingObjects = this.Parent.DrawingObjects;
var PageLimits = this.Parent.Get_PageLimits(this.PageNum + CurPage);
var PageFields = this.Parent.Get_PageFields(this.PageNum + CurPage);
var ColumnStartX = (0 === CurPage ? this.X_ColumnStart : this.Pages[CurPage].X);
var ColumnEndX = (0 === CurPage ? this.X_ColumnEnd : this.Pages[CurPage].XLimit);
var Top_Margin = Y_Top_Margin;
var Bottom_Margin = Y_Bottom_Margin;
var Page_H = Page_Height;
if ( true === this.Parent.Is_TableCellContent() && undefined != Drawing && true == Drawing.Use_TextWrap() )
{
Top_Margin = 0;
Bottom_Margin = 0;
Page_H = 0;
}
if ( undefined != Drawing && true != Drawing.Use_TextWrap() )
{
PageFields.X = X_Left_Field;
PageFields.Y = Y_Top_Field;
PageFields.XLimit = X_Right_Field;
PageFields.YLimit = Y_Bottom_Field;
PageLimits.X = 0;
PageLimits.Y = 0;
PageLimits.XLimit = Page_Width;
PageLimits.YLimit = Page_Height;
}
return { ParagraphLayout : new CParagraphLayout( X, Y , this.Get_StartPage_Absolute() + CurPage, LastW, ColumnStartX, ColumnEndX, X_Left_Margin, X_Right_Margin, Page_Width, Top_Margin, Bottom_Margin, Page_H, PageFields.X, PageFields.Y, this.Pages[CurPage].Y + this.Lines[CurLine].Y - this.Lines[CurLine].Metrics.Ascent, this.Pages[CurPage].Y ), PageLimits : PageLimits };
}
switch ( Item.Type )
{
case para_Text:
case para_Space:
case para_PageNum:
{
LastW = Item.WidthVisible;
break;
}
case para_Drawing:
{
if ( true === Item.Is_Inline() || true === this.Parent.Is_DrawingShape() )
{
LastW = Item.WidthVisible;
}
break;
}
}
X += Item.WidthVisible;
}
return undefined;
},
Get_AnchorPos : function(Drawing) Get_AnchorPos : function(Drawing)
{ {
// Ищем, где находится наш объект // Ищем, где находится наш объект
......
...@@ -2626,6 +2626,26 @@ ParaTab.prototype = ...@@ -2626,6 +2626,26 @@ ParaTab.prototype =
var drawing_Inline = 0x01; var drawing_Inline = 0x01;
var drawing_Anchor = 0x02; var drawing_Anchor = 0x02;
function CParagraphLayout(X, Y, PageNum, LastItemW, ColumnStartX, ColumnEndX, Left_Margin, Right_Margin, Page_W, Top_Margin, Bottom_Margin, Page_H, MarginH, MarginV, LineTop, ParagraphTop)
{
this.X = X;
this.Y = Y;
this.PageNum = PageNum;
this.LastItemW = LastItemW;
this.ColumnStartX = ColumnStartX;
this.ColumnEndX = ColumnEndX;
this.Left_Margin = Left_Margin;
this.Right_Margin = Right_Margin;
this.Page_W = Page_W;
this.Top_Margin = Top_Margin;
this.Bottom_Margin = Bottom_Margin;
this.Page_H = Page_H;
this.Margin_H = MarginH;
this.Margin_V = MarginV;
this.LineTop = LineTop;
this.ParagraphTop = ParagraphTop;
}
function CAnchorPosition() function CAnchorPosition()
{ {
// Рассчитанные координаты // Рассчитанные координаты
...@@ -2658,29 +2678,29 @@ function CAnchorPosition() ...@@ -2658,29 +2678,29 @@ function CAnchorPosition()
CAnchorPosition.prototype = CAnchorPosition.prototype =
{ {
Set : function(W, H, YOffset, X, Y, PageNum, LastItemW, ColumnStartX, ColumnEndX, Left_Margin, Right_Margin, Page_W, Top_Margin, Bottom_Margin, Page_H, MarginH, MarginV, LineTop, ParagraphTop) Set : function(W, H, YOffset, ParaLayout)
{ {
this.W = W; this.W = W;
this.H = H; this.H = H;
this.YOffset = YOffset; this.YOffset = YOffset;
this.X = X; this.X = ParaLayout.X;
this.Y = Y; this.Y = ParaLayout.Y;
this.PageNum = PageNum; this.PageNum = ParaLayout.PageNum;
this.LastItemW = LastItemW; this.LastItemW = ParaLayout.LastItemW;
this.ColumnStartX = ColumnStartX; this.ColumnStartX = ParaLayout.ColumnStartX;
this.ColumnEndX = ColumnEndX; this.ColumnEndX = ParaLayout.ColumnEndX;
this.Left_Margin = Left_Margin; this.Left_Margin = ParaLayout.Left_Margin;
this.Right_Margin = Right_Margin; this.Right_Margin = ParaLayout.Right_Margin;
this.Page_W = Page_W; this.Page_W = ParaLayout.Page_W;
this.Top_Margin = Top_Margin; this.Top_Margin = ParaLayout.Top_Margin;
this.Bottom_Margin = Bottom_Margin; this.Bottom_Margin = ParaLayout.Bottom_Margin;
this.Page_H = Page_H; this.Page_H = ParaLayout.Page_H;
this.Margin_H = MarginH; this.Margin_H = ParaLayout.Margin_H;
this.Margin_V = MarginV; this.Margin_V = ParaLayout.Margin_V;
this.LineTop = LineTop; this.LineTop = ParaLayout.LineTop;
this.ParagraphTop = ParagraphTop; this.ParagraphTop = ParaLayout.ParagraphTop;
}, },
Calculate_X : function(bInline, RelativeFrom, bAlign, Value) Calculate_X : function(bInline, RelativeFrom, bAlign, Value)
...@@ -3899,7 +3919,8 @@ ParaDrawing.prototype = ...@@ -3899,7 +3919,8 @@ ParaDrawing.prototype =
return this.GraphicObj.Selection_Is_TableBorderMove(); return this.GraphicObj.Selection_Is_TableBorderMove();
return false; return false;
}, },
Update_Position : function(X, Y, PageNum, LastItemW, ColumnStartX, ColumnEndX, Left_Margin, Right_Margin, Page_W, Top_Margin, Bottom_Margin, Page_H, MarginH, MarginV, LineTop, ParagraphTop, PageLimits)
Update_Position : function(ParaLayout, PageLimits)
{ {
if ( undefined != this.PositionH_Old ) if ( undefined != this.PositionH_Old )
{ {
...@@ -3917,6 +3938,8 @@ ParaDrawing.prototype = ...@@ -3917,6 +3938,8 @@ ParaDrawing.prototype =
this.DocumentContent = this.Parent.Parent; this.DocumentContent = this.Parent.Parent;
var PageNum = ParaLayout.PageNum;
var OtherFlowObjects = this.mainGraphicObjects.getAllFloatObjectsOnPage( PageNum, this.Parent.Parent ); var OtherFlowObjects = this.mainGraphicObjects.getAllFloatObjectsOnPage( PageNum, this.Parent.Parent );
var bInline = ( drawing_Inline === this.DrawingType ? true : false ); var bInline = ( drawing_Inline === this.DrawingType ? true : false );
...@@ -3940,7 +3963,7 @@ ParaDrawing.prototype = ...@@ -3940,7 +3963,7 @@ ParaDrawing.prototype =
} }
this.Internal_Position.Set( W, H, this.YOffset, X, Y, PageNum, LastItemW, ColumnStartX, ColumnEndX, Left_Margin, Right_Margin, Page_W, Top_Margin, Bottom_Margin, Page_H, MarginH, MarginV, LineTop, ParagraphTop); this.Internal_Position.Set( W, H, this.YOffset, ParaLayout);
this.Internal_Position.Calculate_X(bInline, this.PositionH.RelativeFrom, this.PositionH.Align, this.PositionH.Value); this.Internal_Position.Calculate_X(bInline, this.PositionH.RelativeFrom, this.PositionH.Align, this.PositionH.Value);
this.Internal_Position.Calculate_Y(bInline, this.PositionV.RelativeFrom, this.PositionV.Align, this.PositionV.Value); this.Internal_Position.Calculate_Y(bInline, this.PositionV.RelativeFrom, this.PositionV.Align, this.PositionV.Value);
this.Internal_Position.Correct_Values(bInline, PageLimits, this.AllowOverlap, this.Use_TextWrap(), OtherFlowObjects); this.Internal_Position.Correct_Values(bInline, PageLimits, this.AllowOverlap, this.Use_TextWrap(), OtherFlowObjects);
...@@ -4257,8 +4280,40 @@ ParaDrawing.prototype = ...@@ -4257,8 +4280,40 @@ ParaDrawing.prototype =
return false; return false;
}, },
Set_XYForAdd : function(X, Y) Set_XYForAdd : function(X, Y, NearPos, PageNum)
{ {
if ( null !== NearPos )
{
var Layout = NearPos.Paragraph.Get_Layout( NearPos.ContentPos, this );
var _W = (this.PositionH.Align ? this.W : this.getXfrmExtX() );
var _H = (this.PositionV.Align ? this.H : this.getXfrmExtY() );
this.Internal_Position.Set( _W, _H, this.YOffset, Layout.ParagraphLayout );
this.Internal_Position.Calculate_X(false, c_oAscRelativeFromH.Page, false, X);
this.Internal_Position.Calculate_Y(false, c_oAscRelativeFromV.Page, false, Y);
this.Internal_Position.Correct_Values(false, Layout.PageLimits, this.AllowOverlap, this.Use_TextWrap(), []);
this.PageNum = PageNum;
this.X = this.Internal_Position.CalcX;
this.Y = this.Internal_Position.CalcY;
// Рассчитаем сдвиг с учетом старой привязки
var ValueX = this.Internal_Position.Calculate_X_Value(this.PositionH.RelativeFrom);
this.Set_PositionH( this.PositionH.RelativeFrom, false, ValueX );
// На всякий случай пересчитаем заново координату
this.X = this.Internal_Position.Calculate_X(false, this.PositionH.RelativeFrom, this.PositionH.Align, this.PositionH.Value);
// Рассчитаем сдвиг с учетом старой привязки
var ValueY = this.Internal_Position.Calculate_Y_Value(this.PositionV.RelativeFrom);
this.Set_PositionV( this.PositionV.RelativeFrom, false, ValueY );
// На всякий случай пересчитаем заново координату
this.Y = this.Internal_Position.Calculate_Y(false, this.PositionV.RelativeFrom, this.PositionV.Align, this.PositionV.Value);
}
/*
this.Set_PositionH( c_oAscRelativeFromH.Column, false, 0 ); this.Set_PositionH( c_oAscRelativeFromH.Column, false, 0 );
this.Set_PositionV( c_oAscRelativeFromV.Paragraph, false, 0 ); this.Set_PositionV( c_oAscRelativeFromV.Paragraph, false, 0 );
...@@ -4291,6 +4346,7 @@ ParaDrawing.prototype = ...@@ -4291,6 +4346,7 @@ ParaDrawing.prototype =
this.PositionV.RelativeFrom = c_oAscRelativeFromV.Page; this.PositionV.RelativeFrom = c_oAscRelativeFromV.Page;
this.PositionV.Align = false; this.PositionV.Align = false;
this.PositionV.Value = Y; this.PositionV.Value = Y;
*/
}, },
Get_DrawingType : function() Get_DrawingType : function()
...@@ -4355,51 +4411,41 @@ ParaDrawing.prototype = ...@@ -4355,51 +4411,41 @@ ParaDrawing.prototype =
OnEnd_ChangeFlow : function(X, Y, PageNum, W, H, NearPos, bMove, bLast) OnEnd_ChangeFlow : function(X, Y, PageNum, W, H, NearPos, bMove, bLast)
{ {
var LogicDocument = editor.WordControl.m_oLogicDocument; this.Update_Size( W, H );
if ( true === bMove )
if ( true === bMove && null !== NearPos )
{ {
// Здесь мы должны для первого рассчета оставить привязку относительно страницы, а после рассчета var Layout = NearPos.Paragraph.Get_Layout( NearPos.ContentPos, this );
// изменить привязку на старую, при этом пересчитав координаты так, чтобы картинка не изменила
// своего положения.
this.PositionH_Old = var _W = (this.PositionH.Align ? this.W : this.getXfrmExtX() );
{ var _H = (this.PositionV.Align ? this.H : this.getXfrmExtY() );
RelativeFrom : this.PositionH.RelativeFrom,
Align : this.PositionH.Align,
Value : this.PositionH.Value,
RelativeFrom2 : c_oAscRelativeFromH.Page, this.Internal_Position.Set( _W, _H, this.YOffset, Layout.ParagraphLayout );
Align2 : false, this.Internal_Position.Calculate_X(false, c_oAscRelativeFromH.Page, false, X);
Value2 : X this.Internal_Position.Calculate_Y(false, c_oAscRelativeFromV.Page, false, Y);
}; this.Internal_Position.Correct_Values(false, Layout.PageLimits, this.AllowOverlap, this.Use_TextWrap(), []);
this.PositionV_Old = this.PageNum = PageNum;
{ this.X = this.Internal_Position.CalcX;
RelativeFrom : this.PositionV.RelativeFrom, this.Y = this.Internal_Position.CalcY;
Align : this.PositionV.Align,
Value : this.PositionV.Value,
RelativeFrom2 : c_oAscRelativeFromV.Page, // Рассчитаем сдвиг с учетом старой привязки
Align2 : false, var ValueX = this.Internal_Position.Calculate_X_Value(this.PositionH.RelativeFrom);
Value2 : Y this.Set_PositionH( this.PositionH.RelativeFrom, false, ValueX );
};
this.PositionH.RelativeFrom = c_oAscRelativeFromH.Page; // На всякий случай пересчитаем заново координату
this.PositionH.Align = false; this.X = this.Internal_Position.Calculate_X(false, this.PositionH.RelativeFrom, this.PositionH.Align, this.PositionH.Value);
this.PositionH.Value = X;
this.PositionV.RelativeFrom = c_oAscRelativeFromV.Page; // Рассчитаем сдвиг с учетом старой привязки
this.PositionV.Align = false; var ValueY = this.Internal_Position.Calculate_Y_Value(this.PositionV.RelativeFrom);
this.PositionV.Value = Y; this.Set_PositionV( this.PositionV.RelativeFrom, false, ValueY );
if ( null !== NearPos ) // На всякий случай пересчитаем заново координату
{ this.Y = this.Internal_Position.Calculate_Y(false, this.PositionV.RelativeFrom, this.PositionV.Align, this.PositionV.Value);
this.Remove_FromDocument( false );
this.Add_ToDocument( NearPos, false );
}
}
this.Update_Size( W, H ); this.Remove_FromDocument( false );
this.Add_ToDocument( NearPos, false );
}
if ( true === bLast ) if ( true === bLast )
editor.WordControl.m_oLogicDocument.Recalculate(); editor.WordControl.m_oLogicDocument.Recalculate();
......
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