summaryrefslogtreecommitdiffstats
path: root/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /connectivity/source/drivers/macab/MacabResultSetMetaData.cxx
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'connectivity/source/drivers/macab/MacabResultSetMetaData.cxx')
-rw-r--r--connectivity/source/drivers/macab/MacabResultSetMetaData.cxx216
1 files changed, 216 insertions, 0 deletions
diff --git a/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx b/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx
new file mode 100644
index 000000000..e08d92cfc
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx
@@ -0,0 +1,216 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#include "MacabResultSetMetaData.hxx"
+#include "MacabHeader.hxx"
+#include "MacabRecords.hxx"
+#include "MacabAddressBook.hxx"
+#include "macabutilities.hxx"
+#include <connectivity/dbexception.hxx>
+#include <strings.hrc>
+
+using namespace connectivity::macab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+
+MacabResultSetMetaData::MacabResultSetMetaData(MacabConnection* _pConnection, OUString const & _sTableName)
+ : m_pConnection(_pConnection),
+ m_sTableName(_sTableName),
+ m_aMacabFields()
+{
+}
+
+MacabResultSetMetaData::~MacabResultSetMetaData()
+{
+}
+
+void MacabResultSetMetaData::setMacabFields(const ::rtl::Reference<connectivity::OSQLColumns> &xColumns)
+{
+ static constexpr OUStringLiteral aName = u"Name";
+ MacabRecords *aRecords;
+ MacabHeader *aHeader;
+
+ aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
+
+ // In case, somehow, we don't have anything with the name m_sTableName
+ if(aRecords == nullptr)
+ {
+ impl_throwError(STR_NO_TABLE);
+ }
+
+ aHeader = aRecords->getHeader();
+
+ for (const auto& rxColumn : *xColumns)
+ {
+ OUString aFieldName;
+ sal_uInt32 nFieldNumber;
+
+ rxColumn->getPropertyValue(aName) >>= aFieldName;
+ nFieldNumber = aHeader->getColumnNumber(aFieldName);
+ m_aMacabFields.push_back(nFieldNumber);
+ }
+
+}
+
+sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnDisplaySize(sal_Int32 /* column */)
+{
+ // For now, all columns are the same size.
+ return 50;
+}
+
+sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnType(sal_Int32 column)
+{
+ MacabRecords *aRecords;
+ MacabHeader *aHeader;
+ macabfield *aField;
+
+ aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
+
+ // In case, somehow, we don't have anything with the name m_sTableName
+ if(aRecords == nullptr)
+ {
+ impl_throwError(STR_NO_TABLE);
+ }
+
+ aHeader = aRecords->getHeader();
+ aField = aHeader->get(column-1);
+
+ if(aField == nullptr)
+ {
+ ::dbtools::throwInvalidIndexException(*this);
+ return -1;
+ }
+
+ return ABTypeToDataType(aField->type);
+}
+
+sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnCount()
+{
+ return m_aMacabFields.size();
+}
+
+sal_Bool SAL_CALL MacabResultSetMetaData::isCaseSensitive(sal_Int32)
+{
+ return true;
+}
+
+OUString SAL_CALL MacabResultSetMetaData::getSchemaName(sal_Int32)
+{
+ return OUString();
+}
+
+OUString SAL_CALL MacabResultSetMetaData::getColumnName(sal_Int32 column)
+{
+ sal_uInt32 nFieldNumber = m_aMacabFields[column - 1];
+ MacabRecords *aRecords;
+ MacabHeader *aHeader;
+
+ aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
+
+ // In case, somehow, we don't have anything with the name m_sTableName
+ if(aRecords == nullptr)
+ {
+ impl_throwError(STR_NO_TABLE);
+ }
+
+ aHeader = aRecords->getHeader();
+ OUString aName = aHeader->getString(nFieldNumber);
+
+ return aName;
+}
+
+OUString SAL_CALL MacabResultSetMetaData::getTableName(sal_Int32)
+{
+ return m_sTableName;
+}
+
+OUString SAL_CALL MacabResultSetMetaData::getCatalogName(sal_Int32)
+{
+ return OUString();
+}
+
+OUString SAL_CALL MacabResultSetMetaData::getColumnTypeName(sal_Int32)
+{
+ return OUString();
+}
+
+OUString SAL_CALL MacabResultSetMetaData::getColumnLabel(sal_Int32)
+{
+ return OUString();
+}
+
+OUString SAL_CALL MacabResultSetMetaData::getColumnServiceName(sal_Int32)
+{
+ return OUString();
+}
+
+sal_Bool SAL_CALL MacabResultSetMetaData::isCurrency(sal_Int32)
+{
+ return false;
+}
+
+sal_Bool SAL_CALL MacabResultSetMetaData::isAutoIncrement(sal_Int32)
+{
+ return false;
+}
+
+sal_Bool SAL_CALL MacabResultSetMetaData::isSigned(sal_Int32)
+{
+ return false;
+}
+
+sal_Int32 SAL_CALL MacabResultSetMetaData::getPrecision(sal_Int32)
+{
+ return 0;
+}
+
+sal_Int32 SAL_CALL MacabResultSetMetaData::getScale(sal_Int32)
+{
+ return 0;
+}
+
+sal_Int32 SAL_CALL MacabResultSetMetaData::isNullable(sal_Int32)
+{
+ return sal_Int32(true);
+}
+
+sal_Bool SAL_CALL MacabResultSetMetaData::isSearchable(sal_Int32)
+{
+ return true;
+}
+
+sal_Bool SAL_CALL MacabResultSetMetaData::isReadOnly(sal_Int32)
+{
+ return true;
+}
+
+sal_Bool SAL_CALL MacabResultSetMetaData::isDefinitelyWritable(sal_Int32)
+{
+ return false;
+}
+
+sal_Bool SAL_CALL MacabResultSetMetaData::isWritable(sal_Int32)
+{
+ return false;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */