/src/libreoffice/connectivity/source/drivers/file/FTable.cxx
Line | Count | Source |
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 | | |
21 | | #include <file/FTable.hxx> |
22 | | #include <file/FColumns.hxx> |
23 | | #include <com/sun/star/sdbc/XRow.hpp> |
24 | | #include <com/sun/star/sdbc/XResultSet.hpp> |
25 | | #include <unotools/ucbstreamhelper.hxx> |
26 | | |
27 | | using namespace connectivity; |
28 | | using namespace connectivity::file; |
29 | | using namespace ::com::sun::star::uno; |
30 | | using namespace ::com::sun::star::beans; |
31 | | using namespace ::com::sun::star::sdbcx; |
32 | | using namespace ::com::sun::star::sdbc; |
33 | | using namespace ::com::sun::star::container; |
34 | | |
35 | | OFileTable::OFileTable(sdbcx::OCollection* _pTables,OConnection* _pConnection) |
36 | 0 | : OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()) |
37 | 0 | ,m_pConnection(_pConnection) |
38 | 0 | ,m_nFilePos(0) |
39 | 0 | ,m_nBufferSize(0) |
40 | 0 | ,m_bWriteable(false) |
41 | 0 | { |
42 | 0 | construct(); |
43 | 0 | m_aColumns = new OSQLColumns(); |
44 | 0 | } |
45 | | |
46 | | OFileTable::OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection, |
47 | | const OUString& Name, |
48 | | const OUString& Type, |
49 | | const OUString& Description , |
50 | | const OUString& SchemaName, |
51 | | const OUString& CatalogName ) |
52 | 42.3k | : OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers(), |
53 | 42.3k | Name, |
54 | 42.3k | Type, |
55 | 42.3k | Description, |
56 | 42.3k | SchemaName, |
57 | 42.3k | CatalogName) |
58 | 42.3k | , m_pConnection(_pConnection) |
59 | 42.3k | , m_nFilePos(0) |
60 | 42.3k | , m_nBufferSize(0) |
61 | 42.3k | , m_bWriteable(false) |
62 | 42.3k | { |
63 | 42.3k | m_aColumns = new OSQLColumns(); |
64 | 42.3k | construct(); |
65 | | // refreshColumns(); |
66 | 42.3k | } |
67 | | |
68 | | OFileTable::~OFileTable( ) |
69 | 42.3k | { |
70 | 42.3k | } |
71 | | |
72 | | void OFileTable::refreshColumns() |
73 | 0 | { |
74 | 0 | ::std::vector< OUString> aVector; |
75 | 0 | Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(Any(), |
76 | 0 | m_SchemaName,m_Name, u"%"_ustr); |
77 | |
|
78 | 0 | if(xResult.is()) |
79 | 0 | { |
80 | 0 | Reference< XRow > xRow(xResult,UNO_QUERY); |
81 | 0 | while(xResult->next()) |
82 | 0 | aVector.push_back(xRow->getString(4)); |
83 | 0 | } |
84 | |
|
85 | 0 | if(m_xColumns) |
86 | 0 | m_xColumns->reFill(aVector); |
87 | 0 | else |
88 | 0 | m_xColumns.reset(new OColumns(this,m_aMutex,aVector)); |
89 | 0 | } |
90 | | |
91 | | void OFileTable::refreshKeys() |
92 | 0 | { |
93 | 0 | } |
94 | | |
95 | | void OFileTable::refreshIndexes() |
96 | 0 | { |
97 | 0 | } |
98 | | |
99 | | Any SAL_CALL OFileTable::queryInterface( const Type & rType ) |
100 | 0 | { |
101 | 0 | if( rType == cppu::UnoType<XKeysSupplier>::get()|| |
102 | 0 | rType == cppu::UnoType<XRename>::get()|| |
103 | 0 | rType == cppu::UnoType<XAlterTable>::get()|| |
104 | 0 | rType == cppu::UnoType<XIndexesSupplier>::get()|| |
105 | 0 | rType == cppu::UnoType<XDataDescriptorFactory>::get()) |
106 | 0 | return Any(); |
107 | | |
108 | 0 | return OTable_TYPEDEF::queryInterface(rType); |
109 | 0 | } |
110 | | |
111 | | void SAL_CALL OFileTable::disposing() |
112 | 42.3k | { |
113 | 42.3k | OTable::disposing(); |
114 | | |
115 | 42.3k | ::osl::MutexGuard aGuard(m_aMutex); |
116 | | |
117 | 42.3k | FileClose(); |
118 | 42.3k | } |
119 | | |
120 | | void OFileTable::FileClose() |
121 | 42.5k | { |
122 | 42.5k | ::osl::MutexGuard aGuard(m_aMutex); |
123 | | |
124 | 42.5k | m_pFileStream.reset(); |
125 | 42.5k | m_pBuffer.reset(); |
126 | 42.5k | } |
127 | | |
128 | | bool OFileTable::InsertRow(OValueRefVector& /*rRow*/, const css::uno::Reference< css::container::XIndexAccess>& /*_xCols*/) |
129 | 0 | { |
130 | 0 | return false; |
131 | 0 | } |
132 | | |
133 | | bool OFileTable::DeleteRow(const OSQLColumns& /*_rCols*/) |
134 | 0 | { |
135 | 0 | return false; |
136 | 0 | } |
137 | | |
138 | | bool OFileTable::UpdateRow(OValueRefVector& /*rRow*/, OValueRefRow& /*pOrgRow*/,const css::uno::Reference< css::container::XIndexAccess>& /*_xCols*/) |
139 | 0 | { |
140 | 0 | return false; |
141 | 0 | } |
142 | | |
143 | | void OFileTable::addColumn(const css::uno::Reference< css::beans::XPropertySet>& /*descriptor*/) |
144 | 0 | { |
145 | 0 | OSL_FAIL( "OFileTable::addColumn: not implemented!" ); |
146 | 0 | } |
147 | | |
148 | | void OFileTable::dropColumn(sal_Int32 /*_nPos*/) |
149 | 0 | { |
150 | 0 | OSL_FAIL( "OFileTable::addColumn: not implemented!" ); |
151 | 0 | } |
152 | | |
153 | | |
154 | | std::unique_ptr<SvStream> OFileTable::createStream_simpleError( const OUString& _rFileName, StreamMode _eOpenMode) |
155 | 42.3k | { |
156 | 42.3k | std::unique_ptr<SvStream> pReturn(::utl::UcbStreamHelper::CreateStream( _rFileName, _eOpenMode, bool(_eOpenMode & StreamMode::NOCREATE))); |
157 | 42.3k | if (pReturn && (ERRCODE_NONE != pReturn->GetErrorCode())) |
158 | 0 | { |
159 | 0 | pReturn.reset(); |
160 | 0 | } |
161 | 42.3k | return pReturn; |
162 | 42.3k | } |
163 | | |
164 | | |
165 | | void OFileTable::refreshHeader() |
166 | 0 | { |
167 | 0 | } |
168 | | |
169 | | |
170 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |