1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef SW_AUTHFLD_HXX
20 #define SW_AUTHFLD_HXX
26 #include <boost/ptr_container/ptr_vector.hpp>
30 String aAuthFields
[AUTH_FIELD_END
];
33 SwAuthEntry() : nRefCount(0){}
34 SwAuthEntry( const SwAuthEntry
& rCopy
);
35 sal_Bool
operator==(const SwAuthEntry
& rComp
);
37 inline const String
& GetAuthorField(ToxAuthorityField ePos
)const;
38 inline void SetAuthorField(ToxAuthorityField ePos
,
39 const String
& rField
);
41 void AddRef() { ++nRefCount
; }
42 void RemoveRef() { --nRefCount
; }
43 sal_uInt16
GetRefCount() { return nRefCount
; }
48 ToxAuthorityField eField
;
49 sal_Bool bSortAscending
;
51 eField(AUTH_FIELD_END
),
52 bSortAscending(sal_True
){}
55 class SwAuthorityField
;
56 typedef boost::ptr_vector
<SwTOXSortKey
> SortKeyArr
;
57 typedef boost::ptr_vector
<SwAuthEntry
> SwAuthDataArr
;
59 class SW_DLLPUBLIC SwAuthorityFieldType
: public SwFieldType
62 SwAuthDataArr m_DataArr
;
63 std::vector
<long> m_SequArr
;
64 SortKeyArr m_SortKeyArr
;
65 sal_Unicode m_cPrefix
;
66 sal_Unicode m_cSuffix
;
67 sal_Bool m_bIsSequence
:1;
68 sal_Bool m_bSortByDocument
:1;
69 LanguageType m_eLanguage
;
70 String m_sSortAlgorithm
;
73 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
);
76 SwAuthorityFieldType(SwDoc
* pDoc
);
77 ~SwAuthorityFieldType();
79 virtual SwFieldType
* Copy() const;
81 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhichId
) const;
82 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhichId
);
84 inline void SetDoc(SwDoc
* pNewDoc
) { m_pDoc
= pNewDoc
; }
85 SwDoc
* GetDoc(){ return m_pDoc
; }
86 void RemoveField(long nHandle
);
87 long AddField(const String
& rFieldContents
);
88 sal_Bool
AddField(long nHandle
);
89 void DelSequenceArray()
94 const SwAuthEntry
* GetEntryByHandle(long nHandle
) const;
96 void GetAllEntryIdentifiers( std::vector
<String
>& rToFill
)const;
97 const SwAuthEntry
* GetEntryByIdentifier(const String
& rIdentifier
)const;
99 bool ChangeEntryContent(const SwAuthEntry
* pNewEntry
);
101 sal_uInt16
AppendField(const SwAuthEntry
& rInsert
);
102 long GetHandle(sal_uInt16 nPos
);
104 sal_uInt16
GetSequencePos(long nHandle
);
106 sal_Bool
IsSequence() const {return m_bIsSequence
;}
107 void SetSequence(sal_Bool bSet
)
110 m_bIsSequence
= bSet
;
113 void SetPreSuffix( sal_Unicode cPre
, sal_Unicode cSuf
)
118 sal_Unicode
GetPrefix() const { return m_cPrefix
;}
119 sal_Unicode
GetSuffix() const { return m_cSuffix
;}
121 sal_Bool
IsSortByDocument() const {return m_bSortByDocument
;}
122 void SetSortByDocument(sal_Bool bSet
)
125 m_bSortByDocument
= bSet
;
128 sal_uInt16
GetSortKeyCount() const ;
129 const SwTOXSortKey
* GetSortKey(sal_uInt16 nIdx
) const ;
130 void SetSortKeys(sal_uInt16 nKeyCount
, SwTOXSortKey nKeys
[]);
133 static const String
& GetAuthFieldName(ToxAuthorityField eType
);
134 static const String
& GetAuthTypeName(ToxAuthorityType eType
);
136 LanguageType
GetLanguage() const {return m_eLanguage
;}
137 void SetLanguage(LanguageType nLang
) {m_eLanguage
= nLang
;}
139 const String
& GetSortAlgorithm()const {return m_sSortAlgorithm
;}
140 void SetSortAlgorithm(const String
& rSet
) {m_sSortAlgorithm
= rSet
;}
144 class SwAuthorityField
: public SwField
147 mutable long m_nTempSequencePos
;
149 virtual String
Expand() const;
150 virtual SwField
* Copy() const;
153 SwAuthorityField(SwAuthorityFieldType
* pType
, const String
& rFieldContents
);
154 SwAuthorityField(SwAuthorityFieldType
* pType
, long nHandle
);
157 const String
& GetFieldText(ToxAuthorityField eField
) const;
159 virtual void SetPar1(const OUString
& rStr
);
160 virtual SwFieldType
* ChgTyp( SwFieldType
* );
162 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhichId
) const;
163 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt16 nWhichId
);
165 long GetHandle() const { return m_nHandle
; }
167 virtual String
GetDescription() const;
170 // --- inlines -----------------------------------------------------------
171 inline const String
& SwAuthEntry::GetAuthorField(ToxAuthorityField ePos
)const
173 OSL_ENSURE(AUTH_FIELD_END
> ePos
, "wrong index");
174 return aAuthFields
[ePos
];
176 inline void SwAuthEntry::SetAuthorField(ToxAuthorityField ePos
, const String
& rField
)
178 OSL_ENSURE(AUTH_FIELD_END
> ePos
, "wrong index");
179 if(AUTH_FIELD_END
> ePos
)
180 aAuthFields
[ePos
] = rField
;
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */