1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: flddropdown.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _FLDDROPDOWN_HXX
31 #define _FLDDROPDOWN_HXX
33 #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX
34 #include "com/sun/star/uno/Sequence.hxx"
39 #ifndef INCLUDED_VECTOR
41 #define INCLUDED_VECTOR
45 Field type for dropdown boxes.
47 class SwDropDownFieldType
: public SwFieldType
53 SwDropDownFieldType();
58 virtual ~SwDropDownFieldType();
61 Create a copy of this field type.
63 @return a copy of this type
65 virtual SwFieldType
* Copy () const;
71 The dropdown field contains a list of strings. At most one of them
74 class SW_DLLPUBLIC SwDropDownField
: public SwField
77 the possible values (aka items) of the dropdown box
79 std::vector
<String
> aValues
;
105 @param pTyp field type for this field
107 SwDropDownField(SwFieldType
* pTyp
);
112 @param rSrc dropdown field to copy
114 SwDropDownField(const SwDropDownField
& rSrc
);
119 virtual ~SwDropDownField();
124 The expanded value of the field is the value of the selected
125 item. If no item is selected, an empty string is returned.
127 @return the expanded value of the field
129 virtual String
Expand() const;
132 Creates a copy of this field.
134 @return the copy of this field
136 virtual SwField
* Copy() const;
139 Returns the selected value.
143 @return the selected value
145 virtual const String
& GetPar1() const;
148 Returns the name of the field.
150 @return the name of the field
152 virtual String
GetPar2() const;
155 Sets the selected value.
157 If rStr is an item of the field that item will be
158 selected. Otherwise no item will be selected, i.e. the
159 resulting selection will be empty.
161 virtual void SetPar1(const String
& rStr
);
164 Sets the name of the field.
166 @param rStr the new name of the field
168 virtual void SetPar2(const String
& rStr
);
171 Sets the items of the dropdown box.
173 After setting the items the selection will be empty.
175 @param rItems the new items
177 void SetItems(const std::vector
<String
> & rItems
);
180 Sets the items of the dropdown box.
182 After setting the items the selection will be empty.
184 @param rItems the new items
186 void SetItems(const com::sun::star::uno::Sequence
<rtl::OUString
> & rItems
);
189 Returns the items of the dropdown box.
191 @return the items of the dropdown box
193 com::sun::star::uno::Sequence
<rtl::OUString
> GetItemSequence() const;
196 Returns the selected item.
198 @return the selected item
200 const String
& GetSelectedItem() const;
203 Returns the name of the field.
205 @return the name of the field
207 const String
& GetName() const;
210 Returns the help text of the field.
212 @return the help text of the field
214 const String
& GetHelp() const;
217 Returns the tool tip of the field.
219 @return the tool tip of the field
221 const String
& GetToolTip() const;
224 Sets the selected item.
226 If rItem is found in this dropdown field it is selected. If
227 rItem is not found the selection will be empty.
229 @param rItem the item to be set
231 @retval TRUE the selected item was successfully set
232 @retval TRUE failure (empty selection)
234 BOOL
SetSelectedItem(const String
& rItem
);
237 Sets the name of the field.
239 @param rName the new name of the field
241 void SetName(const String
& rName
);
244 Sets the help text of the field.
246 @param rHelp the help text
248 void SetHelp(const String
& rHelp
);
251 Sets the tool tip of the field.
253 @param rToolTip the tool tip
255 void SetToolTip(const String
& rToolTip
);
258 API: Gets a property value from the dropdown field.
260 @param rVal return value
262 - FIELD_PROP_PAR1 Get selected item (String)
263 - FIELD_PROP_STRINGS Get all items (Sequence)
264 - FIELD_PROP_PAR3 Get the help text of the field.
265 - FIELD_PROP_PAR4 Get the tool tip of the field.
267 virtual BOOL
QueryValue(com::sun::star::uno::Any
&rVal
, USHORT nWhichId
) const;
270 API: Sets a property value on the dropdown field.
272 @param rVal value to set
274 - FIELD_PROP_PAR1 Set selected item (String)
275 - FIELD_PROP_STRINGS Set all items (Sequence)
276 - FIELD_PROP_PAR3 Set the help text of the field.
277 - FIELD_PROP_PAR4 Set the tool tip of the field.
279 virtual BOOL
PutValue(const com::sun::star::uno::Any
&rVal
, USHORT nWhichId
);