Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / markdata.hxx
blob26387109b833485263a6a9825b0c74c1542d49aa
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_MARKDATA_HXX
21 #define INCLUDED_SC_INC_MARKDATA_HXX
23 #include "address.hxx"
24 #include "rangelst.hxx"
25 #include "markmulti.hxx"
26 #include "scdllapi.h"
28 #include <set>
29 #include <vector>
31 namespace sc {
33 struct RowSpan;
34 struct ColRowSpan;
38 class ScMarkArray;
39 class ScRangeList;
41 //! todo:
42 //! It should be possible to have MarkArrays for each table, in order to
43 //! enable "search all" across more than one table again!
45 class SC_DLLPUBLIC ScMarkData
47 public:
48 typedef std::set<SCTAB> MarkedTabsType;
49 private:
50 MarkedTabsType maTabMarked;
52 ScRange aMarkRange; // area
53 ScRange aMultiRange; // maximum area altogether
54 ScMultiSel aMultiSel; // multi selection
55 bool bMarked:1; // rectangle marked
56 bool bMultiMarked:1;
58 bool bMarking:1; // area is being marked -> no MarkToMulti
59 bool bMarkIsNeg:1; // cancel if multi selection
60 ScRangeList aTopEnvelope; // list of ranges in the top envelope of the multi selection
61 ScRangeList aBottomEnvelope; // list of ranges in the bottom envelope of the multi selection
62 ScRangeList aLeftEnvelope; // list of ranges in the left envelope of the multi selection
63 ScRangeList aRightEnvelope; // list of ranges in the right envelope of the multi selection
66 public:
67 ScMarkData();
68 ScMarkData(const ScMarkData& rData);
69 ~ScMarkData();
71 ScMarkData& operator=(const ScMarkData& rData);
73 void ResetMark();
74 void SetMarkArea( const ScRange& rRange );
76 // bSetupMulti must be set to true only for recursive calls to SetMultiMarkArea
77 void SetMultiMarkArea( const ScRange& rRange, bool bMark = true, bool bSetupMulti = false );
79 void MarkToMulti();
80 void MarkToSimple();
82 bool IsMarked() const { return bMarked; }
83 bool IsMultiMarked() const { return bMultiMarked; }
85 void GetMarkArea( ScRange& rRange ) const;
86 void GetMultiMarkArea( ScRange& rRange ) const;
88 void SetAreaTab( SCTAB nTab );
90 void SelectTable( SCTAB nTab, bool bNew );
91 bool GetTableSelect( SCTAB nTab ) const;
93 void SelectOneTable( SCTAB nTab );
94 SCTAB GetSelectCount() const;
95 SCTAB GetFirstSelected() const;
96 SCTAB GetLastSelected() const;
98 const MarkedTabsType& GetSelectedTabs() const { return maTabMarked;}
99 void SetSelectedTabs(const MarkedTabsType& rTabs);
101 void SetMarkNegative( bool bFlag ) { bMarkIsNeg = bFlag; }
102 bool IsMarkNegative() const { return bMarkIsNeg; }
103 void SetMarking( bool bFlag ) { bMarking = bFlag; }
104 bool GetMarkingFlag() const { return bMarking; }
106 // for FillInfo / Document etc.
107 const ScMultiSel& GetMultiSelData() const { return aMultiSel; }
108 ScMarkArray GetMarkArray( SCCOL nCol ) const;
110 bool IsCellMarked( SCCOL nCol, SCROW nRow, bool bNoSimple = false ) const;
112 /** Create a range list of marks.
113 @param nForTab
114 If -1, use start-sheet-tab of the multi-area in ranges.
115 If >= 0, use given sheet-tab in ranges.
117 void FillRangeListWithMarks( ScRangeList* pList, bool bClear, SCTAB nForTab = -1 ) const;
118 void ExtendRangeListTables( ScRangeList* pList ) const;
120 ScRangeList GetMarkedRanges() const;
121 /** Get marked ranges with sheet-tab set to nTab.
122 Marks are stored for the currently active sheet respectively the
123 multi-area start-sheet-tab, update ranges with the sheet for which this
124 is called. */
125 ScRangeList GetMarkedRangesForTab( SCTAB nTab ) const;
127 void MarkFromRangeList( const ScRangeList& rList, bool bReset );
129 std::vector<sc::ColRowSpan> GetMarkedRowSpans() const;
130 std::vector<sc::ColRowSpan> GetMarkedColSpans() const;
132 bool IsColumnMarked( SCCOL nCol ) const;
133 bool IsRowMarked( SCROW nRow ) const;
134 bool IsAllMarked( const ScRange& rRange ) const; // Multi
136 /// May return -1
137 SCROW GetNextMarked( SCCOL nCol, SCROW nRow, bool bUp ) const;
138 bool HasMultiMarks( SCCOL nCol ) const;
139 bool HasAnyMultiMarks() const;
141 // adjust table marking:
142 void InsertTab( SCTAB nTab );
143 void DeleteTab( SCTAB nTab );
145 void ShiftCols(SCCOL nStartCol, long nColOffset);
146 void ShiftRows(SCROW nStartRow, long nRowOffset);
148 // Generate envelopes if multimarked and fills the passed ScRange object with
149 // the smallest range that includes the marked area plus its envelopes.
150 void GetSelectionCover( ScRange& rRange );
151 // Get top, bottom, left and right envelopes
152 const ScRangeList& GetTopEnvelope() const { return aTopEnvelope; }
153 const ScRangeList& GetBottomEnvelope() const { return aBottomEnvelope; }
154 const ScRangeList& GetLeftEnvelope() const { return aLeftEnvelope; }
155 const ScRangeList& GetRightEnvelope() const { return aRightEnvelope; }
157 // iterators for table access
158 typedef std::set<SCTAB>::iterator iterator;
159 typedef std::set<SCTAB>::const_iterator const_iterator;
160 typedef std::set<SCTAB>::const_reverse_iterator const_reverse_iterator;
161 iterator begin();
162 iterator end();
163 const_iterator begin() const;
164 const_iterator end() const;
165 const_reverse_iterator rbegin() const;
168 #endif
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */