LibreOffice Module sc (master)  1
lotrange.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_SOURCE_FILTER_INC_LOTRANGE_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_LOTRANGE_HXX
22 
23 #include <refdata.hxx>
24 #include <types.hxx>
25 
26 #include <memory>
27 
28 typedef sal_uInt16 LR_ID;
29 
30 #define ID_FAIL 0xFFFF
31 
33 {
34  friend class LotusRangeList;
35 private:
36  sal_uInt32 nHash;
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;
52 };
53 
54 inline void LotusRange::Copy( const LotusRange& rCpy )
55 {
56  nHash = rCpy.nHash;
57  nColStart = rCpy.nColStart;
58  nRowStart = rCpy.nRowStart;
59  nColEnd = rCpy.nColEnd;
60  nRowEnd = rCpy.nRowEnd;
61  nId = rCpy.nId;
62 }
63 
64 inline void LotusRange::SetId( LR_ID nNewId )
65 {
66  nId = nNewId;
67 }
68 
70 {
71  Copy( rCpy );
72  return *this;
73 }
74 
75 inline bool LotusRange::operator ==( const LotusRange& rRef ) const
76 {
77  return ( nHash == rRef.nHash && nColStart == rRef.nColStart &&
78  nRowStart == rRef.nRowStart && nColEnd == rRef.nColEnd &&
79  nRowEnd == rRef.nRowEnd );
80 }
81 
82 inline bool LotusRange::IsSingle() const
83 {
84  return ( nColStart == nColEnd && nRowStart == nRowEnd );
85 }
86 
88 {
89 private:
92  std::vector<std::unique_ptr<LotusRange>> maRanges;
93 
94 public:
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( const ScDocument* pDoc, std::unique_ptr<LotusRange> pLR );
101 };
102 
104 {
105  LotusRange aRef( nCol, nRow );
106  return GetIndex( aRef );
107 }
108 
109 inline LR_ID LotusRangeList::GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE )
110 {
111  LotusRange aRef( nColS, nRowS, nColE, nRowE );
112  return GetIndex( aRef );
113 }
114 
115 #endif
116 
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
LR_ID nId
Definition: lotrange.hxx:41
std::vector< std::unique_ptr< LotusRange > > maRanges
Definition: lotrange.hxx:92
void Copy(const LotusRange &)
Definition: lotrange.hxx:54
sal_uInt16 LR_ID
Definition: lotrange.hxx:28
SCROW nRowStart
Definition: lotrange.hxx:38
void MakeHash()
Definition: tool.cxx:329
LR_ID GetIndex(SCCOL nCol, SCROW nRow)
Definition: lotrange.hxx:103
ScComplexRefData aComplRef
Definition: lotrange.hxx:91
LotusRangeList()
Definition: tool.cxx:366
sal_uInt32 nHash
Definition: lotrange.hxx:36
void Append(const ScDocument *pDoc, std::unique_ptr< LotusRange > pLR)
Definition: tool.cxx:400
SCCOL nColEnd
Definition: lotrange.hxx:39
bool operator==(const LotusRange &) const
Definition: lotrange.hxx:75
~LotusRangeList()
Definition: tool.cxx:386
sal_Int16 SCCOL
Definition: types.hxx:22
LotusRange & operator=(const LotusRange &)
Definition: lotrange.hxx:69
LotusRange(SCCOL nCol, SCROW nRow)
Definition: tool.cxx:343
sal_Int32 SCROW
Definition: types.hxx:18
SCROW nRowEnd
Definition: lotrange.hxx:40
void SetId(LR_ID nId)
Definition: lotrange.hxx:64
Complex reference (a range) into the sheet.
Definition: refdata.hxx:123
bool IsSingle() const
Definition: lotrange.hxx:82
SCCOL nColStart
Definition: lotrange.hxx:37