LibreOffice Module sc (master)  1
markarr.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_MARKARR_HXX
21 #define INCLUDED_SC_INC_MARKARR_HXX
22 
23 #include "address.hxx"
24 #include <tools/long.hxx>
25 #include <vector>
26 
27 class ScRangeList;
28 struct ScSheetLimits;
29 
31 {
32  SCROW nRow : 30; // 30 because 31 causes compiler problems with VisualStudio
33  bool bMarked : 1;
34 
35  bool operator==(const ScMarkEntry& rOther) const
36  { return nRow == rOther.nRow && bMarked == rOther.bMarked; }
37 };
38 
45 {
47  std::vector<ScMarkEntry> mvData;
48 
49 friend class ScMarkArrayIter;
50 friend class ScDocument; // for FillInfo
51 
52 public:
53  ScMarkArray( const ScSheetLimits& rLimits );
54  ScMarkArray( ScMarkArray&& rArray ) noexcept;
55  ScMarkArray( const ScMarkArray& rArray );
56  ~ScMarkArray();
57  void Reset( bool bMarked = false, SCSIZE nNeeded = 1 );
58  bool GetMark( SCROW nRow ) const;
59  void SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked );
60  void Set( std::vector<ScMarkEntry> const & );
61  bool IsAllMarked( SCROW nStartRow, SCROW nEndRow ) const;
62  bool HasOneMark( SCROW& rStartRow, SCROW& rEndRow ) const;
63 
64  bool HasMarks() const { return mvData.size() > 1 || ( mvData.size() == 1 && mvData[0].bMarked ); }
65 
66  ScMarkArray& operator=( ScMarkArray const & rSource );
67  ScMarkArray& operator=(ScMarkArray&& rSource) noexcept;
68  bool operator==(ScMarkArray const & rOther ) const;
69 
70  bool Search( SCROW nRow, SCSIZE& nIndex ) const;
71 
73  SCROW GetNextMarked( SCROW nRow, bool bUp ) const;
74  SCROW GetMarkEnd( SCROW nRow, bool bUp ) const;
75 
76  void Shift( SCROW nStartRow, tools::Long nOffset );
77  void Intersect( const ScMarkArray& rOther );
78 };
79 
80 class SC_DLLPUBLIC ScMarkArrayIter // iterate over selected range
81 {
84 public:
85  ScMarkArrayIter( const ScMarkArray* pNewArray );
86  ~ScMarkArrayIter();
87 
88  bool Next( SCROW& rTop, SCROW& rBottom );
89  void reset( const ScMarkArray* pNewArray );
90 };
91 
92 #endif
93 
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< ScMarkEntry > mvData
Definition: markarr.hxx:47
long Long
SCROW nRow
Definition: markarr.hxx:32
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:45
This is a rather odd datastructure.
Definition: markarr.hxx:44
bool bMarked
Definition: markarr.hxx:33
bool operator==(const ScMarkEntry &rOther) const
Definition: markarr.hxx:35
const ScMarkArray * pArray
Definition: markarr.hxx:82
sal_Int32 SCROW
Definition: types.hxx:18
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
const ScSheetLimits & mrSheetLimits
Definition: markarr.hxx:46