1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 #ifndef INCLUDED_SW_INC_REFFLD_HXX 20 #define INCLUDED_SW_INC_REFFLD_HXX 21 22 #include <tools/solar.h> 23 24 #include "fldbas.hxx" 25 26 class SfxPoolItem; 27 class SwDoc; 28 class SwTextNode; 29 class SwTextField; 30 class SwRootFrame; 31 32 bool IsFrameBehind( const SwTextNode& rMyNd, sal_Int32 nMySttPos, 33 const SwTextNode& rBehindNd, sal_Int32 nSttPos ); 34 35 enum REFERENCESUBTYPE 36 { 37 REF_SETREFATTR = 0, 38 REF_SEQUENCEFLD, 39 REF_BOOKMARK, 40 REF_OUTLINE, 41 REF_FOOTNOTE, 42 REF_ENDNOTE 43 }; 44 45 enum REFERENCEMARK 46 { 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)" 61 }; 62 63 /// Get reference. 64 65 class SAL_DLLPUBLIC_RTTI SwGetRefFieldType final : public SwFieldType 66 { 67 SwDoc* m_pDoc; 68 69 /// Overlay in order to update all ref-fields. 70 virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override; 71 public: 72 SwGetRefFieldType(SwDoc* pDoc ); 73 virtual std::unique_ptr<SwFieldType> Copy() const override; 74 GetDoc() const75 SwDoc* GetDoc() const { return m_pDoc; } 76 77 void MergeWithOtherDoc( SwDoc& rDestDoc ); 78 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 }; 84 85 class SW_DLLPUBLIC SwGetRefField final : public SwField 86 { 87 private: 88 OUString m_sSetRefName; 89 OUString m_sSetReferenceLanguage; 90 OUString m_sText; ///< result 91 OUString m_sTextRLHidden; ///< result for layout with redlines hidden 92 sal_uInt16 m_nSubType; 93 /// reference to either a SwTextFootnote::m_nSeqNo or a SwSetExpField::mnSeqNo 94 sal_uInt16 m_nSeqNo; 95 96 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 97 virtual std::unique_ptr<SwField> Copy() const override; 98 99 public: 100 SwGetRefField( SwGetRefFieldType*, const OUString& rSetRef, const OUString& rReferenceLanguage, 101 sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uLong nFormat ); 102 103 virtual ~SwGetRefField() override; 104 105 virtual OUString GetFieldName() const override; 106 GetSetRefName() const107 const OUString& GetSetRefName() const { return m_sSetRefName; } 108 109 // #i81002# 110 /** The <SwTextField> instance, which represents the text attribute for the 111 <SwGetRefField> instance, has to be passed to the method. 112 This <SwTextField> instance is needed for the reference format type REF_UPDOWN 113 and REF_NUMBER. 114 Note: This instance may be NULL (field in Undo/Redo). This will cause 115 no update for these reference format types. */ 116 void UpdateField( const SwTextField* pFieldTextAttr ); 117 118 void SetExpand( const OUString& rStr ); 119 120 /// Get/set sub type. 121 virtual sal_uInt16 GetSubType() const override; 122 virtual void SetSubType( sal_uInt16 n ) override; 123 124 // --> #i81002# 125 bool IsRefToHeadingCrossRefBookmark() const; 126 bool IsRefToNumItemCrossRefBookmark() const; 127 const SwTextNode* GetReferencedTextNode() const; 128 // #i85090# 129 OUString GetExpandedTextOfReferencedTextNode(SwRootFrame const& rLayout) const; 130 131 /// Get/set SequenceNo (of interest only for REF_SEQUENCEFLD). GetSeqNo() const132 sal_uInt16 GetSeqNo() const { return m_nSeqNo; } SetSeqNo(sal_uInt16 n)133 void SetSeqNo( sal_uInt16 n ) { m_nSeqNo = n; } 134 135 // Name of reference. 136 virtual OUString GetPar1() const override; 137 virtual void SetPar1(const OUString& rStr) override; 138 139 virtual OUString GetPar2() const override; 140 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override; 141 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override; 142 143 void ConvertProgrammaticToUIName(); 144 145 virtual OUString GetDescription() const override; 146 }; 147 148 #endif /// INCLUDED_SW_INC_REFFLD_HXX 149 150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 151