Skip to content

Commit

Permalink
Merge branch 'feature/draw' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
konovalovsergey committed Nov 30, 2024
2 parents 80d2343 + 330758b commit 2fc3135
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 91 deletions.
20 changes: 20 additions & 0 deletions common/Drawings/Format/Format.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@
CBaseNoIdObject.call(this);

this.embellishment = null;
/**
* @type {CVarStyle[]}
*/
this.varStyle = [];
}
InitClass(CVariationStyleScheme, CBaseNoIdObject, 0);
Expand Down Expand Up @@ -9801,6 +9804,18 @@
CTheme.prototype.Read_FromBinary2 = function (r) {
this.Id = r.GetString2();
};

/**
* @memberOf CTheme
* @return {boolean}
*/
CTheme.prototype.isVariationClrSchemeLstExists = function() {
let clrScheme = this.themeElements.clrScheme;
let variationClrSchemeLst = clrScheme && clrScheme.clrSchemeExtLst
&& clrScheme.clrSchemeExtLst.variationClrSchemeLst;
return variationClrSchemeLst.length > 0;
}

/**
* @memberOf CTheme
* @param variationIndex
Expand All @@ -9823,6 +9838,11 @@
}
return null;
};
/**
* @param variationIndex
* @param styleIndex
* @return {CVarStyle|null}
*/
CTheme.prototype.getVariationStyleScheme = function (variationIndex, styleIndex) {
let themeExt = this.themeElements.themeExt;
if (themeExt && themeExt.variationStyleSchemeLst[variationIndex]) {
Expand Down
14 changes: 13 additions & 1 deletion common/editorscommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -14780,7 +14780,19 @@
registerServiceWorker();

function consoleLog(val) {
//console.log(val);
// console.log(val);
const showMessages = false;

if (!showMessages) {
return;
}

// see v8 arguments leak - performance loss
// console.log.apply(console, arguments);

for (let i = 0; i < arguments.length; i++) {
console.log(arguments[i]);
}
}

//------------------------------------------------------------export---------------------------------------------------
Expand Down
19 changes: 10 additions & 9 deletions draw/model/VisioDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,18 +375,19 @@
let aFonts = this.loadedFonts;
// load Arial by default
aFonts.push(new AscFonts.CFont("Arial", 0, "", 0));
let newFontIndex = 1;
aFonts.push(new AscFonts.CFont("Calibri", 1, "", 0));
let newFontStartIndex = 2;
this.faceNames.forEach(function (faceName_Type) {
let nameU = faceName_Type.nameU;
aFonts.push(new AscFonts.CFont(nameU, newFontStartIndex, "", 0));
newFontStartIndex += 1;
let fontInfo = api.FontLoader.fontInfos.find(function(cFontInfo) {
return cFontInfo.Name === nameU;
});
if (fontInfo === undefined || fontInfo === null) {
console.log("Unknown font used in visio file: " + nameU);
AscCommon.consoleLog("Unknown font used in visio file: " + nameU);
} else {
console.log("Font", nameU, "will be loaded");
aFonts.push(new AscFonts.CFont(nameU, newFontIndex, "", 0));
newFontIndex += 1;
AscCommon.consoleLog("Font" + nameU + "will be loaded");
}
});

Expand Down Expand Up @@ -1030,7 +1031,7 @@
// if masterNumber is number
mastersSort[masterNumber - 1] = masters[i];
} else {
console.log('check sdkjs/draw/model/VisioDocument.js : parseMasters');
AscCommon.consoleLog('check sdkjs/draw/model/VisioDocument.js : parseMasters');
mastersSort = masters;
break;
}
Expand Down Expand Up @@ -1067,7 +1068,7 @@
// if masterNumber is number
pagesSort[pageNumber - 1] = pages[i];
} else {
console.log('check sdkjs/draw/model/VisioDocument.js : parsePages');
AscCommon.consoleLog('check sdkjs/draw/model/VisioDocument.js : parsePages');
pagesSort = pages;
break;
}
Expand Down Expand Up @@ -1096,7 +1097,7 @@
// if themeNumber is number
themesSort[themeNumber - 1] = themeParts[i];
} else {
console.log('check sdkjs/draw/model/VisioDocument.js : parseThemes');
AscCommon.consoleLog('check sdkjs/draw/model/VisioDocument.js : parseThemes');
themesSort = themeParts;
break;
}
Expand Down Expand Up @@ -1184,7 +1185,7 @@
// if masterNumber is number
solutionsSort[solutionNumber - 1] = solutions[i];
} else {
console.log('check sdkjs/draw/model/VisioDocument.js : parseSolutions');
AscCommon.consoleLog('check sdkjs/draw/model/VisioDocument.js : parseSolutions');
solutionsSort = solutions;
break;
}
Expand Down
56 changes: 28 additions & 28 deletions draw/model/ooxmlApi/convertFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@

