35#include <com/sun/star/beans/XPropertySet.hpp>
36#include <com/sun/star/beans/XPropertySetInfo.hpp>
37#include <com/sun/star/util/Time.hpp>
38#include <com/sun/star/util/DateTime.hpp>
39#include <com/sun/star/util/Date.hpp>
41#define USER_DATA_VERSION_1 "1"
42#define USER_DATA_VERSION USER_DATA_VERSION_1
49 for (
auto const& aID : FLD_SELECT)
54 :
SwFieldPage(pPage, pController,
"modules/swriter/ui/flddocinfopage.ui",
"FieldDocInfoPage", pCoreSet)
57 , m_xTypeList(m_xBuilder->weld_tree_view(
"type-list"))
58 , m_xTypeTree(m_xBuilder->weld_tree_view(
"type-tree"))
62 , m_pTypeView(m_xTypeTree.
get())
63 , m_xSelection(m_xBuilder->weld_widget(
"selectframe"))
64 , m_xSelectionLB(m_xBuilder->weld_tree_view(
"select"))
65 , m_xFormat(m_xBuilder->weld_widget(
"formatframe"))
67 , m_xFixedCB(m_xBuilder->weld_check_button(
"fixed"))
77 m_xFormatLB->get_widget().set_size_request(nWidth * 2, nHeight);
103 uno::Sequence<beans::Property> aCustomProperties;
107 aCustomProperties = xSetInfo->getProperties();
110 if (aCustomProperties.hasElements())
133 sal_uInt16 nSubType = USHRT_MAX;
140 if (
auto const pField =
dynamic_cast<SwDocInfoField const*
>(pCurField))
155 sal_Int32 nSelEntryData = -1;
163 std::vector<OUString> aLst;
166 std::unique_ptr<weld::TreeIter> xExpandEntry;
167 for(
size_t i = 0;
i < aLst.size(); ++
i)
171 const OUString
sId(OUString::number(
i));
176 if (aCustomProperties.hasElements())
180 OUString sText(
SwResId(STR_CUSTOM_FIELD));
181 OUString sEntryId(OUString::number(USHRT_MAX));
183 nullptr,
false, xInfo.get());
184 for (
const auto& rProperty : aCustomProperties)
186 const OUString sEntry = rProperty.Name;
189 nullptr,
nullptr,
false, xEntry.get());
204 nullptr,
nullptr,
false, xEntry.get());
207 if (
static_cast<size_t>(nSelEntryData) ==
i)
253 if (!m_pTypeView->get_selected(m_xSelEntry.get()) &&
254 m_pTypeView->get_iter_first(*m_xSelEntry))
256 m_pTypeView->select(*m_xSelEntry);
258 FillSelectionLB(m_pTypeView->get_id(*m_xSelEntry).toUInt32());
259 SubTypeHdl(*m_xSelectionLB);
264 sal_uInt16 nSubType = m_pTypeView->get_id(*m_xSelEntry).toUInt32();
265 sal_Int32
nPos = m_xSelectionLB->get_selected_index();
266 sal_uInt16 nExtSubType;
273 if (!m_xSelectionLB->n_children())
275 m_xFormatLB->clear();
276 m_xFormat->set_sensitive(
false);
280 const OUString
sName = m_pTypeView->get_text(*m_xSelEntry);
283 uno::Any aVal = m_xCustomPropertySet->getPropertyValue(
sName );
284 const uno::Type& rValueType = aVal.getValueType();
287 nNewType = SvNumFormatType::DATETIME;
291 nNewType = SvNumFormatType::DATE;
295 nNewType = SvNumFormatType::TIME;
298 catch(
const uno::Exception& )
308 nExtSubType = m_xSelectionLB->get_id(
nPos).toUInt32();
314 bool bEnable =
false;
315 bool bOneArea =
false;
317 if (m_xFormatLB->get_active())
318 nOldType = m_xFormatLB->GetFormatType();
326 nNewType = SvNumFormatType::DATE;
331 nNewType = SvNumFormatType::TIME;
335 if (nNewType == SvNumFormatType::ALL)
337 m_xFormatLB->clear();
341 if (nOldType != nNewType)
343 m_xFormatLB->SetFormatType(nNewType);
344 m_xFormatLB->SetOneArea(bOneArea);
349 sal_uInt32 nFormat = 0;
351 sal_uInt16 nOldSubType = 0;
355 if (
auto const pField =
dynamic_cast<SwDocInfoField const*
>(GetCurField()))
357 nFormat = pField->GetFormat();
358 nOldSubType = pField->GetSubType() & 0xff00;
360 nPos = m_xSelectionLB->get_selected_index();
363 nSubType = m_xSelectionLB->get_id(
nPos).toUInt32();
365 nOldSubType &= ~DI_SUB_FIXED;
366 if (nOldSubType == nSubType)
368 if (!nFormat && (nNewType == SvNumFormatType::DATE || nNewType == SvNumFormatType::TIME))
375 if (nNewType == SvNumFormatType::DATE)
377 else if (nNewType == SvNumFormatType::TIME)
381 m_xFormatLB->SetDefFormat(nFormat);
384 else if( (nSubType ==
DI_CUSTOM) && (nNewType != SvNumFormatType::ALL) )
386 m_xFormatLB->SetDefFormat(nFormat);
391 m_xFormat->set_sensitive(bEnable || m_xFixedCB->get_active());
394 m_xFormatLB->clear();
395 else if (m_xFormatLB->get_selected_index() == -1)
396 m_xFormatLB->select(0);
406 if (nSubType == USHRT_MAX)
411 sal_uInt16 nSize = 0;
412 sal_Int32 nSelPos = -1;
413 sal_uInt16 nExtSubType = 0;
419 nExtSubType = pField->GetSubType() & 0xff00;
422 nExtSubType = ((nExtSubType & ~DI_SUB_FIXED) >> 8) - 1;
432 for (sal_uInt16
i = 0;
i < nSize; ++
i)
441 bool bEnable = nSize != 0;
461 if (nSubType == USHRT_MAX)
464 sal_uInt32 nFormat = 0;
496 return std::make_unique<SwFieldDokInfPage>(pPage, pController, pAttrSet);
507 sal_uInt16 nTypeSel = nEntry != -1 ?
m_pTypeView->
get_id(nEntry).toUInt32() : USHRT_MAX;
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
void SetUserData(const OUString &rString)
const OUString & GetUserData() const
const css::uno::Any & GetValue() const
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
virtual void Reset(const SfxItemSet *rSet) override
std::unique_ptr< weld::TreeView > m_xSelectionLB
virtual bool FillItemSet(SfxItemSet *rSet) override
OUString m_sOldCustomFieldName
std::unique_ptr< SwNumFormatTreeView > m_xFormatLB
std::unique_ptr< weld::TreeView > m_xTypeList
std::unique_ptr< weld::TreeView > m_xTypeTree
virtual void FillUserData() override
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Widget > m_xSelection
SwFieldDokInfPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
std::unique_ptr< weld::TreeIter > m_xSelEntry
std::unique_ptr< weld::CheckButton > m_xFixedCB
weld::TreeView * m_pTypeView
virtual ~SwFieldDokInfPage() override
sal_Int32 FillSelectionLB(sal_uInt16 nSubTypeId)
css::uno::Reference< css::beans::XPropertySet > m_xCustomPropertySet
virtual sal_uInt16 GetGroup() override
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
void InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, const OUString &rPar1, const OUString &rPar2, sal_uInt32 nFormatId, sal_Unicode cDelim=' ', bool bIsAutomaticLanguage=true)
SwFieldMgr & GetFieldMgr()
bool IsFieldDlgHtmlMode() const
void EnableInsert(bool bEnable)
SwWrtShell * GetWrtShell()
Base class of all fields.
bool IsAutomaticLanguage() const
virtual sal_uInt16 GetSubType() const
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Used by the UI to modify the document model.
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const=0
virtual void expand_row(const TreeIter &rIter)=0
void connect_row_activated(const Link< TreeView &, bool > &rLink)
virtual OUString get_text(int row, int col=-1) const=0
void append_text(const OUString &rStr)
virtual void insert(const TreeIter *pParent, int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface, bool bChildrenOnDemand, TreeIter *pRet)=0
void connect_changed(const Link< TreeView &, void > &rLink)
virtual bool get_iter_first(TreeIter &rIter) const=0
virtual int get_height_rows(int nRows) const=0
virtual void select(int pos)=0
virtual int get_selected_index() const=0
virtual OUString get_id(int pos) const=0
#define FN_FIELD_DIALOG_DOC_PROPS
SwFieldTypesEnum
List of FieldTypes at UI.
void FillFieldSelect(weld::TreeView &rListBox)
#define USER_DATA_VERSION_1
#define USER_DATA_VERSION
IMPL_LINK_NOARG(SwFieldDokInfPage, TypeHdl, weld::TreeView &, void)
#define FIELD_COLUMN_WIDTH
#define LINK(Instance, Class, Member)
const SwDocInfoSubType DI_DOCNO
const SwDocInfoSubType DI_SUB_AUTHOR
const SwDocInfoSubType DI_CUSTOM
const SwDocInfoSubType DI_SUBTYPE_BEGIN
NB: these must denote consecutive integers! NB2: these are extended by 4 DI_INFO values for backward ...
const SwDocInfoSubType DI_SUB_FIXED
const SwDocInfoSubType DI_PRINT
const SwDocInfoSubType DI_SUB_DATE
const SwDocInfoSubType DI_EDIT
const SwDocInfoSubType DI_SUBJECT
const SwDocInfoSubType DI_SUB_TIME
const SwDocInfoSubType DI_CREATE
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
OUString SwResId(TranslateId aId)