22 #include <strings.hrc>
31 #define USER_DATA_VERSION_1 "1"
32 #define USER_DATA_VERSION USER_DATA_VERSION_1
35 :
SwFieldPage(pPage, pController,
"modules/swriter/ui/flddocumentpage.ui",
36 "FieldDocumentPage", pCoreSet)
39 , m_xTypeLB(m_xBuilder->weld_tree_view(
"type"))
40 , m_xSelection(m_xBuilder->weld_widget(
"selectframe"))
41 , m_xSelectionLB(m_xBuilder->weld_tree_view(
"select"))
42 , m_xValueFT(m_xBuilder->weld_label(
"valueft"))
43 , m_xValueED(m_xBuilder->weld_entry(
"value"))
44 , m_xLevelFT(m_xBuilder->weld_label(
"levelft"))
45 , m_xLevelED(m_xBuilder->weld_spin_button(
"level"))
46 , m_xDateFT(m_xBuilder->weld_label(
"daysft"))
47 , m_xTimeFT(m_xBuilder->weld_label(
"minutesft"))
48 , m_xDateOffsetED(m_xBuilder->weld_spin_button(
"offset"))
49 , m_xFormat(m_xBuilder->weld_widget(
"formatframe"))
50 , m_xFormatLB(m_xBuilder->weld_tree_view(
"format"))
52 , m_xFixedCB(m_xBuilder->weld_check_button(
"fixed"))
58 auto nHeight =
m_xTypeLB->get_height_rows(10);
60 m_xTypeLB->set_size_request(nWidth, nHeight);
160 if(nVal != USHRT_MAX)
162 for (
int i = 0, nEntryCount =
m_xTypeLB->n_children();
i < nEntryCount;
i++)
189 const sal_Int32 nOld = GetTypeSel();
192 SetTypeSel(m_xTypeLB->get_selected_index());
194 if(GetTypeSel() == -1)
197 m_xTypeLB->select(0);
200 if (nOld == GetTypeSel())
211 m_xSelectionLB->clear();
215 std::vector<OUString> aLst;
216 GetFieldMgr().GetSubTypes(nTypeId, aLst);
219 nCount = aLst.size();
221 nCount = GetFieldMgr().GetFormatCount(nTypeId, IsFieldDlgHtmlMode());
223 for (
size_t i = 0;
i < nCount; ++
i)
227 OUString
sId(OUString::number(
i));
229 m_xSelectionLB->append(sId, aLst[
i]);
231 m_xSelectionLB->append(sId, GetFieldMgr().GetFormatStr(nTypeId, i));
235 bool bInsert =
false;
237 OUString
sId(OUString::number(
i));
243 m_xSelectionLB->append(sId, aLst[
i]);
244 if (static_cast<SwDateTimeField*>(GetCurField())->IsFixed() && !i)
245 m_xSelectionLB->select_id(sId);
246 if (!static_cast<SwDateTimeField*>(GetCurField())->IsFixed() && i)
247 m_xSelectionLB->select_id(sId);
251 m_xSelectionLB->append(sId, aLst[i]);
252 if (GetCurField()->GetSubType() == i)
253 m_xSelectionLB->select_id(sId);
258 const OUString sFormat(GetFieldMgr().GetFormatStr(nTypeId, i));
259 m_xSelectionLB->append(sId, sFormat);
260 m_xSelectionLB->select_text(GetFieldMgr().GetFormatStr(nTypeId, GetCurField()->
GetFormat()));
265 if (aLst[i] == GetCurField()->GetPar1())
271 m_xSelectionLB->append(sId, aLst[
i]);
283 nTypeId =
static_cast<SwFieldTypesEnum>(m_xSelectionLB->get_id(0).toUInt32());
288 bool bEnable = nCount != 0;
290 if (bEnable && m_xSelectionLB->get_selected_index() == -1)
291 m_xSelectionLB->select(0);
293 m_xSelection->set_sensitive( bEnable );
296 sal_Int32 nSize = FillFormatLB(nTypeId);
298 bool bValue =
false, bLevel =
false, bNumFormat =
false, bOffset =
false;
299 bool bFormat = nSize != 0;
300 bool bOneArea =
false;
307 bFormat = bNumFormat = bOneArea = bOffset =
true;
309 nFormatType = SvNumFormatType::DATE;
313 m_xDateOffsetED->set_range(INT_MIN, INT_MAX);
316 m_xDateOffsetED->set_value( static_cast<SwDateTimeField*>(GetCurField())->GetOffset() / 24 / 60);
320 bFormat = bNumFormat = bOneArea = bOffset =
true;
322 nFormatType = SvNumFormatType::TIME;
326 m_xDateOffsetED->set_range(-1440, 1440);
329 m_xDateOffsetED->set_value( static_cast<SwDateTimeField*>(GetCurField())->GetOffset() );
336 const sal_uInt16 nTmp = m_xFormatLB->get_selected_id().toUInt32();
340 sal_Int32 nOff = GetCurField()->GetPar2().toInt32();
342 m_xValueED->set_text(
343 OUString::number(nOff - 1) );
345 m_xValueED->set_text(
346 OUString::number(nOff + 1) );
348 m_xValueED->set_text(OUString());
351 m_xValueED->set_text(static_cast<SwPageNumberField*>(GetCurField())->GetUserString());
357 m_xValueFT->set_label(
SwResId(STR_LEVEL));
359 m_xLevelED->set_text(OUString::number(static_cast<SwChapterField*>(GetCurField())->GetLevel(GetWrtShell()->GetLayout()) + 1));
364 m_xValueFT->set_label(
SwResId( STR_OFFSET ));
366 m_xValueED->set_text(GetCurField()->GetPar2());
384 m_xNumFormatLB->SetDefFormat(GetCurField()->
GetFormat());
386 if (m_xNumFormatLB->GetFormatType() == (SvNumFormatType::DATE|SvNumFormatType::TIME))
390 m_xNumFormatLB->SetFormatType(SvNumFormatType::ALL);
391 m_xNumFormatLB->SetFormatType(nFormatType);
393 m_xNumFormatLB->SetDefFormat(GetCurField()->
GetFormat());
397 m_xNumFormatLB->SetFormatType(nFormatType);
399 m_xNumFormatLB->SetOneArea(bOneArea);
402 m_xFormatLB->set_visible(!bNumFormat);
403 m_xNumFormatLB->set_visible(bNumFormat);
405 m_xValueFT->set_visible(bValue);
406 m_xValueED->set_visible(bValue);
407 m_xLevelFT->set_visible(bLevel);
408 m_xLevelED->set_visible(bLevel);
409 m_xDateOffsetED->set_visible(bOffset);
410 m_xFixedCB->set_visible(!bValue && !bLevel && !bOffset);
412 m_xFormat->set_sensitive(bFormat);
413 m_xFixedCB->set_sensitive(bFixed);
418 if (m_xNumFormatLB->get_selected_index() == -1)
419 m_xNumFormatLB->select(0);
420 m_xValueFT->set_sensitive(bValue || bLevel || bOffset);
421 m_xValueED->set_sensitive(bValue);
431 sal_Int32
nPos = m_xSelectionLB->get_selected_index();
436 FillFormatLB(nTypeId);
442 pTextRes = STR_LEVEL;
448 ? STR_VALUE : STR_OFFSET;
452 pTextRes = STR_OFFSET;
458 m_xValueFT->set_label(
SwResId(pTextRes));
471 for( sal_uInt16
i = 0;
i < nSize; ++
i )
474 OUString
sId(OUString::number(nFormatId));
507 sal_Int32
nPos = m_xSelectionLB->get_selected_index();
511 nTypeId =
static_cast<SwFieldTypesEnum>(m_xSelectionLB->get_id(nPos).toUInt32());
518 sal_uInt16 nTmp = m_xFormatLB->get_selected_id().toUInt32();
519 const OUString sOldText( m_xValueFT->get_label() );
523 if (sOldText != sNewText)
524 m_xValueFT->set_label(sNewText);
526 if (sOldText != m_xValueFT->get_label())
527 m_xValueED->set_text(OUString());
544 sal_uInt16 nSubType = 0;
580 aVal = OUString::number(nVal * 60 * 24);
582 aVal = OUString::number(nVal);
594 sal_Int32 nVal =
m_xValueED->get_text().toInt32();
595 aVal = OUString::number(nVal);
625 return std::make_unique<SwFieldDokPage>(pPage, pController, pAttrSet);
635 const sal_Int32 nEntryPos =
m_xTypeLB->get_selected_index();
636 const sal_uInt16 nTypeSel = ( -1 == nEntryPos )
637 ? USHRT_MAX :
m_xTypeLB->get_id(nEntryPos).toUInt32();
#define LINK(Instance, Class, Member)
virtual sal_uInt16 GetGroup() override
IMPL_LINK_NOARG(SwFieldDokPage, TypeHdl, weld::TreeView &, void)
virtual void FillUserData() override
#define USER_DATA_VERSION
void RestorePos(weld::TreeView &rLst1)
void SetUserData(const OUString &rString)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
virtual void Reset(const SfxItemSet *rSet) override
Base class of all fields.
std::unique_ptr< weld::CheckButton > m_xFixedCB
SwWrtShell * GetActiveWrtShell()
constexpr sal_uInt8 MAXLEVEL
static const OUString & GetTypeStr(sal_uInt16 nPos)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId)
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
virtual ~SwFieldDokPage() override
void AddSubType(SwFieldTypesEnum nTypeId)
Used by the UI to modify the document model.
OUString SwResId(TranslateId aId)
SwFieldMgr & GetFieldMgr()
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
std::unique_ptr< SwNumFormatTreeView > m_xNumFormatLB
std::unique_ptr< weld::TreeView > m_xSelectionLB
const OUString & GetUserData() const
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
std::unique_ptr< weld::Entry > m_xValueED
bool IsFieldDlgHtmlMode() const
std::unique_ptr< weld::SpinButton > m_xLevelED
void SavePos(const weld::TreeView &rLst1)
SwFieldTypesEnum
List of FieldTypes at UI.
void InsertField(SwFieldTypesEnum nTypeId, sal_uInt16 nSubType, const OUString &rPar1, const OUString &rPar2, sal_uInt32 nFormatId, sal_Unicode cDelim= ' ', bool bIsAutomaticLanguage=true)
sal_Int32 GetTypeSel() const
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
bool IsAutomaticLanguage() const
#define FIELD_COLUMN_WIDTH
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
std::unique_ptr< weld::TreeView > m_xFormatLB
SwFieldTypesEnum GetTypeId() const
SwWrtShell * GetWrtShell()
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
#define USER_DATA_VERSION_1
std::unique_ptr< weld::TreeView > m_xTypeLB
SwFieldDokPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
std::unique_ptr< weld::SpinButton > m_xDateOffsetED
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
sal_Int32 FillFormatLB(SwFieldTypesEnum nTypeId)
virtual bool FillItemSet(SfxItemSet *rSet) override