Line data Source code
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 SW_REFFLD_HXX
20 : #define SW_REFFLD_HXX
21 :
22 : #include <fldbas.hxx>
23 :
24 : class SfxPoolItem;
25 : class SwDoc;
26 : class SwTxtNode;
27 : class SwTxtFld;
28 :
29 : enum REFERENCESUBTYPE
30 : {
31 : REF_SETREFATTR = 0,
32 : REF_SEQUENCEFLD,
33 : REF_BOOKMARK,
34 : REF_OUTLINE,
35 : REF_FOOTNOTE,
36 : REF_ENDNOTE
37 : };
38 :
39 : enum REFERENCEMARK
40 : {
41 : REF_BEGIN,
42 : REF_PAGE = REF_BEGIN, ///< "Page"
43 : REF_CHAPTER, ///< "Chapter"
44 : REF_CONTENT, ///< "Reference"
45 : REF_UPDOWN, ///< "Above/Below"
46 : REF_PAGE_PGDESC, ///< "As Page Style"
47 : REF_ONLYNUMBER, ///< "Category and Number"
48 : REF_ONLYCAPTION, ///< "Caption Text"
49 : REF_ONLYSEQNO, ///< "Numbering"
50 : // --> #i81002#
51 : /// new reference format types for referencing bookmarks and set references
52 : REF_NUMBER, ///< "Number"
53 : REF_NUMBER_NO_CONTEXT, ///< "Number (no context)"
54 : REF_NUMBER_FULL_CONTEXT, ///< "Number (full context)"
55 : REF_END
56 : };
57 :
58 :
59 : /// Get reference.
60 :
61 1790 : class SwGetRefFieldType : public SwFieldType
62 : {
63 : SwDoc* pDoc;
64 : protected:
65 : /// Overlay in order to update all ref-fields.
66 : virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
67 : public:
68 : SwGetRefFieldType(SwDoc* pDoc );
69 : virtual SwFieldType* Copy() const;
70 :
71 124 : SwDoc* GetDoc() const { return pDoc; }
72 :
73 : void MergeWithOtherDoc( SwDoc& rDestDoc );
74 :
75 : static SwTxtNode* FindAnchor( SwDoc* pDoc, const String& rRefMark,
76 : sal_uInt16 nSubType, sal_uInt16 nSeqNo,
77 : sal_uInt16* pStt, sal_uInt16* pEnd = 0 );
78 : };
79 :
80 :
81 : class SW_DLLPUBLIC SwGetRefField : public SwField
82 : {
83 : private:
84 : OUString sSetRefName;
85 : String sTxt;
86 : sal_uInt16 nSubType;
87 : sal_uInt16 nSeqNo;
88 :
89 : virtual String Expand() const;
90 : virtual SwField* Copy() const;
91 :
92 : // #i81002#
93 : String MakeRefNumStr( const SwTxtNode& rTxtNodeOfField,
94 : const SwTxtNode& rTxtNodeOfReferencedItem,
95 : const sal_uInt32 nRefNumFormat ) const;
96 :
97 : public:
98 : SwGetRefField( SwGetRefFieldType*, const String& rSetRef,
99 : sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uLong nFmt );
100 :
101 : virtual ~SwGetRefField();
102 :
103 : virtual String GetFieldName() const;
104 :
105 0 : const OUString& GetSetRefName() const { return sSetRefName; }
106 :
107 : // #i81002#
108 : /** The <SwTxtFld> instance, which represents the text attribute for the
109 : <SwGetRefField> instance, has to be passed to the method.
110 : This <SwTxtFld> 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 SwTxtFld* pFldTxtAttr );
115 :
116 6 : void SetExpand( const String& rStr ) { sTxt = rStr; }
117 :
118 : /// Get/set sub type.
119 : virtual sal_uInt16 GetSubType() const;
120 : virtual void SetSubType( sal_uInt16 n );
121 :
122 : // --> #i81002#
123 : bool IsRefToHeadingCrossRefBookmark() const;
124 : bool IsRefToNumItemCrossRefBookmark() const;
125 : const SwTxtNode* GetReferencedTxtNode() const;
126 : // #i85090#
127 : String GetExpandedTxtOfReferencedTxtNode() const;
128 :
129 :
130 : /// Get/set SequenceNo (of interest only for REF_SEQUENCEFLD).
131 0 : sal_uInt16 GetSeqNo() const { return nSeqNo; }
132 0 : void SetSeqNo( sal_uInt16 n ) { nSeqNo = n; }
133 :
134 : // Name of reference.
135 : virtual const OUString& GetPar1() const;
136 : virtual void SetPar1(const OUString& rStr);
137 :
138 : virtual OUString GetPar2() const;
139 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
140 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
141 :
142 : void ConvertProgrammaticToUIName();
143 :
144 : virtual String GetDescription() const;
145 : };
146 :
147 :
148 : #endif /// SW_REFFLD_HXX
149 :
150 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|