1#*************************************************************************
2#
3#  The Contents of this file are made available subject to the terms of
4#  the BSD license.
5#
6#  Copyright 2000, 2010 Oracle and/or its affiliates.
7#  All rights reserved.
8#
9#  Redistribution and use in source and binary forms, with or without
10#  modification, are permitted provided that the following conditions
11#  are met:
12#  1. Redistributions of source code must retain the above copyright
13#     notice, this list of conditions and the following disclaimer.
14#  2. Redistributions in binary form must reproduce the above copyright
15#     notice, this list of conditions and the following disclaimer in the
16#     documentation and/or other materials provided with the distribution.
17#  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18#     contributors may be used to endorse or promote products derived
19#     from this software without specific prior written permission.
20#
21#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24#  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25#  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32#
33#**************************************************************************
34
35# Builds the Java DocumentHandling examples of the SDK.
36
37PRJ=../../..
38SETTINGS=$(PRJ)/settings
39
40include $(SETTINGS)/settings.mk
41include $(SETTINGS)/std.mk
42include $(SETTINGS)/dk.mk
43
44# Define non-platform/compiler specific settings
45SAMPLE_NAME=JavaDocumentHandlingExamples
46SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
47SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
48
49DIRFLAG=$(OUT_MISC)/$(SAMPLE_NAME)_directory.flag
50
51APP1_NAME=DocumentConverter
52APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
53APP2_NAME=DocumentLoader
54APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
55APP3_NAME=DocumentPrinter
56APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
57APP4_NAME=DocumentSaver
58APP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_NAME).jar
59
60SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
61		$(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
62
63
64# Targets
65.PHONY: ALL
66ALL : \
67	$(SAMPLE_NAME)
68
69include $(SETTINGS)/stdtarget.mk
70
71$(SAMPLE_CLASS_OUT)/%.class : %.java
72	-$(MKDIR) $(subst /,$(PS),$(@D))
73	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $<
74
75$(SAMPLE_CLASS_OUT)/%.mf :
76	-$(MKDIR) $(subst /,$(PS),$(@D))
77	@echo Main-Class: com.sun.star.lib.loader.Loader> $@
78	$(ECHOLINE)>> $@
79	@echo Name: com/sun/star/lib/loader/Loader.class>> $@
80	@echo Application-Class: $*>> $@
81
82$(SAMPLE_CLASS_OUT)/%.jar : $(SAMPLE_CLASS_OUT)/%.mf $(SAMPLE_CLASS_OUT)/%.class
83	-$(MKDIR) $(subst /,$(PS),$(@D))
84	+cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
85	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
86
87$(APP1_JAR) : $(SAMPLE_CLASS_OUT)/$(APP1_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP1_NAME).class
88$(APP2_JAR) : $(SAMPLE_CLASS_OUT)/$(APP2_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP2_NAME).class
89$(APP3_JAR) : $(SAMPLE_CLASS_OUT)/$(APP3_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP3_NAME).class
90$(APP4_JAR) : $(SAMPLE_CLASS_OUT)/$(APP4_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP4_NAME).class
91
92$(SAMPLE_NAME) : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR)
93	@echo --------------------------------------------------------------------------------
94	@echo The $(APP1_NAME) search the "$(QM)./test$(QM)" directory for documents, convert
95	@echo them using using the "$(QM)MS Word 97$(QM)" filter and the extension "$(QM).doc$(QM)".
96	@echo The converted files are store in "$(QM)$(SAMPLE_GEN_OUT)/converted_files$(QM)".
97	@echo The list of possible filter names can change. Normally an updated list can be found
98	@echo on "$(QM)http://www.openoffice.org/files/documents/25/111/filter_description.html$(QM)".
99	@echo -
100	@echo The $(APP2_NAME) loads the document "$(QM)./test/test1.odt$(QM)".
101	@echo -
102	@echo The $(APP3_NAME) prints the document "$(QM)./test/test1.odt$(QM)" using the
103	@echo the specified printer. If the printer is unknown, the default printer is used.
104	@echo -
105	@echo The $(APP5_NAME) loads the document "$(QM)./test/test1.odt$(QM)" and saves it
106	@echo under "$(QM)$(SAMPLE_GEN_OUT)/savetest/testsave.odt$(QM)".
107	@echo -
108	@echo Please use one of the following commands to execute the examples!
109	@echo -
110	@echo $(MAKE) $(APP1_NAME).run
111	@echo $(MAKE) $(APP2_NAME).run
112	@echo $(MAKE) $(APP3_NAME).run
113	@echo $(MAKE) $(APP4_NAME).run
114	@echo --------
115	@echo The examples need parameters. Please use one the following commands to
116	@echo start the demo if you do not want the default parameters specified in the
117	@echo this makefile. Starting without parameters print a command line help:
118	@echo --- $(APP1_NAME) ---
119	@echo java -jar $(APP1_NAME).jar "$(QM)directory$(QM)" "$(QM)filter name$(QM)" "$(QM)extension$(QM)" "$(QM)output_directory$(QM)"
120	@echo --- $(APP2_NAME) ---
121	@echo java -jar $(APP2_NAME).jar "$(QM)Url|path$(QM)"
122	@echo --- $(APP3_NAME) ---
123	@echo java -jar $(APP3_NAME).jar "$(QM)printername$(QM)" "$(QM)filename$(QM)" "$(QM)pages$(QM)"
124	@echo --- $(APP4_NAME) ---
125	@echo java -jar $(APP4_NAME).jar "$(QM)load Url|path$(QM)" "$(QM)save Url|path$(QM)"
126	@echo --------------------------------------------------------------------------------
127
128$(APP1_NAME).run: $(APP1_JAR)
129	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/converted_files)
130	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test" "MS Word 97" "doc" "$(SAMPLE_GEN_OUT)/converted_files"
131
132$(APP2_NAME).run: $(APP2_JAR)
133	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test/test1.odt"
134
135$(APP3_NAME).run: $(APP3_JAR)
136	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "my_printer" "./test/test1.odt" 1
137
138$(APP4_NAME).run: $(APP4_JAR)
139	-$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/savetest)
140	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "./test/test1.odt" "$(SAMPLE_GEN_OUT)/savetest/testsave.odt"
141
142.PHONY: clean
143clean :
144	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
145	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
146