@Test public void testProduceTemplate() { InstanceID instanceId = mock( InstanceID.class ); LogicalPageBox pageBox = mock( LogicalPageBox.class ); RenderBox content = mock( ParagraphRenderBox.class ); TableRectangle rectangle = mock( TableRectangle.class ); mockStatic( TemplatingOutputProcessor.class ); Long contentOffset = 0L; Whitebox.setInternalState( SimpleStyleSheet.class, "EMPTY_STYLE", new SimpleStyleSheet( styleSheet ) ); Whitebox.setInternalState( NodeLayoutProperties.class, "SIMPLE_NODE_ID", new InstanceID() ); Whitebox.setInternalState( AutoLayoutBoxType.class, "INSTANCE", new AutoLayoutBoxType() ); when( TemplatingOutputProcessor.produceTableLayout( pageBox, sheetLayout, metaData ) ).thenReturn( contentProducer ); when( contentProducer.getColumnCount() ).thenReturn( 3 ); when( contentProducer.getFinishedRows() ).thenReturn( 0 ); when( contentProducer.getFilledRows() ).thenReturn( 3 ); when( content.isCommited() ).thenReturn( true ); when( content.getX() ).thenReturn( 100000L ); when( content.getY() ).thenReturn( 100000L ); when( content.getWidth() ).thenReturn( 185600000L ); when( content.getHeight() ).thenReturn( 6200000L ); when( sheetLayout.getTableBounds( content.getX(), content.getY() + contentOffset, content.getWidth(), content.getHeight(), null ) ).thenReturn( rectangle ); when( content.getNodeLayoutProperties() ).thenReturn( nodeLayoutProperties ); when( nodeLayoutProperties.getInstanceId() ).thenReturn( instanceId ); for ( int i = 0; i < 3; i++ ) { when( contentProducer.getContent( 0, i ) ).thenReturn( null ); when( contentProducer.getContentOffset( 0, i ) ).thenReturn( contentOffset ); } for ( int i = 0; i < 3; i++ ) { when( contentProducer.getContent( 1, i ) ).thenReturn( content ); when( contentProducer.getContentOffset( 1, i ) ).thenReturn( contentOffset ); when( rectangle.isOrigin( i, 1 ) ).thenReturn( true ); } for ( int i = 0; i < 3; i++ ) { when( contentProducer.getContent( 2, i ) ).thenReturn( content ); when( contentProducer.getContentOffset( 2, i ) ).thenReturn( contentOffset ); when( rectangle.isOrigin( i, 2 ) ).thenReturn( false ); } csvTemplateProducer.produceTemplate( pageBox ); assertEquals( csvTemplateProducer.getTemplate(), COMPLETE_TEMPLATE ); }
public void produceTemplate( final LogicalPageBox pageBox ) { TableContentProducer contentProducer = TemplatingOutputProcessor.produceTableLayout( pageBox, sheetLayout, metaData ); final SheetLayout sheetLayout = contentProducer.getSheetLayout(); final int columnCount = contentProducer.getColumnCount(); final int lastColumn = columnCount - 1; final int startRow = contentProducer.getFinishedRows(); final int finishRow = contentProducer.getFilledRows(); StringWriter swriter = new StringWriter(); PrintWriter writer = new PrintWriter( swriter ); for ( int row = startRow; row < finishRow; row++ ) { for ( short col = 0; col < columnCount; col++ ) { final RenderBox content = contentProducer.getContent( row, col ); if ( content == null ) { writer.print( quoter.getSeparator() ); continue; } if ( content.isCommited() == false ) { throw new InvalidReportStateException( "Uncommited content encountered" ); } final long contentOffset = contentProducer.getContentOffset( row, col ); final TableRectangle rectangle = sheetLayout.getTableBounds( content.getX(), content.getY() + contentOffset, content.getWidth(), content .getHeight(), null ); if ( rectangle.isOrigin( col, row ) == false ) { writer.print( quoter.getSeparator() ); continue; } InstanceID instanceId = content.getNodeLayoutProperties().getInstanceId(); String uuid = idMapping.get( instanceId ); if ( uuid == null ) { uuid = String.valueOf( idMapping.size() ); idMapping.put( instanceId, uuid ); } final String formattedtext = "$(" + uuid + ")"; writer.write( formattedtext ); if ( col < lastColumn ) { writer.print( quoter.getSeparator() ); } content.setFinishedTable( true ); } writer.println(); } writer.close(); template = swriter.toString(); }
CsvTemplateProducer implements FastExportTemplateProducer { public void produceTemplate( final LogicalPageBox pageBox ) { TableContentProducer contentProducer = TemplatingOutputProcessor.produceTableLayout( pageBox, sheetLayout, metaData ); final SheetLayout sheetLayout = contentProducer.getSheetLayout(); final int columnCount = contentProducer.getColumnCount(); final int lastColumn = columnCount - 1; final int startRow = contentProducer.getFinishedRows(); final int finishRow = contentProducer.getFilledRows(); StringWriter swriter = new StringWriter(); PrintWriter writer = new PrintWriter( swriter ); for ( int row = startRow; row < finishRow; row++ ) { for ( short col = 0; col < columnCount; col++ ) { final RenderBox content = contentProducer.getContent( row, col ); if ( content == null ) { writer.print( quoter.getSeparator() ); continue; } if ( content.isCommited() == false ) { throw new InvalidReportStateException( "Uncommited content encountered" ); } final long contentOffset = contentProducer.getContentOffset( row, col ); final TableRectangle rectangle = sheetLayout.getTableBounds( content.getX(), content.getY() + contentOffset, content.getWidth(), content .getHeight(), null ); if ( rectangle.isOrigin( col, row ) == false ) { writer.print( quoter.getSeparator() ); continue; } InstanceID instanceId = content.getNodeLayoutProperties().getInstanceId(); String uuid = idMapping.get( instanceId ); if ( uuid == null ) { uuid = String.valueOf( idMapping.size() ); idMapping.put( instanceId, uuid ); } final String formattedtext = "$(" + uuid + ")"; writer.write( formattedtext ); if ( col < lastColumn ) { writer.print( quoter.getSeparator() ); } content.setFinishedTable( true ); } writer.println(); } writer.close(); template = swriter.toString(); } }
CsvTemplateProducer implements FastExportTemplateProducer { public void produceTemplate( final LogicalPageBox pageBox ) { TableContentProducer contentProducer = TemplatingOutputProcessor.produceTableLayout( pageBox, sheetLayout, metaData ); final SheetLayout sheetLayout = contentProducer.getSheetLayout(); final int columnCount = contentProducer.getColumnCount(); final int lastColumn = columnCount - 1; final int startRow = contentProducer.getFinishedRows(); final int finishRow = contentProducer.getFilledRows(); StringWriter swriter = new StringWriter(); PrintWriter writer = new PrintWriter( swriter ); for ( int row = startRow; row < finishRow; row++ ) { for ( short col = 0; col < columnCount; col++ ) { final RenderBox content = contentProducer.getContent( row, col ); if ( content == null ) { writer.print( quoter.getSeparator() ); continue; } if ( content.isCommited() == false ) { throw new InvalidReportStateException( "Uncommited content encountered" ); } final long contentOffset = contentProducer.getContentOffset( row, col ); final TableRectangle rectangle = sheetLayout.getTableBounds( content.getX(), content.getY() + contentOffset, content.getWidth(), content .getHeight(), null ); if ( rectangle.isOrigin( col, row ) == false ) { writer.print( quoter.getSeparator() ); continue; } InstanceID instanceId = content.getNodeLayoutProperties().getInstanceId(); String uuid = idMapping.get( instanceId ); if ( uuid == null ) { uuid = String.valueOf( idMapping.size() ); idMapping.put( instanceId, uuid ); } final String formattedtext = "$(" + uuid + ")"; writer.write( formattedtext ); if ( col < lastColumn ) { writer.print( quoter.getSeparator() ); } content.setFinishedTable( true ); } writer.println(); } writer.close(); template = swriter.toString(); } CsvTemplateProducer( final OutputProcessorMetaData metaData, final SheetLayout sheetLayout,
      final String encoding ); }
