Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef SC_USERLIST_HXX
21 : #define SC_USERLIST_HXX
22 :
23 : #include <tools/stream.hxx>
24 : #include "scdllapi.h"
25 :
26 : #include <boost/ptr_container/ptr_vector.hpp>
27 :
28 : /**
29 : * Stores individual user-defined sort list.
30 : */
31 : class SC_DLLPUBLIC ScUserListData
32 : {
33 : public:
34 0 : struct SubStr
35 : {
36 : OUString maReal;
37 : OUString maUpper;
38 : SubStr(const OUString& rReal, const OUString& rUpper);
39 : };
40 : private:
41 : typedef ::boost::ptr_vector<SubStr> SubStringsType;
42 : SubStringsType maSubStrings;
43 : OUString aStr;
44 :
45 : SAL_DLLPRIVATE void InitTokens();
46 :
47 : public:
48 : ScUserListData(const OUString& rStr);
49 : ScUserListData(const ScUserListData& rData);
50 : ~ScUserListData();
51 :
52 0 : const OUString& GetString() const { return aStr; }
53 : void SetString(const OUString& rStr);
54 : size_t GetSubCount() const;
55 : bool GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex) const;
56 : OUString GetSubStr(sal_uInt16 nIndex) const;
57 : sal_Int32 Compare(const OUString& rSubStr1, const OUString& rSubStr2) const;
58 : sal_Int32 ICompare(const OUString& rSubStr1, const OUString& rSubStr2) const;
59 : };
60 :
61 : /**
62 : * Collection of user-defined sort lists.
63 : */
64 0 : class SC_DLLPUBLIC ScUserList
65 : {
66 : typedef ::boost::ptr_vector<ScUserListData> DataType;
67 : DataType maData;
68 : public:
69 : typedef DataType::iterator iterator;
70 : typedef DataType::const_iterator const_iterator;
71 :
72 : ScUserList();
73 : ScUserList(const ScUserList& r);
74 :
75 : const ScUserListData* GetData( const OUString& rSubStr ) const;
76 : /// If the list in rStr is already inserted
77 : bool HasEntry( const OUString& rStr ) const;
78 :
79 : const ScUserListData* operator[](size_t nIndex) const;
80 : ScUserListData* operator[](size_t nIndex);
81 : ScUserList& operator= ( const ScUserList& r );
82 : bool operator==( const ScUserList& r ) const;
83 : bool operator!=( const ScUserList& r ) const;
84 :
85 : iterator begin();
86 : const_iterator begin() const;
87 : void clear();
88 : size_t size() const;
89 : void push_back(ScUserListData* p);
90 : void erase(iterator itr);
91 : };
92 :
93 : #endif
94 :
95 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|