Line data Source code
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_CONNECTIVITY_SOURCE_INC_FLAT_ETABLE_HXX
21 : #define INCLUDED_CONNECTIVITY_SOURCE_INC_FLAT_ETABLE_HXX
22 :
23 : #include "file/FTable.hxx"
24 : #include "flat/EConnection.hxx"
25 : #include <connectivity/sdbcx/VColumn.hxx>
26 : #include <connectivity/CommonTools.hxx>
27 : #include <tools/urlobj.hxx>
28 : #include "file/quotedstring.hxx"
29 : #include <unotools/syslocale.hxx>
30 :
31 : namespace connectivity
32 : {
33 : namespace flat
34 : {
35 : typedef file::OFileTable OFlatTable_BASE;
36 : class OFlatConnection;
37 :
38 : typedef ::std::pair<sal_Int32, sal_Int32> TRowPositionInFile;
39 :
40 0 : class OFlatTable : public OFlatTable_BASE
41 : {
42 : // maps a row position to a file position
43 : // row n is positions [m_aRowPosToFilePos[n]->first, m_aRowPosToFilePos[n]->second) in file
44 : // "real" row indexes start at 1; for the purposes of m_aRowPosToFilePos, row 0 is headers
45 : ::std::vector<TRowPositionInFile>
46 : m_aRowPosToFilePos;
47 : ::std::vector<sal_Int32> m_aTypes; // holds all type for columns just to avoid to ask the propertyset
48 : ::std::vector<sal_Int32> m_aPrecisions; // same as aboth
49 : ::std::vector<sal_Int32> m_aScales;
50 : QuotedTokenizedString m_aCurrentLine;
51 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xNumberFormatter;
52 : ::com::sun::star::util::Date m_aNullDate;
53 : sal_Int32 m_nRowPos;
54 : sal_Int32 m_nMaxRowCount; // will be set if stream is once eof
55 : sal_Unicode m_cStringDelimiter; // delimiter for strings m_cStringDelimiter blabla m_cStringDelimiter
56 : sal_Unicode m_cFieldDelimiter; // look at the name
57 : bool m_bNeedToReadLine;
58 : private:
59 : void fillColumns(const ::com::sun::star::lang::Locale& _aLocale);
60 : bool CreateFile(const INetURLObject& aFile, bool& bCreateMemo);
61 : bool readLine(sal_Int32 *pEndPos = NULL, sal_Int32 *pStartPos = NULL, bool nonEmpty = false);
62 : void setRowPos(::std::vector<TRowPositionInFile>::size_type rowNum, const TRowPositionInFile &rowPos);
63 : void impl_fillColumnInfo_nothrow(QuotedTokenizedString& aFirstLine, sal_Int32& nStartPosFirstLine, sal_Int32& nStartPosFirstLine2,
64 : sal_Int32& io_nType, sal_Int32& io_nPrecisions, sal_Int32& io_nScales, OUString& o_sTypeName,
65 : const sal_Unicode cDecimalDelimiter, const sal_Unicode cThousandDelimiter, const CharClass& aCharClass);
66 0 : OFlatConnection* getFlatConnection()
67 : {
68 : #if OSL_DEBUG_LEVEL > 0
69 : OFlatConnection* pConnection = dynamic_cast<OFlatConnection*>(m_pConnection);
70 : assert(pConnection);
71 : #else
72 0 : OFlatConnection* pConnection = static_cast<OFlatConnection*>(m_pConnection);
73 : #endif
74 0 : return pConnection;
75 : }
76 : public:
77 : virtual void refreshColumns() SAL_OVERRIDE;
78 :
79 : public:
80 : // DECLARE_CTY_DEFAULTS( OFlatTable_BASE);
81 : OFlatTable( sdbcx::OCollection* _pTables,OFlatConnection* _pConnection,
82 : const OUString& _Name,
83 : const OUString& _Type,
84 : const OUString& _Description = OUString(),
85 : const OUString& _SchemaName = OUString(),
86 : const OUString& _CatalogName = OUString()
87 : );
88 :
89 : void construct() SAL_OVERRIDE; // can throw any exception
90 :
91 : virtual bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) SAL_OVERRIDE;
92 : virtual bool fetchRow(OValueRefRow& _rRow, const OSQLColumns& _rCols, bool bIsTable, bool bRetrieveData) SAL_OVERRIDE;
93 : virtual void refreshHeader() SAL_OVERRIDE;
94 :
95 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 : //XTypeProvider
97 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
99 :
100 : // com::sun::star::lang::XUnoTunnel
101 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 : static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
103 :
104 : OUString getEntry();
105 : };
106 : }
107 : }
108 : #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_FLAT_ETABLE_HXX
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|