CsvTemplateProducer implements FastExportTemplateProducer { public void produceTemplate( final LogicalPageBox pageBox ) { TableContentProducer contentProducer = TemplatingOutputProcessor.produceTableLayout( pageBox, sheetLayout, metaData ); final SheetLayout sheetLayout = contentProducer.getSheetLayout(); final int columnCount = contentProducer.getColumnCount(); final int lastColumn = columnCount - 1; final int startRow = contentProducer.getFinishedRows(); final int finishRow = contentProducer.getFilledRows(); StringWriter swriter = new StringWriter(); PrintWriter writer = new PrintWriter( swriter ); for ( int row = startRow; row < finishRow; row++ ) { for ( short col = 0; col < columnCount; col++ ) { final RenderBox content = contentProducer.getContent( row, col ); if ( content == null ) { writer.print( quoter.getSeparator() ); continue; } if ( content.isCommited() == false ) { throw new InvalidReportStateException( "Uncommited content encountered" ); } final long contentOffset = contentProducer.getContentOffset( row, col ); final TableRectangle rectangle = sheetLayout.getTableBounds( content.getX(), content.getY() + contentOffset, content.getWidth(), content .getHeight(), null ); if ( rectangle.isOrigin( col, row ) == false ) { writer.print( quoter.getSeparator() ); continue; } InstanceID instanceId = content.getNodeLayoutProperties().getInstanceId(); String uuid = idMapping.get( instanceId ); if ( uuid == null ) { uuid = String.valueOf( idMapping.size() ); idMapping.put( instanceId, uuid ); } final String formattedtext = "$(" + uuid + ")"; writer.write( formattedtext ); if ( col < lastColumn ) { writer.print( quoter.getSeparator() ); } content.setFinishedTable( true ); } writer.println(); } writer.close(); template = swriter.toString(); } CsvTemplateProducer( final OutputProcessorMetaData metaData, final SheetLayout sheetLayout,
      final String encoding ); void produceTemplate( final LogicalPageBox pageBox ); CSVQuoter getQuoter(); String getTemplate(); FormattedDataBuilder createDataBuilder(); }
CsvTemplateProducer implements FastExportTemplateProducer { public void produceTemplate( final LogicalPageBox pageBox ) { TableContentProducer contentProducer = TemplatingOutputProcessor.produceTableLayout( pageBox, sheetLayout, metaData ); final SheetLayout sheetLayout = contentProducer.getSheetLayout(); final int columnCount = contentProducer.getColumnCount(); final int lastColumn = columnCount - 1; final int startRow = contentProducer.getFinishedRows(); final int finishRow = contentProducer.getFilledRows(); StringWriter swriter = new StringWriter(); PrintWriter writer = new PrintWriter( swriter ); for ( int row = startRow; row < finishRow; row++ ) { for ( short col = 0; col < columnCount; col++ ) { final RenderBox content = contentProducer.getContent( row, col ); if ( content == null ) { writer.print( quoter.getSeparator() ); continue; } if ( content.isCommited() == false ) { throw new InvalidReportStateException( "Uncommited content encountered" ); } final long contentOffset = contentProducer.getContentOffset( row, col ); final TableRectangle rectangle = sheetLayout.getTableBounds( content.getX(), content.getY() + contentOffset, content.getWidth(), content .getHeight(), null ); if ( rectangle.isOrigin( col, row ) == false ) { writer.print( quoter.getSeparator() ); continue; } InstanceID instanceId = content.getNodeLayoutProperties().getInstanceId(); String uuid = idMapping.get( instanceId ); if ( uuid == null ) { uuid = String.valueOf( idMapping.size() ); idMapping.put( instanceId, uuid ); } final String formattedtext = "$(" + uuid + ")"; writer.write( formattedtext ); if ( col < lastColumn ) { writer.print( quoter.getSeparator() ); } content.setFinishedTable( true ); } writer.println(); } writer.close(); template = swriter.toString(); } CsvTemplateProducer( final OutputProcessorMetaData metaData, final SheetLayout sheetLayout,
      final String encoding ); void produceTemplate( final LogicalPageBox pageBox ); CSVQuoter getQuoter(); String getTemplate(); FormattedDataBuilder createDataBuilder();  }