Skip to content

Commit

Permalink
Enhance the designer properties for the excel emitter (part 3, #1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
speckyspooky authored Jul 15, 2024
1 parent af6352c commit 7588cd0
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,45 +135,6 @@ public static boolean booleanOption(ITaskOption options, IReportContent reportCo
return result;
}

/*
* Read the configuration from the report design if no user property is set
*/
private static Object getReportDesignConfiguration(IReportContent reportContent, String name) {
Object value = null;

if (name.equalsIgnoreCase(ExcelEmitter.AUTO_FILTER)) {
value = reportContent.getDesign().getReportDesign().getExcelAutoFilter();

} else if (name.equalsIgnoreCase(ExcelEmitter.DISABLE_GROUPING)) {
value = reportContent.getDesign().getReportDesign().getExcelDisableGrouping();

} else if (name.equalsIgnoreCase(ExcelEmitter.DISPLAYGRIDLINES_PROP)) {
value = reportContent.getDesign().getReportDesign().getExcelDisplayGridlines();

} else if (name.equalsIgnoreCase(ExcelEmitter.FORCE_RECALCULATION)) {
value = reportContent.getDesign().getReportDesign().getExcelForceRecalculation();

} else if (name.equalsIgnoreCase(ExcelEmitter.FORCEAUTOCOLWIDTHS_PROP)) {
value = reportContent.getDesign().getReportDesign().getExcelForceAutoColWidths();

} else if (name.equalsIgnoreCase(ExcelEmitter.IMAGE_SCALING_CELL_DIMENSION)) {
value = reportContent.getDesign().getReportDesign().getExcelImageScaling();

} else if (name.equalsIgnoreCase(ExcelEmitter.SINGLE_SHEET)) {
value = reportContent.getDesign().getReportDesign().getExcelSingleSheet();

} else if (name.equalsIgnoreCase(ExcelEmitter.SINGLE_SHEET_PAGE_BREAKS)) {
value = reportContent.getDesign().getReportDesign().getExcelSingleSheetPageBreak();

} else if (name.equalsIgnoreCase(ExcelEmitter.STREAMING_XLSX)) {
value = reportContent.getDesign().getReportDesign().getExcelStreamingXlsx();

} else if (name.equalsIgnoreCase(ExcelEmitter.STRUCTURED_HEADER)) {
value = reportContent.getDesign().getReportDesign().getExcelStructuredHeader();
}
return value;
}

/**
* Search for an emitter option and return it as a string
*
Expand Down Expand Up @@ -226,6 +187,10 @@ public static String stringOption(ITaskOption options, IContent birtContent, Str
result = value.toString();
}

if (birtContent != null && birtContent.getReportContent() != null && value == null) {
value = getReportDesignConfiguration(birtContent.getReportContent(), name);
}

return result;
}

Expand Down Expand Up @@ -262,6 +227,10 @@ public static String stringOption(ITaskOption options, IReportContent reportCont
result = value.toString();
}

if (reportContent != null && value == null) {
value = getReportDesignConfiguration(reportContent, name);
}

return result;
}

Expand Down Expand Up @@ -313,6 +282,10 @@ public static int integerOption(ITaskOption options, IContent birtContent, Strin
value = options.getOption(name);
}

if (birtContent != null && birtContent.getReportContent() != null && value == null) {
value = getReportDesignConfiguration(birtContent.getReportContent(), name);
}

if (value instanceof Number) {
result = ((Number) value).intValue();
} else if (value != null) {
Expand Down Expand Up @@ -360,4 +333,55 @@ public static String getPluginName() {
return "uk.co.spudsoft.birt.emitters.excel";
}

/*
* Read the configuration from the report design if no user property is set
*/
private static Object getReportDesignConfiguration(IReportContent reportContent, String name) {
Object value = null;

if (name.equalsIgnoreCase(ExcelEmitter.AUTO_FILTER)) {
value = reportContent.getDesign().getReportDesign().getExcelAutoFilter();

} else if (name.equalsIgnoreCase(ExcelEmitter.DISABLE_GROUPING)) {
value = reportContent.getDesign().getReportDesign().getExcelDisableGrouping();

} else if (name.equalsIgnoreCase(ExcelEmitter.DISPLAYGRIDLINES_PROP)) {
value = reportContent.getDesign().getReportDesign().getExcelDisplayGridlines();

} else if (name.equalsIgnoreCase(ExcelEmitter.FORCE_RECALCULATION)) {
value = reportContent.getDesign().getReportDesign().getExcelForceRecalculation();

} else if (name.equalsIgnoreCase(ExcelEmitter.FORCEAUTOCOLWIDTHS_PROP)) {
value = reportContent.getDesign().getReportDesign().getExcelForceAutoColWidths();

} else if (name.equalsIgnoreCase(ExcelEmitter.IMAGE_SCALING_CELL_DIMENSION)) {
value = reportContent.getDesign().getReportDesign().getExcelImageScaling();

} else if (name.equalsIgnoreCase(ExcelEmitter.PRINT_PAGES_HIGH)) {
value = reportContent.getDesign().getReportDesign().getExcelPrintPagesHigh();

} else if (name.equalsIgnoreCase(ExcelEmitter.PRINT_PAGES_WIDE)) {
value = reportContent.getDesign().getReportDesign().getExcelPrintPagesWide();

} else if (name.equalsIgnoreCase(ExcelEmitter.PRINT_SCALE)) {
value = reportContent.getDesign().getReportDesign().getExcelPrintScale();

} else if (name.equalsIgnoreCase(ExcelEmitter.SINGLE_SHEET)) {
value = reportContent.getDesign().getReportDesign().getExcelSingleSheet();

} else if (name.equalsIgnoreCase(ExcelEmitter.SINGLE_SHEET_PAGE_BREAKS)) {
value = reportContent.getDesign().getReportDesign().getExcelSingleSheetPageBreak();

} else if (name.equalsIgnoreCase(ExcelEmitter.STREAMING_XLSX)) {
value = reportContent.getDesign().getReportDesign().getExcelStreamingXlsx();

} else if (name.equalsIgnoreCase(ExcelEmitter.STRUCTURED_HEADER)) {
value = reportContent.getDesign().getReportDesign().getExcelStructuredHeader();

} else if (name.equalsIgnoreCase(ExcelEmitter.TEMPLATE_FILE)) {
value = reportContent.getDesign().getReportDesign().getExcelTemplateFile();
}
return value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1619,4 +1619,79 @@ public void setExcelStructuredHeader(boolean structuredHeader) throws SemanticEx
setBooleanProperty(EXCEL_STRUCTURED_HEADER, structuredHeader);
}

/**
* Get the configuration for the sheet wide
*
* @return the configuration for the sheet wide
*/
public int getExcelPrintPagesWide() {
return getIntProperty(EXCEL_PRINT_PAGES_WIDE);
}

/**
* Set the configuration to set the sheet wide to fit the page
*
* @param printPagesWide the page wide
* @throws SemanticException
*/
public void setExcelPrintPagesWide(int printPagesWide) throws SemanticException {
setIntProperty(EXCEL_PRINT_PAGES_WIDE, printPagesWide);
}

/**
* Get the configuration for the sheet high
*
* @return the configuration for the sheet high
*/
public int getExcelPrintPagesHigh() {
return getIntProperty(EXCEL_PRINT_PAGES_HIGH);
}

/**
* Set the configuration to set the sheet high to fit the page
*
* @param printPagesHigh the page high
* @throws SemanticException
*/
public void setExcelPrintPagesHigh(int printPagesHigh) throws SemanticException {
setIntProperty(EXCEL_PRINT_PAGES_HIGH, printPagesHigh);
}

/**
* Get the configuration for the page scale
*
* @return the configuration for the page scale
*/
public int getExcelPrintScale() {
return getIntProperty(EXCEL_PRINT_SCALE);
}

/**
* Set the configuration to set the page scale
*
* @param printScale the page scale
* @throws SemanticException
*/
public void setExcelPrintScale(int printScale) throws SemanticException {
setIntProperty(EXCEL_PRINT_SCALE, printScale);
}

/**
* Get the configuration for the used template file
*
* @return the configuration for the used template file
*/
public String getExcelTemplateFile() {
return getStringProperty(EXCEL_TEMPLATE_FILE);
}

/**
* Set the configuration for the template file
*
* @param templateFile template file
* @throws SemanticException
*/
public void setExcelTemplateFile(String templateFile) throws SemanticException {
setStringProperty(EXCEL_TEMPLATE_FILE, templateFile);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ public interface IInternalReportDesignModel {
* within the parent.
*/

String CASCADE_ACL_PROP = IReportItemModel.CASCADE_ACL_PROP;
String CASCADE_ACL_PROP = IInternalReportItemModel.CASCADE_ACL_PROP;

/**
* A Java script expression which returns the ACL associated with the report
* instance in a String.
*/

String ACL_EXPRESSION_PROP = IReportItemModel.ACL_EXPRESSION_PROP;
String ACL_EXPRESSION_PROP = IInternalReportItemModel.ACL_EXPRESSION_PROP;

/**
* Name of the property to keep image in report design display as same size at
Expand Down Expand Up @@ -267,4 +267,25 @@ public interface IInternalReportDesignModel {
* Excel option, display report header and footer at excel sheet
*/
String EXCEL_STRUCTURED_HEADER = "excelStructuredHeader"; //$NON-NLS-1$

/**
* Excel option, set the sheet high to fit the page
*/
String EXCEL_PRINT_PAGES_HIGH = "excelPrintPagesHigh"; //$NON-NLS-1$

/**
* Excel option, set the sheet wide to fit the page
*/
String EXCEL_PRINT_PAGES_WIDE = "excelPrintPagesWide"; //$NON-NLS-1$

/**
* Excel option, set the page scale factor
*/
String EXCEL_PRINT_SCALE = "excelPrintScale"; //$NON-NLS-1$

/**
* Excel option, set the template file for excel
*/
String EXCEL_TEMPLATE_FILE = "excelTemplateFile"; //$NON-NLS-1$

}
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,18 @@
<!-- excel (Spudsoft): show/hide the header and footer on excel sheet -->
<Property canInherit="false" displayNameID="Element.ReportDesign.Emitter.excel.structuredHeader" name="excelStructuredHeader" runtimeSettable="false" since="4.17" type="boolean" >
<Default>false</Default>
</Property>
<!-- excel (Spudsoft): set the page high to fit the printer page -->
<Property canInherit="false" displayNameID="Element.ReportDesign.Emitter.excel.printPagesHigh" name="excelPrintPagesHigh" runtimeSettable="false" since="4.17" type="integer" >
</Property>
<!-- excel (Spudsoft): set the page wide to fit the printer page -->
<Property canInherit="false" displayNameID="Element.ReportDesign.Emitter.excel.printPagesWide" name="excelPrintPagesWide" runtimeSettable="false" since="4.17" type="integer" >
</Property>
<!-- excel (Spudsoft): set the page scale -->
<Property canInherit="false" displayNameID="Element.ReportDesign.Emitter.excel.printScale" name="excelPrintScale" runtimeSettable="false" since="4.17" type="integer" >
</Property>
<!-- excel (Spudsoft): set the excel template file (full qualified file path) -->
<Property canInherit="false" displayNameID="Element.ReportDesign.Emitter.excel.templateFile" name="excelTemplateFile" runtimeSettable="false" since="4.17" type="string" >
</Property>
</PropertyGroup>
<Method context="client" displayNameID="Element.ReportDesign.clientInitialize" name="clientInitialize" since="1.0" toolTipID="Element.ReportDesign.clientInitialize.toolTip">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2638,6 +2638,10 @@ Element.ReportDesign.Emitter.excel.imageScalingToCellDimension=Image scaling to
Element.ReportDesign.Emitter.excel.singleSheetWithPageBreaks=Single sheet with page break
Element.ReportDesign.Emitter.excel.streamingXlsx=Stream writing for XLSX
Element.ReportDesign.Emitter.excel.structuredHeader=Display report footer and header
Element.ReportDesign.Emitter.excel.printPagesHigh=Page high to fit printer page (1 to 32,767)
Element.ReportDesign.Emitter.excel.printPagesWide=Page wide to fit printer page (1 to 32,767)
Element.ReportDesign.Emitter.excel.printScale=Scale page for printing (10% to 400%)
Element.ReportDesign.Emitter.excel.templateFile=File name to template file (full qualified path)

#2. Report Element ( Prefix = Element.ReportElement )
Element.ReportElement.displayName=Display name
Expand Down
Loading

0 comments on commit 7588cd0

Please sign in to comment.