Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "valueproperties.hxx"
21 : #include "strings.hxx"
22 : #include <com/sun/star/form/FormComponentType.hpp>
23 : #include <sal/log.hxx>
24 :
25 : //.........................................................................
26 : namespace xmloff
27 : {
28 : //.........................................................................
29 :
30 : using namespace ::com::sun::star::form;
31 :
32 : //=====================================================================
33 : //= OValuePropertiesMetaData
34 : //=====================================================================
35 : //---------------------------------------------------------------------
36 1 : void OValuePropertiesMetaData::getValuePropertyNames(
37 : OControlElement::ElementType _eType, sal_Int16 _nFormComponentType,
38 : sal_Char const * & _rpCurrentValuePropertyName, sal_Char const * & _rpValuePropertyName)
39 : {
40 : // reset the pointers in case we can't determine the property names
41 1 : _rpCurrentValuePropertyName = _rpValuePropertyName = NULL;
42 1 : switch (_nFormComponentType)
43 : {
44 : case FormComponentType::TEXTFIELD:
45 1 : if (OControlElement::FORMATTED_TEXT == _eType)
46 : {
47 0 : _rpCurrentValuePropertyName = PROPERTY_EFFECTIVE_VALUE;
48 0 : _rpValuePropertyName = PROPERTY_EFFECTIVE_DEFAULT;
49 : }
50 : else
51 : {
52 1 : if (OControlElement::PASSWORD != _eType)
53 : // no CurrentValue" for passwords
54 1 : _rpCurrentValuePropertyName = PROPERTY_TEXT;
55 1 : _rpValuePropertyName = PROPERTY_DEFAULT_TEXT;
56 : }
57 1 : break;
58 :
59 : case FormComponentType::NUMERICFIELD:
60 : case FormComponentType::CURRENCYFIELD:
61 0 : _rpCurrentValuePropertyName = PROPERTY_VALUE;
62 0 : _rpValuePropertyName = PROPERTY_DEFAULT_VALUE;
63 0 : break;
64 :
65 : case FormComponentType::PATTERNFIELD:
66 : case FormComponentType::FILECONTROL:
67 : case FormComponentType::COMBOBOX:
68 0 : _rpValuePropertyName = PROPERTY_DEFAULT_TEXT;
69 : // NO BREAK!!
70 : case FormComponentType::COMMANDBUTTON:
71 0 : _rpCurrentValuePropertyName = PROPERTY_TEXT;
72 0 : break;
73 :
74 : case FormComponentType::CHECKBOX:
75 : case FormComponentType::RADIOBUTTON:
76 0 : _rpValuePropertyName = PROPERTY_REFVALUE;
77 0 : break;
78 :
79 : case FormComponentType::HIDDENCONTROL:
80 0 : _rpValuePropertyName = PROPERTY_HIDDEN_VALUE;
81 0 : break;
82 :
83 : case FormComponentType::SCROLLBAR:
84 0 : _rpCurrentValuePropertyName = PROPERTY_SCROLLVALUE;
85 0 : _rpValuePropertyName = PROPERTY_SCROLLVALUE_DEFAULT;
86 0 : break;
87 :
88 : case FormComponentType::SPINBUTTON:
89 0 : _rpCurrentValuePropertyName = PROPERTY_SPINVALUE;
90 0 : _rpValuePropertyName = PROPERTY_DEFAULT_SPINVALUE;
91 0 : break;
92 :
93 : default:
94 : SAL_WARN( "xmloff", "OValuePropertiesMetaData::getValuePropertyNames: unsupported component type!" );
95 0 : break;
96 : }
97 1 : }
98 :
99 :
100 : //---------------------------------------------------------------------
101 0 : void OValuePropertiesMetaData::getValueLimitPropertyNames(sal_Int16 _nFormComponentType,
102 : sal_Char const * & _rpMinValuePropertyName, sal_Char const * & _rpMaxValuePropertyName)
103 : {
104 0 : _rpMinValuePropertyName = _rpMaxValuePropertyName = NULL;
105 0 : switch (_nFormComponentType)
106 : {
107 : case FormComponentType::NUMERICFIELD:
108 : case FormComponentType::CURRENCYFIELD:
109 0 : _rpMinValuePropertyName = PROPERTY_VALUE_MIN;
110 0 : _rpMaxValuePropertyName = PROPERTY_VALUE_MAX;
111 0 : break;
112 :
113 : case FormComponentType::TEXTFIELD:
114 0 : _rpMinValuePropertyName = PROPERTY_EFFECTIVE_MIN;
115 0 : _rpMaxValuePropertyName = PROPERTY_EFFECTIVE_MAX;
116 0 : break;
117 :
118 : case FormComponentType::SCROLLBAR:
119 0 : _rpMinValuePropertyName = PROPERTY_SCROLLVALUE_MIN;
120 0 : _rpMaxValuePropertyName = PROPERTY_SCROLLVALUE_MAX;
121 0 : break;
122 :
123 : case FormComponentType::SPINBUTTON:
124 0 : _rpMinValuePropertyName = PROPERTY_SPINVALUE_MIN;
125 0 : _rpMaxValuePropertyName = PROPERTY_SPINVALUE_MAX;
126 0 : break;
127 :
128 : default:
129 : SAL_WARN("xmloff", "OValuePropertiesMetaData::getValueLimitPropertyNames: unsupported component type!" );
130 0 : break;
131 : }
132 0 : }
133 :
134 : //---------------------------------------------------------------------
135 28 : void OValuePropertiesMetaData::getRuntimeValuePropertyNames(
136 : OControlElement::ElementType _eType, sal_Int16 _nFormComponentType,
137 : sal_Char const * & _rpValuePropertyName, sal_Char const * & _rpDefaultValuePropertyName )
138 : {
139 : // reset the pointers in case we can't determine the property names
140 28 : _rpValuePropertyName = _rpDefaultValuePropertyName = NULL;
141 28 : switch (_nFormComponentType)
142 : {
143 : case FormComponentType::TEXTFIELD:
144 6 : if (OControlElement::FORMATTED_TEXT == _eType)
145 : {
146 0 : _rpValuePropertyName = PROPERTY_EFFECTIVE_VALUE;
147 0 : _rpDefaultValuePropertyName = PROPERTY_EFFECTIVE_DEFAULT;
148 : }
149 : else
150 : {
151 6 : _rpValuePropertyName = PROPERTY_TEXT;
152 6 : _rpDefaultValuePropertyName = PROPERTY_DEFAULT_TEXT;
153 : }
154 6 : break;
155 :
156 : case FormComponentType::DATEFIELD:
157 0 : _rpValuePropertyName = PROPERTY_DATE;
158 0 : _rpDefaultValuePropertyName = PROPERTY_DEFAULT_DATE;
159 0 : break;
160 :
161 : case FormComponentType::TIMEFIELD:
162 0 : _rpValuePropertyName = PROPERTY_TIME;
163 0 : _rpDefaultValuePropertyName = PROPERTY_DEFAULT_TIME;
164 0 : break;
165 :
166 : case FormComponentType::NUMERICFIELD:
167 : case FormComponentType::CURRENCYFIELD:
168 : case FormComponentType::PATTERNFIELD:
169 : case FormComponentType::FILECONTROL:
170 : case FormComponentType::COMBOBOX:
171 : case FormComponentType::SCROLLBAR:
172 : case FormComponentType::SPINBUTTON:
173 : // For these types, the runtime properties are the same as the ones which in the XML
174 : // stream are named "value properties"
175 0 : getValuePropertyNames( _eType, _nFormComponentType, _rpValuePropertyName, _rpDefaultValuePropertyName );
176 0 : break;
177 :
178 : case FormComponentType::CHECKBOX:
179 : case FormComponentType::RADIOBUTTON:
180 10 : _rpValuePropertyName = PROPERTY_STATE;
181 10 : _rpDefaultValuePropertyName = PROPERTY_DEFAULT_STATE;
182 10 : break;
183 : }
184 28 : }
185 :
186 : //.........................................................................
187 : } // namespace xmloff
188 : //.........................................................................
189 :
190 :
191 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|