35 #include <strings.hrc>
37 #define USER_DATA_VERSION_1 "1"
38 #define USER_DATA_VERSION USER_DATA_VERSION_1
41 :
SwFieldPage(pPage, pController,
"modules/swriter/ui/fldvarpage.ui",
"FieldVarPage", pCoreSet)
42 , m_xTypeLB(m_xBuilder->weld_tree_view(
"type"))
43 , m_xSelection(m_xBuilder->weld_widget(
"selectframe"))
44 , m_xSelectionLB(m_xBuilder->weld_tree_view(
"select"))
45 , m_xNameFT(m_xBuilder->weld_label(
"nameft"))
46 , m_xNameED(m_xBuilder->weld_entry(
"name"))
47 , m_xValueFT(m_xBuilder->weld_label(
"valueft"))
48 , m_xValueED(new
ConditionEdit(m_xBuilder->weld_entry(
"value")))
49 , m_xFormat(m_xBuilder->weld_widget(
"formatframe"))
51 , m_xFormatLB(m_xBuilder->weld_tree_view(
"format"))
52 , m_xChapterFrame(m_xBuilder->weld_widget(
"chapterframe"))
53 , m_xChapterLevelLB(m_xBuilder->weld_combo_box(
"level"))
54 , m_xInvisibleCB(m_xBuilder->weld_check_button(
"invisible"))
55 , m_xSeparatorFT(m_xBuilder->weld_label(
"separatorft"))
56 , m_xSeparatorED(m_xBuilder->weld_entry(
"separator"))
57 , m_xNewPB(m_xBuilder->weld_button(
"apply"))
58 , m_xDelPB(m_xBuilder->weld_button(
"delete"))
67 auto nHeight =
m_xTypeLB->get_height_rows(10);
68 m_xTypeLB->set_size_request(nWidth, nHeight);
112 assert(pCurField &&
"<SwFieldVarPage::Reset(..)> - <SwField> instance missing!");
153 OUString sVal = sUserData.getToken(0,
';', nIdx);
154 sal_uInt16 nVal =
static_cast<sal_uInt16
>(sVal.toInt32());
157 for (sal_Int32
i = 0, nEntryCount =
m_xTypeLB->n_children();
i < nEntryCount;
i++)
186 const sal_Int32 nOld = GetTypeSel();
189 SetTypeSel(m_xTypeLB->get_selected_index());
191 if(GetTypeSel() == -1)
194 m_xTypeLB->select(0);
197 if (nOld != GetTypeSel() || nOld == -1)
202 m_xNameED->set_text(OUString());
203 m_xValueED->set_text(OUString());
206 m_xValueED->SetDropEnable(
false);
222 size_t nSelData = SIZE_MAX;
244 bool bValue =
false, bName =
false, bNumFormat =
false,
245 bInvisible =
false, bShowChapterFrame =
false;
246 bool bFormat = nSize != 0;
284 bValue = bName = bNumFormat = bInvisible =
true;
293 bNumFormat = bInvisible =
true;
392 bValue = bNumFormat =
true;
417 bFormat = bNumFormat =
false;
437 OUString sCmd( pType->
GetCmd() );
438 sal_Int32 nTmpPos = 0;
447 bName = bValue =
true;
452 bName = bValue = bShowChapterFrame =
true;
460 if( !sFieldTypeName.isEmpty() )
496 if (nSelData != 0 && nSelData != SIZE_MAX)
519 m_xFormat->set_sensitive(bFormat || bNumFormat);
539 auto nSelPos = m_xSelectionLB->get_selected_index();
542 m_xValueED->replace_selection(m_xSelectionLB->get_text(nSelPos));
543 ModifyHdl(*m_xNameED);
548 TreeViewInsertHdl(rBox);
566 std::vector<OUString> aList;
568 const size_t nCount = aList.size();
569 for (
size_t i = 0;
i < nCount; ++
i)
579 bool bInsert =
false;
610 && ((static_cast<SwRefPageSetField*>(
GetCurField())->IsOn()
611 &&
i) || (!static_cast<SwRefPageSetField*>(
GetCurField())
662 const sal_Int32 nFormatSel =
m_xFormatLB->get_selected_index();
663 if (nFormatSel != -1)
669 sal_uInt32 nOldNumFormat = 0;
671 if (nNumFormatSel != -1)
673 sOldNumSel = rWidget.
get_text(nNumFormatSel);
681 bool bSpecialFormat =
false;
715 rWidget.
insert(0,
SwResId(FMT_MARK_TEXT), &sId,
nullptr,
nullptr);
716 rWidget.
insert(1,
SwResId(FMT_USERVAR_CMD), &sId,
nullptr,
nullptr);
726 rWidget.
insert(0,
SwResId(FMT_SETVAR_TEXT), &sId,
nullptr,
nullptr);
734 rWidget.
insert(0,
SwResId(FMT_GETVAR_NAME), &sId,
nullptr,
nullptr);
741 rWidget.
insert(0,
SwResId(FMT_GETVAR_NAME), &sId,
nullptr,
nullptr);
757 if (!nOldNumFormat && (nNumFormatSel = rWidget.
find_text(sOldNumSel)) != -1)
758 rWidget.
select(nNumFormatSel);
767 for (sal_uInt16
i = 0;
i < nSize;
i++)
770 OUString
sId(OUString::number(nFieldId));
777 if (!sSelectId.isEmpty())
796 OUString sValue(m_xValueED->get_text());
797 bool bHasValue = !sValue.isEmpty();
799 bool bInsert =
false, bApply =
false, bDelete =
false;
801 OUString
sName( m_xNameED->get_text() );
802 sal_Int32 nLen =
sName.getLength();
811 if (
sName.getLength() != nLen )
813 nLen =
sName.getLength();
814 int nStartPos, nEndPos;
815 m_xNameED->get_selection_bounds(nStartPos, nEndPos);
816 m_xNameED->set_text(
sName );
817 m_xNameED->select_region(nStartPos, nEndPos);
830 bInsert = bApply =
true;
838 bDelete = !pSh->
IsUsed( *pType );
852 bDelete = !pSh->
IsUsed( *pType );
859 bInsert = bApply =
true;
886 if (pType == pFieldType)
890 if (i >= INIT_FLDTYPES && !pSh->
IsUsed(*pFieldType))
914 m_xNewPB->set_sensitive(bApply);
915 m_xDelPB->set_sensitive(bDelete);
916 EnableInsert(bInsert);
923 if (&rBox == m_xDelPB.get())
926 GetFieldMgr().RemoveFieldType(
SwFieldIds::User, m_xSelectionLB->get_selected_text());
942 GetFieldMgr().RemoveFieldType(nWhich, m_xSelectionLB->get_selected_text());
954 else if (&rBox == m_xNewPB.get())
956 OUString
sName(m_xNameED->get_text()), sValue(m_xValueED->get_text());
959 sal_Int32 nNumFormatPos = m_xNumFormatLB->get_selected_index();
968 pType = GetFieldMgr().GetFieldType(nId,
sName);
970 int nFormat = m_xFormatLB->get_selected_index();
972 nFormat = m_xFormatLB->get_id(nFormat).toUInt32();
985 if (nNumFormatPos != -1)
987 sal_uLong nNumberFormat = nNumFormatPos == 0 ? 0 : m_xNumFormatLB->GetFormat();
994 static_cast<SwUserFieldType*
>(pType)->SetContent(m_xValueED->get_text(), nNumberFormat);
1005 sal_Int32 nTmpPos = 0;
1009 static_cast<SwDDEFieldType*
>(pType)->SetType(static_cast<SfxLinkUpdateMode>(nFormat));
1028 if (nNumFormatPos != -1)
1031 aType.SetContent( sValue, nNumFormatPos == 0 ? 0 : m_xNumFormatLB->GetFormat() );
1032 m_xSelectionLB->append_text(
sName);
1033 m_xSelectionLB->select_text(
sName);
1034 GetFieldMgr().InsertFieldType( aType );
1044 sal_Int32 nTmpPos = 0;
1049 m_xSelectionLB->append_text(
sName);
1050 m_xSelectionLB->select_text(
sName);
1051 GetFieldMgr().InsertFieldType(aType);
1056 GetFieldMgr().GetCurField();
1064 bool bEnable = m_xChapterLevelLB->get_active() != 0;
1066 m_xSeparatorED->set_sensitive(bEnable);
1067 m_xSeparatorFT->set_sensitive(bEnable);
1068 SeparatorHdl(*m_xSeparatorED);
1073 bool bEnable = !m_xSeparatorED->get_text().isEmpty() ||
1074 m_xChapterLevelLB->get_active() == 0;
1075 EnableInsert(bEnable);
1086 sal_uInt16 nSubType = (nSubPos == -1) ? 0 :
m_xSelectionLB->get_id(nSubPos).toUInt32();
1092 sal_Int32 nFormatPos =
m_xFormatLB->get_selected_index();
1094 if(nFormatPos == -1)
1097 nFormat =
m_xFormatLB->get_id(nFormatPos).toUInt32();
1148 nSubType =
static_cast< sal_uInt16
>((nSubType & 0xff00) | (pType ?
INP_USR :
INP_VAR));
1175 cSeparator = !sSeparator.isEmpty() ? sSeparator[0] :
' ';
1187 m_xNameED->get_value_changed_from_saved() ||
1188 m_xValueED->get_value_changed_from_saved() ||
1208 return std::make_unique<SwFieldVarPage>( pPage, pController, pAttrSet );
1219 sal_Int32 nTypeSel =
m_xTypeLB->get_selected_index();
1220 if( -1 == nTypeSel )
1223 nTypeSel =
m_xTypeLB->get_id(nTypeSel).toUInt32();
1224 sData += OUString::number( nTypeSel );
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
SwFieldType * GetFieldType(SwFieldIds nResId, size_t nField=0) const
#define LINK(Instance, Class, Member)
Instances of SwFields and those derived from it occur 0 to n times.
The shared part of a user field.
void RestorePos(weld::TreeView &rLst1)
virtual OUString GetName() const override
Only in derived classes.
virtual sal_uInt16 GetGroup() override
void SetUserData(const OUString &rString)
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
const SwExtendedSubType SUB_INVISIBLE
Invisible.
virtual void insert(const TreeIter *pParent, int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface, bool bChildrenOnDemand, TreeIter *pRet)=0
sal_uInt16 GetType() const
virtual void Reset(const SfxItemSet *rSet) override
std::unique_ptr< weld::TreeView > m_xTypeLB
const sal_Unicode cTokenSeparator
Base class of all fields.
SwWrtShell * GetActiveWrtShell()
virtual void FillUserData() override
SfxLinkUpdateMode GetType() const
SwFieldVarPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
static sal_uInt16 GetPos(SwFieldTypesEnum nTypeId)
virtual bool FillItemSet(SfxItemSet *rSet) override
IMPL_LINK(SwFieldVarPage, SubTypeListBoxHdl, weld::TreeView &, rBox, void)
For old documents the Field-Which IDs must be preserved !!!
std::unique_ptr< weld::Entry > m_xSeparatorED
void UpdateFields() const
Used by the UI to modify the document model.
OUString const & GetCmd() const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
SwFieldMgr & GetFieldMgr()
#define USER_DATA_VERSION_1
std::unique_ptr< ConditionEdit > m_xValueED
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
std::unique_ptr< weld::Label > m_xValueFT
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
bool IsUsed(const sw::BroadcastingModify &) const
Query if the paragraph-/character-/frame-/page-style is used.
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
void SetSelectionSel(sal_Int32 nSet)
void FillFormatLB(SwFieldTypesEnum nTypeId)
const OUString & GetUserData() const
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
bool IsFieldDlgHtmlMode() const
std::unique_ptr< weld::TreeView > m_xFormatLB
const SwGetSetExpType GSE_EXPR
Expression.
void FillFieldSelect(weld::TreeView &rListBox)
std::unique_ptr< weld::ComboBox > m_xChapterLevelLB
std::unique_ptr< weld::Button > m_xNewPB
void EnableInsert(bool bEnable)
const SwExtendedSubType SUB_CMD
Show command.
void SavePos(const weld::TreeView &rLst1)
virtual ~SwFieldVarPage() override
sal_Int32 GetSelectionSel() const
virtual int get_selected_index() const =0
SwFieldTypesEnum
List of FieldTypes at UI.
std::unique_ptr< weld::Widget > m_xSelection
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
virtual OUString get_text(int row, int col=-1) const =0
virtual const SwFieldTypes * GetFieldTypes() const =0
OUString SwResId(const char *pId)
sal_uInt16 GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
bool IsAutomaticLanguage() const
#define FIELD_COLUMN_WIDTH
virtual int find_text(const OUString &rText) const =0
SwFieldType * GetTyp() const
static SW_DLLPUBLIC bool IsValidVarName(const OUString &rStr, OUString *pValidName=nullptr)
void SubTypeHdl(const weld::TreeView *)
std::unique_ptr< weld::Widget > m_xChapterFrame
SwFieldTypesEnum GetTypeId() const
std::unique_ptr< weld::TreeView > m_xSelectionLB
virtual void select(int pos)=0
SwWrtShell * GetWrtShell()
const SwGetSetExpType GSE_SEQ
Sequence.
void select_text(const OUString &rText)
std::unique_ptr< SwNumFormatTreeView > m_xNumFormatLB
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
const SwGetSetExpType GSE_FORMULA
Formula.
OUString GetContent(sal_uInt32 nFormat=0)
#define USER_DATA_VERSION
std::unique_ptr< weld::Widget > m_xFormat
static OUString GetTypeStr(sal_uInt16 nPos)
static sal_uInt32 GetSystemFormat(SvNumberFormatter *pFormatter, sal_uInt32 nFormat)
get format in office language
std::unique_ptr< weld::Button > m_xDelPB
const SwGetSetExpType GSE_STRING
String.
sal_uInt16 GetType() const
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
std::unique_ptr< weld::Label > m_xNameFT
void StartAllAction()
For all views of this document.
virtual OUString GetName() const override
Only in derived classes.
std::unique_ptr< weld::Entry > m_xNameED
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
IMPL_LINK_NOARG(SwFieldVarPage, TypeHdl, weld::TreeView &, void)
std::unique_ptr< weld::CheckButton > m_xInvisibleCB
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)