LibreOffice Module connectivity (master) 1
EConnection.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#include <flat/EConnection.hxx>
22#include <flat/ECatalog.hxx>
23#include <flat/EDriver.hxx>
25#include <flat/EStatement.hxx>
27#include <sal/log.hxx>
28
29using namespace connectivity::flat;
30using namespace connectivity::file;
31
33
34
35using namespace ::com::sun::star::uno;
36using namespace ::com::sun::star::beans;
37using namespace ::com::sun::star::sdbcx;
38using namespace ::com::sun::star::sdbc;
39using namespace ::com::sun::star::lang;
40
41
42OFlatConnection::OFlatConnection(ODriver* _pDriver) : OConnection(_pDriver)
43 ,m_nMaxRowsToScan(50)
44 ,m_bHeaderLine(true)
45 ,m_cFieldDelimiter(';')
46 ,m_cStringDelimiter('"')
47 ,m_cDecimalDelimiter(',')
48 ,m_cThousandDelimiter('.')
49{
50}
51
52OFlatConnection::~OFlatConnection()
53{
54}
55
56// XServiceInfo
57
58IMPLEMENT_SERVICE_INFO(OFlatConnection, "com.sun.star.sdbc.drivers.flat.Connection", "com.sun.star.sdbc.Connection")
59
60
61void OFlatConnection::construct(const OUString& url,const Sequence< PropertyValue >& info)
62{
63 osl_atomic_increment( &m_refCount );
64
65 const PropertyValue *pBegin = info.getConstArray();
66 const PropertyValue *pEnd = pBegin + info.getLength();
67 for(;pBegin != pEnd;++pBegin)
68 {
69 if(pBegin->Name == "HeaderLine")
70 {
71 if( ! (pBegin->Value >>= m_bHeaderLine) )
72 SAL_WARN("connectivity.flat", "construct: unable to get property HeaderLine");
73 }
74 else if(pBegin->Name == "FieldDelimiter")
75 {
76 OUString aVal;
77 if( ! (pBegin->Value >>= aVal) )
78 SAL_WARN("connectivity.flat", "construct: unable to get property FieldDelimiter");
79
80 m_cFieldDelimiter = aVal.toChar();
81 }
82 else if(pBegin->Name == "StringDelimiter")
83 {
84 OUString aVal;
85 if( ! (pBegin->Value >>= aVal) )
86 SAL_WARN("connectivity.flat", "construct: unable to get property StringDelimiter");
87
88 m_cStringDelimiter = aVal.toChar();
89 }
90 else if(pBegin->Name == "DecimalDelimiter")
91 {
92 OUString aVal;
93 if( ! (pBegin->Value >>= aVal) )
94 SAL_WARN("connectivity.flat", "construct: unable to get property DecimalDelimiter");
95
96 m_cDecimalDelimiter = aVal.toChar();
97 }
98 else if(pBegin->Name == "ThousandDelimiter")
99 {
100 OUString aVal;
101 if( ! (pBegin->Value >>= aVal) )
102 SAL_WARN("connectivity.flat", "construct: unable to get property ThousandDelimiter");
103
104 m_cThousandDelimiter = aVal.toChar();
105 }
106 else if ( pBegin->Name == "MaxRowScan" )
107 {
108 pBegin->Value >>= m_nMaxRowsToScan;
109 }
110 }
111
112 osl_atomic_decrement( &m_refCount );
113 OConnection::construct(url,info);
114 m_bShowDeleted = true; // we do not supported rows for this type
115}
116
118{
119 ::osl::MutexGuard aGuard( m_aMutex );
120 checkDisposed(OConnection_B::rBHelper.bDisposed);
121
122
124 if(!xMetaData.is())
125 {
126 xMetaData = new OFlatDatabaseMetaData(this);
127 m_xMetaData = xMetaData;
128 }
129
130 return xMetaData;
131}
132
133css::uno::Reference< XTablesSupplier > OFlatConnection::createCatalog()
134{
135 ::osl::MutexGuard aGuard( m_aMutex );
137 if(!xTab.is())
138 {
139 xTab = new OFlatCatalog(this);
140 m_xCatalog = xTab;
141 }
142 return xTab;
143}
144
146{
147 ::osl::MutexGuard aGuard( m_aMutex );
148 checkDisposed(OConnection_B::rBHelper.bDisposed);
149
151 m_aStatements.push_back(WeakReferenceHelper(*pStmt));
152 return pStmt;
153}
154
156{
157 ::osl::MutexGuard aGuard( m_aMutex );
158 checkDisposed(OConnection_B::rBHelper.bDisposed);
159
161 pStmt->construct(sql);
162 m_aStatements.push_back(WeakReferenceHelper(*pStmt));
163 return pStmt;
164}
165
166Reference< XPreparedStatement > SAL_CALL OFlatConnection::prepareCall( const OUString& /*sql*/ )
167{
168 ::osl::MutexGuard aGuard( m_aMutex );
169 checkDisposed(OConnection_B::rBHelper.bDisposed);
170
171 ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::prepareCall", *this );
172 return nullptr;
173}
174
175
176/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define IMPLEMENT_SERVICE_INFO(classname, implasciiname, serviceasciiname)
connectivity::file::OConnection OConnection_B
Definition: EConnection.cxx:32
connectivity::OWeakRefArray m_aStatements
Definition: TConnection.hxx:47
css::uno::WeakReference< css::sdbc::XDatabaseMetaData > m_xMetaData
Definition: TConnection.hxx:53
css::uno::WeakReference< css::sdbcx::XTablesSupplier > m_xCatalog
Definition: FConnection.hxx:41
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() override
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall(const OUString &sql) override
virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement() override
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement(const OUString &sql) override
virtual css::uno::Reference< css::sdbcx::XTablesSupplier > createCatalog() override
#define SAL_WARN(area, stream)
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
void throwFeatureNotImplementedSQLException(const OUString &_rFeatureName, const Reference< XInterface > &_rxContext, const Any &_rNextException)