Commit 1906aba4 authored by Sergey Luzyanin's avatar Sergey Luzyanin

Размер Drawing в процентах

parent bc736780
......@@ -37,6 +37,18 @@ var DISTANCE_TO_TEXT_LEFTRIGHT = 3.2;
function CheckShapeBodyAutoFitReset(oShape)
{
var oParaDrawing = getParaDrawing(oShape);
if(oParaDrawing)
{
if(oParaDrawing.SizeRelH)
{
oParaDrawing.SetSizeRelH(undefined);
}
if(oParaDrawing.SizeRelV)
{
oParaDrawing.SetSizeRelV(undefined);
}
}
if(oShape instanceof CShape)
{
var oPropsToSet = null;
......
......@@ -1035,7 +1035,8 @@ var historyitem_Drawing_SetEffectExtent = 17;// Устанавливаем Eff
var historyitem_Drawing_SetParent = 18;// Устанавливаем Parent
var historyitem_Drawing_SetParaMath = 19; // Добавляем новую формулу для конвертации старого формата в новый
var historyitem_Drawing_LayoutInCell = 20; // Устанавливаем параметр расположения в таблице
var historyitem_Drawing_SetSizeRelH = 21;//Ширина объекта в процентах
var historyitem_Drawing_SetSizeRelV = 22;//Высота объекта в процентах
......
......@@ -2555,6 +2555,94 @@ CShape.prototype =
this.extY = this.parent.Extent.H;
}
}
else
{
var oParaDrawing = getParaDrawing(this);
if(oParaDrawing)
{
if(oParaDrawing.SizeRelH || oParaDrawing.SizeRelV)
{
this.m_oSectPr = null;
var oParentParagraph = oParaDrawing.Get_ParentParagraph();
if(oParentParagraph)
{
var oSectPr = oParentParagraph.Get_SectPr();
if(oSectPr)
{
if(oParaDrawing.SizeRelH)
{
switch(oParaDrawing.SizeRelH.RelativeFrom)
{
case c_oAscRelativeFromH.Margin:
{
this.extX = oSectPr.Get_PageWidth() - oSectPr.Get_PageMargin_Left() - oSectPr.Get_PageMargin_Right();
break;
}
case c_oAscRelativeFromH.Page:
{
this.extX = oSectPr.Get_PageWidth();
break;
}
case c_oAscRelativeFromH.LeftMargin:
{
this.extX = oSectPr.Get_PageMargin_Left();
break;
}
case c_oAscRelativeFromH.RightMargin:
{
this.extX = oSectPr.Get_PageMargin_Right();
break;
}
default:
{
this.extX = oSectPr.Get_PageMargin_Left();
break;
}
}
this.extX *= oParaDrawing.SizeRelH.Percent;
}
if(oParaDrawing.SizeRelV)
{
switch(oParaDrawing.SizeRelV.RelativeFrom)
{
case c_oAscRelativeFromV.Margin:
{
this.extY = oSectPr.Get_PageHeight() - oSectPr.Get_PageMargin_Top() - oSectPr.Get_PageMargin_Bottom();
break;
}
case c_oAscRelativeFromV.Page:
{
this.extY = oSectPr.Get_PageHeight();
break;
}
case c_oAscRelativeFromV.TopMargin:
{
this.extY = oSectPr.Get_PageMargin_Top();
break;
}
case c_oAscRelativeFromV.BottomMargin:
{
this.extY = oSectPr.Get_PageMargin_Bottom();
break;
}
default:
{
this.extY = oSectPr.Get_PageMargin_Top();
break;
}
}
this.extY *= oParaDrawing.SizeRelV.Percent;
}
this.m_oSectPr = new CSectionPr();
this.m_oSectPr.Copy(oSectPr);
}
}
}
}
}
}
else
{
......@@ -2942,7 +3030,9 @@ CShape.prototype =
{
var Width, Height, Width2, Height2;
var bRet = false;
if(this.checkAutofit())
var oParaDrawing = getParaDrawing(this);
var bSizRel = (oParaDrawing && (oParaDrawing.SizeRelH || oParaDrawing.SizeRelV));
if(this.checkAutofit() || bSizRel )
{
if(oSectPr)
{
......@@ -2951,6 +3041,10 @@ CShape.prototype =
this.recalcBounds();
this.recalcText();
this.recalcGeometry();
if(bSizRel)
{
this.recalcTransform();
}
bRet = true;
}
else
......@@ -2967,6 +3061,10 @@ CShape.prototype =
this.recalcBounds();
this.recalcText();
this.recalcGeometry();
if(bSizRel)
{
this.recalcTransform();
}
}
return bRet;
}
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict";
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict";
( /**
* @param {Window} window
......@@ -1954,6 +1954,9 @@
this.PositionH = (undefined != obj.PositionH ) ? new CImagePositionH(obj.PositionH) : undefined;
this.PositionV = (undefined != obj.PositionV ) ? new CImagePositionV(obj.PositionV) : undefined;
this.SizeRelH = (undefined != obj.SizeRelH) ? new CImagePositionH(obj.SizeRelH) : undefined;
this.SizeRelV = (undefined != obj.SizeRelV) ? new CImagePositionH(obj.SizeRelV) : undefined;
this.Internal_Position = (undefined != obj.Internal_Position) ? obj.Internal_Position : null;
this.ImageUrl = (undefined != obj.ImageUrl) ? obj.ImageUrl : null;
......@@ -1982,6 +1985,10 @@
this.Position = undefined;
this.PositionH = undefined;
this.PositionV = undefined;
this.SizeRelH = undefined;
this.SizeRelV = undefined;
this.Internal_Position = null;
this.ImageUrl = null;
this.Locked = false;
......@@ -2027,6 +2034,27 @@
asc_putPositionH: function(v) { this.PositionH = v; },
asc_getPositionV: function() { return this.PositionV; },
asc_putPositionV: function(v) { this.PositionV = v; },
asc_getSizeRelH: function()
{
return this.SizeRelH;
},
asc_putSizeRelH: function(v)
{
this.SizeRelH = v;
},
asc_getSizeRelV: function()
{
return this.SizeRelV;
},
asc_putSizeRelV: function(v)
{
this.SizeRelV = v;
},
asc_getValue_X: function(RelativeFrom) { if ( null != this.Internal_Position ) return this.Internal_Position.Calculate_X_Value(RelativeFrom); return 0; },
asc_getValue_Y: function(RelativeFrom) { if ( null != this.Internal_Position ) return this.Internal_Position.Calculate_Y_Value(RelativeFrom); return 0; },
......@@ -2134,6 +2162,13 @@
prot["put_PositionH"] = prot["asc_putPositionH"] = prot.asc_putPositionH;
prot["get_PositionV"] = prot["asc_getPositionV"] = prot.asc_getPositionV;
prot["put_PositionV"] = prot["asc_putPositionV"] = prot.asc_putPositionV;
prot["get_SizeRelH"] = prot["asc_getSizeRelH"] = prot.asc_getSizeRelH;
prot["put_SizeRelH"] = prot["asc_putSizeRelH"] = prot.asc_putSizeRelH;
prot["get_SizeRelV"] = prot["asc_getSizeRelV"] = prot.asc_getSizeRelV;
prot["put_SizeRelV"] = prot["asc_putSizeRelV"] = prot.asc_putSizeRelV;
prot["get_Value_X"] = prot["asc_getValue_X"] = prot.asc_getValue_X;
prot["get_Value_Y"] = prot["asc_getValue_Y"] = prot.asc_getValue_Y;
prot["get_ImageUrl"] = prot["asc_getImageUrl"] = prot.asc_getImageUrl;
......
......@@ -4087,6 +4087,10 @@ function ParaDrawing(W, H, GraphicObj, DrawingDocument, DocumentContent, Parent)
B: 0
};
this.SizeRelH = undefined;
this.SizeRelV = undefined;
//{RelativeFrom : c_oAscRelativeFromH.Column, Percent: ST_PositivePercentage}
this.AllowOverlap = true;
//привязка к параграфу
......@@ -4280,6 +4284,26 @@ ParaDrawing.prototype =
Percent : this.PositionV.Percent
};
if(this.SizeRelH)
{
Props.SizeRelH =
{
RelativeFrom: this.SizeRelH.RelativeFrom,
Percent: this.SizeRelH.Percent
};
}
if(this.SizeRelV)
{
Props.SizeRelV =
{
RelativeFrom: this.SizeRelV.RelativeFrom,
Percent: this.SizeRelV.Percent
};
}
Props.Internal_Position = this.Internal_Position;
Props.Locked = this.Lock.Is_Locked();
......@@ -4394,6 +4418,19 @@ ParaDrawing.prototype =
}
},
SetSizeRelH : function(oSize)
{
History.Add(this, {Type: historyitem_Drawing_SetSizeRelH, Old: this.SizeRelH, New: oSize});
this.SizeRelH = oSize;
},
SetSizeRelV : function(oSize)
{
History.Add(this, {Type: historyitem_Drawing_SetSizeRelV, Old: this.SizeRelV, New: oSize});
this.SizeRelV = oSize;
},
getXfrmExtX: function()
{
if(isRealObject(this.GraphicObj) && isRealObject(this.GraphicObj.spPr) && isRealObject(this.GraphicObj.spPr.xfrm))
......@@ -4504,6 +4541,15 @@ ParaDrawing.prototype =
}
}
}
if(undefined != Props.SizeRelH)
{
this.SetSizeRelH({RelativeFrom: Props.SizeRelH.RelativeFrom, Percent: Props.SizeRelH.Percent});
}
if(undefined != Props.SizeRelV)
{
this.SetSizeRelV({RelativeFrom: Props.SizeRelV.RelativeFrom, Percent: Props.SizeRelV.Percent});
}
if(bNeedUpdateWH)
{
this.setExtent(newW, newH);
......@@ -4579,7 +4625,7 @@ ParaDrawing.prototype =
this.Height = 0;
return;
}
if(isRealNumber(this.Extent.W) && isRealNumber(this.Extent.H) && (!this.GraphicObj.checkAutofit || !this.GraphicObj.checkAutofit()))
if(isRealNumber(this.Extent.W) && isRealNumber(this.Extent.H) && (!this.GraphicObj.checkAutofit || !this.GraphicObj.checkAutofit()) && !this.SizeRelH && !this.SizeRelV)
{
this.Width = this.Extent.W;
this.Height = this.Extent.H;
......@@ -5268,7 +5314,6 @@ ParaDrawing.prototype =
{
if(this.GraphicObj.CheckNeedRecalcAutoFit(oSectPr))
{
//this.GraphicObj.recalculate();
if(this.GraphicObj)
{
this.GraphicObj.recalcWrapPolygon && this.GraphicObj.recalcWrapPolygon();
......@@ -5286,6 +5331,16 @@ ParaDrawing.prototype =
switch ( Type )
{
case historyitem_Drawing_SetSizeRelH:
{
this.SizeRelH = Data.Old;
break;
}
case historyitem_Drawing_SetSizeRelV:
{
this.SizeRelV = Data.Old;
break;
}
case historyitem_Drawing_SetEffectExtent:
{
this.EffectExtent.L = Data.OldEE.L;
......@@ -5433,6 +5488,16 @@ ParaDrawing.prototype =
switch ( Type )
{
case historyitem_Drawing_SetSizeRelH:
{
this.SizeRelH = Data.New;
break;
}
case historyitem_Drawing_SetSizeRelV:
{
this.SizeRelV = Data.New;
break;
}
case historyitem_Drawing_SetEffectExtent:
{
this.EffectExtent.L = Data.NewEE.L;
......@@ -5605,6 +5670,22 @@ ParaDrawing.prototype =
}
break;
}
case historyitem_Drawing_SetSizeRelH:
case historyitem_Drawing_SetSizeRelV:
{
if( this.GraphicObj)
{
this.GraphicObj.handleUpdateExtents && this.GraphicObj.handleUpdateExtents();
this.GraphicObj.addToRecalculate();
}
var Run = this.Parent.Get_DrawingObjectRun( this.Id );
if(Run)
{
Run.RecalcInfo.Measure = true;
}
break;
}
case historyitem_Drawing_WrappingType:
{
if(this.GraphicObj)
......@@ -5824,6 +5905,21 @@ ParaDrawing.prototype =
switch ( Type )
{
case historyitem_Drawing_SetSizeRelH:
case historyitem_Drawing_SetSizeRelV:
{
if(Data.New)
{
Writer.WriteBool(true);
Writer.WriteLong(Data.New.RelativeFrom);
Writer.WriteDouble(Data.New.Percent);
}
else
{
Writer.WriteBool(false);
}
break;
}
case historyitem_Drawing_SetEffectExtent:
{
writeDouble(Writer, Data.NewEE.L);
......@@ -6003,6 +6099,34 @@ ParaDrawing.prototype =
switch ( Type )
{
case historyitem_Drawing_SetSizeRelH:
{
if(Reader.GetBool())
{
this.SizeRelH = {};
this.SizeRelH.RelativeFrom = Reader.GetLong();
this.SizeRelH.Percent = Reader.GetDouble();
}
else
{
this.SizeRelH = undefined;
}
break;
}
case historyitem_Drawing_SetSizeRelV:
{
if(Reader.GetBool())
{
this.SizeRelV = {};
this.SizeRelV.RelativeFrom = Reader.GetLong();
this.SizeRelV.Percent = Reader.GetDouble();
}
else
{
this.SizeRelV = undefined;
}
break;
}
case historyitem_Drawing_SetEffectExtent:
{
this.EffectExtent.L = readDouble(Reader);
......
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