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