Revert "Revert "Revert "stronger typing for SwClient::GetRegisteredIn"" and fix SwIte...
[LibreOffice.git] / sw / inc / reffld.hxx
blobf50219df9885b9f53c7cdebbda343ab6fda817ce
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SW_INC_REFFLD_HXX
20 #define INCLUDED_SW_INC_REFFLD_HXX
22 #include <tools/solar.h>
24 #include "fldbas.hxx"
26 class SfxPoolItem;
27 class SwDoc;
28 class SwTextNode;
29 class SwContentFrame;
30 class SwTextField;
31 class SwRootFrame;
32 class SwFrame;
34 bool IsFrameBehind( const SwTextNode& rMyNd, sal_Int32 nMySttPos,
35 const SwTextNode& rBehindNd, sal_Int32 nSttPos );
37 #define REFFLDFLAG 0x4000
38 #define REFFLDFLAG_BOOKMARK 0x4800
39 #define REFFLDFLAG_FOOTNOTE 0x5000
40 #define REFFLDFLAG_ENDNOTE 0x6000
41 // #i83479#
42 #define REFFLDFLAG_HEADING 0x7100
43 #define REFFLDFLAG_NUMITEM 0x7200
45 #define REFFLDFLAG_STYLE 0xc000
46 /* we skip past 0x8000, 0x9000, 0xa000 and 0xb000 as when we bitwise 'and'
47 with REFFLDFLAG they are false */
48 #define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100
49 #define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200
51 enum REFERENCESUBTYPE
53 REF_SETREFATTR = 0,
54 REF_SEQUENCEFLD,
55 REF_BOOKMARK,
56 REF_OUTLINE,
57 REF_FOOTNOTE,
58 REF_ENDNOTE,
59 REF_STYLE
62 enum REFERENCEMARK
64 REF_BEGIN,
65 REF_PAGE = REF_BEGIN, ///< "Page"
66 REF_CHAPTER, ///< "Chapter"
67 REF_CONTENT, ///< "Reference"
68 REF_UPDOWN, ///< "Above/Below"
69 REF_PAGE_PGDESC, ///< "As Page Style"
70 REF_ONLYNUMBER, ///< "Category and Number"
71 REF_ONLYCAPTION, ///< "Caption Text"
72 REF_ONLYSEQNO, ///< "Numbering"
73 // --> #i81002#
74 /// new reference format types for referencing bookmarks and set references
75 REF_NUMBER, ///< "Number"
76 REF_NUMBER_NO_CONTEXT, ///< "Number (no context)"
77 REF_NUMBER_FULL_CONTEXT, ///< "Number (full context)"
80 /// Get reference.
82 class SAL_DLLPUBLIC_RTTI SwGetRefFieldType final : public SwFieldType
84 SwDoc& m_rDoc;
86 /// Overlay in order to update all ref-fields.
87 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
88 public:
89 SwGetRefFieldType(SwDoc& rDoc );
90 virtual std::unique_ptr<SwFieldType> Copy() const override;
91 virtual void UpdateFields() override {};
93 SwDoc& GetDoc() const { return m_rDoc; }
95 void MergeWithOtherDoc( SwDoc& rDestDoc );
97 static SwTextNode* FindAnchor( SwDoc* pDoc, const OUString& rRefMark,
98 sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uInt16 nFlags,
99 sal_Int32* pStart, sal_Int32* pEnd = nullptr,
100 SwRootFrame const* pLayout = nullptr,
101 SwTextNode* pSelf = nullptr, SwFrame* pFrame = nullptr);
102 void UpdateGetReferences();
103 void UpdateStyleReferences();
105 private:
106 static SwTextNode* FindAnchorRefStyle( SwDoc* pDoc, const OUString& rRefMark,
107 sal_uInt16 nFlags,
108 sal_Int32* pStart, sal_Int32* pEnd,
109 SwRootFrame const* pLayout,
110 SwTextNode* pSelf, SwFrame* pFrame);
111 static SwTextNode* FindAnchorRefStyleMarginal( SwDoc* pDoc,
112 sal_uInt16 nFlags,
113 sal_Int32* pStart, sal_Int32* pEnd,
114 SwTextNode* pSelf, SwFrame* pFrame,
115 const SwTextNode* pReference, std::u16string_view styleName);
116 static SwTextNode* FindAnchorRefStyleOther( SwDoc* pDoc,
117 sal_Int32* pStart, sal_Int32* pEnd,
118 SwTextNode* pSelf,
119 const SwTextNode* pReference, std::u16string_view styleName);
122 class SAL_DLLPUBLIC_RTTI SwGetRefField final : public SwField
124 private:
125 OUString m_sSetRefName;
126 OUString m_sSetReferenceLanguage;
127 OUString m_sText; ///< result
128 OUString m_sTextRLHidden; ///< result for layout with redlines hidden
129 sal_uInt16 m_nSubType;
130 /// reference to either a SwTextFootnote::m_nSeqNo or a SwSetExpField::mnSeqNo
131 sal_uInt16 m_nSeqNo;
132 sal_uInt16 m_nFlags;
134 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
135 virtual std::unique_ptr<SwField> Copy() const override;
136 public:
137 SW_DLLPUBLIC SwGetRefField( SwGetRefFieldType*, OUString aSetRef, OUString aReferenceLanguage,
138 sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uInt16 nFlags, sal_uLong nFormat );
140 SW_DLLPUBLIC virtual ~SwGetRefField() override;
142 virtual OUString GetFieldName() const override;
144 const OUString& GetSetRefName() const { return m_sSetRefName; }
146 // #i81002#
147 /** The <SwTextField> instance, which represents the text attribute for the
148 <SwGetRefField> instance, has to be passed to the method.
149 This <SwTextField> instance is needed for the reference format type REF_UPDOWN, REF_NUMBER
150 and REF_STYLE.
151 Note: This instance may be NULL (field in Undo/Redo). This will cause
152 no update for these reference format types. */
153 void UpdateField( const SwTextField* pFieldTextAttr, SwFrame* pFrame );
154 void UpdateField( const SwTextField* pFieldTextAttr, SwFrame* pFrame,
155 const SwRootFrame* const pLayout, OUString& rText );
157 void SetExpand( const OUString& rStr );
159 /// Get/set sub type.
160 virtual sal_uInt16 GetSubType() const override;
161 SW_DLLPUBLIC virtual void SetSubType( sal_uInt16 n ) override;
163 // --> #i81002#
164 SW_DLLPUBLIC bool IsRefToHeadingCrossRefBookmark() const;
165 SW_DLLPUBLIC bool IsRefToNumItemCrossRefBookmark() const;
166 SW_DLLPUBLIC const SwTextNode* GetReferencedTextNode(SwTextNode* pTextNode, SwFrame* pFrame) const;
167 // #i85090#
168 SW_DLLPUBLIC OUString GetExpandedTextOfReferencedTextNode(SwRootFrame const& rLayout) const;
170 /// Get/set SequenceNo (of interest only for REF_SEQUENCEFLD).
171 sal_uInt16 GetSeqNo() const { return m_nSeqNo; }
172 void SetSeqNo( sal_uInt16 n ) { m_nSeqNo = n; }
174 /// Get/set flags (currently only used for REF_STYLE)
175 sal_uInt16 GetFlags() const { return m_nFlags; }
176 void SetFlags( sal_uInt16 n ) { m_nFlags = n; }
178 // Name of reference.
179 SW_DLLPUBLIC virtual OUString GetPar1() const override;
180 virtual void SetPar1(const OUString& rStr) override;
182 SW_DLLPUBLIC virtual OUString GetPar2() const override;
183 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override;
184 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override;
186 void ConvertProgrammaticToUIName();
188 virtual OUString GetDescription() const override;
191 #endif /// INCLUDED_SW_INC_REFFLD_HXX
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */