1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
)
44 m_aColumns
= new OSQLColumns();
47 OFileTable::OFileTable( sdbcx::OCollection
* _pTables
,OConnection
* _pConnection
,
50 const OUString
& Description
,
51 const OUString
& SchemaName
,
52 const OUString
& CatalogName
)
53 : OTable_TYPEDEF(_pTables
,_pConnection
->getMetaData()->supportsMixedCaseQuotedIdentifiers(),
59 , m_pConnection(_pConnection
)
64 m_aColumns
= new OSQLColumns();
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
);
81 Reference
< XRow
> xRow(xResult
,UNO_QUERY
);
82 while(xResult
->next())
83 aVector
.push_back(xRow
->getString(4));
87 m_xColumns
->reFill(aVector
);
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())
109 return OTable_TYPEDEF::queryInterface(rType
);
112 void SAL_CALL
OFileTable::disposing()
116 ::osl::MutexGuard
aGuard(m_aMutex
);
121 void OFileTable::FileClose()
123 ::osl::MutexGuard
aGuard(m_aMutex
);
125 m_pFileStream
.reset();
129 bool OFileTable::InsertRow(OValueRefVector
& /*rRow*/, const css::uno::Reference
< css::container::XIndexAccess
>& /*_xCols*/)
134 bool OFileTable::DeleteRow(const OSQLColumns
& /*_rCols*/)
139 bool OFileTable::UpdateRow(OValueRefVector
& /*rRow*/, OValueRefRow
& /*pOrgRow*/,const css::uno::Reference
< css::container::XIndexAccess
>& /*_xCols*/)
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()))
166 void OFileTable::refreshHeader()
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */