35#include <osl/diagnose.h>
43#define REFFLDFLAG 0x4000
44#define REFFLDFLAG_BOOKMARK 0x4800
45#define REFFLDFLAG_FOOTNOTE 0x5000
46#define REFFLDFLAG_ENDNOTE 0x6000
48#define REFFLDFLAG_HEADING 0x7100
49#define REFFLDFLAG_NUMITEM 0x7200
53#define USER_DATA_VERSION_1 "1"
54#define USER_DATA_VERSION USER_DATA_VERSION_1
57 :
SwFieldPage(pPage, pController,
"modules/swriter/ui/fldrefpage.ui",
"FieldRefPage", pCoreSet)
58 , mpSavedSelectedTextNode(nullptr)
59 , mnSavedSelectedPos(0)
60 , m_xTypeLB(m_xBuilder->weld_tree_view(
"type"))
61 , m_xSelection(m_xBuilder->weld_widget(
"selectframe"))
62 , m_xSelectionLB(m_xBuilder->weld_tree_view(
"select"))
63 , m_xSelectionToolTipLB(m_xBuilder->weld_tree_view(
"selecttip"))
64 , m_xFormat(m_xBuilder->weld_widget(
"formatframe"))
65 , m_xFormatLB(m_xBuilder->weld_tree_view(
"format"))
66 , m_xNameFT(m_xBuilder->weld_label(
"nameft"))
67 , m_xNameED(m_xBuilder->weld_entry(
"name"))
68 , m_xValueED(m_xBuilder->weld_entry(
"value"))
69 , m_xFilterED(m_xBuilder->weld_entry(
"filter"))
73 for (
auto const& aID : FLD_REF_PAGE_TYPES)
86 auto nHeight =
m_xTypeLB->get_height_rows(8);
88 m_xTypeLB->set_size_request(nWidth * 1.33, nHeight);
89 m_xFormatLB->set_size_request(nWidth * 1.33, nHeight);
217 for (
size_t n = 0;
n < nFieldTypeCnt; ++
n)
250 sal_uInt16 nFormatBoxPosition = USHRT_MAX;
259 if(nVal != USHRT_MAX)
261 for(sal_Int32
i = 0, nEntryCount =
m_xTypeLB->n_children();
i < nEntryCount; ++
i)
269 if (nIdx>=0 && nIdx<sUserData.getLength())
277 if (nFormatBoxPosition < m_xFormatLB->n_children())
295 const sal_Int32 nOld = GetTypeSel();
298 SetTypeSel(m_xTypeLB->get_selected_index());
300 if(GetTypeSel() == -1)
306 sal_uInt16 nFlag = 0;
308 switch( GetCurField()->GetSubType() )
317 sName = m_sHeadingText;
320 else if ( pRefField &&
323 sName = m_sNumItemText;
328 sName = m_sBookmarkText;
335 sName = m_sFootnoteText;
340 sName = m_sEndnoteText;
361 if (m_xTypeLB->find_text(
sName) == -1)
363 m_xTypeLB->append(OUString::number(nFlag),
sName);
366 m_xTypeLB->select_text(
sName);
367 SetTypeSel(m_xTypeLB->get_selected_index());
372 m_xTypeLB->select(0);
376 if (nOld == GetTypeSel())
379 sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
384 if ( ( !IsFieldEdit() || m_xSelectionLB->n_children() ) &&
387 m_xNameED->set_text(OUString());
388 m_xValueED->set_text(OUString());
389 m_xFilterED->set_text(OUString());
398 if (nOld != -1 &&
REFFLDFLAG & m_xTypeLB->get_id(nOld).toUInt32())
414 const sal_uInt16 nOldId = nOld != -1 ? m_xTypeLB->get_id(nOld).toUInt32() : 0;
422 m_xNameED->set_sensitive(bName);
423 m_xNameFT->set_sensitive(bName);
426 sal_Int32 nSize = FillFormatLB(nTypeId);
427 bool bFormat = nSize != 0;
428 m_xFormat->set_sensitive(bFormat);
431 ModifyHdl(*m_xNameED);
432 ModifyHdl(*m_xFilterED);
504 const sal_Int32 nSelectionSel =
m_xSelectionLB->get_selected_index();
505 if (nSelectionSel != -1)
508 if (
IsFieldEdit() && pRefField && sOldSel.isEmpty())
509 sOldSel = OUString::number( pRefField->
GetSeqNo() + 1 );
534 OUString m_sSelectionToolTipLBId;
535 bool bShowSelectionToolTipLB(
false );
547 const ::sw::mark::IMark* pBkmk = *ppMark;
550 bool isSubstring =
MatchSubstring(pBkmk->GetName(), filterString);
565 for(
size_t n = 0;
n < nCnt; ++
n )
573 sOldSel =
aArr[
n].sDlgEntry;
581 for(
size_t n = 0;
n < nCnt; ++
n )
589 sOldSel =
aArr[
n].sDlgEntry;
595 bShowSelectionToolTipLB =
true;
599 bool bCertainTextNodeSelected(
false );
600 for (
size_t nOutlIdx = 0; nOutlIdx <
maOutlineNodes.size(); ++nOutlIdx )
609 OUString
sId(OUString::number(nOutlIdx));
616 m_sSelectionToolTipLBId =
sId;
618 bCertainTextNodeSelected =
true;
622 m_sSelectionToolTipLBId =
sId;
630 bShowSelectionToolTipLB =
true;
634 bool bCertainTextNodeSelected(
false );
635 for (
size_t nNumItemIdx = 0; nNumItemIdx <
maNumItems.size(); ++nNumItemIdx )
644 OUString
sId(OUString::number(nNumItemIdx));
651 m_sSelectionToolTipLBId =
sId;
653 bCertainTextNodeSelected =
true;
657 m_sSelectionToolTipLBId =
sId;
677 for(
size_t n = 0;
n < nCnt; ++
n )
684 if (
IsFieldEdit() && pRefField && sOldSel.isEmpty() &&
686 sOldSel =
aArr[
n ].sDlgEntry;
689 if (
IsFieldEdit() && pRefField && sOldSel.isEmpty())
690 sOldSel = OUString::number( pRefField->
GetSeqNo() + 1);
696 std::vector<OUString> aLst;
698 for(
const OUString &
i : aLst)
714 if (!m_sSelectionToolTipLBId.isEmpty())
718 if ( bShowSelectionToolTipLB )
752 if(rSubstr.isEmpty())
756 return aListString.indexOf(aSubstr) >= 0;
763 FMT_REF_PAGE_IDX = 0,
764 FMT_REF_CHAPTER_IDX = 1,
765 FMT_REF_TEXT_IDX = 2,
766 FMT_REF_UPDOWN_IDX = 3,
767 FMT_REF_PAGE_PGDSC_IDX = 4,
768 FMT_REF_ONLYNUMBER_IDX = 5,
769 FMT_REF_ONLYCAPTION_IDX = 6,
770 FMT_REF_ONLYSEQNO_IDX = 7,
771 FMT_REF_NUMBER_IDX = 8,
772 FMT_REF_NUMBER_NO_CONTEXT_IDX = 9,
773 FMT_REF_NUMBER_FULL_CONTEXT_IDX = 10
789 FMT_REF_NUMBER_NO_CONTEXT,
790 FMT_REF_NUMBER_FULL_CONTEXT
797 sal_Int32 nFormatSel =
m_xFormatLB->get_selected_index();
798 if (nFormatSel != -1)
805 sal_uInt16 nSize( 0 );
806 bool bAddCrossRefFormats(
false );
812 bAddCrossRefFormats =
true;
819 nSize = FMT_REF_PAGE_PGDSC_IDX + 1;
827 nSize = FMT_REF_ONLYSEQNO_IDX + 1;
840 for (sal_uInt16
i = 0;
i < nSize;
i++)
842 OUString
sId(OUString::number(
GetFieldMgr().GetFormatId( nFieldType,
i )));
847 sal_uInt16 nExtraSize( 0 );
848 if ( bAddCrossRefFormats )
850 sal_uInt16 nFormat = FMT_REF_NUMBER_IDX;
851 OUString
sId(OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat)));
853 nFormat = FMT_REF_NUMBER_NO_CONTEXT_IDX;
854 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
856 nFormat = FMT_REF_NUMBER_FULL_CONTEXT_IDX;
857 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
868 for (sal_uInt16
i = 0;
i < nSize;
i++)
875 if ( bAddCrossRefFormats )
878 OUString
sId(OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat)));
881 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
884 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
889 for (sal_uInt16
i = 0;
i < nSize;
i++)
895 if ( bAddCrossRefFormats )
898 OUString
sId(OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat)));
901 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
904 sId = OUString::number(
GetFieldMgr().GetFormatId(nFieldType, nFormat));
922 if (nFieldDlgFormatSel < m_xFormatLB->n_children())
935 OUString
aName(m_xNameED->get_text());
936 const bool bEmptyName =
aName.isEmpty();
939 sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
946 EnableInsert(bEnable);
948 m_xSelectionLB->select_text(
aName);
953 bool bModified =
false;
956 sal_uInt16 nSubType = 0;
957 const sal_Int32 nEntryPos =
m_xFormatLB->get_selected_index();
958 const sal_uInt32 nFormat = (nEntryPos == -1)
1010 aVal = OUString::number(
aArr[
nPos].nSeqNo );
1016 aVal = OUString::number( pRefField->
GetSeqNo() );
1031 aVal = OUString::number(
aArr[
nPos].nSeqNo );
1037 aVal = OUString::number( pRefField->
GetSeqNo() );
1043 OSL_ENSURE( nEntry != -1,
1044 "<SwFieldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" );
1063 OSL_ENSURE( nEntry != -1,
1064 "<SwFieldRefPage::FillItemSet(..)> - no entry selected in selection tool tip listbox!" );
1099 aVal = OUString::number(
aArr[
nPos].nSeqNo );
1105 aVal = OUString::number( pRefField->
GetSeqNo() );
1112 aVal = OUString::number(nSubType) +
"|" + aVal;
1116 m_xNameED->get_value_changed_from_saved() ||
1117 m_xValueED->get_value_changed_from_saved() ||
1118 m_xTypeLB->get_value_changed_from_saved() ||
1133 return std::make_unique<SwFieldRefPage>(pPage, pController, pAttrSet);
1143 const sal_Int32 nEntryPos =
m_xTypeLB->get_selected_index();
1144 const sal_uInt16 nTypeSel = ( -1 == nEntryPos )
1146 :
m_xTypeLB->get_id(nEntryPos).toUInt32();
1147 const sal_Int32 nFormatEntryPos =
m_xFormatLB->get_selected_index();
1148 const sal_uInt32 nFormatSel = -1 == nFormatEntryPos ? USHRT_MAX : nFormatEntryPos;
1150 OUString::number( nTypeSel ) +
";" +
1151 OUString::number( nFormatSel ));
static bool GetLayoutRTL()
OUString lowercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
Provides numbered items of a document.
virtual bool isNumberedInLayout(SwNodeNum const &rNodeNum, SwRootFrame const &rLayout) const =0
virtual OUString getListItemText(const SwNodeNum &rNodeNum, SwRootFrame const &rLayout) const =0
virtual void getNumItems(IDocumentListItems::tSortedNodeNumList &orNodeNumList) const =0
get vector of all list items, which are numbered
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
Provides access to the marks of a document.
virtual const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
@ CROSSREF_NUMITEM_BOOKMARK
@ CROSSREF_HEADING_BOOKMARK
virtual ::sw::mark::IMark * getMarkForTextNode(const SwTextNode &rTextNode, MarkType eMark)=0
Returns a mark in the document for a paragraph.
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
virtual const_iterator_t getBookmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
Provides outline nodes of a document.
virtual OUString getOutlineText(const tSortedOutlineNodeList::size_type nIdx, SwRootFrame const *pLayout, const bool bWithNumber=true, const bool bWithSpacesForLevel=false, const bool bWithFootnote=true) const =0
virtual void getOutlineNodes(IDocumentOutlineNodes::tSortedOutlineNodeList &orOutlineNodeList) const =0
virtual bool isOutlineInLayout(tSortedOutlineNodeList::size_type nIdx, SwRootFrame const &rLayout) const =0
OUString getLanguage() const
void SetUserData(const OUString &rString)
const OUString & GetUserData() const
const LanguageTag & GetRealLanguageTag() const
OUString GetSelText() const
get selected text of a node at current cursor
bool HasFootnotes(bool bEndNotes=false) const
size_t GetFieldTypeCount(SwFieldIds nResId=SwFieldIds::Unknown) const
count field types with a ResId, if SwFieldIds::Unknown count all
size_t GetSeqFootnoteList(SwSeqFieldList &rList, bool bEndNotes=false)
Give a List of all footnotes and their beginning texts.
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.
const SwPageDesc & GetPageDesc(size_t i) const
static const SwFieldGroupRgn & GetGroupRange(bool bHtmlMode, sal_uInt16 nGrpId)
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) 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)
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)
void SetTypeSel(sal_Int32 nSet)
SwFieldMgr & GetFieldMgr()
bool IsFieldDlgHtmlMode() const
void RestorePos(weld::TreeView &rLst1)
SwWrtShell * GetWrtShell()
void SetSelectionSel(sal_Int32 nSet)
SwFieldRefPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *pSet)
void UpdateSubType(const OUString &filterString)
sal_Int32 FillFormatLB(sal_uInt16 nTypeId)
std::unique_ptr< weld::TreeView > m_xSelectionLB
virtual ~SwFieldRefPage() override
virtual void Reset(const SfxItemSet *rSet) override
virtual sal_uInt16 GetGroup() override
std::unique_ptr< weld::Entry > m_xValueED
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::TreeView > m_xTypeLB
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
virtual void FillUserData() override
IDocumentOutlineNodes::tSortedOutlineNodeList maOutlineNodes
std::unique_ptr< weld::TreeView > m_xSelectionToolTipLB
std::unique_ptr< weld::Widget > m_xSelection
size_t mnSavedSelectedPos
const SwTextNode * mpSavedSelectedTextNode
std::unique_ptr< weld::TreeView > m_xFormatLB
void SaveSelectedTextNode()
std::unique_ptr< weld::Entry > m_xFilterED
static bool MatchSubstring(const OUString &list_string, const OUString &substr)
std::unique_ptr< weld::Entry > m_xNameED
IDocumentListItems::tSortedNodeNumList maNumItems
Instances of SwFields and those derived from it occur 0 to n times.
bool IsRefToNumItemCrossRefBookmark() const
bool IsRefToHeadingCrossRefBookmark() const
const SwTextNode * GetReferencedTextNode() const
const OUString & GetSetRefName() const
sal_uInt16 GetSeqNo() const
Get/set SequenceNo (of interest only for REF_SEQUENCEFLD).
SwFrameFormat & GetMaster()
sal_uInt16 GetType() const
virtual OUString GetName() const override
Only in derived classes.
size_t GetSeqFieldList(SwSeqFieldList &rList, SwRootFrame const *pLayout)
const IDocumentListItems * getIDocumentListItemsAccess() const
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
SwRootFrame * GetLayout() const
const IDocumentOutlineNodes * getIDocumentOutlineNodesAccess() const
Used by the UI to modify the document model.
virtual const OUString & GetName() const =0
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
SwFieldTypesEnum
List of FieldTypes at UI.
#define FIELD_COLUMN_WIDTH
IMPL_LINK_NOARG(SwFieldRefPage, ModifyHdl_Impl, weld::Entry &, void)
#define USER_DATA_VERSION_1
#define USER_DATA_VERSION
#define REFFLDFLAG_BOOKMARK
#define REFFLDFLAG_ENDNOTE
const TranslateId FMT_REF_ARY[]
#define REFFLDFLAG_NUMITEM
#define REFFLDFLAG_HEADING
#define REFFLDFLAG_FOOTNOTE
static sal_uInt16 nFieldDlgFormatSel
CharClass & GetAppCharClass()
#define LINK(Instance, Class, Member)
#define SAL_N_ELEMENTS(arr)
OString strip(const OString &rIn, char c)
const SwGetSetExpType GSE_SEQ
Sequence.
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
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)