tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / sc / source / filter / inc / xladdress.hxx
blobe090d84458425c232e7b748076638ef4566fdb7e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <vector>
23 #include <address.hxx>
25 class XclImpStream;
26 class XclExpStream;
28 /** A 2D cell address struct with Excel column and row indexes. */
29 struct XclAddress
31 sal_uInt16 mnCol;
32 sal_uInt32 mnRow;
34 // coverity[uninit_member] - members deliberately not initialized
35 explicit XclAddress( ScAddress::Uninitialized ) {}
36 explicit XclAddress() : mnCol( 0 ), mnRow( 0 ) {}
37 explicit XclAddress( sal_uInt16 nCol, sal_uInt32 nRow ) : mnCol( nCol ), mnRow( nRow ) {}
39 void Set( sal_uInt16 nCol, sal_uInt32 nRow ) { mnCol = nCol; mnRow = nRow; }
41 void Read( XclImpStream& rStrm );
42 void Write( XclExpStream& rStrm ) const;
45 inline XclImpStream& operator>>( XclImpStream& rStrm, XclAddress& rXclPos )
47 rXclPos.Read( rStrm );
48 return rStrm;
51 inline XclExpStream& operator<<( XclExpStream& rStrm, const XclAddress& rXclPos )
53 rXclPos.Write( rStrm );
54 return rStrm;
57 /** A 2D cell range address struct with Excel column and row indexes. */
58 struct XclRange
60 XclAddress maFirst;
61 XclAddress maLast;
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 ) {}
69 void Set( sal_uInt16 nCol1, sal_uInt32 nRow1, sal_uInt16 nCol2, sal_uInt32 nRow2 )
70 { maFirst.Set( nCol1, nRow1 ); maLast.Set( nCol2, nRow2 ); }
72 sal_uInt16 GetColCount() const {
73 return maFirst.mnCol <= maLast.mnCol && maFirst.mnRow <= maLast.mnRow
74 ? maLast.mnCol - maFirst.mnCol + 1 : 0;
76 sal_uInt32 GetRowCount() const {
77 return maFirst.mnCol <= maLast.mnCol && maFirst.mnRow <= maLast.mnRow
78 ? maLast.mnRow - maFirst.mnRow + 1 : 0;
80 bool Contains( const XclAddress& rPos ) const;
82 void Read( XclImpStream& rStrm, bool bCol16Bit = true );
83 void Write( XclExpStream& rStrm, bool bCol16Bit = true ) const;
86 inline XclImpStream& operator>>( XclImpStream& rStrm, XclRange& rXclRange )
88 rXclRange.Read( rStrm );
89 return rStrm;
92 inline XclExpStream& operator<<( XclExpStream& rStrm, const XclRange& rXclRange )
94 rXclRange.Write( rStrm );
95 return rStrm;
98 typedef ::std::vector< XclRange > XclRangeVector;
100 /** A 2D cell range address list with Excel column and row indexes. */
101 class XclRangeList
103 private:
104 XclRangeVector mRanges;
106 public:
107 explicit XclRangeList() : mRanges() {}
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); }
116 XclRange GetEnclosingRange() const;
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;
124 inline XclImpStream& operator>>( XclImpStream& rStrm, XclRangeList& rXclRanges )
126 rXclRanges.Read( rStrm );
127 return rStrm;
130 inline XclExpStream& operator<<( XclExpStream& rStrm, const XclRangeList& rXclRanges )
132 rXclRanges.Write( rStrm );
133 return rStrm;
136 class XclTracer;
138 /** Base class for import/export address converters. */
139 class XclAddressConverterBase
141 public:
142 explicit XclAddressConverterBase( XclTracer& rTracer, const ScAddress& rMaxPos );
143 virtual ~XclAddressConverterBase();
145 /** Returns whether the "some columns have been cut" warning box should be shown. */
146 bool IsColTruncated() const { return mbColTrunc; }
147 /** Returns whether the "some rows have been cut" warning box should be shown. */
148 bool IsRowTruncated() const { return mbRowTrunc; }
149 /** Returns whether the "some sheets have been cut" warning box should be shown. */
150 bool IsTabTruncated() const { return mbTabTrunc; }
152 /** Checks if the passed sheet index is valid.
153 @param nScTab The sheet index to check.
154 Sets the internal flag that produces a warning box
155 after loading/saving the file, if the sheet index is not valid.
157 void CheckScTab( SCTAB nScTab );
159 protected:
160 XclTracer& mrTracer; /// Tracer for invalid addresses.
161 ScAddress maMaxPos; /// Default maximum position.
162 sal_uInt16 mnMaxCol; /// Maximum column index, as 16-bit value.
163 sal_uInt32 mnMaxRow; /// Maximum row index.
164 bool mbColTrunc; /// Flag for "columns truncated" warning box.
165 bool mbRowTrunc; /// Flag for "rows truncated" warning box.
166 bool mbTabTrunc; /// Flag for "tables truncated" warning box.
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */