LibreOffice Module connectivity (master) 1
component/CTable.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 <component/CTable.hxx>
23
24using namespace connectivity;
25using namespace connectivity::component;
26using namespace connectivity::file;
27using namespace ::cppu;
28using namespace ::dbtools;
29using namespace ::com::sun::star::uno;
30using namespace ::com::sun::star::beans;
31using namespace ::com::sun::star::sdbcx;
32using namespace ::com::sun::star::sdbc;
33using namespace ::com::sun::star::container;
34using namespace ::com::sun::star::lang;
35using namespace ::com::sun::star::sheet;
36using namespace ::com::sun::star::util;
37
38
39OComponentTable::OComponentTable(sdbcx::OCollection* _pTables,file::OConnection* _pConnection,
40 const OUString& Name,
41 const OUString& Type,
42 const OUString& Description ,
43 const OUString& SchemaName,
44 const OUString& CatalogName
45 ) : OComponentTable_BASE(_pTables,_pConnection,Name,
46 Type,
47 Description,
48 SchemaName,
49 CatalogName)
50 ,m_nDataRows(0)
51{
52}
53
55{
56 ::osl::MutexGuard aGuard( m_aMutex );
57
58 ::std::vector< OUString> aVector;
59
60 for(const auto& rxColumn : *m_aColumns)
61 aVector.push_back(Reference< XNamed>(rxColumn,UNO_QUERY_THROW)->getName());
62
63 if(m_xColumns)
64 m_xColumns->reFill(aVector);
65 else
66 m_xColumns.reset(new component::OComponentColumns(this,m_aMutex,aVector));
67}
68
70{
71 // Writer or Calc table has no index
72}
73
74
76{
78 std::vector<Type> aOwnTypes;
79 aOwnTypes.reserve(aTypes.getLength());
80
81 const Type* pBegin = aTypes.getConstArray();
82 const Type* pEnd = pBegin + aTypes.getLength();
83 for(;pBegin != pEnd;++pBegin)
84 {
85 if(!( *pBegin == cppu::UnoType<XKeysSupplier>::get()||
87 *pBegin == cppu::UnoType<XRename>::get()||
90 aOwnTypes.push_back(*pBegin);
91 }
92 aOwnTypes.push_back(cppu::UnoType<css::lang::XUnoTunnel>::get());
93
94 return Sequence< Type >(aOwnTypes.data(), aOwnTypes.size());
95}
96
97
98Any SAL_CALL OComponentTable::queryInterface( const Type & rType )
99{
100 if( rType == cppu::UnoType<XKeysSupplier>::get()||
102 rType == cppu::UnoType<XRename>::get()||
105 return Any();
106
107 return OTable_TYPEDEF::queryInterface(rType);
108}
109
110
112{
113 return m_nDataRows;
114}
115
116bool OComponentTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
117{
118 // prepare positioning:
119
120 sal_uInt32 nNumberOfRecords = m_nDataRows;
121 sal_uInt32 nTempPos = m_nFilePos;
122 m_nFilePos = nCurPos;
123
124 switch(eCursorPosition)
125 {
127 m_nFilePos++;
128 break;
130 if (m_nFilePos > 0)
131 m_nFilePos--;
132 break;
134 m_nFilePos = 1;
135 break;
137 m_nFilePos = nNumberOfRecords;
138 break;
140 m_nFilePos = (m_nFilePos + nOffset < 0) ? 0
141 : static_cast<sal_uInt32>(m_nFilePos + nOffset);
142 break;
145 m_nFilePos = static_cast<sal_uInt32>(nOffset);
146 break;
147 }
148
149 if (m_nFilePos > static_cast<sal_Int32>(nNumberOfRecords))
150 m_nFilePos = static_cast<sal_Int32>(nNumberOfRecords) + 1;
151
152 if (m_nFilePos == 0 || m_nFilePos == static_cast<sal_Int32>(nNumberOfRecords) + 1)
153 {
154 switch(eCursorPosition)
155 {
158 m_nFilePos = 0;
159 break;
164 if (nOffset > 0)
165 m_nFilePos = nNumberOfRecords + 1;
166 else if (nOffset < 0)
167 m_nFilePos = 0;
168 break;
170 m_nFilePos = nTempPos; // previous position
171 break;
172 }
173 return false;
174 }
175
177 nCurPos = m_nFilePos;
178 return true;
179}
180
182{
183 ::osl::MutexGuard aGuard(m_aMutex);
184
186}
187
188
189/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Columns implementation for Writer tables and Calc sheets.
Definition: CColumns.hxx:28
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual sal_Int32 getCurrentLastPos() const override
virtual bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32 &nCurPos) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
OUString SAL_CALL getName() override
Definition: FTable.hxx:81
::rtl::Reference< OSQLColumns > m_aColumns
Definition: FTable.hxx:38
std::unique_ptr< OCollection > m_xColumns
Definition: VTable.hxx:77
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: VTable.cxx:124
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: VTable.cxx:109
mutable::osl::Mutex m_aMutex
Type
OUString Name
const SvXMLTokenMapEntry aTypes[]