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 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 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 OldParagraph = this.Content[this.CurPos.ContentPos];
OldParagraph.Cursor_MoveToStartPos();
OldParagraph.Cursor_MoveRight(1, false, false);
OldParagraph.Split(NewParagraph);
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 } ) );
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;
this.Internal_Content_Add( this.CurPos.ContentPos + 1, NewParagraph );
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)
{
......
This diff is collapsed.
......@@ -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