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