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