From 9f602d49d64ea65f677196124930f3b642605940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=98=89=E8=B1=AA?= <42510293+ziyujiahao@users.noreply.github.com> Date: Thu, 2 Jan 2025 13:34:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor(X-Pack):=20=E5=A2=9E=E5=8A=A0Excel?= =?UTF-8?q?=E6=B0=B4=E5=8D=B0=E5=8D=95=E7=8B=AC=E6=8E=A7=E5=88=B6=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20(#14455)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: xuwei-fit2cloud --- .../io/dataease/commons/utils/ExcelWatermarkUtils.java | 10 +++++----- .../exportCenter/manage/ExportCenterManage.java | 2 +- core/core-frontend/src/locales/en.ts | 1 + core/core-frontend/src/locales/tw.ts | 1 + core/core-frontend/src/locales/zh-CN.ts | 1 + de-xpack | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/commons/utils/ExcelWatermarkUtils.java b/core/core-backend/src/main/java/io/dataease/commons/utils/ExcelWatermarkUtils.java index 966f600e1e..9dbbe34c5a 100644 --- a/core/core-backend/src/main/java/io/dataease/commons/utils/ExcelWatermarkUtils.java +++ b/core/core-backend/src/main/java/io/dataease/commons/utils/ExcelWatermarkUtils.java @@ -78,8 +78,9 @@ public class ExcelWatermarkUtils { } public static byte[] createTextImage(String text, WatermarkContentDTO watermarkContent) { - int width = watermarkContent.getWatermark_fontsize() * text.length() + 100; - int height = watermarkContent.getWatermark_fontsize() + 50; + double radians = Math.toRadians(15);// 15度偏转 + int width = watermarkContent.getWatermark_fontsize() * text.length(); + int height = (int) Math.round(watermarkContent.getWatermark_fontsize() + width * Math.sin(radians)); int fontSize = watermarkContent.getWatermark_fontsize(); Color baseColor = Color.decode(watermarkContent.getWatermark_color()); @@ -95,10 +96,9 @@ public class ExcelWatermarkUtils { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // 设置字体 - g2d.setFont(new Font("Arial", Font.BOLD, fontSize)); + g2d.setFont(new Font("Arial", Font.PLAIN, fontSize)); g2d.setColor(new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50)); // 半透明颜色 - g2d.rotate(Math.toRadians(25), width / 2.0, height / 2.0); // 旋转文字 - + g2d.rotate(radians, width / 2.0, height / 2.0); // 旋转文字 // 绘制文字 FontMetrics fontMetrics = g2d.getFontMetrics(); int textWidth = fontMetrics.stringWidth(text); diff --git a/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java b/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java index 3b385eae4b..f39f5dfac5 100644 --- a/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java +++ b/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java @@ -804,7 +804,7 @@ public class ExportCenterManage implements BaseExportApi { public void addWatermarkTools(Workbook wb){ VisualizationWatermark watermark = watermarkMapper.selectById("system_default"); WatermarkContentDTO watermarkContent = JsonUtil.parseObject(watermark.getSettingContent(), WatermarkContentDTO.class); - if (watermarkContent.getExcelEnable()) { + if (watermarkContent.getEnable() && watermarkContent.getExcelEnable()) { UserFormVO userInfo = visualizationMapper.queryInnerUserInfo(AuthUtils.getUser().getUserId()); // 在主逻辑中添加水印 int watermarkPictureIdx = ExcelWatermarkUtils.addWatermarkImage(wb, watermarkContent,userInfo); // 生成水印图片并获取 ID diff --git a/core/core-frontend/src/locales/en.ts b/core/core-frontend/src/locales/en.ts index 3c9312752c..f8db7c8d4e 100644 --- a/core/core-frontend/src/locales/en.ts +++ b/core/core-frontend/src/locales/en.ts @@ -3945,6 +3945,7 @@ Scatter chart (bubble) chart: {a} (series name), {b} (data name), {c} (value arr watermark: { support_params: 'Currently supported parameters:', enable: 'Enable', + excel_enable: 'Enable watermark for exporting data files', enable_panel_custom: ' Allow dashboards to turn on or off watermarks individually', content: 'Content', custom_content: 'Custom formula', diff --git a/core/core-frontend/src/locales/tw.ts b/core/core-frontend/src/locales/tw.ts index 54be73ff24..9dc02ae6f3 100644 --- a/core/core-frontend/src/locales/tw.ts +++ b/core/core-frontend/src/locales/tw.ts @@ -3843,6 +3843,7 @@ export default { watermark: { support_params: '目前支援的參數:', enable: '啟用水印', + excel_enable: '啟用數據文件導出水印', enable_panel_custom: '允許儀表板單獨開啟或關閉水印', content: '浮水印內容', custom_content: '自訂公式', diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index 30d9bf077d..65750c8a72 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -3847,6 +3847,7 @@ export default { watermark: { support_params: '当前支持的参数:', enable: '启用水印', + excel_enable: '导出数据文件开启水印', enable_panel_custom: '允许仪表板单独打开或者关闭水印', content: '水印内容', custom_content: '自定义公式', diff --git a/de-xpack b/de-xpack index cefee13df7..0e19755eee 160000 --- a/de-xpack +++ b/de-xpack @@ -1 +1 @@ -Subproject commit cefee13df7d1d8cbf41adf8e65460d126f91b0f4 +Subproject commit 0e19755eee5a9961e27e4a0301a8f2b095cfd47c