Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / inc / lotrange.hxx
blobee0253dbffac002a28d544b9cb09e5aff1f97199
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_SOURCE_FILTER_INC_LOTRANGE_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_LOTRANGE_HXX
23 #include <refdata.hxx>
24 #include <types.hxx>
26 struct LOTUS_ROOT;
28 typedef sal_uInt16 LR_ID;
30 #define ID_FAIL 0xFFFF
32 class LotusRange
34 friend class LotusRangeList;
35 private:
36 sal_uInt32 nHash;
37 SCCOL nColStart;
38 SCROW nRowStart;
39 SCCOL nColEnd;
40 SCROW nRowEnd;
41 LR_ID nId;
42 void MakeHash();
43 inline void Copy( const LotusRange& );
44 inline void SetId( LR_ID nId );
45 public:
46 LotusRange( SCCOL nCol, SCROW nRow );
47 LotusRange( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE );
48 LotusRange( const LotusRange& );
49 inline LotusRange &operator =( const LotusRange& );
50 inline bool operator ==( const LotusRange& ) const;
51 inline bool IsSingle() const;
54 inline void LotusRange::Copy( const LotusRange& rCpy )
56 nHash = rCpy.nHash;
57 nColStart = rCpy.nColStart;
58 nRowStart = rCpy.nRowStart;
59 nColEnd = rCpy.nColEnd;
60 nRowEnd = rCpy.nRowEnd;
61 nId = rCpy.nId;
64 inline void LotusRange::SetId( LR_ID nNewId )
66 nId = nNewId;
69 inline LotusRange &LotusRange::operator =( const LotusRange& rCpy )
71 Copy( rCpy );
72 return *this;
75 inline bool LotusRange::operator ==( const LotusRange& rRef ) const
77 return ( nHash == rRef.nHash && nColStart == rRef.nColStart &&
78 nRowStart == rRef.nRowStart && nColEnd == rRef.nColEnd &&
79 nRowEnd == rRef.nRowEnd );
82 inline bool LotusRange::IsSingle() const
84 return ( nColStart == nColEnd && nRowStart == nRowEnd );
87 class LotusRangeList
89 private:
90 LR_ID nIdCnt;
91 ScComplexRefData aComplRef;
92 std::vector<std::unique_ptr<LotusRange>> maRanges;
94 public:
95 LotusRangeList();
96 ~LotusRangeList();
97 inline LR_ID GetIndex( SCCOL nCol, SCROW nRow );
98 inline LR_ID GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE );
99 LR_ID GetIndex( const LotusRange& );
100 void Append( std::unique_ptr<LotusRange> pLR );
103 inline LR_ID LotusRangeList::GetIndex( SCCOL nCol, SCROW nRow )
105 LotusRange aRef( nCol, nRow );
106 return GetIndex( aRef );
109 inline LR_ID LotusRangeList::GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE )
111 LotusRange aRef( nColS, nRowS, nColE, nRowE );
112 return GetIndex( aRef );
115 #endif
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */