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 Forms example of the Developers Guide.
36
37PRJ=../../..
38SETTINGS=$(PRJ)/settings
39
40include $(SETTINGS)/settings.mk
41include $(SETTINGS)/std.mk
42
43# Define non-platform/compiler specific settings
44SAMPLE_NAME=FormsExamples
45SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME)
46SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
47
48APP1_NAME=DataAwareness
49APP1_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP1_NAME)
50APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
51APP2_NAME=ValueBinding
52APP2_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP2_NAME)
53APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
54APP3_NAME=SpreadsheetValueBinding
55APP3_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP3_NAME)
56APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
57APP4_NAME=ControlValidation
58APP4_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP4_NAME)
59APP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_NAME).jar
60
61COMMON_CLASS_OUT = $(SAMPLE_CLASS_OUT)/common
62COMMON_JAVAFILES  = \
63	ButtonOperator.java \
64	ComponentTreeTraversal.java \
65	ControlLock.java \
66	DocumentHelper.java \
67	DocumentType.java \
68	DocumentViewHelper.java \
69	FLTools.java \
70	FormLayer.java \
71	GridFieldValidator.java \
72	InteractionRequest.java \
73	KeyGenerator.java \
74	SalesFilter.java \
75	UNO.java \
76	SpreadsheetView.java \
77	WaitForInput.java \
78	DocumentBasedExample.java \
79	TableCellTextBinding.java \
80	SpreadsheetDocument.java \
81	NumericValidator.java \
82	TextValidator.java \
83	BooleanValidator.java \
84	ListSelectionValidator.java \
85	DateValidator.java \
86	TimeValidator.java \
87	ControlValidator.java \
88	SingleControlValidation.java \
89	HsqlDatabase.java \
90	RowSet.java \
91	URLHelper.java
92
93COMMON_CLASSFILES = $(patsubst %.java,$(COMMON_CLASS_OUT)/%.class,$(COMMON_JAVAFILES))
94
95SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
96		$(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)\
97		$(PATH_SEPARATOR)$(COMMON_CLASS_OUT))
98
99
100# Targets
101.PHONY: ALL
102ALL : \
103    FormsExample
104
105include $(SETTINGS)/stdtarget.mk
106
107$(COMMON_CLASSFILES) : $(COMMON_JAVAFILES)
108	-$(MKDIR) $(subst /,$(PS),$(@D))
109	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMMON_CLASS_OUT) $^
110
111# rule for client/example application manifest file
112$(SAMPLE_GEN_OUT)/%.mf :
113	-$(MKDIR) $(subst /,$(PS),$(@D))
114	@echo Main-Class: com.sun.star.lib.loader.Loader> $@
115	$(ECHOLINE)>> $@
116	@echo Name: com/sun/star/lib/loader/Loader.class>> $@
117	@echo Application-Class: $*>> $@
118
119$(APP1_CLASS_OUT)/$(APP1_NAME).class : $(APP1_NAME).java $(COMMON_CLASSFILES)
120	-$(MKDIR) $(subst /,$(PS),$(@D))
121	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP1_CLASS_OUT) $<
122
123$(APP2_CLASS_OUT)/$(APP2_NAME).class : $(APP2_NAME).java $(COMMON_CLASSFILES)
124	-$(MKDIR) $(subst /,$(PS),$(@D))
125	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP2_CLASS_OUT) $<
126
127$(APP3_CLASS_OUT)/$(APP3_NAME).class : $(APP3_NAME).java $(COMMON_CLASSFILES)
128	-$(MKDIR) $(subst /,$(PS),$(@D))
129	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP3_CLASS_OUT) $<
130
131$(APP4_CLASS_OUT)/$(APP4_NAME).class : $(APP4_NAME).java $(COMMON_CLASSFILES)
132	-$(MKDIR) $(subst /,$(PS),$(@D))
133	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP4_CLASS_OUT) $<
134
135$(APP1_JAR) : $(SAMPLE_GEN_OUT)/$(APP1_NAME).mf $(APP1_CLASS_OUT)/$(APP1_NAME).class $(COMMON_CLASSFILES)
136	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
137	-$(MKDIR) $(subst /,$(PS),$(@D))
138	+$(SDK_JAR) cvfm $@ $< -C $(APP1_CLASS_OUT) .
139	+$(SDK_JAR) uvf $@ -C $(COMMON_CLASS_OUT) .
140	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
141
142$(APP2_JAR) : $(SAMPLE_GEN_OUT)/$(APP2_NAME).mf $(APP2_CLASS_OUT)/$(APP2_NAME).class $(COMMON_CLASSFILES)
143	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
144	-$(MKDIR) $(subst /,$(PS),$(@D))
145	+$(SDK_JAR) cvfm $@ $< -C $(APP2_CLASS_OUT) .
146	+$(SDK_JAR) uvf $@ -C $(COMMON_CLASS_OUT) .
147	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
148
149$(APP3_JAR) : $(SAMPLE_GEN_OUT)/$(APP3_NAME).mf $(APP3_CLASS_OUT)/$(APP3_NAME).class $(COMMON_CLASSFILES)
150	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
151	-$(MKDIR) $(subst /,$(PS),$(@D))
152	+$(SDK_JAR) cvfm $@ $< -C $(APP3_CLASS_OUT) .
153	+$(SDK_JAR) uvf $@ -C $(COMMON_CLASS_OUT) .
154	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
155
156$(APP4_JAR) : $(SAMPLE_GEN_OUT)/$(APP4_NAME).mf $(APP4_CLASS_OUT)/$(APP4_NAME).class $(COMMON_CLASSFILES)
157	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
158	-$(MKDIR) $(subst /,$(PS),$(@D))
159	+$(SDK_JAR) cvfm $@ $< -C $(APP4_CLASS_OUT) .
160	+$(SDK_JAR) uvf $@ -C $(COMMON_CLASS_OUT) .
161	+$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
162
163FormsExample : $(APP1_JAR)  $(APP2_JAR)  $(APP3_JAR)  $(APP4_JAR)
164	@echo --------------------------------------------------------------------------------
165	@echo "$(QM)$(APP1_NAME)$(QM)" demonstrates various things around data aware controls.
166	@echo "$(QM)$(APP2_NAME)$(QM)" demonstrates the use of value bindings for form controls.
167	@echo "$(QM)$(APP3_NAME)$(QM)" demonstrates the usage of the com.sun.star.table.CellValueBinding service
168	@echo "$(QM)$(APP4_NAME)$(QM)" demonstrates the form control validation API
169
170	@echo Please use one of the following commands to run an example:
171	@echo -
172	@echo $(MAKE) $(APP1_NAME).run
173	@echo $(MAKE) $(APP2_NAME).run
174	@echo $(MAKE) $(APP3_NAME).run
175	@echo $(MAKE) $(APP4_NAME).run
176	@echo -
177	@echo Note: The data awareness example needs a running data source with name
178	@echo $(SQM)      $(SQM)"$(QM)OO_SDK_Demo_DB$(QM)". Make sure that you have created such a data source,
179	@echo -
180	@echo The document "$(QM)ProgrammaticScriptAssignment.odt$(QM)" demonstrates
181	@echo how you can programmatically create form controls, and associated
182	@echo scripts with certain events.
183	@echo -
184	@echo $(MAKE) ProgrammaticScriptAssignment.odt.load
185	@echo --------------------------------------------------------------------------------
186
187ProgrammaticScriptAssignment.odt.load : $(COMP_REGISTERFLAG)
188	"$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
189
190%.run: $(SAMPLE_CLASS_OUT)/%.jar
191	$(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
192
193.PHONY: clean
194clean :
195	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
196	-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
197