xref: /aoo42x/main/sw/inc/authfld.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef SW_AUTHFLD_HXX
24cdf0e10cSrcweir #define SW_AUTHFLD_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "swdllapi.h"
27cdf0e10cSrcweir #include <fldbas.hxx>
28cdf0e10cSrcweir #include <toxe.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #define _SVSTDARR_LONGS
31cdf0e10cSrcweir #include <svl/svstdarr.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir class SwAuthDataArr;
34cdf0e10cSrcweir /* -----------------21.09.99 13:32-------------------
35cdf0e10cSrcweir 
36cdf0e10cSrcweir  --------------------------------------------------*/
37cdf0e10cSrcweir class SwAuthEntry
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 	String 		aAuthFields[AUTH_FIELD_END];
40cdf0e10cSrcweir 	sal_uInt16 		nRefCount;
41cdf0e10cSrcweir public:
SwAuthEntry()42cdf0e10cSrcweir 	SwAuthEntry() : nRefCount(0){}
43cdf0e10cSrcweir 	SwAuthEntry( const SwAuthEntry& rCopy );
44cdf0e10cSrcweir 	sal_Bool 			operator==(const SwAuthEntry& rComp);
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 	inline const String& 	GetAuthorField(ToxAuthorityField ePos)const;
47cdf0e10cSrcweir 	inline void				SetAuthorField(ToxAuthorityField ePos,
48cdf0e10cSrcweir 											const String& rField);
49cdf0e10cSrcweir 
AddRef()50cdf0e10cSrcweir 	void			AddRef()				{ ++nRefCount; }
RemoveRef()51cdf0e10cSrcweir 	void			RemoveRef()				{ --nRefCount; }
GetRefCount()52cdf0e10cSrcweir 	sal_uInt16			GetRefCount() 			{ return nRefCount; }
53cdf0e10cSrcweir };
54cdf0e10cSrcweir /* -----------------20.10.99 16:49-------------------
55cdf0e10cSrcweir 
56cdf0e10cSrcweir  --------------------------------------------------*/
57cdf0e10cSrcweir struct SwTOXSortKey
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 	ToxAuthorityField	eField;
60cdf0e10cSrcweir 	sal_Bool				bSortAscending;
SwTOXSortKeySwTOXSortKey61cdf0e10cSrcweir 	SwTOXSortKey() :
62cdf0e10cSrcweir 		eField(AUTH_FIELD_END),
63cdf0e10cSrcweir 		bSortAscending(sal_True){}
64cdf0e10cSrcweir };
65cdf0e10cSrcweir 
66cdf0e10cSrcweir /* -----------------14.09.99 16:15-------------------
67cdf0e10cSrcweir 
68cdf0e10cSrcweir  --------------------------------------------------*/
69cdf0e10cSrcweir class SwAuthorityField;
70cdf0e10cSrcweir class SortKeyArr;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir class SW_DLLPUBLIC SwAuthorityFieldType : public SwFieldType
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	SwDoc*			m_pDoc;
75cdf0e10cSrcweir 	SwAuthDataArr*	m_pDataArr;
76cdf0e10cSrcweir 	SvLongs*		m_pSequArr;
77cdf0e10cSrcweir 	SortKeyArr*		m_pSortKeyArr;
78cdf0e10cSrcweir 	sal_Unicode 	m_cPrefix;
79cdf0e10cSrcweir 	sal_Unicode 	m_cSuffix;
80cdf0e10cSrcweir 	sal_Bool			m_bIsSequence :1;
81cdf0e10cSrcweir 	sal_Bool			m_bSortByDocument :1;
82cdf0e10cSrcweir     LanguageType    m_eLanguage;
83cdf0e10cSrcweir     String          m_sSortAlgorithm;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	// @@@ private copy assignment, but public copy ctor? @@@
86cdf0e10cSrcweir 	const SwAuthorityFieldType& operator=( const SwAuthorityFieldType& );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir protected:
89cdf0e10cSrcweir virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
90cdf0e10cSrcweir 
91cdf0e10cSrcweir public:
92cdf0e10cSrcweir 	SwAuthorityFieldType(SwDoc* pDoc);
93cdf0e10cSrcweir 	SwAuthorityFieldType( const SwAuthorityFieldType& );
94cdf0e10cSrcweir 	~SwAuthorityFieldType();
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	virtual SwFieldType* Copy()    const;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
99cdf0e10cSrcweir     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
100cdf0e10cSrcweir 
SetDoc(SwDoc * pNewDoc)101cdf0e10cSrcweir     inline void     SetDoc(SwDoc* pNewDoc)              { m_pDoc = pNewDoc; }
GetDoc()102cdf0e10cSrcweir     SwDoc*          GetDoc(){ return m_pDoc; }
103cdf0e10cSrcweir 	void				RemoveField(long nHandle);
104cdf0e10cSrcweir 	long				AddField(const String& rFieldContents);
105cdf0e10cSrcweir 	sal_Bool				AddField(long nHandle);
DelSequenceArray()106cdf0e10cSrcweir 	void				DelSequenceArray()
107cdf0e10cSrcweir 						{
108cdf0e10cSrcweir 							m_pSequArr->Remove(0, m_pSequArr->Count());
109cdf0e10cSrcweir 						}
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	const SwAuthEntry*	GetEntryByHandle(long nHandle) const;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	void 				GetAllEntryIdentifiers( SvStringsDtor& rToFill )const;
114cdf0e10cSrcweir 	const SwAuthEntry* 	GetEntryByIdentifier(const String& rIdentifier)const;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     bool                ChangeEntryContent(const SwAuthEntry* pNewEntry);
117cdf0e10cSrcweir 	// import interface
118cdf0e10cSrcweir 	sal_uInt16				AppendField(const SwAuthEntry& rInsert);
119cdf0e10cSrcweir 	long				GetHandle(sal_uInt16 nPos);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	sal_uInt16				GetSequencePos(long nHandle);
122cdf0e10cSrcweir 
IsSequence() const123cdf0e10cSrcweir 	sal_Bool				IsSequence() const 		{return m_bIsSequence;}
SetSequence(sal_Bool bSet)124cdf0e10cSrcweir 	void				SetSequence(sal_Bool bSet)
125cdf0e10cSrcweir 							{
126cdf0e10cSrcweir 								DelSequenceArray();
127cdf0e10cSrcweir 								m_bIsSequence = bSet;
128cdf0e10cSrcweir 							}
129cdf0e10cSrcweir 
SetPreSuffix(sal_Unicode cPre,sal_Unicode cSuf)130cdf0e10cSrcweir 	void				SetPreSuffix( sal_Unicode cPre, sal_Unicode cSuf)
131cdf0e10cSrcweir 							{
132cdf0e10cSrcweir 								m_cPrefix = cPre;
133cdf0e10cSrcweir 								m_cSuffix = cSuf;
134cdf0e10cSrcweir 							}
GetPrefix() const135cdf0e10cSrcweir 	sal_Unicode			GetPrefix() const { return m_cPrefix;}
GetSuffix() const136cdf0e10cSrcweir 	sal_Unicode			GetSuffix() const { return m_cSuffix;}
137cdf0e10cSrcweir 
IsSortByDocument() const138cdf0e10cSrcweir 	sal_Bool				IsSortByDocument() const {return m_bSortByDocument;}
SetSortByDocument(sal_Bool bSet)139cdf0e10cSrcweir 	void				SetSortByDocument(sal_Bool bSet)
140cdf0e10cSrcweir 							{
141cdf0e10cSrcweir 								DelSequenceArray();
142cdf0e10cSrcweir 								m_bSortByDocument = bSet;
143cdf0e10cSrcweir 							}
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	sal_uInt16				GetSortKeyCount() const ;
146cdf0e10cSrcweir 	const SwTOXSortKey*	GetSortKey(sal_uInt16 nIdx) const ;
147cdf0e10cSrcweir 	void				SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey nKeys[]);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	//initui.cxx
150cdf0e10cSrcweir 	static const String& 	GetAuthFieldName(ToxAuthorityField eType);
151cdf0e10cSrcweir 	static const String& 	GetAuthTypeName(ToxAuthorityType eType);
152cdf0e10cSrcweir 
GetLanguage() const153cdf0e10cSrcweir     LanguageType    GetLanguage() const {return m_eLanguage;}
SetLanguage(LanguageType nLang)154cdf0e10cSrcweir     void            SetLanguage(LanguageType nLang)  {m_eLanguage = nLang;}
155cdf0e10cSrcweir 
GetSortAlgorithm() const156cdf0e10cSrcweir     const String&   GetSortAlgorithm()const {return m_sSortAlgorithm;}
SetSortAlgorithm(const String & rSet)157cdf0e10cSrcweir     void            SetSortAlgorithm(const String& rSet) {m_sSortAlgorithm = rSet;}
158cdf0e10cSrcweir 
159cdf0e10cSrcweir };
160cdf0e10cSrcweir /* -----------------14.09.99 16:15-------------------
161cdf0e10cSrcweir 
162cdf0e10cSrcweir  --------------------------------------------------*/
163cdf0e10cSrcweir class SwAuthorityField : public SwField
164cdf0e10cSrcweir {
165cdf0e10cSrcweir     long            m_nHandle;
166cdf0e10cSrcweir     mutable long    m_nTempSequencePos;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     virtual String      Expand() const;
169cdf0e10cSrcweir     virtual SwField*    Copy() const;
170cdf0e10cSrcweir 
171cdf0e10cSrcweir public:
172cdf0e10cSrcweir 	SwAuthorityField(SwAuthorityFieldType* pType, const String& rFieldContents);
173cdf0e10cSrcweir 	SwAuthorityField(SwAuthorityFieldType* pType, long nHandle);
174cdf0e10cSrcweir 	~SwAuthorityField();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	const String&		GetFieldText(ToxAuthorityField eField) const;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	virtual void		SetPar1(const String& rStr);
179cdf0e10cSrcweir 	virtual SwFieldType* ChgTyp( SwFieldType* );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
182cdf0e10cSrcweir     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
183cdf0e10cSrcweir 
GetHandle() const184cdf0e10cSrcweir     long                GetHandle() const       { return m_nHandle; }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     virtual String GetDescription() const;
187cdf0e10cSrcweir };
188cdf0e10cSrcweir 
189cdf0e10cSrcweir // --- inlines -----------------------------------------------------------
GetAuthorField(ToxAuthorityField ePos) const190cdf0e10cSrcweir inline const String& 	SwAuthEntry::GetAuthorField(ToxAuthorityField ePos)const
191cdf0e10cSrcweir {
192cdf0e10cSrcweir 	DBG_ASSERT(AUTH_FIELD_END > ePos, "wrong index");
193cdf0e10cSrcweir 	return aAuthFields[ePos];
194cdf0e10cSrcweir }
SetAuthorField(ToxAuthorityField ePos,const String & rField)195cdf0e10cSrcweir inline void	SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const String& rField)
196cdf0e10cSrcweir {
197cdf0e10cSrcweir 	DBG_ASSERT(AUTH_FIELD_END > ePos, "wrong index");
198cdf0e10cSrcweir 	if(AUTH_FIELD_END > ePos)
199cdf0e10cSrcweir 		aAuthFields[ePos] = rField;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir #endif
203cdf0e10cSrcweir 
204