1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 // Written by DanH, Sept 1995
17 #if !defined(__BACELL_H__)
20 #if !defined(__E32DEF_H_)
24 #if !defined(__S32STRM_H__)
33 Identifies a cell by row and column number.
40 inline TCellRef(TInt aRow,TInt aCol);
42 inline TBool operator==(const TCellRef& aCell) const;
43 inline TBool operator!=(const TCellRef& aCell) const;
45 inline TCellRef& operator+=(const TCellRef& aCell);
46 inline TCellRef& operator-=(const TCellRef& aCell);
48 IMPORT_C void Offset(TInt aRowOffset,TInt aColOffset);
50 IMPORT_C void InternalizeL(RReadStream& aStream);
51 inline void ExternalizeL(RWriteStream& aStream) const;
53 /** The row number. */
55 /** The column number. */
63 IMPORT_C TCellRef operator+(const TCellRef& aLeft,const TCellRef& aRight);
64 IMPORT_C TCellRef operator-(const TCellRef& aLeft,const TCellRef& aRight);
66 inline TCellRef::TCellRef()
67 /** Default constructor.
69 The object's row and column number are undefined. */
71 inline TCellRef::TCellRef(TInt aRow,TInt aCol)
72 : iRow(aRow),iCol(aCol)
73 /** Constructor taking a row and column number.
75 @param aRow The row number.
76 @param aCol The column number. */
78 inline TBool TCellRef::operator==(const TCellRef& aCell) const
79 /** Compares this cell with the specified cell for equality.
81 @param aCell The cell to be compared.
82 @return ETrue, if the row numbers are the same and column numbers are
84 {return aCell.iRow==iRow && aCell.iCol==iCol;}
85 inline TBool TCellRef::operator!=(const TCellRef& aCell) const
86 /** Compares this cell with the specified cell for inequality.
88 @param aCell The cell to be compared.
89 @return ETrue, if the row numbers are different or the column numbers are
91 {return aCell.iRow!=iRow || aCell.iCol!=iCol;}
92 inline TCellRef& TCellRef::operator+=(const TCellRef& aCell)
93 /** Adds the specified cell to this cell.
95 Addition is the process of adding the specified cell's row and column
96 numbers to this cell's row and column numbers respectively.
98 @param aCell The cell to be added.
99 @return A reference to this cell object. */
100 {Offset(aCell.iRow,aCell.iCol);return *this;}
101 inline TCellRef& TCellRef::operator-=(const TCellRef& aCell)
102 /** Subtracts the specified cell from this cell.
104 Subtraction is the process of subtracting the specified cell's row and
105 column numbers from this cell's row and column numbers respectively.
107 @param aCell The cell to be subtracted.
108 @return A reference to this cell object. */
109 {Offset(-aCell.iRow,-aCell.iCol);return *this;}
110 inline void TCellRef::ExternalizeL(RWriteStream& aStream) const
111 /** Externalises an object of this class to a write stream.
113 The presence of this function means that the standard templated operator<<()
114 can be used to externalise objects of this class.
116 @param aStream Stream to which the object should be externalised. */
117 {aStream.WriteInt32L(iRow);aStream.WriteInt32L(iCol);}
122 Identifies a range of cells by start and end cell references.
123 The range is inclusive of both the start and end cells.
131 inline TRangeRef(const TCellRef& aFrom,const TCellRef& aTo);
132 inline TRangeRef(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol);
134 IMPORT_C TBool operator==(const TRangeRef& aRange) const;
135 inline TBool operator!=(const TRangeRef& aRange) const;
137 inline void SetRange(const TCellRef& aFrom,const TCellRef& aTo);
138 inline void SetRange(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol);
139 inline TInt NoRows() const;
140 inline TInt NoCols() const;
141 IMPORT_C TInt NoCells() const;
142 IMPORT_C TBool Contains(const TCellRef& aCell) const;
143 IMPORT_C void InternalizeL(RReadStream& aStream);
144 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
146 /** The start cell. */
151 class TIter; // defined outside TRangeRef class as contains TRangeRef
153 class TRangeRef::TIter
160 IMPORT_C TIter(const TRangeRef& aRangeRef);
161 IMPORT_C TBool operator++();
162 inline TBool InRange() const;
170 inline TRangeRef::TRangeRef()
171 /** Default constructor.
173 The object's start cell and end cell are undefined. */
175 inline TRangeRef::TRangeRef(const TCellRef& aFrom,const TCellRef& aTo)
176 : iFrom(aFrom),iTo(aTo)
177 /** Constructor taking a start and end cell.
179 @param aFrom The start cell.
180 @param aTo The end cell. */
182 inline TRangeRef::TRangeRef(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol)
183 : iFrom(aFromRow,aFromCol),iTo(aToRow,aToCol)
184 /** Constructor taking a start row and start column number, and an end row and
187 @param aFromRow The start row number.
188 @param aFromCol The start column number.
189 @param aToRow The end row number.
190 @param aToCol The end column number. */
192 inline void TRangeRef::SetRange(const TCellRef& aFrom,const TCellRef& aTo)
193 /** Sets the cell range to the specified cells.
195 @param aFrom The start cell for the range.
196 @param aTo The end cell for the range. */
197 {iFrom=aFrom;iTo=aTo;}
198 inline void TRangeRef::SetRange(TInt aFromRow,TInt aFromCol,TInt aToRow,TInt aToCol)
199 /** Sets the cell range to the specified start row and column, and end row
202 @param aFromRow The start row number.
203 @param aFromCol The start column number.
204 @param aToRow The end row number.
205 @param aToCol The end column number. */
206 {iFrom.iRow=aFromRow;iFrom.iCol=aFromCol;iTo.iRow=aToRow;iTo.iCol=aToCol;}
207 inline TBool TRangeRef::operator!=(const TRangeRef& aRange) const
208 /** Compares this cell range with the specified cell range for inequality.
210 @param aRange The cell to be compared.
211 @return ETrue, if the start cells are different or the end cells are
213 {return !operator==(aRange);}
214 inline TInt TRangeRef::NoRows() const
215 /** Gets the number of rows represented by the range.
217 @return The number of rows. */
218 {return iTo.iRow - iFrom.iRow + 1;}
219 inline TInt TRangeRef::NoCols() const
220 /** Gets the number of columns represented by the range.
222 @return The number of columns. */
223 {return iTo.iCol - iFrom.iCol + 1;}
224 inline TBool TRangeRef::TIter::InRange() const
225 {return iRange.Contains(iCurrent);}