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