Input:
set up facesCell s attribute from poiCell and others . [CODESPLIT] public static void convertCell ( final SheetConfiguration sheetConfig , final FacesCell fcell , final Cell poiCell , final Map < String , CellRangeAddress > cellRangeMap , final int originRowIndex , final CellAttributesMap cellAttributesMap , final String saveAttrs ) { CellRangeAddress caddress ; String key = getCellIndexNumberKey ( poiCell ) ; caddress = cellRangeMap . get ( key ) ; if ( caddress != null ) { // has col or row span
 fcell . setColspan ( caddress . getLastColumn ( ) - caddress . getFirstColumn ( ) + 1 ) ; fcell . setRowspan ( caddress . getLastRow ( ) - caddress . getFirstRow ( ) + 1 ) ; } CellControlsUtility . setupControlAttributes ( originRowIndex , fcell , poiCell , sheetConfig , cellAttributesMap ) ; fcell . setHasSaveAttr ( SaveAttrsUtility . isHasSaveAttr ( poiCell , saveAttrs ) ) ; }


Input: Gets the row col from component attributes . [CODESPLIT] public static int [ ] getRowColFromComponentAttributes ( final UIComponent target ) { int rowIndex = ( Integer ) target . getAttributes ( ) . get ( "data-row" ) ; int colIndex = ( Integer ) target . getAttributes ( ) . get ( "data-column" ) ; int [ ] list = new int [ 2 ] ; list [ 0 ] = rowIndex ; list [ 1 ] = colIndex ; return list ; }


Input: Gets the inits the rows from config . [CODESPLIT] public static int getInitRowsFromConfig ( final SheetConfiguration sheetConfig ) { int initRows = 1 ; if ( "Repeat" . equalsIgnoreCase ( sheetConfig . getFormBodyType ( ) ) ) { initRows = sheetConfig . getBodyInitialRows ( ) ; if ( initRows < 1 ) { initRows = 1 ; } } return initRows ; }


Input: Gets the faces row from body row . [CODESPLIT] public static FacesRow getFacesRowFromBodyRow ( final int row , final List < FacesRow > bodyRows , final int topRow ) { FacesRow frow = null ; try { frow = bodyRows . get ( row - topRow ) ; } catch ( Exception e ) { LOG . log ( Level . SEVERE , "getFacesRowFromBodyRow Error row = " + row + "top row = " + topRow + " ; error = " + e . getLocalizedMessage ( ) , e ) ; } return frow ; }


Input: Gets the faces cell from body row . [CODESPLIT] public static FacesCell getFacesCellFromBodyRow ( final int row , final int col , final List < FacesRow > bodyRows , final int topRow , final int leftCol ) { FacesCell cell = null ; try { cell = bodyRows . get ( row - topRow ) . getCells ( ) . get ( col - leftCol ) ; } catch ( Exception e ) { LOG . log ( Level . SEVERE , "getFacesCellFromBodyRow Error row = " + row + " col = " + col + "top row = " + topRow + " leftCol = " + leftCol + " ; error = " + e . getLocalizedMessage ( ) , e ) ; } return cell ; }


Input: Gets the poi cell with row col from current page . [CODESPLIT] public static Cell getPoiCellWithRowColFromCurrentPage ( final int rowIndex , final int colIndex , final Workbook wb ) { if ( wb != null ) { return getPoiCellFromSheet ( rowIndex , colIndex , wb . getSheetAt ( wb . getActiveSheetIndex ( ) ) ) ; } return null ; }


Input: Gets the poi cell from sheet . [CODESPLIT] public static Cell getPoiCellFromSheet ( final int rowIndex , final int colIndex , final Sheet sheet1 ) { if ( ( sheet1 != null ) && ( sheet1 . getRow ( rowIndex ) != null ) ) { return sheet1 . getRow ( rowIndex ) . getCell ( colIndex ) ; } return null ; }


Input: Gets the skey from poi cell . [CODESPLIT] public static String getSkeyFromPoiCell ( final Cell poiCell ) { return poiCell . getSheet ( ) . getSheetName ( ) + "!" + CellUtility . getCellIndexNumberKey ( poiCell . getColumnIndex ( ) , poiCell . getRowIndex ( ) ) ; }


Input: Gets the or add tie cell in map . [CODESPLIT] public static TieCell getOrAddTieCellInMap ( final Cell poiCell , HashMap < String , TieCell > tieCells ) { String skey = CellUtility . getSkeyFromPoiCell ( poiCell ) ; TieCell tieCell = tieCells . get ( skey ) ; if ( tieCell == null ) { tieCell = new TieCell ( ) ; tieCell . setSkey ( skey ) ; tieCells . put ( skey , tieCell ) ; } return tieCell ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ SuppressWarnings ( "rawtypes" ) @ Override public List getSerListFromCtObjChart ( final Object ctObjChart ) { if ( ctObjChart instanceof CTBarChart ) { return ( ( CTBarChart ) ctObjChart ) . getSerList ( ) ; } return emptySerlist ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ SuppressWarnings ( "rawtypes" ) @ Override public final CTAxDataSource getCtAxDataSourceFromSerList ( final List serList ) { if ( ( serList != null ) && ( ! serList . isEmpty ( ) ) && ( serList . get ( 0 ) instanceof CTBarSer ) ) { return ( ( CTBarSer ) serList . get ( 0 ) ) . getCat ( ) ; } return null ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final CTShapeProperties getShapePropertiesFromCTSer ( final Object ctObjSer ) { if ( ctObjSer instanceof CTBarSer ) { return ( ( CTBarSer ) ctObjSer ) . getSpPr ( ) ; } return null ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final CTNumDataSource getCTNumDataSourceFromCTSer ( final Object ctObjSer ) { if ( ctObjSer instanceof CTBarSer ) { return ( ( CTBarSer ) ctObjSer ) . getVal ( ) ; } return null ; }


Input: Gets the current data context name . [CODESPLIT] public final String getCurrentDataContextName ( ) { if ( currentDataContextName == null ) { StringBuilder sb = new StringBuilder ( ) ; List < String > list = this . getCurrentDataContextNameList ( ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { if ( i > 0 ) { sb . append ( ":" + list . get ( i ) ) ; } else { sb . append ( list . get ( i ) ) ; } } this . setCurrentDataContextName ( sb . toString ( ) ) ; } return currentDataContextName ; }


Input: Evaluate the expression . [CODESPLIT] public final Object evaluate ( final String expression , final Map < String , Object > context ) { JexlContext jexlContext = new MapContext ( context ) ; try { JexlEngine jexl = JEXL_LOCAL . get ( ) ; Map < String , Expression > expMap = JEXL_MAP_LOCAL . get ( ) ; Expression jexlExpression = expMap . get ( expression ) ; if ( jexlExpression == null ) { jexlExpression = jexl . createExpression ( expression ) ; expMap . put ( expression , jexlExpression ) ; } return jexlExpression . evaluate ( jexlContext ) ; } catch ( Exception e ) { throw new EvaluationException ( e ) ; } }


Input: evaluate from giving context . [CODESPLIT] public final Object evaluate ( final Map < String , Object > context ) { JexlContext jexlContext = new MapContext ( context ) ; try { return jExpression . evaluate ( jexlContext ) ; } catch ( Exception e ) { throw new EvaluationException ( "An error occurred when evaluating expression " + jExpression . getExpression ( ) , e ) ; } }


Input: save the row before serialize . [CODESPLIT] private void writeObject ( final java . io . ObjectOutputStream out ) throws IOException { this . rowIndex = this . getRow ( ) . getRowNum ( ) ; out . defaultWriteObject ( ) ; }


Input: Adds the row . [CODESPLIT] public final void addRow ( final Integer sourceRowNum , final Row targetRow ) { List < SerialRow > mapRowList = rowsMap . get ( sourceRowNum ) ; if ( mapRowList == null ) { mapRowList = new ArrayList <> ( ) ; } SerialRow serialTarget = new SerialRow ( targetRow , - 1 ) ; if ( ! mapRowList . contains ( serialTarget ) ) { mapRowList . add ( serialTarget ) ; rowsMap . put ( sourceRowNum , mapRowList ) ; } }


Input: Removes the row . [CODESPLIT] public final void removeRow ( final Integer sourceRowNum , final Row targetRow ) { List < SerialRow > mapRowList = rowsMap . get ( sourceRowNum ) ; if ( mapRowList != null ) { mapRowList . remove ( new SerialRow ( targetRow , - 1 ) ) ; rowsMap . put ( sourceRowNum , mapRowList ) ; } }


Input: Merge map . [CODESPLIT] public final void mergeMap ( final RowsMapping addMap ) { Map < Integer , List < SerialRow > > map = addMap . getRowsMap ( ) ; for ( Map . Entry < Integer , List < SerialRow > > entry : map . entrySet ( ) ) { List < SerialRow > entryRowList = entry . getValue ( ) ; if ( ( entryRowList != null ) && ( ! entryRowList . isEmpty ( ) ) ) { for ( SerialRow row : entryRowList ) { this . addRow ( entry . getKey ( ) , row . getRow ( ) ) ; } } } }


Input: recover rows mapping by using it s address . [CODESPLIT] public final void recover ( final Sheet sheet ) { for ( Map . Entry < Integer , List < SerialRow > > entry : this . getRowsMap ( ) . entrySet ( ) ) { List < SerialRow > listRow = entry . getValue ( ) ; for ( SerialRow serialRow : listRow ) { serialRow . recover ( sheet ) ; } } }


Input: return chart type from CTChart object . [CODESPLIT] public static ChartType getChartType ( final CTChart ctChart ) { CTPlotArea plotArea = ctChart . getPlotArea ( ) ; for ( ChartType chartType : ChartType . values ( ) ) { if ( chartType . isThisType ( plotArea ) ) { return chartType ; } } return null ; }


Input: Convert style string to stroke object . [CODESPLIT] public static BasicStroke toStroke ( final String style ) { BasicStroke result = null ; if ( style != null ) { float lineWidth = STROKE_DEFAULT_LINE_WIDTH ; float [ ] dash = { STROKE_DEFAULT_DASH_WIDTH } ; float [ ] dot = { lineWidth } ; if ( style . equalsIgnoreCase ( STYLE_LINE ) ) { result = new BasicStroke ( lineWidth ) ; } else if ( style . equalsIgnoreCase ( STYLE_DASH ) ) { result = new BasicStroke ( lineWidth , BasicStroke . CAP_BUTT , BasicStroke . JOIN_MITER , STROKE_MITER_LIMIT_STYLE_DASH , dash , STROKE_DEFAULT_DASHPHASE ) ; } else if ( style . equalsIgnoreCase ( STYLE_DOT ) ) { result = new BasicStroke ( lineWidth , BasicStroke . CAP_BUTT , BasicStroke . JOIN_MITER , STROKE_MITER_LIMIT_STYLE_DOT , dot , STROKE_DEFAULT_DASHPHASE ) ; } } return result ; }


Input: init chart data . [CODESPLIT] public static ChartData initChartDataFromXSSFChart ( final String chartId , final XSSFChart chart , final XSSFWorkbook wb ) { ThemesTable themeTable = wb . getStylesSource ( ) . getTheme ( ) ; ChartData chartData = new ChartData ( ) ; XSSFRichTextString chartTitle = chart . getTitle ( ) ; if ( chartTitle != null ) { chartData . setTitle ( chartTitle . toString ( ) ) ; } CTChart ctChart = chart . getCTChart ( ) ; ChartType chartType = ChartUtility . getChartType ( ctChart ) ; if ( chartType == null ) { throw new IllegalChartException ( "Unknown chart type" ) ; } chartData . setBgColor ( ColorUtility . getBgColor ( ctChart . getPlotArea ( ) , themeTable ) ) ; chartData . setId ( chartId ) ; chartData . setType ( chartType ) ; List < CTCatAx > ctCatAxList = ctChart . getPlotArea ( ) . getCatAxList ( ) ; if ( ( ctCatAxList != null ) && ( ! ctCatAxList . isEmpty ( ) ) ) { chartData . setCatAx ( new ChartAxis ( ctCatAxList . get ( 0 ) ) ) ; } List < CTValAx > ctValAxList = ctChart . getPlotArea ( ) . getValAxList ( ) ; if ( ( ctValAxList != null ) && ( ! ctValAxList . isEmpty ( ) ) ) { chartData . setValAx ( new ChartAxis ( ctValAxList . get ( 0 ) ) ) ; } ChartObject ctObj = chartType . createChartObject ( ) ; if ( ctObj == null ) { throw new IllegalChartException ( "Cannot create chart object." ) ; } setUpChartData ( chartData , ctChart , themeTable , ctObj ) ; return chartData ; }


Input:
build chartData for line chart . chartData include categoryList and seriesList which used for generate jfreechart . [CODESPLIT] public static void setUpChartData ( final ChartData chartData , final CTChart ctChart , final ThemesTable themeTable , final ChartObject ctObj ) { Object chartObj = null ; @ SuppressWarnings ( "rawtypes" ) List plotCharts = ctObj . getChartListFromCtChart ( ctChart ) ; // chart object
 if ( plotCharts != null && ( ! plotCharts . isEmpty ( ) ) ) { chartObj = plotCharts . get ( 0 ) ; } if ( chartObj != null ) { @ SuppressWarnings ( "rawtypes" ) List bsers = ctObj . getSerListFromCtObjChart ( chartObj ) ; if ( ! AppUtils . emptyList ( bsers ) ) { chartData . buildCategoryList ( ctObj . getCtAxDataSourceFromSerList ( bsers ) ) ; chartData . buildSeriesList ( bsers , themeTable , ctObj ) ; } } }


Input: retrieve anchor information from draw . xml for all the charts in the workbook . then save them to anchors map . [CODESPLIT] public static void initXSSFAnchorsMap ( final XSSFWorkbook wb , final ChartsData charsData ) { Map < String , ClientAnchor > anchortMap = charsData . getChartAnchorsMap ( ) ; Map < String , String > positionMap = charsData . getChartPositionMap ( ) ; anchortMap . clear ( ) ; positionMap . clear ( ) ; for ( int i = 0 ; i < wb . getNumberOfSheets ( ) ; i ++ ) { initXSSFAnchorsMapForSheet ( anchortMap , positionMap , wb . getSheetAt ( i ) ) ; } }


Input: Inits the XSSF anchors map for sheet . [CODESPLIT] private static void initXSSFAnchorsMapForSheet ( final Map < String , ClientAnchor > anchortMap , final Map < String , String > positionMap , final XSSFSheet sheet ) { XSSFDrawing drawing = sheet . createDrawingPatriarch ( ) ; CTDrawing ctDrawing = drawing . getCTDrawing ( ) ; if ( ctDrawing . sizeOfTwoCellAnchorArray ( ) <= 0 ) { return ; } List < CTTwoCellAnchor > alist = ctDrawing . getTwoCellAnchorList ( ) ; for ( int j = 0 ; j < alist . size ( ) ; j ++ ) { CTTwoCellAnchor ctanchor = alist . get ( j ) ; String singleChartId = getAnchorAssociateChartId ( ctanchor ) ; if ( singleChartId != null ) { String chartId = sheet . getSheetName ( ) + "!" + singleChartId ; int dx1 = ( int ) ctanchor . getFrom ( ) . getColOff ( ) ; int dy1 = ( int ) ctanchor . getFrom ( ) . getRowOff ( ) ; int dx2 = ( int ) ctanchor . getTo ( ) . getColOff ( ) ; int dy2 = ( int ) ctanchor . getTo ( ) . getRowOff ( ) ; int col1 = ctanchor . getFrom ( ) . getCol ( ) ; int row1 = ctanchor . getFrom ( ) . getRow ( ) ; int col2 = ctanchor . getTo ( ) . getCol ( ) ; int row2 = ctanchor . getTo ( ) . getRow ( ) ; anchortMap . put ( chartId , new XSSFClientAnchor ( dx1 , dy1 , dx2 , dy2 , col1 , row1 , col2 , row2 ) ) ; positionMap . put ( WebSheetUtility . getFullCellRefName ( sheet . getSheetName ( ) , row1 , col1 ) , chartId ) ; } } }


Input: Gets the anchor associate chart id . [CODESPLIT] private static String getAnchorAssociateChartId ( final CTTwoCellAnchor ctanchor ) { if ( ctanchor . getGraphicFrame ( ) == null ) { return null ; } Node parentNode = ctanchor . getGraphicFrame ( ) . getGraphic ( ) . getGraphicData ( ) . getDomNode ( ) ; NodeList childNodes = parentNode . getChildNodes ( ) ; for ( int i = 0 ; i < childNodes . getLength ( ) ; i ++ ) { Node childNode = childNodes . item ( i ) ; if ( ( childNode != null ) && ( "c:chart" . equalsIgnoreCase ( childNode . getNodeName ( ) ) ) && ( childNode . hasAttributes ( ) ) ) { String rId = getChartIdFromChildNodeAttributes ( childNode . getAttributes ( ) ) ; if ( rId != null ) { return rId ; } } } return null ; }


Input: Gets the chart id from child node attributes . [CODESPLIT] private static String getChartIdFromChildNodeAttributes ( final NamedNodeMap attrs ) { for ( int j = 0 ; j < attrs . getLength ( ) ; j ++ ) { Attr attribute = ( Attr ) attrs . item ( j ) ; if ( "r:id" . equalsIgnoreCase ( attribute . getName ( ) ) ) { return attribute . getValue ( ) ; } } return null ; }


Input: save the workbook before serialize . [CODESPLIT] private void writeObject ( final java . io . ObjectOutputStream out ) throws IOException { out . defaultWriteObject ( ) ; if ( wb != null ) { wb . write ( out ) ; } }


Input: recover the cell reference to the sheet . [CODESPLIT] public void recover ( ) { Map < String , SheetConfiguration > map = this . getSheetConfigMap ( ) ; for ( Entry < String , SheetConfiguration > entry : map . entrySet ( ) ) { entry . getValue ( ) . recover ( this . getWb ( ) ) ; } }


Input:
/ * ( non - Javadoc ) [CODESPLIT] @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ Override public final int buildAt ( String fullName , final ConfigBuildRef configBuildRef , final int atRow , final Map < String , Object > context , final List < RowsMapping > currentRowsMappingList ) { fullName = fullName + ":" + this . getCommandName ( ) ; Collection itemsCollection = ConfigurationUtility . transformToCollectionObject ( configBuildRef . getEngine ( ) , this . getItems ( ) , context ) ; String objClassName = this . getClassName ( ) ; if ( objClassName == null ) { objClassName = configBuildRef . getCollectionObjNameMap ( ) . get ( this . getVar ( ) ) ; } if ( configBuildRef . isAddMode ( ) && itemsCollection . isEmpty ( ) ) { // do something here to insert one empty object
 try { itemsCollection . add ( Class . forName ( objClassName ) . newInstance ( ) ) ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "canot insert empty object in itemCollections error = " + ex . getLocalizedMessage ( ) , ex ) ; return 0 ; } } int insertPosition = buildEachObjects ( fullName , configBuildRef , atRow , context , currentRowsMappingList , itemsCollection , objClassName ) ; return insertPosition - atRow ; }


Input:
Builds the each objects . [CODESPLIT] @ SuppressWarnings ( "rawtypes" ) private int buildEachObjects ( String fullName , final ConfigBuildRef configBuildRef , final int atRow , final Map < String , Object > context , final List < RowsMapping > currentRowsMappingList , final Collection itemsCollection , final String objClassName ) { int index = 0 ; int insertPosition = atRow ; String thisObjClassName = objClassName ; // loop through each object in the collection
 for ( Object obj : itemsCollection ) { // gather and cache object class name which used for add row
 if ( thisObjClassName == null ) { thisObjClassName = obj . getClass ( ) . getName ( ) ; configBuildRef . getCollectionObjNameMap ( ) . put ( this . var , thisObjClassName ) ; } RowsMapping unitRowsMapping = new RowsMapping ( ) ; context . put ( var , obj ) ; CommandUtility . insertEachTemplate ( this . getConfigRange ( ) , configBuildRef , index , insertPosition , unitRowsMapping ) ; ConfigRange currentRange = ConfigurationUtility . buildCurrentRange ( this . getConfigRange ( ) , configBuildRef . getSheet ( ) , insertPosition ) ; currentRowsMappingList . add ( unitRowsMapping ) ; String unitFullName = fullName + "." + index ; currentRange . getAttrs ( ) . setAllowAdd ( false ) ; if ( ( this . allowAdd != null ) && ( "true" . equalsIgnoreCase ( this . allowAdd . trim ( ) ) ) ) { currentRange . getAttrs ( ) . setAllowAdd ( true ) ; configBuildRef . setBodyAllowAdd ( true ) ; } configBuildRef . putShiftAttrs ( unitFullName , currentRange . getAttrs ( ) , new RowsMapping ( unitRowsMapping ) ) ; int length = currentRange . buildAt ( unitFullName , configBuildRef , insertPosition , context , currentRowsMappingList ) ; currentRange . getAttrs ( ) . setFinalLength ( length ) ; insertPosition += length ; currentRowsMappingList . remove ( unitRowsMapping ) ; index ++ ; context . remove ( var ) ; } return insertPosition ; }


Input: Save data in context . [CODESPLIT] public final void saveDataInContext ( final Cell poiCell , final String strValue ) { String saveAttr = SaveAttrsUtility . prepareContextAndAttrsForCell ( poiCell , ConfigurationUtility . getFullNameFromRow ( poiCell . getRow ( ) ) , this ) ; if ( saveAttr != null ) { SaveAttrsUtility . saveDataToObjectInContext ( parent . getSerialDataContext ( ) . getDataContext ( ) , saveAttr , strValue , parent . getExpEngine ( ) ) ; parent . getHelper ( ) . getWebSheetLoader ( ) . setUnsavedStatus ( RequestContext . getCurrentInstance ( ) , true ) ; } }


Input:
recalc whole workbook . [CODESPLIT] public final void reCalc ( ) { parent . getFormulaEvaluator ( ) . clearAllCachedResultValues ( ) ; try { parent . getFormulaEvaluator ( ) . evaluateAll ( ) ; } catch ( Exception ex ) { // skip the formula exception when recalc but log it
 LOG . log ( Level . SEVERE , " recalc formula error : " + ex . getLocalizedMessage ( ) , ex ) ; } }


Input: Gets the poi cell with row col from current page . [CODESPLIT] public final Cell getPoiCellWithRowColFromCurrentPage ( final int rowIndex , final int colIndex ) { return CellUtility . getPoiCellWithRowColFromCurrentPage ( rowIndex , colIndex , parent . getWb ( ) ) ; }


Input: Gets the poi cell with row col from tab . [CODESPLIT] public final Cell getPoiCellWithRowColFromTab ( final int rowIndex , final int colIndex , final String tabName ) { if ( parent . getWb ( ) != null ) { return CellUtility . getPoiCellFromSheet ( rowIndex , colIndex , parent . getWb ( ) . getSheet ( parent . getSheetConfigMap ( ) . get ( tabName ) . getSheetName ( ) ) ) ; } return null ; }


Input: Gets the faces cell with row col from current page . [CODESPLIT] public final FacesCell getFacesCellWithRowColFromCurrentPage ( final int rowIndex , final int colIndex ) { if ( parent . getBodyRows ( ) != null ) { int top = parent . getCurrent ( ) . getCurrentTopRow ( ) ; int left = parent . getCurrent ( ) . getCurrentLeftColumn ( ) ; return parent . getBodyRows ( ) . get ( rowIndex - top ) . getCells ( ) . get ( colIndex - left ) ; } return null ; }


Input:
Restore data context . [CODESPLIT] public final void restoreDataContext ( final String fullName ) { String [ ] parts = fullName . split ( ":" ) ; if ( ! isNeedRestore ( fullName , parts ) ) { return ; } boolean stopSkip = false ; List < String > list = parent . getCurrent ( ) . getCurrentDataContextNameList ( ) ; int listSize = list . size ( ) ; // prepare collection data in context.
 // must loop through the full name which may have multiple
 // layer.
 // i.e. E.department.1:E.employee.0
 // need prepare department.1 and employee.0
 for ( int i = 0 ; i < parts . length ; i ++ ) { String part = parts [ i ] ; boolean skip = false ; if ( ( ! stopSkip ) && ( i < listSize ) ) { String listPart = list . get ( i ) ; if ( part . equalsIgnoreCase ( listPart ) ) { skip = true ; } } if ( ! skip ) { stopSkip = true ; startRestoreDataContext ( part ) ; } } if ( stopSkip ) { parent . getCurrent ( ) . setCurrentDataContextName ( fullName ) ; } return ; }


Input: Get last collect object from full name . [CODESPLIT] public final CollectionObject getLastCollect ( final String fullName ) { String [ ] parts = fullName . split ( ":" ) ; String part = parts [ parts . length - 1 ] ; return startRestoreDataContext ( part ) ; }


Input: Checks if is need restore . [CODESPLIT] private boolean isNeedRestore ( final String fullName , final String [ ] parts ) { if ( fullName == null ) { return false ; } if ( ( parent . getCurrent ( ) . getCurrentDataContextName ( ) != null ) && ( parent . getCurrent ( ) . getCurrentDataContextName ( ) . toLowerCase ( ) . startsWith ( fullName . toLowerCase ( ) ) ) ) { return false ; } return ( ( parts != null ) && ( parts . length > 1 ) ) ; }


Input: Start restore data context . [CODESPLIT] private CollectionObject startRestoreDataContext ( final String part ) { if ( part . startsWith ( TieConstants . EACH_COMMAND_FULL_NAME_PREFIX ) ) { String [ ] varparts = part . split ( "\\." ) ; CollectionObject collect = new CollectionObject ( ) ; collect . setEachCommand ( CommandUtility . getEachCommandFromPartsName ( parent . getCurrentSheetConfig ( ) . getCommandIndexMap ( ) , varparts ) ) ; collect . setLastCollection ( ConfigurationUtility . transformToCollectionObject ( parent . getExpEngine ( ) , collect . getEachCommand ( ) . getItems ( ) , parent . getSerialDataContext ( ) . getDataContext ( ) ) ) ; collect . setLastCollectionIndex ( CommandUtility . prepareCollectionDataInContext ( varparts , collect . getLastCollection ( ) , parent . getSerialDataContext ( ) . getDataContext ( ) ) ) ; return collect ; } return null ; }


Input: Shift row ref . [CODESPLIT] public final void shiftRowRef ( final Sheet sheet , final int shiftnum ) { try { this . setFirstRowRef ( sheet . getRow ( attrs . getFirstRowAddr ( ) . getRow ( ) + shiftnum ) . getCell ( attrs . getFirstRowAddr ( ) . getColumn ( ) , MissingCellPolicy . CREATE_NULL_AS_BLANK ) , false ) ; this . setLastRowPlusRef ( sheet , attrs . getLastRowPlusAddr ( ) . getColumn ( ) , attrs . getLastRowPlusAddr ( ) . getRow ( ) + shiftnum - 1 , false ) ; if ( commandList != null ) { for ( ConfigCommand command : commandList ) { command . shiftRowRef ( sheet , shiftnum ) ; } } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "shiftRowRef error =" + ex . getLocalizedMessage ( ) , ex ) ; } }


Input: set first cell also set static relative address firstCellAddress . [CODESPLIT] public final void setFirstRowRef ( final Cell pFirstRowRef , final boolean alsoCreateAddr ) { this . attrs . setFirstRowRef ( pFirstRowRef ) ; if ( alsoCreateAddr ) { this . setFirstRowAddr ( new SerialCellAddress ( pFirstRowRef ) ) ; } }


Input: set last cell also set static relative address lastCellAddress . [CODESPLIT] public final void setLastRowPlusRef ( final Sheet sheet , final int rightCol , final int lastRow , final boolean alsoSetAddr ) { if ( ( lastRow >= 0 ) && ( sheet != null ) && ( rightCol >= 0 ) ) { Row row = sheet . getRow ( lastRow + 1 ) ; if ( row == null ) { row = sheet . createRow ( lastRow + 1 ) ; } Cell cell = row . getCell ( rightCol ) ; if ( cell == null ) { cell = row . getCell ( rightCol , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; this . attrs . setLastCellCreated ( true ) ; } else { this . attrs . setLastCellCreated ( false ) ; } this . attrs . setLastRowPlusRef ( cell ) ; if ( alsoSetAddr ) { this . setLastRowPlusAddr ( new SerialCellAddress ( cell ) ) ; } } else { this . attrs . setLastRowPlusRef ( null ) ; if ( alsoSetAddr ) { this . attrs . setLastRowPlusAddr ( null ) ; } } }


Input: build the config range at specified point ( start row ) . context include the data objects for evaluation . build sequence is inside - out . e . g . first build all the command area the range included . each command will hold the final length after data populated . then buildCells build all cells in the range except those commands . and update the formulas . [CODESPLIT] public final int buildAt ( final String fullName , final ConfigBuildRef configBuildRef , final int atRow , final Map < String , Object > context , final List < RowsMapping > currentRowsMappingList ) { if ( commandList != null ) { for ( int i = 0 ; i < commandList . size ( ) ; i ++ ) { Command command = commandList . get ( i ) ; command . setFinalLength ( 0 ) ; int populatedLength = command . buildAt ( fullName , configBuildRef , command . getConfigRange ( ) . getFirstRowRef ( ) . getRowIndex ( ) , context , currentRowsMappingList ) ; command . setFinalLength ( populatedLength ) ; } } buildCells ( fullName , configBuildRef , atRow , context , currentRowsMappingList ) ; return this . getLastRowPlusRef ( ) . getRowIndex ( ) - this . getFirstRowRef ( ) . getRowIndex ( ) ; }


Input:
Build all the static cells in the range ( exclude command areas ) . [CODESPLIT] private void buildCells ( final String fullName , final ConfigBuildRef configBuildRef , final int atRow , final Map < String , Object > context , final List < RowsMapping > rowsMappingList ) { if ( ( context == null ) || context . isEmpty ( ) ) { // no need to evaluate as there's no data object.
 return ; } // keep rowsMappingList as current as no change
 // allRowsMappingList = child + current
 List < RowsMapping > allRowsMappingList = ConfigurationUtility . findChildRowsMappingFromShiftMap ( fullName , configBuildRef . getShiftMap ( ) ) ; allRowsMappingList . addAll ( rowsMappingList ) ; int lastRowPlus = this . getLastRowPlusRef ( ) . getRowIndex ( ) ; ShiftFormulaRef shiftFormulaRef = new ShiftFormulaRef ( configBuildRef . getWatchList ( ) , allRowsMappingList ) ; for ( int i = atRow ; i < lastRowPlus ; i ++ ) { buildCellsForRow ( configBuildRef . getSheet ( ) . getRow ( i ) , fullName , context , configBuildRef , shiftFormulaRef ) ; } }


Input: Builds the cells for row . [CODESPLIT] private void buildCellsForRow ( final Row row , final String fullName , final Map < String , Object > context , final ConfigBuildRef configBuildRef , ShiftFormulaRef shiftFormulaRef ) { if ( ( row == null ) || ! ConfigurationUtility . isStaticRowRef ( this , row ) ) { return ; } for ( Cell cell : row ) { buildSingleCell ( cell , context , configBuildRef , shiftFormulaRef ) ; } ConfigurationUtility . setFullNameInHiddenColumn ( row , fullName ) ; }


Input:
Builds the single cell . [CODESPLIT] private void buildSingleCell ( final Cell cell , final Map < String , Object > context , final ConfigBuildRef configBuildRef , final ShiftFormulaRef shiftFormulaRef ) { try { CommandUtility . evaluate ( context , cell , configBuildRef . getEngine ( ) ) ; if ( cell . getCellTypeEnum ( ) == CellType . FORMULA ) { // rebuild formula if necessary for dynamic row
 String originFormula = cell . getCellFormula ( ) ; shiftFormulaRef . setFormulaChanged ( 0 ) ; ConfigurationUtility . buildCellFormulaForShiftedRows ( configBuildRef . getSheet ( ) , configBuildRef . getWbWrapper ( ) , shiftFormulaRef , cell , cell . getCellFormula ( ) ) ; if ( shiftFormulaRef . getFormulaChanged ( ) > 0 ) { configBuildRef . getCachedCells ( ) . put ( cell , originFormula ) ; } } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "build cell ( row = " + cell . getRowIndex ( ) + " column = " + cell . getColumnIndex ( ) + " error = " + ex . getLocalizedMessage ( ) , ex ) ; } }


Input: recover by using it s address . [CODESPLIT] public final void recover ( final Sheet sheet ) { this . getAttrs ( ) . recover ( sheet ) ; if ( this . commandList != null ) { for ( ConfigCommand command : this . commandList ) { command . recover ( sheet ) ; } } }


Input: save the workbook before serialize . [CODESPLIT] private void writeObject ( final java . io . ObjectOutputStream out ) throws IOException { Gson objGson = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) ; this . mapToJson = objGson . toJson ( this . dataContext ) ; out . defaultWriteObject ( ) ; }


Input: load the workbook from saving . [CODESPLIT] private void readObject ( final java . io . ObjectInputStream in ) throws IOException { try { in . defaultReadObject ( ) ; Gson objGson = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) ; Type listType = new TypeToken < Map < String , Object > > ( ) { } . getType ( ) ; this . dataContext = objGson . fromJson ( mapToJson , listType ) ; } catch ( EncryptedDocumentException | ClassNotFoundException e ) { LOG . log ( Level . SEVERE , " error in readObject of serialWorkbook : " + e . getLocalizedMessage ( ) , e ) ; } }


Input: build categotry list . [CODESPLIT] public final void buildCategoryList ( final CTAxDataSource ctAxDs ) { List < ParsedCell > cells = new ArrayList <> ( ) ; try { String fullRangeName = ctAxDs . getStrRef ( ) . getF ( ) ; String sheetName = WebSheetUtility . getSheetNameFromFullCellRefName ( fullRangeName ) ; CellRangeAddress region = CellRangeAddress . valueOf ( WebSheetUtility . removeSheetNameFromFullCellRefName ( fullRangeName ) ) ; for ( int row = region . getFirstRow ( ) ; row <= region . getLastRow ( ) ; row ++ ) { for ( int col = region . getFirstColumn ( ) ; col <= region . getLastColumn ( ) ; col ++ ) { cells . add ( new ParsedCell ( sheetName , row , col ) ) ; } } } catch ( Exception ex ) { LOG . log ( Level . FINE , "failed in buildCategoryList" , ex ) ; } this . setCategoryList ( cells ) ; }


Input: build series list . [CODESPLIT] @ SuppressWarnings ( "rawtypes" ) public final void buildSeriesList ( final List bsers , final ThemesTable themeTable , final ChartObject ctObj ) { List < ChartSeries > lseriesList = new ArrayList <> ( ) ; try { for ( int index = 0 ; index < bsers . size ( ) ; index ++ ) { Object ctObjSer = bsers . get ( index ) ; ChartSeries ctSer = buildChartSeriesInList ( themeTable , ctObj , ctObjSer , index ) ; lseriesList . add ( ctSer ) ; } } catch ( Exception ex ) { LOG . log ( Level . FINE , "failed in buildSerialList" , ex ) ; } this . setSeriesList ( lseriesList ) ; }


Input: Builds the chart series in list . [CODESPLIT] private ChartSeries buildChartSeriesInList ( final ThemesTable themeTable , final ChartObject ctObj , final Object ctObjSer , final int index ) { ChartSeries ctSer = new ChartSeries ( ) ; ctSer . setSeriesLabel ( new ParsedCell ( ctObj . getSeriesLabelFromCTSer ( ctObjSer ) ) ) ; ctSer . setSeriesColor ( ColorUtility . geColorFromSpPr ( index , ctObj . getShapePropertiesFromCTSer ( ctObjSer ) , themeTable , ctObj . isLineColor ( ) ) ) ; List < ParsedCell > cells = new ArrayList <> ( ) ; String fullRangeName = ( ctObj . getCTNumDataSourceFromCTSer ( ctObjSer ) ) . getNumRef ( ) . getF ( ) ; String sheetName = WebSheetUtility . getSheetNameFromFullCellRefName ( fullRangeName ) ; CellRangeAddress region = CellRangeAddress . valueOf ( WebSheetUtility . removeSheetNameFromFullCellRefName ( fullRangeName ) ) ; for ( int row = region . getFirstRow ( ) ; row <= region . getLastRow ( ) ; row ++ ) { for ( int col = region . getFirstColumn ( ) ; col <= region . getLastColumn ( ) ; col ++ ) { cells . add ( new ParsedCell ( sheetName , row , col ) ) ; } } ctSer . setValueList ( cells ) ; ctSer . setValueColorList ( getColorListFromDPTWithValueList ( ctObj . getDPtListFromCTSer ( ctObjSer ) , cells , themeTable , ctObj ) ) ; return ctSer ; }


Input: get color list from dpt . [CODESPLIT] private List < XColor > getColorListFromDPTWithValueList ( final List < CTDPt > dptList , final List < ParsedCell > cells , final ThemesTable themeTable , final ChartObject ctObj ) { List < XColor > colors = new ArrayList <> ( ) ; if ( ( dptList != null ) && ( cells != null ) ) { for ( int index = 0 ; index < cells . size ( ) ; index ++ ) { CTDPt dpt = getDPtFromListWithIndex ( dptList , index ) ; CTShapeProperties ctSpPr = null ; if ( dpt != null ) { ctSpPr = dpt . getSpPr ( ) ; } colors . add ( ColorUtility . geColorFromSpPr ( index , ctSpPr , themeTable , ctObj . isLineColor ( ) ) ) ; } } return colors ; }


Input: get dpt from list . [CODESPLIT] private CTDPt getDPtFromListWithIndex ( final List < CTDPt > dptList , final int index ) { if ( dptList != null ) { for ( CTDPt dpt : dptList ) { if ( dpt . getIdx ( ) . getVal ( ) == index ) { return dpt ; } } } return null ; }


Input: Sets the command index map . [CODESPLIT] public final void setCommandIndexMap ( final Map < String , Command > pcommandIndexMap ) { if ( pcommandIndexMap instanceof HashMap ) { this . commandIndexMap = ( HashMap < String , Command > ) pcommandIndexMap ; } else { this . commandIndexMap = new HashMap <> ( ) ; this . commandIndexMap . putAll ( pcommandIndexMap ) ; } }


Input: recover the cell reference to the sheet . [CODESPLIT] public void recover ( final Workbook wb ) { Sheet sheet = wb . getSheet ( this . sheetName ) ; this . getSerialCachedCells ( ) . recover ( sheet ) ; this . getSerialFinalCommentMap ( ) . recover ( sheet ) ; this . getFormCommand ( ) . recover ( sheet ) ; if ( this . getShiftMap ( ) != null ) { for ( Map . Entry < String , ConfigRangeAttrs > entry : this . getShiftMap ( ) . entrySet ( ) ) { entry . getValue ( ) . recover ( sheet ) ; } } if ( this . getCommandIndexMap ( ) != null ) { for ( Map . Entry < String , Command > entry : this . getCommandIndexMap ( ) . entrySet ( ) ) { entry . getValue ( ) . recover ( sheet ) ; } } }


Input: Gets the pictrues map . [CODESPLIT] public static void getPictruesMap ( final Workbook wb , final Map < String , Picture > picMap ) { if ( wb instanceof XSSFWorkbook ) { getXSSFPictruesMap ( ( XSSFWorkbook ) wb , picMap ) ; } return ; }


Input: Gets the XSSF pictrues map . [CODESPLIT] private static void getXSSFPictruesMap ( final XSSFWorkbook wb , final Map < String , Picture > picMap ) { picMap . clear ( ) ; List < XSSFPictureData > pictures = wb . getAllPictures ( ) ; if ( pictures . isEmpty ( ) ) { return ; } for ( int i = 0 ; i < wb . getNumberOfSheets ( ) ; i ++ ) { XSSFSheet sheet = wb . getSheetAt ( i ) ; for ( POIXMLDocumentPart dr : sheet . getRelations ( ) ) { try { indexPictureInMap ( picMap , sheet , dr ) ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "Load Picture error = " + ex . getLocalizedMessage ( ) , ex ) ; } } } return ; }


