Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#setCompatibilityLevel()

The following examples show how to use org.pentaho.reporting.engine.classic.core.MasterReport#setCompatibilityLevel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WidthComputationIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testLayoutMatrix() throws Exception {
  final MasterReport basereport = new MasterReport();
  basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) );
  basereport.setCompatibilityLevel( null );
  basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  final URL target = LayoutIT.class.getResource( "layout-matrix.xml" );
  final ResourceManager rm = new ResourceManager();
  rm.registerDefaults();
  final Resource directly = rm.createDirectly( target, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();

  final LogicalPageBox logicalPageBox =
      DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), true, false );
  // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000
  // and that only two lines exist for each
  // ModelPrinter.INSTANCE.print(logicalPageBox);
  new ValidateRunner().startValidation( logicalPageBox );
}
 
Example 2
Source File: Prd5321IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Tests the rendering of text in compatibility mode. In this mode elements that do not define an explicit height can
 * be limited in growth to their defined minimum height. This auto-limit only takes place outside of crosstabs (which
 * were not available in pre-5.0 releases) and if the element is contained in a parent band that uses an canvas-layout
 * for its child elements.
 *
 * @throws Exception
 */
@Test
public void testCompatibilityMode() throws Exception {
  URL resource = getClass().getResource( "Prd-5321-2.prpt" );
  ResourceManager mgr = new ResourceManager();
  MasterReport report = (MasterReport) mgr.createDirectly( resource, MasterReport.class ).getResource();
  report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );
  report.setCompatibilityLevel( ClassicEngineBoot.VERSION_3_8 );

  LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );

  RenderNode[] paragraphs = MatchFactory.findElementsByNodeType( logicalPageBox, LayoutNodeTypes.TYPE_BOX_PARAGRAPH );
  Assert.assertEquals( 4, paragraphs.length );
  for ( RenderNode paragraph : paragraphs ) {
    ParagraphRenderBox pb = (ParagraphRenderBox) paragraph;
    Assert.assertNotNull( pb.getFirstChild() );
    Assert.assertSame( pb.getFirstChild(), pb.getLastChild() );
  }
}
 
Example 3
Source File: PlainTextOutputIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private MasterReport createStandardReport( final String longTextLabel ) {
  final MasterReport report = new MasterReport();
  report
      .setPageDefinition( new SimplePageDefinition( PageSize.A4, PageFormat.LANDSCAPE, new Insets( 72, 72, 72, 72 ) ) );
  report.setCompatibilityLevel( null );
  report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  final Band pageHeader = report.getPageHeader();
  final LabelElementFactory labelFactory = new LabelElementFactory();
  labelFactory.setName( "LabelElement" );
  labelFactory.setText( longTextLabel );
  labelFactory.setFontName( "Serif" );
  labelFactory.setFontSize( new Integer( 10 ) );
  labelFactory.setBold( Boolean.FALSE );
  labelFactory.setHeight( 26.0F );
  labelFactory.setWidth( 568.0F );
  labelFactory.setWrap( TextWrap.WRAP );
  labelFactory.setAbsolutePosition( new Point2D.Double( 2.0, 4.0 ) );
  labelFactory.setHorizontalAlignment( ElementAlignment.LEFT );
  labelFactory.setVerticalAlignment( ElementAlignment.TOP );
  final Element labelElement = labelFactory.createElement();
  pageHeader.addElement( labelElement );
  return report;
}
 
Example 4
Source File: NestedBandsIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testNestedRows() throws Exception {
  final MasterReport basereport = new MasterReport();
  basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) );
  basereport.setCompatibilityLevel( null );
  basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  final URL target = LayoutIT.class.getResource( "nested-bands.xml" );
  final ResourceManager rm = new ResourceManager();
  rm.registerDefaults();
  final Resource directly = rm.createDirectly( target, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();

  final LogicalPageBox logicalPageBox =
      DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), false, false );
  // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000
  // and that only two lines exist for each
  new ValidateRunner().startValidation( logicalPageBox );
}
 
Example 5
Source File: WidthComputationIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testLayoutMatrixLegacy() throws Exception {
  final MasterReport basereport = new MasterReport();
  basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) );
  basereport.setCompatibilityLevel( ClassicEngineBoot.computeVersionId( 3, 8, 0 ) );
  basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  final URL target = LayoutIT.class.getResource( "layout-matrix.xml" );
  final ResourceManager rm = new ResourceManager();
  rm.registerDefaults();
  final Resource directly = rm.createDirectly( target, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();

  final LogicalPageBox logicalPageBox =
      DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), true, false );
  // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000
  // and that only two lines exist for each
  // ModelPrinter.INSTANCE.print(logicalPageBox);
  new ValidateRunner().startValidation( logicalPageBox );
}
 
Example 6
Source File: Pre422IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testSubReportDoesNotCrash() throws Exception {
  final URL target = Pre422IT.class.getResource( "Pre-422.xml" );
  final ResourceManager rm = new ResourceManager();
  rm.registerDefaults();
  final Resource directly = rm.createDirectly( target, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();

  final MasterReport basereport = new MasterReport();
  basereport.setCompatibilityLevel( null );
  basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );
  basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) );

  final Band band = report.getReportHeader();
  band.setName( "ReportHeader1" );

  final LogicalPageBox logicalPageBox =
      DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), false, true );
  // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000
  // and that only two lines exist for each
  new ValidateRunner().startValidation( logicalPageBox );

}
 
Example 7
Source File: MinChunkWidthIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testMinChunkWidthSimpleText() throws Exception {
  final MasterReport basereport = new MasterReport();
  basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) );
  basereport.setCompatibilityLevel( null );
  basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  final URL target = LayoutIT.class.getResource( "min-chunkwidth.xml" );
  final ResourceManager rm = new ResourceManager();
  rm.registerDefaults();
  final Resource directly = rm.createDirectly( target, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  // PRD-2736 note: word breaks are implemented now,
  // need to set WORDBREAK to false to keep the previous behaviour
  report.getStyle().setStyleProperty( TextStyleKeys.WORDBREAK, false );

  final LogicalPageBox logicalPageBox =
      DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), true, false );
  // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000
  // and that only two lines exist for each
  // ModelPrinter.INSTANCE.print(logicalPageBox);
  new ValidateRunner( false, false ).startValidation( logicalPageBox );
}
 
Example 8
Source File: Prd3857IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testRowBoxesEstablishOwnBlockContext() throws Exception {
  // this report defines that the group as well as all bands within that group are row-layout.
  // therefore the two itembands end on the same row.

  // The itemband did not define a width, not even a 100% width, and thus ends with a width of auto/zero.
  // therefore the itemband shrinks to the minimal size that still encloses all elements.
  // the elements that have percentage width are resolved against the block context.
  // A band without a width defined (the itemband!), does not establish an own block-context, so it
  // takes the block context of the parent, or as fallback: page.

  final File file = GoldTestBase.locateGoldenSampleReport( "Prd-3479.prpt" );
  final ResourceManager mgr = new ResourceManager();
  mgr.registerDefaults();
  final Resource directly = mgr.createDirectly( file, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setCompatibilityLevel( null );
  report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );
  final RenderNode[] itembands = MatchFactory.findElementsByElementType( logicalPageBox, ItemBandType.INSTANCE );

  assertEquals( 2, itembands.length );
  assertEquals( 48208843, itembands[0].getWidth() );
  assertEquals( 48208843, itembands[1].getWidth() );
  assertEquals( 48208843, itembands[1].getX() );
}
 
Example 9
Source File: CrosstabRowSpanIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testCrosstabCellSpan() throws Exception {
  final URL url = getClass().getResource( "Crosstab-List.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setCompatibilityLevel( ClassicEngineBoot.computeVersionId( 4, 0, 0 ) );

  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );
  // ModelPrinter.print(logicalPageBox);
}
 
