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