// let fillPattern = shape.getCellNumberValue("FillPattern");
// if (fillPattern !== 0) {
// console.log("TextQuickStyleVariation for shapes with FillPattern !== 0 is disabled");
// AscCommon.consoleLog("TextQuickStyleVariation for shapes with FillPattern !== 0 is disabled");
// // consider example https://disk.yandex.ru/d/2fbgXRrCBThlCw
// return;
// }
Expand Down Expand Up @@ -263,7 +263,7 @@
*/
function parseParagraphAndAddToShapeContent(propsRowNum, paragraphPropsCommon, textCShape) {
if (paragraphPropsCommon === null) {
console.log("paragraphPropsCommon is null. Creating default paragraph");
AscCommon.consoleLog("paragraphPropsCommon is null. Creating default paragraph");
// create new paragraph to hold new properties
let oContent = textCShape.getDocContent();
let paragraph = new Paragraph(textCShape.getDrawingDocument(), true);
Expand Down Expand Up @@ -308,10 +308,10 @@
break;
}
} else {
console.log("horizontal align was not parsed so default is set (left)");
AscCommon.consoleLog("horizontal align was not parsed so default is set (left)");
}
} else {
console.log("horizontal align cell was not found so default is set (left)");
AscCommon.consoleLog("horizontal align cell was not found so default is set (left)");
}


Expand Down Expand Up @@ -389,7 +389,7 @@
fontColor = characterColorCell.calculateValue(shape, pageInfo,
visioDocument.themes, themeValWasUsedFor);
} else {
console.log("text color cell not found! set text color as themed");
AscCommon.consoleLog.log("text color cell not found! set text color as themed");
fontColor = AscCommonDraw.themeval(null, shape, pageInfo, visioDocument.themes, "TextColor");
themeValWasUsedFor.fontColor = true;
}
Expand All @@ -411,10 +411,10 @@
if (!isNaN(fontSizeIn)) {
fontSizePt = fontSizeIn * 72; // convert from in to pt
} else {
console.log("font size was not parsed so default is set (9 pt)");
AscCommon.consoleLog("font size was not parsed so default is set (9 pt)");
}
} else {
console.log("font size was not found so default is set (9 pt)");
AscCommon.consoleLog("font size was not found so default is set (9 pt)");
}
oRun.SetFontSize(fontSizePt);

Expand Down Expand Up @@ -443,21 +443,21 @@
cRFonts.CS = {Name: fontName, Index: -1};
cRFonts.EastAsia = {Name: fontName, Index: -1};
} else {
console.log("Font was not found for Run. So default is set (Calibri).");
AscCommon.consoleLog("Font was not found for Run. So default is set (Calibri).");
}
} else {
console.log("Font themed is unhandeled, Calibri is used.");
AscCommon.consoleLog("Font themed is unhandeled, Calibri is used.");
}
} else {
console.log("fontCell was not found so default is set (Calibri). Check mb AsianFont or ScriptFont");
AscCommon.consoleLog("fontCell was not found so default is set (Calibri). Check mb AsianFont or ScriptFont");
}
oRun.Set_RFonts(cRFonts);


// handle style (bold italic underline small caps)
const styleVsdx = characterPropsFinal && characterPropsFinal.getCellStringValue("Style");
if (styleVsdx === "Themed") {
console.log("Themed style text is unhandled");
AscCommon.consoleLog("Themed style text is unhandled");
} else {
oRun.Pr.Bold = Boolean(Number(styleVsdx) & 1);
oRun.Pr.Italic = Boolean(Number(styleVsdx) & 2);
Expand Down Expand Up @@ -778,7 +778,7 @@
} else if (textElementPart.kind === AscCommonDraw.c_oVsdxTextKind.TP) {
propsTP = textElementPart;
} else {
console.log("undkown type in text tag");
AscCommon.consoleLog("undkown type in text tag");
}
});

