diff --git a/metamodel/net/datenwerke/rs/amazons3/service/amazons3/action/ScheduleAsAmazonS3FileAction_.java b/metamodel/net/datenwerke/rs/amazons3/service/amazons3/action/ScheduleAsAmazonS3FileAction_.java new file mode 100644 index 000000000..b59f97ed9 --- /dev/null +++ b/metamodel/net/datenwerke/rs/amazons3/service/amazons3/action/ScheduleAsAmazonS3FileAction_.java @@ -0,0 +1,18 @@ +package net.datenwerke.rs.amazons3.service.amazons3.action; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import net.datenwerke.rs.amazons3.service.amazons3.definitions.AmazonS3Datasink; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ScheduleAsAmazonS3FileAction.class) +public abstract class ScheduleAsAmazonS3FileAction_ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction_ { + + public static volatile SingularAttribute folder; + public static volatile SingularAttribute amazonS3Datasink; + public static volatile SingularAttribute name; + public static volatile SingularAttribute compressed; + +} + diff --git a/metamodel/net/datenwerke/rs/amazons3/service/amazons3/action/ScheduleAsAmazonS3FileAction__.java b/metamodel/net/datenwerke/rs/amazons3/service/amazons3/action/ScheduleAsAmazonS3FileAction__.java new file mode 100644 index 000000000..515d72c75 --- /dev/null +++ b/metamodel/net/datenwerke/rs/amazons3/service/amazons3/action/ScheduleAsAmazonS3FileAction__.java @@ -0,0 +1,16 @@ +package net.datenwerke.rs.amazons3.service.amazons3.action; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class ScheduleAsAmazonS3FileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String amazonS3Datasink = "amazonS3Datasink"; + public static final String compressed = "compressed"; + public static final String folder = "folder"; + public static final String name = "name"; + +} diff --git a/metamodel/net/datenwerke/rs/amazons3/service/amazons3/definitions/AmazonS3Datasink_.java b/metamodel/net/datenwerke/rs/amazons3/service/amazons3/definitions/AmazonS3Datasink_.java new file mode 100644 index 000000000..78f4fc153 --- /dev/null +++ b/metamodel/net/datenwerke/rs/amazons3/service/amazons3/definitions/AmazonS3Datasink_.java @@ -0,0 +1,19 @@ +package net.datenwerke.rs.amazons3.service.amazons3.definitions; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(AmazonS3Datasink.class) +public abstract class AmazonS3Datasink_ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition_ { + + public static volatile SingularAttribute bucketName; + public static volatile SingularAttribute storageClass; + public static volatile SingularAttribute folder; + public static volatile SingularAttribute secretKey; + public static volatile SingularAttribute regionName; + public static volatile SingularAttribute appKey; + +} + diff --git a/metamodel/net/datenwerke/rs/amazons3/service/amazons3/definitions/AmazonS3Datasink__.java b/metamodel/net/datenwerke/rs/amazons3/service/amazons3/definitions/AmazonS3Datasink__.java new file mode 100644 index 000000000..b2b5cca92 --- /dev/null +++ b/metamodel/net/datenwerke/rs/amazons3/service/amazons3/definitions/AmazonS3Datasink__.java @@ -0,0 +1,21 @@ +package net.datenwerke.rs.amazons3.service.amazons3.definitions; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class AmazonS3Datasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String appKey = "appKey"; + public static final String basicDatasinkService = "basicDatasinkService"; + public static final String bucketName = "bucketName"; + public static final String folder = "folder"; + public static final String pbeServiceProvider = "pbeServiceProvider"; + public static final String regionName = "regionName"; + public static final String secretKey = "secretKey"; + public static final String serialVersionUID = "serialVersionUID"; + public static final String storageClass = "storageClass"; + +} diff --git a/metamodel/net/datenwerke/rs/box/service/box/action/ScheduleAsBoxFileAction_.java b/metamodel/net/datenwerke/rs/box/service/box/action/ScheduleAsBoxFileAction_.java new file mode 100644 index 000000000..c173db3d8 --- /dev/null +++ b/metamodel/net/datenwerke/rs/box/service/box/action/ScheduleAsBoxFileAction_.java @@ -0,0 +1,18 @@ +package net.datenwerke.rs.box.service.box.action; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import net.datenwerke.rs.box.service.box.definitions.BoxDatasink; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ScheduleAsBoxFileAction.class) +public abstract class ScheduleAsBoxFileAction_ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction_ { + + public static volatile SingularAttribute folder; + public static volatile SingularAttribute name; + public static volatile SingularAttribute boxDatasink; + public static volatile SingularAttribute compressed; + +} + diff --git a/metamodel/net/datenwerke/rs/box/service/box/action/ScheduleAsBoxFileAction__.java b/metamodel/net/datenwerke/rs/box/service/box/action/ScheduleAsBoxFileAction__.java new file mode 100644 index 000000000..c08665eab --- /dev/null +++ b/metamodel/net/datenwerke/rs/box/service/box/action/ScheduleAsBoxFileAction__.java @@ -0,0 +1,16 @@ +package net.datenwerke.rs.box.service.box.action; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class ScheduleAsBoxFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String boxDatasink = "boxDatasink"; + public static final String compressed = "compressed"; + public static final String folder = "folder"; + public static final String name = "name"; + +} diff --git a/metamodel/net/datenwerke/rs/box/service/box/definitions/BoxDatasink_.java b/metamodel/net/datenwerke/rs/box/service/box/definitions/BoxDatasink_.java new file mode 100644 index 000000000..9e6abbb6e --- /dev/null +++ b/metamodel/net/datenwerke/rs/box/service/box/definitions/BoxDatasink_.java @@ -0,0 +1,17 @@ +package net.datenwerke.rs.box.service.box.definitions; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(BoxDatasink.class) +public abstract class BoxDatasink_ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition_ { + + public static volatile SingularAttribute folder; + public static volatile SingularAttribute secretKey; + public static volatile SingularAttribute appKey; + public static volatile SingularAttribute refreshToken; + +} + diff --git a/metamodel/net/datenwerke/rs/box/service/box/definitions/BoxDatasink__.java b/metamodel/net/datenwerke/rs/box/service/box/definitions/BoxDatasink__.java new file mode 100644 index 000000000..6ae915d20 --- /dev/null +++ b/metamodel/net/datenwerke/rs/box/service/box/definitions/BoxDatasink__.java @@ -0,0 +1,19 @@ +package net.datenwerke.rs.box.service.box.definitions; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class BoxDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String appKey = "appKey"; + public static final String basicDatasinkService = "basicDatasinkService"; + public static final String folder = "folder"; + public static final String pbeServiceProvider = "pbeServiceProvider"; + public static final String refreshToken = "refreshToken"; + public static final String secretKey = "secretKey"; + public static final String serialVersionUID = "serialVersionUID"; + +} diff --git a/metamodel/net/datenwerke/rs/condition/service/condition/entity/Condition_.java b/metamodel/net/datenwerke/rs/condition/service/condition/entity/Condition_.java index 878d5669c..05634db48 100755 --- a/metamodel/net/datenwerke/rs/condition/service/condition/entity/Condition_.java +++ b/metamodel/net/datenwerke/rs/condition/service/condition/entity/Condition_.java @@ -1,10 +1,10 @@ package net.datenwerke.rs.condition.service.condition.entity; -import javax.annotation.Generated; -import javax.persistence.metamodel.SingularAttribute; -import javax.persistence.metamodel.StaticMetamodel; +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; import net.datenwerke.rs.base.service.reportengines.table.entities.TableReport; -import net.datenwerke.rs.condition.client.condition.Condition; +import net.datenwerke.rs.condition.client.condition.Condition; @Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") @StaticMetamodel(Condition.class) diff --git a/metamodel/net/datenwerke/rs/crystal/service/crystal/entities/CrystalReportVariant__.java b/metamodel/net/datenwerke/rs/crystal/service/crystal/entities/CrystalReportVariant__.java index 0d8be3cd9..5ecd30285 100755 --- a/metamodel/net/datenwerke/rs/crystal/service/crystal/entities/CrystalReportVariant__.java +++ b/metamodel/net/datenwerke/rs/crystal/service/crystal/entities/CrystalReportVariant__.java @@ -8,5 +8,6 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class CrystalReportVariant__ extends net.datenwerke.rs.crystal.service.crystal.entities.CrystalReport__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String serialVersionUID = "serialVersionUID"; } diff --git a/metamodel/net/datenwerke/rs/dropbox/service/dropbox/action/ScheduleAsDropboxFileAction_.java b/metamodel/net/datenwerke/rs/dropbox/service/dropbox/action/ScheduleAsDropboxFileAction_.java new file mode 100644 index 000000000..362d1ea8a --- /dev/null +++ b/metamodel/net/datenwerke/rs/dropbox/service/dropbox/action/ScheduleAsDropboxFileAction_.java @@ -0,0 +1,18 @@ +package net.datenwerke.rs.dropbox.service.dropbox.action; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import net.datenwerke.rs.dropbox.service.dropbox.definitions.DropboxDatasink; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ScheduleAsDropboxFileAction.class) +public abstract class ScheduleAsDropboxFileAction_ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction_ { + + public static volatile SingularAttribute folder; + public static volatile SingularAttribute name; + public static volatile SingularAttribute compressed; + public static volatile SingularAttribute dropboxDatasink; + +} + diff --git a/metamodel/net/datenwerke/rs/dropbox/service/dropbox/action/ScheduleAsDropboxFileAction__.java b/metamodel/net/datenwerke/rs/dropbox/service/dropbox/action/ScheduleAsDropboxFileAction__.java new file mode 100644 index 000000000..198fa93c9 --- /dev/null +++ b/metamodel/net/datenwerke/rs/dropbox/service/dropbox/action/ScheduleAsDropboxFileAction__.java @@ -0,0 +1,16 @@ +package net.datenwerke.rs.dropbox.service.dropbox.action; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class ScheduleAsDropboxFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String compressed = "compressed"; + public static final String dropboxDatasink = "dropboxDatasink"; + public static final String folder = "folder"; + public static final String name = "name"; + +} diff --git a/metamodel/net/datenwerke/rs/dropbox/service/dropbox/definitions/DropboxDatasink_.java b/metamodel/net/datenwerke/rs/dropbox/service/dropbox/definitions/DropboxDatasink_.java new file mode 100644 index 000000000..534d407d5 --- /dev/null +++ b/metamodel/net/datenwerke/rs/dropbox/service/dropbox/definitions/DropboxDatasink_.java @@ -0,0 +1,17 @@ +package net.datenwerke.rs.dropbox.service.dropbox.definitions; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(DropboxDatasink.class) +public abstract class DropboxDatasink_ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition_ { + + public static volatile SingularAttribute folder; + public static volatile SingularAttribute secretKey; + public static volatile SingularAttribute appKey; + public static volatile SingularAttribute refreshToken; + +} + diff --git a/metamodel/net/datenwerke/rs/dropbox/service/dropbox/definitions/DropboxDatasink__.java b/metamodel/net/datenwerke/rs/dropbox/service/dropbox/definitions/DropboxDatasink__.java new file mode 100644 index 000000000..b94e9fd9f --- /dev/null +++ b/metamodel/net/datenwerke/rs/dropbox/service/dropbox/definitions/DropboxDatasink__.java @@ -0,0 +1,19 @@ +package net.datenwerke.rs.dropbox.service.dropbox.definitions; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class DropboxDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String appKey = "appKey"; + public static final String basicDatasinkService = "basicDatasinkService"; + public static final String folder = "folder"; + public static final String pbeServiceProvider = "pbeServiceProvider"; + public static final String refreshToken = "refreshToken"; + public static final String secretKey = "secretKey"; + public static final String serialVersionUID = "serialVersionUID"; + +} diff --git a/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/action/ScheduleAsEmailFileAction_.java b/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/action/ScheduleAsEmailFileAction_.java index 5700b099c..a2cc8da38 100644 --- a/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/action/ScheduleAsEmailFileAction_.java +++ b/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/action/ScheduleAsEmailFileAction_.java @@ -9,7 +9,10 @@ @StaticMetamodel(ScheduleAsEmailFileAction.class) public abstract class ScheduleAsEmailFileAction_ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction_ { + public static volatile SingularAttribute subject; public static volatile SingularAttribute name; + public static volatile SingularAttribute compressed; + public static volatile SingularAttribute message; public static volatile SingularAttribute emailDatasink; } diff --git a/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/action/ScheduleAsEmailFileAction__.java b/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/action/ScheduleAsEmailFileAction__.java index d25860a54..412e09044 100644 --- a/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/action/ScheduleAsEmailFileAction__.java +++ b/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/action/ScheduleAsEmailFileAction__.java @@ -8,7 +8,12 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class ScheduleAsEmailFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String PROPERTY_MESSAGE = "PROPERTY_MESSAGE"; + public static final String PROPERTY_SUBJECT = "PROPERTY_SUBJECT"; + public static final String compressed = "compressed"; public static final String emailDatasink = "emailDatasink"; + public static final String message = "message"; public static final String name = "name"; + public static final String subject = "subject"; } diff --git a/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/definitions/EmailDatasink__.java b/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/definitions/EmailDatasink__.java index 846c46de4..57757b76c 100644 --- a/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/definitions/EmailDatasink__.java +++ b/metamodel/net/datenwerke/rs/emaildatasink/service/emaildatasink/definitions/EmailDatasink__.java @@ -8,6 +8,8 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class EmailDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String authenticationService = "authenticationService"; + public static final String basicDatasinkService = "basicDatasinkService"; public static final String encryptionPolicy = "encryptionPolicy"; public static final String forceSender = "forceSender"; public static final String host = "host"; diff --git a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpFileAction_.java b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpFileAction_.java index afe12d3ba..6f297d3f8 100644 --- a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpFileAction_.java +++ b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpFileAction_.java @@ -11,6 +11,7 @@ public abstract class ScheduleAsFtpFileAction_ extends net.datenwerke.scheduler. public static volatile SingularAttribute folder; public static volatile SingularAttribute name; + public static volatile SingularAttribute compressed; public static volatile SingularAttribute ftpDatasink; } diff --git a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpFileAction__.java b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpFileAction__.java index 79eb9a18c..ca0058b54 100644 --- a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpFileAction__.java +++ b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpFileAction__.java @@ -8,6 +8,7 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class ScheduleAsFtpFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String compressed = "compressed"; public static final String folder = "folder"; public static final String ftpDatasink = "ftpDatasink"; public static final String name = "name"; diff --git a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpsFileAction_.java b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpsFileAction_.java index 3d9c10a39..4ecdc5339 100644 --- a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpsFileAction_.java +++ b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpsFileAction_.java @@ -11,6 +11,7 @@ public abstract class ScheduleAsFtpsFileAction_ extends net.datenwerke.scheduler public static volatile SingularAttribute folder; public static volatile SingularAttribute name; + public static volatile SingularAttribute compressed; public static volatile SingularAttribute ftpsDatasink; } diff --git a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpsFileAction__.java b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpsFileAction__.java index 89ba2f109..9c245ef1d 100644 --- a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpsFileAction__.java +++ b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsFtpsFileAction__.java @@ -8,6 +8,7 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class ScheduleAsFtpsFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String compressed = "compressed"; public static final String folder = "folder"; public static final String ftpsDatasink = "ftpsDatasink"; public static final String name = "name"; diff --git a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsSftpFileAction_.java b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsSftpFileAction_.java index 5e1de3796..f685f9d4e 100644 --- a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsSftpFileAction_.java +++ b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsSftpFileAction_.java @@ -12,6 +12,7 @@ public abstract class ScheduleAsSftpFileAction_ extends net.datenwerke.scheduler public static volatile SingularAttribute sftpDatasink; public static volatile SingularAttribute folder; public static volatile SingularAttribute name; + public static volatile SingularAttribute compressed; } diff --git a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsSftpFileAction__.java b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsSftpFileAction__.java index b9fa1b73d..2b5ee26f4 100644 --- a/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsSftpFileAction__.java +++ b/metamodel/net/datenwerke/rs/ftp/service/ftp/action/ScheduleAsSftpFileAction__.java @@ -8,6 +8,7 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class ScheduleAsSftpFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String compressed = "compressed"; public static final String folder = "folder"; public static final String name = "name"; public static final String sftpDatasink = "sftpDatasink"; diff --git a/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/FtpDatasink__.java b/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/FtpDatasink__.java index 8a48731c6..9d4007fc9 100644 --- a/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/FtpDatasink__.java +++ b/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/FtpDatasink__.java @@ -8,6 +8,7 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class FtpDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String basicDatasinkService = "basicDatasinkService"; public static final String folder = "folder"; public static final String ftpMode = "ftpMode"; public static final String host = "host"; diff --git a/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/FtpsDatasink__.java b/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/FtpsDatasink__.java index a3af0feae..83a1a5851 100644 --- a/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/FtpsDatasink__.java +++ b/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/FtpsDatasink__.java @@ -9,6 +9,7 @@ public class FtpsDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { public static final String authenticationType = "authenticationType"; + public static final String basicDatasinkService = "basicDatasinkService"; public static final String dataChannelProtectionLevel = "dataChannelProtectionLevel"; public static final String folder = "folder"; public static final String ftpMode = "ftpMode"; diff --git a/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/SftpDatasink__.java b/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/SftpDatasink__.java index 62c069f94..202caef53 100644 --- a/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/SftpDatasink__.java +++ b/metamodel/net/datenwerke/rs/ftp/service/ftp/definitions/SftpDatasink__.java @@ -9,6 +9,7 @@ public class SftpDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { public static final String authenticationType = "authenticationType"; + public static final String basicDatasinkService = "basicDatasinkService"; public static final String folder = "folder"; public static final String host = "host"; public static final String password = "password"; diff --git a/metamodel/net/datenwerke/rs/googledrive/service/googledrive/action/ScheduleAsGoogleDriveFileAction_.java b/metamodel/net/datenwerke/rs/googledrive/service/googledrive/action/ScheduleAsGoogleDriveFileAction_.java new file mode 100644 index 000000000..11e441d4d --- /dev/null +++ b/metamodel/net/datenwerke/rs/googledrive/service/googledrive/action/ScheduleAsGoogleDriveFileAction_.java @@ -0,0 +1,18 @@ +package net.datenwerke.rs.googledrive.service.googledrive.action; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import net.datenwerke.rs.googledrive.service.googledrive.definitions.GoogleDriveDatasink; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ScheduleAsGoogleDriveFileAction.class) +public abstract class ScheduleAsGoogleDriveFileAction_ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction_ { + + public static volatile SingularAttribute folder; + public static volatile SingularAttribute name; + public static volatile SingularAttribute compressed; + public static volatile SingularAttribute googleDriveDatasink; + +} + diff --git a/metamodel/net/datenwerke/rs/googledrive/service/googledrive/action/ScheduleAsGoogleDriveFileAction__.java b/metamodel/net/datenwerke/rs/googledrive/service/googledrive/action/ScheduleAsGoogleDriveFileAction__.java new file mode 100644 index 000000000..5d3988f8d --- /dev/null +++ b/metamodel/net/datenwerke/rs/googledrive/service/googledrive/action/ScheduleAsGoogleDriveFileAction__.java @@ -0,0 +1,16 @@ +package net.datenwerke.rs.googledrive.service.googledrive.action; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class ScheduleAsGoogleDriveFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String compressed = "compressed"; + public static final String folder = "folder"; + public static final String googleDriveDatasink = "googleDriveDatasink"; + public static final String name = "name"; + +} diff --git a/metamodel/net/datenwerke/rs/googledrive/service/googledrive/definitions/GoogleDriveDatasink_.java b/metamodel/net/datenwerke/rs/googledrive/service/googledrive/definitions/GoogleDriveDatasink_.java new file mode 100644 index 000000000..47b9960de --- /dev/null +++ b/metamodel/net/datenwerke/rs/googledrive/service/googledrive/definitions/GoogleDriveDatasink_.java @@ -0,0 +1,17 @@ +package net.datenwerke.rs.googledrive.service.googledrive.definitions; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(GoogleDriveDatasink.class) +public abstract class GoogleDriveDatasink_ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition_ { + + public static volatile SingularAttribute folder; + public static volatile SingularAttribute secretKey; + public static volatile SingularAttribute appKey; + public static volatile SingularAttribute refreshToken; + +} + diff --git a/metamodel/net/datenwerke/rs/googledrive/service/googledrive/definitions/GoogleDriveDatasink__.java b/metamodel/net/datenwerke/rs/googledrive/service/googledrive/definitions/GoogleDriveDatasink__.java new file mode 100644 index 000000000..069a31638 --- /dev/null +++ b/metamodel/net/datenwerke/rs/googledrive/service/googledrive/definitions/GoogleDriveDatasink__.java @@ -0,0 +1,19 @@ +package net.datenwerke.rs.googledrive.service.googledrive.definitions; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class GoogleDriveDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String appKey = "appKey"; + public static final String basicDatasinkService = "basicDatasinkService"; + public static final String folder = "folder"; + public static final String pbeServiceProvider = "pbeServiceProvider"; + public static final String refreshToken = "refreshToken"; + public static final String secretKey = "secretKey"; + public static final String serialVersionUID = "serialVersionUID"; + +} diff --git a/metamodel/net/datenwerke/rs/jxlsreport/service/jxlsreport/entities/JxlsReport_.java b/metamodel/net/datenwerke/rs/jxlsreport/service/jxlsreport/entities/JxlsReport_.java index cf963654b..71285a824 100755 --- a/metamodel/net/datenwerke/rs/jxlsreport/service/jxlsreport/entities/JxlsReport_.java +++ b/metamodel/net/datenwerke/rs/jxlsreport/service/jxlsreport/entities/JxlsReport_.java @@ -8,7 +8,6 @@ @StaticMetamodel(JxlsReport.class) public abstract class JxlsReport_ extends net.datenwerke.rs.core.service.reportmanager.entities.reports.Report_ { - public static volatile SingularAttribute jxlsOne; public static volatile SingularAttribute reportFile; } diff --git a/metamodel/net/datenwerke/rs/jxlsreport/service/jxlsreport/entities/JxlsReport__.java b/metamodel/net/datenwerke/rs/jxlsreport/service/jxlsreport/entities/JxlsReport__.java index ded632184..649b27c3b 100755 --- a/metamodel/net/datenwerke/rs/jxlsreport/service/jxlsreport/entities/JxlsReport__.java +++ b/metamodel/net/datenwerke/rs/jxlsreport/service/jxlsreport/entities/JxlsReport__.java @@ -8,7 +8,6 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class JxlsReport__ extends net.datenwerke.rs.core.service.reportmanager.entities.reports.Report__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { - public static final String jxlsOne = "jxlsOne"; public static final String reportFile = "reportFile"; public static final String serialVersionUID = "serialVersionUID"; diff --git a/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/action/ScheduleAsLocalFileSystemFileAction_.java b/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/action/ScheduleAsLocalFileSystemFileAction_.java index a1091af87..b95718829 100644 --- a/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/action/ScheduleAsLocalFileSystemFileAction_.java +++ b/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/action/ScheduleAsLocalFileSystemFileAction_.java @@ -12,6 +12,7 @@ public abstract class ScheduleAsLocalFileSystemFileAction_ extends net.datenwerk public static volatile SingularAttribute folder; public static volatile SingularAttribute name; public static volatile SingularAttribute localFileSystemDatasink; + public static volatile SingularAttribute compressed; } diff --git a/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/action/ScheduleAsLocalFileSystemFileAction__.java b/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/action/ScheduleAsLocalFileSystemFileAction__.java index 9609ee1d0..dc715269b 100644 --- a/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/action/ScheduleAsLocalFileSystemFileAction__.java +++ b/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/action/ScheduleAsLocalFileSystemFileAction__.java @@ -8,6 +8,7 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class ScheduleAsLocalFileSystemFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String compressed = "compressed"; public static final String folder = "folder"; public static final String localFileSystemDatasink = "localFileSystemDatasink"; public static final String name = "name"; diff --git a/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/definitions/LocalFileSystemDatasink__.java b/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/definitions/LocalFileSystemDatasink__.java index fed21b4e8..6e6d9d182 100644 --- a/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/definitions/LocalFileSystemDatasink__.java +++ b/metamodel/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/definitions/LocalFileSystemDatasink__.java @@ -8,6 +8,7 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class LocalFileSystemDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String basicDatasinkService = "basicDatasinkService"; public static final String folder = "folder"; public static final String path = "path"; public static final String serialVersionUID = "serialVersionUID"; diff --git a/metamodel/net/datenwerke/rs/onedrive/service/onedrive/action/ScheduleAsOneDriveFileAction_.java b/metamodel/net/datenwerke/rs/onedrive/service/onedrive/action/ScheduleAsOneDriveFileAction_.java new file mode 100644 index 000000000..37928b3f6 --- /dev/null +++ b/metamodel/net/datenwerke/rs/onedrive/service/onedrive/action/ScheduleAsOneDriveFileAction_.java @@ -0,0 +1,18 @@ +package net.datenwerke.rs.onedrive.service.onedrive.action; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import net.datenwerke.rs.onedrive.service.onedrive.definitions.OneDriveDatasink; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ScheduleAsOneDriveFileAction.class) +public abstract class ScheduleAsOneDriveFileAction_ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction_ { + + public static volatile SingularAttribute oneDriveDatasink; + public static volatile SingularAttribute folder; + public static volatile SingularAttribute name; + public static volatile SingularAttribute compressed; + +} + diff --git a/metamodel/net/datenwerke/rs/onedrive/service/onedrive/action/ScheduleAsOneDriveFileAction__.java b/metamodel/net/datenwerke/rs/onedrive/service/onedrive/action/ScheduleAsOneDriveFileAction__.java new file mode 100644 index 000000000..532e0313c --- /dev/null +++ b/metamodel/net/datenwerke/rs/onedrive/service/onedrive/action/ScheduleAsOneDriveFileAction__.java @@ -0,0 +1,16 @@ +package net.datenwerke.rs.onedrive.service.onedrive.action; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class ScheduleAsOneDriveFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String compressed = "compressed"; + public static final String folder = "folder"; + public static final String name = "name"; + public static final String oneDriveDatasink = "oneDriveDatasink"; + +} diff --git a/metamodel/net/datenwerke/rs/onedrive/service/onedrive/definitions/OneDriveDatasink_.java b/metamodel/net/datenwerke/rs/onedrive/service/onedrive/definitions/OneDriveDatasink_.java new file mode 100644 index 000000000..56ce51416 --- /dev/null +++ b/metamodel/net/datenwerke/rs/onedrive/service/onedrive/definitions/OneDriveDatasink_.java @@ -0,0 +1,19 @@ +package net.datenwerke.rs.onedrive.service.onedrive.definitions; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(OneDriveDatasink.class) +public abstract class OneDriveDatasink_ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition_ { + + public static volatile SingularAttribute baseRoot; + public static volatile SingularAttribute folder; + public static volatile SingularAttribute secretKey; + public static volatile SingularAttribute tenantId; + public static volatile SingularAttribute appKey; + public static volatile SingularAttribute refreshToken; + +} + diff --git a/metamodel/net/datenwerke/rs/onedrive/service/onedrive/definitions/OneDriveDatasink__.java b/metamodel/net/datenwerke/rs/onedrive/service/onedrive/definitions/OneDriveDatasink__.java new file mode 100644 index 000000000..18d549d01 --- /dev/null +++ b/metamodel/net/datenwerke/rs/onedrive/service/onedrive/definitions/OneDriveDatasink__.java @@ -0,0 +1,21 @@ +package net.datenwerke.rs.onedrive.service.onedrive.definitions; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class OneDriveDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String appKey = "appKey"; + public static final String baseRoot = "baseRoot"; + public static final String basicDatasinkService = "basicDatasinkService"; + public static final String folder = "folder"; + public static final String pbeServiceProvider = "pbeServiceProvider"; + public static final String refreshToken = "refreshToken"; + public static final String secretKey = "secretKey"; + public static final String serialVersionUID = "serialVersionUID"; + public static final String tenantId = "tenantId"; + +} diff --git a/metamodel/net/datenwerke/rs/printer/service/printer/action/ScheduleAsPrinterFileAction_.java b/metamodel/net/datenwerke/rs/printer/service/printer/action/ScheduleAsPrinterFileAction_.java new file mode 100644 index 000000000..c3ebe5a49 --- /dev/null +++ b/metamodel/net/datenwerke/rs/printer/service/printer/action/ScheduleAsPrinterFileAction_.java @@ -0,0 +1,15 @@ +package net.datenwerke.rs.printer.service.printer.action; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import net.datenwerke.rs.printer.service.printer.definitions.PrinterDatasink; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ScheduleAsPrinterFileAction.class) +public abstract class ScheduleAsPrinterFileAction_ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction_ { + + public static volatile SingularAttribute printerDatasink; + +} + diff --git a/metamodel/net/datenwerke/rs/printer/service/printer/action/ScheduleAsPrinterFileAction__.java b/metamodel/net/datenwerke/rs/printer/service/printer/action/ScheduleAsPrinterFileAction__.java new file mode 100644 index 000000000..9248334d2 --- /dev/null +++ b/metamodel/net/datenwerke/rs/printer/service/printer/action/ScheduleAsPrinterFileAction__.java @@ -0,0 +1,13 @@ +package net.datenwerke.rs.printer.service.printer.action; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class ScheduleAsPrinterFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String printerDatasink = "printerDatasink"; + +} diff --git a/metamodel/net/datenwerke/rs/printer/service/printer/definitions/PrinterDatasink_.java b/metamodel/net/datenwerke/rs/printer/service/printer/definitions/PrinterDatasink_.java new file mode 100644 index 000000000..92094f683 --- /dev/null +++ b/metamodel/net/datenwerke/rs/printer/service/printer/definitions/PrinterDatasink_.java @@ -0,0 +1,14 @@ +package net.datenwerke.rs.printer.service.printer.definitions; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(PrinterDatasink.class) +public abstract class PrinterDatasink_ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition_ { + + public static volatile SingularAttribute printerName; + +} + diff --git a/metamodel/net/datenwerke/rs/printer/service/printer/definitions/PrinterDatasink__.java b/metamodel/net/datenwerke/rs/printer/service/printer/definitions/PrinterDatasink__.java new file mode 100644 index 000000000..07adce4e9 --- /dev/null +++ b/metamodel/net/datenwerke/rs/printer/service/printer/definitions/PrinterDatasink__.java @@ -0,0 +1,15 @@ +package net.datenwerke.rs.printer.service.printer.definitions; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class PrinterDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String basicDatasinkService = "basicDatasinkService"; + public static final String printerName = "printerName"; + public static final String serialVersionUID = "serialVersionUID"; + +} diff --git a/metamodel/net/datenwerke/rs/samba/service/samba/action/ScheduleAsSambaFileAction_.java b/metamodel/net/datenwerke/rs/samba/service/samba/action/ScheduleAsSambaFileAction_.java index 7c8a5e2be..f112840aa 100644 --- a/metamodel/net/datenwerke/rs/samba/service/samba/action/ScheduleAsSambaFileAction_.java +++ b/metamodel/net/datenwerke/rs/samba/service/samba/action/ScheduleAsSambaFileAction_.java @@ -12,6 +12,7 @@ public abstract class ScheduleAsSambaFileAction_ extends net.datenwerke.schedule public static volatile SingularAttribute folder; public static volatile SingularAttribute name; public static volatile SingularAttribute sambaDatasink; + public static volatile SingularAttribute compressed; } diff --git a/metamodel/net/datenwerke/rs/samba/service/samba/action/ScheduleAsSambaFileAction__.java b/metamodel/net/datenwerke/rs/samba/service/samba/action/ScheduleAsSambaFileAction__.java index caff0c06b..e7a4379dd 100644 --- a/metamodel/net/datenwerke/rs/samba/service/samba/action/ScheduleAsSambaFileAction__.java +++ b/metamodel/net/datenwerke/rs/samba/service/samba/action/ScheduleAsSambaFileAction__.java @@ -8,6 +8,7 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class ScheduleAsSambaFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String compressed = "compressed"; public static final String folder = "folder"; public static final String name = "name"; public static final String sambaDatasink = "sambaDatasink"; diff --git a/metamodel/net/datenwerke/rs/samba/service/samba/definitions/SambaDatasink__.java b/metamodel/net/datenwerke/rs/samba/service/samba/definitions/SambaDatasink__.java index 1e1e295d6..a8c7e8b49 100644 --- a/metamodel/net/datenwerke/rs/samba/service/samba/definitions/SambaDatasink__.java +++ b/metamodel/net/datenwerke/rs/samba/service/samba/definitions/SambaDatasink__.java @@ -8,6 +8,7 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class SambaDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String basicDatasinkService = "basicDatasinkService"; public static final String domain = "domain"; public static final String folder = "folder"; public static final String host = "host"; diff --git a/metamodel/net/datenwerke/rs/scheduleasfile/service/scheduleasfile/action/ScheduleAsFtpFileAction_.java b/metamodel/net/datenwerke/rs/scheduleasfile/service/scheduleasfile/action/ScheduleAsFtpFileAction_.java index 2dead7c21..88f40a4fa 100644 --- a/metamodel/net/datenwerke/rs/scheduleasfile/service/scheduleasfile/action/ScheduleAsFtpFileAction_.java +++ b/metamodel/net/datenwerke/rs/scheduleasfile/service/scheduleasfile/action/ScheduleAsFtpFileAction_.java @@ -1,11 +1,11 @@ package net.datenwerke.rs.scheduleasfile.service.scheduleasfile.action; -import javax.annotation.Generated; -import javax.persistence.metamodel.SingularAttribute; +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; import javax.persistence.metamodel.StaticMetamodel; import net.datenwerke.rs.ftp.service.ftp.action.ScheduleAsFtpFileAction; -import net.datenwerke.rs.ftp.service.ftp.definitions.FtpDatasink; +import net.datenwerke.rs.ftp.service.ftp.definitions.FtpDatasink; @Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") @StaticMetamodel(ScheduleAsFtpFileAction.class) diff --git a/metamodel/net/datenwerke/rs/scheduleasfile/service/scheduleasfile/action/ScheduleAsSftpFileAction_.java b/metamodel/net/datenwerke/rs/scheduleasfile/service/scheduleasfile/action/ScheduleAsSftpFileAction_.java index d2c2cd764..8d683907c 100644 --- a/metamodel/net/datenwerke/rs/scheduleasfile/service/scheduleasfile/action/ScheduleAsSftpFileAction_.java +++ b/metamodel/net/datenwerke/rs/scheduleasfile/service/scheduleasfile/action/ScheduleAsSftpFileAction_.java @@ -1,10 +1,10 @@ package net.datenwerke.rs.scheduleasfile.service.scheduleasfile.action; -import javax.annotation.Generated; -import javax.persistence.metamodel.SingularAttribute; +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; import javax.persistence.metamodel.StaticMetamodel; -import net.datenwerke.rs.ftp.service.ftp.action.ScheduleAsSftpFileAction; +import net.datenwerke.rs.ftp.service.ftp.action.ScheduleAsSftpFileAction; @Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") @StaticMetamodel(ScheduleAsSftpFileAction.class) diff --git a/metamodel/net/datenwerke/rs/scp/service/scp/action/ScheduleAsScpFileAction_.java b/metamodel/net/datenwerke/rs/scp/service/scp/action/ScheduleAsScpFileAction_.java index b2101acd1..c9f4137b9 100644 --- a/metamodel/net/datenwerke/rs/scp/service/scp/action/ScheduleAsScpFileAction_.java +++ b/metamodel/net/datenwerke/rs/scp/service/scp/action/ScheduleAsScpFileAction_.java @@ -12,6 +12,7 @@ public abstract class ScheduleAsScpFileAction_ extends net.datenwerke.scheduler. public static volatile SingularAttribute scpDatasink; public static volatile SingularAttribute folder; public static volatile SingularAttribute name; + public static volatile SingularAttribute compressed; } diff --git a/metamodel/net/datenwerke/rs/scp/service/scp/action/ScheduleAsScpFileAction__.java b/metamodel/net/datenwerke/rs/scp/service/scp/action/ScheduleAsScpFileAction__.java index 8c354cb8e..50bda3e04 100644 --- a/metamodel/net/datenwerke/rs/scp/service/scp/action/ScheduleAsScpFileAction__.java +++ b/metamodel/net/datenwerke/rs/scp/service/scp/action/ScheduleAsScpFileAction__.java @@ -8,6 +8,7 @@ @GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") public class ScheduleAsScpFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + public static final String compressed = "compressed"; public static final String folder = "folder"; public static final String name = "name"; public static final String scpDatasink = "scpDatasink"; diff --git a/metamodel/net/datenwerke/rs/scp/service/scp/definitions/ScpDatasink__.java b/metamodel/net/datenwerke/rs/scp/service/scp/definitions/ScpDatasink__.java index ac66c17c3..13e5657b7 100644 --- a/metamodel/net/datenwerke/rs/scp/service/scp/definitions/ScpDatasink__.java +++ b/metamodel/net/datenwerke/rs/scp/service/scp/definitions/ScpDatasink__.java @@ -9,6 +9,7 @@ public class ScpDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { public static final String authenticationType = "authenticationType"; + public static final String basicDatasinkService = "basicDatasinkService"; public static final String folder = "folder"; public static final String host = "host"; public static final String password = "password"; diff --git a/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/action/ScheduleAsScriptDatasinkFileAction_.java b/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/action/ScheduleAsScriptDatasinkFileAction_.java new file mode 100644 index 000000000..b9b44a6ab --- /dev/null +++ b/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/action/ScheduleAsScriptDatasinkFileAction_.java @@ -0,0 +1,17 @@ +package net.datenwerke.rs.scriptdatasink.service.scriptdatasink.action; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import net.datenwerke.rs.scriptdatasink.service.scriptdatasink.definitions.ScriptDatasink; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ScheduleAsScriptDatasinkFileAction.class) +public abstract class ScheduleAsScriptDatasinkFileAction_ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction_ { + + public static volatile SingularAttribute name; + public static volatile SingularAttribute compressed; + public static volatile SingularAttribute scriptDatasink; + +} + diff --git a/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/action/ScheduleAsScriptDatasinkFileAction__.java b/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/action/ScheduleAsScriptDatasinkFileAction__.java new file mode 100644 index 000000000..98449c35d --- /dev/null +++ b/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/action/ScheduleAsScriptDatasinkFileAction__.java @@ -0,0 +1,15 @@ +package net.datenwerke.rs.scriptdatasink.service.scriptdatasink.action; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class ScheduleAsScriptDatasinkFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String compressed = "compressed"; + public static final String name = "name"; + public static final String scriptDatasink = "scriptDatasink"; + +} diff --git a/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/definitions/ScriptDatasink_.java b/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/definitions/ScriptDatasink_.java new file mode 100644 index 000000000..6a3f5789a --- /dev/null +++ b/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/definitions/ScriptDatasink_.java @@ -0,0 +1,15 @@ +package net.datenwerke.rs.scriptdatasink.service.scriptdatasink.definitions; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import net.datenwerke.rs.fileserver.service.fileserver.entities.FileServerFile; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ScriptDatasink.class) +public abstract class ScriptDatasink_ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition_ { + + public static volatile SingularAttribute script; + +} + diff --git a/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/definitions/ScriptDatasink__.java b/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/definitions/ScriptDatasink__.java new file mode 100644 index 000000000..3a3327c4e --- /dev/null +++ b/metamodel/net/datenwerke/rs/scriptdatasink/service/scriptdatasink/definitions/ScriptDatasink__.java @@ -0,0 +1,15 @@ +package net.datenwerke.rs.scriptdatasink.service.scriptdatasink.definitions; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class ScriptDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String basicDatasinkService = "basicDatasinkService"; + public static final String script = "script"; + public static final String serialVersionUID = "serialVersionUID"; + +} diff --git a/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/action/ScheduleAsTableDatasinkFileAction_.java b/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/action/ScheduleAsTableDatasinkFileAction_.java new file mode 100644 index 000000000..0a735f794 --- /dev/null +++ b/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/action/ScheduleAsTableDatasinkFileAction_.java @@ -0,0 +1,15 @@ +package net.datenwerke.rs.tabledatasink.service.tabledatasink.action; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import net.datenwerke.rs.tabledatasink.service.tabledatasink.definitions.TableDatasink; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(ScheduleAsTableDatasinkFileAction.class) +public abstract class ScheduleAsTableDatasinkFileAction_ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction_ { + + public static volatile SingularAttribute tableDatasink; + +} + diff --git a/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/action/ScheduleAsTableDatasinkFileAction__.java b/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/action/ScheduleAsTableDatasinkFileAction__.java new file mode 100644 index 000000000..f073e2995 --- /dev/null +++ b/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/action/ScheduleAsTableDatasinkFileAction__.java @@ -0,0 +1,13 @@ +package net.datenwerke.rs.tabledatasink.service.tabledatasink.action; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class ScheduleAsTableDatasinkFileAction__ extends net.datenwerke.scheduler.service.scheduler.entities.AbstractAction__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String tableDatasink = "tableDatasink"; + +} diff --git a/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/definitions/TableDatasink_.java b/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/definitions/TableDatasink_.java new file mode 100644 index 000000000..6faccb3eb --- /dev/null +++ b/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/definitions/TableDatasink_.java @@ -0,0 +1,19 @@ +package net.datenwerke.rs.tabledatasink.service.tabledatasink.definitions; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; +import net.datenwerke.rs.core.service.datasourcemanager.entities.DatasourceContainer; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(TableDatasink.class) +public abstract class TableDatasink_ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition_ { + + public static volatile SingularAttribute primaryKeys; + public static volatile SingularAttribute datasourceContainer; + public static volatile SingularAttribute batchSize; + public static volatile SingularAttribute tableName; + public static volatile SingularAttribute copyPrimaryKeys; + +} + diff --git a/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/definitions/TableDatasink__.java b/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/definitions/TableDatasink__.java new file mode 100644 index 000000000..09d24a88c --- /dev/null +++ b/metamodel/net/datenwerke/rs/tabledatasink/service/tabledatasink/definitions/TableDatasink__.java @@ -0,0 +1,19 @@ +package net.datenwerke.rs.tabledatasink.service.tabledatasink.definitions; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class TableDatasink__ extends net.datenwerke.rs.core.service.datasinkmanager.entities.DatasinkDefinition__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String basicDatasinkService = "basicDatasinkService"; + public static final String batchSize = "batchSize"; + public static final String copyPrimaryKeys = "copyPrimaryKeys"; + public static final String datasourceContainer = "datasourceContainer"; + public static final String primaryKeys = "primaryKeys"; + public static final String serialVersionUID = "serialVersionUID"; + public static final String tableName = "tableName"; + +} diff --git a/metamodel/net/datenwerke/rs/tsreportarea/service/tsreportarea/entities/TsDiskFileReference_.java b/metamodel/net/datenwerke/rs/tsreportarea/service/tsreportarea/entities/TsDiskFileReference_.java new file mode 100644 index 000000000..980b41601 --- /dev/null +++ b/metamodel/net/datenwerke/rs/tsreportarea/service/tsreportarea/entities/TsDiskFileReference_.java @@ -0,0 +1,15 @@ +package net.datenwerke.rs.tsreportarea.service.tsreportarea.entities; + +import javax.annotation.Generated; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.StaticMetamodel; + +@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") +@StaticMetamodel(TsDiskFileReference.class) +public abstract class TsDiskFileReference_ extends net.datenwerke.rs.tsreportarea.service.tsreportarea.entities.TsDiskGeneralReference_ { + + public static volatile SingularAttribute filename; + public static volatile SingularAttribute data; + +} + diff --git a/metamodel/net/datenwerke/rs/tsreportarea/service/tsreportarea/entities/TsDiskFileReference__.java b/metamodel/net/datenwerke/rs/tsreportarea/service/tsreportarea/entities/TsDiskFileReference__.java new file mode 100644 index 000000000..37c4eec29 --- /dev/null +++ b/metamodel/net/datenwerke/rs/tsreportarea/service/tsreportarea/entities/TsDiskFileReference__.java @@ -0,0 +1,15 @@ +package net.datenwerke.rs.tsreportarea.service.tsreportarea.entities; + +import net.datenwerke.dtoservices.dtogenerator.annotations.GeneratedType; + +/** + * This file was automatically created by DtoAnnotationProcessor, version 0.1 + */ +@GeneratedType("net.datenwerke.entityservices.metadatagenerator.EntityMetadataProcessor") +public class TsDiskFileReference__ extends net.datenwerke.rs.tsreportarea.service.tsreportarea.entities.TsDiskGeneralReference__ implements net.datenwerke.entityservices.metadatagenerator.interfaces.EntityMetadataProvider { + + public static final String data = "data"; + public static final String filename = "filename"; + public static final String serialVersionUID = "serialVersionUID"; + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/Area.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/Area.java index 26da152d7..aee919973 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/Area.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/Area.java @@ -1,42 +1,42 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel; - -public class Area { - Coordinate x; - Coordinate y; - float height; - - public Area(Coordinate x, Coordinate y) { - this.x = x; - this.y = y; - } - - public Coordinate getX() { - return x; - } - - public Coordinate getY() { - return y; - } - - public float getHeight() { - return height; - } - - public void setHeight( float height ) { - this.height = height; - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel; + +public class Area { + Coordinate x; + Coordinate y; + float height; + + public Area(Coordinate x, Coordinate y) { + this.x = x; + this.y = y; + } + + public Coordinate getX() { + return x; + } + + public Coordinate getY() { + return y; + } + + public float getHeight() { + return height; + } + + public void setHeight( float height ) { + this.height = height; + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/AreaBorders.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/AreaBorders.java index 3e27ab17e..eb8c0d10a 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/AreaBorders.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/AreaBorders.java @@ -1,140 +1,140 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel; - -import org.eclipse.birt.report.engine.css.engine.StyleConstants; -import org.eclipse.birt.report.engine.css.engine.value.css.CSSConstants; -import org.w3c.dom.css.CSSValue; - -public class AreaBorders { - public boolean isMergedCells; - - public int bottom; - public int left; - public int right; - public int top; - - public CSSValue[] cssStyle = new CSSValue[4]; - public CSSValue[] cssWidth = new CSSValue[4]; - public CSSValue[] cssColour = new CSSValue[4]; - - private AreaBorders(boolean isMergedCells, int bottom, int left, int right, int top, - CSSValue[] cssStyle, CSSValue[] cssWidth, CSSValue[] cssColour) { - this.isMergedCells = isMergedCells; - this.bottom = bottom; - this.left = left; - this.right = right; - this.top = top; - this.cssStyle = cssStyle; - this.cssWidth = cssWidth; - this.cssColour = cssColour; - } - - public static AreaBorders create(int bottom, int left, int right, int top, BirtStyle borderStyle) { - return create( false, bottom, left, right, top, borderStyle ); - } - - public static AreaBorders createForMergedCells(int bottom, int left, int right, int top, BirtStyle borderStyle) { - return create( true, bottom, left, right, top, borderStyle ); - } - - public static AreaBorders create(boolean isMergedCells, int bottom, int left, int right, int top, BirtStyle borderStyle) { - - CSSValue borderStyleBottom = borderStyle.getProperty( StyleConstants.STYLE_BORDER_BOTTOM_STYLE ); - CSSValue borderWidthBottom = borderStyle.getProperty( StyleConstants.STYLE_BORDER_BOTTOM_WIDTH ); - CSSValue borderColourBottom = borderStyle.getProperty( StyleConstants.STYLE_BORDER_BOTTOM_COLOR ); - CSSValue borderStyleLeft = borderStyle.getProperty( StyleConstants.STYLE_BORDER_LEFT_STYLE ); - CSSValue borderWidthLeft = borderStyle.getProperty( StyleConstants.STYLE_BORDER_LEFT_WIDTH ); - CSSValue borderColourLeft = borderStyle.getProperty( StyleConstants.STYLE_BORDER_LEFT_COLOR ); - CSSValue borderStyleRight = borderStyle.getProperty( StyleConstants.STYLE_BORDER_RIGHT_STYLE ); - CSSValue borderWidthRight = borderStyle.getProperty( StyleConstants.STYLE_BORDER_RIGHT_WIDTH ); - CSSValue borderColourRight = borderStyle.getProperty( StyleConstants.STYLE_BORDER_RIGHT_COLOR ); - CSSValue borderStyleTop = borderStyle.getProperty( StyleConstants.STYLE_BORDER_TOP_STYLE ); - CSSValue borderWidthTop = borderStyle.getProperty( StyleConstants.STYLE_BORDER_TOP_WIDTH ); - CSSValue borderColourTop = borderStyle.getProperty( StyleConstants.STYLE_BORDER_TOP_COLOR ); - -/* borderMsg.append( ", Bottom:" ).append( borderStyleBottom ).append( "/" ).append( borderWidthBottom ).append( "/" + borderColourBottom ); - borderMsg.append( ", Left:" ).append( borderStyleLeft ).append( "/" ).append( borderWidthLeft ).append( "/" + borderColourLeft ); - borderMsg.append( ", Right:" ).append( borderStyleRight ).append( "/" ).append( borderWidthRight ).append( "/" ).append( borderColourRight ); - borderMsg.append( ", Top:" ).append( borderStyleTop ).append( "/" ).append( borderWidthTop ).append( "/" ).append( borderColourTop ); - log.debug( borderMsg.toString() ); -*/ - if( ( borderStyleBottom == null ) || ( CSSConstants.CSS_NONE_VALUE.equals( borderStyleBottom.getCssText() ) ) - || ( borderWidthBottom == null ) || ( "0".equals(borderWidthBottom.getCssText()) ) - || ( borderColourBottom == null ) || ( CSSConstants.CSS_TRANSPARENT_VALUE.equals(borderColourBottom.getCssText() ) ) ) { - borderStyleBottom = null; - borderWidthBottom = null; - borderColourBottom = null; - } - - if( ( borderStyleLeft == null ) || ( CSSConstants.CSS_NONE_VALUE.equals( borderStyleLeft.getCssText() ) ) - || ( borderWidthLeft == null ) || ( "0".equals(borderWidthLeft.getCssText()) ) - || ( borderColourLeft == null ) || ( CSSConstants.CSS_TRANSPARENT_VALUE.equals(borderColourLeft.getCssText() ) ) ) { - borderStyleLeft = null; - borderWidthLeft = null; - borderColourLeft = null; - } - - if( ( borderStyleRight == null ) || ( CSSConstants.CSS_NONE_VALUE.equals( borderStyleRight.getCssText() ) ) - || ( borderWidthRight == null ) || ( "0".equals(borderWidthRight.getCssText()) ) - || ( borderColourRight == null ) || ( CSSConstants.CSS_TRANSPARENT_VALUE.equals(borderColourRight.getCssText() ) ) ) { - borderStyleRight = null; - borderWidthRight = null; - borderColourRight = null; - } - - if( ( borderStyleTop == null ) || ( CSSConstants.CSS_NONE_VALUE.equals( borderStyleTop.getCssText() ) ) - || ( borderWidthTop == null ) || ( "0".equals(borderWidthTop.getCssText()) ) - || ( borderColourTop == null ) || ( CSSConstants.CSS_TRANSPARENT_VALUE.equals(borderColourTop.getCssText() ) ) ) { - borderStyleTop = null; - borderWidthTop = null; - borderColourTop = null; - } - - if( ( ( bottom >= 0 ) && ( ( borderStyleBottom != null ) || ( borderWidthBottom != null ) || ( borderColourBottom != null ) ) ) - || ( ( left >= 0 ) && ( ( borderStyleLeft != null ) || ( borderWidthLeft != null ) || ( borderColourLeft != null ) ) ) - || ( ( right >= 0 ) && ( ( borderStyleRight != null ) || ( borderWidthRight != null ) || ( borderColourRight != null ) ) ) - || ( ( top >= 0 ) && ( ( borderStyleTop != null ) || ( borderWidthTop != null ) || ( borderColourTop != null ) ) ) - ) { - CSSValue[] cssStyle = new CSSValue[] { borderStyleBottom, borderStyleLeft, borderStyleRight, borderStyleTop }; - CSSValue[] cssWidth = new CSSValue[] { borderWidthBottom, borderWidthLeft, borderWidthRight, borderWidthTop }; - CSSValue[] cssColour = new CSSValue[] { borderColourBottom, borderColourLeft, borderColourRight, borderColourTop }; - return new AreaBorders(isMergedCells, bottom, left, right, top, cssStyle, cssWidth, cssColour); - } - return null; - } - - - @Override - public String toString() { - StringBuilder result = new StringBuilder(); - result.append( "[" ).append( top ).append( "," ).append( left ).append( "]" ); - result.append("-"); - result.append( "[" ).append( bottom ).append( "," ).append( right ).append( "]" ); - result.append("="); - for( int i = 0; i < 4; ++i ) { - result.append("["); - result.append( cssStyle[i] ); - result.append(";"); - result.append( cssWidth[i] ); - result.append(";"); - result.append( cssColour[i] ); - result.append("]"); - } - return result.toString(); - } - - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel; + +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.css.engine.value.css.CSSConstants; +import org.w3c.dom.css.CSSValue; + +public class AreaBorders { + public boolean isMergedCells; + + public int bottom; + public int left; + public int right; + public int top; + + public CSSValue[] cssStyle = new CSSValue[4]; + public CSSValue[] cssWidth = new CSSValue[4]; + public CSSValue[] cssColour = new CSSValue[4]; + + private AreaBorders(boolean isMergedCells, int bottom, int left, int right, int top, + CSSValue[] cssStyle, CSSValue[] cssWidth, CSSValue[] cssColour) { + this.isMergedCells = isMergedCells; + this.bottom = bottom; + this.left = left; + this.right = right; + this.top = top; + this.cssStyle = cssStyle; + this.cssWidth = cssWidth; + this.cssColour = cssColour; + } + + public static AreaBorders create(int bottom, int left, int right, int top, BirtStyle borderStyle) { + return create( false, bottom, left, right, top, borderStyle ); + } + + public static AreaBorders createForMergedCells(int bottom, int left, int right, int top, BirtStyle borderStyle) { + return create( true, bottom, left, right, top, borderStyle ); + } + + public static AreaBorders create(boolean isMergedCells, int bottom, int left, int right, int top, BirtStyle borderStyle) { + + CSSValue borderStyleBottom = borderStyle.getProperty( StyleConstants.STYLE_BORDER_BOTTOM_STYLE ); + CSSValue borderWidthBottom = borderStyle.getProperty( StyleConstants.STYLE_BORDER_BOTTOM_WIDTH ); + CSSValue borderColourBottom = borderStyle.getProperty( StyleConstants.STYLE_BORDER_BOTTOM_COLOR ); + CSSValue borderStyleLeft = borderStyle.getProperty( StyleConstants.STYLE_BORDER_LEFT_STYLE ); + CSSValue borderWidthLeft = borderStyle.getProperty( StyleConstants.STYLE_BORDER_LEFT_WIDTH ); + CSSValue borderColourLeft = borderStyle.getProperty( StyleConstants.STYLE_BORDER_LEFT_COLOR ); + CSSValue borderStyleRight = borderStyle.getProperty( StyleConstants.STYLE_BORDER_RIGHT_STYLE ); + CSSValue borderWidthRight = borderStyle.getProperty( StyleConstants.STYLE_BORDER_RIGHT_WIDTH ); + CSSValue borderColourRight = borderStyle.getProperty( StyleConstants.STYLE_BORDER_RIGHT_COLOR ); + CSSValue borderStyleTop = borderStyle.getProperty( StyleConstants.STYLE_BORDER_TOP_STYLE ); + CSSValue borderWidthTop = borderStyle.getProperty( StyleConstants.STYLE_BORDER_TOP_WIDTH ); + CSSValue borderColourTop = borderStyle.getProperty( StyleConstants.STYLE_BORDER_TOP_COLOR ); + +/* borderMsg.append( ", Bottom:" ).append( borderStyleBottom ).append( "/" ).append( borderWidthBottom ).append( "/" + borderColourBottom ); + borderMsg.append( ", Left:" ).append( borderStyleLeft ).append( "/" ).append( borderWidthLeft ).append( "/" + borderColourLeft ); + borderMsg.append( ", Right:" ).append( borderStyleRight ).append( "/" ).append( borderWidthRight ).append( "/" ).append( borderColourRight ); + borderMsg.append( ", Top:" ).append( borderStyleTop ).append( "/" ).append( borderWidthTop ).append( "/" ).append( borderColourTop ); + log.debug( borderMsg.toString() ); +*/ + if( ( borderStyleBottom == null ) || ( CSSConstants.CSS_NONE_VALUE.equals( borderStyleBottom.getCssText() ) ) + || ( borderWidthBottom == null ) || ( "0".equals(borderWidthBottom.getCssText()) ) + || ( borderColourBottom == null ) || ( CSSConstants.CSS_TRANSPARENT_VALUE.equals(borderColourBottom.getCssText() ) ) ) { + borderStyleBottom = null; + borderWidthBottom = null; + borderColourBottom = null; + } + + if( ( borderStyleLeft == null ) || ( CSSConstants.CSS_NONE_VALUE.equals( borderStyleLeft.getCssText() ) ) + || ( borderWidthLeft == null ) || ( "0".equals(borderWidthLeft.getCssText()) ) + || ( borderColourLeft == null ) || ( CSSConstants.CSS_TRANSPARENT_VALUE.equals(borderColourLeft.getCssText() ) ) ) { + borderStyleLeft = null; + borderWidthLeft = null; + borderColourLeft = null; + } + + if( ( borderStyleRight == null ) || ( CSSConstants.CSS_NONE_VALUE.equals( borderStyleRight.getCssText() ) ) + || ( borderWidthRight == null ) || ( "0".equals(borderWidthRight.getCssText()) ) + || ( borderColourRight == null ) || ( CSSConstants.CSS_TRANSPARENT_VALUE.equals(borderColourRight.getCssText() ) ) ) { + borderStyleRight = null; + borderWidthRight = null; + borderColourRight = null; + } + + if( ( borderStyleTop == null ) || ( CSSConstants.CSS_NONE_VALUE.equals( borderStyleTop.getCssText() ) ) + || ( borderWidthTop == null ) || ( "0".equals(borderWidthTop.getCssText()) ) + || ( borderColourTop == null ) || ( CSSConstants.CSS_TRANSPARENT_VALUE.equals(borderColourTop.getCssText() ) ) ) { + borderStyleTop = null; + borderWidthTop = null; + borderColourTop = null; + } + + if( ( ( bottom >= 0 ) && ( ( borderStyleBottom != null ) || ( borderWidthBottom != null ) || ( borderColourBottom != null ) ) ) + || ( ( left >= 0 ) && ( ( borderStyleLeft != null ) || ( borderWidthLeft != null ) || ( borderColourLeft != null ) ) ) + || ( ( right >= 0 ) && ( ( borderStyleRight != null ) || ( borderWidthRight != null ) || ( borderColourRight != null ) ) ) + || ( ( top >= 0 ) && ( ( borderStyleTop != null ) || ( borderWidthTop != null ) || ( borderColourTop != null ) ) ) + ) { + CSSValue[] cssStyle = new CSSValue[] { borderStyleBottom, borderStyleLeft, borderStyleRight, borderStyleTop }; + CSSValue[] cssWidth = new CSSValue[] { borderWidthBottom, borderWidthLeft, borderWidthRight, borderWidthTop }; + CSSValue[] cssColour = new CSSValue[] { borderColourBottom, borderColourLeft, borderColourRight, borderColourTop }; + return new AreaBorders(isMergedCells, bottom, left, right, top, cssStyle, cssWidth, cssColour); + } + return null; + } + + + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + result.append( "[" ).append( top ).append( "," ).append( left ).append( "]" ); + result.append("-"); + result.append( "[" ).append( bottom ).append( "," ).append( right ).append( "]" ); + result.append("="); + for( int i = 0; i < 4; ++i ) { + result.append("["); + result.append( cssStyle[i] ); + result.append(";"); + result.append( cssWidth[i] ); + result.append(";"); + result.append( cssColour[i] ); + result.append("]"); + } + return result.toString(); + } + + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/BirtStyle.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/BirtStyle.java index 819b52d34..1f2c35ee2 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/BirtStyle.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/BirtStyle.java @@ -1,336 +1,336 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - - -package uk.co.spudsoft.birt.emitters.excel; - -import java.util.BitSet; -import java.util.Map; - -import org.eclipse.birt.report.engine.content.IContent; -import org.eclipse.birt.report.engine.content.IStyle; -import org.eclipse.birt.report.engine.css.dom.AbstractStyle; -import org.eclipse.birt.report.engine.css.engine.CSSEngine; -import org.eclipse.birt.report.engine.css.engine.StyleConstants; -import org.eclipse.birt.report.engine.css.engine.value.DataFormatValue; -import org.eclipse.birt.report.engine.css.engine.value.FloatValue; -import org.eclipse.birt.report.engine.css.engine.value.StringValue; -import org.eclipse.birt.report.engine.css.engine.value.css.CSSConstants; -import org.eclipse.birt.report.engine.ir.Expression; -import org.eclipse.birt.report.engine.ir.ReportElementDesign; -import org.w3c.dom.css.CSSPrimitiveValue; -import org.w3c.dom.css.CSSValue; - -public class BirtStyle { - - public static final int NUMBER_OF_STYLES = StyleConstants.NUMBER_OF_STYLE + 1; - public static final int TEXT_ROTATION = StyleConstants.NUMBER_OF_STYLE; - - protected static final String cssProperties[] = { - "margin-left" - , "margin-right" - , "margin-top" - , "DATA_FORMAT" - , "border-right-color" - , "direction" - , "border-top-width" - , "padding-left" - , "border-right-width" - , "padding-bottom" - , "padding-top" - , "NUMBER_ALIGN" - , "padding-right" - , "CAN_SHRINK" - , "border-top-color" - , "background-repeat" - , "margin-bottom" - , "background-width" - , "background-height" - , "border-right-style" - , "border-bottom-color" - , "text-indent" - , "line-height" - , "border-bottom-width" - , "text-align" - , "background-color" - , "color" - , "overflow" - , "TEXT_LINETHROUGH" - , "border-left-color" - , "widows" - , "border-left-width" - , "border-bottom-style" - , "font-weight" - , "font-variant" - , "text-transform" - , "white-space" - , "TEXT_OVERLINE" - , "vertical-align" - , "BACKGROUND_POSITION_X" - , "border-left-style" - , "VISIBLE_FORMAT" - , "MASTER_PAGE" - , "orphans" - , "font-size" - , "font-style" - , "border-top-style" - , "page-break-before" - , "SHOW_IF_BLANK" - , "background-image" - , "BACKGROUND_POSITION_Y" - , "word-spacing" - , "background-attachment" - , "TEXT_UNDERLINE" - , "display" - , "font-family" - , "letter-spacing" - , "page-break-inside" - , "page-break-after" - - , "Rotation" - }; - - - private IStyle elemStyle; - private CSSValue[] propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ]; - private CSSEngine cssEngine; - - public BirtStyle( CSSEngine cssEngine ) { - this.cssEngine = cssEngine; - } - - public BirtStyle(IContent element) { - elemStyle = element.getComputedStyle(); - - if( elemStyle instanceof AbstractStyle ) { - cssEngine = ((AbstractStyle)elemStyle).getCSSEngine(); - } else { - throw new IllegalStateException( "Unable to obtain CSSEngine from elemStyle: " + elemStyle ); - } - - Float rotation = extractRotation(element); - if( rotation != null ) { - setFloat(TEXT_ROTATION, CSSPrimitiveValue.CSS_DEG, rotation); - } - - // Cache the element properties to avoid calculation cost many time - for( int i = 0; i < StyleManager.COMPARE_CSS_PROPERTIES.length; ++i ) { - int prop = StyleManager.COMPARE_CSS_PROPERTIES[ i ]; - propertyOverride[ prop ] = elemStyle.getProperty( prop ); - } - propertyOverride[ StyleConstants.STYLE_DATA_FORMAT ] = elemStyle.getProperty( StyleConstants.STYLE_DATA_FORMAT ); - for( int i = 0; i < FontManager.COMPARE_CSS_PROPERTIES.length; ++i ) { - int prop = FontManager.COMPARE_CSS_PROPERTIES[ i ]; - propertyOverride[ prop ] = elemStyle.getProperty( prop ); - } - - } - - private static Float extractRotation(IContent element) { - Object generatorObject = element.getGenerateBy(); - if( generatorObject instanceof ReportElementDesign ) { - ReportElementDesign generatorDesign = (ReportElementDesign)generatorObject; - Map userProps = generatorDesign.getUserProperties(); - if( userProps != null ) { - Expression rotationExpression = userProps.get( ExcelEmitter.ROTATION_PROP ); - if( rotationExpression != null ) { - try { - return Float.valueOf( rotationExpression.getScriptText() ); - } catch( Exception ex ) { - } - } - } - } - return null; - } - - public void setProperty( int propIndex, CSSValue newValue ) { - if( propertyOverride == null ) { - propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ]; - } - propertyOverride[ propIndex ] = newValue; - } - - public CSSValue getProperty( int propIndex ) { - return propertyOverride[ propIndex ]; - /* - if( ( propertyOverride != null ) - && ( propertyOverride[ propIndex ] != null ) ) { - return propertyOverride[ propIndex ]; - } - if( ( elemStyle != null ) && ( propIndex < StyleConstants.NUMBER_OF_STYLE ) ) { - return elemStyle.getProperty( propIndex ); - } else { - return null; - } - */ - } - - public void setFloat( int propIndex, short units, float newValue ) { - if( propertyOverride == null ) { - propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ]; - } - propertyOverride[ propIndex ] = new FloatValue( units, newValue ); - } - - public void parseString( int propIndex, String newValue ) { - if( propertyOverride == null ) { - propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ]; - } - - if( propIndex < StyleConstants.NUMBER_OF_STYLE ) { - propertyOverride[ propIndex ] = cssEngine.parsePropertyValue( propIndex , newValue ); - } else { - propertyOverride[ propIndex ] = new StringValue( StringValue.CSS_STRING, newValue); - } - } - - public String getString( int propIndex ) { - CSSValue value = getProperty( propIndex ); - if( value != null ) { - return value.getCssText(); - } else { - return null; - } - } - - @Override - protected BirtStyle clone() { - BirtStyle result = new BirtStyle(this.cssEngine); - - result.propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ]; - - for(int i = 0; i < NUMBER_OF_STYLES; ++i ) { - CSSValue value = getProperty( i ); - if( value != null ) { - if( value instanceof DataFormatValue ) { - value = StyleManagerUtils.cloneDataFormatValue((DataFormatValue)value); - } - - result.propertyOverride[ i ] = value; - } - } - - return result; - } - - private static final BitSet SPECIAL_OVERLAY_PROPERTIES = PrepareSpecialOverlayProperties(); - - private static BitSet PrepareSpecialOverlayProperties() { - BitSet result = new BitSet( BirtStyle.NUMBER_OF_STYLES ); - result.set( StyleConstants.STYLE_BACKGROUND_COLOR ); - result.set( StyleConstants.STYLE_BORDER_BOTTOM_STYLE ); - result.set( StyleConstants.STYLE_BORDER_BOTTOM_WIDTH ); - result.set( StyleConstants.STYLE_BORDER_BOTTOM_COLOR ); - result.set( StyleConstants.STYLE_BORDER_LEFT_STYLE ); - result.set( StyleConstants.STYLE_BORDER_LEFT_WIDTH ); - result.set( StyleConstants.STYLE_BORDER_LEFT_COLOR ); - result.set( StyleConstants.STYLE_BORDER_RIGHT_STYLE ); - result.set( StyleConstants.STYLE_BORDER_RIGHT_WIDTH ); - result.set( StyleConstants.STYLE_BORDER_RIGHT_COLOR ); - result.set( StyleConstants.STYLE_BORDER_TOP_STYLE ); - result.set( StyleConstants.STYLE_BORDER_TOP_WIDTH ); - result.set( StyleConstants.STYLE_BORDER_TOP_COLOR ); - result.set( StyleConstants.STYLE_VERTICAL_ALIGN ); - result.set( StyleConstants.STYLE_DATA_FORMAT ); - return result; - } - - private void overlayBorder( IStyle style, int propStyle, int propWidth, int propColour ) { - CSSValue ovlStyle = style.getProperty( propStyle ); - CSSValue ovlWidth = style.getProperty( propWidth ); - CSSValue ovlColour = style.getProperty( propColour ); - if( ( ovlStyle != null ) - && ( ovlWidth != null ) - && ( ovlColour != null ) - && ( ! CSSConstants.CSS_NONE_VALUE.equals( ovlStyle.getCssText() ) ) ) { - setProperty( propStyle, ovlStyle ); - setProperty( propWidth, ovlWidth ); - setProperty( propColour, ovlColour ); - } - } - - public void overlay( IContent element ) { - - // System.out.println( "overlay: Before - " + this.toString() ); - - IStyle style = element.getComputedStyle(); - for(int propIndex = 0; propIndex < StyleConstants.NUMBER_OF_STYLE; ++propIndex ) { - if( ! SPECIAL_OVERLAY_PROPERTIES.get(propIndex) ) { - CSSValue overlayValue = style.getProperty( propIndex ); - CSSValue localValue = getProperty( propIndex ); - if( ( overlayValue != null ) && ! overlayValue.equals( localValue ) ) { - setProperty( propIndex, overlayValue ); - } - } - } - - // Background colour, only overlay if not null and not transparent - CSSValue overlayBgColour = style.getProperty( StyleConstants.STYLE_BACKGROUND_COLOR ); - CSSValue localBgColour = getProperty( StyleConstants.STYLE_BACKGROUND_COLOR ); - if( ( overlayBgColour != null ) - && ( ! CSSConstants.CSS_TRANSPARENT_VALUE.equals( overlayBgColour.getCssText() ) ) - && ( ! overlayBgColour.equals( localBgColour ) ) ) { - setProperty( StyleConstants.STYLE_BACKGROUND_COLOR, overlayBgColour ); - } - - // Borders, only overlay if all three components are not null - and then overlay all three - overlayBorder( style, StyleConstants.STYLE_BORDER_BOTTOM_STYLE, StyleConstants.STYLE_BORDER_BOTTOM_WIDTH, StyleConstants.STYLE_BORDER_BOTTOM_COLOR ); - overlayBorder( style, StyleConstants.STYLE_BORDER_LEFT_STYLE, StyleConstants.STYLE_BORDER_LEFT_WIDTH, StyleConstants.STYLE_BORDER_LEFT_COLOR ); - overlayBorder( style, StyleConstants.STYLE_BORDER_RIGHT_STYLE, StyleConstants.STYLE_BORDER_RIGHT_WIDTH, StyleConstants.STYLE_BORDER_RIGHT_COLOR ); - overlayBorder( style, StyleConstants.STYLE_BORDER_TOP_STYLE, StyleConstants.STYLE_BORDER_TOP_WIDTH, StyleConstants.STYLE_BORDER_TOP_COLOR ); - - // Vertical align, not computed safely, so only check immediate style - CSSValue verticalAlign = element.getStyle().getProperty( StyleConstants.STYLE_VERTICAL_ALIGN ); - if( verticalAlign != null ) { - CSSValue localValue = getProperty( StyleConstants.STYLE_VERTICAL_ALIGN ); - if( ! verticalAlign.equals( localValue ) ) { - setProperty( StyleConstants.STYLE_VERTICAL_ALIGN, verticalAlign ); - } - } - - // Data format - CSSValue overlayDataFormat = style.getProperty( StyleConstants.STYLE_DATA_FORMAT ); - CSSValue localDataFormat = getProperty( StyleConstants.STYLE_DATA_FORMAT ); - if( ! StyleManagerUtils.dataFormatsEquivalent((DataFormatValue)overlayDataFormat, (DataFormatValue)localDataFormat) ) { - setProperty( StyleConstants.STYLE_DATA_FORMAT, StyleManagerUtils.cloneDataFormatValue((DataFormatValue)overlayDataFormat) ); - } - - // Rotation - Float rotation = extractRotation(element); - if( rotation != null ) { - setFloat(TEXT_ROTATION, CSSPrimitiveValue.CSS_DEG, rotation); - } - - // System.out.println( "overlay: After - " + this.toString() ); - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(); - for( int i = 0; i < NUMBER_OF_STYLES; ++i ) { - CSSValue val = getProperty( i ); - if( val != null ) { - try { - result.append(cssProperties[i]).append(':').append(val.getCssText()).append("; "); - } catch(Exception ex) { - result.append(cssProperties[i]).append(":{").append(ex.getMessage()).append("}; "); - } - } - } - return result.toString(); - } - - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + + +package uk.co.spudsoft.birt.emitters.excel; + +import java.util.BitSet; +import java.util.Map; + +import org.eclipse.birt.report.engine.content.IContent; +import org.eclipse.birt.report.engine.content.IStyle; +import org.eclipse.birt.report.engine.css.dom.AbstractStyle; +import org.eclipse.birt.report.engine.css.engine.CSSEngine; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.css.engine.value.DataFormatValue; +import org.eclipse.birt.report.engine.css.engine.value.FloatValue; +import org.eclipse.birt.report.engine.css.engine.value.StringValue; +import org.eclipse.birt.report.engine.css.engine.value.css.CSSConstants; +import org.eclipse.birt.report.engine.ir.Expression; +import org.eclipse.birt.report.engine.ir.ReportElementDesign; +import org.w3c.dom.css.CSSPrimitiveValue; +import org.w3c.dom.css.CSSValue; + +public class BirtStyle { + + public static final int NUMBER_OF_STYLES = StyleConstants.NUMBER_OF_STYLE + 1; + public static final int TEXT_ROTATION = StyleConstants.NUMBER_OF_STYLE; + + protected static final String cssProperties[] = { + "margin-left" + , "margin-right" + , "margin-top" + , "DATA_FORMAT" + , "border-right-color" + , "direction" + , "border-top-width" + , "padding-left" + , "border-right-width" + , "padding-bottom" + , "padding-top" + , "NUMBER_ALIGN" + , "padding-right" + , "CAN_SHRINK" + , "border-top-color" + , "background-repeat" + , "margin-bottom" + , "background-width" + , "background-height" + , "border-right-style" + , "border-bottom-color" + , "text-indent" + , "line-height" + , "border-bottom-width" + , "text-align" + , "background-color" + , "color" + , "overflow" + , "TEXT_LINETHROUGH" + , "border-left-color" + , "widows" + , "border-left-width" + , "border-bottom-style" + , "font-weight" + , "font-variant" + , "text-transform" + , "white-space" + , "TEXT_OVERLINE" + , "vertical-align" + , "BACKGROUND_POSITION_X" + , "border-left-style" + , "VISIBLE_FORMAT" + , "MASTER_PAGE" + , "orphans" + , "font-size" + , "font-style" + , "border-top-style" + , "page-break-before" + , "SHOW_IF_BLANK" + , "background-image" + , "BACKGROUND_POSITION_Y" + , "word-spacing" + , "background-attachment" + , "TEXT_UNDERLINE" + , "display" + , "font-family" + , "letter-spacing" + , "page-break-inside" + , "page-break-after" + + , "Rotation" + }; + + + private IStyle elemStyle; + private CSSValue[] propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ]; + private CSSEngine cssEngine; + + public BirtStyle( CSSEngine cssEngine ) { + this.cssEngine = cssEngine; + } + + public BirtStyle(IContent element) { + elemStyle = element.getComputedStyle(); + + if( elemStyle instanceof AbstractStyle ) { + cssEngine = ((AbstractStyle)elemStyle).getCSSEngine(); + } else { + throw new IllegalStateException( "Unable to obtain CSSEngine from elemStyle: " + elemStyle ); + } + + Float rotation = extractRotation(element); + if( rotation != null ) { + setFloat(TEXT_ROTATION, CSSPrimitiveValue.CSS_DEG, rotation); + } + + // Cache the element properties to avoid calculation cost many time + for( int i = 0; i < StyleManager.COMPARE_CSS_PROPERTIES.length; ++i ) { + int prop = StyleManager.COMPARE_CSS_PROPERTIES[ i ]; + propertyOverride[ prop ] = elemStyle.getProperty( prop ); + } + propertyOverride[ StyleConstants.STYLE_DATA_FORMAT ] = elemStyle.getProperty( StyleConstants.STYLE_DATA_FORMAT ); + for( int i = 0; i < FontManager.COMPARE_CSS_PROPERTIES.length; ++i ) { + int prop = FontManager.COMPARE_CSS_PROPERTIES[ i ]; + propertyOverride[ prop ] = elemStyle.getProperty( prop ); + } + + } + + private static Float extractRotation(IContent element) { + Object generatorObject = element.getGenerateBy(); + if( generatorObject instanceof ReportElementDesign ) { + ReportElementDesign generatorDesign = (ReportElementDesign)generatorObject; + Map userProps = generatorDesign.getUserProperties(); + if( userProps != null ) { + Expression rotationExpression = userProps.get( ExcelEmitter.ROTATION_PROP ); + if( rotationExpression != null ) { + try { + return Float.valueOf( rotationExpression.getScriptText() ); + } catch( Exception ex ) { + } + } + } + } + return null; + } + + public void setProperty( int propIndex, CSSValue newValue ) { + if( propertyOverride == null ) { + propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ]; + } + propertyOverride[ propIndex ] = newValue; + } + + public CSSValue getProperty( int propIndex ) { + return propertyOverride[ propIndex ]; + /* + if( ( propertyOverride != null ) + && ( propertyOverride[ propIndex ] != null ) ) { + return propertyOverride[ propIndex ]; + } + if( ( elemStyle != null ) && ( propIndex < StyleConstants.NUMBER_OF_STYLE ) ) { + return elemStyle.getProperty( propIndex ); + } else { + return null; + } + */ + } + + public void setFloat( int propIndex, short units, float newValue ) { + if( propertyOverride == null ) { + propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ]; + } + propertyOverride[ propIndex ] = new FloatValue( units, newValue ); + } + + public void parseString( int propIndex, String newValue ) { + if( propertyOverride == null ) { + propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ]; + } + + if( propIndex < StyleConstants.NUMBER_OF_STYLE ) { + propertyOverride[ propIndex ] = cssEngine.parsePropertyValue( propIndex , newValue ); + } else { + propertyOverride[ propIndex ] = new StringValue( StringValue.CSS_STRING, newValue); + } + } + + public String getString( int propIndex ) { + CSSValue value = getProperty( propIndex ); + if( value != null ) { + return value.getCssText(); + } else { + return null; + } + } + + @Override + protected BirtStyle clone() { + BirtStyle result = new BirtStyle(this.cssEngine); + + result.propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ]; + + for(int i = 0; i < NUMBER_OF_STYLES; ++i ) { + CSSValue value = getProperty( i ); + if( value != null ) { + if( value instanceof DataFormatValue ) { + value = StyleManagerUtils.cloneDataFormatValue((DataFormatValue)value); + } + + result.propertyOverride[ i ] = value; + } + } + + return result; + } + + private static final BitSet SPECIAL_OVERLAY_PROPERTIES = PrepareSpecialOverlayProperties(); + + private static BitSet PrepareSpecialOverlayProperties() { + BitSet result = new BitSet( BirtStyle.NUMBER_OF_STYLES ); + result.set( StyleConstants.STYLE_BACKGROUND_COLOR ); + result.set( StyleConstants.STYLE_BORDER_BOTTOM_STYLE ); + result.set( StyleConstants.STYLE_BORDER_BOTTOM_WIDTH ); + result.set( StyleConstants.STYLE_BORDER_BOTTOM_COLOR ); + result.set( StyleConstants.STYLE_BORDER_LEFT_STYLE ); + result.set( StyleConstants.STYLE_BORDER_LEFT_WIDTH ); + result.set( StyleConstants.STYLE_BORDER_LEFT_COLOR ); + result.set( StyleConstants.STYLE_BORDER_RIGHT_STYLE ); + result.set( StyleConstants.STYLE_BORDER_RIGHT_WIDTH ); + result.set( StyleConstants.STYLE_BORDER_RIGHT_COLOR ); + result.set( StyleConstants.STYLE_BORDER_TOP_STYLE ); + result.set( StyleConstants.STYLE_BORDER_TOP_WIDTH ); + result.set( StyleConstants.STYLE_BORDER_TOP_COLOR ); + result.set( StyleConstants.STYLE_VERTICAL_ALIGN ); + result.set( StyleConstants.STYLE_DATA_FORMAT ); + return result; + } + + private void overlayBorder( IStyle style, int propStyle, int propWidth, int propColour ) { + CSSValue ovlStyle = style.getProperty( propStyle ); + CSSValue ovlWidth = style.getProperty( propWidth ); + CSSValue ovlColour = style.getProperty( propColour ); + if( ( ovlStyle != null ) + && ( ovlWidth != null ) + && ( ovlColour != null ) + && ( ! CSSConstants.CSS_NONE_VALUE.equals( ovlStyle.getCssText() ) ) ) { + setProperty( propStyle, ovlStyle ); + setProperty( propWidth, ovlWidth ); + setProperty( propColour, ovlColour ); + } + } + + public void overlay( IContent element ) { + + // System.out.println( "overlay: Before - " + this.toString() ); + + IStyle style = element.getComputedStyle(); + for(int propIndex = 0; propIndex < StyleConstants.NUMBER_OF_STYLE; ++propIndex ) { + if( ! SPECIAL_OVERLAY_PROPERTIES.get(propIndex) ) { + CSSValue overlayValue = style.getProperty( propIndex ); + CSSValue localValue = getProperty( propIndex ); + if( ( overlayValue != null ) && ! overlayValue.equals( localValue ) ) { + setProperty( propIndex, overlayValue ); + } + } + } + + // Background colour, only overlay if not null and not transparent + CSSValue overlayBgColour = style.getProperty( StyleConstants.STYLE_BACKGROUND_COLOR ); + CSSValue localBgColour = getProperty( StyleConstants.STYLE_BACKGROUND_COLOR ); + if( ( overlayBgColour != null ) + && ( ! CSSConstants.CSS_TRANSPARENT_VALUE.equals( overlayBgColour.getCssText() ) ) + && ( ! overlayBgColour.equals( localBgColour ) ) ) { + setProperty( StyleConstants.STYLE_BACKGROUND_COLOR, overlayBgColour ); + } + + // Borders, only overlay if all three components are not null - and then overlay all three + overlayBorder( style, StyleConstants.STYLE_BORDER_BOTTOM_STYLE, StyleConstants.STYLE_BORDER_BOTTOM_WIDTH, StyleConstants.STYLE_BORDER_BOTTOM_COLOR ); + overlayBorder( style, StyleConstants.STYLE_BORDER_LEFT_STYLE, StyleConstants.STYLE_BORDER_LEFT_WIDTH, StyleConstants.STYLE_BORDER_LEFT_COLOR ); + overlayBorder( style, StyleConstants.STYLE_BORDER_RIGHT_STYLE, StyleConstants.STYLE_BORDER_RIGHT_WIDTH, StyleConstants.STYLE_BORDER_RIGHT_COLOR ); + overlayBorder( style, StyleConstants.STYLE_BORDER_TOP_STYLE, StyleConstants.STYLE_BORDER_TOP_WIDTH, StyleConstants.STYLE_BORDER_TOP_COLOR ); + + // Vertical align, not computed safely, so only check immediate style + CSSValue verticalAlign = element.getStyle().getProperty( StyleConstants.STYLE_VERTICAL_ALIGN ); + if( verticalAlign != null ) { + CSSValue localValue = getProperty( StyleConstants.STYLE_VERTICAL_ALIGN ); + if( ! verticalAlign.equals( localValue ) ) { + setProperty( StyleConstants.STYLE_VERTICAL_ALIGN, verticalAlign ); + } + } + + // Data format + CSSValue overlayDataFormat = style.getProperty( StyleConstants.STYLE_DATA_FORMAT ); + CSSValue localDataFormat = getProperty( StyleConstants.STYLE_DATA_FORMAT ); + if( ! StyleManagerUtils.dataFormatsEquivalent((DataFormatValue)overlayDataFormat, (DataFormatValue)localDataFormat) ) { + setProperty( StyleConstants.STYLE_DATA_FORMAT, StyleManagerUtils.cloneDataFormatValue((DataFormatValue)overlayDataFormat) ); + } + + // Rotation + Float rotation = extractRotation(element); + if( rotation != null ) { + setFloat(TEXT_ROTATION, CSSPrimitiveValue.CSS_DEG, rotation); + } + + // System.out.println( "overlay: After - " + this.toString() ); + } + + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + for( int i = 0; i < NUMBER_OF_STYLES; ++i ) { + CSSValue val = getProperty( i ); + if( val != null ) { + try { + result.append(cssProperties[i]).append(':').append(val.getCssText()).append("; "); + } catch(Exception ex) { + result.append(cssProperties[i]).append(":{").append(ex.getMessage()).append("}; "); + } + } + } + return result.toString(); + } + + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/CellImage.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/CellImage.java index 2c1bce52f..52e05af10 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/CellImage.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/CellImage.java @@ -1,45 +1,45 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - - -package uk.co.spudsoft.birt.emitters.excel; - -import org.eclipse.birt.report.engine.content.IImageContent; - -/** - *

- * CellImage is used to cache all the required data for inserting images so that they can be - * processed after all other spreadsheet contents has been inserted. - *

- * Processing images after all other spreadsheet contents means that the images will be unaffected - * by any column resizing that may be required. - * Images usually cause row resizing (the emitter never allows an image to spread onto multiple rows), - * but never cause column resizing. - *

- * - * @author Jim Talbut - * - */ -public class CellImage { - public Coordinate location; - public int imageIdx; - public IImageContent image; - public boolean spanColumns; - public CellImage(Coordinate location, int imageIdx, IImageContent image, boolean spanColumns) { - this.location = location; - this.imageIdx = imageIdx; - this.image = image; - this.spanColumns = spanColumns; - } -} - +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + + +package uk.co.spudsoft.birt.emitters.excel; + +import org.eclipse.birt.report.engine.content.IImageContent; + +/** + *

+ * CellImage is used to cache all the required data for inserting images so that they can be + * processed after all other spreadsheet contents has been inserted. + *

+ * Processing images after all other spreadsheet contents means that the images will be unaffected + * by any column resizing that may be required. + * Images usually cause row resizing (the emitter never allows an image to spread onto multiple rows), + * but never cause column resizing. + *

+ * + * @author Jim Talbut + * + */ +public class CellImage { + public Coordinate location; + public int imageIdx; + public IImageContent image; + public boolean spanColumns; + public CellImage(Coordinate location, int imageIdx, IImageContent image, boolean spanColumns) { + this.location = location; + this.imageIdx = imageIdx; + this.image = image; + this.spanColumns = spanColumns; + } +} + diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/ClientAnchorConversions.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/ClientAnchorConversions.java index ecfccfbca..203031b9b 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/ClientAnchorConversions.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/ClientAnchorConversions.java @@ -1,88 +1,88 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - - -package uk.co.spudsoft.birt.emitters.excel; - -/** - *

- * ClientAnchorConversions provides a small set of functions for converting the values used with ClientAnchors. - *

- * This class is very heavily based on the ConvertImageUnits class from the POI examples. - * The differences between that class and this are: - *

    - *
  1. This class contains only the functionality that I need.
  2. - *
  3. This class contains no public static values, only methods.
  4. - *
- *

- * @author Jim Talbut - * - */ -public class ClientAnchorConversions { - - // Constants that defines how many pixels and points there are in a - // millimetre. These values are required for the conversion algorithm. - private static final double PIXELS_PER_MILLIMETRES = 3.78; // MB - private static final short EXCEL_COLUMN_WIDTH_FACTOR = 256; - private static final int UNIT_OFFSET_LENGTH = 7; - private static final int[] UNIT_OFFSET_MAP = new int[] { 0, 36, 73, 109, 146, 182, 219 }; - - /** - * Convert a measure in column width units (1/256th of a character) to a measure in millimetres. - *
- * Makes assumptions about font size and relevant DPI. - * @param widthUnits - * The size in width units. - * The size in millimetres. - */ - public static double widthUnits2Millimetres( 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 / PIXELS_PER_MILLIMETRES; - } - - /** - * Convert a measure of millimetres to width units. - * @param millimetres - * The size in millimetres. - * The size in width units. - */ - public static int millimetres2WidthUnits(double millimetres) { - int pixels = (int)(millimetres * PIXELS_PER_MILLIMETRES); - short widthUnits = (short) (EXCEL_COLUMN_WIDTH_FACTOR * (pixels / UNIT_OFFSET_LENGTH)); - widthUnits += UNIT_OFFSET_MAP[(pixels % UNIT_OFFSET_LENGTH)]; - return widthUnits; - } - - /** - * Convert a measure of pixels to millimetres (for column widths). - * @param pixels - * The size in pixels. - * The size in millimetres. - */ - public static double pixels2Millimetres( double pixels ) { - return pixels / PIXELS_PER_MILLIMETRES; - } - - /** - * Convert a measure of millimetres to pixels (for column widths) - * @param millimetres - * The size in millimetres. - * The size in pixels. - */ - public static int millimetres2Pixels( double millimetres ) { - return (int)(millimetres * PIXELS_PER_MILLIMETRES ); - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + + +package uk.co.spudsoft.birt.emitters.excel; + +/** + *

+ * ClientAnchorConversions provides a small set of functions for converting the values used with ClientAnchors. + *

+ * This class is very heavily based on the ConvertImageUnits class from the POI examples. + * The differences between that class and this are: + *

    + *
  1. This class contains only the functionality that I need.
  2. + *
  3. This class contains no public static values, only methods.
  4. + *
+ *

+ * @author Jim Talbut + * + */ +public class ClientAnchorConversions { + + // Constants that defines how many pixels and points there are in a + // millimetre. These values are required for the conversion algorithm. + private static final double PIXELS_PER_MILLIMETRES = 3.78; // MB + private static final short EXCEL_COLUMN_WIDTH_FACTOR = 256; + private static final int UNIT_OFFSET_LENGTH = 7; + private static final int[] UNIT_OFFSET_MAP = new int[] { 0, 36, 73, 109, 146, 182, 219 }; + + /** + * Convert a measure in column width units (1/256th of a character) to a measure in millimetres. + *
+ * Makes assumptions about font size and relevant DPI. + * @param widthUnits + * The size in width units. + * The size in millimetres. + */ + public static double widthUnits2Millimetres( 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 / PIXELS_PER_MILLIMETRES; + } + + /** + * Convert a measure of millimetres to width units. + * @param millimetres + * The size in millimetres. + * The size in width units. + */ + public static int millimetres2WidthUnits(double millimetres) { + int pixels = (int)(millimetres * PIXELS_PER_MILLIMETRES); + short widthUnits = (short) (EXCEL_COLUMN_WIDTH_FACTOR * (pixels / UNIT_OFFSET_LENGTH)); + widthUnits += UNIT_OFFSET_MAP[(pixels % UNIT_OFFSET_LENGTH)]; + return widthUnits; + } + + /** + * Convert a measure of pixels to millimetres (for column widths). + * @param pixels + * The size in pixels. + * The size in millimetres. + */ + public static double pixels2Millimetres( double pixels ) { + return pixels / PIXELS_PER_MILLIMETRES; + } + + /** + * Convert a measure of millimetres to pixels (for column widths) + * @param millimetres + * The size in millimetres. + * The size in pixels. + */ + public static int millimetres2Pixels( double millimetres ) { + return (int)(millimetres * PIXELS_PER_MILLIMETRES ); + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/Coordinate.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/Coordinate.java index 0b333c336..e8f4fbe8e 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/Coordinate.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/Coordinate.java @@ -1,74 +1,74 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - - -package uk.co.spudsoft.birt.emitters.excel; - -public class Coordinate { - - private int row; - private int col; - - public Coordinate(int row, int col) { - super(); - this.row = row; - this.col = col; - } - - public int getRow() { - return row; - } - - public void setRow(int row) { - this.row = row; - } - - public int getCol() { - return col; - } - - public void setCol(int col) { - this.col = col; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + row; - result = prime * result + col; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Coordinate other = (Coordinate) obj; - if (row != other.row) - return false; - if (col != other.col) - return false; - return true; - } - - @Override - public String toString() { - return "Coordinate [row=" + row + ", col=" + col + "]"; - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + + +package uk.co.spudsoft.birt.emitters.excel; + +public class Coordinate { + + private int row; + private int col; + + public Coordinate(int row, int col) { + super(); + this.row = row; + this.col = col; + } + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getCol() { + return col; + } + + public void setCol(int col) { + this.col = col; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + row; + result = prime * result + col; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Coordinate other = (Coordinate) obj; + if (row != other.row) + return false; + if (col != other.col) + return false; + return true; + } + + @Override + public String toString() { + return "Coordinate [row=" + row + ", col=" + col + "]"; + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/DateFormatConverter.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/DateFormatConverter.java index 5b7b74f1b..300f15344 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/DateFormatConverter.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/DateFormatConverter.java @@ -1,399 +1,399 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - - -package uk.co.spudsoft.birt.emitters.excel; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -public class DateFormatConverter { - - public static class DateFormatTokenizer { - String format; - int pos; - - public DateFormatTokenizer(String format) { - this.format = format; - } - - public String getNextToken() { - if( pos >= format.length() ) { - return null; - } - int subStart = pos; - char curChar = format.charAt(pos); - ++pos; - if( curChar == '\'' ) { - while( ( pos < format.length() ) && ( ( curChar = format.charAt(pos) ) != '\'' ) ) { - ++pos; - } - if( pos < format.length() ) { - ++pos; - } - } else { - char activeChar = curChar; - while( ( pos < format.length() ) && ( ( curChar = format.charAt(pos) ) == activeChar ) ) { - ++pos; - } - } - return format.substring(subStart,pos); - } - - public static String[] tokenize( String format ) { - List result = new ArrayList(); - - DateFormatTokenizer tokenizer = new DateFormatTokenizer(format); - String token; - while( ( token = tokenizer.getNextToken() ) != null ) { - result.add(token); - } - - return result.toArray(new String[0]); - } - - public String toString() { - StringBuilder result = new StringBuilder(); - - DateFormatTokenizer tokenizer = new DateFormatTokenizer(format); - String token; - while( ( token = tokenizer.getNextToken() ) != null ) { - if( result.length() > 0 ) { - result.append( ", " ); - } - result.append("[").append(token).append("]"); - } - - return result.toString(); - } - } - - private static Map tokenConversions = prepareTokenConversions(); - private static Map localePrefixes = prepareLocalePrefixes(); - - private static Map prepareTokenConversions() { - Map result = new HashMap(); - - result.put( "EEEE", "dddd" ); - result.put( "EEE", "ddd" ); - result.put( "EE", "ddd" ); - result.put( "E", "d" ); - result.put( "Z", "" ); - result.put( "z", "" ); - result.put( "a", "am/pm" ); - result.put( "A", "AM/PM" ); - result.put( "K", "H" ); - result.put( "KK", "HH" ); - result.put( "k", "h" ); - result.put( "kk", "hh" ); - result.put( "S", "0" ); - result.put( "SS", "00" ); - result.put( "SSS", "000" ); - - return result; - } - - private static Map prepareLocalePrefixes() { - Map result = new HashMap(); - - result.put( "af", "[$-1010436]" ); - result.put( "am", "[$-101045E]" ); - result.put( "ar_ae", "[$-1013801]" ); - result.put( "ar_bh", "[$-1013C01]" ); - result.put( "ar_dz", "[$-1011401]" ); - result.put( "ar_eg", "[$-1010C01]" ); - result.put( "ar_iq", "[$-1010801]" ); - result.put( "ar_jo", "[$-1012C01]" ); - result.put( "ar_kw", "[$-1013401]" ); - result.put( "ar_lb", "[$-1013001]" ); - result.put( "ar_ly", "[$-1011001]" ); - result.put( "ar_ma", "[$-1011801]" ); - result.put( "ar_om", "[$-1012001]" ); - result.put( "ar_qa", "[$-1014001]" ); - result.put( "ar_sa", "[$-1010401]" ); - result.put( "ar_sy", "[$-1012801]" ); - result.put( "ar_tn", "[$-1011C01]" ); - result.put( "ar_ye", "[$-1012401]" ); - result.put( "as", "[$-101044D]" ); - result.put( "az_az", "[$-101082C]" ); - result.put( "az_az", "[$-101042C]" ); - result.put( "be", "[$-1010423]" ); - result.put( "bg", "[$-1010402]" ); - result.put( "bn", "[$-1010845]" ); - result.put( "bn", "[$-1010445]" ); - result.put( "bo", "[$-1010451]" ); - result.put( "bs", "[$-101141A]" ); - result.put( "ca", "[$-1010403]" ); - result.put( "cs", "[$-1010405]" ); - result.put( "cy", "[$-1010452]" ); - result.put( "da", "[$-1010406]" ); - result.put( "de_at", "[$-1010C07]" ); - result.put( "de_ch", "[$-1010807]" ); - result.put( "de_de", "[$-1010407]" ); - result.put( "de_li", "[$-1011407]" ); - result.put( "de_lu", "[$-1011007]" ); - result.put( "dv", "[$-1010465]" ); - result.put( "el", "[$-1010408]" ); - result.put( "en_au", "[$-1010C09]" ); - result.put( "en_bz", "[$-1012809]" ); - result.put( "en_ca", "[$-1011009]" ); - result.put( "en_cb", "[$-1012409]" ); - result.put( "en_gb", "[$-1010809]" ); - result.put( "en_ie", "[$-1011809]" ); - result.put( "en_in", "[$-1014009]" ); - result.put( "en_jm", "[$-1012009]" ); - result.put( "en_nz", "[$-1011409]" ); - result.put( "en_ph", "[$-1013409]" ); - result.put( "en_tt", "[$-1012C09]" ); - result.put( "en_us", "[$-1010409]" ); - result.put( "en_za", "[$-1011C09]" ); - result.put( "es_ar", "[$-1012C0A]" ); - result.put( "es_bo", "[$-101400A]" ); - result.put( "es_cl", "[$-101340A]" ); - result.put( "es_co", "[$-101240A]" ); - result.put( "es_cr", "[$-101140A]" ); - result.put( "es_do", "[$-1011C0A]" ); - result.put( "es_ec", "[$-101300A]" ); - result.put( "es_es", "[$-101040A]" ); - result.put( "es_gt", "[$-101100A]" ); - result.put( "es_hn", "[$-101480A]" ); - result.put( "es_mx", "[$-101080A]" ); - result.put( "es_ni", "[$-1014C0A]" ); - result.put( "es_pa", "[$-101180A]" ); - result.put( "es_pe", "[$-101280A]" ); - result.put( "es_pr", "[$-101500A]" ); - result.put( "es_py", "[$-1013C0A]" ); - result.put( "es_sv", "[$-101440A]" ); - result.put( "es_uy", "[$-101380A]" ); - result.put( "es_ve", "[$-101200A]" ); - result.put( "et", "[$-1010425]" ); - result.put( "eu", "[$-101042D]" ); - result.put( "fa", "[$-1010429]" ); - result.put( "fi", "[$-101040B]" ); - result.put( "fo", "[$-1010438]" ); - result.put( "fr_be", "[$-101080C]" ); - result.put( "fr_ca", "[$-1010C0C]" ); - result.put( "fr_ch", "[$-101100C]" ); - result.put( "fr_fr", "[$-101040C]" ); - result.put( "fr_lu", "[$-101140C]" ); - result.put( "gd", "[$-101043C]" ); - result.put( "gd_ie", "[$-101083C]" ); - result.put( "gn", "[$-1010474]" ); - result.put( "gu", "[$-1010447]" ); - result.put( "he", "[$-101040D]" ); - result.put( "hi", "[$-1010439]" ); - result.put( "hr", "[$-101041A]" ); - result.put( "hu", "[$-101040E]" ); - result.put( "hy", "[$-101042B]" ); - result.put( "id", "[$-1010421]" ); - result.put( "is", "[$-101040F]" ); - result.put( "it_ch", "[$-1010810]" ); - result.put( "it_it", "[$-1010410]" ); - result.put( "ja", "[$-1010411]" ); - result.put( "kk", "[$-101043F]" ); - result.put( "km", "[$-1010453]" ); - result.put( "kn", "[$-101044B]" ); - result.put( "ko", "[$-1010412]" ); - result.put( "ks", "[$-1010460]" ); - result.put( "la", "[$-1010476]" ); - result.put( "lo", "[$-1010454]" ); - result.put( "lt", "[$-1010427]" ); - result.put( "lv", "[$-1010426]" ); - result.put( "mi", "[$-1010481]" ); - result.put( "mk", "[$-101042F]" ); - result.put( "ml", "[$-101044C]" ); - result.put( "mn", "[$-1010850]" ); - result.put( "mn", "[$-1010450]" ); - result.put( "mr", "[$-101044E]" ); - result.put( "ms_bn", "[$-101083E]" ); - result.put( "ms_my", "[$-101043E]" ); - result.put( "mt", "[$-101043A]" ); - result.put( "my", "[$-1010455]" ); - result.put( "ne", "[$-1010461]" ); - result.put( "nl_be", "[$-1010813]" ); - result.put( "nl_nl", "[$-1010413]" ); - result.put( "no_no", "[$-1010814]" ); - result.put( "or", "[$-1010448]" ); - result.put( "pa", "[$-1010446]" ); - result.put( "pl", "[$-1010415]" ); - result.put( "pt_br", "[$-1010416]" ); - result.put( "pt_pt", "[$-1010816]" ); - result.put( "rm", "[$-1010417]" ); - result.put( "ro", "[$-1010418]" ); - result.put( "ro_mo", "[$-1010818]" ); - result.put( "ru", "[$-1010419]" ); - result.put( "ru_mo", "[$-1010819]" ); - result.put( "sa", "[$-101044F]" ); - result.put( "sb", "[$-101042E]" ); - result.put( "sd", "[$-1010459]" ); - result.put( "si", "[$-101045B]" ); - result.put( "sk", "[$-101041B]" ); - result.put( "sl", "[$-1010424]" ); - result.put( "so", "[$-1010477]" ); - result.put( "sq", "[$-101041C]" ); - result.put( "sr_sp", "[$-1010C1A]" ); - result.put( "sr_sp", "[$-101081A]" ); - result.put( "sv_fi", "[$-101081D]" ); - result.put( "sv_se", "[$-101041D]" ); - result.put( "sw", "[$-1010441]" ); - result.put( "ta", "[$-1010449]" ); - result.put( "te", "[$-101044A]" ); - result.put( "tg", "[$-1010428]" ); - result.put( "th", "[$-101041E]" ); - result.put( "tk", "[$-1010442]" ); - result.put( "tn", "[$-1010432]" ); - result.put( "tr", "[$-101041F]" ); - result.put( "ts", "[$-1010431]" ); - result.put( "tt", "[$-1010444]" ); - result.put( "uk", "[$-1010422]" ); - result.put( "ur", "[$-1010420]" ); - result.put( "UTF_8", "[$-1010000]" ); - result.put( "uz_uz", "[$-1010843]" ); - result.put( "uz_uz", "[$-1010443]" ); - result.put( "vi", "[$-101042A]" ); - result.put( "xh", "[$-1010434]" ); - result.put( "yi", "[$-101043D]" ); - result.put( "zh_cn", "[$-1010804]" ); - result.put( "zh_hk", "[$-1010C04]" ); - result.put( "zh_mo", "[$-1011404]" ); - result.put( "zh_sg", "[$-1011004]" ); - result.put( "zh_tw", "[$-1010404]" ); - result.put( "zu", "[$-1010435]" ); - - result.put( "ar", "[$-1010401]" ); - result.put( "bn", "[$-1010845]" ); - result.put( "de", "[$-1010407]" ); - result.put( "en", "[$-1010409]" ); - result.put( "es", "[$-101040A]" ); - result.put( "fr", "[$-101040C]" ); - result.put( "it", "[$-1010410]" ); - result.put( "ms", "[$-101043E]" ); - result.put( "nl", "[$-1010413]" ); - result.put( "nn", "[$-1010814]" ); - result.put( "no", "[$-1010414]" ); - result.put( "pt", "[$-1010816]" ); - result.put( "sr", "[$-1010C1A]" ); - result.put( "sv", "[$-101041D]" ); - result.put( "uz", "[$-1010843]" ); - result.put( "zh", "[$-1010804]" ); - - result.put( "ga", "[$-101043C]" ); - result.put( "ga_ie", "[$-101083C]" ); - result.put( "in", "[$-1010421]" ); - result.put( "iw", "[$-101040D]" ); - - return result; - } - - public static String getPrefixForLocale( Locale locale ) { - String localeString = locale.toString().toLowerCase(); - String result = localePrefixes.get( localeString ); - if( result == null ) { - result = localePrefixes.get( localeString.substring( 0, 2 ) ); - if( result == null ) { - // Locale parentLocale = new Locale(localeString.substring( 0, 2 )); - // System.out.println( "Unable to find prefix for " + locale + "(" + locale.getDisplayName() + ") or " - // + localeString.substring( 0, 2 ) + "(" + parentLocale.getDisplayName() + ")" ); - return ""; - } - } - return result; - } - - public static String convert( Locale locale, String format ) { - StringBuilder result = new StringBuilder(); - - result.append(getPrefixForLocale(locale)); - DateFormatTokenizer tokenizer = new DateFormatTokenizer(format); - String token; - while( ( token = tokenizer.getNextToken() ) != null ) { - if( token.startsWith("'") ) { - result.append( token.replaceAll("'", "\"") ); - } else if( ! Character.isLetter( token.charAt( 0 ) ) ) { - result.append( token ); - } else { - // It's a code, translate it if necessary - String mappedToken = tokenConversions.get(token); - result.append( mappedToken == null ? token : mappedToken ); - } - } - - return result.toString().trim(); - } - - public static String getJavaDatePattern(int style, Locale locale) { - DateFormat df = DateFormat.getDateInstance(style, locale); - if( df instanceof SimpleDateFormat ) { - return ((SimpleDateFormat)df).toPattern(); - } else { - switch( style ) { - case DateFormat.SHORT: - return "d/MM/yy"; - case DateFormat.MEDIUM: - return "MMM d, yyyy"; - case DateFormat.LONG: - return "MMMM d, yyyy"; - case DateFormat.FULL: - return "dddd, MMMM d, yyyy"; - default: - return "MMM d, yyyy"; - } - } - } - - public static String getJavaTimePattern(int style, Locale locale) { - DateFormat df = DateFormat.getTimeInstance(style, locale); - if( df instanceof SimpleDateFormat ) { - return ((SimpleDateFormat)df).toPattern(); - } else { - switch( style ) { - case DateFormat.SHORT: - return "h:mm a"; - case DateFormat.MEDIUM: - return "h:mm:ss a"; - case DateFormat.LONG: - return "h:mm:ss a"; - case DateFormat.FULL: - return "h:mm:ss a"; - default: - return "h:mm:ss a"; - } - } - } - - public static String getJavaDateTimePattern(int style, Locale locale) { - DateFormat df = DateFormat.getDateTimeInstance(style, style, locale); - if( df instanceof SimpleDateFormat ) { - return ((SimpleDateFormat)df).toPattern(); - } else { - switch( style ) { - case DateFormat.SHORT: - return "M/d/yy h:mm a"; - case DateFormat.MEDIUM: - return "MMM d, yyyy h:mm:ss a"; - case DateFormat.LONG: - return "MMMM d, yyyy h:mm:ss a"; - case DateFormat.FULL: - return "dddd, MMMM d, yyyy h:mm:ss a"; - default: - return "MMM d, yyyy h:mm:ss a"; - } - } - } - +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + + +package uk.co.spudsoft.birt.emitters.excel; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +public class DateFormatConverter { + + public static class DateFormatTokenizer { + String format; + int pos; + + public DateFormatTokenizer(String format) { + this.format = format; + } + + public String getNextToken() { + if( pos >= format.length() ) { + return null; + } + int subStart = pos; + char curChar = format.charAt(pos); + ++pos; + if( curChar == '\'' ) { + while( ( pos < format.length() ) && ( ( curChar = format.charAt(pos) ) != '\'' ) ) { + ++pos; + } + if( pos < format.length() ) { + ++pos; + } + } else { + char activeChar = curChar; + while( ( pos < format.length() ) && ( ( curChar = format.charAt(pos) ) == activeChar ) ) { + ++pos; + } + } + return format.substring(subStart,pos); + } + + public static String[] tokenize( String format ) { + List result = new ArrayList(); + + DateFormatTokenizer tokenizer = new DateFormatTokenizer(format); + String token; + while( ( token = tokenizer.getNextToken() ) != null ) { + result.add(token); + } + + return result.toArray(new String[0]); + } + + public String toString() { + StringBuilder result = new StringBuilder(); + + DateFormatTokenizer tokenizer = new DateFormatTokenizer(format); + String token; + while( ( token = tokenizer.getNextToken() ) != null ) { + if( result.length() > 0 ) { + result.append( ", " ); + } + result.append("[").append(token).append("]"); + } + + return result.toString(); + } + } + + private static Map tokenConversions = prepareTokenConversions(); + private static Map localePrefixes = prepareLocalePrefixes(); + + private static Map prepareTokenConversions() { + Map result = new HashMap(); + + result.put( "EEEE", "dddd" ); + result.put( "EEE", "ddd" ); + result.put( "EE", "ddd" ); + result.put( "E", "d" ); + result.put( "Z", "" ); + result.put( "z", "" ); + result.put( "a", "am/pm" ); + result.put( "A", "AM/PM" ); + result.put( "K", "H" ); + result.put( "KK", "HH" ); + result.put( "k", "h" ); + result.put( "kk", "hh" ); + result.put( "S", "0" ); + result.put( "SS", "00" ); + result.put( "SSS", "000" ); + + return result; + } + + private static Map prepareLocalePrefixes() { + Map result = new HashMap(); + + result.put( "af", "[$-1010436]" ); + result.put( "am", "[$-101045E]" ); + result.put( "ar_ae", "[$-1013801]" ); + result.put( "ar_bh", "[$-1013C01]" ); + result.put( "ar_dz", "[$-1011401]" ); + result.put( "ar_eg", "[$-1010C01]" ); + result.put( "ar_iq", "[$-1010801]" ); + result.put( "ar_jo", "[$-1012C01]" ); + result.put( "ar_kw", "[$-1013401]" ); + result.put( "ar_lb", "[$-1013001]" ); + result.put( "ar_ly", "[$-1011001]" ); + result.put( "ar_ma", "[$-1011801]" ); + result.put( "ar_om", "[$-1012001]" ); + result.put( "ar_qa", "[$-1014001]" ); + result.put( "ar_sa", "[$-1010401]" ); + result.put( "ar_sy", "[$-1012801]" ); + result.put( "ar_tn", "[$-1011C01]" ); + result.put( "ar_ye", "[$-1012401]" ); + result.put( "as", "[$-101044D]" ); + result.put( "az_az", "[$-101082C]" ); + result.put( "az_az", "[$-101042C]" ); + result.put( "be", "[$-1010423]" ); + result.put( "bg", "[$-1010402]" ); + result.put( "bn", "[$-1010845]" ); + result.put( "bn", "[$-1010445]" ); + result.put( "bo", "[$-1010451]" ); + result.put( "bs", "[$-101141A]" ); + result.put( "ca", "[$-1010403]" ); + result.put( "cs", "[$-1010405]" ); + result.put( "cy", "[$-1010452]" ); + result.put( "da", "[$-1010406]" ); + result.put( "de_at", "[$-1010C07]" ); + result.put( "de_ch", "[$-1010807]" ); + result.put( "de_de", "[$-1010407]" ); + result.put( "de_li", "[$-1011407]" ); + result.put( "de_lu", "[$-1011007]" ); + result.put( "dv", "[$-1010465]" ); + result.put( "el", "[$-1010408]" ); + result.put( "en_au", "[$-1010C09]" ); + result.put( "en_bz", "[$-1012809]" ); + result.put( "en_ca", "[$-1011009]" ); + result.put( "en_cb", "[$-1012409]" ); + result.put( "en_gb", "[$-1010809]" ); + result.put( "en_ie", "[$-1011809]" ); + result.put( "en_in", "[$-1014009]" ); + result.put( "en_jm", "[$-1012009]" ); + result.put( "en_nz", "[$-1011409]" ); + result.put( "en_ph", "[$-1013409]" ); + result.put( "en_tt", "[$-1012C09]" ); + result.put( "en_us", "[$-1010409]" ); + result.put( "en_za", "[$-1011C09]" ); + result.put( "es_ar", "[$-1012C0A]" ); + result.put( "es_bo", "[$-101400A]" ); + result.put( "es_cl", "[$-101340A]" ); + result.put( "es_co", "[$-101240A]" ); + result.put( "es_cr", "[$-101140A]" ); + result.put( "es_do", "[$-1011C0A]" ); + result.put( "es_ec", "[$-101300A]" ); + result.put( "es_es", "[$-101040A]" ); + result.put( "es_gt", "[$-101100A]" ); + result.put( "es_hn", "[$-101480A]" ); + result.put( "es_mx", "[$-101080A]" ); + result.put( "es_ni", "[$-1014C0A]" ); + result.put( "es_pa", "[$-101180A]" ); + result.put( "es_pe", "[$-101280A]" ); + result.put( "es_pr", "[$-101500A]" ); + result.put( "es_py", "[$-1013C0A]" ); + result.put( "es_sv", "[$-101440A]" ); + result.put( "es_uy", "[$-101380A]" ); + result.put( "es_ve", "[$-101200A]" ); + result.put( "et", "[$-1010425]" ); + result.put( "eu", "[$-101042D]" ); + result.put( "fa", "[$-1010429]" ); + result.put( "fi", "[$-101040B]" ); + result.put( "fo", "[$-1010438]" ); + result.put( "fr_be", "[$-101080C]" ); + result.put( "fr_ca", "[$-1010C0C]" ); + result.put( "fr_ch", "[$-101100C]" ); + result.put( "fr_fr", "[$-101040C]" ); + result.put( "fr_lu", "[$-101140C]" ); + result.put( "gd", "[$-101043C]" ); + result.put( "gd_ie", "[$-101083C]" ); + result.put( "gn", "[$-1010474]" ); + result.put( "gu", "[$-1010447]" ); + result.put( "he", "[$-101040D]" ); + result.put( "hi", "[$-1010439]" ); + result.put( "hr", "[$-101041A]" ); + result.put( "hu", "[$-101040E]" ); + result.put( "hy", "[$-101042B]" ); + result.put( "id", "[$-1010421]" ); + result.put( "is", "[$-101040F]" ); + result.put( "it_ch", "[$-1010810]" ); + result.put( "it_it", "[$-1010410]" ); + result.put( "ja", "[$-1010411]" ); + result.put( "kk", "[$-101043F]" ); + result.put( "km", "[$-1010453]" ); + result.put( "kn", "[$-101044B]" ); + result.put( "ko", "[$-1010412]" ); + result.put( "ks", "[$-1010460]" ); + result.put( "la", "[$-1010476]" ); + result.put( "lo", "[$-1010454]" ); + result.put( "lt", "[$-1010427]" ); + result.put( "lv", "[$-1010426]" ); + result.put( "mi", "[$-1010481]" ); + result.put( "mk", "[$-101042F]" ); + result.put( "ml", "[$-101044C]" ); + result.put( "mn", "[$-1010850]" ); + result.put( "mn", "[$-1010450]" ); + result.put( "mr", "[$-101044E]" ); + result.put( "ms_bn", "[$-101083E]" ); + result.put( "ms_my", "[$-101043E]" ); + result.put( "mt", "[$-101043A]" ); + result.put( "my", "[$-1010455]" ); + result.put( "ne", "[$-1010461]" ); + result.put( "nl_be", "[$-1010813]" ); + result.put( "nl_nl", "[$-1010413]" ); + result.put( "no_no", "[$-1010814]" ); + result.put( "or", "[$-1010448]" ); + result.put( "pa", "[$-1010446]" ); + result.put( "pl", "[$-1010415]" ); + result.put( "pt_br", "[$-1010416]" ); + result.put( "pt_pt", "[$-1010816]" ); + result.put( "rm", "[$-1010417]" ); + result.put( "ro", "[$-1010418]" ); + result.put( "ro_mo", "[$-1010818]" ); + result.put( "ru", "[$-1010419]" ); + result.put( "ru_mo", "[$-1010819]" ); + result.put( "sa", "[$-101044F]" ); + result.put( "sb", "[$-101042E]" ); + result.put( "sd", "[$-1010459]" ); + result.put( "si", "[$-101045B]" ); + result.put( "sk", "[$-101041B]" ); + result.put( "sl", "[$-1010424]" ); + result.put( "so", "[$-1010477]" ); + result.put( "sq", "[$-101041C]" ); + result.put( "sr_sp", "[$-1010C1A]" ); + result.put( "sr_sp", "[$-101081A]" ); + result.put( "sv_fi", "[$-101081D]" ); + result.put( "sv_se", "[$-101041D]" ); + result.put( "sw", "[$-1010441]" ); + result.put( "ta", "[$-1010449]" ); + result.put( "te", "[$-101044A]" ); + result.put( "tg", "[$-1010428]" ); + result.put( "th", "[$-101041E]" ); + result.put( "tk", "[$-1010442]" ); + result.put( "tn", "[$-1010432]" ); + result.put( "tr", "[$-101041F]" ); + result.put( "ts", "[$-1010431]" ); + result.put( "tt", "[$-1010444]" ); + result.put( "uk", "[$-1010422]" ); + result.put( "ur", "[$-1010420]" ); + result.put( "UTF_8", "[$-1010000]" ); + result.put( "uz_uz", "[$-1010843]" ); + result.put( "uz_uz", "[$-1010443]" ); + result.put( "vi", "[$-101042A]" ); + result.put( "xh", "[$-1010434]" ); + result.put( "yi", "[$-101043D]" ); + result.put( "zh_cn", "[$-1010804]" ); + result.put( "zh_hk", "[$-1010C04]" ); + result.put( "zh_mo", "[$-1011404]" ); + result.put( "zh_sg", "[$-1011004]" ); + result.put( "zh_tw", "[$-1010404]" ); + result.put( "zu", "[$-1010435]" ); + + result.put( "ar", "[$-1010401]" ); + result.put( "bn", "[$-1010845]" ); + result.put( "de", "[$-1010407]" ); + result.put( "en", "[$-1010409]" ); + result.put( "es", "[$-101040A]" ); + result.put( "fr", "[$-101040C]" ); + result.put( "it", "[$-1010410]" ); + result.put( "ms", "[$-101043E]" ); + result.put( "nl", "[$-1010413]" ); + result.put( "nn", "[$-1010814]" ); + result.put( "no", "[$-1010414]" ); + result.put( "pt", "[$-1010816]" ); + result.put( "sr", "[$-1010C1A]" ); + result.put( "sv", "[$-101041D]" ); + result.put( "uz", "[$-1010843]" ); + result.put( "zh", "[$-1010804]" ); + + result.put( "ga", "[$-101043C]" ); + result.put( "ga_ie", "[$-101083C]" ); + result.put( "in", "[$-1010421]" ); + result.put( "iw", "[$-101040D]" ); + + return result; + } + + public static String getPrefixForLocale( Locale locale ) { + String localeString = locale.toString().toLowerCase(); + String result = localePrefixes.get( localeString ); + if( result == null ) { + result = localePrefixes.get( localeString.substring( 0, 2 ) ); + if( result == null ) { + // Locale parentLocale = new Locale(localeString.substring( 0, 2 )); + // System.out.println( "Unable to find prefix for " + locale + "(" + locale.getDisplayName() + ") or " + // + localeString.substring( 0, 2 ) + "(" + parentLocale.getDisplayName() + ")" ); + return ""; + } + } + return result; + } + + public static String convert( Locale locale, String format ) { + StringBuilder result = new StringBuilder(); + + result.append(getPrefixForLocale(locale)); + DateFormatTokenizer tokenizer = new DateFormatTokenizer(format); + String token; + while( ( token = tokenizer.getNextToken() ) != null ) { + if( token.startsWith("'") ) { + result.append( token.replaceAll("'", "\"") ); + } else if( ! Character.isLetter( token.charAt( 0 ) ) ) { + result.append( token ); + } else { + // It's a code, translate it if necessary + String mappedToken = tokenConversions.get(token); + result.append( mappedToken == null ? token : mappedToken ); + } + } + + return result.toString().trim(); + } + + public static String getJavaDatePattern(int style, Locale locale) { + DateFormat df = DateFormat.getDateInstance(style, locale); + if( df instanceof SimpleDateFormat ) { + return ((SimpleDateFormat)df).toPattern(); + } else { + switch( style ) { + case DateFormat.SHORT: + return "d/MM/yy"; + case DateFormat.MEDIUM: + return "MMM d, yyyy"; + case DateFormat.LONG: + return "MMMM d, yyyy"; + case DateFormat.FULL: + return "dddd, MMMM d, yyyy"; + default: + return "MMM d, yyyy"; + } + } + } + + public static String getJavaTimePattern(int style, Locale locale) { + DateFormat df = DateFormat.getTimeInstance(style, locale); + if( df instanceof SimpleDateFormat ) { + return ((SimpleDateFormat)df).toPattern(); + } else { + switch( style ) { + case DateFormat.SHORT: + return "h:mm a"; + case DateFormat.MEDIUM: + return "h:mm:ss a"; + case DateFormat.LONG: + return "h:mm:ss a"; + case DateFormat.FULL: + return "h:mm:ss a"; + default: + return "h:mm:ss a"; + } + } + } + + public static String getJavaDateTimePattern(int style, Locale locale) { + DateFormat df = DateFormat.getDateTimeInstance(style, style, locale); + if( df instanceof SimpleDateFormat ) { + return ((SimpleDateFormat)df).toPattern(); + } else { + switch( style ) { + case DateFormat.SHORT: + return "M/d/yy h:mm a"; + case DateFormat.MEDIUM: + return "MMM d, yyyy h:mm:ss a"; + case DateFormat.LONG: + return "MMMM d, yyyy h:mm:ss a"; + case DateFormat.FULL: + return "dddd, MMMM d, yyyy h:mm:ss a"; + default: + return "MMM d, yyyy h:mm:ss a"; + } + } + } + } \ No newline at end of file diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/EmitterServices.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/EmitterServices.java index 482906978..e9b1676ac 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/EmitterServices.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/EmitterServices.java @@ -1,312 +1,312 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - - -package uk.co.spudsoft.birt.emitters.excel; - -import java.util.Map; - -import org.eclipse.birt.report.engine.api.ITaskOption; -import org.eclipse.birt.report.engine.content.IContent; -import org.eclipse.birt.report.engine.content.IElement; -import org.eclipse.birt.report.engine.content.IReportContent; -import org.eclipse.birt.report.engine.ir.Expression; -import org.eclipse.birt.report.engine.ir.ReportElementDesign; - -import uk.co.spudsoft.birt.emitters.excel.framework.ExcelEmitterPlugin; - -public class EmitterServices { - - /** - * Convert an Object to a boolean, with quite a few options about the class of the Object. - * @param options - * The task options to extract the value from. - * @param birtContent - * The leaf node to look for UserProperties - * @param name - * The name of the value to extract from options. - * @param defaultValue - * Value to return if value is null. - * true if value in some way represents a boolean TRUE value. - */ - public static boolean booleanOption( ITaskOption options, IContent birtContent, String name, boolean defaultValue ) { - boolean result = defaultValue; - Object value = null; - - IElement currentElement = birtContent; - - while( ( currentElement != null ) && ( value == null ) ) { - if( currentElement instanceof IContent ) { - Object designObject = ((IContent)currentElement).getGenerateBy(); - if( designObject instanceof ReportElementDesign ) { - Map userProperties = ((ReportElementDesign)designObject).getUserProperties(); - if( userProperties != null ) { - Expression expression = userProperties.get(name); - if( expression instanceof Expression.Constant ) { - Expression.Constant constant = (Expression.Constant)expression; - value = constant.getValue(); - } - } - } - } - if( value == null ) { - currentElement = currentElement.getParent(); - } - } - if( ( value == null ) && ( birtContent != null ) ) { - Map userProperties = birtContent.getReportContent().getDesign().getUserProperties(); - if( userProperties != null ) { - Expression expression = userProperties.get(name); - if( expression instanceof Expression.Constant ) { - Expression.Constant constant = (Expression.Constant)expression; - value = constant.getValue(); - } - } - } - - if( ( value == null ) && ( options != null ) ) { - value = options.getOption(name); - } - - if( value != null ) { - result = booleanOption(value, defaultValue); - } - - return result; - } - - public static boolean booleanOption( ITaskOption options, IReportContent reportContent, String name, boolean defaultValue ) { - boolean result = defaultValue; - Object value = null; - - if( reportContent != null ) { - Map userProperties = reportContent.getDesign().getUserProperties(); - if( userProperties != null ) { - Expression expression = userProperties.get(name); - if( expression instanceof Expression.Constant ) { - Expression.Constant constant = (Expression.Constant)expression; - value = constant.getValue(); - } - } - } - - if( ( value == null ) && ( options != null ) ) { - value = options.getOption(name); - } - - if( value != null ) { - result = booleanOption(value, defaultValue); - } - - return result; - } - - - /** - * Search for an emitter option and return it as a string - * @param options - * The task options to extract the value from. - * @param birtContent - * The leaf node to look for UserProperties - * @param name - * The name of the value to extract from options. - * @param defaultValue - * Value to return if value is null. - * a string, or the defaultValue - */ - public static String stringOption( ITaskOption options, IContent birtContent, String name, String defaultValue ) { - String result = defaultValue; - Object value = null; - - IElement currentElement = birtContent; - - while( ( currentElement != null ) && ( value == null ) ) { - if( currentElement instanceof IContent ) { - Object designObject = ((IContent)currentElement).getGenerateBy(); - if( designObject instanceof ReportElementDesign ) { - Map userProperties = ((ReportElementDesign)designObject).getUserProperties(); - if( userProperties != null ) { - Expression expression = userProperties.get(name); - if( expression instanceof Expression.Constant ) { - Expression.Constant constant = (Expression.Constant)expression; - value = constant.getValue(); - } - } - } - } - if( value == null ) { - currentElement = currentElement.getParent(); - } - } - if( ( value == null ) && ( birtContent != null ) ) { - Map userProperties = birtContent.getReportContent().getDesign().getUserProperties(); - if( userProperties != null ) { - Expression expression = userProperties.get(name); - if( expression instanceof Expression.Constant ) { - Expression.Constant constant = (Expression.Constant)expression; - value = constant.getValue(); - } - } - } - - if( ( value == null ) && ( options != null ) ) { - value = options.getOption(name); - } - - if( value != null ) { - result = value.toString(); - } - - return result; - } - - /** - * Search for an emitter option and return it as a string - * @param options - * The task options to extract the value from. - * @param reportContent - * The report - * @param name - * The name of the value to extract from options. - * @param defaultValue - * Value to return if value is null. - * a string, or the defaultValue - */ - public static String stringOption( ITaskOption options, IReportContent reportContent, String name, String defaultValue ) { - String result = defaultValue; - Object value = null; - - if( reportContent != null ) { - Map userProperties = reportContent.getDesign().getUserProperties(); - if( userProperties != null ) { - Expression expression = userProperties.get(name); - if( expression instanceof Expression.Constant ) { - Expression.Constant constant = (Expression.Constant)expression; - value = constant.getValue(); - } - } - } - - if( ( value == null ) && ( options != null ) ) { - value = options.getOption(name); - } - - if( value != null ) { - result = value.toString(); - } - - return result; - } - - /** - * Search for an emitter option and return it as an integer - * @param options - * The task options to extract the value from. - * @param birtContent - * The leaf node to look for UserProperties - * @param name - * The name of the value to extract from options. - * @param defaultValue - * Value to return if value is null. - * an integer, or the defaultValue - */ - public static int integerOption( ITaskOption options, IContent birtContent, String name, int defaultValue ) { - int result = defaultValue; - Object value = null; - - IElement currentElement = birtContent; - - while( ( currentElement != null ) && ( value == null ) ) { - if( currentElement instanceof IContent ) { - Object designObject = ((IContent)currentElement).getGenerateBy(); - if( designObject instanceof ReportElementDesign ) { - Map userProperties = ((ReportElementDesign)designObject).getUserProperties(); - if( userProperties != null ) { - Expression expression = userProperties.get(name); - if( expression instanceof Expression.Constant ) { - Expression.Constant constant = (Expression.Constant)expression; - value = constant.getValue(); - } - } - } - } - if( value == null ) { - currentElement = currentElement.getParent(); - } - } - if( ( value == null ) && ( birtContent != null ) ) { - Map userProperties = birtContent.getReportContent().getDesign().getUserProperties(); - if( userProperties != null ) { - Expression expression = userProperties.get(name); - if( expression instanceof Expression.Constant ) { - Expression.Constant constant = (Expression.Constant)expression; - value = constant.getValue(); - } - } - } - - if( ( value == null ) && ( options != null ) ) { - value = options.getOption(name); - } - - if( value instanceof Number ) { - result = ((Number)value).intValue(); - } else if( value != null ) { - try { - result = Integer.parseInt( value.toString() ); - } catch( Exception ex ) { - } - } - - return result; - } - - - - /** - * Convert an Object to a boolean, with quite a few options about the class of the Object. - * @param value - * A value that can be of any type. - * @param defaultValue - * Value to return if value is null. - * true if value in some way represents a boolean TRUE value. - */ - public static boolean booleanOption( Object value, boolean defaultValue ) { - if( value != null ) { - if( value instanceof Boolean ) { - return ((Boolean)value).booleanValue(); - } - if( value instanceof Number ) { - return ((Number)value).doubleValue() != 0.0; - } - if( value != null ) { - return Boolean.parseBoolean(value.toString()); - } - } - return defaultValue; - } - - - /** - * Returns the symbolic name for the plugin. - */ - public static String getPluginName() { - if( ( ExcelEmitterPlugin.getDefault() != null ) && ( ExcelEmitterPlugin.getDefault().getBundle() != null ) ) { - return ExcelEmitterPlugin.getDefault().getBundle().getSymbolicName(); - } else { - return "uk.co.spudsoft.birt.emitters.excel"; - } - } - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + + +package uk.co.spudsoft.birt.emitters.excel; + +import java.util.Map; + +import org.eclipse.birt.report.engine.api.ITaskOption; +import org.eclipse.birt.report.engine.content.IContent; +import org.eclipse.birt.report.engine.content.IElement; +import org.eclipse.birt.report.engine.content.IReportContent; +import org.eclipse.birt.report.engine.ir.Expression; +import org.eclipse.birt.report.engine.ir.ReportElementDesign; + +import uk.co.spudsoft.birt.emitters.excel.framework.ExcelEmitterPlugin; + +public class EmitterServices { + + /** + * Convert an Object to a boolean, with quite a few options about the class of the Object. + * @param options + * The task options to extract the value from. + * @param birtContent + * The leaf node to look for UserProperties + * @param name + * The name of the value to extract from options. + * @param defaultValue + * Value to return if value is null. + * true if value in some way represents a boolean TRUE value. + */ + public static boolean booleanOption( ITaskOption options, IContent birtContent, String name, boolean defaultValue ) { + boolean result = defaultValue; + Object value = null; + + IElement currentElement = birtContent; + + while( ( currentElement != null ) && ( value == null ) ) { + if( currentElement instanceof IContent ) { + Object designObject = ((IContent)currentElement).getGenerateBy(); + if( designObject instanceof ReportElementDesign ) { + Map userProperties = ((ReportElementDesign)designObject).getUserProperties(); + if( userProperties != null ) { + Expression expression = userProperties.get(name); + if( expression instanceof Expression.Constant ) { + Expression.Constant constant = (Expression.Constant)expression; + value = constant.getValue(); + } + } + } + } + if( value == null ) { + currentElement = currentElement.getParent(); + } + } + if( ( value == null ) && ( birtContent != null ) ) { + Map userProperties = birtContent.getReportContent().getDesign().getUserProperties(); + if( userProperties != null ) { + Expression expression = userProperties.get(name); + if( expression instanceof Expression.Constant ) { + Expression.Constant constant = (Expression.Constant)expression; + value = constant.getValue(); + } + } + } + + if( ( value == null ) && ( options != null ) ) { + value = options.getOption(name); + } + + if( value != null ) { + result = booleanOption(value, defaultValue); + } + + return result; + } + + public static boolean booleanOption( ITaskOption options, IReportContent reportContent, String name, boolean defaultValue ) { + boolean result = defaultValue; + Object value = null; + + if( reportContent != null ) { + Map userProperties = reportContent.getDesign().getUserProperties(); + if( userProperties != null ) { + Expression expression = userProperties.get(name); + if( expression instanceof Expression.Constant ) { + Expression.Constant constant = (Expression.Constant)expression; + value = constant.getValue(); + } + } + } + + if( ( value == null ) && ( options != null ) ) { + value = options.getOption(name); + } + + if( value != null ) { + result = booleanOption(value, defaultValue); + } + + return result; + } + + + /** + * Search for an emitter option and return it as a string + * @param options + * The task options to extract the value from. + * @param birtContent + * The leaf node to look for UserProperties + * @param name + * The name of the value to extract from options. + * @param defaultValue + * Value to return if value is null. + * a string, or the defaultValue + */ + public static String stringOption( ITaskOption options, IContent birtContent, String name, String defaultValue ) { + String result = defaultValue; + Object value = null; + + IElement currentElement = birtContent; + + while( ( currentElement != null ) && ( value == null ) ) { + if( currentElement instanceof IContent ) { + Object designObject = ((IContent)currentElement).getGenerateBy(); + if( designObject instanceof ReportElementDesign ) { + Map userProperties = ((ReportElementDesign)designObject).getUserProperties(); + if( userProperties != null ) { + Expression expression = userProperties.get(name); + if( expression instanceof Expression.Constant ) { + Expression.Constant constant = (Expression.Constant)expression; + value = constant.getValue(); + } + } + } + } + if( value == null ) { + currentElement = currentElement.getParent(); + } + } + if( ( value == null ) && ( birtContent != null ) ) { + Map userProperties = birtContent.getReportContent().getDesign().getUserProperties(); + if( userProperties != null ) { + Expression expression = userProperties.get(name); + if( expression instanceof Expression.Constant ) { + Expression.Constant constant = (Expression.Constant)expression; + value = constant.getValue(); + } + } + } + + if( ( value == null ) && ( options != null ) ) { + value = options.getOption(name); + } + + if( value != null ) { + result = value.toString(); + } + + return result; + } + + /** + * Search for an emitter option and return it as a string + * @param options + * The task options to extract the value from. + * @param reportContent + * The report + * @param name + * The name of the value to extract from options. + * @param defaultValue + * Value to return if value is null. + * a string, or the defaultValue + */ + public static String stringOption( ITaskOption options, IReportContent reportContent, String name, String defaultValue ) { + String result = defaultValue; + Object value = null; + + if( reportContent != null ) { + Map userProperties = reportContent.getDesign().getUserProperties(); + if( userProperties != null ) { + Expression expression = userProperties.get(name); + if( expression instanceof Expression.Constant ) { + Expression.Constant constant = (Expression.Constant)expression; + value = constant.getValue(); + } + } + } + + if( ( value == null ) && ( options != null ) ) { + value = options.getOption(name); + } + + if( value != null ) { + result = value.toString(); + } + + return result; + } + + /** + * Search for an emitter option and return it as an integer + * @param options + * The task options to extract the value from. + * @param birtContent + * The leaf node to look for UserProperties + * @param name + * The name of the value to extract from options. + * @param defaultValue + * Value to return if value is null. + * an integer, or the defaultValue + */ + public static int integerOption( ITaskOption options, IContent birtContent, String name, int defaultValue ) { + int result = defaultValue; + Object value = null; + + IElement currentElement = birtContent; + + while( ( currentElement != null ) && ( value == null ) ) { + if( currentElement instanceof IContent ) { + Object designObject = ((IContent)currentElement).getGenerateBy(); + if( designObject instanceof ReportElementDesign ) { + Map userProperties = ((ReportElementDesign)designObject).getUserProperties(); + if( userProperties != null ) { + Expression expression = userProperties.get(name); + if( expression instanceof Expression.Constant ) { + Expression.Constant constant = (Expression.Constant)expression; + value = constant.getValue(); + } + } + } + } + if( value == null ) { + currentElement = currentElement.getParent(); + } + } + if( ( value == null ) && ( birtContent != null ) ) { + Map userProperties = birtContent.getReportContent().getDesign().getUserProperties(); + if( userProperties != null ) { + Expression expression = userProperties.get(name); + if( expression instanceof Expression.Constant ) { + Expression.Constant constant = (Expression.Constant)expression; + value = constant.getValue(); + } + } + } + + if( ( value == null ) && ( options != null ) ) { + value = options.getOption(name); + } + + if( value instanceof Number ) { + result = ((Number)value).intValue(); + } else if( value != null ) { + try { + result = Integer.parseInt( value.toString() ); + } catch( Exception ex ) { + } + } + + return result; + } + + + + /** + * Convert an Object to a boolean, with quite a few options about the class of the Object. + * @param value + * A value that can be of any type. + * @param defaultValue + * Value to return if value is null. + * true if value in some way represents a boolean TRUE value. + */ + public static boolean booleanOption( Object value, boolean defaultValue ) { + if( value != null ) { + if( value instanceof Boolean ) { + return ((Boolean)value).booleanValue(); + } + if( value instanceof Number ) { + return ((Number)value).doubleValue() != 0.0; + } + if( value != null ) { + return Boolean.parseBoolean(value.toString()); + } + } + return defaultValue; + } + + + /** + * Returns the symbolic name for the plugin. + */ + public static String getPluginName() { + if( ( ExcelEmitterPlugin.getDefault() != null ) && ( ExcelEmitterPlugin.getDefault().getBundle() != null ) ) { + return ExcelEmitterPlugin.getDefault().getBundle().getSymbolicName(); + } else { + return "uk.co.spudsoft.birt.emitters.excel"; + } + } + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/ExcelEmitter.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/ExcelEmitter.java index 0d5c0e8bc..53166f6ca 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/ExcelEmitter.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/ExcelEmitter.java @@ -1,447 +1,447 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - - -package uk.co.spudsoft.birt.emitters.excel; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.URISyntaxException; -import java.net.URL; - -import org.apache.poi.ss.usermodel.Workbook; -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.api.IRenderOption; -import org.eclipse.birt.report.engine.content.IAutoTextContent; -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.content.IContainerContent; -import org.eclipse.birt.report.engine.content.IContent; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IGroupContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.IListBandContent; -import org.eclipse.birt.report.engine.content.IListContent; -import org.eclipse.birt.report.engine.content.IListGroupContent; -import org.eclipse.birt.report.engine.content.IPageContent; -import org.eclipse.birt.report.engine.content.IReportContent; -import org.eclipse.birt.report.engine.content.IRowContent; -import org.eclipse.birt.report.engine.content.ITableBandContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITableGroupContent; -import org.eclipse.birt.report.engine.content.ITextContent; -import org.eclipse.birt.report.engine.css.engine.CSSEngine; -import org.eclipse.birt.report.engine.emitter.IContentEmitter; -import org.eclipse.birt.report.engine.emitter.IEmitterServices; - -import uk.co.spudsoft.birt.emitters.excel.framework.ExcelEmitterPlugin; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; -import uk.co.spudsoft.birt.emitters.excel.handlers.PageHandler; - -public abstract class ExcelEmitter implements IContentEmitter { - - public static final String DEBUG = "ExcelEmitter.DEBUG"; - public static final String REMOVE_BLANK_ROWS = "ExcelEmitter.RemoveBlankRows"; - public static final String ROTATION_PROP = "ExcelEmitter.Rotation"; - public static final String FORCEAUTOCOLWIDTHS_PROP = "ExcelEmitter.ForceAutoColWidths"; - public static final String SINGLE_SHEET = "ExcelEmitter.SingleSheet"; - public static final String SINGLE_SHEET_PAGE_BREAKS = "ExcelEmitter.SingleSheetWithPageBreaks"; - public static final String PRINT_BREAK_AFTER = "ExcelEmitter.InsertPrintBreakAfter"; - public static final String DISABLE_GROUPING = "ExcelEmitter.DisableGrouping"; - public static final String STRUCTURED_HEADER = "ExcelEmitter.StructuredHeader"; - public static final String CUSTOM_NUMBER_FORMAT = "ExcelEmitter.CustomNumberFormat"; - public static final String AUTO_FILTER = "ExcelEmitter.AutoFilter"; - public static final String SHEET_PASSWORD = "ExcelEmitter.SheetProtectPassword"; - public static final String GROUP_SUMMARY_HEADER = "ExcelEmitter.GroupSummaryHeader"; - public static final String FREEZE_PANES = "ExcelEmitter.FreezePanes"; - public static final String BLANK_ROW_AFTER_TOP_LEVEL_TABLE = "ExcelEmitter.BlankRowAfterTopLevelTable"; - public static final String SPANNED_ROW_HEIGHT = "ExcelEmitter.SpannedRowHeight"; - public static final String NEST_TABLE_IN_LAST_CELL = "ExcelEmitter.NestedTableInLastCell"; - public static final int SPANNED_ROW_HEIGHT_SPREAD = 0; - public static final int SPANNED_ROW_HEIGHT_FIRST = 1; - public static final int SPANNED_ROW_HEIGHT_IGNORED = 2; - - public static final String PRINT_SCALE = "ExcelEmitter.PrintScale"; - public static final String PRINT_PAGES_WIDE = "ExcelEmitter.PrintPagesWide"; - public static final String PRINT_PAGES_HIGH = "ExcelEmitter.PrintPagesHigh"; - - public static final String DISPLAYFORMULAS_PROP = "ExcelEmitter.DisplayFormulas"; - public static final String DISPLAYGRIDLINES_PROP = "ExcelEmitter.DisplayGridlines"; - public static final String DISPLAYROWCOLHEADINGS_PROP = "ExcelEmitter.DisplayRowColHeadings"; - public static final String DISPLAYZEROS_PROP = "ExcelEmitter.DisplayZeros"; - - public static final String TEMPLATE_FILE = "ExcelEmitter.TemplateFile"; - - /** - * Logger. - */ - protected Logger log; - /** - *

- * Output stream that the report is to be written to. - *

- * This is set in initialize() and reset in end() and must not be set anywhere else. - *

- */ - protected OutputStream reportOutputStream; - /** - *

- * Record of whether the emitter opened the report output stream itself, and it thus responsible for closing it. - *

- */ - protected boolean outputStreamOpened; - /** - *

- * Name of the file that the report is to be written to (for tracking only). - *

- * This is set in initialize() and reset in end() and must not be set anywhere else. - *

- */ - protected String reportOutputFilename; - /** - * The state date passed around the handlers. - */ - private HandlerState handlerState; - - private IRenderOption renderOptions; - /** - * The last page seen, cached so it can be used to call endPage - * - */ - private IPageContent lastPage; - - /** - * Factory for creating the appropriate StyleManagerUtils object - */ - private StyleManagerUtils.Factory utilsFactory; - - protected ExcelEmitter(StyleManagerUtils.Factory utilsFactory) { - this.utilsFactory = utilsFactory; - try { - if( ExcelEmitterPlugin.getDefault() != null ) { - log = ExcelEmitterPlugin.getDefault().getLogger(); - } else { - log = new Logger( this.getClass().getPackage().getName() ); - } - log.debug("ExcelEmitter"); - } catch( Exception ex ) { - Throwable t = ex; - while( t != null ) { - log.debug( t.getMessage() ); - t.printStackTrace(); - t = t.getCause(); - } - } - } - - /** - * Constructs a new workbook to be processed by the emitter. - * The new workbook. - */ - protected abstract Workbook createWorkbook(); - - /** - * Constructs a new workbook to be processed by the emitter. - * @param templateFile - * The file to open as a template for the output file - * The new workbook. - */ - protected abstract Workbook openWorkbook( File templateFile ) throws IOException; - - - public void initialize( IEmitterServices service ) throws BirtException { - renderOptions = service.getRenderOption(); - boolean debug = EmitterServices.booleanOption( renderOptions, (IContent)null, DEBUG, false ); - log.setDebug(debug); - - log.debug("inintialize"); - reportOutputStream = service.getRenderOption().getOutputStream(); - reportOutputFilename = service.getRenderOption().getOutputFileName(); - if( ( reportOutputStream == null ) - && ( ( reportOutputFilename == null ) || reportOutputFilename.isEmpty() ) ) { - throw new BirtException( EmitterServices.getPluginName() - , "Neither output stream nor output filename have been specified" - , null - ); - } - } - - public void start( IReportContent report ) throws BirtException { - log.addPrefix('>'); - log.info( 0, "start:" + report.toString(), null); - - String templatePath = EmitterServices.stringOption( renderOptions, report, TEMPLATE_FILE, null ); - Workbook wb; - if( templatePath != null ) { - URL templateURL = report.getReportContext().getResource( templatePath ); - File templateFile; - try { - templateFile = new File( templateURL.toURI() ); - } catch( URISyntaxException ex ) { - throw new BirtException( EmitterServices.getPluginName() - , "Unable locate template resource for " + templatePath - , ex - ); - } - try { - wb = openWorkbook( templateFile ); - } catch( IOException ex ) { - throw new BirtException( EmitterServices.getPluginName() - , "Unable to open template workbook for " + templateFile.toString() - , ex - ); - } - } else { - wb = createWorkbook(); - } - - CSSEngine cssEngine = report.getRoot().getCSSEngine(); - StyleManagerUtils smu = utilsFactory.create(log); - - StyleManager sm = new StyleManager( wb, log, smu, cssEngine, report.getReportContext().getLocale() ); - - handlerState = new HandlerState(this, log, smu, wb, sm, renderOptions); - handlerState.setHandler( new PageHandler(log, null) ); - - if( EmitterServices.booleanOption( handlerState.getRenderOptions(), report, ExcelEmitter.SINGLE_SHEET_PAGE_BREAKS, false ) ) { - handlerState.getRenderOptions().setOption(ExcelEmitter.SINGLE_SHEET, Boolean.TRUE); - } - } - - public void end( IReportContent report ) throws BirtException { - - if( EmitterServices.booleanOption( handlerState.getRenderOptions(), report, ExcelEmitter.SINGLE_SHEET, false ) ) { - handlerState.reportEnding = true; - handlerState.getHandler().endPage(handlerState, lastPage); - } - - log.removePrefix('>'); - log.debug("end:", report); - - String reportTitle = report.getTitle(); - if( ( handlerState.getWb().getNumberOfSheets() == 1 ) - && ( reportTitle != null )) { - handlerState.getWb().setSheetName(0, reportTitle); - } - - OutputStream outputStream = reportOutputStream; - try { - if( outputStream == null ) { - if( ( reportOutputFilename != null ) && ! reportOutputFilename.isEmpty() ) { - try { - outputStream = new FileOutputStream( reportOutputFilename ); - } catch( IOException ex ) { - log.warn( 0, "File \"" + reportOutputFilename + "\" cannot be opened for writing", ex); - throw new BirtException( EmitterServices.getPluginName() - , "Unable to open file (\"{}\") for writing" - , new Object[] { reportOutputFilename } - , null - , ex - ); - } - } - } - handlerState.getWb().write(outputStream); - } catch( Throwable ex ) { - log.debug("ex:", ex.toString()); - ex.printStackTrace(); - - throw new BirtException( EmitterServices.getPluginName() - , "Unable to save file (\"{}\")" - , new Object[] { reportOutputFilename } - , null - , ex - ); - } finally { - if( reportOutputStream == null ) { - try { - outputStream.close(); - } catch( IOException ex ) { - log.debug("ex:", ex.toString()); - } - } - handlerState = null; - reportOutputFilename = null; - reportOutputStream = null; - } - - } - - public void startPage( IPageContent page ) throws BirtException { - log.addPrefix( 'P' ); - log.debug( handlerState, "startPage: " ); - handlerState.getHandler().startPage(handlerState,page); - } - public void endPage( IPageContent page ) throws BirtException { - lastPage = page; - log.debug( handlerState, "endPage: " ); - handlerState.getHandler().endPage(handlerState,page); - log.removePrefix( 'P' ); - } - - public void startTable( ITableContent table ) throws BirtException { - log.addPrefix( 'T' ); - log.debug( handlerState, "startTable: " ); - handlerState.getHandler().startTable(handlerState,table); - } - public void endTable( ITableContent table ) throws BirtException { - log.debug( handlerState, "endTable: " ); - handlerState.getHandler().endTable(handlerState,table); - log.removePrefix( 'T' ); - } - - public void startTableBand( ITableBandContent band ) throws BirtException { - log.addPrefix( 'B' ); - log.debug( handlerState, "startTableBand: " ); - handlerState.getHandler().startTableBand(handlerState,band); - } - public void endTableBand( ITableBandContent band ) throws BirtException { - log.debug( handlerState, "endTableBand: " ); - handlerState.getHandler().endTableBand(handlerState,band); - log.removePrefix( 'B' ); - } - - public void startRow( IRowContent row ) throws BirtException { - log.addPrefix( 'R' ); - log.debug( handlerState, "startRow: " ); - handlerState.getHandler().startRow(handlerState,row); - } - public void endRow( IRowContent row ) throws BirtException { - log.debug( handlerState, "endRow: " ); - handlerState.getHandler().endRow(handlerState,row); - log.removePrefix( 'R' ); - } - - public void startCell( ICellContent cell ) throws BirtException { - log.addPrefix( 'C' ); - log.debug( handlerState, "startCell: " ); - handlerState.getHandler().startCell(handlerState,cell); - } - public void endCell( ICellContent cell ) throws BirtException { - log.debug( handlerState, "endCell: " ); - handlerState.getHandler().endCell(handlerState,cell); - log.removePrefix( 'C' ); - } - - public void startList( IListContent list ) throws BirtException { - log.addPrefix( 'L' ); - log.debug( handlerState, "startList: " ); - handlerState.getHandler().startList(handlerState,list); - } - public void endList( IListContent list ) throws BirtException { - log.debug( handlerState, "endList: " ); - handlerState.getHandler().endList(handlerState,list); - log.removePrefix( 'L' ); - } - - public void startListBand( IListBandContent listBand ) throws BirtException { - log.addPrefix( 'B' ); - log.debug( handlerState, "startListBand: " ); - handlerState.getHandler().startListBand(handlerState,listBand); - } - public void endListBand( IListBandContent listBand ) throws BirtException { - log.debug( handlerState, "endListBand: " ); - handlerState.getHandler().endListBand(handlerState,listBand); - log.removePrefix( 'B' ); - } - - public void startContainer( IContainerContent container ) throws BirtException { - log.addPrefix( 'O' ); - log.debug( handlerState, "startContainer: " ); - handlerState.getHandler().startContainer(handlerState,container); - } - public void endContainer( IContainerContent container ) throws BirtException { - log.debug( handlerState, "endContainer: " ); - handlerState.getHandler().endContainer(handlerState,container); - log.removePrefix( 'O' ); - } - - public void startText( ITextContent text ) throws BirtException { - log.debug( handlerState, "startText: " ); - handlerState.getHandler().emitText(handlerState,text); - } - - public void startData( IDataContent data ) throws BirtException { - log.debug( handlerState, "startData: " ); - handlerState.getHandler().emitData(handlerState,data); - } - - public void startLabel( ILabelContent label ) throws BirtException { - log.debug( handlerState, "startLabel: " ); - handlerState.getHandler().emitLabel(handlerState,label); - } - - public void startAutoText ( IAutoTextContent autoText ) throws BirtException { - log.debug( handlerState, "startAutoText: " ); - handlerState.getHandler().emitAutoText(handlerState,autoText); - } - - public void startForeign( IForeignContent foreign ) throws BirtException { - log.debug( handlerState, "startForeign: " ); - handlerState.getHandler().emitForeign(handlerState,foreign); - } - - public void startImage( IImageContent image ) throws BirtException { - log.debug( handlerState, "startImage: " ); - handlerState.getHandler().emitImage(handlerState,image); - } - - public void startContent( IContent content ) throws BirtException { - log.addPrefix( 'N' ); - log.debug( handlerState, "startContent: " ); - handlerState.getHandler().startContent(handlerState,content); - } - public void endContent( IContent content) throws BirtException { - log.debug( handlerState, "endContent: " ); - handlerState.getHandler().endContent(handlerState,content); - log.removePrefix( 'N' ); - } - - public void startGroup( IGroupContent group ) throws BirtException { - log.debug( handlerState, "startGroup: " ); - handlerState.getHandler().startGroup(handlerState,group); - } - public void endGroup( IGroupContent group ) throws BirtException { - log.debug( handlerState, "endGroup: " ); - handlerState.getHandler().endGroup(handlerState,group); - } - - public void startTableGroup( ITableGroupContent group ) throws BirtException { - log.addPrefix( 'G' ); - log.debug( handlerState, "startTableGroup: " ); - handlerState.getHandler().startTableGroup(handlerState,group); - } - public void endTableGroup( ITableGroupContent group ) throws BirtException { - log.debug( handlerState, "endTableGroup: " ); - handlerState.getHandler().endTableGroup(handlerState,group); - log.removePrefix( 'G' ); - } - - public void startListGroup( IListGroupContent group ) throws BirtException { - log.addPrefix( 'G' ); - log.debug( handlerState, "startListGroup: " ); - handlerState.getHandler().startListGroup(handlerState,group); - } - public void endListGroup( IListGroupContent group ) throws BirtException { - log.debug( handlerState, "endListGroup: " ); - handlerState.getHandler().endListGroup(handlerState,group); - log.removePrefix( 'G' ); - } - - - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + + +package uk.co.spudsoft.birt.emitters.excel; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.URISyntaxException; +import java.net.URL; + +import org.apache.poi.ss.usermodel.Workbook; +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.api.IRenderOption; +import org.eclipse.birt.report.engine.content.IAutoTextContent; +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.content.IContainerContent; +import org.eclipse.birt.report.engine.content.IContent; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IGroupContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.IListBandContent; +import org.eclipse.birt.report.engine.content.IListContent; +import org.eclipse.birt.report.engine.content.IListGroupContent; +import org.eclipse.birt.report.engine.content.IPageContent; +import org.eclipse.birt.report.engine.content.IReportContent; +import org.eclipse.birt.report.engine.content.IRowContent; +import org.eclipse.birt.report.engine.content.ITableBandContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITableGroupContent; +import org.eclipse.birt.report.engine.content.ITextContent; +import org.eclipse.birt.report.engine.css.engine.CSSEngine; +import org.eclipse.birt.report.engine.emitter.IContentEmitter; +import org.eclipse.birt.report.engine.emitter.IEmitterServices; + +import uk.co.spudsoft.birt.emitters.excel.framework.ExcelEmitterPlugin; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; +import uk.co.spudsoft.birt.emitters.excel.handlers.PageHandler; + +public abstract class ExcelEmitter implements IContentEmitter { + + public static final String DEBUG = "ExcelEmitter.DEBUG"; + public static final String REMOVE_BLANK_ROWS = "ExcelEmitter.RemoveBlankRows"; + public static final String ROTATION_PROP = "ExcelEmitter.Rotation"; + public static final String FORCEAUTOCOLWIDTHS_PROP = "ExcelEmitter.ForceAutoColWidths"; + public static final String SINGLE_SHEET = "ExcelEmitter.SingleSheet"; + public static final String SINGLE_SHEET_PAGE_BREAKS = "ExcelEmitter.SingleSheetWithPageBreaks"; + public static final String PRINT_BREAK_AFTER = "ExcelEmitter.InsertPrintBreakAfter"; + public static final String DISABLE_GROUPING = "ExcelEmitter.DisableGrouping"; + public static final String STRUCTURED_HEADER = "ExcelEmitter.StructuredHeader"; + public static final String CUSTOM_NUMBER_FORMAT = "ExcelEmitter.CustomNumberFormat"; + public static final String AUTO_FILTER = "ExcelEmitter.AutoFilter"; + public static final String SHEET_PASSWORD = "ExcelEmitter.SheetProtectPassword"; + public static final String GROUP_SUMMARY_HEADER = "ExcelEmitter.GroupSummaryHeader"; + public static final String FREEZE_PANES = "ExcelEmitter.FreezePanes"; + public static final String BLANK_ROW_AFTER_TOP_LEVEL_TABLE = "ExcelEmitter.BlankRowAfterTopLevelTable"; + public static final String SPANNED_ROW_HEIGHT = "ExcelEmitter.SpannedRowHeight"; + public static final String NEST_TABLE_IN_LAST_CELL = "ExcelEmitter.NestedTableInLastCell"; + public static final int SPANNED_ROW_HEIGHT_SPREAD = 0; + public static final int SPANNED_ROW_HEIGHT_FIRST = 1; + public static final int SPANNED_ROW_HEIGHT_IGNORED = 2; + + public static final String PRINT_SCALE = "ExcelEmitter.PrintScale"; + public static final String PRINT_PAGES_WIDE = "ExcelEmitter.PrintPagesWide"; + public static final String PRINT_PAGES_HIGH = "ExcelEmitter.PrintPagesHigh"; + + public static final String DISPLAYFORMULAS_PROP = "ExcelEmitter.DisplayFormulas"; + public static final String DISPLAYGRIDLINES_PROP = "ExcelEmitter.DisplayGridlines"; + public static final String DISPLAYROWCOLHEADINGS_PROP = "ExcelEmitter.DisplayRowColHeadings"; + public static final String DISPLAYZEROS_PROP = "ExcelEmitter.DisplayZeros"; + + public static final String TEMPLATE_FILE = "ExcelEmitter.TemplateFile"; + + /** + * Logger. + */ + protected Logger log; + /** + *

+ * Output stream that the report is to be written to. + *

+ * This is set in initialize() and reset in end() and must not be set anywhere else. + *

+ */ + protected OutputStream reportOutputStream; + /** + *

+ * Record of whether the emitter opened the report output stream itself, and it thus responsible for closing it. + *

+ */ + protected boolean outputStreamOpened; + /** + *

+ * Name of the file that the report is to be written to (for tracking only). + *

+ * This is set in initialize() and reset in end() and must not be set anywhere else. + *

+ */ + protected String reportOutputFilename; + /** + * The state date passed around the handlers. + */ + private HandlerState handlerState; + + private IRenderOption renderOptions; + /** + * The last page seen, cached so it can be used to call endPage + * + */ + private IPageContent lastPage; + + /** + * Factory for creating the appropriate StyleManagerUtils object + */ + private StyleManagerUtils.Factory utilsFactory; + + protected ExcelEmitter(StyleManagerUtils.Factory utilsFactory) { + this.utilsFactory = utilsFactory; + try { + if( ExcelEmitterPlugin.getDefault() != null ) { + log = ExcelEmitterPlugin.getDefault().getLogger(); + } else { + log = new Logger( this.getClass().getPackage().getName() ); + } + log.debug("ExcelEmitter"); + } catch( Exception ex ) { + Throwable t = ex; + while( t != null ) { + log.debug( t.getMessage() ); + t.printStackTrace(); + t = t.getCause(); + } + } + } + + /** + * Constructs a new workbook to be processed by the emitter. + * The new workbook. + */ + protected abstract Workbook createWorkbook(); + + /** + * Constructs a new workbook to be processed by the emitter. + * @param templateFile + * The file to open as a template for the output file + * The new workbook. + */ + protected abstract Workbook openWorkbook( File templateFile ) throws IOException; + + + public void initialize( IEmitterServices service ) throws BirtException { + renderOptions = service.getRenderOption(); + boolean debug = EmitterServices.booleanOption( renderOptions, (IContent)null, DEBUG, false ); + log.setDebug(debug); + + log.debug("inintialize"); + reportOutputStream = service.getRenderOption().getOutputStream(); + reportOutputFilename = service.getRenderOption().getOutputFileName(); + if( ( reportOutputStream == null ) + && ( ( reportOutputFilename == null ) || reportOutputFilename.isEmpty() ) ) { + throw new BirtException( EmitterServices.getPluginName() + , "Neither output stream nor output filename have been specified" + , null + ); + } + } + + public void start( IReportContent report ) throws BirtException { + log.addPrefix('>'); + log.info( 0, "start:" + report.toString(), null); + + String templatePath = EmitterServices.stringOption( renderOptions, report, TEMPLATE_FILE, null ); + Workbook wb; + if( templatePath != null ) { + URL templateURL = report.getReportContext().getResource( templatePath ); + File templateFile; + try { + templateFile = new File( templateURL.toURI() ); + } catch( URISyntaxException ex ) { + throw new BirtException( EmitterServices.getPluginName() + , "Unable locate template resource for " + templatePath + , ex + ); + } + try { + wb = openWorkbook( templateFile ); + } catch( IOException ex ) { + throw new BirtException( EmitterServices.getPluginName() + , "Unable to open template workbook for " + templateFile.toString() + , ex + ); + } + } else { + wb = createWorkbook(); + } + + CSSEngine cssEngine = report.getRoot().getCSSEngine(); + StyleManagerUtils smu = utilsFactory.create(log); + + StyleManager sm = new StyleManager( wb, log, smu, cssEngine, report.getReportContext().getLocale() ); + + handlerState = new HandlerState(this, log, smu, wb, sm, renderOptions); + handlerState.setHandler( new PageHandler(log, null) ); + + if( EmitterServices.booleanOption( handlerState.getRenderOptions(), report, ExcelEmitter.SINGLE_SHEET_PAGE_BREAKS, false ) ) { + handlerState.getRenderOptions().setOption(ExcelEmitter.SINGLE_SHEET, Boolean.TRUE); + } + } + + public void end( IReportContent report ) throws BirtException { + + if( EmitterServices.booleanOption( handlerState.getRenderOptions(), report, ExcelEmitter.SINGLE_SHEET, false ) ) { + handlerState.reportEnding = true; + handlerState.getHandler().endPage(handlerState, lastPage); + } + + log.removePrefix('>'); + log.debug("end:", report); + + String reportTitle = report.getTitle(); + if( ( handlerState.getWb().getNumberOfSheets() == 1 ) + && ( reportTitle != null )) { + handlerState.getWb().setSheetName(0, reportTitle); + } + + OutputStream outputStream = reportOutputStream; + try { + if( outputStream == null ) { + if( ( reportOutputFilename != null ) && ! reportOutputFilename.isEmpty() ) { + try { + outputStream = new FileOutputStream( reportOutputFilename ); + } catch( IOException ex ) { + log.warn( 0, "File \"" + reportOutputFilename + "\" cannot be opened for writing", ex); + throw new BirtException( EmitterServices.getPluginName() + , "Unable to open file (\"{}\") for writing" + , new Object[] { reportOutputFilename } + , null + , ex + ); + } + } + } + handlerState.getWb().write(outputStream); + } catch( Throwable ex ) { + log.debug("ex:", ex.toString()); + ex.printStackTrace(); + + throw new BirtException( EmitterServices.getPluginName() + , "Unable to save file (\"{}\")" + , new Object[] { reportOutputFilename } + , null + , ex + ); + } finally { + if( reportOutputStream == null ) { + try { + outputStream.close(); + } catch( IOException ex ) { + log.debug("ex:", ex.toString()); + } + } + handlerState = null; + reportOutputFilename = null; + reportOutputStream = null; + } + + } + + public void startPage( IPageContent page ) throws BirtException { + log.addPrefix( 'P' ); + log.debug( handlerState, "startPage: " ); + handlerState.getHandler().startPage(handlerState,page); + } + public void endPage( IPageContent page ) throws BirtException { + lastPage = page; + log.debug( handlerState, "endPage: " ); + handlerState.getHandler().endPage(handlerState,page); + log.removePrefix( 'P' ); + } + + public void startTable( ITableContent table ) throws BirtException { + log.addPrefix( 'T' ); + log.debug( handlerState, "startTable: " ); + handlerState.getHandler().startTable(handlerState,table); + } + public void endTable( ITableContent table ) throws BirtException { + log.debug( handlerState, "endTable: " ); + handlerState.getHandler().endTable(handlerState,table); + log.removePrefix( 'T' ); + } + + public void startTableBand( ITableBandContent band ) throws BirtException { + log.addPrefix( 'B' ); + log.debug( handlerState, "startTableBand: " ); + handlerState.getHandler().startTableBand(handlerState,band); + } + public void endTableBand( ITableBandContent band ) throws BirtException { + log.debug( handlerState, "endTableBand: " ); + handlerState.getHandler().endTableBand(handlerState,band); + log.removePrefix( 'B' ); + } + + public void startRow( IRowContent row ) throws BirtException { + log.addPrefix( 'R' ); + log.debug( handlerState, "startRow: " ); + handlerState.getHandler().startRow(handlerState,row); + } + public void endRow( IRowContent row ) throws BirtException { + log.debug( handlerState, "endRow: " ); + handlerState.getHandler().endRow(handlerState,row); + log.removePrefix( 'R' ); + } + + public void startCell( ICellContent cell ) throws BirtException { + log.addPrefix( 'C' ); + log.debug( handlerState, "startCell: " ); + handlerState.getHandler().startCell(handlerState,cell); + } + public void endCell( ICellContent cell ) throws BirtException { + log.debug( handlerState, "endCell: " ); + handlerState.getHandler().endCell(handlerState,cell); + log.removePrefix( 'C' ); + } + + public void startList( IListContent list ) throws BirtException { + log.addPrefix( 'L' ); + log.debug( handlerState, "startList: " ); + handlerState.getHandler().startList(handlerState,list); + } + public void endList( IListContent list ) throws BirtException { + log.debug( handlerState, "endList: " ); + handlerState.getHandler().endList(handlerState,list); + log.removePrefix( 'L' ); + } + + public void startListBand( IListBandContent listBand ) throws BirtException { + log.addPrefix( 'B' ); + log.debug( handlerState, "startListBand: " ); + handlerState.getHandler().startListBand(handlerState,listBand); + } + public void endListBand( IListBandContent listBand ) throws BirtException { + log.debug( handlerState, "endListBand: " ); + handlerState.getHandler().endListBand(handlerState,listBand); + log.removePrefix( 'B' ); + } + + public void startContainer( IContainerContent container ) throws BirtException { + log.addPrefix( 'O' ); + log.debug( handlerState, "startContainer: " ); + handlerState.getHandler().startContainer(handlerState,container); + } + public void endContainer( IContainerContent container ) throws BirtException { + log.debug( handlerState, "endContainer: " ); + handlerState.getHandler().endContainer(handlerState,container); + log.removePrefix( 'O' ); + } + + public void startText( ITextContent text ) throws BirtException { + log.debug( handlerState, "startText: " ); + handlerState.getHandler().emitText(handlerState,text); + } + + public void startData( IDataContent data ) throws BirtException { + log.debug( handlerState, "startData: " ); + handlerState.getHandler().emitData(handlerState,data); + } + + public void startLabel( ILabelContent label ) throws BirtException { + log.debug( handlerState, "startLabel: " ); + handlerState.getHandler().emitLabel(handlerState,label); + } + + public void startAutoText ( IAutoTextContent autoText ) throws BirtException { + log.debug( handlerState, "startAutoText: " ); + handlerState.getHandler().emitAutoText(handlerState,autoText); + } + + public void startForeign( IForeignContent foreign ) throws BirtException { + log.debug( handlerState, "startForeign: " ); + handlerState.getHandler().emitForeign(handlerState,foreign); + } + + public void startImage( IImageContent image ) throws BirtException { + log.debug( handlerState, "startImage: " ); + handlerState.getHandler().emitImage(handlerState,image); + } + + public void startContent( IContent content ) throws BirtException { + log.addPrefix( 'N' ); + log.debug( handlerState, "startContent: " ); + handlerState.getHandler().startContent(handlerState,content); + } + public void endContent( IContent content) throws BirtException { + log.debug( handlerState, "endContent: " ); + handlerState.getHandler().endContent(handlerState,content); + log.removePrefix( 'N' ); + } + + public void startGroup( IGroupContent group ) throws BirtException { + log.debug( handlerState, "startGroup: " ); + handlerState.getHandler().startGroup(handlerState,group); + } + public void endGroup( IGroupContent group ) throws BirtException { + log.debug( handlerState, "endGroup: " ); + handlerState.getHandler().endGroup(handlerState,group); + } + + public void startTableGroup( ITableGroupContent group ) throws BirtException { + log.addPrefix( 'G' ); + log.debug( handlerState, "startTableGroup: " ); + handlerState.getHandler().startTableGroup(handlerState,group); + } + public void endTableGroup( ITableGroupContent group ) throws BirtException { + log.debug( handlerState, "endTableGroup: " ); + handlerState.getHandler().endTableGroup(handlerState,group); + log.removePrefix( 'G' ); + } + + public void startListGroup( IListGroupContent group ) throws BirtException { + log.addPrefix( 'G' ); + log.debug( handlerState, "startListGroup: " ); + handlerState.getHandler().startListGroup(handlerState,group); + } + public void endListGroup( IListGroupContent group ) throws BirtException { + log.debug( handlerState, "endListGroup: " ); + handlerState.getHandler().endListGroup(handlerState,group); + log.removePrefix( 'G' ); + } + + + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/FilteredSheet.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/FilteredSheet.java index 6fe36fe5b..22b290fd2 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/FilteredSheet.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/FilteredSheet.java @@ -1,704 +1,704 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.poi.ss.usermodel.AutoFilter; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellRange; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Comment; -import org.apache.poi.ss.usermodel.DataValidation; -import org.apache.poi.ss.usermodel.DataValidationHelper; -import org.apache.poi.ss.usermodel.Drawing; -import org.apache.poi.ss.usermodel.Footer; -import org.apache.poi.ss.usermodel.Header; -import org.apache.poi.ss.usermodel.Hyperlink; -import org.apache.poi.ss.usermodel.PrintSetup; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.SheetConditionalFormatting; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.util.CellAddress; -import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.ss.util.PaneInformation; - -public class FilteredSheet implements Sheet { - - private Sheet sheet; - private int minRow; - private int maxRow; - - public FilteredSheet(Sheet sheet, int minRow, int maxRow) { - this.sheet = sheet; - this.minRow = minRow; - this.maxRow = maxRow; - } - - private class FilteredIterator implements Iterator { - - private Iterator iter; - private int minRow; - private int maxRow; - private Row cur; - - public FilteredIterator(Iterator iter, int minRow, int maxRow) { - this.iter = iter; - this.minRow = minRow; - this.maxRow = maxRow; - } - - public boolean hasNext() { - if( iter.hasNext() ) { - cur = iter.next(); - while( cur.getRowNum() < minRow ) { - if( ! iter.hasNext() ) { - return false; - } - cur = iter.next(); - } - if( cur.getRowNum() > maxRow ) { - return false; - } - return true; - } - return false; - } - - public Row next() { - return cur; - } - - public void remove() { - iter.remove(); - } - - } - - public CellRangeAddress getRepeatingColumns() { - return sheet.getRepeatingColumns(); - } - - public CellRangeAddress getRepeatingRows() { - // TODO Auto-generated method stub - return sheet.getRepeatingRows(); - } - - public void setRepeatingColumns(CellRangeAddress arg0) { - sheet.setRepeatingColumns(arg0); - } - - public void setRepeatingRows(CellRangeAddress arg0) { - sheet.setRepeatingRows(arg0); - } - - public Iterator iterator() { - return rowIterator(); - } - - public Row createRow(int rownum) { - return sheet.createRow(rownum); - } - - public void removeRow(Row row) { - sheet.removeRow(row); - } - - - public Row getRow(int rownum) { - return sheet.getRow(rownum); - } - - - public int getPhysicalNumberOfRows() { - return sheet.getPhysicalNumberOfRows(); - } - - - public int getFirstRowNum() { - return Math.max(minRow, sheet.getFirstRowNum()); - } - - - public int getLastRowNum() { - return Math.min(maxRow, sheet.getLastRowNum()); - } - - - public void setColumnHidden(int columnIndex, boolean hidden) { - sheet.setColumnHidden(columnIndex, hidden); - } - - - public boolean isColumnHidden(int columnIndex) { - return sheet.isColumnHidden(columnIndex); - } - - - public void setRightToLeft(boolean value) { - sheet.setRightToLeft(value); - } - - - public boolean isRightToLeft() { - return sheet.isRightToLeft(); - } - - - public void setColumnWidth(int columnIndex, int width) { - sheet.setColumnWidth(columnIndex, width); - } - - - public int getColumnWidth(int columnIndex) { - return sheet.getColumnWidth(columnIndex); - } - - - public void setDefaultColumnWidth(int width) { - sheet.setDefaultColumnWidth(width); - } - - - public int getDefaultColumnWidth() { - return sheet.getDefaultColumnWidth(); - } - - - public short getDefaultRowHeight() { - return sheet.getDefaultRowHeight(); - } - - - public float getDefaultRowHeightInPoints() { - return sheet.getDefaultRowHeightInPoints(); - } - - - public void setDefaultRowHeight(short height) { - sheet.setDefaultRowHeight(height); - } - - - public void setDefaultRowHeightInPoints(float height) { - sheet.setDefaultRowHeightInPoints(height); - } - - - public CellStyle getColumnStyle(int column) { - return sheet.getColumnStyle(column); - } - - - public int addMergedRegion(CellRangeAddress region) { - return sheet.addMergedRegion(region); - } - - - public void setVerticallyCenter(boolean value) { - sheet.setVerticallyCenter(value); - } - - - public void setHorizontallyCenter(boolean value) { - sheet.setHorizontallyCenter(value); - } - - - public boolean getHorizontallyCenter() { - return sheet.getHorizontallyCenter(); - } - - - public boolean getVerticallyCenter() { - return sheet.getVerticallyCenter(); - } - - - public void removeMergedRegion(int index) { - sheet.removeMergedRegion(index); - } - - - public int getNumMergedRegions() { - return sheet.getNumMergedRegions(); - } - - - public CellRangeAddress getMergedRegion(int index) { - return sheet.getMergedRegion(index); - } - - - public Iterator rowIterator() { - return new FilteredIterator( sheet.rowIterator(), minRow, maxRow ); - } - - - public void setForceFormulaRecalculation(boolean value) { - sheet.setForceFormulaRecalculation(value); - } - - - public boolean getForceFormulaRecalculation() { - return sheet.getForceFormulaRecalculation(); - } - - - public void setAutobreaks(boolean value) { - sheet.setAutobreaks(value); - } - - - public void setDisplayGuts(boolean value) { - sheet.setDisplayGuts(value); - } - - - public void setDisplayZeros(boolean value) { - sheet.setDisplayZeros(value); - } - - - public boolean isDisplayZeros() { - return sheet.isDisplayZeros(); - } - - - public void setFitToPage(boolean value) { - sheet.setFitToPage(value); - } - - - public void setRowSumsBelow(boolean value) { - sheet.setRowSumsBelow(value); - } - - - public void setRowSumsRight(boolean value) { - sheet.setRowSumsRight(value); - } - - - public boolean getAutobreaks() { - return sheet.getAutobreaks(); - } - - - public boolean getDisplayGuts() { - return sheet.getDisplayGuts(); - } - - - public boolean getFitToPage() { - return sheet.getFitToPage(); - } - - - public boolean getRowSumsBelow() { - return sheet.getRowSumsBelow(); - } - - - public boolean getRowSumsRight() { - return sheet.getRowSumsRight(); - } - - - public boolean isPrintGridlines() { - return sheet.isPrintGridlines(); - } - - - public void setPrintGridlines(boolean show) { - sheet.setPrintGridlines(show); - } - - - public PrintSetup getPrintSetup() { - return sheet.getPrintSetup(); - } - - - public Header getHeader() { - return sheet.getHeader(); - } - - - public Footer getFooter() { - return sheet.getFooter(); - } - - - public void setSelected(boolean value) { - sheet.setSelected(value); - } - - - public double getMargin(short margin) { - return sheet.getMargin(margin); - } - - - public void setMargin(short margin, double size) { - sheet.setMargin(margin, size); - } - - - public boolean getProtect() { - return sheet.getProtect(); - } - - - public void protectSheet(String password) { - sheet.protectSheet(password); - } - - - public boolean getScenarioProtect() { - return sheet.getScenarioProtect(); - } - - - public void setZoom(int numerator, int denominator) { - sheet.setZoom(numerator / denominator); - } - - - public short getTopRow() { - return sheet.getTopRow(); - } - - - public short getLeftCol() { - return sheet.getLeftCol(); - } - - - public void showInPane(short toprow, short leftcol) { - sheet.showInPane(toprow, leftcol); - } - - - public void shiftRows(int startRow, int endRow, int n) { - sheet.shiftRows(startRow, endRow, n); - } - - - public void shiftRows(int startRow, int endRow, int n, - boolean copyRowHeight, boolean resetOriginalRowHeight) { - sheet.shiftRows(startRow, endRow, n, copyRowHeight, resetOriginalRowHeight); - } - - - public void createFreezePane(int colSplit, int rowSplit, - int leftmostColumn, int topRow) { - sheet.createFreezePane(colSplit, rowSplit, leftmostColumn, topRow); - } - - - public void createFreezePane(int colSplit, int rowSplit) { - sheet.createFreezePane(colSplit, rowSplit); - } - - - public void createSplitPane(int xSplitPos, int ySplitPos, - int leftmostColumn, int topRow, int activePane) { - sheet.createSplitPane(xSplitPos, ySplitPos, leftmostColumn, topRow, activePane); - } - - - public PaneInformation getPaneInformation() { - return sheet.getPaneInformation(); - } - - - public void setDisplayGridlines(boolean show) { - sheet.setDisplayGridlines(show); - } - - - public boolean isDisplayGridlines() { - // TODO Auto-generated method stub - return sheet.isDisplayGridlines(); - } - - - public void setDisplayFormulas(boolean show) { - sheet.setDisplayFormulas(show); - } - - - public boolean isDisplayFormulas() { - return sheet.isDisplayFormulas(); - } - - - public void setDisplayRowColHeadings(boolean show) { - sheet.setDisplayRowColHeadings(show); - } - - - public boolean isDisplayRowColHeadings() { - return sheet.isDisplayRowColHeadings(); - } - - - public void setRowBreak(int row) { - sheet.setRowBreak(row); - } - - - public boolean isRowBroken(int row) { - return sheet.isRowBroken(row); - } - - - public void removeRowBreak(int row) { - sheet.removeRowBreak(row); - } - - - public int[] getRowBreaks() { - return sheet.getRowBreaks(); - } - - - public int[] getColumnBreaks() { - return sheet.getColumnBreaks(); - } - - - public void setColumnBreak(int column) { - sheet.setColumnBreak(column); - } - - - public boolean isColumnBroken(int column) { - // TODO Auto-generated method stub - return sheet.isColumnBroken(column); - } - - - public void removeColumnBreak(int column) { - sheet.removeColumnBreak(column); - } - - - public void setColumnGroupCollapsed(int columnNumber, boolean collapsed) { - sheet.setColumnGroupCollapsed(columnNumber, collapsed); - } - - - public void groupColumn(int fromColumn, int toColumn) { - sheet.groupColumn(fromColumn, toColumn); - } - - - public void ungroupColumn(int fromColumn, int toColumn) { - sheet.ungroupColumn(fromColumn, toColumn); - } - - - public void groupRow(int fromRow, int toRow) { - sheet.groupRow(fromRow, toRow); - } - - - public void ungroupRow(int fromRow, int toRow) { - sheet.ungroupRow(fromRow, toRow); - } - - - public void setRowGroupCollapsed(int row, boolean collapse) { - sheet.setRowGroupCollapsed(row, collapse); - } - - - public void setDefaultColumnStyle(int column, CellStyle style) { - sheet.setDefaultColumnStyle(column, style); - } - - - public void autoSizeColumn(int column) { - sheet.autoSizeColumn(column); - } - - - public void autoSizeColumn(int column, boolean useMergedCells) { - sheet.autoSizeColumn(column, useMergedCells); - } - - - public Comment getCellComment(int row, int column) { - CellAddress address = new CellAddress(row, column); - return sheet.getCellComment(address); - } - - - public Drawing createDrawingPatriarch() { - return sheet.createDrawingPatriarch(); - } - - - public Workbook getWorkbook() { - return sheet.getWorkbook(); - } - - - public String getSheetName() { - return sheet.getSheetName(); - } - - - public boolean isSelected() { - return sheet.isSelected(); - } - - - public CellRange setArrayFormula(String formula, - CellRangeAddress range) { - return sheet.setArrayFormula(formula, range); - } - - - public CellRange removeArrayFormula(Cell cell) { - return sheet.removeArrayFormula(cell); - } - - - public DataValidationHelper getDataValidationHelper() { - return sheet.getDataValidationHelper(); - } - - - public void addValidationData(DataValidation dataValidation) { - sheet.addValidationData(dataValidation); - } - - - public AutoFilter setAutoFilter(CellRangeAddress range) { - return sheet.setAutoFilter(range); - } - - - public SheetConditionalFormatting getSheetConditionalFormatting() { - return sheet.getSheetConditionalFormatting(); - } - - @Override - public int addMergedRegionUnsafe(CellRangeAddress arg0) { - return sheet.addMergedRegionUnsafe(arg0); - } - - @Override - public CellAddress getActiveCell() { - return sheet.getActiveCell(); - } - - @Override - public Comment getCellComment(CellAddress arg0) { - return sheet.getCellComment(arg0); - } - - @Override - public Map getCellComments() { - return sheet.getCellComments(); - } - - @Override - public int getColumnOutlineLevel(int arg0) { - return sheet.getColumnOutlineLevel(arg0); - } - - @Override - public float getColumnWidthInPixels(int arg0) { - return sheet.getColumnWidthInPixels(arg0); - } - - @Override - public List getDataValidations() { - return sheet.getDataValidations(); - } - - @Override - public Drawing getDrawingPatriarch() { - return sheet.getDrawingPatriarch(); - } - - @Override - public Hyperlink getHyperlink(CellAddress arg0) { - return sheet.getHyperlink(arg0); - } - - @Override - public Hyperlink getHyperlink(int arg0, int arg1) { - return sheet.getHyperlink(arg0, arg1); - } - - @Override - public List getHyperlinkList() { - return sheet.getHyperlinkList(); - } - - @Override - public List getMergedRegions() { - return sheet.getMergedRegions(); - } - - @Override - public boolean isPrintRowAndColumnHeadings() { - return sheet.isPrintRowAndColumnHeadings(); - } - - @Override - public void removeMergedRegions(Collection arg0) { - sheet.removeMergedRegions(arg0); - } - - @Override - public void setActiveCell(CellAddress arg0) { - sheet.setActiveCell(arg0); - } - - @Override - public void setPrintRowAndColumnHeadings(boolean arg0) { - sheet.setPrintRowAndColumnHeadings(arg0); - } - - @Override - public void setZoom(int arg0) { - sheet.setZoom(arg0); - } - - @Override - public void shiftColumns(int arg0, int arg1, int arg2) { - sheet.shiftColumns(arg0, arg1, arg2); - } - - @Override - public void showInPane(int arg0, int arg1) { - sheet.showInPane(arg0, arg1); - } - - @Override - public void validateMergedRegions() { - sheet.validateMergedRegions(); - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.poi.ss.usermodel.AutoFilter; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellRange; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Comment; +import org.apache.poi.ss.usermodel.DataValidation; +import org.apache.poi.ss.usermodel.DataValidationHelper; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.Footer; +import org.apache.poi.ss.usermodel.Header; +import org.apache.poi.ss.usermodel.Hyperlink; +import org.apache.poi.ss.usermodel.PrintSetup; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.SheetConditionalFormatting; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellAddress; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.PaneInformation; + +public class FilteredSheet implements Sheet { + + private Sheet sheet; + private int minRow; + private int maxRow; + + public FilteredSheet(Sheet sheet, int minRow, int maxRow) { + this.sheet = sheet; + this.minRow = minRow; + this.maxRow = maxRow; + } + + private class FilteredIterator implements Iterator { + + private Iterator iter; + private int minRow; + private int maxRow; + private Row cur; + + public FilteredIterator(Iterator iter, int minRow, int maxRow) { + this.iter = iter; + this.minRow = minRow; + this.maxRow = maxRow; + } + + public boolean hasNext() { + if( iter.hasNext() ) { + cur = iter.next(); + while( cur.getRowNum() < minRow ) { + if( ! iter.hasNext() ) { + return false; + } + cur = iter.next(); + } + if( cur.getRowNum() > maxRow ) { + return false; + } + return true; + } + return false; + } + + public Row next() { + return cur; + } + + public void remove() { + iter.remove(); + } + + } + + public CellRangeAddress getRepeatingColumns() { + return sheet.getRepeatingColumns(); + } + + public CellRangeAddress getRepeatingRows() { + // TODO Auto-generated method stub + return sheet.getRepeatingRows(); + } + + public void setRepeatingColumns(CellRangeAddress arg0) { + sheet.setRepeatingColumns(arg0); + } + + public void setRepeatingRows(CellRangeAddress arg0) { + sheet.setRepeatingRows(arg0); + } + + public Iterator iterator() { + return rowIterator(); + } + + public Row createRow(int rownum) { + return sheet.createRow(rownum); + } + + public void removeRow(Row row) { + sheet.removeRow(row); + } + + + public Row getRow(int rownum) { + return sheet.getRow(rownum); + } + + + public int getPhysicalNumberOfRows() { + return sheet.getPhysicalNumberOfRows(); + } + + + public int getFirstRowNum() { + return Math.max(minRow, sheet.getFirstRowNum()); + } + + + public int getLastRowNum() { + return Math.min(maxRow, sheet.getLastRowNum()); + } + + + public void setColumnHidden(int columnIndex, boolean hidden) { + sheet.setColumnHidden(columnIndex, hidden); + } + + + public boolean isColumnHidden(int columnIndex) { + return sheet.isColumnHidden(columnIndex); + } + + + public void setRightToLeft(boolean value) { + sheet.setRightToLeft(value); + } + + + public boolean isRightToLeft() { + return sheet.isRightToLeft(); + } + + + public void setColumnWidth(int columnIndex, int width) { + sheet.setColumnWidth(columnIndex, width); + } + + + public int getColumnWidth(int columnIndex) { + return sheet.getColumnWidth(columnIndex); + } + + + public void setDefaultColumnWidth(int width) { + sheet.setDefaultColumnWidth(width); + } + + + public int getDefaultColumnWidth() { + return sheet.getDefaultColumnWidth(); + } + + + public short getDefaultRowHeight() { + return sheet.getDefaultRowHeight(); + } + + + public float getDefaultRowHeightInPoints() { + return sheet.getDefaultRowHeightInPoints(); + } + + + public void setDefaultRowHeight(short height) { + sheet.setDefaultRowHeight(height); + } + + + public void setDefaultRowHeightInPoints(float height) { + sheet.setDefaultRowHeightInPoints(height); + } + + + public CellStyle getColumnStyle(int column) { + return sheet.getColumnStyle(column); + } + + + public int addMergedRegion(CellRangeAddress region) { + return sheet.addMergedRegion(region); + } + + + public void setVerticallyCenter(boolean value) { + sheet.setVerticallyCenter(value); + } + + + public void setHorizontallyCenter(boolean value) { + sheet.setHorizontallyCenter(value); + } + + + public boolean getHorizontallyCenter() { + return sheet.getHorizontallyCenter(); + } + + + public boolean getVerticallyCenter() { + return sheet.getVerticallyCenter(); + } + + + public void removeMergedRegion(int index) { + sheet.removeMergedRegion(index); + } + + + public int getNumMergedRegions() { + return sheet.getNumMergedRegions(); + } + + + public CellRangeAddress getMergedRegion(int index) { + return sheet.getMergedRegion(index); + } + + + public Iterator rowIterator() { + return new FilteredIterator( sheet.rowIterator(), minRow, maxRow ); + } + + + public void setForceFormulaRecalculation(boolean value) { + sheet.setForceFormulaRecalculation(value); + } + + + public boolean getForceFormulaRecalculation() { + return sheet.getForceFormulaRecalculation(); + } + + + public void setAutobreaks(boolean value) { + sheet.setAutobreaks(value); + } + + + public void setDisplayGuts(boolean value) { + sheet.setDisplayGuts(value); + } + + + public void setDisplayZeros(boolean value) { + sheet.setDisplayZeros(value); + } + + + public boolean isDisplayZeros() { + return sheet.isDisplayZeros(); + } + + + public void setFitToPage(boolean value) { + sheet.setFitToPage(value); + } + + + public void setRowSumsBelow(boolean value) { + sheet.setRowSumsBelow(value); + } + + + public void setRowSumsRight(boolean value) { + sheet.setRowSumsRight(value); + } + + + public boolean getAutobreaks() { + return sheet.getAutobreaks(); + } + + + public boolean getDisplayGuts() { + return sheet.getDisplayGuts(); + } + + + public boolean getFitToPage() { + return sheet.getFitToPage(); + } + + + public boolean getRowSumsBelow() { + return sheet.getRowSumsBelow(); + } + + + public boolean getRowSumsRight() { + return sheet.getRowSumsRight(); + } + + + public boolean isPrintGridlines() { + return sheet.isPrintGridlines(); + } + + + public void setPrintGridlines(boolean show) { + sheet.setPrintGridlines(show); + } + + + public PrintSetup getPrintSetup() { + return sheet.getPrintSetup(); + } + + + public Header getHeader() { + return sheet.getHeader(); + } + + + public Footer getFooter() { + return sheet.getFooter(); + } + + + public void setSelected(boolean value) { + sheet.setSelected(value); + } + + + public double getMargin(short margin) { + return sheet.getMargin(margin); + } + + + public void setMargin(short margin, double size) { + sheet.setMargin(margin, size); + } + + + public boolean getProtect() { + return sheet.getProtect(); + } + + + public void protectSheet(String password) { + sheet.protectSheet(password); + } + + + public boolean getScenarioProtect() { + return sheet.getScenarioProtect(); + } + + + public void setZoom(int numerator, int denominator) { + sheet.setZoom(numerator / denominator); + } + + + public short getTopRow() { + return sheet.getTopRow(); + } + + + public short getLeftCol() { + return sheet.getLeftCol(); + } + + + public void showInPane(short toprow, short leftcol) { + sheet.showInPane(toprow, leftcol); + } + + + public void shiftRows(int startRow, int endRow, int n) { + sheet.shiftRows(startRow, endRow, n); + } + + + public void shiftRows(int startRow, int endRow, int n, + boolean copyRowHeight, boolean resetOriginalRowHeight) { + sheet.shiftRows(startRow, endRow, n, copyRowHeight, resetOriginalRowHeight); + } + + + public void createFreezePane(int colSplit, int rowSplit, + int leftmostColumn, int topRow) { + sheet.createFreezePane(colSplit, rowSplit, leftmostColumn, topRow); + } + + + public void createFreezePane(int colSplit, int rowSplit) { + sheet.createFreezePane(colSplit, rowSplit); + } + + + public void createSplitPane(int xSplitPos, int ySplitPos, + int leftmostColumn, int topRow, int activePane) { + sheet.createSplitPane(xSplitPos, ySplitPos, leftmostColumn, topRow, activePane); + } + + + public PaneInformation getPaneInformation() { + return sheet.getPaneInformation(); + } + + + public void setDisplayGridlines(boolean show) { + sheet.setDisplayGridlines(show); + } + + + public boolean isDisplayGridlines() { + // TODO Auto-generated method stub + return sheet.isDisplayGridlines(); + } + + + public void setDisplayFormulas(boolean show) { + sheet.setDisplayFormulas(show); + } + + + public boolean isDisplayFormulas() { + return sheet.isDisplayFormulas(); + } + + + public void setDisplayRowColHeadings(boolean show) { + sheet.setDisplayRowColHeadings(show); + } + + + public boolean isDisplayRowColHeadings() { + return sheet.isDisplayRowColHeadings(); + } + + + public void setRowBreak(int row) { + sheet.setRowBreak(row); + } + + + public boolean isRowBroken(int row) { + return sheet.isRowBroken(row); + } + + + public void removeRowBreak(int row) { + sheet.removeRowBreak(row); + } + + + public int[] getRowBreaks() { + return sheet.getRowBreaks(); + } + + + public int[] getColumnBreaks() { + return sheet.getColumnBreaks(); + } + + + public void setColumnBreak(int column) { + sheet.setColumnBreak(column); + } + + + public boolean isColumnBroken(int column) { + // TODO Auto-generated method stub + return sheet.isColumnBroken(column); + } + + + public void removeColumnBreak(int column) { + sheet.removeColumnBreak(column); + } + + + public void setColumnGroupCollapsed(int columnNumber, boolean collapsed) { + sheet.setColumnGroupCollapsed(columnNumber, collapsed); + } + + + public void groupColumn(int fromColumn, int toColumn) { + sheet.groupColumn(fromColumn, toColumn); + } + + + public void ungroupColumn(int fromColumn, int toColumn) { + sheet.ungroupColumn(fromColumn, toColumn); + } + + + public void groupRow(int fromRow, int toRow) { + sheet.groupRow(fromRow, toRow); + } + + + public void ungroupRow(int fromRow, int toRow) { + sheet.ungroupRow(fromRow, toRow); + } + + + public void setRowGroupCollapsed(int row, boolean collapse) { + sheet.setRowGroupCollapsed(row, collapse); + } + + + public void setDefaultColumnStyle(int column, CellStyle style) { + sheet.setDefaultColumnStyle(column, style); + } + + + public void autoSizeColumn(int column) { + sheet.autoSizeColumn(column); + } + + + public void autoSizeColumn(int column, boolean useMergedCells) { + sheet.autoSizeColumn(column, useMergedCells); + } + + + public Comment getCellComment(int row, int column) { + CellAddress address = new CellAddress(row, column); + return sheet.getCellComment(address); + } + + + public Drawing createDrawingPatriarch() { + return sheet.createDrawingPatriarch(); + } + + + public Workbook getWorkbook() { + return sheet.getWorkbook(); + } + + + public String getSheetName() { + return sheet.getSheetName(); + } + + + public boolean isSelected() { + return sheet.isSelected(); + } + + + public CellRange setArrayFormula(String formula, + CellRangeAddress range) { + return sheet.setArrayFormula(formula, range); + } + + + public CellRange removeArrayFormula(Cell cell) { + return sheet.removeArrayFormula(cell); + } + + + public DataValidationHelper getDataValidationHelper() { + return sheet.getDataValidationHelper(); + } + + + public void addValidationData(DataValidation dataValidation) { + sheet.addValidationData(dataValidation); + } + + + public AutoFilter setAutoFilter(CellRangeAddress range) { + return sheet.setAutoFilter(range); + } + + + public SheetConditionalFormatting getSheetConditionalFormatting() { + return sheet.getSheetConditionalFormatting(); + } + + @Override + public int addMergedRegionUnsafe(CellRangeAddress arg0) { + return sheet.addMergedRegionUnsafe(arg0); + } + + @Override + public CellAddress getActiveCell() { + return sheet.getActiveCell(); + } + + @Override + public Comment getCellComment(CellAddress arg0) { + return sheet.getCellComment(arg0); + } + + @Override + public Map getCellComments() { + return sheet.getCellComments(); + } + + @Override + public int getColumnOutlineLevel(int arg0) { + return sheet.getColumnOutlineLevel(arg0); + } + + @Override + public float getColumnWidthInPixels(int arg0) { + return sheet.getColumnWidthInPixels(arg0); + } + + @Override + public List getDataValidations() { + return sheet.getDataValidations(); + } + + @Override + public Drawing getDrawingPatriarch() { + return sheet.getDrawingPatriarch(); + } + + @Override + public Hyperlink getHyperlink(CellAddress arg0) { + return sheet.getHyperlink(arg0); + } + + @Override + public Hyperlink getHyperlink(int arg0, int arg1) { + return sheet.getHyperlink(arg0, arg1); + } + + @Override + public List getHyperlinkList() { + return sheet.getHyperlinkList(); + } + + @Override + public List getMergedRegions() { + return sheet.getMergedRegions(); + } + + @Override + public boolean isPrintRowAndColumnHeadings() { + return sheet.isPrintRowAndColumnHeadings(); + } + + @Override + public void removeMergedRegions(Collection arg0) { + sheet.removeMergedRegions(arg0); + } + + @Override + public void setActiveCell(CellAddress arg0) { + sheet.setActiveCell(arg0); + } + + @Override + public void setPrintRowAndColumnHeadings(boolean arg0) { + sheet.setPrintRowAndColumnHeadings(arg0); + } + + @Override + public void setZoom(int arg0) { + sheet.setZoom(arg0); + } + + @Override + public void shiftColumns(int arg0, int arg1, int arg2) { + sheet.shiftColumns(arg0, arg1, arg2); + } + + @Override + public void showInPane(int arg0, int arg1) { + sheet.showInPane(arg0, arg1); + } + + @Override + public void validateMergedRegions() { + sheet.validateMergedRegions(); + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/HandlerState.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/HandlerState.java index 59f262d3d..bc8779c8c 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/HandlerState.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/HandlerState.java @@ -1,294 +1,294 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.eclipse.birt.report.engine.api.IRenderOption; -import org.eclipse.birt.report.engine.api.ReportEngine; -import org.eclipse.birt.report.engine.emitter.IContentEmitter; - -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; -import uk.co.spudsoft.birt.emitters.excel.handlers.IHandler; - -public class HandlerState { - - /** - * The emitter itself - */ - private IContentEmitter emitter; - /** - * Logger. - */ - private Logger log; - /** - * Set of functions for carrying out conversions between BIRT and POI. - */ - private StyleManagerUtils smu; - - /** - * The current handler to pass on the processing to. - * Effectively this is the state machine for the emitter. - */ - private IHandler handler; - - /** - * The workbook being generated. - */ - private Workbook wb; - /** - * Style cache, to enable reuse of styles between cells. - */ - private StyleManager sm; - /** - * Render options - */ - private IRenderOption renderOptions; - /** - * Report engine - */ - private ReportEngine reportEngine; - - /** - * The current POI sheet being processed. - */ - public Sheet currentSheet; - /** - * Collection of CellImage objects for the current sheet. - */ - public List images = new ArrayList(); - /** - * Possible name for the current sheet - */ - public String sheetName; - /** - * Possible password for the current sheet - */ - public String sheetPassword; - /** - * The index of the row that should be created next - */ - public int rowNum; - /** - * The index of the column in which the next data should begin - */ - public int colNum; - /** - * The minimum row height required for this top level row - */ - public float requiredRowHeightInPoints; - public int rowOffset; - public int colOffset; - /** - * Set to true when end() is called and pageEnd has to be called - */ - public boolean reportEnding; - - - /** - * Border overrides for the current row/table - */ - public List areaBorders = new ArrayList(); - - /** - * List of Current Spans - * We could probably use CellRangeAdresses inside the sheet, but - * this way we keep the tests to a minimum. - */ - public List rowSpans = new ArrayList(); - - /** - * List of sheet names - * This map contains the names of sheets created by the emitter along with a count of sheets with that name - * Sheets after the first have the count appended to the name - * Any other sheets that exist in the workbook may be overwritten - */ - public Map sheetNames = new HashMap(); - - /** - * Constructor - * @param log - * @param smu - * @param wb - * @param sm - */ - public HandlerState(IContentEmitter emitter, Logger log, StyleManagerUtils smu, Workbook wb, StyleManager sm, IRenderOption renderOptions) { - super(); - this.emitter = emitter; - this.log = log; - this.smu = smu; - this.wb = wb; - this.sm = sm; - this.renderOptions = renderOptions; - } - - public IContentEmitter getEmitter() { - return emitter; - } - - public Logger getLog() { - return log; - } - - public StyleManagerUtils getSmu() { - return smu; - } - - public Workbook getWb() { - return wb; - } - - public StyleManager getSm() { - return sm; - } - - public IRenderOption getRenderOptions() { - return renderOptions; - } - - public ReportEngine getReportEngine() { - return reportEngine; - } - - public IHandler getHandler() { - return handler; - } - - public void setHandler(IHandler handler) { - this.handler = handler; - this.handler.notifyHandler(this); - } - - public void insertBorderOverload(AreaBorders defn) { - if( areaBorders == null ) { - areaBorders = new ArrayList(); - } - areaBorders.add( defn ); - } - - public void removeBorderOverload(AreaBorders defn) { - if( areaBorders != null ) { - areaBorders.remove(defn); - } - } - - public boolean cellIsMergedWithBorders( int row, int column ) { - if( areaBorders != null ) { - for( AreaBorders areaBorder : areaBorders ) { - if( ( areaBorder.isMergedCells ) - && ( areaBorder.top == row ) - && ( areaBorder.left == column ) ) { - return true; - } - } - - } - return false; - } - - public boolean rowHasMergedCellsWithBorders( int row ) { - if( areaBorders != null ) { - for( AreaBorders areaBorder : areaBorders ) { - if( ( areaBorder.isMergedCells ) - && ( areaBorder.top <= row ) - && ( areaBorder.bottom >= row ) ) { - return true; - } - } - } - return false; - } - - public Area addRowSpan(int rowX, int colX, int rowY, int colY) { - log.debug( "addRowSpan [" + rowX + "," + colX + "] - [" + rowY + "," + colY + "]" ); - Area area = new Area(new Coordinate(rowX, colX), new Coordinate(rowY, colY)); - rowSpans.add(area); - return area; - } - - public int computeNumberSpanBefore(int row, int col) { - int i = 0; - for(Area a : rowSpans) { - log.debug( "Considering span [ ", a.x.getRow(), ",", a.x.getCol(), "]-[", a.y.getRow(), ",", a.y.getCol(), "] for ", row, ",", col ); - - // I'm now not removing passed spans, so do check a.y.row() - if( a.y.getRow() < row ) { - continue; - } - - //Correct this col to know the real col number - if(a.x.getCol() <= col) { - col += (a.y.getCol() - a.x.getCol()) + 1; - } - if(row > a.x.getRow() //Span on first appearance is ok. - && a.x.getCol() <= col //This span is before this column - ) { - i += (a.y.getCol() - a.x.getCol()) + 1; - } - } - return i; - } - - public boolean rowHasSpans( int row ) { - for(Area a : rowSpans) { - // I'm now not removing passed spans, so do check a.y.row() - if( a.y.getRow() < row ) { - continue; - } - return true; - } - - return false; - } - - public float calculateRowSpanHeightRequirement( int row ) { - float result = 0F; - - for(Area a : rowSpans) { - // I'm now not removing passed spans, so do check a.y.row() - if( a.y.getRow() < row ) { - continue; - } - - float heightUnaccountedFor = a.height; - for( int componentRow = a.x.getRow(); componentRow < row; ++componentRow ) { - heightUnaccountedFor -= currentSheet.getRow( componentRow ).getHeightInPoints(); - } - float heightPerRowRemainig = heightUnaccountedFor / ( 1 + a.y.getRow() - row ); - if( heightPerRowRemainig > result ) { - result = heightPerRowRemainig; - } - } - - return result; - } - - public void clearRowSpans() { - rowSpans.clear(); - } - - public int findRowsSpanned( int rowX, int colX ) { - for( Area a : rowSpans ) { - if( ( a.x.getRow() == rowX ) && ( a.x.getCol() == colX ) ) { - return a.y.getRow() - a.x.getRow(); - } - } - return 0; - } -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.eclipse.birt.report.engine.api.IRenderOption; +import org.eclipse.birt.report.engine.api.ReportEngine; +import org.eclipse.birt.report.engine.emitter.IContentEmitter; + +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; +import uk.co.spudsoft.birt.emitters.excel.handlers.IHandler; + +public class HandlerState { + + /** + * The emitter itself + */ + private IContentEmitter emitter; + /** + * Logger. + */ + private Logger log; + /** + * Set of functions for carrying out conversions between BIRT and POI. + */ + private StyleManagerUtils smu; + + /** + * The current handler to pass on the processing to. + * Effectively this is the state machine for the emitter. + */ + private IHandler handler; + + /** + * The workbook being generated. + */ + private Workbook wb; + /** + * Style cache, to enable reuse of styles between cells. + */ + private StyleManager sm; + /** + * Render options + */ + private IRenderOption renderOptions; + /** + * Report engine + */ + private ReportEngine reportEngine; + + /** + * The current POI sheet being processed. + */ + public Sheet currentSheet; + /** + * Collection of CellImage objects for the current sheet. + */ + public List images = new ArrayList(); + /** + * Possible name for the current sheet + */ + public String sheetName; + /** + * Possible password for the current sheet + */ + public String sheetPassword; + /** + * The index of the row that should be created next + */ + public int rowNum; + /** + * The index of the column in which the next data should begin + */ + public int colNum; + /** + * The minimum row height required for this top level row + */ + public float requiredRowHeightInPoints; + public int rowOffset; + public int colOffset; + /** + * Set to true when end() is called and pageEnd has to be called + */ + public boolean reportEnding; + + + /** + * Border overrides for the current row/table + */ + public List areaBorders = new ArrayList(); + + /** + * List of Current Spans + * We could probably use CellRangeAdresses inside the sheet, but + * this way we keep the tests to a minimum. + */ + public List rowSpans = new ArrayList(); + + /** + * List of sheet names + * This map contains the names of sheets created by the emitter along with a count of sheets with that name + * Sheets after the first have the count appended to the name + * Any other sheets that exist in the workbook may be overwritten + */ + public Map sheetNames = new HashMap(); + + /** + * Constructor + * @param log + * @param smu + * @param wb + * @param sm + */ + public HandlerState(IContentEmitter emitter, Logger log, StyleManagerUtils smu, Workbook wb, StyleManager sm, IRenderOption renderOptions) { + super(); + this.emitter = emitter; + this.log = log; + this.smu = smu; + this.wb = wb; + this.sm = sm; + this.renderOptions = renderOptions; + } + + public IContentEmitter getEmitter() { + return emitter; + } + + public Logger getLog() { + return log; + } + + public StyleManagerUtils getSmu() { + return smu; + } + + public Workbook getWb() { + return wb; + } + + public StyleManager getSm() { + return sm; + } + + public IRenderOption getRenderOptions() { + return renderOptions; + } + + public ReportEngine getReportEngine() { + return reportEngine; + } + + public IHandler getHandler() { + return handler; + } + + public void setHandler(IHandler handler) { + this.handler = handler; + this.handler.notifyHandler(this); + } + + public void insertBorderOverload(AreaBorders defn) { + if( areaBorders == null ) { + areaBorders = new ArrayList(); + } + areaBorders.add( defn ); + } + + public void removeBorderOverload(AreaBorders defn) { + if( areaBorders != null ) { + areaBorders.remove(defn); + } + } + + public boolean cellIsMergedWithBorders( int row, int column ) { + if( areaBorders != null ) { + for( AreaBorders areaBorder : areaBorders ) { + if( ( areaBorder.isMergedCells ) + && ( areaBorder.top == row ) + && ( areaBorder.left == column ) ) { + return true; + } + } + + } + return false; + } + + public boolean rowHasMergedCellsWithBorders( int row ) { + if( areaBorders != null ) { + for( AreaBorders areaBorder : areaBorders ) { + if( ( areaBorder.isMergedCells ) + && ( areaBorder.top <= row ) + && ( areaBorder.bottom >= row ) ) { + return true; + } + } + } + return false; + } + + public Area addRowSpan(int rowX, int colX, int rowY, int colY) { + log.debug( "addRowSpan [" + rowX + "," + colX + "] - [" + rowY + "," + colY + "]" ); + Area area = new Area(new Coordinate(rowX, colX), new Coordinate(rowY, colY)); + rowSpans.add(area); + return area; + } + + public int computeNumberSpanBefore(int row, int col) { + int i = 0; + for(Area a : rowSpans) { + log.debug( "Considering span [ ", a.x.getRow(), ",", a.x.getCol(), "]-[", a.y.getRow(), ",", a.y.getCol(), "] for ", row, ",", col ); + + // I'm now not removing passed spans, so do check a.y.row() + if( a.y.getRow() < row ) { + continue; + } + + //Correct this col to know the real col number + if(a.x.getCol() <= col) { + col += (a.y.getCol() - a.x.getCol()) + 1; + } + if(row > a.x.getRow() //Span on first appearance is ok. + && a.x.getCol() <= col //This span is before this column + ) { + i += (a.y.getCol() - a.x.getCol()) + 1; + } + } + return i; + } + + public boolean rowHasSpans( int row ) { + for(Area a : rowSpans) { + // I'm now not removing passed spans, so do check a.y.row() + if( a.y.getRow() < row ) { + continue; + } + return true; + } + + return false; + } + + public float calculateRowSpanHeightRequirement( int row ) { + float result = 0F; + + for(Area a : rowSpans) { + // I'm now not removing passed spans, so do check a.y.row() + if( a.y.getRow() < row ) { + continue; + } + + float heightUnaccountedFor = a.height; + for( int componentRow = a.x.getRow(); componentRow < row; ++componentRow ) { + heightUnaccountedFor -= currentSheet.getRow( componentRow ).getHeightInPoints(); + } + float heightPerRowRemainig = heightUnaccountedFor / ( 1 + a.y.getRow() - row ); + if( heightPerRowRemainig > result ) { + result = heightPerRowRemainig; + } + } + + return result; + } + + public void clearRowSpans() { + rowSpans.clear(); + } + + public int findRowsSpanned( int rowX, int colX ) { + for( Area a : rowSpans ) { + if( ( a.x.getRow() == rowX ) && ( a.x.getCol() == colX ) ) { + return a.y.getRow() - a.x.getRow(); + } + } + return 0; + } +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/RichTextRun.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/RichTextRun.java index 0f34012aa..412a50e00 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/RichTextRun.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/RichTextRun.java @@ -1,51 +1,51 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel; - -import org.apache.poi.ss.usermodel.Font; - -/** - *

- * Class to capture the RichText information needed for nested (and HTML) cells. - *

- * In theory this information could be captured using the RichTextString class from POI, but - * experiments found that to produce NullPoiiunterExceptions and multiple entries in the XLSX files. - *

- * @author jtalbut - * - */ -public class RichTextRun { - /** - * The index of the first character to be formatted using this font. - */ - public int startIndex; - /** - * The font to apply to characters following this. - */ - public Font font; - - public RichTextRun(int startIndex, Font font) { - super(); - this.startIndex = startIndex; - this.font = font; - } - /** - * For debug purposes. - */ - @Override - public String toString() { - return "RichTextRun [" + startIndex + ", " + font.toString().replaceAll("\n", "") + "]"; - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel; + +import org.apache.poi.ss.usermodel.Font; + +/** + *

+ * Class to capture the RichText information needed for nested (and HTML) cells. + *

+ * In theory this information could be captured using the RichTextString class from POI, but + * experiments found that to produce NullPoiiunterExceptions and multiple entries in the XLSX files. + *

+ * @author jtalbut + * + */ +public class RichTextRun { + /** + * The index of the first character to be formatted using this font. + */ + public int startIndex; + /** + * The font to apply to characters following this. + */ + public Font font; + + public RichTextRun(int startIndex, Font font) { + super(); + this.startIndex = startIndex; + this.font = font; + } + /** + * For debug purposes. + */ + @Override + public String toString() { + return "RichTextRun [" + startIndex + ", " + font.toString().replaceAll("\n", "") + "]"; + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/StyleManagerHUtils.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/StyleManagerHUtils.java index bbb6c9d62..130ec115a 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/StyleManagerHUtils.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/StyleManagerHUtils.java @@ -1,287 +1,287 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel; - -import org.apache.poi.hssf.usermodel.HSSFCellStyle; -import org.apache.poi.hssf.usermodel.HSSFFont; -import org.apache.poi.hssf.usermodel.HSSFPalette; -import org.apache.poi.hssf.usermodel.HSSFRichTextString; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.hssf.util.HSSFColor; -import org.apache.poi.ss.usermodel.BorderStyle; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.FillPatternType; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.RichTextString; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder.BorderSide; -import org.eclipse.birt.report.engine.content.IPageContent; -import org.eclipse.birt.report.engine.content.IStyle; -import org.eclipse.birt.report.engine.css.dom.AreaStyle; -import org.eclipse.birt.report.engine.css.engine.StyleConstants; -import org.eclipse.birt.report.engine.ir.DimensionType; -import org.eclipse.birt.report.model.api.util.ColorUtil; -import org.w3c.dom.css.CSSValue; - -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -/** - * StyleManagerHUtils is an extension of the StyleManagerUtils to provide HSSFWorkbook specific functionality. - * @author Jim Talbut - * - */ -public class StyleManagerHUtils extends StyleManagerUtils { - private short paletteIndex = 64; - private static short minPaletteIndex = 40; - - private static Factory factory = new StyleManagerUtils.Factory() { - public StyleManagerUtils create(Logger log) { - return new StyleManagerHUtils(log); - } - }; - - public static Factory getFactory() { - return factory; - } - - - /** - * @param log - * Logger used by StyleManagerHUtils to record anything of interest. - */ - public StyleManagerHUtils(Logger log) { - super(log); - } - - @Override - public RichTextString createRichTextString(String value) { - return new HSSFRichTextString(value); - } - - /** - * Converts a BIRT border style into a POI border style (short constant defined in CellStyle). - * @param birtBorder - * The BIRT border style. - * @param width - * The width of the border as understood by BIRT. - * One of the CellStyle BORDER constants. - */ - private BorderStyle poiBorderStyleFromBirt( String birtBorder, String width ) { - if( "none".equals(birtBorder) ) { - return BorderStyle.NONE; - } - DimensionType dim = DimensionType.parserUnit( width ); - double pxWidth = 3.0; - if( ( dim != null ) && ( "px".equals(dim.getUnits()) ) ){ - pxWidth = dim.getMeasure(); - } - if( "solid".equals(birtBorder) ) { - if( pxWidth < 2.9 ) { - return BorderStyle.THIN; - } else if( pxWidth < 3.1 ) { - return BorderStyle.MEDIUM; - } else { - return BorderStyle.THICK; - } - } else if( "dashed".equals(birtBorder) ) { - if( pxWidth < 2.9 ) { - return BorderStyle.DASHED; - } else { - return BorderStyle.MEDIUM_DASHED; - } - } else if( "dotted".equals(birtBorder) ) { - return BorderStyle.DOTTED; - } else if( "double".equals(birtBorder) ) { - return BorderStyle.DOUBLE; - } else if( "none".equals(birtBorder) ) { - return BorderStyle.NONE; - } - - log.debug( "Border style \"", birtBorder, "\" is not recognised" ); - return BorderStyle.NONE; - } - - /** - * Get an HSSFPalette index for a workbook that closely approximates the passed in colour. - * @param workbook - * The workbook for which the colour is being sought. - * @param colour - * The colour, in the form "rgb(r, g, b)". - * The index into the HSSFPallete for the workbook for a colour that approximates the passed in colour. - */ - private short getHColour( HSSFWorkbook workbook, String colour ) { - int[] rgbInt = ColorUtil.getRGBs(colour); - if( rgbInt == null ) { - return 0; - } - - byte[] rgbByte = new byte[] { (byte)rgbInt[0], (byte)rgbInt[1], (byte)rgbInt[2] }; - HSSFPalette palette = workbook.getCustomPalette(); - - HSSFColor result = palette.findColor(rgbByte[0], rgbByte[1], rgbByte[2]); - if( result == null) { - if( paletteIndex > minPaletteIndex ) { - --paletteIndex; - palette.setColorAtIndex(paletteIndex, rgbByte[0], rgbByte[1], rgbByte[2]); - return paletteIndex; - } else { - result = palette.findSimilarColor(rgbByte[0], rgbByte[1], rgbByte[2]); - } - } - return result.getIndex(); - } - - @Override - public void applyBorderStyle(Workbook workbook, CellStyle style, BorderSide side, CSSValue colour, CSSValue borderStyle, CSSValue width) { - if( ( colour != null ) || ( borderStyle != null ) || ( width != null ) ) { - String colourString = colour == null ? "rgb(0,0,0)" : colour.getCssText(); - String borderStyleString = borderStyle == null ? "solid" : borderStyle.getCssText(); - String widthString = width == null ? "medium" : width.getCssText(); - - if( style instanceof HSSFCellStyle ) { - HSSFCellStyle hStyle = (HSSFCellStyle)style; - - BorderStyle hBorderStyle = poiBorderStyleFromBirt(borderStyleString, widthString); - short colourIndex = getHColour((HSSFWorkbook)workbook, colourString); - if( colourIndex > 0 ) { - if(hBorderStyle != BorderStyle.NONE) { - switch( side ) { - case TOP: - hStyle.setBorderTop(hBorderStyle); - hStyle.setTopBorderColor(colourIndex); - // log.debug( "Top border: " + xStyle.getBorderTop() + " / " + xStyle.getTopBorderXSSFColor().getARGBHex() ); - break; - case LEFT: - hStyle.setBorderLeft(hBorderStyle); - hStyle.setLeftBorderColor(colourIndex); - // log.debug( "Left border: " + xStyle.getBorderLeft() + " / " + xStyle.getLeftBorderXSSFColor().getARGBHex() ); - break; - case RIGHT: - hStyle.setBorderRight(hBorderStyle); - hStyle.setRightBorderColor(colourIndex); - // log.debug( "Right border: " + xStyle.getBorderRight() + " / " + xStyle.getRightBorderXSSFColor().getARGBHex() ); - break; - case BOTTOM: - hStyle.setBorderBottom(hBorderStyle); - hStyle.setBottomBorderColor(colourIndex); - // log.debug( "Bottom border: " + xStyle.getBorderBottom() + " / " + xStyle.getBottomBorderXSSFColor().getARGBHex() ); - break; - } - } - } - } - } - } - - @Override - public void addColourToFont(Workbook workbook, Font font, String colour) { - if(colour == null) { - return ; - } - if(IStyle.TRANSPARENT_VALUE.equals(colour)) { - return ; - } - if(font instanceof HSSFFont) { - HSSFFont hFont = (HSSFFont)font; - short colourIndex = getHColour((HSSFWorkbook)workbook, colour); - if( colourIndex > 0 ) { - hFont.setColor(colourIndex); - } - } - } - - @Override - public void addBackgroundColourToStyle(Workbook workbook, CellStyle style, String colour) { - if(colour == null) { - return ; - } - if(IStyle.TRANSPARENT_VALUE.equals(colour)) { - return ; - } - if(style instanceof HSSFCellStyle) { - HSSFCellStyle cellStyle = (HSSFCellStyle)style; - short colourIndex = getHColour((HSSFWorkbook)workbook, colour); - if( colourIndex > 0 ) { - cellStyle.setFillForegroundColor(colourIndex); - cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); - } - } - } - - @Override - public Font correctFontColorIfBackground(FontManager fm, Workbook wb, BirtStyle birtStyle, Font font) { - HSSFPalette palette = ((HSSFWorkbook)wb).getCustomPalette(); - - CSSValue bgColour = birtStyle.getProperty( StyleConstants.STYLE_BACKGROUND_COLOR ); - int bgRgb[] = parseColour( bgColour == null ? null : bgColour.getCssText(), "white" ); - - short fgRgb[] = HSSFColor.HSSFColorPredefined.BLACK.getTriplet(); - if( ( font != null ) && ( font.getColor() != Short.MAX_VALUE ) ) { - fgRgb = palette.getColor(font.getColor()).getTriplet(); - } - if( ( fgRgb[0] == 255 ) && ( fgRgb[1] == 255 ) && ( fgRgb[2] == 255 ) ) { - fgRgb[0]=fgRgb[1]=fgRgb[2]=0; - } else if( ( fgRgb[0] == 0 ) && ( fgRgb[1] == 0 ) && ( fgRgb[2] == 0 ) ) { - fgRgb[0]=fgRgb[1]=fgRgb[2]=255; - } - - if( ( bgRgb[ 0 ] == fgRgb[ 0 ] ) && ( bgRgb[ 1 ] == fgRgb[ 1 ] ) && ( bgRgb[ 2 ] == fgRgb[ 2 ] ) ) { - - IStyle addedStyle = new AreaStyle( fm.getCssEngine() ); - addedStyle.setColor( contrastColour( bgRgb ) ); - - return fm.getFontWithExtraStyle( font, addedStyle ); - } else { - return font; - } - } - - @Override - public int anchorDxFromMM( double widthMM, double colWidthMM ) { - return (int)( 1023.0 * widthMM / colWidthMM ); - } - - @Override - public int anchorDyFromPoints( float height, float rowHeight ) { - return (int)( 255.0 * height / rowHeight ); - } - - @Override - public void prepareMarginDimensions(Sheet sheet, IPageContent page) { - double headerHeight = 0.5; - double footerHeight = 0.5; - if( ( page.getHeaderHeight() != null ) && isAbsolute( page.getHeaderHeight() ) ) { - headerHeight = page.getHeaderHeight().convertTo(DimensionType.UNITS_IN); - sheet.getPrintSetup().setHeaderMargin(headerHeight); - } - if( ( page.getFooterHeight() != null ) && isAbsolute( page.getFooterHeight() ) ) { - footerHeight = page.getFooterHeight().convertTo(DimensionType.UNITS_IN); - sheet.getPrintSetup().setFooterMargin(footerHeight); - } - if( ( page.getMarginBottom() != null ) && isAbsolute( page.getMarginBottom() ) ) { - sheet.setMargin(Sheet.BottomMargin, footerHeight + page.getMarginBottom().convertTo(DimensionType.UNITS_IN)); - } - if( ( page.getMarginLeft() != null ) && isAbsolute( page.getMarginLeft() ) ) { - sheet.setMargin(Sheet.LeftMargin, page.getMarginLeft().convertTo(DimensionType.UNITS_IN)); - } - if( ( page.getMarginRight() != null ) && isAbsolute( page.getMarginRight() ) ) { - sheet.setMargin(Sheet.RightMargin, page.getMarginRight().convertTo(DimensionType.UNITS_IN)); - } - if( ( page.getMarginTop() != null ) && isAbsolute( page.getMarginTop() ) ) { - sheet.setMargin(Sheet.TopMargin, headerHeight + page.getMarginTop().convertTo(DimensionType.UNITS_IN)); - } - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel; + +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFPalette; +import org.apache.poi.hssf.usermodel.HSSFRichTextString; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.RichTextString; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder.BorderSide; +import org.eclipse.birt.report.engine.content.IPageContent; +import org.eclipse.birt.report.engine.content.IStyle; +import org.eclipse.birt.report.engine.css.dom.AreaStyle; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.ir.DimensionType; +import org.eclipse.birt.report.model.api.util.ColorUtil; +import org.w3c.dom.css.CSSValue; + +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +/** + * StyleManagerHUtils is an extension of the StyleManagerUtils to provide HSSFWorkbook specific functionality. + * @author Jim Talbut + * + */ +public class StyleManagerHUtils extends StyleManagerUtils { + private short paletteIndex = 64; + private static short minPaletteIndex = 40; + + private static Factory factory = new StyleManagerUtils.Factory() { + public StyleManagerUtils create(Logger log) { + return new StyleManagerHUtils(log); + } + }; + + public static Factory getFactory() { + return factory; + } + + + /** + * @param log + * Logger used by StyleManagerHUtils to record anything of interest. + */ + public StyleManagerHUtils(Logger log) { + super(log); + } + + @Override + public RichTextString createRichTextString(String value) { + return new HSSFRichTextString(value); + } + + /** + * Converts a BIRT border style into a POI border style (short constant defined in CellStyle). + * @param birtBorder + * The BIRT border style. + * @param width + * The width of the border as understood by BIRT. + * One of the CellStyle BORDER constants. + */ + private BorderStyle poiBorderStyleFromBirt( String birtBorder, String width ) { + if( "none".equals(birtBorder) ) { + return BorderStyle.NONE; + } + DimensionType dim = DimensionType.parserUnit( width ); + double pxWidth = 3.0; + if( ( dim != null ) && ( "px".equals(dim.getUnits()) ) ){ + pxWidth = dim.getMeasure(); + } + if( "solid".equals(birtBorder) ) { + if( pxWidth < 2.9 ) { + return BorderStyle.THIN; + } else if( pxWidth < 3.1 ) { + return BorderStyle.MEDIUM; + } else { + return BorderStyle.THICK; + } + } else if( "dashed".equals(birtBorder) ) { + if( pxWidth < 2.9 ) { + return BorderStyle.DASHED; + } else { + return BorderStyle.MEDIUM_DASHED; + } + } else if( "dotted".equals(birtBorder) ) { + return BorderStyle.DOTTED; + } else if( "double".equals(birtBorder) ) { + return BorderStyle.DOUBLE; + } else if( "none".equals(birtBorder) ) { + return BorderStyle.NONE; + } + + log.debug( "Border style \"", birtBorder, "\" is not recognised" ); + return BorderStyle.NONE; + } + + /** + * Get an HSSFPalette index for a workbook that closely approximates the passed in colour. + * @param workbook + * The workbook for which the colour is being sought. + * @param colour + * The colour, in the form "rgb(r, g, b)". + * The index into the HSSFPallete for the workbook for a colour that approximates the passed in colour. + */ + private short getHColour( HSSFWorkbook workbook, String colour ) { + int[] rgbInt = ColorUtil.getRGBs(colour); + if( rgbInt == null ) { + return 0; + } + + byte[] rgbByte = new byte[] { (byte)rgbInt[0], (byte)rgbInt[1], (byte)rgbInt[2] }; + HSSFPalette palette = workbook.getCustomPalette(); + + HSSFColor result = palette.findColor(rgbByte[0], rgbByte[1], rgbByte[2]); + if( result == null) { + if( paletteIndex > minPaletteIndex ) { + --paletteIndex; + palette.setColorAtIndex(paletteIndex, rgbByte[0], rgbByte[1], rgbByte[2]); + return paletteIndex; + } else { + result = palette.findSimilarColor(rgbByte[0], rgbByte[1], rgbByte[2]); + } + } + return result.getIndex(); + } + + @Override + public void applyBorderStyle(Workbook workbook, CellStyle style, BorderSide side, CSSValue colour, CSSValue borderStyle, CSSValue width) { + if( ( colour != null ) || ( borderStyle != null ) || ( width != null ) ) { + String colourString = colour == null ? "rgb(0,0,0)" : colour.getCssText(); + String borderStyleString = borderStyle == null ? "solid" : borderStyle.getCssText(); + String widthString = width == null ? "medium" : width.getCssText(); + + if( style instanceof HSSFCellStyle ) { + HSSFCellStyle hStyle = (HSSFCellStyle)style; + + BorderStyle hBorderStyle = poiBorderStyleFromBirt(borderStyleString, widthString); + short colourIndex = getHColour((HSSFWorkbook)workbook, colourString); + if( colourIndex > 0 ) { + if(hBorderStyle != BorderStyle.NONE) { + switch( side ) { + case TOP: + hStyle.setBorderTop(hBorderStyle); + hStyle.setTopBorderColor(colourIndex); + // log.debug( "Top border: " + xStyle.getBorderTop() + " / " + xStyle.getTopBorderXSSFColor().getARGBHex() ); + break; + case LEFT: + hStyle.setBorderLeft(hBorderStyle); + hStyle.setLeftBorderColor(colourIndex); + // log.debug( "Left border: " + xStyle.getBorderLeft() + " / " + xStyle.getLeftBorderXSSFColor().getARGBHex() ); + break; + case RIGHT: + hStyle.setBorderRight(hBorderStyle); + hStyle.setRightBorderColor(colourIndex); + // log.debug( "Right border: " + xStyle.getBorderRight() + " / " + xStyle.getRightBorderXSSFColor().getARGBHex() ); + break; + case BOTTOM: + hStyle.setBorderBottom(hBorderStyle); + hStyle.setBottomBorderColor(colourIndex); + // log.debug( "Bottom border: " + xStyle.getBorderBottom() + " / " + xStyle.getBottomBorderXSSFColor().getARGBHex() ); + break; + } + } + } + } + } + } + + @Override + public void addColourToFont(Workbook workbook, Font font, String colour) { + if(colour == null) { + return ; + } + if(IStyle.TRANSPARENT_VALUE.equals(colour)) { + return ; + } + if(font instanceof HSSFFont) { + HSSFFont hFont = (HSSFFont)font; + short colourIndex = getHColour((HSSFWorkbook)workbook, colour); + if( colourIndex > 0 ) { + hFont.setColor(colourIndex); + } + } + } + + @Override + public void addBackgroundColourToStyle(Workbook workbook, CellStyle style, String colour) { + if(colour == null) { + return ; + } + if(IStyle.TRANSPARENT_VALUE.equals(colour)) { + return ; + } + if(style instanceof HSSFCellStyle) { + HSSFCellStyle cellStyle = (HSSFCellStyle)style; + short colourIndex = getHColour((HSSFWorkbook)workbook, colour); + if( colourIndex > 0 ) { + cellStyle.setFillForegroundColor(colourIndex); + cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + } + } + } + + @Override + public Font correctFontColorIfBackground(FontManager fm, Workbook wb, BirtStyle birtStyle, Font font) { + HSSFPalette palette = ((HSSFWorkbook)wb).getCustomPalette(); + + CSSValue bgColour = birtStyle.getProperty( StyleConstants.STYLE_BACKGROUND_COLOR ); + int bgRgb[] = parseColour( bgColour == null ? null : bgColour.getCssText(), "white" ); + + short fgRgb[] = HSSFColor.HSSFColorPredefined.BLACK.getTriplet(); + if( ( font != null ) && ( font.getColor() != Short.MAX_VALUE ) ) { + fgRgb = palette.getColor(font.getColor()).getTriplet(); + } + if( ( fgRgb[0] == 255 ) && ( fgRgb[1] == 255 ) && ( fgRgb[2] == 255 ) ) { + fgRgb[0]=fgRgb[1]=fgRgb[2]=0; + } else if( ( fgRgb[0] == 0 ) && ( fgRgb[1] == 0 ) && ( fgRgb[2] == 0 ) ) { + fgRgb[0]=fgRgb[1]=fgRgb[2]=255; + } + + if( ( bgRgb[ 0 ] == fgRgb[ 0 ] ) && ( bgRgb[ 1 ] == fgRgb[ 1 ] ) && ( bgRgb[ 2 ] == fgRgb[ 2 ] ) ) { + + IStyle addedStyle = new AreaStyle( fm.getCssEngine() ); + addedStyle.setColor( contrastColour( bgRgb ) ); + + return fm.getFontWithExtraStyle( font, addedStyle ); + } else { + return font; + } + } + + @Override + public int anchorDxFromMM( double widthMM, double colWidthMM ) { + return (int)( 1023.0 * widthMM / colWidthMM ); + } + + @Override + public int anchorDyFromPoints( float height, float rowHeight ) { + return (int)( 255.0 * height / rowHeight ); + } + + @Override + public void prepareMarginDimensions(Sheet sheet, IPageContent page) { + double headerHeight = 0.5; + double footerHeight = 0.5; + if( ( page.getHeaderHeight() != null ) && isAbsolute( page.getHeaderHeight() ) ) { + headerHeight = page.getHeaderHeight().convertTo(DimensionType.UNITS_IN); + sheet.getPrintSetup().setHeaderMargin(headerHeight); + } + if( ( page.getFooterHeight() != null ) && isAbsolute( page.getFooterHeight() ) ) { + footerHeight = page.getFooterHeight().convertTo(DimensionType.UNITS_IN); + sheet.getPrintSetup().setFooterMargin(footerHeight); + } + if( ( page.getMarginBottom() != null ) && isAbsolute( page.getMarginBottom() ) ) { + sheet.setMargin(Sheet.BottomMargin, footerHeight + page.getMarginBottom().convertTo(DimensionType.UNITS_IN)); + } + if( ( page.getMarginLeft() != null ) && isAbsolute( page.getMarginLeft() ) ) { + sheet.setMargin(Sheet.LeftMargin, page.getMarginLeft().convertTo(DimensionType.UNITS_IN)); + } + if( ( page.getMarginRight() != null ) && isAbsolute( page.getMarginRight() ) ) { + sheet.setMargin(Sheet.RightMargin, page.getMarginRight().convertTo(DimensionType.UNITS_IN)); + } + if( ( page.getMarginTop() != null ) && isAbsolute( page.getMarginTop() ) ) { + sheet.setMargin(Sheet.TopMargin, headerHeight + page.getMarginTop().convertTo(DimensionType.UNITS_IN)); + } + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/XlsEmitter.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/XlsEmitter.java index ee428948c..ac50e715c 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/XlsEmitter.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/XlsEmitter.java @@ -1,55 +1,55 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.Workbook; - -/** - * XlsEmitter is the leaf class for implementing the ExcelEmitter with HSSFWorkbook. - * @author Jim Talbut - * - */ -public class XlsEmitter extends ExcelEmitter { - - /** - */ - public XlsEmitter() { - super(StyleManagerHUtils.getFactory()); - log.debug("Constructed XlsEmitter"); - } - - public String getOutputFormat() { - return "xls"; - } - - protected Workbook createWorkbook() { - return new HSSFWorkbook(); - } - - protected Workbook openWorkbook( File templateFile ) throws IOException { - InputStream stream = new FileInputStream( templateFile ); - try { - return new HSSFWorkbook( stream ); - } finally { - stream.close(); - } - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; + +/** + * XlsEmitter is the leaf class for implementing the ExcelEmitter with HSSFWorkbook. + * @author Jim Talbut + * + */ +public class XlsEmitter extends ExcelEmitter { + + /** + */ + public XlsEmitter() { + super(StyleManagerHUtils.getFactory()); + log.debug("Constructed XlsEmitter"); + } + + public String getOutputFormat() { + return "xls"; + } + + protected Workbook createWorkbook() { + return new HSSFWorkbook(); + } + + protected Workbook openWorkbook( File templateFile ) throws IOException { + InputStream stream = new FileInputStream( templateFile ); + try { + return new HSSFWorkbook( stream ); + } finally { + stream.close(); + } + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/XlsxEmitter.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/XlsxEmitter.java index a42134a6e..6d75dce60 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/XlsxEmitter.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/XlsxEmitter.java @@ -1,55 +1,55 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -/** - * XlsxEmitter is the leaf class for implementing the ExcelEmitter with XSSFWorkbook. - * @author Jim Talbut - * - */ -public class XlsxEmitter extends ExcelEmitter { - - /** - */ - public XlsxEmitter() { - super(StyleManagerXUtils.getFactory()); - log.debug("Constructed XlsxEmitter"); - } - - public String getOutputFormat() { - return "xlsx"; - } - - protected Workbook createWorkbook() { - return new XSSFWorkbook(); - } - - protected Workbook openWorkbook( File templateFile ) throws IOException { - InputStream stream = new FileInputStream( templateFile ); - try { - return new XSSFWorkbook( stream ); - } finally { - stream.close(); - } - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +/** + * XlsxEmitter is the leaf class for implementing the ExcelEmitter with XSSFWorkbook. + * @author Jim Talbut + * + */ +public class XlsxEmitter extends ExcelEmitter { + + /** + */ + public XlsxEmitter() { + super(StyleManagerXUtils.getFactory()); + log.debug("Constructed XlsxEmitter"); + } + + public String getOutputFormat() { + return "xlsx"; + } + + protected Workbook createWorkbook() { + return new XSSFWorkbook(); + } + + protected Workbook openWorkbook( File templateFile ) throws IOException { + InputStream stream = new FileInputStream( templateFile ); + try { + return new XSSFWorkbook( stream ); + } finally { + stream.close(); + } + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/framework/ExcelEmitterPlugin.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/framework/ExcelEmitterPlugin.java index 3445e44c4..bbb6b15c6 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/framework/ExcelEmitterPlugin.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/framework/ExcelEmitterPlugin.java @@ -1,69 +1,69 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.framework; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * ExcelEmitterPlugin represents the SpudSoft Excel emitter. - *
- * This is the activator for the plugin and is necessary to capture the eclipse log. - *
- * Note that the BIRT runtime is not OSGi and does not activate the bundle, so getDefault always returns null when used in that environment. - * - * @author Jim Talbut - * - */ -public class ExcelEmitterPlugin extends Plugin { - - private static ExcelEmitterPlugin plugin; - - /** - * Get the plugin, if it has been activated. - * The plugin, if it has been activated, or null otherwise. - */ - public static ExcelEmitterPlugin getDefault() { - return plugin; - } - - private Logger logger; - - /* - * (non-Javadoc) - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext bundleContext) throws Exception { - super.start(bundleContext); - plugin = this; - logger = new Logger(getLog(), bundleContext.getBundle().getSymbolicName()); - } - - /* - * (non-Javadoc) - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext bundleContext) throws Exception { - super.stop(bundleContext); - } - - /** - * Get the logger. - * The logger. - */ - public Logger getLogger() { - return logger; - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.framework; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * ExcelEmitterPlugin represents the SpudSoft Excel emitter. + *
+ * This is the activator for the plugin and is necessary to capture the eclipse log. + *
+ * Note that the BIRT runtime is not OSGi and does not activate the bundle, so getDefault always returns null when used in that environment. + * + * @author Jim Talbut + * + */ +public class ExcelEmitterPlugin extends Plugin { + + private static ExcelEmitterPlugin plugin; + + /** + * Get the plugin, if it has been activated. + * The plugin, if it has been activated, or null otherwise. + */ + public static ExcelEmitterPlugin getDefault() { + return plugin; + } + + private Logger logger; + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + super.start(bundleContext); + plugin = this; + logger = new Logger(getLog(), bundleContext.getBundle().getSymbolicName()); + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + super.stop(bundleContext); + } + + /** + * Get the logger. + * The logger. + */ + public Logger getLogger() { + return logger; + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/framework/Logger.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/framework/Logger.java index 2e750c8b9..41c4dcf3c 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/framework/Logger.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/framework/Logger.java @@ -1,192 +1,192 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.framework; - -import java.util.logging.Level; - -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -/** - * The Logger for the SpudSoft BIRT Excel Emitter. - *
- * In a standard eclipse environment the Logger wraps the eclipse ILog and discards debug messages. - * In the BIRT runtime environment the Logger uses java.util.logging. - *

- * The Logger maintains a stack of characters as a prefix applied to any debug log. - * This is used to track the start/end of items reported by BIRT. - *

- * @author Jim Talbut - * - */ -public class Logger { - - private ILog eclipseLog; - private String pluginId; - private java.util.logging.Logger backupLog; - private StringBuilder prefix = new StringBuilder(); - private boolean debug; - - /** - * Constructor used to initialise the JUL logger. - * @param pluginId - * The plugin ID used to identify the logger with JUL. - */ - public Logger( String pluginId ) { - this.backupLog = java.util.logging.Logger.getLogger(pluginId); - } - - /** - * Constructor used to initialise the eclipse ILog. - * @param log - * The eclipse ILog. - * @param pluginId - * The plugin ID used in IStatus messages. - */ - Logger( ILog log, String pluginId ) { - this.eclipseLog = log; - this.pluginId = pluginId; - } - - /** - * Set the debug state of the logger. - * @param debug - * When true and run within Equinox debug statements are output to the console. - * When not true the prefix handling is turned off. - */ - public void setDebug( boolean debug ) { - this.debug = debug; - } - - /** - * Add a new character to the prefix stack. - * @param c - * Character to add to the prefix stack. - */ - public void addPrefix( char c ) { - if( debug ) { - prefix.append( c ); - } - } - - /** - * Remove a character from the prefix stack, if the appropriate character is at the top of the stack. - * @param c - * Character to remove from the prefix stack. - * @throws IllegalStateException - * If the prefix at the top of the prefix stack does not match c. - */ - public void removePrefix( char c ) { - if( debug ) { - int length = prefix.length(); - char old = prefix.charAt( length - 1 ); - if(old != c ) { - throw new IllegalStateException( "Old prefix (" + old + ") does not match that expected (" + c + "), whole prefix is \"" + prefix + "\"" ); - } - prefix.setLength( length - 1); - } - } - - /** - * Log a message with debug severity. - * @param message - * The message to log. - */ - public void debug( Object ... message ) { - if( eclipseLog != null ) { - if( debug ) { - if( message.length > 1 ) { - StringBuilder msg = new StringBuilder(); - for( Object part : message ) { - msg.append( part ); - } - System.out.println( prefix.toString() + " " + msg.toString() ); - } else { - System.out.println( prefix.toString() + " " + message[0].toString() ); - } - } - } else if( backupLog.isLoggable(Level.FINE) ) { - if( message.length > 1 ) { - StringBuilder msg = new StringBuilder(); - msg.append( prefix ).append( ' ' ); - for( Object part : message ) { - msg.append( part ); - } - backupLog.fine( msg.toString() ); - } else { - backupLog.fine( prefix.toString() + " " + message[0].toString() ); - } - } - } - - /** - * Log a message with info severity. - * @param code - * The message code. - * @param message - * The message to log. - * @param exception - * Any exception associated with the log. - */ - public void info( int code, String message, Throwable exception ) { - if( eclipseLog != null ) { - log( IStatus.INFO, code, message, exception ); - } else { - backupLog.log(Level.INFO, message, exception); - } - } - - /** - * Log a message with warn severity. - * @param code - * The message code. - * @param message - * The message to log. - * @param exception - * Any exception associated with the log. - */ - public void warn( int code, String message, Throwable exception ) { - if( eclipseLog != null ) { - log( IStatus.WARNING, code, message, exception ); - } else { - backupLog.log(Level.WARNING, message, exception); - } - } - - /** - * Log a message with error severity. - * @param code - * The message code. - * @param message - * The message to log. - * @param exception - * Any exception associated with the log. - */ - public void error( int code, String message, Throwable exception ) { - if( eclipseLog != null ) { - log( IStatus.ERROR, code, message, exception ); - } else { - backupLog.log(Level.SEVERE, message, exception); - } - } - - private void log( int severity, int code, String message, Throwable exception ) { - if( eclipseLog != null ) { - IStatus record = new Status( severity, pluginId, code, message, exception); - eclipseLog.log(record); - } - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.framework; + +import java.util.logging.Level; + +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +/** + * The Logger for the SpudSoft BIRT Excel Emitter. + *
+ * In a standard eclipse environment the Logger wraps the eclipse ILog and discards debug messages. + * In the BIRT runtime environment the Logger uses java.util.logging. + *

+ * The Logger maintains a stack of characters as a prefix applied to any debug log. + * This is used to track the start/end of items reported by BIRT. + *

+ * @author Jim Talbut + * + */ +public class Logger { + + private ILog eclipseLog; + private String pluginId; + private java.util.logging.Logger backupLog; + private StringBuilder prefix = new StringBuilder(); + private boolean debug; + + /** + * Constructor used to initialise the JUL logger. + * @param pluginId + * The plugin ID used to identify the logger with JUL. + */ + public Logger( String pluginId ) { + this.backupLog = java.util.logging.Logger.getLogger(pluginId); + } + + /** + * Constructor used to initialise the eclipse ILog. + * @param log + * The eclipse ILog. + * @param pluginId + * The plugin ID used in IStatus messages. + */ + Logger( ILog log, String pluginId ) { + this.eclipseLog = log; + this.pluginId = pluginId; + } + + /** + * Set the debug state of the logger. + * @param debug + * When true and run within Equinox debug statements are output to the console. + * When not true the prefix handling is turned off. + */ + public void setDebug( boolean debug ) { + this.debug = debug; + } + + /** + * Add a new character to the prefix stack. + * @param c + * Character to add to the prefix stack. + */ + public void addPrefix( char c ) { + if( debug ) { + prefix.append( c ); + } + } + + /** + * Remove a character from the prefix stack, if the appropriate character is at the top of the stack. + * @param c + * Character to remove from the prefix stack. + * @throws IllegalStateException + * If the prefix at the top of the prefix stack does not match c. + */ + public void removePrefix( char c ) { + if( debug ) { + int length = prefix.length(); + char old = prefix.charAt( length - 1 ); + if(old != c ) { + throw new IllegalStateException( "Old prefix (" + old + ") does not match that expected (" + c + "), whole prefix is \"" + prefix + "\"" ); + } + prefix.setLength( length - 1); + } + } + + /** + * Log a message with debug severity. + * @param message + * The message to log. + */ + public void debug( Object ... message ) { + if( eclipseLog != null ) { + if( debug ) { + if( message.length > 1 ) { + StringBuilder msg = new StringBuilder(); + for( Object part : message ) { + msg.append( part ); + } + System.out.println( prefix.toString() + " " + msg.toString() ); + } else { + System.out.println( prefix.toString() + " " + message[0].toString() ); + } + } + } else if( backupLog.isLoggable(Level.FINE) ) { + if( message.length > 1 ) { + StringBuilder msg = new StringBuilder(); + msg.append( prefix ).append( ' ' ); + for( Object part : message ) { + msg.append( part ); + } + backupLog.fine( msg.toString() ); + } else { + backupLog.fine( prefix.toString() + " " + message[0].toString() ); + } + } + } + + /** + * Log a message with info severity. + * @param code + * The message code. + * @param message + * The message to log. + * @param exception + * Any exception associated with the log. + */ + public void info( int code, String message, Throwable exception ) { + if( eclipseLog != null ) { + log( IStatus.INFO, code, message, exception ); + } else { + backupLog.log(Level.INFO, message, exception); + } + } + + /** + * Log a message with warn severity. + * @param code + * The message code. + * @param message + * The message to log. + * @param exception + * Any exception associated with the log. + */ + public void warn( int code, String message, Throwable exception ) { + if( eclipseLog != null ) { + log( IStatus.WARNING, code, message, exception ); + } else { + backupLog.log(Level.WARNING, message, exception); + } + } + + /** + * Log a message with error severity. + * @param code + * The message code. + * @param message + * The message to log. + * @param exception + * Any exception associated with the log. + */ + public void error( int code, String message, Throwable exception ) { + if( eclipseLog != null ) { + log( IStatus.ERROR, code, message, exception ); + } else { + backupLog.log(Level.SEVERE, message, exception); + } + } + + private void log( int severity, int code, String message, Throwable exception ) { + if( eclipseLog != null ) { + IStatus record = new Status( severity, pluginId, code, message, exception); + eclipseLog.log(record); + } + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractHandler.java index 53314e1ca..ac7f54fbd 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractHandler.java @@ -1,334 +1,334 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.apache.poi.ss.SpreadsheetVersion; -import org.apache.poi.ss.formula.FormulaParseException; -import org.apache.poi.ss.usermodel.Name; -import org.apache.poi.ss.util.CellReference; -import org.apache.poi.ss.util.CellReference.NameType; -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IAutoTextContent; -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.content.IContainerContent; -import org.eclipse.birt.report.engine.content.IContent; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IGroupContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.IListBandContent; -import org.eclipse.birt.report.engine.content.IListContent; -import org.eclipse.birt.report.engine.content.IListGroupContent; -import org.eclipse.birt.report.engine.content.IPageContent; -import org.eclipse.birt.report.engine.content.IRowContent; -import org.eclipse.birt.report.engine.content.IStyledElement; -import org.eclipse.birt.report.engine.content.ITableBandContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITableGroupContent; -import org.eclipse.birt.report.engine.content.ITextContent; -import org.eclipse.birt.report.engine.css.engine.StyleConstants; -import org.eclipse.birt.report.engine.css.engine.value.css.CSSConstants; -import org.w3c.dom.css.CSSValue; - -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class AbstractHandler implements IHandler { - - protected Logger log; - protected IContent element; - protected IHandler parent; - private CSSValue backgroundColour; - - public AbstractHandler(Logger log, IHandler parent, IContent element) { - this.log = log; - this.parent = parent; - this.element = element; - } - - public void notifyHandler(HandlerState state) { - } - - public String getPath() { - if( parent != null ) { - return this.getClass().getSimpleName() + "/" + parent.getPath(); - } else { - return this.getClass().getSimpleName(); - } - } - - public IHandler getParent() { - return parent; - } - - @SuppressWarnings("unchecked") - public T getAncestor(Class clazz) { - if( parent != null ) { - if( clazz.isInstance(parent) ) { - return (T)parent; - } else { - return parent.getAncestor(clazz); - } - } - return null; - } - - public CSSValue getBackgroundColour() { - if( backgroundColour != null ) { - return backgroundColour; - } - if( element != null ) { - CSSValue elemColour = element.getComputedStyle().getProperty( StyleConstants.STYLE_BACKGROUND_COLOR ); - if( ( elemColour != null ) && ! CSSConstants.CSS_TRANSPARENT_VALUE.equals( elemColour.getCssText() ) ) { - backgroundColour = elemColour; - } - } - if( ( parent != null ) && ( backgroundColour == null ) ) { - backgroundColour = parent.getBackgroundColour(); - } - return backgroundColour; - } - - protected static String getStyleProperty( IStyledElement element, int property, String defaultValue ) { - CSSValue value = element.getComputedStyle().getProperty(property); - if( value != null ) { - return value.getCssText(); - } else { - return defaultValue; - } - } - - protected static String prepareName( String name ) { - char c = name.charAt(0); - boolean requirePreparation = (!(c == '_' || Character.isLetter(c)) || name.indexOf(' ') != -1); - if( !requirePreparation ) { - for( int i = 1; i < name.length(); ++i ) { - c = name.charAt(i); - if(!(Character.isLetter(c) || Character.isDigit(c) || c == '_' )) { - requirePreparation = true; - break; - } - } - } - - if( requirePreparation ) { - name = name.trim(); - char chars[] = name.toCharArray(); - for( int i = 0; i < name.length(); ++i ) { - c = chars[i]; - if(!(Character.isLetter(c) || Character.isDigit(c) || c == '_' )) { - chars[i] = '_'; - } - } - name = new String(chars); - } - - NameType refType = CellReference.classifyCellReference( name, SpreadsheetVersion.EXCEL2007 ); - if( ( NameType.CELL == refType ) || ( NameType.COLUMN == refType ) || ( NameType.ROW == refType ) ) { - name = "_" + name; - } - - return name; - } - - protected void createName(HandlerState state, String bookmark, int row1, int col1, int row2, int col2 ) { - CellReference crFirst = new CellReference( state.currentSheet.getSheetName(), row1, col1, true, true ); - CellReference crLast = new CellReference( row2, col2, true, true ); - String formula = crFirst.formatAsString() + ":" + crLast.formatAsString(); - - Name name = state.currentSheet.getWorkbook().getName(bookmark); - if( name == null ) { - name = state.currentSheet.getWorkbook().createName(); - name.setNameName( bookmark ); - name.setRefersToFormula( formula ); - } else { - String existingFormula = name.getRefersToFormula(); - try { - name.setRefersToFormula(existingFormula + "," + formula); - } catch( FormulaParseException ex ) { - log.warn( 0, "Unable to add \"" + formula + "\" to name (\"" + bookmark + "\") with existing formula: " + existingFormula, ex ); - } - } - } - - public void startPage(HandlerState state, IPageContent page) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startPage" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - public void endPage(HandlerState state, IPageContent page) throws BirtException{ - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endPage" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void startTable(HandlerState state, ITableContent table) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startTable" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - public void endTable(HandlerState state, ITableContent table) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endTable" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void startTableBand(HandlerState state, ITableBandContent band) throws BirtException { - // NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startTableBand" ); - // log.error(0, "Method not implemented", ex); - // throw ex; - } - public void endTableBand(HandlerState state, ITableBandContent band) throws BirtException { - // NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endTableBand" ); - // log.error(0, "Method not implemented", ex); - // throw ex; - } - - public void startRow(HandlerState state, IRowContent row) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startRow" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - public void endRow(HandlerState state, IRowContent row) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endRow" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void startCell(HandlerState state, ICellContent cell) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startCell" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - public void endCell(HandlerState state, ICellContent cell) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endCell" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void startList(HandlerState state, IListContent list) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startList" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - public void endList(HandlerState state, IListContent list) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endList" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void startListBand(HandlerState state, IListBandContent listBand) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startListBand" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - public void endListBand(HandlerState state, IListBandContent listBand) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endListBand" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void startContainer(HandlerState state, IContainerContent container) throws BirtException { - // NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startContainer" ); - // log.error(0, "Method not implemented", ex); - // throw ex; - } - public void endContainer(HandlerState state, IContainerContent container) throws BirtException { - // NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endContainer" ); - // log.error(0, "Method not implemented", ex); - // throw ex; - } - - public void startContent(HandlerState state, IContent content) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startContent" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - public void endContent(HandlerState state, IContent content) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endContent" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void startGroup(HandlerState state, IGroupContent group) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startGroup" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - public void endGroup(HandlerState state, IGroupContent group) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endGroup" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void startTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startTableGroup" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - public void endTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endTableGroup" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void startListGroup(HandlerState state, IListGroupContent group) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startListGroup" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - public void endListGroup(HandlerState state, IListGroupContent group) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endListGroup" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void emitText(HandlerState state, ITextContent text) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitText" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void emitData(HandlerState state, IDataContent data) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitData" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitLabel" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitAutoText" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitForeign" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - - public void emitImage(HandlerState state, IImageContent image) throws BirtException { - NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitImage" ); - log.error(0, "Method not implemented", ex); - throw ex; - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.formula.FormulaParseException; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.ss.util.CellReference.NameType; +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IAutoTextContent; +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.content.IContainerContent; +import org.eclipse.birt.report.engine.content.IContent; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IGroupContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.IListBandContent; +import org.eclipse.birt.report.engine.content.IListContent; +import org.eclipse.birt.report.engine.content.IListGroupContent; +import org.eclipse.birt.report.engine.content.IPageContent; +import org.eclipse.birt.report.engine.content.IRowContent; +import org.eclipse.birt.report.engine.content.IStyledElement; +import org.eclipse.birt.report.engine.content.ITableBandContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITableGroupContent; +import org.eclipse.birt.report.engine.content.ITextContent; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.css.engine.value.css.CSSConstants; +import org.w3c.dom.css.CSSValue; + +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class AbstractHandler implements IHandler { + + protected Logger log; + protected IContent element; + protected IHandler parent; + private CSSValue backgroundColour; + + public AbstractHandler(Logger log, IHandler parent, IContent element) { + this.log = log; + this.parent = parent; + this.element = element; + } + + public void notifyHandler(HandlerState state) { + } + + public String getPath() { + if( parent != null ) { + return this.getClass().getSimpleName() + "/" + parent.getPath(); + } else { + return this.getClass().getSimpleName(); + } + } + + public IHandler getParent() { + return parent; + } + + @SuppressWarnings("unchecked") + public T getAncestor(Class clazz) { + if( parent != null ) { + if( clazz.isInstance(parent) ) { + return (T)parent; + } else { + return parent.getAncestor(clazz); + } + } + return null; + } + + public CSSValue getBackgroundColour() { + if( backgroundColour != null ) { + return backgroundColour; + } + if( element != null ) { + CSSValue elemColour = element.getComputedStyle().getProperty( StyleConstants.STYLE_BACKGROUND_COLOR ); + if( ( elemColour != null ) && ! CSSConstants.CSS_TRANSPARENT_VALUE.equals( elemColour.getCssText() ) ) { + backgroundColour = elemColour; + } + } + if( ( parent != null ) && ( backgroundColour == null ) ) { + backgroundColour = parent.getBackgroundColour(); + } + return backgroundColour; + } + + protected static String getStyleProperty( IStyledElement element, int property, String defaultValue ) { + CSSValue value = element.getComputedStyle().getProperty(property); + if( value != null ) { + return value.getCssText(); + } else { + return defaultValue; + } + } + + protected static String prepareName( String name ) { + char c = name.charAt(0); + boolean requirePreparation = (!(c == '_' || Character.isLetter(c)) || name.indexOf(' ') != -1); + if( !requirePreparation ) { + for( int i = 1; i < name.length(); ++i ) { + c = name.charAt(i); + if(!(Character.isLetter(c) || Character.isDigit(c) || c == '_' )) { + requirePreparation = true; + break; + } + } + } + + if( requirePreparation ) { + name = name.trim(); + char chars[] = name.toCharArray(); + for( int i = 0; i < name.length(); ++i ) { + c = chars[i]; + if(!(Character.isLetter(c) || Character.isDigit(c) || c == '_' )) { + chars[i] = '_'; + } + } + name = new String(chars); + } + + NameType refType = CellReference.classifyCellReference( name, SpreadsheetVersion.EXCEL2007 ); + if( ( NameType.CELL == refType ) || ( NameType.COLUMN == refType ) || ( NameType.ROW == refType ) ) { + name = "_" + name; + } + + return name; + } + + protected void createName(HandlerState state, String bookmark, int row1, int col1, int row2, int col2 ) { + CellReference crFirst = new CellReference( state.currentSheet.getSheetName(), row1, col1, true, true ); + CellReference crLast = new CellReference( row2, col2, true, true ); + String formula = crFirst.formatAsString() + ":" + crLast.formatAsString(); + + Name name = state.currentSheet.getWorkbook().getName(bookmark); + if( name == null ) { + name = state.currentSheet.getWorkbook().createName(); + name.setNameName( bookmark ); + name.setRefersToFormula( formula ); + } else { + String existingFormula = name.getRefersToFormula(); + try { + name.setRefersToFormula(existingFormula + "," + formula); + } catch( FormulaParseException ex ) { + log.warn( 0, "Unable to add \"" + formula + "\" to name (\"" + bookmark + "\") with existing formula: " + existingFormula, ex ); + } + } + } + + public void startPage(HandlerState state, IPageContent page) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startPage" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + public void endPage(HandlerState state, IPageContent page) throws BirtException{ + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endPage" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void startTable(HandlerState state, ITableContent table) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startTable" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + public void endTable(HandlerState state, ITableContent table) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endTable" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void startTableBand(HandlerState state, ITableBandContent band) throws BirtException { + // NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startTableBand" ); + // log.error(0, "Method not implemented", ex); + // throw ex; + } + public void endTableBand(HandlerState state, ITableBandContent band) throws BirtException { + // NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endTableBand" ); + // log.error(0, "Method not implemented", ex); + // throw ex; + } + + public void startRow(HandlerState state, IRowContent row) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startRow" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + public void endRow(HandlerState state, IRowContent row) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endRow" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void startCell(HandlerState state, ICellContent cell) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startCell" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + public void endCell(HandlerState state, ICellContent cell) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endCell" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void startList(HandlerState state, IListContent list) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startList" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + public void endList(HandlerState state, IListContent list) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endList" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void startListBand(HandlerState state, IListBandContent listBand) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startListBand" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + public void endListBand(HandlerState state, IListBandContent listBand) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endListBand" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void startContainer(HandlerState state, IContainerContent container) throws BirtException { + // NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startContainer" ); + // log.error(0, "Method not implemented", ex); + // throw ex; + } + public void endContainer(HandlerState state, IContainerContent container) throws BirtException { + // NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endContainer" ); + // log.error(0, "Method not implemented", ex); + // throw ex; + } + + public void startContent(HandlerState state, IContent content) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startContent" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + public void endContent(HandlerState state, IContent content) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endContent" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void startGroup(HandlerState state, IGroupContent group) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startGroup" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + public void endGroup(HandlerState state, IGroupContent group) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endGroup" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void startTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startTableGroup" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + public void endTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endTableGroup" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void startListGroup(HandlerState state, IListGroupContent group) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".startListGroup" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + public void endListGroup(HandlerState state, IListGroupContent group) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".endListGroup" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void emitText(HandlerState state, ITextContent text) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitText" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void emitData(HandlerState state, IDataContent data) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitData" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitLabel" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitAutoText" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitForeign" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + + public void emitImage(HandlerState state, IImageContent image) throws BirtException { + NoSuchMethodError ex = new NoSuchMethodError( "Method not implemented: " + this.getClass().getSimpleName() + ".emitImage" ); + log.error(0, "Method not implemented", ex); + throw ex; + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealListHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealListHandler.java index 828954ee0..073a0a197 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealListHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealListHandler.java @@ -1,159 +1,159 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IListBandContent; -import org.eclipse.birt.report.engine.content.IListContent; -import org.eclipse.birt.report.engine.content.IListGroupContent; - -import uk.co.spudsoft.birt.emitters.excel.AreaBorders; -import uk.co.spudsoft.birt.emitters.excel.BirtStyle; -import uk.co.spudsoft.birt.emitters.excel.EmitterServices; -import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class AbstractRealListHandler extends AbstractHandler implements NestedTableContainer { - - protected int startRow; - protected int startCol; - - private IListGroupContent currentGroup; - private IListBandContent currentBand; - - private AreaBorders borderDefn; - - private List< NestedTableHandler > nestedTables; - - public AbstractRealListHandler(Logger log, IHandler parent, IListContent list) { - super(log, parent, list); - } - - public void addNestedTable( NestedTableHandler nestedTableHandler ) { - if( nestedTables == null ) { - nestedTables = new ArrayList(); - } - log.debug( "Adding nested table: ", nestedTableHandler ); - nestedTables.add(nestedTableHandler); - } - - public boolean rowHasNestedTable( int rowNum ) { - if( nestedTables != null ) { - for( NestedTableHandler nestedTableHandler : nestedTables ) { - if( nestedTableHandler.includesRow( rowNum ) ) { - log.debug( "Row ", rowNum, " has nested table ", nestedTableHandler ); - return true; - } - } - } - log.debug( "Row ", rowNum, " has no nested tables" ); - return false; - } - - public int extendRowBy( int rowNum ) { - int offset = 1; - if( nestedTables != null ) { - for( NestedTableHandler nestedTableHandler : nestedTables ) { - int nestedTablesOffset = nestedTableHandler.extendParentsRowBy( rowNum ); - if( nestedTablesOffset > offset ) { - log.debug( "Row ", rowNum, " is extended by ", nestedTablesOffset, " thanks to ", nestedTableHandler ); - offset = nestedTablesOffset; - } - } - } - return offset; - } - - @Override - public void startList(HandlerState state, IListContent list) throws BirtException { - startRow = state.rowNum; - startCol = state.colNum; - log.debug( "List started at [", startRow, ",", startCol, "]" ); - } - - @Override - public void endList(HandlerState state, IListContent list) throws BirtException { - state.setHandler(parent); - - int endRow = state.rowNum - 1; - int colStart = 0; - int colEnd = 0; - - for( int row = startRow; row < endRow; ++row ) { - if( state.currentSheet.getRow(row) != null ) { - int lastColInRow = state.currentSheet.getRow(row).getLastCellNum() - 1; - if( lastColInRow > colEnd ) { - colEnd = lastColInRow; - } - } - } - - state.getSmu().applyBordersToArea( state.getSm(), state.currentSheet, colStart, colEnd, startRow, endRow, new BirtStyle( list ) ); - - if( borderDefn != null ) { - state.removeBorderOverload(borderDefn); - } - - if( list.getBookmark() != null ) { - createName(state, prepareName( list.getBookmark() ), startRow, 0, state.rowNum - 1, 0); - } - - if( EmitterServices.booleanOption( state.getRenderOptions(), list, ExcelEmitter.DISPLAYFORMULAS_PROP, false ) ) { - state.currentSheet.setDisplayFormulas(true); - } - if( ! EmitterServices.booleanOption( state.getRenderOptions(), list, ExcelEmitter.DISPLAYGRIDLINES_PROP, true ) ) { - state.currentSheet.setDisplayGridlines(false); - } - if( ! EmitterServices.booleanOption( state.getRenderOptions(), list, ExcelEmitter.DISPLAYROWCOLHEADINGS_PROP, true ) ) { - state.currentSheet.setDisplayRowColHeadings(false); - } - if( ! EmitterServices.booleanOption( state.getRenderOptions(), list, ExcelEmitter.DISPLAYZEROS_PROP, true ) ) { - state.currentSheet.setDisplayZeros(false); - } - } - - @Override - public void startListBand(HandlerState state, IListBandContent band) throws BirtException { - currentBand = band; - state.colNum = startCol; - log.debug( "startListBand with startCol = ", startCol ); - } - - @Override - public void endListBand(HandlerState state, IListBandContent band) throws BirtException { - boolean rowHasNestedTable = rowHasNestedTable( state.rowNum ); - - if( rowHasNestedTable ) { - state.rowNum += extendRowBy( state.rowNum ); - } - state.colNum = startCol; - - currentBand = null; - } - - @Override - public void startListGroup(HandlerState state, IListGroupContent group) throws BirtException { - currentGroup = group; - } - - @Override - public void endListGroup(HandlerState state, IListGroupContent group) throws BirtException { - currentGroup = null; - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IListBandContent; +import org.eclipse.birt.report.engine.content.IListContent; +import org.eclipse.birt.report.engine.content.IListGroupContent; + +import uk.co.spudsoft.birt.emitters.excel.AreaBorders; +import uk.co.spudsoft.birt.emitters.excel.BirtStyle; +import uk.co.spudsoft.birt.emitters.excel.EmitterServices; +import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class AbstractRealListHandler extends AbstractHandler implements NestedTableContainer { + + protected int startRow; + protected int startCol; + + private IListGroupContent currentGroup; + private IListBandContent currentBand; + + private AreaBorders borderDefn; + + private List< NestedTableHandler > nestedTables; + + public AbstractRealListHandler(Logger log, IHandler parent, IListContent list) { + super(log, parent, list); + } + + public void addNestedTable( NestedTableHandler nestedTableHandler ) { + if( nestedTables == null ) { + nestedTables = new ArrayList(); + } + log.debug( "Adding nested table: ", nestedTableHandler ); + nestedTables.add(nestedTableHandler); + } + + public boolean rowHasNestedTable( int rowNum ) { + if( nestedTables != null ) { + for( NestedTableHandler nestedTableHandler : nestedTables ) { + if( nestedTableHandler.includesRow( rowNum ) ) { + log.debug( "Row ", rowNum, " has nested table ", nestedTableHandler ); + return true; + } + } + } + log.debug( "Row ", rowNum, " has no nested tables" ); + return false; + } + + public int extendRowBy( int rowNum ) { + int offset = 1; + if( nestedTables != null ) { + for( NestedTableHandler nestedTableHandler : nestedTables ) { + int nestedTablesOffset = nestedTableHandler.extendParentsRowBy( rowNum ); + if( nestedTablesOffset > offset ) { + log.debug( "Row ", rowNum, " is extended by ", nestedTablesOffset, " thanks to ", nestedTableHandler ); + offset = nestedTablesOffset; + } + } + } + return offset; + } + + @Override + public void startList(HandlerState state, IListContent list) throws BirtException { + startRow = state.rowNum; + startCol = state.colNum; + log.debug( "List started at [", startRow, ",", startCol, "]" ); + } + + @Override + public void endList(HandlerState state, IListContent list) throws BirtException { + state.setHandler(parent); + + int endRow = state.rowNum - 1; + int colStart = 0; + int colEnd = 0; + + for( int row = startRow; row < endRow; ++row ) { + if( state.currentSheet.getRow(row) != null ) { + int lastColInRow = state.currentSheet.getRow(row).getLastCellNum() - 1; + if( lastColInRow > colEnd ) { + colEnd = lastColInRow; + } + } + } + + state.getSmu().applyBordersToArea( state.getSm(), state.currentSheet, colStart, colEnd, startRow, endRow, new BirtStyle( list ) ); + + if( borderDefn != null ) { + state.removeBorderOverload(borderDefn); + } + + if( list.getBookmark() != null ) { + createName(state, prepareName( list.getBookmark() ), startRow, 0, state.rowNum - 1, 0); + } + + if( EmitterServices.booleanOption( state.getRenderOptions(), list, ExcelEmitter.DISPLAYFORMULAS_PROP, false ) ) { + state.currentSheet.setDisplayFormulas(true); + } + if( ! EmitterServices.booleanOption( state.getRenderOptions(), list, ExcelEmitter.DISPLAYGRIDLINES_PROP, true ) ) { + state.currentSheet.setDisplayGridlines(false); + } + if( ! EmitterServices.booleanOption( state.getRenderOptions(), list, ExcelEmitter.DISPLAYROWCOLHEADINGS_PROP, true ) ) { + state.currentSheet.setDisplayRowColHeadings(false); + } + if( ! EmitterServices.booleanOption( state.getRenderOptions(), list, ExcelEmitter.DISPLAYZEROS_PROP, true ) ) { + state.currentSheet.setDisplayZeros(false); + } + } + + @Override + public void startListBand(HandlerState state, IListBandContent band) throws BirtException { + currentBand = band; + state.colNum = startCol; + log.debug( "startListBand with startCol = ", startCol ); + } + + @Override + public void endListBand(HandlerState state, IListBandContent band) throws BirtException { + boolean rowHasNestedTable = rowHasNestedTable( state.rowNum ); + + if( rowHasNestedTable ) { + state.rowNum += extendRowBy( state.rowNum ); + } + state.colNum = startCol; + + currentBand = null; + } + + @Override + public void startListGroup(HandlerState state, IListGroupContent group) throws BirtException { + currentGroup = group; + } + + @Override + public void endListGroup(HandlerState state, IListGroupContent group) throws BirtException { + currentGroup = null; + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableCellHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableCellHandler.java index 2e39a8144..54b80163c 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableCellHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableCellHandler.java @@ -1,317 +1,317 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.util.CellRangeAddress; -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IAutoTextContent; -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.content.IContainerContent; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IElement; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.IListContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITextContent; -import org.eclipse.birt.report.engine.content.impl.CellContent; -import org.eclipse.birt.report.engine.content.impl.TableContent; -import org.eclipse.birt.report.engine.css.engine.StyleConstants; -import org.eclipse.birt.report.engine.emitter.IContentEmitter; -import org.eclipse.birt.report.engine.ir.CellDesign; -import org.eclipse.birt.report.engine.layout.pdf.util.HTML2Content; - -import uk.co.spudsoft.birt.emitters.excel.Area; -import uk.co.spudsoft.birt.emitters.excel.Coordinate; -import uk.co.spudsoft.birt.emitters.excel.EmitterServices; -import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class AbstractRealTableCellHandler extends CellContentHandler { - - protected int column; - private AbstractRealTableRowHandler parentRow; - private boolean containsTable; - - public AbstractRealTableCellHandler(IContentEmitter emitter, Logger log, IHandler parent, ICellContent cell) { - super(emitter, log, parent, cell); - column = cell.getColumn(); - } - - @Override - public void notifyHandler(HandlerState state) { - if( parentRow != null ) { - parentRow.resumeRow(state); - resumeCell(state); - parentRow = null; - } - } - - @Override - public void startCell(HandlerState state, ICellContent cell) throws BirtException { - log.debug( "Cell - " - + "BIRT[" - + cell.getRow() - + ( cell.getRowSpan() > 1 ? "-" + (cell.getRow() + cell.getRowSpan()-1) : "" ) - + "," - + cell.getColumn() - + ( cell.getColSpan() > 1 ? "-" + (cell.getColumn() + cell.getColSpan()-1) : "" ) - + "]" - + " state[" - + state.rowNum - + "," - + state.colNum - + "]" - ); - resumeCell(state); - } - - @Override - public void endCell(HandlerState state, ICellContent cell) throws BirtException { - if( cell.getBookmark() != null ) { - createName(state, prepareName( cell.getBookmark() ), state.rowNum, state.colNum, state.rowNum, state.colNum); - } - - interruptCell(state, ! containsTable ); - } - - public void resumeCell(HandlerState state) { - } - - public void interruptCell(HandlerState state, boolean includeFormatOnly) throws BirtException { - - if( state == null ) { - System.err.println( "state == null" ); - } else if( state.currentSheet == null ) { - System.err.println( "state.currentSheet == null" ); - } else if( state.currentSheet.getRow(state.rowNum) == null ) { - System.err.println( "state.currentSheet.getRow(" + state.rowNum + ") == null" ); - } - - if( ( lastValue != null ) || includeFormatOnly ) { - Cell currentCell = state.currentSheet.getRow(state.rowNum).getCell( column ); - if( currentCell == null ) { - log.debug( "Creating cell[", state.rowNum, ",", column, "]"); - currentCell = state.currentSheet.getRow(state.rowNum).createCell( column ); - } - - ICellContent cell = (ICellContent)element; - Area area = null; - - if(( cell.getColSpan() > 1 )||( cell.getRowSpan() > 1 )) { - - int endRow = state.rowNum + cell.getRowSpan() - 1; - int endCol = state.colNum + cell.getColSpan() - 1; - - if(cell.getRowSpan() > 1) { - log.debug( "Adding row span [", state.rowNum, ",", state.colNum, "] to [", endRow, ",", endCol, "]" ); - area = state.addRowSpan(state.rowNum, state.colNum, endRow, endCol); - } - - int offset = state.computeNumberSpanBefore(state.rowNum, state.colNum); - log.debug( "Offset for [", state.rowNum, ",", state.colNum, "] calculated as ", offset); - log.debug( "Merging [", state.rowNum, ",", state.colNum + offset, "] to [", endRow, ",", endCol + offset, "]" ); - log.debug( "Should be merging ? [", state.rowNum, ",", column, "] to [", endRow, ",", column + cell.getColSpan() - 1, "]" ); - // CellRangeAddress newMergedRegion = new CellRangeAddress( state.rowNum, endRow, state.colNum + offset, endCol + offset ); - CellRangeAddress newMergedRegion = new CellRangeAddress( state.rowNum, endRow, column, column + cell.getColSpan() - 1 ); - state.currentSheet.addMergedRegion( newMergedRegion ); - - colSpan = cell.getColSpan(); - } - - endCellContent(state, cell, lastElement, currentCell, area); - } - - if( state.cellIsMergedWithBorders( state.rowNum, column ) ) { - int absoluteColumn = column; - ++state.colNum; - --colSpan; - while( colSpan > 0 ) { - ++absoluteColumn; - log.debug( "Creating cell[", state.rowNum, ",", absoluteColumn, "]"); - Cell currentCell = state.currentSheet.getRow(state.rowNum).createCell( absoluteColumn ); - endCellContent(state, null, null, currentCell, null); - ++state.colNum; - --colSpan; - } - } else { - state.colNum += colSpan; - } - - state.setHandler(parent); - } - - - @Override - public void startContainer(HandlerState state, IContainerContent container) throws BirtException { - // log.debug( "Container display = " + getStyleProperty( container, StyleConstants.STYLE_DISPLAY, "block") ); - if( ! "inline".equals( getStyleProperty( container, StyleConstants.STYLE_DISPLAY, "block") ) ) { - lastCellContentsWasBlock = true; - } - } - - @Override - public void endContainer(HandlerState state, IContainerContent container) throws BirtException { - // log.debug( "Container display = " + getStyleProperty( container, StyleConstants.STYLE_DISPLAY, "block") ); - if( ! "inline".equals( getStyleProperty( container, StyleConstants.STYLE_DISPLAY, "block") ) ) { - lastCellContentsWasBlock = true; - } - } - - private TableContent cellDesignsTableContent() { - IElement current = element; - while( ( current != null ) && ! ( current instanceof TableContent ) ) { - current = current.getParent(); - } - return (TableContent)current; - } - - @Override - public void startTable(HandlerState state, ITableContent table) throws BirtException { - int colSpan = ((ICellContent)element).getColSpan(); - int rowSpan = ((ICellContent)element).getRowSpan(); - ITableHandler tableHandler = getAncestor(ITableHandler.class); - TableContent myTableContent = cellDesignsTableContent(); - - if( ( tableHandler != null ) - && ( tableHandler.getColumnCount() == colSpan ) - && ( 1 == ( (CellDesign)( (CellContent)table.getParent() ).getGenerateBy()).getContentCount() ) - ) { - // Parent row contains only one item - - containsTable = true; - parentRow = getAncestor(AbstractRealTableRowHandler.class); - interruptCell(state, false); - parentRow.interruptRow(state); - - state.setHandler(new NestedTableHandler(log, this, table, rowSpan)); - state.getHandler().startTable(state, table); - } else if( ( tableHandler != null ) - && ( myTableContent != null ) - && ( table.getParent() instanceof CellContent ) - && ( ( (CellContent)table.getParent() ).getGenerateBy() instanceof CellDesign ) - && ( ( (CellDesign)( (CellContent)table.getParent() ).getGenerateBy()).getColumn() + 1 == myTableContent.getColumnCount() ) - && EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.NEST_TABLE_IN_LAST_CELL, false ) - ) { - // This is last cell in row - - colSpan = table.getColumnCount(); - containsTable = true; - parentRow = getAncestor(AbstractRealTableRowHandler.class); - interruptCell(state, false); - // parentRow.interruptRow(state); - - state.setHandler(new NestedTableHandler(log, this, table, rowSpan)); - state.getHandler().startTable(state, table); - } else if( ( tableHandler != null ) - && ( table.getColumnCount() <= colSpan ) - ) { - // This cell is merged over same number of columns as new table - - containsTable = true; - parentRow = getAncestor(AbstractRealTableRowHandler.class); - interruptCell(state, false); - - removeMergedCell( state, state.rowNum, state.colNum ); - - NestedTableHandler nestedTableHandler = new NestedTableHandler(log, this, table, rowSpan); - nestedTableHandler.setInserted(true); - state.setHandler(nestedTableHandler); - state.getHandler().startTable(state, table); - - } else { - state.setHandler(new FlattenedTableHandler(this, log, this, table)); - state.getHandler().startTable(state, table); - } - } - - @Override - public void startList(HandlerState state, IListContent list) throws BirtException { - int colSpan = ((ICellContent)element).getColSpan(); - ITableHandler tableHandler = getAncestor(ITableHandler.class); - if( ( tableHandler != null ) - && ( tableHandler.getColumnCount() == colSpan ) - && ( 1 == ( (CellDesign)( (CellContent)list.getParent() ).getGenerateBy()).getContentCount() ) - ) { - - containsTable = true; - parentRow = getAncestor(AbstractRealTableRowHandler.class); - interruptCell(state, false); - parentRow.interruptRow(state); - - state.colNum = column; - state.setHandler(new NestedListHandler(log, this, list)); - state.getHandler().startList(state, list); - } else { - state.setHandler(new FlattenedListHandler(this, log, this, list)); - state.getHandler().startList(state, list); - } - } - - @Override - public void emitText(HandlerState state, ITextContent text) throws BirtException { - String textText = text.getText(); - log.debug( "text:", textText ); - emitContent(state,text,textText, ( ! "inline".equals( getStyleProperty(text, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - } - - @Override - public void emitData(HandlerState state, IDataContent data) throws BirtException { - emitContent(state,data,data.getValue(), ( ! "inline".equals( getStyleProperty(data, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - } - - @Override - public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { - // String labelText = ( label.getLabelText() != null ) ? label.getLabelText() : label.getText(); - String labelText = ( label.getText() != null ) ? label.getText() : label.getLabelText(); - log.debug( "labelText:", labelText ); - emitContent(state,label,labelText, ( ! "inline".equals( getStyleProperty(label, StyleConstants.STYLE_DISPLAY, "block") ) )); - } - - @Override - public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { - emitContent(state,autoText,autoText.getText(), ( ! "inline".equals( getStyleProperty(autoText, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - } - - @Override - public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { - - log.debug( "Handling foreign content of type ", foreign.getRawType() ); - if ( IForeignContent.HTML_TYPE.equalsIgnoreCase( foreign.getRawType( ) ) ) - { - HTML2Content.html2Content( foreign ); - contentVisitor.visitChildren( foreign, null ); - } - } - - @Override - public void emitImage(HandlerState state, IImageContent image) throws BirtException { - boolean imageCanSpan = false; - - int colSpan = ((ICellContent)element).getColSpan(); - ITableHandler tableHandler = getAncestor(ITableHandler.class); - if( ( tableHandler != null ) - && ( tableHandler.getColumnCount() == colSpan ) - && ( 1 == ( (CellDesign)( (CellContent)image.getParent() ).getGenerateBy()).getContentCount() ) - ) { - imageCanSpan = true; - } - recordImage(state, new Coordinate( state.rowNum, column ), image, imageCanSpan); - lastElement = image; - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.util.CellRangeAddress; +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IAutoTextContent; +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.content.IContainerContent; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IElement; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.IListContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITextContent; +import org.eclipse.birt.report.engine.content.impl.CellContent; +import org.eclipse.birt.report.engine.content.impl.TableContent; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.emitter.IContentEmitter; +import org.eclipse.birt.report.engine.ir.CellDesign; +import org.eclipse.birt.report.engine.layout.pdf.util.HTML2Content; + +import uk.co.spudsoft.birt.emitters.excel.Area; +import uk.co.spudsoft.birt.emitters.excel.Coordinate; +import uk.co.spudsoft.birt.emitters.excel.EmitterServices; +import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class AbstractRealTableCellHandler extends CellContentHandler { + + protected int column; + private AbstractRealTableRowHandler parentRow; + private boolean containsTable; + + public AbstractRealTableCellHandler(IContentEmitter emitter, Logger log, IHandler parent, ICellContent cell) { + super(emitter, log, parent, cell); + column = cell.getColumn(); + } + + @Override + public void notifyHandler(HandlerState state) { + if( parentRow != null ) { + parentRow.resumeRow(state); + resumeCell(state); + parentRow = null; + } + } + + @Override + public void startCell(HandlerState state, ICellContent cell) throws BirtException { + log.debug( "Cell - " + + "BIRT[" + + cell.getRow() + + ( cell.getRowSpan() > 1 ? "-" + (cell.getRow() + cell.getRowSpan()-1) : "" ) + + "," + + cell.getColumn() + + ( cell.getColSpan() > 1 ? "-" + (cell.getColumn() + cell.getColSpan()-1) : "" ) + + "]" + + " state[" + + state.rowNum + + "," + + state.colNum + + "]" + ); + resumeCell(state); + } + + @Override + public void endCell(HandlerState state, ICellContent cell) throws BirtException { + if( cell.getBookmark() != null ) { + createName(state, prepareName( cell.getBookmark() ), state.rowNum, state.colNum, state.rowNum, state.colNum); + } + + interruptCell(state, ! containsTable ); + } + + public void resumeCell(HandlerState state) { + } + + public void interruptCell(HandlerState state, boolean includeFormatOnly) throws BirtException { + + if( state == null ) { + System.err.println( "state == null" ); + } else if( state.currentSheet == null ) { + System.err.println( "state.currentSheet == null" ); + } else if( state.currentSheet.getRow(state.rowNum) == null ) { + System.err.println( "state.currentSheet.getRow(" + state.rowNum + ") == null" ); + } + + if( ( lastValue != null ) || includeFormatOnly ) { + Cell currentCell = state.currentSheet.getRow(state.rowNum).getCell( column ); + if( currentCell == null ) { + log.debug( "Creating cell[", state.rowNum, ",", column, "]"); + currentCell = state.currentSheet.getRow(state.rowNum).createCell( column ); + } + + ICellContent cell = (ICellContent)element; + Area area = null; + + if(( cell.getColSpan() > 1 )||( cell.getRowSpan() > 1 )) { + + int endRow = state.rowNum + cell.getRowSpan() - 1; + int endCol = state.colNum + cell.getColSpan() - 1; + + if(cell.getRowSpan() > 1) { + log.debug( "Adding row span [", state.rowNum, ",", state.colNum, "] to [", endRow, ",", endCol, "]" ); + area = state.addRowSpan(state.rowNum, state.colNum, endRow, endCol); + } + + int offset = state.computeNumberSpanBefore(state.rowNum, state.colNum); + log.debug( "Offset for [", state.rowNum, ",", state.colNum, "] calculated as ", offset); + log.debug( "Merging [", state.rowNum, ",", state.colNum + offset, "] to [", endRow, ",", endCol + offset, "]" ); + log.debug( "Should be merging ? [", state.rowNum, ",", column, "] to [", endRow, ",", column + cell.getColSpan() - 1, "]" ); + // CellRangeAddress newMergedRegion = new CellRangeAddress( state.rowNum, endRow, state.colNum + offset, endCol + offset ); + CellRangeAddress newMergedRegion = new CellRangeAddress( state.rowNum, endRow, column, column + cell.getColSpan() - 1 ); + state.currentSheet.addMergedRegion( newMergedRegion ); + + colSpan = cell.getColSpan(); + } + + endCellContent(state, cell, lastElement, currentCell, area); + } + + if( state.cellIsMergedWithBorders( state.rowNum, column ) ) { + int absoluteColumn = column; + ++state.colNum; + --colSpan; + while( colSpan > 0 ) { + ++absoluteColumn; + log.debug( "Creating cell[", state.rowNum, ",", absoluteColumn, "]"); + Cell currentCell = state.currentSheet.getRow(state.rowNum).createCell( absoluteColumn ); + endCellContent(state, null, null, currentCell, null); + ++state.colNum; + --colSpan; + } + } else { + state.colNum += colSpan; + } + + state.setHandler(parent); + } + + + @Override + public void startContainer(HandlerState state, IContainerContent container) throws BirtException { + // log.debug( "Container display = " + getStyleProperty( container, StyleConstants.STYLE_DISPLAY, "block") ); + if( ! "inline".equals( getStyleProperty( container, StyleConstants.STYLE_DISPLAY, "block") ) ) { + lastCellContentsWasBlock = true; + } + } + + @Override + public void endContainer(HandlerState state, IContainerContent container) throws BirtException { + // log.debug( "Container display = " + getStyleProperty( container, StyleConstants.STYLE_DISPLAY, "block") ); + if( ! "inline".equals( getStyleProperty( container, StyleConstants.STYLE_DISPLAY, "block") ) ) { + lastCellContentsWasBlock = true; + } + } + + private TableContent cellDesignsTableContent() { + IElement current = element; + while( ( current != null ) && ! ( current instanceof TableContent ) ) { + current = current.getParent(); + } + return (TableContent)current; + } + + @Override + public void startTable(HandlerState state, ITableContent table) throws BirtException { + int colSpan = ((ICellContent)element).getColSpan(); + int rowSpan = ((ICellContent)element).getRowSpan(); + ITableHandler tableHandler = getAncestor(ITableHandler.class); + TableContent myTableContent = cellDesignsTableContent(); + + if( ( tableHandler != null ) + && ( tableHandler.getColumnCount() == colSpan ) + && ( 1 == ( (CellDesign)( (CellContent)table.getParent() ).getGenerateBy()).getContentCount() ) + ) { + // Parent row contains only one item + + containsTable = true; + parentRow = getAncestor(AbstractRealTableRowHandler.class); + interruptCell(state, false); + parentRow.interruptRow(state); + + state.setHandler(new NestedTableHandler(log, this, table, rowSpan)); + state.getHandler().startTable(state, table); + } else if( ( tableHandler != null ) + && ( myTableContent != null ) + && ( table.getParent() instanceof CellContent ) + && ( ( (CellContent)table.getParent() ).getGenerateBy() instanceof CellDesign ) + && ( ( (CellDesign)( (CellContent)table.getParent() ).getGenerateBy()).getColumn() + 1 == myTableContent.getColumnCount() ) + && EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.NEST_TABLE_IN_LAST_CELL, false ) + ) { + // This is last cell in row + + colSpan = table.getColumnCount(); + containsTable = true; + parentRow = getAncestor(AbstractRealTableRowHandler.class); + interruptCell(state, false); + // parentRow.interruptRow(state); + + state.setHandler(new NestedTableHandler(log, this, table, rowSpan)); + state.getHandler().startTable(state, table); + } else if( ( tableHandler != null ) + && ( table.getColumnCount() <= colSpan ) + ) { + // This cell is merged over same number of columns as new table + + containsTable = true; + parentRow = getAncestor(AbstractRealTableRowHandler.class); + interruptCell(state, false); + + removeMergedCell( state, state.rowNum, state.colNum ); + + NestedTableHandler nestedTableHandler = new NestedTableHandler(log, this, table, rowSpan); + nestedTableHandler.setInserted(true); + state.setHandler(nestedTableHandler); + state.getHandler().startTable(state, table); + + } else { + state.setHandler(new FlattenedTableHandler(this, log, this, table)); + state.getHandler().startTable(state, table); + } + } + + @Override + public void startList(HandlerState state, IListContent list) throws BirtException { + int colSpan = ((ICellContent)element).getColSpan(); + ITableHandler tableHandler = getAncestor(ITableHandler.class); + if( ( tableHandler != null ) + && ( tableHandler.getColumnCount() == colSpan ) + && ( 1 == ( (CellDesign)( (CellContent)list.getParent() ).getGenerateBy()).getContentCount() ) + ) { + + containsTable = true; + parentRow = getAncestor(AbstractRealTableRowHandler.class); + interruptCell(state, false); + parentRow.interruptRow(state); + + state.colNum = column; + state.setHandler(new NestedListHandler(log, this, list)); + state.getHandler().startList(state, list); + } else { + state.setHandler(new FlattenedListHandler(this, log, this, list)); + state.getHandler().startList(state, list); + } + } + + @Override + public void emitText(HandlerState state, ITextContent text) throws BirtException { + String textText = text.getText(); + log.debug( "text:", textText ); + emitContent(state,text,textText, ( ! "inline".equals( getStyleProperty(text, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + } + + @Override + public void emitData(HandlerState state, IDataContent data) throws BirtException { + emitContent(state,data,data.getValue(), ( ! "inline".equals( getStyleProperty(data, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + } + + @Override + public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { + // String labelText = ( label.getLabelText() != null ) ? label.getLabelText() : label.getText(); + String labelText = ( label.getText() != null ) ? label.getText() : label.getLabelText(); + log.debug( "labelText:", labelText ); + emitContent(state,label,labelText, ( ! "inline".equals( getStyleProperty(label, StyleConstants.STYLE_DISPLAY, "block") ) )); + } + + @Override + public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { + emitContent(state,autoText,autoText.getText(), ( ! "inline".equals( getStyleProperty(autoText, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + } + + @Override + public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { + + log.debug( "Handling foreign content of type ", foreign.getRawType() ); + if ( IForeignContent.HTML_TYPE.equalsIgnoreCase( foreign.getRawType( ) ) ) + { + HTML2Content.html2Content( foreign ); + contentVisitor.visitChildren( foreign, null ); + } + } + + @Override + public void emitImage(HandlerState state, IImageContent image) throws BirtException { + boolean imageCanSpan = false; + + int colSpan = ((ICellContent)element).getColSpan(); + ITableHandler tableHandler = getAncestor(ITableHandler.class); + if( ( tableHandler != null ) + && ( tableHandler.getColumnCount() == colSpan ) + && ( 1 == ( (CellDesign)( (CellContent)image.getParent() ).getGenerateBy()).getContentCount() ) + ) { + imageCanSpan = true; + } + recordImage(state, new Coordinate( state.rowNum, column ), image, imageCanSpan); + lastElement = image; + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableHandler.java index 6a93ccfad..5b69d11d9 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableHandler.java @@ -1,204 +1,204 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.poi.ss.util.SheetUtil; -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.ITableBandContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITableGroupContent; -import org.eclipse.birt.report.engine.ir.DimensionType; -import org.eclipse.birt.report.engine.ir.GridItemDesign; - -import uk.co.spudsoft.birt.emitters.excel.AreaBorders; -import uk.co.spudsoft.birt.emitters.excel.BirtStyle; -import uk.co.spudsoft.birt.emitters.excel.EmitterServices; -import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; -import uk.co.spudsoft.birt.emitters.excel.FilteredSheet; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class AbstractRealTableHandler extends AbstractHandler implements ITableHandler, NestedTableContainer { - - protected int startRow; - protected int startCol; - protected int startDetailsRow = -1; - protected int endDetailsRow; - - private ITableGroupContent currentGroup; - private ITableBandContent currentBand; - - private BirtStyle tableStyle; - private AreaBorders borderDefn; - - private List< NestedTableHandler > nestedTables; - - public AbstractRealTableHandler(Logger log, IHandler parent, ITableContent table) { - super(log, parent, table); - } - - public int getColumnCount() { - return ((ITableContent)this.element).getColumnCount(); - } - - public void addNestedTable( NestedTableHandler nestedTableHandler ) { - if( nestedTables == null ) { - nestedTables = new ArrayList(); - } - log.debug( "Adding nested table: ", nestedTableHandler ); - nestedTables.add(nestedTableHandler); - } - - public boolean rowHasNestedTable( int rowNum ) { - if( nestedTables != null ) { - for( NestedTableHandler nestedTableHandler : nestedTables ) { - if( nestedTableHandler.includesRow( rowNum ) ) { - log.debug( "Row ", rowNum, " has nested table ", nestedTableHandler ); - return true; - } - } - } - log.debug( "Row ", rowNum, " has no nested tables" ); - return false; - } - - public int extendRowBy( int rowNum ) { - int offset = 1; - if( nestedTables != null ) { - for( NestedTableHandler nestedTableHandler : nestedTables ) { - int nestedTablesOffset = nestedTableHandler.extendParentsRowBy( rowNum ); - if( nestedTablesOffset > offset ) { - log.debug( "Row ", rowNum, " is extended by ", nestedTablesOffset, " thanks to ", nestedTableHandler ); - offset = nestedTablesOffset; - } - } - } - return offset; - } - - @Override - public void startTable(HandlerState state, ITableContent table) throws BirtException { - startRow = state.rowNum; - startCol = state.colNum; - - log.debug( "startTable @ [", startRow, ",", startCol, "]" ); - - for( int col = 0; col < table.getColumnCount(); ++col ) { - DimensionType width = table.getColumn(col).getWidth(); - if( width != null ) { - log.debug( "BIRT table column width: ", col, " = ", width); - int newWidth = state.getSmu().poiColumnWidthFromDimension(width); - int oldWidth = state.currentSheet.getColumnWidth(startCol + col); - if( ( oldWidth == 256 * state.currentSheet.getDefaultColumnWidth() ) || ( newWidth > oldWidth ) ) { - state.currentSheet.setColumnWidth(startCol + col, newWidth); - } - } - } - - tableStyle = new BirtStyle( table ); - borderDefn = AreaBorders.create( -1, startCol, startCol + table.getColumnCount() - 1, startRow, tableStyle ); - if( borderDefn != null ) { - state.insertBorderOverload(borderDefn); - } - - if( table.getGenerateBy() instanceof GridItemDesign ) { - startDetailsRow = state.rowNum; - } - } - - @Override - public void endTable(HandlerState state, ITableContent table) throws BirtException { - if( table.getGenerateBy() instanceof GridItemDesign ) { - endDetailsRow = state.rowNum; - } - - log.debug( "Applying bottom border to [", state.rowNum - 1, ",", startCol, "] - [", state.rowNum - 1, ",", startCol + table.getColumnCount() - 1, "]" ); - state.getSmu().applyBottomBorderToRow( state.getSm(), state.currentSheet, startCol, startCol + table.getColumnCount() - 1, state.rowNum - 1, tableStyle ); - - if( borderDefn != null ) { - state.removeBorderOverload(borderDefn); - } - - log.debug( "Details rows from ", startDetailsRow, " to ", endDetailsRow ); - - if( ( startDetailsRow > 0 ) && ( endDetailsRow > startDetailsRow ) ) { - boolean forceAutoColWidths = EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.FORCEAUTOCOLWIDTHS_PROP, false ); - for( int col = 0; col < table.getColumnCount(); ++col ) { - int oldWidth = state.currentSheet.getColumnWidth(col); - if( forceAutoColWidths || ( oldWidth == 256 * state.currentSheet.getDefaultColumnWidth() ) ) { - FilteredSheet filteredSheet = new FilteredSheet( state.currentSheet, startDetailsRow, Math.min(endDetailsRow, startDetailsRow + 12) ); - double calcWidth = SheetUtil.getColumnWidth( filteredSheet, col, false ); - - if (calcWidth > 1.0) { - calcWidth *= 256; - int maxColumnWidth = 255*256; // The maximum column width for an individual cell is 255 characters - if (calcWidth > maxColumnWidth) { - calcWidth = maxColumnWidth; - } - if( calcWidth > oldWidth ) { - state.currentSheet.setColumnWidth( col, (int)(calcWidth) ); - } - } - } - } - } - - if( ( table.getBookmark() != null ) && ( state.rowNum > startRow ) && ( table.getColumnCount() > 1 ) ) { - createName(state, prepareName( table.getBookmark() ), startRow, 0, state.rowNum - 1, table.getColumnCount() - 1); - } - - if( EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.DISPLAYFORMULAS_PROP, false ) ) { - state.currentSheet.setDisplayFormulas(true); - } - if( ! EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.DISPLAYGRIDLINES_PROP, true ) ) { - state.currentSheet.setDisplayGridlines(false); - } - if( ! EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.DISPLAYROWCOLHEADINGS_PROP, true ) ) { - state.currentSheet.setDisplayRowColHeadings(false); - } - if( ! EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.DISPLAYZEROS_PROP, true ) ) { - state.currentSheet.setDisplayZeros(false); - } - } - - @Override - public void startTableBand(HandlerState state, ITableBandContent band) throws BirtException { - if( ( band.getBandType() == ITableBandContent.BAND_DETAIL ) && ( startDetailsRow < 0 ) ) { - startDetailsRow = state.rowNum; - } - currentBand = band; - } - - @Override - public void endTableBand(HandlerState state, ITableBandContent band) throws BirtException { - if( band.getBandType() == ITableBandContent.BAND_DETAIL ) { - endDetailsRow = state.rowNum - 1; - } - currentBand = null; - } - - @Override - public void startTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { - currentGroup = group; - } - - @Override - public void endTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { - currentGroup = null; - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.ss.util.SheetUtil; +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.ITableBandContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITableGroupContent; +import org.eclipse.birt.report.engine.ir.DimensionType; +import org.eclipse.birt.report.engine.ir.GridItemDesign; + +import uk.co.spudsoft.birt.emitters.excel.AreaBorders; +import uk.co.spudsoft.birt.emitters.excel.BirtStyle; +import uk.co.spudsoft.birt.emitters.excel.EmitterServices; +import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; +import uk.co.spudsoft.birt.emitters.excel.FilteredSheet; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class AbstractRealTableHandler extends AbstractHandler implements ITableHandler, NestedTableContainer { + + protected int startRow; + protected int startCol; + protected int startDetailsRow = -1; + protected int endDetailsRow; + + private ITableGroupContent currentGroup; + private ITableBandContent currentBand; + + private BirtStyle tableStyle; + private AreaBorders borderDefn; + + private List< NestedTableHandler > nestedTables; + + public AbstractRealTableHandler(Logger log, IHandler parent, ITableContent table) { + super(log, parent, table); + } + + public int getColumnCount() { + return ((ITableContent)this.element).getColumnCount(); + } + + public void addNestedTable( NestedTableHandler nestedTableHandler ) { + if( nestedTables == null ) { + nestedTables = new ArrayList(); + } + log.debug( "Adding nested table: ", nestedTableHandler ); + nestedTables.add(nestedTableHandler); + } + + public boolean rowHasNestedTable( int rowNum ) { + if( nestedTables != null ) { + for( NestedTableHandler nestedTableHandler : nestedTables ) { + if( nestedTableHandler.includesRow( rowNum ) ) { + log.debug( "Row ", rowNum, " has nested table ", nestedTableHandler ); + return true; + } + } + } + log.debug( "Row ", rowNum, " has no nested tables" ); + return false; + } + + public int extendRowBy( int rowNum ) { + int offset = 1; + if( nestedTables != null ) { + for( NestedTableHandler nestedTableHandler : nestedTables ) { + int nestedTablesOffset = nestedTableHandler.extendParentsRowBy( rowNum ); + if( nestedTablesOffset > offset ) { + log.debug( "Row ", rowNum, " is extended by ", nestedTablesOffset, " thanks to ", nestedTableHandler ); + offset = nestedTablesOffset; + } + } + } + return offset; + } + + @Override + public void startTable(HandlerState state, ITableContent table) throws BirtException { + startRow = state.rowNum; + startCol = state.colNum; + + log.debug( "startTable @ [", startRow, ",", startCol, "]" ); + + for( int col = 0; col < table.getColumnCount(); ++col ) { + DimensionType width = table.getColumn(col).getWidth(); + if( width != null ) { + log.debug( "BIRT table column width: ", col, " = ", width); + int newWidth = state.getSmu().poiColumnWidthFromDimension(width); + int oldWidth = state.currentSheet.getColumnWidth(startCol + col); + if( ( oldWidth == 256 * state.currentSheet.getDefaultColumnWidth() ) || ( newWidth > oldWidth ) ) { + state.currentSheet.setColumnWidth(startCol + col, newWidth); + } + } + } + + tableStyle = new BirtStyle( table ); + borderDefn = AreaBorders.create( -1, startCol, startCol + table.getColumnCount() - 1, startRow, tableStyle ); + if( borderDefn != null ) { + state.insertBorderOverload(borderDefn); + } + + if( table.getGenerateBy() instanceof GridItemDesign ) { + startDetailsRow = state.rowNum; + } + } + + @Override + public void endTable(HandlerState state, ITableContent table) throws BirtException { + if( table.getGenerateBy() instanceof GridItemDesign ) { + endDetailsRow = state.rowNum; + } + + log.debug( "Applying bottom border to [", state.rowNum - 1, ",", startCol, "] - [", state.rowNum - 1, ",", startCol + table.getColumnCount() - 1, "]" ); + state.getSmu().applyBottomBorderToRow( state.getSm(), state.currentSheet, startCol, startCol + table.getColumnCount() - 1, state.rowNum - 1, tableStyle ); + + if( borderDefn != null ) { + state.removeBorderOverload(borderDefn); + } + + log.debug( "Details rows from ", startDetailsRow, " to ", endDetailsRow ); + + if( ( startDetailsRow > 0 ) && ( endDetailsRow > startDetailsRow ) ) { + boolean forceAutoColWidths = EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.FORCEAUTOCOLWIDTHS_PROP, false ); + for( int col = 0; col < table.getColumnCount(); ++col ) { + int oldWidth = state.currentSheet.getColumnWidth(col); + if( forceAutoColWidths || ( oldWidth == 256 * state.currentSheet.getDefaultColumnWidth() ) ) { + FilteredSheet filteredSheet = new FilteredSheet( state.currentSheet, startDetailsRow, Math.min(endDetailsRow, startDetailsRow + 12) ); + double calcWidth = SheetUtil.getColumnWidth( filteredSheet, col, false ); + + if (calcWidth > 1.0) { + calcWidth *= 256; + int maxColumnWidth = 255*256; // The maximum column width for an individual cell is 255 characters + if (calcWidth > maxColumnWidth) { + calcWidth = maxColumnWidth; + } + if( calcWidth > oldWidth ) { + state.currentSheet.setColumnWidth( col, (int)(calcWidth) ); + } + } + } + } + } + + if( ( table.getBookmark() != null ) && ( state.rowNum > startRow ) && ( table.getColumnCount() > 1 ) ) { + createName(state, prepareName( table.getBookmark() ), startRow, 0, state.rowNum - 1, table.getColumnCount() - 1); + } + + if( EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.DISPLAYFORMULAS_PROP, false ) ) { + state.currentSheet.setDisplayFormulas(true); + } + if( ! EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.DISPLAYGRIDLINES_PROP, true ) ) { + state.currentSheet.setDisplayGridlines(false); + } + if( ! EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.DISPLAYROWCOLHEADINGS_PROP, true ) ) { + state.currentSheet.setDisplayRowColHeadings(false); + } + if( ! EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.DISPLAYZEROS_PROP, true ) ) { + state.currentSheet.setDisplayZeros(false); + } + } + + @Override + public void startTableBand(HandlerState state, ITableBandContent band) throws BirtException { + if( ( band.getBandType() == ITableBandContent.BAND_DETAIL ) && ( startDetailsRow < 0 ) ) { + startDetailsRow = state.rowNum; + } + currentBand = band; + } + + @Override + public void endTableBand(HandlerState state, ITableBandContent band) throws BirtException { + if( band.getBandType() == ITableBandContent.BAND_DETAIL ) { + endDetailsRow = state.rowNum - 1; + } + currentBand = null; + } + + @Override + public void startTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { + currentGroup = group; + } + + @Override + public void endTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { + currentGroup = null; + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableRowHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableRowHandler.java index c75e581e2..8e5625df5 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableRowHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/AbstractRealTableRowHandler.java @@ -1,196 +1,196 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import java.util.Iterator; - -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Row; -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IRowContent; -import org.eclipse.birt.report.engine.ir.DimensionType; -import org.eclipse.birt.report.model.api.util.DimensionUtil; - -import uk.co.spudsoft.birt.emitters.excel.AreaBorders; -import uk.co.spudsoft.birt.emitters.excel.BirtStyle; -import uk.co.spudsoft.birt.emitters.excel.CellImage; -import uk.co.spudsoft.birt.emitters.excel.EmitterServices; -import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.StyleManagerUtils; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public abstract class AbstractRealTableRowHandler extends AbstractHandler { - - protected Row currentRow; - protected int birtRowStartedAtPoiRow; - protected int birtRowStartedAtPoiCol; - protected int myRow; - protected int startCol; - - private BirtStyle rowStyle; - private AreaBorders borderDefn; - - public AbstractRealTableRowHandler(Logger log, IHandler parent, IRowContent row, int startCol) { - super(log, parent, row); - this.startCol = startCol; - } - - @Override - public void startRow(HandlerState state, IRowContent row) throws BirtException { - state.colNum = this.startCol; - birtRowStartedAtPoiRow = state.rowNum; - birtRowStartedAtPoiCol = state.colNum; - resumeRow(state); - } - - @Override - public void endRow(HandlerState state, IRowContent row) throws BirtException { - interruptRow(state); - if( row.getBookmark() != null ) { - createName(state, prepareName( row.getBookmark() ), birtRowStartedAtPoiRow, 0, state.rowNum - 1, currentRow.getLastCellNum() - 1 ); - } - - if( EmitterServices.booleanOption( state.getRenderOptions(), row, ExcelEmitter.PRINT_BREAK_AFTER, false ) ) { - state.currentSheet.setRowBreak( state.rowNum - 1 ); - } - - state.setHandler(parent); - } - - protected abstract boolean isNested(); - - public void resumeRow(HandlerState state) { - log.debug( "Resume row at ", state.rowNum ); - - myRow = state.rowNum; - if( state.currentSheet.getRow(state.rowNum) == null ) { - log.debug( "Creating row ", state.rowNum ); - currentRow = state.currentSheet.createRow( state.rowNum ); - } else { - currentRow = state.currentSheet.getRow( state.rowNum ); - } - state.requiredRowHeightInPoints = 0; - - rowStyle = new BirtStyle( (IRowContent)element ); - borderDefn = AreaBorders.create( myRow, 0, ((IRowContent)element).getTable().getColumnCount() - 1, myRow, rowStyle ); - if( borderDefn != null ) { - state.insertBorderOverload(borderDefn); - } - } - - public void interruptRow(HandlerState state) throws BirtException { - log.debug( "Interrupt row at ", state.rowNum ); - currentRow = state.currentSheet.getRow( state.rowNum ); - - boolean blankRow = EmitterServices.booleanOption( state.getRenderOptions(), element, ExcelEmitter.REMOVE_BLANK_ROWS, true ); - - log.debug( "currentRow.getRowNum() == ", currentRow.getRowNum(), ", state.rowNum == ", state.rowNum ); - - if( state.rowHasMergedCellsWithBorders( state.rowNum ) ) { - for( AreaBorders areaBorder : state.areaBorders ) { - if( ( areaBorder.isMergedCells ) - && ( areaBorder.top <= state.rowNum ) - && ( areaBorder.bottom >= state.rowNum ) ) { - - for( int column = areaBorder.left; column <= areaBorder.right; ++column ) { - if( currentRow.getCell(column) == null ) { - BirtStyle birtCellStyle = new BirtStyle( state.getSm().getCssEngine() ); - log.debug( "Creating cell[", state.rowNum, ",", column, "]"); - Cell cell = state.currentSheet.getRow(state.rowNum).createCell( column ); - state.getSmu().applyAreaBordersToCell(state.areaBorders, cell, birtCellStyle, state.rowNum, column); - CellStyle cellStyle = state.getSm().getStyle(birtCellStyle); - cell.setCellStyle(cellStyle); - } - } - } - } - blankRow = false; - } - - - if( blankRow ) { - for(Iterator iter = currentRow.cellIterator(); iter.hasNext(); ) { - Cell cell = iter.next(); - if( ! StyleManagerUtils.cellIsEmpty(cell)) { - blankRow = false; - break; - } - } - } - if( blankRow ) { - for( CellImage cellImage : state.images ) { - if( cellImage.location.getRow() == state.rowNum ) { - blankRow = false; - break; - } - } - } - if( blankRow ) { - if(state.computeNumberSpanBefore(state.rowNum, state.colNum) > 0) { - //this row is part of a row span. Dont delete it. - blankRow = false; - } - } - if( blankRow ) { - if( ((IRowContent)element).getBookmark() != null ) { - blankRow = false; - } - } - - boolean rowHasNestedTable = ((NestedTableContainer)parent).rowHasNestedTable( state.rowNum ); - - if( blankRow && rowHasNestedTable ) { - blankRow = false; - } - - if( blankRow && isNested() ) { - blankRow = false; - } - - if( blankRow || ( ( ! rowHasNestedTable ) && ( ! isNested() ) && ( currentRow.getPhysicalNumberOfCells() == 0 ) ) ) { - log.debug( "Removing row ", currentRow.getRowNum() ); - state.currentSheet.removeRow(currentRow); - } else { - DimensionType height = ((IRowContent)element).getHeight(); - if(height != null) { - if( DimensionUtil.isAbsoluteUnit(height.getUnits())) { - double points = height.convertTo(DimensionType.UNITS_PT); - currentRow.setHeightInPoints((float)points); - } - } - if( state.requiredRowHeightInPoints > currentRow.getHeightInPoints() ) { - currentRow.setHeightInPoints( state.requiredRowHeightInPoints ); - } - - if( rowHasNestedTable ) { - int increase = ((NestedTableContainer)parent).extendRowBy( state.rowNum ); - log.debug( "Incrementing rowNum from ", state.rowNum, " to ", state.rowNum + increase ); - state.rowNum += increase; - state.getSmu().extendRows( state, birtRowStartedAtPoiRow, birtRowStartedAtPoiCol, state.rowNum, state.colNum ); - } else if( currentRow.getPhysicalNumberOfCells() > 0 ){ - log.debug( "Incrementing rowNum from ", state.rowNum ); - state.rowNum += 1; - } else { - log.debug( "Not incrementing rowNum from ", state.rowNum, " because there are no cells on row ", currentRow.getPhysicalNumberOfCells() ); - } - } - - if( borderDefn != null ) { - state.removeBorderOverload(borderDefn); - borderDefn = null; - } - } -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import java.util.Iterator; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Row; +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IRowContent; +import org.eclipse.birt.report.engine.ir.DimensionType; +import org.eclipse.birt.report.model.api.util.DimensionUtil; + +import uk.co.spudsoft.birt.emitters.excel.AreaBorders; +import uk.co.spudsoft.birt.emitters.excel.BirtStyle; +import uk.co.spudsoft.birt.emitters.excel.CellImage; +import uk.co.spudsoft.birt.emitters.excel.EmitterServices; +import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.StyleManagerUtils; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public abstract class AbstractRealTableRowHandler extends AbstractHandler { + + protected Row currentRow; + protected int birtRowStartedAtPoiRow; + protected int birtRowStartedAtPoiCol; + protected int myRow; + protected int startCol; + + private BirtStyle rowStyle; + private AreaBorders borderDefn; + + public AbstractRealTableRowHandler(Logger log, IHandler parent, IRowContent row, int startCol) { + super(log, parent, row); + this.startCol = startCol; + } + + @Override + public void startRow(HandlerState state, IRowContent row) throws BirtException { + state.colNum = this.startCol; + birtRowStartedAtPoiRow = state.rowNum; + birtRowStartedAtPoiCol = state.colNum; + resumeRow(state); + } + + @Override + public void endRow(HandlerState state, IRowContent row) throws BirtException { + interruptRow(state); + if( row.getBookmark() != null ) { + createName(state, prepareName( row.getBookmark() ), birtRowStartedAtPoiRow, 0, state.rowNum - 1, currentRow.getLastCellNum() - 1 ); + } + + if( EmitterServices.booleanOption( state.getRenderOptions(), row, ExcelEmitter.PRINT_BREAK_AFTER, false ) ) { + state.currentSheet.setRowBreak( state.rowNum - 1 ); + } + + state.setHandler(parent); + } + + protected abstract boolean isNested(); + + public void resumeRow(HandlerState state) { + log.debug( "Resume row at ", state.rowNum ); + + myRow = state.rowNum; + if( state.currentSheet.getRow(state.rowNum) == null ) { + log.debug( "Creating row ", state.rowNum ); + currentRow = state.currentSheet.createRow( state.rowNum ); + } else { + currentRow = state.currentSheet.getRow( state.rowNum ); + } + state.requiredRowHeightInPoints = 0; + + rowStyle = new BirtStyle( (IRowContent)element ); + borderDefn = AreaBorders.create( myRow, 0, ((IRowContent)element).getTable().getColumnCount() - 1, myRow, rowStyle ); + if( borderDefn != null ) { + state.insertBorderOverload(borderDefn); + } + } + + public void interruptRow(HandlerState state) throws BirtException { + log.debug( "Interrupt row at ", state.rowNum ); + currentRow = state.currentSheet.getRow( state.rowNum ); + + boolean blankRow = EmitterServices.booleanOption( state.getRenderOptions(), element, ExcelEmitter.REMOVE_BLANK_ROWS, true ); + + log.debug( "currentRow.getRowNum() == ", currentRow.getRowNum(), ", state.rowNum == ", state.rowNum ); + + if( state.rowHasMergedCellsWithBorders( state.rowNum ) ) { + for( AreaBorders areaBorder : state.areaBorders ) { + if( ( areaBorder.isMergedCells ) + && ( areaBorder.top <= state.rowNum ) + && ( areaBorder.bottom >= state.rowNum ) ) { + + for( int column = areaBorder.left; column <= areaBorder.right; ++column ) { + if( currentRow.getCell(column) == null ) { + BirtStyle birtCellStyle = new BirtStyle( state.getSm().getCssEngine() ); + log.debug( "Creating cell[", state.rowNum, ",", column, "]"); + Cell cell = state.currentSheet.getRow(state.rowNum).createCell( column ); + state.getSmu().applyAreaBordersToCell(state.areaBorders, cell, birtCellStyle, state.rowNum, column); + CellStyle cellStyle = state.getSm().getStyle(birtCellStyle); + cell.setCellStyle(cellStyle); + } + } + } + } + blankRow = false; + } + + + if( blankRow ) { + for(Iterator iter = currentRow.cellIterator(); iter.hasNext(); ) { + Cell cell = iter.next(); + if( ! StyleManagerUtils.cellIsEmpty(cell)) { + blankRow = false; + break; + } + } + } + if( blankRow ) { + for( CellImage cellImage : state.images ) { + if( cellImage.location.getRow() == state.rowNum ) { + blankRow = false; + break; + } + } + } + if( blankRow ) { + if(state.computeNumberSpanBefore(state.rowNum, state.colNum) > 0) { + //this row is part of a row span. Dont delete it. + blankRow = false; + } + } + if( blankRow ) { + if( ((IRowContent)element).getBookmark() != null ) { + blankRow = false; + } + } + + boolean rowHasNestedTable = ((NestedTableContainer)parent).rowHasNestedTable( state.rowNum ); + + if( blankRow && rowHasNestedTable ) { + blankRow = false; + } + + if( blankRow && isNested() ) { + blankRow = false; + } + + if( blankRow || ( ( ! rowHasNestedTable ) && ( ! isNested() ) && ( currentRow.getPhysicalNumberOfCells() == 0 ) ) ) { + log.debug( "Removing row ", currentRow.getRowNum() ); + state.currentSheet.removeRow(currentRow); + } else { + DimensionType height = ((IRowContent)element).getHeight(); + if(height != null) { + if( DimensionUtil.isAbsoluteUnit(height.getUnits())) { + double points = height.convertTo(DimensionType.UNITS_PT); + currentRow.setHeightInPoints((float)points); + } + } + if( state.requiredRowHeightInPoints > currentRow.getHeightInPoints() ) { + currentRow.setHeightInPoints( state.requiredRowHeightInPoints ); + } + + if( rowHasNestedTable ) { + int increase = ((NestedTableContainer)parent).extendRowBy( state.rowNum ); + log.debug( "Incrementing rowNum from ", state.rowNum, " to ", state.rowNum + increase ); + state.rowNum += increase; + state.getSmu().extendRows( state, birtRowStartedAtPoiRow, birtRowStartedAtPoiCol, state.rowNum, state.colNum ); + } else if( currentRow.getPhysicalNumberOfCells() > 0 ){ + log.debug( "Incrementing rowNum from ", state.rowNum ); + state.rowNum += 1; + } else { + log.debug( "Not incrementing rowNum from ", state.rowNum, " because there are no cells on row ", currentRow.getPhysicalNumberOfCells() ); + } + } + + if( borderDefn != null ) { + state.removeBorderOverload(borderDefn); + borderDefn = null; + } + } +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/CellContentHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/CellContentHandler.java index 15672ac9c..f5557ac52 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/CellContentHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/CellContentHandler.java @@ -1,558 +1,558 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import java.io.IOException; -import java.math.BigDecimal; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - -import org.apache.poi.common.usermodel.HyperlinkType; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.Hyperlink; -import org.apache.poi.ss.usermodel.RichTextString; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.util.CellRangeAddress; -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.api.IHTMLActionHandler; -import org.eclipse.birt.report.engine.api.impl.Action; -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.content.IContent; -import org.eclipse.birt.report.engine.content.IHyperlinkAction; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.css.engine.StyleConstants; -import org.eclipse.birt.report.engine.css.engine.value.StringValue; -import org.eclipse.birt.report.engine.css.engine.value.css.CSSConstants; -import org.eclipse.birt.report.engine.emitter.IContentEmitter; -import org.eclipse.birt.report.engine.ir.DimensionType; -import org.eclipse.birt.report.engine.layout.emitter.Image; -import org.eclipse.birt.report.engine.presentation.ContentEmitterVisitor; -import org.w3c.dom.css.CSSValue; - -import uk.co.spudsoft.birt.emitters.excel.Area; -import uk.co.spudsoft.birt.emitters.excel.AreaBorders; -import uk.co.spudsoft.birt.emitters.excel.BirtStyle; -import uk.co.spudsoft.birt.emitters.excel.CellImage; -import uk.co.spudsoft.birt.emitters.excel.ClientAnchorConversions; -import uk.co.spudsoft.birt.emitters.excel.Coordinate; -import uk.co.spudsoft.birt.emitters.excel.EmitterServices; -import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.RichTextRun; -import uk.co.spudsoft.birt.emitters.excel.StyleManager; -import uk.co.spudsoft.birt.emitters.excel.StyleManagerUtils; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class CellContentHandler extends AbstractHandler { - - /** - * Number of milliseconds in a day, to determine whether a given date is date/time/datetime - */ - private static final long oneDay = 24 * 60 * 60 * 1000; - - /** - * The last value added to a cell - */ - protected Object lastValue; - /** - * The BIRT element that provided the lastValue - */ - protected IContent lastElement; - /** - * List of font changes for a single cell. - */ - protected List richTextRuns = new ArrayList(); - /** - * When having to join multiple text blocks together, track whether they are block or inline display - */ - protected boolean lastCellContentsWasBlock; - /** - * When having to join multiple text blocks together, track whether they need more of a gap between them (basically used for flattened table cells) - */ - protected boolean lastCellContentsRequiresSpace; - /** - * The span of the current cell - */ - protected int colSpan; - /** - * Visitor to enable processing of child elements created for foreign (HTML) elements. - */ - protected ContentEmitterVisitor contentVisitor; - /** - * Override the cell alignment to this instead, unless zero - */ - protected CSSValue preferredAlignment; - /** - * URL that this cell should hyperlink to - */ - protected String hyperlinkUrl; - /** - * Bookmark that this cell should hyperlink to - */ - protected String hyperlinkBookmark; - - - public CellContentHandler(IContentEmitter emitter, Logger log, IHandler parent, ICellContent cell) { - super(log, parent, cell); - contentVisitor = new ContentEmitterVisitor( emitter ); - colSpan = 1; - } - - @Override - public void startCell(HandlerState state, ICellContent cell) throws BirtException { - if( cell.getBookmark() != null ) { - System.err.println( "Bookmark: " + cell.getBookmark() ); - } - } - - /** - * Finish processing for the current (real) cell. - * @param element - * The element that signifies the end of the cell (this may not be an ICellContent object if the - * cell is created for a label or text outside of a table). - */ - protected void endCellContent(HandlerState state, ICellContent birtCell, IContent element, Cell cell, Area area ) { - StyleManager sm = state.getSm(); - StyleManagerUtils smu = state.getSmu(); - - BirtStyle birtCellStyle = null; - if( birtCell != null ) { - birtCellStyle = new BirtStyle( birtCell ); - if( element != null ) { - // log.debug( "Overlaying style from ", element ); - birtCellStyle.overlay( element ); - } - } else if( element != null ) { - birtCellStyle = new BirtStyle( element ); - } else { - birtCellStyle = new BirtStyle( state.getSm().getCssEngine() ); - } - if( preferredAlignment != null ) { - birtCellStyle.setProperty( StyleConstants.STYLE_TEXT_ALIGN, preferredAlignment ); - } - if( CSSConstants.CSS_TRANSPARENT_VALUE.equals(birtCellStyle.getString(StyleConstants.STYLE_BACKGROUND_COLOR))) { - if( parent != null ) { - birtCellStyle.setProperty( StyleConstants.STYLE_BACKGROUND_COLOR, parent.getBackgroundColour() ); - } - } - if( hyperlinkUrl != null ) { - Hyperlink hyperlink = cell.getSheet().getWorkbook().getCreationHelper().createHyperlink(HyperlinkType.URL); - hyperlink.setAddress(hyperlinkUrl); - cell.setHyperlink(hyperlink); - } - if( hyperlinkBookmark != null ) { - Hyperlink hyperlink = cell.getSheet().getWorkbook().getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT); - hyperlink.setAddress(prepareName( hyperlinkBookmark )); - cell.setHyperlink(hyperlink); - } - - if( lastValue != null ) { - if( lastValue instanceof String ) { - String lastString = (String)lastValue; - - smu.correctFontColorIfBackground( birtCellStyle ); - for( RichTextRun run : richTextRuns ) { - run.font = smu.correctFontColorIfBackground( sm.getFontManager(), state.getWb(), birtCellStyle, run.font ); - } - - if( ! richTextRuns.isEmpty() ) { - RichTextString rich = smu.createRichTextString( lastString ); - int runStart = richTextRuns.get(0).startIndex; - Font lastFont = richTextRuns.get(0).font; - for( int i = 0; i < richTextRuns.size(); ++i ) { - RichTextRun run = richTextRuns.get(i); - log.debug( "Run: ", run.startIndex, " font :", run.font ); - if( ! lastFont.equals( run.font ) ) { - log.debug("Applying ", runStart, " - ", run.startIndex ); - rich.applyFont(runStart, run.startIndex, lastFont); - runStart = run.startIndex; - lastFont = richTextRuns.get(i).font; - } - } - - log.debug("Finalising with ", runStart, " - ", lastString.length() ); - rich.applyFont(runStart, lastString.length(), lastFont); - - setCellContents( cell, rich ); - } else { - setCellContents( cell, lastString ); - } - - if( lastString.contains("\n") ) { - if( ! CSSConstants.CSS_NOWRAP_VALUE.equals( lastElement.getStyle().getWhiteSpace() ) ) { - birtCellStyle.setProperty( StyleConstants.STYLE_WHITE_SPACE, new StringValue( StringValue.CSS_STRING, CSSConstants.CSS_PRE_VALUE ) ); - } - } - if( ! richTextRuns.isEmpty() ) { - birtCellStyle.setProperty( StyleConstants.STYLE_VERTICAL_ALIGN, new StringValue( StringValue.CSS_STRING, CSSConstants.CSS_TOP_VALUE ) ); - } - if( preferredAlignment != null ) { - birtCellStyle.setProperty( StyleConstants.STYLE_TEXT_ALIGN, preferredAlignment ); - } - - } else { - setCellContents( cell, lastValue ); - } - } - - int colIndex = cell.getColumnIndex(); - state.getSmu().applyAreaBordersToCell(state.areaBorders, cell, birtCellStyle, state.rowNum, colIndex); - - if((birtCell != null) && (( birtCell.getColSpan() > 1 )||( birtCell.getRowSpan() > 1 ))) { - AreaBorders mergedRegionBorders = AreaBorders.createForMergedCells( state.rowNum + birtCell.getRowSpan() - 1, colIndex, colIndex + birtCell.getColSpan() - 1, state.rowNum, birtCellStyle ); - if( mergedRegionBorders != null ) { - state.insertBorderOverload( mergedRegionBorders ); - } - } - - String customNumberFormat = EmitterServices.stringOption(state.getRenderOptions(), element, ExcelEmitter.CUSTOM_NUMBER_FORMAT, null); - if( customNumberFormat != null ) { - StyleManagerUtils.setNumberFormat(birtCellStyle, ExcelEmitter.CUSTOM_NUMBER_FORMAT + customNumberFormat, null); - } - - setCellStyle(sm, cell, birtCellStyle, lastValue); - - // Excel auto calculates the row height (if it isn't specified) as long as the cell isn't merged - if it is merged I have to do it - if( ( ( colSpan > 1 ) || ( state.rowHasSpans( state.rowNum ) ) ) && ( ( lastValue instanceof String ) || ( lastValue instanceof RichTextString ) ) ) { - int spannedRowAlgorithm = EmitterServices.integerOption(state.getRenderOptions(), element, ExcelEmitter.SPANNED_ROW_HEIGHT, ExcelEmitter.SPANNED_ROW_HEIGHT_SPREAD); - Font defaultFont = state.getWb().getFontAt(cell.getCellStyle().getFontIndex()); - double cellWidth = spanWidthMillimetres( state.currentSheet, cell.getColumnIndex(), cell.getColumnIndex() + colSpan - 1 ); - float cellDesiredHeight = smu.calculateTextHeightPoints( cell.getStringCellValue(), defaultFont, cellWidth, richTextRuns ); - if( cellDesiredHeight > state.requiredRowHeightInPoints ) { - int rowSpan = birtCell.getRowSpan(); - if( rowSpan < 2 ) { - state.requiredRowHeightInPoints = cellDesiredHeight; - } else { - switch( spannedRowAlgorithm ) { - case ExcelEmitter.SPANNED_ROW_HEIGHT_FIRST: - state.requiredRowHeightInPoints = cellDesiredHeight; - break; - case ExcelEmitter.SPANNED_ROW_HEIGHT_IGNORED: - break; - default: - if( area != null ) { - area.setHeight(cellDesiredHeight); - } - } - } - } - } - - // Adjust the required row height for any relevant areas based on what's left - float rowSpanHeightRequirement = state.calculateRowSpanHeightRequirement( state.rowNum ); - if( rowSpanHeightRequirement > state.requiredRowHeightInPoints ) { - state.requiredRowHeightInPoints = rowSpanHeightRequirement; - } - - if( EmitterServices.booleanOption( state.getRenderOptions(), element, ExcelEmitter.FREEZE_PANES, false ) ) { - if( state.currentSheet.getPaneInformation() == null ) { - state.currentSheet.createFreezePane( state.colNum, state.rowNum ); - } - } - - lastValue = null; - lastElement = null; - richTextRuns.clear(); - } - - /** - * Calculate the width of a set of columns, in millimetres. - * @param startCol - * The first column to consider (inclusive). - * @param endCol - * The last column to consider (inclusive). - * The sum of the widths of all columns between startCol and endCol (inclusive) in millimetres. - */ - private double spanWidthMillimetres( Sheet sheet, int startCol, int endCol ) { - int result = 0; - for ( int columnIndex = startCol; columnIndex <= endCol; ++columnIndex ) { - result += sheet.getColumnWidth(columnIndex); - } - return ClientAnchorConversions.widthUnits2Millimetres( result ); - } - - - /** - * Set the contents of an empty cell. - * This should now be the only way in which a cell value is set (cells should not be modified). - * @param value - * The value to set. - * @param element - * The BIRT element supplying the value, used to set the style of the cell. - */ - private void setCellContents(Cell cell, Object value) { - log.debug( "Setting cell[", cell.getRow().getRowNum(), ",", cell.getColumnIndex(), "] value to ", value ); - if( value instanceof Double ) { - // cell.setCellType(Cell.CELL_TYPE_NUMERIC); - cell.setCellValue((Double)value); - lastValue = value; - } else if( value instanceof Integer ) { - // cell.setCellType(Cell.CELL_TYPE_NUMERIC); - cell.setCellValue((Integer)value); - lastValue = value; - } else if( value instanceof Long ) { - // cell.setCellType(Cell.CELL_TYPE_NUMERIC); - cell.setCellValue((Long)value); - lastValue = value; - } else if( value instanceof Date ) { - // cell.setCellType(Cell.CELL_TYPE_NUMERIC); - cell.setCellValue((Date)value); - lastValue = value; - } else if( value instanceof Boolean ) { - // cell.setCellType(Cell.CELL_TYPE_BOOLEAN); - cell.setCellValue(((Boolean)value).booleanValue()); - lastValue = value; - } else if( value instanceof BigDecimal ) { - // cell.setCellType(Cell.CELL_TYPE_NUMERIC); - cell.setCellValue(((BigDecimal)value).doubleValue()); - lastValue = value; - } else if( value instanceof String ) { - // cell.setCellType(Cell.CELL_TYPE_STRING); - cell.setCellValue((String)value); - lastValue = value; - } else if( value instanceof RichTextString ) { - // cell.setCellType(Cell.CELL_TYPE_STRING); - cell.setCellValue((RichTextString)value); - lastValue = value; - } else if( value != null ){ - log.debug( "Unhandled data: ", ( value == null ? "" : value ) ); - // cell.setCellType(Cell.CELL_TYPE_STRING); - cell.setCellValue(value.toString()); - lastValue = value; - } - } - - /** - * Set the style of the current cell based on the style of a BIRT element. - * @param element - * The BIRT element to take the style from. - */ - @SuppressWarnings("deprecation") - private void setCellStyle( StyleManager sm, Cell cell, BirtStyle birtStyle, Object value ) { - - if( ( StyleManagerUtils.getNumberFormat(birtStyle) == null ) - && ( StyleManagerUtils.getDateFormat(birtStyle) == null ) - && ( StyleManagerUtils.getDateTimeFormat(birtStyle) == null ) - && ( StyleManagerUtils.getTimeFormat(birtStyle) == null ) - && ( value != null ) - ) { - if( value instanceof Date ) { - long time = ((Date)value).getTime(); - time = time - ((Date)value).getTimezoneOffset() * 60000; - if( time % oneDay == 0 ) { - StyleManagerUtils.setDateFormat( birtStyle, "Short Date", null); - } else if( time < oneDay ) { - StyleManagerUtils.setTimeFormat( birtStyle, "Short Time", null); - } else { - StyleManagerUtils.setDateTimeFormat( birtStyle, "General Date", null); - } - } - } - - // log.debug( "BirtStyle: ", birtStyle); - CellStyle cellStyle = sm.getStyle(birtStyle); - cell.setCellStyle(cellStyle); - } - - private CSSValue preferredAlignment( BirtStyle elementStyle ) { - CSSValue newAlign = elementStyle.getProperty(StyleConstants.STYLE_TEXT_ALIGN); - if( newAlign == null ) { - newAlign = new StringValue(StringValue.CSS_STRING, CSSConstants.CSS_LEFT_VALUE); - } - if( preferredAlignment == null ) { - return newAlign; - } - if( CSSConstants.CSS_LEFT_VALUE.equals(newAlign.getCssText()) ) { - return newAlign; - } else if( CSSConstants.CSS_RIGHT_VALUE.equals(newAlign.getCssText()) ) { - if( CSSConstants.CSS_CENTER_VALUE.equals(preferredAlignment) ) { - return newAlign; - } else { - return preferredAlignment; - } - } else { - return preferredAlignment; - } - } - - /** - * Set the contents of the current cell. - * If the current cell is empty this will format the cell optimally for the new value, if the current cell already has some contents this will simply append the text - * value to the current contents. - * @param value - * The value to put into the current cell. - */ - protected void emitContent(HandlerState state, IContent element, Object value, boolean asBlock) { - if( value == null ) { - return ; - } - if( element.getBookmark() != null ) { - createName(state, prepareName( element.getBookmark() ), state.rowNum, state.colNum, state.rowNum, state.colNum); - } - - if( lastValue == null ) { - lastValue = value; - lastElement = element; - lastCellContentsWasBlock = asBlock; - - IHyperlinkAction birtHyperlink = element.getHyperlinkAction(); - if( birtHyperlink != null ) { - switch( birtHyperlink.getType() ) { - case IHyperlinkAction.ACTION_HYPERLINK: - hyperlinkUrl = birtHyperlink.getHyperlink(); - break; - case IHyperlinkAction.ACTION_BOOKMARK: - hyperlinkBookmark = birtHyperlink.getBookmark(); - break; - case IHyperlinkAction.ACTION_DRILLTHROUGH: - IHTMLActionHandler handler = state.getRenderOptions().getActionHandler(); - if( handler != null ) { - hyperlinkUrl = handler.getURL(new Action(null,birtHyperlink), element.getReportContent().getReportContext()); - } - break; - default: - log.debug( "Unhandled hyperlink type: {}", birtHyperlink.getType() ); - } - } - - return ; - } - - StyleManager sm = state.getSm(); - - // Both to be improved to include formatting - String oldValue = lastValue.toString(); - String newComponent = value.toString(); - - if( lastCellContentsWasBlock - && ! newComponent.startsWith("\n") - && ! oldValue.endsWith("\n") ) { - oldValue = oldValue + "\n"; - lastCellContentsWasBlock = false; - } - if( lastCellContentsRequiresSpace - && ! newComponent.startsWith("\n") - && ! oldValue.endsWith("\n") ) { - oldValue = oldValue + " "; - lastCellContentsRequiresSpace = false; - } - - String newValue = oldValue + newComponent; - lastValue = newValue; - - if( element != null ) { - BirtStyle elementStyle = new BirtStyle(element); - Font newFont = sm.getFontManager().getFont( elementStyle ); - richTextRuns.add(new RichTextRun(oldValue.length(), newFont)); - - preferredAlignment = preferredAlignment(elementStyle); - } - - lastCellContentsWasBlock = asBlock; - hyperlinkUrl = null; - } - - public void recordImage(HandlerState state, Coordinate location, IImageContent image, boolean spanColumns) throws BirtException { - byte[] data = image.getData(); - log.debug("startImage: " - + "[" + image.getMIMEType() +"] " - + "{" + image.getWidth() + " x " + image.getHeight() +"} " - + ( data == null ? "(no data) " : "(" + data.length + " bytes) ") - + image.getURI()); - - StyleManagerUtils smu = state.getSmu(); - Workbook wb = state.getWb(); - String mimeType = image.getMIMEType(); - if( ( data == null ) && ( image.getURI() != null ) ) { - try { - URL imageUrl = new URL( image.getURI() ); - URLConnection conn = imageUrl.openConnection(); - conn.connect(); - mimeType = conn.getContentType(); - int imageType = smu.poiImageTypeFromMimeType( mimeType, null ); - if( imageType == 0 ) { - log.debug( "Unrecognised/unhandled image MIME type: " + mimeType ); - } else { - data = smu.downloadImage(conn); - } - } catch( MalformedURLException ex ) { - log.debug( ex.getClass(), ": ", ex.getMessage() ); - ex.printStackTrace(); - } catch( IOException ex ) { - log.debug( ex.getClass(), ": ", ex.getMessage() ); - ex.printStackTrace(); - } - } - if( data != null ) { - int imageType = smu.poiImageTypeFromMimeType( mimeType, data ); - if( imageType == 0 ) { - log.debug( "Unrecognised/unhandled image MIME type: ", image.getMIMEType() ); - } else { - int imageIdx = wb.addPicture( data, imageType ); - - if( ( image.getHeight() == null ) || ( image.getWidth() == null ) ) { - Image birtImage = new Image(); - birtImage.setInput( data ); - birtImage.check(); - log.debug( "Calculated image dimensions " - + birtImage.getWidth() + " (@" + birtImage.getPhysicalWidthDpi() + "dpi=" + birtImage.getPhysicalWidthInch() + "in) x " - + birtImage.getHeight() + " (@" + birtImage.getPhysicalHeightDpi() + "dpi=" + birtImage.getPhysicalHeightInch() + "in)" - ); - if( image.getWidth() == null ) { - DimensionType Width = new DimensionType( - ( birtImage.getPhysicalWidthInch() > 0 ) ? birtImage.getPhysicalWidthInch() : birtImage.getWidth() / 96.0 - , "in" ); - image.setWidth( Width ); - } - if( image.getHeight() == null ) { - DimensionType Height = new DimensionType( - ( birtImage.getPhysicalHeightInch() > 0 ) ? birtImage.getPhysicalHeightInch() : birtImage.getHeight() / 96.0 - , "in" ); - image.setHeight( Height ); - } - } - - state.images.add( new CellImage(location, imageIdx, image, spanColumns) ); - lastElement = image; - } - } - } - - protected void removeMergedCell(HandlerState state, int row, int col) { - for( int mergeNum = 0; mergeNum < state.currentSheet.getNumMergedRegions(); ++mergeNum ) { - CellRangeAddress region = state.currentSheet.getMergedRegion(mergeNum); - if( ( region.getFirstRow() == row ) && ( region.getFirstColumn() == col ) ) { - state.currentSheet.removeMergedRegion(mergeNum); - break; - } - } - - for( Iterator iter = state.rowSpans.iterator(); iter.hasNext(); ) { - Area area = iter.next(); - Coordinate topLeft = area.getX(); - if( ( topLeft.getRow() == row ) || ( topLeft.getCol() == col ) ) { - iter.remove(); - } - } - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import java.io.IOException; +import java.math.BigDecimal; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; + +import org.apache.poi.common.usermodel.HyperlinkType; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.Hyperlink; +import org.apache.poi.ss.usermodel.RichTextString; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellRangeAddress; +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.api.IHTMLActionHandler; +import org.eclipse.birt.report.engine.api.impl.Action; +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.content.IContent; +import org.eclipse.birt.report.engine.content.IHyperlinkAction; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.css.engine.value.StringValue; +import org.eclipse.birt.report.engine.css.engine.value.css.CSSConstants; +import org.eclipse.birt.report.engine.emitter.IContentEmitter; +import org.eclipse.birt.report.engine.ir.DimensionType; +import org.eclipse.birt.report.engine.layout.emitter.Image; +import org.eclipse.birt.report.engine.presentation.ContentEmitterVisitor; +import org.w3c.dom.css.CSSValue; + +import uk.co.spudsoft.birt.emitters.excel.Area; +import uk.co.spudsoft.birt.emitters.excel.AreaBorders; +import uk.co.spudsoft.birt.emitters.excel.BirtStyle; +import uk.co.spudsoft.birt.emitters.excel.CellImage; +import uk.co.spudsoft.birt.emitters.excel.ClientAnchorConversions; +import uk.co.spudsoft.birt.emitters.excel.Coordinate; +import uk.co.spudsoft.birt.emitters.excel.EmitterServices; +import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.RichTextRun; +import uk.co.spudsoft.birt.emitters.excel.StyleManager; +import uk.co.spudsoft.birt.emitters.excel.StyleManagerUtils; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class CellContentHandler extends AbstractHandler { + + /** + * Number of milliseconds in a day, to determine whether a given date is date/time/datetime + */ + private static final long oneDay = 24 * 60 * 60 * 1000; + + /** + * The last value added to a cell + */ + protected Object lastValue; + /** + * The BIRT element that provided the lastValue + */ + protected IContent lastElement; + /** + * List of font changes for a single cell. + */ + protected List richTextRuns = new ArrayList(); + /** + * When having to join multiple text blocks together, track whether they are block or inline display + */ + protected boolean lastCellContentsWasBlock; + /** + * When having to join multiple text blocks together, track whether they need more of a gap between them (basically used for flattened table cells) + */ + protected boolean lastCellContentsRequiresSpace; + /** + * The span of the current cell + */ + protected int colSpan; + /** + * Visitor to enable processing of child elements created for foreign (HTML) elements. + */ + protected ContentEmitterVisitor contentVisitor; + /** + * Override the cell alignment to this instead, unless zero + */ + protected CSSValue preferredAlignment; + /** + * URL that this cell should hyperlink to + */ + protected String hyperlinkUrl; + /** + * Bookmark that this cell should hyperlink to + */ + protected String hyperlinkBookmark; + + + public CellContentHandler(IContentEmitter emitter, Logger log, IHandler parent, ICellContent cell) { + super(log, parent, cell); + contentVisitor = new ContentEmitterVisitor( emitter ); + colSpan = 1; + } + + @Override + public void startCell(HandlerState state, ICellContent cell) throws BirtException { + if( cell.getBookmark() != null ) { + System.err.println( "Bookmark: " + cell.getBookmark() ); + } + } + + /** + * Finish processing for the current (real) cell. + * @param element + * The element that signifies the end of the cell (this may not be an ICellContent object if the + * cell is created for a label or text outside of a table). + */ + protected void endCellContent(HandlerState state, ICellContent birtCell, IContent element, Cell cell, Area area ) { + StyleManager sm = state.getSm(); + StyleManagerUtils smu = state.getSmu(); + + BirtStyle birtCellStyle = null; + if( birtCell != null ) { + birtCellStyle = new BirtStyle( birtCell ); + if( element != null ) { + // log.debug( "Overlaying style from ", element ); + birtCellStyle.overlay( element ); + } + } else if( element != null ) { + birtCellStyle = new BirtStyle( element ); + } else { + birtCellStyle = new BirtStyle( state.getSm().getCssEngine() ); + } + if( preferredAlignment != null ) { + birtCellStyle.setProperty( StyleConstants.STYLE_TEXT_ALIGN, preferredAlignment ); + } + if( CSSConstants.CSS_TRANSPARENT_VALUE.equals(birtCellStyle.getString(StyleConstants.STYLE_BACKGROUND_COLOR))) { + if( parent != null ) { + birtCellStyle.setProperty( StyleConstants.STYLE_BACKGROUND_COLOR, parent.getBackgroundColour() ); + } + } + if( hyperlinkUrl != null ) { + Hyperlink hyperlink = cell.getSheet().getWorkbook().getCreationHelper().createHyperlink(HyperlinkType.URL); + hyperlink.setAddress(hyperlinkUrl); + cell.setHyperlink(hyperlink); + } + if( hyperlinkBookmark != null ) { + Hyperlink hyperlink = cell.getSheet().getWorkbook().getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT); + hyperlink.setAddress(prepareName( hyperlinkBookmark )); + cell.setHyperlink(hyperlink); + } + + if( lastValue != null ) { + if( lastValue instanceof String ) { + String lastString = (String)lastValue; + + smu.correctFontColorIfBackground( birtCellStyle ); + for( RichTextRun run : richTextRuns ) { + run.font = smu.correctFontColorIfBackground( sm.getFontManager(), state.getWb(), birtCellStyle, run.font ); + } + + if( ! richTextRuns.isEmpty() ) { + RichTextString rich = smu.createRichTextString( lastString ); + int runStart = richTextRuns.get(0).startIndex; + Font lastFont = richTextRuns.get(0).font; + for( int i = 0; i < richTextRuns.size(); ++i ) { + RichTextRun run = richTextRuns.get(i); + log.debug( "Run: ", run.startIndex, " font :", run.font ); + if( ! lastFont.equals( run.font ) ) { + log.debug("Applying ", runStart, " - ", run.startIndex ); + rich.applyFont(runStart, run.startIndex, lastFont); + runStart = run.startIndex; + lastFont = richTextRuns.get(i).font; + } + } + + log.debug("Finalising with ", runStart, " - ", lastString.length() ); + rich.applyFont(runStart, lastString.length(), lastFont); + + setCellContents( cell, rich ); + } else { + setCellContents( cell, lastString ); + } + + if( lastString.contains("\n") ) { + if( ! CSSConstants.CSS_NOWRAP_VALUE.equals( lastElement.getStyle().getWhiteSpace() ) ) { + birtCellStyle.setProperty( StyleConstants.STYLE_WHITE_SPACE, new StringValue( StringValue.CSS_STRING, CSSConstants.CSS_PRE_VALUE ) ); + } + } + if( ! richTextRuns.isEmpty() ) { + birtCellStyle.setProperty( StyleConstants.STYLE_VERTICAL_ALIGN, new StringValue( StringValue.CSS_STRING, CSSConstants.CSS_TOP_VALUE ) ); + } + if( preferredAlignment != null ) { + birtCellStyle.setProperty( StyleConstants.STYLE_TEXT_ALIGN, preferredAlignment ); + } + + } else { + setCellContents( cell, lastValue ); + } + } + + int colIndex = cell.getColumnIndex(); + state.getSmu().applyAreaBordersToCell(state.areaBorders, cell, birtCellStyle, state.rowNum, colIndex); + + if((birtCell != null) && (( birtCell.getColSpan() > 1 )||( birtCell.getRowSpan() > 1 ))) { + AreaBorders mergedRegionBorders = AreaBorders.createForMergedCells( state.rowNum + birtCell.getRowSpan() - 1, colIndex, colIndex + birtCell.getColSpan() - 1, state.rowNum, birtCellStyle ); + if( mergedRegionBorders != null ) { + state.insertBorderOverload( mergedRegionBorders ); + } + } + + String customNumberFormat = EmitterServices.stringOption(state.getRenderOptions(), element, ExcelEmitter.CUSTOM_NUMBER_FORMAT, null); + if( customNumberFormat != null ) { + StyleManagerUtils.setNumberFormat(birtCellStyle, ExcelEmitter.CUSTOM_NUMBER_FORMAT + customNumberFormat, null); + } + + setCellStyle(sm, cell, birtCellStyle, lastValue); + + // Excel auto calculates the row height (if it isn't specified) as long as the cell isn't merged - if it is merged I have to do it + if( ( ( colSpan > 1 ) || ( state.rowHasSpans( state.rowNum ) ) ) && ( ( lastValue instanceof String ) || ( lastValue instanceof RichTextString ) ) ) { + int spannedRowAlgorithm = EmitterServices.integerOption(state.getRenderOptions(), element, ExcelEmitter.SPANNED_ROW_HEIGHT, ExcelEmitter.SPANNED_ROW_HEIGHT_SPREAD); + Font defaultFont = state.getWb().getFontAt(cell.getCellStyle().getFontIndex()); + double cellWidth = spanWidthMillimetres( state.currentSheet, cell.getColumnIndex(), cell.getColumnIndex() + colSpan - 1 ); + float cellDesiredHeight = smu.calculateTextHeightPoints( cell.getStringCellValue(), defaultFont, cellWidth, richTextRuns ); + if( cellDesiredHeight > state.requiredRowHeightInPoints ) { + int rowSpan = birtCell.getRowSpan(); + if( rowSpan < 2 ) { + state.requiredRowHeightInPoints = cellDesiredHeight; + } else { + switch( spannedRowAlgorithm ) { + case ExcelEmitter.SPANNED_ROW_HEIGHT_FIRST: + state.requiredRowHeightInPoints = cellDesiredHeight; + break; + case ExcelEmitter.SPANNED_ROW_HEIGHT_IGNORED: + break; + default: + if( area != null ) { + area.setHeight(cellDesiredHeight); + } + } + } + } + } + + // Adjust the required row height for any relevant areas based on what's left + float rowSpanHeightRequirement = state.calculateRowSpanHeightRequirement( state.rowNum ); + if( rowSpanHeightRequirement > state.requiredRowHeightInPoints ) { + state.requiredRowHeightInPoints = rowSpanHeightRequirement; + } + + if( EmitterServices.booleanOption( state.getRenderOptions(), element, ExcelEmitter.FREEZE_PANES, false ) ) { + if( state.currentSheet.getPaneInformation() == null ) { + state.currentSheet.createFreezePane( state.colNum, state.rowNum ); + } + } + + lastValue = null; + lastElement = null; + richTextRuns.clear(); + } + + /** + * Calculate the width of a set of columns, in millimetres. + * @param startCol + * The first column to consider (inclusive). + * @param endCol + * The last column to consider (inclusive). + * The sum of the widths of all columns between startCol and endCol (inclusive) in millimetres. + */ + private double spanWidthMillimetres( Sheet sheet, int startCol, int endCol ) { + int result = 0; + for ( int columnIndex = startCol; columnIndex <= endCol; ++columnIndex ) { + result += sheet.getColumnWidth(columnIndex); + } + return ClientAnchorConversions.widthUnits2Millimetres( result ); + } + + + /** + * Set the contents of an empty cell. + * This should now be the only way in which a cell value is set (cells should not be modified). + * @param value + * The value to set. + * @param element + * The BIRT element supplying the value, used to set the style of the cell. + */ + private void setCellContents(Cell cell, Object value) { + log.debug( "Setting cell[", cell.getRow().getRowNum(), ",", cell.getColumnIndex(), "] value to ", value ); + if( value instanceof Double ) { + // cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellValue((Double)value); + lastValue = value; + } else if( value instanceof Integer ) { + // cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellValue((Integer)value); + lastValue = value; + } else if( value instanceof Long ) { + // cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellValue((Long)value); + lastValue = value; + } else if( value instanceof Date ) { + // cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellValue((Date)value); + lastValue = value; + } else if( value instanceof Boolean ) { + // cell.setCellType(Cell.CELL_TYPE_BOOLEAN); + cell.setCellValue(((Boolean)value).booleanValue()); + lastValue = value; + } else if( value instanceof BigDecimal ) { + // cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellValue(((BigDecimal)value).doubleValue()); + lastValue = value; + } else if( value instanceof String ) { + // cell.setCellType(Cell.CELL_TYPE_STRING); + cell.setCellValue((String)value); + lastValue = value; + } else if( value instanceof RichTextString ) { + // cell.setCellType(Cell.CELL_TYPE_STRING); + cell.setCellValue((RichTextString)value); + lastValue = value; + } else if( value != null ){ + log.debug( "Unhandled data: ", ( value == null ? "" : value ) ); + // cell.setCellType(Cell.CELL_TYPE_STRING); + cell.setCellValue(value.toString()); + lastValue = value; + } + } + + /** + * Set the style of the current cell based on the style of a BIRT element. + * @param element + * The BIRT element to take the style from. + */ + @SuppressWarnings("deprecation") + private void setCellStyle( StyleManager sm, Cell cell, BirtStyle birtStyle, Object value ) { + + if( ( StyleManagerUtils.getNumberFormat(birtStyle) == null ) + && ( StyleManagerUtils.getDateFormat(birtStyle) == null ) + && ( StyleManagerUtils.getDateTimeFormat(birtStyle) == null ) + && ( StyleManagerUtils.getTimeFormat(birtStyle) == null ) + && ( value != null ) + ) { + if( value instanceof Date ) { + long time = ((Date)value).getTime(); + time = time - ((Date)value).getTimezoneOffset() * 60000; + if( time % oneDay == 0 ) { + StyleManagerUtils.setDateFormat( birtStyle, "Short Date", null); + } else if( time < oneDay ) { + StyleManagerUtils.setTimeFormat( birtStyle, "Short Time", null); + } else { + StyleManagerUtils.setDateTimeFormat( birtStyle, "General Date", null); + } + } + } + + // log.debug( "BirtStyle: ", birtStyle); + CellStyle cellStyle = sm.getStyle(birtStyle); + cell.setCellStyle(cellStyle); + } + + private CSSValue preferredAlignment( BirtStyle elementStyle ) { + CSSValue newAlign = elementStyle.getProperty(StyleConstants.STYLE_TEXT_ALIGN); + if( newAlign == null ) { + newAlign = new StringValue(StringValue.CSS_STRING, CSSConstants.CSS_LEFT_VALUE); + } + if( preferredAlignment == null ) { + return newAlign; + } + if( CSSConstants.CSS_LEFT_VALUE.equals(newAlign.getCssText()) ) { + return newAlign; + } else if( CSSConstants.CSS_RIGHT_VALUE.equals(newAlign.getCssText()) ) { + if( CSSConstants.CSS_CENTER_VALUE.equals(preferredAlignment) ) { + return newAlign; + } else { + return preferredAlignment; + } + } else { + return preferredAlignment; + } + } + + /** + * Set the contents of the current cell. + * If the current cell is empty this will format the cell optimally for the new value, if the current cell already has some contents this will simply append the text + * value to the current contents. + * @param value + * The value to put into the current cell. + */ + protected void emitContent(HandlerState state, IContent element, Object value, boolean asBlock) { + if( value == null ) { + return ; + } + if( element.getBookmark() != null ) { + createName(state, prepareName( element.getBookmark() ), state.rowNum, state.colNum, state.rowNum, state.colNum); + } + + if( lastValue == null ) { + lastValue = value; + lastElement = element; + lastCellContentsWasBlock = asBlock; + + IHyperlinkAction birtHyperlink = element.getHyperlinkAction(); + if( birtHyperlink != null ) { + switch( birtHyperlink.getType() ) { + case IHyperlinkAction.ACTION_HYPERLINK: + hyperlinkUrl = birtHyperlink.getHyperlink(); + break; + case IHyperlinkAction.ACTION_BOOKMARK: + hyperlinkBookmark = birtHyperlink.getBookmark(); + break; + case IHyperlinkAction.ACTION_DRILLTHROUGH: + IHTMLActionHandler handler = state.getRenderOptions().getActionHandler(); + if( handler != null ) { + hyperlinkUrl = handler.getURL(new Action(null,birtHyperlink), element.getReportContent().getReportContext()); + } + break; + default: + log.debug( "Unhandled hyperlink type: {}", birtHyperlink.getType() ); + } + } + + return ; + } + + StyleManager sm = state.getSm(); + + // Both to be improved to include formatting + String oldValue = lastValue.toString(); + String newComponent = value.toString(); + + if( lastCellContentsWasBlock + && ! newComponent.startsWith("\n") + && ! oldValue.endsWith("\n") ) { + oldValue = oldValue + "\n"; + lastCellContentsWasBlock = false; + } + if( lastCellContentsRequiresSpace + && ! newComponent.startsWith("\n") + && ! oldValue.endsWith("\n") ) { + oldValue = oldValue + " "; + lastCellContentsRequiresSpace = false; + } + + String newValue = oldValue + newComponent; + lastValue = newValue; + + if( element != null ) { + BirtStyle elementStyle = new BirtStyle(element); + Font newFont = sm.getFontManager().getFont( elementStyle ); + richTextRuns.add(new RichTextRun(oldValue.length(), newFont)); + + preferredAlignment = preferredAlignment(elementStyle); + } + + lastCellContentsWasBlock = asBlock; + hyperlinkUrl = null; + } + + public void recordImage(HandlerState state, Coordinate location, IImageContent image, boolean spanColumns) throws BirtException { + byte[] data = image.getData(); + log.debug("startImage: " + + "[" + image.getMIMEType() +"] " + + "{" + image.getWidth() + " x " + image.getHeight() +"} " + + ( data == null ? "(no data) " : "(" + data.length + " bytes) ") + + image.getURI()); + + StyleManagerUtils smu = state.getSmu(); + Workbook wb = state.getWb(); + String mimeType = image.getMIMEType(); + if( ( data == null ) && ( image.getURI() != null ) ) { + try { + URL imageUrl = new URL( image.getURI() ); + URLConnection conn = imageUrl.openConnection(); + conn.connect(); + mimeType = conn.getContentType(); + int imageType = smu.poiImageTypeFromMimeType( mimeType, null ); + if( imageType == 0 ) { + log.debug( "Unrecognised/unhandled image MIME type: " + mimeType ); + } else { + data = smu.downloadImage(conn); + } + } catch( MalformedURLException ex ) { + log.debug( ex.getClass(), ": ", ex.getMessage() ); + ex.printStackTrace(); + } catch( IOException ex ) { + log.debug( ex.getClass(), ": ", ex.getMessage() ); + ex.printStackTrace(); + } + } + if( data != null ) { + int imageType = smu.poiImageTypeFromMimeType( mimeType, data ); + if( imageType == 0 ) { + log.debug( "Unrecognised/unhandled image MIME type: ", image.getMIMEType() ); + } else { + int imageIdx = wb.addPicture( data, imageType ); + + if( ( image.getHeight() == null ) || ( image.getWidth() == null ) ) { + Image birtImage = new Image(); + birtImage.setInput( data ); + birtImage.check(); + log.debug( "Calculated image dimensions " + + birtImage.getWidth() + " (@" + birtImage.getPhysicalWidthDpi() + "dpi=" + birtImage.getPhysicalWidthInch() + "in) x " + + birtImage.getHeight() + " (@" + birtImage.getPhysicalHeightDpi() + "dpi=" + birtImage.getPhysicalHeightInch() + "in)" + ); + if( image.getWidth() == null ) { + DimensionType Width = new DimensionType( + ( birtImage.getPhysicalWidthInch() > 0 ) ? birtImage.getPhysicalWidthInch() : birtImage.getWidth() / 96.0 + , "in" ); + image.setWidth( Width ); + } + if( image.getHeight() == null ) { + DimensionType Height = new DimensionType( + ( birtImage.getPhysicalHeightInch() > 0 ) ? birtImage.getPhysicalHeightInch() : birtImage.getHeight() / 96.0 + , "in" ); + image.setHeight( Height ); + } + } + + state.images.add( new CellImage(location, imageIdx, image, spanColumns) ); + lastElement = image; + } + } + } + + protected void removeMergedCell(HandlerState state, int row, int col) { + for( int mergeNum = 0; mergeNum < state.currentSheet.getNumMergedRegions(); ++mergeNum ) { + CellRangeAddress region = state.currentSheet.getMergedRegion(mergeNum); + if( ( region.getFirstRow() == row ) && ( region.getFirstColumn() == col ) ) { + state.currentSheet.removeMergedRegion(mergeNum); + break; + } + } + + for( Iterator iter = state.rowSpans.iterator(); iter.hasNext(); ) { + Area area = iter.next(); + Coordinate topLeft = area.getX(); + if( ( topLeft.getRow() == row ) || ( topLeft.getCol() == col ) ) { + iter.remove(); + } + } + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedListHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedListHandler.java index fa3c9aa8e..afefb3363 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedListHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedListHandler.java @@ -1,97 +1,97 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IAutoTextContent; -import org.eclipse.birt.report.engine.content.IContent; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.IListBandContent; -import org.eclipse.birt.report.engine.content.IListContent; -import org.eclipse.birt.report.engine.content.IListGroupContent; -import org.eclipse.birt.report.engine.content.ITextContent; - -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class FlattenedListHandler extends AbstractHandler { - - private CellContentHandler contentHandler; - - public FlattenedListHandler(CellContentHandler contentHandler, Logger log, IHandler parent, IContent element) { - super(log, parent, element); - this.contentHandler = contentHandler; - } - - @Override - public void startList(HandlerState state, IListContent list) throws BirtException { - } - - @Override - public void endList(HandlerState state, IListContent list) throws BirtException { - contentHandler.lastCellContentsWasBlock = true; - contentHandler.lastCellContentsRequiresSpace = false; - state.setHandler(parent); - } - - @Override - public void startListBand(HandlerState state, IListBandContent listBand) throws BirtException { - } - - @Override - public void endListBand(HandlerState state, IListBandContent listBand) throws BirtException { - } - - @Override - public void startListGroup(HandlerState state, IListGroupContent group) throws BirtException { - } - - @Override - public void endListGroup(HandlerState state, IListGroupContent group) throws BirtException { - } - - @Override - public void emitText(HandlerState state, ITextContent text) throws BirtException { - contentHandler.emitText(state, text); - } - - @Override - public void emitData(HandlerState state, IDataContent data) throws BirtException { - contentHandler.emitData(state, data); - } - - @Override - public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { - contentHandler.emitLabel(state, label); - } - - @Override - public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { - contentHandler.emitAutoText(state, autoText); - } - - @Override - public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { - contentHandler.emitForeign(state, foreign); - } - - @Override - public void emitImage(HandlerState state, IImageContent image) throws BirtException { - contentHandler.emitImage(state, image); - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IAutoTextContent; +import org.eclipse.birt.report.engine.content.IContent; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.IListBandContent; +import org.eclipse.birt.report.engine.content.IListContent; +import org.eclipse.birt.report.engine.content.IListGroupContent; +import org.eclipse.birt.report.engine.content.ITextContent; + +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class FlattenedListHandler extends AbstractHandler { + + private CellContentHandler contentHandler; + + public FlattenedListHandler(CellContentHandler contentHandler, Logger log, IHandler parent, IContent element) { + super(log, parent, element); + this.contentHandler = contentHandler; + } + + @Override + public void startList(HandlerState state, IListContent list) throws BirtException { + } + + @Override + public void endList(HandlerState state, IListContent list) throws BirtException { + contentHandler.lastCellContentsWasBlock = true; + contentHandler.lastCellContentsRequiresSpace = false; + state.setHandler(parent); + } + + @Override + public void startListBand(HandlerState state, IListBandContent listBand) throws BirtException { + } + + @Override + public void endListBand(HandlerState state, IListBandContent listBand) throws BirtException { + } + + @Override + public void startListGroup(HandlerState state, IListGroupContent group) throws BirtException { + } + + @Override + public void endListGroup(HandlerState state, IListGroupContent group) throws BirtException { + } + + @Override + public void emitText(HandlerState state, ITextContent text) throws BirtException { + contentHandler.emitText(state, text); + } + + @Override + public void emitData(HandlerState state, IDataContent data) throws BirtException { + contentHandler.emitData(state, data); + } + + @Override + public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { + contentHandler.emitLabel(state, label); + } + + @Override + public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { + contentHandler.emitAutoText(state, autoText); + } + + @Override + public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { + contentHandler.emitForeign(state, foreign); + } + + @Override + public void emitImage(HandlerState state, IImageContent image) throws BirtException { + contentHandler.emitImage(state, image); + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableCellHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableCellHandler.java index a6f87cab2..7cf63e22f 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableCellHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableCellHandler.java @@ -1,89 +1,89 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IAutoTextContent; -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITextContent; - -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class FlattenedTableCellHandler extends AbstractHandler { - - private CellContentHandler contentHandler; - - public FlattenedTableCellHandler(CellContentHandler contentHandler, Logger log, IHandler parent, ICellContent cell) { - super(log, parent, cell); - this.contentHandler = contentHandler; - } - - @Override - public void startCell(HandlerState state, ICellContent cell) throws BirtException { - } - - @Override - public void endCell(HandlerState state, ICellContent cell) throws BirtException { - contentHandler.lastCellContentsWasBlock = false; - contentHandler.lastCellContentsRequiresSpace = true; - state.setHandler(parent); - } - - @Override - public void startTable(HandlerState state, ITableContent table) throws BirtException { - state.setHandler(new FlattenedTableHandler(contentHandler, log, this, table)); - state.getHandler().startTable(state, table); - } - - @Override - public void emitText(HandlerState state, ITextContent text) throws BirtException { - contentHandler.emitText(state, text); - } - - @Override - public void emitData(HandlerState state, IDataContent data) throws BirtException { - contentHandler.emitData(state, data); - } - - @Override - public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { - contentHandler.emitLabel(state, label); - } - - @Override - public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { - contentHandler.emitAutoText(state, autoText); - } - - @Override - public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { - contentHandler.emitForeign(state, foreign); - } - - @Override - public void emitImage(HandlerState state, IImageContent image) throws BirtException { - contentHandler.emitImage(state, image); - } - - - - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IAutoTextContent; +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITextContent; + +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class FlattenedTableCellHandler extends AbstractHandler { + + private CellContentHandler contentHandler; + + public FlattenedTableCellHandler(CellContentHandler contentHandler, Logger log, IHandler parent, ICellContent cell) { + super(log, parent, cell); + this.contentHandler = contentHandler; + } + + @Override + public void startCell(HandlerState state, ICellContent cell) throws BirtException { + } + + @Override + public void endCell(HandlerState state, ICellContent cell) throws BirtException { + contentHandler.lastCellContentsWasBlock = false; + contentHandler.lastCellContentsRequiresSpace = true; + state.setHandler(parent); + } + + @Override + public void startTable(HandlerState state, ITableContent table) throws BirtException { + state.setHandler(new FlattenedTableHandler(contentHandler, log, this, table)); + state.getHandler().startTable(state, table); + } + + @Override + public void emitText(HandlerState state, ITextContent text) throws BirtException { + contentHandler.emitText(state, text); + } + + @Override + public void emitData(HandlerState state, IDataContent data) throws BirtException { + contentHandler.emitData(state, data); + } + + @Override + public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { + contentHandler.emitLabel(state, label); + } + + @Override + public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { + contentHandler.emitAutoText(state, autoText); + } + + @Override + public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { + contentHandler.emitForeign(state, foreign); + } + + @Override + public void emitImage(HandlerState state, IImageContent image) throws BirtException { + contentHandler.emitImage(state, image); + } + + + + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableHandler.java index 3a0ccdadb..44bcd7aa4 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableHandler.java @@ -1,81 +1,81 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IRowContent; -import org.eclipse.birt.report.engine.content.ITableBandContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITableGroupContent; - -import uk.co.spudsoft.birt.emitters.excel.EmitterServices; -import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class FlattenedTableHandler extends AbstractHandler { - - private CellContentHandler contentHandler; - - public FlattenedTableHandler(CellContentHandler contentHandler, Logger log, IHandler parent, ITableContent table) { - super(log, parent, table); - this.contentHandler = contentHandler; - } - - @Override - public void startTable(HandlerState state, ITableContent table) throws BirtException { - if( ( state.sheetName == null ) || state.sheetName.isEmpty() ) { - String name = table.getName(); - if( ( name != null ) && ! name.isEmpty() ) { - state.sheetName = name; - } - } - if( ( state.sheetPassword == null ) || state.sheetPassword.isEmpty() ) { - String password = EmitterServices.stringOption( state.getRenderOptions(), table, ExcelEmitter.SHEET_PASSWORD, null); - if( ( password != null ) && ! password.isEmpty() ) { - state.sheetPassword = password; - } - } - } - - @Override - public void endTable(HandlerState state, ITableContent table) throws BirtException { - state.setHandler(parent); - } - - @Override - public void startRow(HandlerState state, IRowContent row) throws BirtException { - state.setHandler(new FlattenedTableRowHandler(contentHandler, log, this, row)); - state.getHandler().startRow(state, row); - } - - @Override - public void startTableBand(HandlerState state, ITableBandContent band) throws BirtException { - } - - @Override - public void endTableBand(HandlerState state, ITableBandContent band) throws BirtException { - } - - @Override - public void startTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { - } - - @Override - public void endTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { - } - - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IRowContent; +import org.eclipse.birt.report.engine.content.ITableBandContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITableGroupContent; + +import uk.co.spudsoft.birt.emitters.excel.EmitterServices; +import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class FlattenedTableHandler extends AbstractHandler { + + private CellContentHandler contentHandler; + + public FlattenedTableHandler(CellContentHandler contentHandler, Logger log, IHandler parent, ITableContent table) { + super(log, parent, table); + this.contentHandler = contentHandler; + } + + @Override + public void startTable(HandlerState state, ITableContent table) throws BirtException { + if( ( state.sheetName == null ) || state.sheetName.isEmpty() ) { + String name = table.getName(); + if( ( name != null ) && ! name.isEmpty() ) { + state.sheetName = name; + } + } + if( ( state.sheetPassword == null ) || state.sheetPassword.isEmpty() ) { + String password = EmitterServices.stringOption( state.getRenderOptions(), table, ExcelEmitter.SHEET_PASSWORD, null); + if( ( password != null ) && ! password.isEmpty() ) { + state.sheetPassword = password; + } + } + } + + @Override + public void endTable(HandlerState state, ITableContent table) throws BirtException { + state.setHandler(parent); + } + + @Override + public void startRow(HandlerState state, IRowContent row) throws BirtException { + state.setHandler(new FlattenedTableRowHandler(contentHandler, log, this, row)); + state.getHandler().startRow(state, row); + } + + @Override + public void startTableBand(HandlerState state, ITableBandContent band) throws BirtException { + } + + @Override + public void endTableBand(HandlerState state, ITableBandContent band) throws BirtException { + } + + @Override + public void startTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { + } + + @Override + public void endTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { + } + + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableRowHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableRowHandler.java index 1df54463d..507cefc9f 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableRowHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/FlattenedTableRowHandler.java @@ -1,51 +1,51 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.content.IRowContent; - -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class FlattenedTableRowHandler extends AbstractHandler { - - private CellContentHandler contentHandler; - - public FlattenedTableRowHandler(CellContentHandler contentHandler, Logger log, IHandler parent, IRowContent row) { - super(log, parent, row); - this.contentHandler = contentHandler; - } - - @Override - public void startRow(HandlerState state, IRowContent row) throws BirtException { - contentHandler.lastCellContentsWasBlock = true; - } - - @Override - public void endRow(HandlerState state, IRowContent row) throws BirtException { - contentHandler.lastCellContentsWasBlock = true; - state.setHandler(parent); - } - - @Override - public void startCell(HandlerState state, ICellContent cell) throws BirtException { - state.setHandler(new FlattenedTableCellHandler(contentHandler, log, this, cell)); - state.getHandler().startCell(state, cell); - } - - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.content.IRowContent; + +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class FlattenedTableRowHandler extends AbstractHandler { + + private CellContentHandler contentHandler; + + public FlattenedTableRowHandler(CellContentHandler contentHandler, Logger log, IHandler parent, IRowContent row) { + super(log, parent, row); + this.contentHandler = contentHandler; + } + + @Override + public void startRow(HandlerState state, IRowContent row) throws BirtException { + contentHandler.lastCellContentsWasBlock = true; + } + + @Override + public void endRow(HandlerState state, IRowContent row) throws BirtException { + contentHandler.lastCellContentsWasBlock = true; + state.setHandler(parent); + } + + @Override + public void startCell(HandlerState state, ICellContent cell) throws BirtException { + state.setHandler(new FlattenedTableCellHandler(contentHandler, log, this, cell)); + state.getHandler().startCell(state, cell); + } + + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/IHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/IHandler.java index 6908f762a..d85a99b6b 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/IHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/IHandler.java @@ -1,96 +1,96 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IAutoTextContent; -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.content.IContainerContent; -import org.eclipse.birt.report.engine.content.IContent; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IGroupContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.IListBandContent; -import org.eclipse.birt.report.engine.content.IListContent; -import org.eclipse.birt.report.engine.content.IListGroupContent; -import org.eclipse.birt.report.engine.content.IPageContent; -import org.eclipse.birt.report.engine.content.IRowContent; -import org.eclipse.birt.report.engine.content.ITableBandContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITableGroupContent; -import org.eclipse.birt.report.engine.content.ITextContent; -import org.w3c.dom.css.CSSValue; - -import uk.co.spudsoft.birt.emitters.excel.HandlerState; - -public interface IHandler { - - public IHandler getParent(); - public T getAncestor(Class clazz); - public CSSValue getBackgroundColour(); - - public String getPath(); - public void notifyHandler(HandlerState state); - - public void startPage(HandlerState state, IPageContent page) throws BirtException; - public void endPage(HandlerState state, IPageContent page) throws BirtException; - - public void startTable(HandlerState state, ITableContent table) throws BirtException; - public void endTable(HandlerState state, ITableContent table) throws BirtException; - - public void startTableBand(HandlerState state, ITableBandContent band) throws BirtException; - public void endTableBand(HandlerState state, ITableBandContent band) throws BirtException; - - public void startRow(HandlerState state, IRowContent row) throws BirtException; - public void endRow(HandlerState state, IRowContent row) throws BirtException; - - public void startCell(HandlerState state, ICellContent cell) throws BirtException; - public void endCell(HandlerState state, ICellContent cell) throws BirtException; - - public void startList(HandlerState state, IListContent list) throws BirtException; - public void endList(HandlerState state, IListContent list) throws BirtException; - - public void startListBand(HandlerState state, IListBandContent listBand) throws BirtException; - public void endListBand(HandlerState state, IListBandContent listBand) throws BirtException; - - public void startContainer(HandlerState state, IContainerContent container) throws BirtException; - public void endContainer(HandlerState state, IContainerContent container) throws BirtException; - - public void startContent(HandlerState state, IContent content) throws BirtException; - public void endContent(HandlerState state, IContent content) throws BirtException; - - public void startGroup(HandlerState state, IGroupContent group) throws BirtException; - public void endGroup(HandlerState state, IGroupContent group) throws BirtException; - - public void startTableGroup(HandlerState state, ITableGroupContent group) throws BirtException; - public void endTableGroup(HandlerState state, ITableGroupContent group) throws BirtException; - - public void startListGroup(HandlerState state, IListGroupContent group) throws BirtException; - public void endListGroup(HandlerState state, IListGroupContent group) throws BirtException; - - public void emitText(HandlerState state, ITextContent text) throws BirtException; - - public void emitData(HandlerState state, IDataContent data) throws BirtException; - - public void emitLabel(HandlerState state, ILabelContent label) throws BirtException; - - public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException; - - public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException; - - public void emitImage(HandlerState state, IImageContent image) throws BirtException; - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IAutoTextContent; +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.content.IContainerContent; +import org.eclipse.birt.report.engine.content.IContent; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IGroupContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.IListBandContent; +import org.eclipse.birt.report.engine.content.IListContent; +import org.eclipse.birt.report.engine.content.IListGroupContent; +import org.eclipse.birt.report.engine.content.IPageContent; +import org.eclipse.birt.report.engine.content.IRowContent; +import org.eclipse.birt.report.engine.content.ITableBandContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITableGroupContent; +import org.eclipse.birt.report.engine.content.ITextContent; +import org.w3c.dom.css.CSSValue; + +import uk.co.spudsoft.birt.emitters.excel.HandlerState; + +public interface IHandler { + + public IHandler getParent(); + public T getAncestor(Class clazz); + public CSSValue getBackgroundColour(); + + public String getPath(); + public void notifyHandler(HandlerState state); + + public void startPage(HandlerState state, IPageContent page) throws BirtException; + public void endPage(HandlerState state, IPageContent page) throws BirtException; + + public void startTable(HandlerState state, ITableContent table) throws BirtException; + public void endTable(HandlerState state, ITableContent table) throws BirtException; + + public void startTableBand(HandlerState state, ITableBandContent band) throws BirtException; + public void endTableBand(HandlerState state, ITableBandContent band) throws BirtException; + + public void startRow(HandlerState state, IRowContent row) throws BirtException; + public void endRow(HandlerState state, IRowContent row) throws BirtException; + + public void startCell(HandlerState state, ICellContent cell) throws BirtException; + public void endCell(HandlerState state, ICellContent cell) throws BirtException; + + public void startList(HandlerState state, IListContent list) throws BirtException; + public void endList(HandlerState state, IListContent list) throws BirtException; + + public void startListBand(HandlerState state, IListBandContent listBand) throws BirtException; + public void endListBand(HandlerState state, IListBandContent listBand) throws BirtException; + + public void startContainer(HandlerState state, IContainerContent container) throws BirtException; + public void endContainer(HandlerState state, IContainerContent container) throws BirtException; + + public void startContent(HandlerState state, IContent content) throws BirtException; + public void endContent(HandlerState state, IContent content) throws BirtException; + + public void startGroup(HandlerState state, IGroupContent group) throws BirtException; + public void endGroup(HandlerState state, IGroupContent group) throws BirtException; + + public void startTableGroup(HandlerState state, ITableGroupContent group) throws BirtException; + public void endTableGroup(HandlerState state, ITableGroupContent group) throws BirtException; + + public void startListGroup(HandlerState state, IListGroupContent group) throws BirtException; + public void endListGroup(HandlerState state, IListGroupContent group) throws BirtException; + + public void emitText(HandlerState state, ITextContent text) throws BirtException; + + public void emitData(HandlerState state, IDataContent data) throws BirtException; + + public void emitLabel(HandlerState state, ILabelContent label) throws BirtException; + + public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException; + + public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException; + + public void emitImage(HandlerState state, IImageContent image) throws BirtException; + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/ITableHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/ITableHandler.java index 15f670ce5..2ad19e69a 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/ITableHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/ITableHandler.java @@ -1,18 +1,18 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -public interface ITableHandler extends IHandler { - int getColumnCount(); -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +public interface ITableHandler extends IHandler { + int getColumnCount(); +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedListContentHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedListContentHandler.java index 99d58aa46..95e4a77d5 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedListContentHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedListContentHandler.java @@ -1,91 +1,91 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IAutoTextContent; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.IListContent; -import org.eclipse.birt.report.engine.content.ITextContent; -import org.eclipse.birt.report.engine.css.engine.StyleConstants; -import org.eclipse.birt.report.engine.emitter.IContentEmitter; -import org.eclipse.birt.report.engine.layout.pdf.util.HTML2Content; - -import uk.co.spudsoft.birt.emitters.excel.Coordinate; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class NestedListContentHandler extends CellContentHandler { - - protected int column; - - public NestedListContentHandler(IContentEmitter emitter, Logger log, IHandler parent, IListContent list, int column) { - super(emitter, log, parent, null); - this.element = list; - this.column = column; - } - - @Override - public void emitText(HandlerState state, ITextContent text) throws BirtException { - String textText = text.getText(); - log.debug( "text:", textText ); - emitContent(state,text,textText, ( ! "inline".equals( getStyleProperty(text, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - state.setHandler(parent); - } - - @Override - public void emitData(HandlerState state, IDataContent data) throws BirtException { - emitContent(state,data,data.getValue(), ( ! "inline".equals( getStyleProperty(data, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - state.setHandler(parent); - } - - @Override - public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { - // String labelText = ( label.getLabelText() != null ) ? label.getLabelText() : label.getText(); - String labelText = ( label.getText() != null ) ? label.getText() : label.getLabelText(); - log.debug( "labelText:", labelText ); - emitContent(state,label,labelText, ( ! "inline".equals( getStyleProperty(label, StyleConstants.STYLE_DISPLAY, "block") ) )); - state.setHandler(parent); - } - - @Override - public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { - emitContent(state,autoText,autoText.getText(), ( ! "inline".equals( getStyleProperty(autoText, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - state.setHandler(parent); - } - - @Override - public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { - - log.debug( "Handling foreign content of type ", foreign.getRawType() ); - if ( IForeignContent.HTML_TYPE.equalsIgnoreCase( foreign.getRawType( ) ) ) - { - HTML2Content.html2Content( foreign ); - contentVisitor.visitChildren( foreign, null ); - } - state.setHandler(parent); - } - - @Override - public void emitImage(HandlerState state, IImageContent image) throws BirtException { - recordImage(state, new Coordinate( state.rowNum, column ), image, false); - lastElement = image; - state.setHandler(parent); - } - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IAutoTextContent; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.IListContent; +import org.eclipse.birt.report.engine.content.ITextContent; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.emitter.IContentEmitter; +import org.eclipse.birt.report.engine.layout.pdf.util.HTML2Content; + +import uk.co.spudsoft.birt.emitters.excel.Coordinate; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class NestedListContentHandler extends CellContentHandler { + + protected int column; + + public NestedListContentHandler(IContentEmitter emitter, Logger log, IHandler parent, IListContent list, int column) { + super(emitter, log, parent, null); + this.element = list; + this.column = column; + } + + @Override + public void emitText(HandlerState state, ITextContent text) throws BirtException { + String textText = text.getText(); + log.debug( "text:", textText ); + emitContent(state,text,textText, ( ! "inline".equals( getStyleProperty(text, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + state.setHandler(parent); + } + + @Override + public void emitData(HandlerState state, IDataContent data) throws BirtException { + emitContent(state,data,data.getValue(), ( ! "inline".equals( getStyleProperty(data, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + state.setHandler(parent); + } + + @Override + public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { + // String labelText = ( label.getLabelText() != null ) ? label.getLabelText() : label.getText(); + String labelText = ( label.getText() != null ) ? label.getText() : label.getLabelText(); + log.debug( "labelText:", labelText ); + emitContent(state,label,labelText, ( ! "inline".equals( getStyleProperty(label, StyleConstants.STYLE_DISPLAY, "block") ) )); + state.setHandler(parent); + } + + @Override + public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { + emitContent(state,autoText,autoText.getText(), ( ! "inline".equals( getStyleProperty(autoText, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + state.setHandler(parent); + } + + @Override + public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { + + log.debug( "Handling foreign content of type ", foreign.getRawType() ); + if ( IForeignContent.HTML_TYPE.equalsIgnoreCase( foreign.getRawType( ) ) ) + { + HTML2Content.html2Content( foreign ); + contentVisitor.visitChildren( foreign, null ); + } + state.setHandler(parent); + } + + @Override + public void emitImage(HandlerState state, IImageContent image) throws BirtException { + recordImage(state, new Coordinate( state.rowNum, column ), image, false); + lastElement = image; + state.setHandler(parent); + } + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedListHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedListHandler.java index 0783baec7..d6015a1f8 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedListHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedListHandler.java @@ -1,26 +1,26 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.report.engine.content.IListContent; - -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class NestedListHandler extends TopLevelListHandler { - - public NestedListHandler(Logger log, IHandler parent, IListContent list) { - super(log, parent, list); - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.report.engine.content.IListContent; + +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class NestedListHandler extends TopLevelListHandler { + + public NestedListHandler(Logger log, IHandler parent, IListContent list) { + super(log, parent, list); + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableCellHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableCellHandler.java index 9af4e37ac..3ec0b9eef 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableCellHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableCellHandler.java @@ -1,27 +1,27 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.emitter.IContentEmitter; - -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class NestedTableCellHandler extends AbstractRealTableCellHandler { - - public NestedTableCellHandler(IContentEmitter emitter, Logger log, IHandler parent, ICellContent cell, int colOffset) { - super(emitter, log, parent, cell); - column = cell.getColumn() + colOffset; - } -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.emitter.IContentEmitter; + +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class NestedTableCellHandler extends AbstractRealTableCellHandler { + + public NestedTableCellHandler(IContentEmitter emitter, Logger log, IHandler parent, ICellContent cell, int colOffset) { + super(emitter, log, parent, cell); + column = cell.getColumn() + colOffset; + } +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableContainer.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableContainer.java index f5990b0ab..bfd19c6fa 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableContainer.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableContainer.java @@ -1,23 +1,23 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - - -public interface NestedTableContainer extends IHandler { - - public void addNestedTable( NestedTableHandler nestedTableHandler ); - public boolean rowHasNestedTable( int rowNum ); - public int extendRowBy( int rowNum ); - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + + +public interface NestedTableContainer extends IHandler { + + public void addNestedTable( NestedTableHandler nestedTableHandler ); + public boolean rowHasNestedTable( int rowNum ); + public int extendRowBy( int rowNum ); + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableHandler.java index 8e12b8e27..121bbe137 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableHandler.java @@ -1,121 +1,121 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IRowContent; -import org.eclipse.birt.report.engine.content.ITableContent; - -import uk.co.spudsoft.birt.emitters.excel.Coordinate; -import uk.co.spudsoft.birt.emitters.excel.EmitterServices; -import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class NestedTableHandler extends AbstractRealTableHandler { - - boolean inserted = false; - - private Coordinate topLeft; - private Coordinate bottomRight; - private int parentRowSpan; - - @Override - public String toString() { - return "NestedTableHandler [topLeft=" + topLeft + ", bottomRight=" + bottomRight + ", parentRowSpan=" + parentRowSpan + "]"; - } - - public NestedTableHandler(Logger log, IHandler parent, ITableContent table, int parentRowSpan) { - super(log, parent, table); - this.parentRowSpan = parentRowSpan; - } - - public void setInserted(boolean inserted) { - this.inserted = inserted; - } - - public boolean includesRow( int rowNum ) { - return ( ( topLeft.getRow() <= rowNum ) && ( bottomRight.getRow() >= rowNum ) ); - } - - public int extendParentsRowBy( int rowNum ) { - if( rowNum == topLeft.getRow() + parentRowSpan - 1 ) { - if( bottomRight.getRow() - topLeft.getRow() >= parentRowSpan - 1 ) { - int extension = 2 + bottomRight.getRow() - topLeft.getRow() - parentRowSpan; - log.debug( "Nested table ", this, " extends row ", rowNum, " by ", extension ); - return extension; - } - } - return 1; - } - - @Override - public void startTable(HandlerState state, ITableContent table) throws BirtException { - --state.colNum; - topLeft = new Coordinate(state.rowNum, state.colNum); - log.debug( "startTable called with topLeft = [", topLeft.getRow(), ", ", topLeft.getCol(), "]" ); - super.startTable(state, table); - if( ( state.sheetName == null ) || state.sheetName.isEmpty() ) { - String name = table.getName(); - if( ( name != null ) && ! name.isEmpty() ) { - state.sheetName = name; - } - } - if( ( state.sheetPassword == null ) || state.sheetPassword.isEmpty() ) { - String password = EmitterServices.stringOption( state.getRenderOptions(), table, ExcelEmitter.SHEET_PASSWORD, null); - if( ( password != null ) && ! password.isEmpty() ) { - state.sheetPassword = password; - } - } - } - - @Override - public void startRow(HandlerState state, IRowContent row) throws BirtException { - log.debug( "startRow called with topLeft = [", topLeft.getRow(), ", ", topLeft.getCol(), "]" ); - NestedTableRowHandler rowHandler = new NestedTableRowHandler(log, this, row, topLeft.getCol()); - - state.setHandler(rowHandler); - state.getHandler().startRow(state, row); - } - - @Override - public void endTable(HandlerState state, ITableContent table) throws BirtException { - - bottomRight = new Coordinate(state.rowNum - 1, state.colNum); - - super.endTable(state, table); - - // Parent could be a ListHandler (all derive from TopLevelListHandler) or a CellHandler - // If it's a cell handler we need to undo the rowNum increment from the last nested table row - if( ! ( parent instanceof TopLevelListHandler ) ) { - log.debug( "Decrementing rowNum from ", state.rowNum ); - --state.rowNum; - --state.colNum; - } - - state.rowNum = topLeft.getRow(); - - NestedTableContainer parentTableHandler = this.getAncestor( NestedTableContainer.class ); - parentTableHandler.addNestedTable( this ); - - if( bottomRight.getRow() < topLeft.getRow() + parentRowSpan - 1 ) { - state.getSmu().extendRows( state, topLeft.getRow(), topLeft.getCol(), topLeft.getRow() + parentRowSpan, bottomRight.getCol() ); - } - - state.setHandler(parent); - } - - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IRowContent; +import org.eclipse.birt.report.engine.content.ITableContent; + +import uk.co.spudsoft.birt.emitters.excel.Coordinate; +import uk.co.spudsoft.birt.emitters.excel.EmitterServices; +import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class NestedTableHandler extends AbstractRealTableHandler { + + boolean inserted = false; + + private Coordinate topLeft; + private Coordinate bottomRight; + private int parentRowSpan; + + @Override + public String toString() { + return "NestedTableHandler [topLeft=" + topLeft + ", bottomRight=" + bottomRight + ", parentRowSpan=" + parentRowSpan + "]"; + } + + public NestedTableHandler(Logger log, IHandler parent, ITableContent table, int parentRowSpan) { + super(log, parent, table); + this.parentRowSpan = parentRowSpan; + } + + public void setInserted(boolean inserted) { + this.inserted = inserted; + } + + public boolean includesRow( int rowNum ) { + return ( ( topLeft.getRow() <= rowNum ) && ( bottomRight.getRow() >= rowNum ) ); + } + + public int extendParentsRowBy( int rowNum ) { + if( rowNum == topLeft.getRow() + parentRowSpan - 1 ) { + if( bottomRight.getRow() - topLeft.getRow() >= parentRowSpan - 1 ) { + int extension = 2 + bottomRight.getRow() - topLeft.getRow() - parentRowSpan; + log.debug( "Nested table ", this, " extends row ", rowNum, " by ", extension ); + return extension; + } + } + return 1; + } + + @Override + public void startTable(HandlerState state, ITableContent table) throws BirtException { + --state.colNum; + topLeft = new Coordinate(state.rowNum, state.colNum); + log.debug( "startTable called with topLeft = [", topLeft.getRow(), ", ", topLeft.getCol(), "]" ); + super.startTable(state, table); + if( ( state.sheetName == null ) || state.sheetName.isEmpty() ) { + String name = table.getName(); + if( ( name != null ) && ! name.isEmpty() ) { + state.sheetName = name; + } + } + if( ( state.sheetPassword == null ) || state.sheetPassword.isEmpty() ) { + String password = EmitterServices.stringOption( state.getRenderOptions(), table, ExcelEmitter.SHEET_PASSWORD, null); + if( ( password != null ) && ! password.isEmpty() ) { + state.sheetPassword = password; + } + } + } + + @Override + public void startRow(HandlerState state, IRowContent row) throws BirtException { + log.debug( "startRow called with topLeft = [", topLeft.getRow(), ", ", topLeft.getCol(), "]" ); + NestedTableRowHandler rowHandler = new NestedTableRowHandler(log, this, row, topLeft.getCol()); + + state.setHandler(rowHandler); + state.getHandler().startRow(state, row); + } + + @Override + public void endTable(HandlerState state, ITableContent table) throws BirtException { + + bottomRight = new Coordinate(state.rowNum - 1, state.colNum); + + super.endTable(state, table); + + // Parent could be a ListHandler (all derive from TopLevelListHandler) or a CellHandler + // If it's a cell handler we need to undo the rowNum increment from the last nested table row + if( ! ( parent instanceof TopLevelListHandler ) ) { + log.debug( "Decrementing rowNum from ", state.rowNum ); + --state.rowNum; + --state.colNum; + } + + state.rowNum = topLeft.getRow(); + + NestedTableContainer parentTableHandler = this.getAncestor( NestedTableContainer.class ); + parentTableHandler.addNestedTable( this ); + + if( bottomRight.getRow() < topLeft.getRow() + parentRowSpan - 1 ) { + state.getSmu().extendRows( state, topLeft.getRow(), topLeft.getCol(), topLeft.getRow() + parentRowSpan, bottomRight.getCol() ); + } + + state.setHandler(parent); + } + + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableRowHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableRowHandler.java index 7f96deac6..9dda5185d 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableRowHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/NestedTableRowHandler.java @@ -1,52 +1,52 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.content.IRowContent; - -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class NestedTableRowHandler extends AbstractRealTableRowHandler { - - public NestedTableRowHandler(Logger log, IHandler parent, IRowContent row, int startCol) { - super(log, parent, row, startCol); - } - - @Override - public void startRow(HandlerState state, IRowContent row) throws BirtException { - log.debug( "startRow called with colOffset = ", startCol ); - super.startRow(state, row); - } - - @Override - public void startCell(HandlerState state, ICellContent cell) throws BirtException { - log.debug( "startCell called with colOffset = ", startCol ); - state.setHandler(new NestedTableCellHandler(state.getEmitter(), log, this, cell, startCol)); - state.getHandler().startCell(state, cell); - } - - @Override - public void endRow(HandlerState state, IRowContent row) throws BirtException { - super.endRow(state, row); - } - - @Override - protected boolean isNested() { - return true; - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.content.IRowContent; + +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class NestedTableRowHandler extends AbstractRealTableRowHandler { + + public NestedTableRowHandler(Logger log, IHandler parent, IRowContent row, int startCol) { + super(log, parent, row, startCol); + } + + @Override + public void startRow(HandlerState state, IRowContent row) throws BirtException { + log.debug( "startRow called with colOffset = ", startCol ); + super.startRow(state, row); + } + + @Override + public void startCell(HandlerState state, ICellContent cell) throws BirtException { + log.debug( "startCell called with colOffset = ", startCol ); + state.setHandler(new NestedTableCellHandler(state.getEmitter(), log, this, cell, startCol)); + state.getHandler().startCell(state, cell); + } + + @Override + public void endRow(HandlerState state, IRowContent row) throws BirtException { + super.endRow(state, row); + } + + @Override + protected boolean isNested() { + return true; + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/PageHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/PageHandler.java index 4e69ef492..86c1621ac 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/PageHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/PageHandler.java @@ -1,398 +1,398 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import java.util.Collection; - -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.ClientAnchor; -import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; -import org.apache.poi.ss.usermodel.Drawing; -import org.apache.poi.ss.usermodel.HeaderFooter; -import org.apache.poi.ss.usermodel.PrintSetup; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.util.CellRangeAddress; -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IAutoTextContent; -import org.eclipse.birt.report.engine.content.IContent; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.IListContent; -import org.eclipse.birt.report.engine.content.IPageContent; -import org.eclipse.birt.report.engine.content.IRowContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITextContent; -import org.eclipse.birt.report.engine.content.impl.CellContent; -import org.eclipse.birt.report.engine.ir.DimensionType; -import org.eclipse.birt.report.engine.presentation.ContentEmitterVisitor; - -import uk.co.spudsoft.birt.emitters.excel.CellImage; -import uk.co.spudsoft.birt.emitters.excel.ClientAnchorConversions; -import uk.co.spudsoft.birt.emitters.excel.Coordinate; -import uk.co.spudsoft.birt.emitters.excel.EmitterServices; -import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.StyleManagerUtils; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class PageHandler extends AbstractHandler { - - public PageHandler(Logger log, IPageContent page) { - super(log, null, page); - } - - private void setupPageSize(HandlerState state, IPageContent page) { - PrintSetup printSetup = state.currentSheet.getPrintSetup(); - printSetup.setPaperSize(state.getSmu().getPaperSizeFromString(page.getPageType())); - if( page.getOrientation() != null ) { - if( "landscape".equals(page.getOrientation())) { - printSetup.setLandscape(true); - } - } - } - - private String contentAsString( HandlerState state, Object obj ) throws BirtException { - - StringCellHandler stringCellHandler = new StringCellHandler( state.getEmitter(), log, this, - obj instanceof CellContent ? (CellContent)obj : null ); - - state.setHandler(stringCellHandler); - - stringCellHandler.visit(obj); - - state.setHandler(this); - - return stringCellHandler.getString(); - } - - @SuppressWarnings("rawtypes") - private void processHeaderFooter( HandlerState state, Collection birtHeaderFooter, HeaderFooter poiHeaderFooter ) throws BirtException { - boolean handledAsGrid = false; - for( Object ftrObject : birtHeaderFooter ) { - if( ftrObject instanceof ITableContent ) { - ITableContent ftrTable = (ITableContent)ftrObject; - if( ftrTable.getChildren().size() == 1 ) { - Object child = ftrTable.getChildren().toArray()[ 0 ]; - if( child instanceof IRowContent ) { - IRowContent row = (IRowContent)child; - if( ftrTable.getColumnCount() <= 3 ) { - Object[] cellObjects = row.getChildren().toArray(); - if( ftrTable.getColumnCount() == 1 ) { - poiHeaderFooter.setLeft( contentAsString( state, cellObjects[ 0 ] ) ); - handledAsGrid = true; - } else if( ftrTable.getColumnCount() == 2 ) { - poiHeaderFooter.setLeft( contentAsString( state, cellObjects[ 0 ] ) ); - poiHeaderFooter.setRight( contentAsString( state, cellObjects[ 1 ] ) ); - handledAsGrid = true; - } else if( ftrTable.getColumnCount() == 3 ) { - poiHeaderFooter.setLeft( contentAsString( state, cellObjects[ 0 ] ) ); - poiHeaderFooter.setCenter( contentAsString( state, cellObjects[ 1 ] ) ); - poiHeaderFooter.setRight( contentAsString( state, cellObjects[ 2 ] ) ); - handledAsGrid = true; - } - } - } - } - } - if( ! handledAsGrid ) { - poiHeaderFooter.setLeft( contentAsString( state, ftrObject ) ); - } - } - } - - @SuppressWarnings("rawtypes") - private void outputStructuredHeaderFooter( HandlerState state, Collection birtHeaderFooter ) throws BirtException { - ContentEmitterVisitor visitor = new ContentEmitterVisitor(state.getEmitter()); - for( Object content : birtHeaderFooter ) { - if( content instanceof IContent ) { - visitor.visit((IContent)content, null); - } - } - - } - - @Override - public void startPage(HandlerState state, IPageContent page) throws BirtException { - - if( state.getWb().getNumberOfSheets() > 0 ) { - if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.SINGLE_SHEET_PAGE_BREAKS, false ) ) { - state.currentSheet.setRowBreak( state.rowNum - 1 ); - } - if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.SINGLE_SHEET, false ) ) { - return ; - } - } - - state.currentSheet = state.getWb().createSheet(); - log.debug("Page type: ", page.getPageType()); - - if( page.getPageType() != null ) { - setupPageSize(state, page); - } - - if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.DISPLAYFORMULAS_PROP, false ) ) { - state.currentSheet.setDisplayFormulas(true); - } - if( ! EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.DISPLAYGRIDLINES_PROP, true ) ) { - state.currentSheet.setDisplayGridlines(false); - } - if( ! EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.DISPLAYROWCOLHEADINGS_PROP, true ) ) { - state.currentSheet.setDisplayRowColHeadings(false); - } - if( ! EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.DISPLAYZEROS_PROP, true ) ) { - state.currentSheet.setDisplayZeros(false); - } - int pagesHigh = EmitterServices.integerOption( state.getRenderOptions(), page, ExcelEmitter.PRINT_PAGES_HIGH, -1 ); - if( ( pagesHigh > 0 ) && ( pagesHigh < Short.MAX_VALUE ) ) { - state.currentSheet.getPrintSetup().setFitHeight((short)pagesHigh); - state.currentSheet.setAutobreaks(true); - } - int pagesWide = EmitterServices.integerOption( state.getRenderOptions(), page, ExcelEmitter.PRINT_PAGES_WIDE, -1 ); - if( ( pagesWide > 0 ) && ( pagesWide < Short.MAX_VALUE ) ) { - state.currentSheet.getPrintSetup().setFitWidth((short)pagesWide); - state.currentSheet.setAutobreaks(true); - } - int printScale = EmitterServices.integerOption( state.getRenderOptions(), page, ExcelEmitter.PRINT_SCALE, -1 ); - if( ( printScale > 0 ) && ( printScale < Short.MAX_VALUE ) ) { - state.currentSheet.getPrintSetup().setScale((short)printScale); - } - - if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.STRUCTURED_HEADER, false ) ) { - outputStructuredHeaderFooter(state, page.getHeader()); - } else { - processHeaderFooter(state, page.getHeader(), state.currentSheet.getHeader() ); - processHeaderFooter(state, page.getFooter(), state.currentSheet.getFooter() ); - } - - state.getSmu().prepareMarginDimensions(state.currentSheet, page); - } - - private String prepareSheetName( HandlerState state ) { - if( state.sheetName != null ) { - String preparedName = state.sheetName; - Integer nameCount = state.sheetNames.get(preparedName); - if( nameCount != null ) { - ++nameCount; - state.sheetNames.put(preparedName, nameCount); - preparedName = preparedName + " " + nameCount; - } else { - state.sheetNames.put(preparedName,1); - } - return preparedName; - } - return null; - } - - @Override - public void endPage(HandlerState state, IPageContent page) throws BirtException { - - if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.SINGLE_SHEET, false ) - && ! state.reportEnding ) { - return ; - } - - if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.STRUCTURED_HEADER, false ) ) { - outputStructuredHeaderFooter(state, page.getFooter()); - } - - String sheetName = prepareSheetName( state ); - if( sheetName != null ) { - log.debug("Attempting to name sheet ", ( state.getWb().getNumberOfSheets() - 1 ), " \"", sheetName, "\" "); - int existingSheetIndex = -1; - for( int i = 0; i < state.getWb().getNumberOfSheets() - 1; ++i ) { - if( state.getWb().getSheetName(i).equals(sheetName)) { - log.debug("Found matching sheet at ", i, " \"", state.getWb().getSheetName(i), "\"" ); - existingSheetIndex = i; - break; - } - } - if (existingSheetIndex >= 0) { - log.debug("Deleting sheet at ", existingSheetIndex, " \"", state.getWb().getSheetName(existingSheetIndex), "\"" ); - state.getWb().removeSheetAt(existingSheetIndex); - } - state.getWb().setSheetName(state.getWb().getNumberOfSheets() - 1, sheetName); - if (existingSheetIndex >= 0) { - state.getWb().setSheetOrder(sheetName,existingSheetIndex); - } - state.sheetName = null; - } - if( state.sheetPassword != null ) { - log.debug("Attempting to protect sheet ", ( state.getWb().getNumberOfSheets() - 1 ) ); - state.currentSheet.protectSheet( state.sheetPassword ); - state.sheetPassword = null; - } - - Drawing drawing = null; - if( ! state.images.isEmpty() ) { - drawing = state.currentSheet.createDrawingPatriarch(); - } - for( CellImage cellImage : state.images ) { - processCellImage(state,drawing,cellImage); - } - state.images.clear(); - state.rowNum = 0; - state.colNum = 0; - state.clearRowSpans(); - state.areaBorders.clear(); - - state.currentSheet = null; - } - - private CellRangeAddress getMergedRegionBegunBy( Sheet sheet, int row, int col ) { - for( int i = 0; i < sheet.getNumMergedRegions(); ++i ) { - CellRangeAddress range = sheet.getMergedRegion(i); - if( ( range.getFirstColumn() == col ) && ( range.getFirstRow() == row ) ) { - return range; - } - } - return null; - } - - /** - *

- * Process a CellImage from the images list and place the image on the sheet. - *

- * This involves changing the row height as necesssary and determining the column spread of the image. - *

- * @param cellImage - * The image to be placed on the sheet. - */ - private void processCellImage( HandlerState state, Drawing drawing, CellImage cellImage ) { - Coordinate location = cellImage.location; - - Cell cell = state.currentSheet.getRow( location.getRow() ).getCell( location.getCol() ); - - IImageContent image = cellImage.image; - - StyleManagerUtils smu = state.getSmu(); - float ptHeight = cell.getRow().getHeightInPoints(); - if( image.getHeight() != null ) { - ptHeight = smu.fontSizeInPoints( image.getHeight().toString() ); - } - - // Get image width - int endCol = cell.getColumnIndex(); - double lastColWidth = ClientAnchorConversions.widthUnits2Millimetres( (short)state.currentSheet.getColumnWidth( endCol ) ) - + 2.0; - int dx = smu.anchorDxFromMM( lastColWidth, lastColWidth ); - double mmWidth = 0.0; - if( smu.isAbsolute(image.getWidth())) { - mmWidth = image.getWidth().convertTo(DimensionType.UNITS_MM); - } else if(smu.isPixels(image.getWidth())) { - mmWidth = ClientAnchorConversions.pixels2Millimetres( image.getWidth().getMeasure() ); - } - // Allow image to span multiple columns - CellRangeAddress mergedRegion = getMergedRegionBegunBy( state.currentSheet, location.getRow(), location.getCol() ); - if( (cellImage.spanColumns) || ( mergedRegion != null ) ) { - log.debug( "Image size: ", image.getWidth(), " translates as mmWidth = ", mmWidth ); - if( mmWidth > 0) { - double mmAccumulatedWidth = 0; - int endColLimit = cellImage.spanColumns ? 256 : mergedRegion.getLastColumn(); - for( endCol = cell.getColumnIndex(); mmAccumulatedWidth < mmWidth && endCol < endColLimit; ++ endCol ) { - lastColWidth = ClientAnchorConversions.widthUnits2Millimetres( (short)state.currentSheet.getColumnWidth( endCol ) ) - + 2.0; - mmAccumulatedWidth += lastColWidth; - log.debug( "lastColWidth = ", lastColWidth, "; mmAccumulatedWidth = ", mmAccumulatedWidth); - } - if( mmAccumulatedWidth > mmWidth ) { - mmAccumulatedWidth -= lastColWidth; - --endCol; - double mmShort = mmWidth - mmAccumulatedWidth; - dx = smu.anchorDxFromMM( mmShort, lastColWidth ); - } - } - } else { - float widthRatio = (float)(mmWidth / lastColWidth); - ptHeight = ptHeight / widthRatio; - } - - int rowsSpanned = state.findRowsSpanned( cell.getRowIndex(), cell.getColumnIndex() ); - float neededRowHeightPoints = ptHeight; - - for( int i = 0; i < rowsSpanned; ++i ) { - int rowIndex = cell.getRowIndex() + 1 + i; - neededRowHeightPoints -= state.currentSheet.getRow(rowIndex).getHeightInPoints(); - } - - if( neededRowHeightPoints > cell.getRow().getHeightInPoints()) { - cell.getRow().setHeightInPoints( neededRowHeightPoints ); - } - - // ClientAnchor anchor = wb.getCreationHelper().createClientAnchor(); - ClientAnchor anchor = state.getWb().getCreationHelper().createClientAnchor(); - anchor.setCol1(cell.getColumnIndex()); - anchor.setRow1(cell.getRowIndex()); - anchor.setCol2(endCol); - anchor.setRow2(cell.getRowIndex() + rowsSpanned); - anchor.setDx2(dx); - anchor.setDy2( smu.anchorDyFromPoints( ptHeight, cell.getRow().getHeightInPoints() ) ); - anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE); - drawing.createPicture(anchor, cellImage.imageIdx); - } - - - @Override - public void startList(HandlerState state, IListContent list) throws BirtException { - state.setHandler(new TopLevelListHandler(log,this,list)); - state.getHandler().startList(state, list); - } - - @Override - public void startTable(HandlerState state, ITableContent table) throws BirtException { - state.setHandler(new TopLevelTableHandler(log,this,table)); - state.getHandler().startTable(state, table); - } - - @Override - public void emitText(HandlerState state, ITextContent text) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitText(state, text); - } - - @Override - public void emitData(HandlerState state, IDataContent data) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitData(state, data); - } - - @Override - public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitLabel(state, label); - } - - @Override - public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitAutoText(state, autoText); - } - - @Override - public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitForeign(state, foreign); - } - - @Override - public void emitImage(HandlerState state, IImageContent image) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitImage(state, image); - } - - - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import java.util.Collection; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.HeaderFooter; +import org.apache.poi.ss.usermodel.PrintSetup; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.util.CellRangeAddress; +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IAutoTextContent; +import org.eclipse.birt.report.engine.content.IContent; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.IListContent; +import org.eclipse.birt.report.engine.content.IPageContent; +import org.eclipse.birt.report.engine.content.IRowContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITextContent; +import org.eclipse.birt.report.engine.content.impl.CellContent; +import org.eclipse.birt.report.engine.ir.DimensionType; +import org.eclipse.birt.report.engine.presentation.ContentEmitterVisitor; + +import uk.co.spudsoft.birt.emitters.excel.CellImage; +import uk.co.spudsoft.birt.emitters.excel.ClientAnchorConversions; +import uk.co.spudsoft.birt.emitters.excel.Coordinate; +import uk.co.spudsoft.birt.emitters.excel.EmitterServices; +import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.StyleManagerUtils; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class PageHandler extends AbstractHandler { + + public PageHandler(Logger log, IPageContent page) { + super(log, null, page); + } + + private void setupPageSize(HandlerState state, IPageContent page) { + PrintSetup printSetup = state.currentSheet.getPrintSetup(); + printSetup.setPaperSize(state.getSmu().getPaperSizeFromString(page.getPageType())); + if( page.getOrientation() != null ) { + if( "landscape".equals(page.getOrientation())) { + printSetup.setLandscape(true); + } + } + } + + private String contentAsString( HandlerState state, Object obj ) throws BirtException { + + StringCellHandler stringCellHandler = new StringCellHandler( state.getEmitter(), log, this, + obj instanceof CellContent ? (CellContent)obj : null ); + + state.setHandler(stringCellHandler); + + stringCellHandler.visit(obj); + + state.setHandler(this); + + return stringCellHandler.getString(); + } + + @SuppressWarnings("rawtypes") + private void processHeaderFooter( HandlerState state, Collection birtHeaderFooter, HeaderFooter poiHeaderFooter ) throws BirtException { + boolean handledAsGrid = false; + for( Object ftrObject : birtHeaderFooter ) { + if( ftrObject instanceof ITableContent ) { + ITableContent ftrTable = (ITableContent)ftrObject; + if( ftrTable.getChildren().size() == 1 ) { + Object child = ftrTable.getChildren().toArray()[ 0 ]; + if( child instanceof IRowContent ) { + IRowContent row = (IRowContent)child; + if( ftrTable.getColumnCount() <= 3 ) { + Object[] cellObjects = row.getChildren().toArray(); + if( ftrTable.getColumnCount() == 1 ) { + poiHeaderFooter.setLeft( contentAsString( state, cellObjects[ 0 ] ) ); + handledAsGrid = true; + } else if( ftrTable.getColumnCount() == 2 ) { + poiHeaderFooter.setLeft( contentAsString( state, cellObjects[ 0 ] ) ); + poiHeaderFooter.setRight( contentAsString( state, cellObjects[ 1 ] ) ); + handledAsGrid = true; + } else if( ftrTable.getColumnCount() == 3 ) { + poiHeaderFooter.setLeft( contentAsString( state, cellObjects[ 0 ] ) ); + poiHeaderFooter.setCenter( contentAsString( state, cellObjects[ 1 ] ) ); + poiHeaderFooter.setRight( contentAsString( state, cellObjects[ 2 ] ) ); + handledAsGrid = true; + } + } + } + } + } + if( ! handledAsGrid ) { + poiHeaderFooter.setLeft( contentAsString( state, ftrObject ) ); + } + } + } + + @SuppressWarnings("rawtypes") + private void outputStructuredHeaderFooter( HandlerState state, Collection birtHeaderFooter ) throws BirtException { + ContentEmitterVisitor visitor = new ContentEmitterVisitor(state.getEmitter()); + for( Object content : birtHeaderFooter ) { + if( content instanceof IContent ) { + visitor.visit((IContent)content, null); + } + } + + } + + @Override + public void startPage(HandlerState state, IPageContent page) throws BirtException { + + if( state.getWb().getNumberOfSheets() > 0 ) { + if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.SINGLE_SHEET_PAGE_BREAKS, false ) ) { + state.currentSheet.setRowBreak( state.rowNum - 1 ); + } + if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.SINGLE_SHEET, false ) ) { + return ; + } + } + + state.currentSheet = state.getWb().createSheet(); + log.debug("Page type: ", page.getPageType()); + + if( page.getPageType() != null ) { + setupPageSize(state, page); + } + + if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.DISPLAYFORMULAS_PROP, false ) ) { + state.currentSheet.setDisplayFormulas(true); + } + if( ! EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.DISPLAYGRIDLINES_PROP, true ) ) { + state.currentSheet.setDisplayGridlines(false); + } + if( ! EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.DISPLAYROWCOLHEADINGS_PROP, true ) ) { + state.currentSheet.setDisplayRowColHeadings(false); + } + if( ! EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.DISPLAYZEROS_PROP, true ) ) { + state.currentSheet.setDisplayZeros(false); + } + int pagesHigh = EmitterServices.integerOption( state.getRenderOptions(), page, ExcelEmitter.PRINT_PAGES_HIGH, -1 ); + if( ( pagesHigh > 0 ) && ( pagesHigh < Short.MAX_VALUE ) ) { + state.currentSheet.getPrintSetup().setFitHeight((short)pagesHigh); + state.currentSheet.setAutobreaks(true); + } + int pagesWide = EmitterServices.integerOption( state.getRenderOptions(), page, ExcelEmitter.PRINT_PAGES_WIDE, -1 ); + if( ( pagesWide > 0 ) && ( pagesWide < Short.MAX_VALUE ) ) { + state.currentSheet.getPrintSetup().setFitWidth((short)pagesWide); + state.currentSheet.setAutobreaks(true); + } + int printScale = EmitterServices.integerOption( state.getRenderOptions(), page, ExcelEmitter.PRINT_SCALE, -1 ); + if( ( printScale > 0 ) && ( printScale < Short.MAX_VALUE ) ) { + state.currentSheet.getPrintSetup().setScale((short)printScale); + } + + if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.STRUCTURED_HEADER, false ) ) { + outputStructuredHeaderFooter(state, page.getHeader()); + } else { + processHeaderFooter(state, page.getHeader(), state.currentSheet.getHeader() ); + processHeaderFooter(state, page.getFooter(), state.currentSheet.getFooter() ); + } + + state.getSmu().prepareMarginDimensions(state.currentSheet, page); + } + + private String prepareSheetName( HandlerState state ) { + if( state.sheetName != null ) { + String preparedName = state.sheetName; + Integer nameCount = state.sheetNames.get(preparedName); + if( nameCount != null ) { + ++nameCount; + state.sheetNames.put(preparedName, nameCount); + preparedName = preparedName + " " + nameCount; + } else { + state.sheetNames.put(preparedName,1); + } + return preparedName; + } + return null; + } + + @Override + public void endPage(HandlerState state, IPageContent page) throws BirtException { + + if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.SINGLE_SHEET, false ) + && ! state.reportEnding ) { + return ; + } + + if( EmitterServices.booleanOption( state.getRenderOptions(), page, ExcelEmitter.STRUCTURED_HEADER, false ) ) { + outputStructuredHeaderFooter(state, page.getFooter()); + } + + String sheetName = prepareSheetName( state ); + if( sheetName != null ) { + log.debug("Attempting to name sheet ", ( state.getWb().getNumberOfSheets() - 1 ), " \"", sheetName, "\" "); + int existingSheetIndex = -1; + for( int i = 0; i < state.getWb().getNumberOfSheets() - 1; ++i ) { + if( state.getWb().getSheetName(i).equals(sheetName)) { + log.debug("Found matching sheet at ", i, " \"", state.getWb().getSheetName(i), "\"" ); + existingSheetIndex = i; + break; + } + } + if (existingSheetIndex >= 0) { + log.debug("Deleting sheet at ", existingSheetIndex, " \"", state.getWb().getSheetName(existingSheetIndex), "\"" ); + state.getWb().removeSheetAt(existingSheetIndex); + } + state.getWb().setSheetName(state.getWb().getNumberOfSheets() - 1, sheetName); + if (existingSheetIndex >= 0) { + state.getWb().setSheetOrder(sheetName,existingSheetIndex); + } + state.sheetName = null; + } + if( state.sheetPassword != null ) { + log.debug("Attempting to protect sheet ", ( state.getWb().getNumberOfSheets() - 1 ) ); + state.currentSheet.protectSheet( state.sheetPassword ); + state.sheetPassword = null; + } + + Drawing drawing = null; + if( ! state.images.isEmpty() ) { + drawing = state.currentSheet.createDrawingPatriarch(); + } + for( CellImage cellImage : state.images ) { + processCellImage(state,drawing,cellImage); + } + state.images.clear(); + state.rowNum = 0; + state.colNum = 0; + state.clearRowSpans(); + state.areaBorders.clear(); + + state.currentSheet = null; + } + + private CellRangeAddress getMergedRegionBegunBy( Sheet sheet, int row, int col ) { + for( int i = 0; i < sheet.getNumMergedRegions(); ++i ) { + CellRangeAddress range = sheet.getMergedRegion(i); + if( ( range.getFirstColumn() == col ) && ( range.getFirstRow() == row ) ) { + return range; + } + } + return null; + } + + /** + *

+ * Process a CellImage from the images list and place the image on the sheet. + *

+ * This involves changing the row height as necesssary and determining the column spread of the image. + *

+ * @param cellImage + * The image to be placed on the sheet. + */ + private void processCellImage( HandlerState state, Drawing drawing, CellImage cellImage ) { + Coordinate location = cellImage.location; + + Cell cell = state.currentSheet.getRow( location.getRow() ).getCell( location.getCol() ); + + IImageContent image = cellImage.image; + + StyleManagerUtils smu = state.getSmu(); + float ptHeight = cell.getRow().getHeightInPoints(); + if( image.getHeight() != null ) { + ptHeight = smu.fontSizeInPoints( image.getHeight().toString() ); + } + + // Get image width + int endCol = cell.getColumnIndex(); + double lastColWidth = ClientAnchorConversions.widthUnits2Millimetres( (short)state.currentSheet.getColumnWidth( endCol ) ) + + 2.0; + int dx = smu.anchorDxFromMM( lastColWidth, lastColWidth ); + double mmWidth = 0.0; + if( smu.isAbsolute(image.getWidth())) { + mmWidth = image.getWidth().convertTo(DimensionType.UNITS_MM); + } else if(smu.isPixels(image.getWidth())) { + mmWidth = ClientAnchorConversions.pixels2Millimetres( image.getWidth().getMeasure() ); + } + // Allow image to span multiple columns + CellRangeAddress mergedRegion = getMergedRegionBegunBy( state.currentSheet, location.getRow(), location.getCol() ); + if( (cellImage.spanColumns) || ( mergedRegion != null ) ) { + log.debug( "Image size: ", image.getWidth(), " translates as mmWidth = ", mmWidth ); + if( mmWidth > 0) { + double mmAccumulatedWidth = 0; + int endColLimit = cellImage.spanColumns ? 256 : mergedRegion.getLastColumn(); + for( endCol = cell.getColumnIndex(); mmAccumulatedWidth < mmWidth && endCol < endColLimit; ++ endCol ) { + lastColWidth = ClientAnchorConversions.widthUnits2Millimetres( (short)state.currentSheet.getColumnWidth( endCol ) ) + + 2.0; + mmAccumulatedWidth += lastColWidth; + log.debug( "lastColWidth = ", lastColWidth, "; mmAccumulatedWidth = ", mmAccumulatedWidth); + } + if( mmAccumulatedWidth > mmWidth ) { + mmAccumulatedWidth -= lastColWidth; + --endCol; + double mmShort = mmWidth - mmAccumulatedWidth; + dx = smu.anchorDxFromMM( mmShort, lastColWidth ); + } + } + } else { + float widthRatio = (float)(mmWidth / lastColWidth); + ptHeight = ptHeight / widthRatio; + } + + int rowsSpanned = state.findRowsSpanned( cell.getRowIndex(), cell.getColumnIndex() ); + float neededRowHeightPoints = ptHeight; + + for( int i = 0; i < rowsSpanned; ++i ) { + int rowIndex = cell.getRowIndex() + 1 + i; + neededRowHeightPoints -= state.currentSheet.getRow(rowIndex).getHeightInPoints(); + } + + if( neededRowHeightPoints > cell.getRow().getHeightInPoints()) { + cell.getRow().setHeightInPoints( neededRowHeightPoints ); + } + + // ClientAnchor anchor = wb.getCreationHelper().createClientAnchor(); + ClientAnchor anchor = state.getWb().getCreationHelper().createClientAnchor(); + anchor.setCol1(cell.getColumnIndex()); + anchor.setRow1(cell.getRowIndex()); + anchor.setCol2(endCol); + anchor.setRow2(cell.getRowIndex() + rowsSpanned); + anchor.setDx2(dx); + anchor.setDy2( smu.anchorDyFromPoints( ptHeight, cell.getRow().getHeightInPoints() ) ); + anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE); + drawing.createPicture(anchor, cellImage.imageIdx); + } + + + @Override + public void startList(HandlerState state, IListContent list) throws BirtException { + state.setHandler(new TopLevelListHandler(log,this,list)); + state.getHandler().startList(state, list); + } + + @Override + public void startTable(HandlerState state, ITableContent table) throws BirtException { + state.setHandler(new TopLevelTableHandler(log,this,table)); + state.getHandler().startTable(state, table); + } + + @Override + public void emitText(HandlerState state, ITextContent text) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitText(state, text); + } + + @Override + public void emitData(HandlerState state, IDataContent data) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitData(state, data); + } + + @Override + public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitLabel(state, label); + } + + @Override + public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitAutoText(state, autoText); + } + + @Override + public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitForeign(state, foreign); + } + + @Override + public void emitImage(HandlerState state, IImageContent image) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitImage(state, image); + } + + + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/StringCellHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/StringCellHandler.java index 193f1342b..f7c8f34b5 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/StringCellHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/StringCellHandler.java @@ -1,145 +1,145 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.apache.poi.ss.usermodel.Cell; -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IAutoTextContent; -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.content.IContainerContent; -import org.eclipse.birt.report.engine.content.IContent; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITextContent; -import org.eclipse.birt.report.engine.css.engine.StyleConstants; -import org.eclipse.birt.report.engine.emitter.IContentEmitter; -import org.eclipse.birt.report.engine.layout.pdf.util.HTML2Content; - -import uk.co.spudsoft.birt.emitters.excel.Area; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class StringCellHandler extends CellContentHandler { - - private String result = null; - - public StringCellHandler(IContentEmitter emitter, Logger log, IHandler parent, ICellContent cell) { - super(emitter, log, parent, cell); - } - - @Override - public void endCell(HandlerState state, ICellContent cell) throws BirtException { - endCellContent(state, cell, lastElement, null, null ); - } - - @Override - protected void endCellContent(HandlerState state, ICellContent birtCell, IContent element, Cell cell, Area area) { - if( lastValue != null ) { - if( lastValue instanceof String ) { - result = (String)lastValue; - } else { - result = lastValue.toString(); - } - } - } - - public void visit( Object obj ) throws BirtException { - if( obj instanceof ICellContent ) { - contentVisitor.visitCell( (ICellContent)obj, null ); - } else if( obj instanceof ILabelContent ) { - contentVisitor.visitLabel( (ILabelContent)obj, null ); - } else if( obj instanceof ITextContent ) { - contentVisitor.visitText( (ITextContent)obj, null ); - } else if( obj instanceof IAutoTextContent ) { - contentVisitor.visitAutoText( (IAutoTextContent)obj, null ); - } else if( obj instanceof IForeignContent ) { - contentVisitor.visitForeign( (IForeignContent)obj, null ); - } else { - log.warn(0, "Not visiting " + obj.getClass(), null); - } - } - - public String getString() { - if( result == null ) { - if( lastValue != null ) { - if( lastValue instanceof String ) { - result = (String)lastValue; - } else { - result = lastValue.toString(); - } - } - } - if( result == null ) { - result = ""; - } - return result; - } - - - @Override - public void startTable(HandlerState state, ITableContent table) throws BirtException { - state.setHandler(new FlattenedTableHandler(this, log, this, table)); - state.getHandler().startTable(state, table); - } - - @Override - public void emitText(HandlerState state, ITextContent text) throws BirtException { - String textText = text.getText(); - log.debug( "text:", textText ); - emitContent(state,text,textText, ( ! "inline".equals( getStyleProperty(text, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - } - - @Override - public void emitData(HandlerState state, IDataContent data) throws BirtException { - emitContent(state,data,data.getValue(), ( ! "inline".equals( getStyleProperty(data, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - } - - @Override - public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { - String labelText = ( label.getLabelText() != null ) ? label.getLabelText() : label.getText(); - log.debug( "labelText:" + labelText ); - emitContent(state,label,labelText, ( ! "inline".equals( getStyleProperty(label, StyleConstants.STYLE_DISPLAY, "block") ) )); - } - - @Override - public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { - emitContent(state,autoText,autoText.getText(), ( ! "inline".equals( getStyleProperty(autoText, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - } - - @Override - public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { - - log.debug( "Handling foreign content of type " + foreign.getRawType() ); - if ( IForeignContent.HTML_TYPE.equalsIgnoreCase( foreign.getRawType( ) ) ) - { - HTML2Content.html2Content( foreign ); - contentVisitor.visitChildren( foreign, null ); - } - } - - @Override - public void emitImage(HandlerState state, IImageContent image) throws BirtException { - } - - @Override - public void endContainer(HandlerState state, IContainerContent container) throws BirtException { - lastCellContentsWasBlock = ( ! "inline".equals( getStyleProperty(container, StyleConstants.STYLE_DISPLAY, "block") ) ); - } - - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.apache.poi.ss.usermodel.Cell; +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IAutoTextContent; +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.content.IContainerContent; +import org.eclipse.birt.report.engine.content.IContent; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITextContent; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.emitter.IContentEmitter; +import org.eclipse.birt.report.engine.layout.pdf.util.HTML2Content; + +import uk.co.spudsoft.birt.emitters.excel.Area; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class StringCellHandler extends CellContentHandler { + + private String result = null; + + public StringCellHandler(IContentEmitter emitter, Logger log, IHandler parent, ICellContent cell) { + super(emitter, log, parent, cell); + } + + @Override + public void endCell(HandlerState state, ICellContent cell) throws BirtException { + endCellContent(state, cell, lastElement, null, null ); + } + + @Override + protected void endCellContent(HandlerState state, ICellContent birtCell, IContent element, Cell cell, Area area) { + if( lastValue != null ) { + if( lastValue instanceof String ) { + result = (String)lastValue; + } else { + result = lastValue.toString(); + } + } + } + + public void visit( Object obj ) throws BirtException { + if( obj instanceof ICellContent ) { + contentVisitor.visitCell( (ICellContent)obj, null ); + } else if( obj instanceof ILabelContent ) { + contentVisitor.visitLabel( (ILabelContent)obj, null ); + } else if( obj instanceof ITextContent ) { + contentVisitor.visitText( (ITextContent)obj, null ); + } else if( obj instanceof IAutoTextContent ) { + contentVisitor.visitAutoText( (IAutoTextContent)obj, null ); + } else if( obj instanceof IForeignContent ) { + contentVisitor.visitForeign( (IForeignContent)obj, null ); + } else { + log.warn(0, "Not visiting " + obj.getClass(), null); + } + } + + public String getString() { + if( result == null ) { + if( lastValue != null ) { + if( lastValue instanceof String ) { + result = (String)lastValue; + } else { + result = lastValue.toString(); + } + } + } + if( result == null ) { + result = ""; + } + return result; + } + + + @Override + public void startTable(HandlerState state, ITableContent table) throws BirtException { + state.setHandler(new FlattenedTableHandler(this, log, this, table)); + state.getHandler().startTable(state, table); + } + + @Override + public void emitText(HandlerState state, ITextContent text) throws BirtException { + String textText = text.getText(); + log.debug( "text:", textText ); + emitContent(state,text,textText, ( ! "inline".equals( getStyleProperty(text, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + } + + @Override + public void emitData(HandlerState state, IDataContent data) throws BirtException { + emitContent(state,data,data.getValue(), ( ! "inline".equals( getStyleProperty(data, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + } + + @Override + public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { + String labelText = ( label.getLabelText() != null ) ? label.getLabelText() : label.getText(); + log.debug( "labelText:" + labelText ); + emitContent(state,label,labelText, ( ! "inline".equals( getStyleProperty(label, StyleConstants.STYLE_DISPLAY, "block") ) )); + } + + @Override + public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { + emitContent(state,autoText,autoText.getText(), ( ! "inline".equals( getStyleProperty(autoText, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + } + + @Override + public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { + + log.debug( "Handling foreign content of type " + foreign.getRawType() ); + if ( IForeignContent.HTML_TYPE.equalsIgnoreCase( foreign.getRawType( ) ) ) + { + HTML2Content.html2Content( foreign ); + contentVisitor.visitChildren( foreign, null ); + } + } + + @Override + public void emitImage(HandlerState state, IImageContent image) throws BirtException { + } + + @Override + public void endContainer(HandlerState state, IContainerContent container) throws BirtException { + lastCellContentsWasBlock = ( ! "inline".equals( getStyleProperty(container, StyleConstants.STYLE_DISPLAY, "block") ) ); + } + + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelContentHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelContentHandler.java index 2f984f7f8..25b69183e 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelContentHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelContentHandler.java @@ -1,118 +1,118 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellType; -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.ITextContent; -import org.eclipse.birt.report.engine.css.engine.StyleConstants; -import org.eclipse.birt.report.engine.emitter.IContentEmitter; -import org.eclipse.birt.report.engine.layout.pdf.util.HTML2Content; - -import uk.co.spudsoft.birt.emitters.excel.Coordinate; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class TopLevelContentHandler extends CellContentHandler { - - public TopLevelContentHandler(IContentEmitter emitter, Logger log, IHandler parent) { - super(emitter, log, parent, null); - } - - - @Override - public void emitText(HandlerState state, ITextContent text) throws BirtException { - log.debug( "Creating row ", state.rowNum, " for text" ); - state.currentSheet.createRow( state.rowNum ); - - emitContent(state, text, text.getText(), ( ! "inline".equals( getStyleProperty(text, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - - Cell currentCell = state.currentSheet.getRow(state.rowNum).createCell( 0 ); - currentCell.setCellType(CellType.BLANK); - - endCellContent(state, null, text, currentCell, null); - - ++state.rowNum; - state.setHandler(parent); - } - - @Override - public void emitData(HandlerState state, IDataContent data) throws BirtException { - log.debug( "Creating row ", state.rowNum, " for data" ); - state.currentSheet.createRow( state.rowNum ); - - emitContent(state, data, data.getValue(), ( ! "inline".equals( getStyleProperty(data, StyleConstants.STYLE_DISPLAY, "block") ) ) ); - - Cell currentCell = state.currentSheet.getRow(state.rowNum).createCell( 0 ); - currentCell.setCellType(CellType.BLANK); - - endCellContent(state, null, data, currentCell, null); - - ++state.rowNum; - state.setHandler(parent); - } - - @Override - public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { - log.debug( "Creating row ", state.rowNum, " for label" ); - state.currentSheet.createRow( state.rowNum ); - - String labelText = ( label.getLabelText() != null ) ? label.getLabelText() : label.getText(); - emitContent(state,label,labelText, ( ! "inline".equals( getStyleProperty(label, StyleConstants.STYLE_DISPLAY, "block") ) )); - - Cell currentCell = state.currentSheet.getRow(state.rowNum).createCell( 0 ); - currentCell.setCellType(CellType.BLANK); - - endCellContent(state, null, label, currentCell, null); - - ++state.rowNum; - state.setHandler(parent); - } - - @Override - public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { - - log.debug( "Handling foreign content of type ", foreign.getRawType() ); - if ( IForeignContent.HTML_TYPE.equalsIgnoreCase( foreign.getRawType( ) ) ) - { - HTML2Content.html2Content( foreign ); - contentVisitor.visitChildren( foreign, null ); - } - - state.setHandler(parent); - } - - @Override - public void emitImage(HandlerState state, IImageContent image) throws BirtException { - log.debug( "Creating row ", state.rowNum, " for image" ); - state.currentSheet.createRow( state.rowNum ); - - recordImage(state, new Coordinate( state.rowNum, 0 ), image, true); - Cell currentCell = state.currentSheet.getRow(state.rowNum).createCell( 0 ); - currentCell.setCellType(CellType.BLANK); - - endCellContent(state, null, image, currentCell, null); - - ++state.rowNum; - state.setHandler(parent); - } - - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.ITextContent; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; +import org.eclipse.birt.report.engine.emitter.IContentEmitter; +import org.eclipse.birt.report.engine.layout.pdf.util.HTML2Content; + +import uk.co.spudsoft.birt.emitters.excel.Coordinate; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class TopLevelContentHandler extends CellContentHandler { + + public TopLevelContentHandler(IContentEmitter emitter, Logger log, IHandler parent) { + super(emitter, log, parent, null); + } + + + @Override + public void emitText(HandlerState state, ITextContent text) throws BirtException { + log.debug( "Creating row ", state.rowNum, " for text" ); + state.currentSheet.createRow( state.rowNum ); + + emitContent(state, text, text.getText(), ( ! "inline".equals( getStyleProperty(text, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + + Cell currentCell = state.currentSheet.getRow(state.rowNum).createCell( 0 ); + currentCell.setCellType(CellType.BLANK); + + endCellContent(state, null, text, currentCell, null); + + ++state.rowNum; + state.setHandler(parent); + } + + @Override + public void emitData(HandlerState state, IDataContent data) throws BirtException { + log.debug( "Creating row ", state.rowNum, " for data" ); + state.currentSheet.createRow( state.rowNum ); + + emitContent(state, data, data.getValue(), ( ! "inline".equals( getStyleProperty(data, StyleConstants.STYLE_DISPLAY, "block") ) ) ); + + Cell currentCell = state.currentSheet.getRow(state.rowNum).createCell( 0 ); + currentCell.setCellType(CellType.BLANK); + + endCellContent(state, null, data, currentCell, null); + + ++state.rowNum; + state.setHandler(parent); + } + + @Override + public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { + log.debug( "Creating row ", state.rowNum, " for label" ); + state.currentSheet.createRow( state.rowNum ); + + String labelText = ( label.getLabelText() != null ) ? label.getLabelText() : label.getText(); + emitContent(state,label,labelText, ( ! "inline".equals( getStyleProperty(label, StyleConstants.STYLE_DISPLAY, "block") ) )); + + Cell currentCell = state.currentSheet.getRow(state.rowNum).createCell( 0 ); + currentCell.setCellType(CellType.BLANK); + + endCellContent(state, null, label, currentCell, null); + + ++state.rowNum; + state.setHandler(parent); + } + + @Override + public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { + + log.debug( "Handling foreign content of type ", foreign.getRawType() ); + if ( IForeignContent.HTML_TYPE.equalsIgnoreCase( foreign.getRawType( ) ) ) + { + HTML2Content.html2Content( foreign ); + contentVisitor.visitChildren( foreign, null ); + } + + state.setHandler(parent); + } + + @Override + public void emitImage(HandlerState state, IImageContent image) throws BirtException { + log.debug( "Creating row ", state.rowNum, " for image" ); + state.currentSheet.createRow( state.rowNum ); + + recordImage(state, new Coordinate( state.rowNum, 0 ), image, true); + Cell currentCell = state.currentSheet.getRow(state.rowNum).createCell( 0 ); + currentCell.setCellType(CellType.BLANK); + + endCellContent(state, null, image, currentCell, null); + + ++state.rowNum; + state.setHandler(parent); + } + + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelListHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelListHandler.java index 353238191..863d963bb 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelListHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelListHandler.java @@ -1,154 +1,154 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import java.util.Stack; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IAutoTextContent; -import org.eclipse.birt.report.engine.content.IDataContent; -import org.eclipse.birt.report.engine.content.IForeignContent; -import org.eclipse.birt.report.engine.content.IImageContent; -import org.eclipse.birt.report.engine.content.ILabelContent; -import org.eclipse.birt.report.engine.content.IListBandContent; -import org.eclipse.birt.report.engine.content.IListContent; -import org.eclipse.birt.report.engine.content.IListGroupContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITextContent; -import org.eclipse.birt.report.engine.ir.ListGroupDesign; -import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants; - -import uk.co.spudsoft.birt.emitters.excel.BirtStyle; -import uk.co.spudsoft.birt.emitters.excel.EmitterServices; -import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class TopLevelListHandler extends AbstractRealListHandler { - - private Stack groupStarts; - - public TopLevelListHandler(Logger log,IHandler parent, IListContent list) { - super(log, parent, list); - } - - @Override - public void startList(HandlerState state, IListContent list) throws BirtException { - log.debug( "Call startList on ", this ); - super.startList(state, list); - String name = list.getName(); - if( ( name != null ) && ! name.isEmpty() ) { - state.sheetName = name; - } - - String password = EmitterServices.stringOption( state.getRenderOptions(), list, ExcelEmitter.SHEET_PASSWORD, null); - if( ( password != null ) && ! password.isEmpty() ) { - state.sheetPassword = password; - } - - BirtStyle birtStyle = new BirtStyle(list); - log.debug( "List Style: {}", birtStyle ); - } - - @Override - public void startTable(HandlerState state, ITableContent table) throws BirtException { - ++state.colNum; - state.setHandler(new NestedTableHandler(log, this, table, 1)); - state.getHandler().startTable(state, table); - } - - @Override - public void startListGroup(HandlerState state, IListGroupContent group) throws BirtException { - if( groupStarts == null ) { - groupStarts = new Stack(); - } - groupStarts.push(state.rowNum); - - - Object groupDesignObject = group.getGenerateBy(); - if( groupDesignObject instanceof ListGroupDesign ) { - ListGroupDesign groupDesign = (ListGroupDesign)groupDesignObject; - if( DesignChoiceConstants.PAGE_BREAK_BEFORE_ALWAYS.equals( groupDesign.getPageBreakBefore() ) - || DesignChoiceConstants.PAGE_BREAK_BEFORE_ALWAYS_EXCLUDING_FIRST.equals( groupDesign.getPageBreakBefore() ) - || DesignChoiceConstants.PAGE_BREAK_AFTER_ALWAYS.equals( groupDesign.getPageBreakAfter() ) - || DesignChoiceConstants.PAGE_BREAK_AFTER_ALWAYS_EXCLUDING_LAST.equals( groupDesign.getPageBreakAfter() ) - ) { - if( group.getTOC() != null ) { - state.sheetName = group.getTOC().toString(); - } - } - } - } - - @Override - public void startListBand(HandlerState state, IListBandContent band) throws BirtException { - super.startListBand(state, band); - } - - @Override - public void endListGroup(HandlerState state, IListGroupContent group) throws BirtException { - int start = groupStarts.pop(); - if( start < state.rowNum - 2 ) { - - boolean disableGrouping = false; - - // Report user props and context first - if( EmitterServices.booleanOption( state.getRenderOptions(), group, ExcelEmitter.DISABLE_GROUPING, false ) ) { - disableGrouping = true; - } - - if( ! disableGrouping ) { - state.currentSheet.groupRow(start, state.rowNum - 2); - } - } - } - - @Override - public void emitText(HandlerState state, ITextContent text) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitText(state, text); - } - - @Override - public void emitData(HandlerState state, IDataContent data) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitData(state, data); - } - - @Override - public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitLabel(state, label); - } - - @Override - public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitAutoText(state, autoText); - } - - @Override - public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitForeign(state, foreign); - } - - @Override - public void emitImage(HandlerState state, IImageContent image) throws BirtException { - state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); - state.getHandler().emitImage(state, image); - } - - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import java.util.Stack; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IAutoTextContent; +import org.eclipse.birt.report.engine.content.IDataContent; +import org.eclipse.birt.report.engine.content.IForeignContent; +import org.eclipse.birt.report.engine.content.IImageContent; +import org.eclipse.birt.report.engine.content.ILabelContent; +import org.eclipse.birt.report.engine.content.IListBandContent; +import org.eclipse.birt.report.engine.content.IListContent; +import org.eclipse.birt.report.engine.content.IListGroupContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITextContent; +import org.eclipse.birt.report.engine.ir.ListGroupDesign; +import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants; + +import uk.co.spudsoft.birt.emitters.excel.BirtStyle; +import uk.co.spudsoft.birt.emitters.excel.EmitterServices; +import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class TopLevelListHandler extends AbstractRealListHandler { + + private Stack groupStarts; + + public TopLevelListHandler(Logger log,IHandler parent, IListContent list) { + super(log, parent, list); + } + + @Override + public void startList(HandlerState state, IListContent list) throws BirtException { + log.debug( "Call startList on ", this ); + super.startList(state, list); + String name = list.getName(); + if( ( name != null ) && ! name.isEmpty() ) { + state.sheetName = name; + } + + String password = EmitterServices.stringOption( state.getRenderOptions(), list, ExcelEmitter.SHEET_PASSWORD, null); + if( ( password != null ) && ! password.isEmpty() ) { + state.sheetPassword = password; + } + + BirtStyle birtStyle = new BirtStyle(list); + log.debug( "List Style: {}", birtStyle ); + } + + @Override + public void startTable(HandlerState state, ITableContent table) throws BirtException { + ++state.colNum; + state.setHandler(new NestedTableHandler(log, this, table, 1)); + state.getHandler().startTable(state, table); + } + + @Override + public void startListGroup(HandlerState state, IListGroupContent group) throws BirtException { + if( groupStarts == null ) { + groupStarts = new Stack(); + } + groupStarts.push(state.rowNum); + + + Object groupDesignObject = group.getGenerateBy(); + if( groupDesignObject instanceof ListGroupDesign ) { + ListGroupDesign groupDesign = (ListGroupDesign)groupDesignObject; + if( DesignChoiceConstants.PAGE_BREAK_BEFORE_ALWAYS.equals( groupDesign.getPageBreakBefore() ) + || DesignChoiceConstants.PAGE_BREAK_BEFORE_ALWAYS_EXCLUDING_FIRST.equals( groupDesign.getPageBreakBefore() ) + || DesignChoiceConstants.PAGE_BREAK_AFTER_ALWAYS.equals( groupDesign.getPageBreakAfter() ) + || DesignChoiceConstants.PAGE_BREAK_AFTER_ALWAYS_EXCLUDING_LAST.equals( groupDesign.getPageBreakAfter() ) + ) { + if( group.getTOC() != null ) { + state.sheetName = group.getTOC().toString(); + } + } + } + } + + @Override + public void startListBand(HandlerState state, IListBandContent band) throws BirtException { + super.startListBand(state, band); + } + + @Override + public void endListGroup(HandlerState state, IListGroupContent group) throws BirtException { + int start = groupStarts.pop(); + if( start < state.rowNum - 2 ) { + + boolean disableGrouping = false; + + // Report user props and context first + if( EmitterServices.booleanOption( state.getRenderOptions(), group, ExcelEmitter.DISABLE_GROUPING, false ) ) { + disableGrouping = true; + } + + if( ! disableGrouping ) { + state.currentSheet.groupRow(start, state.rowNum - 2); + } + } + } + + @Override + public void emitText(HandlerState state, ITextContent text) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitText(state, text); + } + + @Override + public void emitData(HandlerState state, IDataContent data) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitData(state, data); + } + + @Override + public void emitLabel(HandlerState state, ILabelContent label) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitLabel(state, label); + } + + @Override + public void emitAutoText(HandlerState state, IAutoTextContent autoText) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitAutoText(state, autoText); + } + + @Override + public void emitForeign(HandlerState state, IForeignContent foreign) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitForeign(state, foreign); + } + + @Override + public void emitImage(HandlerState state, IImageContent image) throws BirtException { + state.setHandler(new TopLevelContentHandler(state.getEmitter(), log, this)); + state.getHandler().emitImage(state, image); + } + + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableCellHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableCellHandler.java index 7ef7a23f4..038d916bd 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableCellHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableCellHandler.java @@ -1,27 +1,27 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.emitter.IContentEmitter; - -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class TopLevelTableCellHandler extends AbstractRealTableCellHandler { - - public TopLevelTableCellHandler(IContentEmitter emitter, Logger log, IHandler parent, ICellContent cell) { - super(emitter, log, parent, cell); - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.emitter.IContentEmitter; + +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class TopLevelTableCellHandler extends AbstractRealTableCellHandler { + + public TopLevelTableCellHandler(IContentEmitter emitter, Logger log, IHandler parent, ICellContent cell) { + super(emitter, log, parent, cell); + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableHandler.java index 2952d60e6..2db3d26df 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableHandler.java @@ -1,131 +1,131 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import java.util.Stack; - -import org.apache.poi.ss.util.CellRangeAddress; -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.IRowContent; -import org.eclipse.birt.report.engine.content.ITableContent; -import org.eclipse.birt.report.engine.content.ITableGroupContent; -import org.eclipse.birt.report.engine.ir.TableGroupDesign; -import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants; - -import uk.co.spudsoft.birt.emitters.excel.EmitterServices; -import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class TopLevelTableHandler extends AbstractRealTableHandler { - - private Stack groupStarts; - - public TopLevelTableHandler(Logger log,IHandler parent, ITableContent table) { - super(log, parent, table); - } - - @Override - public void startTable(HandlerState state, ITableContent table) throws BirtException { - state.colNum = 0; - super.startTable(state, table); - String name = table.getName(); - if( ( name != null ) && ! name.isEmpty() ) { - state.sheetName = name; - } - - String password = EmitterServices.stringOption( state.getRenderOptions(), table, ExcelEmitter.SHEET_PASSWORD, null); - if( ( password != null ) && ! password.isEmpty() ) { - state.sheetPassword = password; - } - if( EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.GROUP_SUMMARY_HEADER, false ) ) { - state.currentSheet.setRowSumsBelow( false ); - } - } - - @Override - public void endTable(HandlerState state, ITableContent table) throws BirtException { - super.endTable(state, table); - - boolean autoFilter = EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.AUTO_FILTER, false ); - if( autoFilter ) { - log.debug( "Applying auto filter to [", this.startRow, ",", this.startCol, "] - [", this.endDetailsRow, ",", state.colNum - 1, "]" ); - CellRangeAddress wholeTable = new CellRangeAddress(startRow, endDetailsRow, startCol, state.colNum - 1); - state.currentSheet.setAutoFilter(wholeTable); - } - - boolean blankRowAfterTopLevelTable = EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.BLANK_ROW_AFTER_TOP_LEVEL_TABLE, false ); - if( blankRowAfterTopLevelTable ) { - ++state.rowNum; - } - - state.setHandler(parent); - } - - @Override - public void startRow(HandlerState state, IRowContent row) throws BirtException { - state.setHandler(new TopLevelTableRowHandler(log, this, row)); - state.getHandler().startRow(state, row); - } - - @Override - public void startTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { - log.debug( "startTableGroup @" + state.rowNum + " called " + group.getBookmark() ); - if( groupStarts == null ) { - groupStarts = new Stack(); - } - groupStarts.push(state.rowNum); - - Object groupDesignObject = group.getGenerateBy(); - if( groupDesignObject instanceof TableGroupDesign ) { - TableGroupDesign groupDesign = (TableGroupDesign)groupDesignObject; - if( DesignChoiceConstants.PAGE_BREAK_BEFORE_ALWAYS.equals( groupDesign.getPageBreakBefore() ) - || DesignChoiceConstants.PAGE_BREAK_BEFORE_ALWAYS_EXCLUDING_FIRST.equals( groupDesign.getPageBreakBefore() ) - || DesignChoiceConstants.PAGE_BREAK_AFTER_ALWAYS.equals( groupDesign.getPageBreakAfter() ) - || DesignChoiceConstants.PAGE_BREAK_AFTER_ALWAYS_EXCLUDING_LAST.equals( groupDesign.getPageBreakAfter() ) - ) { - if( group.getTOC() != null ) { - state.sheetName = group.getTOC().toString(); - } - } - } - - } - - @Override - public void endTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { - log.debug( "endTableGroup @" + state.rowNum + " called " + group.getBookmark() ); - int start = groupStarts.pop(); - if( start < state.rowNum - 1 ) { - - boolean disableGrouping = false; - - // Report user props and context first - if( EmitterServices.booleanOption( state.getRenderOptions(), group, ExcelEmitter.DISABLE_GROUPING, false ) ) { - disableGrouping = true; - } - - if( ! disableGrouping ) { - if( state.currentSheet.getRowSumsBelow() ) { - log.debug( "TableGroup of rows below ", start, " - ", state.rowNum - 2 ); - state.currentSheet.groupRow(start, state.rowNum - 2); - } else { - log.debug( "TableGroup of rows above ", start + 1, " - ", state.rowNum - 1 ); - state.currentSheet.groupRow(start + 1, state.rowNum - 1); - } - } - } - } - -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import java.util.Stack; + +import org.apache.poi.ss.util.CellRangeAddress; +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.IRowContent; +import org.eclipse.birt.report.engine.content.ITableContent; +import org.eclipse.birt.report.engine.content.ITableGroupContent; +import org.eclipse.birt.report.engine.ir.TableGroupDesign; +import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants; + +import uk.co.spudsoft.birt.emitters.excel.EmitterServices; +import uk.co.spudsoft.birt.emitters.excel.ExcelEmitter; +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class TopLevelTableHandler extends AbstractRealTableHandler { + + private Stack groupStarts; + + public TopLevelTableHandler(Logger log,IHandler parent, ITableContent table) { + super(log, parent, table); + } + + @Override + public void startTable(HandlerState state, ITableContent table) throws BirtException { + state.colNum = 0; + super.startTable(state, table); + String name = table.getName(); + if( ( name != null ) && ! name.isEmpty() ) { + state.sheetName = name; + } + + String password = EmitterServices.stringOption( state.getRenderOptions(), table, ExcelEmitter.SHEET_PASSWORD, null); + if( ( password != null ) && ! password.isEmpty() ) { + state.sheetPassword = password; + } + if( EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.GROUP_SUMMARY_HEADER, false ) ) { + state.currentSheet.setRowSumsBelow( false ); + } + } + + @Override + public void endTable(HandlerState state, ITableContent table) throws BirtException { + super.endTable(state, table); + + boolean autoFilter = EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.AUTO_FILTER, false ); + if( autoFilter ) { + log.debug( "Applying auto filter to [", this.startRow, ",", this.startCol, "] - [", this.endDetailsRow, ",", state.colNum - 1, "]" ); + CellRangeAddress wholeTable = new CellRangeAddress(startRow, endDetailsRow, startCol, state.colNum - 1); + state.currentSheet.setAutoFilter(wholeTable); + } + + boolean blankRowAfterTopLevelTable = EmitterServices.booleanOption( state.getRenderOptions(), table, ExcelEmitter.BLANK_ROW_AFTER_TOP_LEVEL_TABLE, false ); + if( blankRowAfterTopLevelTable ) { + ++state.rowNum; + } + + state.setHandler(parent); + } + + @Override + public void startRow(HandlerState state, IRowContent row) throws BirtException { + state.setHandler(new TopLevelTableRowHandler(log, this, row)); + state.getHandler().startRow(state, row); + } + + @Override + public void startTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { + log.debug( "startTableGroup @" + state.rowNum + " called " + group.getBookmark() ); + if( groupStarts == null ) { + groupStarts = new Stack(); + } + groupStarts.push(state.rowNum); + + Object groupDesignObject = group.getGenerateBy(); + if( groupDesignObject instanceof TableGroupDesign ) { + TableGroupDesign groupDesign = (TableGroupDesign)groupDesignObject; + if( DesignChoiceConstants.PAGE_BREAK_BEFORE_ALWAYS.equals( groupDesign.getPageBreakBefore() ) + || DesignChoiceConstants.PAGE_BREAK_BEFORE_ALWAYS_EXCLUDING_FIRST.equals( groupDesign.getPageBreakBefore() ) + || DesignChoiceConstants.PAGE_BREAK_AFTER_ALWAYS.equals( groupDesign.getPageBreakAfter() ) + || DesignChoiceConstants.PAGE_BREAK_AFTER_ALWAYS_EXCLUDING_LAST.equals( groupDesign.getPageBreakAfter() ) + ) { + if( group.getTOC() != null ) { + state.sheetName = group.getTOC().toString(); + } + } + } + + } + + @Override + public void endTableGroup(HandlerState state, ITableGroupContent group) throws BirtException { + log.debug( "endTableGroup @" + state.rowNum + " called " + group.getBookmark() ); + int start = groupStarts.pop(); + if( start < state.rowNum - 1 ) { + + boolean disableGrouping = false; + + // Report user props and context first + if( EmitterServices.booleanOption( state.getRenderOptions(), group, ExcelEmitter.DISABLE_GROUPING, false ) ) { + disableGrouping = true; + } + + if( ! disableGrouping ) { + if( state.currentSheet.getRowSumsBelow() ) { + log.debug( "TableGroup of rows below ", start, " - ", state.rowNum - 2 ); + state.currentSheet.groupRow(start, state.rowNum - 2); + } else { + log.debug( "TableGroup of rows above ", start + 1, " - ", state.rowNum - 1 ); + state.currentSheet.groupRow(start + 1, state.rowNum - 1); + } + } + } + } + +} diff --git a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableRowHandler.java b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableRowHandler.java index 86e2ebdd2..303b415a1 100644 --- a/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableRowHandler.java +++ b/spudsoft-birt-emitter-src/uk/co/spudsoft/birt/emitters/excel/handlers/TopLevelTableRowHandler.java @@ -1,45 +1,45 @@ -/************************************************************************************* - * Copyright (c) 2011, 2012, 2013 James Talbut. - * jim-emitters@spudsoft.co.uk - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * James Talbut - Initial implementation. - ************************************************************************************/ - -package uk.co.spudsoft.birt.emitters.excel.handlers; - -import org.eclipse.birt.core.exception.BirtException; -import org.eclipse.birt.report.engine.content.ICellContent; -import org.eclipse.birt.report.engine.content.IRowContent; - -import uk.co.spudsoft.birt.emitters.excel.HandlerState; -import uk.co.spudsoft.birt.emitters.excel.framework.Logger; - -public class TopLevelTableRowHandler extends AbstractRealTableRowHandler { - - public TopLevelTableRowHandler(Logger log, IHandler parent, IRowContent row) { - super(log, parent, row, 0); - } - - @Override - public void startRow(HandlerState state, IRowContent row) throws BirtException { - super.startRow(state, row); - state.rowOffset = 0; - } - - @Override - public void startCell(HandlerState state, ICellContent cell) throws BirtException { - state.setHandler(new TopLevelTableCellHandler(state.getEmitter(), log, this, cell)); - state.getHandler().startCell(state, cell); - } - - @Override - protected boolean isNested() { - return false; - } -} +/************************************************************************************* + * Copyright (c) 2011, 2012, 2013 James Talbut. + * jim-emitters@spudsoft.co.uk + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * James Talbut - Initial implementation. + ************************************************************************************/ + +package uk.co.spudsoft.birt.emitters.excel.handlers; + +import org.eclipse.birt.core.exception.BirtException; +import org.eclipse.birt.report.engine.content.ICellContent; +import org.eclipse.birt.report.engine.content.IRowContent; + +import uk.co.spudsoft.birt.emitters.excel.HandlerState; +import uk.co.spudsoft.birt.emitters.excel.framework.Logger; + +public class TopLevelTableRowHandler extends AbstractRealTableRowHandler { + + public TopLevelTableRowHandler(Logger log, IHandler parent, IRowContent row) { + super(log, parent, row, 0); + } + + @Override + public void startRow(HandlerState state, IRowContent row) throws BirtException { + super.startRow(state, row); + state.rowOffset = 0; + } + + @Override + public void startCell(HandlerState state, ICellContent cell) throws BirtException { + state.setHandler(new TopLevelTableCellHandler(state.getEmitter(), log, this, cell)); + state.getHandler().startCell(state, cell); + } + + @Override + protected boolean isNested() { + return false; + } +} diff --git a/src/net/datenwerke/rs/JerseyConfig.java b/src/net/datenwerke/rs/JerseyConfig.java new file mode 100644 index 000000000..0595121c1 --- /dev/null +++ b/src/net/datenwerke/rs/JerseyConfig.java @@ -0,0 +1,23 @@ +package net.datenwerke.rs; + +import javax.inject.Inject; + +import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.jersey.server.ResourceConfig; +import org.jvnet.hk2.guice.bridge.api.GuiceBridge; +import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; + +public class JerseyConfig extends ResourceConfig { + + @Inject + public JerseyConfig(ServiceLocator locator) { + packages("net.datenwerke.rs.saiku.server.rest", "net.datenwerke.rs.legacysaiku.server.rest"); + + GuiceBridge.getGuiceBridge().initializeGuiceBridge(locator); + // add your Guice modules. +// Injector injector = Guice.createInjector(new GuiceModule()); + GuiceIntoHK2Bridge guiceBridge = locator.getService(GuiceIntoHK2Bridge.class); + guiceBridge.bridgeGuiceInjector(ReportServerServiceConfig.injector); + + } +} \ No newline at end of file diff --git a/src/net/datenwerke/rs/ReportServerServiceConfig.java b/src/net/datenwerke/rs/ReportServerServiceConfig.java index 3daaa9430..d15c8f8c3 100755 --- a/src/net/datenwerke/rs/ReportServerServiceConfig.java +++ b/src/net/datenwerke/rs/ReportServerServiceConfig.java @@ -16,10 +16,11 @@ import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Module; +import com.google.inject.Scopes; import com.google.inject.persist.PersistFilter; import com.google.inject.servlet.ServletModule; -import com.sun.jersey.api.json.JSONConfiguration; -import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; + +import org.glassfish.jersey.servlet.ServletContainer; import net.datenwerke.async.DwAsyncModule; import net.datenwerke.dbpool.DbPoolModule; @@ -244,12 +245,14 @@ public class ReportServerServiceConfig extends DwGwtFrameworkBase { private final Logger logger = LoggerFactory.getLogger(getClass().getName()); - public static final String CODE_VERSION = "2022-08-18-14-06-26"; + public static final String CODE_VERSION = "2022-08-29-15-57-59"; public static final String ENTERPRISE_MODULE_LOCATION = "net.datenwerke.rsenterprise.main.service.RsEnterpriseModule"; private static final String ENTERPRISE_MODULE_LOAD_MODULE_METHOD = "getEnterpriseModules"; private static final String ENTERPRISE_MODULE_CONFIG_SERVLETS_METHOD = "configureServlets"; private static final String ENTERPRISE_CHECK_SERVLET = "net.datenwerke.rsenterprise.main.server.EnterpriseCheckRpcServiceImpl"; + + static Injector injector; static { LogSetupHelper.InitRsLogging(); @@ -297,6 +300,8 @@ private Injector doGetInjector() { injector.injectMembers(this); injectorInitialized(); + + ReportServerServiceConfig.injector = injector; return injector; } @@ -547,10 +552,15 @@ protected void configureServlets() { serve(BASE_URL + "trace").with(TracerServlet.class); serve(BASE_URL + "version").with(VersionInfoServlet.class); - - Map jerseyParams = new HashMap(); - jerseyParams.put(JSONConfiguration.FEATURE_POJO_MAPPING, "true"); - serve(BASE_URL + "rest/*").with(GuiceContainer.class, jerseyParams); + + bind(ServletContainer.class).in(Scopes.SINGLETON); + Map params = new HashMap<>(); + params.put("javax.ws.rs.Application", "net.datenwerke.rs.JerseyConfig"); + serve(BASE_URL + "rest/*").with(ServletContainer.class, params); + +// Map jerseyParams = new HashMap(); +// jerseyParams.put(JSONConfiguration.FEATURE_POJO_MAPPING, "true"); +// serve(BASE_URL + "rest/*").with(GuiceContainer.class, jerseyParams); } }; } diff --git a/src/net/datenwerke/rs/amazons3/service/amazons3/hooker/ScheduleConfigAsAmazonS3DatasinkHooker.java b/src/net/datenwerke/rs/amazons3/service/amazons3/hooker/ScheduleConfigAsAmazonS3DatasinkHooker.java index 70c9f3dcc..40d3bdb11 100644 --- a/src/net/datenwerke/rs/amazons3/service/amazons3/hooker/ScheduleConfigAsAmazonS3DatasinkHooker.java +++ b/src/net/datenwerke/rs/amazons3/service/amazons3/hooker/ScheduleConfigAsAmazonS3DatasinkHooker.java @@ -67,7 +67,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setAmazonS3DatasinkDto( (AmazonS3DatasinkDto) dtoServiceProvider.get().createDto(action.getAmazonS3Datasink())); diff --git a/src/net/datenwerke/rs/box/service/box/hooker/ScheduleConfigAsBoxDatasinkHooker.java b/src/net/datenwerke/rs/box/service/box/hooker/ScheduleConfigAsBoxDatasinkHooker.java index 191e72f60..bd285c8a9 100644 --- a/src/net/datenwerke/rs/box/service/box/hooker/ScheduleConfigAsBoxDatasinkHooker.java +++ b/src/net/datenwerke/rs/box/service/box/hooker/ScheduleConfigAsBoxDatasinkHooker.java @@ -67,7 +67,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setBoxDatasinkDto((BoxDatasinkDto) dtoServiceProvider.get().createDto(action.getBoxDatasink())); if (null == info.getBoxDatasinkDto()) diff --git a/src/net/datenwerke/rs/dropbox/service/dropbox/hooker/ScheduleConfigAsDropboxDatasinkHooker.java b/src/net/datenwerke/rs/dropbox/service/dropbox/hooker/ScheduleConfigAsDropboxDatasinkHooker.java index 67b25f34f..9d2a07f73 100644 --- a/src/net/datenwerke/rs/dropbox/service/dropbox/hooker/ScheduleConfigAsDropboxDatasinkHooker.java +++ b/src/net/datenwerke/rs/dropbox/service/dropbox/hooker/ScheduleConfigAsDropboxDatasinkHooker.java @@ -67,7 +67,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setDropboxDatasinkDto((DropboxDatasinkDto) dtoServiceProvider.get().createDto(action.getDropboxDatasink())); if (null == info.getDropboxDatasinkDto()) diff --git a/src/net/datenwerke/rs/emaildatasink/service/emaildatasink/hooker/ScheduleConfigAsEmailDatasinkHooker.java b/src/net/datenwerke/rs/emaildatasink/service/emaildatasink/hooker/ScheduleConfigAsEmailDatasinkHooker.java index 222fd7319..b57e77e38 100644 --- a/src/net/datenwerke/rs/emaildatasink/service/emaildatasink/hooker/ScheduleConfigAsEmailDatasinkHooker.java +++ b/src/net/datenwerke/rs/emaildatasink/service/emaildatasink/hooker/ScheduleConfigAsEmailDatasinkHooker.java @@ -71,7 +71,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setSubject(action.getSubject()); info.setMessage(action.getMessage()); info.setName(action.getName()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setEmailDatasinkDto((EmailDatasinkDto) dtoServiceProvider.get().createDto(action.getEmailDatasink())); if (null == info.getEmailDatasinkDto()) diff --git a/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsFtpFileHooker.java b/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsFtpFileHooker.java index f6b72f787..765b342d5 100644 --- a/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsFtpFileHooker.java +++ b/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsFtpFileHooker.java @@ -67,7 +67,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setFtpDatasinkDto((FtpDatasinkDto) dtoServiceProvider.get().createDto(action.getFtpDatasink())); if (null == info.getFtpDatasinkDto()) diff --git a/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsFtpsFileHooker.java b/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsFtpsFileHooker.java index c2530b925..a365f831a 100644 --- a/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsFtpsFileHooker.java +++ b/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsFtpsFileHooker.java @@ -68,7 +68,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setFtpsDatasinkDto((FtpsDatasinkDto) dtoServiceProvider.get().createDto(action.getFtpsDatasink())); if (null == info.getFtpsDatasinkDto()) diff --git a/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsSftpFileHooker.java b/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsSftpFileHooker.java index 9a2049f9f..25dbe3c47 100644 --- a/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsSftpFileHooker.java +++ b/src/net/datenwerke/rs/ftp/service/ftp/hooker/ScheduleConfigAsSftpFileHooker.java @@ -67,7 +67,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setSftpDatasinkDto((SftpDatasinkDto) dtoServiceProvider.get().createDto(action.getSftpDatasink())); if (null == info.getSftpDatasinkDto()) diff --git a/src/net/datenwerke/rs/googledrive/service/googledrive/hooker/ScheduleConfigAsGoogleDriveDatasinkHooker.java b/src/net/datenwerke/rs/googledrive/service/googledrive/hooker/ScheduleConfigAsGoogleDriveDatasinkHooker.java index 8a99f0f44..643dccbb5 100644 --- a/src/net/datenwerke/rs/googledrive/service/googledrive/hooker/ScheduleConfigAsGoogleDriveDatasinkHooker.java +++ b/src/net/datenwerke/rs/googledrive/service/googledrive/hooker/ScheduleConfigAsGoogleDriveDatasinkHooker.java @@ -69,7 +69,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setGoogleDriveDatasinkDto( (GoogleDriveDatasinkDto) dtoServiceProvider.get().createDto(action.getGoogleDriveDatasink())); diff --git a/src/net/datenwerke/rs/legacysaiku/server/rest/SaikuRestModule.java b/src/net/datenwerke/rs/legacysaiku/server/rest/SaikuRestModule.java index 4d0c6ffe4..e7e3a9beb 100644 --- a/src/net/datenwerke/rs/legacysaiku/server/rest/SaikuRestModule.java +++ b/src/net/datenwerke/rs/legacysaiku/server/rest/SaikuRestModule.java @@ -1,7 +1,8 @@ package net.datenwerke.rs.legacysaiku.server.rest; +import org.glassfish.jersey.server.ResourceConfig; + import com.google.inject.AbstractModule; -import com.sun.jersey.api.core.ClassNamesResourceConfig; import net.datenwerke.rs.legacysaiku.server.rest.resources.BasicRepositoryResource; import net.datenwerke.rs.legacysaiku.server.rest.resources.BasicRepositoryResource2; @@ -21,7 +22,7 @@ protected void configure() { /* register rest resources */ // ResourceConfig rc = new PackagesResourceConfig(this.getClass().getPackage().getName()); - ClassNamesResourceConfig cnrc = new ClassNamesResourceConfig(BasicRepositoryResource.class, + ResourceConfig cnrc = new ResourceConfig(BasicRepositoryResource.class, BasicRepositoryResource2.class, BasicTagRepositoryResource.class, DataSourceResource.class, ExporterResource.class, OlapDiscoverResource.class, QueryResource.class, SessionResource.class, StatisticsResource.class, SaikuI18nResource.class); diff --git a/src/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/hooker/ScheduleConfigAsLocalFileSystemHooker.java b/src/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/hooker/ScheduleConfigAsLocalFileSystemHooker.java index 0a120ae07..704cd0065 100644 --- a/src/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/hooker/ScheduleConfigAsLocalFileSystemHooker.java +++ b/src/net/datenwerke/rs/localfsdatasink/service/localfsdatasink/hooker/ScheduleConfigAsLocalFileSystemHooker.java @@ -69,7 +69,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setLocalFileSystemDatasinkDto( (LocalFileSystemDatasinkDto) dtoServiceProvider.get().createDto(action.getLocalFileSystemDatasink())); diff --git a/src/net/datenwerke/rs/onedrive/service/onedrive/hooker/ScheduleConfigAsOneDriveDatasinkHooker.java b/src/net/datenwerke/rs/onedrive/service/onedrive/hooker/ScheduleConfigAsOneDriveDatasinkHooker.java index 09f322665..8200c9dfa 100644 --- a/src/net/datenwerke/rs/onedrive/service/onedrive/hooker/ScheduleConfigAsOneDriveDatasinkHooker.java +++ b/src/net/datenwerke/rs/onedrive/service/onedrive/hooker/ScheduleConfigAsOneDriveDatasinkHooker.java @@ -66,7 +66,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setOneDriveDatasinkDto( (OneDriveDatasinkDto) dtoServiceProvider.get().createDto(action.getOneDriveDatasink())); diff --git a/src/net/datenwerke/rs/saiku/server/rest/SaikuRestModule.java b/src/net/datenwerke/rs/saiku/server/rest/SaikuRestModule.java index 4dec829ec..e5cd70b28 100755 --- a/src/net/datenwerke/rs/saiku/server/rest/SaikuRestModule.java +++ b/src/net/datenwerke/rs/saiku/server/rest/SaikuRestModule.java @@ -1,12 +1,11 @@ package net.datenwerke.rs.saiku.server.rest; +import org.glassfish.jersey.server.ResourceConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.inject.AbstractModule; -import com.sun.jersey.api.core.ClassNamesResourceConfig; -import net.datenwerke.rs.saiku.server.rest.resources.AdminResource; import net.datenwerke.rs.saiku.server.rest.resources.BasicRepositoryResource2; import net.datenwerke.rs.saiku.server.rest.resources.DataSourceResource; import net.datenwerke.rs.saiku.server.rest.resources.ExporterResource; @@ -28,7 +27,7 @@ protected void configure() { /* register rest resources */ // ResourceConfig rc = new PackagesResourceConfig(this.getClass().getPackage().getName()); - ClassNamesResourceConfig cnrc = new ClassNamesResourceConfig(AdminResource.class, BasicRepositoryResource2.class, + ResourceConfig cnrc = new ResourceConfig(BasicRepositoryResource2.class, DataSourceResource.class, ExporterResource.class, FilterRepositoryResource.class, InfoResource.class, License.class, OlapDiscoverResource.class, Query2Resource.class, SessionResource.class, SaikuI18nResource.class, StatisticsResource.class); diff --git a/src/net/datenwerke/rs/saiku/server/rest/resources/AdminResource.java b/src/net/datenwerke/rs/saiku/server/rest/resources/AdminResource.java deleted file mode 100644 index f51321acd..000000000 --- a/src/net/datenwerke/rs/saiku/server/rest/resources/AdminResource.java +++ /dev/null @@ -1,693 +0,0 @@ -/* - * Copyright 2015 OSBI Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.datenwerke.rs.saiku.server.rest.resources; - -import java.io.InputStream; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.StreamingOutput; - -import org.saiku.database.dto.SaikuUser; - -import com.sun.jersey.core.header.FormDataContentDisposition; - -import net.datenwerke.rs.saiku.server.rest.objects.DataSourceMapper; - -/** - * AdminResource for the Saiku 3.0+ Admin console - */ -@Path("/saiku/admin") -public class AdminResource { - -// private DatasourceService datasourceService; -// -// private UserService userService; -// private static final Logger log = LoggerFactory.getLogger(DataSourceResource.class); -// private OlapDiscoverService olapDiscoverService; -// private LogExtractor logExtractor; -// -// public LogExtractor getLogExtractor() { -// return logExtractor; -// } -// -// public void setLogExtractor(LogExtractor logExtractor) { -// this.logExtractor = logExtractor; -// } -// -// public void setOlapDiscoverService(OlapDiscoverService olapDiscoverService) { -// this.olapDiscoverService = olapDiscoverService; -// } -// -// public void setDatasourceService(DatasourceService ds) { -// datasourceService = ds; -// } -// -// public void setUserService(UserService us) { -// userService = us; -// } -// -// -// private IDatasourceManager repositoryDatasourceManager; -// -// public IDatasourceManager getRepositoryDatasourceManager() { -// return repositoryDatasourceManager; -// } -// -// public void setRepositoryDatasourceManager( -// IDatasourceManager repositoryDatasourceManager) { -// this.repositoryDatasourceManager = repositoryDatasourceManager; -// } - /** - * Get all the available data sources on the platform. - * - * @return A response containing a list of datasources. - */ - @GET - @Produces({ "application/json" }) - @Path("/datasources") -// @ReturnType("java.lang.List") - public Response getAvailableDataSources() { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// List l = new ArrayList<>(); -// try { -// for (SaikuDatasource d : datasourceService.getDatasources().values()) { -// l.add(new DataSourceMapper(d)); -// } -// return Response.ok().entity(l).build(); -// } catch (SaikuServiceException e) { -// log.error(this.getClass().getName(), e); -// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getLocalizedMessage()).type("text/plain").build(); -// } - throw new RuntimeException("not implemented"); - } - - /** - * Update a specific Saiku data source. - * - * @param json The Json data source object - * @param id The datasource id. - * @return A response containing the datasource. - */ - @PUT - @Produces({ "application/json" }) - @Consumes({ "application/json" }) - @Path("/datasources/{id}") -// @ReturnType("org.saiku.web.rest.objects.DataSourceMapper") - public Response updateDatasource(DataSourceMapper json, @PathParam("id") String id) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// -// try { -// datasourceService.addDatasource( json.toSaikuDataSource(), true ); -// return Response.ok().type("application/json").entity(json).build(); -// } -// catch (Exception e){ -// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getLocalizedMessage()) -// .type("text/plain").build(); -// } - throw new RuntimeException("not implemented"); - } - - /** - * Refresh a Saiku data source. - * - * @param id The data source id. - * @return A response containing the data source definition. - */ - @GET - @Produces({ "application/json" }) - @Path("/datasources/{id}/refresh") -// @ReturnType("java.util.List") - public Response refreshDatasource(@PathParam("id") String id) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// -// try { -// olapDiscoverService.refreshConnection(id); -// return Response.ok().entity(olapDiscoverService.getConnection(id)).type("application/json").build(); -// } catch (Exception e) { -// log.error(this.getClass().getName(), e); -// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getLocalizedMessage()) -// .type("text/plain").build(); -// } - throw new RuntimeException("not implemented"); - - } - - /** - * Create a data source on the Saiku server. - * - * @param json The json data source object - * @return A response containing the data source object - */ - @POST - @Produces({ "application/json" }) - @Consumes({ "application/json" }) - @Path("/datasources") -// @ReturnType("org.saiku.web.rest.objects.DataSourceMapper") - public Response createDatasource(DataSourceMapper json) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// -// try { -// datasourceService.addDatasource(json.toSaikuDataSource(), false); -// return Response.ok().entity(json).type("application/json").build(); -// } catch (Exception e) { -// log.error("Error adding data source", e); -// return Response.serverError().status(Response.Status.INTERNAL_SERVER_ERROR) -// .entity(e.getLocalizedMessage()) -// .type("text/plain").build(); -// } - throw new RuntimeException("not implemented"); - } - - /** - * Delete data source from the Saiku server - * - * @param id The data source ID - * @return A response containing a list of data sources remaining on the - * platform. - */ - @DELETE - @Path("/datasources/{id}") - public Response deleteDatasource(@PathParam("id") String id) { -// -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// datasourceService.removeDatasource(id); -// return Response.ok().type("application/json").entity(datasourceService.getDatasources()).build(); - throw new RuntimeException("not implemented"); - } - - /** - * Get all the available schema. - * - * @return A list of schema - */ - @GET - @Produces({ "application/json" }) - @Path("/schema") -// @ReturnType("java.util.List") - public Response getAvailableSchema() { -// -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// return Response.ok().entity(datasourceService.getAvailableSchema()).build(); - throw new RuntimeException("not implemented"); - } - - /** - * Upload a new schema to the Saiku server. - * - * @param is Input stream (file form data param) - * @param detail Detail (file form data param) - * @param name Schema name - * @param id Schema id - * @return A response containing a list of available schema. - */ - @PUT - @Produces({ "application/json" }) - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Path("/schema/{id}") -// @ReturnType("java.util.List") - public Response uploadSchemaPut(InputStream is, FormDataContentDisposition detail, String name, - @PathParam("id") String id) { -// public Response uploadSchemaPut(@FormDataParam("file") InputStream is, @FormDataParam("file") FormDataContentDisposition detail, -// @FormDataParam("name") String name, @PathParam("id") String id) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// String path = "/datasources/" + name + ".xml"; -// String schema = getStringFromInputStream(is); -// try { -// datasourceService.addSchema(schema, path, name); -// return Response.ok().entity(datasourceService.getAvailableSchema()).build(); -// } catch (Exception e) { -// log.error("Error uploading schema: "+name, e); -// return Response.serverError().status(Response.Status.INTERNAL_SERVER_ERROR) -// .entity(e.getLocalizedMessage()) -// .type("text/plain").build(); -// } - throw new RuntimeException("not implemented"); - - } - - /** - * Upload new schema to the Saiku server - * - * @param is Input stream (file form data param) - * @param detail Detail (file form data param) - * @param name Schema name - * @param id Schema id - * @return A response containing a list of available schema. - */ - @POST - @Produces({ "application/json" }) - @Consumes("multipart/form-data") - @Path("/schema/{id}") -// @ReturnType("java.util.List") - public Response uploadSchema(InputStream is, FormDataContentDisposition detail, String name, - @PathParam("id") String id) { -// public Response uploadSchema(@FormDataParam("file") InputStream is, @FormDataParam("file") FormDataContentDisposition detail, -// @FormDataParam("name") String name, @PathParam("id") String id) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// String path = "/datasources/" + name + ".xml"; -// String schema = getStringFromInputStream(is); -// try { -// datasourceService.addSchema(schema, path, name); -// return Response.ok().entity(datasourceService.getAvailableSchema()).build(); -// } catch (Exception e) { -// log.error("Error uploading schema: "+name, e); -// return Response.serverError().status(Response.Status.INTERNAL_SERVER_ERROR) -// .entity(e.getLocalizedMessage()) -// .type("text/plain").build(); -// } - throw new RuntimeException("not implemented"); - } - - /** - * Updates the locale parameter of the datasource - * - * @param locale the new locale for the data source - * @param datasourceName ID of the data source whose locale should be changed - * @return Response indicating success or fail - */ - @PUT - @Produces({ "application/json" }) - @Consumes({ "application/json" }) - @Path("/datasources/{datasourceName}/locale") -// @ReturnType("org.saiku.web.rest.objects.DataSourceMapper") - public Response updateDatasourceLocale(String locale, @PathParam("datasourceName") String datasourceName) { -// try { -// boolean overwrite = true; -// SaikuDatasource saikuDatasource = datasourceService.getDatasource(datasourceName); -// datasourceService.setLocaleOfDataSource(saikuDatasource, locale); -// datasourceService.addDatasource(saikuDatasource, overwrite); -// return Response.ok().type("application/json").entity(new DataSourceMapper(saikuDatasource)).build(); -// } catch(SaikuDataSourceException e){ -// return Response.ok().type("application/json").entity(e.getLocalizedMessage()).build(); -// } catch (Exception e) { -// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getLocalizedMessage()) -// .type("text/plain").build(); -// } - throw new RuntimeException("not implemented"); - } - - /** - * Get existing Saiku users from the Saiku server. - * - * @return A list of available users. - */ - @GET - @Produces({ "application/json" }) - @Path("/users") -// @ReturnType("java.util.List") - public Response getExistingUsers() { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// return Response.ok().entity(userService.getUsers()).build(); - throw new RuntimeException("not implemented"); - } - - /** - * Delete a schema from the Saiku server. - * - * @param id The schema ID. - * @return A response containing available schema. - */ - @DELETE - @Path("/schema/{id}") -// @ReturnType("java.util.List") - public Response deleteSchema(@PathParam("id") String id) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// datasourceService.removeSchema(id); -// return Response.status(Response.Status.NO_CONTENT).entity(datasourceService.getAvailableSchema()).build(); - throw new RuntimeException("not implemented"); - } - - /** - * Get Saved Schema By ID - * - * @param id - * @return a schema file. - */ - @GET - @Path("/schema/{id}") - @Produces("application/xml") -// @ReturnType("MondrianSchema") - public Response getSavedSchema(@PathParam("id") String id) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// String p = ""; -// for(MondrianSchema s :datasourceService.getAvailableSchema()){ -// if(s.getName().equals(id)){ -// -// try { -// p= repositoryDatasourceManager.getInternalFileData(s.getPath()); -// } catch (RepositoryException e) { -// Response.serverError().entity(e.getLocalizedMessage()).build(); -// } -// break; -// } -// } -// -// return Response -// .ok(p.getBytes(), MediaType.APPLICATION_OCTET_STREAM) -// .header("content-disposition", "attachment; filename = " + id) -// .build(); - throw new RuntimeException("not implemented"); - } - - /** - * Import a legacy data source into the Saiku server. - * - * @return A status 200. - */ - @GET - @Path("/datasource/import") - public Response importLegacyDatasources() { -// -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// datasourceService.importLegacyDatasources(); -// return Response.ok().build(); - throw new RuntimeException("not implemented"); - } - - /** - * Import legacy schema. - * - * @return A status 200 - */ - @GET - @Path("/schema/import") - public Response importLegacySchema() { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// -// datasourceService.importLegacySchema(); -// return Response.ok().build(); - throw new RuntimeException("not implemented"); - } - - /** - * Import legacy users into the Saiku server/ - * - * @return A status 200. - */ - @GET - @Path("/users/import") - public Response importLegacyUsers() { -// -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// datasourceService.importLegacyUsers(); -// return Response.ok().build(); - throw new RuntimeException("not implemented"); - } - - /** - * Get user details for a user in the Saiku server. - * - * @param id The user ID. - * @return A response containing the user details object for the selected user. - */ - @GET - @Produces({ "application/json" }) - @Path("/users/{id}") -// @ReturnType("org.saiku.database.dto.SaikuUser") - public Response getUserDetails(@PathParam("id") int id) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// return Response.ok().entity(userService.getUser(id)).build(); - throw new RuntimeException("not implemented"); - } - - /** - * Update a users user details on the Saiku server. - * - * @param jsonString SaikuUser object. - * @param userName The username for the user to be updated. - * @return A response containing a user object. - */ - @PUT - @Produces({ "application/json" }) - @Consumes("application/json") - @Path("/users/{username}") -// @ReturnType("org.saiku.database.dto.SaikuUser") - public Response updateUserDetails(SaikuUser jsonString, @PathParam("username") String userName) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// if(jsonString.getPassword() == null || jsonString.getPassword().equals("")) { -// return Response.ok().entity(userService.updateUser(jsonString, false)).build(); -// } -// else{ -// return Response.ok().entity(userService.updateUser(jsonString, true)).build(); -// } - throw new RuntimeException("not implemented"); - } - - /** - * Create user details on the Saiku server. - * - * @param jsonString SaikuUser object - * @return A response containing the user object. - */ - @POST - @Produces({ "application/json" }) - @Consumes({ "application/json" }) - @Path("/users") -// @ReturnType("org.saiku.database.dto.SaikuUser") - public Response createUserDetails(SaikuUser jsonString) { -// -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// return Response.ok().entity(userService.addUser(jsonString)).build(); - throw new RuntimeException("not implemented"); - } - - /** - * Delete a user from the Saiku server. - * - * @param username The username to remove - * @return A status 200. - */ - @DELETE - @Produces({ "application/json" }) - @Path("/users/{username}") - public Response removeUser(@PathParam("username") String username) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// userService.removeUser(username); -// return Response.ok().build(); - throw new RuntimeException("not implemented"); - } - - /** - * Get string from an input stream object. - * - * @param is The input stream to convert. - * @return A string representation of the input stream. - */ - private static String getStringFromInputStream(InputStream is) { -// -// BufferedReader br = null; -// StringBuilder sb = new StringBuilder(); -// -// String line; -// try { -// -// br = new BufferedReader(new InputStreamReader(is)); -// while ((line = br.readLine()) != null) { -// sb.append(line); -// } -// -// } catch (IOException e) { -// log.error("IO Exception when reading from input stream", e); -// } finally { -// if (br != null) { -// try { -// br.close(); -// } catch (IOException e) { -// log.error("IO Exception closing input stream",e ); -// } -// } -// } -// -// return sb.toString(); - throw new RuntimeException("not implemented"); - } - - /** - * Get the Saiku server version. - * - * @return A Response containing the Saiku server version. - */ - @GET - @Produces("text/plain") - @Path("/version") -// @ReturnType("java.lang.String") - public Response getVersion() { -// Properties prop = new Properties(); -// InputStream input = null; -// String version = ""; -// ClassLoader classloader = Thread.currentThread().getContextClassLoader(); -// InputStream is = classloader.getResourceAsStream("org/saiku/web/rest/resources/version.properties"); -// try { -// -// //input = new FileInputStream("version.properties"); -// -// // load a properties file -// prop.load(is); -// -// // get the property value and print it out -// version = prop.getProperty("VERSION"); -// } catch (IOException ex) { -// log.error("IO Exception when reading input stream", ex); -// } -// return Response.ok().entity(version).type("text/plain").build(); - throw new RuntimeException("not implemented"); - } - - /** - * Backup the Saiku server repository. - * - * @return A Zip file containing the backup. - */ - @GET - @Produces("application/zip") - @Path("/backup") - public StreamingOutput getBackup() { -// if(!userService.isAdmin()){ -// return null; -// } -// return new StreamingOutput() { -// public void write(OutputStream output) throws IOException, WebApplicationException { -// BufferedOutputStream bus = new BufferedOutputStream(output); -// bus.write(datasourceService.exportRepository()); -// -// } -// }; - throw new RuntimeException("not implemented"); - } - - /** - * Restore the repository on a Saiku server. - * - * @param is The input stream - * @param detail The file detail - * @return A status 200. - */ - @POST - @Produces("text/plain") - @Consumes("multipart/form-data") - @Path("/restore") - public Response postRestore(InputStream is, FormDataContentDisposition detail) { -// public Response postRestore(@FormDataParam("file") InputStream is, @FormDataParam("file") FormDataContentDisposition detail){ -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// try { -// byte[] bytes = IOUtils.toByteArray(is); -// datasourceService.restoreRepository(bytes); -// return Response.ok().entity("Restore Ok").type("text/plain").build(); -// } catch (IOException e) { -// log.error("Error reading restore file", e); -// } -// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Restore Ok").type("text/plain").build(); - throw new RuntimeException("not implemented"); - } - - /** - * Restore old legacy files on the Saiku server. - * - * @param is Input stream - * @param detail The file detail - * @return A status 200 - */ - @POST - @Produces("text/plain") - @Consumes("multipart/form-data") - @Path("/legacyfiles") - public Response postRestoreFiles(InputStream is, FormDataContentDisposition detail) { -// public Response postRestoreFiles(@FormDataParam("file") InputStream is, @FormDataParam("file") FormDataContentDisposition detail){ -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// try { -// byte[] bytes = IOUtils.toByteArray(is); -// datasourceService.restoreLegacyFiles(bytes); -// return Response.ok().entity("Restore Ok").type("text/plain").build(); -// } catch (IOException e) { -// log.error("Error reading restore file", e); -// } -// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Restore Ok").type("text/plain").build(); - throw new RuntimeException("not implemented"); - } - - @GET - @Produces("text/plain") - @Path("/log/{logname}") - public Response getLogFile(@PathParam("logname") String logname) { -// if(!userService.isAdmin()){ -// return Response.status(Response.Status.FORBIDDEN).build(); -// } -// try { -// return Response.status(Response.Status.OK).entity(logExtractor.readLog(logname)).build(); -// } catch (IOException e) { -// log.error("Could not read log file",e); -// return Response.serverError().entity("Could not read log file").build(); -// } - throw new RuntimeException("not implemented"); - } - - @GET - @Produces("application/json") - @Path("/datakeys") - public Response getPropertiesKeys() { -// return Response.ok(repositoryDatasourceManager.getAvailablePropertiesKeys()).build(); - throw new RuntimeException("not implemented"); - } -} diff --git a/src/net/datenwerke/rs/saiku/server/rest/resources/BasicRepositoryResource2.java b/src/net/datenwerke/rs/saiku/server/rest/resources/BasicRepositoryResource2.java index ddb951a41..307878765 100644 --- a/src/net/datenwerke/rs/saiku/server/rest/resources/BasicRepositoryResource2.java +++ b/src/net/datenwerke/rs/saiku/server/rest/resources/BasicRepositoryResource2.java @@ -15,13 +15,11 @@ */ package net.datenwerke.rs.saiku.server.rest.resources; -import java.io.InputStream; import java.io.Serializable; import java.util.List; import javax.inject.Inject; import javax.persistence.EntityManager; -import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.FormParam; import javax.ws.rs.GET; @@ -39,7 +37,6 @@ import org.slf4j.LoggerFactory; import com.google.inject.Provider; -import com.sun.jersey.core.header.FormDataContentDisposition; import net.datenwerke.rs.saiku.service.saiku.SaikuSessionContainer; import net.datenwerke.rs.saiku.service.saiku.entities.SaikuReport; @@ -419,83 +416,4 @@ public Response moveResource(@FormParam("source") String source, @FormParam("tar } - /** - * Upload a zip archive to the server. - * - * @param test Not used. - * @param uploadedInputStream File Info - * @param fileDetail File Info - * @param directory Location - * @return A response status 200 - */ - @POST - @Path("/zipupload") - @Consumes(MediaType.MULTIPART_FORM_DATA) - public Response uploadArchiveZip(@QueryParam("test") String test, InputStream uploadedInputStream, - FormDataContentDisposition fileDetail, String directory) { -// public Response uploadArchiveZip( -// @QueryParam("test") String test, -// @FormDataParam("file") InputStream uploadedInputStream, -// @FormDataParam("file") FormDataContentDisposition fileDetail, -// @FormDataParam("directory") String directory) -// { - // String zipFile = fileDetail.getFileName(); - // String output = ""; - // try { - // if (StringUtils.isBlank(zipFile)) - // throw new Exception("You must specify a zip file to upload"); - // - // output = "Uploding file: " + zipFile + " ...\r\n"; - // ZipInputStream zis = new ZipInputStream(uploadedInputStream); - // ZipEntry ze = zis.getNextEntry(); - // byte[] doc = null; - // boolean isFile = false; - // if (ze == null) { - // doc = IOUtils.toByteArray(uploadedInputStream); - // isFile = true; - // } - // while (ze != null || doc != null) { - // String fileName = null; - // if (!isFile) { - // fileName = ze.getName(); - // doc = IOUtils.toByteArray(zis); - // } else { - // fileName = zipFile; - // } - // - // output += "Saving " + fileName + "... "; - // String fullPath = (StringUtils.isNotBlank(directory)) ? directory + "/" + - // fileName : fileName; - // - // String content = new String(doc); - // Response r = saveResource(fullPath, content); - // doc = null; - // - // if (Status.OK.getStatusCode() != r.getStatus()) { - // output += " ERROR: " + r.getEntity().toString() + "\r\n"; - // } else { - // output += " OK\r\n"; - // } - // if (!isFile) - // ze = zis.getNextEntry(); - // } - // - // if (!isFile) { - // zis.closeEntry(); - // zis.close(); - // } - // uploadedInputStream.close(); - // - // output += " SUCCESSFUL!\r\n"; - // return Response.ok(output).build(); - // - // } catch(Exception e){ - // log.error("Cannot unzip resources " + zipFile ,e); - // String error = ExceptionUtils.getRootCauseMessage(e); - // return Response.serverError().entity(output + "\r\n" + error).build(); - // } - throw new RuntimeException("not implemented"); - - } - } diff --git a/src/net/datenwerke/rs/saiku/server/rest/resources/ISaikuRepository.java b/src/net/datenwerke/rs/saiku/server/rest/resources/ISaikuRepository.java deleted file mode 100644 index 4bd14f9c4..000000000 --- a/src/net/datenwerke/rs/saiku/server/rest/resources/ISaikuRepository.java +++ /dev/null @@ -1,59 +0,0 @@ -package net.datenwerke.rs.saiku.server.rest.resources; - -import java.util.List; - -import javax.ws.rs.DELETE; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; - -import org.saiku.repository.IRepositoryObject; - -public interface ISaikuRepository { - - /** - * Get Saved Queries. - * - * @return A list of SavedQuery Objects. - */ - @GET - @Produces({ "application/json" }) - List getReposaasitory(@QueryParam("path") String path, @QueryParam("type") String type); - - /** - * Load a resource. - * - * @param file - The name of the repository file to load. - * @return A Repository File Object. - */ - @GET - @Produces({ "text/plain" }) - @Path("/resource") - Response getRessdource(@QueryParam("file") String file); - - /** - * Save a resource. - * - * @param file - The name of the repository file to load. - * @param content - The content to save. - * @return Status - */ - @POST - @Path("/resource") - Response saveRedfsource(@FormParam("file") String file, @FormParam("content") String content); - - /** - * Delete a resource. - * - * @param file - The name of the repository file to load. - * @return Status - */ - @DELETE - @Path("/resource") - Response deletesdResource(@QueryParam("file") String file); - -} \ No newline at end of file diff --git a/src/net/datenwerke/rs/saiku/server/rest/resources/InfoResource.java b/src/net/datenwerke/rs/saiku/server/rest/resources/InfoResource.java index 0c9f96d1d..b69dd61e3 100644 --- a/src/net/datenwerke/rs/saiku/server/rest/resources/InfoResource.java +++ b/src/net/datenwerke/rs/saiku/server/rest/resources/InfoResource.java @@ -17,6 +17,7 @@ import java.util.List; +import javax.inject.Inject; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @@ -30,8 +31,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.inject.Inject; - /** * Info Resource to get platform information. */ diff --git a/src/net/datenwerke/rs/saiku/server/rest/resources/OlapDiscoverResource.java b/src/net/datenwerke/rs/saiku/server/rest/resources/OlapDiscoverResource.java index f8339aaa5..19f9ffa19 100644 --- a/src/net/datenwerke/rs/saiku/server/rest/resources/OlapDiscoverResource.java +++ b/src/net/datenwerke/rs/saiku/server/rest/resources/OlapDiscoverResource.java @@ -24,6 +24,8 @@ import java.util.List; import java.util.Map; +import javax.inject.Inject; +import javax.inject.Provider; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -50,9 +52,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.inject.Inject; -import com.google.inject.Provider; - import net.datenwerke.hookhandler.shared.hookhandler.HookHandlerService; import net.datenwerke.rs.saiku.service.hooks.SaikuCubeMetadataHook; import net.datenwerke.rs.saiku.service.locale.SaikuMessages; diff --git a/src/net/datenwerke/rs/saiku/server/rest/resources/Query2Resource.java b/src/net/datenwerke/rs/saiku/server/rest/resources/Query2Resource.java index 212203232..b5380faaf 100644 --- a/src/net/datenwerke/rs/saiku/server/rest/resources/Query2Resource.java +++ b/src/net/datenwerke/rs/saiku/server/rest/resources/Query2Resource.java @@ -25,6 +25,8 @@ import java.util.List; import java.util.Map; +import javax.inject.Inject; +import javax.inject.Provider; import javax.servlet.ServletException; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -61,8 +63,6 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.CollectionType; -import com.google.inject.Inject; -import com.google.inject.Provider; import net.datenwerke.rs.saiku.server.rest.objects.resultset.QueryResult; import net.datenwerke.rs.saiku.server.rest.util.RestUtil; diff --git a/src/net/datenwerke/rs/saiku/server/rest/resources/SessionResource.java b/src/net/datenwerke/rs/saiku/server/rest/resources/SessionResource.java index b7576ce4c..e2abd0d5e 100644 --- a/src/net/datenwerke/rs/saiku/server/rest/resources/SessionResource.java +++ b/src/net/datenwerke/rs/saiku/server/rest/resources/SessionResource.java @@ -21,6 +21,8 @@ import java.util.Map; import java.util.UUID; +import javax.inject.Inject; +import javax.inject.Provider; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -38,9 +40,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.inject.Inject; -import com.google.inject.Provider; - import net.datenwerke.rs.utils.localization.LocalizationServiceImpl; import net.datenwerke.security.service.authenticator.AuthenticatorService; diff --git a/src/net/datenwerke/rs/saiku/server/rest/util/StartupResource.java b/src/net/datenwerke/rs/saiku/server/rest/util/StartupResource.java deleted file mode 100644 index 8e18d73fa..000000000 --- a/src/net/datenwerke/rs/saiku/server/rest/util/StartupResource.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.datenwerke.rs.saiku.server.rest.util; - -import java.util.logging.Level; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.sun.jersey.spi.container.servlet.WebComponent; - -public class StartupResource { - - private static final Logger log = LoggerFactory.getLogger(StartupResource.class); - - public void init() { - // com.sun.jersey.spi.container.servlet.WebComponent - try { - java.util.logging.Logger jerseyLogger = java.util.logging.Logger.getLogger(WebComponent.class.getName()); - if (jerseyLogger != null) { - jerseyLogger.setLevel(Level.SEVERE); - log.debug("Disabled INFO Logging for com.sun.jersey.spi.container.servlet.WebComponent"); - } else { - - } - } catch (Exception e) { - log.error( - "Trying to disabling logging for com.sun.jersey.spi.container.servlet.WebComponent INFO Output failed", - e); - } - } - -} diff --git a/src/net/datenwerke/rs/samba/service/samba/hooker/ScheduleConfigAsSambaFileHooker.java b/src/net/datenwerke/rs/samba/service/samba/hooker/ScheduleConfigAsSambaFileHooker.java index 9ab5b514e..8a6c06f29 100644 --- a/src/net/datenwerke/rs/samba/service/samba/hooker/ScheduleConfigAsSambaFileHooker.java +++ b/src/net/datenwerke/rs/samba/service/samba/hooker/ScheduleConfigAsSambaFileHooker.java @@ -67,7 +67,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setSambaDatasinkDto((SambaDatasinkDto) dtoServiceProvider.get().createDto(action.getSambaDatasink())); if (null == info.getSambaDatasinkDto()) diff --git a/src/net/datenwerke/rs/scheduler/service/scheduler/hookers/ScheduleViaEmailHooker.java b/src/net/datenwerke/rs/scheduler/service/scheduler/hookers/ScheduleViaEmailHooker.java index 5bbe6dccb..2a2df3bef 100755 --- a/src/net/datenwerke/rs/scheduler/service/scheduler/hookers/ScheduleViaEmailHooker.java +++ b/src/net/datenwerke/rs/scheduler/service/scheduler/hookers/ScheduleViaEmailHooker.java @@ -57,7 +57,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setSubject(action.getSubject()); info.setMessage(action.getMessage()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); rsd.addAdditionalInfo(info); } diff --git a/src/net/datenwerke/rs/scp/service/scp/hooker/ScheduleConfigAsScpFileHooker.java b/src/net/datenwerke/rs/scp/service/scp/hooker/ScheduleConfigAsScpFileHooker.java index 42acdb234..fca3265f9 100644 --- a/src/net/datenwerke/rs/scp/service/scp/hooker/ScheduleConfigAsScpFileHooker.java +++ b/src/net/datenwerke/rs/scp/service/scp/hooker/ScheduleConfigAsScpFileHooker.java @@ -68,7 +68,7 @@ public void adaptScheduleDefinition(ReportScheduleDefinition rsd, ReportExecuteJ info.setName(action.getName()); info.setFolder(action.getFolder()); - info.setCompressed(action.isCompressed()); + info.setCompressed(Boolean.TRUE.equals(action.isCompressed())); info.setScpDatasinkDto((ScpDatasinkDto) dtoServiceProvider.get().createDto(action.getScpDatasink())); if (null == info.getScpDatasinkDto())