merge the formfield patch from ooo-build
[ooovba.git] / sw / inc / authfld.hxx
blobcb8ac0733b405d41b955d60e95407fe3a9645cf2
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.15 $
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 #include "swdllapi.h"
34 #include <fldbas.hxx>
35 #include <toxe.hxx>
37 #define _SVSTDARR_LONGS
38 #include <svtools/svstdarr.hxx>
40 class SwAuthDataArr;
41 /* -----------------21.09.99 13:32-------------------
43 --------------------------------------------------*/
44 class SwAuthEntry
46 String aAuthFields[AUTH_FIELD_END];
47 USHORT nRefCount;
48 public:
49 SwAuthEntry() : nRefCount(0){}
50 SwAuthEntry( const SwAuthEntry& rCopy );
51 BOOL operator==(const SwAuthEntry& rComp);
53 inline const String& GetAuthorField(ToxAuthorityField ePos)const;
54 inline void SetAuthorField(ToxAuthorityField ePos,
55 const String& rField);
57 void AddRef() { ++nRefCount; }
58 void RemoveRef() { --nRefCount; }
59 USHORT GetRefCount() { return nRefCount; }
61 /* -----------------20.10.99 16:49-------------------
63 --------------------------------------------------*/
64 struct SwTOXSortKey
66 ToxAuthorityField eField;
67 BOOL bSortAscending;
68 SwTOXSortKey() :
69 eField(AUTH_FIELD_END),
70 bSortAscending(TRUE){}
73 /* -----------------14.09.99 16:15-------------------
75 --------------------------------------------------*/
76 class SwAuthorityField;
77 class SortKeyArr;
79 class SW_DLLPUBLIC SwAuthorityFieldType : public SwFieldType
81 SwDoc* m_pDoc;
82 SwAuthDataArr* m_pDataArr;
83 SvLongs* m_pSequArr;
84 SortKeyArr* m_pSortKeyArr;
85 sal_Unicode m_cPrefix;
86 sal_Unicode m_cSuffix;
87 BOOL m_bIsSequence :1;
88 BOOL m_bSortByDocument :1;
89 LanguageType m_eLanguage;
90 String m_sSortAlgorithm;
92 // @@@ private copy assignment, but public copy ctor? @@@
93 const SwAuthorityFieldType& operator=( const SwAuthorityFieldType& );
95 public:
96 SwAuthorityFieldType(SwDoc* pDoc);
97 SwAuthorityFieldType( const SwAuthorityFieldType& );
98 ~SwAuthorityFieldType();
100 virtual SwFieldType* Copy() const;
101 virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew );
103 virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, USHORT nWhichId ) const;
104 virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, USHORT nWhichId );
106 inline void SetDoc(SwDoc* pNewDoc) { m_pDoc = pNewDoc; }
107 SwDoc* GetDoc(){ return m_pDoc; }
108 void RemoveField(long nHandle);
109 long AddField(const String& rFieldContents);
110 BOOL AddField(long nHandle);
111 void DelSequenceArray()
113 m_pSequArr->Remove(0, m_pSequArr->Count());
116 const SwAuthEntry* GetEntryByHandle(long nHandle) const;
118 void GetAllEntryIdentifiers( SvStringsDtor& rToFill )const;
119 const SwAuthEntry* GetEntryByIdentifier(const String& rIdentifier)const;
121 bool ChangeEntryContent(const SwAuthEntry* pNewEntry);
122 // import interface
123 USHORT AppendField(const SwAuthEntry& rInsert);
124 long GetHandle(USHORT nPos);
126 USHORT GetSequencePos(long nHandle);
128 BOOL IsSequence() const {return m_bIsSequence;}
129 void SetSequence(BOOL bSet)
131 DelSequenceArray();
132 m_bIsSequence = bSet;
135 void SetPreSuffix( sal_Unicode cPre, sal_Unicode cSuf)
137 m_cPrefix = cPre;
138 m_cSuffix = cSuf;
140 sal_Unicode GetPrefix() const { return m_cPrefix;}
141 sal_Unicode GetSuffix() const { return m_cSuffix;}
143 BOOL IsSortByDocument() const {return m_bSortByDocument;}
144 void SetSortByDocument(BOOL bSet)
146 DelSequenceArray();
147 m_bSortByDocument = bSet;
150 USHORT GetSortKeyCount() const ;
151 const SwTOXSortKey* GetSortKey(USHORT nIdx) const ;
152 void SetSortKeys(USHORT nKeyCount, SwTOXSortKey nKeys[]);
154 //initui.cxx
155 static const String& GetAuthFieldName(ToxAuthorityField eType);
156 static const String& GetAuthTypeName(ToxAuthorityType eType);
158 LanguageType GetLanguage() const {return m_eLanguage;}
159 void SetLanguage(LanguageType nLang) {m_eLanguage = nLang;}
161 const String& GetSortAlgorithm()const {return m_sSortAlgorithm;}
162 void SetSortAlgorithm(const String& rSet) {m_sSortAlgorithm = rSet;}
165 /* -----------------14.09.99 16:15-------------------
167 --------------------------------------------------*/
168 class SwAuthorityField : public SwField
170 long m_nHandle;
171 mutable long m_nTempSequencePos;
172 public:
173 SwAuthorityField(SwAuthorityFieldType* pType, const String& rFieldContents);
174 SwAuthorityField(SwAuthorityFieldType* pType, long nHandle);
175 ~SwAuthorityField();
177 const String& GetFieldText(ToxAuthorityField eField) const;
179 virtual String Expand() const;
180 virtual SwField* Copy() const;
181 virtual void SetPar1(const String& rStr);
182 virtual SwFieldType* ChgTyp( SwFieldType* );
184 virtual BOOL QueryValue( com::sun::star::uno::Any& rVal, USHORT nWhichId ) const;
185 virtual BOOL PutValue( const com::sun::star::uno::Any& rVal, USHORT nWhichId );
187 long GetHandle() const { return m_nHandle; }
189 virtual String GetDescription() const;
192 // --- inlines -----------------------------------------------------------
193 inline const String& SwAuthEntry::GetAuthorField(ToxAuthorityField ePos)const
195 DBG_ASSERT(AUTH_FIELD_END > ePos, "wrong index");
196 return aAuthFields[ePos];
198 inline void SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const String& rField)
200 DBG_ASSERT(AUTH_FIELD_END > ePos, "wrong index");
201 if(AUTH_FIELD_END > ePos)
202 aAuthFields[ePos] = rField;
205 #endif