diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-11-30 14:44:46 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-11-30 14:44:46 +0000 |
commit | 1becba6356524f199edea28c718a052e0e6f1478 (patch) | |
tree | 6174adc2801e23e531629692187998f86834562f | |
parent | 08b4374045238631144b6927bf6f1253e98cd6b2 (diff) | |
parent | 17ca33d11352af246ecbb2f2c92e614aff4e1021 (diff) |
slideshow1: merge with DEV300 m44
351 files changed, 101096 insertions, 39022 deletions
diff --git a/apache-commons/java/codec/makefile.mk b/apache-commons/java/codec/makefile.mk index 5ab525b4e9ba..7945803bf867 100644 --- a/apache-commons/java/codec/makefile.mk +++ b/apache-commons/java/codec/makefile.mk @@ -50,7 +50,7 @@ TARFILE_NAME=commons-codec-1.3-src TARFILE_ROOTDIR=commons-codec-1.3 -PATCH_FILE_NAME=$(PRJ)$/patches$/codec.patch +PATCH_FILES=$(PRJ)$/patches$/codec.patch #CONVERTFILES=build.xml diff --git a/apache-commons/java/httpclient/makefile.mk b/apache-commons/java/httpclient/makefile.mk index 8e9dd0c74760..8d3c696705f2 100644 --- a/apache-commons/java/httpclient/makefile.mk +++ b/apache-commons/java/httpclient/makefile.mk @@ -50,7 +50,7 @@ TARFILE_NAME=commons-httpclient-3.1-src TARFILE_ROOTDIR=commons-httpclient-3.1 -#PATCH_FILE_NAME=$(PRJ)$/patches$/httpclient.patch +#PATCH_FILES=$(PRJ)$/patches$/httpclient.patch #CONVERTFILES=build.xml diff --git a/apache-commons/java/lang/makefile.mk b/apache-commons/java/lang/makefile.mk index c65416865483..3699660632f5 100644 --- a/apache-commons/java/lang/makefile.mk +++ b/apache-commons/java/lang/makefile.mk @@ -50,7 +50,7 @@ TARFILE_NAME=commons-lang-2.3-src TARFILE_ROOTDIR=commons-lang-2.3-src -#PATCH_FILE_NAME=$(PRJ)$/patches$/logging.patch +#PATCH_FILES=$(PRJ)$/patches$/logging.patch #CONVERTFILES=build.xml diff --git a/apache-commons/java/logging/makefile.mk b/apache-commons/java/logging/makefile.mk index 55bd8f4f9d6d..ab3476974b1b 100644 --- a/apache-commons/java/logging/makefile.mk +++ b/apache-commons/java/logging/makefile.mk @@ -50,7 +50,7 @@ TARFILE_NAME=commons-logging-1.1.1-src TARFILE_ROOTDIR=commons-logging-1.1.1-src -PATCH_FILE_NAME=$(PRJ)$/patches$/logging.patch +PATCH_FILES=$(PRJ)$/patches$/logging.patch CONVERTFILES=build.xml diff --git a/jfreereport/download/core.zip b/jfreereport/download/core.zip Binary files differindex 2b307e32bf6b..813d87d49573 100644 --- a/jfreereport/download/core.zip +++ b/jfreereport/download/core.zip diff --git a/jfreereport/download/flute.zip b/jfreereport/download/flute.zip Binary files differindex c80046d37b5b..ff1ade906ad4 100644 --- a/jfreereport/download/flute.zip +++ b/jfreereport/download/flute.zip diff --git a/jfreereport/download/jcommon-1.0.10.zip b/jfreereport/download/jcommon-1.0.10.zip Binary files differdeleted file mode 100644 index 169cf809ed24..000000000000 --- a/jfreereport/download/jcommon-1.0.10.zip +++ /dev/null diff --git a/jfreereport/download/jcommon-serializer.zip b/jfreereport/download/jcommon-serializer.zip Binary files differdeleted file mode 100644 index f348c6aa87dc..000000000000 --- a/jfreereport/download/jcommon-serializer.zip +++ /dev/null diff --git a/jfreereport/download/libbase.zip b/jfreereport/download/libbase.zip Binary files differnew file mode 100644 index 000000000000..88f555d9ef7c --- /dev/null +++ b/jfreereport/download/libbase.zip diff --git a/jfreereport/download/libfonts.zip b/jfreereport/download/libfonts.zip Binary files differindex 27d8ceeab23a..91fbac87b3a6 100644 --- a/jfreereport/download/libfonts.zip +++ b/jfreereport/download/libfonts.zip diff --git a/jfreereport/download/libformula.zip b/jfreereport/download/libformula.zip Binary files differindex 5307e59ead08..c819c963767e 100644 --- a/jfreereport/download/libformula.zip +++ b/jfreereport/download/libformula.zip diff --git a/jfreereport/download/liblayout.zip b/jfreereport/download/liblayout.zip Binary files differindex b1ba3e9e3ee6..1311fae496f5 100644 --- a/jfreereport/download/liblayout.zip +++ b/jfreereport/download/liblayout.zip diff --git a/jfreereport/download/libloader.zip b/jfreereport/download/libloader.zip Binary files differindex 71592c483613..505329e0b6ea 100644 --- a/jfreereport/download/libloader.zip +++ b/jfreereport/download/libloader.zip diff --git a/jfreereport/download/librepository.zip b/jfreereport/download/librepository.zip Binary files differindex 5fe4fa836b46..9541579941cf 100644 --- a/jfreereport/download/librepository.zip +++ b/jfreereport/download/librepository.zip diff --git a/jfreereport/download/libserializer.zip b/jfreereport/download/libserializer.zip Binary files differnew file mode 100644 index 000000000000..94823b28e614 --- /dev/null +++ b/jfreereport/download/libserializer.zip diff --git a/jfreereport/download/libxml.zip b/jfreereport/download/libxml.zip Binary files differindex 88e928f31be0..be5cecb2490e 100644 --- a/jfreereport/download/libxml.zip +++ b/jfreereport/download/libxml.zip diff --git a/jfreereport/java/flute/makefile.mk b/jfreereport/java/flute/makefile.mk index fabd456a51c6..e68f9fdc27f6 100644 --- a/jfreereport/java/flute/makefile.mk +++ b/jfreereport/java/flute/makefile.mk @@ -33,37 +33,28 @@ PRJ=..$/.. PRJNAME=jfreereport TARGET=flute -VERSION=-1.3-jfree-20061107 +VERSION=-1.3.0 # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - -# override buildfile -ANT_BUILDFILE=ant$/build.xml - .INCLUDE : antsettings.mk .IF "$(SOLAR_JAVA)" != "" # --- Files -------------------------------------------------------- TARFILE_NAME=$(TARGET) - TARFILE_ROOTDIR=$(TARGET) +# PATCH_FILES=$(PRJ)$/patches$/$(TARGET).patch +# CONVERTFILES=build.xml -PATCH_FILE_NAME=$(PRJ)$/patches$/$(TARGET).patch - -CONVERTFILES=ant$/build.xml\ - ant$/build.properties - -OUT2CLASS=$(TARGET)$(VERSION).jar .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar .ENDIF .ENDIF # $(SOLAR_JAVA)!= "" @@ -75,5 +66,10 @@ BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION .IF "$(SOLAR_JAVA)" != "" .INCLUDE : tg_ext.mk + +ALLTAR : $(CLASSDIR)$/$(TARGET)$(VERSION).jar +$(CLASSDIR)$/$(TARGET)$(VERSION).jar : $(PACKAGE_DIR)$/$(INSTALL_FLAG_FILE) + $(COPY) $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/build$/lib$/$(TARGET).jar $(CLASSDIR)$/$(TARGET)$(VERSION).jar + .ENDIF diff --git a/jfreereport/java/jfreereport/makefile.mk b/jfreereport/java/jfreereport/makefile.mk index 689bf93b9859..939964906eea 100644 --- a/jfreereport/java/jfreereport/makefile.mk +++ b/jfreereport/java/jfreereport/makefile.mk @@ -32,39 +32,29 @@ PRJ=..$/.. PRJNAME=jfreereport -TARGET=pentaho-reporting-flow-engine +TARGET=flow-engine VERSION=-0.9.2 # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - -# override buildfile -ANT_BUILDFILE=build.xml - .INCLUDE : antsettings.mk .IF "$(SOLAR_JAVA)" != "" # --- Files -------------------------------------------------------- TARFILE_NAME=core - TARFILE_ROOTDIR=core - -PATCH_FILE_NAME=$(PRJ)$/patches$/$(TARGET).patch - -CONVERTFILES=build.xml\ - build.properties \ - source/org/jfree/report/expressions/ReportFormulaContext.java - -OUT2CLASS=$(TARGET)$(VERSION).jar +PATCH_FILES=$(PRJ)$/patches$/$(TARGET).patch +# ADDITIONAL_FILES=MANIFEST.MF +CONVERTFILES=build.xml .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar .ENDIF .ENDIF # $(SOLAR_JAVA)!= "" @@ -76,4 +66,9 @@ BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION .IF "$(SOLAR_JAVA)" != "" .INCLUDE : tg_ext.mk + +ALLTAR : $(CLASSDIR)$/$(TARGET)$(VERSION).jar +$(CLASSDIR)$/$(TARGET)$(VERSION).jar : $(PACKAGE_DIR)$/$(INSTALL_FLAG_FILE) + $(COPY) $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/build$/lib$/$(TARGET).jar $(CLASSDIR)$/$(TARGET)$(VERSION).jar + .ENDIF diff --git a/jfreereport/java/jcommon/makefile.mk b/jfreereport/java/libbase/makefile.mk index a56273be0174..0fab39a8a2c6 100644 --- a/jfreereport/java/jcommon/makefile.mk +++ b/jfreereport/java/libbase/makefile.mk @@ -32,37 +32,28 @@ PRJ=..$/.. PRJNAME=jfreereport -TARGET=jcommon-1.0.10 - +TARGET=libbase +VERSION=-1.0.0 # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - -# override buildfile -ANT_BUILDFILE=ant$/build.xml - .INCLUDE : antsettings.mk .IF "$(SOLAR_JAVA)" != "" # --- Files -------------------------------------------------------- TARFILE_NAME=$(TARGET) - TARFILE_ROOTDIR=$(TARGET) -PATCH_FILE_NAME=$(PRJ)$/patches$/jcommon.patch - -CONVERTFILES=ant$/build.xml\ - ant$/build.properties - -OUT2CLASS=$(TARGET).jar +# PATCH_FILES=$(PRJ)$/patches$/libbase.patch +# CONVERTFILES=build.xml .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar .ENDIF .ENDIF # $(SOLAR_JAVA)!= "" @@ -74,5 +65,14 @@ BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) com .IF "$(SOLAR_JAVA)" != "" .INCLUDE : tg_ext.mk + +$(PACKAGE_DIR)$/$(CONFIGURE_FLAG_FILE) : $(CLASSDIR)$/commons-logging-1.1.1.jar +ALLTAR : $(CLASSDIR)$/$(TARGET)$(VERSION).jar + +$(CLASSDIR)$/commons-logging-1.1.1.jar : + $(COPY) $(SOLARBINDIR)$/commons-logging-1.1.1.jar $(CLASSDIR)$/commons-logging-1.1.1.jar + +$(CLASSDIR)$/$(TARGET)$(VERSION).jar : $(CLASSDIR)$/commons-logging-1.1.1.jar $(PACKAGE_DIR)$/$(INSTALL_FLAG_FILE) + $(COPY) $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/build$/lib$/$(TARGET).jar $(CLASSDIR)$/$(TARGET)$(VERSION).jar .ENDIF diff --git a/jfreereport/java/libfonts/makefile.mk b/jfreereport/java/libfonts/makefile.mk index 8d1ea39b213c..e8e289337f5b 100644 --- a/jfreereport/java/libfonts/makefile.mk +++ b/jfreereport/java/libfonts/makefile.mk @@ -33,37 +33,27 @@ PRJ=..$/.. PRJNAME=jfreereport TARGET=libfonts -VERSION=-0.3.3 +VERSION=-1.0.0 # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - -# override buildfile -ANT_BUILDFILE=build.xml - .INCLUDE : antsettings.mk .IF "$(SOLAR_JAVA)" != "" # --- Files -------------------------------------------------------- TARFILE_NAME=$(TARGET) - TARFILE_ROOTDIR=$(TARGET) - -PATCH_FILE_NAME=$(PRJ)$/patches$/$(TARGET).patch - -CONVERTFILES=build.xml\ - build.properties - -OUT2CLASS=$(TARGET)$(VERSION).jar +PATCH_FILES=$(PRJ)$/patches$/$(TARGET).patch +CONVERTFILES=build.xml .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar .ENDIF .ENDIF # $(SOLAR_JAVA)!= "" @@ -75,5 +65,10 @@ BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION .IF "$(SOLAR_JAVA)" != "" .INCLUDE : tg_ext.mk + +ALLTAR : $(CLASSDIR)$/$(TARGET)$(VERSION).jar +$(CLASSDIR)$/$(TARGET)$(VERSION).jar : $(PACKAGE_DIR)$/$(INSTALL_FLAG_FILE) + $(COPY) $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/build$/lib$/$(TARGET).jar $(CLASSDIR)$/$(TARGET)$(VERSION).jar + .ENDIF diff --git a/jfreereport/java/libformula/makefile.mk b/jfreereport/java/libformula/makefile.mk index a94c3a2843ec..1e4a3093f4bb 100644 --- a/jfreereport/java/libformula/makefile.mk +++ b/jfreereport/java/libformula/makefile.mk @@ -33,58 +33,29 @@ PRJ=..$/.. PRJNAME=jfreereport TARGET=libformula -VERSION=-0.1.14 +VERSION=-0.2.0 # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - -# override buildfile -ANT_BUILDFILE=build.xml - .INCLUDE : antsettings.mk .IF "$(SOLAR_JAVA)" != "" # --- Files -------------------------------------------------------- TARFILE_NAME=$(TARGET) - TARFILE_ROOTDIR=$(TARGET) - -PATCH_FILE_NAME=$(PRJ)$/patches$/$(TARGET).patch - -CONVERTFILES=build.xml\ - build.properties \ - source/org/jfree/formula/function/text/MidFunctionDescription.java \ - source/org/jfree/formula/function/AbstractFunctionDescription.java \ - source/org/jfree/formula/function/datetime/Hour-Function.properties \ - source/org/jfree/formula/function/information/IsBlank-Function.properties \ - source/org/jfree/formula/function/information/IsErr-Function.properties \ - source/org/jfree/formula/function/information/IsError-Function.properties \ - source/org/jfree/formula/function/information/IsEven-Function.properties \ - source/org/jfree/formula/function/information/IsLogical-Function.properties \ - source/org/jfree/formula/function/information/IsNa-Function.properties \ - source/org/jfree/formula/function/information/IsNonText-Function.properties \ - source/org/jfree/formula/function/information/IsNumber-Function.properties \ - source/org/jfree/formula/function/information/IsOdd-Function.properties \ - source/org/jfree/formula/function/information/IsText-Function.properties \ - source/org/jfree/formula/function/logical/If-Function.properties \ - source/org/jfree/formula/function/logical/Not-Function.properties \ - source/org/jfree/formula/function/logical/Or-Function.properties \ - source/org/jfree/formula/function/math/Even-Function.properties \ - source/org/jfree/formula/function/math/ModFunctionDescription.java \ - source/org/jfree/formula/function/text/Trim-Function.properties \ - source/org/jfree/formula/parser/FormulaParser.java - -ADDITIONAL_FILES=source/org/jfree/formula/function/information/IsRef-Function.properties -OUT2CLASS=$(TARGET)$(VERSION).jar +PATCH_FILES=$(PRJ)$/patches$/$(TARGET).patch +CONVERTFILES=build.xml \ + source$/org$/pentaho$/reporting$/libraries$/formula$/function$/datetime$/DateDifFunction.java \ + source$/org$/pentaho$/reporting$/libraries$/formula$/lvalues$/FormulaFunction.java .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar .ENDIF @@ -97,6 +68,11 @@ BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION .IF "$(SOLAR_JAVA)" != "" .INCLUDE : tg_ext.mk + +ALLTAR : $(CLASSDIR)$/$(TARGET)$(VERSION).jar +$(CLASSDIR)$/$(TARGET)$(VERSION).jar : $(PACKAGE_DIR)$/$(INSTALL_FLAG_FILE) + $(COPY) $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/build$/lib$/$(TARGET).jar $(CLASSDIR)$/$(TARGET)$(VERSION).jar + .ENDIF # $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/source$/org$/jfree$/formula$/function$/information$/IsRef-Function.properties : # @@-$(MKDIRHIER) $(@:d) diff --git a/jfreereport/java/liblayout/makefile.mk b/jfreereport/java/liblayout/makefile.mk index 3d98868f5485..409b9715fe13 100644 --- a/jfreereport/java/liblayout/makefile.mk +++ b/jfreereport/java/liblayout/makefile.mk @@ -33,37 +33,27 @@ PRJ=..$/.. PRJNAME=jfreereport TARGET=liblayout -VERSION=-0.2.8 +VERSION=-0.2.9 # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - -# override buildfile -ANT_BUILDFILE=build.xml - .INCLUDE : antsettings.mk .IF "$(SOLAR_JAVA)" != "" # --- Files -------------------------------------------------------- TARFILE_NAME=$(TARGET) - TARFILE_ROOTDIR=$(TARGET) - -PATCH_FILE_NAME=$(PRJ)$/patches$/$(TARGET).patch - -CONVERTFILES=build.xml\ - build.properties - -OUT2CLASS=$(TARGET)$(VERSION).jar +PATCH_FILES=$(PRJ)$/patches$/$(TARGET).patch +CONVERTFILES=build.xml .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar .ENDIF .ENDIF # $(SOLAR_JAVA)!= "" @@ -75,5 +65,10 @@ BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION .IF "$(SOLAR_JAVA)" != "" .INCLUDE : tg_ext.mk + +ALLTAR : $(CLASSDIR)$/$(TARGET)$(VERSION).jar +$(CLASSDIR)$/$(TARGET)$(VERSION).jar : $(PACKAGE_DIR)$/$(INSTALL_FLAG_FILE) + $(COPY) $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/build$/lib$/$(TARGET).jar $(CLASSDIR)$/$(TARGET)$(VERSION).jar + .ENDIF diff --git a/jfreereport/java/libloader/makefile.mk b/jfreereport/java/libloader/makefile.mk index e1a03334cf6e..9cb1e93066a8 100644 --- a/jfreereport/java/libloader/makefile.mk +++ b/jfreereport/java/libloader/makefile.mk @@ -33,37 +33,27 @@ PRJ=..$/.. PRJNAME=jfreereport TARGET=libloader -VERSION=-0.3.6 +VERSION=-1.0.0 # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - -# override buildfile -ANT_BUILDFILE=build.xml - .INCLUDE : antsettings.mk .IF "$(SOLAR_JAVA)" != "" # --- Files -------------------------------------------------------- TARFILE_NAME=$(TARGET) - TARFILE_ROOTDIR=$(TARGET) - -PATCH_FILE_NAME=$(PRJ)$/patches$/$(TARGET).patch - -CONVERTFILES=build.xml\ - build.properties - -OUT2CLASS=$(TARGET)$(VERSION).jar +PATCH_FILES=$(PRJ)$/patches$/$(TARGET).patch +CONVERTFILES=build.xml .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar .ENDIF .ENDIF # $(SOLAR_JAVA)!= "" @@ -75,5 +65,10 @@ BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION .IF "$(SOLAR_JAVA)" != "" .INCLUDE : tg_ext.mk + +ALLTAR : $(CLASSDIR)$/$(TARGET)$(VERSION).jar +$(CLASSDIR)$/$(TARGET)$(VERSION).jar : $(PACKAGE_DIR)$/$(INSTALL_FLAG_FILE) + $(COPY) $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/build$/lib$/$(TARGET).jar $(CLASSDIR)$/$(TARGET)$(VERSION).jar + .ENDIF diff --git a/jfreereport/java/librepository/makefile.mk b/jfreereport/java/librepository/makefile.mk index f37334224b5f..d6bdab754f88 100644 --- a/jfreereport/java/librepository/makefile.mk +++ b/jfreereport/java/librepository/makefile.mk @@ -33,37 +33,27 @@ PRJ=..$/.. PRJNAME=jfreereport TARGET=librepository -VERSION=-0.1.4 +VERSION=-1.0.0 # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - -# override buildfile -ANT_BUILDFILE=build.xml - .INCLUDE : antsettings.mk .IF "$(SOLAR_JAVA)" != "" # --- Files -------------------------------------------------------- TARFILE_NAME=$(TARGET) - TARFILE_ROOTDIR=$(TARGET) - -PATCH_FILE_NAME=$(PRJ)$/patches$/$(TARGET).patch - -CONVERTFILES=build.xml\ - build.properties - -OUT2CLASS=$(TARGET)$(VERSION).jar +PATCH_FILES=$(PRJ)$/patches$/$(TARGET).patch +CONVERTFILES=build.xml .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar .ENDIF .ENDIF # $(SOLAR_JAVA)!= "" @@ -75,5 +65,10 @@ BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION .IF "$(SOLAR_JAVA)" != "" .INCLUDE : tg_ext.mk + +ALLTAR : $(CLASSDIR)$/$(TARGET)$(VERSION).jar +$(CLASSDIR)$/$(TARGET)$(VERSION).jar : $(PACKAGE_DIR)$/$(INSTALL_FLAG_FILE) + $(COPY) $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/build$/lib$/$(TARGET).jar $(CLASSDIR)$/$(TARGET)$(VERSION).jar + .ENDIF diff --git a/jfreereport/java/jcommon-serializer/makefile.mk b/jfreereport/java/libserializer/makefile.mk index f10e411e5e52..a062670e63a2 100644 --- a/jfreereport/java/jcommon-serializer/makefile.mk +++ b/jfreereport/java/libserializer/makefile.mk @@ -32,38 +32,28 @@ PRJ=..$/.. PRJNAME=jfreereport -TARGET=jcommon-serializer -VERSION=-0.2.0 +TARGET=libserializer +VERSION=-1.0.0 # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - -# override buildfile -ANT_BUILDFILE=build.xml - .INCLUDE : antsettings.mk .IF "$(SOLAR_JAVA)" != "" # --- Files -------------------------------------------------------- TARFILE_NAME=$(TARGET) - TARFILE_ROOTDIR=$(TARGET) - -PATCH_FILE_NAME=$(PRJ)$/patches$/$(TARGET).patch - -CONVERTFILES=build.xml\ - build.properties +PATCH_FILES=$(PRJ)$/patches$/$(TARGET).patch +CONVERTFILES=build.xml -OUT2CLASS=$(TARGET)$(VERSION).jar - .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar .ENDIF .ENDIF # $(SOLAR_JAVA)!= "" @@ -75,5 +65,10 @@ BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION .IF "$(SOLAR_JAVA)" != "" .INCLUDE : tg_ext.mk + +ALLTAR : $(CLASSDIR)$/$(TARGET)$(VERSION).jar +$(CLASSDIR)$/$(TARGET)$(VERSION).jar : $(PACKAGE_DIR)$/$(INSTALL_FLAG_FILE) + $(COPY) $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/build$/lib$/$(TARGET).jar $(CLASSDIR)$/$(TARGET)$(VERSION).jar + .ENDIF diff --git a/jfreereport/java/libxml/makefile.mk b/jfreereport/java/libxml/makefile.mk index d98a3d8ef015..fafb16753eb3 100644 --- a/jfreereport/java/libxml/makefile.mk +++ b/jfreereport/java/libxml/makefile.mk @@ -33,37 +33,27 @@ PRJ=..$/.. PRJNAME=jfreereport TARGET=libxml -VERSION=-0.9.9 +VERSION=-1.0.0 # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - -# override buildfile -ANT_BUILDFILE=build.xml - .INCLUDE : antsettings.mk .IF "$(SOLAR_JAVA)" != "" # --- Files -------------------------------------------------------- TARFILE_NAME=$(TARGET) - TARFILE_ROOTDIR=$(TARGET) - -PATCH_FILE_NAME=$(PRJ)$/patches$/$(TARGET).patch - -CONVERTFILES=build.xml\ - build.properties - -OUT2CLASS=$(TARGET)$(VERSION).jar +PATCH_FILES=$(PRJ)$/patches$/$(TARGET).patch +CONVERTFILES=build.xml .IF "$(JAVACISGCJ)"=="yes" JAVA_HOME= .EXPORT : JAVA_HOME -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj -f $(ANT_BUILDFILE) jar .ELSE -BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) compile +BUILD_ACTION=$(ANT) -Dlib="../../../class" -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE) jar .ENDIF .ENDIF # $(SOLAR_JAVA)!= "" @@ -75,5 +65,10 @@ BUILD_ACTION=$(ANT) -Dlibdir="../../../class" -Dbuild.label="build-$(RSCREVISION .IF "$(SOLAR_JAVA)" != "" .INCLUDE : tg_ext.mk + +ALLTAR : $(CLASSDIR)$/$(TARGET)$(VERSION).jar +$(CLASSDIR)$/$(TARGET)$(VERSION).jar : $(PACKAGE_DIR)$/$(INSTALL_FLAG_FILE) + $(COPY) $(PACKAGE_DIR)$/$(TARFILE_ROOTDIR)$/build$/lib$/$(TARGET).jar $(CLASSDIR)$/$(TARGET)$(VERSION).jar + .ENDIF diff --git a/jfreereport/java/sac/makefile.mk b/jfreereport/java/sac/makefile.mk index ed96af4060ff..0ce628ed8ee6 100644 --- a/jfreereport/java/sac/makefile.mk +++ b/jfreereport/java/sac/makefile.mk @@ -50,7 +50,7 @@ TARFILE_NAME=sacjava-1.3 TARFILE_ROOTDIR=$(TARGET) -PATCH_FILE_NAME=$(PRJ)$/patches$/sac.patch +PATCH_FILES=$(PRJ)$/patches$/sac.patch ADDITIONAL_FILES=build.xml diff --git a/jfreereport/patches/flow-engine.patch b/jfreereport/patches/flow-engine.patch new file mode 100644 index 000000000000..ca3c84e53627 --- /dev/null +++ b/jfreereport/patches/flow-engine.patch @@ -0,0 +1,10 @@ +--- misc/core/build.xml (Revision 6728)
++++ misc/build/core/build.xml (Arbeitskopie)
+@@ -24,6 +24,6 @@
+ <!-- Setup the compile classpath -->
+ <path id="classpath">
+- <fileset dir="lib">
++ <fileset dir="${lib}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
diff --git a/jfreereport/patches/flute.patch b/jfreereport/patches/flute.patch index f06f2a630a63..27cca426319d 100644 --- a/jfreereport/patches/flute.patch +++ b/jfreereport/patches/flute.patch @@ -1,86 +1,19 @@ -*** misc/flute/ant/build.properties Thu Oct 18 08:20:03 2007 ---- misc/build/flute/ant/build.properties Thu Oct 18 14:07:28 2007 -*************** -*** 14,21 **** - - # - # Make sure that JDK 1.2 compatible class files are generated -! build.target=1.2 -! build.source=1.2 - - # - # All path settings are relative to the project root directory ---- 14,21 ---- - - # - # Make sure that JDK 1.2 compatible class files are generated -! build.target=1.3 -! build.source=1.3 - - # - # All path settings are relative to the project root directory -*** misc/flute/ant/build.xml Thu Oct 18 08:20:03 2007 ---- misc/build/flute/ant/build.xml Mon Oct 22 09:13:22 2007 -*************** -*** 19,26 **** - </path> - <isClassAndFileAvailable class-name="org.w3c.css.sac.Parser" - property-name="core.Enabled" -! file-name="${libdir}/${sac-jar-file}" -! classpath-id="core.Classpath"/> - <fail unless="core.Enabled"/> - - </target> ---- 19,25 ---- - </path> - <isClassAndFileAvailable class-name="org.w3c.css.sac.Parser" - property-name="core.Enabled" -! file-name="${libdir}/${sac-jar-file}"/> - <fail unless="core.Enabled"/> - - </target> -*************** -*** 38,59 **** - - <target name="compile" depends="initialise"> - -! <fileset dir="source/" id="core.SourceFiles"> -! <exclude name="**/junit/**"/> -! <include name="**/*.java"/> -! </fileset> -! -! <fileset dir="source/" id="core.ResourceFiles"> -! <exclude name="**/junit/**"/> -! <include name="**/*.properties"/> -! <include name="**/*.jj"/> -! </fileset> -! -! <build-core target-jar="${flute-jar-file}" -! source-files-id="core.SourceFiles" -! resource-files-id="core.ResourceFiles" -! classpath-id="core.Classpath"> -! </build-core> - </target> - - ---- 37,56 ---- - - <target name="compile" depends="initialise"> - -! <build-all target-jar="${flute-jar-file}" source-dir="source"> -! <all-classpath> -! <pathelement location="${libdir}/${sac-jar-file}"/> -! </all-classpath> -! <all-sources> -! <exclude name="**/junit/**"/> -! <include name="**/*.java"/> -! </all-sources> -! <all-resources> -! <exclude name="**/junit/**"/> -! <include name="**/*.properties"/> -! <include name="**/*.jj"/> -! </all-resources> -! </build-all> - </target> - - +--- misc/flute/build.xml (Revision 6820)
++++ misc/build/flute/build.xml (Arbeitskopie)
+@@ -9,6 +9,7 @@
+ <property name="build.doc" value="${build}/api"/>
+ <property name="build.lib" value="${build}/lib"/>
+ <property name="packagenames" value="org.w3c.flute.*"/>
++ <property name="lib" value="lib"/>
+
+ <!-- Targets -->
+ <!-- Prepare build directories -->
+@@ -21,7 +22,7 @@
+
+ <!-- Setup the compile classpath -->
+ <path id="classpath">
+- <fileset dir="lib">
++ <fileset dir="${lib}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
diff --git a/jfreereport/patches/jcommon-serializer.patch b/jfreereport/patches/jcommon-serializer.patch deleted file mode 100644 index c717ef4e0fa6..000000000000 --- a/jfreereport/patches/jcommon-serializer.patch +++ /dev/null @@ -1,21 +0,0 @@ -*** misc/jcommon-serializer/build.properties Mon Dec 11 13:40:27 2006 ---- misc/build/jcommon-serializer/build.properties Fri Jul 27 09:04:38 2007 -*************** -*** 13,20 **** - - ## - # Make sure that JDK 1.2 compatible class files are generated -! build.target=1.2 -! build.source=1.2 - - # - # All path settings are relative to the project root directory ---- 13,20 ---- - - ## - # Make sure that JDK 1.2 compatible class files are generated -! build.target=1.3 -! build.source=1.3 - - # - # All path settings are relative to the project root directory diff --git a/jfreereport/patches/jcommon.patch b/jfreereport/patches/jcommon.patch deleted file mode 100644 index 1deea7683a64..000000000000 --- a/jfreereport/patches/jcommon.patch +++ /dev/null @@ -1,50 +0,0 @@ -*** misc/jcommon-1.0.10/ant/build.properties Mon Dec 11 13:40:27 2006 ---- misc/build/jcommon-1.0.10/ant/build.properties Fri Jul 27 09:04:38 2007 -*************** -*** 14,21 **** - - ## - # Make sure that JDK 1.2 compatible class files are generated -! build.target=1.2 -! build.source=1.2 - - # - # All path settings are relative to the project root directory ---- 14,21 ---- - - ## - # Make sure that JDK 1.2 compatible class files are generated -! build.target=1.3 -! build.source=1.3 - - # - # All path settings are relative to the project root directory -*** misc/jcommon-1.0.10/ant/build.xml Mon May 21 19:25:06 2007 ---- misc/build/jcommon-1.0.10/ant/build.xml Thu Oct 18 11:58:48 2007 -*************** -*** 329,338 **** - <delete dir="distribution"/> - </target> - - - <!-- ALL --> - <target name="all" -! depends="compile,compile-xml,compile-junit-tests,javadoc,zip,targz,maven-bundle" - description="Compiles JCommon, builds the jar files, generates the Javadoc HTML pages and creates distribution files (.zip and .tar.gz)."> - </target> - ---- 329,342 ---- - <delete dir="distribution"/> - </target> - -+ <!-- Copy jar file into environment --> -+ <target name="copyjar" depends="compile"> -+ <copy file="${jcommon-jar-file}" tofile="../../../class/${jcommon-jar-file}"/> -+ </target> - - <!-- ALL --> - <target name="all" -! depends="compile,compile-xml,compile-junit-tests,javadoc,zip,targz,maven-bundle,copyjar" - description="Compiles JCommon, builds the jar files, generates the Javadoc HTML pages and creates distribution files (.zip and .tar.gz)."> - </target> - diff --git a/jfreereport/patches/libbase.patch b/jfreereport/patches/libbase.patch new file mode 100644 index 000000000000..87f79aad156b --- /dev/null +++ b/jfreereport/patches/libbase.patch @@ -0,0 +1,19 @@ +--- misc/libbase/build.xml (Revision 6728)
++++ misc/build/libbase/build.xml (Arbeitskopie)
+@@ -6,6 +6,7 @@
+ <property name="build.classes" value="${build}/classes"/>
+ <property name="build.doc" value="${build}/api"/>
+ <property name="build.lib" value="${build}/lib"/>
++ <property name="lib" value="lib"/>
+
+ <!-- Targets -->
+ <!-- Prepare build directories -->
+@@ -18,7 +19,7 @@
+
+ <!-- Setup the compile classpath -->
+ <path id="classpath">
+- <fileset dir="lib">
++ <fileset dir="${lib}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
diff --git a/jfreereport/patches/libfonts.patch b/jfreereport/patches/libfonts.patch index 0a088773db3a..de09e87b32d6 100644 --- a/jfreereport/patches/libfonts.patch +++ b/jfreereport/patches/libfonts.patch @@ -1,21 +1,10 @@ -*** misc/libfonts/build.properties Sun May 27 19:19:06 2007 ---- misc/build/libfonts/build.properties Fri Jul 27 09:05:17 2007 -*************** -*** 14,21 **** - - # - # Make sure that JDK 1.2 compatible class files are generated - build.target=1.4 -! build.source=1.2 - build.retro.target=1.2 - build.retro.jdk=/opt/jdk1.2.2 - ---- 14,21 ---- - - # - # Make sure that JDK 1.2 compatible class files are generated - build.target=1.4 -! build.source=1.3 - build.retro.target=1.2 - build.retro.jdk=/opt/jdk1.2.2 - +--- misc/libfonts/build.xml (Revision 6728)
++++ misc/build/libfonts/build.xml (Arbeitskopie)
+@@ -23,6 +23,6 @@
+ <!-- Setup the compile classpath -->
+ <path id="classpath">
+- <fileset dir="lib">
++ <fileset dir="${lib}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
diff --git a/jfreereport/patches/libformula.patch b/jfreereport/patches/libformula.patch index af163d8380bc..07968b448675 100644 --- a/jfreereport/patches/libformula.patch +++ b/jfreereport/patches/libformula.patch @@ -1,289 +1,27 @@ -*** misc/libformula/build.properties Mon May 21 19:44:21 2007 ---- misc/build/libformula/build.properties Fri Jul 27 09:05:29 2007 -*************** -*** 18,25 **** - - # - # Make sure that JDK 1.2 compatible class files are generated - build.target=1.4 -! build.source=1.2 - build.retro.target=1.2 - build.retro.jdk=/opt/jdk1.2.2 - ---- 18,25 ---- - - # - # Make sure that JDK 1.2 compatible class files are generated - build.target=1.4 -! build.source=1.3 - build.retro.target=1.2 - build.retro.jdk=/opt/jdk1.2.2 - ---- misc/libformula/source/org/jfree/formula/function/text/MidFunctionDescription.java 2007-10-18 08:21:30.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/text/MidFunctionDescription.java 2008-07-07 14:44:01.790739928 +0200 -@@ -62,7 +62,7 @@ - - public Type getParameterType(final int position) - { -- if(position == 1) -+ if(position == 0) - { - return TextType.TYPE; +--- misc/libformula/source/org/pentaho/reporting/libraries/formula/function/datetime/DateDifFunction.java 2008-12-12 13:04:46.000000000 +0100 ++++ misc/build/libformula/source/org/pentaho/reporting/libraries/formula/function/datetime/DateDifFunction.java 2008-12-15 08:15:18.293125000 +0100 +@@ -198,12 +198,6 @@ + LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE); } ---- misc/libformula/source/org/jfree/formula/function/AbstractFunctionDescription.java 2007-10-18 08:21:39.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/AbstractFunctionDescription.java 2008-09-04 08:17:14.114375000 +0200 -@@ -31,6 +31,7 @@ - package org.jfree.formula.function; - - import java.util.Locale; -+import java.util.MissingResourceException; - import java.util.ResourceBundle; - - /** -@@ -72,7 +73,15 @@ - - protected ResourceBundle getBundle(final Locale locale) - { -- return ResourceBundle.getBundle(bundleName, locale); -+ try -+ { -+ return ResourceBundle.getBundle(bundleName, locale); -+ } -+ catch(MissingResourceException ex) -+ { -+ return ResourceBundle.getBundle(bundleName, Locale.ENGLISH); -+ } -+ // return ResourceBundle.getBundle(bundleName, locale); - } - - public String getDisplayName(final Locale locale) ---- misc/libformula/source/org/jfree/formula/function/datetime/Hour-Function.properties 2007-10-18 08:21:38.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/datetime/Hour-Function.properties 2008-09-04 13:57:59.458125000 +0200 -@@ -5,4 +5,4 @@ - display-name=HOUR - description=Returns the hour (0 through 23) from a time. - parameter.0.display-name=Time --parameter.0.description=The time -+parameter.0.description=The time. ---- misc/libformula/source/org/jfree/formula/function/information/IsBlank-Function.properties 2007-10-18 08:21:36.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsBlank-Function.properties 2008-09-08 14:25:30.271875000 +0200 -@@ -4,6 +4,6 @@ - - display-name=ISBLANK - description=Checks, whether the value is undefined (null). --parameter.0.description=A value. -+parameter.0.description=The value to be tested. - parameter.0.display-name=Value - ---- misc/libformula/source/org/jfree/formula/function/information/IsErr-Function.properties 2007-10-18 08:21:36.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsErr-Function.properties 2008-09-08 14:25:30.303125000 +0200 -@@ -4,5 +4,5 @@ - - display-name=ISERR - description=Tells if the parameter is of error type but returns false if the error is of type NA. --parameter.0.description=A value. -+parameter.0.description=The value to be tested. - parameter.0.display-name=Value ---- misc/libformula/source/org/jfree/formula/function/information/IsError-Function.properties 2007-10-18 08:21:36.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsError-Function.properties 2008-09-08 14:27:09.865625000 +0200 -@@ -3,6 +3,6 @@ - # - - display-name=ISERROR --description=Tells if the parameter is of error type but returns false. --parameter.0.description=A value. -+description=Returns TRUE if the value is an error value. -+parameter.0.description=The value to be tested. - parameter.0.display-name=Value ---- misc/libformula/source/org/jfree/formula/function/information/IsEven-Function.properties 2007-10-18 08:21:36.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsEven-Function.properties 2008-09-08 14:25:30.350000000 +0200 -@@ -4,6 +4,6 @@ - - display-name=ISEVEN - description=Checks whatever the value is an even number. --parameter.0.description=A value. -+parameter.0.description=The value to be tested. - parameter.0.display-name=Value - ---- misc/libformula/source/org/jfree/formula/function/information/IsLogical-Function.properties 2007-10-18 08:21:36.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsLogical-Function.properties 2008-09-08 14:27:49.021875000 +0200 -@@ -3,7 +3,7 @@ - # - - display-name=ISLOGICAL --description=Checks whatever the value is of type Logical. --parameter.0.description=A value. -+description=Returns TRUE if the value carries a logical number format. -+parameter.0.description=The value to be tested. - parameter.0.display-name=Value - ---- misc/libformula/source/org/jfree/formula/function/information/IsNa-Function.properties 2007-10-18 08:21:36.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsNa-Function.properties 2008-09-08 14:25:30.412500000 +0200 -@@ -4,5 +4,5 @@ - - display-name=ISNA - description=Tells if the parameter is of error type NA. --parameter.0.description=A value. -+parameter.0.description=The value to be tested. - parameter.0.display-name=Value ---- misc/libformula/source/org/jfree/formula/function/information/IsNonText-Function.properties 2007-10-18 08:21:36.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsNonText-Function.properties 2008-09-08 14:29:02.709375000 +0200 -@@ -3,7 +3,7 @@ - # - - display-name=ISNONTEXT --description=Checks whatever the value is not of type Text. --parameter.0.description=A value. -+description=Returns TRUE if the value is not text. -+parameter.0.description=The value to be tested. - parameter.0.display-name=Value - ---- misc/libformula/source/org/jfree/formula/function/information/IsNumber-Function.properties 2007-10-18 08:21:36.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsNumber-Function.properties 2008-09-08 14:25:30.475000000 +0200 -@@ -4,6 +4,6 @@ - - display-name=ISNUMBER - description=Checks whatever the value is of type Number. --parameter.0.description=A value. -+parameter.0.description=The value to be tested. - parameter.0.display-name=Value - ---- misc/libformula/source/org/jfree/formula/function/information/IsOdd-Function.properties 2007-10-18 08:21:36.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsOdd-Function.properties 2008-09-08 14:25:30.506250000 +0200 -@@ -4,6 +4,6 @@ - - display-name=ISODD - description=Checks whatever the value is an odd number. --parameter.0.description=A value. -+parameter.0.description=The value to be tested. - parameter.0.display-name=Value - ---- misc/libformula/source/org/jfree/formula/function/information/IsRef-Function.properties 2008-12-02 08:28:02.985345116 +0100 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsRef-Function.properties 2008-11-18 12:04:59.132277875 +0100 -@@ -1 +1,9 @@ --dummy -+# -+# Copyright (c) 2007, Pentaho Corporation. All Rights Reserved. -+# -+ -+display-name=ISREF -+description=Checks whatever the value is a reference. -+parameter.0.description=A value. -+parameter.0.display-name=Value -+ ---- misc/libformula/source/org/jfree/formula/function/information/IsText-Function.properties 2007-10-18 08:21:36.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/information/IsText-Function.properties 2008-09-08 14:28:53.631250000 +0200 -@@ -3,7 +3,7 @@ - # - - display-name=ISTEXT --description=Checks whatever the value is of type Text. --parameter.0.description=A value. -+description=Returns TRUE if value is text. -+parameter.0.description=The value to be tested. - parameter.0.display-name=Value - ---- misc/libformula/source/org/jfree/formula/function/logical/If-Function.properties 2007-10-18 08:21:39.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/logical/If-Function.properties 2008-12-02 08:27:33.611012901 +0100 -@@ -3,11 +3,11 @@ - # - - display-name=IF --description=Conditional execution --parameter.0.description=Condition --parameter.0.display-name=A Condition --parameter.1.description=True-Term --parameter.1.display-name=A term that is evaluated if the condition evaluates to true. --parameter.2.description=False-Term --parameter.2.display-name=A term that is evaluated if the condition evaluates to false. -+description=Specifies a logical test to be performed. -+parameter.0.display-name=Test -+parameter.0.description=Any value or expression which can be either TRUE or FALSE. -+parameter.1.display-name=Then_value -+parameter.1.description=The result of the function if the logical test returns a TRUE. -+parameter.2.display-name=Otherwise_value -+parameter.2.description=The result of the function if the logical test returns FALSE. - ---- misc/libformula/source/org/jfree/formula/function/logical/Not-Function.properties 2007-10-18 08:21:39.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/logical/Not-Function.properties 2008-09-05 09:14:37.771875000 +0200 -@@ -2,8 +2,8 @@ - # Copyright (c) 2007, Pentaho Corporation. All Rights Reserved. - # - --display-name=AND --description=Logical AND --parameter.0.description=Condition --parameter.0.display-name=A Condition -+display-name=NOT -+description=Compute logical NOT of the parameter. -+parameter.0.description=A logical parameter. -+parameter.0.display-name=Value - ---- misc/libformula/source/org/jfree/formula/function/logical/Or-Function.properties 2007-10-18 08:21:39.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/logical/Or-Function.properties 2008-09-05 09:15:17.990625000 +0200 -@@ -3,7 +3,6 @@ - # - - display-name=OR --description=Logical OR --parameter.0.description=Condition --parameter.0.display-name=A Condition +- if (res < 0) +- { +- throw new EvaluationException( +- LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE); +- } - -+description=Compute logical OR of all parameters. -+parameter.0.description=A logical parameter. -+parameter.0.display-name=Value ---- misc/libformula/source/org/jfree/formula/function/math/Even-Function.properties 2007-10-18 08:21:37.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/math/Even-Function.properties 2008-09-18 08:20:28.037500000 +0200 -@@ -2,7 +2,7 @@ - # Copyright (c) 2007, Pentaho Corporation. All Rights Reserved. - # - --display-name=Even -+display-name=EVEN - description=Returns the rounding a number up to the nearest even integer. - parameter.0.description=A value. - parameter.0.display-name=Value ---- misc/libformula/source/org/jfree/formula/function/math/ModFunctionDescription.java 2007-10-18 08:21:37.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/math/ModFunctionDescription.java 2008-11-18 12:04:59.248540478 +0100 -@@ -56,7 +56,7 @@ - - public int getParameterCount() - { -- return 12; -+ return 2; + //noinspection UnpredictableBigDecimalConstructorCall + return new TypeValuePair(NumberType.GENERIC_NUMBER, new BigDecimal((double) res)); } +--- misc/libformula/source/org/pentaho/reporting/libraries/formula/lvalues/FormulaFunction.java 2008-12-12 13:04:46.000000000 +0100 ++++ misc/build/libformula/source/org/pentaho/reporting/libraries/formula/lvalues/FormulaFunction.java 2008-12-15 08:13:14.308750000 +0100 +@@ -161,7 +161,8 @@ - public Type getParameterType(final int position) ---- misc/libformula/source/org/jfree/formula/function/text/Trim-Function.properties 2007-10-18 08:21:29.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/function/text/Trim-Function.properties 2008-09-18 08:19:05.146875000 +0200 -@@ -2,7 +2,7 @@ - # Copyright (c) 2007, Pentaho Corporation. All Rights Reserved. - # - --display-name=LOWER -+display-name=TRIM - description=Returns the given text free of leading and trailing spaces. Internal multiple spaces are replaced by one. - parameter.0.description=A value. - parameter.0.display-name=Value ---- misc/libformula/source/org/jfree/formula/parser/FormulaParser.java 2007-10-18 08:21:39.000000000 +0200 -+++ misc/build/libformula/source/org/jfree/formula/parser/FormulaParser.java 2008-09-10 13:22:53.306875000 +0200 -@@ -87,8 +87,15 @@ - // x.initialize(new DefaultFormulaContext()); - // System.out.println(x); - -- final LValue x = parser.parse("(1)()"); -- x.initialize(new DefaultFormulaContext()); -- System.out.println(x); -+ final GeneratedFormulaParserTokenManager tokenParser = new GeneratedFormulaParserTokenManager(new JavaCharStream(new StringReader("DATEDIFF"),1,1)); -+ Token token = tokenParser.getNextToken(); -+ StringBuffer a = new StringBuffer(); -+ while( token.kind != GeneratedFormulaParserConstants.EOF ) -+ { -+ a.append(token.image); -+ token = tokenParser.getNextToken(); -+ } -+ -+ System.out.println(a.toString()); + for (int i = 0; i < parameters.length; i++) + { +- parameters[i].initialize(context); ++ if ( parameters[i] != null ) ++ parameters[i].initialize(context); + } } - } + diff --git a/jfreereport/patches/liblayout.patch b/jfreereport/patches/liblayout.patch index a304ccf59c25..a30fdd82a9f6 100644 --- a/jfreereport/patches/liblayout.patch +++ b/jfreereport/patches/liblayout.patch @@ -1,79 +1,10 @@ -*** misc/liblayout/build.properties Wed May 30 19:06:41 2007 ---- misc/build/liblayout/build.properties Fri Jul 27 09:05:42 2007 -*************** -*** 14,21 **** - - # - # Make sure that JDK 1.2 compatible class files are generated -! build.target=1.2 -! build.source=1.2 - build.retro.jdk=/opt/jdk1.2.2 - - # ---- 14,21 ---- - - # - # Make sure that JDK 1.2 compatible class files are generated -! build.target=1.3 -! build.source=1.3 - build.retro.jdk=/opt/jdk1.2.2 - - # -*************** -*** 39,51 **** - # JFree.org/JFreeReport libraries - jcommon-jar-file=jcommon-1.0.10.jar - flute-jar-file=flute-1.3-jfree-20061107.jar -! libloader-jar-file=libloader-0.3.5.jar -! librepository-jar-file=librepository-0.1.3.jar - # - # One of these is required. - libfonts-core-jar-file=libfonts-core-0.3.3.jar -! libfonts-jar-file=libfonts-0.3.2.jar -! libxml-jar-file=libxml-0.9.8.jar - - # 3rd party libraries .. - ---- 39,51 ---- - # JFree.org/JFreeReport libraries - jcommon-jar-file=jcommon-1.0.10.jar - flute-jar-file=flute-1.3-jfree-20061107.jar -! libloader-jar-file=libloader-0.3.6.jar -! librepository-jar-file=librepository-0.1.4.jar - # - # One of these is required. - libfonts-core-jar-file=libfonts-core-0.3.3.jar -! libfonts-jar-file=libfonts-0.3.3.jar -! libxml-jar-file=libxml-0.9.9.jar - - # 3rd party libraries .. - -*************** -*** 66,69 **** - liblayout-bundle-file=${liblayout.name}-${liblayout.version}-bundle.jar - liblayout-jar-file=${liblayout.name}-${liblayout.version}.jar - liblayout-core-jar-file=${liblayout.name}-core-${liblayout.version}.jar -! module-output-pdf-jar-file=${liblayout.name}-module-output-pdf-${liblayout.version}.jar ---- 66,69 ---- - liblayout-bundle-file=${liblayout.name}-${liblayout.version}-bundle.jar - liblayout-jar-file=${liblayout.name}-${liblayout.version}.jar - liblayout-core-jar-file=${liblayout.name}-core-${liblayout.version}.jar -! module-output-pdf-jar-file=${liblayout.name}-module-output-pdf-${liblayout.version}.jar -*** misc/liblayout/build.xml Thu Oct 18 08:21:18 2007 ---- misc/build/liblayout/build.xml Mon Oct 22 12:42:45 2007 -*************** -*** 55,67 **** - <isClassAvailableEx class-name="org.jfree.xmlns.LibXmlInfo" - property-name="lib.xmlns.present"> - <test-classpath> -- <pathelement location="${libdir}/${jaxp-jar-file}"/> - <pathelement location="${libdir}/${libxml-jar-file}"/> - <pathelement location="${libdir}/${jcommon-jar-file}"/> - <pathelement location="${libdir}/${libloader-jar-file}"/> - </test-classpath> - <additional-tests> -- <available file="${libdir}/${jaxp-jar-file}"/> - <available file="${libdir}/${libxml-jar-file}"/> - <available file="${libdir}/${jcommon-jar-file}"/> - </additional-tests> ---- 55,65 ---- +--- misc/liblayout/build.xml (Revision 6728)
++++ misc/build/liblayout/build.xml (Arbeitskopie)
+@@ -24,6 +24,6 @@
+ <!-- Setup the compile classpath -->
+ <path id="classpath">
+- <fileset dir="lib">
++ <fileset dir="${lib}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
diff --git a/jfreereport/patches/libloader.patch b/jfreereport/patches/libloader.patch index 75f1b190c31b..67b538f35f48 100644 --- a/jfreereport/patches/libloader.patch +++ b/jfreereport/patches/libloader.patch @@ -1,21 +1,11 @@ -*** misc/libloader/build.properties Mon May 21 19:29:36 2007 ---- misc/build/libloader/build.properties Fri Jul 27 09:05:56 2007 -*************** -*** 14,21 **** - - # - # Make sure that JDK 1.2 compatible class files are generated -! build.target=1.4 -! build.source=1.2 - build.retro.jdk=/opt/jdk1.2.2 - # - # All path settings are relative to the project root directory ---- 14,21 ---- - - # - # Make sure that JDK 1.2 compatible class files are generated -! build.target=1.4 -! build.source=1.3 - build.retro.jdk=/opt/jdk1.2.2 - # - # All path settings are relative to the project root directory +--- misc/libloader/build.xml 2009-02-12 18:01:56.000000000 +0100
++++ misc/build/libloader/build.xml 2009-02-13 09:57:21.856601684 +0100
+@@ -23,7 +23,7 @@
+
+ <!-- Setup the compile classpath -->
+ <path id="classpath">
+- <fileset dir="lib">
++ <fileset dir="${lib}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
diff --git a/jfreereport/patches/librepository.patch b/jfreereport/patches/librepository.patch index dd86f848f87b..9fe1e48ccdc6 100644 --- a/jfreereport/patches/librepository.patch +++ b/jfreereport/patches/librepository.patch @@ -1,22 +1,10 @@ -*** misc/librepository/build.properties Sun May 27 19:23:24 2007 ---- misc/build/librepository/build.properties Fri Jul 27 09:06:11 2007 -*************** -*** 18,25 **** - - # - # Make sure that JDK 1.2 compatible class files are generated - build.target=1.4 -! build.source=1.2 - build.retro.target=1.2 - build.retro.jdk=/opt/jdk1.2.2 - ---- 18,25 ---- - - # - # Make sure that JDK 1.2 compatible class files are generated - build.target=1.4 -! build.source=1.3 - build.retro.target=1.2 - build.retro.jdk=/opt/jdk1.2.2 - - +--- misc/librepository/build.xml (Revision 6728)
++++ misc/build/librepository/build.xml (Arbeitskopie)
+@@ -24,6 +24,6 @@
+ <!-- Setup the compile classpath -->
+ <path id="classpath">
+- <fileset dir="lib">
++ <fileset dir="${lib}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
diff --git a/jfreereport/patches/libserializer.patch b/jfreereport/patches/libserializer.patch new file mode 100644 index 000000000000..b2a610a6478f --- /dev/null +++ b/jfreereport/patches/libserializer.patch @@ -0,0 +1,10 @@ +--- misc/libserializer/build.xml (Revision 6728)
++++ misc/build/libserializer/build.xml (Arbeitskopie)
+@@ -24,6 +24,6 @@
+ <!-- Setup the compile classpath -->
+ <path id="classpath">
+- <fileset dir="lib">
++ <fileset dir="${lib}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
diff --git a/jfreereport/patches/libxml.patch b/jfreereport/patches/libxml.patch index 1193da101b04..70c2aecc2444 100644 --- a/jfreereport/patches/libxml.patch +++ b/jfreereport/patches/libxml.patch @@ -1,21 +1,10 @@ -*** misc/libxml/build.properties Sun May 27 20:44:28 2007 ---- misc/build/libxml/build.properties Fri Jul 27 09:06:22 2007 -*************** -*** 18,25 **** - - # - # Make sure that JDK 1.2 compatible class files are generated - build.target=1.4 -! build.source=1.2 - - # You probably want to override this in your local build setup file - build.retro.target=1.2 ---- 18,25 ---- - - # - # Make sure that JDK 1.2 compatible class files are generated - build.target=1.4 -! build.source=1.3 - - # You probably want to override this in your local build setup file - build.retro.target=1.2 +--- misc/libxml/build.xml (Revision 6728)
++++ misc/build/libxml/build.xml (Arbeitskopie)
+@@ -24,6 +24,6 @@
+ <!-- Setup the compile classpath -->
+ <path id="classpath">
+- <fileset dir="lib">
++ <fileset dir="${lib}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
diff --git a/jfreereport/patches/pentaho-reporting-flow-engine.patch b/jfreereport/patches/pentaho-reporting-flow-engine.patch deleted file mode 100644 index 8030461d7777..000000000000 --- a/jfreereport/patches/pentaho-reporting-flow-engine.patch +++ /dev/null @@ -1,312 +0,0 @@ ---- misc/core/build.properties 2007-10-18 08:20:01.000000000 +0200 -+++ misc/build/core/build.properties 2008-09-08 11:51:22.178125000 +0200 -@@ -17,8 +17,8 @@ - - # - # Make sure that JDK 1.2 compatible class files are generated --build.target=1.2 --build.source=1.2 -+build.target=1.3 -+build.source=1.3 - build.retro.jdk=/opt/jdk1.2.2 - - # -@@ -40,15 +40,15 @@ - - # Used by: core libraries - jcommon-jar-file=jcommon-1.0.10.jar --jcommon-serializer-jar-file=jcommon-serializer-0.1.0.jar --libfonts-jar-file=libfonts-0.3.2.jar -+jcommon-serializer-jar-file=jcommon-serializer-0.2.0.jar -+libfonts-jar-file=libfonts-0.3.3.jar - libfonts-core-jar-file=libfonts-0.3.2.jar - libfonts-itext-jar-file=libfonts-0.3.2.jar - liblayout-jar-file=liblayout-0.2.8.jar --libloader-jar-file=libloader-0.3.5.jar --libxml-jar-file=libxml-0.9.8.jar --libformula-jar-file=libformula-0.1.13.jar --librepository-jar-file=librepository-0.1.3.jar -+libloader-jar-file=libloader-0.3.6.jar -+libxml-jar-file=libxml-0.9.9.jar -+libformula-jar-file=libformula-0.1.14.jar -+librepository-jar-file=librepository-0.1.4.jar - flute-jar-file=flute-1.3-jfree-20061107.jar - - # ---- misc/core/build.xml 2007-10-18 08:20:01.000000000 +0200 -+++ misc/build/core/build.xml 2008-09-08 11:51:22.162500000 +0200 -@@ -54,13 +54,11 @@ - <isClassAvailableEx class-name="org.jfree.xmlns.LibXmlInfo" - property-name="lib.xmlns.present"> - <test-classpath> -- <pathelement location="${libdir}/${jaxp-jar-file}"/> - <pathelement location="${libdir}/${libxml-jar-file}"/> - <pathelement location="${libdir}/${jcommon-jar-file}"/> - <pathelement location="${libdir}/${libloader-jar-file}"/> - </test-classpath> - <additional-tests> -- <available file="${libdir}/${jaxp-jar-file}"/> - <available file="${libdir}/${libxml-jar-file}"/> - <available file="${libdir}/${jcommon-jar-file}"/> - </additional-tests> -@@ -136,6 +134,7 @@ - source-dir="source"> - <all-sources> - <exclude name="org/jfree/report/modules/gui/pdf/**" unless="lib.itext.present"/> -+ <exclude name="org/jfree/report/modules/gui/swing/pdf/**" unless="lib.itext.present"/> - </all-sources> - <all-classpath> - <pathelement location="${libdir}/${jcommon-jar-file}"/> -@@ -168,6 +167,7 @@ - <include name="*.jpg"/> - <include name="**/*.jpg"/> - <exclude name="org/jfree/report/modules/gui/pdf/**" unless="lib.itext.present"/> -+ <exclude name="org/jfree/report/modules/gui/swing/pdf/**" unless="lib.itext.present"/> - </all-resources> - </build-all> - </target> -@@ -179,6 +179,7 @@ - jdk-dir="${build.retro.jdk}"> - <all-sources> - <exclude name="org/jfree/report/modules/gui/pdf/**" unless="lib.itext.present"/> -+ <exclude name="org/jfree/report/modules/gui/swing/pdf/**" unless="lib.itext.present"/> - </all-sources> - <all-classpath> - <pathelement location="${libdir}/${jcommon-jar-file}"/> -@@ -211,6 +212,7 @@ - <include name="*.jpg"/> - <include name="**/*.jpg"/> - <exclude name="org/jfree/report/modules/gui/pdf/**" unless="lib.itext.present"/> -+ <exclude name="org/jfree/report/modules/gui/swing/pdf/**" unless="lib.itext.present"/> - </all-resources> - </build-retro> - </target> ---- misc/core/source/org/jfree/report/expressions/ReportFormulaContext.java 2007-10-18 08:19:32.000000000 +0200 -+++ misc/build/core/source/org/jfree/report/expressions/ReportFormulaContext.java 2008-10-01 09:38:50.951250000 +0200 -@@ -28,7 +28,6 @@ - * (C) Copyright 2000-2005, by Object Refinery Limited. - * (C) Copyright 2005-2007, by Pentaho Corporation. - */ -- - package org.jfree.report.expressions; - - import org.jfree.formula.ContextEvaluationException; -@@ -40,6 +39,9 @@ - import org.jfree.formula.typing.Type; - import org.jfree.formula.typing.TypeRegistry; - import org.jfree.formula.typing.coretypes.AnyType; -+import org.jfree.formula.typing.coretypes.DateTimeType; -+import org.jfree.formula.typing.coretypes.NumberType; -+import org.jfree.formula.typing.coretypes.TextType; - import org.jfree.report.DataFlags; - import org.jfree.report.DataRow; - import org.jfree.report.DataSourceException; -@@ -53,101 +55,111 @@ - */ - public class ReportFormulaContext implements FormulaContext - { -- private FormulaContext backend; -- private DataRow dataRow; -- private Object declaringElement; -- -- public ReportFormulaContext(final FormulaContext backend, -- final DataRow dataRow) -- { -- this.backend = backend; -- this.dataRow = dataRow; -- } -- -- public LocalizationContext getLocalizationContext() -- { -- return backend.getLocalizationContext(); -- } -- -- public Configuration getConfiguration() -- { -- return backend.getConfiguration(); -- } -- -- public FunctionRegistry getFunctionRegistry() -- { -- return backend.getFunctionRegistry(); -- } -- -- public TypeRegistry getTypeRegistry() -- { -- return backend.getTypeRegistry(); -- } -- -- public OperatorFactory getOperatorFactory() -- { -- return backend.getOperatorFactory(); -- } -- -- public boolean isReferenceDirty(final Object name) throws ContextEvaluationException -- { -- try -- { -- final DataFlags flags = dataRow.getFlags(String.valueOf(name)); -- if (flags == null) -- { -- throw new ContextEvaluationException -- (new LibFormulaErrorValue(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); -- } -- return flags.isChanged(); -- } -- catch(Exception e) -- { -- throw new ContextEvaluationException -- (new LibFormulaErrorValue(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); -- } -- } -- -- public Type resolveReferenceType(final Object name) -- { -- return AnyType.TYPE; -- } -- -- public Object resolveReference(final Object name) throws ContextEvaluationException -- { -- if (name == null) -- { -- throw new NullPointerException(); -- } -- try -- { -- return dataRow.get(String.valueOf(name)); -- } -- catch (DataSourceException e) -- { -- Log.debug ("Error while resolving formula reference: ", e); -- throw new ContextEvaluationException(new LibFormulaErrorValue -- (LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); -- } -- } -- -- public DataRow getDataRow() -- { -- return dataRow; -- } -- -- public void setDataRow(final DataRow dataRow) -- { -- this.dataRow = dataRow; -- } -- -- public Object getDeclaringElement() -- { -- return declaringElement; -- } -- -- public void setDeclaringElement(final Object declaringElement) -- { -- this.declaringElement = declaringElement; -- } -+ -+ private FormulaContext backend; -+ private DataRow dataRow; -+ private Object declaringElement; -+ -+ public ReportFormulaContext(final FormulaContext backend, -+ final DataRow dataRow) -+ { -+ this.backend = backend; -+ this.dataRow = dataRow; -+ } -+ -+ public LocalizationContext getLocalizationContext() -+ { -+ return backend.getLocalizationContext(); -+ } -+ -+ public Configuration getConfiguration() -+ { -+ return backend.getConfiguration(); -+ } -+ -+ public FunctionRegistry getFunctionRegistry() -+ { -+ return backend.getFunctionRegistry(); -+ } -+ -+ public TypeRegistry getTypeRegistry() -+ { -+ return backend.getTypeRegistry(); -+ } -+ -+ public OperatorFactory getOperatorFactory() -+ { -+ return backend.getOperatorFactory(); -+ } -+ -+ public boolean isReferenceDirty(final Object name) throws ContextEvaluationException -+ { -+ try -+ { -+ final DataFlags flags = dataRow.getFlags(String.valueOf(name)); -+ if ( flags == null ) -+ { -+ throw new ContextEvaluationException(new LibFormulaErrorValue(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); -+ } -+ return flags.isChanged(); -+ } catch ( Exception e ) -+ { -+ throw new ContextEvaluationException(new LibFormulaErrorValue(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); -+ } -+ } -+ -+ public Type resolveReferenceType(final Object name) -+ { -+ try -+ { -+ final DataFlags flags = dataRow.getFlags(String.valueOf(name)); -+ if ( flags != null) -+ { -+ if ( flags.isDate() ) -+ return DateTimeType.DATE_TYPE; -+ if ( flags.isNumeric() ) -+ return NumberType.GENERIC_NUMBER; -+ return TextType.TYPE; -+ } -+ } catch ( DataSourceException ex ) -+ { -+ } -+ return AnyType.TYPE; -+ } -+ -+ public Object resolveReference(final Object name) throws ContextEvaluationException -+ { -+ if ( name == null ) -+ { -+ throw new NullPointerException(); -+ } -+ try -+ { -+ return dataRow.get(String.valueOf(name)); -+ } catch ( DataSourceException e ) -+ { -+ Log.debug("Error while resolving formula reference: ", e); -+ throw new ContextEvaluationException(new LibFormulaErrorValue(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE)); -+ } -+ } -+ -+ public DataRow getDataRow() -+ { -+ return dataRow; -+ } -+ -+ public void setDataRow(final DataRow dataRow) -+ { -+ this.dataRow = dataRow; -+ } -+ -+ public Object getDeclaringElement() -+ { -+ return declaringElement; -+ } -+ -+ public void setDeclaringElement(final Object declaringElement) -+ { -+ this.declaringElement = declaringElement; -+ } - } diff --git a/jfreereport/prj/build.lst b/jfreereport/prj/build.lst index 1300a71bacb7..62cdd738c3b6 100644 --- a/jfreereport/prj/build.lst +++ b/jfreereport/prj/build.lst @@ -1,13 +1,13 @@ -jf jfreereport : solenv NULL +jf jfreereport : solenv APACHE_COMMONS:apache-commons NULL jf jfreereport usr1 - all jf_mkout NULL jf jfreereport\java\sac nmake - all jf_sac NULL -jf jfreereport\java\jcommon nmake - all jf_jcommon NULL +jf jfreereport\java\libbase nmake - all jf_libbase NULL jf jfreereport\java\flute nmake - all jf_flute jf_sac NULL -jf jfreereport\java\libxml nmake - all jf_libxml jf_jcommon jf_libloader NULL -jf jfreereport\java\libloader nmake - all jf_libloader jf_jcommon NULL -jf jfreereport\java\libfonts nmake - all jf_libfonts jf_jcommon jf_libloader NULL -jf jfreereport\java\libformula nmake - all jf_libformula jf_jcommon NULL -jf jfreereport\java\librepository nmake - all jf_librepository jf_jcommon NULL -jf jfreereport\java\jcommon-serializer nmake - all jf_jcommon-serializer jf_jcommon NULL -jf jfreereport\java\jfreereport nmake - all jf_jfreereport jf_liblayout jf_libformula jf_jcommon-serializer NULL -jf jfreereport\java\liblayout nmake - all jf_liblayout jf_jcommon jf_flute jf_libfonts jf_libloader jf_librepository jf_libxml jf_sac NULL +jf jfreereport\java\libloader nmake - all jf_libloader jf_libbase NULL +jf jfreereport\java\libxml nmake - all jf_libxml jf_libbase jf_libloader NULL +jf jfreereport\java\libformula nmake - all jf_libformula jf_libbase NULL +jf jfreereport\java\libfonts nmake - all jf_libfonts jf_libbase jf_libloader NULL +jf jfreereport\java\librepository nmake - all jf_librepository jf_libbase NULL +jf jfreereport\java\libserializer nmake - all jf_libserializer jf_libbase NULL +jf jfreereport\java\jfreereport nmake - all jf_jfreereport jf_liblayout jf_libformula jf_libserializer NULL +jf jfreereport\java\liblayout nmake - all jf_liblayout jf_libbase jf_flute jf_libfonts jf_libloader jf_librepository jf_libxml jf_sac NULL diff --git a/reportbuilder/images/em42.png b/reportbuilder/images/em42.png Binary files differnew file mode 100644 index 000000000000..31f48ea8fb69 --- /dev/null +++ b/reportbuilder/images/em42.png diff --git a/reportbuilder/images/em42_hc.png b/reportbuilder/images/em42_hc.png Binary files differnew file mode 100644 index 000000000000..3870cc4709d4 --- /dev/null +++ b/reportbuilder/images/em42_hc.png diff --git a/reportbuilder/java/com/sun/star/report/DataRow.java b/reportbuilder/java/com/sun/star/report/DataRow.java new file mode 100644 index 000000000000..1875578213ed --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/DataRow.java @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataRow.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +/** + * This feeds data into the reporting engine, in case the data has been provided + * by the caller. The methods are a mix of TableModel methods and methods borrowed + * from the java.sql.ResultSet interface. + * + * The column and row index starts at 1 (as it is done in JDBC). + * + * @author Thomas Morgner + */ +public interface DataRow +{ + + public int getColumnCount() throws DataSourceException; + + public String getColumnName(int column) throws DataSourceException; + + public Object getObject(int column) throws DataSourceException; +} diff --git a/reportbuilder/java/com/sun/star/report/DataSource.java b/reportbuilder/java/com/sun/star/report/DataSource.java new file mode 100644 index 000000000000..20f83a8a7798 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/DataSource.java @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataSource.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +/** + * This feeds data into the reporting engine, in case the data has been provided + * by the caller. The methods are a mix of TableModel methods and methods borrowed + * from the java.sql.ResultSet interface. + * + * The column and row index starts at 1 (as it is done in JDBC). + * + * @author Thomas Morgner + */ +public interface DataSource extends DataRow +{ + + public int getRowCount() throws DataSourceException; + + public boolean absolute(int row) throws DataSourceException; + + public boolean next() throws DataSourceException; + + public void close() throws DataSourceException; +} diff --git a/reportbuilder/java/com/sun/star/report/DataSourceException.java b/reportbuilder/java/com/sun/star/report/DataSourceException.java new file mode 100644 index 000000000000..cbb6b394f914 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/DataSourceException.java @@ -0,0 +1,97 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataSourceException.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +/** + * A general exception to indicate that there was an error while accessing the + * datasource. + * + * @author Thomas Morgner + */ +public class DataSourceException extends Exception +{ + + /** + * Constructs a new exception with <code>null</code> as its detail message. + * The cause is not initialized, and may subsequently be initialized by a call + * to {@link #initCause}. + */ + public DataSourceException() + { + super(); + } + + /** + * Constructs a new exception with the specified detail message. The cause is + * not initialized, and may subsequently be initialized by a call to {@link + * #initCause}. + * + * @param message the detail message. The detail message is saved for later + * retrieval by the {@link #getMessage()} method. + */ + public DataSourceException(String message) + { + super(message); + } + + /** + * Constructs a new exception with the specified detail message and cause. + * <p>Note that the detail message associated with <code>cause</code> is + * <i>not</i> automatically incorporated in this exception's detail message. + * + * @param message the detail message (which is saved for later retrieval by + * the {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the {@link + * #getCause()} method). (A <tt>null</tt> value is permitted, + * and indicates that the cause is nonexistent or unknown.) + * @since 1.4 + */ + public DataSourceException(String message, Throwable cause) + { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail message of + * <tt>(cause==null ? null : cause.toString())</tt> (which typically contains + * the class and detail message of <tt>cause</tt>). This constructor is useful + * for exceptions that are little more than wrappers for other throwables (for + * example, {@link PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the {@link + * #getCause()} method). (A <tt>null</tt> value is permitted, + * and indicates that the cause is nonexistent or unknown.) + * @since 1.4 + */ + public DataSourceException(Throwable cause) + { + super(cause); + } +} diff --git a/reportbuilder/java/com/sun/star/report/DataSourceFactory.java b/reportbuilder/java/com/sun/star/report/DataSourceFactory.java new file mode 100644 index 000000000000..01a64436e7c0 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/DataSourceFactory.java @@ -0,0 +1,46 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataSourceFactory.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import java.util.Map; + +/** + * Allows to query the data repository and returns a datasource for the + * specified name and parameters. The parameters-map can be null, if there + * are no parameters required. + * + * @author Thomas Morgner + */ +public interface DataSourceFactory +{ + + public DataSource queryData(String name, Map parameter) + throws DataSourceException; +} diff --git a/reportbuilder/java/com/sun/star/report/ImageService.java b/reportbuilder/java/com/sun/star/report/ImageService.java new file mode 100644 index 000000000000..e0b558933703 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ImageService.java @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ImageService.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import java.io.InputStream; +import java.awt.Dimension; + +/** + * + * @author oj93728 + */ +public interface ImageService +{ + + /** + * @return the mime-type of the image as string. + */ + public String getMimeType(final InputStream image) throws ReportExecutionException; + + /** + * @return the mime-type of the image as string. + */ + public String getMimeType(final byte[] image) throws ReportExecutionException; + + /** + * @returns the dimension in 100th mm. + **/ + public Dimension getImageSize(final InputStream image) throws ReportExecutionException; + + /** + * @returns the dimension in 100th mm. + **/ + public Dimension getImageSize(final byte[] image) throws ReportExecutionException; +} + diff --git a/reportbuilder/java/com/sun/star/report/InputRepository.java b/reportbuilder/java/com/sun/star/report/InputRepository.java new file mode 100644 index 000000000000..5ee660f9d03a --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/InputRepository.java @@ -0,0 +1,85 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: InputRepository.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import java.io.InputStream; +import java.io.IOException; + +/** + * This allows the job processor to load data from a repository. It is assumed, + * that all resource names are given as strings and furthermore, that the names + * identify a resource uniquely within the input repository. + * + * An input repository connects the report processing to the xml definitions. + * Unless defined otherwise, it is assumed, that the input-name is 'content.xml'; + * possible other files are 'settings.xml' and 'styles.xml' (see the Oasis standard + * for details on these files and their contents). + * + * @author Thomas Morgner + */ +public interface InputRepository +{ + + /** + * Returns a unique identifier for this repository. Two repositories accessing + * the same location should return the same id. The identifier must never + * be null. + * + * @return the repository id + */ + public Object getId(); + + public InputStream createInputStream(final String name) throws IOException; + + /** allows to acces sub repositories inside this repository + * + * @param name describes the path to the sub repository + * @return the sub repository + * @throws java.io.IOException when the sub repository doesn't exist. + */ + public InputRepository openInputRepository(final String name) throws IOException; + + /** + * This returns an version number for the given resource. Return zero, if + * the resource is not versionable, else return a unique number for each version. + * As rule of thumb: Increase the version number by at least one for each change + * made to the resource. + * + * @param name the name of the resource + * @return the version number + */ + public long getVersion(final String name); + + public boolean exists(final String name); + + public boolean isReadable(final String name); + + public void closeInputRepository(); +} diff --git a/reportbuilder/java/com/sun/star/report/JobDefinitionException.java b/reportbuilder/java/com/sun/star/report/JobDefinitionException.java new file mode 100644 index 000000000000..74a33077fcf8 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/JobDefinitionException.java @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: JobDefinitionException.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +/** + * Creation-Date: 05.02.2006, 17:36:33 + * + * @author Thomas Morgner + */ +public class JobDefinitionException extends RuntimeException +{ + + /** + * Creates a StackableRuntimeException with no message and no parent. + */ + public JobDefinitionException() + { + } + + /** + * Creates an exception. + * + * @param message the exception message. + */ + public JobDefinitionException(final String message) + { + super(message); + } + + /** + * Creates an exception. + * + * @param message the exception message. + * @param ex the parent exception. + */ + public JobDefinitionException(final String message, final Exception ex) + { + super(message, ex); + } +} diff --git a/reportbuilder/java/com/sun/star/report/JobProgressIndicator.java b/reportbuilder/java/com/sun/star/report/JobProgressIndicator.java new file mode 100644 index 000000000000..00dcdecc9a8d --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/JobProgressIndicator.java @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: JobProgressIndicator.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +/** + * Based on + * http://api.openoffice.org/docs/common/ref/com/sun/star/task/XStatusIndicator.html + * + * @author Thomas Morgner + */ +public interface JobProgressIndicator +{ + + /** + * Updates the progress description. + * + * @param string the new description + */ + public void setText(String string); + + /** + * Initializes the progress indicator and sets the progress description to + * the text given in the parameter <code>text</code>. The progress values + * passed to this indicator will not exceed the given <code>maxValue</code>. + * The value range of this indicator is set to 0 to <code>maxValue</code> + * Stopped indicators must ignore that call. + * + * @param string the progress description + * @param maxValue the maximum value + * @see JobProgressIndicator#setText(String) + */ + public void start(String text, int maxValue); + + /** + * Updates the value to the specified value. Invalid values must be ignored. + * Stopped indicators must ignore that call. + * + * @param value the new value that should be shown now. This must fit the + * range [0..maxValue] as defined in {@link JobProgressIndicator#start(String, int)}. + */ + public void setValue(int value); + + /** + * Stop the progress. A progress indicator cannot be destructed before end() + * has been called. + */ + public void end(); + + /** + * Clear progress value and description. Calling of setValue(0) and + * setText("") should do the same. Stopped indicators must ignore this call. + */ + public void reset(); +} diff --git a/reportbuilder/java/com/sun/star/report/JobProperties.java b/reportbuilder/java/com/sun/star/report/JobProperties.java new file mode 100644 index 000000000000..b0fcff494b87 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/JobProperties.java @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: JobProperties.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +public interface JobProperties +{ + + public void setProperty(String key, Object value) + throws JobDefinitionException; + + public Object getProperty(String key); + + /** + * A type safe clone operation. We derive a copy of all properties, + * so that changes to the original job properties collection does not + * affect the copy. + * + * @return a copy. + */ + public JobProperties copy(); +} diff --git a/reportbuilder/java/com/sun/star/report/OfficeToken.java b/reportbuilder/java/com/sun/star/report/OfficeToken.java new file mode 100644 index 000000000000..5649abdac863 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/OfficeToken.java @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeToken.java,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.report; + +/** + * + * @author Ocke Janssen + */ +public class OfficeToken { + public static final String GRAPHIC = "graphic"; + public static final String GRAPHICS = "Graphics"; + public static final String GRAPHIC_PROPERTIES = "graphic-properties"; + public static final String PARAGRAPH = "paragraph"; + public static final String TRUE = "true"; + public static final String FALSE = "false"; + public static final String FRAME = "frame"; + public static final String STYLE_NAME = "style-name"; + public static final String BACKGROUND_COLOR = "background-color"; + public static final String COVERED_TABLE_CELL = "covered-table-cell"; + public static final String TABLE = "table"; + public static final String TABLE_COLUMN = "table-column"; + public static final String TABLE_COLUMNS = "table-columns"; + public static final String TABLE_HEADER_COLUMNS = "table-header-columns"; + public static final String TABLE_HEADER_ROWS = "table-header-rows"; + public static final String TABLE_ROWS = "table-rows"; + public static final String TABLE_ROW = "table-row"; + public static final String TABLE_CELL = "table-cell"; + public static final String P = "p"; + public static final String OBJECT_OLE = "object-ole"; + public static final String IMAGE = "image"; + public static final String IMAGE_DATA = "image-data"; + public static final String PRESERVE_IRI = "preserve-IRI"; + public static final String SCALE = "scale"; + public static final String NAME = "name"; + public static final String SHAPES = "shapes"; +} diff --git a/reportbuilder/java/com/sun/star/report/OutputRepository.java b/reportbuilder/java/com/sun/star/report/OutputRepository.java new file mode 100644 index 000000000000..915ca1b88324 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/OutputRepository.java @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OutputRepository.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import java.io.OutputStream; +import java.io.IOException; + +/** + * A repository for writing. Providing a repository always assumes, + * that more than one stream can be written. + * + * @author Thomas Morgner + */ +public interface OutputRepository +{ + + /** + * Creates an output stream for writing the data. If there is an entry with + * that name already contained in the repository, try to overwrite it. + * + * @param name + * the name of the output stream + * @param mimeType + * the mime type of the to-be-created output stream. Repository implementations which do not support + * associating a mime time with a stream might ignore this parameter. + * @return the outputstream + * @throws IOException if opening the stream fails + */ + public OutputStream createOutputStream(final String name, final String mimeType) throws IOException; + + /** allows to acces sub repositories inside this repository + * + * @param name describes the path to the sub repository + * @return the sub repository + * @throws java.io.IOException when the sub repository doesn't exist. + */ + public OutputRepository openOutputRepository(final String name, final String mimeType) throws IOException; + + public boolean exists(final String name); + + public boolean existsStorage(final String name); + + public boolean isWritable(final String name); + + public void closeOutputRepository(); +} diff --git a/reportbuilder/java/com/sun/star/report/ParameterMap.java b/reportbuilder/java/com/sun/star/report/ParameterMap.java new file mode 100644 index 000000000000..cf3aed4de598 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ParameterMap.java @@ -0,0 +1,71 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ParameterMap.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +public interface ParameterMap +{ + + /** + * Adds a property to this properties collection. If a property with the given name + * exist, the property will be replaced with the new value. If the value is null, the + * property will be removed. + * + * @param key the property key. + * @param value the property value. + */ + public void put(final String key, final Object value); + + /** + * Retrieves the value stored for a key in this properties collection. + * + * @param key the property key. + * @return The stored value, or <code>null</code> if the key does not exist in this + * collection. + */ + public Object get(final String key); + + /** + * Retrieves the value stored for a key in this properties collection, and returning the + * default value if the key was not stored in this properties collection. + * + * @param key the property key. + * @param defaultValue the default value to be returned when the key is not stored in + * this properties collection. + * @return The stored value, or the default value if the key does not exist in this + * collection. + */ + public Object get(final String key, final Object defaultValue); + + public String[] keys(); + + public void clear(); + + public int size(); +} diff --git a/reportbuilder/java/com/sun/star/report/ReportAddIn.java b/reportbuilder/java/com/sun/star/report/ReportAddIn.java new file mode 100644 index 000000000000..6057a1e20eb2 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportAddIn.java @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportAddIn.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +/** + * A report add-in defines a set of expressions, which can + * be used in the reporting. + * + * Each expression must provide meta-data to support GUI implementors. + * Expressions are assumed to be statefull, if they are not, they are + * free to be implemented as stateless expression. + */ +public interface ReportAddIn +{ + + public int getExpressionCount(); + + public ReportExpression createExpression(int expression); + + public ReportExpressionMetaData getMetaData(int expression); +} diff --git a/reportbuilder/java/com/sun/star/report/ReportEngine.java b/reportbuilder/java/com/sun/star/report/ReportEngine.java new file mode 100644 index 000000000000..549f5bb224c7 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportEngine.java @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportEngine.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +/** + * The job factory collects all required properties to build a reportJob + * object. Implementors should define a suitable set of properties to allow + * the configuration of the created report jobs. + * + * How these properties are collected is beyond the scope of this interface. + * For each type of Job, there should be separate job-factory (remote jobs + * vs. local jobs etc). + * + * @author Thomas Morgner + */ +public interface ReportEngine +{ + + public ReportJobDefinition createJobDefinition(); + + public ReportEngineMetaData getMetaData(); + + /** + * Open points: How to define scheduling? + * + * @return the report job definition for the job description. + * @throws JobDefinitionException + */ + public ReportJob createJob(ReportJobDefinition definition) + throws JobDefinitionException; +} diff --git a/reportbuilder/java/com/sun/star/report/ReportEngineMetaData.java b/reportbuilder/java/com/sun/star/report/ReportEngineMetaData.java new file mode 100644 index 000000000000..486a58053e51 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportEngineMetaData.java @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportEngineMetaData.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +public interface ReportEngineMetaData +{ + + /** + * Checks, whether a certain output type is available. + * Feed the mime-type of the output type in and you'll get + * a true or false back. + * + * @param mimeType + * @return true, if the output type is supported; false otherwise. + */ + public boolean isOutputSupported(String mimeType); + + /** + * Lists all supported output parameters for the given mime-type. + * This listing can be used to build a generic user interface for + * configuring a certain output. + * + * @param mimeType + * @return + */ + public String[] getOutputParameters(String mimeType); + + public Class getParameterType(String parameter); + + public boolean isMandatory(String parameter); + + public boolean isEnumeration(String parameter); + + public Object[] getEnumerationValues(String parameter); +} diff --git a/reportbuilder/java/com/sun/star/report/ReportEngineParameterNames.java b/reportbuilder/java/com/sun/star/report/ReportEngineParameterNames.java new file mode 100644 index 000000000000..4b0002ba8d8c --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportEngineParameterNames.java @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportEngineParameterNames.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report; + +/** + * Making this enumeration typesafe and fully defined here would + * be nice, wouldn't it? + */ +public class ReportEngineParameterNames +{ + public static final String CONTENT_TYPE = "content-type"; + public static final String INPUT_NAME= "input.name"; + public static final String INPUT_REPOSITORY = "input.repository"; + public static final String OUTPUT_NAME= "output.name"; + public static final String OUTPUT_REPOSITORY = "output.repository"; + public static final String INPUT_DATASOURCE_FACTORY = "input.datasource-factory"; + public static final String IMAGE_SERVICE = "ImageService"; + public static final String INPUT_REPORTJOB_FACTORY = "input.reportjob-factory"; + public static final String INPUT_MASTER_COLUMNS = "input.master-columns"; + public static final String INPUT_MASTER_VALUES = "input.master-values"; + public static final String INPUT_DETAIL_COLUMNS = "input.detail-columns"; + public static final String MIMETYPE = "output.mimetype"; + public static final String AUTHOR = "Author"; + public static final String TITLE = "Title"; + + private ReportEngineParameterNames () + { + } +} diff --git a/reportbuilder/java/com/sun/star/report/ReportExecutionException.java b/reportbuilder/java/com/sun/star/report/ReportExecutionException.java new file mode 100644 index 000000000000..55ba51e4a61e --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportExecutionException.java @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportExecutionException.java,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report; + +public class ReportExecutionException extends Exception +{ + /** + * Constructs a new exception with <code>null</code> as its detail message. The cause is + * not initialized, and may subsequently be initialized by a call to {@link + * #initCause}. + */ + public ReportExecutionException () + { + } + + /** + * Constructs a new exception with the specified cause and a detail message of + * <tt>(cause==null ? null : cause.toString())</tt> (which typically contains the class + * and detail message of <tt>cause</tt>). This constructor is useful for exceptions that + * are little more than wrappers for other throwables (for example, {@link + * java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} + * method). (A <tt>null</tt> value is permitted, and indicates that the + * cause is nonexistent or unknown.) + * @since 1.4 + */ + public ReportExecutionException (Throwable cause) + { + super(cause); + } + + /** + * Constructs a new exception with the specified detail message. The cause is not + * initialized, and may subsequently be initialized by a call to {@link #initCause}. + * + * @param message the detail message. The detail message is saved for later retrieval by + * the {@link #getMessage()} method. + */ + public ReportExecutionException (String message) + { + super(message); + } + + /** + * Constructs a new exception with the specified detail message and cause. <p>Note that + * the detail message associated with <code>cause</code> is <i>not</i> automatically + * incorporated in this exception's detail message. + * + * @param message the detail message (which is saved for later retrieval by the {@link + * #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the {@link + * #getCause()} method). (A <tt>null</tt> value is permitted, and + * indicates that the cause is nonexistent or unknown.) + * @since 1.4 + */ + public ReportExecutionException (String message, Throwable cause) + { + super(message, cause); + } +} diff --git a/reportbuilder/java/com/sun/star/report/ReportExpression.java b/reportbuilder/java/com/sun/star/report/ReportExpression.java new file mode 100644 index 000000000000..c544659f2c4f --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportExpression.java @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportExpression.java,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report; + +/** + * Expressions are simple computation components. + * + * Expressions are always assumed to be immutable. They are not allowed to + * change their state and it is not guaranteed, in which order they get called. + * If the expression has been called before, the last computed value will be + * available from the datarow. + * + * This construct allows us to write expressions in the form + * "Sum := Sum + Column". + * + * Multiple calls to getValue on the same expression instance must return the + * same value (assuming that the datarow passed in is the same). + */ +public interface ReportExpression +{ + public void setParameters (Object[] parameters); + public Object getParameters (); + + public Object getValue(DataRow row); +} diff --git a/reportbuilder/java/com/sun/star/report/ReportExpressionMetaData.java b/reportbuilder/java/com/sun/star/report/ReportExpressionMetaData.java new file mode 100644 index 000000000000..830ae3927f44 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportExpressionMetaData.java @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportExpressionMetaData.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import java.util.Locale; + +public interface ReportExpressionMetaData +{ + + public int getParameterCount(); + + public String getParameterName(int param); + + public String getParameterDisplayName(int param, Locale locale); + + public String getParameterDescription(int param, Locale locale); + + public String getName(); + + public String getDisplayName(Locale l); + + public String getDescription(Locale l); +} diff --git a/reportbuilder/java/com/sun/star/report/ReportFunction.java b/reportbuilder/java/com/sun/star/report/ReportFunction.java new file mode 100644 index 000000000000..e7127552cb39 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportFunction.java @@ -0,0 +1,47 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportFunction.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +/** + * Functions are statefull computation components. + * + * Functions are allowed to have a state, but are considered + * immutable (the same is true for expressions). Functions are + * allowed to update their state on every call to 'advance', which + * signals, that the cursor has been moved. + * + * Functions have no way to 'reset' their state, if a reset is needed, + * the report engine is urged to query a new instance from the ReportAddin. + */ +public interface ReportFunction extends ReportExpression +{ + + public ReportFunction advance(DataRow row); +} diff --git a/reportbuilder/java/com/sun/star/report/ReportJob.java b/reportbuilder/java/com/sun/star/report/ReportJob.java new file mode 100644 index 000000000000..bbd02ff5e390 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportJob.java @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportJob.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import java.io.IOException; + +/** + * This allows some simple job control. A job can be interrupted (or if it has + * not yet been started, canceled), and the job status can be queried (scheduled, + * running, finished). + * + * <table border="1"> + * <tr> + * <th>JobStatus</th><th>running</th><th>finished</th> + * </tr> + * <tr> + * <td>Scheduled</td><td>false</td><td>false</td> + * </tr> + * <tr> + * <td>Running</td><td>true</td><td>false</td> + * </tr> + * <tr> + * <td>Finished</td><td>false</td><td>true</td> + * </tr> + * </table> + * + * @author Thomas Morgner + */ +public interface ReportJob +{ + + /** + * Although we might want to run the job as soon as it has been + * created, sometimes it is wiser to let the user add some listeners + * first. If we execute at once, the user either has to deal with + * threading code or wont receive any progress information in single + * threaded environments. + */ + public void execute() + throws ReportExecutionException, IOException; + + /** + * Interrupt the job. + */ + public void interrupt(); + + /** + * Queries the jobs execution status. + * + * @return true, if the job is currently running, false otherwise. + */ + public boolean isRunning(); + + /** + * Queries the jobs result status. + * + * @return true, if the job is finished (or has been interrupted), false + * if the job waits for activation. + */ + public boolean isFinished(); + + public void addProgressIndicator(JobProgressIndicator indicator); + + public void removeProgressIndicator(JobProgressIndicator indicator); +} diff --git a/reportbuilder/java/com/sun/star/report/ReportJobDefinition.java b/reportbuilder/java/com/sun/star/report/ReportJobDefinition.java new file mode 100644 index 000000000000..ff1b78b6aace --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportJobDefinition.java @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportJobDefinition.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +/** + * The report job is created by the report job factory and holds all properties + * required to complete the reporting task. + * + * @author Thomas Morgner + */ +public interface ReportJobDefinition +{ + + /** + * The parameters of the root report definition. The report parameters are using + * by the query factory to parametrize the query statement. + * + * The query parameters for the subreports are defined using mappings, it would not + * make sense to define them here. + * + * @return a map containing the report parameters + */ + public ParameterMap getQueryParameters(); + + /** + * The report processing parameters control the behaviour of the report. There are + * several mandatory parameters, some optional and possibly some not-yet-understood + * parameters. Use the engine meta data to find out, which parameters are supported. + * + * @return the processing parameters + */ + public JobProperties getProcessingParameters(); +} diff --git a/reportbuilder/java/com/sun/star/report/ReportJobFactory.java b/reportbuilder/java/com/sun/star/report/ReportJobFactory.java new file mode 100644 index 000000000000..cf8ed01ba736 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/ReportJobFactory.java @@ -0,0 +1,44 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReportJobFactory.java,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import com.sun.star.beans.NamedValue; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.uno.Exception; + +/** + * + * @author Ocke Janssen + */ +public interface ReportJobFactory +{ + + public ReportJob createReportJob(final NamedValue[] namedValue) throws IllegalArgumentException, ReportExecutionException, Exception; +} diff --git a/reportbuilder/java/com/sun/star/report/SDBCReportData.java b/reportbuilder/java/com/sun/star/report/SDBCReportData.java new file mode 100644 index 000000000000..5107d8ebf427 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/SDBCReportData.java @@ -0,0 +1,375 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SDBCReportData.java,v $ + * $Revision: 1.6.32.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.sdb.XParametersSupplier; +import java.sql.Timestamp; + +import com.sun.star.sdbc.DataType; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XResultSetMetaData; +import com.sun.star.sdbc.XResultSetMetaDataSupplier; +import com.sun.star.sdbc.XRow; +import com.sun.star.sdbc.XRowSet; +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.uno.Any; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.DateTime; +import com.sun.star.util.Time; + +public class SDBCReportData implements DataSource +{ + + private final XRowSet rowSet; + private final XRow row; + private int rowCount; + private XIndexAccess parameters; + private int firstParameterIndex = -1; + private int columnCount; + private final String[] columnNames; + private final int[] columnTypes; + + public SDBCReportData(final XRowSet rowSet) throws SQLException + { + row = (XRow) UnoRuntime.queryInterface(XRow.class, rowSet); + this.rowSet = rowSet; + + if (rowSet == null) + { + rowCount = 0; + columnCount = 0; + columnTypes = new int[1]; + columnNames = new String[1]; + } + else + { + final XParametersSupplier xSuppParams = (XParametersSupplier) UnoRuntime.queryInterface( + XParametersSupplier.class, rowSet); + if (xSuppParams != null) + { + parameters = xSuppParams.getParameters(); + } + + final XColumnsSupplier columnsSup = (XColumnsSupplier)UnoRuntime.queryInterface(XColumnsSupplier.class, rowSet); + final XNameAccess columns = columnsSup.getColumns(); + final String[] columnNamesList = columns.getElementNames(); + final XResultSetMetaDataSupplier sup = (XResultSetMetaDataSupplier) UnoRuntime.queryInterface(XResultSetMetaDataSupplier.class, rowSet); + final XResultSetMetaData resultSetMetaData = sup.getMetaData(); + + columnCount = resultSetMetaData.getColumnCount(); + firstParameterIndex = columnCount + 1; + if (parameters != null) + columnCount += parameters.getCount(); + + columnTypes = new int[columnCount]; + columnNames = new String[columnCount]; + + for (int i = 1; i <= columnCount; ++i) + { + if (i < firstParameterIndex) + { + columnNames[i - 1] = columnNamesList[i - 1];// resultSetMetaData.getColumnName(i); + columnTypes[i - 1] = resultSetMetaData.getColumnType(i); + } + else + { + try + { + final XPropertySet paramColumn = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, parameters.getByIndex(i - firstParameterIndex)); + columnNames[i - 1] = (String) paramColumn.getPropertyValue("Name"); + columnTypes[i - 1] = ((Integer) paramColumn.getPropertyValue("Type")).intValue(); + } + catch (Exception e) + { + columnNames[i - 1] = "Error"; + columnTypes[i - 1] = DataType.CHAR; + } + } + } + + if (rowSet.last()) + { + rowCount = rowSet.getRow(); + rowSet.beforeFirst(); + } + else + { + rowCount = 0; + } + } + } + + public int getColumnCount() throws DataSourceException + { + return columnCount; + } + + public int getRowCount() + { + return rowCount; + } + + public String getColumnName(final int column) throws DataSourceException + { + return columnNames[column - 1]; + } + + public boolean absolute(final int row) throws DataSourceException + { + if (rowSet == null) + return false; + try + { + if (row == 0) + { + rowSet.beforeFirst(); + return true; + } + return rowSet.absolute(row); + } + catch (SQLException e) + { + throw new DataSourceException(e.getMessage(), e); + } + } + + public boolean next() throws DataSourceException + { + if (rowSet == null) + return false; + try + { + return rowSet.next(); + } + catch (SQLException e) + { + throw new DataSourceException(e.getMessage(), e); + } + } + + public void close() throws DataSourceException + { + } + +// public int getCurrentRow() throws DataSourceException +// { +// try +// { +// return rowSet.getRow(); +// } +// catch (SQLException e) +// { +// throw new DataSourceException(e.getMessage(), e); +// } +// } + static private java.sql.Date getDate(final Object obj) + { + final java.sql.Date date; + if (obj instanceof com.sun.star.util.Date) + { + final com.sun.star.util.Date unodate = (com.sun.star.util.Date) obj; + date = java.sql.Date.valueOf(getDateString(unodate.Year, unodate.Month, unodate.Day).toString()); + } + else + { + date = null; + } + return date; + } + + private static StringBuffer getTimeString(final int hours, final int minutes, final int seconds) + { + final StringBuffer timeString = new StringBuffer(); + if (hours < 10) + { + timeString.append('0'); + } + timeString.append(hours); + timeString.append(':'); + if (minutes < 10) + { + timeString.append('0'); + } + timeString.append(minutes); + timeString.append(':'); + if (seconds < 10) + { + timeString.append('0'); + } + timeString.append(seconds); + return timeString; + } + + static private StringBuffer getDateString(final int years, final int months, final int days) + { + final StringBuffer str = new StringBuffer(); + str.append(years); + final StringBuffer str2 = new StringBuffer("0000"); + str2.delete(0, str.length()); + str.insert(0, str2); + str.append('-'); + if (months < 10) + { + str.append('0'); + } + str.append(months); + str.append('-'); + if (days < 10) + { + str.append('0'); + } + str.append(days); + return str; + } + + static private java.sql.Time getTime(final Object obj) + { + final java.sql.Time time; + if (obj instanceof Time) + { + final Time unoTime = (Time) obj; + time = java.sql.Time.valueOf(getTimeString(unoTime.Hours, unoTime.Minutes, unoTime.Seconds).toString()); + } + else + { + time = null; + } + return time; + } + + static private Timestamp getTimestamp(final Object obj) + { + final Timestamp ts; + if (obj instanceof DateTime) + { + final DateTime unoTs = (DateTime) obj; + final StringBuffer str = getDateString(unoTs.Year, unoTs.Month, unoTs.Day); + str.append(' '); + str.append(getTimeString(unoTs.Hours, unoTs.Minutes, unoTs.Seconds)); + str.append('.'); + str.append(unoTs.HundredthSeconds); + ts = java.sql.Timestamp.valueOf(str.toString()); + } + else + { + ts = null; + } + return ts; + } + + public Object getObject(final int column) throws DataSourceException + { + if (rowSet == null) + return null; + try + { + final boolean isParameterValue = (parameters != null) && (column >= firstParameterIndex); + Object obj; + final boolean wasNull; + if (isParameterValue) + { + final XPropertySet paramCol = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, parameters.getByIndex(column - firstParameterIndex)); + obj = paramCol.getPropertyValue("Value"); + wasNull = obj == null; + } + else + { + obj = row.getObject(column, null); + wasNull = row.wasNull(); + } + + if (wasNull) + { + obj = null; + } + else + { + obj = convertObject(columnTypes[column - 1], obj); + } + return obj; + } + catch (SQLException ex) + { + throw new DataSourceException(ex.getMessage(), ex); + } + catch (UnknownPropertyException ex) + { + throw new DataSourceException(ex.getMessage(), ex); + } + catch (IndexOutOfBoundsException ex) + { + throw new DataSourceException(ex.getMessage(), ex); + } + catch (WrappedTargetException ex) + { + throw new DataSourceException(ex.getMessage(), ex); + } + } + + private Object convertObject(final int type, final Object obj) + { + final Object ret; + switch (type) + { + case DataType.DATE: + ret = getDate(obj); + break; + case DataType.TIME: + ret = getTime(obj); + break; + case DataType.TIMESTAMP: + ret = getTimestamp(obj); + break; + case DataType.DECIMAL: + case DataType.NUMERIC: + if (!(obj instanceof Any)) + { + ret = new java.math.BigDecimal((String) obj); + } + else + { + ret = obj; + } + break; + default: + ret = obj; + break; + } + return ret; + } +} diff --git a/reportbuilder/java/com/sun/star/report/SDBCReportDataFactory.java b/reportbuilder/java/com/sun/star/report/SDBCReportDataFactory.java new file mode 100644 index 000000000000..bc248c29bbd9 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/SDBCReportDataFactory.java @@ -0,0 +1,645 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SDBCReportDataFactory.java,v $ + * $Revision: 1.9.18.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.container.XIndexAccess; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.sdbc.XConnection; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdb.XCompletedExecution; +import com.sun.star.sdb.XParametersSupplier; +import com.sun.star.sdb.XQueriesSupplier; +import com.sun.star.sdb.XSingleSelectQueryComposer; +import com.sun.star.sdb.tools.XConnectionTools; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XParameters; +import com.sun.star.sdbc.XPreparedStatement; +import com.sun.star.uno.Exception; +import java.util.Map; + +import com.sun.star.sdbc.XRowSet; +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.task.XInteractionHandler; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Very primitive implementation, just to show how this could be used ... + * + */ +public class SDBCReportDataFactory implements DataSourceFactory +{ + private static final Log LOGGER = LogFactory.getLog(SDBCReportDataFactory.class); + public static final String COMMAND_TYPE = "command-type"; + public static final String ESCAPE_PROCESSING = "escape-processing"; + public static final String GROUP_EXPRESSIONS = "group-expressions"; + public static final String MASTER_VALUES = "master-values"; + public static final String MASTER_COLUMNS = "master-columns"; + public static final String DETAIL_COLUMNS = "detail-columns"; + public static final String UNO_FILTER = "Filter"; + private static final String APPLY_FILTER = "ApplyFilter"; + private static final String UNO_COMMAND = "Command"; + private static final String UNO_ORDER = "Order"; + private static final String UNO_APPLY_FILTER = "ApplyFilter"; + private static final String UNO_COMMAND_TYPE = "CommandType"; + private final XConnection connection; + private final XComponentContext m_cmpCtx; + private static final int FAILED = 0; + private static final int DONE = 1; + private static final int RETRIEVE_COLUMNS = 2; + private static final int RETRIEVE_OBJECT = 3; + private static final int HANDLE_QUERY = 4; + private static final int HANDLE_TABLE = 5; + private static final int HANDLE_SQL = 6; + + public SDBCReportDataFactory(final XComponentContext cmpCtx, final XConnection connection) + { + this.connection = connection; + m_cmpCtx = cmpCtx; + } + + public DataSource queryData(final String command, final Map parameters) throws DataSourceException + { + try + { + if ( command == null ) + { + return new SDBCReportData(null); + } + int commandType = CommandType.COMMAND; + final String commandTypeValue = (String) parameters.get(COMMAND_TYPE); + if ( commandTypeValue != null ) + { + if ( commandTypeValue.equals("query") ) + { + commandType = CommandType.QUERY; + } + else if ( commandTypeValue.equals("table") ) + { + commandType = CommandType.TABLE; + } + else + { + commandType = CommandType.COMMAND; + } + } + final XRowSet rowSet = createRowSet(command, commandType, parameters); + final XPropertySet rowSetProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, rowSet); + + final XConnectionTools tools = (XConnectionTools) UnoRuntime.queryInterface(XConnectionTools.class, connection); + fillOrderStatement(command, commandType, parameters, tools, rowSetProp); + + if ( command.length() != 0 ) + { + final int oldParameterCount = fillParameter(parameters, tools, command, commandType, rowSet); + + final XCompletedExecution execute = (XCompletedExecution) UnoRuntime.queryInterface(XCompletedExecution.class, rowSet); + if ( execute != null && oldParameterCount > 0 ) + { + final XInteractionHandler handler = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, m_cmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.sdb.InteractionHandler", m_cmpCtx)); + execute.executeWithCompletion(handler); + } + else + { + rowSet.execute(); + } + } + return new SDBCReportData(rowSet); + } catch ( Exception ex ) + { + throw new DataSourceException(ex.getMessage(), ex); + } + } + + private String getOrderStatement(final int commandType, final String command, final List groupExpressions) + { + final StringBuffer order = new StringBuffer(); + final int count = groupExpressions.size(); + if ( count != 0 ) + { + try + { + final String quote = connection.getMetaData().getIdentifierQuoteString(); + final XComponent[] hold = new XComponent[1]; + final XNameAccess columns = getFieldsByCommandDescriptor(commandType, command, hold); + + for (int i = 0; i < count; i++) + { + final Object[] pair = (Object[]) groupExpressions.get(i); + String expression = (String) pair[0]; + + if (columns.hasByName(expression)) + { + expression = quote + expression + quote; + } + expression = expression.trim(); // Trim away white spaces + + if (expression.length() > 0) + { + order.append(expression); + if (order.length() > 0) + { + order.append(' '); + } + final String sorting = (String) pair[1]; + if (sorting == null || sorting.equals(OfficeToken.FALSE)) + { + order.append("DESC"); + } + if ((i + 1) < count) + { + order.append(", "); + } + } + } + } + catch (IndexOutOfBoundsException ex) + { + LOGGER.error("ReportProcessing failed", ex); + } + catch (SQLException ex) + { + LOGGER.error("ReportProcessing failed", ex); + } + } + return order.toString(); + } + + private XNameAccess getFieldsByCommandDescriptor(final int commandType, final String command, final XComponent[] out) throws SQLException + { + final Class[] parameter = new Class[3]; + parameter[0] = Integer.class; + parameter[1] = String.class; + parameter[2] = out.getClass(); + final XConnectionTools tools = (XConnectionTools) UnoRuntime.queryInterface(XConnectionTools.class, connection); + try + { + tools.getClass().getMethod("getFieldsByCommandDescriptor", parameter); + return tools.getFieldsByCommandDescriptor(commandType, command, out); + } catch ( NoSuchMethodException ex ) + { + } + + XNameAccess xFields = null; + // some kind of state machine to ease the sharing of code + int eState = FAILED; + switch ( commandType ) + { + case CommandType.TABLE: + eState = HANDLE_TABLE; + break; + case CommandType.QUERY: + eState = HANDLE_QUERY; + break; + case CommandType.COMMAND: + eState = HANDLE_SQL; + break; + } + + // needed in various states: + XNameAccess xObjectCollection = null; + XColumnsSupplier xSupplyColumns = null; + + try + { + // go! + while ((DONE != eState) && (FAILED != eState)) + { + switch ( eState ) + { + case HANDLE_TABLE: + { + // initial state for handling the tables + + // get the table objects + final XTablesSupplier xSupplyTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, connection); + if ( xSupplyTables != null ) + { + xObjectCollection = xSupplyTables.getTables(); + // if something went wrong 'til here, then this will be handled in the next state + + // next state: get the object + } + eState = RETRIEVE_OBJECT; + } + break; + + case HANDLE_QUERY: + { + // initial state for handling the tables + + // get the table objects + final XQueriesSupplier xSupplyQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, connection); + if ( xSupplyQueries != null ) + { + xObjectCollection = xSupplyQueries.getQueries(); + // if something went wrong 'til here, then this will be handled in the next state + + // next state: get the object + } + eState = RETRIEVE_OBJECT; + } + break; + + case RETRIEVE_OBJECT: + // here we should have an object (aka query or table) collection, and are going + // to retrieve the desired object + + // next state: default to FAILED + eState = FAILED; + + if ( xObjectCollection != null && xObjectCollection.hasByName(command) ) + { + xSupplyColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xObjectCollection.getByName(command)); + + // next: go for the columns + eState = RETRIEVE_COLUMNS; + } + break; + + case RETRIEVE_COLUMNS: + // next state: default to FAILED + eState = FAILED; + + if ( xSupplyColumns != null ) + { + xFields = xSupplyColumns.getColumns(); + // that's it + eState = DONE; + } + break; + + case HANDLE_SQL: + { + String sStatementToExecute = command; + + // well, the main problem here is to handle statements which contain a parameter + // If we would simply execute a parametrized statement, then this will fail because + // we cannot supply any parameter values. + // Thus, we try to analyze the statement, and to append a WHERE 0=1 filter criterion + // This should cause every driver to not really execute the statement, but to return + // an empty result set with the proper structure. We then can use this result set + // to retrieve the columns. + + try + { + final XMultiServiceFactory xComposerFac = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, connection); + + if ( xComposerFac != null ) + { + final XSingleSelectQueryComposer xComposer = (XSingleSelectQueryComposer) UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, xComposerFac.createInstance("com.sun.star.sdb.SingleSelectQueryComposer")); + if ( xComposer != null ) + { + xComposer.setQuery(sStatementToExecute); + + // Now set the filter to a dummy restriction which will result in an empty + // result set. + xComposer.setFilter("0=1"); + + sStatementToExecute = xComposer.getQuery(); + } + } + } catch ( com.sun.star.uno.Exception ex ) + { + // silent this error, this was just a try. If we're here, we did not change sStatementToExecute, + // so it will still be _rCommand, which then will be executed without being touched + } + + // now execute + final XPreparedStatement xStatement = connection.prepareStatement(sStatementToExecute); + // transfer ownership of this temporary object to the caller + out[0] = (XComponent) UnoRuntime.queryInterface(XComponent.class, xStatement); + + // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter + // failed - in this case, the MaxRows restriction should at least ensure that there + // is no data returned (which would be potentially expensive) + final XPropertySet xStatementProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStatement); + try + { + if ( xStatementProps != null ) + { + xStatementProps.setPropertyValue("MaxRows", new Integer(0)); + } + } catch ( com.sun.star.uno.Exception ex ) + { + // oh damn. Not much of a chance to recover, we will no retrieve the complete + // full blown result set + } + + xSupplyColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xStatement.executeQuery()); + // this should have given us a result set which does not contain any data, but + // the structural information we need + + // so the next state is to get the columns + eState = RETRIEVE_COLUMNS; + } + break; + default: + eState = FAILED; + } + } + } catch ( com.sun.star.uno.Exception ex ) + { + } + return xFields; + } + + private XSingleSelectQueryComposer getComposer(final XConnectionTools tools, + final String command, + final int commandType) + { + final Class[] parameter = new Class[2]; + parameter[0] = int.class; + parameter[1] = String.class; + try + { + final Object[] param = new Object[2]; + param[0] = commandType; + param[1] = command; + Method call = tools.getClass().getMethod("getComposer", parameter); + return (XSingleSelectQueryComposer) call.invoke(tools, param); + } catch ( NoSuchMethodException ex ) + { + } catch ( IllegalAccessException ex ) + { + // should not happen + // assert False + } catch ( java.lang.reflect.InvocationTargetException ex ) + { + // should not happen + // assert False + } + try + { + final XMultiServiceFactory factory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, connection); + final XSingleSelectQueryComposer out = (XSingleSelectQueryComposer) UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, factory.createInstance("com.sun.star.sdb.SingleSelectQueryAnalyzer")); + final String quote = connection.getMetaData().getIdentifierQuoteString(); + String statement = command; + switch ( commandType ) + { + case CommandType.TABLE: + statement = "SELECT * FROM " + quote + command + quote; + break; + case CommandType.QUERY: + { + final XQueriesSupplier xSupplyQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, connection); + final XNameAccess queries = xSupplyQueries.getQueries(); + if ( queries.hasByName(command) ) + { + final XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, queries.getByName(command)); + final Boolean escape = (Boolean) prop.getPropertyValue("EscapeProcessing"); + if (escape.booleanValue()) + { + statement = (String) prop.getPropertyValue(UNO_COMMAND); + final XSingleSelectQueryComposer composer = getComposer(tools, statement, CommandType.COMMAND); + if (composer != null) + { + final String order = (String) prop.getPropertyValue(UNO_ORDER); + if (order != null && order.length() != 0) + { + composer.setOrder(order); + } + final Boolean applyFilter = (Boolean) prop.getPropertyValue(UNO_APPLY_FILTER); + if (applyFilter.booleanValue()) + { + final String filter = (String) prop.getPropertyValue(UNO_FILTER); + if (filter != null && filter.length() != 0) + { + composer.setFilter(filter); + } + } + statement = composer.getQuery(); + } + } + } + } + break; + case CommandType.COMMAND: + statement = command; + break; + } + out.setElementaryQuery(statement); + return out; + } catch ( Exception e ) + { + } + return null; + } + + int fillParameter(final Map parameters, + final XConnectionTools tools, + final String command, + final int commandType, final XRowSet rowSet) + throws SQLException, + UnknownPropertyException, + PropertyVetoException, + IllegalArgumentException, + WrappedTargetException + { + int oldParameterCount = 0; + + final XSingleSelectQueryComposer composer = getComposer(tools, command, commandType); + if ( composer != null ) + { + final XPropertySet rowSetProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, rowSet); + if ( ((Boolean)rowSetProp.getPropertyValue(APPLY_FILTER)).booleanValue() ) + { + composer.setFilter((String)rowSetProp.getPropertyValue("Filter")); + } + // get old parameter count + final XParametersSupplier paraSup = (XParametersSupplier) UnoRuntime.queryInterface(XParametersSupplier.class, composer); + if ( paraSup != null ) + { + final XIndexAccess params = paraSup.getParameters(); + if ( params != null ) + { + oldParameterCount = params.getCount(); + } + } + final ArrayList masterValues = (ArrayList) parameters.get(MASTER_VALUES); + if ( masterValues != null && !masterValues.isEmpty() ) + { + // Vector masterColumns = (Vector) parameters.get("master-columns"); + final ArrayList detailColumns = (ArrayList) parameters.get(DETAIL_COLUMNS); + if ( oldParameterCount < detailColumns.size() ) + { + // create the new filter + final String quote = connection.getMetaData().getIdentifierQuoteString(); + final StringBuffer oldFilter = new StringBuffer(); + oldFilter.append(composer.getFilter()); + if ( oldFilter.length() != 0 ) + { + oldFilter.append(" AND "); + } + int newParamterCounter = 1; + for (final Iterator it = detailColumns.iterator(); it.hasNext(); + ++newParamterCounter) + { + final String detail = (String) it.next(); + //String master = (String) masterIt.next(); + oldFilter.append(quote); + oldFilter.append(detail); + oldFilter.append(quote); + oldFilter.append(" = :link_"); + oldFilter.append(newParamterCounter); + if ( it.hasNext() ) + { + oldFilter.append(" AND "); + } + } + + composer.setFilter(oldFilter.toString()); + } + else + oldParameterCount = 0; + + final String sQuery = composer.getQuery(); + rowSetProp.setPropertyValue(UNO_COMMAND, sQuery); + rowSetProp.setPropertyValue(UNO_COMMAND_TYPE, + new Integer(CommandType.COMMAND)); + + final XParameters para = (XParameters) UnoRuntime.queryInterface(XParameters.class, rowSet); + + for (int i = 0; + i < masterValues.size(); + i++) + { + Object object = masterValues.get(i); + if ( object instanceof BigDecimal ) + { + object = ((BigDecimal) object).toString(); + } + para.setObject(oldParameterCount + i + 1, object); + } + } + } + + return oldParameterCount; + } + + private final XRowSet createRowSet(final String command, + final int commandType, final Map parameters) + throws Exception + { + final XRowSet rowSet = (XRowSet) UnoRuntime.queryInterface(XRowSet.class, m_cmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.sdb.RowSet", m_cmpCtx)); + final XPropertySet rowSetProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, rowSet); + + rowSetProp.setPropertyValue("ActiveConnection", connection); + final Boolean escapeProcessing = (Boolean)parameters.get(ESCAPE_PROCESSING); + rowSetProp.setPropertyValue("EscapeProcessing", escapeProcessing); + rowSetProp.setPropertyValue(UNO_COMMAND_TYPE, new Integer(commandType)); + rowSetProp.setPropertyValue(UNO_COMMAND, command); + + final String filter = (String) parameters.get(UNO_FILTER); + if ( filter != null ) + { + rowSetProp.setPropertyValue("Filter", filter); + rowSetProp.setPropertyValue(APPLY_FILTER, Boolean.valueOf(filter.length() != 0)); + } + else + { + rowSetProp.setPropertyValue(APPLY_FILTER, Boolean.FALSE); + } + return rowSet; + } + + void fillOrderStatement(final String command, + final int commandType, final Map parameters, + final XConnectionTools tools, + final XPropertySet rowSetProp) + throws SQLException, + UnknownPropertyException, + PropertyVetoException, + IllegalArgumentException, + WrappedTargetException, + NoSuchElementException + { + final StringBuffer order = new StringBuffer(getOrderStatement(commandType, command, (ArrayList) parameters.get(GROUP_EXPRESSIONS))); + if ( order.length() > 0 && commandType != CommandType.TABLE ) + { + String statement = command; + final XSingleSelectQueryComposer composer = getComposer(tools, command, commandType); + if ( composer != null ) + { + statement = composer.getQuery(); + composer.setQuery(statement); + final String sOldOrder = composer.getOrder(); + if ( sOldOrder.length() > 0 ) + { + order.append(','); + order.append(sOldOrder); + composer.setOrder(""); + statement = composer.getQuery(); + } + } + else + { + if ( commandType == CommandType.QUERY ) + { + final XQueriesSupplier xSupplyQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, connection); + final XNameAccess queries = xSupplyQueries.getQueries(); + if ( queries.hasByName(command) ) + { + final XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, queries.getByName(command)); + final Boolean escape = (Boolean) prop.getPropertyValue("EscapeProcessing"); + rowSetProp.setPropertyValue("EscapeProcessing", escape); + final String queryCommand = (String) prop.getPropertyValue(UNO_COMMAND); + statement = "SELECT * FROM (" + queryCommand + ")"; + } + + } + else + { + statement = "SELECT * FROM (" + command + ")"; + } + } + rowSetProp.setPropertyValue(UNO_COMMAND, statement); + rowSetProp.setPropertyValue(UNO_COMMAND_TYPE, new Integer(CommandType.COMMAND)); + } + rowSetProp.setPropertyValue("Order", order.toString()); + } +} + diff --git a/reportbuilder/java/com/sun/star/report/SOImageService.java b/reportbuilder/java/com/sun/star/report/SOImageService.java new file mode 100644 index 000000000000..3073a52179fa --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/SOImageService.java @@ -0,0 +1,182 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SOImageService.java,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import java.awt.Dimension; +import java.io.InputStream; + +import com.sun.star.awt.Size; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.graphic.XGraphicProvider; +import com.sun.star.io.IOException; +import com.sun.star.io.XInputStream; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter; +import com.sun.star.lib.uno.adapter.InputStreamToXInputStreamAdapter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; + +/** + * @author oj93728 + */ +public class SOImageService implements ImageService +{ + + private final XGraphicProvider m_xGraphicProvider; + + /** + * Creates a new instance of SOImageService + */ + public SOImageService(final XComponentContext xCompContext) + throws ReportExecutionException, com.sun.star.uno.Exception + { + if (xCompContext == null) + { + throw new ReportExecutionException(); + } + + + final XMultiComponentFactory m_xMCF = xCompContext.getServiceManager(); + m_xGraphicProvider = (XGraphicProvider) UnoRuntime.queryInterface(XGraphicProvider.class, + m_xMCF.createInstanceWithContext("com.sun.star.graphic.GraphicProvider", xCompContext)); + + if (m_xGraphicProvider == null) + { + throw new ReportExecutionException("There is no graphic-provider available."); + } + } + + public Dimension getImageSize(final InputStream image) throws ReportExecutionException + { + return getImageSize(new InputStreamToXInputStreamAdapter(image)); + } + + private Dimension getImageSize(final XInputStream image) throws ReportExecutionException + { + final Dimension dim = new Dimension(); + try + { + final PropertyValue[] value = new PropertyValue[]{new PropertyValue()}; + // value[0] = new PropertyValue(); + value[0].Name = "InputStream"; + value[0].Value = image; + + final XPropertySet xImage = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, + m_xGraphicProvider.queryGraphic(value)); + + if (xImage != null) + { + final XPropertySetInfo xInfo = xImage.getPropertySetInfo(); + if (xInfo.hasPropertyByName("Size100thMM")) + { + Size imageSize = (Size) xImage.getPropertyValue("Size100thMM"); + dim.setSize(imageSize.Width, imageSize.Height); + if (dim.height == 0 && dim.width == 0) + { + imageSize = (Size) xImage.getPropertyValue("SizePixel"); + final int dpi = java.awt.Toolkit.getDefaultToolkit().getScreenResolution(); + final double fac = 2540 / dpi; + dim.setSize(imageSize.Width * fac, imageSize.Height * fac); + } + } + else if (xInfo.hasPropertyByName("SizePixel")) + { + final Size imageSize = (Size) xImage.getPropertyValue("SizePixel"); + final int dpi = java.awt.Toolkit.getDefaultToolkit().getScreenResolution(); + final double fac = 2540 / dpi; + dim.setSize(imageSize.Width * fac, imageSize.Height * fac); + } + } + } + catch (Exception ex) + { + throw new ReportExecutionException("Failed to query Image-Size", ex); + } + return dim; + } + + public Dimension getImageSize(final byte[] image) throws ReportExecutionException + { + return getImageSize(new ByteArrayToXInputStreamAdapter(image)); + } + + private String getMimeType(final XInputStream image) throws ReportExecutionException + { + try + { + final PropertyValue[] value = new PropertyValue[]{new PropertyValue()}; + value[0].Name = "InputStream"; + value[0].Value = image; + + final XPropertySet xImage = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, + m_xGraphicProvider.queryGraphic(value)); + + if (xImage != null) + { + final XPropertySetInfo xInfo = xImage.getPropertySetInfo(); + if (xInfo.hasPropertyByName("MimeType")) + { + return (String) xImage.getPropertyValue("MimeType"); + } + } + } + catch (UnknownPropertyException ex) + { + throw new ReportExecutionException(); + } + catch (WrappedTargetException ex) + { + throw new ReportExecutionException(); + } + catch (com.sun.star.lang.IllegalArgumentException ex) + { + throw new ReportExecutionException(); + } + catch (IOException ex) + { + throw new ReportExecutionException(); + } + return null; + } + + public String getMimeType(final InputStream image) throws ReportExecutionException + { + return getMimeType(new InputStreamToXInputStreamAdapter(image)); + } + + public String getMimeType(final byte[] image) throws ReportExecutionException + { + return getMimeType(new ByteArrayToXInputStreamAdapter(image)); + } +} diff --git a/reportbuilder/java/com/sun/star/report/StorageRepository.java b/reportbuilder/java/com/sun/star/report/StorageRepository.java new file mode 100644 index 000000000000..bf5687da14ae --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/StorageRepository.java @@ -0,0 +1,339 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StorageRepository.java,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report; + +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.embed.ElementModes; +import com.sun.star.embed.InvalidStorageException; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import java.io.*; +import com.sun.star.embed.XStorage; +import com.sun.star.embed.XTransactedObject; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.io.XStream; +import com.sun.star.lib.uno.adapter.XInputStreamToInputStreamAdapter; +import com.sun.star.lib.uno.adapter.XOutputStreamToOutputStreamAdapter; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * A directory holds all the contents here. + * + * + * @author Ocke Janssen + */ +public class StorageRepository implements InputRepository, OutputRepository +{ + private static final Log LOGGER = LogFactory.getLog(SDBCReportDataFactory.class); + private static final String REPORT_PROCESSING_FAILED = "ReportProcessing failed"; + private XStorage input; + private XStorage output; + + /** + * + * @param input + * @param output + * @throws java.io.IOException + */ + public StorageRepository(final XStorage input, final XStorage output) + { + this.input = input; + this.output = output; + } + + public StorageRepository(final XStorage storage, final boolean isOutput) + { + if (isOutput) + { + this.output = storage; + } + else + { + this.input = storage; + } + } + + public InputStream createInputStream(final String name) throws IOException + { + if (input == null) + { + throw new IOException("input is NULL"); + } + try + { + final XStream xStream = (XStream) UnoRuntime.queryInterface(XStream.class, input.openStreamElement(name, ElementModes.READ)); + return new BufferedInputStream(new XInputStreamToInputStreamAdapter(xStream.getInputStream()), 102400); + } + catch (com.sun.star.uno.Exception e) + { + throw new IOException("createInputStream"); + } + } + + /** + * Creates an output stream for writing the data. If there is an entry with + * that name already contained in the repository, try to overwrite it. + * + * @param name + * @param mimeType + * @return the outputstream + * @throws IOException if opening the stream fails + */ + public OutputStream createOutputStream(final String name, final String mimeType) throws IOException + { + if (output == null) + { + throw new IOException("output is NULL"); + } + try + { + final XStream stream = (XStream) UnoRuntime.queryInterface(XStream.class, output.openStreamElement(name, ElementModes.WRITE | ElementModes.TRUNCATE)); + stream.getInputStream().closeInput(); + if (mimeType != null) + { + final XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, stream); + prop.setPropertyValue("MediaType", mimeType); + } + return new BufferedOutputStream(new XOutputStreamToOutputStreamAdapter(stream.getOutputStream()), 204800); + } + catch (com.sun.star.uno.Exception e) + { + throw new IOException("createOutputStream"); + } + } + + public boolean exists(final String name) + { + try + { + return output.isStreamElement(name); + } + catch (InvalidStorageException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (com.sun.star.lang.IllegalArgumentException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (NoSuchElementException ex) + { + // We expect this exception, no need to log it. + } + return false; + } + + public boolean isWritable(final String name) + { + return true; + } + + public Object getId() + { + return "1"; + } + + public long getVersion(final String name) + { + return 1; + } + + public boolean isReadable(final String name) + { + try + { + if (input != null) + { + return input.isStreamElement(name); + } + } + catch (InvalidStorageException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (com.sun.star.lang.IllegalArgumentException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (NoSuchElementException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + return false; + } + + public InputRepository openInputRepository(final String name) throws IOException + { + try + { + final String temp = shortenName(name); + if (!input.isStorageElement(temp)) + { + throw new IOException(); + } + final XStorage storage = (XStorage) UnoRuntime.queryInterface(XStorage.class, input.openStorageElement(temp, ElementModes.READ)); + return new StorageRepository(storage, false); + } + catch (NoSuchElementException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (WrappedTargetException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (InvalidStorageException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (IllegalArgumentException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (com.sun.star.io.IOException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + throw new IOException(); + } + + final String shortenName(final String name) + { + final String temp; + if (name.startsWith("./")) + { + temp = name.substring(2); + } + else + { + temp = name; + } + return temp; + } + + public OutputRepository openOutputRepository(final String name, final String mimeType) throws IOException + { + try + { + final String temp = shortenName(name); + final XStorage storage = (XStorage) UnoRuntime.queryInterface(XStorage.class, output.openStorageElement(temp, ElementModes.WRITE)); + if (mimeType != null) + { + final XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, storage); + prop.setPropertyValue("MediaType", mimeType); + } + return new StorageRepository(storage, true); + } + catch (UnknownPropertyException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (PropertyVetoException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (IllegalArgumentException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (WrappedTargetException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (InvalidStorageException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (com.sun.star.io.IOException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + + throw new IOException(); + } + + public void closeInputRepository() + { + if (input != null) + { + input.dispose(); + } + } + + public void closeOutputRepository() + { + if (output != null) + { + try + { + final XTransactedObject obj = (XTransactedObject) UnoRuntime.queryInterface(XTransactedObject.class, output); + if (obj != null) + { + obj.commit(); + } + } + catch (com.sun.star.io.IOException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (WrappedTargetException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + output.dispose(); + } + + } + + public boolean existsStorage(final String name) + { + try + { + return output.isStorageElement(name); + } + catch (InvalidStorageException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (com.sun.star.lang.IllegalArgumentException ex) + { + LOGGER.error(REPORT_PROCESSING_FAILED, ex); + } + catch (NoSuchElementException ex) + { + // We expect this exception, no need to log it. + } + return false; + } +} diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/Author-Function.properties b/reportbuilder/java/com/sun/star/report/function/metadata/Author-Function.properties new file mode 100644 index 000000000000..4dfc3e01f0be --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/Author-Function.properties @@ -0,0 +1,33 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: Author-Function.properties,v $ +# +# $Revision: 1.2 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +display-name=AUTHOR +description=Returns the author of the report.
\ No newline at end of file diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/Author-Function_en_US.properties b/reportbuilder/java/com/sun/star/report/function/metadata/Author-Function_en_US.properties new file mode 100644 index 000000000000..4dfc3e01f0be --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/Author-Function_en_US.properties @@ -0,0 +1,33 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: Author-Function.properties,v $ +# +# $Revision: 1.2 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +display-name=AUTHOR +description=Returns the author of the report.
\ No newline at end of file diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunction.java b/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunction.java new file mode 100644 index 000000000000..63b15fab0200 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunction.java @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AuthorFunction.java,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.function.metadata; + +import com.sun.star.report.ReportEngineParameterNames; +import org.pentaho.reporting.libraries.formula.EvaluationException; +import org.pentaho.reporting.libraries.formula.FormulaContext; +import org.pentaho.reporting.libraries.formula.LibFormulaErrorValue; +import org.pentaho.reporting.libraries.formula.function.Function; +import org.pentaho.reporting.libraries.formula.function.ParameterCallback; +import org.pentaho.reporting.libraries.formula.lvalues.TypeValuePair; +import org.pentaho.reporting.libraries.formula.typing.coretypes.TextType; + +/** + * + * @author Ocke Janssen + */ +public class AuthorFunction implements Function +{ + + public AuthorFunction() + { + } + + public String getCanonicalName() + { + return "AUTHOR"; + } + + public TypeValuePair evaluate(final FormulaContext context,final ParameterCallback parameters) + throws EvaluationException + { + if (parameters.getParameterCount() != 0) + { + throw new EvaluationException(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE); + } + + return new TypeValuePair(TextType.TYPE, context.getConfiguration().getConfigProperty(ReportEngineParameterNames.AUTHOR)); + } +} diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunctionDescription.java b/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunctionDescription.java new file mode 100644 index 000000000000..fecfcd5753c1 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/AuthorFunctionDescription.java @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AuthorFunctionDescription.java,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.function.metadata; + +import org.pentaho.reporting.libraries.formula.function.AbstractFunctionDescription; +import org.pentaho.reporting.libraries.formula.function.FunctionCategory; +import org.pentaho.reporting.libraries.formula.typing.Type; +import org.pentaho.reporting.libraries.formula.typing.coretypes.NumberType; +import org.pentaho.reporting.libraries.formula.typing.coretypes.TextType; + +/** + * + * @author Ocke Janssen + */ +public class AuthorFunctionDescription extends AbstractFunctionDescription +{ + + public AuthorFunctionDescription() + { + super("AUTHOR","com.sun.star.report.function.metadata.Author-Function"); + } + + public FunctionCategory getCategory() + { + return MetaDataFunctionCategory.CATEGORY; + } + + public int getParameterCount() + { + return 0; + } + + public Type getParameterType(final int position) + { + return null; + } + + public Type getValueType() + { + return TextType.TYPE; + } + + public boolean isParameterMandatory(final int position) + { + return false; + } +} diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/MetaDataFunctionCategory.java b/reportbuilder/java/com/sun/star/report/function/metadata/MetaDataFunctionCategory.java new file mode 100644 index 000000000000..2e47bafaceca --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/MetaDataFunctionCategory.java @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: MetaDataFunctionCategory.java,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.function.metadata; + +import org.pentaho.reporting.libraries.formula.function.AbstractFunctionCategory; +import org.pentaho.reporting.libraries.formula.function.FunctionCategory; + +/** + * + * @author Ocke Janssen + */ +public class MetaDataFunctionCategory extends AbstractFunctionCategory +{ + + public static final FunctionCategory CATEGORY = new MetaDataFunctionCategory(); + + private MetaDataFunctionCategory() + { + super("com.sun.star.report.function.metadata.category"); + } +} + diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/Title-Function.properties b/reportbuilder/java/com/sun/star/report/function/metadata/Title-Function.properties new file mode 100644 index 000000000000..ef678be150da --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/Title-Function.properties @@ -0,0 +1,33 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: Title-Function.properties,v $ +# +# $Revision: 1.2 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +display-name=TITLE +description=Returns the title of the report.
\ No newline at end of file diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/Title-Function_en_US.properties b/reportbuilder/java/com/sun/star/report/function/metadata/Title-Function_en_US.properties new file mode 100644 index 000000000000..ef678be150da --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/Title-Function_en_US.properties @@ -0,0 +1,33 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: Title-Function.properties,v $ +# +# $Revision: 1.2 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +display-name=TITLE +description=Returns the title of the report.
\ No newline at end of file diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/TitleFunction.java b/reportbuilder/java/com/sun/star/report/function/metadata/TitleFunction.java new file mode 100644 index 000000000000..be342dc27706 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/TitleFunction.java @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TitleFunction.java,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.function.metadata; + +import com.sun.star.report.ReportEngineParameterNames; +import org.pentaho.reporting.libraries.formula.EvaluationException; +import org.pentaho.reporting.libraries.formula.FormulaContext; +import org.pentaho.reporting.libraries.formula.LibFormulaErrorValue; +import org.pentaho.reporting.libraries.formula.function.Function; +import org.pentaho.reporting.libraries.formula.function.ParameterCallback; +import org.pentaho.reporting.libraries.formula.lvalues.TypeValuePair; +import org.pentaho.reporting.libraries.formula.typing.coretypes.TextType; + +/** + * + * @author Ocke Janssen + */ +public class TitleFunction implements Function +{ + + public TitleFunction() + { + } + + public String getCanonicalName() + { + return "TITLE"; + } + + public TypeValuePair evaluate(final FormulaContext context,final ParameterCallback parameters) + throws EvaluationException + { + if (parameters.getParameterCount() != 0) + { + throw new EvaluationException(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE); + } + + return new TypeValuePair(TextType.TYPE, context.getConfiguration().getConfigProperty(ReportEngineParameterNames.TITLE)); + } +} diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/TitleFunctionDescription.java b/reportbuilder/java/com/sun/star/report/function/metadata/TitleFunctionDescription.java new file mode 100644 index 000000000000..5db1a898b04e --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/TitleFunctionDescription.java @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TitleFunctionDescription.java,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.function.metadata; + +import org.pentaho.reporting.libraries.formula.function.AbstractFunctionDescription; +import org.pentaho.reporting.libraries.formula.function.FunctionCategory; +import org.pentaho.reporting.libraries.formula.typing.Type; +import org.pentaho.reporting.libraries.formula.typing.coretypes.NumberType; +import org.pentaho.reporting.libraries.formula.typing.coretypes.TextType; + +/** + * + * @author Ocke Janssen + */ +public class TitleFunctionDescription extends AbstractFunctionDescription +{ + + public TitleFunctionDescription() + { + super("TITLE","com.sun.star.report.function.metadata.Title-Function"); + } + + public FunctionCategory getCategory() + { + return MetaDataFunctionCategory.CATEGORY; + } + + public int getParameterCount() + { + return 0; + } + + public Type getParameterType(final int position) + { + return null; + } + + public Type getValueType() + { + return TextType.TYPE; + } + + public boolean isParameterMandatory(final int position) + { + return false; + } +} diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/category.properties b/reportbuilder/java/com/sun/star/report/function/metadata/category.properties new file mode 100644 index 000000000000..c193c5c7374a --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/category.properties @@ -0,0 +1,33 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: category.properties,v $ +# +# $Revision: 1.2 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +display-name=Document Information +description=Contains functions to access document information. diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/category_en_US.properties b/reportbuilder/java/com/sun/star/report/function/metadata/category_en_US.properties new file mode 100644 index 000000000000..44b7ed1d5e9b --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/category_en_US.properties @@ -0,0 +1,33 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: category.properties,v $ +# +# $Revision: 1.2 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +display-name=MetaData +description=Contains functions about meta data
\ No newline at end of file diff --git a/reportbuilder/java/com/sun/star/report/function/metadata/makefile.mk b/reportbuilder/java/com/sun/star/report/function/metadata/makefile.mk new file mode 100644 index 000000000000..1025bcea7cb7 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/function/metadata/makefile.mk @@ -0,0 +1,68 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.3.22.2 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ = ..$/..$/..$/..$/..$/..$/.. +PRJNAME = reportbuilder +TARGET= rpt_java_css_metadata +PACKAGE = com$/sun$/star$/report$/function$/metadata + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk +#----- compile .java files ----------------------------------------- + +.IF "$(SYSTEM_JFREEREPORT)" == "YES" +CLASSPATH!:==$(CLASSPATH)$(PATH_SEPERATOR)$(LIBBASE_JAR)$(PATH_SEPERATOR)$(LIBFORMULA_JAR) +.ELSE +JARFILES += libbase-1.0.0.jar libformula-0.2.0.jar +.ENDIF + +JAVAFILES := AuthorFunction.java \ + AuthorFunctionDescription.java \ + TitleFunction.java \ + TitleFunctionDescription.java \ + MetaDataFunctionCategory.java + +# PROPERTYFILES := $(shell @$(FIND) . -name "*.properties") +PROPERTYFILES := $(CLASSDIR)$/$(PACKAGE)$/category.properties \ + $(CLASSDIR)$/$(PACKAGE)$/category_en_US.properties \ + $(CLASSDIR)$/$(PACKAGE)$/Author-Function.properties \ + $(CLASSDIR)$/$(PACKAGE)$/Author-Function_en_US.properties \ + $(CLASSDIR)$/$(PACKAGE)$/Title-Function.properties \ + $(CLASSDIR)$/$(PACKAGE)$/Title-Function_en_US.properties + +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk + +ALLTAR : $(PROPERTYFILES) + +$(CLASSDIR)$/$(PACKAGE)$/%.properties : %.properties + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ diff --git a/reportbuilder/java/com/sun/star/report/makefile.mk b/reportbuilder/java/com/sun/star/report/makefile.mk new file mode 100644 index 000000000000..9c5c2998f5c0 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/makefile.mk @@ -0,0 +1,78 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.8.46.2 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ = ..$/..$/..$/..$/.. +PRJNAME = reportbuilder +TARGET=rpt_java_css +PACKAGE = com$/sun$/star$/report + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk +#----- compile .java files ----------------------------------------- + +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar +.IF "$(SYSTEM_JFREEREPORT)" == "YES" +XCLASSPATH!:==$(XCLASSPATH)$(PATH_SEPERATOR)$(JCOMMON_JAR)$(PATH_SEPERATOR)$(COMMONS_LOGGING_JAR) +.ELSE +JARFILES += jcommon-1.0.10.jar commons-logging-1.1.1.jar +.ENDIF + +JAVAFILES := DataRow.java\ + DataSource.java\ + DataSourceException.java\ + DataSourceFactory.java\ + InputRepository.java\ + JobDefinitionException.java\ + JobProgressIndicator.java\ + JobProperties.java\ + OutputRepository.java\ + ParameterMap.java\ + ReportAddIn.java\ + ReportEngine.java\ + ReportEngineMetaData.java\ + ReportEngineParameterNames.java\ + ReportExecutionException.java\ + ReportExpression.java\ + ReportExpressionMetaData.java\ + ReportFunction.java\ + ReportJob.java\ + ReportJobFactory.java\ + ReportJobDefinition.java\ + ImageService.java\ + SOImageService.java\ + StorageRepository.java\ + SDBCReportData.java\ + SDBCReportDataFactory.java \ + OfficeToken.java + + +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk diff --git a/reportbuilder/java/com/sun/star/report/pentaho/DefaultNameGenerator.java b/reportbuilder/java/com/sun/star/report/pentaho/DefaultNameGenerator.java new file mode 100644 index 000000000000..6cfac589b900 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/DefaultNameGenerator.java @@ -0,0 +1,149 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DefaultNameGenerator.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import java.io.IOException; + +import com.sun.star.report.OutputRepository; + +public class DefaultNameGenerator +{ + + private final OutputRepository outputRepository; + + public DefaultNameGenerator(final OutputRepository outputRepository) + { + if (outputRepository == null) + { + throw new NullPointerException(); + } + this.outputRepository = outputRepository; + } + + public String generateName(final String namePrefix, final String mimeType) + throws IOException + { + return generateName(namePrefix, mimeType, true); + } + + public String generateStorageName(final String namePrefix, final String mimeType) + throws IOException + { + return generateName(namePrefix, mimeType, false); + } + + /** + * Generates a new, unique name for storing resources in the output repository. Assuming that proper synchronization + * has been applied, the generated name will be unique within that repository. + * + * @param namePrefix a user defined name for that resource. + * @param mimeType the mime type of the resource to be stored in the repository. + * @return the generated, fully qualified name. + */ + private String generateName(final String namePrefix, final String mimeType, final boolean isStream) + throws IOException + { + final String name; + if (namePrefix != null) + { + name = namePrefix; + } + else + { + name = "file"; + } + + String firstFileName = name; + final String suffix; + if (mimeType != null) + { + suffix = getSuffixForType(mimeType); + firstFileName += "." + suffix; + } + else + { + suffix = null; + } + boolean exists; + if (isStream) + { + exists = outputRepository.exists(firstFileName); + } + else + { + exists = outputRepository.existsStorage(firstFileName); + } + if (exists) + { + int counter = 0; + while (exists) + { + if (counter < 0) // wraparound should not happen.. + { + throw new IOException(); + } + firstFileName = name + counter; + if (suffix != null) + { + firstFileName += "." + suffix; + } + if (isStream) + { + exists = outputRepository.exists(firstFileName); + } + else + { + exists = outputRepository.existsStorage(firstFileName); + } + counter += 1; + } + } + return firstFileName; + } + + protected String getSuffixForType(final String mimeType) + { + if ("image/png".equals(mimeType)) + { + return "png"; + } + if ("image/jpeg".equals(mimeType)) + { + return "jpg"; + } + if ("image/gif".equals(mimeType)) + { + return "gif"; + } + + // todo ... use a flexible mapping ... + return "dat"; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/Manifest.mf b/reportbuilder/java/com/sun/star/report/pentaho/Manifest.mf new file mode 100644 index 000000000000..70f3ff695cbb --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/Manifest.mf @@ -0,0 +1,7 @@ +RegistrationClassName: com.sun.star.report.pentaho.SOReportJobFactory +Class-Path: reportbuilderwizard.jar + flute-1.3.0.jar libserializer-1.0.0.jar libbase-1.0.0.jar + libfonts-1.0.0.jar libformula-0.2.0.jar liblayout-0.2.9.jar + libloader-1.0.0.jar librepository-1.0.0.jar libxml-1.0.0.jar + flow-engine-0.9.2.jar sac.jar commons-logging-1.1.1.jar +UNO-Type-Path: diff --git a/reportbuilder/java/com/sun/star/report/pentaho/OfficeNamespaces.java b/reportbuilder/java/com/sun/star/report/pentaho/OfficeNamespaces.java new file mode 100644 index 000000000000..15e364c40e8d --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/OfficeNamespaces.java @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeNamespaces.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +/** + * Creation-Date: Feb 22, 2007, 1:53:29 PM + * + * @author Thomas Morgner + */ +public class OfficeNamespaces +{ + + public static final String OFFICE_NS = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; + public static final String TABLE_NS = "urn:oasis:names:tc:opendocument:xmlns:table:1.0"; + public static final String TEXT_NS = "urn:oasis:names:tc:opendocument:xmlns:text:1.0"; + public static final String STYLE_NS = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"; + public static final String DRAWING_NS = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"; + public static final String FO_NS = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"; + public static final String XLINK_NS = "http://www.w3.org/1999/xlink"; + public static final String PURL_NS = "http://purl.org/dc/elements/1.1/"; + public static final String META_NS = "urn:oasis:names:tc:opendocument:xmlns:meta:1.0"; + public static final String DATASTYLE_NS = "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"; + public static final String SVG_NS = "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"; + public static final String CHART_NS = "urn:oasis:names:tc:opendocument:xmlns:chart:1.0"; + public static final String DR3D_NS = "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"; + public static final String MATHML_NS = "http://www.w3.org/1998/Math/MathML"; + public static final String FORM_NS = "urn:oasis:names:tc:opendocument:xmlns:form:1.0"; + public static final String SCRIPT_NS = "urn:oasis:names:tc:opendocument:xmlns:script:1.0"; + public static final String OO2004_NS = "http://openoffice.org/2004/office"; + public static final String OOW2004_NS = "http://openoffice.org/2004/writer"; + public static final String OOC2004_NS = "http://openoffice.org/2004/calc"; + public static final String XML_EVENT_NS = "http://www.w3.org/2001/xml-events"; + public static final String XFORMS_NS = "http://www.w3.org/2002/xforms"; + public static final String XSD_NS = "http://www.w3.org/2001/XMLSchema"; + public static final String XSI_NS = "http://www.w3.org/2001/XMLSchema-instance"; + public static final String OOREPORT_NS = "http://openoffice.org/2005/report"; + public static final String CONFIG = "urn:oasis:names:tc:opendocument:xmlns:config:1.0"; + + /** + * @deprecated + */ + public static final String NUMBER_NS = DATASTYLE_NS; + + private OfficeNamespaces() + { + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/PentahoFormulaContext.java b/reportbuilder/java/com/sun/star/report/pentaho/PentahoFormulaContext.java new file mode 100644 index 000000000000..46d541679741 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/PentahoFormulaContext.java @@ -0,0 +1,99 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PentahoFormulaContext.java,v $ + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import org.pentaho.reporting.libraries.formula.ContextEvaluationException; +import org.pentaho.reporting.libraries.formula.FormulaContext; +import org.pentaho.reporting.libraries.formula.LocalizationContext; +import org.pentaho.reporting.libraries.formula.function.FunctionRegistry; +import org.pentaho.reporting.libraries.formula.operators.OperatorFactory; +import org.pentaho.reporting.libraries.formula.typing.Type; +import org.pentaho.reporting.libraries.formula.typing.TypeRegistry; +import org.pentaho.reporting.libraries.base.config.Configuration; + +/** + * + * @author Ocke Janssen + */ +public class PentahoFormulaContext implements FormulaContext +{ + final private FormulaContext backend; + final private Configuration config; + + public PentahoFormulaContext(final FormulaContext backend, final Configuration _config) + { + this.backend = backend; + config = _config; + } + + public LocalizationContext getLocalizationContext() + { + return backend.getLocalizationContext(); + } + + public Configuration getConfiguration() + { + return config; + } + + public FunctionRegistry getFunctionRegistry() + { + return backend.getFunctionRegistry(); + } + + public TypeRegistry getTypeRegistry() + { + return backend.getTypeRegistry(); + } + + public OperatorFactory getOperatorFactory() + { + return backend.getOperatorFactory(); + } + + public Type resolveReferenceType(final Object name) throws ContextEvaluationException + { + return backend.resolveReferenceType(name); + } + + public Object resolveReference(final Object name) throws ContextEvaluationException + { + if (name == null) + { + throw new NullPointerException(); + } + return backend.resolveReference(name); + } + + public boolean isReferenceDirty(final Object name) throws ContextEvaluationException + { + return backend.isReferenceDirty(name); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportAddIn.java b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportAddIn.java new file mode 100644 index 000000000000..db8ad9e4409e --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportAddIn.java @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PentahoReportAddIn.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import com.sun.star.report.ReportAddIn; +import com.sun.star.report.ReportExpression; +import com.sun.star.report.ReportExpressionMetaData; +import com.sun.star.report.pentaho.expressions.SumExpression; + +/** + * This class is a dummy implementation. Ignore it for now, we may extend this + * one later. + */ +public class PentahoReportAddIn implements ReportAddIn +{ + + public PentahoReportAddIn() + { + } + + public ReportExpression createExpression(final int expression) + { + return (expression == 0) ? new SumExpression() : null; + } + + public int getExpressionCount() + { + return 1; + } + + public ReportExpressionMetaData getMetaData(final int expression) + { + // todo implement me + return null; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportEngine.java b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportEngine.java new file mode 100644 index 000000000000..d114edf34f71 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportEngine.java @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PentahoReportEngine.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import com.sun.star.report.JobDefinitionException; +import com.sun.star.report.ReportEngine; +import com.sun.star.report.ReportEngineMetaData; +import com.sun.star.report.ReportJob; +import com.sun.star.report.ReportJobDefinition; +import com.sun.star.report.util.DefaultReportJobDefinition; +import org.jfree.report.JFreeReportBoot; + +public class PentahoReportEngine implements ReportEngine +{ + + private final ReportEngineMetaData metaData; + + public PentahoReportEngine() + { + JFreeReportBoot.getInstance().start(); + this.metaData = new PentahoReportEngineMetaData(); + } + + public ReportEngineMetaData getMetaData() + { + return metaData; + } + + public ReportJobDefinition createJobDefinition() + { + return new DefaultReportJobDefinition(metaData); + } + + /** + * Open points: How to define scheduling? + * + * @return the report job definition for the job description. + * + * @throws com.sun.star.report.JobDefinitionException + * + */ + public ReportJob createJob(final ReportJobDefinition definition) + throws JobDefinitionException + { + return new PentahoReportJob(definition); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportEngineMetaData.java b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportEngineMetaData.java new file mode 100644 index 000000000000..7285e9b897be --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportEngineMetaData.java @@ -0,0 +1,146 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PentahoReportEngineMetaData.java,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import com.sun.star.report.ReportJobFactory; +import java.util.HashMap; +import java.util.HashSet; + +import com.sun.star.report.DataSourceFactory; +import com.sun.star.report.InputRepository; +import com.sun.star.report.OutputRepository; +import com.sun.star.report.ReportEngineMetaData; +import com.sun.star.report.ReportEngineParameterNames; +import com.sun.star.report.ImageService; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.pentaho.reporting.libraries.base.util.HashNMap; + +public class PentahoReportEngineMetaData + implements ReportEngineMetaData +{ + + public static final String OPENDOCUMENT_TEXT = "application/vnd.oasis.opendocument.text"; + public static final String OPENDOCUMENT_SPREADSHEET = "application/vnd.oasis.opendocument.spreadsheet"; + public static final String OPENDOCUMENT_CHART = "application/vnd.oasis.opendocument.chart"; + public final static String CONTENT_TYPE = "content-type"; + public static final String DEBUG = "raw/text+xml"; + private final Set mandatoryParameters; + private final Map parameterTypes; + private final HashNMap enumerationValues; + + public PentahoReportEngineMetaData() + { + mandatoryParameters = new HashSet(); + mandatoryParameters.add(ReportEngineParameterNames.CONTENT_TYPE); + mandatoryParameters.add(ReportEngineParameterNames.INPUT_NAME); + mandatoryParameters.add(ReportEngineParameterNames.INPUT_REPOSITORY); + mandatoryParameters.add(ReportEngineParameterNames.OUTPUT_NAME); + mandatoryParameters.add(ReportEngineParameterNames.OUTPUT_REPOSITORY); + mandatoryParameters.add(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY); + mandatoryParameters.add(ReportEngineParameterNames.IMAGE_SERVICE); + mandatoryParameters.add(ReportEngineParameterNames.INPUT_REPORTJOB_FACTORY); + mandatoryParameters.add(ReportEngineParameterNames.INPUT_MASTER_COLUMNS); + mandatoryParameters.add(ReportEngineParameterNames.INPUT_MASTER_VALUES); + mandatoryParameters.add(ReportEngineParameterNames.INPUT_DETAIL_COLUMNS); + mandatoryParameters.add(ReportEngineParameterNames.AUTHOR); + mandatoryParameters.add(ReportEngineParameterNames.TITLE); + + + parameterTypes = new HashMap(); + parameterTypes.put(ReportEngineParameterNames.CONTENT_TYPE, String.class); + parameterTypes.put(ReportEngineParameterNames.INPUT_NAME, String.class); + parameterTypes.put(ReportEngineParameterNames.OUTPUT_NAME, String.class); + parameterTypes.put(ReportEngineParameterNames.INPUT_REPOSITORY, InputRepository.class); + parameterTypes.put(ReportEngineParameterNames.OUTPUT_REPOSITORY, OutputRepository.class); + parameterTypes.put(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY, DataSourceFactory.class); + parameterTypes.put(ReportEngineParameterNames.IMAGE_SERVICE, ImageService.class); + parameterTypes.put(ReportEngineParameterNames.INPUT_REPORTJOB_FACTORY, ReportJobFactory.class); + parameterTypes.put(ReportEngineParameterNames.INPUT_MASTER_COLUMNS, List.class); + parameterTypes.put(ReportEngineParameterNames.INPUT_MASTER_VALUES, List.class); + parameterTypes.put(ReportEngineParameterNames.INPUT_DETAIL_COLUMNS, List.class); + parameterTypes.put(ReportEngineParameterNames.AUTHOR, String.class); + parameterTypes.put(ReportEngineParameterNames.TITLE, String.class); + + enumerationValues = new HashNMap(); + enumerationValues.add(CONTENT_TYPE, + PentahoReportEngineMetaData.OPENDOCUMENT_TEXT); + enumerationValues.add(CONTENT_TYPE, + PentahoReportEngineMetaData.OPENDOCUMENT_SPREADSHEET); + enumerationValues.add(CONTENT_TYPE, + PentahoReportEngineMetaData.OPENDOCUMENT_CHART); + enumerationValues.add(CONTENT_TYPE, PentahoReportEngineMetaData.DEBUG); + } + + public Object[] getEnumerationValues(final String parameter) + { + return enumerationValues.toArray(parameter); + } + + public Class getParameterType(final String parameter) + { + return (Class) parameterTypes.get(parameter); + } + + public boolean isEnumeration(final String parameter) + { + return enumerationValues.containsKey(parameter); + } + + /** + * Checks, whether a certain output type is available. Feed the mime-type of the output + * type in and you'll get a true or false back. + * + * @param mimeType + * @return true, if the output type is supported; false otherwise. + */ + public boolean isOutputSupported(final String mimeType) + { + return enumerationValues.containsValue(CONTENT_TYPE, mimeType.toLowerCase()); + } + + /** + * Lists all supported output parameters for the given mime-type. This listing can be + * used to build a generic user interface for configuring a certain output. + * + * @param mimeType + * @return + */ + public String[] getOutputParameters(final String mimeType) + { + return new String[0]; + } + + public boolean isMandatory(final String parameter) + { + return mandatoryParameters.contains(parameter); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportJob.java b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportJob.java new file mode 100644 index 000000000000..f64c1bd7d741 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/PentahoReportJob.java @@ -0,0 +1,396 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PentahoReportJob.java,v $ + * $Revision: 1.8.16.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import java.io.IOException; +import java.util.ArrayList; + +import com.sun.star.report.DataSourceFactory; +import com.sun.star.report.InputRepository; +import com.sun.star.report.JobDefinitionException; +import com.sun.star.report.JobProgressIndicator; +import com.sun.star.report.JobProperties; +import com.sun.star.report.OutputRepository; +import com.sun.star.report.ParameterMap; +import com.sun.star.report.ReportEngineParameterNames; +import com.sun.star.report.ReportExecutionException; +import com.sun.star.report.ReportJob; +import com.sun.star.report.ReportJobDefinition; +import com.sun.star.report.ImageService; +import com.sun.star.report.SDBCReportDataFactory; +import com.sun.star.report.pentaho.loader.InputRepositoryLoader; +import com.sun.star.report.pentaho.model.OfficeDetailSection; +import com.sun.star.report.pentaho.model.OfficeDocument; +import com.sun.star.report.pentaho.model.OfficeGroup; +import com.sun.star.report.pentaho.model.OfficeReport; +import com.sun.star.report.pentaho.output.chart.ChartRawReportProcessor; +import com.sun.star.report.pentaho.output.text.TextRawReportProcessor; +import com.sun.star.report.pentaho.output.spreadsheet.SpreadsheetRawReportProcessor; +import java.util.List; +import org.pentaho.reporting.libraries.formula.lvalues.ContextLookup; +import org.pentaho.reporting.libraries.formula.lvalues.FormulaFunction; +import org.pentaho.reporting.libraries.formula.lvalues.LValue; +import org.pentaho.reporting.libraries.formula.lvalues.Term; +import org.pentaho.reporting.libraries.formula.parser.FormulaParser; +import org.pentaho.reporting.libraries.formula.parser.ParseException; +import org.pentaho.reporting.libraries.formula.DefaultFormulaContext; +import org.pentaho.reporting.libraries.formula.function.FunctionCategory; +import org.pentaho.reporting.libraries.formula.function.FunctionRegistry; +import org.jfree.report.expressions.Expression; +import org.jfree.report.expressions.FormulaExpression; +import org.jfree.report.flow.DefaultReportJob; +import org.jfree.report.flow.ReportProcessor; +import org.jfree.report.flow.raw.XmlPrintReportProcessor; +import org.jfree.report.structure.Node; +import org.jfree.report.structure.Section; +import org.jfree.report.util.ReportParameters; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.pentaho.reporting.libraries.resourceloader.Resource; +import org.pentaho.reporting.libraries.resourceloader.ResourceException; +import org.pentaho.reporting.libraries.resourceloader.ResourceManager; + +/** + * ToDo: Allow interrupting of jobs and report the report progress + */ +public class PentahoReportJob implements ReportJob +{ + private static final Log LOGGER = LogFactory.getLog(PentahoReportJob.class); + private boolean finished; + private final List listeners; + private final DataSourceFactory dataSourceFactory; + private final OutputRepository outputRepository; + private final JobProperties jobProperties; + private OfficeDocument report; + private final ResourceManager resourceManager; + private final String outputName; + private final ImageService imageService; + private final InputRepository inputRepository; + private final ReportJobDefinition definition; + private final List masterValues; + private final List detailColumns; + + public ReportJobDefinition getDefinition() + { + return definition; + } + + public PentahoReportJob(final ReportJobDefinition definition) + throws JobDefinitionException + { + if (definition == null) + { + throw new NullPointerException(); + } + + this.definition = definition; + this.listeners = new ArrayList(); + this.jobProperties = definition.getProcessingParameters().copy(); + + this.dataSourceFactory = (DataSourceFactory) jobProperties.getProperty(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY); + if (this.dataSourceFactory == null) + { + throw new JobDefinitionException("DataSourceFactory must not be null."); + } + + this.outputRepository = (OutputRepository) jobProperties.getProperty(ReportEngineParameterNames.OUTPUT_REPOSITORY); + if (this.outputRepository == null) + { + throw new JobDefinitionException("OutputRepository must not be null."); + } + + this.inputRepository = + (InputRepository) jobProperties.getProperty(ReportEngineParameterNames.INPUT_REPOSITORY); + if (inputRepository == null) + { + throw new JobDefinitionException("InputRepository must not be null."); + } + + this.outputName = (String) jobProperties.getProperty(ReportEngineParameterNames.OUTPUT_NAME); + if (outputName == null) + { + throw new JobDefinitionException("OutputName must not be null"); + } + + this.imageService = (ImageService) jobProperties.getProperty(ReportEngineParameterNames.IMAGE_SERVICE); + if (imageService == null) + { + throw new JobDefinitionException("A valid image-service implementation must be given."); + } + + this.masterValues = (ArrayList) jobProperties.getProperty(ReportEngineParameterNames.INPUT_MASTER_VALUES); + this.detailColumns = (ArrayList) jobProperties.getProperty(ReportEngineParameterNames.INPUT_DETAIL_COLUMNS); + + this.resourceManager = new ResourceManager(); + this.resourceManager.registerDefaults(); + this.resourceManager.registerLoader(new InputRepositoryLoader(inputRepository)); + + try + { + this.report = parseReport(definition); + } + catch (ResourceException e) + { + throw new JobDefinitionException("Failed to parse the report.", e); + } + } + + private OfficeDocument parseReport(final ReportJobDefinition definition) + throws ResourceException, JobDefinitionException + { + final String reportResource = (String) this.jobProperties.getProperty(ReportEngineParameterNames.INPUT_NAME); + if (reportResource == null) + { + throw new JobDefinitionException("Report definition name must be given"); + } + + final Resource res = resourceManager.createDirectly("sun:oo://" + reportResource, OfficeDocument.class); + final OfficeDocument tempReport = (OfficeDocument) res.getResource(); + tempReport.setDataFactory(new StarReportDataFactory(dataSourceFactory)); + tempReport.setJobProperties(definition.getProcessingParameters().copy()); + final ReportParameters inputParameters = tempReport.getInputParameters(); + + final ParameterMap queryParameters = definition.getQueryParameters(); + final String[] paramKeys = queryParameters.keys(); + for (int i = 0; i < paramKeys.length; i++) + { + final String key = paramKeys[i]; + inputParameters.put(key, queryParameters.get(key)); + } + + return tempReport; + } + + public void addProgressIndicator(final JobProgressIndicator indicator) + { + listeners.add(indicator); + } + + /** + * Interrupt the job. + */ + public void interrupt() + { + // hey, not yet .. + } + + /** + * Queries the jobs result status. + * + * @return true, if the job is finished (or has been interrupted), false if the job + * waits for activation. + */ + public boolean isFinished() + { + return finished; + } + + public void finish() + { + finished = true; + } + + /** + * Queries the jobs execution status. + * + * @return true, if the job is currently running, false otherwise. + */ + public boolean isRunning() + { + return !finished; + } + + public void removeProgressIndicator(final JobProgressIndicator indicator) + { + listeners.remove(indicator); + } + + private void collectGroupExpressions(final Node[] nodes, final List expressions, final FormulaParser parser, final Expression reportFunctions[]) + { + for (int i = 0; i < nodes.length; i++) + { + final Node node = nodes[i]; + if (node instanceof OfficeGroup) + { + final OfficeGroup group = (OfficeGroup) node; + final FormulaExpression exp = (FormulaExpression) group.getGroupingExpression(); + + try + { + final String expression = exp.getFormulaExpression(); + if ( expression == null) + continue; + final FormulaFunction function = (FormulaFunction) parser.parse(expression); + final LValue[] parameters = function.getChildValues(); + if (parameters.length > 0) + { + String name = parameters[0].toString(); + for (int j = 0; j < reportFunctions.length; j++) + { + if (reportFunctions[j] instanceof FormulaExpression) + { + final FormulaExpression reportExp = (FormulaExpression) reportFunctions[j]; + + if (reportExp.getName().equals(name)) + { + final LValue val = (LValue) parser.parse(reportExp.getFormulaExpression()); + if (val instanceof FormulaFunction) + { + final FormulaFunction reportFunction = (FormulaFunction) val; + + final ContextLookup context = (ContextLookup) reportFunction.getChildValues()[0]; + name = context.getName(); + } + else if (val instanceof Term) + { + final Term term = (Term) val; + final ContextLookup context = (ContextLookup) term.getHeadValue().getChildValues()[0]; + name = context.getName(); + } + break; + } + } + } + + final Object[] pair = new Object[2]; + pair[0] = name; + pair[1] = group.getAttribute(OfficeNamespaces.OOREPORT_NS, "sort-ascending"); + expressions.add(pair); + } + } + catch (ParseException ex) + { + LOGGER.error("ReportProcessing failed", ex); + } + } + else if (node instanceof OfficeDetailSection) + { + return; + } + if (node instanceof Section) + { + final Section section = (Section) node; + collectGroupExpressions(section.getNodeArray(), expressions, parser, reportFunctions); + } + } + } + + private void setMetaDataProperties(DefaultReportJob job) + { + job.getConfiguration().setConfigProperty(ReportEngineParameterNames.AUTHOR, (String) jobProperties.getProperty(ReportEngineParameterNames.AUTHOR)); + job.getConfiguration().setConfigProperty(ReportEngineParameterNames.TITLE, (String) jobProperties.getProperty(ReportEngineParameterNames.TITLE)); + } + /** + * Although we might want to run the job as soon as it has been created, sometimes it is + * wiser to let the user add some listeners first. If we execute at once, the user + * either has to deal with threading code or wont receive any progress information in + * single threaded environments. + */ + public void execute() + throws ReportExecutionException, IOException + { + final DefaultReportJob job = new DefaultReportJob(report); + setMetaDataProperties(job); + final String contentType = (String) jobProperties.getProperty(ReportEngineParameterNames.CONTENT_TYPE); + //noinspection OverlyBroadCatchBlock + try + { + final ReportParameters parameters = job.getParameters(); + + if (masterValues != null && detailColumns != null) + { + parameters.put(SDBCReportDataFactory.MASTER_VALUES, masterValues); + parameters.put(SDBCReportDataFactory.DETAIL_COLUMNS, detailColumns); + } + + final Node[] nodes = report.getNodeArray(); + + final FormulaParser parser = new FormulaParser(); + final ArrayList expressions = new ArrayList(); + final OfficeReport officeReport = (OfficeReport) ((Section) nodes[0]).getNode(0); + final Section reportBody = (Section) officeReport.getBodySection(); + collectGroupExpressions(reportBody.getNodeArray(), expressions, parser, officeReport.getExpressions()); + parameters.put(SDBCReportDataFactory.GROUP_EXPRESSIONS, expressions); + final String command = (String) officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, "command"); + final String commandType = (String) officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, SDBCReportDataFactory.COMMAND_TYPE); + final String escapeProcessing = (String) officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, SDBCReportDataFactory.ESCAPE_PROCESSING); + report.setQuery(command); + parameters.put(SDBCReportDataFactory.COMMAND_TYPE, commandType); + parameters.put(SDBCReportDataFactory.ESCAPE_PROCESSING,new Boolean(!("false".equals(escapeProcessing)))); + + final String filter = (String) officeReport.getAttribute(OfficeNamespaces.OOREPORT_NS, "filter"); + parameters.put(SDBCReportDataFactory.UNO_FILTER, filter); + + final long startTime = System.currentTimeMillis(); + final ReportProcessor rp = getProcessorForContentType(contentType); + rp.processReport(job); + job.close(); + final long endTime = System.currentTimeMillis(); + LOGGER.debug("Report processing time: " + (endTime - startTime)); + } + catch (final Exception e) + { + String message = e.getMessage(); + if ( message.length() == 0 ) + message = "Failed to process the report"; + throw new ReportExecutionException(message, e); + } + + } + + protected ReportProcessor getProcessorForContentType(final String mimeType) + throws ReportExecutionException + { + final ReportProcessor ret; + + if (PentahoReportEngineMetaData.OPENDOCUMENT_SPREADSHEET.equals(mimeType)) + { + ret = new SpreadsheetRawReportProcessor(inputRepository, outputRepository, outputName, imageService, dataSourceFactory); + } + else if (PentahoReportEngineMetaData.OPENDOCUMENT_TEXT.equals(mimeType)) + { + ret = new TextRawReportProcessor(inputRepository, outputRepository, outputName, imageService, dataSourceFactory); + } + else if (PentahoReportEngineMetaData.OPENDOCUMENT_CHART.equals(mimeType)) + { + ret = new ChartRawReportProcessor(inputRepository, outputRepository, outputName, imageService, dataSourceFactory); + } + else if (PentahoReportEngineMetaData.DEBUG.equals(mimeType)) + { + ret = new XmlPrintReportProcessor(System.out, "ISO-8859-1"); + } + else + { + throw new ReportExecutionException("Invalid mime-type"); + } + + return ret; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaOpCodeMapper.java b/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaOpCodeMapper.java new file mode 100644 index 000000000000..a225c93a749d --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaOpCodeMapper.java @@ -0,0 +1,155 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SOFormulaOpCodeMapper.java,v $ + * + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import com.sun.star.lang.XServiceInfo; +import com.sun.star.uno.XComponentContext; +import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.sheet.FormulaLanguage; +import com.sun.star.sheet.FormulaMapGroup; +import com.sun.star.sheet.FormulaOpCodeMapEntry; +import com.sun.star.sheet.FormulaToken; +import java.util.ArrayList; +import java.util.Map; + +public final class SOFormulaOpCodeMapper extends WeakBase + implements com.sun.star.sheet.XFormulaOpCodeMapper, XServiceInfo +{ + + private final XComponentContext m_xContext; + private static final String __serviceName = "com.sun.star.report.pentaho.SOFormulaOpCodeMapper"; + private final SOFormulaParser parser; + // attributes + final private int m_OpCodeExternal = 0; + final private int m_OpCodeUnknown = 0; + + public SOFormulaOpCodeMapper(XComponentContext context, SOFormulaParser parser) + { + m_xContext = context; + this.parser = parser; + } + + + // com.sun.star.sheet.XFormulaOpCodeMapper: + public int getOpCodeExternal() + { + return m_OpCodeExternal; + } + + public int getOpCodeUnknown() + { + return m_OpCodeUnknown; + } + + public com.sun.star.sheet.FormulaToken[] getMappings(String[] Names, int Language) throws com.sun.star.lang.IllegalArgumentException + { + if ( Language != FormulaLanguage.ODFF ) + throw new IllegalArgumentException(); + final ArrayList token = new ArrayList(); + final Map parserNames = parser.getNames(); + for (int i = 0; i < Names.length; i++) + { + if ( parserNames.containsKey(Names[i]) ) + { + token.add(((FormulaOpCodeMapEntry) parserNames.get(Names[i])).Token); + } + + } + return (com.sun.star.sheet.FormulaToken[]) token.toArray(new FormulaToken[token.size()]); + } + + public com.sun.star.sheet.FormulaOpCodeMapEntry[] getAvailableMappings(int Language, int Groups) throws com.sun.star.lang.IllegalArgumentException + { + if ( Language != FormulaLanguage.ODFF ) + throw new IllegalArgumentException(); + final ArrayList token = new ArrayList(); + if ( Groups == FormulaMapGroup.SPECIAL ) + { + return (com.sun.star.sheet.FormulaOpCodeMapEntry[]) parser.getSpecialOpCodes().toArray(new FormulaOpCodeMapEntry[parser.getSpecialOpCodes().size()]); + } + else + { + if ( (Groups & FormulaMapGroup.ARRAY_SEPARATORS) != 0 ) + { + token.addAll(parser.getGroup(SOFormulaParser.ARRAY_SEPARATORS).values()); + } + if ( (Groups & FormulaMapGroup.SEPARATORS) != 0 ) + { + token.addAll(parser.getGroup(SOFormulaParser.SEPARATORS).values()); + } + if ( (Groups & FormulaMapGroup.ARRAY_SEPARATORS) != 0 ) + { + token.addAll(parser.getGroup(SOFormulaParser.ARRAY_SEPARATORS).values()); + } + if ( (Groups & FormulaMapGroup.UNARY_OPERATORS) != 0 ) + { + token.addAll(parser.getGroup(SOFormulaParser.UNARY_OPERATORS).values()); + } + if ( (Groups & FormulaMapGroup.BINARY_OPERATORS) != 0 ) + { + token.addAll(parser.getGroup(SOFormulaParser.BINARY_OPERATORS).values()); + } + if ( (Groups & FormulaMapGroup.FUNCTIONS) != 0 ) + { + token.addAll(parser.getGroup(SOFormulaParser.FUNCTIONS).values()); + } + } + + return (com.sun.star.sheet.FormulaOpCodeMapEntry[]) token.toArray(new FormulaOpCodeMapEntry[token.size()]); + } + + public String getImplementationName() + { + return SOFormulaOpCodeMapper.class.getName(); + } + + public boolean supportsService(String sServiceName) + { + return sServiceName.equals(__serviceName); + } + + public String[] getSupportedServiceNames() + { + return getServiceNames(); + } + + /** + * This method is a simple helper function to used in the static component initialisation functions as well as + * in getSupportedServiceNames. + */ + public static String[] getServiceNames() + { + return new String[] + { + __serviceName + }; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaParser.java b/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaParser.java new file mode 100644 index 000000000000..26a454cab9aa --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/SOFormulaParser.java @@ -0,0 +1,429 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SOFormulaParser.java,v $ + * + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import com.sun.star.lang.XServiceInfo; +import com.sun.star.sheet.XFormulaOpCodeMapper; +import com.sun.star.uno.Exception; +import com.sun.star.uno.XComponentContext; +import com.sun.star.lib.uno.helper.ComponentBase; +import com.sun.star.uno.Type; +import com.sun.star.lib.uno.helper.PropertySetMixin; +import com.sun.star.sheet.FormulaLanguage; +import com.sun.star.sheet.FormulaMapGroup; +import com.sun.star.sheet.FormulaMapGroupSpecialOffset; +import com.sun.star.sheet.FormulaOpCodeMapEntry; +import com.sun.star.sheet.FormulaToken; +import com.sun.star.uno.Any; +import com.sun.star.uno.UnoRuntime; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; +import org.pentaho.reporting.libraries.formula.DefaultFormulaContext; +import org.pentaho.reporting.libraries.formula.function.FunctionRegistry; +import org.pentaho.reporting.libraries.formula.parser.FormulaParser; +import org.pentaho.reporting.libraries.formula.parser.GeneratedFormulaParserConstants; +import org.pentaho.reporting.libraries.formula.parser.GeneratedFormulaParserTokenManager; +import org.pentaho.reporting.libraries.formula.parser.JavaCharStream; +import org.pentaho.reporting.libraries.formula.parser.ParseException; +import org.pentaho.reporting.libraries.formula.parser.Token; +import org.pentaho.reporting.libraries.formula.parser.TokenMgrError; +import org.pentaho.reporting.libraries.base.config.Configuration; + +public final class SOFormulaParser extends ComponentBase + implements com.sun.star.report.meta.XFormulaParser, XServiceInfo +{ + + public static final int SEPARATORS = 0; + public static final int ARRAY_SEPARATORS = 1; + public static final int UNARY_OPERATORS = 2; + public static final int BINARY_OPERATORS = 3; + public static final int FUNCTIONS = 4; + private final XComponentContext m_xContext; + private final PropertySetMixin m_prophlp; + private static final String __serviceName = "com.sun.star.report.meta.FormulaParser"; + private static final String OPERATORS = "org.pentaho.reporting.libraries.formula.operators."; + + // attributes + final private List m_OpCodeMap = new ArrayList(); + private XFormulaOpCodeMapper formulaOpCodeMapper = null; + private final Map parserAllOpCodes = new HashMap(); + private final Map parserNames = new HashMap(); + private final Map[] groupOpCodes = new HashMap[5]; + private final Vector specialOpCodes = new Vector(); + + public Vector getSpecialOpCodes() + { + return specialOpCodes; + } + private int ownTokenCounter = 1000; + private final FormulaOpCodeMapEntry opCodePush; + private final FormulaParser parser; + + public SOFormulaParser(XComponentContext context) + { + + m_xContext = context; + final ClassLoader cl = java.lang.Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); + + parser = new FormulaParser(); + try + { + final XFormulaOpCodeMapper mapper = (XFormulaOpCodeMapper) UnoRuntime.queryInterface(XFormulaOpCodeMapper.class, m_xContext.getServiceManager().createInstanceWithContext("simple.formula.FormulaOpCodeMapperObj", m_xContext)); + FormulaOpCodeMapEntry[] opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.FUNCTIONS); + final DefaultFormulaContext defaultContext = new DefaultFormulaContext(); + final FunctionRegistry functionRegistry = defaultContext.getFunctionRegistry(); + + String[] names = functionRegistry.getFunctionNames(); + addOpCodes(names, opCodes, FUNCTIONS); + names = getOperators(defaultContext, OPERATORS); + opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.UNARY_OPERATORS); + addOpCodes(names, opCodes, UNARY_OPERATORS); + opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.BINARY_OPERATORS); + addOpCodes(names, opCodes, BINARY_OPERATORS); + + names = GeneratedFormulaParserConstants.tokenImage.clone(); + for (int i = 0; i < names.length; i++) + { + final String token = names[i]; + if ( token != null && token.length() > 0 && token.charAt(0) == '"' ) + { + names[i] = token.substring(1, token.length() - 1); + } + } + opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.SEPARATORS); + addOpCodes(names, opCodes, SEPARATORS, false); + + opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.ARRAY_SEPARATORS); + addOpCodes(names, opCodes, ARRAY_SEPARATORS, false); + + opCodes = mapper.getAvailableMappings(FormulaLanguage.ODFF, FormulaMapGroup.SPECIAL); + names = new String[opCodes.length]; + + for (int i = 0; i < opCodes.length; i++) + { + final FormulaOpCodeMapEntry opCode = opCodes[i]; + parserAllOpCodes.put(opCode.Token.OpCode, opCode); + specialOpCodes.add(opCode); + } + // addOpCodes(names, opCodes,SPECIAL,false); + } catch ( Exception ex ) + { + ex.printStackTrace(); + } + opCodePush = (FormulaOpCodeMapEntry) specialOpCodes.get(FormulaMapGroupSpecialOffset.PUSH); + Thread.currentThread().setContextClassLoader(cl); + // use the last parameter of the PropertySetMixin constructor + // for your optional attributes if necessary. See the documentation + // of the PropertySetMixin helper for further information. + // Ensure that your attributes are initialized correctly! + m_prophlp = new PropertySetMixin(m_xContext, this, + new Type(com.sun.star.report.meta.XFormulaParser.class), null); + } + ; + + // com.sun.star.sheet.XFormulaParser: + public com.sun.star.sheet.FormulaToken[] parseFormula(String aFormula) + { + final ArrayList tokens = new ArrayList(); + if ( !"=".equals(aFormula) ) + { + String formula; + if ( aFormula.charAt(0) == '=' ) + formula = aFormula.substring(1); + else + formula = aFormula; + final ArrayList images = new ArrayList(); + try + { + int brackets = 0; + final GeneratedFormulaParserTokenManager tokenParser = new GeneratedFormulaParserTokenManager(new JavaCharStream(new StringReader(formula), 1, 1)); + Token token = tokenParser.getNextToken(); + while (token.kind != GeneratedFormulaParserConstants.EOF) + { + final FormulaToken formulaToken; + images.add(token.image); + final String upper = token.image.toUpperCase(); + if ( parserNames.containsKey(upper) ) + { + if ( token.image.equals("(")) + brackets++; + else if ( token.image.equals(")")) + --brackets; + final FormulaOpCodeMapEntry opCode = (FormulaOpCodeMapEntry) parserNames.get(upper); + formulaToken = opCode.Token; + } + else if ( token.kind == GeneratedFormulaParserConstants.WHITESPACE ) + { + final FormulaOpCodeMapEntry opCode = (FormulaOpCodeMapEntry) specialOpCodes.get(FormulaMapGroupSpecialOffset.SPACES); + formulaToken = opCode.Token; + } + else + { + formulaToken = new FormulaToken(); + formulaToken.OpCode = opCodePush.Token.OpCode; + formulaToken.Data = new Any(Type.STRING, token.image); + } + + tokens.add(formulaToken); + token = tokenParser.getNextToken(); + } + if ( brackets > 0 ) + { + final FormulaOpCodeMapEntry opCode = (FormulaOpCodeMapEntry) parserNames.get(")"); + while ( brackets-- != 0 ) + { + formula = formula.concat(")"); + images.add(")"); + tokens.add(opCode.Token); + } + + } + + parser.parse(formula); + } catch ( ParseException ex ) + { + boolean found = false; + // error occured so all token must be bad + for (int i = 0; i < tokens.size(); i++) + { + if ( !found && images.get(i).equals(ex.currentToken.image) ) + found = true; + if ( found ) + { + final FormulaToken dest = new FormulaToken(); + dest.OpCode = ((FormulaOpCodeMapEntry) specialOpCodes.get(FormulaMapGroupSpecialOffset.BAD)).Token.OpCode; + dest.Data = new Any(Type.STRING, images.get(i)); + tokens.remove(i); + tokens.add(i, dest); + } + } + } catch ( java.lang.Exception e ) + { + } catch ( TokenMgrError e ) + { + } + } + FormulaToken[] ret = (FormulaToken[]) tokens.toArray(new FormulaToken[tokens.size()]); + return ret; + } + + public String printFormula(com.sun.star.sheet.FormulaToken[] aTokens) + { + final StringBuffer ret = new StringBuffer(); + for (int i = 0; i < aTokens.length; i++) + { + final FormulaToken formulaToken = aTokens[i]; + if ( formulaToken.OpCode == opCodePush.Token.OpCode && !formulaToken.Data.equals(Any.VOID) ) + { + ret.append(formulaToken.Data); + } + else if ( parserAllOpCodes.containsKey(formulaToken.OpCode) ) + { + final FormulaOpCodeMapEntry opCode = (FormulaOpCodeMapEntry) parserAllOpCodes.get(formulaToken.OpCode); + if ( opCode.Name.length() > 0 ) + ret.append(opCode.Name); + else if ( !formulaToken.Data.equals(Any.VOID) ) + ret.append(formulaToken.Data); + } + } + return ret.toString(); + } + + // com.sun.star.beans.XPropertySet: + public com.sun.star.beans.XPropertySetInfo getPropertySetInfo() + { + return m_prophlp.getPropertySetInfo(); + } + + public void setPropertyValue(String aPropertyName, Object aValue) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.beans.PropertyVetoException, com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.setPropertyValue(aPropertyName, aValue); + } + + public Object getPropertyValue(String aPropertyName) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + return m_prophlp.getPropertyValue(aPropertyName); + } + + public void addPropertyChangeListener(String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.addPropertyChangeListener(aPropertyName, xListener); + } + + public void removePropertyChangeListener(String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.removePropertyChangeListener(aPropertyName, xListener); + } + + public void addVetoableChangeListener(String aPropertyName, com.sun.star.beans.XVetoableChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.addVetoableChangeListener(aPropertyName, xListener); + } + + public void removeVetoableChangeListener(String aPropertyName, com.sun.star.beans.XVetoableChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.removeVetoableChangeListener(aPropertyName, xListener); + } + + // com.sun.star.report.meta.XFormulaParser: + public com.sun.star.sheet.FormulaOpCodeMapEntry[] getOpCodeMap() + { + return (com.sun.star.sheet.FormulaOpCodeMapEntry[]) m_OpCodeMap.toArray(new FormulaOpCodeMapEntry[m_OpCodeMap.size()]); + } + + public void setOpCodeMap(com.sun.star.sheet.FormulaOpCodeMapEntry[] the_value) + { +// m_prophlp.prepareSet("OpCodeMap", null); +// synchronized (this) +// { +// m_OpCodeMap.clear(); +// } + } + + public String getImplementationName() + { + return SOFormulaParser.class.getName(); + } + + public boolean supportsService(String sServiceName) + { + return sServiceName.equals(__serviceName); + } + + public String[] getSupportedServiceNames() + { + return getServiceNames(); + } + + /** + * This method is a simple helper function to used in the static component initialisation functions as well as + * in getSupportedServiceNames. + */ + public static String[] getServiceNames() + { + return new String[] + { + __serviceName + }; + } + + public XFormulaOpCodeMapper getFormulaOpCodeMapper() + { + if ( formulaOpCodeMapper == null ) + { + formulaOpCodeMapper = new SOFormulaOpCodeMapper(m_xContext, this); + } + + return formulaOpCodeMapper; + } + + private void addOpCodes(String[] names, FormulaOpCodeMapEntry[] opCodes, int group) + { + addOpCodes(names, opCodes, group, true); + } + + private void addOpCodes(String[] names, FormulaOpCodeMapEntry[] opCodes, int group, boolean add) + { + groupOpCodes[group] = new HashMap(); + for (int j = 0; j < names.length; j++) + { + FormulaOpCodeMapEntry opCode = null; + int i = 0; + for (; i < opCodes.length; i++) + { + opCode = opCodes[i]; + if ( names[j].equals(opCode.Name) ) + { + break; + } + } + if ( i >= opCodes.length ) + { + if ( !add ) + continue; + final FormulaToken token = new FormulaToken(ownTokenCounter++, Any.VOID); + opCode = new FormulaOpCodeMapEntry(names[j], token); + } + parserNames.put(names[j], opCode); + parserAllOpCodes.put(opCode.Token.OpCode, opCode); + groupOpCodes[group].put(opCode.Token.OpCode, opCode); + } + } + + final public Map getNames() + { + return parserNames; + } + + final public Map getGroup(int group) + { + return groupOpCodes[group]; + } + + private String[] getOperators(DefaultFormulaContext defaultContext, final String _kind) + { + final ArrayList ops = new ArrayList(); + final Configuration configuration = defaultContext.getConfiguration(); + final Iterator iter = configuration.findPropertyKeys(_kind); + while (iter.hasNext()) + { + final String configKey = (String) iter.next(); + if ( configKey.endsWith(".class") == false ) + { + continue; + } + final String operatorClass = configuration.getConfigProperty(configKey); + if ( operatorClass == null ) + { + continue; + } + if ( operatorClass.length() == 0 ) + { + continue; + } + final String tokenKey = configKey.substring(0, configKey.length() - ".class".length()) + ".token"; + final String token = configuration.getConfigProperty(tokenKey); + if ( token == null ) + { + continue; + } + ops.add(token.trim()); + } + return (String[]) ops.toArray(new String[ops.size()]); + } +} + diff --git a/reportbuilder/java/com/sun/star/report/pentaho/SOFunctionManager.java b/reportbuilder/java/com/sun/star/report/pentaho/SOFunctionManager.java new file mode 100644 index 000000000000..059aed34796a --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/SOFunctionManager.java @@ -0,0 +1,198 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: XFunctionManager.java,v $ + * + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import com.sun.star.container.NoSuchElementException; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.report.meta.XFunctionDescription; +import com.sun.star.uno.XComponentContext; +import com.sun.star.lib.uno.helper.ComponentBase; +import com.sun.star.report.meta.XFunctionCategory; +import com.sun.star.report.meta.XFunctionManager; +import org.pentaho.reporting.libraries.formula.DefaultFormulaContext; +import org.pentaho.reporting.libraries.formula.function.FunctionCategory; +import org.pentaho.reporting.libraries.formula.function.FunctionDescription; +import org.pentaho.reporting.libraries.formula.function.FunctionRegistry; +import org.pentaho.reporting.libraries.formula.lvalues.LValue; +import org.pentaho.reporting.libraries.formula.parser.FormulaParser; +import org.pentaho.reporting.libraries.formula.parser.ParseException; + +/** + * This class capsulates the class, that implements the minimal component, a factory for creating the service + * (<CODE>__getComponentFactory</CODE>) and a method, that writes the information into the given registry key + * (<CODE>__writeRegistryServiceInfo</CODE>). + */ +public final class SOFunctionManager extends ComponentBase implements XFunctionManager, XServiceInfo +{ + + private final XComponentContext m_xContext; + /** + * The service name, that must be used to get an instance of this service. + */ + private static final String __serviceName = + "com.sun.star.report.meta.FunctionManager"; + final private FunctionCategory[] categories; + final private FunctionRegistry functionRegistry; + final private DefaultFormulaContext defaultContext; + + public SOFunctionManager(XComponentContext context) + { + m_xContext = context; + final ClassLoader cl = java.lang.Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); + defaultContext = new DefaultFormulaContext(); + functionRegistry = defaultContext.getFunctionRegistry(); + categories = functionRegistry.getCategories(); + Thread.currentThread().setContextClassLoader(cl); + + } + + /** + * This method returns an array of all supported service names. + * + * @return Array of supported service names. + */ + public String[] getSupportedServiceNames() + { + return getServiceNames(); + } + + /** + * This method is a simple helper function to used in the static component initialisation functions as well as + * in getSupportedServiceNames. + */ + public static String[] getServiceNames() + { + return new String[] + { + __serviceName + }; + } + + /** + * This method returns true, if the given service will be supported by the component. + * + * @param sServiceName Service name. + * @return True, if the given service name will be supported. + */ + public boolean supportsService(final String sServiceName) + { + return sServiceName.equals(__serviceName); + } + + /** + * Return the class name of the component. + * + * @return Class name of the component. + */ + public String getImplementationName() + { + return SOFunctionManager.class.getName(); + } + + // com.sun.star.container.XElementAccess: + public com.sun.star.uno.Type getElementType() + { + return new com.sun.star.uno.Type(XFunctionCategory.class); + } + + public boolean hasElements() + { + return categories.length != 0; + } + + // com.sun.star.container.XIndexAccess: + public int getCount() + { + return categories.length; + } + + public Object getByIndex(int Index) throws com.sun.star.lang.IndexOutOfBoundsException, com.sun.star.lang.WrappedTargetException + { + return getCategory(Index); + } + + // com.sun.star.report.meta.XFunctionManager: + public com.sun.star.report.meta.XFunctionCategory getCategory(int position) throws com.sun.star.lang.IndexOutOfBoundsException, com.sun.star.lang.WrappedTargetException + { + if ( position >= categories.length ) + throw new com.sun.star.lang.IndexOutOfBoundsException(); + return new StarFunctionCategory(defaultContext,m_xContext, functionRegistry, position, categories[position]); + } + + public int getFunctionStartAtIndex(String formula, int position) + { + int nStartPos = -1; + try + { + final FormulaParser parser = new FormulaParser(); + final LValue x = parser.parse(formula); + String part = x.toString(); + while ( part.length() < position ) + { + final LValue[] children = x.getChildValues(); + if ( children != null ) + { + for(int i = 0; i < children.length;++i) + { + part = children[i].toString(); + } + } + } + } catch ( ParseException ex ) + { + } + return nStartPos; + } + + public XFunctionDescription getFunctionByName(String arg0) throws NoSuchElementException + { + final FunctionDescription func = functionRegistry.getMetaData(arg0); + if ( func == null ) + throw new NoSuchElementException(); + int i = 0; + for (; i < categories.length; i++) + { + if ( categories[i] == func.getCategory() ) + break; + } + try + { + return new StarFunctionDescription(defaultContext, m_xContext, getCategory(i), functionRegistry, func); + } + catch ( Exception ex ) + { + } + return null; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/SOReportJobFactory.java b/reportbuilder/java/com/sun/star/report/pentaho/SOReportJobFactory.java new file mode 100644 index 000000000000..cda541184968 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/SOReportJobFactory.java @@ -0,0 +1,437 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SOReportJobFactory.java,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.beans.XPropertyChangeListener; +import com.sun.star.beans.XVetoableChangeListener; +import com.sun.star.embed.XStorage; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XInitialization; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XSingleComponentFactory; +import com.sun.star.lib.uno.helper.Factory; +import com.sun.star.lib.uno.helper.PropertySetMixin; +import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.registry.InvalidRegistryException; +import com.sun.star.registry.InvalidValueException; +import com.sun.star.registry.XRegistryKey; +import com.sun.star.registry.XSimpleRegistry; +import com.sun.star.report.DataSourceFactory; +import com.sun.star.report.JobProperties; +import com.sun.star.report.ReportEngineParameterNames; +import com.sun.star.report.ReportExecutionException; +import com.sun.star.report.ReportJob; +import com.sun.star.report.ReportJobDefinition; +import com.sun.star.report.ReportJobFactory; +import com.sun.star.report.SDBCReportDataFactory; +import com.sun.star.report.SOImageService; +import com.sun.star.report.StorageRepository; +import com.sun.star.report.XReportDefinition; +import com.sun.star.report.pentaho.SOReportJobFactory._SOReportJobFactory; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XRowSet; +import com.sun.star.task.XJob; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * This class capsulates the class, that implements the minimal component, a factory for creating the service + * (<CODE>__getComponentFactory</CODE>) and a method, that writes the information into the given registry key + * (<CODE>__writeRegistryServiceInfo</CODE>). + */ +public class SOReportJobFactory +{ + + private SOReportJobFactory() + { + } + + public static class _SOReportJobFactory extends WeakBase implements XInitialization, XServiceInfo, XJob, XPropertySet, ReportJobFactory + { + + private static final Log LOGGER = LogFactory.getLog(_SOReportJobFactory.class); + /** + * The service name, that must be used to get an instance of this service. + */ + private static final String __serviceName = + "com.sun.star.report.pentaho.SOReportJobFactory"; + private final PropertySetMixin m_prophlp; + /** + * The initial component contextr, that gives access to the service manager, supported singletons, ... It's + * often later used + */ + private final XComponentContext m_cmpCtx; + private XConnection activeConnection; + private XReportDefinition report; + + public _SOReportJobFactory(final XComponentContext xCompContext) + { + m_cmpCtx = xCompContext; + m_prophlp = new PropertySetMixin(m_cmpCtx, this, + new Type(XJob.class), + null); // no optionals + } + + /** + * This method is a member of the interface for initializing an object directly after its creation. + * + * @param object This array of arbitrary objects will be passed to the component after its creation. + * @throws Exception Every exception will not be handled, but will be passed to the caller. + */ + public void initialize(final Object[] object) + throws com.sun.star.uno.Exception + { + /* The component describes what arguments its expected and in which + * order!At this point you can read the objects and can intialize + * your component using these objects. + */ + } + + /** + * This method returns an array of all supported service names. + * + * @return Array of supported service names. + */ + public String[] getSupportedServiceNames() + { + return getServiceNames(); + } + + /** + * This method is a simple helper function to used in the static component initialisation functions as well as + * in getSupportedServiceNames. + */ + public static String[] getServiceNames() + { + return new String[] + { + __serviceName + }; + } + + /** + * This method returns true, if the given service will be supported by the component. + * + * @param sServiceName Service name. + * @return True, if the given service name will be supported. + */ + public boolean supportsService(final String sServiceName) + { + return sServiceName.equals(__serviceName); + } + + /** + * Return the class name of the component. + * + * @return Class name of the component. + */ + public String getImplementationName() + { + return SOReportJobFactory.class.getName(); + } + + private String getLocaleFromRegistry(final XSimpleRegistry simpleReg, final String path, final String value) + { + String currentLocale = null; + try + { + simpleReg.open(path, true, false); + XRegistryKey xRegistryRootKey = simpleReg.getRootKey(); + // read locale + XRegistryKey locale = xRegistryRootKey.openKey(value); + if ( locale != null ) + { + final String newLocale = locale.getStringValue(); + if ( newLocale != null ) + { + currentLocale = newLocale.replace('-', '_'); + } + } + } + catch ( InvalidValueException ex ) + { + Logger.getLogger(SOReportJobFactory.class.getName()).log(Level.SEVERE, null, ex); + } + catch ( InvalidRegistryException ex ) + { + Logger.getLogger(SOReportJobFactory.class.getName()).log(Level.SEVERE, null, ex); + } + + return currentLocale; + } + + public Object execute(final NamedValue[] namedValue) + throws com.sun.star.lang.IllegalArgumentException, com.sun.star.uno.Exception + { + final ClassLoader cl = java.lang.Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); + try + { + XSimpleRegistry simpleReg = (XSimpleRegistry) UnoRuntime.queryInterface(XSimpleRegistry.class, + m_cmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.configuration.ConfigurationRegistry", m_cmpCtx)); + + String currentLocale = getLocaleFromRegistry(simpleReg,"org.openoffice.Setup","L10N/ooSetupSystemLocale"); + if ( currentLocale == null || "".equals(currentLocale) ) + { + currentLocale = getLocaleFromRegistry(simpleReg,"org.openoffice.Office.Linguistic","General/DefaultLocale"); + } + if ( currentLocale != null && !"".equals(currentLocale) ) + System.setProperty("org.pentaho.reporting.libraries.formula.locale", currentLocale); + final ReportJob job = createReportJob(namedValue); + job.execute(); + + } + catch ( java.lang.Exception e ) + { + LOGGER.error("ReportProcessing failed", e); + throw new com.sun.star.lang.WrappedTargetException(e.getMessage(), this, null); + } + catch ( java.lang.IncompatibleClassChangeError e2 ) + { + LOGGER.error("Detected an IncompatibleClassChangeError"); + throw new com.sun.star.lang.WrappedTargetException("caught a " + e2.getClass().getName(), this, new com.sun.star.uno.Exception(e2.getLocalizedMessage())); + } + Thread.currentThread().setContextClassLoader(cl); + + return null; + } + + public ReportJob createReportJob(final NamedValue[] namedValue) throws IllegalArgumentException, ReportExecutionException, Exception + { + XStorage input = null; + XStorage output = null; + XRowSet rowSet = null; + String mimetype = null; + String author = null; + String title = null; + + for ( int i = 0; i < namedValue.length; ++i ) + { + final NamedValue aProps = namedValue[i]; + if ( "ActiveConnection".equalsIgnoreCase(aProps.Name) ) + { + activeConnection = (XConnection) UnoRuntime.queryInterface(XConnection.class, aProps.Value); + } + else if ( "ReportDefinition".equalsIgnoreCase(aProps.Name) ) + { + report = (XReportDefinition) UnoRuntime.queryInterface(XReportDefinition.class, aProps.Value); + } + else if ( "InputStorage".equalsIgnoreCase(aProps.Name) ) + { + input = (XStorage) UnoRuntime.queryInterface(XStorage.class, aProps.Value); + } + else if ( "OutputStorage".equalsIgnoreCase(aProps.Name) ) + { + output = (XStorage) UnoRuntime.queryInterface(XStorage.class, aProps.Value); + } + else if ( "RowSet".equalsIgnoreCase(aProps.Name) ) + { + rowSet = (XRowSet) UnoRuntime.queryInterface(XRowSet.class, aProps.Value); + } + else if ( "mimetype".equalsIgnoreCase(aProps.Name) ) + { + mimetype = (String) aProps.Value; + } + else if ( ReportEngineParameterNames.AUTHOR.equalsIgnoreCase(aProps.Name) ) + { + author = (String) aProps.Value; + } + else if ( ReportEngineParameterNames.TITLE.equalsIgnoreCase(aProps.Name) ) + { + title = (String) aProps.Value; + } + } + + if ( input == null || output == null ) + { + throw new com.sun.star.lang.IllegalArgumentException(); + } + + if ( rowSet == null ) + { + if ( report == null || activeConnection == null ) + { + throw new com.sun.star.lang.IllegalArgumentException(); + } + mimetype = report.getMimeType(); + } + else + { + final XPropertySet set = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, rowSet); + if ( set == null ) + { + throw new com.sun.star.lang.IllegalArgumentException(); + } + activeConnection = (XConnection) UnoRuntime.queryInterface(XConnection.class, set.getPropertyValue("ActiveConnection")); + } + if ( mimetype == null ) + { + mimetype = PentahoReportEngineMetaData.OPENDOCUMENT_TEXT; + } + + final DataSourceFactory dataFactory = new SDBCReportDataFactory(m_cmpCtx, activeConnection); + final StorageRepository storageRepository = new StorageRepository(input, output); + + final String inputName = "content.xml"; + final String outputName = "content.xml"; + + final PentahoReportEngine engine = new PentahoReportEngine(); + final ReportJobDefinition definition = engine.createJobDefinition(); + final JobProperties procParms = definition.getProcessingParameters(); + procParms.setProperty(ReportEngineParameterNames.INPUT_REPOSITORY, storageRepository); + procParms.setProperty(ReportEngineParameterNames.OUTPUT_REPOSITORY, storageRepository); + procParms.setProperty(ReportEngineParameterNames.INPUT_NAME, inputName); + procParms.setProperty(ReportEngineParameterNames.OUTPUT_NAME, outputName); + procParms.setProperty(ReportEngineParameterNames.CONTENT_TYPE, mimetype); + procParms.setProperty(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY, dataFactory); + procParms.setProperty(ReportEngineParameterNames.IMAGE_SERVICE, new SOImageService(m_cmpCtx)); + procParms.setProperty(ReportEngineParameterNames.INPUT_REPORTJOB_FACTORY, this); + if ( author != null ) + { + procParms.setProperty(ReportEngineParameterNames.AUTHOR, author); + } + if ( title != null ) + { + procParms.setProperty(ReportEngineParameterNames.TITLE, title); + } + + return engine.createJob(definition); + } + + // com.sun.star.beans.XPropertySet: + public com.sun.star.beans.XPropertySetInfo getPropertySetInfo() + { + return m_prophlp.getPropertySetInfo(); + } + + public void setPropertyValue(final String aPropertyName, final Object aValue) + throws UnknownPropertyException, PropertyVetoException, com.sun.star.lang.IllegalArgumentException, + WrappedTargetException + { + m_prophlp.setPropertyValue(aPropertyName, aValue); + } + + public Object getPropertyValue(final String aPropertyName) + throws UnknownPropertyException, WrappedTargetException + { + return m_prophlp.getPropertyValue(aPropertyName); + } + + public void addPropertyChangeListener(final String aPropertyName, final XPropertyChangeListener xListener) + throws UnknownPropertyException, WrappedTargetException + { + m_prophlp.addPropertyChangeListener(aPropertyName, xListener); + } + + public void removePropertyChangeListener(final String aPropertyName, final XPropertyChangeListener xListener) + throws UnknownPropertyException, WrappedTargetException + { + m_prophlp.removePropertyChangeListener(aPropertyName, xListener); + } + + public void addVetoableChangeListener(final String aPropertyName, final XVetoableChangeListener xListener) + throws UnknownPropertyException, WrappedTargetException + { + m_prophlp.addVetoableChangeListener(aPropertyName, xListener); + } + + public void removeVetoableChangeListener(final String aPropertyName, final XVetoableChangeListener xListener) + throws UnknownPropertyException, WrappedTargetException + { + m_prophlp.removeVetoableChangeListener(aPropertyName, xListener); + } + } + + /** + * Gives a factory for creating the service. This method is called by the <code>JavaLoader</code> + * <p/> + * + * @param sImplName the name of the implementation for which a service is desired + * @return returns a <code>XSingleComponentFactory</code> for creating the component + * @see com.sun.star.comp.loader.JavaLoader + */ + public static XSingleComponentFactory __getComponentFactory(final String sImplName) + { + XSingleComponentFactory xFactory = null; + + try + { + if ( sImplName.equals(_SOReportJobFactory.class.getName()) ) + { + xFactory = Factory.createComponentFactory(_SOReportJobFactory.class, _SOReportJobFactory.getServiceNames()); + } + else if ( sImplName.equals(SOFunctionManager.class.getName()) ) + { + xFactory = Factory.createComponentFactory(SOFunctionManager.class, SOFunctionManager.getServiceNames()); + } + else if ( sImplName.equals(SOFormulaParser.class.getName()) ) + { + xFactory = Factory.createComponentFactory(SOFormulaParser.class, SOFormulaParser.getServiceNames()); + } + } + catch ( java.lang.IncompatibleClassChangeError e2 ) + { + } + + return xFactory; + } + + /** + * Writes the service information into the given registry key. This method is called by the <code>JavaLoader</code> + * <p/> + * + * @param regKey the registryKey + * @return returns true if the operation succeeded + * @see com.sun.star.comp.loader.JavaLoader + */ + public static boolean __writeRegistryServiceInfo(final XRegistryKey regKey) + { + return Factory.writeRegistryServiceInfo(SOFunctionManager.class.getName(), + SOFunctionManager.getServiceNames(), + regKey) && + Factory.writeRegistryServiceInfo(_SOReportJobFactory.class.getName(), + _SOReportJobFactory.getServiceNames(), + regKey) && + Factory.writeRegistryServiceInfo(SOFormulaParser.class.getName(), + SOFormulaParser.getServiceNames(), + regKey); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionCategory.java b/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionCategory.java new file mode 100644 index 000000000000..9c98f42eb6eb --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionCategory.java @@ -0,0 +1,162 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StarFunctionCategory.java,v $ + * + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import com.sun.star.uno.XComponentContext; +import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.uno.Type; +import com.sun.star.lib.uno.helper.PropertySetMixin; +import com.sun.star.report.meta.XFunctionDescription; +import java.util.Locale; +import java.util.MissingResourceException; +import org.pentaho.reporting.libraries.formula.DefaultFormulaContext; +import org.pentaho.reporting.libraries.formula.function.FunctionCategory; +import org.pentaho.reporting.libraries.formula.function.FunctionRegistry; + + +public final class StarFunctionCategory extends WeakBase + implements com.sun.star.report.meta.XFunctionCategory +{ + private final XComponentContext m_xContext; + private final PropertySetMixin m_prophlp; + // attributes + private final int m_Number; + private final FunctionCategory category; + private final FunctionRegistry functionRegistry; + private final String functions[]; + private final DefaultFormulaContext defaultContext; + private final Locale defaultLocale; + + public StarFunctionCategory( DefaultFormulaContext defaultContext,final XComponentContext context,final FunctionRegistry functionRegistry,final int _number,final FunctionCategory category ) + { + this.defaultContext = defaultContext; + m_xContext = context; + m_Number = _number; + this.category = category; + this.functionRegistry = functionRegistry; + Locale locale; + try + { + category.getDisplayName(defaultContext.getLocalizationContext().getLocale()); + locale = defaultContext.getLocalizationContext().getLocale(); + } + catch(MissingResourceException e) + { + locale = Locale.ENGLISH; + } + this.defaultLocale = locale; + + functions = functionRegistry.getFunctionNamesByCategory(category); + // use the last parameter of the PropertySetMixin constructor + // for your optional attributes if necessary. See the documentation + // of the PropertySetMixin helper for further information. + // Ensure that your attributes are initialized correctly! + m_prophlp = new PropertySetMixin(m_xContext, this, + new Type(com.sun.star.report.meta.XFunctionCategory.class), null); + }; + + // com.sun.star.beans.XPropertySet: + public com.sun.star.beans.XPropertySetInfo getPropertySetInfo() + { + return m_prophlp.getPropertySetInfo(); + } + + public void setPropertyValue(String aPropertyName, Object aValue) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.beans.PropertyVetoException, com.sun.star.lang.IllegalArgumentException,com.sun.star.lang.WrappedTargetException + { + m_prophlp.setPropertyValue(aPropertyName, aValue); + } + + public Object getPropertyValue(String aPropertyName) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + return m_prophlp.getPropertyValue(aPropertyName); + } + + public void addPropertyChangeListener(String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.addPropertyChangeListener(aPropertyName, xListener); + } + + public void removePropertyChangeListener(String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.removePropertyChangeListener(aPropertyName, xListener); + } + + public void addVetoableChangeListener(String aPropertyName, com.sun.star.beans.XVetoableChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.addVetoableChangeListener(aPropertyName, xListener); + } + + public void removeVetoableChangeListener(String aPropertyName, com.sun.star.beans.XVetoableChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.removeVetoableChangeListener(aPropertyName, xListener); + } + + // com.sun.star.container.XElementAccess: + public com.sun.star.uno.Type getElementType() + { + return new com.sun.star.uno.Type(XFunctionDescription.class); + } + + public boolean hasElements() + { + return functions.length != 0; + } + + // com.sun.star.container.XIndexAccess: + public int getCount() + { + return functions.length; + } + + public Object getByIndex(int Index) throws com.sun.star.lang.IndexOutOfBoundsException, com.sun.star.lang.WrappedTargetException + { + return getFunction(Index); + } + + // com.sun.star.report.meta.XFunctionCategory: + public int getNumber() + { + return m_Number; + } + + public String getName() + { + return category.getDisplayName(defaultLocale); + } + + public com.sun.star.report.meta.XFunctionDescription getFunction(int position) throws com.sun.star.lang.IndexOutOfBoundsException, com.sun.star.lang.WrappedTargetException + { + if ( position >= functions.length ) + throw new IndexOutOfBoundsException(); + return new StarFunctionDescription(defaultContext,m_xContext,this,functionRegistry,functionRegistry.getMetaData(functions[position])); + } + +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionDescription.java b/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionDescription.java new file mode 100644 index 000000000000..bca8ad026b19 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/StarFunctionDescription.java @@ -0,0 +1,191 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StarFunctionDescription.java,v $ + * + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import com.sun.star.uno.XComponentContext; +import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.uno.Type; +import com.sun.star.lib.uno.helper.PropertySetMixin; +import com.sun.star.report.meta.XFunctionCategory; +import com.sun.star.sheet.FunctionArgument; +import java.util.Locale; +import java.util.MissingResourceException; +import org.pentaho.reporting.libraries.formula.DefaultFormulaContext; +import org.pentaho.reporting.libraries.formula.function.FunctionDescription; +import org.pentaho.reporting.libraries.formula.function.FunctionRegistry; + +public final class StarFunctionDescription extends WeakBase + implements com.sun.star.report.meta.XFunctionDescription +{ + + private final XComponentContext m_xContext; + private final PropertySetMixin m_prophlp; + // attributes +// final private com.sun.star.report.meta.XFunctionCategory m_Category; + private final FunctionDescription functionDescription; + private final FunctionRegistry functionRegistry; + private final XFunctionCategory category; + private final Locale defaultLocale; + + public StarFunctionDescription(final DefaultFormulaContext defaultContext, final XComponentContext context, final XFunctionCategory category, final FunctionRegistry functionRegistry, final FunctionDescription functionDescription) + { + m_xContext = context; + this.category = category; + Locale locale; + try + { + functionDescription.getDisplayName(defaultContext.getLocalizationContext().getLocale()); + locale = defaultContext.getLocalizationContext().getLocale(); + } catch ( MissingResourceException e ) + { + locale = Locale.ENGLISH; + } + this.defaultLocale = locale; + + this.functionDescription = functionDescription; + this.functionRegistry = functionRegistry; + // use the last parameter of the PropertySetMixin constructor + // for your optional attributes if necessary. See the documentation + // of the PropertySetMixin helper for further information. + // Ensure that your attributes are initialized correctly! + m_prophlp = new PropertySetMixin(m_xContext, this, + new Type(com.sun.star.report.meta.XFunctionDescription.class), null); + } + ; + + // com.sun.star.beans.XPropertySet: + public com.sun.star.beans.XPropertySetInfo getPropertySetInfo() + { + return m_prophlp.getPropertySetInfo(); + } + + public void setPropertyValue(String aPropertyName, Object aValue) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.beans.PropertyVetoException, com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.setPropertyValue(aPropertyName, aValue); + } + + public Object getPropertyValue(String aPropertyName) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + return m_prophlp.getPropertyValue(aPropertyName); + } + + public void addPropertyChangeListener(String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.addPropertyChangeListener(aPropertyName, xListener); + } + + public void removePropertyChangeListener(String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.removePropertyChangeListener(aPropertyName, xListener); + } + + public void addVetoableChangeListener(String aPropertyName, com.sun.star.beans.XVetoableChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.addVetoableChangeListener(aPropertyName, xListener); + } + + public void removeVetoableChangeListener(String aPropertyName, com.sun.star.beans.XVetoableChangeListener xListener) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.WrappedTargetException + { + m_prophlp.removeVetoableChangeListener(aPropertyName, xListener); + } + + // com.sun.star.report.meta.XFunctionDescription: + public com.sun.star.report.meta.XFunctionCategory getCategory() + { + return category; + } + + public String getName() + { + return functionDescription.getDisplayName(defaultLocale); + } + + public String getDescription() + { + return functionDescription.getDescription(defaultLocale); + } + + public String getSignature() + { + final int count = functionDescription.getParameterCount(); + final StringBuffer signature = new StringBuffer(getName()); + signature.append("("); + for (int i = 0; i < count; i++) + { + signature.append(functionDescription.getParameterDisplayName(i, defaultLocale)); + if ( i != (count - 1) ) + signature.append(";"); + } + signature.append(")"); + return signature.toString(); + } + + public com.sun.star.sheet.FunctionArgument[] getArguments() + { + int count = functionDescription.getParameterCount(); + final boolean infinite = functionDescription.isInfiniteParameterCount(); + if ( infinite ) + { + count = 30; + } + final FunctionArgument[] args = new FunctionArgument[count]; + for (int i = 0; i < args.length; i++) + { + final int pos = infinite ? 0 : i; + args[i] = new FunctionArgument(); + args[i].Description = functionDescription.getParameterDescription(pos, defaultLocale); + args[i].Name = functionDescription.getParameterDisplayName(pos, defaultLocale); + args[i].IsOptional = !functionDescription.isParameterMandatory(pos); + } + return args; + } + + public String createFormula(String[] arguments) throws com.sun.star.lang.DisposedException, com.sun.star.lang.IllegalArgumentException, com.sun.star.uno.Exception + { + final boolean infinite = functionDescription.isInfiniteParameterCount(); + final int count = functionDescription.getParameterCount(); + if ( !infinite && arguments.length > count ) + throw new com.sun.star.lang.IllegalArgumentException(); + + final StringBuffer formula = new StringBuffer(getName()); + formula.append("("); + for (int i = 0; i < arguments.length; ++i) + { + if ( arguments[i].length() == 0 ) + break; + formula.append(arguments[i]); + if ( i < (arguments.length - 1) && arguments[i+1].length() != 0 ) + formula.append(";"); + } + formula.append(")"); + return formula.toString(); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/StarReportData.java b/reportbuilder/java/com/sun/star/report/pentaho/StarReportData.java new file mode 100644 index 000000000000..7d65f881ec6c --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/StarReportData.java @@ -0,0 +1,170 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StarReportData.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho; + +import com.sun.star.report.DataSource; +import org.jfree.report.DataSourceException; +import org.jfree.report.ReportData; + +public class StarReportData implements ReportData +{ + + private final DataSource dataSource; + private int currentRow; + private final int rowCount; + + public StarReportData(final DataSource dataSource) + throws com.sun.star.report.DataSourceException + { + if (dataSource == null) + { + throw new NullPointerException(); + } + this.dataSource = dataSource; + this.currentRow = 0; + this.rowCount = dataSource.getRowCount(); + } + + public boolean setCursorPosition(final int row) throws DataSourceException + { + try + { + final boolean ret = dataSource.absolute(row); + if (ret) + { + currentRow = row; + } + return ret; + } + catch (com.sun.star.report.DataSourceException e) + { + throw new DataSourceException("Failed to move cursor", e); + } + } + + public void close() + throws DataSourceException + { + try + { + dataSource.close(); + } + catch (com.sun.star.report.DataSourceException e) + { + throw new DataSourceException("Failed to close datasource", e); + } + } + + public int getCursorPosition() + throws DataSourceException + { + return currentRow; + } + + /** + * This operation checks, whether a call to next will be likely to succeed. If + * there is a next data row, this should return true. + * + * @return + * @throws org.jfree.report.DataSourceException + * + */ + public boolean isAdvanceable() throws DataSourceException + { + return currentRow < rowCount; + } + + public boolean next() + throws DataSourceException + { + try + { + if (dataSource.next()) + { + currentRow += 1; + return true; + } + return false; + } + catch (com.sun.star.report.DataSourceException e) + { + throw new DataSourceException("Failed to move cursor", e); + } + } + + public Object get(final int column) + throws DataSourceException + { + if (!isReadable()) + { + throw new DataSourceException("Failed to query column."); + } + + try + { + return dataSource.getObject(column + 1); + } + catch (com.sun.star.report.DataSourceException e) + { + throw new DataSourceException("Failed to query column.", e); + } + } + + public int getColumnCount() + throws DataSourceException + { + try + { + return dataSource.getColumnCount(); + } + catch (com.sun.star.report.DataSourceException e) + { + throw new DataSourceException("Failed to query column count.", e); + } + } + + public String getColumnName(final int column) + throws DataSourceException + { + try + { + return dataSource.getColumnName(column + 1); + } + catch (com.sun.star.report.DataSourceException e) + { + throw new DataSourceException("Failed to query column name.", e); + } + } + + public boolean isReadable() throws DataSourceException + { + return currentRow > 0 && rowCount > 0; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/StarReportDataFactory.java b/reportbuilder/java/com/sun/star/report/pentaho/StarReportDataFactory.java new file mode 100644 index 000000000000..2a3600213d6c --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/StarReportDataFactory.java @@ -0,0 +1,126 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StarReportDataFactory.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho; + +import java.util.HashMap; + +import org.jfree.report.ReportDataFactory; +import org.jfree.report.ReportData; +import org.jfree.report.DataSet; +import org.jfree.report.ReportDataFactoryException; +import com.sun.star.report.DataSourceException; +import com.sun.star.report.DataSourceFactory; + +public class StarReportDataFactory implements ReportDataFactory, Cloneable +{ + private final DataSourceFactory backend; + + public StarReportDataFactory (DataSourceFactory backend) + { + this.backend = backend; + } + + /** + * Queries a datasource. The string 'query' defines the name of the query. The + * Parameterset given here may contain more data than actually needed. + * <p/> + * The dataset may change between two calls, do not assume anything! + * + * @param query + * @param parameters + * @return + */ + public ReportData queryData (final String query, final DataSet parameters) + throws ReportDataFactoryException + { + try + { + final HashMap map = new HashMap(); + final int count = parameters.getColumnCount(); + for (int i = 0; i < count; i++) + { + final Object o = parameters.get(i); + map.put (parameters.getColumnName(i), o); + } + return new StarReportData(backend.queryData(query, map)); + } + catch(DataSourceException dse) + { + String message = dse.getMessage(); + if ( message.length() == 0 ) + message = "Failed to create report data wrapper"; + throw new ReportDataFactoryException(message,dse); + } + catch (org.jfree.report.DataSourceException e) + { + String message = e.getMessage(); + if ( message.length() == 0 ) + message = "Failed to query data"; + throw new ReportDataFactoryException(message); + } + } + + public void open() + { + + } + + public void close() + { + + } + + + /** + * Derives a freshly initialized report data factory, which is independend of + * the original data factory. Opening or Closing one data factory must not + * affect the other factories. + * + * @return + */ + public ReportDataFactory derive() + { + try + { + return (ReportDataFactory) clone(); + } + catch (CloneNotSupportedException e) + { + throw new IllegalStateException("Clone failed?"); + } + } + + public Object clone () throws CloneNotSupportedException + { + return super.clone(); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/StarReportModule.java b/reportbuilder/java/com/sun/star/report/pentaho/StarReportModule.java new file mode 100644 index 000000000000..e39de6fb2f00 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/StarReportModule.java @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StarReportModule.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho; + +import org.pentaho.reporting.libraries.base.boot.AbstractModule; +import org.pentaho.reporting.libraries.base.boot.ModuleInitializeException; +import org.pentaho.reporting.libraries.base.boot.SubSystem; + +public class StarReportModule extends AbstractModule +{ + public StarReportModule () + throws ModuleInitializeException + { + loadModuleInfo(); + } + + /** + * Initializes the module. Use this method to perform all initial setup operations. This + * method is called only once in a modules lifetime. If the initializing cannot be + * completed, throw a ModuleInitializeException to indicate the error,. The module will + * not be available to the system. + * + * @param subSystem the subSystem. + * @throws org.jfree.base.modules.ModuleInitializeException + * if an error ocurred while initializing the module. + */ + public void initialize (final SubSystem subSystem) + throws ModuleInitializeException + { + + + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/configuration.properties b/reportbuilder/java/com/sun/star/report/pentaho/configuration.properties new file mode 100644 index 000000000000..8af708eb60c5 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/configuration.properties @@ -0,0 +1,158 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: configuration.properties,v $ +# +# $Revision: 1.6 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + + +## +# Do not modify the following lines. They connect this module to the central +# parser registry. +org.pentaho.reporting.libraries.resourceloader.factory.modules.com.sun.star.report.pentaho.model.OfficeDocument.star=com.sun.star.report.pentaho.parser.StarXmlFactoryModule +org.pentaho.reporting.libraries.resourceloader.factory.modules.com.sun.star.report.pentaho.model.OfficeStylesCollection.star=com.sun.star.report.pentaho.parser.StarStyleXmlFactoryModule +org.pentaho.reporting.libraries.resourceloader.factory.modules.com.sun.star.report.pentaho.styles.StyleMapper.star=com.sun.star.report.pentaho.styles.StyleMapperXmlFactoryModule + +## +# The known namespaces. +# +org.jfree.report.namespaces.star-rpt.Uri=http://openoffice.org/2005/report +org.jfree.report.namespaces.star-rpt.Default-Style=res://com/sun/star/report/pentaho/star-rpt.css +org.jfree.report.namespaces.star-rpt.Prefix=rpt +org.jfree.report.namespaces.star-rpt.ClassAttr=style-name + +org.jfree.report.namespaces.star-office.Uri=http://openoffice.org/2004/office +org.jfree.report.namespaces.star-office.Default-Style=res://com/sun/star/report/pentaho/star-office.css +org.jfree.report.namespaces.star-office.Prefix=office +org.jfree.report.namespaces.star-office.ClassAttr=style-name + +org.jfree.report.namespaces.oasis-style.Uri=urn:oasis:names:tc:opendocument:xmlns:style:1.0 +org.jfree.report.namespaces.oasis-style.Default-Style=res://com/sun/star/report/pentaho/oasis-style.css +org.jfree.report.namespaces.oasis-style.Prefix=style + +org.jfree.report.namespaces.oasis-table.Uri=urn:oasis:names:tc:opendocument:xmlns:table:1.0 +org.jfree.report.namespaces.oasis-table.Default-Style=res://com/sun/star/report/pentaho/oasis-table.css +org.jfree.report.namespaces.oasis-table.Prefix=table +org.jfree.report.namespaces.oasis-table.ClassAttr=style-name + +org.jfree.report.namespaces.oasis-draw.Uri=urn:oasis:names:tc:opendocument:xmlns:drawing:1.0 +org.jfree.report.namespaces.oasis-draw.Default-Style=res://com/sun/star/report/pentaho/oasis-draw.css +org.jfree.report.namespaces.oasis-draw.Prefix=draw +org.jfree.report.namespaces.oasis-draw.ClassAttr=style-name + +org.jfree.report.namespaces.oasis-chart.Uri=urn:oasis:names:tc:opendocument:xmlns:chart:1.0 +org.jfree.report.namespaces.oasis-chart.Default-Style=res://com/sun/star/report/pentaho/oasis-chart.css +org.jfree.report.namespaces.oasis-chart.Prefix=chart +org.jfree.report.namespaces.oasis-chart.ClassAttr=style-name + +org.jfree.report.namespaces.oasis-text.Uri=urn:oasis:names:tc:opendocument:xmlns:text:1.0 +org.jfree.report.namespaces.oasis-text.Default-Style=res://com/sun/star/report/pentaho/oasis-text.css +org.jfree.report.namespaces.oasis-text.Prefix=text +org.jfree.report.namespaces.oasis-text.ClassAttr=style-name + +org.jfree.report.namespaces.oasis-number.Uri=urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0 +org.jfree.report.namespaces.oasis-number.Default-Style=res://com/sun/star/report/pentaho/oasis-number.css +org.jfree.report.namespaces.oasis-number.Prefix=number +org.jfree.report.namespaces.oasis-number.ClassAttr=style-name + +org.jfree.report.namespaces.oasis-form.Uri=urn:oasis:names:tc:opendocument:xmlns:form:1.0 +org.jfree.report.namespaces.oasis-form.Default-Style=res://com/sun/star/report/pentaho/oasis-form.css +org.jfree.report.namespaces.oasis-form.Prefix=form + +# +# This defines a subset of the real XSL-FO standard. +org.jfree.report.namespaces.oasis-compat-fo.Uri=urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0 +org.jfree.report.namespaces.oasis-compat-fo.Default-Style=res://com/sun/star/report/pentaho/xsl-fo.css +org.jfree.report.namespaces.oasis-compat-fo.Prefix=fo + +# +# This defines a subset of the real XSL-FO standard. +org.jfree.report.namespaces.oasis-compat-svg.Uri=urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0 +org.jfree.report.namespaces.oasis-compat-svg.Default-Style=res://com/sun/star/report/pentaho/svg.css +org.jfree.report.namespaces.oasis-compat-svg.Prefix=svg + +# +# This defines a subset of the real XSL-FO standard. +org.jfree.report.namespaces.oasis-compat-smil.Uri=urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0 +org.jfree.report.namespaces.oasis-compat-smil.Default-Style=res://com/sun/star/report/pentaho/smil.css +org.jfree.report.namespaces.oasis-compat-smil.Prefix=svg + +org.jfree.report.namespaces.xsl-fo.Uri=http://www.w3.org/1999/XSL/Format +org.jfree.report.namespaces.xsl-fo.Default-Style=res://com/sun/star/report/pentaho/xsl-fo.css +org.jfree.report.namespaces.xsl-fo.Prefix=fo + +org.jfree.report.namespaces.svg.Uri=http://www.w3.org/2000/svg +org.jfree.report.namespaces.svg.Default-Style=res://com/sun/star/report/pentaho/svg.css +org.jfree.report.namespaces.svg.Prefix=svg +org.jfree.report.namespaces.svg.ClassAttr=class +org.jfree.report.namespaces.svg.StyleAttr=style + +org.jfree.report.namespaces.xml-xlink.Uri=http://www.w3.org/1999/xlink +#org.jfree.report.namespaces.xml-xlink.Default-Style=res://com/sun/star/report/pentaho/xml-xlink.css +org.jfree.report.namespaces.xml-xlink.Prefix=xlink + +# +# Tag-definition for the XML-writer. +# Prefix is 'com.sun.star.report.pentaho.output.' +# +# Declare the namespaces (this is independent of the ones defined above ..) +# <prefix>"namespace."<ns-prefix>=<ns-uri> +com.sun.star.report.pentaho.output.namespace.oasis-text=urn:oasis:names:tc:opendocument:xmlns:text:1.0 +com.sun.star.report.pentaho.output.default.oasis-text=deny + +com.sun.star.report.pentaho.output.namespace.oasis-config=urn:oasis:names:tc:opendocument:xmlns:config:1.0 +com.sun.star.report.pentaho.output.default.oasis-config=allow + +# +# Next define the tags for which we want to customize the indent-behaviour +com.sun.star.report.pentaho.output.tag.oasis-text.p=deny +com.sun.star.report.pentaho.output.tag.oasis-text.section=allow +com.sun.star.report.pentaho.output.tag.oasis-text.variable-decls=allow +com.sun.star.report.pentaho.output.tag.oasis-text.variable-decl=allow + +com.sun.star.report.pentaho.output.tag.oasis-config.config-item=deny + +com.sun.star.report.pentaho.output.namespace.oasis-data=urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0 +com.sun.star.report.pentaho.output.default.oasis-data=allow +com.sun.star.report.pentaho.output.tag.oasis-data.text=deny +com.sun.star.report.pentaho.output.tag.oasis-data.currency-symbol=deny + +com.sun.star.report.pentaho.output.namespace.oasis-draw=urn:oasis:names:tc:opendocument:xmlns:drawing:1.0 +com.sun.star.report.pentaho.output.default.oasis-draw=deny + +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.FixedTextElement=com.sun.star.report.pentaho.layoutprocessor.FixedTextLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.FormattedTextElement=com.sun.star.report.pentaho.layoutprocessor.FormattedTextLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.ObjectOleElement=com.sun.star.report.pentaho.layoutprocessor.ObjectOleLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.ImageElement=com.sun.star.report.pentaho.layoutprocessor.ImageElementLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.TableCellElement=com.sun.star.report.pentaho.layoutprocessor.TableCellLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.OfficeReport=com.sun.star.report.pentaho.layoutprocessor.OfficeReportLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.OfficeGroup=com.sun.star.report.pentaho.layoutprocessor.OfficeGroupLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.OfficeGroupSection=com.sun.star.report.pentaho.layoutprocessor.OfficeGroupSectionLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.VariablesDeclarationSection=com.sun.star.report.pentaho.layoutprocessor.VariablesDeclarationLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.OfficeDetailSection=com.sun.star.report.pentaho.layoutprocessor.OfficeDetailLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.OfficeTableSection=com.sun.star.report.pentaho.layoutprocessor.OfficeTableLayoutController +org.jfree.report.flow.structure.com.sun.star.report.pentaho.model.OfficeGroupInstanceSection=com.sun.star.report.pentaho.layoutprocessor.OfficeGroupInstanceSectionLayoutController diff --git a/reportbuilder/java/com/sun/star/report/pentaho/expressions/SumExpression.java b/reportbuilder/java/com/sun/star/report/pentaho/expressions/SumExpression.java new file mode 100644 index 000000000000..e1259d168b44 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/expressions/SumExpression.java @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SumExpression.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.expressions; + +import com.sun.star.report.ReportExpression; +import com.sun.star.report.DataRow; + +public class SumExpression implements ReportExpression +{ + private Object[] parameters; + + public SumExpression () + { + } + + public Object getParameters () + { + return parameters; + } + + public Object getValue (final DataRow row) + { + + return null; + } + + public void setParameters (final Object[] parameters) + { + this.parameters = parameters; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/expressions/SumExpressionMetaData.java b/reportbuilder/java/com/sun/star/report/pentaho/expressions/SumExpressionMetaData.java new file mode 100644 index 000000000000..8e2d395c8493 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/expressions/SumExpressionMetaData.java @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SumExpressionMetaData.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.expressions; + +import java.util.Locale; + +import com.sun.star.report.ReportExpressionMetaData; + +public class SumExpressionMetaData implements ReportExpressionMetaData +{ + public String getDescription (final Locale l) + { + // todo implement me + return null; + } + + public String getDisplayName (final Locale l) + { + // todo implement me + return null; + } + + public String getName () + { + // todo implement me + return null; + } + + public int getParameterCount () + { + // todo implement me + return 0; + } + + public String getParameterDescription (final int param,final Locale locale) + { + // todo implement me + return null; + } + + public String getParameterDisplayName (final int param,final Locale locale) + { + // todo implement me + return null; + } + + public String getParameterName (final int param) + { + // todo implement me + return null; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/AbstractReportElementLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/AbstractReportElementLayoutController.java new file mode 100644 index 000000000000..3f7245bf12c9 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/AbstractReportElementLayoutController.java @@ -0,0 +1,270 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AbstractReportElementLayoutController.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho.layoutprocessor; + +import com.sun.star.report.pentaho.model.ReportElement; +import com.sun.star.report.pentaho.model.OfficeGroupSection; +import org.jfree.report.DataSourceException; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.DataRow; +import org.jfree.report.DataFlags; +import org.jfree.report.structure.Element; +import org.jfree.report.structure.Group; +import org.jfree.report.expressions.Expression; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.layoutprocessor.AbstractLayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutControllerUtil; +import org.jfree.report.flow.layoutprocessor.SectionLayoutController; +import org.pentaho.reporting.libraries.formula.lvalues.LValue; +import org.pentaho.reporting.libraries.formula.lvalues.ContextLookup; + +/** + * Todo: Document me! + * + * @author Thomas Morgner + * @since 05.03.2007 + * @noinspection CloneableClassWithoutClone + */ +public abstract class AbstractReportElementLayoutController + extends AbstractLayoutController +{ + + public static final int NOT_STARTED = 0; + public static final int FINISHED = 2; + private int state; + + protected AbstractReportElementLayoutController() + { + } + + /** + * Advances the processing position. + * + * @param target the report target that receives generated events. + * @return the new layout controller instance representing the new state. + * + * @throws org.jfree.report.DataSourceException if there was a problem reading data from + * the datasource. + * @throws org.jfree.report.ReportProcessingException if there was a general problem during + * the report processing. + * @throws org.jfree.report.ReportDataFactoryException if a query failed. + */ + public LayoutController advance(final ReportTarget target) + throws DataSourceException, ReportDataFactoryException, + ReportProcessingException + { + if (state != AbstractReportElementLayoutController.NOT_STARTED) + { + throw new IllegalStateException(); + } + + boolean isPrintableContent = true; + final ReportElement text = (ReportElement) getNode(); + // Tests we have to perform: + // 1. Print when group changes. We can know whether a group changed by + // looking at the newly introduced iteration counter. + // + // Whether we use the next one or the one after that depends on whether + // this element is a child of a group-header or group-footer. + + // 2. Print repeated values. This never applies to static text or static + // elements. + if ((text.isPrintWhenGroupChanges() && !isGroupChanged()) || (!text.isPrintRepeatedValues() && !isValueChanged())) + { + // if this is set to true, then we print the element only if this is the + // first occurrence in this group. + // or + // If this is set to true, we evaluate the formula of the element and + // try to derive whether there was a change. + isPrintableContent = false; + } + + // 3. Evaluate the Display Condition + final Expression dc = text.getDisplayCondition(); + if (dc != null) + { + final Object o = LayoutControllerUtil.evaluateExpression(getFlowController(), text, dc); + if (Boolean.FALSE.equals(o)) + { +// LOGGER.debug ("DISPLAY Condition forbids printing"); + isPrintableContent = false; + } + } + + if (!isPrintableContent) + { + // There is no printable content at all. Set the state to FINISHED + return join(getFlowController()); + } + else + { + // delegate to the handler .. + return delegateContentGeneration(target); + } + + } + + protected abstract boolean isValueChanged(); + + protected boolean isGroupChanged() + { + // search the group. + final SectionLayoutController slc = findGroup(); + if (slc == null) + { + // Always print the content of the report header and footer and + // the page header and footer. + return true; + } + + // we are in the first iteration, so yes, the group has changed recently. + return slc.getIterationCount() == 0; + } + + private SectionLayoutController findGroup() + { + LayoutController parent = getParent(); + boolean skipNext = false; + while (parent != null) + { + if (!(parent instanceof SectionLayoutController)) + { + parent = parent.getParent(); + } + else + { + final SectionLayoutController slc = (SectionLayoutController) parent; + final Element element = slc.getElement(); + if (element instanceof OfficeGroupSection) + { + // This is a header or footer. So we take the next group instead. + skipNext = true; + parent = parent.getParent(); + } + else if (!(element instanceof Group)) + { + parent = parent.getParent(); + } + else if (skipNext) + { + skipNext = false; + parent = parent.getParent(); + } + else + { + return (SectionLayoutController) parent; + } + } + } + return null; + } + + /** + * Joins with a delegated process flow. This is generally called from a child + * flow and should *not* (I mean it!) be called from outside. If you do, + * you'll suffer. + * + * @param flowController the flow controller of the parent. + * @return the joined layout controller that incorperates all changes from the + * delegate. + */ + public LayoutController join(final FlowController flowController) + throws DataSourceException, ReportDataFactoryException, + ReportProcessingException + { + final AbstractReportElementLayoutController alc = + (AbstractReportElementLayoutController) clone(); + alc.state = AbstractReportElementLayoutController.FINISHED; + return alc; + } + + protected abstract LayoutController delegateContentGeneration(final ReportTarget target) + throws ReportProcessingException, ReportDataFactoryException, + DataSourceException; + + /** + * Checks, whether the layout controller would be advanceable. If this method + * returns true, it is generally safe to call the 'advance()' method. + * + * @return true, if the layout controller is advanceable, false otherwise. + */ + public boolean isAdvanceable() + { + return state != AbstractReportElementLayoutController.FINISHED; + } + + protected boolean isReferenceChanged(final LValue lValue) + { + if (lValue instanceof ContextLookup) + { + final ContextLookup rval = (ContextLookup) lValue; + final String s = rval.getName(); + final DataRow view = getFlowController().getMasterRow().getGlobalView(); + try + { + final DataFlags flags = view.getFlags(s); + if (flags != null && flags.isChanged()) + { +// LOGGER.debug ("Reference " + s + " is changed"); + return true; + } +// LOGGER.debug ("Reference " + s + " is unchanged"); + } + catch (DataSourceException e) + { + // ignore .. assume that the reference has not changed. + } + } + final LValue[] childValues = lValue.getChildValues(); + for (int i = 0; i < childValues.length; i++) + { + final LValue value = childValues[i]; + if (isReferenceChanged(value)) + { + return true; + } + } +// LOGGER.debug ("Unchanged."); + return false; + } + + public int getState() + { + return state; + } + + protected void setState(final int state) + { + this.state = state; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FixedTextLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FixedTextLayoutController.java new file mode 100644 index 000000000000..9ced56ef7ac4 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FixedTextLayoutController.java @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FixedTextLayoutController.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.layoutprocessor; + +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutControllerFactory; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportContext; +import org.jfree.report.data.GlobalMasterRow; +import org.jfree.report.data.ReportDataRow; +import org.jfree.report.structure.Section; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.DataSourceException; +import com.sun.star.report.pentaho.model.FixedTextElement; + +/** + * Processes a fixed-text element of the OpenOffice reporting specifciation. + * The element itself contains a single paragraph which contains the content. + * After checking, whether this element should be printed, this layout + * controller simply delegates the dirty work to a suitable handler. + * + * @author Thomas Morgner + * @noinspection CloneableClassWithoutClone + * @since 05.03.2007 + */ +public class FixedTextLayoutController + extends AbstractReportElementLayoutController +{ + + public FixedTextLayoutController() + { + } + + + protected boolean isValueChanged() + { + final FlowController controller = getFlowController(); + final GlobalMasterRow masterRow = controller.getMasterRow(); + final ReportDataRow reportDataRow = masterRow.getReportDataRow(); + return reportDataRow.getCursor() == 0; + } + + protected LayoutController delegateContentGeneration + (final ReportTarget target) + throws ReportProcessingException, ReportDataFactoryException, + DataSourceException + { + final FixedTextElement fte = (FixedTextElement) getNode(); + final Section content = fte.getContent(); + + final FlowController flowController = getFlowController(); + final ReportContext reportContext = flowController.getReportContext(); + final LayoutControllerFactory layoutControllerFactory = + reportContext.getLayoutControllerFactory(); + + final FixedTextLayoutController flc = (FixedTextLayoutController) clone(); + flc.setState(AbstractReportElementLayoutController.FINISHED); + return layoutControllerFactory.create(flowController, content, flc); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java new file mode 100755 index 000000000000..4eea93329cb4 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java @@ -0,0 +1,166 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FormatValueUtility.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package com.sun.star.report.pentaho.layoutprocessor; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.OfficeToken; +import com.sun.star.report.pentaho.model.FormattedTextElement; +import org.jfree.layouting.util.AttributeMap; +import org.jfree.report.DataFlags; +import org.jfree.report.DataSourceException; +import org.jfree.report.data.DefaultDataFlags; +import org.jfree.report.expressions.FormulaExpression; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.layoutprocessor.LayoutControllerUtil; + +/** + * Creation-Date: 06.06.2007, 17:03:30 + * + * @author Thomas Morgner + */ +public class FormatValueUtility +{ + private static final String BOOLEAN_VALUE = "boolean-value"; + private static final String STRING_VALUE = "string-value"; + + public static final String VALUE_TYPE = "value-type"; + private static SimpleDateFormat dateFormat; + + private FormatValueUtility() + { + } + + public static String applyValueForVariable(final Object value, final AttributeMap variableSection) + { + String ret = null; + if (value instanceof Date) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "date"); + ret = formatDate((Date) value); + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "date-value", ret); + } + else if (value instanceof Number) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "float"); + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "value", String.valueOf(value)); + } + else if (value instanceof Boolean) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "boolean"); + if (Boolean.TRUE.equals(value)) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS,BOOLEAN_VALUE, OfficeToken.TRUE); + } + else + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS,BOOLEAN_VALUE, OfficeToken.FALSE); + } + } + else if (value != null) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "string"); + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS,STRING_VALUE, String.valueOf(value)); + } + else + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, VALUE_TYPE, "string"); + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS,STRING_VALUE, ""); + } + return ret; + } + + public static void applyValueForCell(final Object value, final AttributeMap variableSection) + { + if (value instanceof Date) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "date-value", formatDate((Date) value)); + } + else if (value instanceof Number) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS, "value", String.valueOf(value)); + } + else if (value instanceof Boolean) + { + if (Boolean.TRUE.equals(value)) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS,BOOLEAN_VALUE, OfficeToken.TRUE); + } + else + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS,BOOLEAN_VALUE, OfficeToken.FALSE); + } + } + else if (value != null) + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS,STRING_VALUE, String.valueOf(value)); + } + else + { + variableSection.setAttribute(OfficeNamespaces.OFFICE_NS,STRING_VALUE, ""); + } + } + + private static synchronized String formatDate(final Date date) + { + if (dateFormat == null) + { + dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'S'Z'"); + } + return dateFormat.format(date); + } + + public static DataFlags computeDataFlag(final FormattedTextElement element, + final FlowController flowController) + throws DataSourceException + { + // here it is relatively easy. We have to evaluate the expression, convert + // the result into a string, and print that string. + final FormulaExpression formulaExpression = element.getValueExpression(); + final Object result = LayoutControllerUtil.evaluateExpression(flowController, element, formulaExpression); + if (result == null) + { + // ignore it. Ignoring it is much better than printing 'null'. + // LOGGER.debug("Formula '" + formulaExpression.getFormula() + "' evaluated to null."); + return null; + } + else if (result instanceof DataFlags) + { + return (DataFlags) result; + } + else + { + return new DefaultDataFlags(null, result, true); + } + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java new file mode 100644 index 000000000000..c5c69d24716b --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java @@ -0,0 +1,217 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FormattedTextLayoutController.java,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho.layoutprocessor; + +import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.OfficeToken; +import com.sun.star.report.pentaho.model.FormattedTextElement; +import com.sun.star.report.pentaho.model.OfficeDocument; +import com.sun.star.report.pentaho.model.OfficeStyle; +import org.pentaho.reporting.libraries.formula.Formula; +import org.pentaho.reporting.libraries.formula.lvalues.LValue; +import org.pentaho.reporting.libraries.formula.parser.ParseException; +import org.jfree.report.DataFlags; +import org.jfree.report.DataSourceException; +import org.jfree.report.JFreeReportInfo; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.expressions.FormulaExpression; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.structure.Element; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jfree.layouting.util.AttributeMap; + +/** + * Todo: Document me! + * + * @author Thomas Morgner + * @since 05.03.2007 + */ +public class FormattedTextLayoutController + extends AbstractReportElementLayoutController +{ + private static final Log LOGGER = LogFactory.getLog(FormattedTextLayoutController.class); + public FormattedTextLayoutController() + { + } + + private VariablesCollection getVariablesCollection() + { + LayoutController parent = getParent(); + while (parent != null) + { + if (parent instanceof OfficeRepeatingStructureLayoutController) + { + final OfficeRepeatingStructureLayoutController orslc = + (OfficeRepeatingStructureLayoutController) parent; + if (orslc.isNormalFlowProcessing()) + { + return null; + } + + return orslc.getVariablesCollection(); + } + parent = parent.getParent(); + } + return null; + } + + protected boolean isValueChanged() + { + try + { + final FormattedTextElement element = (FormattedTextElement) getNode(); + final FormulaExpression formulaExpression = element.getValueExpression(); + final Formula formula = formulaExpression.getCompiledFormula(); + final LValue lValue = formula.getRootReference(); + return isReferenceChanged(lValue); + } + catch (final ParseException e) + { + LOGGER.debug("Parse Exception", e); + return false; + } + } + + protected LayoutController delegateContentGeneration(final ReportTarget target) + throws ReportProcessingException, ReportDataFactoryException, + DataSourceException + { + final FormattedTextElement element = (FormattedTextElement) getNode(); + final VariablesCollection vc = getVariablesCollection(); + if (vc != null) + { + final String name = vc.addVariable(element); + final AttributeMap variablesGet = new AttributeMap(); + variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, + Element.TYPE_ATTRIBUTE, "variable-get"); + variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, + Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TEXT_NS); + variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "name", name); + //variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "display", "value"); + + final String dataStyleName = computeValueStyle(); + if (dataStyleName != null) + { + variablesGet.setAttribute(OfficeNamespaces.STYLE_NS, "data-style-name", dataStyleName); + } + + final String valueType = computeValueType(); + variablesGet.setAttribute(OfficeNamespaces.OFFICE_NS, FormatValueUtility.VALUE_TYPE, valueType); + target.startElement(variablesGet); + + target.endElement(variablesGet); + } + else + { + + final DataFlags df = FormatValueUtility.computeDataFlag(element, getFlowController()); + if (df != null) + { + target.processContent(df); + } + } + + return join(getFlowController()); + } + + private OfficeDocument getDocument() + { + LayoutController parent = getParent(); + while (parent != null) + { + final Object node = parent.getNode(); + if (node instanceof OfficeDocument) + { + return (OfficeDocument) node; + } + parent = parent.getParent(); + } + return null; + } + + private Element getParentTableCell() + { + LayoutController parent = getParent(); + while (parent != null) + { + if (parent instanceof TableCellLayoutController) + { + final TableCellLayoutController cellController = (TableCellLayoutController) parent; + return cellController.getElement(); + } + parent = parent.getParent(); + } + return null; + } + + private String computeValueStyle() + { + final Element tce = getParentTableCell(); + if (tce == null) + { + return null; + } + + final String cellStyleName = (String) tce.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); + if (cellStyleName == null) + { + return null; + } + final OfficeDocument document = getDocument(); + if (document == null) + { + return null; + } + + final OfficeStyle style = document.getStylesCollection().getStyle("table-cell", cellStyleName); + return (String) style.getAttribute(OfficeNamespaces.STYLE_NS, "data-style-name"); + } + + private String computeValueType() + { + final Element tce = getParentTableCell(); + if (tce == null) + { + // NO particular format means: Fallback to string and hope and pray .. + throw new IllegalStateException("A formatted text element must be a child of a Table-Cell."); + } + + final String type = (String) tce.getAttribute(OfficeNamespaces.OFFICE_NS, FormatValueUtility.VALUE_TYPE); + if (type == null) + { + LOGGER.error("The Table-Cell does not have a office:value attribute defined. Your content will be messed up."); + return "string"; + } + return type; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementContext.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementContext.java new file mode 100644 index 000000000000..4f5ffbdcf35e --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementContext.java @@ -0,0 +1,94 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ImageElementContext.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.layoutprocessor; + +/** + * Todo: Document me! + * + * @author Thomas Morgner + * @since 30.03.2007 + */ +public class ImageElementContext +{ + private final int colSpan; + private final int rowSpan; + private String[] rowStyles; + private String[] colStyles; + + public ImageElementContext(final int colSpan, final int rowSpan) + { + this.colSpan = colSpan; + this.rowSpan = rowSpan; + this.colStyles = new String[colSpan]; + this.rowStyles = new String[rowSpan]; + } + + public int getColSpan() + { + return colSpan; + } + + public int getRowSpan() + { + return rowSpan; + } + + public String[] getRowStyles() + { + return rowStyles; + } + + public String[] getColStyles() + { + return colStyles; + } + + public void setRowStyle (final int pos, final String styleName) + { + rowStyles[pos] = styleName; + } + + public void setColStyle (final int pos, final String styleName) + { + colStyles[pos] = styleName; + } + + public String getRowStyle (final int pos) + { + return rowStyles[pos]; + } + + public String getColStyle (final int pos) + { + return colStyles[pos]; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java new file mode 100644 index 000000000000..8cd296151005 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java @@ -0,0 +1,332 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ImageElementLayoutController.java,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho.layoutprocessor; + +import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.OfficeToken; +import com.sun.star.report.pentaho.model.ImageElement; +import org.pentaho.reporting.libraries.formula.Formula; +import org.pentaho.reporting.libraries.formula.lvalues.LValue; +import org.pentaho.reporting.libraries.formula.parser.ParseException; +import org.jfree.layouting.util.AttributeMap; +import org.jfree.report.DataSourceException; +import org.jfree.report.JFreeReportInfo; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.util.TextUtilities; +import org.jfree.report.data.GlobalMasterRow; +import org.jfree.report.data.ReportDataRow; +import org.jfree.report.expressions.FormulaExpression; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutControllerUtil; +import org.jfree.report.structure.Element; +import org.jfree.report.structure.Section; +import org.jfree.report.structure.Node; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.pentaho.reporting.libraries.base.util.ObjectUtilities; + +/** + * Produces an image. The image-structures itself (draw:frame and so on) are not generated here. This element produces a + * place-holder element and relies on the output target to compute a sensible position for the element. The report + * definition does not give any hints about the size of the image, so we have to derive this from the surrounding + * context. + * + * @author Thomas Morgner + * @since 05.03.2007 + */ +public class ImageElementLayoutController + extends AbstractReportElementLayoutController +{ + private static final Log LOGGER = LogFactory.getLog(ImageElementLayoutController.class); + private ImageElementContext context; + + public ImageElementLayoutController() + { + } + + protected LayoutController delegateContentGeneration(final ReportTarget target) + throws ReportProcessingException, ReportDataFactoryException, + DataSourceException + { + final ImageElement imageElement = (ImageElement) getNode(); + final FormulaExpression formulaExpression = imageElement.getFormula(); + if (formulaExpression == null) + { + // A static image is easy. At least at this level. Dont ask about the weird things we have to do in the + // output targets ... + final String linkTarget = imageElement.getImageData(); + generateImage(target, linkTarget, imageElement.isScale(), imageElement.isPreserveIRI()); + } + else + { + final Object value = + LayoutControllerUtil.evaluateExpression(getFlowController(), imageElement, formulaExpression); + generateImage(target, value, imageElement.isScale(), imageElement.isPreserveIRI()); + } + return join(getFlowController()); + } + + private void generateImage(final ReportTarget target, + final Object linkTarget, + final boolean scale, + final boolean preserveIri) + throws ReportProcessingException, DataSourceException + { + if (linkTarget == null) + { + return; + } + + final AttributeMap image = new AttributeMap(); + image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE, JFreeReportInfo.REPORT_NAMESPACE); + image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE, OfficeToken.IMAGE); + image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.SCALE, String.valueOf(scale)); + image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.PRESERVE_IRI, String.valueOf(preserveIri)); + image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "image-context", createContext()); + image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, OfficeToken.IMAGE_DATA, linkTarget); + target.startElement(image); + target.endElement(image); + } + + protected ImageElementContext createContext() + { + if (context == null) + { + + // Step 1: Find the parent cell. + final LayoutController cellController = findParentCell(); + if (cellController == null) + { + LOGGER.warn("Image is not contained in a table. Unable to calculate the image-size."); + return null; + } + final Element tableCell = (Element) cellController.getNode(); + final int rowSpan = TextUtilities.parseInt((String) tableCell.getAttribute(OfficeNamespaces.TABLE_NS, "number-rows-spanned"), 1); + final int colSpan = TextUtilities.parseInt((String) tableCell.getAttribute(OfficeNamespaces.TABLE_NS, "number-columns-spanned"), 1); + if (rowSpan < 1 || colSpan < 1) + { + LOGGER.warn("Rowspan or colspan for image-size calculation was invalid."); + return null; + } + + final LayoutController rowController = cellController.getParent(); + if (rowController == null) + { + LOGGER.warn("Table-Cell has no parent. Unable to calculate the image-size."); + return null; + } + final Section tableRow = (Section) rowController.getNode(); + // we are now making the assumption, that the row is a section, that contains the table-cell. + // This breaks the ability to return nodes or to construct reports on the fly, but the OO-report format + // is weird anyway and wont support such advanced techniques for the next few centuries .. + final int columnPos = findNodeInSection(tableRow, tableCell, OfficeToken.COVERED_TABLE_CELL); + if (columnPos == -1) + { + LOGGER.warn("Table-Cell is not a direct child of the table-row. Unable to calculate the image-size."); + return null; + } + + final LayoutController tableController = rowController.getParent(); + if (tableController == null) + { + LOGGER.warn("Table-Row has no Table. Unable to calculate the image-size."); + return null; + } + + final Section table = (Section) tableController.getNode(); + // ok, we got a table, so as next we have to search for the columns now. + final Section columns = (Section) table.findFirstChild(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMNS); + if (columns.getNodeCount() <= columnPos + colSpan) + { + // the colspan is to large. The table definition is therefore invalid. We do not try to fix this. + LOGGER.warn( + "The Table's defined columns do not match the col-span or col-position. Unable to calculate the image-size."); + return null; + } + + final ImageElementContext context = new ImageElementContext(colSpan, rowSpan); + addColumnStyles(context, columns, columnPos, colSpan); + // finally search the styles for the row now. + final int rowPos = findNodeInSection(table, tableRow, null); + if (rowPos == -1) + { + LOGGER.warn("Table-Cell is not a direct child of the table-row. Unable to calculate the image-size."); + return null; + } + + addRowStyles(context, table,rowPos,rowSpan); + this.context = context; + } + return this.context; + } + + private int findNodeInSection(final Section tableRow, + final Element tableCell, + final String secondType) + { + int retval = 0; + final Node[] nodes = tableRow.getNodeArray(); + final String namespace = tableCell.getNamespace(); + final String type = tableCell.getType(); + for (int i = 0; i < nodes.length; i++) + { + final Node node = nodes[i]; + if (!(node instanceof Element)) + { + continue; + } + final Element child = (Element) node; + /* + if (! OfficeToken.COVERED_TABLE_CELL.equals(child.getType()) && + (ObjectUtilities.equal(child.getNamespace(), namespace) == false || + ObjectUtilities.equal(child.getType(), type) == false)) + */ + if (!ObjectUtilities.equal(child.getNamespace(), namespace) || + (!ObjectUtilities.equal(child.getType(), type) && (secondType == null || !ObjectUtilities.equal(child.getType(), secondType)))) + { + continue; + } + + if (node == tableCell) + { + return retval; + } + retval += 1; + } + return -1; + } + + private LayoutController findParentCell() + { + LayoutController parent = getParent(); + while (parent != null) + { + final Object node = parent.getNode(); + if (node instanceof Element) + { + final Element element = (Element) node; + if (OfficeNamespaces.TABLE_NS.equals(element.getNamespace()) && "table-cell".equals(element.getType())) + { + return parent; + } + } + parent = parent.getParent(); + } + return null; + } + + protected boolean isValueChanged() + { + final ImageElement imageElement = (ImageElement) getNode(); + final FormulaExpression formulaExpression = imageElement.getFormula(); + if (formulaExpression == null) + { + final FlowController controller = getFlowController(); + final GlobalMasterRow masterRow = controller.getMasterRow(); + final ReportDataRow reportDataRow = masterRow.getReportDataRow(); + if (reportDataRow.getCursor() == 0) + { + return true; + } + return false; + } + + try + { + final Formula formula = formulaExpression.getCompiledFormula(); + final LValue lValue = formula.getRootReference(); + return isReferenceChanged(lValue); + } + catch (ParseException e) + { + return false; + } + } + + void addColumnStyles(final ImageElementContext context, final Section columns, final int columnPos, final int colSpan) + { + final Node[] columnDefs = columns.getNodeArray(); + int columnCounter = 0; + for (int i = 0; i < columnDefs.length; i++) + { + final Element column = (Element) columnDefs[i]; + + if (!ObjectUtilities.equal(column.getNamespace(), OfficeNamespaces.TABLE_NS) || + !ObjectUtilities.equal(column.getType(), OfficeToken.TABLE_COLUMN)) + { + continue; + } + if (columnCounter >= columnPos) + { + final String colStyle = (String) column.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); + context.setColStyle(columnCounter - columnPos, colStyle); + } + + columnCounter += 1; + + if (columnCounter >= (columnPos + colSpan)) + { + break; + } + + } + } + + void addRowStyles(final ImageElementContext context, final Section table, final int rowPos, final int rowSpan) + { + final Node[] rows = table.getNodeArray(); + int rowCounter = 0; + for (int i = 0; i < rows.length; i++) + { + final Element row = (Element) rows[i]; + + if (!ObjectUtilities.equal(row.getNamespace(), OfficeNamespaces.TABLE_NS) || + !ObjectUtilities.equal(row.getType(), OfficeToken.TABLE_ROW)) + { + continue; + } + if (rowCounter >= rowPos) + { + final String rowStyle = (String) row.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); + context.setRowStyle(rowCounter - rowPos, rowStyle); + } + + rowCounter += 1; + + if (rowCounter >= (rowPos + rowSpan)) + { + break; + } + } + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java new file mode 100644 index 000000000000..97e4332217a9 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java @@ -0,0 +1,126 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ObjectOleLayoutController.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho.layoutprocessor; + +import com.sun.star.report.SDBCReportDataFactory; +import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.OfficeToken; +import com.sun.star.report.pentaho.model.ObjectOleElement; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import org.jfree.report.DataSourceException; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.layouting.util.AttributeMap; +import org.jfree.report.DataFlags; +import org.jfree.report.DataRow; +import org.jfree.report.JFreeReportInfo; +import org.jfree.report.structure.Element; + +/** + * + * @author Ocke Janssen + */ +public class ObjectOleLayoutController extends AbstractReportElementLayoutController +{ + + public ObjectOleLayoutController() + { + } + + protected boolean isValueChanged() + { + final ObjectOleElement element = (ObjectOleElement) getNode(); + final List masterfields = element.getMasterfields(); + final DataRow view = getFlowController().getMasterRow().getGlobalView(); + for (final Iterator iter = masterfields.iterator(); iter.hasNext();) + { + final String master = (String) iter.next(); + try + { + final DataFlags flags = view.getFlags(master); + if (flags != null && flags.isChanged()) + { + return true; + } + } + catch (DataSourceException e) + { + // ignore .. assume that the reference has not changed. + } + } + return false; + } + + protected LayoutController delegateContentGeneration(final ReportTarget target) throws ReportProcessingException, ReportDataFactoryException, DataSourceException + { + final ObjectOleElement element = (ObjectOleElement) getNode(); + final String url = element.getUrl(); + if (url != null) + { + final AttributeMap ole = new AttributeMap(); + ole.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE, JFreeReportInfo.REPORT_NAMESPACE); + ole.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE, OfficeToken.OBJECT_OLE); + ole.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "href", url); + ole.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "class-id", element.getClassid()); + final List masterfields = element.getMasterfields(); + final List values = new ArrayList(); + final DataRow view = getFlowController().getMasterRow().getGlobalView(); + for (final Iterator iter = masterfields.iterator(); iter.hasNext();) + { + final String master = (String) iter.next(); + try + { + final DataFlags flags = view.getFlags(master); + if (flags != null) + { + values.add(flags.getValue()); + } + } + catch (DataSourceException e) + { + // ignore .. assume that the reference has not changed. + } + } + ole.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, SDBCReportDataFactory.MASTER_COLUMNS, masterfields); + ole.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, SDBCReportDataFactory.MASTER_VALUES, values); + ole.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, SDBCReportDataFactory.DETAIL_COLUMNS, element.getDetailfields()); + + target.startElement(ole); + target.endElement(ole); + } + + return join(getFlowController()); + } +} + diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeDetailLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeDetailLayoutController.java new file mode 100644 index 000000000000..9060ed64981d --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeDetailLayoutController.java @@ -0,0 +1,164 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeDetailLayoutController.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.layoutprocessor; + +import com.sun.star.report.pentaho.model.VariablesDeclarationSection; +import org.jfree.report.DataSourceException; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.ReportData; +import org.jfree.report.data.GlobalMasterRow; +import org.jfree.report.data.ReportDataRow; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.layoutprocessor.ElementLayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.flow.layoutprocessor.SectionLayoutController; + +/** + * Creation-Date: 11.04.2007, 11:04:02 + * + * @author Thomas Morgner + */ +public class OfficeDetailLayoutController extends SectionLayoutController +{ + public static final int STATE_PROCESS_VARIABLES = 2; + public static final int STATE_PROCESS_NORMAL_FLOW = 3; + + private boolean waitForJoin; + private int state; + + public OfficeDetailLayoutController() + { + } + + /** + * Initializes the layout controller. This method is called exactly once. It + * is the creators responsibility to call this method. + * <p/> + * Calling initialize after the first advance must result in a + * IllegalStateException. + * + * @param node the currently processed object or layout node. + * @param flowController the current flow controller. + * @param parent the parent layout controller that was responsible for + * instantiating this controller. + * @throws org.jfree.report.DataSourceException + * if there was a problem reading data from the datasource. + * @throws org.jfree.report.ReportProcessingException + * if there was a general problem during the report processing. + * @throws org.jfree.report.ReportDataFactoryException + * if a query failed. + */ + public void initialize(final Object node, + final FlowController flowController, + final LayoutController parent) + throws DataSourceException, ReportDataFactoryException, + ReportProcessingException + { + super.initialize(node, flowController, parent); + state = OfficeDetailLayoutController.STATE_PROCESS_VARIABLES; + } + + /** + * This method is called for each newly instantiated layout controller. The returned layout controller instance should + * have a processing state of either 'OPEN' or 'FINISHING' depending on whether there is any content or any child + * nodes to process. + * + * @param target the report target that receives generated events. + * @return the new layout controller instance representing the new state. + * @throws org.jfree.report.DataSourceException + * if there was a problem reading data from the datasource. + * @throws org.jfree.report.ReportProcessingException + * if there was a general problem during the report processing. + * @throws org.jfree.report.ReportDataFactoryException + * if a query failed. + */ + protected LayoutController startElement(final ReportTarget target) + throws DataSourceException, ReportProcessingException, ReportDataFactoryException + { + final FlowController fc = getFlowController(); + final GlobalMasterRow masterRow = fc.getMasterRow(); + final ReportDataRow reportDataRow = masterRow.getReportDataRow(); + final ReportData reportData = reportDataRow.getReportData(); + if (!reportData.isReadable()) + { + reportData.isReadable(); + // If this report has no data, then do not print the detail section. The detail section + // is the only section that behaves this way, and for now this is only done in the OO-implementation + final SectionLayoutController derived = (SectionLayoutController) clone(); + derived.setProcessingState(ElementLayoutController.FINISHED); + derived.setFlowController(fc); + return derived; + } + + if (state == OfficeDetailLayoutController.STATE_PROCESS_VARIABLES) + { + final VariablesDeclarationSection variables = new VariablesDeclarationSection(); + final OfficeDetailLayoutController controller = (OfficeDetailLayoutController) clone(); + controller.state = OfficeDetailLayoutController.STATE_PROCESS_NORMAL_FLOW; + controller.waitForJoin = true; + return processChild(controller, variables, fc); + } + + return super.startElement(target); + } + + protected void resetSectionForRepeat() + { + super.resetSectionForRepeat(); + state = STATE_PROCESS_VARIABLES; + } + + /** + * Joins with a delegated process flow. This is generally called from a child + * flow and should *not* (I mean it!) be called from outside. If you do, + * you'll suffer. + * + * @param flowController the flow controller of the parent. + * @return the joined layout controller that incorperates all changes from the + * delegate. + */ + public LayoutController join(final FlowController flowController) + { + if (waitForJoin) + { + final OfficeDetailLayoutController derived = (OfficeDetailLayoutController) clone(); + derived.setProcessingState(ElementLayoutController.NOT_STARTED); + derived.setFlowController(flowController); + derived.waitForJoin = false; + return derived; + } + return super.join(flowController); + } + +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupInstanceSectionLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupInstanceSectionLayoutController.java new file mode 100644 index 000000000000..8a3779cebe03 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupInstanceSectionLayoutController.java @@ -0,0 +1,160 @@ +package com.sun.star.report.pentaho.layoutprocessor; + +import org.jfree.report.flow.layoutprocessor.SectionLayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.flow.layoutprocessor.ElementLayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutControllerFactory; +import org.jfree.report.flow.layoutprocessor.LayoutControllerUtil; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.ReportContext; +import org.jfree.report.DataSourceException; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.expressions.Expression; +import org.jfree.report.structure.Element; +import org.jfree.report.structure.Node; +import org.jfree.layouting.util.AttributeMap; +import com.sun.star.report.pentaho.model.VariablesDeclarationSection; +import com.sun.star.report.pentaho.model.OfficeGroupSection; +import org.jfree.report.JFreeReportInfo; + +/** + * Creation-Date: 25.07.2007, 14:50:45 + * + * @author Thomas Morgner + */ +public class OfficeGroupInstanceSectionLayoutController extends SectionLayoutController +{ + public static final int STATE_PROCESS_VARIABLES = 2; + public static final int STATE_PROCESS_NORMAL_FLOW = 3; + private int state; + private boolean waitForJoin; + + public OfficeGroupInstanceSectionLayoutController() + { + } + + public void initialize(final Object node, final FlowController flowController, final LayoutController parent) + throws DataSourceException, ReportDataFactoryException, ReportProcessingException + { + super.initialize(node, flowController, parent); + state = STATE_PROCESS_VARIABLES; + } + + protected LayoutController processContent(final ReportTarget target) + throws DataSourceException, ReportProcessingException, ReportDataFactoryException + { + if (state == OfficeGroupInstanceSectionLayoutController.STATE_PROCESS_VARIABLES) + { + // todo: Fill the variables section with something sensible .. + final VariablesDeclarationSection variables = new VariablesDeclarationSection(); + final OfficeGroupInstanceSectionLayoutController controller = + (OfficeGroupInstanceSectionLayoutController) clone(); + controller.state = + OfficeGroupLayoutController.STATE_PROCESS_NORMAL_FLOW; + controller.waitForJoin = true; + return processChild(controller, variables, getFlowController()); + } + return super.processContent(target); + } + + // isDisplayable is private in version 0.9.1, so until the upgrade we keep this copy of the method + // todo: Delete it unce the sun-cvs contains version 0.9.2. + protected LayoutController processChild(final SectionLayoutController derived, + final Node node, + final FlowController flowController) + throws DataSourceException, ReportProcessingException, + ReportDataFactoryException + { + final ReportContext reportContext = flowController.getReportContext(); + final LayoutControllerFactory layoutControllerFactory = reportContext.getLayoutControllerFactory(); + if (isDisplayable(node)) + { + derived.setProcessingState(ElementLayoutController.WAITING_FOR_JOIN); + return layoutControllerFactory.create(flowController, node, derived); + } + else + { + derived.setProcessingState(ElementLayoutController.WAITING_FOR_JOIN); + final LayoutController childLc = layoutControllerFactory.create(flowController, node, derived); + return LayoutControllerUtil.skipInvisibleElement(childLc); + } + } + + protected boolean isDisplayable(final Node node) throws DataSourceException + { + if (! (node instanceof OfficeGroupSection) ) + { + return _isDisplayable(node); + } + + final OfficeGroupSection section = (OfficeGroupSection) node; + if (section.isRepeatSection()) + { + return false; + } + return _isDisplayable(node); + } + + protected boolean _isDisplayable(final Node node) + throws DataSourceException + { + // temp method until the pending upgrade to 0.9.2. Later we just call super.isDisplayable(..) instead. + if (!node.isEnabled()) + { + return false; + } + + final Expression expression = node.getDisplayCondition(); + if (expression == null) + { + return true; + } + + final Object result = LayoutControllerUtil.evaluateExpression(getFlowController(), node, expression); + if (Boolean.TRUE.equals(result)) + { + return true; + } + return false; + } + + protected void resetSectionForRepeat() + { + super.resetSectionForRepeat(); + state = STATE_PROCESS_VARIABLES; + } + + /** + * Joins with a delegated process flow. This is generally called from a child + * flow and should *not* (I mean it!) be called from outside. If you do, + * you'll suffer. + * + * @param flowController the flow controller of the parent. + * @return the joined layout controller that incorperates all changes from the + * delegate. + */ + public LayoutController join(final FlowController flowController) + { + if (waitForJoin) + { + final OfficeGroupInstanceSectionLayoutController derived = (OfficeGroupInstanceSectionLayoutController) clone(); + derived.setProcessingState(ElementLayoutController.OPENED); + derived.setFlowController(flowController); + derived.waitForJoin = false; + return derived; + } + return super.join(flowController); + } + + protected AttributeMap computeAttributes(final FlowController fc, final Element element, final ReportTarget target) + throws DataSourceException + { + final AttributeMap map = new AttributeMap( super.computeAttributes(fc, element, target) ); + map.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "iteration-count", new Integer(getIterationCount())); + map.makeReadOnly(); + return map; + } + +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupLayoutController.java new file mode 100644 index 000000000000..78180c7dc9cb --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupLayoutController.java @@ -0,0 +1,209 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeGroupLayoutController.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.layoutprocessor; + +import com.sun.star.report.pentaho.model.OfficeGroup; +import com.sun.star.report.pentaho.model.OfficeGroupSection; +import org.jfree.layouting.util.AttributeMap; +import org.jfree.report.DataSourceException; +import org.jfree.report.JFreeReportInfo; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.layoutprocessor.ElementLayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.flow.layoutprocessor.SectionLayoutController; +import org.jfree.report.structure.Element; + +/** + * Todo: Document me! + * + * @author Thomas Morgner + * @since 15.03.2007 + */ +public class OfficeGroupLayoutController extends SectionLayoutController + implements OfficeRepeatingStructureLayoutController +{ + public static final int STATE_PROCESS_REPEATING_HEADER = 0; + public static final int STATE_PROCESS_REPEATING_FOOTER = 1; + public static final int STATE_PROCESS_NORMAL_FLOW = 3; + private boolean waitForJoin; + private int state; + private VariablesCollection variablesCollection; + private boolean repeatHeader; + private boolean repeatFooter; + + public OfficeGroupLayoutController() + { + } + + + /** + * Initializes the layout controller. This method is called exactly once. It + * is the creators responsibility to call this method. + * <p/> + * Calling initialize after the first advance must result in a + * IllegalStateException. + * + * @param node the currently processed object or layout node. + * @param flowController the current flow controller. + * @param parent the parent layout controller that was responsible for + * instantiating this controller. + * @throws org.jfree.report.DataSourceException + * if there was a problem reading data from the datasource. + * @throws org.jfree.report.ReportProcessingException + * if there was a general problem during the report processing. + * @throws org.jfree.report.ReportDataFactoryException + * if a query failed. + */ + public void initialize(final Object node, + final FlowController flowController, + final LayoutController parent) + throws DataSourceException, ReportDataFactoryException, + ReportProcessingException + { + super.initialize(node, flowController, parent); + state = OfficeGroupLayoutController.STATE_PROCESS_REPEATING_HEADER; + variablesCollection = new VariablesCollection(computeVariablesPrefix()); + + + final OfficeGroup group = (OfficeGroup) getElement(); + final OfficeGroupSection header = group.getHeader(); + repeatHeader = (header != null && header.isRepeatSection()); + + final OfficeGroupSection footer = group.getFooter(); + repeatFooter = (footer != null && footer.isRepeatSection()); + } + + + protected LayoutController processContent(final ReportTarget target) + throws DataSourceException, ReportProcessingException, + ReportDataFactoryException + { + if (state == OfficeGroupLayoutController.STATE_PROCESS_REPEATING_HEADER) + { + + final OfficeGroupLayoutController controller = + (OfficeGroupLayoutController) clone(); + controller.state = + OfficeGroupLayoutController.STATE_PROCESS_REPEATING_FOOTER; + + if (!repeatHeader) + { + return controller; + } + + final OfficeGroup group = (OfficeGroup) getElement(); + final OfficeGroupSection header = group.getHeader(); + controller.waitForJoin = true; + return processChild(controller, header, getFlowController()); + } + + if (state == OfficeGroupLayoutController.STATE_PROCESS_REPEATING_FOOTER) + { + + final OfficeGroupLayoutController controller = + (OfficeGroupLayoutController) clone(); + controller.state = OfficeGroupLayoutController.STATE_PROCESS_NORMAL_FLOW; + + if (!repeatFooter) + { + return controller; + } + + final OfficeGroup group = (OfficeGroup) getElement(); + final OfficeGroupSection footer = group.getFooter(); + controller.waitForJoin = true; + return processChild(controller, footer, getFlowController()); + } + + return super.processContent(target); + } + + /** + * Joins with a delegated process flow. This is generally called from a child + * flow and should *not* (I mean it!) be called from outside. If you do, + * you'll suffer. + * + * @param flowController the flow controller of the parent. + * @return the joined layout controller that incorperates all changes from the + * delegate. + */ + public LayoutController join(final FlowController flowController) + { + if (waitForJoin) + { + final OfficeGroupLayoutController derived = (OfficeGroupLayoutController) clone(); + derived.setProcessingState(ElementLayoutController.OPENED); + derived.setFlowController(flowController); + derived.waitForJoin = false; + return derived; + } + return super.join(flowController); + } + + public boolean isNormalFlowProcessing () + { + return state == OfficeGroupLayoutController.STATE_PROCESS_NORMAL_FLOW; + } + + private String computeVariablesPrefix() + { + int count = 0; + LayoutController lc = this; + while (lc != null) + { + if (lc instanceof OfficeGroupLayoutController) + { + count += 1; + } + lc = lc.getParent(); + } + return "auto_group_" + count + "_"; + } + + public VariablesCollection getVariablesCollection() + { + return variablesCollection; + } + + protected AttributeMap computeAttributes(final FlowController fc, final Element element, final ReportTarget target) + throws DataSourceException + { + final AttributeMap map = new AttributeMap( super.computeAttributes(fc, element, target) ); + final String value = String.valueOf(repeatHeader || repeatFooter); + map.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "repeating-header-or-footer", value); + map.makeReadOnly(); + return map; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupSectionLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupSectionLayoutController.java new file mode 100644 index 000000000000..496ccd841e46 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeGroupSectionLayoutController.java @@ -0,0 +1,115 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeGroupSectionLayoutController.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.layoutprocessor; + +import org.jfree.report.flow.layoutprocessor.SectionLayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.flow.layoutprocessor.ElementLayoutController; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.structure.Element; +import org.jfree.report.DataSourceException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.layouting.util.AttributeMap; +import com.sun.star.report.OfficeToken; +import com.sun.star.report.pentaho.model.OfficeGroupSection; +import org.jfree.report.JFreeReportInfo; + +/** + * This layoutcontroller simply checks, whether the parent layout controller + * is a OfficeGroupLayoutController and whether this layout controller is + * processing the normal flow or an repeating section. If a repeating section + * is being processed, an marker attribute is added to the element's call + * to OutputProcessor.startElement() and OutputProcessor.endElement(). + * + * @author Thomas Morgner + * @since 19.03.2007 + */ +public class OfficeGroupSectionLayoutController extends SectionLayoutController +{ + + public OfficeGroupSectionLayoutController() + { + } + + protected LayoutController startElement(final ReportTarget target) + throws DataSourceException, ReportProcessingException, ReportDataFactoryException + { + final OfficeGroupSection section = (OfficeGroupSection) getElement(); + if (!section.isRepeatSection()) + { + return super.startElement(target); + } + + final LayoutController controller = getParent(); + if (!(controller instanceof OfficeGroupLayoutController)) + { + return super.startElement(target); + } + final OfficeGroupLayoutController oglc = (OfficeGroupLayoutController) controller; + if (!oglc.isNormalFlowProcessing()) + { + return super.startElement(target); + } + + // Skip the processing if the section is a repeating header or footer and we are processing the normal flow .. + final ElementLayoutController clone = (ElementLayoutController) this.clone(); + clone.setProcessingState(ElementLayoutController.FINISHED); + return clone; + } + + protected AttributeMap computeAttributes(final FlowController fc, + final Element element, + final ReportTarget target) + throws DataSourceException + { + final AttributeMap attrs = super.computeAttributes(fc, element, target); + final LayoutController controller = getParent(); + if (!(controller instanceof OfficeGroupLayoutController)) + { + return attrs; + } + final OfficeGroupLayoutController oglc = (OfficeGroupLayoutController) controller; + if (oglc.isNormalFlowProcessing()) + { + return attrs; + } + + final AttributeMap retval = new AttributeMap(attrs); + retval.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "repeated-section", OfficeToken.TRUE); + retval.makeReadOnly(); + return retval; + } + + +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficePageSectionLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficePageSectionLayoutController.java new file mode 100644 index 000000000000..9189cb06f9a5 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficePageSectionLayoutController.java @@ -0,0 +1,29 @@ +package com.sun.star.report.pentaho.layoutprocessor; + +import org.jfree.report.flow.layoutprocessor.SectionLayoutController; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.structure.Element; +import org.jfree.report.DataSourceException; +import org.jfree.layouting.util.AttributeMap; +import org.jfree.report.JFreeReportInfo; + +/** + * Todo: Document Me + * + * @author Thomas Morgner + */ +public class OfficePageSectionLayoutController extends SectionLayoutController +{ + public OfficePageSectionLayoutController() + { + } + + protected AttributeMap computeAttributes(final FlowController flowController, final Element element, final ReportTarget reportTarget) throws DataSourceException + { + final AttributeMap map = new AttributeMap( super.computeAttributes(flowController, element, reportTarget)); + map.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "role", "spreadsheet-section"); + map.makeReadOnly(); + return map; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeRepeatingStructureLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeRepeatingStructureLayoutController.java new file mode 100644 index 000000000000..47a1daa1b7fa --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeRepeatingStructureLayoutController.java @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeRepeatingStructureLayoutController.java,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.layoutprocessor; + +import org.jfree.report.flow.layoutprocessor.LayoutController; + +/** + * Todo: Document me! + * + * @author Thomas Morgner + * @since 22.03.2007 + */ +public interface OfficeRepeatingStructureLayoutController extends LayoutController +{ + public boolean isNormalFlowProcessing(); + + public VariablesCollection getVariablesCollection(); + +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeReportLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeReportLayoutController.java new file mode 100644 index 000000000000..20816814e11c --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeReportLayoutController.java @@ -0,0 +1,277 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeReportLayoutController.java,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.layoutprocessor; + +import com.sun.star.report.pentaho.model.OfficeReport; +import com.sun.star.report.pentaho.model.VariablesDeclarationSection; +import org.jfree.report.DataSourceException; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportContext; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.layoutprocessor.ElementLayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutControllerFactory; +import org.jfree.report.structure.Node; + +/** + * Todo: Document me! + * + * @author Thomas Morgner + * @since 06.03.2007 + */ +public class OfficeReportLayoutController extends ElementLayoutController + implements OfficeRepeatingStructureLayoutController +{ + private static final int STATE_NOT_STARTED = 0; + private static final int STATE_TEMPLATES = 1; + private static final int STATE_PAGE_HEADER_DONE = 2; + private static final int STATE_PAGE_FOOTER_DONE = 3; + private static final int STATE_SPREADSHEET_PAGE_HEADER_DONE = 4; + private static final int STATE_SPREADSHEET_PAGE_FOOTER_DONE = 5; + private static final int STATE_COLUMN_HEADER_DONE = 6; + private static final int STATE_COLUMN_FOOTER_DONE = 7; + private static final int STATE_INITIAL_VARIABLES_DONE = 8; + private static final int STATE_REPORT_HEADER_DONE = 9; + private static final int STATE_REPORT_BODY_DONE = 10; + private static final int STATE_REPORT_FOOTER_VARIABLES = 11; + private static final int STATE_REPORT_FOOTER_DONE = 12; + + private int state; + private VariablesCollection variablesCollection; + + public OfficeReportLayoutController() + { + } + + + /** + * Initializes the layout controller. This method is called exactly once. It + * is the creators responsibility to call this method. + * <p/> + * Calling initialize after the first advance must result in a + * IllegalStateException. + * + * @param node the currently processed object or layout node. + * @param flowController the current flow controller. + * @param parent the parent layout controller that was responsible for + * instantiating this controller. + * @throws org.jfree.report.DataSourceException + * if there was a problem reading data from the datasource. + * @throws org.jfree.report.ReportProcessingException + * if there was a general problem during the report processing. + * @throws org.jfree.report.ReportDataFactoryException + * if a query failed. + */ + public void initialize(final Object node, final FlowController flowController, + final LayoutController parent) + throws DataSourceException, ReportDataFactoryException, + ReportProcessingException + { + super.initialize(node, flowController, parent); + variablesCollection = new VariablesCollection("auto_report_"); + } + + /** + * Processes any content in this element. This method is called when the + * processing state is 'OPENED'. The returned layout controller will retain + * the 'OPENED' state as long as there is more content available. Once all + * content has been processed, the returned layout controller should carry a + * 'FINISHED' state. + * + * @param target the report target that receives generated events. + * @return the new layout controller instance representing the new state. + * + * @throws org.jfree.report.DataSourceException + * if there was a problem reading data from the datasource. + * @throws org.jfree.report.ReportProcessingException + * if there was a general problem during the report processing. + * @throws org.jfree.report.ReportDataFactoryException + * if a query failed. + */ + protected LayoutController processContent(final ReportTarget target) + throws DataSourceException, ReportProcessingException, + ReportDataFactoryException + { + final OfficeReport or = (OfficeReport) getElement(); + + switch (state) + { + case OfficeReportLayoutController.STATE_NOT_STARTED: + { + return delegateToTemplates(OfficeReportLayoutController.STATE_TEMPLATES); + } + case OfficeReportLayoutController.STATE_TEMPLATES: + { + return delegateSection(or.getPageHeader(), + OfficeReportLayoutController.STATE_PAGE_HEADER_DONE); + } + case OfficeReportLayoutController.STATE_PAGE_HEADER_DONE: + { + return delegateSpreadsheetSection(or.getPageHeader(), + OfficeReportLayoutController.STATE_SPREADSHEET_PAGE_HEADER_DONE); + } + case OfficeReportLayoutController.STATE_SPREADSHEET_PAGE_HEADER_DONE: + { + return delegateSection(or.getPageFooter(), + OfficeReportLayoutController.STATE_PAGE_FOOTER_DONE); + } + case OfficeReportLayoutController.STATE_PAGE_FOOTER_DONE: + { + return delegateSection(or.getColumnHeader(), + OfficeReportLayoutController.STATE_COLUMN_HEADER_DONE); + } + case OfficeReportLayoutController.STATE_COLUMN_HEADER_DONE: + { + return delegateSection(or.getColumnFooter(), + OfficeReportLayoutController.STATE_COLUMN_FOOTER_DONE); + } + case OfficeReportLayoutController.STATE_COLUMN_FOOTER_DONE: + { + return delegateSection(new VariablesDeclarationSection(), + OfficeReportLayoutController.STATE_INITIAL_VARIABLES_DONE); + } + case OfficeReportLayoutController.STATE_INITIAL_VARIABLES_DONE: + { + return delegateSection(or.getReportHeader(), + OfficeReportLayoutController.STATE_REPORT_HEADER_DONE); + } + case OfficeReportLayoutController.STATE_REPORT_HEADER_DONE: + { + return delegateSection(or.getBodySection(), + OfficeReportLayoutController.STATE_REPORT_BODY_DONE); + } + case OfficeReportLayoutController.STATE_REPORT_BODY_DONE: + { + return delegateSection(new VariablesDeclarationSection(), + OfficeReportLayoutController.STATE_REPORT_FOOTER_VARIABLES); + } + case OfficeReportLayoutController.STATE_REPORT_FOOTER_VARIABLES: + { + return delegateSection(or.getReportFooter(), + OfficeReportLayoutController.STATE_REPORT_FOOTER_DONE); + } + case OfficeReportLayoutController.STATE_REPORT_FOOTER_DONE: + { + return delegateSpreadsheetSection(or.getPageFooter(), + OfficeReportLayoutController.STATE_SPREADSHEET_PAGE_FOOTER_DONE); + } + case OfficeReportLayoutController.STATE_SPREADSHEET_PAGE_FOOTER_DONE: + { + final OfficeReportLayoutController olc = (OfficeReportLayoutController) clone(); + olc.setProcessingState(ElementLayoutController.FINISHING); + return olc; + } + default: + { + throw new IllegalStateException("Invalid processing state encountered."); + } + } + } + + private LayoutController delegateSpreadsheetSection(final Node node, final int nextState) + throws DataSourceException, ReportProcessingException, ReportDataFactoryException + { + final OfficeReportLayoutController olc = (OfficeReportLayoutController) clone(); + olc.state = nextState; + + if (node == null) + { + return olc; + } + + final OfficePageSectionLayoutController templateLc = new OfficePageSectionLayoutController(); + templateLc.initialize(node, getFlowController(), olc); + return templateLc; + } + + private LayoutController delegateToTemplates(final int nextState) + throws ReportProcessingException, ReportDataFactoryException, + DataSourceException + { + final OfficeReportLayoutController olc = (OfficeReportLayoutController) clone(); + olc.state = nextState; + + final OfficeTableTemplateLayoutController templateLc = new OfficeTableTemplateLayoutController(); + templateLc.initialize(getElement(), getFlowController(), olc); + return templateLc; + + } + + private LayoutController delegateSection(final Node n, final int nextState) + throws ReportProcessingException, ReportDataFactoryException, + DataSourceException + { + final OfficeReportLayoutController olc = (OfficeReportLayoutController) clone(); + olc.state = nextState; + if (n == null) + { + return olc; + } + + final FlowController flowController = getFlowController(); + final ReportContext reportContext = flowController.getReportContext(); + final LayoutControllerFactory layoutControllerFactory = + reportContext.getLayoutControllerFactory(); + return layoutControllerFactory.create(flowController, n, olc); + + } + + + /** + * Joins with a delegated process flow. This is generally called from a child + * flow and should *not* (I mean it!) be called from outside. If you do, + * you'll suffer. + * + * @param flowController the flow controller of the parent. + * @return the joined layout controller that incorperates all changes from the + * delegate. + */ + public LayoutController join(final FlowController flowController) + { + final OfficeReportLayoutController derived = (OfficeReportLayoutController) clone(); + derived.setFlowController(flowController); + return derived; + } + + public boolean isNormalFlowProcessing() + { + return state != OfficeReportLayoutController.STATE_PAGE_HEADER_DONE && + state != OfficeReportLayoutController.STATE_PAGE_FOOTER_DONE; + } + + public VariablesCollection getVariablesCollection() + { + return variablesCollection; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeTableLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeTableLayoutController.java new file mode 100644 index 000000000000..d83ebb63957d --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeTableLayoutController.java @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeTableLayoutController.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho.layoutprocessor; + +import org.jfree.report.flow.layoutprocessor.SectionLayoutController; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.structure.Element; +import org.jfree.report.structure.Section; +import org.jfree.report.structure.Node; +import org.jfree.report.DataSourceException; +import org.jfree.report.util.IntegerCache; +import org.jfree.layouting.util.AttributeMap; +import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.OfficeToken; +import org.jfree.report.JFreeReportInfo; + +/** + * Creation-Date: 24.04.2007, 14:40:20 + * + * @author Thomas Morgner + */ +public class OfficeTableLayoutController extends SectionLayoutController +{ + + public OfficeTableLayoutController() + { + } + + protected AttributeMap computeAttributes(final FlowController fc, final Element element, final ReportTarget target) + throws DataSourceException + { + final AttributeMap attributeMap = new AttributeMap( super.computeAttributes(fc, element, target) ); + final Section s = (Section) element; + int rowCount = 0; + final Node[] nodeArray = s.getNodeArray(); + for (int i = 0; i < nodeArray.length; i++) + { + final Node node = nodeArray[i]; + if (node instanceof Element) + { + final Element child = (Element) node; + if (OfficeNamespaces.TABLE_NS.equals(child.getNamespace()) && + OfficeToken.TABLE_ROW.equals(child.getType())) + { + rowCount += 1; + } + } + } + + attributeMap.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "table-row-count", IntegerCache.getInteger(rowCount)); + attributeMap.makeReadOnly(); + return attributeMap; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeTableTemplateLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeTableTemplateLayoutController.java new file mode 100644 index 000000000000..f3a7f776db5c --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/OfficeTableTemplateLayoutController.java @@ -0,0 +1,191 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeTableTemplateLayoutController.java,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho.layoutprocessor; + +import java.util.ArrayList; + +import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.pentaho.model.OfficeGroup; +import com.sun.star.report.pentaho.model.OfficeReport; +import java.util.List; +import org.jfree.report.DataSourceException; +import org.jfree.report.JFreeReportInfo; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.flow.layoutprocessor.SectionLayoutController; +import org.jfree.report.structure.Element; +import org.jfree.report.structure.Node; +import org.jfree.report.structure.Section; + +/** + * Creation-Date: 24.04.2007, 16:06:52 + * + * @author Thomas Morgner + */ +public class OfficeTableTemplateLayoutController extends SectionLayoutController +{ + + private Node[] nodes; + + public OfficeTableTemplateLayoutController() + { + } + + /** + * Initializes the layout controller. This method is called exactly once. It is the creators responsibility to call + * this method. + * <p/> + * Calling initialize after the first advance must result in a IllegalStateException. + * + * @param node the currently processed object or layout node. + * @param flowController the current flow controller. + * @param parent the parent layout controller that was responsible for instantiating this controller. + * @throws org.jfree.report.DataSourceException + * if there was a problem reading data from the datasource. + * @throws org.jfree.report.ReportProcessingException + * if there was a general problem during the report processing. + * @throws org.jfree.report.ReportDataFactoryException + * if a query failed. + */ + public void initialize(final Object node, final FlowController flowController, final LayoutController parent) + throws DataSourceException, ReportDataFactoryException, ReportProcessingException + { + final Section section = new Section(); + section.setNamespace(JFreeReportInfo.REPORT_NAMESPACE); + section.setType("template"); + super.initialize(section, flowController, parent); + + final OfficeReport report = (OfficeReport) node; + final ArrayList tables = new ArrayList(); + if (report.getPageHeader() != null) + { + addFromSection(tables, (Section) report.getPageHeader()); + } + if (report.getReportHeader() != null) + { + addFromSection(tables, (Section) report.getReportHeader()); + } + addPBody(tables, (Section) report.getPreBodySection()); + addFromBody(tables, (Section) report.getBodySection()); + addPBody(tables, (Section) report.getPostBodySection()); + if (report.getReportFooter() != null) + { + addFromSection(tables, (Section) report.getReportFooter()); + } + if (report.getPageFooter() != null) + { + addFromSection(tables, (Section) report.getPageFooter()); + } + + this.nodes = (Node[]) tables.toArray(new Node[tables.size()]); + } + + private void addPBody(final List tables, final Section section) + { + if (section != null) + { + // tables.add(section); + final Node[] nodeArray = section.getNodeArray(); + for (int i = 0; i < nodeArray.length; i++) + { + final Node node = nodeArray[i]; + tables.add(node); + } + + } + } + + private void addFromBody(final List tables, final Section section) + { + final Node[] nodeArray = section.getNodeArray(); + for (int i = 0; i < nodeArray.length; i++) + { + final Node node = nodeArray[i]; + if (node instanceof Section) + { + final Section child = (Section) node; + if (node instanceof OfficeGroup) + { + addFromGroup(tables, child); + } + else + { + addFromSection(tables, child); + } + } + } + } + + private void addFromGroup(final List tables, final Section section) + { + final Node[] nodeArray = section.getNodeArray(); + for (int i = 0; i < nodeArray.length; i++) + { + final Node node = nodeArray[i]; + if (node instanceof Section) + { + final Section element = (Section) node; + if (JFreeReportInfo.REPORT_NAMESPACE.equals(element.getNamespace()) && "group-body".equals(element.getType())) + { + addFromBody(tables, element); + } + else + { + addFromSection(tables, element); + } + } + } + } + + private void addFromSection(final List tables, final Section section) + { + final Node[] nodeArray = section.getNodeArray(); + for (int i = 0; i < nodeArray.length; i++) + { + final Node node = nodeArray[i]; + if (node instanceof Element) + { + final Element element = (Element) node; + if (OfficeNamespaces.TABLE_NS.equals(element.getNamespace()) && + "table".equals(element.getType())) + { + tables.add(element); + } + } + } + } + + public Node[] getNodes() + { + return nodes; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java new file mode 100644 index 000000000000..daacce47aa48 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java @@ -0,0 +1,193 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TableCellLayoutController.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho.layoutprocessor; + +import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.OfficeToken; +import com.sun.star.report.pentaho.model.FormatCondition; +import com.sun.star.report.pentaho.model.FormattedTextElement; +import com.sun.star.report.pentaho.model.ReportElement; +import org.jfree.layouting.util.AttributeMap; +import org.jfree.report.DataSourceException; +import org.jfree.report.DataFlags; +import org.jfree.report.expressions.Expression; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.layoutprocessor.LayoutControllerUtil; +import org.jfree.report.flow.layoutprocessor.SectionLayoutController; +import org.jfree.report.structure.Element; +import org.jfree.report.structure.Node; +import org.jfree.report.structure.Section; +import org.pentaho.reporting.libraries.base.util.ObjectUtilities; + +/** + * Before writing the table cell, we have to evaluate the childs of the cell. The cell itself can either be empty or it + * has a one ore more paragraphs inside. The paragraph contains a single report element, but may contain additional + * other content. + * + * @author Thomas Morgner + * @noinspection CloneableClassWithoutClone + * @since 05.03.2007 + */ +public class TableCellLayoutController extends SectionLayoutController +{ + + public TableCellLayoutController() + { + } + + protected AttributeMap computeAttributes(final FlowController fc, + final Element element, + final ReportTarget target) + throws DataSourceException + { + final AttributeMap attributeMap = new AttributeMap(super.computeAttributes(fc, element, target)); + final String definedStyle = (String) attributeMap.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); + attributeMap.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME, getDisplayStyleName((Section) element, definedStyle)); + + try + { + final DataFlags value = computeValue(); + if (value != null) + { + FormatValueUtility.applyValueForCell(value.getValue(), attributeMap); + } + } + catch (Exception e) + { + // ignore .. + } + attributeMap.makeReadOnly(); + return attributeMap; + } + + private DataFlags computeValue() throws DataSourceException + { + // Search for the first FormattedTextElement + final Section cell = (Section) getElement(); + final FormattedTextElement element = findFormattedTextElement(cell); + if (element == null) + { + return null; + } + return FormatValueUtility.computeDataFlag(element, getFlowController()); + } + + private FormattedTextElement findFormattedTextElement(final Section section) + { + final Node[] nodeArray = section.getNodeArray(); + for (int i = 0; i < nodeArray.length; i++) + { + final Node node = nodeArray[i]; + if (node instanceof FormattedTextElement) + { + return (FormattedTextElement) node; + } + else if (node instanceof Section) + { + final FormattedTextElement retval = findFormattedTextElement((Section) node); + if (retval != null) + { + return retval; + } + } + } + return null; + } + + private String getDisplayStyleName(final Section section, + final String defaultStyle) + { + if (!section.isEnabled() || section.getNodeCount() == 0) + { + return defaultStyle; + } + + final Node[] nodes = section.getNodeArray(); + for (int i = 0; i < nodes.length; i++) + { + final Node child = nodes[i]; + if (child instanceof ReportElement && child.isEnabled()) + { + final ReportElement element = (ReportElement) child; + if (element.getFormatConditionCount() > 0) + { + final Expression displayCond = element.getDisplayCondition(); + if (displayCond != null) + { + try + { + if (Boolean.FALSE.equals(LayoutControllerUtil.evaluateExpression(getFlowController(), element, displayCond))) + { + continue; + } + } + catch (DataSourceException e) + { + // ignore silently .. + } + } + + final FormatCondition[] conditions = element.getFormatConditions(); + for (int j = 0; j < conditions.length; j++) + { + final FormatCondition formCond = conditions[j]; + if (formCond.isEnabled()) + { + try + { + final Object o = LayoutControllerUtil.evaluateExpression(getFlowController(), element, formCond.getFormula()); + if (Boolean.TRUE.equals(o)) + { + return formCond.getStyleName(); + } + } + catch (DataSourceException e) + { + // ignore silently .. + } + } + } + } + } + + if (child instanceof Section) + { + final String childFormatCondition = + getDisplayStyleName((Section) child, defaultStyle); + if (!ObjectUtilities.equal(childFormatCondition, defaultStyle)) + { + return childFormatCondition; + } + } + } + return defaultStyle; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesCollection.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesCollection.java new file mode 100644 index 000000000000..ee9bfd442bca --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesCollection.java @@ -0,0 +1,103 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: VariablesCollection.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.layoutprocessor; + +import java.util.ArrayList; + +import com.sun.star.report.pentaho.model.FormattedTextElement; +import java.util.List; + +/** + * A variables collection is used to collect all FormattedTextElement objects + * of a repeated header or footer. Later, for each of these elements a variable + * setter is inserted into a hidden (in fact just very small) paragraph. These + * variables can later be read using the 'variable-get' construct. + * + * From the idea, this is equal to the 'strings' declaration of CSS3, although + * this code is explicit instead of declarative. + * + * @author Thomas Morgner + * @since 22.03.2007 + */ +public class VariablesCollection +{ + private VariablesCollection parent; + private String namePrefix; + private List variables; + + public VariablesCollection(final String namePrefix) + { + this(namePrefix, null); + } + + public VariablesCollection(final String namePrefix, final VariablesCollection parent) + { + if (namePrefix == null) + { + throw new NullPointerException("NamePrefix cannot be null"); + } + + this.namePrefix = namePrefix; + this.parent = parent; + this.variables = new ArrayList(); + } + + public VariablesCollection getParent() + { + return parent; + } + + public String getNamePrefix() + { + return namePrefix; + } + + public String addVariable (final FormattedTextElement element) + { + variables.add(element); + final int size = variables.size(); + return namePrefix + size; + } + + public FormattedTextElement[] getVariables () + { + return (FormattedTextElement[]) + variables.toArray(new FormattedTextElement[variables.size()]); + } + + public int getVariablesCount () + { + return variables.size(); + } + + +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java new file mode 100644 index 000000000000..6a6b6f19d1f0 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/VariablesDeclarationLayoutController.java @@ -0,0 +1,190 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: VariablesDeclarationLayoutController.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.layoutprocessor; + +import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.pentaho.model.FormattedTextElement; +import org.jfree.layouting.util.AttributeMap; +import org.jfree.report.DataSourceException; +import org.jfree.report.JFreeReportInfo; +import org.jfree.report.ReportDataFactoryException; +import org.jfree.report.ReportProcessingException; +import org.jfree.report.expressions.FormulaExpression; +import org.jfree.report.flow.FlowController; +import org.jfree.report.flow.ReportTarget; +import org.jfree.report.flow.layoutprocessor.AbstractLayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutController; +import org.jfree.report.flow.layoutprocessor.LayoutControllerUtil; +import org.jfree.report.structure.Element; +import java.util.Date; +import java.text.SimpleDateFormat; + +/** + * Writes a full variables-declaration section. + * + * @author Thomas Morgner + * @since 20.03.2007 + */ +public class VariablesDeclarationLayoutController + extends AbstractLayoutController +{ + private boolean processed; + + public VariablesDeclarationLayoutController() + { + } + + private OfficeRepeatingStructureLayoutController getRepeatingParent() + { + LayoutController parent = getParent(); + while (parent != null) + { + if (parent instanceof OfficeRepeatingStructureLayoutController) + { + return (OfficeRepeatingStructureLayoutController) parent; + } + parent = parent.getParent(); + } + return null; + } + + /** + * Advances the processing position. + * + * @param target the report target that receives generated events. + * @return the new layout controller instance representing the new state. + * + * @throws org.jfree.report.DataSourceException + * if there was a problem reading data from the datasource. + * @throws org.jfree.report.ReportProcessingException + * if there was a general problem during the report processing. + * @throws org.jfree.report.ReportDataFactoryException + * if a query failed. + */ + public LayoutController advance(final ReportTarget target) + throws DataSourceException, ReportDataFactoryException, + ReportProcessingException + { + if (processed) + { + throw new IllegalStateException("Already processed."); + } + + final VariablesDeclarationLayoutController vlc = + (VariablesDeclarationLayoutController) clone(); + vlc.processed = true; + + final OfficeRepeatingStructureLayoutController orslc = getRepeatingParent(); + if (orslc == null) + { + // There is no repeating parent. What the heck are we doing here .. + return vlc; + } + + final VariablesCollection collection = orslc.getVariablesCollection(); + if (collection.getVariablesCount() == 0) + { + // no processing necessary, as the header or footer contain no variables at all .. + return vlc; + } + + + final Element node = (Element) getNode(); + final AttributeMap vdSection = node.getAttributeMap(); + target.startElement(vdSection); + + final FormattedTextElement[] variables = collection.getVariables(); + for (int i = 0; i < variables.length; i++) + { + final FormattedTextElement variable = variables[i]; + final String varName = collection.getNamePrefix() + (i + 1); + final AttributeMap map = generateVariableSetSection(variable); + map.setAttribute(OfficeNamespaces.TEXT_NS, "name", varName); + target.startElement(map); + target.endElement(map); + + } + target.endElement(vdSection); + return vlc; + } + + private AttributeMap generateVariableSetSection(final FormattedTextElement variable) + throws DataSourceException + { + final AttributeMap variableSection = new AttributeMap(); + variableSection.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TEXT_NS); + variableSection.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE, "variable-set"); + variableSection.setAttribute(OfficeNamespaces.TEXT_NS, "display", "none"); + + final FormulaExpression valueExpression = variable.getValueExpression(); + final Object value = LayoutControllerUtil.evaluateExpression(getFlowController(), variable, valueExpression); + String formula = FormatValueUtility.applyValueForVariable(value, variableSection); + if ( formula == null ) + formula = "" + value; + if (value instanceof Date) + { + final Date date = (Date)value; + final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy;MM;dd"); + formula = "Date(" + dateFormat.format(date) + ")"; + } + variableSection.setAttribute(OfficeNamespaces.TEXT_NS, "formula", "ooow:" + formula); + return variableSection; + } + + /** + * Checks, whether the layout controller would be advanceable. If this method + * returns true, it is generally safe to call the 'advance()' method. + * + * @return true, if the layout controller is advanceable, false otherwise. + */ + public boolean isAdvanceable() + { + return !processed; + } + + /** + * Joins with a delegated process flow. This is generally called from a child + * flow and should *not* (I mean it!) be called from outside. If you do, + * you'll suffer. + * + * @param flowController the flow controller of the parent. + * @return the joined layout controller that incorperates all changes from the + * delegate. + */ + public LayoutController join(final FlowController flowController) + throws DataSourceException, ReportDataFactoryException, + ReportProcessingException + { + throw new UnsupportedOperationException + ("Join is not supported in this layout controller"); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/loader/InputRepositoryLoader.java b/reportbuilder/java/com/sun/star/report/pentaho/loader/InputRepositoryLoader.java new file mode 100644 index 000000000000..fc6021202e68 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/loader/InputRepositoryLoader.java @@ -0,0 +1,172 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: InputRepositoryLoader.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho.loader; + +import java.net.URL; +import java.util.Map; +import java.util.HashMap; + +import com.sun.star.report.InputRepository; +import org.pentaho.reporting.libraries.resourceloader.ResourceData; +import org.pentaho.reporting.libraries.resourceloader.ResourceKey; +import org.pentaho.reporting.libraries.resourceloader.ResourceKeyCreationException; +import org.pentaho.reporting.libraries.resourceloader.ResourceLoader; +import org.pentaho.reporting.libraries.resourceloader.ResourceLoadingException; +import org.pentaho.reporting.libraries.resourceloader.ResourceManager; +import org.pentaho.reporting.libraries.resourceloader.loader.LoaderUtils; + +public class InputRepositoryLoader implements ResourceLoader +{ + + private final InputRepository inputRepository; + private ResourceManager resourceManager; + + public InputRepositoryLoader(final InputRepository inputRepository) + { + if (inputRepository == null) + { + throw new NullPointerException(); + } + this.inputRepository = inputRepository; + } + + /** + * Checks, whether this resource loader implementation was responsible for + * creating this key. + * + * @param key + * @return + */ + public boolean isSupportedKey(final ResourceKey key) + { + return InputRepositoryLoader.class.getName().equals(key.getSchema()); + } + + /** + * Creates a new resource key from the given object and the factory keys. + * + * @param value + * @param factoryKeys + * @return the created key or null, if the format was not recognized. + * @throws org.jfree.resourceloader.ResourceKeyCreationException + * if creating the key failed. + */ + public ResourceKey createKey(final Object value, + final Map factoryKeys) + throws ResourceKeyCreationException + { + if (value instanceof String) + { + final String strVal = (String) value; + if (strVal.startsWith("sun:oo://")) + { + return new ResourceKey(InputRepositoryLoader.class.getName(), + new InputResourceKey(inputRepository.getId(), strVal), factoryKeys); + } + } + return null; + } + + /** + * Derives a new resource key from the given key. If neither a path nor new + * factory-keys are given, the parent key is returned. + * + * @param parent the parent + * @param path the derived path (can be null). + * @param factoryKeys the optional factory keys (can be null). + * @return the derived key. + * @throws org.jfree.resourceloader.ResourceKeyCreationException + * if the key cannot be derived for any reason. + */ + public ResourceKey deriveKey(final ResourceKey parent, + final String path, + final Map factoryKeys) + throws ResourceKeyCreationException + { + if (!isSupportedKey(parent)) + { + throw new ResourceKeyCreationException("Assertation: Unsupported parent key type"); + } + + final InputResourceKey parentKey = (InputResourceKey) parent.getIdentifier(); + final String resource; + if (path.startsWith("sun:oo://")) + { + resource = path; + } + else if (path.charAt(0) == '/') + { + resource = "sun:oo:/" + path; + } + else + { + resource = LoaderUtils.mergePaths(parentKey.getPath(), path); + } + final Map map; + if (factoryKeys != null) + { + map = new HashMap(); + map.putAll(parent.getFactoryParameters()); + map.putAll(factoryKeys); + } + else + { + map = parent.getFactoryParameters(); + } + return new ResourceKey(parent.getSchema(), + new InputResourceKey(parentKey.getInputRepositoryId(), resource), map); + } + + public URL toURL(final ResourceKey key) + { + return null; + } + + public ResourceData load(final ResourceKey key) + throws ResourceLoadingException + { + if (!isSupportedKey(key)) + { + throw new ResourceLoadingException("None of my keys."); + } + + return new InputRepositoryResourceData(key, inputRepository); + } + + public void setResourceManager(final ResourceManager manager) + { + this.resourceManager = manager; + } + + public ResourceManager getResourceManager() + { + return resourceManager; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/loader/InputRepositoryResourceData.java b/reportbuilder/java/com/sun/star/report/pentaho/loader/InputRepositoryResourceData.java new file mode 100644 index 000000000000..14a437f4bb57 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/loader/InputRepositoryResourceData.java @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: InputRepositoryResourceData.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.loader; + +import java.io.IOException; +import java.io.InputStream; + +import com.sun.star.report.InputRepository; +import org.pentaho.reporting.libraries.resourceloader.ResourceKey; +import org.pentaho.reporting.libraries.resourceloader.ResourceLoadingException; +import org.pentaho.reporting.libraries.resourceloader.ResourceManager; +import org.pentaho.reporting.libraries.resourceloader.loader.AbstractResourceData; + +public class InputRepositoryResourceData extends AbstractResourceData +{ + private final InputRepository inputRepository; + private final ResourceKey key; + private final String resourceIdentifer; + + public InputRepositoryResourceData (final ResourceKey key, + final InputRepository repository) + { + this.key = key; + this.inputRepository = repository; + final InputResourceKey rkey = (InputResourceKey) key.getIdentifier(); + final String identifier = rkey.getPath(); + this.resourceIdentifer = identifier.substring("sun:oo://".length()); + } + + public Object getAttribute (final String key) + { + // we dont support attributes here .. + return null; + } + + public ResourceKey getKey () + { + return key; + } + + public InputStream getResourceAsStream (final ResourceManager caller) + throws ResourceLoadingException + { + try + { + return inputRepository.createInputStream(resourceIdentifer); + } + catch (IOException e) + { + throw new ResourceLoadingException + ("Failed to create input stream for " + resourceIdentifer, e); + } + } + + public long getVersion (final ResourceManager caller) + { + return inputRepository.getVersion(resourceIdentifer); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/loader/InputResourceKey.java b/reportbuilder/java/com/sun/star/report/pentaho/loader/InputResourceKey.java new file mode 100644 index 000000000000..a4f2f1ca4553 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/loader/InputResourceKey.java @@ -0,0 +1,71 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: InputResourceKey.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.loader; + +import java.io.Serializable; + +/** + * Creation-Date: Feb 22, 2007, 8:51:42 PM + * + * @author Thomas Morgner + */ +public class InputResourceKey implements Serializable +{ + private static final long serialVersionUID = 2819901838705793075L; + + private final Object inputRepositoryId; + private final String path; + + public InputResourceKey(final Object inputRepositoryId, final String path) + { + this.inputRepositoryId = inputRepositoryId; + this.path = path; + } + + public Object getInputRepositoryId() + { + return inputRepositoryId; + } + + public String getPath() + { + return path; + } + + public String toString() + { + return "InputResourceKey{" + + "inputRepositoryId=" + inputRepositoryId + + ", path='" + path + '\'' + + '}'; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/makefile.mk b/reportbuilder/java/com/sun/star/report/pentaho/makefile.mk new file mode 100644 index 000000000000..fc2abb55e96a --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/makefile.mk @@ -0,0 +1,124 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.7.58.2 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ = ..$/..$/..$/..$/..$/.. +PRJNAME = reportbuilder +TARGET=sun-report-builder +PACKAGE = com$/sun$/star$/report$/pentaho +# we have circular dependencies +nodep=true +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + +#----- compile .java files ----------------------------------------- +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar +.IF "$(SYSTEM_JFREEREPORT)" == "YES" +XCLASSPATH!:=$(XCLASSPATH)$(FLUTE_JAR)$(PATH_SEPERATOR)$(LIBBASE_JAR)$(PATH_SEPERATOR)$(LIBXML_JAR)$(PATH_SEPERATOR)$(JFREEREPORT_JAR)$(PATH_SEPERATOR)$(LIBLOADER_JAR)$(PATH_SEPERATOR)$(SAC_JAR)$(PATH_SEPERATOR)$(LIBLAYOUT_JAR)$(PATH_SEPERATOR)$(LIBSERIALIZER_JAR)$(PATH_SEPERATOR)$(LIBFONTS_JAR)$(PATH_SEPERATOR)$(LIBFORMULA_JAR)$(PATH_SEPERATOR)$(LIBREPOSITORY_JAR)$(PATH_SEPERATOR)$(COMMONS_LOGGING_JAR) +COMP=fix_system_jfreereport +.ELSE +JARFILES += flute-1.3.0.jar libbase-1.0.0.jar libfonts-1.0.0.jar libformula-0.2.0.jar liblayout-0.2.9.jar libloader-1.0.0.jar librepository-1.0.0.jar libxml-1.0.0.jar flow-engine-0.9.2.jar sac.jar commons-logging-1.1.1.jar +.ENDIF + +JAVAFILES := $(shell @$(FIND) . -name "*.java") +# JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:s/.java/.class/)) + +#----- copy .properties and .css files ----------------------------------------- +# external find gives / for 4nt too... +# PROPERTYFILES := $(subst,/,$/ $(subst,./,$(CLASSDIR)$/$(PACKAGE)$/ $(shell @$(FIND) . -name "*.properties"))) +PROPERTYFILES := $(CLASSDIR)$/$(PACKAGE)$/configuration.properties \ + $(CLASSDIR)$/$(PACKAGE)$/module.properties \ + $(CLASSDIR)$/$(PACKAGE)$/parser$/selectors.properties + +# CSSFILES := $(subst,./,$(CLASSDIR)$/$(PACKAGE)$/ $(shell @$(FIND) . -name "*.css")) +CSSFILES := $(CLASSDIR)$/$(PACKAGE)$/oasis-datastyle.css\ + $(CLASSDIR)$/$(PACKAGE)$/oasis-draw.css\ + $(CLASSDIR)$/$(PACKAGE)$/oasis-form.css\ + $(CLASSDIR)$/$(PACKAGE)$/oasis-style.css\ + $(CLASSDIR)$/$(PACKAGE)$/oasis-table.css\ + $(CLASSDIR)$/$(PACKAGE)$/oasis-text.css\ + $(CLASSDIR)$/$(PACKAGE)$/smil.css\ + $(CLASSDIR)$/$(PACKAGE)$/star-office.css\ + $(CLASSDIR)$/$(PACKAGE)$/star-report.css\ + $(CLASSDIR)$/$(PACKAGE)$/star-rpt.css\ + $(CLASSDIR)$/$(PACKAGE)$/svg.css\ + $(CLASSDIR)$/$(PACKAGE)$/xsl-fo.css + +XSDFILES := $(CLASSDIR)$/$(PACKAGE)$/parser$/rpt-schema-v1.0-os.xsd \ + $(CLASSDIR)$/$(PACKAGE)$/styles$/stylemapper.xsd + +XMLFILES := $(CLASSDIR)$/$(PACKAGE)$/styles$/stylemapper.xml + +TXTFILES := $(CLASSDIR)$/$(PACKAGE)$/parser$/style-mapping.txt + + +#----- make a jar from compiled files ------------------------------ + +JARCLASSDIRS = . +JARTARGET = $(TARGET).jar +JARCOMPRESS = TRUE +CUSTOMMANIFESTFILE = Manifest.mf + + +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk + +.IF "$(JARTARGETN)"!="" +$(JARTARGETN) : $(COMP) $(PROPERTYFILES) $(CSSFILES) $(XSDFILES) $(TXTFILES) $(XMLFILES) +.ENDIF # "$(JARTARGETN)"!="" + +fix_system_jfreereport: + @echo "Fix Java Class-Path entry for JFree JFreeReport libraries from system." + @$(SED) '/flute/,/sac/d' -i ../../../../../../$(INPATH)/class/sun-report-builder/META-INF/MANIFEST.MF + @$(SED) -r -e "s#^Class-Path.*#\0\n file://$(LIBBASE_JAR)\n file://$(SAC_JAR)\n file://$(LIBXML_JAR)\n\ + file://$(FLUTE_JAR)\n file://$(JFREEREPORT_JAR)\n file://$(LIBLAYOUT_JAR)\n file://$(LIBLOADER_JAR)\n file://$(LIBFORMULA_JAR)\n\ + file://$(LIBREPOSITORY_JAR)\n file://$(LIBFONTS_JAR)\n file://$(LIBSERIALIZER_JAR)#" \ + -i ../../../../../../$(INPATH)/class/sun-report-builder/META-INF/MANIFEST.MF + +$(CLASSDIR)$/$(PACKAGE)$/%.properties : %.properties + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ + +$(CLASSDIR)$/$(PACKAGE)$/%.css : %.css + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ + +$(CLASSDIR)$/$(PACKAGE)$/%.xsd : %.xsd + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ + +$(CLASSDIR)$/$(PACKAGE)$/%.xml : %.xml + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ + +$(CLASSDIR)$/$(PACKAGE)$/%.txt : %.txt + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ + diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/DataStyle.java b/reportbuilder/java/com/sun/star/report/pentaho/model/DataStyle.java new file mode 100644 index 000000000000..efef723425da --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/DataStyle.java @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataStyle.java,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.model; + +import org.jfree.report.structure.Section; +import com.sun.star.report.pentaho.OfficeNamespaces; + +/** + * Represents an automatic or manual data style definition. + * + * @author Thomas Morgner + * @since 02.03.2007 + */ +public class DataStyle extends Section +{ + public DataStyle() + { + } + + public String getStyleName() + { + return (String) getAttribute(OfficeNamespaces.STYLE_NS, "name"); + } + + public void setStyleName(final String name) + { + setAttribute(OfficeNamespaces.STYLE_NS, "name", name); + } + + +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/FixedTextElement.java b/reportbuilder/java/com/sun/star/report/pentaho/model/FixedTextElement.java new file mode 100644 index 000000000000..7632ee1fd650 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/FixedTextElement.java @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FixedTextElement.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.model; + +import org.jfree.report.structure.Section; + +/** + * Todo: Document me! + * + * @author Thomas Morgner + * @since 02.03.2007 + */ +public class FixedTextElement extends ReportElement +{ + private final Section content; + + public FixedTextElement() + { + content = new Section(); + content.setVirtual(true); + } + + public Section getContent() + { + return content; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/FontFaceDeclsSection.java b/reportbuilder/java/com/sun/star/report/pentaho/model/FontFaceDeclsSection.java new file mode 100644 index 000000000000..9b509b0b0157 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/FontFaceDeclsSection.java @@ -0,0 +1,78 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FontFaceDeclsSection.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.model; + +import java.util.HashMap; + +import com.sun.star.report.pentaho.OfficeNamespaces; +import java.util.Map; +import org.jfree.report.structure.Element; + +/** + * Todo: Document me! + * + * @author Thomas Morgner + * @since 13.03.2007 + */ +public class FontFaceDeclsSection extends Element +{ + private final Map fontFaces; + + public FontFaceDeclsSection() + { + fontFaces = new HashMap(); + setType("font-face-decls"); + setNamespace(OfficeNamespaces.OFFICE_NS); + } + + public void addFontFace(final FontFaceElement style) + { + fontFaces.put (style.getStyleName(), style); + } + + public FontFaceElement getFontFace (final String name) + { + return (FontFaceElement) fontFaces.get(name); + } + + public FontFaceElement[] getAllFontFaces() + { + return (FontFaceElement[]) fontFaces.values().toArray + (new FontFaceElement[fontFaces.size()]); + } + + + public boolean containsFont(final String fontName) + { + return fontFaces.containsKey(fontName); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/FontFaceElement.java b/reportbuilder/java/com/sun/star/report/pentaho/model/FontFaceElement.java new file mode 100644 index 000000000000..48abe9e1f088 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/FontFaceElement.java @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FontFaceElement.java,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.model; + +import org.jfree.report.structure.Section; +import com.sun.star.report.pentaho.OfficeNamespaces; + +/** + * Represents an automatic or manual data style definition. + * + * @author Thomas Morgner + * @since 02.03.2007 + */ +public class FontFaceElement extends Section +{ + public FontFaceElement() + { + } + + public String getStyleName() + { + return (String) getAttribute(OfficeNamespaces.STYLE_NS, "name"); + } + + public void setStyleName(final String name) + { + setAttribute(OfficeNamespaces.STYLE_NS, "name", name); + } + + +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/FormatCondition.java b/reportbuilder/java/com/sun/star/report/pentaho/model/FormatCondition.java new file mode 100644 index 000000000000..43e84abc4651 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/FormatCondition.java @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FormatCondition.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.model; + +import org.jfree.report.expressions.FormulaExpression; + +/** + * The format condition defines, what style-format is applied to an element. + * + * @author Thomas Morgner + * @since 02.03.2007 + */ +public class FormatCondition +{ + private final FormulaExpression formula; + private final String styleName; + private final boolean enabled; + + public FormatCondition(final FormulaExpression formula, + final String styleName, + final boolean enabled) + { + this.formula = formula; + this.styleName = styleName; + this.enabled = enabled; + } + + + public FormulaExpression getFormula() + { + return formula; + } + + public String getStyleName() + { + return styleName; + } + + public boolean isEnabled() + { + return enabled; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/FormattedTextElement.java b/reportbuilder/java/com/sun/star/report/pentaho/model/FormattedTextElement.java new file mode 100644 index 000000000000..f902cae1a346 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/FormattedTextElement.java @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FormattedTextElement.java,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.model; + +import org.jfree.report.expressions.FormulaExpression; + +/** + * A formatted text element takes a formula, evaluates it and formats the + * given element using some arbitary style. (As this is totally undocumented, + * we leave this out for now. Either we'll insert a field there or we call + * an UNO-component to do the formatting. + * + * @author Thomas Morgner + * @since 02.03.2007 + */ +public class FormattedTextElement extends ReportElement +{ + private FormulaExpression valueExpression; + + public FormattedTextElement() + { + } + + + public FormulaExpression getValueExpression() + { + return valueExpression; + } + + public void setValueExpression(final FormulaExpression valueExpression) + { + this.valueExpression = valueExpression; + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/ImageElement.java b/reportbuilder/java/com/sun/star/report/pentaho/model/ImageElement.java new file mode 100644 index 000000000000..45e11580cd8f --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/ImageElement.java @@ -0,0 +1,86 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ImageElement.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.model; + +import org.jfree.report.expressions.FormulaExpression; +import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.OfficeToken; + +/** + * Todo: Document me! + * + * @author Thomas Morgner + * @since 02.03.2007 + */ +public class ImageElement extends ReportElement +{ + private FormulaExpression formula; + + public ImageElement() + { + } + + public FormulaExpression getFormula() + { + return formula; + } + + public void setFormula(final FormulaExpression formula) + { + this.formula = formula; + } + + public boolean isScale() + { + return OfficeToken.TRUE.equals(getAttribute(OfficeNamespaces.OOREPORT_NS, OfficeToken.SCALE)); + } + + public void setScale(final boolean scale) + { + setAttribute(OfficeNamespaces.OOREPORT_NS, OfficeToken.SCALE, String.valueOf(scale)); + } + + public boolean isPreserveIRI() + { + return OfficeToken.TRUE.equals(getAttribute(OfficeNamespaces.OOREPORT_NS, OfficeToken.PRESERVE_IRI)); + } + + public void setPreserveIRI(final boolean preserveIRI) + { + setAttribute(OfficeNamespaces.OOREPORT_NS, OfficeToken.PRESERVE_IRI, String.valueOf(preserveIRI)); + } + + public String getImageData() + { + return (String) getAttribute(OfficeNamespaces.FORM_NS, OfficeToken.IMAGE_DATA); + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/ObjectOleElement.java b/reportbuilder/java/com/sun/star/report/pentaho/model/ObjectOleElement.java new file mode 100644 index 000000000000..c31c3ae8497a --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/ObjectOleElement.java @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ObjectOleElement.java,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.report.pentaho.model; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author Ocke Janssen + */ +public class ObjectOleElement extends ReportElement{ + + private String url; + private final List masterfields; + private final List detailfields; + private String classid; + + public String getClassid() { + return classid; + } + + public List getDetailfields() { + return detailfields; + } + + public List getMasterfields() { + return masterfields; + } + + public ObjectOleElement() + { + masterfields = new ArrayList(); + detailfields = new ArrayList(); + } + + public String getUrl() { + return url; + } + + public void setClassId(final String classid) { + this.classid = classid; + } + public void setUrl(final String _url ){ + url = _url; + } + + public void addMasterDetailFields(final String master,final String detail){ + if ( master != null ){ + masterfields.add(master); + detailfields.add(detail == null ? master : detail); + } + } + +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/OfficeDetailSection.java b/reportbuilder/java/com/sun/star/report/pentaho/model/OfficeDetailSection.java new file mode 100644 index 000000000000..d66c17c29132 --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/OfficeDetailSection.java @@ -0,0 +1,47 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeDetailSection.java,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package com.sun.star.report.pentaho.model; + +import org.jfree.report.structure.DetailSection; + +/** + * A Marker-Class. + * + * @author Thomas Morgner + * @since 02.03.2007 + */ +public class OfficeDetailSection extends DetailSection +{ + public OfficeDetailSection() + { + } +} diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/OfficeDocument.java b/reportbuilder/java/com/sun/star/report/pentaho/model/OfficeDocument.java new file mode 100644 index 000000000000..02727c2b9d2a --- /dev/null +++ b/reportbuilder/java/com/sun/star/report/pentaho/model/OfficeDocument.java @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: OfficeDocument.java,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser |