1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
32 bool IsFrameBehind( const SwTextNode
& rMyNd
, sal_Int32 nMySttPos
,
33 const SwTextNode
& rBehindNd
, sal_Int32 nSttPos
);
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"
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)"
65 class SAL_DLLPUBLIC_RTTI SwGetRefFieldType final
: public SwFieldType
69 /// Overlay in order to update all ref-fields.
70 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
;
72 SwGetRefFieldType(SwDoc
& rDoc
);
73 virtual std::unique_ptr
<SwFieldType
> Copy() const override
;
75 SwDoc
& GetDoc() const { return m_rDoc
; }
77 void MergeWithOtherDoc( SwDoc
& rDestDoc
);
79 static SwTextNode
* FindAnchor( SwDoc
* pDoc
, const OUString
& rRefMark
,
80 sal_uInt16 nSubType
, sal_uInt16 nSeqNo
,
81 sal_Int32
* pStt
, sal_Int32
* pEnd
= nullptr,
82 SwRootFrame
const* pLayout
= nullptr);
83 void UpdateGetReferences();
86 class SW_DLLPUBLIC SwGetRefField final
: public SwField
89 OUString m_sSetRefName
;
90 OUString m_sSetReferenceLanguage
;
91 OUString m_sText
; ///< result
92 OUString m_sTextRLHidden
; ///< result for layout with redlines hidden
93 sal_uInt16 m_nSubType
;
94 /// reference to either a SwTextFootnote::m_nSeqNo or a SwSetExpField::mnSeqNo
97 virtual OUString
ExpandImpl(SwRootFrame
const* pLayout
) const override
;
98 virtual std::unique_ptr
<SwField
> Copy() const override
;
101 SwGetRefField( SwGetRefFieldType
*, const OUString
& rSetRef
, const OUString
& rReferenceLanguage
,
102 sal_uInt16 nSubType
, sal_uInt16 nSeqNo
, sal_uLong nFormat
);
104 virtual ~SwGetRefField() override
;
106 virtual OUString
GetFieldName() const override
;
108 const OUString
& GetSetRefName() const { return m_sSetRefName
; }
111 /** The <SwTextField> instance, which represents the text attribute for the
112 <SwGetRefField> instance, has to be passed to the method.
113 This <SwTextField> instance is needed for the reference format type REF_UPDOWN
115 Note: This instance may be NULL (field in Undo/Redo). This will cause
116 no update for these reference format types. */
117 void UpdateField( const SwTextField
* pFieldTextAttr
);
119 void SetExpand( const OUString
& rStr
);
121 /// Get/set sub type.
122 virtual sal_uInt16
GetSubType() const override
;
123 virtual void SetSubType( sal_uInt16 n
) override
;
126 bool IsRefToHeadingCrossRefBookmark() const;
127 bool IsRefToNumItemCrossRefBookmark() const;
128 const SwTextNode
* GetReferencedTextNode() const;
130 OUString
GetExpandedTextOfReferencedTextNode(SwRootFrame
const& rLayout
) const;
132 /// Get/set SequenceNo (of interest only for REF_SEQUENCEFLD).
133 sal_uInt16
GetSeqNo() const { return m_nSeqNo
; }
134 void SetSeqNo( sal_uInt16 n
) { m_nSeqNo
= n
; }
136 // Name of reference.
137 virtual OUString
GetPar1() const override
;
138 virtual void SetPar1(const OUString
& rStr
) override
;
140 virtual OUString
GetPar2() const override
;
141 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt16 nWhichId
) const override
;
142 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt16 nWhichId
) override
;
144 void ConvertProgrammaticToUIName();
146 virtual OUString
GetDescription() const override
;
149 #endif /// INCLUDED_SW_INC_REFFLD_HXX
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */