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