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#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
30namespace sc {
31
32struct ColRowSpan;
33
34}
35
36class ScMarkArray;
37
41
43{
44public:
45 typedef std::set<SCTAB> MarkedTabsType;
46private:
48
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
57 bool bMarked:1; // rectangle marked
59
60 bool bMarking:1; // area is being marked -> no MarkToMulti
61 bool bMarkIsNeg:1; // cancel if multi selection
62
63public:
64 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);
70
71 void ResetMark();
72 void SetMarkArea( const ScRange& rRange );
73
74 // bSetupMulti must be set to true only for recursive calls to SetMultiMarkArea
75 void SetMultiMarkArea( const ScRange& rRange, bool bMark = true, bool bSetupMulti = false );
76
77 void MarkToMulti();
78 void MarkToSimple();
79
80 bool IsMarked() const { return bMarked; }
81 bool IsMultiMarked() const { return bMultiMarked; }
82
83 const ScRange& GetMarkArea() const { return aMarkRange; }
84 const ScRange& GetMultiMarkArea() const { return aMultiRange; }
85 const ScRange& GetArea() const { return bMultiMarked ? aMultiRange : aMarkRange; }
86
87 void SetAreaTab( SCTAB nTab );
88
89 void SelectTable( SCTAB nTab, bool bNew );
90 bool GetTableSelect( SCTAB nTab ) const;
91
92 void SelectOneTable( SCTAB nTab );
93 SCTAB GetSelectCount() const;
94 SCTAB GetFirstSelected() const;
95 SCTAB GetLastSelected() const;
96
97 const MarkedTabsType& GetSelectedTabs() const { return maTabMarked;}
98 void SetSelectedTabs(const MarkedTabsType& rTabs);
99
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; }
104
105 // for FillInfo / Document etc.
106 const ScMultiSel& GetMultiSelData() const { return aMultiSel; }
107 ScMarkArray GetMarkArray( SCCOL nCol ) const { return aMultiSel.GetMarkArray( nCol ); }
108
109 bool IsCellMarked( SCCOL nCol, SCROW nRow, bool bNoSimple = false ) const;
110
116 void FillRangeListWithMarks( ScRangeList* pList, bool bClear, SCTAB nForTab = -1 ) const;
117 void ExtendRangeListTables( ScRangeList* pList ) const;
118
119 ScRangeList GetMarkedRanges() const;
124 ScRangeList GetMarkedRangesForTab( SCTAB nTab ) const;
125
126 void MarkFromRangeList( const ScRangeList& rList, bool bReset );
127
128 std::vector<sc::ColRowSpan> GetMarkedRowSpans() const;
129 std::vector<sc::ColRowSpan> GetMarkedColSpans() const;
130
131 bool IsColumnMarked( SCCOL nCol ) const;
132 bool IsRowMarked( SCROW nRow ) const;
133 bool IsAllMarked( const ScRange& rRange ) const; // Multi
134
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;
138
140 SCROW GetNextMarked( SCCOL nCol, SCROW nRow, bool bUp ) const;
141 bool HasMultiMarks( SCCOL nCol ) const;
142 bool HasAnyMultiMarks() const;
143
144 // adjust table marking:
145 void InsertTab( SCTAB nTab );
146 void DeleteTab( SCTAB nTab );
147
148 void ShiftCols(const ScDocument& rDoc, SCCOL nStartCol, sal_Int32 nColOffset);
149 void ShiftRows(const ScDocument& rDoc, SCROW nStartRow, sal_Int32 nRowOffset);
150
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 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; }
159
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(); }
166};
167
168/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This is a rather odd datastructure.
Definition: markarr.hxx:44
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
bool bMarkIsNeg
Definition: markdata.hxx:61
const_iterator end() const
Definition: markdata.hxx:164
const ScSheetLimits & mrSheetLimits
Definition: markdata.hxx:56
const ScRange & GetArea() const
Definition: markdata.hxx:85
const ScRange & GetMultiMarkArea() const
Definition: markdata.hxx:84
const ScRange & GetMarkArea() const
Definition: markdata.hxx:83
bool IsMultiMarked() const
Definition: markdata.hxx:81
ScRangeList aBottomEnvelope
Definition: markdata.hxx:53
void SetMarkNegative(bool bFlag)
Definition: markdata.hxx:100
void SetMarking(bool bFlag)
Definition: markdata.hxx:102
bool IsMarkNegative() const
Definition: markdata.hxx:101
ScMarkData(const ScMarkData &rData)=default
std::set< SCTAB > MarkedTabsType
Definition: markdata.hxx:45
ScRangeList aTopEnvelope
Definition: markdata.hxx:52
ScMultiSel aMultiSel
Definition: markdata.hxx:51
MarkedTabsType maTabMarked
Definition: markdata.hxx:47
bool bMarked
Definition: markdata.hxx:57
const ScMultiSel & GetMultiSelData() const
Definition: markdata.hxx:106
const ScRangeList & GetLeftEnvelope() const
Definition: markdata.hxx:157
ScRange aMarkRange
Definition: markdata.hxx:49
std::set< SCTAB >::const_reverse_iterator const_reverse_iterator
Definition: markdata.hxx:162
ScRangeList aRightEnvelope
Definition: markdata.hxx:55
bool GetMarkingFlag() const
Definition: markdata.hxx:103
ScRange aMultiRange
Definition: markdata.hxx:50
const ScRangeList & GetBottomEnvelope() const
Definition: markdata.hxx:156
bool IsMarked() const
Definition: markdata.hxx:80
const ScRangeList & GetTopEnvelope() const
Definition: markdata.hxx:155
ScMarkArray GetMarkArray(SCCOL nCol) const
Definition: markdata.hxx:107
const ScRangeList & GetRightEnvelope() const
Definition: markdata.hxx:158
const MarkedTabsType & GetSelectedTabs() const
Definition: markdata.hxx:97
ScRangeList aLeftEnvelope
Definition: markdata.hxx:54
const_iterator begin() const
Definition: markdata.hxx:163
std::set< SCTAB >::const_iterator const_iterator
Definition: markdata.hxx:161
ScMarkData(ScMarkData &&rData)=default
const_reverse_iterator rbegin() const
Definition: markdata.hxx:165
bool bMultiMarked
Definition: markdata.hxx:58
bool bMarking
Definition: markdata.hxx:60
ScMarkArray GetMarkArray(SCCOL nCol) const
Definition: markmulti.cxx:334
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17