27 #include <flddinf.hrc>
28 #include <strings.hrc>
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
54 :
SwFieldPage(pPage, pController,
"modules/swriter/ui/flddocinfopage.ui",
"FieldDocInfoPage", pCoreSet)
57 , m_xTypeTLB(m_xBuilder->weld_tree_view(
"type"))
58 , m_xSelection(m_xBuilder->weld_widget(
"selectframe"))
59 , m_xSelectionLB(m_xBuilder->weld_tree_view(
"select"))
60 , m_xFormat(m_xBuilder->weld_widget(
"formatframe"))
62 , m_xFixedCB(m_xBuilder->weld_check_button(
"fixed"))
68 auto nHeight =
m_xTypeTLB->get_height_rows(10);
70 m_xFormatLB->get_widget().set_size_request(nWidth * 2, nHeight);
102 sal_uInt16 nSubType = USHRT_MAX;
109 if (
auto const pField = dynamic_cast<SwDocInfoField const*>(pCurField))
124 sal_Int32 nSelEntryData = -1;
132 std::vector<OUString> aLst;
134 std::unique_ptr<weld::TreeIter> xEntry(
m_xTypeTLB->make_iterator());
135 std::unique_ptr<weld::TreeIter> xExpandEntry;
136 for(
size_t i = 0;
i < aLst.size(); ++
i)
140 const OUString
sId(OUString::number(
i));
145 uno::Reference< beans::XPropertySetInfo > xSetInfo =
xCustomPropertySet->getPropertySetInfo();
146 const uno::Sequence< beans::Property > rProperties = xSetInfo->getProperties();
148 if( rProperties.hasElements() )
150 std::unique_ptr<weld::TreeIter> xInfo(
m_xTypeTLB->make_iterator());
152 OUString sText(
SwResId(STR_CUSTOM_FIELD));
153 OUString sEntryId(OUString::number(USHRT_MAX));
154 m_xTypeTLB->insert(
nullptr, -1, &sText, &sEntryId,
nullptr,
155 nullptr,
false, xInfo.get());
156 for (
const auto& rProperty : rProperties)
158 const OUString sEntry = rProperty.Name;
160 m_xTypeTLB->insert(xInfo.get(), -1, &sEntry, &sId,
161 nullptr,
nullptr,
false, xEntry.get());
165 xExpandEntry =
m_xTypeTLB->make_iterator(xInfo.get());
176 nullptr,
nullptr,
false, xEntry.get());
179 if (static_cast<size_t>(nSelEntryData) ==
i)
193 nSubType =
m_xTypeTLB->get_id(*m_xSelEntry).toUInt32();
199 nSubType =
m_xTypeTLB->get_id(*m_xSelEntry).toUInt32();
225 if (!m_xTypeTLB->get_selected(m_xSelEntry.get()) &&
226 m_xTypeTLB->get_iter_first(*m_xSelEntry))
228 m_xTypeTLB->select(*m_xSelEntry);
230 FillSelectionLB(m_xTypeTLB->get_id(*m_xSelEntry).toUInt32());
231 SubTypeHdl(*m_xSelectionLB);
236 sal_uInt16 nSubType = m_xTypeTLB->get_id(*m_xSelEntry).toUInt32();
237 sal_Int32
nPos = m_xSelectionLB->get_selected_index();
238 sal_uInt16 nExtSubType;
245 if (!m_xSelectionLB->n_children())
247 m_xFormatLB->clear();
248 m_xFormat->set_sensitive(
false);
252 const OUString
sName = m_xTypeTLB->get_text(*m_xSelEntry);
255 uno::Any aVal = xCustomPropertySet->getPropertyValue( sName );
256 const uno::Type& rValueType = aVal.getValueType();
259 nNewType = SvNumFormatType::DATETIME;
263 nNewType = SvNumFormatType::DATE;
267 nNewType = SvNumFormatType::TIME;
270 catch(
const uno::Exception& )
280 nExtSubType = m_xSelectionLB->get_id(nPos).toUInt32();
286 bool bEnable =
false;
287 bool bOneArea =
false;
289 if (m_xFormatLB->get_active())
290 nOldType = m_xFormatLB->GetFormatType();
298 nNewType = SvNumFormatType::DATE;
303 nNewType = SvNumFormatType::TIME;
307 if (nNewType == SvNumFormatType::ALL)
309 m_xFormatLB->clear();
313 if (nOldType != nNewType)
315 m_xFormatLB->SetFormatType(nNewType);
316 m_xFormatLB->SetOneArea(bOneArea);
321 sal_uInt32 nFormat = 0;
323 sal_uInt16 nOldSubType = 0;
327 if (
auto const pField = dynamic_cast<SwDocInfoField const*>(GetCurField()))
329 nFormat = pField->GetFormat();
330 nOldSubType = pField->GetSubType() & 0xff00;
332 nPos = m_xSelectionLB->get_selected_index();
335 nSubType = m_xSelectionLB->get_id(nPos).toUInt32();
338 if (nOldSubType == nSubType)
340 if (!nFormat && (nNewType == SvNumFormatType::DATE || nNewType == SvNumFormatType::TIME))
347 if (nNewType == SvNumFormatType::DATE)
349 else if (nNewType == SvNumFormatType::TIME)
353 m_xFormatLB->SetDefFormat(nFormat);
356 else if( (nSubType ==
DI_CUSTOM) && (nNewType != SvNumFormatType::ALL) )
358 m_xFormatLB->SetDefFormat(nFormat);
363 m_xFormat->set_sensitive(bEnable || m_xFixedCB->get_active());
366 m_xFormatLB->clear();
367 else if (m_xFormatLB->get_selected_index() == -1)
368 m_xFormatLB->select(0);
378 if (nSubType == USHRT_MAX)
383 sal_uInt16 nSize = 0;
384 sal_Int32 nSelPos = -1;
385 sal_uInt16 nExtSubType = 0;
389 if (
auto const pField = dynamic_cast<SwDocInfoField const*>(
GetCurField()))
391 nExtSubType = pField->GetSubType() & 0xff00;
394 nExtSubType = ((nExtSubType & ~DI_SUB_FIXED) >> 8) - 1;
404 for (sal_uInt16
i = 0;
i < nSize; ++
i)
413 bool bEnable = nSize != 0;
432 sal_uInt16 nSubType =
m_xTypeTLB->get_id(*m_xSelEntry).toUInt32();
433 if (nSubType == USHRT_MAX)
436 sal_uInt32 nFormat = 0;
468 return std::make_unique<SwFieldDokInfPage>(pPage, pController, pAttrSet);
478 int nEntry =
m_xTypeTLB->get_selected_index();
479 sal_uInt16 nTypeSel = nEntry != -1 ?
m_xTypeTLB->get_id(nEntry).toUInt32() : USHRT_MAX;
#define LINK(Instance, Class, Member)
const SwDocInfoSubType DI_SUB_TIME
SwFieldDokInfPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
virtual bool FillItemSet(SfxItemSet *rSet) override
#define USER_DATA_VERSION_1
void SetUserData(const OUString &rString)
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
virtual ~SwFieldDokInfPage() override
Base class of all fields.
virtual void Reset(const SfxItemSet *rSet) override
virtual sal_uInt16 GetGroup() override
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
std::unique_ptr< SwNumFormatTreeView > m_xFormatLB
const SwDocInfoSubType DI_EDIT
sal_Int32 FillSelectionLB(sal_uInt16 nSubTypeId)
Used by the UI to modify the document model.
OUString SwResId(TranslateId aId)
SwFieldMgr & GetFieldMgr()
void append_text(const OUString &rStr)
IMPL_LINK_NOARG(SwFieldDokInfPage, TypeHdl, weld::TreeView &, void)
const SwDocInfoSubType DI_SUBJECT
const OUString & GetUserData() const
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
std::unique_ptr< weld::CheckButton > m_xFixedCB
bool IsFieldDlgHtmlMode() const
const css::uno::Any & GetValue() const
css::uno::Reference< css::beans::XPropertySet > xCustomPropertySet
#define SAL_N_ELEMENTS(arr)
const SwDocInfoSubType DI_CUSTOM
void FillFieldSelect(weld::TreeView &rListBox)
const SwDocInfoSubType DI_PRINT
void EnableInsert(bool bEnable)
const SwDocInfoSubType DI_CREATE
SwFieldTypesEnum
List of FieldTypes at UI.
std::unique_ptr< weld::Widget > m_xSelection
std::unique_ptr< weld::TreeView > m_xSelectionLB
void InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, const OUString &rPar1, const OUString &rPar2, sal_uInt32 nFormatId, sal_Unicode cDelim= ' ', bool bIsAutomaticLanguage=true)
const SwDocInfoSubType DI_SUB_DATE
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
bool IsAutomaticLanguage() const
virtual sal_uInt16 GetSubType() const
#define FIELD_COLUMN_WIDTH
const SwDocInfoSubType DI_SUB_AUTHOR
SwWrtShell * GetWrtShell()
const SwDocInfoSubType DI_SUBTYPE_BEGIN
NB: these must denote consecutive integers! NB2: these are extended by 4 DI_INFO values for backward ...
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
const SwDocInfoSubType DI_DOCNO
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::TreeIter > m_xSelEntry
std::unique_ptr< weld::TreeView > m_xTypeTLB
virtual void FillUserData() override
OUString m_sOldCustomFieldName
const SwDocInfoSubType DI_SUB_FIXED
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
#define USER_DATA_VERSION
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
#define FN_FIELD_DIALOG_DOC_PROPS