24#include <core_resource.hxx>
26#include <osl/diagnose.h>
31#include <com/sun/star/sdbc/SQLException.hpp>
32#include <com/sun/star/sdbc/XConnection.hpp>
33#include <com/sun/star/beans/PropertyAttribute.hpp>
49using namespace ::
cppu;
53ODBTableDecorator::ODBTableDecorator(
const Reference< XConnection >& _rxConnection,
const Reference< XColumnsSupplier >& _rxNewTable,
54 const Reference< XNumberFormatsSupplier >& _rxNumberFormats,
const Reference< XNameAccess >& _xColumnDefinitions )
57 ,m_xTable(_rxNewTable)
58 ,m_xColumnDefinitions(_xColumnDefinitions)
60 ,m_xMetaData( _rxConnection.is() ? _rxConnection->getMetaData() :
Reference< XDatabaseMetaData >() )
61 ,m_xNumberFormats( _rxNumberFormats )
73 return css::uno::Sequence<sal_Int8>();
80 OTableDescriptor_BASE::disposing();
93 Any & rConvertedValue,
147 SAL_WARN(
"dbaccess",
"Property is readonly!");
180 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
186 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
192 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
198 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
204 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
220 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
221 Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
260 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
266 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
272 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
278 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
284 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
289 SAL_WARN(
"dbaccess",
"Invalid Handle for table");
295 bool bNotFound =
true;
296 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
299 Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
309 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
310 Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
312 Sequence< Property > aTableProps = xInfo->getProperties();
313 for (
Property & prop : asNonConstRange(aTableProps))
331 return new ::cppu::OPropertyArrayHelper(aTableProps);
336 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
338 Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
339 bool bIsDescriptor = (xInfo->getPropertyByName(
PROPERTY_NAME).Attributes & PropertyAttribute::READONLY) == 0;
353OUString SAL_CALL ODBTableDecorator::getImplementationName()
355 return "com.sun.star.sdb.dbaccess.ODBTableDecorator";
357sal_Bool SAL_CALL ODBTableDecorator::supportsService(
const OUString& _rServiceName)
360 for (
const OUString& s : aSupported)
361 if (s == _rServiceName)
366css::uno::Sequence< OUString > SAL_CALL ODBTableDecorator::getSupportedServiceNames()
377 aRet =
m_xTable->queryInterface(rType);
380 aRet = OTableDescriptor_BASE::queryInterface(rType);
391 Reference<XTypeProvider> xTypes(
m_xTable,UNO_QUERY);
392 OSL_ENSURE(xTypes.is(),
"Table must be a TypeProvider!");
393 return xTypes->getTypes();
400 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
401 Reference<XRename> xRename(
m_xTable,UNO_QUERY);
405 xRename->rename(_rNewName);
412 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
413 Reference<XAlterTable> xAlter(
m_xTable,UNO_QUERY);
416 xAlter->alterColumnByName(_rName,_rxDescriptor);
424 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
425 Reference<XAlterTable> xAlter(
m_xTable,UNO_QUERY);
429 xAlter->alterColumnByIndex(_nIndex,_rxDescriptor);
437 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
438 return Reference< XIndexesSupplier>(
m_xTable,UNO_QUERY_THROW)->getIndexes();
444 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
445 return Reference< XKeysSupplier>(
m_xTable,UNO_QUERY_THROW)->getKeys();
451 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
462 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
463 Reference<XNamed> xName(
m_xTable,UNO_QUERY);
464 OSL_ENSURE(xName.is(),
"Table should support the XNamed interface");
465 return xName->getName();
470 if (comphelper::isUnoTunnelId<ODBTableDecorator>(rId))
474 Reference<XUnoTunnel> xTunnel(
m_xTable,UNO_QUERY);
476 nRet = xTunnel->getSomething(rId);
492 Reference<XPropertySet> xProp(
m_xTable,UNO_QUERY);
509 catch(
const SQLException&)
511 SAL_WARN(
"dbaccess",
"ODBTableDecorator::ODBTableDecorator : could not collect the privileges !");
518 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
521 OSL_ENSURE(
xFactory.is(),
"ODBTableDecorator::createDataDescriptor: invalid table!" );
522 Reference< XColumnsSupplier > xColsSupp;
524 xColsSupp.set(
xFactory->createDataDescriptor(), css::uno::UNO_QUERY);
536 return ::cppu::OPropertySetHelper::createPropertySetInfo(
getInfoHelper());
542 ::connectivity::checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
544 std::vector< OUString> aVector;
546 Reference<XNameAccess> xNames;
552 const Sequence< OUString> aNames = xNames->getElementNames();
553 aVector.insert(aVector.end(), aNames.begin(), aNames.end());
577 Reference<XNameAccess> xNames;
582 if ( xNames.is() && xNames->hasByName(_rName) )
584 Reference<XPropertySet> xProp(xNames->getByName(_rName),UNO_QUERY);
586 Reference<XPropertySet> xColumnDefinition;
605 xDrop->dropByName(_sName);
610 Reference<XDataDescriptorFactory> xNames;
612 xNames.set(
m_xTable->getColumns(),UNO_QUERY);
613 Reference< XPropertySet > xRet;
621 OTableDescriptor_BASE::acquire();
626 OTableDescriptor_BASE::release();
::cppu::IPropertyArrayHelper * getArrayHelper(sal_Int32 nId)
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
void registerProperty(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
void disposing(std::unique_lock< std::mutex > &rGuard)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
const css::uno::Sequence< sal_Int8 > & getSeq() const
mutable::osl::Mutex m_aMutex
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
void setMediator(OContainerMediator *_pMediator)
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual ::cppu::IPropertyArrayHelper * createArrayHelper(sal_Int32 _nId) const override
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getIndexes() override
virtual void SAL_CALL setName(const OUString &aName) override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual void SAL_CALL release() noexcept override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
virtual css::uno::Reference< css::beans::XPropertySet > createColumnDescriptor() override
creates a column descriptor object.
css::uno::Reference< css::sdbc::XConnection > m_xConnection
virtual void refreshColumns() override
virtual void SAL_CALL rename(const OUString &_rNewName) override
virtual OUString SAL_CALL getName() override
virtual void SAL_CALL disposing() override
css::uno::Reference< css::util::XNumberFormatsSupplier > m_xNumberFormats
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
css::uno::Reference< css::container::XContainerListener > m_xColumnMediator
virtual ~ODBTableDecorator() override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns() override
css::uno::Reference< css::container::XNameAccess > m_xColumnDefinitions
ODBTableDecorator(const css::uno::Reference< css::sdbc::XConnection > &_rxConn, const css::uno::Reference< css::sdbcx::XColumnsSupplier > &_rxTable, const css::uno::Reference< css::util::XNumberFormatsSupplier > &_rxNumberFormats, const css::uno::Reference< css::container::XNameAccess > &_rxColumnDefinitions)
constructs a wrapper supporting the com.sun.star.sdb.Table service.
std::unique_ptr<::connectivity::sdbcx::OCollection > m_pColumns
virtual rtl::Reference< OColumn > createColumn(const OUString &_rName) const override
creates an OColumn object which should represent the column with a given name
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual void SAL_CALL alterColumnByIndex(sal_Int32 _nIndex, const css::uno::Reference< css::beans::XPropertySet > &_rxDescriptor) override
virtual void SAL_CALL alterColumnByName(const OUString &_rName, const css::uno::Reference< css::beans::XPropertySet > &_rxDescriptor) override
css::uno::Reference< css::sdbcx::XColumnsSupplier > m_xTable
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor() override
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
virtual void columnAppended(const css::uno::Reference< css::beans::XPropertySet > &_rxSourceDescriptor) override
notifies that a column, created from a column descriptor, has been appended
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData
virtual void columnDropped(const OUString &_sName) override
notifies that a column with a given name has been dropped
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getKeys() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
void fillPrivileges() const
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
void registerPropertiesFor(ODataSettings_Base *_pItem)
register the properties from the param given.
provides the properties for description.
describes all properties for a columns of a table.
Reference< XSingleServiceFactory > xFactory
#define SAL_WARN(area, stream)
sal_Int64 getSomething_cast(void *p)
css::uno::Sequence< OUString > getSupportedServiceNames()
::cppu::WeakComponentImplHelper< css::sdbcx::XColumnsSupplier, css::sdbcx::XKeysSupplier, css::container::XNamed, css::lang::XServiceInfo, css::sdbcx::XDataDescriptorFactory, css::sdbcx::XIndexesSupplier, css::sdbcx::XRename, css::lang::XUnoTunnel, css::sdbcx::XAlterTable > OTableDescriptor_BASE
Reference< XConnection > m_xConnection
#define PROPERTY_ID_FONTFAMILY
#define PROPERTY_ID_TEXTEMPHASIS
#define PROPERTY_ID_TEXTRELIEF
#define PROPERTY_ID_DESCRIPTION
#define PROPERTY_ID_PRIVILEGES
#define PROPERTY_ID_AUTOGROW
#define PROPERTY_ID_CATALOGNAME
#define PROPERTY_ID_FONTWORDLINEMODE
#define PROPERTY_ID_FILTER
#define PROPERTY_ID_FONTHEIGHT
#define PROPERTY_ID_FONTSLANT
#define PROPERTY_ID_FONTSTYLENAME
#define PROPERTY_ID_FONTSTRIKEOUT
#define PROPERTY_ID_FONTUNDERLINE
#define PROPERTY_ID_FONTWIDTH
#define PROPERTY_ID_FONTWEIGHT
#define PROPERTY_ID_SCHEMANAME
#define PROPERTY_ID_FONTNAME
#define PROPERTY_ID_ORDER
#define PROPERTY_ID_FONTTYPE
#define PROPERTY_ID_FONTCHARWIDTH
#define PROPERTY_ID_TEXTLINECOLOR
#define PROPERTY_ID_TEXTCOLOR
#define PROPERTY_ID_FONTKERNING
#define PROPERTY_ID_FONTORIENTATION
#define PROPERTY_ID_ROW_HEIGHT
#define PROPERTY_ID_FONTPITCH
#define PROPERTY_ID_APPLYFILTER
#define PROPERTY_ID_FONTCHARSET
constexpr OUStringLiteral PROPERTY_SCHEMANAME(u"SchemaName")
constexpr OUStringLiteral PROPERTY_DESCRIPTION(u"Description")
constexpr OUStringLiteral SQLSTATE_GENERAL
constexpr OUStringLiteral PROPERTY_CATALOGNAME(u"CatalogName")
constexpr OUStringLiteral PROPERTY_TYPE(u"Type")
constexpr OUStringLiteral PROPERTY_NAME(u"Name")
constexpr OUStringLiteral SERVICE_SDBCX_TABLE
constexpr OUStringLiteral PROPERTY_PRIVILEGES(u"Privileges")