xref: /trunk/main/sc/inc/userlist.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 
28 #ifndef SC_USERLIST_HXX
29 #define SC_USERLIST_HXX
30 
31 #include <tools/stream.hxx>
32 #include "scdllapi.h"
33 #include "collect.hxx"
34 
35 //------------------------------------------------------------------------
36 class SC_DLLPUBLIC ScUserListData : public ScDataObject
37 {
38 friend class ScUserList;
39     String  aStr;
40     sal_uInt16  nTokenCount;
41     String* pSubStrings;
42     String* pUpperSub;
43 
44     SC_DLLPRIVATE void  InitTokens();
45 
46 public:
47                     ScUserListData(const String& rStr);
48                     ScUserListData(const ScUserListData& rData);
49     virtual         ~ScUserListData();
50 
51     virtual ScDataObject*       Clone() const { return new ScUserListData(*this); }
52 
53     const   String&         GetString() const { return aStr; }
54             void            SetString( const String& rStr);
55             sal_uInt16          GetSubCount() const;
56             sal_Bool            GetSubIndex(const String& rSubStr, sal_uInt16& rIndex) const;
57             String          GetSubStr(sal_uInt16 nIndex) const;
58             StringCompare   Compare(const String& rSubStr1, const String& rSubStr2) const;
59             StringCompare   ICompare(const String& rSubStr1, const String& rSubStr2) const;
60 };
61 
62 //------------------------------------------------------------------------
63 class SC_DLLPUBLIC ScUserList : public ScCollection
64 {
65 public:
66                     ScUserList( sal_uInt16 nLim = 4, sal_uInt16 nDel = 4);
67                     ScUserList( const ScUserList& rUserList ) : ScCollection ( rUserList ) {}
68 
69     virtual ScDataObject*       Clone() const;
70 
71             ScUserListData* GetData( const String& rSubStr ) const;
72             /// If the list in rStr is already inserted
73             sal_Bool            HasEntry( const String& rStr ) const;
74 
75     inline  ScUserListData* operator[]( const sal_uInt16 nIndex) const;
76     inline  ScUserList&     operator= ( const ScUserList& r );
77             sal_Bool            operator==( const ScUserList& r ) const;
78     inline  sal_Bool            operator!=( const ScUserList& r ) const;
79 };
80 
81 inline  ScUserList& ScUserList::operator=( const ScUserList& r )
82     { return (ScUserList&)ScCollection::operator=( r ); }
83 
84 inline ScUserListData* ScUserList::operator[]( const sal_uInt16 nIndex) const
85     { return (ScUserListData*)At(nIndex); }
86 
87 inline sal_Bool ScUserList::operator!=( const ScUserList& r ) const
88     { return !operator==( r ); }
89 
90 #endif
91 
92