xref: /aoo42x/main/sw/inc/authfld.hxx (revision 1d2dbeb0)
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_AUTHFLD_HXX
24 #define SW_AUTHFLD_HXX
25 
26 #include "swdllapi.h"
27 #include <fldbas.hxx>
28 #include <toxe.hxx>
29 
30 #define _SVSTDARR_LONGS
31 #include <svl/svstdarr.hxx>
32 
33 class SwAuthDataArr;
34 /* -----------------21.09.99 13:32-------------------
35 
36  --------------------------------------------------*/
37 class SwAuthEntry
38 {
39 	String 		aAuthFields[AUTH_FIELD_END];
40 	sal_uInt16 		nRefCount;
41 public:
SwAuthEntry()42 	SwAuthEntry() : nRefCount(0){}
43 	SwAuthEntry( const SwAuthEntry& rCopy );
44 	sal_Bool 			operator==(const SwAuthEntry& rComp);
45 
46 	inline const String& 	GetAuthorField(ToxAuthorityField ePos)const;
47 	inline void				SetAuthorField(ToxAuthorityField ePos,
48 											const String& rField);
49 
AddRef()50 	void			AddRef()				{ ++nRefCount; }
RemoveRef()51 	void			RemoveRef()				{ --nRefCount; }
GetRefCount()52 	sal_uInt16			GetRefCount() 			{ return nRefCount; }
53 };
54 /* -----------------20.10.99 16:49-------------------
55 
56  --------------------------------------------------*/
57 struct SwTOXSortKey
58 {
59 	ToxAuthorityField	eField;
60 	sal_Bool				bSortAscending;
SwTOXSortKeySwTOXSortKey61 	SwTOXSortKey() :
62 		eField(AUTH_FIELD_END),
63 		bSortAscending(sal_True){}
64 };
65 
66 /* -----------------14.09.99 16:15-------------------
67 
68  --------------------------------------------------*/
69 class SwAuthorityField;
70 class SortKeyArr;
71 
72 class SW_DLLPUBLIC SwAuthorityFieldType : public SwFieldType
73 {
74 	SwDoc*			m_pDoc;
75 	SwAuthDataArr*	m_pDataArr;
76 	SvLongs*		m_pSequArr;
77 	SortKeyArr*		m_pSortKeyArr;
78 	sal_Unicode 	m_cPrefix;
79 	sal_Unicode 	m_cSuffix;
80 	sal_Bool			m_bIsSequence :1;
81 	sal_Bool			m_bSortByDocument :1;
82     LanguageType    m_eLanguage;
83     String          m_sSortAlgorithm;
84 
85 	// @@@ private copy assignment, but public copy ctor? @@@
86 	const SwAuthorityFieldType& operator=( const SwAuthorityFieldType& );
87 
88 protected:
89 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
90 
91 public:
92 	SwAuthorityFieldType(SwDoc* pDoc);
93 	SwAuthorityFieldType( const SwAuthorityFieldType& );
94 	~SwAuthorityFieldType();
95 
96 	virtual SwFieldType* Copy()    const;
97 
98     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
99     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
100 
SetDoc(SwDoc * pNewDoc)101     inline void     SetDoc(SwDoc* pNewDoc)              { m_pDoc = pNewDoc; }
GetDoc()102     SwDoc*          GetDoc(){ return m_pDoc; }
103 	void				RemoveField(long nHandle);
104 	long				AddField(const String& rFieldContents);
105 	sal_Bool				AddField(long nHandle);
DelSequenceArray()106 	void				DelSequenceArray()
107 						{
108 							m_pSequArr->Remove(0, m_pSequArr->Count());
109 						}
110 
111 	const SwAuthEntry*	GetEntryByHandle(long nHandle) const;
112 
113 	void 				GetAllEntryIdentifiers( SvStringsDtor& rToFill )const;
114 	const SwAuthEntry* 	GetEntryByIdentifier(const String& rIdentifier)const;
115 
116     bool                ChangeEntryContent(const SwAuthEntry* pNewEntry);
117 	// import interface
118 	sal_uInt16				AppendField(const SwAuthEntry& rInsert);
119 	long				GetHandle(sal_uInt16 nPos);
120 
121 	sal_uInt16				GetSequencePos(long nHandle);
122 
IsSequence() const123 	sal_Bool				IsSequence() const 		{return m_bIsSequence;}
SetSequence(sal_Bool bSet)124 	void				SetSequence(sal_Bool bSet)
125 							{
126 								DelSequenceArray();
127 								m_bIsSequence = bSet;
128 							}
129 
SetPreSuffix(sal_Unicode cPre,sal_Unicode cSuf)130 	void				SetPreSuffix( sal_Unicode cPre, sal_Unicode cSuf)
131 							{
132 								m_cPrefix = cPre;
133 								m_cSuffix = cSuf;
134 							}
GetPrefix() const135 	sal_Unicode			GetPrefix() const { return m_cPrefix;}
GetSuffix() const136 	sal_Unicode			GetSuffix() const { return m_cSuffix;}
137 
IsSortByDocument() const138 	sal_Bool				IsSortByDocument() const {return m_bSortByDocument;}
SetSortByDocument(sal_Bool bSet)139 	void				SetSortByDocument(sal_Bool bSet)
140 							{
141 								DelSequenceArray();
142 								m_bSortByDocument = bSet;
143 							}
144 
145 	sal_uInt16				GetSortKeyCount() const ;
146 	const SwTOXSortKey*	GetSortKey(sal_uInt16 nIdx) const ;
147 	void				SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey nKeys[]);
148 
149 	//initui.cxx
150 	static const String& 	GetAuthFieldName(ToxAuthorityField eType);
151 	static const String& 	GetAuthTypeName(ToxAuthorityType eType);
152 
GetLanguage() const153     LanguageType    GetLanguage() const {return m_eLanguage;}
SetLanguage(LanguageType nLang)154     void            SetLanguage(LanguageType nLang)  {m_eLanguage = nLang;}
155 
GetSortAlgorithm() const156     const String&   GetSortAlgorithm()const {return m_sSortAlgorithm;}
SetSortAlgorithm(const String & rSet)157     void            SetSortAlgorithm(const String& rSet) {m_sSortAlgorithm = rSet;}
158 
159 };
160 /* -----------------14.09.99 16:15-------------------
161 
162  --------------------------------------------------*/
163 class SwAuthorityField : public SwField
164 {
165     long            m_nHandle;
166     mutable long    m_nTempSequencePos;
167 
168     virtual String      Expand() const;
169     virtual SwField*    Copy() const;
170 
171 public:
172 	SwAuthorityField(SwAuthorityFieldType* pType, const String& rFieldContents);
173 	SwAuthorityField(SwAuthorityFieldType* pType, long nHandle);
174 	~SwAuthorityField();
175 
176 	const String&		GetFieldText(ToxAuthorityField eField) const;
177 
178 	virtual void		SetPar1(const String& rStr);
179 	virtual SwFieldType* ChgTyp( SwFieldType* );
180 
181     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
182     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
183 
GetHandle() const184     long                GetHandle() const       { return m_nHandle; }
185 
186     virtual String GetDescription() const;
187 };
188 
189 // --- inlines -----------------------------------------------------------
GetAuthorField(ToxAuthorityField ePos) const190 inline const String& 	SwAuthEntry::GetAuthorField(ToxAuthorityField ePos)const
191 {
192 	DBG_ASSERT(AUTH_FIELD_END > ePos, "wrong index");
193 	return aAuthFields[ePos];
194 }
SetAuthorField(ToxAuthorityField ePos,const String & rField)195 inline void	SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const String& rField)
196 {
197 	DBG_ASSERT(AUTH_FIELD_END > ePos, "wrong index");
198 	if(AUTH_FIELD_END > ePos)
199 		aAuthFields[ePos] = rField;
200 }
201 
202 #endif
203 
204