29 #include <strings.hrc>
38 #define REFFLDFLAG 0x4000
39 #define REFFLDFLAG_BOOKMARK 0x4800
40 #define REFFLDFLAG_FOOTNOTE 0x5000
41 #define REFFLDFLAG_ENDNOTE 0x6000
43 #define REFFLDFLAG_HEADING 0x7100
44 #define REFFLDFLAG_NUMITEM 0x7200
48 #define USER_DATA_VERSION_1 "1"
49 #define USER_DATA_VERSION USER_DATA_VERSION_1
52 :
SwFieldPage(pPage, pController,
"modules/swriter/ui/fldrefpage.ui",
"FieldRefPage", pCoreSet)
55 , mpSavedSelectedTextNode(nullptr)
56 , mnSavedSelectedPos(0)
57 , m_xTypeLB(m_xBuilder->weld_tree_view(
"type"))
58 , m_xSelection(m_xBuilder->weld_widget(
"selectframe"))
59 , m_xSelectionLB(m_xBuilder->weld_tree_view(
"select"))
60 , m_xSelectionToolTipLB(m_xBuilder->weld_tree_view(
"selecttip"))
61 , m_xFormat(m_xBuilder->weld_widget(
"formatframe"))
62 , m_xFormatLB(m_xBuilder->weld_tree_view(
"format"))
63 , m_xNameFT(m_xBuilder->weld_label(
"nameft"))
64 , m_xNameED(m_xBuilder->weld_entry(
"name"))
65 , m_xValueED(m_xBuilder->weld_entry(
"value"))
66 , m_xFilterED(m_xBuilder->weld_entry(
"filter"))
83 auto nHeight =
m_xTypeLB->get_height_rows(8);
85 m_xTypeLB->set_size_request(nWidth * 1.33, nHeight);
86 m_xFormatLB->set_size_request(nWidth * 1.33, nHeight);
197 for (
size_t n = 0;
n < nFieldTypeCnt; ++
n)
230 sal_uInt16 nFormatBoxPosition =
USHRT_MAX;
235 if(!
IsRefresh() && sUserData.getToken(0,
';', nIdx).
238 const sal_uInt16 nVal =
static_cast< sal_uInt16
>(sUserData.getToken(0,
';', nIdx).toInt32());
241 for(sal_Int32
i = 0, nEntryCount =
m_xTypeLB->n_children();
i < nEntryCount; ++
i)
249 if (nIdx>=0 && nIdx<sUserData.getLength())
251 nFormatBoxPosition =
static_cast< sal_uInt16
>(sUserData.getToken(0,
';', nIdx).toInt32());
257 if (nFormatBoxPosition < m_xFormatLB->n_children())
275 const sal_Int32 nOld = GetTypeSel();
278 SetTypeSel(m_xTypeLB->get_selected_index());
280 if(GetTypeSel() == -1)
286 sal_uInt16 nFlag = 0;
288 switch( GetCurField()->GetSubType() )
297 sName = sHeadingText;
300 else if ( pRefField &&
303 sName = sNumItemText;
308 sName = sBookmarkText;
315 sName = sFootnoteText;
320 sName = sEndnoteText;
325 sName =
SwResId(STR_GETREFFLD);
330 sName =
static_cast<SwGetRefField*
>(GetCurField())->GetSetRefName();
335 if (m_xTypeLB->find_text(sName) == -1)
337 m_xTypeLB->append(OUString::number(nFlag), sName);
340 m_xTypeLB->select_text(sName);
341 SetTypeSel(m_xTypeLB->get_selected_index());
346 m_xTypeLB->select(0);
350 if (nOld == GetTypeSel())
353 sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
361 if ( ( !IsFieldEdit() || m_xSelectionLB->n_children() ) &&
364 m_xNameED->set_text(OUString());
365 m_xValueED->set_text(OUString());
366 m_xFilterED->set_text(OUString());
372 if (nOld != -1 &&
REFFLDFLAG & m_xTypeLB->get_id(nOld).toUInt32())
388 const sal_uInt16 nOldId = nOld != -1 ? m_xTypeLB->get_id(nOld).toUInt32() : 0;
396 m_xNameED->set_sensitive(bName);
397 m_xNameFT->set_sensitive(bName);
400 sal_Int32 nSize = FillFormatLB(nTypeId);
401 bool bFormat = nSize != 0;
402 m_xFormat->set_sensitive(bFormat);
405 ModifyHdl(*m_xNameED);
406 ModifyHdl(*m_xFilterED);
475 const sal_Int32 nSelectionSel =
m_xSelectionLB->get_selected_index();
476 if (nSelectionSel != -1)
480 sOldSel = OUString::number( pRefField->
GetSeqNo() + 1 );
505 OUString m_sSelectionToolTipLBId;
506 bool bShowSelectionToolTipLB(
false );
518 const ::sw::mark::IMark* pBkmk = *ppMark;
521 bool isSubstring =
MatchSubstring(pBkmk->GetName(), filterString);
536 for(
size_t n = 0;
n < nCnt; ++
n )
544 sOldSel = aArr[
n].sDlgEntry;
552 for(
size_t n = 0;
n < nCnt; ++
n )
560 sOldSel = aArr[
n].sDlgEntry;
566 bShowSelectionToolTipLB =
true;
570 bool bCertainTextNodeSelected(
false );
571 for (
size_t nOutlIdx = 0; nOutlIdx <
maOutlineNodes.size(); ++nOutlIdx )
573 if (!pIDoc->isOutlineInLayout(nOutlIdx, *pSh->
GetLayout()))
577 bool isSubstring =
MatchSubstring(pIDoc->getOutlineText(nOutlIdx, pSh->
GetLayout(),
true,
true,
false), filterString);
580 OUString
sId(OUString::number(nOutlIdx));
582 pIDoc->getOutlineText(nOutlIdx, pSh->
GetLayout(),
true,
true,
false));
587 m_sSelectionToolTipLBId = sId;
589 bCertainTextNodeSelected =
true;
593 m_sSelectionToolTipLBId = sId;
601 bShowSelectionToolTipLB =
true;
605 bool bCertainTextNodeSelected(
false );
606 for (
size_t nNumItemIdx = 0; nNumItemIdx <
maNumItems.size(); ++nNumItemIdx )
615 OUString
sId(OUString::number(nNumItemIdx));
622 m_sSelectionToolTipLBId = sId;
624 bCertainTextNodeSelected =
true;
628 m_sSelectionToolTipLBId = sId;
648 for(
size_t n = 0;
n < nCnt; ++
n )
656 aArr[
n ].nSeqNo == pRefField->
GetSeqNo())
657 sOldSel = aArr[
n ].sDlgEntry;
661 sOldSel = OUString::number( pRefField->
GetSeqNo() + 1);
667 std::vector<OUString> aLst;
669 for(
const OUString &
i : aLst)
685 if (!m_sSelectionToolTipLBId.isEmpty())
689 if ( bShowSelectionToolTipLB )
723 if(rSubstr.isEmpty())
727 return aListString.indexOf(aSubstr) >= 0;
734 FMT_REF_PAGE_IDX = 0,
735 FMT_REF_CHAPTER_IDX = 1,
736 FMT_REF_TEXT_IDX = 2,
737 FMT_REF_UPDOWN_IDX = 3,
738 FMT_REF_PAGE_PGDSC_IDX = 4,
739 FMT_REF_ONLYNUMBER_IDX = 5,
740 FMT_REF_ONLYCAPTION_IDX = 6,
741 FMT_REF_ONLYSEQNO_IDX = 7,
742 FMT_REF_NUMBER_IDX = 8,
743 FMT_REF_NUMBER_NO_CONTEXT_IDX = 9,
744 FMT_REF_NUMBER_FULL_CONTEXT_IDX = 10
760 FMT_REF_NUMBER_NO_CONTEXT,
761 FMT_REF_NUMBER_FULL_CONTEXT
768 sal_Int32 nFormatSel =
m_xFormatLB->get_selected_index();
769 if (nFormatSel != -1)
776 sal_uInt16 nSize( 0 );
777 bool bAddCrossRefFormats(
false );
783 bAddCrossRefFormats =
true;
790 nSize = FMT_REF_PAGE_PGDSC_IDX + 1;
798 nSize = FMT_REF_ONLYSEQNO_IDX + 1;
811 for (sal_uInt16
i = 0;
i < nSize;
i++)
813 OUString
sId(OUString::number(
GetFieldMgr().GetFormatId( nFieldType,
i )));
818 sal_uInt16 nExtraSize( 0 );
819 if ( bAddCrossRefFormats )
821 sal_uInt16 nFormat = FMT_REF_NUMBER_IDX;
822 OUString
sId(OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat)));
824 nFormat = FMT_REF_NUMBER_NO_CONTEXT_IDX;
825 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
827 nFormat = FMT_REF_NUMBER_FULL_CONTEXT_IDX;
828 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
839 for (sal_uInt16
i = 0;
i < nSize;
i++)
846 if ( bAddCrossRefFormats )
849 OUString
sId(OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat)));
851 nFormat = FMT_REF_NUMBER_NO_CONTEXT_IDX + SAL_N_ELEMENTS(
FMT_REF_ARY);
852 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
854 nFormat = FMT_REF_NUMBER_FULL_CONTEXT_IDX + SAL_N_ELEMENTS(
FMT_REF_ARY);
855 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
860 for (sal_uInt16
i = 0;
i < nSize;
i++)
866 if ( bAddCrossRefFormats )
869 OUString
sId(OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat)));
871 nFormat = FMT_REF_NUMBER_NO_CONTEXT_IDX + 2 * SAL_N_ELEMENTS(
FMT_REF_ARY);
872 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
874 nFormat = FMT_REF_NUMBER_FULL_CONTEXT_IDX + 2 * SAL_N_ELEMENTS(
FMT_REF_ARY);
875 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
893 if (nFieldDlgFormatSel < m_xFormatLB->n_children())
906 OUString
aName(m_xNameED->get_text());
907 const bool bEmptyName =
aName.isEmpty();
910 sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
917 EnableInsert(bEnable);
919 m_xSelectionLB->select_text(
aName);
924 bool bModified =
false;
927 sal_uInt16 nSubType = 0;
928 const sal_Int32 nEntryPos =
m_xFormatLB->get_selected_index();
929 const sal_uLong nFormat = (nEntryPos == -1)
982 aVal = OUString::number( aArr[nPos].nSeqNo );
988 aVal = OUString::number( pRefField->
GetSeqNo() );
1003 aVal = OUString::number( aArr[nPos].nSeqNo );
1009 aVal = OUString::number( pRefField->
GetSeqNo() );
1015 OSL_ENSURE( nEntry != -1,
1016 "<SwFieldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" );
1035 OSL_ENSURE( nEntry != -1,
1036 "<SwFieldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" );
1071 aVal = OUString::number( aArr[nPos].nSeqNo );
1077 aVal = OUString::number( pRefField->
GetSeqNo() );
1084 aVal = OUString::number(nSubType) +
"|" + aVal;
1088 m_xNameED->get_value_changed_from_saved() ||
1089 m_xValueED->get_value_changed_from_saved() ||
1090 m_xTypeLB->get_value_changed_from_saved() ||
1094 InsertField( static_cast<SwFieldTypesEnum>(nTypeId), nSubType,
aName, aVal, nFormat );
1105 return std::make_unique<SwFieldRefPage>(pPage, pController, pAttrSet);
1115 const sal_Int32 nEntryPos =
m_xTypeLB->get_selected_index();
1116 const sal_uInt16 nTypeSel = ( -1 == nEntryPos )
1118 :
m_xTypeLB->get_id(nEntryPos).toUInt32();
1119 const sal_Int32 nFormatEntryPos =
m_xFormatLB->get_selected_index();
1120 const sal_uInt32 nFormatSel = -1 == nFormatEntryPos ?
USHRT_MAX : nFormatEntryPos;
1122 OUString::number( nTypeSel ) +
";" +
1123 OUString::number( nFormatSel ));
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.
virtual void getNumItems(IDocumentListItems::tSortedNodeNumList &orNodeNumList) const =0
get vector of all list items, which are numbered
IMPL_LINK_NOARG(SwFieldRefPage, ModifyHdl_Impl, weld::Entry &, void)
IDocumentListItems::tSortedNodeNumList maNumItems
virtual const OUString & GetName() const =0
void RestorePos(weld::TreeView &rLst1)
virtual sal_uInt16 GetGroup() override
std::unique_ptr< weld::Entry > m_xValueED
void SetUserData(const OUString &rString)
#define REFFLDFLAG_ENDNOTE
#define USER_DATA_VERSION
const IDocumentOutlineNodes * getIDocumentOutlineNodesAccess() const
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
Provides numbered items of a document.
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
IDocumentOutlineNodes::tSortedOutlineNodeList maOutlineNodes
SwWrtShell * GetActiveWrtShell()
Provides access to the marks of a document.
void SaveSelectedTextNode()
static const OUString & GetTypeStr(sal_uInt16 nPos)
std::unique_ptr< weld::Entry > m_xFilterED
bool HasWriterListeners() const
Used by the UI to modify the document model.
virtual ~SwFieldRefPage() override
static sal_uInt16 nFieldDlgFormatSel
SwFieldMgr & GetFieldMgr()
std::unique_ptr< weld::Widget > m_xSelection
static SwFieldTypesEnum GetTypeId(sal_uInt16 nPos)
OUString getLanguage() const
virtual void getOutlineNodes(IDocumentOutlineNodes::tSortedOutlineNodeList &orOutlineNodeList) const =0
bool SeekEntry(const SeqFieldLstElem &rNew, size_t *pPos) const
bool IsUsed(const sw::BroadcastingModify &) const
Query if the paragraph-/character-/frame-/page-style is used.
const SwTextNode * mpSavedSelectedTextNode
virtual bool FillItemSet(SfxItemSet *rSet) override
void SetSelectionSel(sal_Int32 nSet)
const OUString & GetUserData() const
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
#define REFFLDFLAG_NUMITEM
bool IsFieldDlgHtmlMode() const
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
#define SAL_N_ELEMENTS(arr)
std::unique_ptr< weld::TreeView > m_xSelectionToolTipLB
virtual const_iterator_t getBookmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
bool IsRefToNumItemCrossRefBookmark() const
#define REFFLDFLAG_BOOKMARK
void SavePos(const weld::TreeView &rLst1)
static bool MatchSubstring(const OUString &list_string, const OUString &substr)
SwFieldTypesEnum
List of FieldTypes at UI.
size_t GetFieldTypeCount(SwFieldIds nResId=SwFieldIds::Unknown) const
count field types with a ResId, if SwFieldIds::Unknown count all
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
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 void Reset(const SfxItemSet *rSet) override
size_t GetSeqFootnoteList(SwSeqFieldList &rList, bool bEndNotes=false)
Give a List of all footnotes and their beginning texts.
OUString SwResId(const char *pId)
OUString lowercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
void UpdateSubType(const OUString &filterString)
#define FIELD_COLUMN_WIDTH
virtual OUString GetName() const override
Only in derived classes.
const LanguageTag & GetRealLanguageTag() const
SwWrtShell * GetWrtShell()
const SwGetSetExpType GSE_SEQ
Sequence.
sal_uInt16 GetSeqNo() const
Get/set SequenceNo (of interest only for REF_SEQUENCEFLD).
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
virtual ::sw::mark::IMark * getMarkForTextNode(const SwTextNode &rTextNode, MarkType eMark)=0
Returns a mark in the document for a paragraph.
bool IsRefToHeadingCrossRefBookmark() const
const IDocumentListItems * getIDocumentListItemsAccess() const
bool HasFootnotes(bool bEndNotes=false) const
std::unique_ptr< weld::TreeView > m_xFormatLB
Provides outline nodes of a document.
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
OUString GetSelText() const
get selected text of a node at current cursor
virtual const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
OString strip(const OString &rIn, char c)
virtual void FillUserData() override
const OUString & GetSetRefName() const
std::unique_ptr< weld::TreeView > m_xTypeLB
static const char * FMT_REF_ARY[]
#define REFFLDFLAG_HEADING
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
sal_uInt16 GetType() const
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
sal_Int32 FillFormatLB(sal_uInt16 nTypeId)
SwRootFrame * GetLayout() const
CharClass & GetAppCharClass()
size_t mnSavedSelectedPos
#define REFFLDFLAG_FOOTNOTE
std::unique_ptr< weld::TreeView > m_xSelectionLB
const SwTextNode * GetReferencedTextNode() const
void SetTypeSel(sal_Int32 nSet)
size_t GetSeqFieldList(SwSeqFieldList &rList, SwRootFrame const *pLayout)
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
SwFieldRefPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
std::unique_ptr< weld::Entry > m_xNameED
#define USER_DATA_VERSION_1