Input: save pciture in map with index . [CODESPLIT] private static void indexPictureInMap ( final Map < String , Picture > picMap , final XSSFSheet sheet , final POIXMLDocumentPart dr ) { if ( dr instanceof XSSFDrawing ) { XSSFDrawing drawing = ( XSSFDrawing ) dr ; List < XSSFShape > shapes = drawing . getShapes ( ) ; for ( XSSFShape shape : shapes ) { if ( shape instanceof XSSFPicture ) { XSSFPicture pic = ( XSSFPicture ) shape ; XSSFClientAnchor anchor = pic . getPreferredSize ( ) ; CTMarker ctMarker = anchor . getFrom ( ) ; String picIndex = WebSheetUtility . getFullCellRefName ( sheet . getSheetName ( ) , ctMarker . getRow ( ) , ctMarker . getCol ( ) ) ; picMap . put ( picIndex , pic ) ; } } } }


Input: Generate picture style . [CODESPLIT] public static String generatePictureStyle ( final Sheet sheet1 , final FacesCell fcell , final Cell cell , final Picture pic ) { ClientAnchor anchor = pic . getClientAnchor ( ) ; if ( anchor != null ) { AnchorSize anchorSize = getAnchorSize ( sheet1 , fcell , cell , anchor ) ; if ( anchorSize != null ) { return "MARGIN-LEFT:" + String . format ( "%.2f" , anchorSize . getPercentLeft ( ) ) + "%;MARGIN-TOP:" + String . format ( "%.2f" , anchorSize . getPercentTop ( ) ) + "%;width:" + String . format ( "%.2f" , anchorSize . getPercentWidth ( ) ) + "%;" ; } } return "" ; }


