1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_FLAT_ETABLE_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_INC_FLAT_ETABLE_HXX
23 #include <file/FTable.hxx>
24 #include <flat/EConnection.hxx>
25 #include <connectivity/CommonTools.hxx>
26 #include <file/quotedstring.hxx>
27 #include <unotools/syslocale.hxx>
28 #include <com/sun/star/util/XNumberFormatter.hpp>
30 namespace connectivity::flat
32 typedef file::OFileTable OFlatTable_BASE
;
33 class OFlatConnection
;
35 typedef std::pair
<sal_Int32
, sal_Int32
> TRowPositionInFile
;
37 class OFlatTable
: public OFlatTable_BASE
39 // maps a row position to a file position
40 // row n is positions [m_aRowPosToFilePos[n]->first, m_aRowPosToFilePos[n]->second) in file
41 // "real" row indexes start at 1; for the purposes of m_aRowPosToFilePos, row 0 is headers
42 std::vector
<TRowPositionInFile
>
44 std::vector
<sal_Int32
> m_aTypes
; // holds all type for columns just to avoid to ask the propertyset
45 std::vector
<sal_Int32
> m_aPrecisions
; // same as aboth
46 std::vector
<sal_Int32
> m_aScales
;
47 QuotedTokenizedString m_aCurrentLine
;
48 css::uno::Reference
< css::util::XNumberFormatter
> m_xNumberFormatter
;
49 css::util::Date m_aNullDate
;
51 sal_Int32 m_nMaxRowCount
; // will be set if stream is once eof
52 sal_Unicode m_cStringDelimiter
; // delimiter for strings m_cStringDelimiter blabla m_cStringDelimiter
53 sal_Unicode m_cFieldDelimiter
; // look at the name
54 bool m_bNeedToReadLine
;
56 void fillColumns(const css::lang::Locale
& _aLocale
);
57 bool readLine(sal_Int32
*pEndPos
, sal_Int32
*pStartPos
, bool nonEmpty
= false);
58 void setRowPos(std::vector
<TRowPositionInFile
>::size_type rowNum
, const TRowPositionInFile
&rowPos
);
59 void impl_fillColumnInfo_nothrow(QuotedTokenizedString
const & aFirstLine
, sal_Int32
& nStartPosFirstLine
, sal_Int32
& nStartPosFirstLine2
,
60 sal_Int32
& io_nType
, sal_Int32
& io_nPrecisions
, sal_Int32
& io_nScales
, OUString
& o_sTypeName
,
61 const sal_Unicode cDecimalDelimiter
, const sal_Unicode cThousandDelimiter
, const CharClass
& aCharClass
);
62 OFlatConnection
* getFlatConnection()
64 #if OSL_DEBUG_LEVEL > 0
65 OFlatConnection
* pConnection
= dynamic_cast<OFlatConnection
*>(m_pConnection
);
68 OFlatConnection
* pConnection
= static_cast<OFlatConnection
*>(m_pConnection
);
73 virtual void refreshColumns() override
;
76 // DECLARE_CTY_DEFAULTS( OFlatTable_BASE);
77 OFlatTable( sdbcx::OCollection
* _pTables
,OFlatConnection
* _pConnection
,
80 const OUString
& Description
= OUString(),
81 const OUString
& SchemaName
= OUString(),
82 const OUString
& CatalogName
= OUString()
85 void construct() override
; // can throw any exception
87 virtual bool seekRow(IResultSetHelper::Movement eCursorPosition
, sal_Int32 nOffset
, sal_Int32
& nCurPos
) override
;
88 virtual bool fetchRow(OValueRefRow
& _rRow
, const OSQLColumns
& _rCols
, bool bRetrieveData
) override
;
89 virtual void refreshHeader() override
;
91 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
93 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
94 virtual void SAL_CALL
disposing() override
;
96 // css::lang::XUnoTunnel
97 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
98 static css::uno::Sequence
< sal_Int8
> getUnoTunnelId();
100 OUString
getEntry() const;
104 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_FLAT_ETABLE_HXX
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */