1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
30*cdf0e10cSrcweir #include "valueproperties.hxx"
31*cdf0e10cSrcweir #include "strings.hxx"
32*cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir //.........................................................................
35*cdf0e10cSrcweir namespace xmloff
36*cdf0e10cSrcweir {
37*cdf0e10cSrcweir //.........................................................................
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir 	using namespace ::com::sun::star::form;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 	//=====================================================================
42*cdf0e10cSrcweir 	//= OValuePropertiesMetaData
43*cdf0e10cSrcweir 	//=====================================================================
44*cdf0e10cSrcweir 	//---------------------------------------------------------------------
45*cdf0e10cSrcweir 	void OValuePropertiesMetaData::getValuePropertyNames(
46*cdf0e10cSrcweir 			OControlElement::ElementType _eType, sal_Int16 _nFormComponentType,
47*cdf0e10cSrcweir 			sal_Char const * & _rpCurrentValuePropertyName, sal_Char const * & _rpValuePropertyName)
48*cdf0e10cSrcweir 	{
49*cdf0e10cSrcweir 		// reset the pointers in case we can't determine the property names
50*cdf0e10cSrcweir 		_rpCurrentValuePropertyName = _rpValuePropertyName = NULL;
51*cdf0e10cSrcweir 		switch (_nFormComponentType)
52*cdf0e10cSrcweir 		{
53*cdf0e10cSrcweir 			case FormComponentType::TEXTFIELD:
54*cdf0e10cSrcweir 				if (OControlElement::FORMATTED_TEXT == _eType)
55*cdf0e10cSrcweir 				{
56*cdf0e10cSrcweir 					_rpCurrentValuePropertyName = PROPERTY_EFFECTIVE_VALUE;
57*cdf0e10cSrcweir 					_rpValuePropertyName = PROPERTY_EFFECTIVE_DEFAULT;
58*cdf0e10cSrcweir 				}
59*cdf0e10cSrcweir 				else
60*cdf0e10cSrcweir 				{
61*cdf0e10cSrcweir 					if (OControlElement::PASSWORD != _eType)
62*cdf0e10cSrcweir 						// no CurrentValue" for passwords
63*cdf0e10cSrcweir 						_rpCurrentValuePropertyName = PROPERTY_TEXT;
64*cdf0e10cSrcweir 					_rpValuePropertyName = PROPERTY_DEFAULT_TEXT;
65*cdf0e10cSrcweir 				}
66*cdf0e10cSrcweir 				break;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 			case FormComponentType::NUMERICFIELD:
69*cdf0e10cSrcweir 			case FormComponentType::CURRENCYFIELD:
70*cdf0e10cSrcweir 				_rpCurrentValuePropertyName = PROPERTY_VALUE;
71*cdf0e10cSrcweir 				_rpValuePropertyName = PROPERTY_DEFAULT_VALUE;
72*cdf0e10cSrcweir 				break;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 			case FormComponentType::PATTERNFIELD:
75*cdf0e10cSrcweir 			case FormComponentType::FILECONTROL:
76*cdf0e10cSrcweir 			case FormComponentType::COMBOBOX:
77*cdf0e10cSrcweir 				_rpValuePropertyName = PROPERTY_DEFAULT_TEXT;
78*cdf0e10cSrcweir 				// NO BREAK!!
79*cdf0e10cSrcweir 			case FormComponentType::COMMANDBUTTON:
80*cdf0e10cSrcweir 				_rpCurrentValuePropertyName = PROPERTY_TEXT;
81*cdf0e10cSrcweir 				break;
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir             case FormComponentType::CHECKBOX:
84*cdf0e10cSrcweir 			case FormComponentType::RADIOBUTTON:
85*cdf0e10cSrcweir 				_rpValuePropertyName = PROPERTY_REFVALUE;
86*cdf0e10cSrcweir 				break;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 			case FormComponentType::HIDDENCONTROL:
89*cdf0e10cSrcweir 				_rpValuePropertyName = PROPERTY_HIDDEN_VALUE;
90*cdf0e10cSrcweir 				break;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir             case FormComponentType::SCROLLBAR:
93*cdf0e10cSrcweir 				_rpCurrentValuePropertyName = PROPERTY_SCROLLVALUE;
94*cdf0e10cSrcweir 				_rpValuePropertyName = PROPERTY_SCROLLVALUE_DEFAULT;
95*cdf0e10cSrcweir                 break;
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir             case FormComponentType::SPINBUTTON:
98*cdf0e10cSrcweir 				_rpCurrentValuePropertyName = PROPERTY_SPINVALUE;
99*cdf0e10cSrcweir 				_rpValuePropertyName = PROPERTY_DEFAULT_SPINVALUE;
100*cdf0e10cSrcweir                 break;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir             default:
103*cdf0e10cSrcweir                 OSL_ENSURE( false, "OValuePropertiesMetaData::getValuePropertyNames: unsupported component type!" );
104*cdf0e10cSrcweir                 break;
105*cdf0e10cSrcweir 		}
106*cdf0e10cSrcweir 	}
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	//---------------------------------------------------------------------
110*cdf0e10cSrcweir 	void OValuePropertiesMetaData::getValueLimitPropertyNames(sal_Int16 _nFormComponentType,
111*cdf0e10cSrcweir 		sal_Char const * & _rpMinValuePropertyName, sal_Char const * & _rpMaxValuePropertyName)
112*cdf0e10cSrcweir 	{
113*cdf0e10cSrcweir 		_rpMinValuePropertyName = _rpMaxValuePropertyName = NULL;
114*cdf0e10cSrcweir 		switch (_nFormComponentType)
115*cdf0e10cSrcweir 		{
116*cdf0e10cSrcweir 			case FormComponentType::NUMERICFIELD:
117*cdf0e10cSrcweir 			case FormComponentType::CURRENCYFIELD:
118*cdf0e10cSrcweir 				_rpMinValuePropertyName = PROPERTY_VALUE_MIN;
119*cdf0e10cSrcweir 				_rpMaxValuePropertyName = PROPERTY_VALUE_MAX;
120*cdf0e10cSrcweir 				break;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 			case FormComponentType::TEXTFIELD:
123*cdf0e10cSrcweir 				_rpMinValuePropertyName = PROPERTY_EFFECTIVE_MIN;
124*cdf0e10cSrcweir 				_rpMaxValuePropertyName = PROPERTY_EFFECTIVE_MAX;
125*cdf0e10cSrcweir 				break;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir             case FormComponentType::SCROLLBAR:
128*cdf0e10cSrcweir 				_rpMinValuePropertyName = PROPERTY_SCROLLVALUE_MIN;
129*cdf0e10cSrcweir 				_rpMaxValuePropertyName = PROPERTY_SCROLLVALUE_MAX;
130*cdf0e10cSrcweir 				break;
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir             case FormComponentType::SPINBUTTON:
133*cdf0e10cSrcweir 				_rpMinValuePropertyName = PROPERTY_SPINVALUE_MIN;
134*cdf0e10cSrcweir 				_rpMaxValuePropertyName = PROPERTY_SPINVALUE_MAX;
135*cdf0e10cSrcweir 				break;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir             default:
138*cdf0e10cSrcweir                 OSL_ENSURE( false, "OValuePropertiesMetaData::getValueLimitPropertyNames: unsupported component type!" );
139*cdf0e10cSrcweir                 break;
140*cdf0e10cSrcweir 		}
141*cdf0e10cSrcweir 	}
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	//---------------------------------------------------------------------
144*cdf0e10cSrcweir 	void OValuePropertiesMetaData::getRuntimeValuePropertyNames(
145*cdf0e10cSrcweir 		OControlElement::ElementType _eType, sal_Int16 _nFormComponentType,
146*cdf0e10cSrcweir 		sal_Char const * & _rpValuePropertyName, sal_Char const * & _rpDefaultValuePropertyName )
147*cdf0e10cSrcweir 	{
148*cdf0e10cSrcweir 		// reset the pointers in case we can't determine the property names
149*cdf0e10cSrcweir 		_rpValuePropertyName = _rpDefaultValuePropertyName = NULL;
150*cdf0e10cSrcweir 		switch (_nFormComponentType)
151*cdf0e10cSrcweir 		{
152*cdf0e10cSrcweir 			case FormComponentType::TEXTFIELD:
153*cdf0e10cSrcweir 				if (OControlElement::FORMATTED_TEXT == _eType)
154*cdf0e10cSrcweir 				{
155*cdf0e10cSrcweir 					_rpValuePropertyName = PROPERTY_EFFECTIVE_VALUE;
156*cdf0e10cSrcweir 					_rpDefaultValuePropertyName = PROPERTY_EFFECTIVE_DEFAULT;
157*cdf0e10cSrcweir 				}
158*cdf0e10cSrcweir 				else
159*cdf0e10cSrcweir 				{
160*cdf0e10cSrcweir 					_rpValuePropertyName = PROPERTY_TEXT;
161*cdf0e10cSrcweir 					_rpDefaultValuePropertyName = PROPERTY_DEFAULT_TEXT;
162*cdf0e10cSrcweir 				}
163*cdf0e10cSrcweir 				break;
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 			case FormComponentType::DATEFIELD:
166*cdf0e10cSrcweir 				_rpValuePropertyName = PROPERTY_DATE;
167*cdf0e10cSrcweir 				_rpDefaultValuePropertyName = PROPERTY_DEFAULT_DATE;
168*cdf0e10cSrcweir                 break;
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 			case FormComponentType::TIMEFIELD:
171*cdf0e10cSrcweir 				_rpValuePropertyName = PROPERTY_TIME;
172*cdf0e10cSrcweir 				_rpDefaultValuePropertyName = PROPERTY_DEFAULT_TIME;
173*cdf0e10cSrcweir                 break;
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 			case FormComponentType::NUMERICFIELD:
176*cdf0e10cSrcweir 			case FormComponentType::CURRENCYFIELD:
177*cdf0e10cSrcweir 			case FormComponentType::PATTERNFIELD:
178*cdf0e10cSrcweir 			case FormComponentType::FILECONTROL:
179*cdf0e10cSrcweir 			case FormComponentType::COMBOBOX:
180*cdf0e10cSrcweir             case FormComponentType::SCROLLBAR:
181*cdf0e10cSrcweir             case FormComponentType::SPINBUTTON:
182*cdf0e10cSrcweir 				// For these types, the runtime properties are the same as the ones which in the XML
183*cdf0e10cSrcweir 				// stream are named "value properties"
184*cdf0e10cSrcweir 				getValuePropertyNames( _eType, _nFormComponentType, _rpValuePropertyName, _rpDefaultValuePropertyName );
185*cdf0e10cSrcweir 				break;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 			case FormComponentType::CHECKBOX:
188*cdf0e10cSrcweir 			case FormComponentType::RADIOBUTTON:
189*cdf0e10cSrcweir 				_rpValuePropertyName = PROPERTY_STATE;
190*cdf0e10cSrcweir 				_rpDefaultValuePropertyName = PROPERTY_DEFAULT_STATE;
191*cdf0e10cSrcweir 				break;
192*cdf0e10cSrcweir 		}
193*cdf0e10cSrcweir 	}
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir //.........................................................................
196*cdf0e10cSrcweir }	// namespace xmloff
197*cdf0e10cSrcweir //.........................................................................
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir 
200