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