31#define USER_DATA_VERSION_1 "1"
32#define USER_DATA_VERSION USER_DATA_VERSION_1
37 :
SwFieldPage(pPage, pController,
"modules/swriter/ui/fldfuncpage.ui",
"FieldFuncPage", pCoreSet)
39 , m_bDropDownLBChanged(false)
40 , m_xTypeLB(m_xBuilder->weld_tree_view(
"type"))
41 , m_xSelectionLB(m_xBuilder->weld_tree_view(
"select"))
42 , m_xFormat(m_xBuilder->weld_widget(
"formatframe"))
43 , m_xFormatLB(m_xBuilder->weld_tree_view(
"format"))
44 , m_xNameFT(m_xBuilder->weld_label(
"nameft"))
45 , m_xNameED(new
ConditionEdit(m_xBuilder->weld_entry(
"condFunction")))
46 , m_xValueGroup(m_xBuilder->weld_widget(
"valuegroup"))
47 , m_xValueFT(m_xBuilder->weld_label(
"valueft"))
48 , m_xValueED(m_xBuilder->weld_entry(
"value"))
49 , m_xCond1FT(m_xBuilder->weld_label(
"cond1ft"))
50 , m_xCond1ED(new
ConditionEdit(m_xBuilder->weld_entry(
"cond1")))
51 , m_xCond2FT(m_xBuilder->weld_label(
"cond2ft"))
52 , m_xCond2ED(new
ConditionEdit(m_xBuilder->weld_entry(
"cond2")))
53 , m_xMacroBT(m_xBuilder->weld_button(
"macro"))
54 , m_xListGroup(m_xBuilder->weld_widget(
"listgroup"))
55 , m_xListItemED(m_xBuilder->weld_entry(
"item"))
56 , m_xListAddPB(m_xBuilder->weld_button(
"add"))
57 , m_xListItemsLB(m_xBuilder->weld_tree_view(
"listitems"))
58 , m_xListRemovePB(m_xBuilder->weld_button(
"remove"))
59 , m_xListUpPB(m_xBuilder->weld_button(
"up"))
60 , m_xListDownPB(m_xBuilder->weld_button(
"down"))
61 , m_xListNameED(m_xBuilder->weld_entry(
"listname"))
69 auto nHeight =
m_xTypeLB->get_height_rows(10);
70 m_xTypeLB->set_size_request(nWidth, nHeight);
147 if(nVal != USHRT_MAX)
149 for (sal_Int32
i = 0, nEntryCount =
m_xTypeLB->n_children();
i < nEntryCount; ++
i)
193 const sal_Int32 nOld = GetTypeSel();
196 SetTypeSel(m_xTypeLB->get_selected_index());
198 if(GetTypeSel() == -1)
201 m_xTypeLB->select(0);
204 if (nOld == GetTypeSel())
213 m_xFormatLB->clear();
215 const sal_uInt16 nSize = GetFieldMgr().GetFormatCount(nTypeId, IsFieldDlgHtmlMode());
217 for (sal_uInt16
i = 0;
i < nSize;
i++)
219 m_xFormatLB->append(OUString::number(GetFieldMgr().GetFormatId(nTypeId,
i)),
220 GetFieldMgr().GetFormatStr(nTypeId,
i));
228 if (m_xFormatLB->get_selected_index() == -1)
229 m_xFormatLB->select(0);
232 bool bValue =
false, bName =
false, bMacro =
false, bInsert =
true;
233 bool bFormat = nSize != 0;
239 m_xCond1FT->set_visible(!bDropDown && bCondTextField);
240 m_xCond1ED->set_visible(!bDropDown && bCondTextField);
241 m_xCond2FT->set_visible(!bDropDown && bCondTextField);
242 m_xCond2ED->set_visible(!bDropDown && bCondTextField);
243 m_xValueGroup->set_visible(!bDropDown && !bCondTextField);
244 m_xMacroBT->set_visible(!bDropDown);
245 m_xNameED->set_visible(!bDropDown);
246 m_xNameFT->set_visible(!bDropDown);
248 m_xListGroup->set_visible(bDropDown);
250 m_xNameED->SetDropEnable(
false);
258 m_xListItemsLB->clear();
259 for (
const OUString& rItem : aItems)
260 m_xListItemsLB->append_text(rItem);
262 m_xListNameED->set_text(pDrop->
GetPar2());
263 m_xListNameED->save_value();
264 m_bDropDownLBChanged =
false;
268 m_xNameED->set_text(GetCurField()->GetPar1());
269 m_xValueED->set_text(GetCurField()->GetPar2());
274 m_xNameED->set_text(OUString());
275 m_xValueED->set_text(OUString());
278 ListEnableHdl(*m_xListItemED);
280 if (m_xNameFT->get_label() != m_sOldNameFT)
281 m_xNameFT->set_label(m_sOldNameFT);
282 if (m_xValueFT->get_label() != m_sOldValueFT)
283 m_xValueFT->set_label(m_sOldValueFT);
289 if (!GetFieldMgr().GetMacroPath().isEmpty())
294 m_xNameFT->set_label(
SwResId(STR_MACNAME));
295 m_xValueFT->set_label(
SwResId(STR_PROMPT));
296 m_xNameED->set_text(GetFieldMgr().GetMacroName());
297 m_xNameED->set_accessible_name(m_xNameFT->get_label());
298 m_xValueED->set_accessible_name(m_xValueFT->get_label());
302 m_xNameFT->set_label(
SwResId(STR_COND));
303 m_xNameED->SetDropEnable(
true);
305 m_xNameED->set_accessible_name(m_xNameFT->get_label());
306 m_xValueED->set_accessible_name(m_xValueFT->get_label());
311 m_xNameFT->set_label(
SwResId(STR_COND));
312 m_xNameED->SetDropEnable(
true);
313 m_xValueFT->set_label(
SwResId(STR_INSTEXT));
315 if (!IsFieldEdit() && pSh)
317 bName = bValue =
true;
318 m_xNameED->set_accessible_name(m_xNameFT->get_label());
319 m_xValueED->set_accessible_name(m_xValueFT->get_label());
324 m_xNameFT->set_label(
SwResId(STR_COND));
325 m_xNameED->SetDropEnable(
true);
329 m_xCond1ED->set_text(GetCurField()->GetPar2().
getToken(0,
'|', nIdx));
330 m_xCond2ED->set_text(GetCurField()->GetPar2().
getToken(0,
'|', nIdx));
333 bName = bValue =
true;
334 m_xNameED->set_accessible_name(m_xNameFT->get_label());
335 m_xValueED->set_accessible_name(m_xValueFT->get_label());
339 m_xNameFT->set_label(
SwResId(STR_JUMPEDITFLD));
340 m_xValueFT->set_label(
SwResId(STR_PROMPT));
341 bName = bValue =
true;
342 m_xNameED->set_accessible_name(m_xNameFT->get_label());
343 m_xValueED->set_accessible_name(m_xValueFT->get_label());
347 m_xValueFT->set_label(
SwResId(STR_PROMPT));
349 m_xNameED->set_accessible_name(m_xNameFT->get_label());
350 m_xValueED->set_accessible_name(m_xValueFT->get_label());
355 m_xNameFT->set_label(
SwResId(STR_COMBCHRS_FT));
356 m_xNameED->SetDropEnable(
true);
359 const sal_Int32 nLen = m_xNameED->get_text().getLength();
362 m_xNameED->set_accessible_name(m_xNameFT->get_label());
363 m_xValueED->set_accessible_name(m_xValueFT->get_label());
372 m_xSelectionLB->hide();
374 m_xFormat->set_sensitive(bFormat);
375 m_xNameFT->set_sensitive(bName);
376 m_xNameED->set_sensitive(bName);
377 m_xValueGroup->set_sensitive(bValue);
378 m_xMacroBT->set_sensitive(bMacro);
380 EnableInsert( bInsert );
388 m_xNameED->set_text( m_xSelectionLB->get_selected_text() );
393 SelectHdl(*m_xSelectionLB);
400 ListModifyHdl(&rControl);
405 ListModifyHdl(&rControl);
439 if( nSelPos < m_xListItemsLB->n_children() - 1)
455 ListEnableHdl(*m_xListItemED);
461 m_xListAddPB->set_sensitive(!m_xListItemED->get_text().isEmpty() &&
462 -1 == m_xListItemsLB->find_text(m_xListItemED->get_text()));
463 bool bEnableButtons = m_xListItemsLB->get_selected_index() != -1;
464 m_xListRemovePB->set_sensitive(bEnableButtons);
465 m_xListUpPB->set_sensitive(bEnableButtons && (m_xListItemsLB->get_selected_index() > 0));
466 m_xListDownPB->set_sensitive(bEnableButtons &&
467 (m_xListItemsLB->get_selected_index() < (m_xListItemsLB->n_children() - 1)));
479 std::vector<OUString> aLst;
481 const size_t nCount = aLst.size();
487 bool bEnable =
nCount != 0;
518 sal_uInt16 nSubType = 0;
520 const sal_Int32 nEntryPos =
m_xFormatLB->get_selected_index();
521 const sal_uInt32 nFormat = (nEntryPos == -1)
548 for (sal_Int32
i = 0, nEntryCount =
m_xListItemsLB->n_children();
i < nEntryCount; ++
i)
561 m_xNameED->get_value_changed_from_saved() ||
580 return std::make_unique<SwFieldFuncPage>(pPage, pController, pAttrSet);
590 const sal_Int32 nEntryPos =
m_xTypeLB->get_selected_index();
591 const sal_uInt16 nTypeSel = ( -1 == nEntryPos )
593 :
m_xTypeLB->get_id(nEntryPos).toUInt32();
599 const sal_Int32 nLen = m_xNameED->get_text().getLength();
608 EnableInsert( bEnable );
void SetUserData(const OUString &rString)
const OUString & GetUserData() const
OUString GetSelText() const
get selected text of a node at current cursor
virtual OUString GetPar2() const override
Returns the name of the field.
css::uno::Sequence< OUString > GetItemSequence() const
Returns the items of the dropdown box.
const OUString & GetSelectedItem() const
Returns the selected item.
std::unique_ptr< weld::Button > m_xListAddPB
virtual ~SwFieldFuncPage() override
std::unique_ptr< weld::TreeView > m_xListItemsLB
std::unique_ptr< ConditionEdit > m_xCond2ED
virtual sal_uInt16 GetGroup() override
std::unique_ptr< weld::Label > m_xValueFT
bool m_bDropDownLBChanged
std::unique_ptr< weld::Button > m_xListDownPB
std::unique_ptr< weld::Entry > m_xValueED
virtual void FillUserData() override
std::unique_ptr< weld::Entry > m_xListItemED
std::unique_ptr< weld::Entry > m_xListNameED
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
SwFieldFuncPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
virtual void Reset(const SfxItemSet *rSet) override
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::Widget > m_xValueGroup
std::unique_ptr< weld::Button > m_xMacroBT
std::unique_ptr< weld::Label > m_xNameFT
std::unique_ptr< weld::Button > m_xListUpPB
std::unique_ptr< ConditionEdit > m_xNameED
std::unique_ptr< ConditionEdit > m_xCond1ED
std::unique_ptr< weld::TreeView > m_xFormatLB
void ListModifyHdl(const weld::Widget *)
std::unique_ptr< weld::TreeView > m_xSelectionLB
std::unique_ptr< weld::Button > m_xListRemovePB
std::unique_ptr< weld::TreeView > m_xTypeLB
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
static const OUString & GetTypeStr(sal_uInt16 nPos)
void SetMacroPath(const OUString &rPath)
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
const OUString & GetMacroPath() const
static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId)
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
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
void SavePos(const weld::TreeView &rLst1)
SwFieldMgr & GetFieldMgr()
bool IsFieldDlgHtmlMode() const
void RestorePos(weld::TreeView &rLst1)
void EnableInsert(bool bEnable)
SwFieldTypesEnum GetTypeId() const
virtual OUString GetPar1() const
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Used by the UI to modify the document model.
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
#define MAX_COMBINED_CHARACTERS
SwFieldTypesEnum
List of FieldTypes at UI.
void FillFieldSelect(weld::TreeView &rListBox)
const TranslateId FMT_MARK_ARY[]
IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView &, void)
#define USER_DATA_VERSION_1
#define USER_DATA_VERSION
IMPL_LINK(SwFieldFuncPage, ListModifyButtonHdl, weld::Button &, rControl, void)
#define FIELD_COLUMN_WIDTH
#define LINK(Instance, Class, Member)
sal_Int32 getToken(const Context &rContext, const char *pToken)
OUString ChooseMacro(weld::Window *pParent, const uno::Reference< frame::XModel > &rxLimitToDocument, const uno::Reference< frame::XFrame > &xDocFrame, bool bChooseOnly)
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)
SwWrtShell * GetActiveWrtShell()
OUString SwResId(TranslateId aId)