21 #include <sfx2/sfxsids.hrc>
26 #include <flddinf.hrc>
27 #include <strings.hrc>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/beans/XPropertySetInfo.hpp>
35 #include <com/sun/star/util/Time.hpp>
36 #include <com/sun/star/util/DateTime.hpp>
37 #include <com/sun/star/util/Date.hpp>
39 #define USER_DATA_VERSION_1 "1"
40 #define USER_DATA_VERSION USER_DATA_VERSION_1
52 :
SwFieldPage(pPage, pController,
"modules/swriter/ui/flddocinfopage.ui",
"FieldDocInfoPage", pCoreSet)
55 , m_xTypeTLB(m_xBuilder->weld_tree_view(
"type"))
56 , m_xSelection(m_xBuilder->weld_widget(
"selectframe"))
57 , m_xSelectionLB(m_xBuilder->weld_tree_view(
"select"))
58 , m_xFormat(m_xBuilder->weld_widget(
"formatframe"))
60 , m_xFixedCB(m_xBuilder->weld_check_button(
"fixed"))
66 auto nHeight =
m_xTypeTLB->get_height_rows(10);
68 m_xFormatLB->get_widget().set_size_request(nWidth * 2, nHeight);
99 nSubType =
static_cast<const SwDocInfoField*
>(pCurField)->GetSubType() & 0xff;
114 sal_Int32 nSelEntryData = -1;
119 nSelEntryData = sUserData.getToken(0,
';', nIdx).toInt32();
122 std::vector<OUString> aLst;
124 std::unique_ptr<weld::TreeIter> xEntry(
m_xTypeTLB->make_iterator());
125 std::unique_ptr<weld::TreeIter> xExpandEntry;
126 for(
size_t i = 0;
i < aLst.size(); ++
i)
130 const OUString
sId(OUString::number(
i));
135 uno::Reference< beans::XPropertySetInfo > xSetInfo =
xCustomPropertySet->getPropertySetInfo();
136 const uno::Sequence< beans::Property > rProperties = xSetInfo->getProperties();
138 if( rProperties.hasElements() )
140 std::unique_ptr<weld::TreeIter> xInfo(
m_xTypeTLB->make_iterator());
142 OUString sText(
SwResId(STR_CUSTOM_FIELD));
143 OUString sEntryId(OUString::number(
USHRT_MAX));
144 m_xTypeTLB->insert(
nullptr, -1, &sText, &sEntryId,
nullptr,
145 nullptr,
false, xInfo.get());
146 for (
const auto& rProperty : rProperties)
148 const OUString sEntry = rProperty.Name;
150 m_xTypeTLB->insert(xInfo.get(), -1, &sEntry, &sId,
151 nullptr,
nullptr,
false, xEntry.get());
155 xExpandEntry =
m_xTypeTLB->make_iterator(xInfo.get());
166 nullptr,
nullptr,
false, xEntry.get());
169 if (static_cast<size_t>(nSelEntryData) ==
i)
183 nSubType =
m_xTypeTLB->get_id(*m_xSelEntry).toUInt32();
189 nSubType =
m_xTypeTLB->get_id(*m_xSelEntry).toUInt32();
215 if (!m_xTypeTLB->get_selected(m_xSelEntry.get()) &&
216 m_xTypeTLB->get_iter_first(*m_xSelEntry))
218 m_xTypeTLB->select(*m_xSelEntry);
220 FillSelectionLB(m_xTypeTLB->get_id(*m_xSelEntry).toUInt32());
221 SubTypeHdl(*m_xSelectionLB);
226 sal_uInt16 nSubType = m_xTypeTLB->get_id(*m_xSelEntry).toUInt32();
227 sal_Int32
nPos = m_xSelectionLB->get_selected_index();
228 sal_uInt16 nExtSubType;
235 if (!m_xSelectionLB->n_children())
237 m_xFormatLB->clear();
238 m_xFormat->set_sensitive(
false);
242 const OUString
sName = m_xTypeTLB->get_text(*m_xSelEntry);
245 uno::Any aVal = xCustomPropertySet->getPropertyValue( sName );
246 const uno::Type& rValueType = aVal.getValueType();
249 nNewType = SvNumFormatType::DATETIME;
253 nNewType = SvNumFormatType::DATE;
257 nNewType = SvNumFormatType::TIME;
260 catch(
const uno::Exception& )
270 nExtSubType = m_xSelectionLB->get_id(nPos).toUInt32();
276 bool bEnable =
false;
277 bool bOneArea =
false;
279 if (m_xFormatLB->get_active())
280 nOldType = m_xFormatLB->GetFormatType();
288 nNewType = SvNumFormatType::DATE;
293 nNewType = SvNumFormatType::TIME;
297 if (nNewType == SvNumFormatType::ALL)
299 m_xFormatLB->clear();
303 if (nOldType != nNewType)
305 m_xFormatLB->SetFormatType(nNewType);
306 m_xFormatLB->SetOneArea(bOneArea);
311 sal_uInt32 nFormat = IsFieldEdit() ?
static_cast<SwDocInfoField*
>(GetCurField())->GetFormat() : 0;
313 sal_uInt16 nOldSubType = IsFieldEdit() ? (
static_cast<SwDocInfoField*
>(GetCurField())->GetSubType() & 0xff00) : 0;
317 nPos = m_xSelectionLB->get_selected_index();
320 nSubType = m_xSelectionLB->get_id(nPos).toUInt32();
323 if (nOldSubType == nSubType)
325 if (!nFormat && (nNewType == SvNumFormatType::DATE || nNewType == SvNumFormatType::TIME))
332 if (nNewType == SvNumFormatType::DATE)
334 else if (nNewType == SvNumFormatType::TIME)
338 m_xFormatLB->SetDefFormat(nFormat);
341 else if( (nSubType ==
DI_CUSTOM) && (nNewType != SvNumFormatType::ALL) )
343 m_xFormatLB->SetDefFormat(nFormat);
347 m_xFormat->set_sensitive(bEnable);
349 if (bEnable && m_xFormatLB->get_selected_index() == -1)
350 m_xFormatLB->select(0);
365 sal_uInt16 nSize = 0;
366 sal_Int32 nSelPos = -1;
372 nExtSubType = ((nExtSubType & ~DI_SUB_FIXED) >> 8) - 1;
382 for (sal_uInt16
i = 0;
i < nSize; ++
i)
391 bool bEnable = nSize != 0;
410 sal_uInt16 nSubType =
m_xTypeTLB->get_id(*m_xSelEntry).toUInt32();
414 sal_uInt32 nFormat = 0;
446 return std::make_unique<SwFieldDokInfPage>(pPage, pController, pAttrSet);
456 int nEntry =
m_xTypeTLB->get_selected_index();
#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::unique_ptr< SwNumFormatTreeView > m_xFormatLB
const SwDocInfoSubType DI_EDIT
sal_Int32 FillSelectionLB(sal_uInt16 nSubTypeId)
Used by the UI to modify the document model.
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
OUString SwResId(const char *pId)
bool IsAutomaticLanguage() 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 ...
const SwDocInfoSubType DI_DOCNO
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
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)