Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / inc / dpitemdata.hxx
blob823a6c1e142521e8d9dd673b9534dde998cc07d3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #ifndef __SC_DPITEMDATA_HXX__
11 #define __SC_DPITEMDATA_HXX__
13 #include "scdllapi.h"
14 #include "address.hxx"
16 #include "sal/types.h"
17 #include "tools/solar.h"
18 #include "rtl/ustring.hxx"
19 #include "calcmacros.hxx"
20 #include "dpglobal.hxx"
22 /**
23 * When assigning a string value, you can also assign an interned string
24 * whose life-cycle is managed by the pivot cache that it belongs to. Those
25 * methods that take a string pointer assume that the string is interned.
27 * <p>Do make sure that an item with an interned string won't persist after
28 * the pivot cache has been destroyed or reloaded.</p>
30 class SC_DLLPUBLIC ScDPItemData
32 friend class ScDPCache;
34 public:
35 enum Type { GroupValue = 0, RangeStart = 1, Value = 2, String = 3, Error = 4, Empty = 5 };
37 static const sal_Int32 DateFirst;
38 static const sal_Int32 DateLast;
40 struct GroupValueAttr
42 sal_Int32 mnGroupType;
43 sal_Int32 mnValue;
46 struct Hash
48 size_t operator() (const ScDPItemData& rVal) const;
51 private:
53 union {
54 const OUString* mpString;
55 GroupValueAttr maGroupValue;
56 double mfValue;
59 sal_uInt8 meType:3;
60 bool mbStringInterned:1;
62 void DisposeString();
64 public:
65 // case insensitive equality
66 static sal_Int32 Compare(const ScDPItemData& rA, const ScDPItemData& rB);
68 ScDPItemData();
69 ScDPItemData(const ScDPItemData& r);
70 ScDPItemData(const OUString& rStr);
71 ScDPItemData(sal_Int32 nGroupType, sal_Int32 nValue);
72 ~ScDPItemData();
74 Type GetType() const;
75 void SetEmpty();
76 void SetString(const OUString& rS);
77 void SetString(const OUString* pS);
78 void SetValue(double fVal);
79 void SetRangeStart(double fVal);
80 void SetRangeFirst();
81 void SetRangeLast();
82 void SetErrorString(const OUString* pS);
83 bool IsCaseInsEqual(const ScDPItemData& r) const;
85 // exact equality
86 bool operator==(const ScDPItemData& r) const;
87 bool operator!=(const ScDPItemData& r) const;
88 bool operator< (const ScDPItemData& r) const;
90 ScDPItemData& operator= (const ScDPItemData& r);
92 bool IsEmpty() const;
93 bool IsValue() const;
94 OUString GetString() const;
95 double GetValue() const;
96 GroupValueAttr GetGroupValue() const;
97 bool HasStringData() const ;
99 ScDPValue::Type GetCellType() const;
101 #if DEBUG_PIVOT_TABLE
102 void Dump(const char* msg) const;
103 #endif
106 #endif
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */