LibreOffice Module sc (master)  1
xladdress.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_XLADDRESS_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XLADDRESS_HXX
22 
23 #include <vector>
24 #include <address.hxx>
25 
26 class XclImpStream;
27 class XclExpStream;
28 
30 struct XclAddress
31 {
32  sal_uInt16 mnCol;
33  sal_uInt32 mnRow;
34 
36  explicit XclAddress() : mnCol( 0 ), mnRow( 0 ) {}
37  explicit XclAddress( sal_uInt16 nCol, sal_uInt32 nRow ) : mnCol( nCol ), mnRow( nRow ) {}
38 
39  void Set( sal_uInt16 nCol, sal_uInt32 nRow ) { mnCol = nCol; mnRow = nRow; }
40 
41  void Read( XclImpStream& rStrm );
42  void Write( XclExpStream& rStrm ) const;
43 };
44 
45 inline XclImpStream& operator>>( XclImpStream& rStrm, XclAddress& rXclPos )
46 {
47  rXclPos.Read( rStrm );
48  return rStrm;
49 }
50 
51 inline XclExpStream& operator<<( XclExpStream& rStrm, const XclAddress& rXclPos )
52 {
53  rXclPos.Write( rStrm );
54  return rStrm;
55 }
56 
58 struct XclRange
59 {
62 
63  explicit XclRange( ScAddress::Uninitialized e ) : maFirst( e ), maLast( e ) {}
64  explicit XclRange() {}
65  explicit XclRange( const XclAddress& rPos ) : maFirst( rPos ), maLast( rPos ) {}
66  explicit XclRange( sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2 ) :
67  maFirst( nCol1, nRow1 ), maLast( nCol2, nRow2 ) {}
68 
69  void Set( sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2 )
70  { maFirst.Set( nCol1, nRow1 ); maLast.Set( nCol2, nRow2 ); }
71 
72  sal_uInt16 GetColCount() const {
73  return maFirst.mnCol <= maLast.mnCol && maFirst.mnRow <= maLast.mnRow
74  ? maLast.mnCol - maFirst.mnCol + 1 : 0;
75  }
76  sal_uInt32 GetRowCount() const {
77  return maFirst.mnCol <= maLast.mnCol && maFirst.mnRow <= maLast.mnRow
78  ? maLast.mnRow - maFirst.mnRow + 1 : 0;
79  }
80  bool Contains( const XclAddress& rPos ) const;
81 
82  void Read( XclImpStream& rStrm, bool bCol16Bit = true );
83  void Write( XclExpStream& rStrm, bool bCol16Bit = true ) const;
84 };
85 
86 inline XclImpStream& operator>>( XclImpStream& rStrm, XclRange& rXclRange )
87 {
88  rXclRange.Read( rStrm );
89  return rStrm;
90 }
91 
92 inline XclExpStream& operator<<( XclExpStream& rStrm, const XclRange& rXclRange )
93 {
94  rXclRange.Write( rStrm );
95  return rStrm;
96 }
97 
98 typedef ::std::vector< XclRange > XclRangeVector;
99 
102 {
103 private:
105 
106 public:
107  explicit XclRangeList() : mRanges() {}
108 
109  size_t size() const { return mRanges.size(); }
110  bool empty() const { return mRanges.empty(); }
111  XclRangeVector::const_iterator begin() const { return mRanges.begin(); }
112  XclRangeVector::const_iterator end() const { return mRanges.end(); }
113  void clear() { mRanges.clear(); }
114  void push_back(const XclRange &rRange) { mRanges.push_back(rRange); }
115 
116  XclRange GetEnclosingRange() const;
117 
118  void Read( XclImpStream& rStrm, bool bCol16Bit = true, sal_uInt16 nCountInStream = 0 );
119  void Write( XclExpStream& rStrm, bool bCol16Bit = true, sal_uInt16 nCountInStream = 0 ) const;
120  void WriteSubList( XclExpStream& rStrm,
121  size_t nBegin, size_t nCount, bool bCol16Bit = true, sal_uInt16 nCountInStream = 0 ) const;
122 };
123 
124 inline XclImpStream& operator>>( XclImpStream& rStrm, XclRangeList& rXclRanges )
125 {
126  rXclRanges.Read( rStrm );
127  return rStrm;
128 }
129 
130 inline XclExpStream& operator<<( XclExpStream& rStrm, const XclRangeList& rXclRanges )
131 {
132  rXclRanges.Write( rStrm );
133  return rStrm;
134 }
135 
136 class XclTracer;
137 
140 {
141 public:
142  explicit XclAddressConverterBase( XclTracer& rTracer, const ScAddress& rMaxPos );
143  virtual ~XclAddressConverterBase();
144 
146  bool IsColTruncated() const { return mbColTrunc; }
148  bool IsRowTruncated() const { return mbRowTrunc; }
150  bool IsTabTruncated() const { return mbTabTrunc; }
151 
157  void CheckScTab( SCTAB nScTab );
158 
159 protected:
162  sal_uInt16 mnMaxCol;
163  sal_uInt32 mnMaxRow;
164  bool mbColTrunc;
165  bool mbRowTrunc;
166  bool mbTabTrunc;
167 };
168 
169 #endif
170 
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScAddress maMaxPos
Tracer for invalid addresses.
Definition: xladdress.hxx:161
This class wraps an MSFilterTracer to create trace logs for import/export filters.
Definition: xltracer.hxx:51
This class is used to export Excel record streams.
Definition: xestream.hxx:71
void Write(XclExpStream &rStrm, bool bCol16Bit=true) const
Definition: xladdress.cxx:63
sal_uInt16 mnMaxCol
Default maximum position.
Definition: xladdress.hxx:162
void push_back(const XclRange &rRange)
Definition: xladdress.hxx:114
bool mbTabTrunc
Flag for "rows truncated" warning box.
Definition: xladdress.hxx:166
void Write(XclExpStream &rStrm) const
Definition: xladdress.cxx:34
XclAddress maLast
Definition: xladdress.hxx:61
sal_uInt32 mnRow
Definition: xladdress.hxx:33
XclAddress maFirst
Definition: xladdress.hxx:60
void CheckScTab(SCTAB nScTab)
Checks if the passed sheet index is valid.
Definition: xladdress.cxx:140
void Read(XclImpStream &rStrm)
Definition: xladdress.cxx:28
size_t size() const
Definition: xladdress.hxx:109
void Read(XclImpStream &rStrm, bool bCol16Bit=true, sal_uInt16 nCountInStream=0)
Definition: xladdress.cxx:90
void clear()
Definition: xladdress.hxx:113
sal_uInt32 mnMaxRow
Maximum column index, as 16-bit value.
Definition: xladdress.hxx:163
XclImpStream & operator>>(XclImpStream &rStrm, XclAddress &rXclPos)
Definition: xladdress.hxx:45
bool IsTabTruncated() const
Returns whether the "some sheets have been cut" warning box should be shown.
Definition: xladdress.hxx:150
XclAddress(ScAddress::Uninitialized)
Definition: xladdress.hxx:35
void Set(sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2)
Definition: xladdress.hxx:69
XclRange(sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2)
Definition: xladdress.hxx:66
bool empty() const
Definition: xladdress.hxx:110
::std::vector< XclRange > XclRangeVector
Definition: xladdress.hxx:98
XclRangeVector::const_iterator end() const
Definition: xladdress.hxx:112
XclRangeVector::const_iterator begin() const
Definition: xladdress.hxx:111
bool Contains(const XclAddress &rPos) const
Definition: xladdress.cxx:40
void Read(XclImpStream &rStrm, bool bCol16Bit=true)
Definition: xladdress.cxx:46
XclAddress(sal_uInt16 nCol, sal_uInt32 nRow)
Definition: xladdress.hxx:37
bool IsColTruncated() const
Returns whether the "some columns have been cut" warning box should be shown.
Definition: xladdress.hxx:146
bool IsRowTruncated() const
Returns whether the "some rows have been cut" warning box should be shown.
Definition: xladdress.hxx:148
bool mbColTrunc
Maximum row index.
Definition: xladdress.hxx:164
A 2D cell range address list with Excel column and row indexes.
Definition: xladdress.hxx:101
XclRange(ScAddress::Uninitialized e)
Definition: xladdress.hxx:63
sal_uInt16 mnCol
Definition: xladdress.hxx:32
A 2D cell address struct with Excel column and row indexes.
Definition: xladdress.hxx:30
void Set(sal_uInt16 nCol, sal_uInt32 nRow)
Definition: xladdress.hxx:39
virtual ~XclAddressConverterBase()
Definition: xladdress.cxx:136
sal_uInt16 GetColCount() const
Definition: xladdress.hxx:72
XclRange(const XclAddress &rPos)
Definition: xladdress.hxx:65
sal_uInt32 GetRowCount() const
Definition: xladdress.hxx:76
XclAddressConverterBase(XclTracer &rTracer, const ScAddress &rMaxPos)
Definition: xladdress.cxx:123
XclRange GetEnclosingRange() const
Definition: xladdress.cxx:72
bool mbRowTrunc
Flag for "columns truncated" warning box.
Definition: xladdress.hxx:165
Base class for import/export address converters.
Definition: xladdress.hxx:139
XclExpStream & operator<<(XclExpStream &rStrm, const XclAddress &rXclPos)
Definition: xladdress.hxx:51
This class is used to import record oriented streams.
Definition: xistream.hxx:278
void WriteSubList(XclExpStream &rStrm, size_t nBegin, size_t nCount, bool bCol16Bit=true, sal_uInt16 nCountInStream=0) const
Definition: xladdress.cxx:108
void Write(XclExpStream &rStrm, bool bCol16Bit=true, sal_uInt16 nCountInStream=0) const
Definition: xladdress.cxx:103
A 2D cell range address struct with Excel column and row indexes.
Definition: xladdress.hxx:58
sal_Int16 SCTAB
Definition: types.hxx:23
XclRangeVector mRanges
Definition: xladdress.hxx:104