1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_INC_MARKARR_HXX
21 #define INCLUDED_SC_INC_MARKARR_HXX
23 #include "address.hxx"
28 #define SC_MARKARRAY_DELTA 4
37 This is a rather odd datastructure. We store alternating marked/not-marked entries,
38 and for each entry the range is defined as :
39 [previousEntry.nRow+1, currentEntry.nRow]
45 std::unique_ptr
<ScMarkEntry
[]> pData
;
48 friend class ScMarkArrayIter
;
49 friend class ScDocument
; // for FillInfo
52 ScMarkArray(SCROW nMaxRow
);
53 ScMarkArray( ScMarkArray
&& rArray
) noexcept
;
54 ScMarkArray( const ScMarkArray
& rArray
);
56 void Reset( bool bMarked
= false, SCSIZE nNeeded
= 1 );
57 bool GetMark( SCROW nRow
) const;
58 void SetMarkArea( SCROW nStartRow
, SCROW nEndRow
, bool bMarked
);
59 void Set( std::vector
<ScMarkEntry
> const & );
60 bool IsAllMarked( SCROW nStartRow
, SCROW nEndRow
) const;
61 bool HasOneMark( SCROW
& rStartRow
, SCROW
& rEndRow
) const;
63 bool HasMarks() const { return ( nCount
> 1 || ( nCount
== 1 && pData
[0].bMarked
) ); }
65 ScMarkArray
& operator=( ScMarkArray
const & rSource
);
66 ScMarkArray
& operator=(ScMarkArray
&& rSource
) noexcept
;
67 bool operator==(ScMarkArray
const & rOther
) const;
69 bool Search( SCROW nRow
, SCSIZE
& nIndex
) const;
71 /// Including current row, may return -1 if bUp and not found
72 SCROW
GetNextMarked( SCROW nRow
, bool bUp
) const;
73 SCROW
GetMarkEnd( SCROW nRow
, bool bUp
) const;
75 void Shift( SCROW nStartRow
, long nOffset
);
76 void Intersect( const ScMarkArray
& rOther
);
79 class ScMarkArrayIter
// iterate over selected range
81 const ScMarkArray
* pArray
;
84 ScMarkArrayIter( const ScMarkArray
* pNewArray
);
87 bool Next( SCROW
& rTop
, SCROW
& rBottom
);
88 void reset( const ScMarkArray
* pNewArray
);
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */