update emoji autocorrect entries from po-files
[LibreOffice.git] / connectivity / source / drivers / file / FTable.cxx
blob0ef5189eeb957339ad1ad8b42f6b3e1c4e6107b4
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 <cppuhelper/typeprovider.hxx>
26 #include <com/sun/star/lang/DisposedException.hpp>
27 #include <com/sun/star/sdbc/ColumnValue.hpp>
28 #include <unotools/ucbstreamhelper.hxx>
30 using namespace connectivity;
31 using namespace connectivity::file;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::sdbcx;
35 using namespace ::com::sun::star::sdbc;
36 using namespace ::com::sun::star::container;
38 OFileTable::OFileTable(sdbcx::OCollection* _pTables,OConnection* _pConnection)
39 : OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers())
40 ,m_pConnection(_pConnection)
41 ,m_pFileStream(NULL)
42 ,m_nFilePos(0)
43 ,m_pBuffer(NULL)
44 ,m_nBufferSize(0)
45 ,m_bWriteable(false)
47 construct();
48 m_aColumns = new OSQLColumns();
51 OFileTable::OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection,
52 const OUString& _Name,
53 const OUString& _Type,
54 const OUString& _Description ,
55 const OUString& _SchemaName,
56 const OUString& _CatalogName )
57 : OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers(),
58 _Name,
59 _Type,
60 _Description,
61 _SchemaName,
62 _CatalogName)
63 , m_pConnection(_pConnection)
64 , m_pFileStream(NULL)
65 , m_nFilePos(0)
66 , m_pBuffer(NULL)
67 , m_nBufferSize(0)
68 , m_bWriteable(false)
70 m_aColumns = new OSQLColumns();
71 construct();
72 // refreshColumns();
75 OFileTable::~OFileTable( )
79 void OFileTable::refreshColumns()
81 TStringVector aVector;
82 Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(Any(),
83 m_SchemaName,m_Name, OUString("%"));
85 if(xResult.is())
87 Reference< XRow > xRow(xResult,UNO_QUERY);
88 while(xResult->next())
89 aVector.push_back(xRow->getString(4));
92 if(m_pColumns)
93 m_pColumns->reFill(aVector);
94 else
95 m_pColumns = new OColumns(this,m_aMutex,aVector);
98 void OFileTable::refreshKeys()
102 void OFileTable::refreshIndexes()
106 Any SAL_CALL OFileTable::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
108 if( rType == cppu::UnoType<XKeysSupplier>::get()||
109 rType == cppu::UnoType<XRename>::get()||
110 rType == cppu::UnoType<XAlterTable>::get()||
111 rType == cppu::UnoType<XIndexesSupplier>::get()||
112 rType == cppu::UnoType<XDataDescriptorFactory>::get())
113 return Any();
115 return OTable_TYPEDEF::queryInterface(rType);
118 void SAL_CALL OFileTable::disposing()
120 OTable::disposing();
122 ::osl::MutexGuard aGuard(m_aMutex);
124 FileClose();
127 Sequence< sal_Int8 > OFileTable::getUnoTunnelImplementationId()
129 static ::cppu::OImplementationId * pId = 0;
130 if (! pId)
132 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
133 if (! pId)
135 static ::cppu::OImplementationId aId;
136 pId = &aId;
139 return pId->getImplementationId();
142 // com::sun::star::lang::XUnoTunnel
144 sal_Int64 OFileTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException, std::exception)
146 return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
147 ? reinterpret_cast< sal_Int64 >( this )
148 : OTable_TYPEDEF::getSomething(rId);
151 void OFileTable::FileClose()
153 ::osl::MutexGuard aGuard(m_aMutex);
155 if (m_pFileStream && m_pFileStream->IsWritable())
156 m_pFileStream->Flush();
158 delete m_pFileStream;
159 m_pFileStream = NULL;
161 if (m_pBuffer)
163 delete[] m_pBuffer;
164 m_pBuffer = NULL;
168 void SAL_CALL OFileTable::acquire() throw()
170 OTable_TYPEDEF::acquire();
173 void SAL_CALL OFileTable::release() throw()
175 OTable_TYPEDEF::release();
178 bool OFileTable::InsertRow(OValueRefVector& /*rRow*/, bool /*bFlush*/, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& /*_xCols*/)
180 return false;
183 bool OFileTable::DeleteRow(const OSQLColumns& /*_rCols*/)
185 return false;
188 bool OFileTable::UpdateRow(OValueRefVector& /*rRow*/, OValueRefRow& /*pOrgRow*/,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& /*_xCols*/)
190 return false;
193 void OFileTable::addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& /*descriptor*/)
195 OSL_FAIL( "OFileTable::addColumn: not implemented!" );
198 void OFileTable::dropColumn(sal_Int32 /*_nPos*/)
200 OSL_FAIL( "OFileTable::addColumn: not implemented!" );
204 SvStream* OFileTable::createStream_simpleError( const OUString& _rFileName, StreamMode _eOpenMode)
206 SvStream* pReturn = ::utl::UcbStreamHelper::CreateStream( _rFileName, _eOpenMode, bool(_eOpenMode & StreamMode::NOCREATE));
207 if (pReturn && (ERRCODE_NONE != pReturn->GetErrorCode()))
209 delete pReturn;
210 pReturn = NULL;
212 return pReturn;
216 void OFileTable::refreshHeader()
221 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */