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

Доработка буквицы. Исправлен баг, связанный с копированием параграфа....

Доработка буквицы. Исправлен баг, связанный с копированием параграфа. Исправлен рассчет метрик строки с точным расстоянием между строк.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@49260 954022d7-b5bf-4e40-9824-e11837661b57
parent 9e31c91a
......@@ -1773,25 +1773,171 @@ CDocument.prototype =
this.Document_UpdateRulersState();
},
Add_DropCap : function()
Add_DropCap : function(bInText)
{
var NewParagraph = new Paragraph( this.DrawingDocument, this, 0, 0, 0, X_Right_Field, Y_Bottom_Field );
var OldParagraph = this.Content[this.CurPos.ContentPos];
OldParagraph.Cursor_MoveToStartPos();
OldParagraph.Cursor_MoveRight(1, false, false);
OldParagraph.Split(NewParagraph);
// Определим параграф, к которому мы будем добавлять буквицу
var Pos = -1;
OldParagraph.CompiledPr.NeedRecalc = true;
OldParagraph.Pr.FramePr = new CFramePr();
OldParagraph.Pr.FramePr.Init_Default_DropCap(false);
OldParagraph.Select_All();
OldParagraph.Add( new ParaTextPr( { FontSize : 20 } ) );
if ( false === this.Selection.Use && type_Paragraph === this.Content[this.CurPos.ContentPos].GetType() )
Pos = this.CurPos.ContentPos;
else if ( true === this.Selection.Use && this.Selection.StartPos <= this.Selection.EndPos && type_Paragraph === this.Content[this.Selection.StartPos].GetType() )
Pos = this.Selection.StartPos;
else if ( true === this.Selection.Use && this.Selection.StartPos > this.Selection.EndPos && type_Paragraph === this.Content[this.Selection.EndPos].GetType() )
Pos = this.Selection.EndPos;
this.Internal_Content_Add( this.CurPos.ContentPos + 1, NewParagraph );
if ( -1 === Pos )
return;
this.Recalculate();
var OldParagraph = this.Content[Pos];
if ( OldParagraph.Lines.length <= 0 )
return;
if ( false === this.Document_Is_SelectionLocked( changestype_None, { Type : changestype_2_Element_and_Type, Element : OldParagraph, CheckType : changestype_Paragraph_Content } ) )
{
this.Create_NewHistoryPoint();
var NewParagraph = new Paragraph( this.DrawingDocument, this, 0, 0, 0, X_Right_Field, Y_Bottom_Field );
var TextPr = OldParagraph.Split_DropCap( NewParagraph );
var LineH = OldParagraph.Lines[0].Bottom - OldParagraph.Lines[0].Top;
var LineTA = OldParagraph.Lines[0].Metrics.TextAscent2;
var LineTD = OldParagraph.Lines[0].Metrics.TextDescent + OldParagraph.Lines[0].Metrics.LineGap;
NewParagraph.Pr.FramePr = new CFramePr();
NewParagraph.Pr.FramePr.Init_Default_DropCap( bInText );
NewParagraph.Update_DropCapByLines( TextPr, NewParagraph.Pr.FramePr.Lines, LineH, LineTA, LineTD );
this.Internal_Content_Add( Pos, NewParagraph );
NewParagraph.Cursor_MoveToStartPos();
NewParagraph.Document_SetThisElementCurrent();
this.Recalculate();
}
},
Remove_DropCap : function(bDropCap)
{
var Pos = -1;
if ( false === this.Selection.Use && type_Paragraph === this.Content[this.CurPos.ContentPos].GetType() )
Pos = this.CurPos.ContentPos;
else if ( true === this.Selection.Use && this.Selection.StartPos <= this.Selection.EndPos && type_Paragraph === this.Content[this.Selection.StartPos].GetType() )
Pos = this.Selection.StartPos;
else if ( true === this.Selection.Use && this.Selection.StartPos > this.Selection.EndPos && type_Paragraph === this.Content[this.Selection.EndPos].GetType() )
Pos = this.Selection.EndPos;
if ( -1 === Pos )
return;
var Para = this.Content[Pos];
var FramePr = Para.Get_FramePr();
// Возможно буквицой является предыдущий параграф
if ( undefined === FramePr && true === bDropCap )
{
var Prev = Para.Get_DocumentPrev();
if ( null != Prev && type_Paragraph === Prev.GetType() )
{
var PrevFramePr = Prev.Get_FramePr();
if ( undefined != PrevFramePr && undefined != PrevFramePr.DropCap )
{
Para = Prev;
FramePr = PrevFramePr;
}
else
return;
}
else
return;
}
if ( undefined === FramePr )
return;
var FrameParas = Para.Internal_Get_FrameParagraphs();
if ( false === bDropCap )
{
if ( false === this.Document_Is_SelectionLocked( changestype_None, { Type : changestype_2_ElementsArray_and_Type, Elements : FrameParas, CheckType : changestype_Paragraph_Content } ) )
{
this.Create_NewHistoryPoint();
var Count = FrameParas.length;
for ( var Index = 0; Index < Count; Index++ )
{
FrameParas[Index].Set_FramePr(undefined, true);
}
this.Recalculate();
}
}
else
{
// Сначала найдем параграф, к которому относится буквица
var Next = Para.Get_DocumentNext();
var Last = Para;
while ( null != Next )
{
if ( type_Paragraph != Next.GetType() || undefined === Next.Get_FramePr() || true != FramePr.Compare( Next.Get_FramePr() ) )
break;
Last = Next;
Next = Next.Get_DocumentNext();
}
if ( null != Next && type_Paragraph === Next.GetType() )
{
FrameParas.push(Next);
if ( false === this.Document_Is_SelectionLocked( changestype_None, { Type : changestype_2_ElementsArray_and_Type, Elements : FrameParas, CheckType : changestype_Paragraph_Content } ) )
{
this.Create_NewHistoryPoint();
// Удалим ненужный элемент
FrameParas.splice( FrameParas.length - 1, 1 );
// Передвинем курсор в начало следующего параграфа, и рассчитаем текстовые настройки и расстояния между строк
Next.Cursor_MoveToStartPos();
var Spacing = Next.Get_CompiledPr2(false).ParaPr.Spacing.Copy();
var TextPr = Next.Internal_CalculateTextPr(Next.CurPos.ContentPos);
var Count = FrameParas.length;
for ( var Index = 0; Index < Count; Index++ )
{
var FramePara = FrameParas[Index];
FramePara.Set_FramePr( undefined, true );
FramePara.Set_Spacing( Spacing, true );
FramePara.Select_All();
FramePara.Add( new ParaTextPr( TextPr ) );
}
Last.CopyPr( Next );
Last.Concat( Next );
this.Internal_Content_Remove(Next.Index, 1);
Last.Cursor_MoveToStartPos();
Last.Document_SetThisElementCurrent();
this.Recalculate();
}
}
else
{
if ( false === this.Document_Is_SelectionLocked( changestype_None, { Type : changestype_2_ElementsArray_and_Type, Elements : FrameParas, CheckType : changestype_Paragraph_Content } ) )
{
this.Create_NewHistoryPoint();
var Count = FrameParas.length;
for ( var Index = 0; Index < Count; Index++ )
{
FrameParas[Index].Set_FramePr(undefined, true);
}
this.Recalculate();
}
}
}
},
CheckRange : function(X0, Y0, X1, Y1, _Y0, _Y1, X_lf, X_rf, PageNum)
{
......
......@@ -192,7 +192,7 @@ Paragraph.prototype =
{
var Item = this.Content[Index];
if ( true === Item.Is_RealContent() )
Para.Internal_Content_Add( Para.Content.length, Item.Copy() );
Para.Internal_Content_Add( Para.Content.length, Item.Copy(), false );
}
return Para;
......@@ -343,7 +343,7 @@ Paragraph.prototype =
// Добавляем элемент в содержимое параграфа. (Здесь передвигаются все позиции
// CurPos.ContentPos, Selection.StartPos, Selection.EndPos)
Internal_Content_Add : function (Pos, Item)
Internal_Content_Add : function (Pos, Item, bCorrectPos)
{
if ( true === Item.Is_RealContent() )
{
......@@ -354,7 +354,7 @@ Paragraph.prototype =
this.Content.splice( Pos, 0, Item );
if ( this.CurPos.ContentPos >= Pos )
this.Set_ContentPos( this.CurPos.ContentPos + 1 );
this.Set_ContentPos( this.CurPos.ContentPos + 1, bCorrectPos );
if ( this.Selection.StartPos >= Pos )
this.Selection.StartPos++;
......@@ -1269,11 +1269,23 @@ Paragraph.prototype =
if ( LineTextDescent < TextDescent )
LineTextDescent = TextDescent;
if ( LineAscent < TextAscent + Item.YOffset )
LineAscent = TextAscent + Item.YOffset;
if ( linerule_Exact === ParaPr.Spacing.LineRule )
{
// Смещение не учитывается в метриках строки, когда расстояние между строк точное
if ( LineAscent < TextAscent )
LineAscent = TextAscent;
if ( LineDescent < TextDescent - Item.YOffset )
LineDescent = TextDescent - Item.YOffset;
if ( LineDescent < TextDescent )
LineDescent = TextDescent;
}
else
{
if ( LineAscent < TextAscent + Item.YOffset )
LineAscent = TextAscent + Item.YOffset;
if ( LineDescent < TextDescent - Item.YOffset )
LineDescent = TextDescent - Item.YOffset;
}
if ( !bWord )
{
......@@ -1500,14 +1512,25 @@ Paragraph.prototype =
// Добавляем длину пробелов до слова
X += nSpaceLen;
if ( LineAscent < Item.Height + Item.YOffset )
LineAscent = Item.Height + Item.YOffset;
if ( linerule_Exact === ParaPr.Spacing.LineRule )
{
if ( LineAscent < Item.Height )
LineAscent = Item.Height;
if ( Item.Height + Item.YOffset > this.Lines[CurLine].Metrics.Ascent )
this.Lines[CurLine].Metrics.Ascent = Item.Height + Item.YOffset;
if ( Item.Height > this.Lines[CurLine].Metrics.Ascent )
this.Lines[CurLine].Metrics.Ascent = Item.Height;
}
else
{
if ( LineAscent < Item.Height + Item.YOffset )
LineAscent = Item.Height + Item.YOffset;
if ( -Item.YOffset > this.Lines[CurLine].Metrics.Descent )
this.Lines[CurLine].Metrics.Descent = -Item.YOffset;
if ( Item.Height + Item.YOffset > this.Lines[CurLine].Metrics.Ascent )
this.Lines[CurLine].Metrics.Ascent = Item.Height + Item.YOffset;
if ( -Item.YOffset > this.Lines[CurLine].Metrics.Descent )
this.Lines[CurLine].Metrics.Descent = -Item.YOffset;
}
X += Item.Width;
......@@ -1658,11 +1681,23 @@ Paragraph.prototype =
if ( LineTextDescent < TextDescent )
LineTextDescent = TextDescent;
if ( LineAscent < TextAscent + Item.YOffset )
LineAscent = TextAscent + Item.YOffset;
if ( LineDescent < TextDescent - Item.YOffset )
LineDescent = TextDescent - Item.YOffset;
if ( linerule_Exact === ParaPr.Spacing.LineRule )
{
if ( LineAscent < TextAscent )
LineAscent = TextAscent;
if ( LineDescent < TextDescent )
LineDescent = TextDescent;
}
else
{
if ( LineAscent < TextAscent + Item.YOffset )
LineAscent = TextAscent + Item.YOffset;
if ( LineDescent < TextDescent - Item.YOffset )
LineDescent = TextDescent - Item.YOffset;
}
if ( X + nSpaceLen + Item.Width > XEnd && ( false === bFirstItemOnLine || RangesCount > 0 ) )
{
......@@ -3268,6 +3303,9 @@ Paragraph.prototype =
// Пересчитываем заданную позицию элемента или текущую позицию курсора.
Internal_Recalculate_CurPos : function(Pos, UpdateCurPos, UpdateTarget, ReturnTarget)
{
if ( this.Lines.length <= 0 )
return { X : 0, Y : 0, Height : 0, Internal : { Line : 0, Page : 0, Range : 0 } };
var LinePos = this.Internal_Get_ParaPos_By_Pos( Pos );
var CurLine = LinePos.Line;
......@@ -10450,8 +10488,113 @@ Paragraph.prototype =
return;
}
this.Pr.FramePr = new CFramePr();
this.Pr.FramePr.Set_FromObject( FramePr );
var FrameParas = this.Internal_Get_FrameParagraphs();
// Тут FramePr- объект класса из api.js CParagraphFrame
if ( true === FramePr.FromDropCapMenu && 1 === FrameParas.length )
{
// Здесь мы смотрим только на количество строк, шрифт, тип и горизонтальный отступ от текста
var NewFramePr = FramePr_old.Copy();
if ( undefined != FramePr.DropCap )
{
var OldLines = NewFramePr.Lines;
NewFramePr.Init_Default_DropCap( FramePr.DropCap === c_oAscDropCap.Drop ? true : false );
NewFramePr.Lines = OldLines;
}
if ( undefined != FramePr.Lines )
{
var AnchorPara = this.Get_FrameAnchorPara();
if ( null === AnchorPara || AnchorPara.Lines.length <= 0 )
return;
var LineH = AnchorPara.Lines[0].Bottom - AnchorPara.Lines[0].Top;
var LineTA = AnchorPara.Lines[0].Metrics.TextAscent2;
var LineTD = AnchorPara.Lines[0].Metrics.TextDescent + AnchorPara.Lines[0].Metrics.LineGap;
this.Set_Spacing( { LineRule : linerule_Exact, Line : FramePr.Lines * LineH }, false );
this.Update_DropCapByLines( this.Internal_CalculateTextPr( this.Internal_GetStartPos() ), FramePr.Lines, LineH, LineTA, LineTD );
}
if ( undefined != FramePr.FontFamily )
{
var FF = new ParaTextPr( { RFonts : { Ascii : { Name : FramePr.FontFamily.Name, Index : -1 } } } );
this.Select_All();
this.Add( FF );
this.Selection_Remove();
}
if ( undefined != FramePr.HSpace )
NewFramePr.HSpace = FramePr.HSpace;
this.Pr.FramePr = NewFramePr;
}
else
{
var NewFramePr = FramePr_old.Copy();
if ( undefined != FramePr.H )
NewFramePr.H = FramePr.H;
if ( undefined != FramePr.HAnchor )
NewFramePr.HAnchor = FramePr.HAnchor;
if ( undefined != FramePr.HRule )
NewFramePr.HRule = FramePr.HRule;
if ( undefined != FramePr.HSpace )
NewFramePr.HSpace = FramePr.HSpace;
if ( undefined != FramePr.Lines )
NewFramePr.Lines = FramePr.Lines;
if ( undefined != FramePr.VAnchor )
NewFramePr.VAnchor = FramePr.VAnchor;
if ( undefined != FramePr.VSpace )
NewFramePr.VSpace = FramePr.VSpace;
// Потому что undefined - нормальное значение (и W всегда заполняется в интерфейсе)
NewFramePr.W = FramePr.W;
if ( undefined != FramePr.Wrap )
NewFramePr.Wrap = FramePr.Wrap;
if ( undefined != FramePr.X )
NewFramePr.X = FramePr.X;
if ( undefined != FramePr.XAlign )
NewFramePr.XAlign = FramePr.XAlign;
if ( undefined != FramePr.Y )
NewFramePr.Y = FramePr.Y;
if ( undefined != FramePr.YAlign )
NewFramePr.YAlign = FramePr.YAlign;
this.Pr.FramePr = NewFramePr;
}
if ( undefined != FramePr.Brd )
{
var Count = FrameParas.length;
for ( var Index = 0; Index < Count; Index++ )
{
FrameParas[Index].Set_Borders( FramePr.Brd );
}
}
if ( undefined != FramePr.Shd )
{
var Count = FrameParas.length;
for ( var Index = 0; Index < Count; Index++ )
{
FrameParas[Index].Set_Shd( FramePr.Shd );
}
}
History.Add( this, { Type : historyitem_Paragraph_FramePr, Old : FramePr_old, New : this.Pr.FramePr } );
this.CompiledPr.NeedRecalc = true;
},
......@@ -10547,12 +10690,21 @@ Paragraph.prototype =
if ( Math.abs( H - this.CalculatedFrame.H ) > 0.001 )
{
if ( H <= this.CalculatedFrame.H )
if ( undefined != FramePr.DropCap && dropcap_None != FramePr.DropCap && 1 === FrameParas.length )
{
NewFramePr.Lines = this.Update_DropCapByHeight( H );
NewFramePr.HRule = linerule_Exact;
NewFramePr.H = H;
}
else
NewFramePr.HRule = linerule_AtLeast;
{
if ( H <= this.CalculatedFrame.H )
NewFramePr.HRule = linerule_Exact;
else
NewFramePr.HRule = linerule_AtLeast;
NewFramePr.H = H;
NewFramePr.H = H;
}
}
var Count = FrameParas.length;
......@@ -10609,6 +10761,7 @@ Paragraph.prototype =
}
FramePr.Brd = ParaPr.Brd;
FramePr.Shd = ParaPr.Shd;
},
Can_AddDropCap : function()
......@@ -10623,6 +10776,229 @@ Paragraph.prototype =
return false;
},
Split_DropCap : function(NewParagraph)
{
var Count = this.Content.length;
var Pos = 0;
var PTextPr = null;
for (; Pos < Count; Pos++ )
{
var Type = this.Content[Pos].Type;
if ( para_TextPr === Type )
PTextPr = this.Content[Pos];
if ( para_Text === Type )
break;
}
if ( Pos >= Count )
return null;
var TextPr = this.Internal_CalculateTextPr(Pos);
var DropCap = this.Content[Pos];
this.Internal_Content_Remove2( 0, Pos + 1 );
if ( null != PTextPr )
this.Internal_Content_Add( 0, PTextPr );
NewParagraph.Internal_Content_Add( 0, DropCap );
return TextPr;
},
Update_DropCapByLines : function(TextPr, Count, LineH, LineTA, LineTD)
{
// Мы должны сделать так, чтобы высота данного параграфа была точно Count * LineH
this.Set_Spacing( { Before : 0, After : 0, LineRule : linerule_Exact, Line : Count * LineH - 0.001 }, false );
var FontSize = 72;
TextPr.FontSize = FontSize;
g_oTextMeasurer.SetTextPr(TextPr);
g_oTextMeasurer.SetFontSlot(fontslot_ASCII, 1);
var TDescent = null;
var TAscent = null;
var TempCount = this.Content.length;
for ( var Index = 0; Index < TempCount; Index++ )
{
var Item = this.Content[Index];
if ( para_Text === Item.Type )
{
var Temp = g_oTextMeasurer.Measure2( Item.Value );
if ( null === TAscent || TAscent < Temp.Ascent )
TAscent = Temp.Ascent;
if ( null === TDescent || TDescent > Temp.Ascent - Temp.Height )
TDescent = Temp.Ascent - Temp.Height;
}
}
var THeight = 0;
if ( null === TAscent || null === TDescent )
THeight = g_oTextMeasurer.GetHeight();
else
THeight = -TDescent + TAscent;
var EmHeight = THeight;
var NewEmHeight = (Count - 1) * LineH + LineTA;
var Koef = NewEmHeight / EmHeight;
TextPr.FontSize *= Koef;
g_oTextMeasurer.SetTextPr(TextPr);
g_oTextMeasurer.SetFontSlot(fontslot_ASCII, 1);
var TNewDescent = null;
var TNewAscent = null;
var TempCount = this.Content.length;
for ( var Index = 0; Index < TempCount; Index++ )
{
var Item = this.Content[Index];
if ( para_Text === Item.Type )
{
var Temp = g_oTextMeasurer.Measure2( Item.Value );
if ( null === TNewAscent || TNewAscent < Temp.Ascent )
TNewAscent = Temp.Ascent;
if ( null === TNewDescent || TNewDescent > Temp.Ascent - Temp.Height )
TNewDescent = Temp.Ascent - Temp.Height;
}
}
var TNewHeight = 0;
if ( null === TNewAscent || null === TNewDescent )
TNewHeight = g_oTextMeasurer.GetHeight();
else
TNewHeight = -TNewDescent + TNewAscent;
var Descent = g_oTextMeasurer.GetDescender();
var Dy = Descent + TNewHeight - TNewAscent + LineTD;
var PTextPr = new ParaTextPr( { RFonts : { Ascii : { Name : TextPr.RFonts.Ascii.Name, Index : -1 } }, FontSize : FontSize * Koef, Position : Dy } );
this.Select_All();
this.Add( PTextPr );
this.Selection_Remove();
},
Update_DropCapByHeight : function(Height)
{
// Ищем следующий параграф, к которому относится буквица
var AnchorPara = this.Get_FrameAnchorPara();
if ( null === AnchorPara || AnchorPara.Lines.length <= 0 )
return 1;
this.Set_Spacing( { LineRule : linerule_Exact, Line : Height }, false );
var LineH = AnchorPara.Lines[0].Bottom - AnchorPara.Lines[0].Top;
var LineTA = AnchorPara.Lines[0].Metrics.TextAscent2;
var LineTD = AnchorPara.Lines[0].Metrics.TextDescent + AnchorPara.Lines[0].Metrics.LineGap;
// Посчитаем количество строк
var LinesCount = Math.ceil( Height / LineH );
var TextPr = this.Internal_CalculateTextPr(this.Internal_GetStartPos());
g_oTextMeasurer.SetTextPr(TextPr);
g_oTextMeasurer.SetFontSlot(fontslot_ASCII, 1);
var TDescent = null;
var TAscent = null;
var TempCount = this.Content.length;
for ( var Index = 0; Index < TempCount; Index++ )
{
var Item = this.Content[Index];
if ( para_Text === Item.Type )
{
var Temp = g_oTextMeasurer.Measure2( Item.Value );
if ( null === TAscent || TAscent < Temp.Ascent )
TAscent = Temp.Ascent;
if ( null === TDescent || TDescent > Temp.Ascent - Temp.Height )
TDescent = Temp.Ascent - Temp.Height;
}
}
var THeight = 0;
if ( null === TAscent || null === TDescent )
THeight = g_oTextMeasurer.GetHeight();
else
THeight = -TDescent + TAscent;
var Koef = (Height - LineTD) / THeight;
TextPr.FontSize *= Koef;
g_oTextMeasurer.SetTextPr(TextPr);
g_oTextMeasurer.SetFontSlot(fontslot_ASCII, 1);
var TNewDescent = null;
var TNewAscent = null;
var TempCount = this.Content.length;
for ( var Index = 0; Index < TempCount; Index++ )
{
var Item = this.Content[Index];
if ( para_Text === Item.Type )
{
var Temp = g_oTextMeasurer.Measure2( Item.Value );
if ( null === TNewAscent || TNewAscent < Temp.Ascent )
TNewAscent = Temp.Ascent;
if ( null === TNewDescent || TNewDescent > Temp.Ascent - Temp.Height )
TNewDescent = Temp.Ascent - Temp.Height;
}
}
var TNewHeight = 0;
if ( null === TNewAscent || null === TNewDescent )
TNewHeight = g_oTextMeasurer.GetHeight();
else
TNewHeight = -TNewDescent + TNewAscent;
var Descent = g_oTextMeasurer.GetDescender();
var Dy = Descent + TNewHeight - TNewAscent + LineTD;
var PTextPr = new ParaTextPr( { RFonts : { Ascii : { Name : TextPr.RFonts.Ascii.Name, Index : -1 } }, FontSize : TextPr.FontSize, Position : Dy } );
this.Select_All();
this.Add( PTextPr );
this.Selection_Remove();
return LinesCount;
},
Get_FrameAnchorPara : function()
{
var FramePr = this.Get_FramePr();
if ( undefined === FramePr )
return null;
var Next = this.Get_DocumentNext();
while ( null != Next )
{
if ( type_Paragraph === Next.GetType() )
{
var NextFramePr = Next.Get_FramePr();
if ( undefined === NextFramePr || false === FramePr.Compare( NextFramePr ) )
return Next;
}
Next = Next.Get_DocumentNext();
}
return Next;
},
// Разделяем данный параграф
Split : function(NewParagraph, Pos)
{
......@@ -13118,38 +13494,51 @@ CParaLineMetrics.prototype =
var ExactValue = Math.max( 1, ParaPr.Spacing.Line );
LineGap = ExactValue - ( TextAscent + TextDescent );
if ( LineGap < 0 )
{
var Ascent_old = this.Ascent;
var Descent_old = this.Descent;
var TextDescent_old = this.TextDescent;
var TextAscent_old = this.TextAscent;
var DiffAsc = Ascent_old - TextAscent_old;
var DiffDes = Descent_old - TextDescent_old;
if ( -LineGap < DiffAsc + DiffDes )
// TODO: пересмотреть тут
// if ( LineGap < 0 )
// {
// var Ascent_old = this.Ascent;
// var Descent_old = this.Descent;
// var TextDescent_old = this.TextDescent;
// var TextAscent_old = this.TextAscent;
//
// var DiffAsc = Ascent_old - TextAscent_old;
// var DiffDes = Descent_old - TextDescent_old;
//
// LineGap += DiffAsc + DiffDes;
//
// Ascent_old = TextAscent_old;
// Descent_old = TextDescent_old;
//
// this.Ascent = ExactValue * Ascent_old / ( Ascent_old + Descent_old );
// this.Descent = ExactValue * Descent_old / ( Ascent_old + Descent_old );
//
// LineGap = 0;
// }
// else
// {
var Gap = this.Ascent + this.Descent - ExactValue;
if ( Gap > 0 )
{
var NewVal = DiffAsc + DiffDes + LineGap;
var DiffAsc_new = NewVal * DiffAsc / (DiffAsc + DiffDes);
var DiffDes_new = NewVal * DiffDes / (DiffAsc + DiffDes);
this.Ascent = TextAscent_old + DiffAsc_new;
this.Descent = TextDescent_old + DiffDes_new;
if ( this.Ascent < Gap )
{
this.Ascent = 0;
this.Descent = ExactValue;
}
else
{
this.Ascent -= Gap; // уменьшаем Ascent
}
}
else
{
LineGap += DiffAsc + DiffDes;
Ascent_old = TextAscent_old;
Descent_old = TextDescent_old;
this.Ascent = ExactValue * Ascent_old / ( Ascent_old + Descent_old );
this.Descent = ExactValue * Descent_old / ( Ascent_old + Descent_old );
this.Ascent -= Gap; // все в Ascent
}
LineGap = 0;
}
// }
break;
}
......
......@@ -110,7 +110,7 @@ CParaSpellChecker.prototype =
this.Elements.push( new CParaSpellCheckerElement( StartPos, EndPos, Word, Lang ) );
},
Check : function()
Check : function(ParagraphForceRedraw)
{
var Paragraph = g_oTableId.Get_ById( this.ParaId );
var bCurrent = Paragraph.Is_ThisElementCurrent();
......@@ -146,6 +146,8 @@ CParaSpellChecker.prototype =
if ( 0 < usrWords.length )
spellCheck(editor, {"type": "spell", "ParagraphId": this.ParaId, "RecalcId" : this.RecalcId, "ElementId" : 0, "usrWords" : usrWords, "usrLang" : usrLang });
else if ( undefined != ParagraphForceRedraw )
ParagraphForceRedraw.ReDraw();
},
Check_CallBack : function(RecalcId, UsrCorrect)
......@@ -797,6 +799,33 @@ Paragraph.prototype.Continue_CheckSpelling = function()
else if ( pararecalc_0_Spell_Lang === this.RecalcInfo.Recalc_0_Spell.Type )
CheckLang = true;
var ParaForceRedraw = undefined;
var PrevPara = this.Get_DocumentPrev();
if ( null != PrevPara && type_Paragraph === PrevPara.GetType() && undefined != PrevPara.Get_FramePr() && undefined != PrevPara.Get_FramePr().DropCap )
{
if ( this.SpellChecker.Elements.length > 0 )
{
var bDontCheckFirstWord = true;
var Element = this.SpellChecker.Elements[0];
var StartPos = Element.StartPos;
for ( var TempPos = 0; TempPos < StartPos; TempPos++ )
{
var Item = this.Content[TempPos];
if ( para_Space === Item.Type )
{
bDontCheckFirstWord = false;
break;
}
}
if ( true === bDontCheckFirstWord && true != Element.Checked )
{
Element.Checked = true;
ParaForceRedraw = this;
}
}
}
if ( true === CheckLang )
{
// Пройдемся по всем словам и проверим словарь, в котором должно проверяться слово (если словарь поменялся,
......@@ -817,7 +846,7 @@ Paragraph.prototype.Continue_CheckSpelling = function()
this.SpellChecker.RecalcId = this.LogicDocument.RecalcId;
this.SpellChecker.ParaId = this.Get_Id();
this.SpellChecker.Check();
this.SpellChecker.Check(ParaForceRedraw);
this.RecalcInfo.Recalc_0_Spell.Type = pararecalc_0_Spell_None;
};
......@@ -5026,6 +5026,9 @@ CTextPr.prototype =
Check_NeedRecalc : function()
{
// Потому что в параграфе внутри Internal_recalculate_0 кэшируются ParaTextPr
return true;
if ( undefined != this.Bold )
return true;
......@@ -5878,6 +5881,15 @@ CFramePr.prototype =
this.Wrap = wrap_Around;
this.VAnchor = c_oAscVAnchor.Text;
this.HAnchor = ( true === bInside ? c_oAscHAnchor.Text : c_oAscHAnchor.Page );
this.X = undefined;
this.XAlign = undefined;
this.Y = undefined;
this.YAlign = undefined;
this.H = undefined;
this.W = undefined;
this.HRule = undefined;
},
Get_W : function()
......
......@@ -1668,6 +1668,7 @@ function CParagraphFrame(obj)
this.Y = obj.Y;
this.YAlign = obj.YAlign;
this.Brd = (undefined != obj.Brd && null != obj.Brd) ? new CParagraphBorders (obj.Brd) : null;
this.Shd = (undefined != obj.Shd && null != obj.Shd) ? new CParagraphShd (obj.Shd) : null;
this.FontFamily = (undefined != obj.FontFamily && null != obj.FontFamily) ? new CTextFontFamily (obj.FontFamily) : null;
}
else
......@@ -1688,6 +1689,7 @@ function CParagraphFrame(obj)
this.XAlign = undefined;
this.Y = undefined;
this.YAlign = undefined;
this.Shd = null;
this.Brd = null;
this.FontFamily = null;
}
......@@ -1723,6 +1725,8 @@ CParagraphFrame.prototype.get_YAlign = function () { return this.YAlign; }
CParagraphFrame.prototype.put_YAlign = function (v) { this.YAlign = v; }
CParagraphFrame.prototype.get_Borders = function () { return this.Brd; }
CParagraphFrame.prototype.put_Borders = function (v) { this.Brd = v; }
CParagraphFrame.prototype.get_Shade = function () { return this.Shd; }
CParagraphFrame.prototype.put_Shade = function (v) { this.Shd = v; }
CParagraphFrame.prototype.get_FontFamily = function () { return this.FontFamily; }
CParagraphFrame.prototype.put_FontFamily = function (v) { this.FontFamily = v; }
CParagraphFrame.prototype.put_FromDropCapMenu = function (v) { this.FromDropCapMenu = v; }
......
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