xref: /aoo41x/main/sw/inc/flddropdown.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef SW_FLDDROPDOWN_HXX
24cdf0e10cSrcweir #define SW_FLDDROPDOWN_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx"
27cdf0e10cSrcweir #include "swdllapi.h"
28cdf0e10cSrcweir #include "fldbas.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <vector>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir /**
33cdf0e10cSrcweir     Field type for dropdown boxes.
34cdf0e10cSrcweir */
35cdf0e10cSrcweir class SwDropDownFieldType : public SwFieldType
36cdf0e10cSrcweir {
37cdf0e10cSrcweir public:
38cdf0e10cSrcweir     /**
39cdf0e10cSrcweir        Constructor
40cdf0e10cSrcweir     */
41cdf0e10cSrcweir     SwDropDownFieldType();
42cdf0e10cSrcweir 
43cdf0e10cSrcweir     /**
44cdf0e10cSrcweir        Destructor
45cdf0e10cSrcweir     */
46cdf0e10cSrcweir     virtual ~SwDropDownFieldType();
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     /**
49cdf0e10cSrcweir        Create a copy of this field type.
50cdf0e10cSrcweir 
51cdf0e10cSrcweir        @return a copy of this type
52cdf0e10cSrcweir     */
53cdf0e10cSrcweir     virtual SwFieldType * Copy () const;
54cdf0e10cSrcweir };
55cdf0e10cSrcweir 
56cdf0e10cSrcweir /**
57cdf0e10cSrcweir    Dropdown field.
58cdf0e10cSrcweir 
59cdf0e10cSrcweir    The dropdown field contains a list of strings. At most one of them
60cdf0e10cSrcweir    can be selected.
61cdf0e10cSrcweir */
62cdf0e10cSrcweir class SW_DLLPUBLIC SwDropDownField : public SwField
63cdf0e10cSrcweir {
64cdf0e10cSrcweir     /**
65cdf0e10cSrcweir        the possible values (aka items) of the dropdown box
66cdf0e10cSrcweir     */
67cdf0e10cSrcweir     std::vector<String> aValues;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     /**
70cdf0e10cSrcweir       the selected item
71cdf0e10cSrcweir     */
72cdf0e10cSrcweir     String aSelectedItem;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     /**
75cdf0e10cSrcweir       the name of the field
76cdf0e10cSrcweir     */
77cdf0e10cSrcweir     String aName;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     /**
80cdf0e10cSrcweir        help text
81cdf0e10cSrcweir      */
82cdf0e10cSrcweir     String aHelp;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     /**
85cdf0e10cSrcweir        tool tip string
86cdf0e10cSrcweir      */
87cdf0e10cSrcweir     String aToolTip;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     /**
90cdf0e10cSrcweir        Expands the field.
91cdf0e10cSrcweir 
92cdf0e10cSrcweir        The expanded value of the field is the value of the selected
93cdf0e10cSrcweir        item. If no item is selected, an empty string is returned.
94cdf0e10cSrcweir 
95cdf0e10cSrcweir        @return the expanded value of the field
96cdf0e10cSrcweir     */
97cdf0e10cSrcweir     virtual String Expand() const;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     /**
100cdf0e10cSrcweir        Creates a copy of this field.
101cdf0e10cSrcweir 
102cdf0e10cSrcweir        @return the copy of this field
103cdf0e10cSrcweir     */
104cdf0e10cSrcweir     virtual SwField * Copy() const;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir public:
107cdf0e10cSrcweir     /**
108cdf0e10cSrcweir        Constructor
109cdf0e10cSrcweir 
110cdf0e10cSrcweir        @param pTyp field type for this field
111cdf0e10cSrcweir     */
112cdf0e10cSrcweir     SwDropDownField(SwFieldType * pTyp);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     /**
115cdf0e10cSrcweir        Copy constructor
116cdf0e10cSrcweir 
117cdf0e10cSrcweir        @param rSrc dropdown field to copy
118cdf0e10cSrcweir     */
119cdf0e10cSrcweir     SwDropDownField(const SwDropDownField & rSrc);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     /**
122cdf0e10cSrcweir        Destructor
123cdf0e10cSrcweir     */
124cdf0e10cSrcweir     virtual ~SwDropDownField();
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     /**
127cdf0e10cSrcweir        Returns the selected value.
128cdf0e10cSrcweir 
129cdf0e10cSrcweir        @see Expand
130cdf0e10cSrcweir 
131cdf0e10cSrcweir        @return the selected value
132cdf0e10cSrcweir     */
133cdf0e10cSrcweir     virtual const String & GetPar1() const;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     /**
136cdf0e10cSrcweir        Returns the name of the field.
137cdf0e10cSrcweir 
138cdf0e10cSrcweir        @return the name of the field
139cdf0e10cSrcweir     */
140cdf0e10cSrcweir     virtual String GetPar2() const;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     /**
143cdf0e10cSrcweir        Sets the selected value.
144cdf0e10cSrcweir 
145cdf0e10cSrcweir        If rStr is an item of the field that item will be
146cdf0e10cSrcweir        selected. Otherwise no item will be selected, i.e. the
147cdf0e10cSrcweir        resulting selection will be empty.
148cdf0e10cSrcweir     */
149cdf0e10cSrcweir     virtual void SetPar1(const String & rStr);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     /**
152cdf0e10cSrcweir        Sets the name of the field.
153cdf0e10cSrcweir 
154cdf0e10cSrcweir        @param rStr the new name of the field
155cdf0e10cSrcweir     */
156cdf0e10cSrcweir     virtual void SetPar2(const String & rStr);
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     /**
159cdf0e10cSrcweir        Sets the items of the dropdown box.
160cdf0e10cSrcweir 
161cdf0e10cSrcweir        After setting the items the selection will be empty.
162cdf0e10cSrcweir 
163cdf0e10cSrcweir        @param rItems the new items
164cdf0e10cSrcweir     */
165cdf0e10cSrcweir     void SetItems(const std::vector<String> & rItems);
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     /**
168cdf0e10cSrcweir        Sets the items of the dropdown box.
169cdf0e10cSrcweir 
170cdf0e10cSrcweir        After setting the items the selection will be empty.
171cdf0e10cSrcweir 
172cdf0e10cSrcweir        @param rItems the new items
173cdf0e10cSrcweir     */
174cdf0e10cSrcweir     void SetItems(const com::sun::star::uno::Sequence<rtl::OUString> & rItems);
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     /**
177cdf0e10cSrcweir         Returns the items of the dropdown box.
178cdf0e10cSrcweir 
179cdf0e10cSrcweir         @return the items of the dropdown box
180cdf0e10cSrcweir     */
181cdf0e10cSrcweir     com::sun::star::uno::Sequence<rtl::OUString> GetItemSequence() const;
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     /**
184cdf0e10cSrcweir        Returns the selected item.
185cdf0e10cSrcweir 
186cdf0e10cSrcweir        @return the selected item
187cdf0e10cSrcweir     */
188cdf0e10cSrcweir     const String & GetSelectedItem() const;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     /**
191cdf0e10cSrcweir        Returns the name of the field.
192cdf0e10cSrcweir 
193cdf0e10cSrcweir        @return the name of the field
194cdf0e10cSrcweir     */
195cdf0e10cSrcweir     const String & GetName() const;
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     /**
198cdf0e10cSrcweir        Returns the help text of the field.
199cdf0e10cSrcweir 
200cdf0e10cSrcweir        @return the help text of the field
201cdf0e10cSrcweir     */
202cdf0e10cSrcweir     const String & GetHelp() const;
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     /**
205cdf0e10cSrcweir        Returns the tool tip of the field.
206cdf0e10cSrcweir 
207cdf0e10cSrcweir        @return the tool tip of the field
208cdf0e10cSrcweir      */
209cdf0e10cSrcweir     const String & GetToolTip() const;
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     /**
212cdf0e10cSrcweir        Sets the selected item.
213cdf0e10cSrcweir 
214cdf0e10cSrcweir        If rItem is found in this dropdown field it is selected. If
215cdf0e10cSrcweir        rItem is not found the selection will be empty.
216cdf0e10cSrcweir 
217cdf0e10cSrcweir        @param rItem the item to be set
218cdf0e10cSrcweir 
219cdf0e10cSrcweir        @retval sal_True the selected item was successfully set
220cdf0e10cSrcweir        @retval sal_True failure (empty selection)
221cdf0e10cSrcweir     */
222cdf0e10cSrcweir     sal_Bool SetSelectedItem(const String & rItem);
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     /**
225cdf0e10cSrcweir        Sets the name of the field.
226cdf0e10cSrcweir 
227cdf0e10cSrcweir        @param rName the new name of the field
228cdf0e10cSrcweir     */
229cdf0e10cSrcweir     void SetName(const String & rName);
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     /**
232cdf0e10cSrcweir        Sets the help text of the field.
233cdf0e10cSrcweir 
234cdf0e10cSrcweir        @param rHelp    the help text
235cdf0e10cSrcweir     */
236cdf0e10cSrcweir     void SetHelp(const String & rHelp);
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     /**
239cdf0e10cSrcweir        Sets the tool tip of the field.
240cdf0e10cSrcweir 
241cdf0e10cSrcweir        @param rToolTip  the tool tip
242cdf0e10cSrcweir     */
243cdf0e10cSrcweir     void SetToolTip(const String & rToolTip);
244cdf0e10cSrcweir 
245cdf0e10cSrcweir     /**
246cdf0e10cSrcweir        API: Gets a property value from the dropdown field.
247cdf0e10cSrcweir 
248cdf0e10cSrcweir        @param rVal return value
249cdf0e10cSrcweir        @param nMId
250cdf0e10cSrcweir           - FIELD_PROP_PAR1 Get selected item (String)
251cdf0e10cSrcweir           - FIELD_PROP_STRINGS Get all items (Sequence)
252cdf0e10cSrcweir           - FIELD_PROP_PAR3 Get the help text of the field.
253cdf0e10cSrcweir           - FIELD_PROP_PAR4 Get the tool tip of the field.
254cdf0e10cSrcweir     */
255cdf0e10cSrcweir     virtual sal_Bool QueryValue(com::sun::star::uno::Any &rVal, sal_uInt16 nWhichId) const;
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     /**
258cdf0e10cSrcweir        API: Sets a property value on the dropdown field.
259cdf0e10cSrcweir 
260cdf0e10cSrcweir        @param rVal value to set
261cdf0e10cSrcweir        @param nMId
262cdf0e10cSrcweir           - FIELD_PROP_PAR1 Set selected item (String)
263cdf0e10cSrcweir           - FIELD_PROP_STRINGS Set all items (Sequence)
264cdf0e10cSrcweir           - FIELD_PROP_PAR3  Set the help text of the field.
265cdf0e10cSrcweir           - FIELD_PROP_PAR4  Set the tool tip of the field.
266cdf0e10cSrcweir     */
267cdf0e10cSrcweir         virtual sal_Bool PutValue(const com::sun::star::uno::Any &rVal, sal_uInt16 nWhichId);
268cdf0e10cSrcweir };
269cdf0e10cSrcweir 
270cdf0e10cSrcweir #endif
271