lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 86d57fa2 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@60836 954022d7-b5bf-4e40-9824-e11837661b57
parent 725835da
...@@ -714,6 +714,7 @@ function CCollaborativeEditing() ...@@ -714,6 +714,7 @@ function CCollaborativeEditing()
if ( true === OtherChanges ) if ( true === OtherChanges )
{ {
editor.WordControl.m_oLogicDocument.Stop_Recalculate(); editor.WordControl.m_oLogicDocument.Stop_Recalculate();
editor.WordControl.m_oLogicDocument.EndPreview_MailMergeResult();
editor.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.ApplyChanges); editor.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.ApplyChanges);
......
...@@ -13980,6 +13980,33 @@ CDocument.prototype.Recalculate_FromStart = function(bUpdateStates) ...@@ -13980,6 +13980,33 @@ CDocument.prototype.Recalculate_FromStart = function(bUpdateStates)
this.Document_UpdateSelectionState(); this.Document_UpdateSelectionState();
} }
}; };
CDocument.prototype.Start_MailMerge = function(MailMergeMap)
{
this.MailMergeMap = MailMergeMap;
editor.sync_StartMailMerge();
};
CDocument.prototype.Get_MailMergeReceptionsCount = function()
{
if (null === this.MailMergeMap || !this.MailMergeMap)
return 0;
return this.MailMergeMap.length;
};
CDocument.prototype.Get_MailMergeFieldsNameList = function()
{
if (this.Get_MailMergeReceptionsCount() <= 0)
return [];
// Предполагаем, что в первом элементе перечислены все поля
var Element = this.MailMergeMap[0];
var aList = [];
for (var sId in Element)
{
aList.push(sId);
}
return aList;
};
CDocument.prototype.Preview_MailMergeResult = function(Index) CDocument.prototype.Preview_MailMergeResult = function(Index)
{ {
if (null === this.MailMergeMap) if (null === this.MailMergeMap)
...@@ -13993,6 +14020,8 @@ CDocument.prototype.Preview_MailMergeResult = function(Index) ...@@ -13993,6 +14020,8 @@ CDocument.prototype.Preview_MailMergeResult = function(Index)
this.FieldsManager.Update_MailMergeFields(this.MailMergeMap[Index]); this.FieldsManager.Update_MailMergeFields(this.MailMergeMap[Index]);
this.Recalculate_FromStart(true); this.Recalculate_FromStart(true);
editor.sync_PreviewMailMergeResult(Index);
}; };
CDocument.prototype.EndPreview_MailMergeResult = function() CDocument.prototype.EndPreview_MailMergeResult = function()
{ {
...@@ -14004,6 +14033,8 @@ CDocument.prototype.EndPreview_MailMergeResult = function() ...@@ -14004,6 +14033,8 @@ CDocument.prototype.EndPreview_MailMergeResult = function()
this.FieldsManager.Restore_MailMergeTemplate(); this.FieldsManager.Restore_MailMergeTemplate();
this.Recalculate_FromStart(true); this.Recalculate_FromStart(true);
editor.sync_EndPreviewMailMergeResult();
}; };
CDocument.prototype.Add_MailMergeField = function(Name) CDocument.prototype.Add_MailMergeField = function(Name)
{ {
......
...@@ -72,43 +72,95 @@ ParaField.prototype.Add = function(Item) ...@@ -72,43 +72,95 @@ ParaField.prototype.Add = function(Item)
{ {
switch (Item.Type) switch (Item.Type)
{ {
case para_Run : case para_Run :
case para_Hyperlink:
{ {
var CurItem = this.Content[this.State.ContentPos]; var TextPr = this.Get_FirstTextPr();
Item.Select_All();
Item.Apply_TextPr(TextPr);
Item.Selection_Remove();
var CurPos = this.State.ContentPos;
var CurItem = this.Content[CurPos];
if (para_Run === CurItem.Type)
{
var NewRun = CurItem.Split2(CurItem.State.ContentPos);
this.Add_ToContent(CurPos + 1, Item);
this.Add_ToContent(CurPos + 2, NewRun);
this.State.ContentPos = CurPos + 2;
this.Content[this.State.ContentPos].Cursor_MoveToStartPos();
}
else
CurItem.Add(Item);
break;
}
case para_Math :
{
var ContentPos = new CParagraphContentPos();
this.Get_ParaContentPos(false, false, ContentPos);
var CurPos = ContentPos.Get(0);
switch ( CurItem.Type ) // Ран формула делит на части, а в остальные элементы добавляется целиком
if (para_Run === this.Content[CurPos].Type)
{ {
case para_Run : // Разделяем текущий элемент (возвращается правая часть)
{ var NewElement = this.Content[CurPos].Split(ContentPos, 1);
var NewRun = CurItem.Split2(CurItem.State.ContentPos);
this.Internal_Content_Add( CurPos + 1, Item ); if (null !== NewElement)
this.Internal_Content_Add( CurPos + 2, NewRun ); this.Add_ToContent(CurPos + 1, NewElement, true);
this.State.ContentPos = CurPos + 1;
break; var Elem = new ParaMath();
} Elem.Root.Load_FromMenu(Item.Menu, this);
Elem.Root.Correct_Content(true);
this.Add_ToContent(CurPos + 1, Elem, true);
// Перемещаем кусор в конец формулы
this.State.ContentPos = CurPos + 1;
this.Content[this.State.ContentPos].Cursor_MoveToEndPos(false);
}
else
this.Content[CurPos].Add(Item);
default: break;
}
case para_Field:
{
// Вместо добавления самого элемента добавляем его содержимое
var Count = Item.Content.length;
if (Count > 0)
{
var CurPos = this.State.ContentPos;
var CurItem = this.Content[CurPos];
var CurContentPos = new CParagraphContentPos();
CurItem.Get_ParaContentPos(false, false, CurContentPos);
var NewItem = CurItem.Split(CurContentPos, 0);
for (var Index = 0; Index < Count; Index++)
{ {
this.Content[this.State.ContentPos].Add( Item ); this.Add_ToContent(CurPos + Index + 1, Item.Content[Index], false);
break;
} }
this.Add_ToContent(CurPos + Count + 1, NewItem, false);
this.State.ContentPos = CurPos + Count;
this.Content[this.State.ContentPos].Cursor_MoveToEndPos();
} }
break; break;
} }
default : default :
{ {
this.Content[this.State.ContentPos].Add( Item ); this.Content[this.State.ContentPos].Add(Item);
break; break;
} }
} }
}; };
ParaField.prototype.Split = function (ContentPos, Depth) ParaField.prototype.Split = function (ContentPos, Depth)
{ {
var NewField = ParaField.superclass.Split.apply(this, arguments); // Не даем разделять поле
return NewField; return null;
}; };
ParaField.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRange, _CurPage) ParaField.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRange, _CurPage)
{ {
...@@ -161,11 +213,13 @@ ParaField.prototype.Map_MailMerge = function(Value) ...@@ -161,11 +213,13 @@ ParaField.prototype.Map_MailMerge = function(Value)
oRun.Add_ToContent(Index, oText); oRun.Add_ToContent(Index, oText);
} }
oRun.Set_Pr(this.Get_FirstTextPr());
// Подменяем содержимое поля // Подменяем содержимое поля
this.Content = []; this.Content = [];
this.Content[0] = oRun; this.Content[0] = oRun;
// В контенте ищем первый ран и копируем его настройки this.Cursor_MoveToStartPos();
if (bHistory) if (bHistory)
History.TurnOn(); History.TurnOn();
...@@ -174,6 +228,7 @@ ParaField.prototype.Restore_Template = function() ...@@ -174,6 +228,7 @@ ParaField.prototype.Restore_Template = function()
{ {
// Восстанавливаем содержимое поля. // Восстанавливаем содержимое поля.
this.Content = this.TemplateContent; this.Content = this.TemplateContent;
this.Cursor_MoveToStartPos();
}; };
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Undo/Redo функции // Undo/Redo функции
...@@ -438,6 +493,8 @@ ParaField.prototype.Read_FromBinary2 = function(Reader) ...@@ -438,6 +493,8 @@ ParaField.prototype.Read_FromBinary2 = function(Reader)
this.Content.push(Element); this.Content.push(Element);
} }
this.TemplateContent = this.Content;
if (editor) if (editor)
editor.WordControl.m_oLogicDocument.Register_Field(this); editor.WordControl.m_oLogicDocument.Register_Field(this);
}; };
...@@ -73,39 +73,45 @@ ParaHyperlink.prototype.Add = function(Item) ...@@ -73,39 +73,45 @@ ParaHyperlink.prototype.Add = function(Item)
{ {
switch (Item.Type) switch (Item.Type)
{ {
case para_Run : case para_Run :
case para_Field:
{ {
var CurItem = this.Content[this.State.ContentPos]; var TextPr = this.Get_FirstTextPr();
Item.Select_All();
switch ( CurItem.Type ) Item.Apply_TextPr(TextPr);
Item.Selection_Remove();
var CurPos = this.State.ContentPos;
var CurItem = this.Content[CurPos];
if (para_Run === CurItem.Type || para_Math === CurItem.Type)
{ {
case para_Run : var ContentPos = new CParagraphContentPos();
{ this.Content[CurPos].Get_ParaContentPos(false, false, ContentPos);
var NewRun = CurItem.Split2(CurItem.State.ContentPos);
this.Internal_Content_Add( CurPos + 1, Item ); // Разделяем текущий элемент (возвращается правая часть)
this.Internal_Content_Add( CurPos + 2, NewRun ); var NewElement = this.Content[CurPos].Split(ContentPos, 0);
this.State.ContentPos = CurPos + 1;
break;
}
default: if (null !== NewElement)
{ this.Add_ToContent(CurPos + 1, NewElement);
this.Content[this.State.ContentPos].Add( Item );
break; this.Add_ToContent(CurPos + 1, Item);
}
this.State.ContentPos = CurPos + 1;
this.Content[this.State.ContentPos].Cursor_MoveToEndPos(false);
} }
else
CurItem.Add(Item);
break; break;
} }
case para_Math : case para_Math :
{ {
var ContentPos = new CParagraphContentPos(); var ContentPos = new CParagraphContentPos();
this.Get_ParaContentPos(false, false, ContentPos); this.Get_ParaContentPos(false, false, ContentPos);
var CurPos = ContentPos.Get(0); var CurPos = ContentPos.Get(0);
if ( para_Math !== this.Content[CurPos].Type ) // Ран формула делит на части, а в остальные элементы добавляется целиком
if (para_Run === this.Content[CurPos].Type)
{ {
// Разделяем текущий элемент (возвращается правая часть) // Разделяем текущий элемент (возвращается правая часть)
var NewElement = this.Content[CurPos].Split(ContentPos, 1); var NewElement = this.Content[CurPos].Split(ContentPos, 1);
...@@ -127,10 +133,34 @@ ParaHyperlink.prototype.Add = function(Item) ...@@ -127,10 +133,34 @@ ParaHyperlink.prototype.Add = function(Item)
break; break;
} }
case para_Hyperlink:
{
// Вместо добавления самого элемента добавляем его содержимое
var Count = Item.Content.length;
if (Count > 0)
{
var CurPos = this.State.ContentPos;
var CurItem = this.Content[CurPos];
var CurContentPos = new CParagraphContentPos();
CurItem.Get_ParaContentPos(false, false, CurContentPos);
var NewItem = CurItem.Split(CurContentPos, 0);
for (var Index = 0; Index < Count; Index++)
{
this.Add_ToContent(CurPos + Index + 1, Item.Content[Index], false);
}
this.Add_ToContent(CurPos + Count + 1, NewItem, false);
this.State.ContentPos = CurPos + Count;
this.Content[this.State.ContentPos].Cursor_MoveToEndPos();
}
break;
}
default : default :
{ {
this.Content[this.State.ContentPos].Add( Item ); this.Content[this.State.ContentPos].Add(Item);
break; break;
} }
} }
...@@ -197,15 +227,6 @@ ParaHyperlink.prototype.Draw_Lines = function(PDSL) ...@@ -197,15 +227,6 @@ ParaHyperlink.prototype.Draw_Lines = function(PDSL)
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// Работаем со значениями // Работаем со значениями
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
ParaHyperlink.prototype.Get_Text = function(Text)
{
var ContentLen = this.Content.length;
for ( var CurPos = 0; CurPos < ContentLen; CurPos++ )
{
this.Content[CurPos].Get_Text( Text );
}
};
ParaHyperlink.prototype.Set_Visited = function(Value) ParaHyperlink.prototype.Set_Visited = function(Value)
{ {
this.Visited = Value; this.Visited = Value;
......
...@@ -2784,26 +2784,27 @@ Paragraph.prototype = ...@@ -2784,26 +2784,27 @@ Paragraph.prototype =
var ContentPos = this.Get_ParaContentPos(false, false); var ContentPos = this.Get_ParaContentPos(false, false);
var CurPos = ContentPos.Get(0); var CurPos = ContentPos.Get(0);
if ( para_Math !== this.Content[CurPos].Type && para_Hyperlink !== this.Content[CurPos].Type ) // Ран формула делит на части, а в остальные элементы формула добавляется целиком.
if (para_Run === this.Content[CurPos].Type)
{ {
// Разделяем текущий элемент (возвращается правая часть) // Разделяем текущий элемент (возвращается правая часть)
var NewElement = this.Content[CurPos].Split( ContentPos, 1 ); var NewElement = this.Content[CurPos].Split(ContentPos, 1);
if ( null !== NewElement ) if (null !== NewElement)
this.Internal_Content_Add( CurPos + 1, NewElement ); this.Internal_Content_Add(CurPos + 1, NewElement);
var Elem = new ParaMath(); var MathElement = new ParaMath();
Elem.Root.Load_FromMenu(Item.Menu, this); MathElement.Root.Load_FromMenu(Item.Menu, this);
Elem.Root.Correct_Content(true); MathElement.Root.Correct_Content(true);
// Добавляем гиперссылку в содержимое параграфа
this.Internal_Content_Add( CurPos + 1, Elem ); this.Internal_Content_Add(CurPos + 1, MathElement);
// Перемещаем кусор в конец формулы // Перемещаем кусор в конец формулы
this.CurPos.ContentPos = CurPos + 1; this.CurPos.ContentPos = CurPos + 1;
this.Content[this.CurPos.ContentPos].Cursor_MoveToEndPos(false); this.Content[this.CurPos.ContentPos].Cursor_MoveToEndPos(false);
} }
else else
this.Content[CurPos].Add( Item ); this.Content[CurPos].Add(Item);
break; break;
} }
...@@ -2812,8 +2813,8 @@ Paragraph.prototype = ...@@ -2812,8 +2813,8 @@ Paragraph.prototype =
var ContentPos = this.Get_ParaContentPos(false, false); var ContentPos = this.Get_ParaContentPos(false, false);
var CurPos = ContentPos.Get(0); var CurPos = ContentPos.Get(0);
// В поле не добавляем другое поле // Формулу и ран поле делит на части, в остальные элементы добавляется целиком.
if (para_Field !== this.Content[CurPos].Type) if (para_Run === this.Content[CurPos].Type || para_Math === this.Content[CurPos].Type)
{ {
// Разделяем текущий элемент (возвращается правая часть) // Разделяем текущий элемент (возвращается правая часть)
var NewElement = this.Content[CurPos].Split(ContentPos, 1); var NewElement = this.Content[CurPos].Split(ContentPos, 1);
...@@ -2827,6 +2828,8 @@ Paragraph.prototype = ...@@ -2827,6 +2828,8 @@ Paragraph.prototype =
this.CurPos.ContentPos = CurPos + 1; this.CurPos.ContentPos = CurPos + 1;
this.Content[this.CurPos.ContentPos].Cursor_MoveToEndPos(false); this.Content[this.CurPos.ContentPos].Cursor_MoveToEndPos(false);
} }
else
this.Content[CurPos].Add(Item);
break; break;
} }
...@@ -5116,7 +5119,7 @@ Paragraph.prototype = ...@@ -5116,7 +5119,7 @@ Paragraph.prototype =
EndContentPos = Temp; EndContentPos = Temp;
} }
// Если у нас попадает комментарий с данную область, тогда удалим его. // Если у нас попадает комментарий в данную область, тогда удалим его.
// TODO: Переделать здесь, когда комментарии смогут лежать во всех классах (например в Hyperlink) // TODO: Переделать здесь, когда комментарии смогут лежать во всех классах (например в Hyperlink)
var StartPos = StartContentPos.Get(0); var StartPos = StartContentPos.Get(0);
...@@ -5160,7 +5163,9 @@ Paragraph.prototype = ...@@ -5160,7 +5163,9 @@ Paragraph.prototype =
var NewElementS = this.Content[StartPos].Split( StartContentPos, 1 ); var NewElementS = this.Content[StartPos].Split( StartContentPos, 1 );
var HyperPos = 0; var HyperPos = 0;
Hyperlink.Add_ToContent( HyperPos++, NewElementS );
if (null !== NewElementS)
Hyperlink.Add_ToContent(HyperPos++, NewElementS);
for ( var CurPos = StartPos + 1; CurPos <= EndPos; CurPos++ ) for ( var CurPos = StartPos + 1; CurPos <= EndPos; CurPos++ )
{ {
...@@ -5169,7 +5174,9 @@ Paragraph.prototype = ...@@ -5169,7 +5174,9 @@ Paragraph.prototype =
this.Internal_Content_Remove2( StartPos + 1, EndPos - StartPos ); this.Internal_Content_Remove2( StartPos + 1, EndPos - StartPos );
this.Internal_Content_Add( StartPos + 1, Hyperlink ); this.Internal_Content_Add( StartPos + 1, Hyperlink );
this.Internal_Content_Add( StartPos + 2, NewElementE );
if (null !== NewElementE)
this.Internal_Content_Add(StartPos + 2, NewElementE);
this.Selection.StartPos = StartPos + 1; this.Selection.StartPos = StartPos + 1;
this.Selection.EndPos = StartPos + 1; this.Selection.EndPos = StartPos + 1;
......
...@@ -307,6 +307,16 @@ CParagraphContentWithParagraphLikeContent.prototype.Get_TextPr = function(_Conte ...@@ -307,6 +307,16 @@ CParagraphContentWithParagraphLikeContent.prototype.Get_TextPr = function(_Conte
else else
return this.Content[_ContentPos.Get(Depth)].Get_TextPr(_ContentPos, Depth + 1); return this.Content[_ContentPos.Get(Depth)].Get_TextPr(_ContentPos, Depth + 1);
}; };
CParagraphContentWithParagraphLikeContent.prototype.Get_FirstTextPr = function()
{
if (this.Content.length <= 0)
return new CTextPr();
if (para_Run === this.Content[0].Type)
return this.Content[0].Get_TextPr();
else
return this.Content[0].Get_FirstTextPr();
};
CParagraphContentWithParagraphLikeContent.prototype.Get_CompiledTextPr = function(Copy) CParagraphContentWithParagraphLikeContent.prototype.Get_CompiledTextPr = function(Copy)
{ {
var TextPr = null; var TextPr = null;
...@@ -981,6 +991,14 @@ CParagraphContentWithParagraphLikeContent.prototype.Split = function (ContentPos ...@@ -981,6 +991,14 @@ CParagraphContentWithParagraphLikeContent.prototype.Split = function (ContentPos
return Element; return Element;
}; };
CParagraphContentWithParagraphLikeContent.prototype.Get_Text = function(Text)
{
var ContentLen = this.Content.length;
for ( var CurPos = 0; CurPos < ContentLen; CurPos++ )
{
this.Content[CurPos].Get_Text( Text );
}
};
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции пересчета // Функции пересчета
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
......
...@@ -7791,6 +7791,39 @@ asc_docs_api.prototype.asc_AddMath2 = function(Type) ...@@ -7791,6 +7791,39 @@ asc_docs_api.prototype.asc_AddMath2 = function(Type)
} }
}; };
//----------------------------------------------------------------------------------------------------------------------
// Функции для работы с MailMerge
//----------------------------------------------------------------------------------------------------------------------
asc_docs_api.prototype.asc_StartMailMerge = function(aList)
{
this.WordControl.m_oLogicDocument.Start_MailMerge();
};
asc_docs_api.prototype.asc_GetReceptionsCount = function()
{
return this.WordControl.m_oLogicDocument.Get_MailMergeReceptionsCount();
};
asc_docs_api.prototype.sync_StartMailMerge = function()
{
this.asc_fireCallback("asc_onStartMailMerge");
};
asc_docs_api.prototype.sync_PreviewMailMergeResult = function(Index)
{
this.asc_fireCallback("asc_onPreviewMailMergeResult", Index);
};
asc_docs_api.prototype.sync_EndPreviewMailMergeResult = function()
{
this.asc_fireCallback("asc_onEndPreviewMailMergeResult");
};
asc_docs_api.prototype.asc_GetMailMergeFieldsNameList = function()
{
return this.WordControl.m_oLogicDocument.Get_MailMergeFieldsNameList();
};
asc_docs_api.prototype.asc_AddMailMergeField = function(Name)
{
this.WordControl.m_oLogicDocument.Add_MailMergeField(Name);
};
window["asc_docs_api"] = asc_docs_api; window["asc_docs_api"] = asc_docs_api;
window["asc_docs_api"].prototype["asc_nativeOpenFile"] = function(base64File, version) window["asc_docs_api"].prototype["asc_nativeOpenFile"] = function(base64File, version)
{ {
......
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