xref: /AOO41X/main/sw/inc/authfld.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef SW_AUTHFLD_HXX
28*cdf0e10cSrcweir #define SW_AUTHFLD_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "swdllapi.h"
31*cdf0e10cSrcweir #include <fldbas.hxx>
32*cdf0e10cSrcweir #include <toxe.hxx>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #define _SVSTDARR_LONGS
35*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir class SwAuthDataArr;
38*cdf0e10cSrcweir /* -----------------21.09.99 13:32-------------------
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir  --------------------------------------------------*/
41*cdf0e10cSrcweir class SwAuthEntry
42*cdf0e10cSrcweir {
43*cdf0e10cSrcweir 	String 		aAuthFields[AUTH_FIELD_END];
44*cdf0e10cSrcweir 	sal_uInt16 		nRefCount;
45*cdf0e10cSrcweir public:
46*cdf0e10cSrcweir 	SwAuthEntry() : nRefCount(0){}
47*cdf0e10cSrcweir 	SwAuthEntry( const SwAuthEntry& rCopy );
48*cdf0e10cSrcweir 	sal_Bool 			operator==(const SwAuthEntry& rComp);
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 	inline const String& 	GetAuthorField(ToxAuthorityField ePos)const;
51*cdf0e10cSrcweir 	inline void				SetAuthorField(ToxAuthorityField ePos,
52*cdf0e10cSrcweir 											const String& rField);
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 	void			AddRef()				{ ++nRefCount; }
55*cdf0e10cSrcweir 	void			RemoveRef()				{ --nRefCount; }
56*cdf0e10cSrcweir 	sal_uInt16			GetRefCount() 			{ return nRefCount; }
57*cdf0e10cSrcweir };
58*cdf0e10cSrcweir /* -----------------20.10.99 16:49-------------------
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir  --------------------------------------------------*/
61*cdf0e10cSrcweir struct SwTOXSortKey
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir 	ToxAuthorityField	eField;
64*cdf0e10cSrcweir 	sal_Bool				bSortAscending;
65*cdf0e10cSrcweir 	SwTOXSortKey() :
66*cdf0e10cSrcweir 		eField(AUTH_FIELD_END),
67*cdf0e10cSrcweir 		bSortAscending(sal_True){}
68*cdf0e10cSrcweir };
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir /* -----------------14.09.99 16:15-------------------
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir  --------------------------------------------------*/
73*cdf0e10cSrcweir class SwAuthorityField;
74*cdf0e10cSrcweir class SortKeyArr;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir class SW_DLLPUBLIC SwAuthorityFieldType : public SwFieldType
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir 	SwDoc*			m_pDoc;
79*cdf0e10cSrcweir 	SwAuthDataArr*	m_pDataArr;
80*cdf0e10cSrcweir 	SvLongs*		m_pSequArr;
81*cdf0e10cSrcweir 	SortKeyArr*		m_pSortKeyArr;
82*cdf0e10cSrcweir 	sal_Unicode 	m_cPrefix;
83*cdf0e10cSrcweir 	sal_Unicode 	m_cSuffix;
84*cdf0e10cSrcweir 	sal_Bool			m_bIsSequence :1;
85*cdf0e10cSrcweir 	sal_Bool			m_bSortByDocument :1;
86*cdf0e10cSrcweir     LanguageType    m_eLanguage;
87*cdf0e10cSrcweir     String          m_sSortAlgorithm;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	// @@@ private copy assignment, but public copy ctor? @@@
90*cdf0e10cSrcweir 	const SwAuthorityFieldType& operator=( const SwAuthorityFieldType& );
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir protected:
93*cdf0e10cSrcweir virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir public:
96*cdf0e10cSrcweir 	SwAuthorityFieldType(SwDoc* pDoc);
97*cdf0e10cSrcweir 	SwAuthorityFieldType( const SwAuthorityFieldType& );
98*cdf0e10cSrcweir 	~SwAuthorityFieldType();
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	virtual SwFieldType* Copy()    const;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
103*cdf0e10cSrcweir     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir     inline void     SetDoc(SwDoc* pNewDoc)              { m_pDoc = pNewDoc; }
106*cdf0e10cSrcweir     SwDoc*          GetDoc(){ return m_pDoc; }
107*cdf0e10cSrcweir 	void				RemoveField(long nHandle);
108*cdf0e10cSrcweir 	long				AddField(const String& rFieldContents);
109*cdf0e10cSrcweir 	sal_Bool				AddField(long nHandle);
110*cdf0e10cSrcweir 	void				DelSequenceArray()
111*cdf0e10cSrcweir 						{
112*cdf0e10cSrcweir 							m_pSequArr->Remove(0, m_pSequArr->Count());
113*cdf0e10cSrcweir 						}
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	const SwAuthEntry*	GetEntryByHandle(long nHandle) const;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	void 				GetAllEntryIdentifiers( SvStringsDtor& rToFill )const;
118*cdf0e10cSrcweir 	const SwAuthEntry* 	GetEntryByIdentifier(const String& rIdentifier)const;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     bool                ChangeEntryContent(const SwAuthEntry* pNewEntry);
121*cdf0e10cSrcweir 	// import interface
122*cdf0e10cSrcweir 	sal_uInt16				AppendField(const SwAuthEntry& rInsert);
123*cdf0e10cSrcweir 	long				GetHandle(sal_uInt16 nPos);
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 	sal_uInt16				GetSequencePos(long nHandle);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	sal_Bool				IsSequence() const 		{return m_bIsSequence;}
128*cdf0e10cSrcweir 	void				SetSequence(sal_Bool bSet)
129*cdf0e10cSrcweir 							{
130*cdf0e10cSrcweir 								DelSequenceArray();
131*cdf0e10cSrcweir 								m_bIsSequence = bSet;
132*cdf0e10cSrcweir 							}
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	void				SetPreSuffix( sal_Unicode cPre, sal_Unicode cSuf)
135*cdf0e10cSrcweir 							{
136*cdf0e10cSrcweir 								m_cPrefix = cPre;
137*cdf0e10cSrcweir 								m_cSuffix = cSuf;
138*cdf0e10cSrcweir 							}
139*cdf0e10cSrcweir 	sal_Unicode			GetPrefix() const { return m_cPrefix;}
140*cdf0e10cSrcweir 	sal_Unicode			GetSuffix() const { return m_cSuffix;}
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 	sal_Bool				IsSortByDocument() const {return m_bSortByDocument;}
143*cdf0e10cSrcweir 	void				SetSortByDocument(sal_Bool bSet)
144*cdf0e10cSrcweir 							{
145*cdf0e10cSrcweir 								DelSequenceArray();
146*cdf0e10cSrcweir 								m_bSortByDocument = bSet;
147*cdf0e10cSrcweir 							}
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	sal_uInt16				GetSortKeyCount() const ;
150*cdf0e10cSrcweir 	const SwTOXSortKey*	GetSortKey(sal_uInt16 nIdx) const ;
151*cdf0e10cSrcweir 	void				SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey nKeys[]);
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 	//initui.cxx
154*cdf0e10cSrcweir 	static const String& 	GetAuthFieldName(ToxAuthorityField eType);
155*cdf0e10cSrcweir 	static const String& 	GetAuthTypeName(ToxAuthorityType eType);
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     LanguageType    GetLanguage() const {return m_eLanguage;}
158*cdf0e10cSrcweir     void            SetLanguage(LanguageType nLang)  {m_eLanguage = nLang;}
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     const String&   GetSortAlgorithm()const {return m_sSortAlgorithm;}
161*cdf0e10cSrcweir     void            SetSortAlgorithm(const String& rSet) {m_sSortAlgorithm = rSet;}
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir };
164*cdf0e10cSrcweir /* -----------------14.09.99 16:15-------------------
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir  --------------------------------------------------*/
167*cdf0e10cSrcweir class SwAuthorityField : public SwField
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir     long            m_nHandle;
170*cdf0e10cSrcweir     mutable long    m_nTempSequencePos;
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     virtual String      Expand() const;
173*cdf0e10cSrcweir     virtual SwField*    Copy() const;
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir public:
176*cdf0e10cSrcweir 	SwAuthorityField(SwAuthorityFieldType* pType, const String& rFieldContents);
177*cdf0e10cSrcweir 	SwAuthorityField(SwAuthorityFieldType* pType, long nHandle);
178*cdf0e10cSrcweir 	~SwAuthorityField();
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 	const String&		GetFieldText(ToxAuthorityField eField) const;
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	virtual void		SetPar1(const String& rStr);
183*cdf0e10cSrcweir 	virtual SwFieldType* ChgTyp( SwFieldType* );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
186*cdf0e10cSrcweir     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     long                GetHandle() const       { return m_nHandle; }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     virtual String GetDescription() const;
191*cdf0e10cSrcweir };
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir // --- inlines -----------------------------------------------------------
194*cdf0e10cSrcweir inline const String& 	SwAuthEntry::GetAuthorField(ToxAuthorityField ePos)const
195*cdf0e10cSrcweir {
196*cdf0e10cSrcweir 	DBG_ASSERT(AUTH_FIELD_END > ePos, "wrong index");
197*cdf0e10cSrcweir 	return aAuthFields[ePos];
198*cdf0e10cSrcweir }
199*cdf0e10cSrcweir inline void	SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const String& rField)
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir 	DBG_ASSERT(AUTH_FIELD_END > ePos, "wrong index");
202*cdf0e10cSrcweir 	if(AUTH_FIELD_END > ePos)
203*cdf0e10cSrcweir 		aAuthFields[ePos] = rField;
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir #endif
207*cdf0e10cSrcweir 
208