xref: /aoo4110/main/sw/inc/reffld.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef SW_REFFLD_HXX
24 #define SW_REFFLD_HXX
25 
26 #include <fldbas.hxx>
27 
28 class SfxPoolItem;
29 class SwDoc;
30 class SwTxtNode;
31 class SwTxtFld;
32 
33 enum REFERENCESUBTYPE
34 {
35 	REF_SETREFATTR = 0,
36 	REF_SEQUENCEFLD,
37 	REF_BOOKMARK,
38 	REF_OUTLINE,
39 	REF_FOOTNOTE,
40 	REF_ENDNOTE
41 };
42 
43 enum REFERENCEMARK
44 {
45 	REF_BEGIN,
46 	REF_PAGE = REF_BEGIN,
47 	REF_CHAPTER,
48 	REF_CONTENT,
49 	REF_UPDOWN,
50 	REF_PAGE_PGDESC,
51 	REF_ONLYNUMBER,
52 	REF_ONLYCAPTION,
53 	REF_ONLYSEQNO,
54     // --> OD 2007-08-24 #i81002#
55     // new reference format types for referencing bookmarks and set references
56     REF_NUMBER,
57     REF_NUMBER_NO_CONTEXT,
58     REF_NUMBER_FULL_CONTEXT,
59     // <--
60 	REF_END
61 };
62 
63 
64 /*--------------------------------------------------------------------
65 	Beschreibung: Referenz holen
66  --------------------------------------------------------------------*/
67 
68 class SwGetRefFieldType : public SwFieldType
69 {
70 	SwDoc* pDoc;
71 protected:
72 	// ueberlagert, um alle Ref-Felder zu updaten
73    virtual void Modify( const SfxPoolItem*, const SfxPoolItem * );
74 public:
75 	SwGetRefFieldType(SwDoc* pDoc );
76 	virtual SwFieldType*    Copy() const;
77 
GetDoc() const78 	SwDoc* 					GetDoc() const { return pDoc; }
79 
80 	void MergeWithOtherDoc( SwDoc& rDestDoc );
81 
82 	static SwTxtNode* FindAnchor( SwDoc* pDoc, const String& rRefMark,
83 										sal_uInt16 nSubType, sal_uInt16 nSeqNo,
84 										sal_uInt16* pStt, sal_uInt16* pEnd = 0 );
85 };
86 
87 /*--------------------------------------------------------------------
88 	Beschreibung: Referenzfeld
89  --------------------------------------------------------------------*/
90 
91 class SW_DLLPUBLIC SwGetRefField : public SwField
92 {
93 private:
94 	String sSetRefName;
95 	String sTxt;
96 	sal_uInt16 nSubType;
97 	sal_uInt16 nSeqNo;
98 
99     virtual String      Expand() const;
100     virtual SwField*    Copy() const;
101 
102     // --> OD 2007-08-24 #i81002#
103     String MakeRefNumStr( const SwTxtNode& rTxtNodeOfField,
104                           const SwTxtNode& rTxtNodeOfReferencedItem,
105                           const sal_uInt32 nRefNumFormat ) const;
106     // <--
107 public:
108 	SwGetRefField( SwGetRefFieldType*, const String& rSetRef,
109 					sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uLong nFmt );
110 
111     virtual ~SwGetRefField();
112 
113     virtual String      GetFieldName() const;
114 
GetSetRefName() const115 	const String& 		GetSetRefName() const { return sSetRefName; }
116 
117     // --> OD 2007-09-06 #i81002#
118     // The <SwTxtFld> instance, which represents the text attribute for the
119     // <SwGetRefField> instance, has to be passed to the method.
120     // This <SwTxtFld> instance is needed for the reference format type REF_UPDOWN
121     // and REF_NUMBER.
122     // Note: This instance may be NULL (field in Undo/Redo). This will cause
123     // no update for these reference format types.
124     void                UpdateField( const SwTxtFld* pFldTxtAttr );
125     // <--
SetExpand(const String & rStr)126 	void 				SetExpand( const String& rStr ) { sTxt = rStr; }
127 
128 	// SubType erfragen/setzen
129 	virtual sal_uInt16 		GetSubType() const;
130 	virtual void  		SetSubType( sal_uInt16 n );
131 
132     // --> OD 2007-11-09 #i81002#
133     bool IsRefToHeadingCrossRefBookmark() const;
134     bool IsRefToNumItemCrossRefBookmark() const;
135     const SwTxtNode* GetReferencedTxtNode() const;
136     // <--
137     // --> OD 2008-01-09 #i85090#
138     String GetExpandedTxtOfReferencedTxtNode() const;
139     // <--
140 
141 	// SequenceNo erfragen/setzen (nur fuer REF_SEQUENCEFLD interressant)
GetSeqNo() const142 	sal_uInt16 				GetSeqNo() const		{ return nSeqNo; }
SetSeqNo(sal_uInt16 n)143 	void  				SetSeqNo( sal_uInt16 n ) 	{ nSeqNo = n; }
144 
145 	// Name der Referenz
146 	virtual const String& GetPar1() const;
147 	virtual void		SetPar1(const String& rStr);
148 
149 	virtual String 		GetPar2() const;
150     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
151     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
152 
153     void                ConvertProgrammaticToUIName();
154 
155     virtual String GetDescription() const;
156 };
157 
158 
159 #endif // SW_REFFLD_HXX
160 
161