pioneer
2 years ago
commit
1de4fe2852
26 changed files with 853 additions and 0 deletions
@ -0,0 +1,6 @@ |
|||||||
|
# open-JSD-10846 |
||||||
|
|
||||||
|
JSD-10846 自定义单元格边框粗细度\ |
||||||
|
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||||
|
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||||
|
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,168 @@ |
|||||||
|
apply plugin: 'java' |
||||||
|
|
||||||
|
buildscript { |
||||||
|
repositories { |
||||||
|
maven { |
||||||
|
url = uri('https://mvn.fanruan.com/repository/maven-public/') |
||||||
|
} |
||||||
|
dependencies { |
||||||
|
classpath localGroovy() |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ext { |
||||||
|
/** |
||||||
|
* 项目中依赖的jar的路径 |
||||||
|
* 1.如果依赖的jar需要打包到zip中,放置在lib根目录下 |
||||||
|
* 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可 |
||||||
|
*/ |
||||||
|
libPath = "$projectDir/../webroot/WEB-INF/lib" |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否对插件的class进行加密保护,防止反编译 |
||||||
|
*/ |
||||||
|
guard = true |
||||||
|
|
||||||
|
def pluginInfo = getPluginInfo() |
||||||
|
pluginPre = "fine-plugin" |
||||||
|
pluginName = pluginInfo.id |
||||||
|
pluginVersion = pluginInfo.version |
||||||
|
|
||||||
|
outputPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/classes" |
||||||
|
XMLPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0" |
||||||
|
pluginLibPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/lib" |
||||||
|
} |
||||||
|
|
||||||
|
group = 'com.fr.plugin' |
||||||
|
version = '10.0' |
||||||
|
|
||||||
|
compileJava { |
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8 |
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8 |
||||||
|
} |
||||||
|
|
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java { |
||||||
|
destinationDirectory.set(file(outputPath)) |
||||||
|
} |
||||||
|
output.resourcesDir = file(outputPath) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ant.importBuild("encrypt.xml") |
||||||
|
//定义ant变量 |
||||||
|
ant.projectDir = projectDir |
||||||
|
ant.references["compile.classpath"] = ant.path { |
||||||
|
fileset(dir: libPath, includes: '**/*.jar') |
||||||
|
fileset(dir: ".", includes: "**/*.jar") |
||||||
|
} |
||||||
|
|
||||||
|
clean.doFirst { |
||||||
|
delete file(outputPath) |
||||||
|
delete file("$projectDir/classes") |
||||||
|
delete file("$projectDir/transform-classes") |
||||||
|
} |
||||||
|
|
||||||
|
classes.dependsOn('clean') |
||||||
|
|
||||||
|
tasks.withType(JavaCompile) { |
||||||
|
options.encoding = "UTF-8" |
||||||
|
} |
||||||
|
|
||||||
|
task copyFiles(type: Copy, dependsOn: 'classes') { |
||||||
|
from outputPath |
||||||
|
into "$projectDir/classes" |
||||||
|
} |
||||||
|
|
||||||
|
task copy_plugin_config(type: Copy, dependsOn: 'copy_plugin_lib') { |
||||||
|
from "$projectDir/plugin.xml" |
||||||
|
into XMLPath |
||||||
|
} |
||||||
|
|
||||||
|
task copy_plugin_lib(type: Copy) { |
||||||
|
from("$projectDir/lib") { |
||||||
|
include "*.jar" |
||||||
|
} |
||||||
|
into file(pluginLibPath) |
||||||
|
} |
||||||
|
|
||||||
|
task copy_dependencies(type: Copy) { |
||||||
|
from configurations.runtimeClasspath |
||||||
|
into file("$projectDir/lib") |
||||||
|
exclude "fine-third*", "fine-activator*", "fine-core*", "fine-webui*", "fine-datasource*", "fine-decision*", "fine-schedule*", "fine-swift*", "fine-accumulator*", "fine-report*", "fineio*" |
||||||
|
} |
||||||
|
|
||||||
|
task preJar(type: Copy, dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas') { |
||||||
|
from "$projectDir/classes" |
||||||
|
into "$projectDir/transform-classes" |
||||||
|
include "**/*.*" |
||||||
|
} |
||||||
|
jar.dependsOn("preJar") |
||||||
|
|
||||||
|
task makeJar(type: Jar, dependsOn: preJar) { |
||||||
|
from fileTree(dir: "$projectDir/transform-classes") |
||||||
|
archiveBaseName.set(pluginPre) |
||||||
|
archiveAppendix.set(pluginName) |
||||||
|
archiveVersion.set(pluginVersion) |
||||||
|
destinationDirectory = file("$buildDir/libs") |
||||||
|
|
||||||
|
doLast() { |
||||||
|
delete file("$projectDir/classes") |
||||||
|
delete file("$projectDir/transform-classes") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
task copyFile(type: Copy, dependsOn: ["makeJar"]) { |
||||||
|
from "$buildDir/libs" |
||||||
|
from("$projectDir/lib") { |
||||||
|
include "*.jar" |
||||||
|
} |
||||||
|
from "$projectDir/plugin.xml" |
||||||
|
into file("$buildDir/temp/plugin") |
||||||
|
} |
||||||
|
|
||||||
|
task zip(type: Zip, dependsOn: ["copyFile"]) { |
||||||
|
from "$buildDir/temp/plugin" |
||||||
|
destinationDirectory = file("$buildDir/install") |
||||||
|
archiveBaseName.set(pluginPre) |
||||||
|
archiveAppendix.set(pluginName) |
||||||
|
archiveVersion.set(pluginVersion) |
||||||
|
} |
||||||
|
|
||||||
|
//控制build时包含哪些文件,排除哪些文件 |
||||||
|
processResources { |
||||||
|
// exclude everything |
||||||
|
// 用*.css没效果 |
||||||
|
// exclude '**/*.css' |
||||||
|
// except this file |
||||||
|
// include 'xx.xml' |
||||||
|
} |
||||||
|
|
||||||
|
/*读取plugin.xml中的version*/ |
||||||
|
|
||||||
|
def getPluginInfo() { |
||||||
|
def xmlFile = file("plugin.xml") |
||||||
|
if (!xmlFile.exists()) { |
||||||
|
return ["id": "none", "version": "1.0.0"] |
||||||
|
} |
||||||
|
def plugin = new groovy.xml.XmlParser().parse(xmlFile) |
||||||
|
def version = plugin.version.text() |
||||||
|
def id = plugin.id.text() |
||||||
|
return ["id": id, "version": version] |
||||||
|
} |
||||||
|
|
||||||
|
repositories { |
||||||
|
// mavenLocal() |
||||||
|
maven { |
||||||
|
url = uri('https://mvn.fanruan.com/repository/maven-public/') |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//使用本地jar |
||||||
|
implementation fileTree(dir: 'lib', include: ['**/*.jar']) |
||||||
|
// 指定依赖引用 |
||||||
|
// implementation files("../finekit/build/libs/finekit-10.0.jar") |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||||
|
<project> |
||||||
|
<target name="compile_encrypt_javas" depends="copyFiles"> |
||||||
|
<echo message="加密文件"/> |
||||||
|
<echo message="${projectDir}"/> |
||||||
|
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask"> |
||||||
|
<classpath refid="compile.classpath"/> |
||||||
|
</taskdef> |
||||||
|
<pretreatment baseDir="${projectDir}"/> |
||||||
|
</target> |
||||||
|
<target name="compile_plain_javas" depends="copyFiles"> |
||||||
|
</target> |
||||||
|
</project> |
Binary file not shown.
@ -0,0 +1,31 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<plugin> |
||||||
|
<id>com.fr.plugin.ajhdf.pdf</id> |
||||||
|
<name><![CDATA[导出PDF文档定制_EK]]></name> |
||||||
|
<active>yes</active> |
||||||
|
<version>2.0.4</version> |
||||||
|
<env-version>10.0~10.0</env-version> |
||||||
|
<jartime>2018-10-31</jartime> |
||||||
|
<vendor>fr.open</vendor> |
||||||
|
<description><![CDATA[导出PDF文档定制]]></description> |
||||||
|
<change-notes><![CDATA[ |
||||||
|
[2022-10-17]适配正式版本10.0.19.2022.09.27<br/> |
||||||
|
[2022-09-25]JSD-10846插件初始化<br/> |
||||||
|
<p>导出PDF文档定制</p> |
||||||
|
]]></change-notes> |
||||||
|
<main-package>com.fr.plugin.ajhdf</main-package> |
||||||
|
<prefer-packages> |
||||||
|
<prefer-package>com.fanruan.api.*</prefer-package> |
||||||
|
</prefer-packages> |
||||||
|
<extra-core> |
||||||
|
<LocaleFinder class="com.fr.plugin.ajhdf.LocaleFinder"/> |
||||||
|
<IOFileAttrMark class="com.fr.plugin.ajhdf.provider.PdfExportAttr"/> |
||||||
|
</extra-core> |
||||||
|
<extra-report> |
||||||
|
<ExportExtensionProcessor class="com.fr.plugin.ajhdf.provider.FileExportExtension"/> |
||||||
|
</extra-report> |
||||||
|
<extra-designer> |
||||||
|
<ExportAttrTabProvider class="com.fr.plugin.ajhdf.provider.DocSummaryTab"/> |
||||||
|
</extra-designer> |
||||||
|
<function-recorder class="com.fr.plugin.ajhdf.LocaleFinder"/> |
||||||
|
</plugin> |
@ -0,0 +1,40 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2020 |
||||||
|
* Project: starter |
||||||
|
* FileName: LocaleFinder |
||||||
|
* Author: xx |
||||||
|
* Date: 2020/8/31 22:19 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ajhdf; |
||||||
|
|
||||||
|
import com.fr.intelli.record.Focus; |
||||||
|
import com.fr.intelli.record.Original; |
||||||
|
import com.fr.record.analyzer.EnableMetrics; |
||||||
|
import com.fr.stable.fun.Authorize; |
||||||
|
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||||
|
|
||||||
|
import static com.fr.plugin.ajhdf.LocaleFinder.PLUGIN_ID; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <LocaleFinder> |
||||||
|
* |
||||||
|
* @author xx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@EnableMetrics |
||||||
|
@Authorize(callSignKey = PLUGIN_ID) |
||||||
|
public class LocaleFinder extends AbstractLocaleFinder { |
||||||
|
public static final String PLUGIN_ID = "com.fr.plugin.ajhdf.pdf"; |
||||||
|
|
||||||
|
@Override |
||||||
|
@Focus(id = PLUGIN_ID, text = "Plugin-ajhdf", source = Original.PLUGIN) |
||||||
|
public String find() { |
||||||
|
return "com/fr/plugin/ajhdf/locale/lang"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
package com.fr.plugin.ajhdf.export; |
||||||
|
|
||||||
|
import com.fanruan.api.i18n.I18nKit; |
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.io.exporter.PDFExporter; |
||||||
|
import com.fr.main.workbook.ResultWorkBook; |
||||||
|
import com.fr.page.PagePainterProvider; |
||||||
|
import com.fr.page.ReportPageProvider; |
||||||
|
import com.fr.plugin.ajhdf.painter.PagePainterPlus; |
||||||
|
import com.fr.plugin.ajhdf.provider.PdfExportAttr; |
||||||
|
import com.fr.plugin.context.PluginContexts; |
||||||
|
import com.fr.stable.bridge.StableFactory; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
import java.io.OutputStream; |
||||||
|
import java.util.HashMap; |
||||||
|
|
||||||
|
/** |
||||||
|
* 直接继承默认的pdf导出exporter,PDFExporter |
||||||
|
*/ |
||||||
|
public class PDFExporterPlus extends PDFExporter { |
||||||
|
private float scale; |
||||||
|
|
||||||
|
public PDFExporterPlus() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void export(OutputStream outputStream, ResultWorkBook resultWorkBook, int[] ints) throws Exception { |
||||||
|
if (ComparatorUtils.equals(this.scale, 0.0f)) { |
||||||
|
try { |
||||||
|
PdfExportAttr pdfExportAttr = resultWorkBook.getAttrMark(PdfExportAttr.XML_TAG); |
||||||
|
this.scale = pdfExportAttr.getStrokeScale(); |
||||||
|
} catch (Exception e) { |
||||||
|
} |
||||||
|
} |
||||||
|
super.export(outputStream, resultWorkBook, ints); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected PagePainterProvider getPagePainterProvider(ReportPageProvider reportPageProvider, Graphics2D graphics2D, HashMap<String, Class> hashMap) { |
||||||
|
if (PluginContexts.currentContext() == null || !PluginContexts.currentContext().isAvailable()) { |
||||||
|
LogKit.error(I18nKit.getLocText("Plugin-ajhdf_licence_Expired")); |
||||||
|
return StableFactory.getMarkedInstanceObjectFromClass("PagePainter", new Object[]{reportPageProvider, graphics2D, Integer.valueOf(String.valueOf(96)), Boolean.FALSE}, hashMap, PagePainterProvider.class, null); |
||||||
|
} |
||||||
|
if (ComparatorUtils.equals(this.scale, 0.0f)) { |
||||||
|
return StableFactory.getMarkedInstanceObjectFromClass("PagePainter", new Object[]{reportPageProvider, graphics2D, Integer.valueOf(String.valueOf(96)), Boolean.FALSE}, hashMap, PagePainterProvider.class, null); |
||||||
|
} |
||||||
|
return new PagePainterPlus(reportPageProvider, graphics2D, 96, Boolean.FALSE, this.scale); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
package com.fr.plugin.ajhdf.operate; |
||||||
|
|
||||||
|
import com.fr.general.ReportDeclareRecordType; |
||||||
|
import com.fr.io.collection.ExportCollection; |
||||||
|
import com.fr.plugin.ajhdf.export.PDFExporterPlus; |
||||||
|
import com.fr.stable.web.SessionProvider; |
||||||
|
import com.fr.web.core.reserve.DefaultOperate; |
||||||
|
import com.fr.web.core.utils.ExportUtils; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
|
||||||
|
|
||||||
|
public class CustomPDFOperate extends DefaultOperate { |
||||||
|
|
||||||
|
/** |
||||||
|
* 返回一个带有PDFExporterPlus导出的ExportCollection |
||||||
|
* |
||||||
|
* @param req |
||||||
|
* @param res |
||||||
|
* @param sessionProvider |
||||||
|
* @param fileName |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public ExportCollection newExportCollection(HttpServletRequest req, HttpServletResponse res, SessionProvider sessionProvider, String fileName) { |
||||||
|
ExportCollection exportCollection = ExportCollection.create(); |
||||||
|
exportCollection.setExporter(new PDFExporterPlus()); |
||||||
|
exportCollection.setRecordType(ReportDeclareRecordType.EXPORT_TYPE_PDF); |
||||||
|
this.setContent(req, res, fileName, false); |
||||||
|
return exportCollection; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置响应的类型,设置文件名等 |
||||||
|
* |
||||||
|
* @param req |
||||||
|
* @param res |
||||||
|
* @param fileName |
||||||
|
* @param isEmbed |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void setContent(HttpServletRequest req, HttpServletResponse res, String fileName, boolean isEmbed) { |
||||||
|
ExportUtils.setPDFContent(res, fileName, isEmbed); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,139 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2022 |
||||||
|
* Project: starter |
||||||
|
* FileName: PagePainterPlus |
||||||
|
* Author: xx |
||||||
|
* Date: 2022/9/27 14:17 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ajhdf.painter; |
||||||
|
|
||||||
|
import com.fr.base.DynamicNumberList; |
||||||
|
import com.fr.base.Style; |
||||||
|
import com.fr.interruption.Condition; |
||||||
|
import com.fr.interruption.Conditions; |
||||||
|
import com.fr.interruption.ExporterScene; |
||||||
|
import com.fr.page.ClippedPageProvider; |
||||||
|
import com.fr.page.PagePainter; |
||||||
|
import com.fr.page.ReportPageProvider; |
||||||
|
import com.fr.plugin.ajhdf.style.StylePDF; |
||||||
|
import com.fr.report.cell.CellElement; |
||||||
|
import com.fr.report.cell.cellattr.BrokenCellInfo; |
||||||
|
import com.fr.report.cell.cellattr.CellGUIAttr; |
||||||
|
import com.fr.report.cell.cellattr.PageExportCellElement; |
||||||
|
import com.fr.stable.monitor.MemoryHelper; |
||||||
|
import org.jetbrains.annotations.NotNull; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Iterator; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <PagePainterPlus> |
||||||
|
* |
||||||
|
* @author xx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class PagePainterPlus extends PagePainter { |
||||||
|
private boolean isPrint; |
||||||
|
|
||||||
|
private float scale; |
||||||
|
|
||||||
|
public PagePainterPlus() { |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
public PagePainterPlus(ReportPageProvider reportPage, Graphics2D g2d, int resolution, boolean isPrint) { |
||||||
|
super(reportPage, g2d, resolution, isPrint); |
||||||
|
} |
||||||
|
|
||||||
|
public PagePainterPlus(ReportPageProvider reportPage, Graphics2D g2d, int resolution, boolean isPrint, float scale) { |
||||||
|
super(reportPage, g2d, resolution, isPrint); |
||||||
|
this.scale = scale; |
||||||
|
} |
||||||
|
|
||||||
|
public PagePainterPlus(ReportPageProvider reportPage, Graphics2D g2d, int resolution, boolean isPrint, boolean isShowAsImageInWeb) { |
||||||
|
super(reportPage, g2d, resolution, isPrint, isShowAsImageInWeb); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void prepareCell(ClippedPageProvider page, DynamicNumberList columnWidthList, DynamicNumberList rowHeightList, int offsetX, int offsetY) { |
||||||
|
List<CellElement> cellElements = new ArrayList<>(); |
||||||
|
List<Rectangle> rectangles = new ArrayList<>(); |
||||||
|
List<Rectangle> rectangleList = new ArrayList<>(); |
||||||
|
Iterator cellIterator = page.cellIterator(); |
||||||
|
Condition condition = Conditions.get(ExporterScene.PDF_CELL); |
||||||
|
int cellIndex = 0; |
||||||
|
|
||||||
|
Rectangle cellRectangle; |
||||||
|
while (cellIterator.hasNext()) { |
||||||
|
PageExportCellElement pageExportCellElement = new PageExportCellElement((CellElement) cellIterator.next()); |
||||||
|
CellGUIAttr cellGUIAttr = pageExportCellElement.getCellGUIAttr(); |
||||||
|
if (cellGUIAttr == null) { |
||||||
|
cellGUIAttr = CellGUIAttr.DEFAULT_CELLGUIATTR; |
||||||
|
} |
||||||
|
|
||||||
|
cellRectangle = new Rectangle(pageExportCellElement.getColumn(), pageExportCellElement.getRow(), pageExportCellElement.getColumnSpan(), pageExportCellElement.getRowSpan()); |
||||||
|
Rectangle rangeRectangle = new Rectangle(columnWidthList.getRangeValue(0, cellRectangle.x), rowHeightList.getRangeValue(0, cellRectangle.y), columnWidthList.getRangeValue(cellRectangle.x, cellRectangle.x + cellRectangle.width), rowHeightList.getRangeValue(cellRectangle.y, cellRectangle.y + cellRectangle.height)); |
||||||
|
rangeRectangle.x += offsetX; |
||||||
|
rangeRectangle.y += offsetY; |
||||||
|
this.paintCellAfterPrepare(pageExportCellElement, cellGUIAttr, rangeRectangle, cellElements, rectangles, rectangleList); |
||||||
|
++cellIndex; |
||||||
|
if ((cellIndex & 7) == 0) { |
||||||
|
condition.setMetric(cellIndex); |
||||||
|
MemoryHelper.getMemoryAlarmProcessor().interruptIfConditionMet(condition); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
int count = 0; |
||||||
|
for (int i = cellElements.size(); count < i; ++count) { |
||||||
|
CellElement element = (CellElement) cellElements.get(count); |
||||||
|
cellRectangle = (Rectangle) rectangles.get(count); |
||||||
|
Rectangle rectangle = (Rectangle) rectangleList.get(count); |
||||||
|
// 修改边框样式
|
||||||
|
StylePDF.paintBorder(this.g2d, element.getStyle(), cellRectangle, rectangle, this.scale); |
||||||
|
if ((count & 7) == 0) { |
||||||
|
condition.setMetric(cellIndex); |
||||||
|
MemoryHelper.getMemoryAlarmProcessor().interruptIfConditionMet(condition); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void paintCellAfterPrepare(PageExportCellElement pageExportCellElement, CellGUIAttr cellGUIAttr, Rectangle rectangle, java.util.List<CellElement> cellElements, java.util.List<Rectangle> rectangles, List<Rectangle> rectangles1) { |
||||||
|
BrokenCellInfo brokenCellInfo = pageExportCellElement.getBrokenCellInfo(); |
||||||
|
Rectangle tmpRectangle; |
||||||
|
if (brokenCellInfo != null && brokenCellInfo.getClipInfo() != null) { |
||||||
|
tmpRectangle = brokenCellInfo.getClipInfo(); |
||||||
|
} else { |
||||||
|
tmpRectangle = new Rectangle(0, 0, rectangle.width, rectangle.height); |
||||||
|
} |
||||||
|
|
||||||
|
if (brokenCellInfo != null && brokenCellInfo.getPaintInfo() != null) { |
||||||
|
Rectangle paintInfo = brokenCellInfo.getPaintInfo(); |
||||||
|
rectangle.x += paintInfo.x; |
||||||
|
rectangle.y += paintInfo.y; |
||||||
|
rectangle.width = paintInfo.width; |
||||||
|
rectangle.height = paintInfo.height; |
||||||
|
} |
||||||
|
|
||||||
|
cellElements.add(pageExportCellElement); |
||||||
|
rectangles.add(rectangle); |
||||||
|
rectangles1.add(tmpRectangle); |
||||||
|
if (this.needPaintCell(rectangle)) { |
||||||
|
if (this.shouldPaintCellBackground(cellGUIAttr)) { |
||||||
|
Style.paintBackground(this.g2d, pageExportCellElement.getStyle(), rectangle, tmpRectangle); |
||||||
|
} |
||||||
|
|
||||||
|
this.paintCellContent(cellGUIAttr, this.isPrint, pageExportCellElement, rectangle, tmpRectangle); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private boolean needPaintCell(@NotNull Rectangle rectangle) { |
||||||
|
return 0 < rectangle.width && 0 < rectangle.height; |
||||||
|
} |
||||||
|
|
||||||
|
private boolean shouldPaintCellBackground(CellGUIAttr cellGUIAttr) { |
||||||
|
return this.isPrint && cellGUIAttr.isPrintBackground() || !this.isPrint && cellGUIAttr.isPrintBackground(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2022 |
||||||
|
* Project: starter |
||||||
|
* FileName: DocSummaryTab |
||||||
|
* Author: xx |
||||||
|
* Date: 2022/1/4 13:55 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ajhdf.provider; |
||||||
|
|
||||||
|
import com.fr.design.beans.BasicStorePane; |
||||||
|
import com.fr.design.fun.impl.AbstractExportAttrTabProvider; |
||||||
|
import com.fr.plugin.ajhdf.ui.PdfExportPane; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <DocSummaryTab> |
||||||
|
* |
||||||
|
* @author xx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class DocSummaryTab extends AbstractExportAttrTabProvider { |
||||||
|
@Override |
||||||
|
public BasicStorePane<?> toServiceComponent() { |
||||||
|
return new PdfExportPane(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
package com.fr.plugin.ajhdf.provider; |
||||||
|
|
||||||
|
import com.fanruan.api.i18n.I18nKit; |
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fr.io.collection.ExportCollection; |
||||||
|
import com.fr.plugin.ajhdf.operate.CustomPDFOperate; |
||||||
|
import com.fr.plugin.context.PluginContexts; |
||||||
|
import com.fr.stable.fun.Authorize; |
||||||
|
import com.fr.web.core.ReportSessionIDInfor; |
||||||
|
import com.fr.web.core.reserve.DefaultExportExtension; |
||||||
|
import com.fr.web.core.reserve.DefaultOperate; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import static com.fr.plugin.ajhdf.LocaleFinder.PLUGIN_ID; |
||||||
|
|
||||||
|
/** |
||||||
|
* 默认的实现是在DefaultExportExtension里面的,因为修改的只是pdf导出的部分逻辑 |
||||||
|
* 所以直接继承DefaultExportExtension |
||||||
|
*/ |
||||||
|
@Authorize(callSignKey = PLUGIN_ID) |
||||||
|
public class FileExportExtension extends DefaultExportExtension { |
||||||
|
private static Map<String, DefaultOperate> operateMap = new HashMap<String, DefaultOperate>(); |
||||||
|
|
||||||
|
static { |
||||||
|
operateMap.put("pdf", new CustomPDFOperate()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ExportCollection createCollection(HttpServletRequest req, HttpServletResponse res, ReportSessionIDInfor reportSessionIDInfor, String format, String fileName, boolean isEmbed) throws Exception { |
||||||
|
if (PluginContexts.currentContext() == null || !PluginContexts.currentContext().isAvailable()) { |
||||||
|
LogKit.error(I18nKit.getLocText("Plugin-ajhdf_licence_Expired")); |
||||||
|
return super.createCollection(req, res, reportSessionIDInfor, format, fileName, isEmbed); |
||||||
|
} |
||||||
|
DefaultOperate operate = operateMap.get(format.toLowerCase()); |
||||||
|
if (operate != null) { |
||||||
|
return operate.newExportCollection(req, res, reportSessionIDInfor, fileName); |
||||||
|
} |
||||||
|
return super.createCollection(req, res, reportSessionIDInfor, format, fileName, isEmbed); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,79 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2022 |
||||||
|
* Project: starter |
||||||
|
* FileName: PdfExportAttr |
||||||
|
* Author: xx |
||||||
|
* Date: 2022/1/4 13:58 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ajhdf.provider; |
||||||
|
|
||||||
|
import com.fr.json.JSONException; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.stable.fun.Authorize; |
||||||
|
import com.fr.stable.fun.impl.AbstractIOFileAttrMark; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
|
||||||
|
import static com.fr.plugin.ajhdf.LocaleFinder.PLUGIN_ID; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <PdfExportAttr> |
||||||
|
* |
||||||
|
* @author xx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@Authorize(callSignKey = PLUGIN_ID) |
||||||
|
public class PdfExportAttr extends AbstractIOFileAttrMark { |
||||||
|
public final static String XML_TAG = "PdfExportAttr"; |
||||||
|
private static final long serialVersionUID = 6037990832141495913L; |
||||||
|
// 边框缩放比例,参考GraphDrawHelper.drawLine() -> draw() -> getStroke() -> zoomStroke()
|
||||||
|
private float strokeScale; |
||||||
|
|
||||||
|
public PdfExportAttr() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String xmlTag() { |
||||||
|
return XML_TAG; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
if (reader.isChildNode()) { |
||||||
|
String tagName = reader.getTagName(); |
||||||
|
if ("Attr".equals(tagName)) { |
||||||
|
setStrokeScale(reader.getAttrAsFloat("strokeScale", 1.0F)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
writer.startTAG("Attr"); |
||||||
|
writer.attr("strokeScale", this.strokeScale); |
||||||
|
writer.end(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public PdfExportAttr clone() { |
||||||
|
PdfExportAttr cloned = (PdfExportAttr) super.clone(); |
||||||
|
cloned.strokeScale = strokeScale; |
||||||
|
return cloned; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JSONObject createJSONConfig() throws JSONException { |
||||||
|
JSONObject json = super.createJSONConfig(); |
||||||
|
json.put("strokeScale", this.strokeScale); |
||||||
|
return json; |
||||||
|
} |
||||||
|
|
||||||
|
public float getStrokeScale() { |
||||||
|
return strokeScale; |
||||||
|
} |
||||||
|
|
||||||
|
public void setStrokeScale(float strokeScale) { |
||||||
|
this.strokeScale = strokeScale; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,99 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2022 |
||||||
|
* Project: starter |
||||||
|
* FileName: StylePDF |
||||||
|
* Author: xx |
||||||
|
* Date: 2022/9/27 14:59 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ajhdf.style; |
||||||
|
|
||||||
|
import com.fr.base.GraphHelper; |
||||||
|
import com.fr.base.Style; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.stable.GraphDrawHelper; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <StylePDF> |
||||||
|
* |
||||||
|
* @author xx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class StylePDF extends Style { |
||||||
|
private static final long serialVersionUID = -1498763211837836528L; |
||||||
|
|
||||||
|
public static void paintBorder(Graphics2D g2d, Style style, Rectangle paintRectangle, Rectangle clipRectangle, float scale) { |
||||||
|
if (ComparatorUtils.equals(paintRectangle.width, 0) || ComparatorUtils.equals(paintRectangle.height, 0)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
g2d.translate(paintRectangle.getX(), paintRectangle.getY()); |
||||||
|
Rectangle rectangle = new Rectangle(0, 0, paintRectangle.width, paintRectangle.height); |
||||||
|
if (clipRectangle != null) { |
||||||
|
rectangle = rectangle.intersection(clipRectangle); |
||||||
|
} |
||||||
|
g2d.translate(rectangle.getX(), rectangle.getY()); |
||||||
|
if (style == null) { |
||||||
|
style = DEFAULT_STYLE; |
||||||
|
} |
||||||
|
paintBorder(g2d, style, rectangle.getWidth(), rectangle.getHeight(), scale); |
||||||
|
g2d.translate(-rectangle.getX(), -rectangle.getY()); |
||||||
|
g2d.translate(-paintRectangle.getX(), -paintRectangle.getY()); |
||||||
|
} |
||||||
|
|
||||||
|
public static void paintBorder(Graphics2D g2d, Style style, double width, double height, float scale) { |
||||||
|
if (style == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
double borderLeftMargin = 0.0; |
||||||
|
double borderRightMargin = 0.0; |
||||||
|
int borderLeft; |
||||||
|
if (style.getBorderLeft() != 0) { |
||||||
|
borderLeft = GraphHelper.getLineStyleSize(style.getBorderLeft()); |
||||||
|
borderLeftMargin = (double) (borderLeft / 2); |
||||||
|
} |
||||||
|
|
||||||
|
if (style.getBorderRight() != 0) { |
||||||
|
borderLeft = GraphHelper.getLineStyleSize(style.getBorderRight()); |
||||||
|
borderRightMargin = (double) (borderLeft / 2); |
||||||
|
} |
||||||
|
|
||||||
|
double borderTopMarign = 0.0; |
||||||
|
double borderBottomMargin = 0.0; |
||||||
|
int borderTop; |
||||||
|
if (style.getBorderTop() != 0) { |
||||||
|
borderTop = GraphHelper.getLineStyleSize(style.getBorderTop()); |
||||||
|
borderTopMarign = (double) (borderTop / 2); |
||||||
|
} |
||||||
|
|
||||||
|
if (style.getBorderBottom() != 0) { |
||||||
|
borderTop = GraphHelper.getLineStyleSize(style.getBorderBottom()); |
||||||
|
borderBottomMargin = (double) (borderTop / 2); |
||||||
|
} |
||||||
|
|
||||||
|
if (style.getBorderTop() != 0) { |
||||||
|
g2d.setPaint(style.getBorderTopColor()); |
||||||
|
// 改为传入scale,调整边框粗细
|
||||||
|
GraphDrawHelper.drawLine(g2d, 0.0 - borderLeftMargin, 0.0, width + borderRightMargin, 0.0, style.getBorderTop(), scale); |
||||||
|
} |
||||||
|
|
||||||
|
if (style.getBorderLeft() != 0) { |
||||||
|
g2d.setPaint(style.getBorderLeftColor()); |
||||||
|
// 改为传入scale,调整边框粗细
|
||||||
|
GraphDrawHelper.drawLine(g2d, 0.0, 0.0 - borderTopMarign, 0.0, height + borderBottomMargin, style.getBorderLeft(), scale); |
||||||
|
} |
||||||
|
|
||||||
|
if (style.getBorderBottom() != 0) { |
||||||
|
g2d.setPaint(style.getBorderBottomColor()); |
||||||
|
// 改为传入scale,调整边框粗细
|
||||||
|
GraphDrawHelper.drawLine(g2d, 0.0 - borderLeftMargin, height, width + borderRightMargin, height, style.getBorderBottom(), scale); |
||||||
|
} |
||||||
|
|
||||||
|
if (style.getBorderRight() != 0) { |
||||||
|
g2d.setPaint(style.getBorderRightColor()); |
||||||
|
// 改为传入scale,调整边框粗细
|
||||||
|
GraphDrawHelper.drawLine(g2d, width, 0.0 - borderTopMarign, width, height + borderBottomMargin, style.getBorderRight(), scale); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,96 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2022 |
||||||
|
* Project: starter |
||||||
|
* FileName: PdfExportPane |
||||||
|
* Author: xx |
||||||
|
* Date: 2022/1/4 13:59 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.ajhdf.ui; |
||||||
|
|
||||||
|
import com.fanruan.api.design.DesignKit; |
||||||
|
import com.fanruan.api.design.ui.component.UILabel; |
||||||
|
import com.fanruan.api.design.ui.component.UITextField; |
||||||
|
import com.fanruan.api.design.ui.layout.TableLayoutKit; |
||||||
|
import com.fanruan.api.i18n.I18nKit; |
||||||
|
import com.fanruan.api.util.StringKit; |
||||||
|
import com.fr.base.io.BaseBook; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.report.AbstractExportPane; |
||||||
|
import com.fr.plugin.ajhdf.provider.PdfExportAttr; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <PdfExportPane> |
||||||
|
* |
||||||
|
* @author xx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class PdfExportPane extends AbstractExportPane { |
||||||
|
private static final long serialVersionUID = -3364831983419854602L; |
||||||
|
private final UITextField strokeScaleTextField; |
||||||
|
|
||||||
|
public PdfExportPane() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); |
||||||
|
|
||||||
|
UILabel strokeScaleLabel = new UILabel(I18nKit.getLocText("Plugin-ajhdf_Stroke_Scale")); |
||||||
|
strokeScaleTextField = new UITextField(10); |
||||||
|
|
||||||
|
double p = TableLayoutKit.PREFERRED; |
||||||
|
double f = TableLayoutKit.FILL; |
||||||
|
double[] columnSize = new double[]{p, f}; |
||||||
|
double[] rowSize = new double[]{p, p, p}; |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{strokeScaleLabel, strokeScaleTextField}, |
||||||
|
}; |
||||||
|
JPanel propertiesPane = TableLayoutKit.createTableLayoutPane(components, rowSize, columnSize); |
||||||
|
|
||||||
|
JPanel customPropertiesPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); |
||||||
|
customPropertiesPane.add(propertiesPane, BorderLayout.CENTER); |
||||||
|
JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(DesignKit.i18nText("Plugin-ajhdf_Custom_Properties_Title")); |
||||||
|
centerPane.add(customPropertiesPane, BorderLayout.CENTER); |
||||||
|
this.add(centerPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populate(Object attr) { |
||||||
|
populateBean(attr); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update(Object attr) { |
||||||
|
updateBean(attr); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(Object attr) { |
||||||
|
BaseBook target = DesignerContext.getDesignerFrame().getSelectedJTemplate().getTarget(); |
||||||
|
PdfExportAttr pdfExportAttr = target.getAttrMark(PdfExportAttr.XML_TAG); |
||||||
|
if (null != pdfExportAttr) { |
||||||
|
this.strokeScaleTextField.setText(String.valueOf(pdfExportAttr.getStrokeScale())); |
||||||
|
} else { |
||||||
|
this.strokeScaleTextField.setText("1.0"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateBean(Object attr) { |
||||||
|
BaseBook target = DesignerContext.getDesignerFrame().getSelectedJTemplate().getTarget(); |
||||||
|
PdfExportAttr pdfExportAttr = target.getAttrMark(PdfExportAttr.XML_TAG); |
||||||
|
if (null == pdfExportAttr) { |
||||||
|
pdfExportAttr = new PdfExportAttr(); |
||||||
|
target.addAttrMark(pdfExportAttr); |
||||||
|
} |
||||||
|
float scale = StringKit.isBlank(this.strokeScaleTextField.getText()) ? 1.0F : Float.parseFloat(this.strokeScaleTextField.getText()); |
||||||
|
pdfExportAttr.setStrokeScale(scale); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return DesignKit.i18nText("Plugin-ajhdf_Pdf_Export_Attributes"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
Plugin-ajhdf=PDF Export Custom Plugin |
||||||
|
Plugin-ajhdf_licence_Expired=PDF Export Custom Plugin Licence Expired |
||||||
|
Plugin-ajhdf_Pdf_Export_Attributes=PDF Export Attributes |
||||||
|
Plugin-ajhdf_Custom_Properties_Title=Excel Export Custom Properties |
||||||
|
Plugin-ajhdf_Stroke_Scale=Border Scale: |
@ -0,0 +1,5 @@ |
|||||||
|
Plugin-ajhdf=PDF Export Custom Plugin |
||||||
|
Plugin-ajhdf_licence_Expired=PDF Export Custom Plugin Licence Expired |
||||||
|
Plugin-ajhdf_Pdf_Export_Attributes=PDF Export Attributes |
||||||
|
Plugin-ajhdf_Custom_Properties_Title=Excel Export Custom Properties |
||||||
|
Plugin-ajhdf_Stroke_Scale=Border Scale: |
@ -0,0 +1,5 @@ |
|||||||
|
Plugin-ajhdf=\u5BFC\u51FAPDF\u6587\u6863\u5B9A\u5236\u63D2\u4EF6 |
||||||
|
Plugin-ajhdf_licence_Expired=\u5BFC\u51FAPDF\u6587\u6863\u5B9A\u5236\u63D2\u4EF6\u6388\u6743\u8BB8\u53EF\u8FC7\u671F |
||||||
|
Plugin-ajhdf_Pdf_Export_Attributes=PDF\u5BFC\u51FA\u5C5E\u6027 |
||||||
|
Plugin-ajhdf_Custom_Properties_Title=PDF\u5BFC\u51FA\u81EA\u5B9A\u4E49\u5C5E\u6027 |
||||||
|
Plugin-ajhdf_Stroke_Scale=\u8FB9\u6846\u7F29\u653E\u6BD4\u4F8B\uFF1A |
Loading…
Reference in new issue