Expand Down Expand Up @@ -820,10 +820,10 @@
}
// else leave center align
} else {
console.log("vertical align cell was not parsed for shape. align set to center. Shape:", shape);
AscCommon.consoleLog("vertical align cell was not parsed for shape. align set to center. Shape:", shape);
}
} else {
console.log("vertical align cell was not found for shape. align set to center. Shape:", shape);
AscCommon.consoleLog("vertical align cell was not found for shape. align set to center. Shape:", shape);
}


Expand Down Expand Up @@ -1186,7 +1186,7 @@
endArrow.len = arrowSize + sizeEnumVsdxShift;
endArrow.w = arrowSize + sizeEnumVsdxShift;
} else {
console.log("arrowSize unknown:", arrowSize);
AscCommon.consoleLog("arrowSize unknown:", arrowSize);
endArrow.len = AscFormat.LineEndSize.vsdxMedium;
endArrow.w = AscFormat.LineEndSize.vsdxMedium;
}
Expand Down Expand Up @@ -1223,7 +1223,7 @@
// also check for {}, undefined, NaN, null
if (isNaN(pinX_inch) || pinX_inch === null || isNaN(pinY_inch) || pinY_inch === null ||
areShapeLayersInvisible) {
// console.log('pinX_inch or pinY_inch is NaN for Shape or areShapeLayersInvisible. Its ok sometimes. ' +
// AscCommon.consoleLog('pinX_inch or pinY_inch is NaN for Shape or areShapeLayersInvisible. Its ok sometimes. ' +
// 'Empty CShape is returned. See original shape: ', this);
// let's use empty shape
let emptyCShape = new AscFormat.CShape();
Expand Down Expand Up @@ -1377,7 +1377,7 @@
} else {
let fillForegndCell = this.getCell("FillForegnd");
if (fillForegndCell) {
// console.log("FillForegnd was found:", fillForegndCell);
// AscCommon.consoleLog("FillForegnd was found:", fillForegndCell);
uniFillForegnd = fillForegndCell.calculateValue(this, pageInfo,
visioDocument.themes, themeValWasUsedFor, gradientEnabled);

Expand All @@ -1391,15 +1391,15 @@
fillObj.color.color.RGBA.A = fillObj.color.color.RGBA.A * (1 - fillForegndTransValue);
}
} else {
console.log("fillForegndTrans value is themed or something. Not calculated for", this);
AscCommon.consoleLog("fillForegndTrans value is themed or something. Not calculated for", this);
}
}
}


let fillBkgndCell = this.getCell("FillBkgnd");
if (fillBkgndCell) {
// console.log("FillBkgnd was found:", fillBkgndCell);
// AscCommon.consoleLog("FillBkgnd was found:", fillBkgndCell);
uniFillBkgnd = fillBkgndCell.calculateValue(this, pageInfo,
visioDocument.themes, themeValWasUsedFor);

Expand All @@ -1413,17 +1413,17 @@
fillObj.color.color.RGBA.A = fillObj.color.color.RGBA.A * (1 - fillBkgndTransValue);
}
} else {
// console.log("fillBkgndTrans value is themed or something. Not calculated for", this);
// AscCommon.consoleLog("fillBkgndTrans value is themed or something. Not calculated for", this);
}
}

let lineColorCell = this.getCell("LineColor");
if (lineColorCell) {
// console.log("LineColor was found for shape", lineColorCell);
// AscCommon.consoleLog("LineColor was found for shape", lineColorCell);
lineUniFill = lineColorCell.calculateValue(this, pageInfo,
visioDocument.themes, themeValWasUsedFor);
} else {
console.log("LineColor cell for line stroke (border) was not found painting red");
AscCommon.consoleLog("LineColor cell for line stroke (border) was not found painting red");
lineUniFill = AscFormat.CreateUnfilFromRGB(255,0,0);
}

Expand All @@ -1440,12 +1440,12 @@
if (!isNaN(lineWeightInches)) {
lineWidthEmu = lineWeightInches * AscCommonWord.g_dKoef_in_to_mm * AscCommonWord.g_dKoef_mm_to_emu;
} else {
console.log("caught unknown error. line will be painted 9525 emus");
AscCommon.consoleLog("caught unknown error. line will be painted 9525 emus");
// 9255 emus = 0.01041666666666667 inches is document.xml StyleSheet ID=0 LineWeight e. g. default value
lineWidthEmu = 9525;
}
} else {
console.log("LineWeight cell was not calculated. line will be painted 9525 emus");
AscCommon.consoleLog("LineWeight cell was not calculated. line will be painted 9525 emus");
lineWidthEmu = 9525;
}

Expand Down Expand Up @@ -1559,7 +1559,7 @@
case 24:
return AscCommon.global_hatch_offsets.pct50;
default:
console.log("patten fill unhandled");
AscCommon.consoleLog("patten fill unhandled");
return AscCommon.global_hatch_offsets.cross;
}
}
Expand All @@ -1576,7 +1576,7 @@
} else if (uniFillForegnd) {
uniFillForegndWithPattern = uniFillForegnd;
} else {
console.log("FillForegnd not found for shape", this);
AscCommon.consoleLog("FillForegnd not found for shape", this);
uniFillForegndWithPattern = AscFormat.CreateNoFillUniFill();
}

Expand Down Expand Up @@ -1619,7 +1619,7 @@
}

if (this.type === "Foreign") {
// console.log("Shape has type Foreign and may not be displayed. " +
// AscCommon.consoleLog("Shape has type Foreign and may not be displayed. " +
// "Check shape.elements --> ForeignData_Type obj. See shape:", this);

let foreignDataObject = this.getForeignDataObject();
Expand All @@ -1643,7 +1643,7 @@

cShape = this.cImageShape;
} else {
console.log("Unknown error: cImageShape was not initialized on ooxml parse");
AscCommon.consoleLog("Unknown error: cImageShape was not initialized on ooxml parse");
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions draw/model/ooxmlApi/get-geometry-from-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
let noShowCell = geometrySection.getCell("NoShow");

if (noShowCell === null || noShowCell === undefined) {
console.log("noShowCell variable is null or undefined see shape: ", shape);
AscCommon.consoleLog("noShowCell variable is null or undefined see shape: ", shape);
continue;
}
if (Number(noShowCell.v) === 1) {
Expand Down Expand Up @@ -392,8 +392,8 @@
// let a = Math.sqrt(rX1*rX1*b*b/(b*b-rY1*rY1));
// it is not useful I guess bcs ellipse is rotated so we need another equation

// console.log('For ellipse with relative center (', cx, ', ', cy, ')');
// console.log('point 1: (', x1, ', ', y1, '), point 2: (', x2, ', ', y2, ')');
// AscCommon.consoleLog('For ellipse with relative center (', cx, ', ', cy, ')');
// AscCommon.consoleLog('point 1: (', x1, ', ', y1, '), point 2: (', x2, ', ', y2, ')');

let rx = Math.hypot(x1 - cx, y1 - cy);
let ry = Math.hypot(x2 - cx, y2 - cy);
Expand Down Expand Up @@ -423,7 +423,7 @@

let wRhR = transformEllipseParams(newX, newY, newA, newB, newC, newD);
if (!wRhR) {
console.log('Ellipse command for rotated ellipse is not yet realized');
AscCommon.consoleLog('Ellipse command for rotated ellipse is not yet realized');
}
// start to draw from ellipse right point

Expand Down Expand Up @@ -466,7 +466,7 @@
// ellipticalArcTo could catch cases line these but
// there inaccuracy comes
path.lnTo(newX, newY);
console.log("tranform ellipticalArcTo to line",
AscCommon.consoleLog("tranform ellipticalArcTo to line",
newX, newY, controlPoint.x, controlPoint.y, 0, 1);
// path.ellipticalArcTo(newX, newY, controlPoint.x, controlPoint.y, 0, 1);
} else {
Expand Down Expand Up @@ -660,7 +660,7 @@
path.lnTo(maxValue, yNew);
} else {
// visio doesnt draw diagonal infinite lines
console.log("visio doesnt draw diagonal infinite lines");
AscCommon.consoleLog("visio doesnt draw diagonal infinite lines");
}
// don't set last point here bcs it is always the only one element in geometry
break;
Expand Down
Loading

0 comments on commit 2fc3135

Please sign in to comment.