Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sw / flddropdown.hxx
blob0bf7aedb9e7a719f9e619881cc080900a1a6f31e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: flddropdown.hxx,v $
10 * $Revision: 1.5 $
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 #include <com/sun/star/uno/Sequence.hxx>
34 #include <fldbas.hxx>
35 #include <vector>
36 namespace binfilter {
38 using namespace ::com::sun::star::uno;
39 using namespace ::rtl;
40 using namespace std;
42 /**
43 Field type for dropdown boxes.
45 class SwDropDownFieldType : public SwFieldType
47 public:
48 /**
49 Constructor
51 SwDropDownFieldType();
53 /**
54 Destructor
56 virtual ~SwDropDownFieldType();
58 /**
59 Create a copy of this field type.
61 @return a copy of this type
63 virtual SwFieldType * Copy () const;
66 /**
67 Dropdown field.
69 The dropdown field contains a list of strings. At most one of them
70 can be selected.
72 class SwDropDownField : public SwField
74 /**
75 the possible values (aka items) of the dropdown box
77 vector<String> aValues;
79 /**
80 the selected item
82 String aSelectedItem;
84 /**
85 the name of the field
87 String aName;
89 public:
90 /**
91 Constructor
93 @param pTyp field type for this field
95 SwDropDownField(SwFieldType * pTyp);
97 /**
98 Copy constructor
100 @param rSrc dropdown field to copy
102 SwDropDownField(const SwDropDownField & rSrc);
105 Destructor
107 virtual ~SwDropDownField();
110 Expands the field.
112 The expanded value of the field is the value of the selected
113 item. If no item is selected, an empty string is returned.
115 @return the expanded value of the field
117 virtual String Expand() const;
120 Creates a copy of this field.
122 @return the copy of this field
124 virtual SwField * Copy() const;
127 Returns the selected value.
129 @see Expand
131 @return the selected value
133 virtual const String & GetPar1() const;
136 Returns the name of the field.
138 @return the name of the field
140 virtual String GetPar2() const;
143 Sets the selected value.
145 If rStr is an item of the field that item will be
146 selected. Otherwise no item will be selected, i.e. the
147 resulting selection will be empty.
149 virtual void SetPar1(const String & rStr);
152 Sets the name of the field.
154 @param rStr the new name of the field
156 virtual void SetPar2(const String & rStr);
159 Sets the items of the dropdown box.
161 After setting the items the selection will be empty.
163 @param rItems the new items
165 void SetItems(const Sequence<OUString> & rItems);
167 /**
168 Returns the items of the dropdown box.
170 @return the items of the dropdown box
172 Sequence<OUString> GetItemSequence() const;
175 Returns the selected item.
177 @return the selected item
179 const String & GetSelectedItem() const;
182 Returns the name of the field.
184 @return the name of the field
186 const String & GetName() const;
189 Sets the selected item.
191 If rItem is found in this dropdown field it is selected. If
192 rItem is not found the selection will be empty.
194 @param rItem the item to be set
196 @retval TRUE the selected item was successfully set
197 @retval TRUE failure (empty selection)
199 BOOL SetSelectedItem(const String & rItem);
202 Sets the name of the field.
204 @param rName the new name of the field
206 void SetName(const String & rName);
209 API: Gets a property value from the dropdown field.
211 @param rVal return value
212 @param nMId
213 - FIELD_PROP_PAR1 Get selected item (String)
214 - FIELD_PROP_STRINGS Get all items (Sequence)
216 virtual BOOL QueryValue(Any &rVal, BYTE nMId) const;
219 API: Sets a property value on the dropdown field.
221 @param rVal value to set
222 @param nMId
223 - FIELD_PROP_PAR1 Set selected item (String)
224 - FIELD_PROP_STRINGS Set all items (Sequence)
226 virtual BOOL PutValue(const Any &rVal, BYTE nMId);
229 } //namespace binfilter
230 #endif