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 :
10 : #ifndef INCLUDED_SC_INC_DPITEMDATA_HXX
11 : #define INCLUDED_SC_INC_DPITEMDATA_HXX
12 :
13 : #include "scdllapi.h"
14 : #include "address.hxx"
15 :
16 : #include <sal/types.h>
17 : #include <rtl/ustring.hxx>
18 : #include "calcmacros.hxx"
19 : #include "dpglobal.hxx"
20 :
21 : /**
22 : * When assigning a string value, you can also assign an interned string
23 : * whose life-cycle is managed by the pivot cache that it belongs to. Those
24 : * methods that take a string pointer assume that the string is interned.
25 : *
26 : * <p>Do make sure that an item with an interned string won't persist after
27 : * the pivot cache has been destroyed or reloaded.</p>
28 : */
29 : class SC_DLLPUBLIC ScDPItemData
30 : {
31 : friend class ScDPCache;
32 :
33 : public:
34 : enum Type { GroupValue = 0, RangeStart = 1, Value = 2, String = 3, Error = 4, Empty = 5 };
35 :
36 : static const sal_Int32 DateFirst;
37 : static const sal_Int32 DateLast;
38 :
39 : struct GroupValueAttr
40 : {
41 : sal_Int32 mnGroupType;
42 : sal_Int32 mnValue;
43 : };
44 :
45 : struct Hash
46 : {
47 : size_t operator() (const ScDPItemData& rVal) const;
48 : };
49 :
50 : private:
51 :
52 : union {
53 : const OUString* mpString;
54 : GroupValueAttr maGroupValue;
55 : double mfValue;
56 : };
57 :
58 : sal_uInt8 meType:3;
59 : bool mbStringInterned:1;
60 :
61 : void DisposeString();
62 :
63 : public:
64 : // case insensitive equality
65 : static sal_Int32 Compare(const ScDPItemData& rA, const ScDPItemData& rB);
66 :
67 : ScDPItemData();
68 : ScDPItemData(const ScDPItemData& r);
69 : ScDPItemData(const OUString& rStr);
70 : ScDPItemData(sal_Int32 nGroupType, sal_Int32 nValue);
71 : ~ScDPItemData();
72 :
73 6001 : Type GetType() const { return static_cast<Type>(meType); }
74 : void SetEmpty();
75 : void SetString(const OUString& rS);
76 : void SetString(const OUString* pS);
77 : void SetValue(double fVal);
78 : void SetRangeStart(double fVal);
79 : void SetRangeFirst();
80 : void SetRangeLast();
81 : void SetErrorString(const OUString* pS);
82 : bool IsCaseInsEqual(const ScDPItemData& r) const;
83 :
84 : // exact equality
85 : bool operator==(const ScDPItemData& r) const;
86 : bool operator!=(const ScDPItemData& r) const;
87 : bool operator< (const ScDPItemData& r) const;
88 :
89 : ScDPItemData& operator= (const ScDPItemData& r);
90 :
91 : bool IsEmpty() const;
92 : bool IsValue() const;
93 : OUString GetString() const;
94 : double GetValue() const;
95 : GroupValueAttr GetGroupValue() const;
96 : bool HasStringData() const ;
97 :
98 : ScDPValue::Type GetCellType() const;
99 :
100 : #if DEBUG_PIVOT_TABLE
101 : void Dump(const char* msg) const;
102 : #endif
103 : };
104 :
105 : #endif
106 :
107 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|