21#include <core_resource.hxx>
25#include <com/sun/star/sdb/tools/CompositionType.hpp>
26#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
34 using ::com::sun::star::uno::Reference;
35 using ::com::sun::star::sdbc::XConnection;
36 using ::com::sun::star::uno::RuntimeException;
37 using ::com::sun::star::lang::IllegalArgumentException;
38 using ::com::sun::star::beans::XPropertySet;
39 using ::com::sun::star::container::NoSuchElementException;
40 using ::com::sun::star::sdbcx::XTablesSupplier;
41 using ::com::sun::star::container::XNameAccess;
42 using ::com::sun::star::uno::UNO_QUERY_THROW;
43 using ::com::sun::star::lang::WrappedTargetException;
44 using ::com::sun::star::uno::Exception;
45 using ::com::sun::star::uno::UNO_QUERY;
46 using ::com::sun::star::beans::XPropertySetInfo;
47 using ::com::sun::star::uno::XComponentContext;
49 namespace CompositionType = ::com::sun::star::sdb::tools::CompositionType;
54 TableName::TableName(
const Reference<XComponentContext>& _rContext,
const Reference< XConnection >& _rxConnection )
55 :ConnectionDependentComponent( _rContext )
57 setWeakConnection( _rxConnection );
60 TableName::~TableName()
64 OUString SAL_CALL TableName::getCatalogName()
70 void SAL_CALL TableName::setCatalogName(
const OUString& _catalogName )
73 msCatalog = _catalogName;
76 OUString SAL_CALL TableName::getSchemaName()
82 void SAL_CALL TableName::setSchemaName(
const OUString& _schemaName )
85 msSchema = _schemaName;
88 OUString SAL_CALL TableName::getTableName()
94 void SAL_CALL TableName::setTableName(
const OUString& _tableName )
100 OUString SAL_CALL TableName::getNameForSelect()
106 Reference< XPropertySet > SAL_CALL TableName::getTable()
110 Reference< XTablesSupplier > xSuppTables(
getConnection(), UNO_QUERY_THROW );
111 Reference< XNameAccess > xTables( xSuppTables->getTables(), css::uno::UNO_SET_THROW );
113 Reference< XPropertySet > xTable;
116 xTable.set( xTables->getByName( getComposedName( CompositionType::Complete,
false ) ), UNO_QUERY_THROW );
118 catch(
const WrappedTargetException& )
120 throw NoSuchElementException();
123 catch(
const NoSuchElementException& ) {
throw; }
127 throw NoSuchElementException();
133 void SAL_CALL TableName::setTable(
const Reference< XPropertySet >& _table )
137 Reference< XPropertySetInfo > xPSI( _table, UNO_QUERY );
143 throw IllegalArgumentException(
144 DBA_RES( STR_NO_TABLE_OBJECT ),
158 throw IllegalArgumentException( e.Message, e.Context, 0 );
168 EComposeRule lcl_translateCompositionType_throw( sal_Int32 _nType )
172 sal_Int32 nCompositionType;
176 { CompositionType::ForTableDefinitions, EComposeRule::InTableDefinitions },
177 { CompositionType::ForIndexDefinitions, EComposeRule::InIndexDefinitions },
178 { CompositionType::ForDataManipulation, EComposeRule::InDataManipulation },
179 { CompositionType::ForProcedureCalls, EComposeRule::InProcedureCalls },
180 { CompositionType::ForPrivilegeDefinitions, EComposeRule::InPrivilegeDefinitions },
181 { CompositionType::Complete, EComposeRule::Complete }
184 auto const found = std::find_if(std::begin(TypeTable), std::end(TypeTable)
185 , [_nType](
auto const & type){
return type.nCompositionType == _nType; });
186 if (found == std::end(TypeTable))
187 throw IllegalArgumentException(
188 DBA_RES( STR_INVALID_COMPOSITION_TYPE ),
193 return found->eComposeRule;
197 OUString SAL_CALL TableName::getComposedName( ::sal_Int32
Type,
sal_Bool Quote )
203 msCatalog, msSchema,
msName, Quote,
204 lcl_translateCompositionType_throw(
Type ) );
207 void SAL_CALL TableName::setComposedName(
const OUString& ComposedName, ::sal_Int32
Type )
214 msCatalog, msSchema,
msName,
215 lcl_translateCompositionType_throw(
Type ) );
a class for guarding methods of a connection-dependent component
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr OUStringLiteral PROPERTY_SCHEMANAME(u"SchemaName")
constexpr OUStringLiteral PROPERTY_CATALOGNAME(u"CatalogName")
constexpr OUStringLiteral PROPERTY_NAME(u"Name")