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