Branch libreoffice-6-3
[LibreOffice.git] / sw / inc / reffld.hxx
blobf2c61877b180da03ca607616eadf237b899a1b40
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 "fldbas.hxx"
24 class SfxPoolItem;
25 class SwDoc;
26 class SwTextNode;
27 class SwTextField;
28 class SwRootFrame;
30 bool IsFrameBehind( const SwTextNode& rMyNd, sal_Int32 nMySttPos,
31 const SwTextNode& rBehindNd, sal_Int32 nSttPos );
33 enum REFERENCESUBTYPE
35 REF_SETREFATTR = 0,
36 REF_SEQUENCEFLD,
37 REF_BOOKMARK,
38 REF_OUTLINE,
39 REF_FOOTNOTE,
40 REF_ENDNOTE
43 enum REFERENCEMARK
45 REF_BEGIN,
46 REF_PAGE = REF_BEGIN, ///< "Page"
47 REF_CHAPTER, ///< "Chapter"
48 REF_CONTENT, ///< "Reference"
49 REF_UPDOWN, ///< "Above/Below"
50 REF_PAGE_PGDESC, ///< "As Page Style"
51 REF_ONLYNUMBER, ///< "Category and Number"
52 REF_ONLYCAPTION, ///< "Caption Text"
53 REF_ONLYSEQNO, ///< "Numbering"
54 // --> #i81002#
55 /// new reference format types for referencing bookmarks and set references
56 REF_NUMBER, ///< "Number"
57 REF_NUMBER_NO_CONTEXT, ///< "Number (no context)"
58 REF_NUMBER_FULL_CONTEXT, ///< "Number (full context)"
61 /// Get reference.
63 class SAL_DLLPUBLIC_RTTI SwGetRefFieldType : public SwFieldType
65 SwDoc* m_pDoc;
66 protected:
67 /// Overlay in order to update all ref-fields.
68 virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
69 public:
70 SwGetRefFieldType(SwDoc* pDoc );
71 virtual std::unique_ptr<SwFieldType> Copy() const override;
73 SwDoc* GetDoc() const { return m_pDoc; }
75 void MergeWithOtherDoc( SwDoc& rDestDoc );
77 static SwTextNode* FindAnchor( SwDoc* pDoc, const OUString& rRefMark,
78 sal_uInt16 nSubType, sal_uInt16 nSeqNo,
79 sal_Int32* pStt, sal_Int32* pEnd = nullptr,
80 SwRootFrame const* pLayout = nullptr);
83 class SW_DLLPUBLIC SwGetRefField : public SwField
85 private:
86 OUString m_sSetRefName;
87 OUString m_sSetReferenceLanguage;
88 OUString m_sText; ///< result
89 OUString m_sTextRLHidden; ///< result for layout with redlines hidden
90 sal_uInt16 m_nSubType;
91 /// reference to either a SwTextFootnote::m_nSeqNo or a SwSetExpField::mnSeqNo
92 sal_uInt16 m_nSeqNo;
94 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
95 virtual std::unique_ptr<SwField> Copy() const override;
97 public:
98 SwGetRefField( SwGetRefFieldType*, const OUString& rSetRef, const OUString& rReferenceLanguage,
99 sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uLong nFormat );
101 virtual ~SwGetRefField() override;
103 virtual OUString GetFieldName() const override;
105 const OUString& GetSetRefName() const { return m_sSetRefName; }
107 // #i81002#
108 /** The <SwTextField> instance, which represents the text attribute for the
109 <SwGetRefField> instance, has to be passed to the method.
110 This <SwTextField> instance is needed for the reference format type REF_UPDOWN
111 and REF_NUMBER.
112 Note: This instance may be NULL (field in Undo/Redo). This will cause
113 no update for these reference format types. */
114 void UpdateField( const SwTextField* pFieldTextAttr );
116 void SetExpand( const OUString& rStr );
118 /// Get/set sub type.
119 virtual sal_uInt16 GetSubType() const override;
120 virtual void SetSubType( sal_uInt16 n ) override;
122 // --> #i81002#
123 bool IsRefToHeadingCrossRefBookmark() const;
124 bool IsRefToNumItemCrossRefBookmark() const;
125 const SwTextNode* GetReferencedTextNode() const;
126 // #i85090#
127 OUString GetExpandedTextOfReferencedTextNode(SwRootFrame const& rLayout) const;
129 /// Get/set SequenceNo (of interest only for REF_SEQUENCEFLD).
130 sal_uInt16 GetSeqNo() const { return m_nSeqNo; }
131 void SetSeqNo( sal_uInt16 n ) { m_nSeqNo = n; }
133 // Name of reference.
134 virtual OUString GetPar1() const override;
135 virtual void SetPar1(const OUString& rStr) override;
137 virtual OUString GetPar2() const override;
138 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override;
139 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override;
141 void ConvertProgrammaticToUIName();
143 virtual OUString GetDescription() const override;
146 #endif /// INCLUDED_SW_INC_REFFLD_HXX
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */