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