LibreOffice Module sw (master) 1
formatcontentcontrol.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/text/XTextContent.hpp>
23#include <com/sun/star/beans/PropertyValue.hpp>
24
26#include <sal/types.h>
27#include <svl/poolitem.hxx>
28
29#include "calbck.hxx"
30#include "swdllapi.h"
31
34class SwTextNode;
36
38{
42 PICTURE,
43 DATE,
44};
45
48{
49 std::shared_ptr<SwContentControl> m_pContentControl;
51
52public:
53 SwTextContentControl* GetTextAttr() { return m_pTextAttr; }
54 void SetTextAttr(SwTextContentControl* pTextAttr);
55
57 void DoCopy(SwTextNode& rTargetTextNode);
58
59 explicit SwFormatContentControl(sal_uInt16 nWhich);
60
61 explicit SwFormatContentControl(const std::shared_ptr<SwContentControl>& pContentControl,
62 sal_uInt16 nWhich);
63 ~SwFormatContentControl() override;
64
66 bool operator==(const SfxPoolItem&) const override;
67 SwFormatContentControl* Clone(SfxItemPool* pPool = nullptr) const override;
68
73 void NotifyChangeTextNode(SwTextNode* pTextNode);
74 static SwFormatContentControl* CreatePoolDefault(sal_uInt16 nWhich);
75 std::shared_ptr<SwContentControl> GetContentControl() { return m_pContentControl; }
76 const std::shared_ptr<SwContentControl>& GetContentControl() const { return m_pContentControl; }
77
78 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
79};
80
83{
84public:
88 OUString m_aValue;
89
90 void dumpAsXml(xmlTextWriterPtr pWriter) const;
91
92 OUString ToString() const;
93
94 bool operator==(const SwContentControlListItem& rOther) const;
95
96 static void ItemsToAny(const std::vector<SwContentControlListItem>& rItems,
97 css::uno::Any& rVal);
98
99 static std::vector<SwContentControlListItem> ItemsFromAny(const css::uno::Any& rVal);
100};
101
104{
105 css::uno::WeakReference<css::text::XTextContent> m_wXContentControl;
106
108
111
113 bool m_bShowingPlaceHolder = false;
114
116 bool m_bCheckbox = false;
117
119 bool m_bChecked = false;
120
123
126
127 std::vector<SwContentControlListItem> m_aListItems;
128
129 bool m_bPicture = false;
130
131 bool m_bDate = false;
132
135
138
141
144
147
150
153
155 OUString m_aColor;
156
158 std::optional<size_t> m_oSelectedListItem;
159
161 std::optional<double> m_oSelectedDate;
162
167 bool m_bReadWrite = false;
168
169public:
170 SwTextContentControl* GetTextAttr() const;
171
172 SwTextNode* GetTextNode() const { return m_pTextNode; }
173
174 SwFormatContentControl* GetFormatContentControl() const { return m_pFormat; }
175
176 void SetFormatContentControl(SwFormatContentControl* pFormat) { m_pFormat = pFormat; };
177
178 void NotifyChangeTextNode(SwTextNode* pTextNode);
179
180 const css::uno::WeakReference<css::text::XTextContent>& GetXContentControl() const
181 {
182 return m_wXContentControl;
183 }
184
185 void SetXContentControl(const css::uno::Reference<css::text::XTextContent>& xContentCnotrol)
186 {
187 m_wXContentControl = xContentCnotrol;
188 }
189
190 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
191
192 explicit SwContentControl(SwFormatContentControl* pFormat);
193
194 virtual ~SwContentControl() override;
195
196 void SetShowingPlaceHolder(bool bShowingPlaceHolder)
197 {
198 m_bShowingPlaceHolder = bShowingPlaceHolder;
199 }
200
201 bool GetShowingPlaceHolder() const { return m_bShowingPlaceHolder; }
202
203 void SetCheckbox(bool bCheckbox) { m_bCheckbox = bCheckbox; }
204
205 bool GetCheckbox() const { return m_bCheckbox; }
206
207 void SetChecked(bool bChecked) { m_bChecked = bChecked; }
208
209 bool GetChecked() const { return m_bChecked; }
210
211 void SetCheckedState(const OUString& rCheckedState) { m_aCheckedState = rCheckedState; }
212
213 OUString GetCheckedState() const { return m_aCheckedState; }
214
215 void SetUncheckedState(const OUString& rUncheckedState) { m_aUncheckedState = rUncheckedState; }
216
217 OUString GetUncheckedState() const { return m_aUncheckedState; }
218
219 std::vector<SwContentControlListItem> GetListItems() const { return m_aListItems; }
220
221 bool HasListItems() const { return !m_aListItems.empty(); }
222
223 void SetListItems(const std::vector<SwContentControlListItem>& rListItems)
224 {
225 m_aListItems = rListItems;
226 }
227
228 void SetPicture(bool bPicture) { m_bPicture = bPicture; }
229
230 bool GetPicture() const { return m_bPicture; }
231
232 void SetDate(bool bDate) { m_bDate = bDate; }
233
234 bool GetDate() const { return m_bDate; }
235
236 void SetDateFormat(const OUString& rDateFormat) { m_aDateFormat = rDateFormat; }
237
238 OUString GetDateFormat() const { return m_aDateFormat; }
239
240 void SetDateLanguage(const OUString& rDateLanguage) { m_aDateLanguage = rDateLanguage; }
241
242 OUString GetDateLanguage() const { return m_aDateLanguage; }
243
244 void SetCurrentDate(const OUString& rCurrentDate) { m_aCurrentDate = rCurrentDate; }
245
246 OUString GetCurrentDate() const { return m_aCurrentDate; }
247
249 void SetCurrentDateValue(double fCurrentDate);
250
252 double GetCurrentDateValue() const;
253
255 OUString GetDateString() const;
256
257 void SetPlaceholderDocPart(const OUString& rPlaceholderDocPart)
258 {
259 m_aPlaceholderDocPart = rPlaceholderDocPart;
260 }
261
262 OUString GetPlaceholderDocPart() const { return m_aPlaceholderDocPart; }
263
264 void SetSelectedListItem(std::optional<size_t> oSelectedListItem)
265 {
266 m_oSelectedListItem = oSelectedListItem;
267 }
268
269 std::optional<size_t> GetSelectedListItem() const { return m_oSelectedListItem; }
270
271 void SetSelectedDate(std::optional<double> oSelectedDate) { m_oSelectedDate = oSelectedDate; }
272
273 std::optional<double> GetSelectedDate() const { return m_oSelectedDate; }
274
275 void dumpAsXml(xmlTextWriterPtr pWriter) const;
276
277 void SetDataBindingPrefixMappings(const OUString& rDataBindingPrefixMappings)
278 {
279 m_aDataBindingPrefixMappings = rDataBindingPrefixMappings;
280 }
281
282 OUString GetDataBindingPrefixMappings() const { return m_aDataBindingPrefixMappings; }
283
284 void SetDataBindingXpath(const OUString& rDataBindingXpath)
285 {
286 m_aDataBindingXpath = rDataBindingXpath;
287 }
288
289 OUString GetDataBindingXpath() const { return m_aDataBindingXpath; }
290
291 void SetDataBindingStoreItemID(const OUString& rDataBindingStoreItemID)
292 {
293 m_aDataBindingStoreItemID = rDataBindingStoreItemID;
294 }
295
296 OUString GetDataBindingStoreItemID() const { return m_aDataBindingStoreItemID; }
297
298 void SetColor(const OUString& rColor) { m_aColor = rColor; }
299
300 OUString GetColor() const { return m_aColor; }
301
302 void SetReadWrite(bool bReadWrite) { m_bReadWrite = bReadWrite; }
303
304 bool GetReadWrite() const { return m_bReadWrite; }
305};
306
307/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
virtual bool operator==(const SfxPoolItem &) const=0
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
Represents one list item in a content control dropdown list.
OUString m_aValue
This must not be empty.
OUString m_aDisplayText
This may be empty, ToString() falls back to m_aValue.
Stores the properties of a content control.
void SetSelectedDate(std::optional< double > oSelectedDate)
OUString m_aCheckedState
If m_bCheckbox is true, the value of a checked checkbox.
void SetShowingPlaceHolder(bool bShowingPlaceHolder)
OUString m_aDataBindingXpath
The data bindings's XPath: just remembered.
void SetPicture(bool bPicture)
void SetPlaceholderDocPart(const OUString &rPlaceholderDocPart)
void SetDataBindingXpath(const OUString &rDataBindingXpath)
OUString GetCheckedState() const
SwFormatContentControl * m_pFormat
SwFormatContentControl * GetFormatContentControl() const
std::vector< SwContentControlListItem > GetListItems() const
OUString m_aDateLanguage
If m_bDate is true, the date's BCP 47 language tag.
void SetCurrentDate(const OUString &rCurrentDate)
void SetReadWrite(bool bReadWrite)
void SetDateFormat(const OUString &rDateFormat)
OUString GetUncheckedState() const
void SetDataBindingPrefixMappings(const OUString &rDataBindingPrefixMappings)
OUString GetColor() const
void SetCheckedState(const OUString &rCheckedState)
OUString GetDateLanguage() const
void SetListItems(const std::vector< SwContentControlListItem > &rListItems)
std::optional< size_t > m_oSelectedListItem
Stores a list item index, in case the doc model is not yet updated.
OUString GetDataBindingPrefixMappings() const
void SetFormatContentControl(SwFormatContentControl *pFormat)
OUString m_aDataBindingPrefixMappings
The data bindings's prefix mappings: just remembered.
const css::uno::WeakReference< css::text::XTextContent > & GetXContentControl() const
OUString GetDateFormat() const
std::optional< size_t > GetSelectedListItem() const
void SetDateLanguage(const OUString &rDateLanguage)
css::uno::WeakReference< css::text::XTextContent > m_wXContentControl
void SetXContentControl(const css::uno::Reference< css::text::XTextContent > &xContentCnotrol)
void SetChecked(bool bChecked)
void SetColor(const OUString &rColor)
OUString GetDataBindingStoreItemID() const
OUString m_aDateFormat
If m_bDate is true, the date format in a syntax accepted by SvNumberFormatter::PutEntry().
std::optional< double > m_oSelectedDate
Stores a date timestamp, in case the doc model is not yet updated.
void SetUncheckedState(const OUString &rUncheckedState)
void SetDataBindingStoreItemID(const OUString &rDataBindingStoreItemID)
std::optional< double > GetSelectedDate() const
SwTextNode * m_pTextNode
Can be nullptr if not in a document for undo purposes.
std::vector< SwContentControlListItem > m_aListItems
OUString m_aUncheckedState
If m_bCheckbox is true, the value of an unchecked checkbox.
OUString m_aCurrentDate
Date in YYYY-MM-DDT00:00:00Z format.
void SetCheckbox(bool bCheckbox)
OUString GetPlaceholderDocPart() const
void SetDate(bool bDate)
OUString GetDataBindingXpath() const
OUString m_aPlaceholderDocPart
The placeholder's doc part: just remembered.
OUString m_aColor
The color: just remembered.
void SetSelectedListItem(std::optional< size_t > oSelectedListItem)
OUString GetCurrentDate() const
OUString m_aDataBindingStoreItemID
The data bindings's store item ID: just remembered.
bool GetShowingPlaceHolder() const
SwTextNode * GetTextNode() const
SfxPoolItem subclass that wraps an SwContentControl.
std::shared_ptr< SwContentControl > m_pContentControl
const std::shared_ptr< SwContentControl > & GetContentControl() const
SwTextContentControl * m_pTextAttr
SwTextContentControl * GetTextAttr()
std::shared_ptr< SwContentControl > GetContentControl()
SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:84
UNO API wrapper around an SwContentControl, exposed as the com.sun.star.text.ContentControl service.
Color m_aColor
SwContentControlType
DATE
OUString GetDateString(const css::util::DateTime &_rDT)
#define SW_DLLPUBLIC
Definition: swdllapi.h:28