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