22#include <libxml/xmlwriter.h>
39inline constexpr OUStringLiteral CURRENT_DATE_FORMAT =
u"YYYY-MM-DD";
49 , m_pTextAttr(nullptr)
54 const std::shared_ptr<SwContentControl>& pContentControl, sal_uInt16 nWhich)
56 , m_pContentControl(pContentControl)
57 , m_pTextAttr(nullptr)
61 SAL_WARN(
"sw.core",
"SwFormatContentControl ctor: no pContentControl?");
99 SAL_WARN(
"sw.core",
"SwFormatContentControl::SetTextAttr: already has a text attribute");
103 SAL_WARN(
"sw.core",
"SwFormatContentControl::SetTextAttr: no attribute to remove");
108 SAL_WARN(
"sw.core",
"inserted SwFormatContentControl has no SwContentControl");
131 SAL_WARN(
"sw.core",
"SwFormatContentControl::NotifyChangeTextNode: no content control?");
146 SAL_WARN(
"sw.core",
"SwFormatContentControl::DoCopy: called for SwFormatContentControl "
147 "with no SwContentControl.");
157 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwFormatContentControl"));
158 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
159 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"m_pTextAttr"),
"%p",
m_pTextAttr);
167 (void)xmlTextWriterEndElement(pWriter);
171 :
sw::BroadcastingModify()
173 , m_pTextNode(nullptr)
209 if (rHint.
GetId() != SfxHintId::SwLegacyModify)
228 sal_uInt32 nFormat = pNumberFormatter->
GetEntryKey(
234 sal_Int32 nCheckPos = 0;
237 pNumberFormatter->
PutEntry(aFormat, nCheckPos,
nType, nFormat,
241 const Color* pColor =
nullptr;
266 sal_Int32 nCheckPos = 0;
268 OUString sFormat = CURRENT_DATE_FORMAT;
277 const Color* pColor =
nullptr;
278 pNumberFormatter->
GetOutputString(fCurrentDate, nFormat, aFormatted, &pColor,
false);
294 sal_Int32 nCheckPos = 0;
296 OUString sFormat = CURRENT_DATE_FORMAT;
305 double dCurrentDate = 0;
306 OUString aCurrentDate =
m_aCurrentDate.replaceAll(
"T00:00:00Z",
"");
307 (void)pNumberFormatter->
IsNumberFormat(aCurrentDate, nFormat, dCurrentDate);
339 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwContentControl"));
340 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
341 (void)xmlTextWriterWriteFormatAttribute(
342 pWriter, BAD_CAST(
"showing-place-holder"),
"%s",
344 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"checkbox"),
"%s",
346 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"checked"),
"%s",
347 BAD_CAST(OString::boolean(
m_bChecked).getStr()));
348 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"checked-state"),
"%s",
350 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"unchecked-state"),
"%s",
352 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"picture"),
353 BAD_CAST(OString::boolean(
m_bPicture).getStr()));
354 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"date"),
355 BAD_CAST(OString::boolean(
m_bDate).getStr()));
356 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"date-format"),
358 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"date-language"),
360 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"current-date"),
362 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"plain-text"),
364 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"placeholder-doc-part"),
366 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"data-binding-prefix-mappings"),
368 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"data-binding-xpath"),
370 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"data-binding-store-item-id"),
372 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"color"),
373 BAD_CAST(
m_aColor.toUtf8().getStr()));
379 rListItem.dumpAsXml(pWriter);
383 (void)xmlTextWriterEndElement(pWriter);
388 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwContentControlListItem"));
389 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
390 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"display-text"),
392 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"value"),
393 BAD_CAST(
m_aValue.toUtf8().getStr()));
395 (void)xmlTextWriterEndElement(pWriter);
416 uno::Sequence<uno::Sequence<beans::PropertyValue>> aRet(rItems.size());
418 uno::Sequence<beans::PropertyValue>* pRet = aRet.getArray();
419 for (
size_t i = 0;
i < rItems.size(); ++
i)
422 uno::Sequence<beans::PropertyValue> aItem = {
432std::vector<SwContentControlListItem>
435 std::vector<SwContentControlListItem> aRet;
437 uno::Sequence<uno::Sequence<beans::PropertyValue>> aSequence;
439 for (
const auto& rItem : aSequence)
443 auto it =
aMap.find(
"DisplayText");
444 if (it !=
aMap.end())
448 it =
aMap.find(
"Value");
449 if (it !=
aMap.end())
453 aRet.push_back(aItem);
462 sal_Int32 nEnd,
bool bIsCopy)
467 if (!pTargetTextNode)
470 "SwTextContentControl ctor: cannot copy content control without target node");
472 rAttr.
DoCopy(*pTargetTextNode);
475 return pTextContentControl;
490 if (rFormatContentControl.GetTextAttr() ==
this)
499 if (rFormatContentControl.GetTextAttr() ==
this)
507 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTextContentControl"));
508 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
511 (void)xmlTextWriterEndElement(pWriter);
struct _xmlTextWriter * xmlTextWriterPtr
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
virtual bool operator==(const SfxPoolItem &) const=0
void Broadcast(const SfxHint &rHint)
const SwModify * GetRegisteredIn() const
Represents one list item in a content control dropdown list.
void dumpAsXml(xmlTextWriterPtr pWriter) const
bool operator==(const SwContentControlListItem &rOther) const
OUString m_aValue
This must not be empty.
const OUString & ToString() const
static std::vector< SwContentControlListItem > ItemsFromAny(const css::uno::Any &rVal)
static void ItemsToAny(const std::vector< SwContentControlListItem > &rItems, css::uno::Any &rVal)
OUString m_aDisplayText
This may be empty, ToString() falls back to m_aValue.
OUString m_aCheckedState
If m_bCheckbox is true, the value of a checked checkbox.
virtual ~SwContentControl() override
OUString m_aDataBindingXpath
The data bindings's XPath: just remembered.
void NotifyChangeTextNode(SwTextNode *pTextNode)
void SetXContentControl(const rtl::Reference< SwXContentControl > &xContentCnotrol)
SwFormatContentControl * m_pFormat
unotools::WeakReference< SwXContentControl > m_wXContentControl
OUString m_aDateLanguage
If m_bDate is true, the date's BCP 47 language tag.
SwContentControl(SwFormatContentControl *pFormat)
OUString GetDateString() const
Formats m_oSelectedDate, taking m_aDateFormat and m_aDateLanguage into account.
bool ShouldOpenPopup(const vcl::KeyCode &rKeyCode)
Given rKeyCode as a keyboard event, should a popup be opened for this content control?
bool m_bShowingPlaceHolder
Current content is placeholder text.
SwTextContentControl * GetTextAttr() const
void dumpAsXml(xmlTextWriterPtr pWriter) const
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
double GetCurrentDateValue() const
Parses m_aCurrentDate and returns it.
OUString m_aDataBindingPrefixMappings
The data bindings's prefix mappings: just remembered.
bool HasListItems() const
OUString m_aDateFormat
If m_bDate is true, the date format in a syntax accepted by SvNumberFormatter::PutEntry().
void SetCurrentDateValue(double fCurrentDate)
Formats fCurrentDate and sets it.
bool m_bChecked
If m_bCheckbox is true, is the checkbox checked?
std::optional< double > m_oSelectedDate
Stores a date timestamp, in case the doc model is not yet updated.
bool m_bCheckbox
Display the content control as a checkbox.
SwTextNode * m_pTextNode
Can be nullptr if not in a document for undo purposes.
bool m_bPlainText
Plain text, i.e. not rich text.
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.
OUString m_aPlaceholderDocPart
The placeholder's doc part: just remembered.
OUString m_aColor
The color: just remembered.
OUString m_aDataBindingStoreItemID
The data bindings's store item ID: just remembered.
bool IsInteractingCharacter(sal_Unicode cCh)
Should this character (during key input) interact with the content control?
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
SfxPoolItem subclass that wraps an SwContentControl.
void NotifyChangeTextNode(SwTextNode *pTextNode)
Notify clients registered at m_pContentControl that this content control is being (re-)moved.
std::shared_ptr< SwContentControl > m_pContentControl
SwFormatContentControl(sal_uInt16 nWhich)
SwTextContentControl * m_pTextAttr
SwTextContentControl * GetTextAttr()
bool operator==(const SfxPoolItem &) const override
SfxPoolItem.
~SwFormatContentControl() override
void dumpAsXml(xmlTextWriterPtr pWriter) const override
void DoCopy(SwTextNode &rTargetTextNode)
This method must be called when the hint is actually copied.
static SwFormatContentControl * CreatePoolDefault(sal_uInt16 nWhich)
void SetTextAttr(SwTextContentControl *pTextAttr)
SwFormatContentControl * Clone(SfxItemPool *pPool=nullptr) const override
void Add(SwClient *pDepend)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
const SfxPoolItem & GetAttr() const
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
void SetHasDummyChar(const bool bFlag)
SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
static SwTextContentControl * CreateTextContentControl(SwTextNode *pTargetTextNode, SwFormatContentControl &rAttr, sal_Int32 nStart, sal_Int32 nEnd, bool bIsCopy)
void ChgTextNode(SwTextNode *pNode)
SwTextContentControl(SwFormatContentControl &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
~SwTextContentControl() override
void dumpAsXml(xmlTextWriterPtr pWriter) const override
SwTextNode is a paragraph in the document model.
SvtBroadcaster & GetNotifier()
virtual void CallSwClientNotify(const SfxHint &rHint) const override
sal_uInt16 GetCode() const
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
constexpr sal_uInt16 KEY_DOWN
#define LANGUAGE_ENGLISH_US
#define SAL_WARN(area, stream)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Dialog to specify the properties of date form field.
HashMap_OWString_Interface aMap
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND