LibreOffice Module sc (master)  1
markdata.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_SC_INC_MARKDATA_HXX
21 #define INCLUDED_SC_INC_MARKDATA_HXX
22 
23 #include "address.hxx"
24 #include "rangelst.hxx"
25 #include "markmulti.hxx"
26 #include "scdllapi.h"
27 
28 #include <set>
29 #include <vector>
30 
31 namespace sc {
32 
33 struct ColRowSpan;
34 
35 }
36 
37 class ScMarkArray;
38 
42 
44 {
45 public:
46  typedef std::set<SCTAB> MarkedTabsType;
47 private:
48  MarkedTabsType maTabMarked;
49 
51  ScRange aMultiRange; // maximum area altogether
52  ScMultiSel aMultiSel; // multi selection
53  ScRangeList aTopEnvelope; // list of ranges in the top envelope of the multi selection
54  ScRangeList aBottomEnvelope; // list of ranges in the bottom envelope of the multi selection
55  ScRangeList aLeftEnvelope; // list of ranges in the left envelope of the multi selection
56  ScRangeList aRightEnvelope; // list of ranges in the right envelope of the multi selection
58  bool bMarked:1; // rectangle marked
59  bool bMultiMarked:1;
60 
61  bool bMarking:1; // area is being marked -> no MarkToMulti
62  bool bMarkIsNeg:1; // cancel if multi selection
63 
64 public:
65  ScMarkData(const ScSheetLimits& rSheetLimits);
66  ScMarkData(const ScSheetLimits& rSheetLimits, const ScRangeList& rList);
67  ScMarkData(const ScMarkData& rData) = default;
68  ScMarkData(ScMarkData&& rData) = default;
69  ScMarkData& operator=(const ScMarkData& rData);
70  ScMarkData& operator=(ScMarkData&& rData);
71  ~ScMarkData();
72 
73  void ResetMark();
74  void SetMarkArea( const ScRange& rRange );
75 
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 );
78 
79  void MarkToMulti();
80  void MarkToSimple();
81 
82  bool IsMarked() const { return bMarked; }
83  bool IsMultiMarked() const { return bMultiMarked; }
84 
85  void GetMarkArea( ScRange& rRange ) const;
86  void GetMultiMarkArea( ScRange& rRange ) const;
87 
88  void SetAreaTab( SCTAB nTab );
89 
90  void SelectTable( SCTAB nTab, bool bNew );
91  bool GetTableSelect( SCTAB nTab ) const;
92 
93  void SelectOneTable( SCTAB nTab );
94  SCTAB GetSelectCount() const;
95  SCTAB GetFirstSelected() const;
96  SCTAB GetLastSelected() const;
97 
98  const MarkedTabsType& GetSelectedTabs() const { return maTabMarked;}
99  void SetSelectedTabs(const MarkedTabsType& rTabs);
100 
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; }
105 
106  // for FillInfo / Document etc.
107  const ScMultiSel& GetMultiSelData() const { return aMultiSel; }
108  ScMarkArray GetMarkArray( SCCOL nCol ) const;
109 
110  bool IsCellMarked( SCCOL nCol, SCROW nRow, bool bNoSimple = false ) const;
111 
117  void FillRangeListWithMarks( ScRangeList* pList, bool bClear, SCTAB nForTab = -1 ) const;
118  void ExtendRangeListTables( ScRangeList* pList ) const;
119 
120  ScRangeList GetMarkedRanges() const;
125  ScRangeList GetMarkedRangesForTab( SCTAB nTab ) const;
126 
127  void MarkFromRangeList( const ScRangeList& rList, bool bReset );
128 
129  std::vector<sc::ColRowSpan> GetMarkedRowSpans() const;
130  std::vector<sc::ColRowSpan> GetMarkedColSpans() const;
131 
132  bool IsColumnMarked( SCCOL nCol ) const;
133  bool IsRowMarked( SCROW nRow ) const;
134  bool IsAllMarked( const ScRange& rRange ) const; // Multi
135 
137  SCROW GetNextMarked( SCCOL nCol, SCROW nRow, bool bUp ) const;
138  bool HasMultiMarks( SCCOL nCol ) const;
139  bool HasAnyMultiMarks() const;
140 
141  // adjust table marking:
142  void InsertTab( SCTAB nTab );
143  void DeleteTab( SCTAB nTab );
144 
145  void ShiftCols(const ScDocument* pDoc, SCCOL nStartCol, long nColOffset);
146  void ShiftRows(const ScDocument* pDoc, SCROW nStartRow, long nRowOffset);
147 
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; }
156 
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;
166 };
167 
168 #endif
169 
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
ScMultiSel aMultiSel
Definition: markdata.hxx:52
const ScSheetLimits & mrSheetLimits
Definition: markdata.hxx:57
ScRange aMultiRange
Definition: markdata.hxx:51
const MarkedTabsType & GetSelectedTabs() const
Definition: markdata.hxx:98
enumrange< T >::Iterator begin(enumrange< T >)
This is a rather odd datastructure.
Definition: markarr.hxx:43
bool IsMultiMarked() const
Definition: markdata.hxx:83
ScRange aMarkRange
Definition: markdata.hxx:50
bool IsMarked() const
Definition: markdata.hxx:82
sal_Int16 SCCOL
Definition: types.hxx:22
const ScRangeList & GetBottomEnvelope() const
Definition: markdata.hxx:153
ScRangeList aTopEnvelope
Definition: markdata.hxx:53
std::set< SCTAB >::iterator iterator
Definition: markdata.hxx:158
ScRangeList aLeftEnvelope
Definition: markdata.hxx:55
std::set< SCTAB >::const_iterator const_iterator
Definition: markdata.hxx:159
bool IsMarkNegative() const
Definition: markdata.hxx:102
enumrange< T >::Iterator end(enumrange< T >)
sal_Int32 SCROW
Definition: types.hxx:18
ScRangeList aBottomEnvelope
Definition: markdata.hxx:54
const ScRangeList & GetTopEnvelope() const
Definition: markdata.hxx:152
MarkedTabsType maTabMarked
Definition: markdata.hxx:48
bool GetMarkingFlag() const
Definition: markdata.hxx:104
std::set< SCTAB >::const_reverse_iterator const_reverse_iterator
Definition: markdata.hxx:160
void SetMarking(bool bFlag)
Definition: markdata.hxx:103
void SetMarkNegative(bool bFlag)
Definition: markdata.hxx:101
const ScRangeList & GetLeftEnvelope() const
Definition: markdata.hxx:154
const ScMultiSel & GetMultiSelData() const
Definition: markdata.hxx:107
ScRangeList aRightEnvelope
Definition: markdata.hxx:56
std::set< SCTAB > MarkedTabsType
Definition: markdata.hxx:46
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
const ScRangeList & GetRightEnvelope() const
Definition: markdata.hxx:155
sal_Int16 SCTAB
Definition: types.hxx:23