LibreOffice Module sc (master) 1
chartpos.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 <tools/solar.h>
24#include <memory>
25#include <map>
26
27// map of row number to ScAddress*
28typedef std::map<SCROW, std::unique_ptr<ScAddress>> RowMap;
29// map of column number to RowMap
30typedef std::map<SCCOL, RowMap> ColumnMap;
31
33{
34 friend class ScChartPositioner;
35
36 std::unique_ptr<std::unique_ptr<ScAddress>[]> ppData;
37 std::unique_ptr<std::unique_ptr<ScAddress>[]> ppColHeader;
38 std::unique_ptr<std::unique_ptr<ScAddress>[]> ppRowHeader;
39 sal_uInt64 nCount;
42
43 ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows,
44 SCCOL nColAdd, // header columns
45 SCROW nRowAdd, // header rows
46 ColumnMap& rCols // table with col tables with address*
47 );
48
51
52public:
54
55 SCCOL GetColCount() const { return nColCount; }
56 SCROW GetRowCount() const { return nRowCount; }
57
58 bool IsValid( SCCOL nCol, SCROW nRow ) const
59 { return nCol < nColCount && nRow < nRowCount; }
60 // data column by column
61 sal_uInt64 GetIndex( SCCOL nCol, SCROW nRow ) const
62 { return static_cast<sal_uInt64>(nCol) * nRowCount + nRow; }
63
64 const ScAddress* GetPosition( sal_uInt64 nIndex ) const
65 {
66 if ( nIndex < nCount )
67 return ppData[ nIndex ].get();
68 return nullptr;
69 }
70
72 const ScAddress* GetPosition( SCCOL nChartCol, SCROW nChartRow ) const
73 {
74 if ( IsValid( nChartCol, nChartRow ) )
75 return ppData[ GetIndex( nChartCol, nChartRow ) ].get();
76 return nullptr;
77 }
78 const ScAddress* GetColHeaderPosition( SCCOL nChartCol ) const
79 {
80 if ( nChartCol < nColCount )
81 return ppColHeader[ nChartCol ].get();
82 return nullptr;
83 }
84 const ScAddress* GetRowHeaderPosition( SCROW nChartRow ) const
85 {
86 if ( nChartRow < nRowCount )
87 return ppRowHeader[ nChartRow ].get();
88 return nullptr;
89 }
90};
91
92enum class ScChartGlue {
93 NA,
94 NONE, // old mimic
95 Cols, // old mimic
96 Rows,
97 Both
98};
99
100class ScDocument;
101
102class ScChartPositioner final // only parameter struct
103{
106 std::unique_ptr<ScChartPositionMap> pPositionMap;
113
114 void CheckColRowHeaders();
115
116 void GlueState(); // summarised areas
117 void CreatePositionMap();
118
119public:
121 SCCOL nStartColP, SCROW nStartRowP,
122 SCCOL nEndColP, SCROW nEndRowP );
123 ScChartPositioner( ScDocument& rDoc, ScRangeListRef xRangeList );
124 ScChartPositioner( const ScChartPositioner& rPositioner );
125
127
128 const ScRangeListRef& GetRangeList() const { return aRangeListRef; }
129 void SetRangeList( const ScRange& rNew );
130
131 void SetHeaders(bool bCol, bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; }
132 bool HasColHeaders() const { return bColHeaders; }
133 bool HasRowHeaders() const { return bRowHeaders; }
134
135 void InvalidateGlue();
137};
138
139/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScChartGlue
Definition: chartpos.hxx:92
std::map< SCCOL, RowMap > ColumnMap
Definition: chartpos.hxx:30
std::map< SCROW, std::unique_ptr< ScAddress > > RowMap
Definition: chartpos.hxx:28
std::unique_ptr< std::unique_ptr< ScAddress >[]> ppRowHeader
Definition: chartpos.hxx:38
std::unique_ptr< std::unique_ptr< ScAddress >[]> ppColHeader
Definition: chartpos.hxx:37
const ScAddress * GetRowHeaderPosition(SCROW nChartRow) const
Definition: chartpos.hxx:84
bool IsValid(SCCOL nCol, SCROW nRow) const
Definition: chartpos.hxx:58
const ScAddress * GetColHeaderPosition(SCCOL nChartCol) const
Definition: chartpos.hxx:78
ScChartPositionMap(const ScChartPositionMap &)=delete
const ScAddress * GetPosition(sal_uInt64 nIndex) const
Definition: chartpos.hxx:64
SCROW GetRowCount() const
Definition: chartpos.hxx:56
SCCOL GetColCount() const
deletes all ScAddress*
Definition: chartpos.hxx:55
ScChartPositionMap(SCCOL nChartCols, SCROW nChartRows, SCCOL nColAdd, SCROW nRowAdd, ColumnMap &rCols)
Definition: chartpos.cxx:447
sal_uInt64 nCount
Definition: chartpos.hxx:39
const ScAddress * GetPosition(SCCOL nChartCol, SCROW nChartRow) const
might be NULL indicating "no value"
Definition: chartpos.hxx:72
ScChartPositionMap & operator=(const ScChartPositionMap &)=delete
sal_uInt64 GetIndex(SCCOL nCol, SCROW nRow) const
Definition: chartpos.hxx:61
std::unique_ptr< std::unique_ptr< ScAddress >[]> ppData
Definition: chartpos.hxx:36
bool HasColHeaders() const
Definition: chartpos.hxx:132
bool HasRowHeaders() const
Definition: chartpos.hxx:133
void SetHeaders(bool bCol, bool bRow)
Definition: chartpos.hxx:131
ScChartGlue eGlue
Definition: chartpos.hxx:107
void CheckColRowHeaders()
Definition: chartpos.cxx:271
const ScChartPositionMap * GetPositionMap()
Definition: chartpos.cxx:335
void SetRangeList(const ScRange &rNew)
Definition: chartpos.cxx:89
const ScRangeListRef & GetRangeList() const
Definition: chartpos.hxx:128
void CreatePositionMap()
Definition: chartpos.cxx:341
ScChartPositioner(ScDocument &rDoc, SCTAB nTab, SCCOL nStartColP, SCROW nStartRowP, SCCOL nEndColP, SCROW nEndRowP)
Definition: chartpos.cxx:45
ScRangeListRef aRangeListRef
Definition: chartpos.hxx:104
void InvalidateGlue()
Definition: chartpos.cxx:441
ScDocument & rDocument
Definition: chartpos.hxx:105
std::unique_ptr< ScChartPositionMap > pPositionMap
Definition: chartpos.hxx:106
sal_Int32 nIndex
NONE
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17