Accept Merge Request #158: (hyc -> master)

Merge Request: 【修改】excel,word,ps考点

Created By: @华允传
Accepted By: @华允传
URL: https://g-iswv8783.coding.net/p/education/d/pengchen-exam-java/git/merge/158?initial=true
This commit is contained in:
华允传
2025-08-26 23:22:00 +08:00
committed by Coding
6 changed files with 260 additions and 301 deletions

View File

@@ -102,11 +102,19 @@ public class XlsxMaster {
String value = (String) methodWithArgs.invoke(excelFunctions, poiCell, workbook);
if (value != null) {
judgementXlsxVOS = setJudgementXlsx(
judgementXlsxVOS,
""+sheetName+""+docxFunction +"@"+cellRef+ "@" + value,
""+sheetName+""+firstName +""+cellRef+""+ examName + value
);
if ("getCellDataFormat".equals(function)){
judgementXlsxVOS = setJudgementXlsx(
judgementXlsxVOS,
""+sheetName+""+docxFunction +"@"+cellRef+ "@" + value,
""+sheetName+""+firstName +""+cellRef+""+ examName + ""
);
}else {
judgementXlsxVOS = setJudgementXlsx(
judgementXlsxVOS,
""+sheetName+""+docxFunction +"@"+cellRef+ "@" + value,
""+sheetName+""+firstName +""+cellRef+""+ examName + value
);
}
}
}
}
@@ -129,11 +137,19 @@ public class XlsxMaster {
// for (String cellRef : cellRefs) {
String value = (String) methodWithArgs.invoke(rangingFunctions, rangeStr, workbook,sheetNum);
if (value != null) {
judgementXlsxVOS = setJudgementXlsx(
judgementXlsxVOS,
"" + sheetName + "" + docxFunction + "@" + rangeStr + "@" + value,
"" + sheetName + "" + firstName + "" + rangeStr + "" + examName + value
);
if ("printCellFormatNumStyle".equals(function)){
judgementXlsxVOS = setJudgementXlsx(
judgementXlsxVOS,
""+sheetName+""+docxFunction +"@"+rangeStr+ "@" + value,
""+sheetName+""+firstName +""+rangeStr+""+ examName + ""
);
}else {
judgementXlsxVOS = setJudgementXlsx(
judgementXlsxVOS,
""+sheetName+""+docxFunction +"@"+rangeStr+ "@" + value,
""+sheetName+""+firstName +""+rangeStr+""+ examName + value
);
}
}
// }
}

View File

@@ -329,65 +329,24 @@ public class ChartHandler {
return "未找到图表位置";
}
/** 图表-设计 - 图表样式 */
/** 图表-设计 - 图表样式*\
public String getChartStyle(XSSFChart chart, XSSFSheet sheet) {
if (chart == null) return "无图表";
try {
Node chartNode = chart.getCTChartSpace().getDomNode();
// 先尝试取 c14:style
NodeList c14StyleNodes = ((Element) chartNode)
.getElementsByTagNameNS("http://schemas.microsoft.com/office/drawing/2007/8/2/chart", "style");
if (c14StyleNodes.getLength() > 0) {
String val = ((Element) c14StyleNodes.item(0)).getAttribute("val");
int styleId = Integer.parseInt(val);
// 映射 101114 → 114
if (styleId >= 101 && styleId <= 114) {
styleId -= 100;
}
return "样式" + styleId;
}
// 再尝试取 c:style
NodeList cStyleNodes = ((Element) chartNode)
.getElementsByTagNameNS("http://schemas.openxmlformats.org/drawingml/2006/chart", "style");
if (cStyleNodes.getLength() > 0) {
String val = ((Element) cStyleNodes.item(0)).getAttribute("val");
int styleId = Integer.parseInt(val);
return "样式" + styleId;
}
return "未定义样式";
} catch (Exception e) {
e.printStackTrace();
return "解析图表样式时出错: " + e.getMessage();
}
}
/**
* 打印图表对应的 XML
*/
public static void printChartXml(XSSFChart chart) {
if (chart == null) {
System.out.println("无图表");
return;
}
try {
PackagePart part = chart.getPackagePart();
try (InputStream is = part.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"))) {
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}
String xml = chart.getCTChartSpace().xmlText();
System.out.println(xml);
} catch (Exception e) {
e.printStackTrace();
System.out.println("读取图表XML失败: " + e.getMessage());
}
}

View File

@@ -10,7 +10,9 @@ import org.apache.poi.xssf.usermodel.*;
import pc.exam.pp.module.judgement.utils.wps_word.utils.ColorUtils;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -400,10 +402,17 @@ public class RangIng {
if (cell.getCellType() == CellType.FORMULA) {
CellType evaluatedType = evaluator.evaluateFormulaCell(cell);
String val;
String val = null;
switch (evaluatedType) {
case NUMERIC:
val = String.valueOf(cell.getNumericCellValue());
if (DateUtil.isCellDateFormatted(cell)) {
// 如果是日期格式,格式化为 yyyy/M/d
Date date = cell.getDateCellValue();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/M/d");
val = sdf.format(date);
} else {
val = String.valueOf(cell.getNumericCellValue());
}
break;
case STRING:
val = cell.getStringCellValue();
@@ -414,8 +423,6 @@ public class RangIng {
case ERROR:
val = "错误值";
break;
default:
val = null;
}
if (val != null) {
@@ -430,6 +437,7 @@ public class RangIng {
//范围 - 填充 背景色
public String getFillBgColors(String cellRefRange, Workbook workbook, int sheetIndex) {
List<String> cellRefs = getCellRefsInRange(cellRefRange);

View File

@@ -9,6 +9,7 @@ import org.docx4j.dml.wordprocessingDrawing.Inline;
import org.docx4j.mce.AlternateContent;
import org.docx4j.model.structure.DocumentModel;
import org.docx4j.model.structure.HeaderFooterPolicy;
import org.docx4j.model.structure.PageDimensions;
import org.docx4j.model.structure.SectionWrapper;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
@@ -209,76 +210,37 @@ public class SectionPage {
}
}
// 每行字符数
// 每行字符数 + 每页行数
// public static String getSectionPageCharNumber(P paragraph,
// HeaderFooterPolicy hfp,
// WordprocessingMLPackage wordMLPackage,
// List<SectionWrapper> sections) {
// try {
// if (sections == null || sections.isEmpty()) {
// return "【没有节信息】";
// }
//
// // 这里只取第一个节(通常文档只有一个节,如果有多个可以 for 循环)
// SectionWrapper sectionWrapper = sections.get(0);
// SectPr sectPr = sectionWrapper.getSectPr();
// if (sectPr == null) {
// return "【无 SectPr 信息】";
// }
// System.out.println("==============");
//
//
//
// // 页面属性
// SectPr.PgSz pgSz = sectPr.getPgSz();
// SectPr.PgMar pgMar = sectPr.getPgMar();
// if (pgSz == null || pgMar == null) {
// return "【无页面设置】";
// }
//
// int pageW = pgSz.getW().intValue(); // 页面宽度 (twip)
// int pageH = pgSz.getH().intValue(); // 页面高度 (twip)
// int left = pgMar.getLeft().intValue();
// int right = pgMar.getRight().intValue();
// int top = pgMar.getTop().intValue();
// int bottom = pgMar.getBottom().intValue();
//
// // 可用区域
// int availableWidth = pageW - left - right;
// int availableHeight = pageH - top - bottom;
//
// // 网格设置
// CTDocGrid grid = sectPr.getDocGrid();
// if (grid == null) {
// return "【未设置文档网格】";
// }
//
// StringBuilder sb = new StringBuilder("【页面设置(文档网格)】");
//
// // 每行字符数
// if (grid.getCharSpace() != null) {
// int charSpace = grid.getCharSpace().intValue();
// if (charSpace > 0) {
// int charsPerLine = Math.round((float) availableWidth / charSpace);
// sb.append("【每行字符数】").append(charsPerLine).append(" 字/行");
// }
// }
//
// // 每页行数
// if (grid.getLinePitch() != null) {
// int linePitch = grid.getLinePitch().intValue();
// if (linePitch > 0) {
// int linesPerPage = Math.round((float) availableHeight / linePitch);
// sb.append("【每页行数】").append(linesPerPage).append(" 行/页");
// }
// }
//
// return sb.toString();
//
// } catch (Exception e) {
// return "【计算异常】" + e.getMessage();
// }
// }
public static String getSectionPageCharNumber(P paragraph,
HeaderFooterPolicy hfp,
WordprocessingMLPackage wordMLPackage,
List<SectionWrapper> sections) {
if (paragraph == null || paragraph.getPPr() == null) return "未知";
SectPr sectPr = paragraph.getPPr().getSectPr();
if (sectPr == null) return "";
CTDocGrid docGrid = sectPr.getDocGrid();
if (docGrid == null || docGrid.getCharSpace() == null) {
return "未设置";
}
// 取 charSpace (每个字的宽度, twips)
int charSpace = docGrid.getCharSpace().intValue();
// 计算可写宽度(页面宽度 - 左右边距)
PageDimensions pageDim = new PageDimensions(sectPr);
int availableWidth = pageDim.getWritableWidthTwips();
// 反推字数 (四舍五入)
int charsPerLine = Math.round((float) availableWidth / (float) charSpace);
System.out.println("charSpace = " + charSpace);
System.out.println("可写宽度 = " + availableWidth);
System.out.println("反推字数 = " + charsPerLine);
return "【每行字符数】" + charsPerLine + " 字/行";
}

View File

@@ -1257,28 +1257,52 @@ public class TextInfo {
return judgementWordsVOS;
}
// 文本内容
public static String getTextValue(List<JudgementWordsVO> judgementWordsVOS, Anchor anchor, int betoLong,WordprocessingMLPackage wordMLPackage){
public static String getTextValue(List<JudgementWordsVO> judgementWordsVOS,
Anchor anchor,
int betoLong,
WordprocessingMLPackage wordMLPackage) {
Object graphicData = anchor.getGraphic().getGraphicData().getAny().get(0);
// 正确处理 JAXBElement
if (graphicData instanceof JAXBElement) {
JAXBElement<?> jaxbElement = (JAXBElement<?>) graphicData;
Object value = jaxbElement.getValue();
// 现在可以尝试转换为实际类型
if (value.getClass().getName().contains("CTWordprocessingShape")) {
if (value instanceof CTWordprocessingShape) {
// 文本内容
CTWordprocessingShape textInfo = (CTWordprocessingShape) value;
String textValue = textInfo.getTxbx().getTxbxContent().getContent().toString();
if (textValue!=null){
return textValue;
if (value instanceof CTWordprocessingShape) {
CTWordprocessingShape textInfo = (CTWordprocessingShape) value;
if (textInfo.getTxbx() != null && textInfo.getTxbx().getTxbxContent() != null) {
StringBuilder sb = new StringBuilder();
List<Object> contents = textInfo.getTxbx().getTxbxContent().getContent();
for (Object obj : contents) {
// 解包 JAXBElement
Object unwrapped = (obj instanceof JAXBElement) ? ((JAXBElement<?>) obj).getValue() : obj;
if (unwrapped instanceof P) {
P para = (P) unwrapped;
List<Object> paraContents = para.getContent();
for (Object pc : paraContents) {
Object inner = (pc instanceof JAXBElement) ? ((JAXBElement<?>) pc).getValue() : pc;
if (inner instanceof R) {
R run = (R) inner;
for (Object rc : run.getContent()) {
Object rcVal = (rc instanceof JAXBElement) ? ((JAXBElement<?>) rc).getValue() : rc;
if (rcVal instanceof Text) {
sb.append(((Text) rcVal).getValue());
}
}
}
}
sb.append("\n"); // 段落换行
}
}
return sb.toString().trim();
}
}
}
return null;
return "";
}
// 文字方向
public static String getTextVert(List<JudgementWordsVO> judgementWordsVOS, Anchor anchor, int betoLong, WordprocessingMLPackage wordMLPackage) {
if (anchor == null

View File

@@ -169,17 +169,17 @@ function processLayers(layers, resultArray) {
// 读取图层样式
var styles = getLayerStyles(layer);
if (styles) {
if (styles && !isEmptyObject(styles)) {
info["图层样式"] = styles;
}
// 检测滤镜信息
var filterInfo = detectFilters(layer.name);
if (filterInfo) {
if (filterInfo && !isEmptyObject(filterInfo)) {
info["滤镜信息"] = filterInfo;
}
// 选中当前图层为智能对象后
var soLayer = app.activeDocument.activeLayer;
@@ -324,7 +324,7 @@ function processFile(path) {
processLayers(doc.layers, result["图层信息"]);
// 获取智能对象图层数(递归计算)
result["智能对象图层数"] = countSmartObjectsRecursive(doc.layers);
// result["智能对象图层数"] = countSmartObjectsRecursive(doc.layers);
// 写入 JSON 文件
var baseName = fileRef.name.replace(/\.psd$/i, "");
@@ -526,194 +526,178 @@ function getWarpTextProps() {
function getLayerStyles(layer) {
var styles = {};
// ---- 激活图层 ----
app.activeDocument.activeLayer = layer;
// ---- 获取 ActionDescriptor ----
var desc;
try {
// 尝试 CC/2025 方法
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID("Lyr "), layer.id);
var desc = executeActionGet(ref);
if (!desc.hasKey(stringIDToTypeID("layerEffects"))) {
$.writeln("图层无 layerEffects" + layer.name);
return null;
if (layer.id !== undefined) {
ref.putIdentifier(charIDToTypeID("Lyr "), layer.id);
} else {
throw "CS6 fallback";
}
desc = executeActionGet(ref);
} catch (e) {
// CS6 fallback
var ref2 = new ActionReference();
ref2.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
desc = executeActionGet(ref2);
}
// ---- 判断 layerEffects 是否存在 ----
if (!desc.hasKey(stringIDToTypeID("layerEffects"))) {
$.writeln("图层 " + layer.name + " 没有 layerEffects");
return styles; // 空对象
}
try {
var effects = desc.getObjectValue(stringIDToTypeID("layerEffects"));
var styles = {};
// ============ 描边 ===============
// ---- 描边 ----
if (effects.hasKey(stringIDToTypeID("frameFX"))) {
var frameFX = effects.getObjectValue(stringIDToTypeID("frameFX"));
var keys = [];
for (var i = 0; i < frameFX.count; i++) {
keys.push(i + ": " + typeIDToStringID(frameFX.getKey(i)));
}
var enabled = frameFX.getBoolean(stringIDToTypeID("enabled"));
styles["描边_启用"] = frameFX.getBoolean(stringIDToTypeID("enabled"));
if (enabled) {
if (frameFX.hasKey(stringIDToTypeID("size"))) {
styles["描边_大小"] = frameFX.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
}
if (frameFX.hasKey(stringIDToTypeID("color"))) {
var colorDesc = frameFX.getObjectValue(stringIDToTypeID("color"));
styles["描边_颜色"] = colorDescToHex(colorDesc);
}
if (frameFX.hasKey(stringIDToTypeID("style"))) {
var posEnum = frameFX.getEnumerationValue(stringIDToTypeID("style"));
var posStringID = typeIDToStringID(posEnum);
styles["描边_位置"] = getStrokePositionName(posStringID);
} else {
styles["描边_位置"] = "未知";
}
if (frameFX.hasKey(stringIDToTypeID("opacity"))) {
styles["描边_不透明度"] = Math.round(frameFX.getUnitDoubleValue(stringIDToTypeID("opacity"))) + "%";
}
if (frameFX.hasKey(stringIDToTypeID("mode"))) {
var blendMode = frameFX.getEnumerationValue(stringIDToTypeID("mode"));
styles["描边_混合模式"] = getBlendModeName(blendMode);
if (frameFX.hasKey(stringIDToTypeID("enabled"))) {
var enabled = frameFX.getBoolean(stringIDToTypeID("enabled"));
if (enabled) {
if (frameFX.hasKey(stringIDToTypeID("size"))) {
styles["描边_大小"] = frameFX.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
}
if (frameFX.hasKey(stringIDToTypeID("color"))) {
styles["描边_颜色"] = colorDescToHex(frameFX.getObjectValue(stringIDToTypeID("color")));
}
if (frameFX.hasKey(stringIDToTypeID("style"))) {
var posEnum = frameFX.getEnumerationValue(stringIDToTypeID("style"));
var posStringID = typeIDToStringID(posEnum);
styles["描边_位置"] = getStrokePositionName(posStringID);
} else {
styles["描边_位置"] = "未知";
}
if (frameFX.hasKey(stringIDToTypeID("opacity"))) {
styles["描边_不透明度"] = Math.round(frameFX.getUnitDoubleValue(stringIDToTypeID("opacity"))) + "%";
}
if (frameFX.hasKey(stringIDToTypeID("mode"))) {
styles["描边_混合模式"] = getBlendModeName(frameFX.getEnumerationValue(stringIDToTypeID("mode")));
}
}
}
}
// ============ 内发光 ===============
// ---- 内发光 ----
if (effects.hasKey(stringIDToTypeID("innerGlow"))) {
var innerGlow = effects.getObjectValue(stringIDToTypeID("innerGlow"));
// var keys = [];
// for (var i = 0; i < innerGlow.count; i++) {
// keys.push(i + ": " + typeIDToStringID(innerGlow.getKey(i)));
// }
styles["内发光_启用"] = innerGlow.getBoolean(stringIDToTypeID("enabled"));
if (styles["内发光_启用"]) {
if (innerGlow.hasKey(stringIDToTypeID("opacity"))) {
styles["内发光_不透明度"] = Math.round(innerGlow.getUnitDoubleValue(stringIDToTypeID("opacity")) ) + "%";
if (innerGlow.hasKey(stringIDToTypeID("enabled"))) {
var enabled = innerGlow.getBoolean(stringIDToTypeID("enabled"));
if (enabled) {
if (innerGlow.hasKey(stringIDToTypeID("opacity"))) {
styles["内发光_不透明度"] = Math.round(innerGlow.getUnitDoubleValue(stringIDToTypeID("opacity"))) + "%";
}
if (innerGlow.hasKey(stringIDToTypeID("color"))) {
styles["内发光_颜色"] = colorDescToHex(innerGlow.getObjectValue(stringIDToTypeID("color")));
}
if (innerGlow.hasKey(stringIDToTypeID("blur"))) {
styles["内发光_大小"] = innerGlow.getUnitDoubleValue(stringIDToTypeID("blur")) + " 像素";
}
if (innerGlow.hasKey(stringIDToTypeID("mode"))) {
var modeID = innerGlow.getEnumerationValue(stringIDToTypeID("mode"));
styles["内发光_混合模式"] = getBlendModeName(modeID);
}
if (innerGlow.hasKey(stringIDToTypeID("source"))) {
var source = innerGlow.getEnumerationValue(stringIDToTypeID("source"));
styles["内发光_来源"] = getInnerGlowSourceName(source);
}
}
if (innerGlow.hasKey(stringIDToTypeID("mode"))) {
var modeID = innerGlow.getEnumerationValue(stringIDToTypeID("mode"));
styles["内发光_混合模式"] = getBlendModeName(modeID);
}
if (innerGlow.hasKey(stringIDToTypeID("blur"))) {
styles["内发光_大小"] = innerGlow.getUnitDoubleValue(stringIDToTypeID("blur")) + " 像素";
}
if (innerGlow.hasKey(stringIDToTypeID("color"))) {
styles["内发光_颜色"] = colorDescToHex(innerGlow.getObjectValue(stringIDToTypeID("color")));
}
// if (innerGlow.hasKey(stringIDToTypeID("glowTechnique"))) {
// var tech = innerGlow.getEnumerationValue(stringIDToTypeID("glowTechnique"));
// styles["内发光_技巧"] = getInnerGlowTechniqueName(tech);
// }
if (innerGlow.hasKey(stringIDToTypeID("source"))) {
var source = innerGlow.getEnumerationValue(stringIDToTypeID("source"));
styles["内发光_来源"] = getInnerGlowSourceName(source);
}
// if (innerGlow.hasKey(stringIDToTypeID("chokeMatte"))) {
// styles["内发光_阻塞"] = innerGlow.getUnitDoubleValue(stringIDToTypeID("chokeMatte")) + " 像素";
// }
// if (innerGlow.hasKey(stringIDToTypeID("blur"))) {
// styles["内发光_模糊"] = innerGlow.getUnitDoubleValue(stringIDToTypeID("blur")) + " 像素";
// }
}
}
// ========= 斜面和浮雕 =========
// ---- 斜面和浮雕 ----
if (effects.hasKey(stringIDToTypeID("bevelEmboss"))) {
var bevel = effects.getObjectValue(stringIDToTypeID("bevelEmboss"));
styles["斜面_启用"] = bevel.getBoolean(stringIDToTypeID("enabled"));
if (styles["斜面_启用"]) {
styles["斜面_样式"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("style")));
styles["斜面_方法"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("technique")));
styles["斜面_深度"] = bevel.getDouble(stringIDToTypeID("strength")) + "%";
styles["斜面_方向"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("direction")));
styles["斜面_大小"] = bevel.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
styles["斜面_软化"] = bevel.getUnitDoubleValue(stringIDToTypeID("soften")) + " 像素";
styles["斜面_使用全局光"] = bevel.getBoolean(stringIDToTypeID("useGlobalAngle"));
styles["斜面_角度"] = bevel.getInteger(stringIDToTypeID("localLightingAngle")) + "°";
if (bevel.hasKey(stringIDToTypeID("enabled"))) {
var enabled = bevel.getBoolean(stringIDToTypeID("enabled"));
if (enabled) {
styles["斜面_样式"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("style")));
styles["斜面_方法"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("technique")));
styles["斜面_深度"] = bevel.getDouble(stringIDToTypeID("strength")) + "%";
styles["斜面_方向"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("direction")));
styles["斜面_大小"] = bevel.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
styles["斜面_软化"] = bevel.getUnitDoubleValue(stringIDToTypeID("soften")) + " 像素";
styles["斜面_使用全局光"] = bevel.getBoolean(stringIDToTypeID("useGlobalAngle"));
styles["斜面_角度"] = bevel.getInteger(stringIDToTypeID("localLightingAngle")) + "°";
if (bevel.hasKey(stringIDToTypeID("highlightColor"))) {
var color = bevel.getObjectValue(stringIDToTypeID("highlightColor"));
styles["斜面_高光颜色"] = colorToHex(color);
}
if (bevel.hasKey(stringIDToTypeID("highlightMode"))) {
var mode = bevel.getEnumerationValue(stringIDToTypeID("highlightMode"));
styles["斜面_高光模式"] = typeIDToStringID(mode);
if (bevel.hasKey(stringIDToTypeID("highlightColor"))) {
var color = bevel.getObjectValue(stringIDToTypeID("highlightColor"));
styles["斜面_高光颜色"] = colorToHex(color);
}
if (bevel.hasKey(stringIDToTypeID("highlightMode"))) {
var mode = bevel.getEnumerationValue(stringIDToTypeID("highlightMode"));
styles["斜面_高光模式"] = typeIDToStringID(mode);
}
}
}
}
// ========= 光泽Satin =========
if (effects.hasKey(stringIDToTypeID("satin"))) {
var satin = effects.getObjectValue(stringIDToTypeID("satin"));
styles["光泽_启用"] = satin.getBoolean(stringIDToTypeID("enabled"));
if (styles["光泽_启用"]) {
styles["光泽_混合模式"] = typeIDToStringID(satin.getEnumerationValue(stringIDToTypeID("mode")));
styles["光泽_不透明度"] = satin.getInteger(stringIDToTypeID("opacity")) + "%";
styles["光泽_角度"] = satin.getInteger(stringIDToTypeID("localLightingAngle")) + "°";
styles["光泽_距离"] = satin.getUnitDoubleValue(stringIDToTypeID("distance")) + " 像素";
styles["光泽_大小"] = satin.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
}
}
// ============ 外发光 ===============
// ---- 外发光 ----
if (effects.hasKey(stringIDToTypeID("outerGlow"))) {
var outerGlow = effects.getObjectValue(stringIDToTypeID("outerGlow"));
styles["外发光_启用"] = outerGlow.getBoolean(stringIDToTypeID("enabled"));
// 遍历输出所有 key 名称,方便调试
// var keys = [];
// for (var i = 0; i < outerGlow.count; i++) {
// var key = outerGlow.getKey(i);
// var keyName = typeIDToStringID(key);
// keys.push(keyName);
// }
if (styles["外发光_启用"]) {
if (outerGlow.hasKey(stringIDToTypeID("opacity"))) {
styles["外发光_不透明度"] = Math.round(outerGlow.getUnitDoubleValue(stringIDToTypeID("opacity")) ) + "%";
}
if (outerGlow.hasKey(stringIDToTypeID("color"))) {
styles["外发光_颜色"] = colorDescToHex(outerGlow.getObjectValue(stringIDToTypeID("color")));
}
if (outerGlow.hasKey(stringIDToTypeID("glowTechnique"))) {
var techniqueEnum = outerGlow.getEnumerationValue(stringIDToTypeID("glowTechnique"));
var techniqueStr = typeIDToStringID(techniqueEnum);
styles["外发光_图素方法"] = getOuterGlowTechniqueName(techniqueStr); // 例如返回"精确"
}
if (outerGlow.hasKey(stringIDToTypeID("blur"))) {
styles["外发光_大小"] = outerGlow.getUnitDoubleValue(stringIDToTypeID("blur")) + " 像素";
}
if (outerGlow.hasKey(stringIDToTypeID("chokeMatte"))) {
styles["外发光_阻塞"] = outerGlow.getUnitDoubleValue(stringIDToTypeID("chokeMatte")) + " 像素";
}
try{
if (outerGlow.hasKey(stringIDToTypeID("transferSpec"))) {
var transferSpec = outerGlow.getObjectValue(stringIDToTypeID("transferSpec")); // 先获取对象
var nameID = stringIDToTypeID("name");
if (transferSpec.hasKey(nameID)) {
styles["外发光_等高线"] = transferSpec.getString(nameID);
}
if (outerGlow.hasKey(stringIDToTypeID("enabled"))) {
var enabled = outerGlow.getBoolean(stringIDToTypeID("enabled"));
if (styles["外发光_启用"]) {
if (outerGlow.hasKey(stringIDToTypeID("opacity"))) {
styles["外发光_不透明度"] = Math.round(outerGlow.getUnitDoubleValue(stringIDToTypeID("opacity"))) + "%";
}
if (outerGlow.hasKey(stringIDToTypeID("color"))) {
styles["外发光_颜色"] = colorDescToHex(outerGlow.getObjectValue(stringIDToTypeID("color")));
}
if (outerGlow.hasKey(stringIDToTypeID("glowTechnique"))) {
var techEnum = outerGlow.getEnumerationValue(stringIDToTypeID("glowTechnique"));
styles["外发光_图素方法"] = getOuterGlowTechniqueName(typeIDToStringID(techEnum));
}
if (outerGlow.hasKey(stringIDToTypeID("blur"))) {
styles["外发光_大小"] = outerGlow.getUnitDoubleValue(stringIDToTypeID("blur")) + " 像素";
}
if (outerGlow.hasKey(stringIDToTypeID("chokeMatte"))) {
styles["外发光_阻塞"] = outerGlow.getUnitDoubleValue(stringIDToTypeID("chokeMatte")) + " 像素";
}
if (outerGlow.hasKey(stringIDToTypeID("mode"))) {
styles["外发光_混合模式"] = getBlendModeName(outerGlow.getEnumerationValue(stringIDToTypeID("mode")));
}
} catch (e) {
// alert("外发光_等高线: " + e.message);
return null;
}
if (outerGlow.hasKey(stringIDToTypeID("mode"))) {
var blendMode = outerGlow.getEnumerationValue(stringIDToTypeID("mode"));
styles["外发光_混合模式"] = getBlendModeName(blendMode);
}
}
}
// ---- 光泽Satin ----
if (effects.hasKey(stringIDToTypeID("satin"))) {
var satin = effects.getObjectValue(stringIDToTypeID("satin"));
if (satin.hasKey(stringIDToTypeID("enabled"))) {
var enabled = satin.getBoolean(stringIDToTypeID("enabled"));
if (enabled) {
if (satin.hasKey(stringIDToTypeID("opacity"))) {
styles["光泽_不透明度"] = Math.round(satin.getUnitDoubleValue(stringIDToTypeID("opacity"))) + "%";
}
if (satin.hasKey(stringIDToTypeID("color"))) {
styles["光泽_颜色"] = colorDescToHex(satin.getObjectValue(stringIDToTypeID("color")));
}
if (satin.hasKey(stringIDToTypeID("mode"))) {
styles["光泽_混合模式"] = getBlendModeName(satin.getEnumerationValue(stringIDToTypeID("mode")));
}
if (satin.hasKey(stringIDToTypeID("angle"))) {
styles["光泽_角度"] = satin.getUnitDoubleValue(stringIDToTypeID("angle")) + "°";
}
if (satin.hasKey(stringIDToTypeID("distance"))) {
styles["光泽_距离"] = satin.getUnitDoubleValue(stringIDToTypeID("distance")) + " 像素";
}
if (satin.hasKey(stringIDToTypeID("size"))) {
styles["光泽_大小"] = satin.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
}
}
}
}
return hasOwnProperties(styles) ? styles : null;
} catch (e) {
// alert("读取图层样式异常: " + e.message);
return null;
}
}
@@ -940,4 +924,10 @@ function hasOwnProperties(obj) {
}
function isEmptyObject(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) return false;
}
return true;
}