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