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 _CONNECTIVITY_FLAT_TABLE_HXX_
21 : #define _CONNECTIVITY_FLAT_TABLE_HXX_
22 :
23 : #include "file/FTable.hxx"
24 : #include "connectivity/sdbcx/VColumn.hxx"
25 : #include "connectivity/CommonTools.hxx"
26 : #include <tools/urlobj.hxx>
27 : #include "file/quotedstring.hxx"
28 : #include <unotools/syslocale.hxx>
29 :
30 : namespace connectivity
31 : {
32 : namespace flat
33 : {
34 : typedef file::OFileTable OFlatTable_BASE;
35 : class OFlatConnection;
36 :
37 : typedef ::std::map< ::rtl::OUString,
38 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>, comphelper::UStringMixLess > OContainer;
39 : typedef ::std::map<sal_Int32, sal_Int32> TRowPositionsInFile;
40 :
41 0 : class OFlatTable : public OFlatTable_BASE
42 : {
43 : // maps a row postion to a file position
44 : TRowPositionsInFile m_aFilePosToEndLinePos;
45 : ::std::map<sal_Int32, TRowPositionsInFile::iterator>
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_nStartRowFilePos;
54 : sal_Int32 m_nRowPos;
55 : sal_Int32 m_nMaxRowCount; // will be set if stream is once eof
56 : sal_Unicode m_cStringDelimiter; // delimiter for strings m_cStringDelimiter blabla m_cStringDelimiter
57 : sal_Unicode m_cFieldDelimiter; // look at the name
58 : bool m_bNeedToReadLine;
59 : private:
60 : void fillColumns(const ::com::sun::star::lang::Locale& _aLocale);
61 : sal_Bool CreateFile(const INetURLObject& aFile, sal_Bool& bCreateMemo);
62 : sal_Bool readLine(sal_Int32& _rnCurrentPos);
63 : void impl_fillColumnInfo_nothrow(QuotedTokenizedString& aFirstLine,xub_StrLen& nStartPosFirstLine,xub_StrLen& nStartPosFirstLine2
64 : ,sal_Int32& io_nType,sal_Int32& io_nPrecisions,sal_Int32& io_nScales,String& o_sTypeName
65 : ,const sal_Unicode cDecimalDelimiter,const sal_Unicode cThousandDelimiter,const CharClass& aCharClass);
66 : public:
67 : virtual void refreshColumns();
68 :
69 : public:
70 : // DECLARE_CTY_DEFAULTS( OFlatTable_BASE);
71 : OFlatTable( sdbcx::OCollection* _pTables,OFlatConnection* _pConnection,
72 : const ::rtl::OUString& _Name,
73 : const ::rtl::OUString& _Type,
74 : const ::rtl::OUString& _Description = ::rtl::OUString(),
75 : const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
76 : const ::rtl::OUString& _CatalogName = ::rtl::OUString()
77 : );
78 :
79 : void construct(); // can throw any exception
80 :
81 : virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos);
82 : virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool bIsTable,sal_Bool bRetrieveData);
83 : virtual void refreshHeader();
84 :
85 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
86 : //XTypeProvider
87 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
88 : virtual void SAL_CALL disposing(void);
89 :
90 : // com::sun::star::lang::XUnoTunnel
91 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
92 : static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
93 :
94 : String getEntry();
95 : };
96 : }
97 : }
98 : #endif // _CONNECTIVITY_FLAT_TABLE_HXX_
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|