summaryrefslogtreecommitdiffstats
path: root/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx
parentInitial commit. (diff)
downloadlibreoffice-upstream/1%7.0.4.tar.xz
libreoffice-upstream/1%7.0.4.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx')
-rw-r--r--connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx222
1 files changed, 222 insertions, 0 deletions
diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx
new file mode 100644
index 000000000..9a4365abf
--- /dev/null
+++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx
@@ -0,0 +1,222 @@
+/* -*- 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 <ado/ADatabaseMetaDataResultSetMetaData.hxx>
+#include <ado/Awrapado.hxx>
+#include <connectivity/dbexception.hxx>
+
+
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+
+ODatabaseMetaDataResultSetMetaData::~ODatabaseMetaDataResultSetMetaData()
+{
+ if(m_pRecordSet)
+ m_pRecordSet->Release();
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
+{
+ sal_Int32 nSize = 0;
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ nSize = (*m_mColumnsIter).second.getColumnDisplaySize();
+ else if(m_pRecordSet)
+ {
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ nSize = aField.GetActualSize();
+ }
+ return nSize;
+}
+
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnType( sal_Int32 column )
+{
+ sal_Int32 nType = 0;
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ nType = (*m_mColumnsIter).second.getColumnType();
+ else if(m_pRecordSet)
+ {
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ nType = ADOS::MapADOType2Jdbc(aField.GetADOType());
+ }
+ return nType;
+}
+
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnCount( )
+{
+ if(!m_pRecordSet)
+ return 0;
+ if(m_nColCount != -1)
+ return m_nColCount;
+
+ if(m_vMapping.size())
+ return m_mColumns.size();
+
+ ADOFields* pFields = nullptr;
+ m_pRecordSet->get_Fields(&pFields);
+ WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields);
+ m_nColCount = aFields.GetItemCount();
+ return m_nColCount;
+}
+
+
+OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnName( sal_Int32 column )
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getColumnName();
+ if(!m_pRecordSet)
+ return OUString();
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ return aField.GetName();
+
+ return OUString();
+}
+
+OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnLabel( sal_Int32 column )
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getColumnLabel();
+ return getColumnName(column);
+}
+
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCurrency( sal_Int32 column )
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isCurrency();
+ if(!m_pRecordSet)
+ return false;
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ {
+ return (aField.GetAttributes() & adFldFixed) == adFldFixed;
+ }
+ return false;
+}
+
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSigned( sal_Int32 column )
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isSigned();
+ if(!m_pRecordSet)
+ return false;
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ {
+ return (aField.GetAttributes() & adFldNegativeScale) == adFldNegativeScale;
+ }
+ return false;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getPrecision( sal_Int32 column )
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getPrecision();
+ if(!m_pRecordSet)
+ return 0;
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ return aField.GetPrecision();
+ return 0;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getScale( sal_Int32 column )
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getScale();
+
+ if(!m_pRecordSet)
+ return 0;
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ return aField.GetNumericScale();
+ return 0;
+}
+
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::isNullable( sal_Int32 column )
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isNullable();
+
+ if(!m_pRecordSet)
+ return sal_Int32(false);
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ {
+ return sal_Int32((aField.GetAttributes() & adFldIsNullable) == adFldIsNullable);
+ }
+ return sal_Int32(false);
+}
+
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isReadOnly( sal_Int32 column )
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isReadOnly();
+
+ if(!m_pRecordSet)
+ return false;
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ {
+ // return (aField.GetStatus() & adFieldReadOnly) == adFieldReadOnly;
+ }
+ return false;
+}
+
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isDefinitelyWritable();
+
+ if(!m_pRecordSet)
+ return false;
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ {
+ return (aField.GetAttributes() & adFldUpdatable) == adFldUpdatable;
+ }
+ return false;
+;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isWritable( sal_Int32 column )
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isWritable();
+ return isDefinitelyWritable(column);
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */