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 Charts examples of the Developers Guide.
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=DevGuideChartExample
33*b1cdbd2cSJim JagielskiSAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
34*b1cdbd2cSJim JagielskiSAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
35*b1cdbd2cSJim Jagielski
36*b1cdbd2cSJim JagielskiAPP1_NAME=ChartInCalc
37*b1cdbd2cSJim JagielskiAPP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
38*b1cdbd2cSJim JagielskiAPP2_NAME=ChartInDraw
39*b1cdbd2cSJim JagielskiAPP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
40*b1cdbd2cSJim JagielskiAPP3_NAME=ChartInWriter
41*b1cdbd2cSJim JagielskiAPP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
42*b1cdbd2cSJim JagielskiAPP4_NAME=ListenAtCalcRangeInDraw
43*b1cdbd2cSJim JagielskiAPP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_NAME).jar
44*b1cdbd2cSJim JagielskiAPP5_NAME=SelectionChangeListener
45*b1cdbd2cSJim JagielskiAPP5_JAR=$(SAMPLE_CLASS_OUT)/$(APP5_NAME).jar
46*b1cdbd2cSJim Jagielski
47*b1cdbd2cSJim JagielskiCOMP_NAME=JavaSampleChartAddIn
48*b1cdbd2cSJim JagielskiCOMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
49*b1cdbd2cSJim JagielskiCOMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
50*b1cdbd2cSJim JagielskiCOMP_JAR_NAME = $(COMP_NAME).uno.jar
51*b1cdbd2cSJim JagielskiCOMP_JAR = $(SAMPLE_CLASS_OUT)/$(COMP_JAR_NAME)
52*b1cdbd2cSJim JagielskiCOMP_MANIFESTFILE = $(SAMPLE_CLASS_OUT)/$(COMP_NAME).uno.Manifest
53*b1cdbd2cSJim JagielskiCOMP_UNOPKG_MANIFEST = $(SAMPLE_CLASS_OUT)/$(COMP_NAME)/META-INF/manifest.xml
54*b1cdbd2cSJim JagielskiCOMP_REGISTERFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_register_component.flag
55*b1cdbd2cSJim JagielskiCOMP_COMPONENTS=$(COMP_NAME).components
56*b1cdbd2cSJim Jagielski
57*b1cdbd2cSJim JagielskiCOMPJAVAFILES  = \
58*b1cdbd2cSJim Jagielski	   JavaSampleChartAddIn.java
59*b1cdbd2cSJim Jagielski
60*b1cdbd2cSJim JagielskiAPP_JAVAFILES  = \
61*b1cdbd2cSJim Jagielski	   Helper.java \
62*b1cdbd2cSJim Jagielski	   CalcHelper.java \
63*b1cdbd2cSJim Jagielski	   ChartHelper.java
64*b1cdbd2cSJim Jagielski
65*b1cdbd2cSJim JagielskiCOMPCLASSFILES= $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(COMPJAVAFILES))
66*b1cdbd2cSJim Jagielski
67*b1cdbd2cSJim JagielskiAPP_CLASSFILES= $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(APP_JAVAFILES))
68*b1cdbd2cSJim JagielskiAPP_CLASSNAMES= $(patsubst %.java,%.class,$(APP_JAVAFILES))
69*b1cdbd2cSJim Jagielski
70*b1cdbd2cSJim Jagielski$(COMP_NAME)_CLASSFILES = $(COMP_NAME).class
71*b1cdbd2cSJim Jagielski
72*b1cdbd2cSJim JagielskiSDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
73*b1cdbd2cSJim Jagielski		$(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
74*b1cdbd2cSJim Jagielski
75*b1cdbd2cSJim Jagielski
76*b1cdbd2cSJim Jagielski# Targets
77*b1cdbd2cSJim Jagielski.PHONY: ALL
78*b1cdbd2cSJim JagielskiALL : $(SAMPLE_NAME)
79*b1cdbd2cSJim Jagielski
80*b1cdbd2cSJim Jagielskiinclude $(SETTINGS)/stdtarget.mk
81*b1cdbd2cSJim Jagielski
82*b1cdbd2cSJim Jagielski$(SAMPLE_CLASS_OUT)/%.Manifest :
83*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
84*b1cdbd2cSJim Jagielski	@echo RegistrationClassName: $(basename $(basename $(@F)))> $@
85*b1cdbd2cSJim Jagielski
86*b1cdbd2cSJim Jagielski# rule for client/example application class files, explicit dependencies to common
87*b1cdbd2cSJim Jagielski# java files which are used in all examples.
88*b1cdbd2cSJim Jagielski$(SAMPLE_CLASS_OUT)/%.class : %.java $(APP_JAVAFILES)
89*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
90*b1cdbd2cSJim Jagielski	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $< $(APP_JAVAFILES)
91*b1cdbd2cSJim Jagielski
92*b1cdbd2cSJim Jagielski$(COMPCLASSFILES) : $(JAVAFILES)
93*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
94*b1cdbd2cSJim Jagielski	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $(COMPJAVAFILES)
95*b1cdbd2cSJim Jagielski
96*b1cdbd2cSJim Jagielski# rule for client/example application manifest file
97*b1cdbd2cSJim Jagielski$(SAMPLE_CLASS_OUT)/%.mf :
98*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
99*b1cdbd2cSJim Jagielski	@echo Main-Class: com.sun.star.lib.loader.Loader> $@
100*b1cdbd2cSJim Jagielski	$(ECHOLINE)>> $@
101*b1cdbd2cSJim Jagielski	@echo Name: com/sun/star/lib/loader/Loader.class>> $@
102*b1cdbd2cSJim Jagielski	@echo Application-Class: $*>> $@
103*b1cdbd2cSJim Jagielski
104*b1cdbd2cSJim Jagielski# rule for client/example application jar file
105*b1cdbd2cSJim Jagielski$(SAMPLE_CLASS_OUT)/%.jar : $(SAMPLE_CLASS_OUT)/%.mf $(SAMPLE_CLASS_OUT)/%.class
106*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
107*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
108*b1cdbd2cSJim Jagielski	+cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $*.mf $**.class $(APP_CLASSNAMES)
109*b1cdbd2cSJim Jagielski
110*b1cdbd2cSJim Jagielski	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
111*b1cdbd2cSJim Jagielski
112*b1cdbd2cSJim Jagielski# rule for component jar file
113*b1cdbd2cSJim Jagielski$(COMP_JAR) : $(COMP_MANIFESTFILE) $(COMPCLASSFILES)
114*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
115*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
116*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
117*b1cdbd2cSJim Jagielski
118*b1cdbd2cSJim Jagielski# rule for component package manifest
119*b1cdbd2cSJim Jagielski$(SAMPLE_CLASS_OUT)/%/manifest.xml :
120*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
121*b1cdbd2cSJim Jagielski	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
122*b1cdbd2cSJim Jagielski	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
123*b1cdbd2cSJim Jagielski	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
124*b1cdbd2cSJim Jagielski	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
125*b1cdbd2cSJim Jagielski	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
126*b1cdbd2cSJim Jagielski	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
127*b1cdbd2cSJim Jagielski
128*b1cdbd2cSJim Jagielski# rule for component pacakge file
129*b1cdbd2cSJim Jagielski$(COMP_PACKAGE) : $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
130*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
131*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
132*b1cdbd2cSJim Jagielski	$(SDK_ZIP) $@ $(COMP_COMPONENTS)
133*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) ../../bin/$(@F) -u $(<F)
134*b1cdbd2cSJim Jagielski	cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) ../../../bin/$(@F) -u META-INF/manifest.xml
135*b1cdbd2cSJim Jagielski
136*b1cdbd2cSJim Jagielski$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
137*b1cdbd2cSJim Jagielskiifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
138*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
139*b1cdbd2cSJim Jagielski	-$(MKDIR) $(subst /,$(PS),$(@D))
140*b1cdbd2cSJim Jagielski	$(DEPLOYTOOL) $(COMP_PACKAGE_URL)
141*b1cdbd2cSJim Jagielski	@echo flagged > $(subst /,$(PS),$@)
142*b1cdbd2cSJim Jagielskielse
143*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
144*b1cdbd2cSJim Jagielski	@echo  If you want to install your component automatically, please set the environment
145*b1cdbd2cSJim Jagielski	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
146*b1cdbd2cSJim Jagielski	@echo  possible if no office instance is running.
147*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
148*b1cdbd2cSJim Jagielskiendif
149*b1cdbd2cSJim Jagielski
150*b1cdbd2cSJim Jagielski$(APP1_JAR) : $(SAMPLE_CLASS_OUT)/$(APP1_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP1_NAME).class
151*b1cdbd2cSJim Jagielski$(APP2_JAR) : $(SAMPLE_CLASS_OUT)/$(APP2_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP2_NAME).class
152*b1cdbd2cSJim Jagielski$(APP3_JAR) : $(SAMPLE_CLASS_OUT)/$(APP3_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP3_NAME).class
153*b1cdbd2cSJim Jagielski$(APP4_JAR) : $(SAMPLE_CLASS_OUT)/$(APP4_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP4_NAME).class
154*b1cdbd2cSJim Jagielski$(APP5_JAR) : $(SAMPLE_CLASS_OUT)/$(APP5_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP5_NAME).class
155*b1cdbd2cSJim Jagielski
156*b1cdbd2cSJim Jagielski$(SAMPLE_NAME) : $(COMP_REGISTERFLAG) $(APP1_JAR)  $(APP2_JAR)  $(APP3_JAR)  $(APP4_JAR)  $(APP5_JAR)
157*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
158*b1cdbd2cSJim Jagielski	@echo When you run the "$(QM)$(APP5_NAME)$(QM)" example please select the
159*b1cdbd2cSJim Jagielski	@echo legend or the title to add a $(APP5_NAME). The example terminates
160*b1cdbd2cSJim Jagielski	@echo when the document is closed.
161*b1cdbd2cSJim Jagielski	@echo -
162*b1cdbd2cSJim Jagielski	@echo Please use the following commands to execute the examples!
163*b1cdbd2cSJim Jagielski	@echo -
164*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(APP1_NAME).run
165*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(APP2_NAME).run
166*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(APP3_NAME).run
167*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(APP4_NAME).run
168*b1cdbd2cSJim Jagielski	@echo $(MAKE) $(APP5_NAME).run
169*b1cdbd2cSJim Jagielski	@echo --------
170*b1cdbd2cSJim Jagielski	@echo The Chart add-in component was installed if SDK_AUTO_DEPLOYMENT = YES.
171*b1cdbd2cSJim Jagielski	@echo Load the "$(QM)AddInChart.ods$(QM)" document in your office to see the new chart type,
172*b1cdbd2cSJim Jagielski	@echo and see the example description.
173*b1cdbd2cSJim Jagielski	@echo -
174*b1cdbd2cSJim Jagielski	@echo $(MAKE) AddInChart.ods.load
175*b1cdbd2cSJim Jagielski	@echo --------------------------------------------------------------------------------
176*b1cdbd2cSJim Jagielski
177*b1cdbd2cSJim Jagielski%.run: $(SAMPLE_CLASS_OUT)/%.jar
178*b1cdbd2cSJim Jagielski	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
179*b1cdbd2cSJim Jagielski
180*b1cdbd2cSJim JagielskiAddInChart.ods.load : $(REGISTERFLAG)
181*b1cdbd2cSJim Jagielski	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
182*b1cdbd2cSJim Jagielski
183*b1cdbd2cSJim Jagielski.PHONY: clean
184*b1cdbd2cSJim Jagielskiclean :
185*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
186*b1cdbd2cSJim Jagielski	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
187*b1cdbd2cSJim Jagielski	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
188