Branch libreoffice-24-8-3
[LibreOffice.git] / sc / inc / dpoutput.hxx
blob29423ab66c57c9a98d031c9885135b02f345a352
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <com/sun/star/sheet/DataPilotOutputRangeType.hpp>
23 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
24 #include <com/sun/star/uno/Sequence.hxx>
26 #include <tools/long.hxx>
28 #include "address.hxx"
30 #include "dptypes.hxx"
31 #include "pivot/PivotTableFormats.hxx"
32 #include "pivot/PivotTableFormatOutput.hxx"
34 #include <memory>
35 #include <vector>
37 namespace com::sun::star::sheet {
38 struct DataPilotFieldFilter;
39 struct DataPilotTablePositionData;
40 struct DataResult;
41 struct MemberResult;
42 class XDimensionsSupplier;
44 namespace tools { class Rectangle; }
45 class ScDocument;
46 struct ScDPOutLevelData;
47 class ScDPOutputImpl;
48 class ScDPObject;
50 class ScDPOutput
52 private:
53 ScDocument* mpDocument;
54 sc::FormatOutput maFormatOutput;
55 css::uno::Reference<css::sheet::XDimensionsSupplier> mxSource;
56 ScAddress maStartPos;
57 std::vector<ScDPOutLevelData> mpColFields;
58 std::vector<ScDPOutLevelData> mpRowFields;
59 std::vector<ScDPOutLevelData> mpPageFields;
60 css::uno::Sequence<css::uno::Sequence<css::sheet::DataResult>> maData;
61 OUString maDataDescription;
63 // Number format related parameters
64 std::unique_ptr<sal_uInt32[]> mpColNumberFormat;
65 std::unique_ptr<sal_uInt32[]> mpRowNumberFormat;
66 std::vector<bool> maRowCompactFlags;
67 sal_Int32 mnColFormatCount;
68 sal_Int32 mnRowFormatCount;
69 sal_uInt32 mnSingleNumberFormat;
70 size_t mnRowDims; // Including empty ones.
72 // Output geometry related parameters
73 sal_Int32 mnColCount;
74 sal_Int32 mnRowCount;
75 sal_Int32 mnHeaderSize;
76 SCCOL mnTabStartCol;
77 SCROW mnTabStartRow;
78 SCCOL mnMemberStartCol;
79 SCROW mnMemberStartRow;
80 SCCOL mnDataStartCol;
81 SCROW mnDataStartRow;
82 SCCOL mnTabEndCol;
83 SCROW mnTabEndRow;
84 bool mbDoFilter:1;
85 bool mbResultsError:1;
86 bool mbSizesValid:1;
87 bool mbSizeOverflow:1;
88 bool mbHeaderLayout:1; // true : grid, false : standard
89 bool mbHasCompactRowField:1; // true: at least one of the row fields has compact layout.
90 bool mbExpandCollapse:1; // true: show expand/collapse buttons
91 bool mbHideHeader : 1;
93 void DataCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
94 const css::sheet::DataResult& rData );
95 void HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
96 const css::sheet::MemberResult& rData,
97 bool bColHeader, tools::Long nLevel );
99 void FieldCell(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScDPOutLevelData& rData, bool bInTable);
100 void MultiFieldCell(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bRowField);
102 /// Computes number of columns needed to write row fields.
103 SCCOL GetColumnsForRowFields() const;
104 void CalcSizes();
106 /** Query which sub-area of the table the cell is in. See
107 css.sheet.DataPilotTablePositionType for the interpretation of the
108 return value. */
109 sal_Int32 GetPositionType(const ScAddress& rPos);
110 /// Returns the range of row fields that are contained by table's row fields column nCol.
111 void GetRowFieldRange(SCCOL nCol, sal_Int32& nRowFieldStart, sal_Int32& nRowFieldEnd) const;
112 /// Find row field index from row position in case of compact layout.
113 sal_Int32 GetRowFieldCompact(SCCOL nColQuery, SCROW nRowQuery) const;
115 void outputPageFields(SCTAB nTab);
116 void outputColumnHeaders(SCTAB nTab, ScDPOutputImpl& rOutputImpl);
117 void outputRowHeader(SCTAB nTab, ScDPOutputImpl& rOutputImpl);
118 void outputDataResults(SCTAB nTab);
120 public:
121 ScDPOutput(ScDocument* pDocument,
122 css::uno::Reference<css::sheet::XDimensionsSupplier> xSource,
123 const ScAddress& rPosition, bool bFilter, bool bExpandCollapse,
124 ScDPObject& rObject, bool bHideHeader);
125 ~ScDPOutput();
127 void SetPosition( const ScAddress& rPos );
129 void Output(); //! Refresh?
130 ScRange GetOutputRange( sal_Int32 nRegionType = css::sheet::DataPilotOutputRangeType::WHOLE );
131 sal_Int32 GetHeaderRows() const;
132 bool HasError(); // range overflow or exception from source
134 void GetPositionData(const ScAddress& rPos, css::sheet::DataPilotTablePositionData& rPosData);
136 /** Get filtering criteria based on the position of the cell within data
137 field region. */
138 bool GetDataResultPositionData(::std::vector< css::sheet::DataPilotFieldFilter >& rFilters, const ScAddress& rPos);
140 tools::Long GetHeaderDim( const ScAddress& rPos, css::sheet::DataPilotFieldOrientation& rOrient );
141 bool GetHeaderDrag(
142 const ScAddress& rPos, bool bMouseLeft, bool bMouseTop, tools::Long nDragDim,
143 tools::Rectangle& rPosRect, css::sheet::DataPilotFieldOrientation& rOrient, tools::Long& rDimPos );
144 bool IsFilterButton( const ScAddress& rPos );
146 void GetMemberResultNames(ScDPUniqueStringSet& rNames, tools::Long nDimension);
148 void SetHeaderLayout(bool bUseGrid);
149 bool GetHeaderLayout() const { return mbHeaderLayout;}
151 void setFormats(sc::PivotTableFormats const& rPivotTableFormats)
153 maFormatOutput.setFormats(rPivotTableFormats);
156 static void GetDataDimensionNames(
157 OUString& rSourceName, OUString& rGivenName,
158 const css::uno::Reference< css::uno::XInterface>& xDim );
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */