Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / lotrange.hxx
blobbbf98ab1fa31c98537ee36b1e67acaf51a5db054
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 #pragma once
22 #include <refdata.hxx>
23 #include <types.hxx>
25 #include <memory>
27 typedef sal_uInt16 LR_ID;
29 #define ID_FAIL 0xFFFF
31 class LotusRange
33 friend class LotusRangeList;
34 private:
35 sal_uInt32 nHash;
36 SCCOL nColStart;
37 SCROW nRowStart;
38 SCCOL nColEnd;
39 SCROW nRowEnd;
40 LR_ID nId;
41 void MakeHash();
42 inline void Copy( const LotusRange& );
43 inline void SetId( LR_ID nId );
44 public:
45 LotusRange( SCCOL nCol, SCROW nRow );
46 LotusRange( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE );
47 LotusRange( const LotusRange& );
48 inline LotusRange &operator =( const LotusRange& );
49 inline bool operator ==( const LotusRange& ) const;
50 inline bool IsSingle() const;
53 inline void LotusRange::Copy( const LotusRange& rCpy )
55 nHash = rCpy.nHash;
56 nColStart = rCpy.nColStart;
57 nRowStart = rCpy.nRowStart;
58 nColEnd = rCpy.nColEnd;
59 nRowEnd = rCpy.nRowEnd;
60 nId = rCpy.nId;
63 inline void LotusRange::SetId( LR_ID nNewId )
65 nId = nNewId;
68 inline LotusRange &LotusRange::operator =( const LotusRange& rCpy )
70 Copy( rCpy );
71 return *this;
74 inline bool LotusRange::operator ==( const LotusRange& rRef ) const
76 return ( nHash == rRef.nHash && nColStart == rRef.nColStart &&
77 nRowStart == rRef.nRowStart && nColEnd == rRef.nColEnd &&
78 nRowEnd == rRef.nRowEnd );
81 inline bool LotusRange::IsSingle() const
83 return ( nColStart == nColEnd && nRowStart == nRowEnd );
86 class LotusRangeList
88 private:
89 LR_ID nIdCnt;
90 ScComplexRefData aComplRef;
91 std::vector<std::unique_ptr<LotusRange>> maRanges;
93 public:
94 LotusRangeList();
95 ~LotusRangeList();
96 inline LR_ID GetIndex( SCCOL nCol, SCROW nRow );
97 inline LR_ID GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE );
98 LR_ID GetIndex( const LotusRange& );
99 void Append( const ScDocument* pDoc, std::unique_ptr<LotusRange> pLR );
102 inline LR_ID LotusRangeList::GetIndex( SCCOL nCol, SCROW nRow )
104 LotusRange aRef( nCol, nRow );
105 return GetIndex( aRef );
108 inline LR_ID LotusRangeList::GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE )
110 LotusRange aRef( nColS, nRowS, nColE, nRowE );
111 return GetIndex( aRef );
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */