xref: /trunk/main/connectivity/source/inc/flat/ETable.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _CONNECTIVITY_FLAT_TABLE_HXX_
29 #define _CONNECTIVITY_FLAT_TABLE_HXX_
30 
31 #include "file/FTable.hxx"
32 #include "connectivity/sdbcx/VColumn.hxx"
33 #include "connectivity/CommonTools.hxx"
34 #include <tools/urlobj.hxx>
35 #include "file/quotedstring.hxx"
36 #include <unotools/syslocale.hxx>
37 
38 namespace connectivity
39 {
40     namespace flat
41     {
42         typedef file::OFileTable OFlatTable_BASE;
43         class OFlatConnection;
44 
45         typedef ::std::map< ::rtl::OUString,
46                         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>, comphelper::UStringMixLess > OContainer;
47         typedef ::std::map<sal_Int32, sal_Int32>    TRowPositionsInFile;
48 
49         class OFlatTable :  public OFlatTable_BASE
50         {
51             // maps a row postion to a file position
52             TRowPositionsInFile             m_aFilePosToEndLinePos;
53             ::std::map<sal_Int32, TRowPositionsInFile::iterator>
54                                             m_aRowPosToFilePos;
55             ::std::vector<sal_Int32>        m_aTypes;       // holds all type for columns just to avoid to ask the propertyset
56             ::std::vector<sal_Int32>        m_aPrecisions;  // same as aboth
57             ::std::vector<sal_Int32>        m_aScales;
58             QuotedTokenizedString           m_aCurrentLine;
59             ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xNumberFormatter;
60             ::com::sun::star::util::Date    m_aNullDate;
61             sal_Int32                       m_nStartRowFilePos;
62             sal_Int32                       m_nRowPos;
63             sal_Int32                       m_nMaxRowCount; // will be set if stream is once eof
64             sal_Unicode                     m_cStringDelimiter;     // delimiter for strings m_cStringDelimiter blabla m_cStringDelimiter
65             sal_Unicode                     m_cFieldDelimiter;      // look at the name
66             bool                            m_bNeedToReadLine;
67         private:
68             void fillColumns(const ::com::sun::star::lang::Locale& _aLocale);
69             sal_Bool CreateFile(const INetURLObject& aFile, sal_Bool& bCreateMemo);
70             sal_Bool readLine(sal_Int32& _rnCurrentPos);
71             void impl_fillColumnInfo_nothrow(QuotedTokenizedString& aFirstLine,xub_StrLen& nStartPosFirstLine,xub_StrLen& nStartPosFirstLine2
72                                              ,sal_Int32& io_nType,sal_Int32& io_nPrecisions,sal_Int32& io_nScales,String& o_sTypeName
73                                              ,const sal_Unicode cDecimalDelimiter,const sal_Unicode cThousandDelimiter,const CharClass& aCharClass);
74         public:
75             virtual void refreshColumns();
76 
77         public:
78             //  DECLARE_CTY_DEFAULTS( OFlatTable_BASE);
79             OFlatTable( sdbcx::OCollection* _pTables,OFlatConnection* _pConnection,
80                     const ::rtl::OUString& _Name,
81                     const ::rtl::OUString& _Type,
82                     const ::rtl::OUString& _Description = ::rtl::OUString(),
83                     const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
84                     const ::rtl::OUString& _CatalogName = ::rtl::OUString()
85                 );
86 
87             void construct(); // can throw any exception
88 
89             virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos);
90             virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool bIsTable,sal_Bool bRetrieveData);
91             virtual void refreshHeader();
92 
93             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
94             //XTypeProvider
95             virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
96             virtual void SAL_CALL disposing(void);
97 
98             // com::sun::star::lang::XUnoTunnel
99             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
100             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
101 
102             String getEntry();
103         };
104     }
105 }
106 #endif // _CONNECTIVITY_FLAT_TABLE_HXX_
107 
108