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