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