cid#1636677 Uninitialized scalar field
[LibreOffice.git] / connectivity / source / drivers / file / FTable.cxx
blob120af8a61a1142f148979d866f5d2143f253ff7f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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 <comphelper/servicehelper.hxx>
26 #include <unotools/ucbstreamhelper.hxx>
28 using namespace connectivity;
29 using namespace connectivity::file;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::beans;
32 using namespace ::com::sun::star::sdbcx;
33 using namespace ::com::sun::star::sdbc;
34 using namespace ::com::sun::star::container;
36 OFileTable::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)
43 construct();
44 m_aColumns = new OSQLColumns();
47 OFileTable::OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection,
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)
64 m_aColumns = new OSQLColumns();
65 construct();
66 // refreshColumns();
69 OFileTable::~OFileTable( )
73 void OFileTable::refreshColumns()
75 ::std::vector< OUString> aVector;
76 Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(Any(),
77 m_SchemaName,m_Name, u"%"_ustr);
79 if(xResult.is())
81 Reference< XRow > xRow(xResult,UNO_QUERY);
82 while(xResult->next())
83 aVector.push_back(xRow->getString(4));
86 if(m_xColumns)
87 m_xColumns->reFill(aVector);
88 else
89 m_xColumns.reset(new OColumns(this,m_aMutex,aVector));
92 void OFileTable::refreshKeys()
96 void OFileTable::refreshIndexes()
100 Any SAL_CALL OFileTable::queryInterface( const Type & rType )
102 if( rType == cppu::UnoType<XKeysSupplier>::get()||
103 rType == cppu::UnoType<XRename>::get()||
104 rType == cppu::UnoType<XAlterTable>::get()||
105 rType == cppu::UnoType<XIndexesSupplier>::get()||
106 rType == cppu::UnoType<XDataDescriptorFactory>::get())
107 return Any();
109 return OTable_TYPEDEF::queryInterface(rType);
112 void SAL_CALL OFileTable::disposing()
114 OTable::disposing();
116 ::osl::MutexGuard aGuard(m_aMutex);
118 FileClose();
121 void OFileTable::FileClose()
123 ::osl::MutexGuard aGuard(m_aMutex);
125 m_pFileStream.reset();
126 m_pBuffer.reset();
129 bool OFileTable::InsertRow(OValueRefVector& /*rRow*/, const css::uno::Reference< css::container::XIndexAccess>& /*_xCols*/)
131 return false;
134 bool OFileTable::DeleteRow(const OSQLColumns& /*_rCols*/)
136 return false;
139 bool OFileTable::UpdateRow(OValueRefVector& /*rRow*/, OValueRefRow& /*pOrgRow*/,const css::uno::Reference< css::container::XIndexAccess>& /*_xCols*/)
141 return false;
144 void OFileTable::addColumn(const css::uno::Reference< css::beans::XPropertySet>& /*descriptor*/)
146 OSL_FAIL( "OFileTable::addColumn: not implemented!" );
149 void OFileTable::dropColumn(sal_Int32 /*_nPos*/)
151 OSL_FAIL( "OFileTable::addColumn: not implemented!" );
155 std::unique_ptr<SvStream> OFileTable::createStream_simpleError( const OUString& _rFileName, StreamMode _eOpenMode)
157 std::unique_ptr<SvStream> pReturn(::utl::UcbStreamHelper::CreateStream( _rFileName, _eOpenMode, bool(_eOpenMode & StreamMode::NOCREATE)));
158 if (pReturn && (ERRCODE_NONE != pReturn->GetErrorCode()))
160 pReturn.reset();
162 return pReturn;
166 void OFileTable::refreshHeader()
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */