/src/libreoffice/sc/inc/markdata.hxx
Line | Count | Source |
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 "address.hxx" |
23 | | #include "rangelst.hxx" |
24 | | #include "markmulti.hxx" |
25 | | #include "scdllapi.h" |
26 | | |
27 | | #include <set> |
28 | | #include <vector> |
29 | | |
30 | | namespace sc { |
31 | | |
32 | | struct ColRowSpan; |
33 | | |
34 | | } |
35 | | |
36 | | //! todo: |
37 | | //! It should be possible to have MarkArrays for each table, in order to |
38 | | //! enable "search all" across more than one table again! |
39 | | |
40 | | class ScMarkData |
41 | | { |
42 | | public: |
43 | | typedef std::set<SCTAB> MarkedTabsType; |
44 | | private: |
45 | | MarkedTabsType maTabMarked; |
46 | | |
47 | | ScRange aMarkRange; // area |
48 | | ScRange aMultiRange; // maximum area altogether |
49 | | ScMultiSel aMultiSel; // multi selection |
50 | | ScRangeList aTopEnvelope; // list of ranges in the top envelope of the multi selection |
51 | | ScRangeList aBottomEnvelope; // list of ranges in the bottom envelope of the multi selection |
52 | | ScRangeList aLeftEnvelope; // list of ranges in the left envelope of the multi selection |
53 | | ScRangeList aRightEnvelope; // list of ranges in the right envelope of the multi selection |
54 | | const ScSheetLimits& mrSheetLimits; |
55 | | bool bMarked:1; // rectangle marked |
56 | | bool bMultiMarked:1; |
57 | | |
58 | | bool bMarking:1; // area is being marked -> no MarkToMulti |
59 | | bool bMarkIsNeg:1; // cancel if multi selection |
60 | | |
61 | | public: |
62 | | SC_DLLPUBLIC ScMarkData(const ScSheetLimits& rSheetLimits); |
63 | | ScMarkData(const ScSheetLimits& rSheetLimits, const ScRangeList& rList); |
64 | 27.9k | ScMarkData(const ScMarkData& rData) = default; |
65 | 0 | ScMarkData(ScMarkData&& rData) = default; |
66 | | ScMarkData& operator=(const ScMarkData& rData); |
67 | | ScMarkData& operator=(ScMarkData&& rData); |
68 | | |
69 | | SC_DLLPUBLIC void ResetMark(); |
70 | | SC_DLLPUBLIC void SetMarkArea( const ScRange& rRange ); |
71 | | |
72 | | // bSetupMulti must be set to true only for recursive calls to SetMultiMarkArea |
73 | | SC_DLLPUBLIC void SetMultiMarkArea( const ScRange& rRange, bool bMark = true, bool bSetupMulti = false ); |
74 | | |
75 | | SC_DLLPUBLIC void MarkToMulti(); |
76 | | SC_DLLPUBLIC void MarkToSimple(); |
77 | | |
78 | 5.29k | bool IsMarked() const { return bMarked; } |
79 | 116k | bool IsMultiMarked() const { return bMultiMarked; } |
80 | | |
81 | 6.55k | const ScRange& GetMarkArea() const { return aMarkRange; } |
82 | 588 | const ScRange& GetMultiMarkArea() const { return aMultiRange; } |
83 | 704 | const ScRange& GetArea() const { return bMultiMarked ? aMultiRange : aMarkRange; } |
84 | | |
85 | | void SetAreaTab( SCTAB nTab ); |
86 | | |
87 | | SC_DLLPUBLIC void SelectTable( SCTAB nTab, bool bNew ); |
88 | | bool GetTableSelect( SCTAB nTab ) const; |
89 | | |
90 | | SC_DLLPUBLIC void SelectOneTable( SCTAB nTab ); |
91 | | SC_DLLPUBLIC SCTAB GetSelectCount() const; |
92 | | SC_DLLPUBLIC SCTAB GetFirstSelected() const; |
93 | | SCTAB GetLastSelected() const; |
94 | | |
95 | 0 | const MarkedTabsType& GetSelectedTabs() const { return maTabMarked;} |
96 | | SC_DLLPUBLIC void SetSelectedTabs(const MarkedTabsType& rTabs); |
97 | | |
98 | 0 | void SetMarkNegative( bool bFlag ) { bMarkIsNeg = bFlag; } |
99 | 0 | bool IsMarkNegative() const { return bMarkIsNeg; } |
100 | 236 | void SetMarking( bool bFlag ) { bMarking = bFlag; } |
101 | 0 | bool GetMarkingFlag() const { return bMarking; } |
102 | | |
103 | | // for FillInfo / Document etc. |
104 | 108k | const ScMultiSel& GetMultiSelData() const { return aMultiSel; } |
105 | 0 | ScMarkArray GetMarkArray( SCCOL nCol ) const { return aMultiSel.GetMarkArray( nCol ); } |
106 | | |
107 | | SC_DLLPUBLIC bool IsCellMarked( SCCOL nCol, SCROW nRow, bool bNoSimple = false ) const; |
108 | | |
109 | | /** Create a range list of marks. |
110 | | @param nForTab |
111 | | If -1, use start-sheet-tab of the multi-area in ranges. |
112 | | If >= 0, use given sheet-tab in ranges. |
113 | | */ |
114 | | void FillRangeListWithMarks( ScRangeList* pList, bool bClear, SCTAB nForTab = -1 ) const; |
115 | | void ExtendRangeListTables( ScRangeList* pList ) const; |
116 | | |
117 | | SC_DLLPUBLIC ScRangeList GetMarkedRanges() const; |
118 | | /** Get marked ranges with sheet-tab set to nTab. |
119 | | Marks are stored for the currently active sheet respectively the |
120 | | multi-area start-sheet-tab, update ranges with the sheet for which this |
121 | | is called. */ |
122 | | ScRangeList GetMarkedRangesForTab( SCTAB nTab ) const; |
123 | | |
124 | | void MarkFromRangeList( const ScRangeList& rList, bool bReset ); |
125 | | |
126 | | std::vector<sc::ColRowSpan> GetMarkedRowSpans() const; |
127 | | std::vector<sc::ColRowSpan> GetMarkedColSpans() const; |
128 | | |
129 | | SC_DLLPUBLIC bool IsColumnMarked( SCCOL nCol ) const; |
130 | | SC_DLLPUBLIC bool IsRowMarked( SCROW nRow ) const; |
131 | | SC_DLLPUBLIC bool IsAllMarked( const ScRange& rRange ) const; // Multi |
132 | | |
133 | | // Returns the first column of the range [column,nLastCol] for which |
134 | | // all those columns have equal marks. Value returned is not less than nMinCol. |
135 | | SCCOL GetStartOfEqualColumns( SCCOL nLastCol, SCCOL nMinCol = 0 ) const; |
136 | | |
137 | | /// May return -1 |
138 | | SC_DLLPUBLIC SCROW GetNextMarked( SCCOL nCol, SCROW nRow, bool bUp ) const; |
139 | | SC_DLLPUBLIC bool HasMultiMarks( SCCOL nCol ) const; |
140 | | bool HasAnyMultiMarks() const; |
141 | | |
142 | | // adjust table marking: |
143 | | SC_DLLPUBLIC void InsertTab( SCTAB nTab ); |
144 | | SC_DLLPUBLIC void DeleteTab( SCTAB nTab ); |
145 | | |
146 | | void ShiftCols(const ScDocument& rDoc, SCCOL nStartCol, sal_Int32 nColOffset); |
147 | | void ShiftRows(const ScDocument& rDoc, SCROW nStartRow, sal_Int32 nRowOffset); |
148 | | |
149 | | // Generate envelopes if multimarked and fills the passed ScRange object with |
150 | | // the smallest range that includes the marked area plus its envelopes. |
151 | | SC_DLLPUBLIC void GetSelectionCover( ScRange& rRange ); |
152 | | // Get top, bottom, left and right envelopes |
153 | 0 | const ScRangeList& GetTopEnvelope() const { return aTopEnvelope; } |
154 | 0 | const ScRangeList& GetBottomEnvelope() const { return aBottomEnvelope; } |
155 | 0 | const ScRangeList& GetLeftEnvelope() const { return aLeftEnvelope; } |
156 | 0 | const ScRangeList& GetRightEnvelope() const { return aRightEnvelope; } |
157 | | |
158 | | // iterators for table access |
159 | | typedef std::set<SCTAB>::const_iterator const_iterator; |
160 | | typedef std::set<SCTAB>::const_reverse_iterator const_reverse_iterator; |
161 | 186k | const_iterator begin() const { return maTabMarked.begin(); } |
162 | 126k | const_iterator end() const { return maTabMarked.end(); } |
163 | 0 | const_reverse_iterator rbegin() const { return maTabMarked.rbegin(); } |
164 | | }; |
165 | | |
166 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |