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