Line data Source code
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 SC_MARKDATA_HXX
21 : #define SC_MARKDATA_HXX
22 :
23 : #include "address.hxx"
24 : #include "scdllapi.h"
25 :
26 : #include <set>
27 :
28 : namespace sc {
29 :
30 : struct RowSpan;
31 : struct ColRowSpan;
32 :
33 : }
34 :
35 : class ScMarkArray;
36 : class ScRangeList;
37 :
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!
41 :
42 :
43 : class SC_DLLPUBLIC ScMarkData
44 : {
45 : public:
46 : typedef std::set<SCTAB> MarkedTabsType;
47 : private:
48 : MarkedTabsType maTabMarked;
49 :
50 : ScRange aMarkRange; // area
51 : ScRange aMultiRange; // maximum area altogether
52 : ScMarkArray* pMultiSel; // multi selection
53 : bool bMarked:1; // rectangle marked
54 : bool bMultiMarked:1;
55 :
56 : bool bMarking:1; // area is being marked -> no MarkToMulti
57 : bool bMarkIsNeg:1; // cancel if multi selection
58 :
59 : public:
60 : ScMarkData();
61 : ScMarkData(const ScMarkData& rData);
62 : ~ScMarkData();
63 :
64 : ScMarkData& operator=(const ScMarkData& rData);
65 :
66 : void ResetMark();
67 : void SetMarkArea( const ScRange& rRange );
68 :
69 : void SetMultiMarkArea( const ScRange& rRange, bool bMark = true );
70 :
71 : void MarkToMulti();
72 : void MarkToSimple();
73 :
74 0 : bool IsMarked() const { return bMarked; }
75 0 : bool IsMultiMarked() const { return bMultiMarked; }
76 :
77 : void GetMarkArea( ScRange& rRange ) const;
78 : void GetMultiMarkArea( ScRange& rRange ) const;
79 :
80 : void SetAreaTab( SCTAB nTab );
81 :
82 : void SelectTable( SCTAB nTab, bool bNew );
83 : bool GetTableSelect( SCTAB nTab ) const;
84 :
85 : void SelectOneTable( SCTAB nTab );
86 : SCTAB GetSelectCount() const;
87 : SCTAB GetFirstSelected() const;
88 : SCTAB GetLastSelected() const;
89 :
90 : const MarkedTabsType& GetSelectedTabs() const;
91 : void SetSelectedTabs(const MarkedTabsType& rTabs);
92 :
93 0 : void SetMarkNegative( bool bFlag ) { bMarkIsNeg = bFlag; }
94 0 : bool IsMarkNegative() const { return bMarkIsNeg; }
95 0 : void SetMarking( bool bFlag ) { bMarking = bFlag; }
96 0 : bool GetMarkingFlag() const { return bMarking; }
97 :
98 : // for FillInfo / Document etc.
99 0 : const ScMarkArray* GetArray() const { return pMultiSel; }
100 :
101 : bool IsCellMarked( SCCOL nCol, SCROW nRow, bool bNoSimple = false ) const;
102 : void FillRangeListWithMarks( ScRangeList* pList, bool bClear ) const;
103 : void ExtendRangeListTables( ScRangeList* pList ) const;
104 :
105 : ScRangeList GetMarkedRanges() const;
106 :
107 : void MarkFromRangeList( const ScRangeList& rList, bool bReset );
108 :
109 : std::vector<sc::ColRowSpan> GetMarkedRowSpans() const;
110 : std::vector<sc::ColRowSpan> GetMarkedColSpans() const;
111 :
112 : bool IsColumnMarked( SCCOL nCol ) const;
113 : bool IsRowMarked( SCROW nRow ) const;
114 : bool IsAllMarked( const ScRange& rRange ) const; // Multi
115 :
116 : /// May return -1
117 : SCsROW GetNextMarked( SCCOL nCol, SCsROW nRow, bool bUp ) const;
118 : bool HasMultiMarks( SCCOL nCol ) const;
119 : bool HasAnyMultiMarks() const;
120 :
121 : // adjust table marking:
122 : void InsertTab( SCTAB nTab );
123 : void DeleteTab( SCTAB nTab );
124 :
125 : // iterators for table access
126 : typedef std::set<SCTAB>::iterator iterator;
127 : typedef std::set<SCTAB>::const_iterator const_iterator;
128 : iterator begin();
129 : iterator end();
130 : const_iterator begin() const;
131 : const_iterator end() const;
132 : };
133 :
134 : #endif
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|