Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sw / authfld.hxx
blob6680ad6707fd6618ecf9134da5d84f187180a523
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: authfld.hxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _AUTHFLD_HXX
31 #define _AUTHFLD_HXX
33 #ifndef _FLDBAS_HXX
34 #include <fldbas.hxx>
35 #endif
36 #ifndef _TOXE_HXX
37 #include <toxe.hxx>
38 #endif
40 #define _SVSTDARR_LONGS
41 #include <bf_svtools/svstdarr.hxx>
42 namespace binfilter {
43 class SvUShorts;
44 extern String& GetString( const ::com::sun::star::uno::Any& rAny, String& rStr ); //STRIP008
46 class SwAuthDataArr;
47 /* -----------------21.09.99 13:32-------------------
49 --------------------------------------------------*/
50 class SwAuthEntry
52 String aAuthFields[AUTH_FIELD_END];
53 USHORT nRefCount;
54 public:
55 SwAuthEntry() : nRefCount(0){}
56 SwAuthEntry( const SwAuthEntry& rCopy );
57 BOOL operator==(const SwAuthEntry& rComp);
59 BOOL GetFirstAuthorField(USHORT& nPos, String& rToFill)const;
60 BOOL GetNextAuthorField(USHORT& nPos, String& rToFill)const;
61 inline const String& GetAuthorField(ToxAuthorityField ePos)const;
62 inline void SetAuthorField(ToxAuthorityField ePos,
63 const String& rField);
65 void AddRef() { ++nRefCount; }
66 void RemoveRef() { --nRefCount; }
67 USHORT GetRefCount() { return nRefCount; }
69 /* -----------------20.10.99 16:49-------------------
71 --------------------------------------------------*/
72 struct SwTOXSortKey
74 ToxAuthorityField eField;
75 BOOL bSortAscending;
76 SwTOXSortKey() :
77 eField(AUTH_FIELD_END),
78 bSortAscending(TRUE){}
81 /* -----------------14.09.99 16:15-------------------
83 --------------------------------------------------*/
85 class SwAuthorityField;
86 class SortKeyArr;
87 class SwAuthorityFieldType : public SwFieldType
89 SwDoc* m_pDoc;
90 SwAuthDataArr* m_pDataArr;
91 SvLongs* m_pSequArr;
92 SortKeyArr* m_pSortKeyArr;
93 sal_Unicode m_cPrefix;
94 sal_Unicode m_cSuffix;
95 BOOL m_bIsSequence :1;
96 BOOL m_bSortByDocument :1;
97 LanguageType m_eLanguage;
98 String m_sSortAlgorithm;
100 const SwAuthorityFieldType& operator=( const SwAuthorityFieldType& );
102 public:
103 SwAuthorityFieldType(SwDoc* pDoc);
104 SwAuthorityFieldType( const SwAuthorityFieldType& );
105 ~SwAuthorityFieldType();
107 virtual SwFieldType* Copy() const;
108 virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
110 virtual BOOL QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMId ) const;
111 virtual BOOL PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMId );
113 inline SwDoc* GetDoc() const { return m_pDoc; }
114 inline void SetDoc(SwDoc* pNewDoc) { m_pDoc = pNewDoc; }
116 void RemoveField(long nHandle);
117 long AddField(const String& rFieldContents);
118 BOOL AddField(long nHandle);
119 void DelSequenceArray()
121 m_pSequArr->Remove(0, m_pSequArr->Count());
124 const SwAuthEntry* GetEntryByHandle(long nHandle) const;
126 // import interface
127 USHORT AppendField(const SwAuthEntry& rInsert);
128 long GetHandle(USHORT nPos);
129 USHORT GetPosition(long nHandle);
131 USHORT GetEntryCount() const;
132 const SwAuthEntry* GetEntryByPosition(USHORT nPos) const;
134 USHORT GetSequencePos(long nHandle);
136 BOOL IsSequence() const {return m_bIsSequence;}
137 void SetSequence(BOOL bSet)
139 DelSequenceArray();
140 m_bIsSequence = bSet;
143 void SetPreSuffix( sal_Unicode cPre, sal_Unicode cSuf)
145 m_cPrefix = cPre;
146 m_cSuffix = cSuf;
148 sal_Unicode GetPrefix() const { return m_cPrefix;}
149 sal_Unicode GetSuffix() const { return m_cSuffix;}
151 BOOL IsSortByDocument() const {return m_bSortByDocument;}
152 void SetSortByDocument(BOOL bSet)
154 DelSequenceArray();
155 m_bSortByDocument = bSet;
158 USHORT GetSortKeyCount() const ;
159 const SwTOXSortKey* GetSortKey(USHORT nIdx) const ;
160 void SetSortKeys(USHORT nKeyCount, SwTOXSortKey nKeys[]);
161 static const String& GetAuthTypeName(ToxAuthorityType eType);
163 LanguageType GetLanguage() const {return m_eLanguage;}
164 void SetLanguage(LanguageType nLang) {m_eLanguage = nLang;}
166 const String& GetSortAlgorithm()const {return m_sSortAlgorithm;}
167 void SetSortAlgorithm(const String& rSet) {m_sSortAlgorithm = rSet;}
170 /* -----------------14.09.99 16:15-------------------
172 --------------------------------------------------*/
173 class SwAuthorityField : public SwField
175 long nHandle;
177 public:
178 SwAuthorityField(SwAuthorityFieldType* pType, const String& rFieldContents);
179 SwAuthorityField(SwAuthorityFieldType* pType, long nHandle);
180 ~SwAuthorityField();
182 const String& GetFieldText(ToxAuthorityField eField) const;
184 virtual String Expand() const;
185 virtual SwField* Copy() const;
186 virtual void SetPar1(const String& rStr);
187 virtual SwFieldType* ChgTyp( SwFieldType* );
189 virtual BOOL QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMId ) const;
190 virtual BOOL PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMId );
192 long GetHandle() const { return nHandle; }
194 //import interface
195 USHORT GetHandlePosition() const;
198 // --- inlines -----------------------------------------------------------
199 inline const String& SwAuthEntry::GetAuthorField(ToxAuthorityField ePos)const
201 DBG_ASSERT(AUTH_FIELD_END > ePos, "wrong index");
202 return aAuthFields[ePos];
204 inline void SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const String& rField)
206 DBG_ASSERT(AUTH_FIELD_END > ePos, "wrong index");
207 if(AUTH_FIELD_END > ePos)
208 aAuthFields[ePos] = rField;
211 } //namespace binfilter
212 #endif