Input: Generate chart style . [CODESPLIT] public static String generateChartStyle ( final Sheet sheet1 , final FacesCell fcell , final Cell cell , final String chartId , final Map < String , ClientAnchor > anchorsMap ) { ClientAnchor anchor = anchorsMap . get ( chartId ) ; if ( anchor != null ) { AnchorSize anchorSize = getAnchorSize ( sheet1 , fcell , cell , anchor ) ; if ( anchorSize != null ) { return "MARGIN-LEFT:" + String . format ( "%.2f" , anchorSize . getPercentLeft ( ) ) + "%;MARGIN-TOP:" + String . format ( "%.2f" , anchorSize . getPercentTop ( ) ) + "%;width:" + String . format ( "%.2f" , anchorSize . getPercentWidth ( ) ) + "%;height:135%;" ; } } return "" ; }


Input: Gets the anchor size . [CODESPLIT] public static AnchorSize getAnchorSize ( final Sheet sheet1 , final FacesCell fcell , final Cell cell , final ClientAnchor anchor ) { if ( ! ( sheet1 instanceof XSSFSheet ) ) { return null ; } double picWidth = 0.0 ; double picHeight = 0.0 ; int left = anchor . getDx1 ( ) / org . apache . poi . util . Units . EMU_PER_PIXEL ; int top = ( int ) ( ( double ) anchor . getDy1 ( ) / org . apache . poi . util . Units . EMU_PER_PIXEL / WebSheetUtility . PICTURE_HEIGHT_ADJUST ) ; int right = anchor . getDx2 ( ) / org . apache . poi . util . Units . EMU_PER_PIXEL ; int bottom = ( int ) ( ( double ) anchor . getDy2 ( ) / org . apache . poi . util . Units . EMU_PER_PIXEL / WebSheetUtility . PICTURE_HEIGHT_ADJUST ) ; double cellWidth = 0.0 ; double cellHeight = 0.0 ; if ( ( cell != null ) && ( fcell != null ) ) { for ( int col = cell . getColumnIndex ( ) ; col < cell . getColumnIndex ( ) + fcell . getColspan ( ) ; col ++ ) { cellWidth += sheet1 . getColumnWidthInPixels ( col ) ; } double lastCellWidth = sheet1 . getColumnWidthInPixels ( cell . getColumnIndex ( ) + fcell . getColspan ( ) - 1 ) ; for ( int rowIndex = cell . getRowIndex ( ) ; rowIndex < cell . getRowIndex ( ) + fcell . getRowspan ( ) ; rowIndex ++ ) { cellHeight += WebSheetUtility . pointsToPixels ( sheet1 . getRow ( rowIndex ) . getHeightInPoints ( ) ) ; } double lastCellHeight = WebSheetUtility . pointsToPixels ( sheet1 . getRow ( cell . getRowIndex ( ) + fcell . getRowspan ( ) - 1 ) . getHeightInPoints ( ) ) ; picWidth = cellWidth - lastCellWidth + right - left ; picHeight = cellHeight - lastCellHeight + bottom - top ; } else { for ( short col = anchor . getCol1 ( ) ; col < anchor . getCol2 ( ) ; col ++ ) { picWidth += sheet1 . getColumnWidthInPixels ( col ) ; } for ( int rowindex = anchor . getRow1 ( ) ; rowindex < anchor . getRow2 ( ) ; rowindex ++ ) { Row row = sheet1 . getRow ( rowindex ) ; if ( row != null ) { picHeight += WebSheetUtility . pointsToPixels ( row . getHeightInPoints ( ) ) ; } } } return new AnchorSize ( left , top , ( int ) picWidth , ( int ) picHeight , cellWidth , cellHeight ) ; }


Input:
Put . [CODESPLIT] public final void put ( final Cell cell , final CellType formula ) { Map < Cell , FormulaMapping > map = cachedMap ; // if cellType not null then only specified Type will be put into Cache
 // e.g. only formula cell will be cached then pass in
 // Cell.CELL_TYPE_FORMULA
 if ( ( cell != null ) && ( ( formula == null ) || ( cell . getCellTypeEnum ( ) == formula ) ) ) { String value = CellUtility . getCellValueWithFormat ( cell , parent . getFormulaEvaluator ( ) , parent . getDataFormatter ( ) ) ; FormulaMapping f = map . get ( cell ) ; if ( f == null ) { f = new FormulaMapping ( ) ; } f . setValue ( value ) ; map . put ( cell , f ) ; } }


Input:
Put . [CODESPLIT] public final void put ( final Cell cell , final String originFormula ) { Map < Cell , FormulaMapping > map = cachedMap ; // if cellType not null then only specified Type will be put into Cache
 // e.g. only formula cell will be cached then pass in
 // Cell.CELL_TYPE_FORMULA
 if ( ( cell != null ) && ( originFormula != null ) ) { FormulaMapping f = map . get ( cell ) ; if ( f == null ) { f = new FormulaMapping ( ) ; } f . setOriginFormula ( originFormula ) ; String value = CellUtility . getCellValueWithFormat ( cell , parent . getFormulaEvaluator ( ) , parent . getDataFormatter ( ) ) ; f . setValue ( value ) ; map . put ( cell , f ) ; } }


Input: Checks if is value changed . [CODESPLIT] public final boolean isValueChanged ( final Cell cell ) { String newValue = CellUtility . getCellValueWithFormat ( cell , parent . getFormulaEvaluator ( ) , parent . getDataFormatter ( ) ) ; return isValueChanged ( cell , newValue ) ; }


Input: Checks if is value changed . [CODESPLIT] public final boolean isValueChanged ( final Cell cell , final String pnewValue ) { Map < Cell , FormulaMapping > map = cachedMap ; String oldValue = map . get ( cell ) . getValue ( ) ; String newValue = pnewValue ; if ( oldValue == null ) { oldValue = "" ; } if ( newValue == null ) { newValue = "" ; } return ( ! oldValue . equals ( newValue ) ) ; }


Input: Gets the pattern . [CODESPLIT] public Pattern getPattern ( ) { if ( ( this . pattern == null ) && ( alias != null ) ) { this . pattern = Pattern . compile ( "\\s*" + ParserUtility . wildcardToRegex ( alias ) ) ; } return pattern ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final void encodeBegin ( final FacesContext context ) throws IOException { webSheetBean = ( TieWebSheetBean ) this . getAttributes ( ) . get ( TieConstants . ATTRS_WEBSHEETBEAN ) ; if ( ( webSheetBean != null ) && ( webSheetBean . getWebFormClientId ( ) == null ) ) { LOG . fine ( "WebSheet component parameter setup" ) ; webSheetBean . setClientId ( this . getClientId ( ) ) ; webSheetBean . setWebFormClientId ( this . getClientId ( ) + ":" + TieConstants . COMPONENT_ID ) ; String maxrows = ( String ) this . getAttributes ( ) . get ( "maxRowsPerPage" ) ; if ( ( maxrows != null ) && ( ! maxrows . isEmpty ( ) ) ) { webSheetBean . setMaxRowsPerPage ( Integer . valueOf ( maxrows ) ) ; } Boolean hideSingleSheetTabTitle = ( Boolean ) this . getAttributes ( ) . get ( "hideSingleSheetTabTitle" ) ; if ( hideSingleSheetTabTitle != null ) { webSheetBean . setHideSingleSheetTabTitle ( hideSingleSheetTabTitle ) ; } } super . encodeBegin ( context ) ; }


Input:
Return real chart picture when browser requesting the image . [CODESPLIT] public StreamedContent getChart ( ) throws IOException { FacesContext context = FacesContext . getCurrentInstance ( ) ; if ( context . getCurrentPhaseId ( ) == PhaseId . RENDER_RESPONSE ) { // So, we're rendering the HTML. Return a stub StreamedContent so
 // that it will generate right URL.
 LOG . fine ( " return empty chart picture" ) ; return new DefaultStreamedContent ( ) ; } else { // So, browser is requesting the image. Return a real
 // StreamedContent with the image bytes.
 String chartId = context . getExternalContext ( ) . getRequestParameterMap ( ) . get ( "chartViewId" ) ; BufferedImage bufferedImg = ( BufferedImage ) FacesContext . getCurrentInstance ( ) . getExternalContext ( ) . getSessionMap ( ) . get ( chartId ) ; ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; ImageIO . write ( bufferedImg , "png" , os ) ; FacesContext . getCurrentInstance ( ) . getExternalContext ( ) . getSessionMap ( ) . remove ( chartId ) ; return new DefaultStreamedContent ( new ByteArrayInputStream ( os . toByteArray ( ) ) , "image/png" ) ; } }


Input: save the cell before serialize . [CODESPLIT] private void writeObject ( final java . io . ObjectOutputStream out ) throws IOException { this . cellAddr = new SerialCellAddress ( this . cell ) ; out . defaultWriteObject ( ) ; }


Input: recover cell by using it s address . [CODESPLIT] public final void recover ( final Sheet sheet ) { if ( this . cellAddr != null ) { this . setCell ( sheet . getRow ( this . cellAddr . getRow ( ) ) . getCell ( this . cellAddr . getColumn ( ) ) ) ; } }


Input: Gets the row style . [CODESPLIT] public static String getRowStyle ( final Workbook wb , final Cell poiCell , final String inputType , final float rowHeight , final int rowspan ) { CellStyle cellStyle = poiCell . getCellStyle ( ) ; if ( ( cellStyle != null ) && ( rowspan == 1 ) ) { short fontIdx = cellStyle . getFontIndex ( ) ; Font font = wb . getFontAt ( fontIdx ) ; float maxHeight = rowHeight ; if ( ! inputType . isEmpty ( ) ) { maxHeight = Math . min ( font . getFontHeightInPoints ( ) + 8f , rowHeight ) ; } return "height:" + WebSheetUtility . pointsToPixels ( maxHeight ) + "px;" ; } return "" ; }


Input: Gets the cell font style . [CODESPLIT] public static String getCellFontStyle ( final Workbook wb , final Cell poiCell ) { CellStyle cellStyle = poiCell . getCellStyle ( ) ; StringBuilder webStyle = new StringBuilder ( ) ; if ( cellStyle != null ) { short fontIdx = cellStyle . getFontIndex ( ) ; Font font = wb . getFontAt ( fontIdx ) ; if ( font . getItalic ( ) ) { webStyle . append ( "font-style: italic;" ) ; } if ( font . getBold ( ) ) { webStyle . append ( "font-weight: bold;" ) ; } webStyle . append ( "font-size: " + font . getFontHeightInPoints ( ) + "pt;" ) ; String decoration = getCellFontDecoration ( font ) ; if ( decoration . length ( ) > 0 ) { webStyle . append ( "text-decoration:" + decoration + ";" ) ; } webStyle . append ( getCellFontColor ( font ) ) ; } return webStyle . toString ( ) ; }


Input: get cell font color . [CODESPLIT] private static String getCellFontColor ( final Font font ) { short [ ] rgbfix = { TieConstants . RGB_MAX , TieConstants . RGB_MAX , TieConstants . RGB_MAX } ; if ( font instanceof XSSFFont ) { XSSFColor color = ( ( XSSFFont ) font ) . getXSSFColor ( ) ; if ( color != null ) { rgbfix = ColorUtility . getTripletFromXSSFColor ( color ) ; } } if ( rgbfix [ 0 ] != TieConstants . RGB_MAX ) { return "color:rgb(" + FacesUtility . strJoin ( rgbfix , "," ) + ");" ; } return "" ; }


Input: Get font decoration . [CODESPLIT] private static String getCellFontDecoration ( final Font font ) { StringBuilder decoration = new StringBuilder ( ) ; if ( font . getUnderline ( ) != 0 ) { decoration . append ( " underline" ) ; } if ( font . getStrikeout ( ) ) { decoration . append ( " line-through" ) ; } return decoration . toString ( ) ; }


Input: Gets the cell style . [CODESPLIT] public static String getCellStyle ( final Workbook wb , final Cell poiCell , final String inputType ) { CellStyle cellStyle = poiCell . getCellStyle ( ) ; StringBuilder webStyle = new StringBuilder ( ) ; if ( cellStyle != null ) { if ( ! inputType . isEmpty ( ) ) { webStyle . append ( getAlignmentFromCell ( poiCell , cellStyle ) ) ; webStyle . append ( getVerticalAlignmentFromCell ( cellStyle ) ) ; } webStyle . append ( ColorUtility . getBgColorFromCell ( wb , poiCell , cellStyle ) ) ; } return webStyle . toString ( ) ; }


Input: Gets the column style . [CODESPLIT] public static String getColumnStyle ( final Workbook wb , final FacesCell fcell , final Cell poiCell , final float rowHeight ) { String inputType = fcell . getInputType ( ) ; CellStyle cellStyle = poiCell . getCellStyle ( ) ; StringBuilder webStyle = new StringBuilder ( ) ; if ( cellStyle != null ) { if ( fcell . isContainPic ( ) || fcell . isContainChart ( ) ) { webStyle . append ( "vertical-align: top;" ) ; } else { webStyle . append ( getAlignmentFromCell ( poiCell , cellStyle ) ) ; webStyle . append ( getVerticalAlignmentFromCell ( cellStyle ) ) ; } webStyle . append ( ColorUtility . getBgColorFromCell ( wb , poiCell , cellStyle ) ) ; webStyle . append ( getRowStyle ( wb , poiCell , inputType , rowHeight , fcell . getRowspan ( ) ) ) ; } else { webStyle . append ( getAlignmentFromCellType ( poiCell ) ) ; } return webStyle . toString ( ) ; }


Input: Gets the alignment from cell . [CODESPLIT] private static String getAlignmentFromCell ( final Cell poiCell , final CellStyle cellStyle ) { String style = "" ; switch ( cellStyle . getAlignmentEnum ( ) ) { case LEFT : style = TieConstants . TEXT_ALIGN_LEFT ; break ; case RIGHT : style = TieConstants . TEXT_ALIGN_RIGHT ; break ; case CENTER : style = TieConstants . TEXT_ALIGN_CENTER ; break ; case GENERAL : style = getAlignmentFromCellType ( poiCell ) ; break ; default : break ; } return style ; }


Input: Gets the vertical alignment from cell . [CODESPLIT] private static String getVerticalAlignmentFromCell ( final CellStyle cellStyle ) { String style = "" ; switch ( cellStyle . getVerticalAlignmentEnum ( ) ) { case TOP : style = TieConstants . VERTICAL_ALIGN_TOP ; break ; case CENTER : style = TieConstants . VERTICAL_ALIGN_CENTER ; break ; case BOTTOM : style = TieConstants . VERTICAL_ALIGN_BOTTOM ; break ; default : break ; } return style ; }


Input: e . g . lineNumberColumnWidth and addRowColumnWidth [CODESPLIT] public static int calcTotalWidth ( final Sheet sheet1 , final int firstCol , final int lastCol , final int additionalWidth ) { int totalWidth = additionalWidth ; for ( int i = firstCol ; i <= lastCol ; i ++ ) { totalWidth += sheet1 . getColumnWidth ( i ) ; } return totalWidth ; }


Input: Calc total height . [CODESPLIT] public static int calcTotalHeight ( final Sheet sheet1 , final int firstRow , final int lastRow , final int additionalHeight ) { int totalHeight = additionalHeight ; for ( int i = firstRow ; i <= lastRow ; i ++ ) { totalHeight += sheet1 . getRow ( i ) . getHeight ( ) ; } return totalHeight ; }


Input:
Setup cell style . [CODESPLIT] public static void setupCellStyle ( final Workbook wb , final FacesCell fcell , final Cell poiCell , final float rowHeight ) { CellStyle cellStyle = poiCell . getCellStyle ( ) ; if ( ( cellStyle != null ) && ( ! cellStyle . getLocked ( ) ) ) { // not locked
 if ( fcell . getInputType ( ) . isEmpty ( ) ) { fcell . setInputType ( CellStyleUtility . getInputTypeFromCellType ( poiCell ) ) ; } if ( fcell . getControl ( ) . isEmpty ( ) && ( ! fcell . getInputType ( ) . isEmpty ( ) ) ) { fcell . setControl ( "text" ) ; } setInputStyleBaseOnInputType ( fcell , poiCell ) ; } String webStyle = getCellStyle ( wb , poiCell , fcell . getInputType ( ) ) + getCellFontStyle ( wb , poiCell ) + getRowStyle ( wb , poiCell , fcell . getInputType ( ) , rowHeight , fcell . getRowspan ( ) ) ; fcell . setStyle ( webStyle ) ; fcell . setColumnStyle ( getColumnStyle ( wb , fcell , poiCell , rowHeight ) ) ; }


Input: set up Input Style parameter for input number component which need those parameters to make it work . e . g . symbol symbol position decimal places . [CODESPLIT] static void setInputStyleBaseOnInputType ( final FacesCell fcell , final Cell poiCell ) { if ( ( fcell == null ) || fcell . getInputType ( ) . isEmpty ( ) ) { return ; } switch ( fcell . getInputType ( ) ) { case TieConstants . CELL_INPUT_TYPE_PERCENTAGE : fcell . setSymbol ( "%" ) ; fcell . setSymbolPosition ( "p" ) ; fcell . setDecimalPlaces ( CellStyleUtility . getDecimalPlacesFromFormat ( poiCell ) ) ; break ; case TieConstants . CELL_INPUT_TYPE_INTEGER : fcell . setDecimalPlaces ( ( short ) 0 ) ; break ; case TieConstants . CELL_INPUT_TYPE_DOUBLE : fcell . setDecimalPlaces ( CellStyleUtility . getDecimalPlacesFromFormat ( poiCell ) ) ; fcell . setSymbol ( CellStyleUtility . getSymbolFromFormat ( poiCell ) ) ; fcell . setSymbolPosition ( CellStyleUtility . getSymbolPositionFromFormat ( poiCell ) ) ; break ; default : break ; } }


Input: Gets the input type from cell type . [CODESPLIT] @ SuppressWarnings ( "deprecation" ) private static String getInputTypeFromCellType ( final Cell cell ) { String inputType = TieConstants . CELL_INPUT_TYPE_TEXT ; if ( cell . getCellTypeEnum ( ) == CellType . NUMERIC ) { inputType = TieConstants . CELL_INPUT_TYPE_DOUBLE ; } CellStyle style = cell . getCellStyle ( ) ; if ( style != null ) { int formatIndex = style . getDataFormat ( ) ; String formatString = style . getDataFormatString ( ) ; if ( DateUtil . isADateFormat ( formatIndex , formatString ) ) { inputType = TieConstants . CELL_INPUT_TYPE_DATE ; } else { if ( isAPercentageCell ( formatString ) ) { inputType = TieConstants . CELL_INPUT_TYPE_PERCENTAGE ; } } } return inputType ; }


Input: get decimal places from format string e . g . 0 . 00 will return 2 [CODESPLIT] private static short getDecimalPlacesFromFormat ( final Cell cell ) { CellStyle style = cell . getCellStyle ( ) ; if ( style == null ) { return 0 ; } String formatString = style . getDataFormatString ( ) ; if ( formatString == null ) { return 0 ; } int ipos = formatString . indexOf ( ' ' ) ; if ( ipos < 0 ) { return 0 ; } short counter = 0 ; for ( int i = ipos + 1 ; i < formatString . length ( ) ; i ++ ) { if ( formatString . charAt ( i ) == ' ' ) { counter ++ ; } else { break ; } } return counter ; }


Input:
get symbol from format string e . g . [ $CAD ] # ##0 . 00 will return CAD . While $# ##0 . 00 will return $ [CODESPLIT] private static String getSymbolFromFormat ( final Cell cell ) { CellStyle style = cell . getCellStyle ( ) ; if ( style == null ) { return null ; } String formatString = style . getDataFormatString ( ) ; if ( formatString == null ) { return null ; } if ( formatString . indexOf ( TieConstants . CELL_ADDR_PRE_FIX ) < 0 ) { return null ; } int ipos = formatString . indexOf ( "[$" ) ; if ( ipos < 0 ) { // only $ found, then return default dollar symbol
 return "$" ; } // return specified dollar symbol
 return formatString . substring ( ipos + 2 , formatString . indexOf ( ' ' , ipos ) ) ; }


Input: get symbol position from format string e . g . [ $CAD ] # ##0 . 00 will return p . While # ##0 . 00 $ will return s [CODESPLIT] private static String getSymbolPositionFromFormat ( final Cell cell ) { CellStyle style = cell . getCellStyle ( ) ; if ( style == null ) { return "p" ; } String formatString = style . getDataFormatString ( ) ; if ( formatString == null ) { return "p" ; } int symbolpos = formatString . indexOf ( ' ' ) ; int numberpos = formatString . indexOf ( ' ' ) ; if ( numberpos < 0 ) { numberpos = formatString . indexOf ( ' ' ) ; } if ( symbolpos < numberpos ) { return "p" ; } else { return "s" ; } }


Input: return faces context resource path . [CODESPLIT] public static Set < String > getResourcePaths ( final FacesContext context , final String path ) { return context . getExternalContext ( ) . getResourcePaths ( path ) ; }


Input: get resource file as stream . [CODESPLIT] public static InputStream getResourceAsStream ( final FacesContext context , final String path ) { return context . getExternalContext ( ) . getResourceAsStream ( path ) ; }


Input: evaluate expression . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public static < T > T evaluateExpressionGet ( final FacesContext context , final String expression ) { if ( expression == null ) { return null ; } return ( T ) context . getApplication ( ) . evaluateExpressionGet ( context , expression , Object . class ) ; }


Input: remove prefix path of the full path . [CODESPLIT] public static String removePrefixPath ( final String prefix , final String resource ) { String normalizedResource = resource ; if ( normalizedResource . startsWith ( prefix ) ) { normalizedResource = normalizedResource . substring ( prefix . length ( ) - 1 ) ; } return normalizedResource ; }


Input: evaluate input type . [CODESPLIT] public static boolean evalInputType ( final String input , final String type ) { Scanner scanner = new Scanner ( input ) ; boolean ireturn = false ; if ( "Integer" . equalsIgnoreCase ( type ) ) { ireturn = scanner . hasNextInt ( ) ; } else if ( "Double" . equalsIgnoreCase ( type ) ) { ireturn = scanner . hasNextDouble ( ) ; } else if ( "Boolean" . equalsIgnoreCase ( type ) ) { ireturn = scanner . hasNextBoolean ( ) ; } else if ( "Byte" . equalsIgnoreCase ( type ) ) { ireturn = scanner . hasNextByte ( ) ; } else if ( type . toLowerCase ( ) . startsWith ( "text" ) ) { ireturn = true ; } scanner . close ( ) ; return ireturn ; }


Input: Find bean in context . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public static < T > T findBean ( final String beanName ) { FacesContext context = FacesContext . getCurrentInstance ( ) ; return ( T ) context . getApplication ( ) . evaluateExpressionGet ( context , TieConstants . EL_START + beanName + TieConstants . EL_END , Object . class ) ; }


Input: evaluate expression . [CODESPLIT] public static < T > T evaluateExpression ( final String expression , final Class < ? extends T > expected ) { return evaluateExpression ( FacesContext . getCurrentInstance ( ) , expression , expected ) ; }


Input: evaluate expression . [CODESPLIT] public static < T > T evaluateExpression ( final FacesContext context , final String expression , final Class < ? extends T > expected ) { return context . getApplication ( ) . evaluateExpressionGet ( context , expression , expected ) ; }


Input: join string . [CODESPLIT] public static String strJoin ( final short [ ] aArr , final String sSep ) { StringBuilder sbStr = new StringBuilder ( ) ; for ( int i = 0 , il = aArr . length ; i < il ; i ++ ) { if ( i > 0 ) { sbStr . append ( sSep ) ; } sbStr . append ( aArr [ i ] ) ; } return sbStr . toString ( ) ; }


Input: round number according to decimal places . [CODESPLIT] public static double round ( final double value , final int places ) { if ( places < 0 ) { throw new IllegalArgumentException ( ) ; } BigDecimal bd = BigDecimal . valueOf ( value ) ; bd = bd . setScale ( places , RoundingMode . HALF_UP ) ; return bd . doubleValue ( ) ; }


Input: get tab type . [CODESPLIT] public String getTabType ( ) { int sheetId = webFormTabView . getActiveIndex ( ) ; if ( ( sheetId >= 0 ) && ( tabs != null ) ) { if ( sheetId >= tabs . size ( ) ) { sheetId = 0 ; } tabType = tabs . get ( sheetId ) . type . toLowerCase ( ) ; } else { tabType = TieConstants . TAB_TYPE_NONE ; } return tabType ; }


Input: get tab style . [CODESPLIT] public String getTabStyle ( ) { String tabStyle = TieConstants . TAB_STYLE_VISIBLE ; int sheetId = webFormTabView . getActiveIndex ( ) ; if ( ( sheetId >= 0 ) && ( sheetId < tabs . size ( ) ) ) { tabStyle = TieConstants . TAB_STYLE_INVISIBLE ; } return tabStyle ; }


Input: Gets the default date pattern . [CODESPLIT] public String getDefaultDatePattern ( ) { if ( defaultDatePattern == null ) { DateFormat formatter = DateFormat . getDateInstance ( DateFormat . SHORT , Locale . getDefault ( ) ) ; defaultDatePattern = ( ( SimpleDateFormat ) formatter ) . toLocalizedPattern ( ) ; } return defaultDatePattern ; }


Input: Gets the decimal separator by default locale . [CODESPLIT] public String getDecimalSeparatorByDefaultLocale ( ) { final DecimalFormat nf = ( DecimalFormat ) DecimalFormat . getInstance ( getDefaultLocale ( ) ) ; return "" + nf . getDecimalFormatSymbols ( ) . getDecimalSeparator ( ) ; }


Input: Gets the thousand separator by default locale . [CODESPLIT] public String getThousandSeparatorByDefaultLocale ( ) { final DecimalFormat nf = ( DecimalFormat ) DecimalFormat . getInstance ( getDefaultLocale ( ) ) ; return "" + nf . getDecimalFormatSymbols ( ) . getGroupingSeparator ( ) ; }


Input: Sets the tie command alias list . [CODESPLIT] public void setTieCommandAliasList ( String aliasListJson ) { Gson gson = new Gson ( ) ; Type aliasListType = new TypeToken < ArrayList < TieCommandAlias > > ( ) { } . getType ( ) ; this . tieCommandAliasList = gson . fromJson ( aliasListJson , aliasListType ) ; }


Input:
Watch list serve for formula changes . Basically all the rows appeared in the formula in the current sheet will be watched . Note if the cell reference is from other sheet or workbooks it will be ignored . [CODESPLIT] private List < Integer > buildFormWatchList ( final XSSFEvaluationWorkbook wbWrapper , final Sheet sheet ) { List < Integer > watchList = new ArrayList <> ( ) ; ConfigRange cRange = this . getConfigRange ( ) ; List < ConfigCommand > commandList = cRange . getCommandList ( ) ; if ( commandList . isEmpty ( ) ) { // if no command then no dynamic changes. then no need formula
 // shifts.
 return watchList ; } int lastStaticRow = commandList . get ( 0 ) . getTopRow ( ) - 1 ; if ( lastStaticRow < 0 ) { lastStaticRow = this . getTopRow ( ) ; } int sheetIndex = sheet . getWorkbook ( ) . getSheetIndex ( sheet ) ; for ( int i = this . getTopRow ( ) ; i <= this . getLastRow ( ) ; i ++ ) { Row row = sheet . getRow ( i ) ; for ( Cell cell : row ) { if ( cell . getCellTypeEnum ( ) == CellType . FORMULA ) { buildWatchListForCell ( wbWrapper , sheetIndex , cell , watchList , lastStaticRow ) ; } } } return watchList ; }


Input:
Builds the watch list for cell . [CODESPLIT] private void buildWatchListForCell ( final XSSFEvaluationWorkbook wbWrapper , final int sheetIndex , final Cell cell , final List < Integer > watchList , final int lastStaticRow ) { String formula = cell . getCellFormula ( ) ; Ptg [ ] ptgs = FormulaParser . parse ( formula , wbWrapper , FormulaType . CELL , sheetIndex ) ; for ( int k = 0 ; k < ptgs . length ; k ++ ) { Object ptg = ptgs [ k ] ; // For area formula, only first row is watched.
 // Reason is the lastRow must shift same rows with
 // firstRow.
 // Otherwise it's difficult to calculate.
 // In case some situation cannot fit, then should make
 // change to the formula.
 int areaInt = ShiftFormulaUtility . getFirstSupportedRowNumFromPtg ( ptg ) ; if ( areaInt >= 0 ) { addToWatchList ( areaInt , lastStaticRow , watchList ) ; } } // when insert row, the formula may changed. so here is the
 // workaround.
 // change formula to user formula to preserve the row
 // changes.
 cell . setCellType ( CellType . STRING ) ; cell . setCellValue ( TieConstants . USER_FORMULA_PREFIX + formula + TieConstants . USER_FORMULA_SUFFIX ) ; }


Input: Only rows in dynamic area will be added to watch list . [CODESPLIT] private void addToWatchList ( final int addRow , final int lastStaticRow , final List < Integer > watchList ) { if ( ( addRow > lastStaticRow ) && ! ( watchList . contains ( addRow ) ) ) { watchList . add ( addRow ) ; } }


Input:
/ * ( non - Javadoc ) [CODESPLIT] @ Override /**
	 * build the command area at the row.
	 */ public final int buildAt ( String fullName , final ConfigBuildRef configBuildRef , final int atRow , final Map < String , Object > context , List < RowsMapping > currentRowsMappingList ) { configBuildRef . setWatchList ( buildFormWatchList ( configBuildRef . getWbWrapper ( ) , configBuildRef . getSheet ( ) ) ) ; fullName = this . getCommandName ( ) ; RowsMapping unitRowsMapping = new RowsMapping ( ) ; for ( Integer index : configBuildRef . getWatchList ( ) ) { if ( ConfigurationUtility . isStaticRow ( this . getConfigRange ( ) , index ) ) { unitRowsMapping . addRow ( index , configBuildRef . getSheet ( ) . getRow ( index ) ) ; } } currentRowsMappingList = new ArrayList <> ( ) ; currentRowsMappingList . add ( unitRowsMapping ) ; this . getConfigRange ( ) . getAttrs ( ) . setAllowAdd ( false ) ; configBuildRef . putShiftAttrs ( fullName , this . getConfigRange ( ) . getAttrs ( ) , new RowsMapping ( unitRowsMapping ) ) ; configBuildRef . setOriginConfigRange ( new ConfigRange ( this . getConfigRange ( ) ) ) ; configBuildRef . getOriginConfigRange ( ) . indexCommandRange ( configBuildRef . getCommandIndexMap ( ) ) ; int length = this . getConfigRange ( ) . buildAt ( fullName , configBuildRef , atRow , context , currentRowsMappingList ) ; this . getConfigRange ( ) . getAttrs ( ) . setFinalLength ( length ) ; this . setFinalLength ( length ) ; configBuildRef . getSheet ( ) . setColumnHidden ( TieConstants . HIDDEN_FULL_NAME_COLUMN , true ) ; configBuildRef . getSheet ( ) . setColumnHidden ( TieConstants . HIDDEN_SAVE_OBJECTS_COLUMN , true ) ; configBuildRef . getSheet ( ) . setColumnHidden ( TieConstants . HIDDEN_ORIGIN_ROW_NUMBER_COLUMN , true ) ; return length ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ SuppressWarnings ( "rawtypes" ) @ Override public final List getSerListFromCtObjChart ( final Object ctObjChart ) { if ( ctObjChart instanceof CTLineChart ) { return ( ( CTLineChart ) ctObjChart ) . getSerList ( ) ; } return emptyLinelist ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final CTShapeProperties getShapePropertiesFromCTSer ( final Object ctObjSer ) { if ( ctObjSer instanceof CTLineSer ) { return ( ( CTLineSer ) ctObjSer ) . getSpPr ( ) ; } return null ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final CTNumDataSource getCTNumDataSourceFromCTSer ( final Object ctObjSer ) { if ( ctObjSer instanceof CTLineSer ) { return ( ( CTLineSer ) ctObjSer ) . getVal ( ) ; } return null ; }


Input: check it s a command comment . [CODESPLIT] public static boolean isCommandString ( final String str ) { if ( str == null ) { return false ; } return str . startsWith ( TieConstants . COMMAND_PREFIX ) ; }


Input: method string is start as $ follow by method name then with { and } . i . e . $init { department . name } [CODESPLIT] public static boolean isMethodString ( final String str ) { if ( str == null ) { return false ; } return str . matches ( TieConstants . METHOD_REGEX ) ; }


Input: empty method string is start as $ follow with { and } . i . e . $ { department . name } [CODESPLIT] public static boolean isEmptyMethodString ( final String str ) { if ( str == null ) { return false ; } return str . startsWith ( TieConstants . METHOD_PREFIX ) ; }


Input: widget method start with $widget . e . g . $widget . calendar { .... [CODESPLIT] public static boolean isWidgetMethodString ( final String str ) { if ( str == null ) { return false ; } return str . startsWith ( TieConstants . METHOD_WIDGET_PREFIX ) ; }


Input: validate method start with $validate { rule = ... error = ... } . [CODESPLIT] public static boolean isValidateMethodString ( final String str ) { if ( str == null ) { return false ; } return str . startsWith ( TieConstants . METHOD_VALIDATE_PREFIX ) ; }


Input:
Parses the widget attributes . [CODESPLIT] public static void parseWidgetAttributes ( final Cell cell , final String newComment , final CellAttributesMap cellAttributesMap ) { if ( ( newComment == null ) || ( newComment . isEmpty ( ) ) ) { return ; } int widgetStart = newComment . indexOf ( TieConstants . METHOD_WIDGET_PREFIX ) ; int elStart = newComment . indexOf ( TieConstants . EL_START_BRACKET ) ; if ( ( widgetStart < 0 ) || ( widgetStart >= elStart ) ) { return ; } String type = newComment . substring ( widgetStart + TieConstants . METHOD_WIDGET_PREFIX . length ( ) , elStart ) ; String values = getStringBetweenBracket ( newComment ) ; if ( values == null ) { return ; } // map's key is sheetName!$columnIndex$rowIndex
 String key = getAttributeKeyInMapByCell ( cell ) ; // one cell only has one control widget
 cellAttributesMap . getCellInputType ( ) . put ( key , type ) ; List < CellFormAttributes > inputs = cellAttributesMap . getCellInputAttributes ( ) . get ( key ) ; if ( inputs == null ) { inputs = new ArrayList <> ( ) ; cellAttributesMap . getCellInputAttributes ( ) . put ( key , inputs ) ; } parseInputAttributes ( inputs , values ) ; parseSpecialAttributes ( key , type , inputs , cellAttributesMap ) ; }


Input:
get attribute key in map by cell . [CODESPLIT] public static String getAttributeKeyInMapByCell ( final Cell cell ) { if ( cell == null ) { return null ; } // map's key is sheetName!$columnIndex$rowIndex
 return cell . getSheet ( ) . getSheetName ( ) + "!" + CellUtility . getCellIndexNumberKey ( cell ) ; }


Input:
Parses the validate attributes . [CODESPLIT] public static void parseValidateAttributes ( final Cell cell , final String newComment , final CellAttributesMap cellAttributesMap ) { if ( ( newComment == null ) || ( newComment . isEmpty ( ) ) ) { return ; } if ( ! newComment . startsWith ( TieConstants . METHOD_VALIDATE_PREFIX ) ) { return ; } String values = getStringBetweenBracket ( newComment ) ; if ( values == null ) { return ; } // map's key is sheetName!$columnIndex$rowIndex
 String key = getAttributeKeyInMapByCell ( cell ) ; List < CellFormAttributes > attrs = cellAttributesMap . getCellValidateAttributes ( ) . get ( key ) ; if ( attrs == null ) { attrs = new ArrayList <> ( ) ; cellAttributesMap . getCellValidateAttributes ( ) . put ( key , attrs ) ; } parseValidateAttributes ( attrs , values ) ; }


Input: get the string between two bracket . . e . g . $save { employee . name } return employee . name . [CODESPLIT] public static String getStringBetweenBracket ( final String newComment ) { if ( newComment == null ) { return null ; } int elStart = newComment . indexOf ( TieConstants . EL_START_BRACKET ) ; int elEnd = findPairBracketPosition ( newComment , elStart ) ; if ( elStart >= elEnd ) { return null ; } return newComment . substring ( elStart + 1 , elEnd ) ; }


Input: Find pair bracket position . [CODESPLIT] private static int findPairBracketPosition ( final String str , final int startPos ) { int bracketNum = 0 ; for ( int i = startPos ; i < str . length ( ) ; i ++ ) { char current = str . charAt ( i ) ; if ( current == TieConstants . EL_START_BRACKET ) { bracketNum ++ ; } else if ( current == TieConstants . EL_END ) { bracketNum -- ; if ( bracketNum <= 0 ) { return i ; } } } return - 1 ; }


Input: Parse the attributes from string . [CODESPLIT] public static Map < String , String > parseCommandAttributes ( final String attrString ) { Map < String , String > attrMap = new LinkedHashMap <> ( ) ; Matcher attrMatcher = TieConstants . ATTR_REGEX_PATTERN . matcher ( attrString ) ; while ( attrMatcher . find ( ) ) { String attrData = attrMatcher . group ( ) ; int attrNameEndIndex = attrData . indexOf ( ' ' ) ; String attrName = attrData . substring ( 0 , attrNameEndIndex ) . trim ( ) ; String attrValuePart = attrData . substring ( attrNameEndIndex + 1 ) . trim ( ) ; String attrValue = attrValuePart . substring ( 1 , attrValuePart . length ( ) - 1 ) ; attrMap . put ( attrName , attrValue ) ; } return attrMap ; }


Input:
parse input attributes . [CODESPLIT] public static void parseInputAttributes ( final List < CellFormAttributes > clist , final String controlAttrs ) { // only one type control allowed for one cell.
 clist . clear ( ) ; if ( controlAttrs != null ) { String [ ] cattrs = controlAttrs . split ( TieConstants . SPLIT_SPACE_SEPERATE_ATTRS_REGX , - 1 ) ; for ( String cattr : cattrs ) { String [ ] details = splitByEualSign ( cattr ) ; if ( details . length > 1 ) { CellFormAttributes attr = new CellFormAttributes ( ) ; attr . setType ( details [ 0 ] . trim ( ) ) ; attr . setValue ( details [ 1 ] . replaceAll ( "\"" , "" ) ) ; clist . add ( attr ) ; } } } }


Input:
parse validate attributes . [CODESPLIT] public static void parseValidateAttributes ( final List < CellFormAttributes > clist , final String controlAttrs ) { // one cell could have multiple validation rules.
 if ( controlAttrs == null ) { return ; } String [ ] cattrs = controlAttrs . split ( TieConstants . SPLIT_SPACE_SEPERATE_ATTRS_REGX , - 1 ) ; CellFormAttributes attr = new CellFormAttributes ( ) ; for ( String cattr : cattrs ) { extractValidationAttributes ( attr , cattr ) ; } if ( ( attr . getValue ( ) != null ) && ( ! attr . getValue ( ) . isEmpty ( ) ) ) { clist . add ( attr ) ; } }


Input: extractValidationAttributes . [CODESPLIT] private static void extractValidationAttributes ( final CellFormAttributes attr , final String cattr ) { String [ ] details = splitByEualSign ( cattr ) ; if ( details . length > 1 ) { if ( details [ 0 ] . equalsIgnoreCase ( TieConstants . VALIDATION_RULE_TAG ) ) { attr . setValue ( details [ 1 ] . replaceAll ( "\"" , "" ) ) ; } else if ( details [ 0 ] . equalsIgnoreCase ( TieConstants . VALIDATION_ERROR_MSG_TAG ) ) { attr . setMessage ( details [ 1 ] . replaceAll ( "\"" , "" ) ) ; } } }


Input: split string by = sign . [CODESPLIT] private static String [ ] splitByEualSign ( final String attrData ) { int attrNameEndIndex = attrData . indexOf ( ' ' ) ; if ( attrNameEndIndex < 0 ) { return new String [ 0 ] ; } String attrName = attrData . substring ( 0 , attrNameEndIndex ) . trim ( ) ; String attrValue = attrData . substring ( attrNameEndIndex + 1 ) . trim ( ) ; String [ ] rlist = new String [ 2 ] ; rlist [ 0 ] = attrName ; rlist [ 1 ] = attrValue ; return rlist ; }


Input: parse select item attributes . [CODESPLIT] public static void parseSpecialAttributes ( final String key , final String type , final List < CellFormAttributes > inputs , final CellAttributesMap cellAttributesMap ) { SpecialAttributes sAttr = new SpecialAttributes ( ) ; for ( CellFormAttributes attr : inputs ) { gatherSpecialAttributes ( type , sAttr , attr ) ; } if ( sAttr . selectLabels != null ) { processSelectItemAttributes ( key , cellAttributesMap , sAttr ) ; } if ( type . equalsIgnoreCase ( TieConstants . WIDGET_CALENDAR ) ) { processCalendarAttributes ( key , cellAttributesMap , sAttr ) ; } }


Input: Process calendar attributes . [CODESPLIT] private static void processCalendarAttributes ( final String key , final CellAttributesMap cellAttributesMap , final SpecialAttributes sAttr ) { cellAttributesMap . getCellDatePattern ( ) . put ( key , sAttr . defaultDatePattern ) ; }


Input: Process select item attributes . [CODESPLIT] private static void processSelectItemAttributes ( final String key , final CellAttributesMap cellAttributesMap , final SpecialAttributes sAttr ) { if ( ( sAttr . selectValues == null ) || ( sAttr . selectValues . length != sAttr . selectLabels . length ) ) { sAttr . selectValues = sAttr . selectLabels ; } Map < String , String > smap = cellAttributesMap . getCellSelectItemsAttributes ( ) . get ( key ) ; if ( smap == null ) { smap = new LinkedHashMap <> ( ) ; } smap . clear ( ) ; if ( sAttr . defaultSelectLabel != null ) { smap . put ( sAttr . defaultSelectLabel , sAttr . defaultSelectValue ) ; } for ( int i = 0 ; i < sAttr . selectLabels . length ; i ++ ) { smap . put ( sAttr . selectLabels [ i ] , sAttr . selectValues [ i ] ) ; } cellAttributesMap . getCellSelectItemsAttributes ( ) . put ( key , smap ) ; }


Input: Gather special attributes . [CODESPLIT] private static void gatherSpecialAttributes ( final String type , final SpecialAttributes sAttr , final CellFormAttributes attr ) { String attrKey = attr . getType ( ) ; if ( attrKey . equalsIgnoreCase ( TieConstants . SELECT_ITEM_LABELS ) ) { sAttr . selectLabels = attr . getValue ( ) . split ( ";" ) ; } if ( attrKey . equalsIgnoreCase ( TieConstants . SELECT_ITEM_VALUES ) ) { sAttr . selectValues = attr . getValue ( ) . split ( ";" ) ; } if ( attrKey . equalsIgnoreCase ( TieConstants . DEFAULT_SELECT_ITEM_LABEL ) ) { sAttr . defaultSelectLabel = attr . getValue ( ) ; } if ( attrKey . equalsIgnoreCase ( TieConstants . DEFAULT_SELECT_ITEM_VALUE ) ) { sAttr . defaultSelectValue = attr . getValue ( ) ; } if ( type . equalsIgnoreCase ( TieConstants . WIDGET_CALENDAR ) && attrKey . equalsIgnoreCase ( TieConstants . WIDGET_ATTR_PATTERN ) ) { sAttr . defaultDatePattern = attr . getValue ( ) ; } }


Input:
Parse Comment To Map [CODESPLIT] public static void parseCommentToMap ( final String cellKey , final String newComment , final Map < String , Map < String , String > > sheetCommentMap , final boolean normalComment ) { if ( ( newComment != null ) && ( ! newComment . trim ( ) . isEmpty ( ) ) ) { // normal comment key is $$
 String commentKey = TieConstants . NORMAL_COMMENT_KEY_IN_MAP ; if ( ! normalComment ) { // not normal comment. e.g. ${... or $init{... or
 // key = $ or key = $init
 commentKey = newComment . substring ( 0 , newComment . indexOf ( TieConstants . EL_START_BRACKET ) ) ; } Map < String , String > map = sheetCommentMap . get ( commentKey ) ; if ( map == null ) { map = new HashMap <> ( ) ; } // inner map's key is sheetName!$columnIndex$rowIndex
 map . put ( cellKey , newComment ) ; sheetCommentMap . put ( commentKey , map ) ; } }


Input:
find first non letterordigit position from string . [CODESPLIT] public static int findFirstNonCellNamePosition ( String input , int startPosition ) { char c ; for ( int i = startPosition ; i < input . length ( ) ; i ++ ) { c = input . charAt ( i ) ; if ( c != ' ' && ! Character . isLetterOrDigit ( c ) ) { return i ; } } return - 1 ; // not found
 }


Input:
Removes the chars from string . [CODESPLIT] public static String removeCharsFromString ( String inputStr , int start , int end ) { StringBuilder sb = new StringBuilder ( inputStr ) ; sb . delete ( start , end ) ; //    	 if ((start > 0) && (inputStr.charAt(start - 1) ==' ')) {
 //    		 // if end with a space, then remove it as well.
 //    		 sb.deleteCharAt(start - 1);
 //    	 }
 return sb . toString ( ) ; }


Input:
Gets the excel column name . [CODESPLIT] public static String getExcelColumnName ( final int pnumber ) { StringBuilder converted = new StringBuilder ( ) ; // Repeatedly divide the number by 26 and convert the
 // remainder into the appropriate letter.
 int number = pnumber ; while ( number >= 0 ) { int remainder = number % TieConstants . EXCEL_LETTER_NUMBERS ; converted . insert ( 0 , ( char ) ( remainder + ' ' ) ) ; number = ( number / TieConstants . EXCEL_LETTER_NUMBERS ) - 1 ; } return converted . toString ( ) ; }


Input: return full name for cell with sheet name and $ format e . g . Sheet1$A$1 [CODESPLIT] public static String getFullCellRefName ( final Sheet sheet1 , final Cell cell ) { if ( ( sheet1 != null ) && ( cell != null ) ) { return sheet1 . getSheetName ( ) + "!$" + getExcelColumnName ( cell . getColumnIndex ( ) ) + "$" + ( cell . getRowIndex ( ) + 1 ) ; } return null ; }


Input: return full name for cell with sheet name and $ format e . g . Sheet1$A$1 [CODESPLIT] public static String getFullCellRefName ( final String sheetName , final int rowIndex , final int colIndex ) { if ( sheetName != null ) { return sheetName + "!$" + getExcelColumnName ( colIndex ) + "$" + ( rowIndex + 1 ) ; } return null ; }


Input: return sheet name from cell full name e . g . return Sheet1 from Sheet1$A$1 [CODESPLIT] public static String getSheetNameFromFullCellRefName ( final String fullName ) { if ( ( fullName != null ) && ( fullName . contains ( "!" ) ) ) { return fullName . substring ( 0 , fullName . indexOf ( ' ' ) ) ; } return null ; }


Input: remove sheet name from cell full name e . g . return $A$1 from Sheet1$A$1 [CODESPLIT] public static String removeSheetNameFromFullCellRefName ( final String fullName ) { if ( ( fullName != null ) && ( fullName . contains ( "!" ) ) ) { return fullName . substring ( fullName . indexOf ( ' ' ) + 1 ) ; } return fullName ; }


Input: Convert col to int . [CODESPLIT] public static int convertColToInt ( final String col ) { String name = col . toUpperCase ( ) ; int number = 0 ; int pow = 1 ; for ( int i = name . length ( ) - 1 ; i >= 0 ; i -- ) { number += ( name . charAt ( i ) - ' ' + 1 ) * pow ; pow *= TieConstants . EXCEL_LETTER_NUMBERS ; } return number - 1 ; }


Input:
Gets the cell by reference . [CODESPLIT] public static Cell getCellByReference ( final String cellRef , final Sheet sheet ) { Cell c = null ; try { CellReference ref = new CellReference ( cellRef ) ; Row r = sheet . getRow ( ref . getRow ( ) ) ; if ( r != null ) { c = r . getCell ( ref . getCol ( ) , MissingCellPolicy . CREATE_NULL_AS_BLANK ) ; } } catch ( Exception ex ) { // use log.debug because mostly it's expected
 LOG . log ( Level . SEVERE , "WebForm WebFormHelper getCellByReference cellRef = " + cellRef + "; error = " + ex . getLocalizedMessage ( ) , ex ) ; } return c ; }


Input: pixel units to excel width units ( units of 1 / 256th of a character width ) . [CODESPLIT] public static short pixel2WidthUnits ( final int pxs ) { short widthUnits = ( short ) ( EXCEL_COLUMN_WIDTH_FACTOR * ( pxs / UNIT_OFFSET_LENGTH ) ) ; widthUnits += UNIT_OFFSET_MAP [ pxs % UNIT_OFFSET_LENGTH ] ; return widthUnits ; }


Input: excel width units ( units of 1 / 256th of a character width ) to pixel units . [CODESPLIT] public static int widthUnits2Pixel ( final int widthUnits ) { int pixels = ( widthUnits / EXCEL_COLUMN_WIDTH_FACTOR ) * UNIT_OFFSET_LENGTH ; int offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR ; pixels += Math . round ( offsetWidthUnits / ( ( float ) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH ) ) ; return pixels ; }


Input: Height units 2 pixel . [CODESPLIT] public static int heightUnits2Pixel ( final short heightUnits ) { int pixels = heightUnits / EXCEL_ROW_HEIGHT_FACTOR ; int offsetHeightUnits = heightUnits % EXCEL_ROW_HEIGHT_FACTOR ; pixels += Math . round ( ( float ) offsetHeightUnits / ( ( float ) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH / 2 ) ) ; pixels += ( Math . floor ( pixels / PIXEL_HEIGHT_ASPC_ADJUST ) + 1 ) * 4 ; return pixels ; }


Input: Checks if is date . [CODESPLIT] public static boolean isDate ( final String s ) { Pattern pattern = Pattern . compile ( DATE_REGEX_4_DIGIT_YEAR ) ; String [ ] terms = s . split ( " " ) ; Matcher matcher ; for ( String term : terms ) { matcher = pattern . matcher ( term ) ; if ( matcher . matches ( ) ) { return true ; } } pattern = Pattern . compile ( DATE_REGEX_2_DIGIT_YEAR ) ; terms = s . split ( " " ) ; for ( String term : terms ) { matcher = pattern . matcher ( term ) ; if ( matcher . matches ( ) ) { return true ; } } return false ; }


Input: Parses the date . [CODESPLIT] public static String parseDate ( final String entry ) { Pattern pattern = Pattern . compile ( DATE_REGEX_4_DIGIT_YEAR ) ; String [ ] terms = entry . split ( " " ) ; Matcher matcher ; for ( String term : terms ) { matcher = pattern . matcher ( term ) ; if ( matcher . matches ( ) ) { return matcher . group ( ) ; } } pattern = Pattern . compile ( DATE_REGEX_2_DIGIT_YEAR ) ; terms = entry . split ( " " ) ; for ( String term : terms ) { matcher = pattern . matcher ( term ) ; if ( matcher . matches ( ) ) { return matcher . group ( ) ; } } return "" ; }


Input: Checks if is numeric . [CODESPLIT] public static boolean isNumeric ( final String str ) { String s = str ; if ( s . startsWith ( "-" ) ) { s = s . substring ( 1 ) ; } char c ; int i ; int sLen = s . length ( ) ; ShouldContinueParameter sPara = new ShouldContinueParameter ( false , false , 0 ) ; for ( i = 0 ; i < sLen ; i ++ ) { c = s . charAt ( i ) ; if ( c < ' ' || c > ' ' ) { if ( ! shouldContinue ( c , sPara ) ) { return false ; } } else { if ( sPara . isCommaHit ( ) ) { sPara . setSinceLastComma ( sPara . getSinceLastComma ( ) + 1 ) ; } } } return true ; }


Input: Should continue . [CODESPLIT] private static boolean shouldContinue ( final char c , final ShouldContinueParameter para ) { if ( c == ' ' && ! para . isDecimalHit ( ) ) { para . setDecimalHit ( true ) ; if ( para . isCommaHit ( ) && para . getSinceLastComma ( ) != 3 ) { return false ; } return true ; } else if ( c == ' ' && ! para . isDecimalHit ( ) ) { if ( para . isCommaHit ( ) ) { if ( para . getSinceLastComma ( ) != 3 ) { return false ; } para . setSinceLastComma ( 0 ) ; } para . setCommaHit ( true ) ; return true ; } return false ; }


Input: Sets the object property . [CODESPLIT] public static void setObjectProperty ( final Object obj , final String propertyName , final String propertyValue , final boolean ignoreNonExisting ) { try { Method method = obj . getClass ( ) . getMethod ( "set" + Character . toUpperCase ( propertyName . charAt ( 0 ) ) + propertyName . substring ( 1 ) , new Class [ ] { String . class } ) ; method . invoke ( obj , propertyValue ) ; } catch ( Exception e ) { String msg = "failed to set property '" + propertyName + "' to value '" + propertyValue + "' for object " + obj ; if ( ignoreNonExisting ) { LOG . info ( msg ) ; } else { LOG . warning ( msg ) ; throw new IllegalArgumentException ( e ) ; } } }


Input: Cell compare to . [CODESPLIT] public static int cellCompareTo ( final Cell thisCell , final Cell otherCell ) { int r = thisCell . getRowIndex ( ) - otherCell . getRowIndex ( ) ; if ( r != 0 ) { return r ; } r = thisCell . getColumnIndex ( ) - otherCell . getColumnIndex ( ) ; if ( r != 0 ) { return r ; } return 0 ; }


Input: Inside range . [CODESPLIT] public static boolean insideRange ( final ConfigRange child , final ConfigRange parent ) { return ( ( cellCompareTo ( child . getFirstRowRef ( ) , parent . getFirstRowRef ( ) ) >= 0 ) && ( cellCompareTo ( child . getLastRowPlusRef ( ) , parent . getLastRowPlusRef ( ) ) <= 0 ) ) ; }


Input: return the last column of the sheet . [CODESPLIT] public static int getSheetRightCol ( final Sheet sheet ) { try { if ( sheet instanceof XSSFSheet ) { XSSFSheet xsheet = ( XSSFSheet ) sheet ; int rightCol = getSheetRightColFromDimension ( xsheet ) ; if ( rightCol > TieConstants . MAX_COLUMNS_IN_SHEET ) { clearHiddenColumns ( sheet ) ; rightCol = getSheetRightColFromDimension ( xsheet ) ; } return rightCol ; } } catch ( Exception e ) { LOG . log ( Level . SEVERE , "error in getSheetRightCol : " + e . getLocalizedMessage ( ) , e ) ; } return - 1 ; }


Input: Clear hidden columns . [CODESPLIT] public static void clearHiddenColumns ( final Sheet sheet ) { for ( Row row : sheet ) { if ( row . getLastCellNum ( ) > TieConstants . MAX_COLUMNS_IN_SHEET ) { deleteHiddenColumnsInRow ( row ) ; } } }


Input: Delete hidden columns in row . [CODESPLIT] private static void deleteHiddenColumnsInRow ( final Row row ) { deleteCellFromRow ( row , TieConstants . HIDDEN_SAVE_OBJECTS_COLUMN ) ; deleteCellFromRow ( row , TieConstants . HIDDEN_ORIGIN_ROW_NUMBER_COLUMN ) ; deleteCellFromRow ( row , TieConstants . HIDDEN_FULL_NAME_COLUMN ) ; }


Input: Delete cell from row . [CODESPLIT] private static void deleteCellFromRow ( final Row row , final int cellNum ) { Cell cell = row . getCell ( cellNum ) ; if ( cell != null ) { row . removeCell ( cell ) ; } }


Input: return the last column of the sheet . [CODESPLIT] private static int getSheetRightColFromDimension ( final XSSFSheet xsheet ) { CTSheetDimension dimension = xsheet . getCTWorksheet ( ) . getDimension ( ) ; String sheetDimensions = dimension . getRef ( ) ; if ( sheetDimensions . indexOf ( ' ' ) < 0 ) { return - 1 ; } else { return CellRangeAddress . valueOf ( sheetDimensions ) . getLastColumn ( ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final String getSeriesLabelFromCTSer ( final Object ctObjSer ) { if ( ctObjSer instanceof CTAreaSer ) { return ( ( CTAreaSer ) ctObjSer ) . getTx ( ) . getStrRef ( ) . getF ( ) ; } return null ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final CTShapeProperties getShapePropertiesFromCTSer ( final Object ctObjSer ) { if ( ctObjSer instanceof CTAreaSer ) { return ( ( CTAreaSer ) ctObjSer ) . getSpPr ( ) ; } return null ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public final CTNumDataSource getCTNumDataSourceFromCTSer ( final Object ctObjSer ) { if ( ctObjSer instanceof CTAreaSer ) { return ( ( CTAreaSer ) ctObjSer ) . getVal ( ) ; } return null ; }


Input: process event . [CODESPLIT] @ Override public final void processEvent ( final SystemEvent event ) { LOGGER . log ( Level . INFO , "Running on TieFaces {0}" , AppUtils . getBuildVersion ( ) ) ; }


Input: Refresh after status changed . [CODESPLIT] private void refreshAfterStatusChanged ( final boolean oldStatus , final boolean newStatus , final int formRow , final int formCol , final FacesCell cell , final boolean updateGui ) { if ( ! newStatus ) { cell . setErrormsg ( "" ) ; } cell . setInvalid ( newStatus ) ; if ( updateGui && ( oldStatus != newStatus ) && ( parent . getWebFormClientId ( ) != null ) ) { RequestContext . getCurrentInstance ( ) . update ( parent . getWebFormClientId ( ) + ":" + ( formRow ) + ":group" + ( formCol ) ) ; } }


Input:
Validate with row col in current page . [CODESPLIT] public boolean validateWithRowColInCurrentPage ( final int row , final int col , boolean updateGui ) { //until now passEmptyCheck has one to one relation to submitMode
 //e.g. when passEmptyCheck = false, then submitMode = true.
 boolean submitMode = parent . getSubmitMode ( ) ; boolean passEmptyCheck = ! submitMode ; int topRow = parent . getCurrent ( ) . getCurrentTopRow ( ) ; int leftCol = parent . getCurrent ( ) . getCurrentLeftColumn ( ) ; boolean pass = true ; FacesRow fRow = CellUtility . getFacesRowFromBodyRow ( row , parent . getBodyRows ( ) , topRow ) ; if ( fRow == null ) { return pass ; } FacesCell cell = CellUtility . getFacesCellFromBodyRow ( row , col , parent . getBodyRows ( ) , topRow , leftCol ) ; if ( cell == null ) { return pass ; } Cell poiCell = parent . getCellHelper ( ) . getPoiCellWithRowColFromCurrentPage ( row , col ) ; boolean oldStatus = cell . isInvalid ( ) ; String value = CellUtility . getCellValueWithoutFormat ( poiCell ) ; if ( value == null ) { value = "" ; } else { value = value . trim ( ) ; } if ( passEmptyCheck && value . isEmpty ( ) ) { refreshAfterStatusChanged ( oldStatus , false , row - topRow , col - leftCol , cell , updateGui ) ; return pass ; } if ( ( ( parent . isOnlyValidateInSubmitMode ( ) && submitMode ) || ! parent . isOnlyValidateInSubmitMode ( ) ) && ! validateByTieWebSheetValidationBean ( poiCell , topRow , leftCol , cell , value , updateGui ) ) { return false ; } SheetConfiguration sheetConfig = parent . getSheetConfigMap ( ) . get ( parent . getCurrent ( ) . getCurrentTabName ( ) ) ; List < CellFormAttributes > cellAttributes = CellControlsUtility . findCellValidateAttributes ( parent . getCellAttributesMap ( ) . getCellValidateAttributes ( ) , fRow . getOriginRowIndex ( ) , poiCell ) ; if ( parent . isAdvancedContext ( ) && parent . getConfigAdvancedContext ( ) . getErrorSuffix ( ) != null && ! checkErrorMessageFromObjectInContext ( row - topRow , col - leftCol , cell , poiCell , value , sheetConfig , updateGui ) ) { return false ; } if ( cellAttributes != null ) { pass = validateAllRulesForSingleCell ( row - topRow , col - leftCol , cell , poiCell , value , sheetConfig , cellAttributes , updateGui ) ; } if ( pass ) { refreshAfterStatusChanged ( oldStatus , false , row - topRow , col - leftCol , cell , updateGui ) ; } return pass ; }


Input: Validate by tie web sheet validation bean . [CODESPLIT] private boolean validateByTieWebSheetValidationBean ( final Cell poiCell , final int topRow , final int leftCol , final FacesCell cell , final String value , boolean updateGui ) { if ( parent . getTieWebSheetValidationBean ( ) != null ) { String errormsg = null ; String fullName = ConfigurationUtility . getFullNameFromRow ( poiCell . getRow ( ) ) ; String saveAttr = SaveAttrsUtility . prepareContextAndAttrsForCell ( poiCell , fullName , parent . getCellHelper ( ) ) ; if ( saveAttr != null ) { int row = poiCell . getRowIndex ( ) ; int col = poiCell . getColumnIndex ( ) ; errormsg = parent . getTieWebSheetValidationBean ( ) . validate ( parent . getSerialDataContext ( ) . getDataContext ( ) , saveAttr , ConfigurationUtility . getFullNameFromRow ( poiCell . getRow ( ) ) , poiCell . getSheet ( ) . getSheetName ( ) , row , col , value ) ; if ( ( errormsg != null ) && ( ! errormsg . isEmpty ( ) ) ) { cell . setErrormsg ( errormsg ) ; refreshAfterStatusChanged ( false , true , row - topRow , col - leftCol , cell , updateGui ) ; return false ; } } } return true ; }


Input: Check error message from object in context . [CODESPLIT] private boolean checkErrorMessageFromObjectInContext ( final int formRow , final int formCol , final FacesCell cell , final Cell poiCell , final String value , final SheetConfiguration sheetConfig , boolean updateGui ) { @ SuppressWarnings ( "unchecked" ) HashMap < String , TieCell > tieCells = ( HashMap < String , TieCell > ) parent . getSerialDataContext ( ) . getDataContext ( ) . get ( "tiecells" ) ; if ( tieCells != null ) { TieCell tieCell = tieCells . get ( CellUtility . getSkeyFromPoiCell ( poiCell ) ) ; if ( tieCell != null && tieCell . getContextObject ( ) != null ) { String errorMethod = tieCell . getMethodStr ( ) + parent . getConfigAdvancedContext ( ) . getErrorSuffix ( ) ; String errorMessage = CellControlsUtility . getObjectPropertyValue ( tieCell . getContextObject ( ) , errorMethod , true ) ; if ( errorMessage != null && ! errorMessage . isEmpty ( ) ) { cell . setErrormsg ( errorMessage ) ; LOG . log ( Level . INFO , "Validation failed for sheet {0} row {1} column {2} : {3}" , new Object [ ] { poiCell . getSheet ( ) . getSheetName ( ) , poiCell . getRowIndex ( ) , poiCell . getColumnIndex ( ) , errorMessage } ) ; refreshAfterStatusChanged ( false , true , formRow , formCol , cell , updateGui ) ; return false ; } } } return true ; }


Input: Validate all rules for single cell . [CODESPLIT] private boolean validateAllRulesForSingleCell ( final int formRow , final int formCol , final FacesCell cell , final Cell poiCell , final String value , final SheetConfiguration sheetConfig , final List < CellFormAttributes > cellAttributes , boolean updateGui ) { Sheet sheet1 = parent . getWb ( ) . getSheet ( sheetConfig . getSheetName ( ) ) ; for ( CellFormAttributes attr : cellAttributes ) { boolean pass = doValidation ( value , attr , poiCell . getRowIndex ( ) , poiCell . getColumnIndex ( ) , sheet1 ) ; if ( ! pass ) { String errmsg = attr . getMessage ( ) ; if ( errmsg == null ) { errmsg = TieConstants . DEFALT_MSG_INVALID_INPUT ; } cell . setErrormsg ( errmsg ) ; LOG . log ( Level . INFO , "Validation failed for sheet {0} row {1} column {2} : {3}" , new Object [ ] { poiCell . getSheet ( ) . getSheetName ( ) , poiCell . getRowIndex ( ) , poiCell . getColumnIndex ( ) , errmsg } ) ; refreshAfterStatusChanged ( false , true , formRow , formCol , cell , updateGui ) ; return false ; } } return true ; }


Input: Do validation . [CODESPLIT] private boolean doValidation ( final Object value , final CellFormAttributes attr , final int rowIndex , final int colIndex , final Sheet sheet ) { boolean pass ; String attrValue = attr . getValue ( ) ; attrValue = attrValue . replace ( "$value" , value . toString ( ) + "" ) . replace ( "$rowIndex" , rowIndex + "" ) . replace ( "$colIndex" , colIndex + "" ) . replace ( "$sheetName" , sheet . getSheetName ( ) ) ; attrValue = ConfigurationUtility . replaceExpressionWithCellValue ( attrValue , rowIndex , sheet ) ; if ( attrValue . contains ( TieConstants . EL_START ) ) { Object returnObj = FacesUtility . evaluateExpression ( attrValue , Object . class ) ; attrValue = returnObj . toString ( ) ; pass = Boolean . parseBoolean ( attrValue ) ; } else { pass = parent . getCellHelper ( ) . evalBoolExpression ( attrValue ) ; } return pass ; }


Input: Validate cell . [CODESPLIT] public final boolean validateCell ( final UIComponent target ) { int [ ] rowcol = CellUtility . getRowColFromComponentAttributes ( target ) ; int row = rowcol [ 0 ] ; int col = rowcol [ 1 ] ; return validateWithRowColInCurrentPage ( row , col , true ) ; }


Input: Validate current page . [CODESPLIT] public final boolean validateCurrentPage ( ) { boolean allpass = true ; int top = parent . getCurrent ( ) . getCurrentTopRow ( ) ; for ( int irow = 0 ; irow < parent . getBodyRows ( ) . size ( ) ; irow ++ ) { if ( ! validateRowInCurrentPage ( irow + top , false ) ) { allpass = false ; } } return allpass ; }


Input: Validate row in current page . [CODESPLIT] public final boolean validateRowInCurrentPage ( final int irow , final boolean updateGui ) { SheetConfiguration sheetConfig = parent . getSheetConfigMap ( ) . get ( parent . getCurrent ( ) . getCurrentTabName ( ) ) ; return this . validateRow ( irow , sheetConfig , updateGui ) ; }


Input: Validate row . [CODESPLIT] private boolean validateRow ( final int irow , final SheetConfiguration sheetConfig , boolean updateGui ) { boolean pass = true ; if ( sheetConfig == null ) { return pass ; } int top = sheetConfig . getBodyCellRange ( ) . getTopRow ( ) ; List < FacesCell > cellRow = parent . getBodyRows ( ) . get ( irow - top ) . getCells ( ) ; for ( int index = 0 ; index < cellRow . size ( ) ; index ++ ) { FacesCell fcell = cellRow . get ( index ) ; if ( ( fcell != null ) && ( ! validateWithRowColInCurrentPage ( irow , fcell . getColumnIndex ( ) , updateGui ) ) ) { pass = false ; } } return pass ; }


Input:
Triggered when value in cells changed . e . g . user edit cell . [CODESPLIT] public void valueChangeEvent ( final AjaxBehaviorEvent event ) { try { FacesContext facesContext = FacesContext . getCurrentInstance ( ) ; String tblName = parent . getWebFormClientId ( ) ; UIComponent target = event . getComponent ( ) ; boolean pass = validateCell ( target ) ; if ( pass ) { // to improve performance, re-validate current row only
 // page validation take times. will happen when change tab(page)
 // or
 // reload page.
 int [ ] rowcol = CellUtility . getRowColFromComponentAttributes ( target ) ; validateRowInCurrentPage ( rowcol [ 0 ] , true ) ; refreshCachedCellsInCurrentPage ( facesContext , tblName ) ; } } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "Validation error:" + ex . getLocalizedMessage ( ) , ex ) ; } }


Input:
Refresh cached cells in current page . [CODESPLIT] private void refreshCachedCellsInCurrentPage ( final FacesContext facesContext , final String tblName ) { // refresh current page calculation fields
 UIComponent s = facesContext . getViewRoot ( ) . findComponent ( tblName ) ; if ( s == null ) { return ; } DataTable webDataTable = ( DataTable ) s ; int first = webDataTable . getFirst ( ) ; int rowsToRender = webDataTable . getRowsToRender ( ) ; int rowCounts = webDataTable . getRowCount ( ) ; int top = parent . getCurrent ( ) . getCurrentTopRow ( ) ; int left = parent . getCurrent ( ) . getCurrentLeftColumn ( ) ; for ( int i = first ; i <= ( first + rowsToRender ) ; i ++ ) { if ( i < rowCounts ) { refreshCachedCellsInRow ( tblName , top , left , i ) ; } } }


Input: Refresh cached cells in row . [CODESPLIT] private void refreshCachedCellsInRow ( final String tblName , final int top , final int left , final int i ) { FacesRow dataRow = parent . getBodyRows ( ) . get ( i ) ; int isize = dataRow . getCells ( ) . size ( ) ; for ( int index = 0 ; index < isize ; index ++ ) { FacesCell fcell = dataRow . getCells ( ) . get ( index ) ; Cell poiCell = parent . getCellHelper ( ) . getPoiCellWithRowColFromCurrentPage ( i + top , index + left ) ; if ( poiCell != null ) { parent . getHelper ( ) . getWebSheetLoader ( ) . refreshCachedCell ( tblName , i , index , poiCell , fcell ) ; } } }


Input: set submit mode flag with javascript for holding in client side . [CODESPLIT] public void setSubmitModeInView ( final Boolean fullflag ) { if ( FacesContext . getCurrentInstance ( ) != null ) { Map < String , Object > viewMap = FacesContext . getCurrentInstance ( ) . getViewRoot ( ) . getViewMap ( ) ; if ( viewMap != null ) { Boolean flag = ( Boolean ) viewMap . get ( TieConstants . SUBMITMODE ) ; if ( ( flag == null ) || ( ! flag . equals ( fullflag ) ) ) { viewMap . put ( TieConstants . SUBMITMODE , fullflag ) ; } } } }