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