1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "valueproperties.hxx"
21 #include "strings.hxx"
22 #include <com/sun/star/form/FormComponentType.hpp>
23 #include <sal/log.hxx>
25 //.........................................................................
28 //.........................................................................
30 using namespace ::com::sun::star::form
;
32 //=====================================================================
33 //= OValuePropertiesMetaData
34 //=====================================================================
35 //---------------------------------------------------------------------
36 void OValuePropertiesMetaData::getValuePropertyNames(
37 OControlElement::ElementType _eType
, sal_Int16 _nFormComponentType
,
38 sal_Char
const * & _rpCurrentValuePropertyName
, sal_Char
const * & _rpValuePropertyName
)
40 // reset the pointers in case we can't determine the property names
41 _rpCurrentValuePropertyName
= _rpValuePropertyName
= NULL
;
42 switch (_nFormComponentType
)
44 case FormComponentType::TEXTFIELD
:
45 if (OControlElement::FORMATTED_TEXT
== _eType
)
47 _rpCurrentValuePropertyName
= PROPERTY_EFFECTIVE_VALUE
;
48 _rpValuePropertyName
= PROPERTY_EFFECTIVE_DEFAULT
;
52 if (OControlElement::PASSWORD
!= _eType
)
53 // no CurrentValue" for passwords
54 _rpCurrentValuePropertyName
= PROPERTY_TEXT
;
55 _rpValuePropertyName
= PROPERTY_DEFAULT_TEXT
;
59 case FormComponentType::NUMERICFIELD
:
60 case FormComponentType::CURRENCYFIELD
:
61 _rpCurrentValuePropertyName
= PROPERTY_VALUE
;
62 _rpValuePropertyName
= PROPERTY_DEFAULT_VALUE
;
65 case FormComponentType::PATTERNFIELD
:
66 case FormComponentType::FILECONTROL
:
67 case FormComponentType::COMBOBOX
:
68 _rpValuePropertyName
= PROPERTY_DEFAULT_TEXT
;
70 case FormComponentType::COMMANDBUTTON
:
71 _rpCurrentValuePropertyName
= PROPERTY_TEXT
;
74 case FormComponentType::CHECKBOX
:
75 case FormComponentType::RADIOBUTTON
:
76 _rpValuePropertyName
= PROPERTY_REFVALUE
;
79 case FormComponentType::HIDDENCONTROL
:
80 _rpValuePropertyName
= PROPERTY_HIDDEN_VALUE
;
83 case FormComponentType::SCROLLBAR
:
84 _rpCurrentValuePropertyName
= PROPERTY_SCROLLVALUE
;
85 _rpValuePropertyName
= PROPERTY_SCROLLVALUE_DEFAULT
;
88 case FormComponentType::SPINBUTTON
:
89 _rpCurrentValuePropertyName
= PROPERTY_SPINVALUE
;
90 _rpValuePropertyName
= PROPERTY_DEFAULT_SPINVALUE
;
94 SAL_WARN( "xmloff", "OValuePropertiesMetaData::getValuePropertyNames: unsupported component type!" );
100 //---------------------------------------------------------------------
101 void OValuePropertiesMetaData::getValueLimitPropertyNames(sal_Int16 _nFormComponentType
,
102 sal_Char
const * & _rpMinValuePropertyName
, sal_Char
const * & _rpMaxValuePropertyName
)
104 _rpMinValuePropertyName
= _rpMaxValuePropertyName
= NULL
;
105 switch (_nFormComponentType
)
107 case FormComponentType::NUMERICFIELD
:
108 case FormComponentType::CURRENCYFIELD
:
109 _rpMinValuePropertyName
= PROPERTY_VALUE_MIN
;
110 _rpMaxValuePropertyName
= PROPERTY_VALUE_MAX
;
113 case FormComponentType::TEXTFIELD
:
114 _rpMinValuePropertyName
= PROPERTY_EFFECTIVE_MIN
;
115 _rpMaxValuePropertyName
= PROPERTY_EFFECTIVE_MAX
;
118 case FormComponentType::SCROLLBAR
:
119 _rpMinValuePropertyName
= PROPERTY_SCROLLVALUE_MIN
;
120 _rpMaxValuePropertyName
= PROPERTY_SCROLLVALUE_MAX
;
123 case FormComponentType::SPINBUTTON
:
124 _rpMinValuePropertyName
= PROPERTY_SPINVALUE_MIN
;
125 _rpMaxValuePropertyName
= PROPERTY_SPINVALUE_MAX
;
129 SAL_WARN("xmloff", "OValuePropertiesMetaData::getValueLimitPropertyNames: unsupported component type!" );
134 //---------------------------------------------------------------------
135 void OValuePropertiesMetaData::getRuntimeValuePropertyNames(
136 OControlElement::ElementType _eType
, sal_Int16 _nFormComponentType
,
137 sal_Char
const * & _rpValuePropertyName
, sal_Char
const * & _rpDefaultValuePropertyName
)
139 // reset the pointers in case we can't determine the property names
140 _rpValuePropertyName
= _rpDefaultValuePropertyName
= NULL
;
141 switch (_nFormComponentType
)
143 case FormComponentType::TEXTFIELD
:
144 if (OControlElement::FORMATTED_TEXT
== _eType
)
146 _rpValuePropertyName
= PROPERTY_EFFECTIVE_VALUE
;
147 _rpDefaultValuePropertyName
= PROPERTY_EFFECTIVE_DEFAULT
;
151 _rpValuePropertyName
= PROPERTY_TEXT
;
152 _rpDefaultValuePropertyName
= PROPERTY_DEFAULT_TEXT
;
156 case FormComponentType::DATEFIELD
:
157 _rpValuePropertyName
= PROPERTY_DATE
;
158 _rpDefaultValuePropertyName
= PROPERTY_DEFAULT_DATE
;
161 case FormComponentType::TIMEFIELD
:
162 _rpValuePropertyName
= PROPERTY_TIME
;
163 _rpDefaultValuePropertyName
= PROPERTY_DEFAULT_TIME
;
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 getValuePropertyNames( _eType
, _nFormComponentType
, _rpValuePropertyName
, _rpDefaultValuePropertyName
);
178 case FormComponentType::CHECKBOX
:
179 case FormComponentType::RADIOBUTTON
:
180 _rpValuePropertyName
= PROPERTY_STATE
;
181 _rpDefaultValuePropertyName
= PROPERTY_DEFAULT_STATE
;
186 //.........................................................................
187 } // namespace xmloff
188 //.........................................................................
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */