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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include "valueproperties.hxx"
27 #include "strings.hxx"
28 #include <com/sun/star/form/FormComponentType.hpp>
29 
30 //.........................................................................
31 namespace xmloff
32 {
33 //.........................................................................
34 
35 	using namespace ::com::sun::star::form;
36 
37 	//=====================================================================
38 	//= OValuePropertiesMetaData
39 	//=====================================================================
40 	//---------------------------------------------------------------------
getValuePropertyNames(OControlElement::ElementType _eType,sal_Int16 _nFormComponentType,sal_Char const * & _rpCurrentValuePropertyName,sal_Char const * & _rpValuePropertyName)41 	void OValuePropertiesMetaData::getValuePropertyNames(
42 			OControlElement::ElementType _eType, sal_Int16 _nFormComponentType,
43 			sal_Char const * & _rpCurrentValuePropertyName, sal_Char const * & _rpValuePropertyName)
44 	{
45 		// reset the pointers in case we can't determine the property names
46 		_rpCurrentValuePropertyName = _rpValuePropertyName = NULL;
47 		switch (_nFormComponentType)
48 		{
49 			case FormComponentType::TEXTFIELD:
50 				if (OControlElement::FORMATTED_TEXT == _eType)
51 				{
52 					_rpCurrentValuePropertyName = PROPERTY_EFFECTIVE_VALUE;
53 					_rpValuePropertyName = PROPERTY_EFFECTIVE_DEFAULT;
54 				}
55 				else
56 				{
57 					if (OControlElement::PASSWORD != _eType)
58 						// no CurrentValue" for passwords
59 						_rpCurrentValuePropertyName = PROPERTY_TEXT;
60 					_rpValuePropertyName = PROPERTY_DEFAULT_TEXT;
61 				}
62 				break;
63 
64 			case FormComponentType::NUMERICFIELD:
65 			case FormComponentType::CURRENCYFIELD:
66 				_rpCurrentValuePropertyName = PROPERTY_VALUE;
67 				_rpValuePropertyName = PROPERTY_DEFAULT_VALUE;
68 				break;
69 
70 			case FormComponentType::PATTERNFIELD:
71 			case FormComponentType::FILECONTROL:
72 			case FormComponentType::COMBOBOX:
73 				_rpValuePropertyName = PROPERTY_DEFAULT_TEXT;
74 				// NO BREAK!!
75 			case FormComponentType::COMMANDBUTTON:
76 				_rpCurrentValuePropertyName = PROPERTY_TEXT;
77 				break;
78 
79             case FormComponentType::CHECKBOX:
80 			case FormComponentType::RADIOBUTTON:
81 				_rpValuePropertyName = PROPERTY_REFVALUE;
82 				break;
83 
84 			case FormComponentType::HIDDENCONTROL:
85 				_rpValuePropertyName = PROPERTY_HIDDEN_VALUE;
86 				break;
87 
88             case FormComponentType::SCROLLBAR:
89 				_rpCurrentValuePropertyName = PROPERTY_SCROLLVALUE;
90 				_rpValuePropertyName = PROPERTY_SCROLLVALUE_DEFAULT;
91                 break;
92 
93             case FormComponentType::SPINBUTTON:
94 				_rpCurrentValuePropertyName = PROPERTY_SPINVALUE;
95 				_rpValuePropertyName = PROPERTY_DEFAULT_SPINVALUE;
96                 break;
97 
98             default:
99                 OSL_ENSURE( false, "OValuePropertiesMetaData::getValuePropertyNames: unsupported component type!" );
100                 break;
101 		}
102 	}
103 
104 
105 	//---------------------------------------------------------------------
getValueLimitPropertyNames(sal_Int16 _nFormComponentType,sal_Char const * & _rpMinValuePropertyName,sal_Char const * & _rpMaxValuePropertyName)106 	void OValuePropertiesMetaData::getValueLimitPropertyNames(sal_Int16 _nFormComponentType,
107 		sal_Char const * & _rpMinValuePropertyName, sal_Char const * & _rpMaxValuePropertyName)
108 	{
109 		_rpMinValuePropertyName = _rpMaxValuePropertyName = NULL;
110 		switch (_nFormComponentType)
111 		{
112 			case FormComponentType::NUMERICFIELD:
113 			case FormComponentType::CURRENCYFIELD:
114 				_rpMinValuePropertyName = PROPERTY_VALUE_MIN;
115 				_rpMaxValuePropertyName = PROPERTY_VALUE_MAX;
116 				break;
117 
118 			case FormComponentType::TEXTFIELD:
119 				_rpMinValuePropertyName = PROPERTY_EFFECTIVE_MIN;
120 				_rpMaxValuePropertyName = PROPERTY_EFFECTIVE_MAX;
121 				break;
122 
123             case FormComponentType::SCROLLBAR:
124 				_rpMinValuePropertyName = PROPERTY_SCROLLVALUE_MIN;
125 				_rpMaxValuePropertyName = PROPERTY_SCROLLVALUE_MAX;
126 				break;
127 
128             case FormComponentType::SPINBUTTON:
129 				_rpMinValuePropertyName = PROPERTY_SPINVALUE_MIN;
130 				_rpMaxValuePropertyName = PROPERTY_SPINVALUE_MAX;
131 				break;
132 
133             default:
134                 OSL_ENSURE( false, "OValuePropertiesMetaData::getValueLimitPropertyNames: unsupported component type!" );
135                 break;
136 		}
137 	}
138 
139 	//---------------------------------------------------------------------
getRuntimeValuePropertyNames(OControlElement::ElementType _eType,sal_Int16 _nFormComponentType,sal_Char const * & _rpValuePropertyName,sal_Char const * & _rpDefaultValuePropertyName)140 	void OValuePropertiesMetaData::getRuntimeValuePropertyNames(
141 		OControlElement::ElementType _eType, sal_Int16 _nFormComponentType,
142 		sal_Char const * & _rpValuePropertyName, sal_Char const * & _rpDefaultValuePropertyName )
143 	{
144 		// reset the pointers in case we can't determine the property names
145 		_rpValuePropertyName = _rpDefaultValuePropertyName = NULL;
146 		switch (_nFormComponentType)
147 		{
148 			case FormComponentType::TEXTFIELD:
149 				if (OControlElement::FORMATTED_TEXT == _eType)
150 				{
151 					_rpValuePropertyName = PROPERTY_EFFECTIVE_VALUE;
152 					_rpDefaultValuePropertyName = PROPERTY_EFFECTIVE_DEFAULT;
153 				}
154 				else
155 				{
156 					_rpValuePropertyName = PROPERTY_TEXT;
157 					_rpDefaultValuePropertyName = PROPERTY_DEFAULT_TEXT;
158 				}
159 				break;
160 
161 			case FormComponentType::DATEFIELD:
162 				_rpValuePropertyName = PROPERTY_DATE;
163 				_rpDefaultValuePropertyName = PROPERTY_DEFAULT_DATE;
164                 break;
165 
166 			case FormComponentType::TIMEFIELD:
167 				_rpValuePropertyName = PROPERTY_TIME;
168 				_rpDefaultValuePropertyName = PROPERTY_DEFAULT_TIME;
169                 break;
170 
171 			case FormComponentType::NUMERICFIELD:
172 			case FormComponentType::CURRENCYFIELD:
173 			case FormComponentType::PATTERNFIELD:
174 			case FormComponentType::FILECONTROL:
175 			case FormComponentType::COMBOBOX:
176             case FormComponentType::SCROLLBAR:
177             case FormComponentType::SPINBUTTON:
178 				// For these types, the runtime properties are the same as the ones which in the XML
179 				// stream are named "value properties"
180 				getValuePropertyNames( _eType, _nFormComponentType, _rpValuePropertyName, _rpDefaultValuePropertyName );
181 				break;
182 
183 			case FormComponentType::CHECKBOX:
184 			case FormComponentType::RADIOBUTTON:
185 				_rpValuePropertyName = PROPERTY_STATE;
186 				_rpDefaultValuePropertyName = PROPERTY_DEFAULT_STATE;
187 				break;
188 		}
189 	}
190 
191 //.........................................................................
192 }	// namespace xmloff
193 //.........................................................................
194 
195 
196