Skip to content

Commit

Permalink
Release/v7.2.0 (#2819)
Browse files Browse the repository at this point in the history
* [bug] fix presentation file build when it was opened on client

* fix presentations opening

* fix saving groups

* [se] Fix bug 57275

* fix some issues in saving on client:
* fix losing notes for slides after first slide;
* fix writing rels of blips which have link to the same image
* fix writing src rect

* [de] Fix matrix insertion

* Fix minimixation bug

* Fix minimixation bug

* [bug] fix bug 57508

* Fix imports for preview drawer (#2817)

* [all] Fix export for openXml, StaxParser

* Feature/mobile (#2818)

* Developing

* Fix for native

* Developing

* Fix draw text

* .

* Fix strikeout/underline in text with rotate direction

Co-authored-by: Sergey Luzyanin <[email protected]>
Co-authored-by: GoshaZotov <[email protected]>
Co-authored-by: Sergey Konovalov <[email protected]>
Co-authored-by: Vladimir Privezenov <[email protected]>
  • Loading branch information
5 people committed Jun 8, 2022
1 parent d3da8cc commit 4d7ec06
Show file tree
Hide file tree
Showing 46 changed files with 369 additions and 706 deletions.
1 change: 1 addition & 0 deletions cell/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,7 @@ var editor;
}

var openXml = AscCommon.openXml;
var StaxParser = AscCommon.StaxParser;
var pivotCaches = {};
var xmlParserContext = new AscCommon.XmlParserContext();
xmlParserContext.DrawingDocument = this.wbModel.DrawingDocument;
Expand Down
97 changes: 29 additions & 68 deletions cell/graphics/DrawingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,33 +384,6 @@
NativeContext.prototype.getImageData = function (sx,sy,sw,sh) {};
NativeContext.prototype.putImageData = function (image_data,dx,dy,dirtyX,dirtyY,dirtyWidth,dirtyHeight) {};

function NativeFontManager() {
this.m_lUnits_Per_Em = 0;
this.m_lAscender = 0;
this.m_lDescender = 0;
this.m_lLineHeight = 0;
}

NativeFontManager.prototype.init = function (fontInfo) {
this.m_lUnits_Per_Em = fontInfo[3];
this.m_lAscender = fontInfo[0];
this.m_lDescender = fontInfo[2];
this.m_lLineHeight = fontInfo[2];
};
NativeFontManager.prototype.MeasureChar = function (lUnicode) {
var bounds = g_oTextMeasurer.Measurer["GetDrawingBox"](lUnicode);
return {
fAdvanceX: bounds[0], oBBox: {
fMinX: bounds[1], fMaxX: bounds[2], fMinY: bounds[3], fMaxY: bounds[4]
}
};
};
NativeFontManager.prototype.SetTextMatrix = function (fA, fB, fC, fD, fE, fF) {
window["native"]["PD_transform"](fA, fB, fC, fD, fE, fF);
};



/**
* Emulates scalable canvas context
* -----------------------------------------------------------------------------
Expand Down Expand Up @@ -447,9 +420,6 @@
this.changeUnits(undefined !== settings.units ? settings.units : this.units);

this.fmgrGraphics = undefined !== settings.fmgrGraphics ? settings.fmgrGraphics : null;
if (window["IS_NATIVE_EDITOR"]) {
this.fmgrGraphics = [new NativeFontManager(), new NativeFontManager(), new NativeFontManager(), new NativeFontManager()];
}

if (null === this.fmgrGraphics) {
throw "Can not set graphics in DrawingContext";
Expand Down Expand Up @@ -876,24 +846,25 @@
res.descender = factor * d;
res.lineGap = factor * (fm.m_lLineHeight - fm.m_lAscender - d);

var face;
if (window["IS_NATIVE_EDITOR"]) {
face = g_oTextMeasurer.Measurer['GetFace']();
res.nat_scale = face[0];
res.nat_y1 = face[1];
res.nat_y2 = face[2];
} else {
var faceMetrics = fm.m_pFont.cellGetMetrics();
res.nat_scale = faceMetrics[0];
res.nat_y1 = faceMetrics[1];
res.nat_y2 = faceMetrics[2];
}
var faceMetrics = fm.m_pFont.cellGetMetrics();
res.nat_scale = faceMetrics[0];
res.nat_y1 = faceMetrics[1];
res.nat_y2 = faceMetrics[2];

res.nat_y1 *= r2;
res.nat_y2 *= r2;
return res;
};

DrawingContext.prototype.nativeTextDecorationTransform = function(isStart)
{
// текст рисуется с трансформом, а strikeout/underline - без (матрица применяется ДО отрисовщика)
if (isStart)
window["native"]["PD_transform"](this._im.sx, this._im.shy, this._im.shx, this._im.sy, this._im.tx, this._im.ty);
else
window["native"]["PD_transform"](this._mt.sx, this._mt.shy, this._mt.shx, this._mt.sy, this._mt.tx, this._mt.ty);
};

/**
*
* @param font
Expand All @@ -905,14 +876,6 @@
var r;
this.font.assign(font);

if (window["IS_NATIVE_EDITOR"]) {
this.font.fs = this.font.getSize() * this.scaleFactor * 96.0 / 25.4;
// this.font.fs = this.font.getSize() * 2.54 * this.scaleFactor * this.deviceDPI / 72.0;

// this.font.fs = this.font.getSize() * 2.54 * this.scaleFactor *
// this.deviceScale * this.deviceDPI / 96.0 * (96.0 / (this.deviceDPI * this.deviceScale));
}

var italic = this.font.getItalic();
var bold = this.font.getBold();
var fontStyle;
Expand All @@ -928,7 +891,7 @@

if (window["IS_NATIVE_EDITOR"]) {
var fontInfo = AscFonts.g_fontApplication.GetFontInfo(this.font.getName(), fontStyle, this.LastFontOriginInfo);
fontInfo = GetLoadInfoForMeasurer(fontInfo, fontStyle);
fontInfo = AscCommon.GetLoadInfoForMeasurer(fontInfo, fontStyle);

var flag = 0;
if (fontInfo.NeedBold) {
Expand All @@ -944,18 +907,19 @@
flag |= 0x08;
}

if (!angle) {
window["native"]["PD_LoadFont"](fontInfo.Path, fontInfo.FaceIndex, this.font.getSize(), flag);
}
AscCommon.g_oTextMeasurer.Flush();
fontInfo = g_oTextMeasurer.Measurer["LoadFont"](fontInfo.Path, fontInfo.FaceIndex, this.font.getSize(), flag);
if (angle) {
this.fmgrGraphics[1].init(fontInfo);
} else {
this.fmgrGraphics[0].init(fontInfo);
this.fmgrGraphics[3].init(fontInfo);
}
r = true;
// выставляем шрифт и отрисовщику...
var drawFontSize = this.font.getSize() * this.scaleFactor * 96.0 / 25.4;
window["native"]["PD_LoadFont"](fontInfo.Path, fontInfo.FaceIndex, drawFontSize, flag);

// на отрисовке ячейки трансформ выставляется/сбрасывается. так что тут - только если есть angle
if (angle)
window["native"]["PD_transform"](this._mt.sx, this._mt.shy, this._mt.shx, this._mt.sy, this._mt.tx, this._mt.ty);

// ...и измерятелю
AscFonts.g_fontApplication.LoadFont(this.font.getName(), AscCommon.g_font_loader, this.fmgrGraphics[3],
this.font.getSize(), fontStyle, this.ppiX, this.ppiY);

return this;
} else {
if (angle) {
r = AscFonts.g_fontApplication.LoadFont(this.font.getName(), AscCommon.g_font_loader, this.fmgrGraphics[1],
Expand Down Expand Up @@ -1042,12 +1006,9 @@
// Replace Non-breaking space(0xA0) with White-space(0x20)
code = 0xA0 === code ? 0x20 : code;
if (window["IS_NATIVE_EDITOR"]) {
//TODO: cache
// if (null != this.LastFontOriginInfo.Replace)
// code = g_fontApplication.GetReplaceGlyph(code, this.LastFontOriginInfo.Replace);

window["native"]["PD_FillText"](_x, _y, code);
_x += Asc.round(g_oTextMeasurer.Measurer["MeasureChar"](code));
// убрать это!!! все сдвиги ДОЛЖНЫ быть вщять из измерятеля/шейпера
_x += asc_round((this.measureChar(undefined, 3, code).width) * this.scaleFactor * 96.0 / 25.4);
} else {
_x = asc_round(manager.LoadString4C(code, _x, _y));
pGlyph = manager.m_oGlyphString.m_pGlyphsBuffer[0];
Expand Down
18 changes: 7 additions & 11 deletions cell/model/DataValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1484,24 +1484,20 @@

CDataValidations.prototype._containRanges = function (_ranges1, _ranges2) {
//проверка на то, что диапазон второго range входит в дипапазон первого
var res = false;
if (_ranges1 && _ranges2 && _ranges1.length && _ranges2.length) {
for (var j = 0; j < _ranges1.length; j++) {
var _contains = false;
for (var n = 0; n < _ranges2.length; n++) {
if (_ranges1[j].containsRange(_ranges2[n])) {
_contains = true;
break;
}
}
if (!_contains) {
return false;
//проверяем, вошёл ли целиком массив диапазонов второго в один из первых
if (_ranges1[j].containsRanges(_ranges2)) {
res = true;
break;
}
}
} else {
return false;
res = false;
}

return true;
return res;
};

CDataValidations.prototype.clear = function (ws, ranges, addToHistory) {
Expand Down
5 changes: 2 additions & 3 deletions cell/model/DrawingObjects/Format/ShapePrototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var CShape = AscFormat.CShape;

var History = AscCommon.History;

var G_O_DEFAULT_COLOR_MAP = AscFormat.GenerateDefaultColorMap();


CShape.prototype.getEditorType = function()
{
Expand Down Expand Up @@ -837,7 +837,7 @@ CShape.prototype.recalculateContent = function()

CShape.prototype.Get_ColorMap = function()
{
return G_O_DEFAULT_COLOR_MAP;
return AscFormat.DEFAULT_COLOR_MAP;
};

CShape.prototype.getStyles = function(index)
Expand Down Expand Up @@ -895,6 +895,5 @@ AscFormat.CTextBody.prototype.getDrawingDocument = function()

//------------------------------------------------------------export----------------------------------------------------
window['AscFormat'] = window['AscFormat'] || {};
window['AscFormat'].G_O_DEFAULT_COLOR_MAP = G_O_DEFAULT_COLOR_MAP;
window['AscFormat'].addToDrawings = addToDrawings;
})(window);
20 changes: 10 additions & 10 deletions cell/model/Serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -7417,10 +7417,10 @@
if ( c_oSer_PivotTypes.id == type ) {
pivotCache.id = this.stream.GetLong();
} else if ( c_oSer_PivotTypes.cache == type ) {
new openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), pivotCache);
new AscCommon.openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), pivotCache);
} else if ( c_oSer_PivotTypes.record == type ) {
var cacheRecords = new Asc.CT_PivotCacheRecords();
new openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), cacheRecords);
new AscCommon.openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), cacheRecords);
pivotCache.cacheRecords = cacheRecords;
} else
res = c_oSerConstants.ReadUnknown;
Expand Down Expand Up @@ -8010,7 +8010,7 @@
data.cacheId = this.stream.GetLong();
} else if (c_oSer_PivotTypes.table == type) {
data.table = new Asc.CT_pivotTableDefinition(true);
new openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), data.table);
new AscCommon.openXml.SaxParserBase().parse(AscCommon.GetStringUtf8(this.stream, length), data.table);
} else
res = c_oSerConstants.ReadUnknown;
return res;
Expand Down Expand Up @@ -10372,7 +10372,7 @@
newContext.readAttributes(attr, uq);
}
this.CustomStyles[newContext.name] = newContext;
openXml.SaxParserDataTransfer.curTableStyle = newContext;
AscCommon.openXml.SaxParserDataTransfer.curTableStyle = newContext;
} else {
newContext = null;
}
Expand Down Expand Up @@ -10631,7 +10631,7 @@
var val;
val = vals["type"];
if(undefined !== val){
var tableStyle = openXml.SaxParserDataTransfer.curTableStyle;
var tableStyle = AscCommon.openXml.SaxParserDataTransfer.curTableStyle;
if("wholeTable"===val)
tableStyle.wholeTable = this;
else if("headerRow"===val)
Expand Down Expand Up @@ -10695,7 +10695,7 @@
}
val = vals["dxfId"];
if (undefined !== val) {
this.dxf = openXml.SaxParserDataTransfer.dxfs[tableStyle.pivot ? val - 0 : val - 1] || null;
this.dxf = AscCommon.openXml.SaxParserDataTransfer.dxfs[tableStyle.pivot ? val - 0 : val - 1] || null;
}
}
};
Expand All @@ -10715,7 +10715,7 @@
var content = jsZipWrapper.files["presetTableStyles.xml"].sync("string");
jsZipWrapper.close();
var stylesXml = new CT_PresetTableStyles(wb.TableStyles.DefaultStyles, wb.TableStyles.DefaultStylesPivot);
new openXml.SaxParserBase().parse(content, stylesXml);
new AscCommon.openXml.SaxParserBase().parse(content, stylesXml);
wb.TableStyles.concatStyles();
}
}
Expand Down Expand Up @@ -10962,7 +10962,7 @@
}
this.fonts.push(newContext);
} else if ("fills" === elem) {
openXml.SaxParserDataTransfer.priorityBg = false;
AscCommon.openXml.SaxParserDataTransfer.priorityBg = false;
} else if ("fill" === elem) {
newContext = new AscCommonExcel.Fill();
if (newContext.readAttributes) {
Expand Down Expand Up @@ -10996,8 +10996,8 @@
// }
// this.cellStyles = newContext;
} else if ("dxfs" === elem) {
openXml.SaxParserDataTransfer.dxfs = this.dxfs;
openXml.SaxParserDataTransfer.priorityBg = true;
AscCommon.openXml.SaxParserDataTransfer.dxfs = this.dxfs;
AscCommon.openXml.SaxParserDataTransfer.priorityBg = true;
} else if ("dxf" === elem) {
newContext = new CT_Dxf();
if (newContext.readAttributes) {
Expand Down
2 changes: 1 addition & 1 deletion cell/model/SerializeXml.js
Original file line number Diff line number Diff line change
Expand Up @@ -2683,7 +2683,7 @@
let oRel = reader.rels.getRelationship(context.InitOpenManager.legacyDrawingId);
let oRelPart = reader.rels.pkg.getPartByUri(oRel.targetFullName);
let oContent = oRelPart.getDocumentContent();
let oReader = new StaxParser(oContent, oRelPart, reader.context);
let oReader = new AscCommon.StaxParser(oContent, oRelPart, reader.context);
let oElement = new AscFormat.CVMLDrawing();
if (oElement) {
oElement.fromXml(oReader, true);
Expand Down
8 changes: 2 additions & 6 deletions cell/native/Graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ CGraphics.prototype =
oFontStyle = AscFonts.FontStyle.FontStyleBoldItalic;

var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(font.FontFamily.Name, oFontStyle, this.LastFontOriginInfo);
var _info = GetLoadInfoForMeasurer(_fontinfo, oFontStyle);
var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, oFontStyle);

this.m_oLastFont.SetUpName = font.FontFamily.Name;
this.m_oLastFont.SetUpSize = font.FontSize;
Expand All @@ -801,8 +801,6 @@ CGraphics.prototype =
if (_info.SrcBold) flag |= 0x04;
if (_info.SrcItalic) flag |= 0x08;

g_oTextMeasurer.Measurer["LoadFont"](_info.Path, _info.FaceIndex, font.FontSize, flag);

this.Native["PD_LoadFont"](_info.Path, _info.FaceIndex, font.FontSize, flag);
},

Expand Down Expand Up @@ -875,16 +873,14 @@ CGraphics.prototype =
_lastFont.SetUpStyle = _style;

var _fontinfo = AscFonts.g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo);
var _info = GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle);
var _info = AscCommon.GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle);

var flag = 0;
if (_info.NeedBold) flag |= 0x01;
if (_info.NeedItalic) flag |= 0x02;
if (_info.SrcBold) flag |= 0x04;
if (_info.SrcItalic) flag |= 0x08;

g_oTextMeasurer.Measurer["LoadFont"](_info.Path, _info.FaceIndex, _lastFont.SetUpSize, flag);

this.Native["PD_LoadFont"](_info.Path, _info.FaceIndex, _lastFont.SetUpSize, flag);
}
},
Expand Down
Loading

0 comments on commit 4d7ec06

Please sign in to comment.