Example 10
Source File: TableToHtmlExportIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testHtmlExportFull() throws Exception {
  final URL url = getClass().getResource( "Prd-3931.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setCompatibilityLevel( null );
  report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  final Group rootGroup = report.getRootGroup();
  assertTrue( rootGroup instanceof CrosstabGroup );

  final CrosstabGroup ct = (CrosstabGroup) rootGroup;
  ct.setPrintColumnTitleHeader( true );
  ct.setPrintDetailsHeader( false );

  final MemoryByteArrayOutputStream outputStream = new MemoryByteArrayOutputStream();
  HtmlReportUtil.createStreamHTML( report, outputStream );

  final String htmlText = new String( outputStream.toByteArray(), "UTF-8" );
  DebugLog.log( htmlText );
  assertTrue( htmlText.contains( "<td colspan=\"2\" valign=\"top\" class=\"style-1\">2003</td>" ) );
  assertTrue( htmlText.contains( "<td colspan=\"2\" valign=\"top\" class=\"style-1\">2004</td>" ) );
  assertTrue( htmlText.contains( "<td colspan=\"2\" valign=\"top\" class=\"style-1\">2005</td>" ) );
  assertTrue( htmlText.contains( "<td valign=\"top\" class=\"style-3\">Product Line</td>" ) );
  assertTrue( htmlText.contains( "<td valign=\"top\" class=\"style-3\">Market</td>" ) );
}
 
Example 11
Source File: Prd3514IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testLineBreaksOnStart() throws ReportProcessingException, ContentProcessingException {
  Element textField = new Element();
  textField.setName( "textField" );
  textField.getStyle().setStyleProperty( TextStyleKeys.FONT, "Arial" );
  textField.getStyle().setStyleProperty( TextStyleKeys.FONTSIZE, 14 );
  textField.getStyle().setStyleProperty( TextStyleKeys.TEXT_WRAP, TextWrap.NONE );
  textField.getStyle().setStyleProperty( TextStyleKeys.TRIM_TEXT_CONTENT, false );
  textField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 97f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 20f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 0f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 0f );
  textField.setElementType( LabelType.INSTANCE );
  textField.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "\nClassic Cars" );

  final MasterReport report = new MasterReport();
  report.getReportHeader().addElement( textField );
  report.setCompatibilityLevel( null );
  report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, report.getReportHeader(), false, false );
  ModelPrinter.INSTANCE.print( logicalPageBox );

  RenderNode textFieldBox = MatchFactory.findElementByName( logicalPageBox, "textField" );
  assertNotNull( textFieldBox );

  assertEquals( 0, textFieldBox.getY() );

  // box only contains one line, and min-size is set to 8, max size = 20, so the line-height of 14.024 is used.
  assertEquals( StrictGeomUtility.toInternalValue( 28 ), textFieldBox.getHeight() );
}
 
Example 12
Source File: TableToHtmlExportIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testExportToXml() throws Exception {
  final URL url = getClass().getResource( "Prd-3931.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setCompatibilityLevel( ClassicEngineBoot.computeVersionId( 4, 0, 0 ) );

  final LogicalPageBox pageBox = DebugReportRunner.layoutPage( report, 0 );
  // ModelPrinter.INSTANCE.print(pageBox);
}
 
Example 13
Source File: MigrateReportTask.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void run() {
  final MasterReport masterReportElement = reportContext.getContextRoot();
  final Integer compatibilityLevel = masterReportElement.getCompatibilityLevel();
  if ( compatibilityLevel == null ) {
    return;
  }
  if ( compatibilityLevel.intValue() > minimumVersionNeeded ) {
    // already done.
    return;
  }

  final Window window = LibSwingUtil.getWindowAncestor( designerContext.getView().getParent() );
  final MigrateConfirmationDialog dialog;
  if ( window instanceof JDialog ) {
    dialog = new MigrateConfirmationDialog( (JDialog) window );
  } else if ( window instanceof JFrame ) {
    dialog = new MigrateConfirmationDialog( (JFrame) window );
  } else {
    dialog = new MigrateConfirmationDialog();
  }

  final UserInput userInput = dialog.performSelection();
  if ( userInput == UserInput.Clear ) {
    masterReportElement.setCompatibilityLevel( null );
  } else if ( userInput == UserInput.Migrate ) {
    MigrateReportAction.migrateReport( designerContext );
  }
}
 
Example 14
Source File: TableToHtmlExportIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testHtmlExportFullComplexText() throws Exception {
  final URL url = getClass().getResource( "Prd-3931.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setCompatibilityLevel( null );
  report.getReportConfiguration()
      .setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "true" );

  final Group rootGroup = report.getRootGroup();
  assertTrue( rootGroup instanceof CrosstabGroup );

  final CrosstabGroup ct = (CrosstabGroup) rootGroup;
  ct.setPrintColumnTitleHeader( true );
  ct.setPrintDetailsHeader( false );

  final MemoryByteArrayOutputStream outputStream = new MemoryByteArrayOutputStream();
  HtmlReportUtil.createStreamHTML( report, outputStream );

  final String htmlText = new String( outputStream.toByteArray(), "UTF-8" );
  DebugLog.log( htmlText );
  assertTrue( htmlText.contains( "<td colspan=\"2\" valign=\"top\" class=\"style-1\">2003</td>" ) );
  assertTrue( htmlText.contains( "<td colspan=\"2\" valign=\"top\" class=\"style-1\">2004</td>" ) );
  assertTrue( htmlText.contains( "<td colspan=\"2\" valign=\"top\" class=\"style-1\">2005</td>" ) );
  assertTrue( htmlText.contains( "<td valign=\"top\" class=\"style-3\">Product Line</td>" ) );
  assertTrue( htmlText.contains( "<td valign=\"top\" class=\"style-3\">Market</td>" ) );
}
 
Example 15
Source File: CrosstabRenderIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testLegacyRendering() throws Exception {
  final URL url = getClass().getResource( "CrosstabTest.prpt" );
  final ResourceManager manager = new ResourceManager();
  manager.registerDefaults();
  final Resource res = manager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) res.getResource();
  report.setCompatibilityLevel( ClassicEngineBoot.computeVersionId( 4, 0, 0 ) );

  final LogicalPageBox box = DebugReportRunner.layoutPage( report, 0 );
  // ModelPrinter.print(box);
}
 
Example 16
Source File: CompatibilityUpdater.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void performUpdate( final MasterReport report ) {
  final Integer versionRaw = report.getCompatibilityLevel();
  if ( versionRaw == null ) {
    version = -1;
  } else {
    version = versionRaw.intValue();
  }
  if ( version == -1 ) {
    return;
  }
  performUpdateInternal( report );
  report.setCompatibilityLevel( null );
}
 
Example 17
Source File: Prd3514IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void testWeirdTocLayout() throws ReportProcessingException, ContentProcessingException {

    Element textField = new Element();
    textField.setName( "textField" );
    textField.getStyle().setStyleProperty( TextStyleKeys.FONT, "Arial" );
    textField.getStyle().setStyleProperty( TextStyleKeys.FONTSIZE, 14 );
    textField.getStyle().setStyleProperty( TextStyleKeys.TEXT_WRAP, TextWrap.NONE );
    textField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 97f );
    textField.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 20f );
    textField.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 0f );
    textField.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 0f );
    textField.setElementType( LabelType.INSTANCE );
    textField.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "Classic Cars" );

    Element dotField = new Element();
    dotField.setName( "dotField" );
    dotField.getStyle().setStyleProperty( TextStyleKeys.FONT, "Arial" );
    dotField.getStyle().setStyleProperty( TextStyleKeys.FONTSIZE, 14 );
    dotField.getStyle().setStyleProperty( ElementStyleKeys.ALIGNMENT, ElementAlignment.RIGHT );
    dotField.getStyle().setStyleProperty( ElementStyleKeys.VALIGNMENT, ElementAlignment.TOP );
    dotField.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 97f );
    dotField.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 0f );
    dotField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 628.463f );
    dotField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 20f );
    dotField.getStyle().setStyleProperty( ElementStyleKeys.WIDTH, 100f );
    dotField.getStyle().setStyleProperty( ElementStyleKeys.MAX_WIDTH, 100f );
    dotField.setElementType( LabelType.INSTANCE );
    dotField
        .setAttribute(
            AttributeNames.Core.NAMESPACE,
            AttributeNames.Core.VALUE,
            " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "
                + " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "
                + ". . . . . . . . . . . . . . . . . ." );

    Band band = new Band();
    band.setName( "outer-box" );
    band.setLayout( "inline" );
    band.getStyle().setStyleProperty( ElementStyleKeys.BOX_SIZING, BoxSizing.CONTENT_BOX );
    band.getStyle().setStyleProperty( ElementStyleKeys.OVERFLOW_X, false );
    band.getStyle().setStyleProperty( ElementStyleKeys.OVERFLOW_Y, false );
    band.getStyle().setStyleProperty( TextStyleKeys.LINEHEIGHT, 1f );
    band.getStyle().setStyleProperty( TextStyleKeys.WHITE_SPACE_COLLAPSE, WhitespaceCollapse.PRESERVE_BREAKS );
    band.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 708f );
    band.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 12f );
    band.getStyle().setStyleProperty( ElementStyleKeys.MAX_HEIGHT, 20f );
    band.addElement( textField );
    band.addElement( dotField );

    final MasterReport report = new MasterReport();
    report.getReportHeader().addElement( band );
    report.setCompatibilityLevel( null );
    report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
        "false" );

    LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, report.getReportHeader(), false, false );
    ModelPrinter.INSTANCE.print( logicalPageBox );

    RenderNode textFieldBox = MatchFactory.findElementByName( logicalPageBox, "textField" );
    assertNotNull( textFieldBox );

    assertEquals( 0, textFieldBox.getY() );

    // box only contains one line, and min-size is set to 8, max size = 20, so the line-height of 14.024 is used.
    assertEquals( StrictGeomUtility.toInternalValue( 14 ), textFieldBox.getHeight() );
  }
 
Example 18
Source File: Prd2087IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void testOrphan1Crash() throws Exception {
  final MasterReport masterReport = DebugReportRunner.parseGoldenSampleReport( "Prd-2087-Orphan-0.prpt" );
  masterReport.setCompatibilityLevel( ClassicEngineBoot.computeVersionId( 3, 8, 0 ) );
  DebugReportRunner.createXmlTablePageable( masterReport );
}
 
Example 19
Source File: Prd3688IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void testPrd3688Strict() throws Exception {
  final MasterReport report = new MasterReport();
  report.setCompatibilityLevel( ClassicEngineBoot.computeVersionId( 3, 8, 0 ) );

  final Element e1 = createDataItem( "Header" );
  e1.setName( "E1" );
  e1.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -37f );
  e1.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 11f );
  e1.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 500f );
  e1.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 0f );

  final Element e2 = createDataItem( "Header" );
  e2.setName( "E2" );
  e2.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -50f );
  e2.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 11f );
  e2.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 0f );
  e2.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 0f );

  final Element e3 = createDataItem( "Header" );
  e3.setName( "E3" );
  e3.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 1464f );
  e3.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 3.5f );
  e3.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 0f );
  e3.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 12.5f );

  report.getReportHeader().setName( "RH" );
  report.getReportHeader().addElement( e1 );
  report.getReportHeader().addElement( e2 );
  report.getReportHeader().addElement( e3 );

  final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, report.getReportHeader() );
  // ModelPrinter.INSTANCE.print(logicalPageBox);

  final RenderNode e1Box = MatchFactory.findElementByName( logicalPageBox, "E1" );
  final RenderNode e2Box = MatchFactory.findElementByName( logicalPageBox, "E2" );
  final RenderNode e3Box = MatchFactory.findElementByName( logicalPageBox, "E3" );
  final RenderNode rhBox = MatchFactory.findElementByName( logicalPageBox, "RH" );

  assertEquals( StrictGeomUtility.toInternalValue( 500 ), e1Box.getX() );
  assertEquals( StrictGeomUtility.toInternalValue( 0 ), e1Box.getY() );
  assertEquals( StrictGeomUtility.toInternalValue( 173.16f ), e1Box.getWidth() );
  assertEquals( StrictGeomUtility.toInternalValue( 11 ), e1Box.getHeight() );

  assertEquals( StrictGeomUtility.toInternalValue( 0 ), e2Box.getX() );
  assertEquals( StrictGeomUtility.toInternalValue( 0 ), e2Box.getY() );
  assertEquals( StrictGeomUtility.toInternalValue( 234 ), e2Box.getWidth() );
  assertEquals( StrictGeomUtility.toInternalValue( 11 ), e2Box.getHeight() );

  assertEquals( StrictGeomUtility.toInternalValue( 0 ), e3Box.getX() );
  assertEquals( StrictGeomUtility.toInternalValue( 12.5 ), e3Box.getY() );
  assertEquals( StrictGeomUtility.toInternalValue( 1464f ), e3Box.getWidth() );
  assertEquals( StrictGeomUtility.toInternalValue( 3.5f ), e3Box.getHeight() );

  assertEquals( StrictGeomUtility.toInternalValue( 0 ), rhBox.getX() );
  assertEquals( StrictGeomUtility.toInternalValue( 0 ), rhBox.getY() );
  assertEquals( StrictGeomUtility.toInternalValue( 468f ), rhBox.getWidth() );
  assertEquals( StrictGeomUtility.toInternalValue( 16 ), rhBox.getHeight() );

}
 
