LibreOffice Module sc (master)  1
chartarr.hxx
Go to the documentation of this file.
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 INCLUDED_SC_INC_CHARTARR_HXX
21 #define INCLUDED_SC_INC_CHARTARR_HXX
22 
23 #include "rangelst.hxx"
24 #include "chartpos.hxx"
25 
26 #include <memory>
27 
28 class ScDocument;
29 
30 // ScMemChart is a stripped-down SchMemChart from old chart,
31 // used only to transport a rectangular data array for the UNO API,
32 // contains only column/row header text and data values.
33 
35 {
38  std::unique_ptr<double[]> pData;
39  std::unique_ptr<OUString[]> pColText;
40  std::unique_ptr<OUString[]> pRowText;
41 
42  ScMemChart(const ScMemChart& rMemChart) = delete;
43 
44 public:
45  ScMemChart(SCCOL nCols, SCROW nRows);
46  ~ScMemChart();
47 
48  SCCOL GetColCount() const { return nColCnt; }
49  SCROW GetRowCount() const { return nRowCnt; }
50  const OUString& GetColText(SCCOL nCol) const { return pColText[nCol]; }
51  const OUString& GetRowText(SCROW nRow) const { return pRowText[nRow]; }
52  double GetData(SCCOL nCol, SCROW nRow) const { return pData[nCol * nRowCnt + nRow]; }
53  void SetData(SCCOL nCol, SCROW nRow, const double& rVal)
54  {
55  pData[nCol * nRowCnt + nRow] = rVal;
56  }
57  void SetColText(SCCOL nCol, const OUString& rText) { pColText[nCol] = rText; }
58  void SetRowText(SCROW nRow, const OUString& rText) { pRowText[nRow] = rText; }
59 };
60 
61 class ScChartArray // only parameter-struct
62 {
65 
66 private:
67  std::unique_ptr<ScMemChart> CreateMemChartSingle();
68  std::unique_ptr<ScMemChart> CreateMemChartMulti();
69 
70 public:
71  ScChartArray(ScDocument& rDoc, const ScRangeListRef& rRangeList);
72 
73  const ScRangeListRef& GetRangeList() const { return aPositioner.GetRangeList(); }
74  const ScChartPositionMap* GetPositionMap() { return aPositioner.GetPositionMap(); }
75 
76  void SetHeaders(bool bCol, bool bRow) { aPositioner.SetHeaders(bCol, bRow); }
77  bool HasColHeaders() const { return aPositioner.HasColHeaders(); }
78  bool HasRowHeaders() const { return aPositioner.HasRowHeaders(); }
79 
80  std::unique_ptr<ScMemChart> CreateMemChart();
81 };
82 
83 #endif
84 
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & GetColText(SCCOL nCol) const
Definition: chartarr.hxx:50
ScChartPositioner aPositioner
Definition: chartarr.hxx:64
const OUString & GetRowText(SCROW nRow) const
Definition: chartarr.hxx:51
const ScRangeListRef & GetRangeList() const
Definition: chartpos.hxx:129
SCROW nRowCnt
Definition: chartarr.hxx:36
std::unique_ptr< ScMemChart > CreateMemChartSingle()
Definition: chartarr.cxx:110
std::unique_ptr< double[]> pData
Definition: chartarr.hxx:38
bool HasRowHeaders() const
Definition: chartpos.hxx:134
bool HasRowHeaders() const
Definition: chartarr.hxx:78
std::unique_ptr< OUString[]> pRowText
Definition: chartarr.hxx:40
ScDocument & rDocument
Definition: chartarr.hxx:63
sal_Int16 SCCOL
Definition: types.hxx:22
void SetRowText(SCROW nRow, const OUString &rText)
Definition: chartarr.hxx:58
ScMemChart(const ScMemChart &rMemChart)=delete
void SetHeaders(bool bCol, bool bRow)
Definition: chartarr.hxx:76
ScChartArray(ScDocument &rDoc, const ScRangeListRef &rRangeList)
Definition: chartarr.cxx:53
void SetHeaders(bool bCol, bool bRow)
Definition: chartpos.hxx:132
sal_Int32 SCROW
Definition: types.hxx:18
SCROW GetRowCount() const
Definition: chartarr.hxx:49
const ScChartPositionMap * GetPositionMap()
Definition: chartarr.hxx:74
std::unique_ptr< ScMemChart > CreateMemChart()
Definition: chartarr.cxx:58
void SetColText(SCCOL nCol, const OUString &rText)
Definition: chartarr.hxx:57
std::unique_ptr< OUString[]> pColText
Definition: chartarr.hxx:39
SCCOL nColCnt
Definition: chartarr.hxx:37
bool HasColHeaders() const
Definition: chartarr.hxx:77
const ScRangeListRef & GetRangeList() const
Definition: chartarr.hxx:73
SCCOL GetColCount() const
Definition: chartarr.hxx:48
bool HasColHeaders() const
Definition: chartpos.hxx:133
std::unique_ptr< ScMemChart > CreateMemChartMulti()
Definition: chartarr.cxx:273
double GetData(SCCOL nCol, SCROW nRow) const
Definition: chartarr.hxx:52
void SetData(SCCOL nCol, SCROW nRow, const double &rVal)
Definition: chartarr.hxx:53
const ScChartPositionMap * GetPositionMap()
Definition: chartpos.cxx:333