1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SW_INC_FLDDROPDOWN_HXX
20 #define INCLUDED_SW_INC_FLDDROPDOWN_HXX
22 #include <com/sun/star/uno/Sequence.h>
29 Field type for dropdown boxes.
31 class SAL_DLLPUBLIC_RTTI SwDropDownFieldType final
: public SwFieldType
37 SwDropDownFieldType();
42 virtual ~SwDropDownFieldType() override
;
45 Create a copy of this field type.
47 @return a copy of this type
49 virtual std::unique_ptr
<SwFieldType
> Copy() const override
;
55 The dropdown field contains a list of strings. At most one of them
58 class SW_DLLPUBLIC SwDropDownField final
: public SwField
61 the possible values (aka items) of the dropdown box
63 std::vector
<OUString
> m_aValues
;
68 OUString m_aSelectedItem
;
88 The expanded value of the field is the value of the selected
89 item. If no item is selected, an empty string is returned.
91 @return the expanded value of the field
93 virtual OUString
ExpandImpl(SwRootFrame
const* pLayout
) const override
;
96 Creates a copy of this field.
98 @return the copy of this field
100 virtual std::unique_ptr
<SwField
> Copy() const override
;
106 @param pTyp field type for this field
108 SwDropDownField(SwFieldType
* pTyp
);
113 @param rSrc dropdown field to copy
115 SwDropDownField(const SwDropDownField
& rSrc
);
120 virtual ~SwDropDownField() override
;
123 Returns the selected value.
127 @return the selected value
129 virtual OUString
GetPar1() const override
;
132 Returns the name of the field.
134 @return the name of the field
136 virtual OUString
GetPar2() const override
;
139 Sets the selected value.
141 If rStr is an item of the field that item will be
142 selected. Otherwise no item will be selected, i.e. the
143 resulting selection will be empty.
145 virtual void SetPar1(const OUString
& rStr
) override
;
148 Sets the name of the field.
150 @param rStr the new name of the field
152 virtual void SetPar2(const OUString
& rStr
) override
;
155 Sets the items of the dropdown box.
157 After setting the items the selection will be empty.
159 @param rItems the new items
161 void SetItems(std::vector
<OUString
>&& rItems
);
164 Sets the items of the dropdown box.
166 After setting the items the selection will be empty.
168 @param rItems the new items
170 void SetItems(const css::uno::Sequence
<OUString
>& rItems
);
173 Returns the items of the dropdown box.
175 @return the items of the dropdown box
177 css::uno::Sequence
<OUString
> GetItemSequence() const;
180 Returns the selected item.
182 @return the selected item
184 const OUString
& GetSelectedItem() const { return m_aSelectedItem
; }
187 Returns the name of the field.
189 @return the name of the field
191 const OUString
& GetName() const { return m_aName
; }
194 Returns the help text of the field.
196 @return the help text of the field
198 const OUString
& GetHelp() const { return m_aHelp
; }
201 Returns the tool tip of the field.
203 @return the tool tip of the field
205 const OUString
& GetToolTip() const { return m_aToolTip
; }
208 Sets the selected item.
210 If rItem is found in this dropdown field it is selected. If
211 rItem is not found the selection will be empty.
213 @param rItem the item to be set
215 void SetSelectedItem(const OUString
& rItem
);
218 Sets the name of the field.
220 @param rName the new name of the field
222 void SetName(const OUString
& rName
);
225 Sets the help text of the field.
227 @param rHelp the help text
229 void SetHelp(const OUString
& rHelp
);
232 Sets the tool tip of the field.
234 @param rToolTip the tool tip
236 void SetToolTip(const OUString
& rToolTip
);
239 API: Gets a property value from the dropdown field.
241 @param rVal return value
243 - FIELD_PROP_PAR1 Get selected item (String)
244 - FIELD_PROP_STRINGS Get all items (Sequence)
245 - FIELD_PROP_PAR3 Get the help text of the field.
246 - FIELD_PROP_PAR4 Get the tool tip of the field.
248 virtual bool QueryValue(css::uno::Any
& rVal
, sal_uInt16 nWhichId
) const override
;
251 API: Sets a property value on the dropdown field.
253 @param rVal value to set
255 - FIELD_PROP_PAR1 Set selected item (String)
256 - FIELD_PROP_STRINGS Set all items (Sequence)
257 - FIELD_PROP_PAR3 Set the help text of the field.
258 - FIELD_PROP_PAR4 Set the tool tip of the field.
260 virtual bool PutValue(const css::uno::Any
& rVal
, sal_uInt16 nWhichId
) override
;
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */