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