diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-05-27 11:38:42 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-05-31 14:40:45 +0200 |
commit | d0ebc93087975ce361b618512548bc05b5b95c8b (patch) | |
tree | 4e0b22ca7cd62610e519f2bf4650b4f08d5af431 /sw/inc | |
parent | c04e1a32a1610c735ef2de6e8fde107abb1b66ae (diff) |
sw content controls, date: add current date handling
While working on the DOCX import for dates, it turns out there is a need
to store the selected date in machine-readable format as well. This is
useful, because once the timestamp is formatted, the user is allowed to
hand-edit the result, so otherwise the selected date would be lost.
This commit adds:
- doc model & UNO API
- click handler (store the selected date, default to the current date in
the date picker if possible)
- ODT filter
- DOCX export
And tests for all these.
(cherry picked from commit 79baafccf3d390810f516b2cf9cb3ad2b4e9e63b)
Change-Id: I00f4e87ebfe0e8a19486367c32d472ccd2ff16a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135150
Tested-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/inc')
-rw-r--r-- | sw/inc/formatcontentcontrol.hxx | 13 | ||||
-rw-r--r-- | sw/inc/unoprnms.hxx | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index 1dba4bce03a6..90452dfaeb2b 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -135,6 +135,9 @@ class SW_DLLPUBLIC SwContentControl : public sw::BroadcastingModify /// If m_bDate is true, the date's BCP 47 language tag. OUString m_aDateLanguage; + /// Date in YYYY-MM-DDT00:00:00Z format. + OUString m_aCurrentDate; + /// Stores a list item index, in case the doc model is not yet updated. std::optional<size_t> m_oSelectedListItem; @@ -216,6 +219,16 @@ public: OUString GetDateLanguage() const { return m_aDateLanguage; } + void SetCurrentDate(const OUString& rCurrentDate) { m_aCurrentDate = rCurrentDate; } + + OUString GetCurrentDate() const { return m_aCurrentDate; } + + /// Formats fCurrentDate and sets it. + void SetCurrentDateValue(double fCurrentDate); + + /// Parses m_aCurrentDate and returns it. + double GetCurrentDateValue() const; + /// Formats m_oSelectedDate, taking m_aDateFormat and m_aDateLanguage into account. OUString GetDateString() const; diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 4ac4aa7d0dca..72aaf746cb1e 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -879,6 +879,7 @@ #define UNO_NAME_PICTURE "Picture" #define UNO_NAME_DATE_FORMAT "DateFormat" #define UNO_NAME_DATE_LANGUAGE "DateLanguage" +#define UNO_NAME_CURRENT_DATE "CurrentDate" #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |