1*b1cdbd2cSJim Jagielski#**************************************************************
2*b1cdbd2cSJim Jagielski#
3*b1cdbd2cSJim Jagielski#  Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski#  or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski#  distributed with this work for additional information
6*b1cdbd2cSJim Jagielski#  regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski#  to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski#  "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski#  with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski#
11*b1cdbd2cSJim Jagielski#    http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski#
13*b1cdbd2cSJim Jagielski#  Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski#  software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski#  KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski#  specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski#  under the License.
19*b1cdbd2cSJim Jagielski#
20*b1cdbd2cSJim Jagielski#**************************************************************
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski# Builds the Java DocumentHandling examples of the SDK.
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim JagielskiPRJ=../../..
25*b1cdbd2cSJim JagielskiSETTINGS=$(PRJ)/settings
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/settings.mk
28*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/std.mk
29*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/dk.mk
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski# Define non-platform/compiler specific settings
32*b1cdbd2cSJim JagielskiSAMPLE_NAME=JavaDocumentHandlingExamples
33*b1cdbd2cSJim JagielskiSAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
34*b1cdbd2cSJim JagielskiSAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
35*b1cdbd2cSJim Jagielski
36*b1cdbd2cSJim JagielskiDIRFLAG=$(OUT_MISC)/$(SAMPLE_NAME)_directory.flag
37*b1cdbd2cSJim Jagielski
38*b1cdbd2cSJim JagielskiAPP1_NAME=DocumentConverter
39*b1cdbd2cSJim JagielskiAPP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
40*b1cdbd2cSJim JagielskiAPP2_NAME=DocumentLoader
41*b1cdbd2cSJim JagielskiAPP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
42*b1cdbd2cSJim JagielskiAPP3_NAME=DocumentPrinter
43*b1cdbd2cSJim JagielskiAPP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
44*b1cdbd2cSJim JagielskiAPP4_NAME=DocumentSaver
45*b1cdbd2cSJim JagielskiAPP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_NAME).jar
46*b1cdbd2cSJim Jagielski
47*b1cdbd2cSJim JagielskiSDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
48*b1cdbd2cSJim Jagielski		$(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
49*b1cdbd2cSJim Jagielski
50*b1cdbd2cSJim Jagielski
51*b1cdbd2cSJim Jagielski# Targets
52*b1cdbd2cSJim Jagielski.PHONY: ALL
53*b1cdbd2cSJim JagielskiALL : \
54*b1cdbd2cSJim Jagielski	$(SAMPLE_NAME)
55*b1cdbd2cSJim Jagielski
56*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/stdtarget.mk
57*b1cdbd2cSJim Jagielski
58*b1cdbd2cSJim Jagielski$(SAMPLE_CLASS_OUT)/%.class : %.java
59*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
60*b1cdbd2cSJim Jagielski	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $<
61*b1cdbd2cSJim Jagielski
62*b1cdbd2cSJim Jagielski$(SAMPLE_CLASS_OUT)/%.mf :
63*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
64*b1cdbd2cSJim Jagielski	@echo Main-Class: com.sun.star.lib.loader.Loader> $@
65*b1cdbd2cSJim Jagielski	$(ECHOLINE)>> $@
66*b1cdbd2cSJim Jagielski	@echo Name: com/sun/star/lib/loader/Loader.class>> $@
67*b1cdbd2cSJim Jagielski	@echo Application-Class: $*>> $@
68*b1cdbd2cSJim Jagielski
69*b1cdbd2cSJim Jagielski$(SAMPLE_CLASS_OUT)/%.jar : $(SAMPLE_CLASS_OUT)/%.mf $(SAMPLE_CLASS_OUT)/%.class
70*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
71*b1cdbd2cSJim Jagielski	+cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
72*b1cdbd2cSJim Jagielski	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
73*b1cdbd2cSJim Jagielski
74*b1cdbd2cSJim Jagielski$(APP1_JAR) : $(SAMPLE_CLASS_OUT)/$(APP1_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP1_NAME).class
75*b1cdbd2cSJim Jagielski$(APP2_JAR) : $(SAMPLE_CLASS_OUT)/$(APP2_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP2_NAME).class
76*b1cdbd2cSJim Jagielski$(APP3_JAR) : $(SAMPLE_CLASS_OUT)/$(APP3_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP3_NAME).class
77*b1cdbd2cSJim Jagielski$(APP4_JAR) : $(SAMPLE_CLASS_OUT)/$(APP4_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP4_NAME).class
78*b1cdbd2cSJim Jagielski
79*b1cdbd2cSJim Jagielski$(SAMPLE_NAME) : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR)
80*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
81*b1cdbd2cSJim Jagielski	@echo The $(APP1_NAME) search the "$(QM)./test$(QM)" directory for documents, convert
82*b1cdbd2cSJim Jagielski	@echo them using using the "$(QM)MS Word 97$(QM)" filter and the extension "$(QM).doc$(QM)".
83*b1cdbd2cSJim Jagielski	@echo The converted files are store in "$(QM)$(SAMPLE_GEN_OUT)/converted_files$(QM)".
84*b1cdbd2cSJim Jagielski	@echo The list of possible filter names can change. Normally an updated list can be found
85*b1cdbd2cSJim Jagielski	@echo on "$(QM)http://www.openoffice.org/files/documents/25/111/filter_description.html$(QM)".
86*b1cdbd2cSJim Jagielski	@echo -
87*b1cdbd2cSJim Jagielski	@echo The $(APP2_NAME) loads the document "$(QM)./test/test1.odt$(QM)".
88*b1cdbd2cSJim Jagielski	@echo -
89*b1cdbd2cSJim Jagielski	@echo The $(APP3_NAME) prints the document "$(QM)./test/test1.odt$(QM)" using the
90*b1cdbd2cSJim Jagielski	@echo the specified printer. If the printer is unknown, the default printer is used.
91*b1cdbd2cSJim Jagielski	@echo -
92*b1cdbd2cSJim Jagielski	@echo The $(APP5_NAME) loads the document "$(QM)./test/test1.odt$(QM)" and saves it
93*b1cdbd2cSJim Jagielski	@echo under "$(QM)$(SAMPLE_GEN_OUT)/savetest/testsave.odt$(QM)".
94*b1cdbd2cSJim Jagielski	@echo -
95*b1cdbd2cSJim Jagielski	@echo Please use one of the following commands to execute the examples!
96*b1cdbd2cSJim Jagielski	@echo -
97*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(APP1_NAME).run
98*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(APP2_NAME).run
99*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(APP3_NAME).run
100*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(APP4_NAME).run
101*b1cdbd2cSJim Jagielski	@echo --------
102*b1cdbd2cSJim Jagielski	@echo The examples need parameters. Please use one the following commands to
103*b1cdbd2cSJim Jagielski	@echo start the demo if you do not want the default parameters specified in the
104*b1cdbd2cSJim Jagielski	@echo this makefile. Starting without parameters print a command line help:
105*b1cdbd2cSJim Jagielski	@echo --- $(APP1_NAME) ---
106*b1cdbd2cSJim Jagielski	@echo java -jar $(APP1_NAME).jar "$(QM)directory$(QM)" "$(QM)filter name$(QM)" "$(QM)extension$(QM)" "$(QM)output_directory$(QM)"
107*b1cdbd2cSJim Jagielski	@echo --- $(APP2_NAME) ---
108*b1cdbd2cSJim Jagielski	@echo java -jar $(APP2_NAME).jar "$(QM)Url|path$(QM)"
109*b1cdbd2cSJim Jagielski	@echo --- $(APP3_NAME) ---
110*b1cdbd2cSJim Jagielski	@echo java -jar $(APP3_NAME).jar "$(QM)printername$(QM)" "$(QM)filename$(QM)" "$(QM)pages$(QM)"
111*b1cdbd2cSJim Jagielski	@echo --- $(APP4_NAME) ---
112*b1cdbd2cSJim Jagielski	@echo java -jar $(APP4_NAME).jar "$(QM)load Url|path$(QM)" "$(QM)save Url|path$(QM)"
113*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
114*b1cdbd2cSJim Jagielski
115*b1cdbd2cSJim Jagielski$(APP1_NAME).run: $(APP1_JAR)
116*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/converted_files)
117*b1cdbd2cSJim Jagielski	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test" "MS Word 97" "doc" "$(SAMPLE_GEN_OUT)/converted_files"
118*b1cdbd2cSJim Jagielski
119*b1cdbd2cSJim Jagielski$(APP2_NAME).run: $(APP2_JAR)
120*b1cdbd2cSJim Jagielski	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test/test1.odt"
121*b1cdbd2cSJim Jagielski
122*b1cdbd2cSJim Jagielski$(APP3_NAME).run: $(APP3_JAR)
123*b1cdbd2cSJim Jagielski	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "my_printer" "./test/test1.odt" 1
124*b1cdbd2cSJim Jagielski
125*b1cdbd2cSJim Jagielski$(APP4_NAME).run: $(APP4_JAR)
126*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/savetest)
127*b1cdbd2cSJim Jagielski	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test/test1.odt" "$(SAMPLE_GEN_OUT)/savetest/testsave.odt"
128*b1cdbd2cSJim Jagielski
129*b1cdbd2cSJim Jagielski.PHONY: clean
130*b1cdbd2cSJim Jagielskiclean :
131*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
132*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
133