Example 20
Source File: RichTextLineBreakingIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Test
public void testWeirdTocLayoutComplex() throws ReportProcessingException, ContentProcessingException {

  if ( !DebugReportRunner.isSafeToTestComplexText() ) {
    return;
  }

  Element textField = new Element();
  textField.setName( "textField" );
  textField.getStyle().setStyleProperty( TextStyleKeys.FONT, "Arial" );
  textField.getStyle().setStyleProperty( TextStyleKeys.FONTSIZE, 14 );
  textField.getStyle().setStyleProperty( TextStyleKeys.TEXT_WRAP, TextWrap.NONE );
  textField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 97f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 20f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 0f );
  textField.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 0f );
  textField.setElementType( LabelType.INSTANCE );
  textField.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "Classic Cars\n" );

  Element dotField = new Element();
  dotField.setName( "dotField" );
  dotField.getStyle().setStyleProperty( TextStyleKeys.FONT, "Arial" );
  dotField.getStyle().setStyleProperty( TextStyleKeys.FONTSIZE, 14 );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.ALIGNMENT, ElementAlignment.RIGHT );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.VALIGNMENT, ElementAlignment.TOP );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 97f );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 0f );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 628.463f );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 20f );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.WIDTH, 100f );
  dotField.getStyle().setStyleProperty( ElementStyleKeys.MAX_WIDTH, 100f );
  dotField.setElementType( LabelType.INSTANCE );
  dotField.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, " Some more data" );

  Band band = new Band();
  band.setName( "outer-box" );
  band.setLayout( "inline" );
  band.getStyle().setStyleProperty( ElementStyleKeys.BOX_SIZING, BoxSizing.CONTENT_BOX );
  band.getStyle().setStyleProperty( ElementStyleKeys.OVERFLOW_X, false );
  band.getStyle().setStyleProperty( ElementStyleKeys.DYNAMIC_HEIGHT, true );
  band.getStyle().setStyleProperty( ElementStyleKeys.OVERFLOW_Y, false );
  band.getStyle().setStyleProperty( TextStyleKeys.LINEHEIGHT, 1f );
  band.getStyle().setStyleProperty( TextStyleKeys.WHITE_SPACE_COLLAPSE, WhitespaceCollapse.PRESERVE_BREAKS );
  band.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 708f );
  band.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 12f );
  band.getStyle().setStyleProperty( ElementStyleKeys.MAX_HEIGHT, 20f );
  band.addElement( textField );
  band.addElement( dotField );

  final MasterReport report = new MasterReport();
  report.getReportHeader().addElement( band );
  report.setCompatibilityLevel( null );
  report.getReportConfiguration()
      .setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "true" );
  report.getStyle().setStyleProperty( TextStyleKeys.WORDBREAK, true );

  LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, report.getReportHeader(), false, false );

  ParagraphRenderBox outerBox = (ParagraphRenderBox) MatchFactory.findElementByName( logicalPageBox, "outer-box" );
  assertNotNull( outerBox );
  assertEquals( 0, outerBox.getY() );
  assertTrue( outerBox.getHeight() > StrictGeomUtility.toInternalValue( 14 ) );
  assertTrue( outerBox.isComplexParagraph() );

  BlockRenderBox pool = (BlockRenderBox) outerBox.getLineboxContainer();
  assertTrue( pool.getFirstChild() != pool.getLastChild() );
  assertTrue( pool.getFirstChild().getNext() == pool.getLastChild() );
  assertStructure( (RenderBox) pool.getFirstChild() );
  assertStructure( (RenderBox) pool.getLastChild() );

}