Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / sw / inc / reffld.hxx
blobff9a801f8e063aa6361f6367b0d52bebccf05fd0
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;
29 bool IsFrameBehind( const SwTextNode& rMyNd, sal_Int32 nMySttPos,
30 const SwTextNode& rBehindNd, sal_Int32 nSttPos );
32 enum REFERENCESUBTYPE
34 REF_SETREFATTR = 0,
35 REF_SEQUENCEFLD,
36 REF_BOOKMARK,
37 REF_OUTLINE,
38 REF_FOOTNOTE,
39 REF_ENDNOTE
42 enum REFERENCEMARK
44 REF_BEGIN,
45 REF_PAGE = REF_BEGIN, ///< "Page"
46 REF_CHAPTER, ///< "Chapter"
47 REF_CONTENT, ///< "Reference"
48 REF_UPDOWN, ///< "Above/Below"
49 REF_PAGE_PGDESC, ///< "As Page Style"
50 REF_ONLYNUMBER, ///< "Category and Number"
51 REF_ONLYCAPTION, ///< "Caption Text"
52 REF_ONLYSEQNO, ///< "Numbering"
53 // --> #i81002#
54 /// new reference format types for referencing bookmarks and set references
55 REF_NUMBER, ///< "Number"
56 REF_NUMBER_NO_CONTEXT, ///< "Number (no context)"
57 REF_NUMBER_FULL_CONTEXT, ///< "Number (full context)"
60 /// Get reference.
62 class SwGetRefFieldType : public SwFieldType
64 SwDoc* pDoc;
65 protected:
66 /// Overlay in order to update all ref-fields.
67 virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
68 public:
69 SwGetRefFieldType(SwDoc* pDoc );
70 virtual SwFieldType* Copy() const override;
72 SwDoc* GetDoc() const { return pDoc; }
74 void MergeWithOtherDoc( SwDoc& rDestDoc );
76 static SwTextNode* FindAnchor( SwDoc* pDoc, const OUString& rRefMark,
77 sal_uInt16 nSubType, sal_uInt16 nSeqNo,
78 sal_Int32* pStt, sal_Int32* pEnd = nullptr );
81 class SW_DLLPUBLIC SwGetRefField : public SwField
83 private:
84 OUString sSetRefName;
85 OUString sText;
86 sal_uInt16 nSubType;
87 sal_uInt16 nSeqNo;
89 virtual OUString Expand() const override;
90 virtual SwField* Copy() const override;
92 // #i81002#
93 static OUString MakeRefNumStr( const SwTextNode& rTextNodeOfField,
94 const SwTextNode& rTextNodeOfReferencedItem,
95 const sal_uInt32 nRefNumFormat );
97 public:
98 SwGetRefField( SwGetRefFieldType*, const OUString& rSetRef,
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 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 ) { sText = 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() const;
129 /// Get/set SequenceNo (of interest only for REF_SEQUENCEFLD).
130 sal_uInt16 GetSeqNo() const { return nSeqNo; }
131 void SetSeqNo( sal_uInt16 n ) { 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: */