Branch libreoffice-24-8-3
[LibreOffice.git] / sc / inc / dpitemdata.hxx
blobaed04cf78e725e8aed382bd788ed681f22365700
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 #pragma once
12 #include "scdllapi.h"
14 #include <sal/types.h>
15 #include <rtl/ustring.h>
16 #include <rtl/ustring.hxx>
17 #include "calcmacros.hxx"
18 #include "dpglobal.hxx"
20 /**
21 * When assigning a string value, you can also assign an interned string
22 * whose life-cycle is managed by the pivot cache that it belongs to. Those
23 * methods that take a string pointer assume that the string is interned.
25 * <p>Do make sure that an item with an interned string won't persist after
26 * the pivot cache has been destroyed or reloaded.</p>
28 class ScDPItemData
30 friend class ScDPCache;
32 public:
33 enum Type { GroupValue = 0, RangeStart = 1, Value = 2, String = 3, Error = 4, Empty = 5 };
35 SC_DLLPUBLIC static const sal_Int32 DateFirst;
36 SC_DLLPUBLIC static const sal_Int32 DateLast;
38 struct GroupValueAttr
40 sal_Int32 mnGroupType;
41 sal_Int32 mnValue;
44 private:
46 union {
47 rtl_uString* mpString;
48 GroupValueAttr maGroupValue;
49 double mfValue;
52 sal_uInt8 meType:3;
53 bool mbStringInterned:1;
55 void DisposeString();
57 public:
58 // case insensitive equality
59 static sal_Int32 Compare(const ScDPItemData& rA, const ScDPItemData& rB);
61 ScDPItemData();
62 ScDPItemData(const ScDPItemData& r);
63 ScDPItemData(const OUString& rStr);
64 ScDPItemData(sal_Int32 nGroupType, sal_Int32 nValue);
65 SC_DLLPUBLIC ~ScDPItemData();
67 Type GetType() const { return static_cast<Type>(meType); }
68 void SetEmpty();
69 void SetString(const OUString& rS);
70 void SetStringInterned( rtl_uString* pS );
71 void SetValue(double fVal);
72 void SetRangeStart(double fVal);
73 void SetRangeFirst();
74 void SetRangeLast();
75 void SetErrorStringInterned( rtl_uString* pS );
76 bool IsCaseInsEqual(const ScDPItemData& r) const;
78 // exact equality
79 bool operator==(const ScDPItemData& r) const;
80 bool operator< (const ScDPItemData& r) const;
82 ScDPItemData& operator= (const ScDPItemData& r);
84 SC_DLLPUBLIC bool IsEmpty() const;
85 bool IsValue() const;
86 SC_DLLPUBLIC OUString GetString() const;
87 SC_DLLPUBLIC double GetValue() const;
88 SC_DLLPUBLIC GroupValueAttr GetGroupValue() const;
89 SC_DLLPUBLIC bool HasStringData() const ;
91 ScDPValue::Type GetCellType() const;
93 #if DEBUG_PIVOT_TABLE
94 void Dump(const char* msg) const;
95 #endif
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */