21#include <com/sun/star/sdbc/ColumnValue.hpp>
22#include <com/sun/star/sdbc/DataType.hpp>
23#include <com/sun/star/sdbc/SQLException.hpp>
24#include <com/sun/star/text/XTextDocument.hpp>
25#include <com/sun/star/text/XTextTable.hpp>
26#include <com/sun/star/text/XTextTablesSupplier.hpp>
27#include <com/sun/star/table/XCellRange.hpp>
28#include <com/sun/star/text/XText.hpp>
29#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
41static void lcl_GetDataArea(
const uno::Reference<text::XTextTable>& xTable, sal_Int32& rColumnCount,
44 uno::Reference<container::XIndexAccess> xColumns = xTable->getColumns();
46 rColumnCount = xColumns->getCount();
48 uno::Reference<container::XIndexAccess> xRows = xTable->getRows();
50 rRowCount = xRows->getCount() - 1;
53static void lcl_GetColumnInfo(
const uno::Reference<text::XTextTable>& xTable, sal_Int32 nDocColumn,
54 bool bHasHeaders, OUString& rName, sal_Int32& rDataType,
57 uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY);
61 uno::Reference<text::XText> xHeaderText(
62 xCellRange->getCellByPosition(nDocColumn, 0), uno::UNO_QUERY);
64 rName = xHeaderText->getString();
68 rDataType = sdbc::DataType::VARCHAR;
72 const uno::Reference<text::XTextTable>& xTable, sal_Int32 nStartCol,
73 bool bHasHeaders, sal_Int32 nDBRow, sal_Int32 nDBColumn)
75 sal_Int32 nDocColumn = nStartCol + nDBColumn - 1;
76 sal_Int32 nDocRow = nDBRow - 1;
80 uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY);
81 uno::Reference<table::XCell> xCell;
84 xCell = xCellRange->getCellByPosition(nDocColumn, nDocRow);
86 catch (
const lang::IndexOutOfBoundsException& )
89 "getCellByPosition(" << nDocColumn <<
", " << nDocRow <<
") failed");
95 const uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
106 throw sdbc::SQLException();
111 const bool bStoresMixedCaseQuotedIdentifiers
116 OUString aColumnName;
117 sal_Int32
eType = sdbc::DataType::OTHER;
118 bool bCurrency =
false;
122 sal_Int32 nPrecision = 0;
123 sal_Int32 nDecimals = 0;
127 case sdbc::DataType::VARCHAR:
128 aTypeName =
"VARCHAR";
130 case sdbc::DataType::DECIMAL:
131 aTypeName =
"DECIMAL";
133 case sdbc::DataType::BIT:
136 case sdbc::DataType::DATE:
139 case sdbc::DataType::TIME:
142 case sdbc::DataType::TIMESTAMP:
143 aTypeName =
"TIMESTAMP";
146 SAL_WARN(
"connectivity.writer",
"missing type name");
151 OUString aAlias = aColumnName;
153 sal_Int32 nExprCnt = 0;
156 aAlias = aColumnName + OUString::number(++nExprCnt);
161 aAlias, aTypeName, OUString(), OUString(), sdbc::ColumnValue::NULLABLE, nPrecision,
162 nDecimals,
eType,
false,
false, bCurrency, bStoresMixedCaseQuotedIdentifiers,
169 const OUString& Name,
const OUString&
Type)
171 OUString() , OUString() )
172 , m_pWriterConnection(_pConnection)
181 uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(xDoc, uno::UNO_QUERY);
182 uno::Reference<container::XNameAccess> xTables = xTextTablesSupplier->getTextTables();
183 if (xTables.is() && xTables->hasByName(
m_Name))
201 OFileTable::disposing();
213 _rRow->setDeleted(
false);
221 const OValueRefVector::size_type
nCount = std::min(_rRow->size(), _rCols.size() + 1);
222 for (OValueRefVector::size_type
i = 1;
i <
nCount;
i++)
224 if ((*_rRow)[
i]->isBound())
static void lcl_GetDataArea(const uno::Reference< text::XTextTable > &xTable, sal_Int32 &rColumnCount, sal_Int32 &rRowCount)
static void lcl_SetValue(connectivity::ORowSetValue &rValue, const uno::Reference< text::XTextTable > &xTable, sal_Int32 nStartCol, bool bHasHeaders, sal_Int32 nDBRow, sal_Int32 nDBColumn)
static void lcl_GetColumnInfo(const uno::Reference< text::XTextTable > &xTable, sal_Int32 nDocColumn, bool bHasHeaders, OUString &rName, sal_Int32 &rDataType, bool &rCurrency)
OUString getString() const
Shared Table base class for Writer tables and Calc sheets.
virtual void refreshColumns() override
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() override
OConnection * m_pConnection
const OUString & getSchema() const
OUString SAL_CALL getName() override
::rtl::Reference< OSQLColumns > m_aColumns
OConnection * getConnection() const
css::uno::Reference< css::text::XTextDocument > const & acquireDoc()
bool fetchRow(OValueRefRow &_rRow, const OSQLColumns &_rCols, bool bRetrieveData) override
css::uno::Reference< css::text::XTextTable > m_xTable
OWriterConnection * m_pWriterConnection
OWriterTable(sdbcx::OCollection *_pTables, OWriterConnection *_pConnection, const OUString &Name, const OUString &Type)
void SAL_CALL disposing() override
void construct() override
mutable::osl::Mutex m_aMutex
#define SAL_WARN(area, stream)
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)