LibreOffice Module sc (master) 1
refdata.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 "address.hxx"
23#include "scdllapi.h"
24#include "calcmacros.hxx"
25
26struct ScSheetLimits;
27
30{
31private:
35
36 union
37 {
39 struct
40 {
41 bool bColRel :1;
42 bool bColDeleted :1;
43 bool bRowRel :1;
44 bool bRowDeleted :1;
45 bool bTabRel :1;
46 bool bTabDeleted :1;
47 bool bFlag3D :1;
48 bool bRelName :1;
50 };
51
52public:
54 void InitFlags() { mnFlagValue = 0; }
56 void InitAddress( const ScAddress& rAdr );
57 void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab );
59 void InitAddressRel( const ScDocument& rDoc, const ScAddress& rAdr, const ScAddress& rPos );
61 void InitFromRefAddress( const ScDocument& rDoc, const ScRefAddress& rRef, const ScAddress& rPos );
62 sal_uInt8 FlagValue() const { return mnFlagValue;}
63
64 void SetColRel( bool bVal ) { Flags.bColRel = bVal; }
65 bool IsColRel() const { return Flags.bColRel; }
66 void SetRowRel( bool bVal ) { Flags.bRowRel = bVal; }
67 bool IsRowRel() const { return Flags.bRowRel; }
68 void SetTabRel( bool bVal ) { Flags.bTabRel = bVal; }
69 bool IsTabRel() const { return Flags.bTabRel; }
70
71 void SetAbsCol( SCCOL nVal );
72 void SetRelCol( SCCOL nVal );
73 void IncCol( SCCOL nInc );
74 void SetAbsRow( SCROW nVal );
75 void SetRelRow( SCROW nVal );
76 void IncRow( SCROW nInc );
77 void SetAbsTab( SCTAB nVal );
78 void SetRelTab( SCTAB nVal );
79 void IncTab( SCTAB nInc );
80
81 void SetColDeleted( bool bVal );
82 bool IsColDeleted() const { return Flags.bColDeleted;}
83 void SetRowDeleted( bool bVal );
84 bool IsRowDeleted() const { return Flags.bRowDeleted;}
85 void SetTabDeleted( bool bVal );
86 bool IsTabDeleted() const { return Flags.bTabDeleted;}
87 bool IsDeleted() const;
88
89 void SetFlag3D( bool bVal ) { Flags.bFlag3D = bVal; }
90 bool IsFlag3D() const { return Flags.bFlag3D; }
91 void SetRelName( bool bVal ) { Flags.bRelName = bVal; }
92 bool IsRelName() const { return Flags.bRelName; }
93
94 bool Valid(const ScDocument& rDoc) const;
95 bool ColValid(const ScDocument& rDoc) const;
96 bool RowValid(const ScDocument& rDoc) const;
97 bool TabValid(const ScDocument& rDoc) const;
101 bool ValidExternal(const ScDocument& rDoc) const;
102
103 ScAddress toAbs( const ScSheetLimits& rLimits, const ScAddress& rPos ) const;
104 ScAddress toAbs( const ScDocument& rDoc, const ScAddress& rPos ) const;
105 void SetAddress( const ScSheetLimits& rLimits, const ScAddress& rAddr, const ScAddress& rPos );
106 SCROW Row() const;
107 SCCOL Col() const;
108 SCTAB Tab() const;
109
111 static void PutInOrder( ScSingleRefData& rRef1, ScSingleRefData& rRef2, const ScAddress& rPos );
112
113 bool operator==( const ScSingleRefData& ) const;
114 bool operator!=( const ScSingleRefData& ) const;
115
116#if DEBUG_FORMULA_COMPILER
117 void Dump( int nIndent = 0 ) const;
118#endif
119};
120
123{
126 bool bTrimToData = false;
127
129 { Ref1.InitFlags(); Ref2.InitFlags(); }
130 void InitRange( const ScRange& rRange )
131 {
132 Ref1.InitAddress( rRange.aStart );
133 Ref2.InitAddress( rRange.aEnd );
134 }
135 void InitRangeRel( const ScDocument& rDoc, const ScRange& rRange, const ScAddress& rPos )
136 {
137 Ref1.InitAddressRel( rDoc, rRange.aStart, rPos );
138 Ref2.InitAddressRel( rDoc, rRange.aEnd, rPos );
139 }
140 void InitRange( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
141 SCCOL nCol2, SCROW nRow2, SCTAB nTab2 )
142 {
143 Ref1.InitAddress( nCol1, nRow1, nTab1 );
144 Ref2.InitAddress( nCol2, nRow2, nTab2 );
145 }
146
148 void InitFromRefAddresses( const ScDocument& rDoc, const ScRefAddress& rRef1, const ScRefAddress& rRef2, const ScAddress& rPos );
149
150 bool Valid(const ScDocument& rDoc) const;
151
155 bool ValidExternal(const ScDocument& rDoc) const;
156
158 bool IsEntireCol( const ScSheetLimits& rLimits ) const;
159
161 bool IsEntireRow( const ScSheetLimits& rLimits ) const;
162
163 SC_DLLPUBLIC ScRange toAbs( const ScSheetLimits& rLimits, const ScAddress& rPos ) const;
164 SC_DLLPUBLIC ScRange toAbs( const ScDocument& rDoc, const ScAddress& rPos ) const;
165
168 void SetRange( const ScSheetLimits& rLimits, const ScRange& rRange, const ScAddress& rPos );
169
171 void PutInOrder( const ScAddress& rPos );
172
173 bool operator==( const ScComplexRefData& r ) const
174 { return Ref1 == r.Ref1 && Ref2 == r.Ref2; }
178 ScComplexRefData& Extend( const ScSheetLimits& rLimits, const ScSingleRefData & rRef, const ScAddress & rPos );
179 ScComplexRefData& Extend( const ScSheetLimits& rLimits, const ScComplexRefData & rRef, const ScAddress & rPos );
180
184 bool IncEndColSticky( const ScDocument& rDoc, SCCOL nDelta, const ScAddress& rPos );
185
189 bool IncEndRowSticky( const ScDocument& rDoc, SCROW nDelta, const ScAddress& rPos );
190
191 bool IsDeleted() const;
192
193 bool IsTrimToData() const { return bTrimToData; }
194 void SetTrimToData(bool bSet) { bTrimToData = bSet; }
195
196#if DEBUG_FORMULA_COMPILER
197 void Dump( int nIndent = 0 ) const;
198#endif
199};
200
201/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void PutInOrder(T &nStart, T &nEnd)
Definition: address.hxx:150
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
Flags
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
Complex reference (a range) into the sheet.
Definition: refdata.hxx:123
bool operator==(const ScComplexRefData &r) const
Definition: refdata.hxx:173
SC_DLLPUBLIC ScRange toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Definition: refdata.cxx:493
bool IsTrimToData() const
Definition: refdata.hxx:193
void InitRange(const ScRange &rRange)
Definition: refdata.hxx:130
bool Valid(const ScDocument &rDoc) const
Definition: refdata.cxx:478
void InitRangeRel(const ScDocument &rDoc, const ScRange &rRange, const ScAddress &rPos)
Definition: refdata.hxx:135
void InitFlags()
Definition: refdata.hxx:128
ScSingleRefData Ref2
Definition: refdata.hxx:125
bool IsEntireRow(const ScSheetLimits &rLimits) const
Whether this references entire rows, 1:1.
Definition: refdata.cxx:516
bool IsDeleted() const
Definition: refdata.cxx:580
bool IncEndRowSticky(const ScDocument &rDoc, SCROW nDelta, const ScAddress &rPos)
Increment or decrement end row unless or until sticky.
Definition: refdata.cxx:551
void SetRange(const ScSheetLimits &rLimits, const ScRange &rRange, const ScAddress &rPos)
Set a new range, assuming that the ordering of the range matches the ordering of the reference data f...
Definition: refdata.cxx:498
void SetTrimToData(bool bSet)
Definition: refdata.hxx:194
void InitRange(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2)
Definition: refdata.hxx:140
bool ValidExternal(const ScDocument &rDoc) const
In external references nTab is -1 for the start tab and -1 for the end tab if one sheet and the exter...
Definition: refdata.cxx:483
bool IncEndColSticky(const ScDocument &rDoc, SCCOL nDelta, const ScAddress &rPos)
Increment or decrement end column unless or until sticky.
Definition: refdata.cxx:522
bool IsEntireCol(const ScSheetLimits &rLimits) const
Whether this references entire columns, A:A.
Definition: refdata.cxx:509
void InitFromRefAddresses(const ScDocument &rDoc, const ScRefAddress &rRef1, const ScRefAddress &rRef2, const ScAddress &rPos)
InitFlags and set range, relative to rPos if rRef1 and rRef2 say so.
Definition: refdata.cxx:380
ScComplexRefData & Extend(const ScSheetLimits &rLimits, const ScSingleRefData &rRef, const ScAddress &rPos)
Enlarge range if reference passed is not within existing range.
Definition: refdata.cxx:394
void PutInOrder(const ScAddress &rPos)
Adjust ordering (front-top-left/rear-bottom-right) to a new position.
Definition: refdata.cxx:504
ScSingleRefData Ref1
Definition: refdata.hxx:124
Single reference (one address) into the sheet.
Definition: refdata.hxx:30
void InitAddress(const ScAddress &rAdr)
InitAddress: InitFlags and set address.
Definition: refdata.cxx:27
bool IsRowDeleted() const
Definition: refdata.hxx:84
void SetRowRel(bool bVal)
Definition: refdata.hxx:66
void InitAddressRel(const ScDocument &rDoc, const ScAddress &rAdr, const ScAddress &rPos)
InitAddressRel: InitFlags and set address, everything relative to rPos.
Definition: refdata.cxx:40
void SetTabRel(bool bVal)
Definition: refdata.hxx:68
bool IsTabRel() const
Definition: refdata.hxx:69
bool IsRowRel() const
Definition: refdata.hxx:67
bool bTabDeleted
Definition: refdata.hxx:46
bool bColDeleted
Definition: refdata.hxx:42
bool IsColRel() const
Definition: refdata.hxx:65
bool bRowDeleted
Definition: refdata.hxx:44
bool bRelName
Reference derived from RangeName with relative values.
Definition: refdata.hxx:48
sal_uInt8 FlagValue() const
Definition: refdata.hxx:62
bool IsTabDeleted() const
Definition: refdata.hxx:86
void SetFlag3D(bool bVal)
Definition: refdata.hxx:89
bool IsFlag3D() const
Definition: refdata.hxx:90
void InitFlags()
No default ctor, because used in ScRawToken union, set InitFlags!
Definition: refdata.hxx:54
void SetRelName(bool bVal)
Definition: refdata.hxx:91
bool IsColDeleted() const
Definition: refdata.hxx:82
void SetColRel(bool bVal)
Definition: refdata.hxx:64
sal_uInt8 mnFlagValue
Definition: refdata.hxx:38
bool IsRelName() const
Definition: refdata.hxx:92
bool bFlag3D
3D-Ref
Definition: refdata.hxx:47
unsigned char sal_uInt8
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
bool operator!=(const XclExpString &rLeft, const XclExpString &rRight)
Definition: xestring.hxx:248
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)
Definition: xlstyle.cxx:518