tdf#48459 sw inline heading: don't apply inside frames or over 120 chars
[LibreOffice.git] / sc / inc / chartpos.hxx
blob9ab8ec500ece34afe95e9b5ae117afc9d57d93a8
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 "rangelst.hxx"
23 #include <memory>
24 #include <map>
26 // map of row number to ScAddress*
27 typedef std::map<SCROW, std::unique_ptr<ScAddress>> RowMap;
28 // map of column number to RowMap
29 typedef std::map<SCCOL, RowMap> ColumnMap;
31 class ScChartPositionMap
33 friend class ScChartPositioner;
35 std::unique_ptr<std::unique_ptr<ScAddress>[]> ppData;
36 std::unique_ptr<std::unique_ptr<ScAddress>[]> ppColHeader;
37 std::unique_ptr<std::unique_ptr<ScAddress>[]> ppRowHeader;
38 sal_uInt64 nCount;
39 SCCOL nColCount;
40 SCROW nRowCount;
42 ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows,
43 SCCOL nColAdd, // header columns
44 SCROW nRowAdd, // header rows
45 ColumnMap& rCols // table with col tables with address*
48 ScChartPositionMap( const ScChartPositionMap& ) = delete;
49 ScChartPositionMap& operator=( const ScChartPositionMap& ) = delete;
51 public:
52 ~ScChartPositionMap(); //! deletes all ScAddress*
54 SCCOL GetColCount() const { return nColCount; }
55 SCROW GetRowCount() const { return nRowCount; }
57 bool IsValid( SCCOL nCol, SCROW nRow ) const
58 { return nCol < nColCount && nRow < nRowCount; }
59 // data column by column
60 sal_uInt64 GetIndex( SCCOL nCol, SCROW nRow ) const
61 { return static_cast<sal_uInt64>(nCol) * nRowCount + nRow; }
63 const ScAddress* GetPosition( sal_uInt64 nIndex ) const
65 if ( nIndex < nCount )
66 return ppData[ nIndex ].get();
67 return nullptr;
70 //! might be NULL indicating "no value"
71 const ScAddress* GetPosition( SCCOL nChartCol, SCROW nChartRow ) const
73 if ( IsValid( nChartCol, nChartRow ) )
74 return ppData[ GetIndex( nChartCol, nChartRow ) ].get();
75 return nullptr;
77 const ScAddress* GetColHeaderPosition( SCCOL nChartCol ) const
79 if ( nChartCol < nColCount )
80 return ppColHeader[ nChartCol ].get();
81 return nullptr;
83 const ScAddress* GetRowHeaderPosition( SCROW nChartRow ) const
85 if ( nChartRow < nRowCount )
86 return ppRowHeader[ nChartRow ].get();
87 return nullptr;
91 enum class ScChartGlue {
92 NA,
93 NONE, // old mimic
94 Cols, // old mimic
95 Rows,
96 Both
99 class ScDocument;
101 class ScChartPositioner final // only parameter struct
103 ScRangeListRef aRangeListRef;
104 ScDocument& rDocument;
105 std::unique_ptr<ScChartPositionMap> pPositionMap;
106 ScChartGlue eGlue;
107 SCCOL nStartCol;
108 SCROW nStartRow;
109 bool bColHeaders;
110 bool bRowHeaders;
111 bool bDummyUpperLeft;
113 void CheckColRowHeaders();
115 void GlueState(); // summarised areas
116 void CreatePositionMap();
118 public:
119 ScChartPositioner( ScDocument& rDoc, SCTAB nTab,
120 SCCOL nStartColP, SCROW nStartRowP,
121 SCCOL nEndColP, SCROW nEndRowP );
122 ScChartPositioner( ScDocument& rDoc, ScRangeListRef xRangeList );
123 ScChartPositioner( const ScChartPositioner& rPositioner );
125 ~ScChartPositioner();
127 const ScRangeListRef& GetRangeList() const { return aRangeListRef; }
128 void SetRangeList( const ScRange& rNew );
130 void SetHeaders(bool bCol, bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; }
131 bool HasColHeaders() const { return bColHeaders; }
132 bool HasRowHeaders() const { return bRowHeaders; }
134 void InvalidateGlue();
135 const ScChartPositionMap* GetPositionMap();
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */