merged tag ooo/OOO330_m14
[LibreOffice.git] / sw / inc / flddropdown.hxx
blob77963bf1510a562d859bd9dcd7780f916b9c8b1a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef _FLDDROPDOWN_HXX
28 #define _FLDDROPDOWN_HXX
30 #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX
31 #include "com/sun/star/uno/Sequence.hxx"
32 #endif
33 #include "swdllapi.h"
34 #include "fldbas.hxx"
36 #ifndef INCLUDED_VECTOR
37 #include <vector>
38 #define INCLUDED_VECTOR
39 #endif
41 /**
42 Field type for dropdown boxes.
44 class SwDropDownFieldType : public SwFieldType
46 public:
47 /**
48 Constructor
50 SwDropDownFieldType();
52 /**
53 Destructor
55 virtual ~SwDropDownFieldType();
57 /**
58 Create a copy of this field type.
60 @return a copy of this type
62 virtual SwFieldType * Copy () const;
65 /**
66 Dropdown field.
68 The dropdown field contains a list of strings. At most one of them
69 can be selected.
71 class SW_DLLPUBLIC SwDropDownField : public SwField
73 /**
74 the possible values (aka items) of the dropdown box
76 std::vector<String> aValues;
78 /**
79 the selected item
81 String aSelectedItem;
83 /**
84 the name of the field
86 String aName;
88 /**
89 help text
91 String aHelp;
93 /**
94 tool tip string
96 String aToolTip;
98 public:
99 /**
100 Constructor
102 @param pTyp field type for this field
104 SwDropDownField(SwFieldType * pTyp);
107 Copy constructor
109 @param rSrc dropdown field to copy
111 SwDropDownField(const SwDropDownField & rSrc);
114 Destructor
116 virtual ~SwDropDownField();
119 Expands the field.
121 The expanded value of the field is the value of the selected
122 item. If no item is selected, an empty string is returned.
124 @return the expanded value of the field
126 virtual String Expand() const;
129 Creates a copy of this field.
131 @return the copy of this field
133 virtual SwField * Copy() const;
136 Returns the selected value.
138 @see Expand
140 @return the selected value
142 virtual const String & GetPar1() const;
145 Returns the name of the field.
147 @return the name of the field
149 virtual String GetPar2() const;
152 Sets the selected value.
154 If rStr is an item of the field that item will be
155 selected. Otherwise no item will be selected, i.e. the
156 resulting selection will be empty.
158 virtual void SetPar1(const String & rStr);
161 Sets the name of the field.
163 @param rStr the new name of the field
165 virtual void SetPar2(const String & rStr);
168 Sets the items of the dropdown box.
170 After setting the items the selection will be empty.
172 @param rItems the new items
174 void SetItems(const std::vector<String> & rItems);
177 Sets the items of the dropdown box.
179 After setting the items the selection will be empty.
181 @param rItems the new items
183 void SetItems(const com::sun::star::uno::Sequence<rtl::OUString> & rItems);
186 Returns the items of the dropdown box.
188 @return the items of the dropdown box
190 com::sun::star::uno::Sequence<rtl::OUString> GetItemSequence() const;
193 Returns the selected item.
195 @return the selected item
197 const String & GetSelectedItem() const;
200 Returns the name of the field.
202 @return the name of the field
204 const String & GetName() const;
207 Returns the help text of the field.
209 @return the help text of the field
211 const String & GetHelp() const;
214 Returns the tool tip of the field.
216 @return the tool tip of the field
218 const String & GetToolTip() const;
221 Sets the selected item.
223 If rItem is found in this dropdown field it is selected. If
224 rItem is not found the selection will be empty.
226 @param rItem the item to be set
228 @retval TRUE the selected item was successfully set
229 @retval TRUE failure (empty selection)
231 BOOL SetSelectedItem(const String & rItem);
234 Sets the name of the field.
236 @param rName the new name of the field
238 void SetName(const String & rName);
241 Sets the help text of the field.
243 @param rHelp the help text
245 void SetHelp(const String & rHelp);
248 Sets the tool tip of the field.
250 @param rToolTip the tool tip
252 void SetToolTip(const String & rToolTip);
255 API: Gets a property value from the dropdown field.
257 @param rVal return value
258 @param nMId
259 - FIELD_PROP_PAR1 Get selected item (String)
260 - FIELD_PROP_STRINGS Get all items (Sequence)
261 - FIELD_PROP_PAR3 Get the help text of the field.
262 - FIELD_PROP_PAR4 Get the tool tip of the field.
264 virtual BOOL QueryValue(com::sun::star::uno::Any &rVal, USHORT nWhichId) const;
267 API: Sets a property value on the dropdown field.
269 @param rVal value to set
270 @param nMId
271 - FIELD_PROP_PAR1 Set selected item (String)
272 - FIELD_PROP_STRINGS Set all items (Sequence)
273 - FIELD_PROP_PAR3 Set the help text of the field.
274 - FIELD_PROP_PAR4 Set the tool tip of the field.
276 virtual BOOL PutValue(const com::sun::star::uno::Any &rVal, USHORT nWhichId);
279 #endif