diff --git a/build.xml b/build.xml index 8e951e5..c8ef9b5 100644 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ - + diff --git a/lib/finekit-10.0.jar b/lib/finekit-10.0.jar new file mode 100644 index 0000000..1b13991 Binary files /dev/null and b/lib/finekit-10.0.jar differ diff --git a/plugin.xml b/plugin.xml index c71f871..1d3c347 100644 --- a/plugin.xml +++ b/plugin.xml @@ -4,12 +4,13 @@ com.fr.plugin.export yes - 3.0 + 4.0 10.0 - 2018-10-21 + 2019-09-25 author [2017-12-21]修复功能点记录重复的问题。
[2017-12-21]适配9.0同时修复导出时可能出现空指针错误。
[2016-01-25]修复xml导出无法正确导出带有格式信息的单元格内容。
diff --git a/pom.xml b/pom.xml index c606d7d..4402f37 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,15 @@ jar demo-export-xml + + + com.fanruan.api + finekit + 10.0 + system + ${project.basedir}/lib/finekit-10.0.jar + + ${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.export.xml-1.0/classes diff --git a/src/main/java/com/fr/plugin/export/xml/XmlFileHandler.java b/src/main/java/com/fr/plugin/export/xml/XmlFileHandler.java index ad4aa1f..31f70c7 100644 --- a/src/main/java/com/fr/plugin/export/xml/XmlFileHandler.java +++ b/src/main/java/com/fr/plugin/export/xml/XmlFileHandler.java @@ -1,6 +1,6 @@ package com.fr.plugin.export.xml; -import com.fr.stable.EncodeConstants; +import com.fanruan.api.macro.EncodeConstants; import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; /** diff --git a/src/main/java/com/fr/plugin/export/xml/core/IconLoader.java b/src/main/java/com/fr/plugin/export/xml/core/IconLoader.java index 66dde4e..706d806 100644 --- a/src/main/java/com/fr/plugin/export/xml/core/IconLoader.java +++ b/src/main/java/com/fr/plugin/export/xml/core/IconLoader.java @@ -1,8 +1,6 @@ package com.fr.plugin.export.xml.core; -import com.fr.base.Icon; -import com.fr.base.IconManager; -import com.fr.general.IOUtils; +import com.fanruan.api.report.SundryKit; /** @@ -11,8 +9,8 @@ import com.fr.general.IOUtils; public class IconLoader { public static String loadIcon() { - Icon icon = new Icon("xml", IOUtils.readImage("/com/fr/plugin/export/xml/images/xml16.png")); - IconManager.getIconManager().addIcon(icon, true); - return icon.getName(); + String name = "xml"; + SundryKit.loadToolbarIcon(name, "/com/fr/plugin/export/xml/images/xml16.png"); + return name; } } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/export/xml/core/XmlExportOperate.java b/src/main/java/com/fr/plugin/export/xml/core/XmlExportOperate.java index 3c3a112..b9c3a8e 100644 --- a/src/main/java/com/fr/plugin/export/xml/core/XmlExportOperate.java +++ b/src/main/java/com/fr/plugin/export/xml/core/XmlExportOperate.java @@ -1,12 +1,10 @@ package com.fr.plugin.export.xml.core; +import com.fanruan.api.report.export.BaseOperate; import com.fr.general.DeclareRecordType; import com.fr.io.collection.ExportCollection; -import com.fr.io.exporter.CSVExporter; import com.fr.plugin.export.xml.exporter.XmlExporter; -import com.fr.web.core.ReportSessionIDInfor; -import com.fr.web.core.reserve.DefaultOperate; -import com.fr.web.core.utils.ExportUtils; +import com.fr.stable.web.SessionProvider; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -14,7 +12,7 @@ import javax.servlet.http.HttpServletResponse; /** * Created by richie on 16/1/19. */ -public class XmlExportOperate extends DefaultOperate { +public class XmlExportOperate extends BaseOperate { @Override public void setContent(HttpServletRequest req, HttpServletResponse res, String fileName, boolean isEmbed) { @@ -24,7 +22,7 @@ public class XmlExportOperate extends DefaultOperate { } @Override - public ExportCollection createCollection(HttpServletRequest req, HttpServletResponse res, ReportSessionIDInfor sessionIDInfor, String fileName) { + public ExportCollection newExportCollection(HttpServletRequest req, HttpServletResponse res, SessionProvider sessionIDInfor, String fileName) { ExportCollection collection = ExportCollection.create(); collection.setExporter(new XmlExporter()); collection.setRecordType(DeclareRecordType.EXPORT_TYPE_CSV); diff --git a/src/main/java/com/fr/plugin/export/xml/core/XmlExtensionButton.java b/src/main/java/com/fr/plugin/export/xml/core/XmlExtensionButton.java index 1f6a112..1d3b88b 100644 --- a/src/main/java/com/fr/plugin/export/xml/core/XmlExtensionButton.java +++ b/src/main/java/com/fr/plugin/export/xml/core/XmlExtensionButton.java @@ -1,8 +1,8 @@ package com.fr.plugin.export.xml.core; -import com.fr.form.ui.WebContentUtils; +import com.fanruan.api.i18n.I18nKit; import com.fr.form.ui.Widget; -import com.fr.general.Inter; +import com.fr.js.JavaScript; import com.fr.js.JavaScriptImpl; import com.fr.report.fun.impl.AbstractExtensionButton; import com.fr.stable.web.Repository; @@ -10,10 +10,10 @@ import com.fr.stable.web.Repository; /** * Created by richie on 15/12/15. */ -public class XmlExtensionButton extends AbstractExtensionButton{ +public class XmlExtensionButton extends AbstractExtensionButton { public XmlExtensionButton() { - super(Inter.getLocText("Plugin-Xml_Export"), IconLoader.loadIcon()); + super(I18nKit.getLocText("Plugin-Xml_Export"), IconLoader.loadIcon()); } public XmlExtensionButton(String text) { @@ -55,7 +55,7 @@ public class XmlExtensionButton extends AbstractExtensionButton{ } @Override - protected JavaScriptImpl clickAction(Repository repo) { - return new JavaScriptImpl(WebContentUtils.getContentPanel(repo) + ".exportReportToXML()"); + protected JavaScript clickAction(Repository repo) { + return new JavaScriptImpl("_g().exportReportToXML()"); } } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/export/xml/exporter/XmlExporter.java b/src/main/java/com/fr/plugin/export/xml/exporter/XmlExporter.java index f74e6c0..b576c92 100644 --- a/src/main/java/com/fr/plugin/export/xml/exporter/XmlExporter.java +++ b/src/main/java/com/fr/plugin/export/xml/exporter/XmlExporter.java @@ -1,27 +1,22 @@ package com.fr.plugin.export.xml.exporter; +import com.fanruan.api.log.LogKit; +import com.fanruan.api.report.PrintKit; +import com.fanruan.api.report.export.BaseAppExporter; +import com.fanruan.api.util.GeneralKit; +import com.fanruan.api.util.StringKit; import com.fr.base.Style; -import com.fr.general.FRLogger; -import com.fr.general.GeneralUtils; -import com.fr.io.core.ExporterUtils; -import com.fr.io.exporter.AbstractAppExporter; -import com.fr.log.FineLoggerFactory; import com.fr.main.workbook.ResultWorkBook; import com.fr.page.ClippedPageProvider; import com.fr.page.PageSetProvider; import com.fr.page.PaperSettingProvider; import com.fr.page.ReportPageProvider; -import com.fr.plugin.PluginLicense; -import com.fr.plugin.PluginLicenseManager; -import com.fr.plugin.export.xml.core.XmlConstants; +import com.fr.plugin.context.PluginContexts; import com.fr.report.cell.CellElement; -import com.fr.report.cell.cellattr.CellGUIAttr; -import com.fr.report.core.ReportUtils; import com.fr.report.elementcase.ElementGetter; import com.fr.report.report.ECReport; import com.fr.report.report.ResultReport; import com.fr.stable.EncodeConstants; -import com.fr.stable.StringUtils; import java.io.OutputStream; import java.io.OutputStreamWriter; @@ -33,11 +28,11 @@ import java.util.List; /** * Created by richie on 16/1/21. */ -public class XmlExporter extends AbstractAppExporter { +public class XmlExporter extends BaseAppExporter { @Override public void export(OutputStream out, ResultWorkBook book) throws Exception { - List paperSettingList = ReportUtils.getPaperSettingListFromWorkBook(book); + List paperSettingList = PrintKit.getPaperSettings(book); for (int i = 0, len = book.getReportCount(); i < len; i++) { this.export(out, book.getResultReport(i), (PaperSettingProvider) paperSettingList.get(i)); } @@ -47,7 +42,7 @@ public class XmlExporter extends AbstractAppExporter { public void export(java.io.OutputStream out, PageSetProvider pageSet) throws Exception { for (int i = 0; i < pageSet.size(); i++) { ReportPageProvider reportPage = pageSet.getPage(i); - ClippedPageProvider page = ExporterUtils.support(reportPage); + ClippedPageProvider page = PrintKit.pick(reportPage); if (page == null) { break; } @@ -58,14 +53,13 @@ public class XmlExporter extends AbstractAppExporter { private void export(OutputStream out, ResultReport report, PaperSettingProvider paperSetting) throws Exception { if (report != null) { - FineLoggerFactory.getLogger().info("UnLayerReport start export"); + LogKit.info("UnLayerReport start export"); exportReport(out, (ECReport) report, 0, (report).getRowCount()); } } public void exportReport(OutputStream out, ElementGetter reportCase, int start, int end) throws Exception { - PluginLicense license = PluginLicenseManager.getInstance().getPluginLicenseByID(XmlConstants.PLUGIN_ID); - if (license != null && license.isAvailable()) { + if (PluginContexts.currentContext().isAvailable()) { PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, EncodeConstants.ENCODING_UTF_8)); StringBuilder xmlBuffer = new StringBuilder(); xmlBuffer.append(""); @@ -76,17 +70,26 @@ public class XmlExporter extends AbstractAppExporter { while (it.hasNext()) { xmlBuffer.append(""); + String exportText; CellElement cell = (CellElement) it.next(); - Object value = getCellValue(cell); - Style style = cell.getStyle(); - String str; - if (style != null) { - Format format = style.getFormat(); - str = Style.valueToText(value, format); + if (cell == null) { + exportText = StringKit.EMPTY; } else { - str = GeneralUtils.objectToString(value); + boolean export = PrintKit.isCellPrintable(cell); + if (export) { + Object value = cell.getValue(); + Style style = cell.getStyle(); + if (style != null) { + Format format = style.getFormat(); + exportText = Style.valueToText(value, format); + } else { + exportText = GeneralKit.objectToString(value); + } + } else { + exportText = StringKit.EMPTY; + } } - xmlBuffer.append(str); + xmlBuffer.append(exportText); xmlBuffer.append(""); } @@ -99,19 +102,4 @@ public class XmlExporter extends AbstractAppExporter { throw new RuntimeException("XML Export Plugin License Expired!"); } } - - - private Object getCellValue(CellElement cell) { - if (cell == null) { - return null; - } - Object value = cell.getValue(); - CellGUIAttr gui = cell.getCellGUIAttr(); - if (gui != null && !gui.isPrintContent()) { - value = StringUtils.EMPTY; - } - return value == null ? StringUtils.EMPTY : value; - } - - } \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/export/xml/ui/XmlExportToolbarUI.java b/src/main/java/com/fr/plugin/export/xml/ui/XmlExportToolbarUI.java index c647414..1a6a1ef 100644 --- a/src/main/java/com/fr/plugin/export/xml/ui/XmlExportToolbarUI.java +++ b/src/main/java/com/fr/plugin/export/xml/ui/XmlExportToolbarUI.java @@ -1,8 +1,8 @@ package com.fr.plugin.export.xml.ui; +import com.fanruan.api.i18n.I18nKit; import com.fr.design.fun.impl.AbstractToolbarItem; import com.fr.form.ui.Widget; -import com.fr.locale.InterProviderFactory; import com.fr.plugin.export.xml.core.XmlExtensionButton; /** @@ -21,6 +21,6 @@ public class XmlExportToolbarUI extends AbstractToolbarItem { @Override public String nameForWidget() { - return InterProviderFactory.getProvider().getLocText("Plugin-Xml_Export"); + return I18nKit.getLocText("Plugin-Xml_Export"); } } \ No newline at end of file