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