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 .
22 #include "file/FTable.hxx"
23 #include "file/FColumns.hxx"
24 #include <com/sun/star/sdbc/XRow.hpp>
25 #include <com/sun/star/sdbc/XResultSet.hpp>
26 #include <cppuhelper/typeprovider.hxx>
27 #include <com/sun/star/lang/DisposedException.hpp>
28 #include <com/sun/star/sdbc/ColumnValue.hpp>
29 #include <unotools/ucbstreamhelper.hxx>
30 #include <tools/debug.hxx>
32 using namespace connectivity
;
33 using namespace connectivity::file
;
34 using namespace ::com::sun::star::uno
;
35 using namespace ::com::sun::star::beans
;
36 using namespace ::com::sun::star::sdbcx
;
37 using namespace ::com::sun::star::sdbc
;
38 using namespace ::com::sun::star::container
;
40 OFileTable::OFileTable(sdbcx::OCollection
* _pTables
,OConnection
* _pConnection
)
41 : OTable_TYPEDEF(_pTables
,_pConnection
->getMetaData()->supportsMixedCaseQuotedIdentifiers())
42 ,m_pConnection(_pConnection
)
50 m_aColumns
= new OSQLColumns();
53 OFileTable::OFileTable( sdbcx::OCollection
* _pTables
,OConnection
* _pConnection
,
54 const OUString
& _Name
,
55 const OUString
& _Type
,
56 const OUString
& _Description
,
57 const OUString
& _SchemaName
,
58 const OUString
& _CatalogName
)
59 : OTable_TYPEDEF(_pTables
,_pConnection
->getMetaData()->supportsMixedCaseQuotedIdentifiers(),
65 , m_pConnection(_pConnection
)
72 m_aColumns
= new OSQLColumns();
77 OFileTable::~OFileTable( )
81 void OFileTable::refreshColumns()
83 TStringVector aVector
;
84 Reference
< XResultSet
> xResult
= m_pConnection
->getMetaData()->getColumns(Any(),
85 m_SchemaName
,m_Name
, OUString("%"));
89 Reference
< XRow
> xRow(xResult
,UNO_QUERY
);
90 while(xResult
->next())
91 aVector
.push_back(xRow
->getString(4));
95 m_pColumns
->reFill(aVector
);
97 m_pColumns
= new OColumns(this,m_aMutex
,aVector
);
100 void OFileTable::refreshKeys()
104 void OFileTable::refreshIndexes()
108 Any SAL_CALL
OFileTable::queryInterface( const Type
& rType
) throw(RuntimeException
, std::exception
)
110 if( rType
== ::getCppuType((const Reference
<XKeysSupplier
>*)0) ||
111 rType
== ::getCppuType((const Reference
<XRename
>*)0) ||
112 rType
== ::getCppuType((const Reference
<XAlterTable
>*)0) ||
113 rType
== ::getCppuType((const Reference
<XIndexesSupplier
>*)0) ||
114 rType
== ::getCppuType((const Reference
<XDataDescriptorFactory
>*)0))
117 return OTable_TYPEDEF::queryInterface(rType
);
120 void SAL_CALL
OFileTable::disposing(void)
124 ::osl::MutexGuard
aGuard(m_aMutex
);
129 Sequence
< sal_Int8
> OFileTable::getUnoTunnelImplementationId()
131 static ::cppu::OImplementationId
* pId
= 0;
134 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
137 static ::cppu::OImplementationId aId
;
141 return pId
->getImplementationId();
144 // com::sun::star::lang::XUnoTunnel
146 sal_Int64
OFileTable::getSomething( const Sequence
< sal_Int8
> & rId
) throw (RuntimeException
, std::exception
)
148 return (rId
.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
149 ? reinterpret_cast< sal_Int64
>( this )
150 : OTable_TYPEDEF::getSomething(rId
);
153 void OFileTable::FileClose()
155 ::osl::MutexGuard
aGuard(m_aMutex
);
157 if (m_pFileStream
&& m_pFileStream
->IsWritable())
158 m_pFileStream
->Flush();
160 delete m_pFileStream
;
161 m_pFileStream
= NULL
;
170 void SAL_CALL
OFileTable::acquire() throw()
172 OTable_TYPEDEF::acquire();
175 void SAL_CALL
OFileTable::release() throw()
177 OTable_TYPEDEF::release();
180 bool OFileTable::InsertRow(OValueRefVector
& /*rRow*/, bool /*bFlush*/, const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& /*_xCols*/)
185 bool OFileTable::DeleteRow(const OSQLColumns
& /*_rCols*/)
190 bool OFileTable::UpdateRow(OValueRefVector
& /*rRow*/, OValueRefRow
& /*pOrgRow*/,const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& /*_xCols*/)
195 void OFileTable::addColumn(const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& /*descriptor*/)
197 OSL_FAIL( "OFileTable::addColumn: not implemented!" );
200 void OFileTable::dropColumn(sal_Int32
/*_nPos*/)
202 OSL_FAIL( "OFileTable::addColumn: not implemented!" );
206 SvStream
* OFileTable::createStream_simpleError( const OUString
& _rFileName
, StreamMode _eOpenMode
)
208 utl::UcbLockBytesHandler
* p_null_dummy
= NULL
;
209 SvStream
* pReturn
= ::utl::UcbStreamHelper::CreateStream( _rFileName
, _eOpenMode
, (_eOpenMode
& STREAM_NOCREATE
) == STREAM_NOCREATE
, p_null_dummy
);
210 if (pReturn
&& (ERRCODE_NONE
!= pReturn
->GetErrorCode()))
219 void OFileTable::refreshHeader()
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */