Commit dcb0cd76 authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented merge function for changes of classes CTable/CTableRow/CTableCell/ParaDrawing.

parent ef29eb22
......@@ -57,6 +57,31 @@ AscDFH.changesFactory[AscDFH.historyitem_Drawing_LayoutInCell] = CChangesPa
AscDFH.changesFactory[AscDFH.historyitem_Drawing_SetSizeRelH] = CChangesParaDrawingSizeRelH;
AscDFH.changesFactory[AscDFH.historyitem_Drawing_SetSizeRelV] = CChangesParaDrawingSizeRelV;
//----------------------------------------------------------------------------------------------------------------------
// Карта зависимости изменений
//----------------------------------------------------------------------------------------------------------------------
AscDFH.paradrawingChangesRelationMap = {};
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_DrawingType] = [AscDFH.historyitem_Drawing_DrawingType];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_WrappingType] = [AscDFH.historyitem_Drawing_WrappingType];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_Distance] = [AscDFH.historyitem_Drawing_Distance];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_AllowOverlap] = [AscDFH.historyitem_Drawing_AllowOverlap];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_PositionH] = [AscDFH.historyitem_Drawing_PositionH];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_PositionV] = [AscDFH.historyitem_Drawing_PositionV];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_BehindDoc] = [AscDFH.historyitem_Drawing_BehindDoc];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetGraphicObject] = [AscDFH.historyitem_Drawing_SetGraphicObject];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetSimplePos] = [AscDFH.historyitem_Drawing_SetSimplePos];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetExtent] = [AscDFH.historyitem_Drawing_SetExtent];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetWrapPolygon] = [AscDFH.historyitem_Drawing_SetWrapPolygon];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetLocked] = [AscDFH.historyitem_Drawing_SetLocked];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetRelativeHeight] = [AscDFH.historyitem_Drawing_SetRelativeHeight];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetEffectExtent] = [AscDFH.historyitem_Drawing_SetEffectExtent];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetParent] = [AscDFH.historyitem_Drawing_SetParent];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetParaMath] = [AscDFH.historyitem_Drawing_SetParaMath];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_LayoutInCell] = [AscDFH.historyitem_Drawing_LayoutInCell];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetSizeRelH] = [AscDFH.historyitem_Drawing_SetSizeRelH];
AscDFH.paradrawingChangesRelationMap[AscDFH.historyitem_Drawing_SetSizeRelV] = [AscDFH.historyitem_Drawing_SetSizeRelV];
//----------------------------------------------------------------------------------------------------------------------
/**
* @constructor
* @extends {AscDFH.CChangesBaseLongValue}
......
......@@ -51,6 +51,90 @@ AscDFH.changesFactory[AscDFH.historyitem_TableCell_Pr] = CChangesTabl
AscDFH.changesFactory[AscDFH.historyitem_TableCell_TextDirection] = CChangesTableCellTextDirection;
AscDFH.changesFactory[AscDFH.historyitem_TableCell_NoWrap] = CChangesTableCellNoWrap;
//----------------------------------------------------------------------------------------------------------------------
// Карта зависимости изменений
//----------------------------------------------------------------------------------------------------------------------
AscDFH.tablecellChangesRelationMap = {};
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_GridSpan] = [
AscDFH.historyitem_TableCell_GridSpan,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_Margins] = [
AscDFH.historyitem_TableCell_Margins,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_Shd] = [
AscDFH.historyitem_TableCell_Shd,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_VMerge] = [
AscDFH.historyitem_TableCell_VMerge,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_Border_Left] = [
AscDFH.historyitem_TableCell_Border_Left,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_Border_Right] = [
AscDFH.historyitem_TableCell_Border_Right,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_Border_Top] = [
AscDFH.historyitem_TableCell_Border_Top,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_Border_Bottom] = [
AscDFH.historyitem_TableCell_Border_Bottom,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_VAlign] = [
AscDFH.historyitem_TableCell_VAlign,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_W] = [
AscDFH.historyitem_TableCell_W,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_Pr] = [
AscDFH.historyitem_TableCell_GridSpan,
AscDFH.historyitem_TableCell_Margins,
AscDFH.historyitem_TableCell_Shd,
AscDFH.historyitem_TableCell_VMerge,
AscDFH.historyitem_TableCell_Border_Left,
AscDFH.historyitem_TableCell_Border_Right,
AscDFH.historyitem_TableCell_Border_Top,
AscDFH.historyitem_TableCell_Border_Bottom,
AscDFH.historyitem_TableCell_VAlign,
AscDFH.historyitem_TableCell_W,
AscDFH.historyitem_TableCell_Pr,
AscDFH.historyitem_TableCell_TextDirection,
AscDFH.historyitem_TableCell_NoWrap
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_TextDirection] = [
AscDFH.historyitem_TableCell_TextDirection,
AscDFH.historyitem_TableCell_Pr
];
AscDFH.tablecellChangesRelationMap[AscDFH.historyitem_TableCell_NoWrap] = [
AscDFH.historyitem_TableCell_NoWrap,
AscDFH.historyitem_TableCell_Pr
];
/**
* Общая функция объединения изменений, которые зависят только от себя и AscDFH.historyitem_TableCell_Pr
* @param oChange
* @returns {boolean}
*/
function private_TableCellChangesOnMergePr(oChange)
{
if (oChange.Class !== this.Class)
return true;
if (oChange.Type === this.Type || oChange.Type === AscDFH.historyitem_TableCell_Pr)
return false;
return true;
}
//----------------------------------------------------------------------------------------------------------------------
/**
* @constructor
* @extends {AscDFH.CChangesBaseLongProperty}
......@@ -67,6 +151,7 @@ CChangesTableCellGridSpan.prototype.private_SetValue = function(Value)
oCell.Pr.GridSpan = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellGridSpan.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......@@ -194,6 +279,7 @@ CChangesTableCellMargins.prototype.private_SetValue = function(Value)
oCell.Pr.TableCellMar = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellMargins.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseObjectProperty}
......@@ -214,6 +300,7 @@ CChangesTableCellShd.prototype.private_SetValue = function(Value)
oCell.Pr.Shd = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellShd.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseLongProperty}
......@@ -230,6 +317,7 @@ CChangesTableCellVMerge.prototype.private_SetValue = function(Value)
oCell.Pr.VMerge = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellVMerge.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......@@ -347,6 +435,7 @@ CChangesTableCellBorderLeft.prototype.private_SetValue = function(Value)
oCell.Pr.TableCellBorders.Left = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellBorderLeft.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......@@ -464,6 +553,7 @@ CChangesTableCellBorderTop.prototype.private_SetValue = function(Value)
oCell.Pr.TableCellBorders.Top = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellBorderTop.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......@@ -581,6 +671,7 @@ CChangesTableCellBorderRight.prototype.private_SetValue = function(Value)
oCell.Pr.TableCellBorders.Right = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellBorderRight.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......@@ -698,6 +789,7 @@ CChangesTableCellBorderBottom.prototype.private_SetValue = function(Value)
oCell.Pr.TableCellBorders.Bottom = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellBorderBottom.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseLongProperty}
......@@ -714,6 +806,7 @@ CChangesTableCellVAlign.prototype.private_SetValue = function(Value)
oCell.Pr.VAlign = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellVAlign.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseObjectValue}
......@@ -734,6 +827,7 @@ CChangesTableCellW.prototype.private_SetValue = function(Value)
oCell.Pr.TableCellW = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellW.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseObjectValue}
......@@ -754,6 +848,83 @@ CChangesTableCellPr.prototype.private_SetValue = function(Value)
oCell.Pr = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellPr.prototype.Merge = function(oChange)
{
if (this.Class !== oChange.Class)
return true;
if (this.Type === oChange.Type)
return false;
if (!this.New)
this.New = new CTableCellPr();
switch(oChange.Type)
{
case AscDFH.historyitem_TableCell_GridSpan:
{
this.New.GridSpan = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_Margins:
{
this.New.TableCellMar = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_Shd:
{
this.New.Shd = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_VMerge:
{
this.New.VMerge = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_Border_Left:
{
this.New.TableCellBorders.Left = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_Border_Right:
{
this.New.TableCellBorders.Right = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_Border_Top:
{
this.New.TableCellBorders.Top = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_Border_Bottom:
{
this.New.TableCellBorders.Bottom = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_VAlign:
{
this.New.VAlign = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_W:
{
this.New.TableCellW = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_TextDirection:
{
this.New.TextDirection = oChange.New;
break;
}
case AscDFH.historyitem_TableCell_NoWrap:
{
this.New.NoWrap = oChange.New;
break;
}
}
return true;
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseLongProperty}
......@@ -770,6 +941,7 @@ CChangesTableCellTextDirection.prototype.private_SetValue = function(Value)
oCell.Pr.TextDirection = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellTextDirection.prototype.Merge = private_TableCellChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseBoolProperty}
......@@ -786,3 +958,4 @@ CChangesTableCellNoWrap.prototype.private_SetValue = function(Value)
oCell.Pr.NoWrap = Value;
oCell.Recalc_CompiledPr();
};
CChangesTableCellNoWrap.prototype.Merge = private_TableCellChangesOnMergePr;
\ No newline at end of file
This diff is collapsed.
......@@ -46,6 +46,63 @@ AscDFH.changesFactory[AscDFH.historyitem_TableRow_RemoveCell] = CChangesTableRo
AscDFH.changesFactory[AscDFH.historyitem_TableRow_TableHeader] = CChangesTableRowTableHeader;
AscDFH.changesFactory[AscDFH.historyitem_TableRow_Pr] = CChangesTableRowPr;
//----------------------------------------------------------------------------------------------------------------------
// Карта зависимости изменений
//----------------------------------------------------------------------------------------------------------------------
AscDFH.tablerowChangesRelationMap = {};
AscDFH.tablerowChangesRelationMap[AscDFH.historyitem_TableRow_Before] = [
AscDFH.historyitem_TableRow_Before,
AscDFH.historyitem_TableRow_Pr
];
AscDFH.tablerowChangesRelationMap[AscDFH.historyitem_TableRow_After] = [
AscDFH.historyitem_TableRow_After,
AscDFH.historyitem_TableRow_Pr
];
AscDFH.tablerowChangesRelationMap[AscDFH.historyitem_TableRow_CellSpacing] = [
AscDFH.historyitem_TableRow_CellSpacing,
AscDFH.historyitem_TableRow_Pr
];
AscDFH.tablerowChangesRelationMap[AscDFH.historyitem_TableRow_Height] = [
AscDFH.historyitem_TableRow_Height,
AscDFH.historyitem_TableRow_Pr
];
AscDFH.tablerowChangesRelationMap[AscDFH.historyitem_TableRow_AddCell] = [
AscDFH.historyitem_TableRow_AddCell,
AscDFH.historyitem_TableRow_RemoveCell
];
AscDFH.tablerowChangesRelationMap[AscDFH.historyitem_TableRow_RemoveCell] = [
AscDFH.historyitem_TableRow_AddCell,
AscDFH.historyitem_TableRow_RemoveCell
];
AscDFH.tablerowChangesRelationMap[AscDFH.historyitem_TableRow_TableHeader] = [
AscDFH.historyitem_TableRow_TableHeader,
AscDFH.historyitem_TableRow_Pr
];
AscDFH.tablerowChangesRelationMap[AscDFH.historyitem_TableRow_Pr] = [
AscDFH.historyitem_TableRow_Before,
AscDFH.historyitem_TableRow_After,
AscDFH.historyitem_TableRow_CellSpacing,
AscDFH.historyitem_TableRow_Height,
AscDFH.historyitem_TableRow_TableHeader,
AscDFH.historyitem_TableRow_Pr
];
/**
* Общая функция объединения изменений, которые зависят только от себя и AscDFH.historyitem_TableRow_Pr
* @param oChange
* @returns {boolean}
*/
function private_TableRowChangesOnMergePr(oChange)
{
if (oChange.Class !== this.Class)
return true;
if (oChange.Type === this.Type || oChange.Type === AscDFH.historyitem_TableRow_Pr)
return false;
return true;
}
//----------------------------------------------------------------------------------------------------------------------
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......@@ -151,6 +208,7 @@ CChangesTableRowBefore.prototype.private_SetValue = function(Value)
oTableRow.Pr.WBefore = Value.WBefore;
oTableRow.Recalc_CompiledPr();
};
CChangesTableRowBefore.prototype.Merge = private_TableRowChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......@@ -256,6 +314,7 @@ CChangesTableRowAfter.prototype.private_SetValue = function(Value)
oTableRow.Pr.WAfter = Value.WBefore;
oTableRow.Recalc_CompiledPr();
};
CChangesTableRowAfter.prototype.Merge = private_TableRowChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......@@ -326,6 +385,7 @@ CChangesTableRowCellSpacing.prototype.private_SetValue = function(Value)
oTableRow.Pr.TableCellSpacing = Value;
oTableRow.Recalc_CompiledPr();
};
CChangesTableRowCellSpacing.prototype.Merge = private_TableRowChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseObjectProperty}
......@@ -346,6 +406,7 @@ CChangesTableRowHeight.prototype.private_SetValue = function(Value)
oTable.Pr.Height = Value;
oTable.Recalc_CompiledPr();
};
CChangesTableRowHeight.prototype.Merge = private_TableRowChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -494,6 +555,7 @@ CChangesTableRowTableHeader.prototype.private_SetValue = function(Value)
oRow.Pr.TableHeader = Value;
oRow.Recalc_CompiledPr();
};
CChangesTableRowTableHeader.prototype.Merge = private_TableRowChangesOnMergePr;
/**
* @constructor
* @extends {AscDFH.CChangesBaseObjectValue}
......@@ -514,3 +576,47 @@ CChangesTableRowPr.prototype.private_SetValue = function(Value)
oRow.Pr = Value;
oRow.Recalc_CompiledPr();
};
CChangesTableRowPr.prototype.Merge = function(oChange)
{
if (this.Class !== oChange.Class)
return true;
if (this.Type === oChange.Type)
return false;
if (!this.New)
this.New = new CTableRowPr();
switch (oChange.Type)
{
case AscDFH.historyitem_TableRow_Before:
{
this.New.GridBefore = oChange.New.GridBefore;
this.New.WBefore = oChange.New.WBefore;
break;
}
case AscDFH.historyitem_TableRow_After:
{
this.New.GridAfter = oChange.New.GridAfter;
this.New.WAfter = oChange.New.WAfter;
break;
}
case AscDFH.historyitem_TableRow_CellSpacing:
{
this.New.TableCellSpacing = oChange.New;
break;
}
case AscDFH.historyitem_TableRow_Height:
{
this.New.Height = oChange.New;
break;
}
case AscDFH.historyitem_TableRow_TableHeader:
{
this.New.TableHeader = oChange.New;
break;
}
}
return true;
};
\ No newline at end of file
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