39#define USER_DATA_VERSION_1 "1"
40#define USER_DATA_VERSION USER_DATA_VERSION_1
43 :
SwFieldPage(pPage, pController,
"modules/swriter/ui/fldvarpage.ui",
"FieldVarPage", pCoreSet)
44 , m_xTypeLB(m_xBuilder->weld_tree_view(
"type"))
45 , m_xSelection(m_xBuilder->weld_widget(
"selectframe"))
46 , m_xSelectionLB(m_xBuilder->weld_tree_view(
"select"))
47 , m_xNameFT(m_xBuilder->weld_label(
"nameft"))
48 , m_xNameED(m_xBuilder->weld_entry(
"name"))
49 , m_xValueFT(m_xBuilder->weld_label(
"valueft"))
50 , m_xValueED(new
ConditionEdit(m_xBuilder->weld_entry(
"value")))
51 , m_xFormat(m_xBuilder->weld_widget(
"formatframe"))
53 , m_xFormatLB(m_xBuilder->weld_tree_view(
"format"))
54 , m_xChapterFrame(m_xBuilder->weld_widget(
"chapterframe"))
55 , m_xChapterLevelLB(m_xBuilder->weld_combo_box(
"level"))
56 , m_xInvisibleCB(m_xBuilder->weld_check_button(
"invisible"))
57 , m_xSeparatorFT(m_xBuilder->weld_label(
"separatorft"))
58 , m_xSeparatorED(m_xBuilder->weld_entry(
"separator"))
59 , m_xNewPB(m_xBuilder->weld_button(
"apply"))
60 , m_xDelPB(m_xBuilder->weld_button(
"delete"))
69 auto nHeight =
m_xTypeLB->get_height_rows(10);
70 m_xTypeLB->set_size_request(nWidth, nHeight);
122 assert(pCurField &&
"<SwFieldVarPage::Reset(..)> - <SwField> instance missing!");
163 std::u16string_view sVal =
o3tl::getToken(sUserData, 0,
';', nIdx);
164 sal_uInt16 nVal = o3tl::narrowing<sal_uInt16>(
o3tl::toInt32(sVal));
165 if (USHRT_MAX != nVal)
167 for (sal_Int32
i = 0, nEntryCount =
m_xTypeLB->n_children();
i < nEntryCount;
i++)
196 const sal_Int32 nOld = GetTypeSel();
199 SetTypeSel(m_xTypeLB->get_selected_index());
201 if(GetTypeSel() == -1)
204 m_xTypeLB->select(0);
207 if (nOld != GetTypeSel() || nOld == -1)
212 m_xNameED->set_text(OUString());
213 m_xValueED->set_text(OUString());
216 m_xValueED->SetDropEnable(
false);
230 sal_uInt32 nNumberFormat = 0;
232 if (nNumFormatPos != -1)
234 nNumberFormat = rNumFormatLB.
GetFormat();
235 if ((rbText = (nNumFormatPos == 0 && nNumberFormat ==
SAL_MAX_UINT32)))
238 return nNumberFormat;
245 size_t nSelData = SIZE_MAX;
267 bool bValue =
false, bName =
false, bNumFormat =
false,
268 bInvisible =
false, bShowChapterFrame =
false;
269 bool bFormat = nSize != 0;
315 bValue = bName = bNumFormat = bInvisible =
true;
324 bNumFormat = bInvisible =
true;
418 bValue = bNumFormat =
true;
443 bFormat = bNumFormat =
false;
463 OUString sCmd( pType->
GetCmd() );
464 sal_Int32 nTmpPos = 0;
473 bName = bValue =
true;
478 bName = bValue = bShowChapterFrame =
true;
486 if( !sFieldTypeName.isEmpty() )
522 if (nSelData != 0 && nSelData != SIZE_MAX)
545 m_xFormat->set_sensitive(bFormat || bNumFormat);
565 auto nSelPos = m_xSelectionLB->get_selected_index();
568 m_xValueED->replace_selection(m_xSelectionLB->get_text(nSelPos));
569 ModifyHdl(*m_xNameED);
574 TreeViewInsertHdl(rBox);
592 std::vector<OUString> aList;
594 const size_t nCount = aList.size();
605 bool bInsert =
false;
688 const sal_Int32 nFormatSel =
m_xFormatLB->get_selected_index();
689 if (nFormatSel != -1)
695 sal_uInt32 nOldNumFormat = 0;
697 if (nNumFormatSel != -1)
699 sOldNumSel = rWidget.
get_text(nNumFormatSel);
707 bool bSpecialFormat =
false;
745 rWidget.
select(nOldIndex + 2);
758 rWidget.
select(nOldIndex + 1);
769 rWidget.
select(nOldIndex + 1);
779 rWidget.
select(nOldIndex + 1);
795 if (!nOldNumFormat && (nNumFormatSel = rWidget.
find_text(sOldNumSel)) != -1)
796 rWidget.
select(nNumFormatSel);
805 for (sal_uInt16
i = 0;
i < nSize;
i++)
808 OUString
sId(OUString::number(nFieldId));
815 if (!sSelectId.isEmpty())
834 OUString sValue(m_xValueED->get_text());
835 bool bHasValue = !sValue.isEmpty();
837 bool bInsert =
false, bApply =
false, bDelete =
false;
839 OUString
sName( m_xNameED->get_text() );
840 sal_Int32 nLen =
sName.getLength();
849 if (
sName.getLength() != nLen )
851 nLen =
sName.getLength();
852 int nStartPos, nEndPos;
853 m_xNameED->get_selection_bounds(nStartPos, nEndPos);
854 m_xNameED->set_text(
sName );
855 m_xNameED->select_region(nStartPos, nEndPos);
868 bInsert = bApply =
true;
876 bDelete = !pSh->
IsUsed( *pType );
890 bDelete = !pSh->
IsUsed( *pType );
897 bInsert = bApply =
true;
924 if (pType == pFieldType)
952 m_xNewPB->set_sensitive(bApply);
953 m_xDelPB->set_sensitive(bDelete);
954 EnableInsert(bInsert);
961 if (&rBox == m_xDelPB.get())
964 GetFieldMgr().RemoveFieldType(
SwFieldIds::User, m_xSelectionLB->get_selected_text());
980 GetFieldMgr().RemoveFieldType(nWhich, m_xSelectionLB->get_selected_text());
992 else if (&rBox == m_xNewPB.get())
994 OUString
sName(m_xNameED->get_text()), sValue(m_xValueED->get_text());
997 sal_Int32 nNumFormatPos = m_xNumFormatLB->get_selected_index();
1006 pType = GetFieldMgr().GetFieldType(
nId,
sName);
1008 int nFormat = m_xFormatLB->get_selected_index();
1010 nFormat = m_xFormatLB->get_id(nFormat).toUInt32();
1023 if (nNumFormatPos != -1)
1037 static_cast<SwUserFieldType*
>(pType)->SetContent(m_xValueED->get_text(), nNumberFormat);
1048 sal_Int32 nTmpPos = 0;
1071 if (nNumFormatPos != -1)
1081 m_xSelectionLB->append_text(
sName);
1082 m_xSelectionLB->select_text(
sName);
1083 GetFieldMgr().InsertFieldType( aType );
1093 sal_Int32 nTmpPos = 0;
1098 m_xSelectionLB->append_text(
sName);
1099 m_xSelectionLB->select_text(
sName);
1100 GetFieldMgr().InsertFieldType(aType);
1105 GetFieldMgr().GetCurField();
1113 bool bEnable = m_xChapterLevelLB->get_active() != 0;
1115 m_xSeparatorED->set_sensitive(bEnable);
1116 m_xSeparatorFT->set_sensitive(bEnable);
1117 SeparatorHdl(*m_xSeparatorED);
1122 bool bEnable = !m_xSeparatorED->get_text().isEmpty() ||
1123 m_xChapterLevelLB->get_active() == 0;
1124 EnableInsert(bEnable);
1135 sal_uInt16 nSubType = (nSubPos == -1) ? 0 :
m_xSelectionLB->get_id(nSubPos).toUInt32();
1141 sal_Int32 nFormatPos =
m_xFormatLB->get_selected_index();
1143 if(nFormatPos == -1)
1146 nFormat =
m_xFormatLB->get_id(nFormatPos).toUInt32();
1197 nSubType =
static_cast< sal_uInt16
>((nSubType & 0xff00) | (pType ?
INP_USR :
INP_VAR));
1224 cSeparator = !sSeparator.isEmpty() ? sSeparator[0] :
' ';
1236 m_xNameED->get_value_changed_from_saved() ||
1237 m_xValueED->get_value_changed_from_saved() ||
1257 return std::make_unique<SwFieldVarPage>( pPage, pController, pAttrSet );
1268 sal_Int32 nTypeSel =
m_xTypeLB->get_selected_index();
1269 if( -1 == nTypeSel )
1270 nTypeSel = USHRT_MAX;
1272 nTypeSel =
m_xTypeLB->get_id(nTypeSel).toUInt32();
1273 sData += OUString::number( nTypeSel );
virtual const SwFieldTypes * GetFieldTypes() const =0
void SetUserData(const OUString &rString)
const OUString & GetUserData() const
static SW_DLLPUBLIC bool IsValidVarName(const OUString &rStr, OUString *pValidName=nullptr)
OUString const & GetCmd() const
SfxLinkUpdateMode GetType() const
virtual OUString GetName() const override
Only in derived classes.
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
void StartAllAction()
For all views of this document.
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
bool IsUsed(const sw::BroadcastingModify &) const
Query if the paragraph-/character-/frame-/page-style is used.
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
static const OUString & GetTypeStr(sal_uInt16 nPos)
SwFieldType * GetFieldType(SwFieldIds nResId, size_t nField=0) const
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
const OUString & GetCurFieldPar2() const
static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId)
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
const OUString & GetCurFieldPar1() const
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)
sal_Int32 GetSelectionSel() const
void EnableInsert(bool bEnable)
SwWrtShell * GetWrtShell()
void SetSelectionSel(sal_Int32 nSet)
Instances of SwFields and those derived from it occur 0 to n times.
virtual void UpdateFields()
virtual bool FillItemSet(SfxItemSet *rSet) override
virtual void Reset(const SfxItemSet *rSet) override
std::unique_ptr< weld::Entry > m_xNameED
void FillFormatLB(SwFieldTypesEnum nTypeId)
std::unique_ptr< weld::TreeView > m_xSelectionLB
virtual ~SwFieldVarPage() override
SwFieldVarPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
std::unique_ptr< weld::Label > m_xNameFT
std::unique_ptr< weld::Button > m_xNewPB
std::unique_ptr< weld::Button > m_xDelPB
std::unique_ptr< weld::TreeView > m_xFormatLB
std::unique_ptr< weld::Label > m_xValueFT
virtual void FillUserData() override
std::unique_ptr< weld::ComboBox > m_xChapterLevelLB
void SubTypeHdl(const weld::TreeView *)
std::unique_ptr< ConditionEdit > m_xValueED
std::unique_ptr< weld::TreeView > m_xTypeLB
std::unique_ptr< weld::CheckButton > m_xInvisibleCB
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< weld::Widget > m_xChapterFrame
virtual sal_uInt16 GetGroup() override
std::unique_ptr< SwNumFormatTreeView > m_xNumFormatLB
std::unique_ptr< weld::Entry > m_xSeparatorED
std::unique_ptr< weld::Widget > m_xSelection
std::unique_ptr< weld::Widget > m_xFormat
Base class of all fields.
SwFieldTypesEnum GetTypeId() const
bool IsAutomaticLanguage() const
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
SwFieldType * GetTyp() const
sal_uInt16 GetType() const
The shared part of a user field.
virtual OUString GetName() const override
Only in derived classes.
OUString GetContent(sal_uInt32 nFormat=0) const
sal_uInt16 GetType() const
void SetContent(const OUString &rStr, sal_uInt32 nFormat=0)
OUString GetInputOrDateTime(sal_uInt32 nFormat) const
static sal_uInt32 GetSystemFormat(SvNumberFormatter *pFormatter, sal_uInt32 nFormat)
get format in office language
Used by the UI to modify the document model.
virtual int find_text(const OUString &rText) const=0
virtual OUString get_text(int row, int col=-1) const=0
virtual void insert(const TreeIter *pParent, int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface, bool bChildrenOnDemand, TreeIter *pRet)=0
virtual void select(int pos)=0
virtual int get_selected_index() const=0
void select_text(const OUString &rText)
virtual OUString GetName() const override
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
SwFieldTypesEnum
List of FieldTypes at UI.
@ Database
For old documents the Field-Which IDs must be preserved !!!
void FillFieldSelect(weld::TreeView &rListBox)
#define FIELD_COLUMN_WIDTH
IMPL_LINK_NOARG(SwFieldVarPage, TypeHdl, weld::TreeView &, void)
#define USER_DATA_VERSION_1
#define USER_DATA_VERSION
static sal_uInt32 lcl_getUsedNumFormat(const SwNumFormatTreeView &rNumFormatLB, bool &rbText)
IMPL_LINK(SwFieldVarPage, SubTypeListBoxHdl, weld::TreeView &, rBox, void)
#define LINK(Instance, Class, Member)
const SwExtendedSubType SUB_CMD
Show command.
const SwExtendedSubType SUB_INVISIBLE
Invisible.
const SwGetSetExpType GSE_SEQ
Sequence.
const SwGetSetExpType GSE_EXPR
Expression.
const SwGetSetExpType GSE_FORMULA
Formula.
const SwGetSetExpType GSE_STRING
String.
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)
const sal_Unicode cTokenSeparator
SwWrtShell * GetActiveWrtShell()
OUString SwResId(TranslateId aId)
constexpr sal_uInt8 MAXLEVEL
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND