'use strict'; const JV = require('../jpc_value_define'); const JpcCommonHelper = require('./jpc_helper_common'); const JpcFlowTabHelper = { getRowHeight(bands, rptTpl, isEx) { let rst = 0; const FLOW_INFO_STR = (!isEx) ? JV.NODE_FLOW_INFO : JV.NODE_FLOW_INFO_EX; const tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT]; const band = bands[tab[JV.PROP_BAND_NAME]]; if (band) { let maxFieldMeasure = 1.0; if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) { const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl); maxFieldMeasure = 1.0 * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor; } else { maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT; } rst = maxFieldMeasure; } return rst; }, getMaxRowsPerPage(bands, rptTpl, isEx) { let rst = 1; const FLOW_INFO_STR = (!isEx) ? JV.NODE_FLOW_INFO : JV.NODE_FLOW_INFO_EX; const tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT]; const band = bands[tab[JV.PROP_BAND_NAME]]; if (band) { let maxFieldMeasure = 1.0; if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) { const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl); maxFieldMeasure = 1.0 * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor; } else { maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT; } rst = Math.floor((band.Bottom - band.Top) / maxFieldMeasure); } return rst; }, getActualContentAreaHeight(bands, rptTpl, segments, rowAmt, page, isEx) { let rst = 1; const FLOW_INFO_STR = (!isEx) ? JV.NODE_FLOW_INFO : JV.NODE_FLOW_INFO_EX; const tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT]; const band = bands[tab[JV.PROP_BAND_NAME]]; if (band) { let maxFieldMeasure = 1.0; if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) { const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl); maxFieldMeasure = 1.0 * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor; } else { maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT; } if (segments.length >= page) { rst = rowAmt * maxFieldMeasure; } } return rst; }, chkSegEnd(bands, rptTpl, segmentLength, preRec, pageRecAmt, isEx) { let me = this, rst = false; const remainAmt = preRec + pageRecAmt - segmentLength; rst = me.hasEnoughSpace(rptTpl, bands, remainAmt, isEx); return rst; }, hasEnoughSpace(rptTpl, bands, remainAmt, isEx) { if (remainAmt < 0) return false; let rst = true, measurement = 1.0, douDiffForCompare = 0.00001; const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl); const FLOW_INFO_STR = (!isEx) ? JV.NODE_FLOW_INFO : JV.NODE_FLOW_INFO_EX; const tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT]; const band = bands[tab[JV.PROP_BAND_NAME]]; if (band !== null && band !== undefined) { measurement = 1.0 * tab[JV.PROP_CMN_HEIGHT] * unitFactor; const spareHeight = measurement * remainAmt; const douH = band.Bottom - band.Top; rst = ((spareHeight >= douH) || ((spareHeight - douH) <= douDiffForCompare)); } return rst; }, }; module.exports = JpcFlowTabHelper;