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 .
19 #ifndef INCLUDED_SW_INC_FLDDROPDOWN_HXX
20 #define INCLUDED_SW_INC_FLDDROPDOWN_HXX
22 #include <com/sun/star/uno/Sequence.hxx>
29 Field type for dropdown boxes.
31 class SwDropDownFieldType
: public SwFieldType
37 SwDropDownFieldType();
42 virtual ~SwDropDownFieldType();
45 Create a copy of this field type.
47 @return a copy of this type
49 virtual SwFieldType
* Copy () const SAL_OVERRIDE
;
55 The dropdown field contains a list of strings. At most one of them
58 class SW_DLLPUBLIC SwDropDownField
: public SwField
61 the possible values (aka items) of the dropdown box
63 std::vector
<OUString
> aValues
;
68 OUString aSelectedItem
;
88 The expanded value of the field is the value of the selected
89 item. If no item is selected, an empty string is returned.
91 @return the expanded value of the field
93 virtual OUString
Expand() const SAL_OVERRIDE
;
96 Creates a copy of this field.
98 @return the copy of this field
100 virtual SwField
* Copy() const SAL_OVERRIDE
;
106 @param pTyp field type for this field
108 SwDropDownField(SwFieldType
* pTyp
);
113 @param rSrc dropdown field to copy
115 SwDropDownField(const SwDropDownField
& rSrc
);
120 virtual ~SwDropDownField();
123 Returns the selected value.
127 @return the selected value
129 virtual OUString
GetPar1() const SAL_OVERRIDE
;
132 Returns the name of the field.
134 @return the name of the field
136 virtual OUString
GetPar2() const SAL_OVERRIDE
;
139 Sets the selected value.
141 If rStr is an item of the field that item will be
142 selected. Otherwise no item will be selected, i.e. the
143 resulting selection will be empty.
145 virtual void SetPar1(const OUString
& rStr
) SAL_OVERRIDE
;
148 Sets the name of the field.
150 @param rStr the new name of the field
152 virtual void SetPar2(const OUString
& rStr
) SAL_OVERRIDE
;
155 Sets the items of the dropdown box.
157 After setting the items the selection will be empty.
159 @param rItems the new items
161 void SetItems(const std::vector
<OUString
> & rItems
);
164 Sets the items of the dropdown box.
166 After setting the items the selection will be empty.
168 @param rItems the new items
170 void SetItems(const com::sun::star::uno::Sequence
<OUString
> & rItems
);
173 Returns the items of the dropdown box.
175 @return the items of the dropdown box
177 com::sun::star::uno::Sequence
<OUString
> GetItemSequence() const;
180 Returns the selected item.
182 @return the selected item
184 const OUString
& GetSelectedItem() const { return aSelectedItem
;}
187 Returns the name of the field.
189 @return the name of the field
191 const OUString
& GetName() const { return aName
;}
194 Returns the help text of the field.
196 @return the help text of the field
198 const OUString
& GetHelp() const { return aHelp
;}
201 Returns the tool tip of the field.
203 @return the tool tip of the field
205 const OUString
& GetToolTip() const { return aToolTip
;}
208 Sets the selected item.
210 If rItem is found in this dropdown field it is selected. If
211 rItem is not found the selection will be empty.
213 @param rItem the item to be set
215 @retval true the selected item was successfully set
216 @retval false failure (empty selection)
218 bool SetSelectedItem(const OUString
& rItem
);
221 Sets the name of the field.
223 @param rName the new name of the field
225 void SetName(const OUString
& rName
);
228 Sets the help text of the field.
230 @param rHelp the help text
232 void SetHelp(const OUString
& rHelp
);
235 Sets the tool tip of the field.
237 @param rToolTip the tool tip
239 void SetToolTip(const OUString
& rToolTip
);
242 API: Gets a property value from the dropdown field.
244 @param rVal return value
246 - FIELD_PROP_PAR1 Get selected item (String)
247 - FIELD_PROP_STRINGS Get all items (Sequence)
248 - FIELD_PROP_PAR3 Get the help text of the field.
249 - FIELD_PROP_PAR4 Get the tool tip of the field.
251 virtual bool QueryValue(com::sun::star::uno::Any
&rVal
, sal_uInt16 nWhichId
) const SAL_OVERRIDE
;
254 API: Sets a property value on the dropdown field.
256 @param rVal value to set
258 - FIELD_PROP_PAR1 Set selected item (String)
259 - FIELD_PROP_STRINGS Set all items (Sequence)
260 - FIELD_PROP_PAR3 Set the help text of the field.
261 - FIELD_PROP_PAR4 Set the tool tip of the field.
263 virtual bool PutValue(const com::sun::star::uno::Any
&rVal
, sal_uInt16 nWhichId
) SAL_OVERRIDE
;
268 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */