import {JRBaseFactory} from "./JRBaseFactory"; import {Report} from "../../items/Report"; import {Unit, SizeUnit} from "../../drawing/Unit"; import {PaperSettings} from "../../drawing/PaperSettings"; import {PaperKind} from "../../drawing/PaperKind"; import {SchemaConstants} from "../SchemaConstants"; export class SchemaDesignFactory extends JRBaseFactory { createObject(atts:{}):any { this.getDigester().peek(this.getDigester().getCount() - 1); // page width and height let pageWidth = atts[SchemaConstants.ATTRIBUTE_pageWidth]; let pageHeight = atts[SchemaConstants.ATTRIBUTE_pageHeight]; // new report with paper const pageKind:string = atts[SchemaConstants.ATTRIBUTE_pageKind]; const paper = new PaperSettings(); if (pageKind !== 'Custom') { paper.paperKind = PaperKind[pageKind]; } else { paper.paperKind = PaperKind.Custom; paper.paperSize = new SizeUnit(Unit.from(pageWidth), Unit.from(pageHeight)); } const report = new Report(paper); report.name = atts[SchemaConstants.ATTRIBUTE_name]; if (atts[SchemaConstants.ATTRIBUTE_bandWidth]) { report.bandWidth = Unit.from(atts[SchemaConstants.ATTRIBUTE_bandWidth]); } const columnCount = atts[SchemaConstants.ATTRIBUTE_columnCount]; if (columnCount) { report.columnCount = parseInt(columnCount); } // const columnWidth = atts[SchemaConstants.ATTRIBUTE_columnWidth]; // if (columnWidth) { // report.columnWidth = parseInt(columnWidth); // } const leftMargin = atts[SchemaConstants.ATTRIBUTE_leftMargin]; if (leftMargin) { report.leftMargin = Unit.pixel(parseInt(leftMargin)); } const rightMargin = atts[SchemaConstants.ATTRIBUTE_rightMargin]; if (leftMargin) { report.rightMargin = Unit.pixel(parseInt(rightMargin)); } const topMargin = atts[SchemaConstants.ATTRIBUTE_topMargin]; if (topMargin) { report.topMargin = Unit.pixel(parseInt(topMargin)); } const bottomMargin = atts[SchemaConstants.ATTRIBUTE_bottomMargin]; if (bottomMargin) { report.bottomMargin = Unit.pixel(parseInt(bottomMargin)); } const uuid = atts[SchemaConstants.ATTRIBUTE_uuid]; if (uuid) { report.objectId = uuid; } return report; } }