sw lok: assign a parent window to property dialog
[LibreOffice.git] / sc / inc / chartpos.hxx
blobdb699ef2e062fce786129b13ad7fd4f026479145
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 #ifndef INCLUDED_SC_INC_CHARTPOS_HXX
21 #define INCLUDED_SC_INC_CHARTPOS_HXX
23 #include "rangelst.hxx"
24 #include <memory>
25 #include <map>
27 class ScAddress;
29 // map of row number to ScAddress*
30 typedef std::map<sal_uLong, ScAddress*> RowMap;
31 // map of column number to RowMap*
32 typedef std::map<sal_uLong, RowMap*> ColumnMap;
34 class ScChartPositionMap
36 friend class ScChartPositioner;
38 std::unique_ptr<ScAddress*[]> ppData;
39 std::unique_ptr<ScAddress*[]> ppColHeader;
40 std::unique_ptr<ScAddress*[]> ppRowHeader;
41 sal_uLong nCount;
42 SCCOL nColCount;
43 SCROW nRowCount;
45 ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows,
46 SCCOL nColAdd, // header columns
47 SCROW nRowAdd, // header rows
48 ColumnMap& rCols // table with col tables with address*
51 ScChartPositionMap( const ScChartPositionMap& ) = delete;
52 ScChartPositionMap& operator=( const ScChartPositionMap& ) = delete;
54 public:
55 ~ScChartPositionMap(); //! deletes all ScAddress*
57 SCCOL GetColCount() const { return nColCount; }
58 SCROW GetRowCount() const { return nRowCount; }
60 bool IsValid( SCCOL nCol, SCROW nRow ) const
61 { return nCol < nColCount && nRow < nRowCount; }
62 // data column by column
63 sal_uLong GetIndex( SCCOL nCol, SCROW nRow ) const
64 { return static_cast<sal_uLong>(nCol) * nRowCount + nRow; }
66 const ScAddress* GetPosition( sal_uLong nIndex ) const
68 if ( nIndex < nCount )
69 return ppData[ nIndex ];
70 return nullptr;
73 //! might be NULL indicating "no value"
74 const ScAddress* GetPosition( SCCOL nChartCol, SCROW nChartRow ) const
76 if ( IsValid( nChartCol, nChartRow ) )
77 return ppData[ GetIndex( nChartCol, nChartRow ) ];
78 return nullptr;
80 const ScAddress* GetColHeaderPosition( SCCOL nChartCol ) const
82 if ( nChartCol < nColCount )
83 return ppColHeader[ nChartCol ];
84 return nullptr;
86 const ScAddress* GetRowHeaderPosition( SCROW nChartRow ) const
88 if ( nChartRow < nRowCount )
89 return ppRowHeader[ nChartRow ];
90 return nullptr;
94 enum class ScChartGlue {
95 NA,
96 NONE, // old mimic
97 Cols, // old mimic
98 Rows,
99 Both
102 class ScDocument;
104 class ScChartPositioner final // only parameter struct
106 ScRangeListRef aRangeListRef;
107 ScDocument* pDocument;
108 std::unique_ptr<ScChartPositionMap> pPositionMap;
109 ScChartGlue eGlue;
110 SCCOL nStartCol;
111 SCROW nStartRow;
112 bool bColHeaders;
113 bool bRowHeaders;
114 bool bDummyUpperLeft;
116 void CheckColRowHeaders();
118 void GlueState(); // summarised areas
119 void CreatePositionMap();
121 public:
122 ScChartPositioner( ScDocument* pDoc, SCTAB nTab,
123 SCCOL nStartColP, SCROW nStartRowP,
124 SCCOL nEndColP, SCROW nEndRowP );
125 ScChartPositioner( ScDocument* pDoc, const ScRangeListRef& rRangeList );
126 ScChartPositioner( const ScChartPositioner& rPositioner );
128 ~ScChartPositioner();
130 const ScRangeListRef& GetRangeList() const { return aRangeListRef; }
131 void SetRangeList( const ScRange& rNew );
133 void SetHeaders(bool bCol, bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; }
134 bool HasColHeaders() const { return bColHeaders; }
135 bool HasRowHeaders() const { return bRowHeaders; }
137 void InvalidateGlue();
138 const ScChartPositionMap* GetPositionMap();
141 #endif
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */