From 7a3eff265280d311816f4bc180ef2ec74400e57d Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Thu, 22 Aug 2013 09:19:17 +0100 Subject: [PATCH] Set Table privileges. (firebird-sdbc) Change-Id: Ia73f2f2107e17c03bc568075a0a99bc7a21fb8a7 --- .../source/drivers/firebird/Table.cxx | 37 +++++++++++++++++-- .../source/drivers/firebird/Table.hxx | 5 ++- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx index abc57afde448..98e446b590cd 100644 --- a/connectivity/source/drivers/firebird/Table.cxx +++ b/connectivity/source/drivers/firebird/Table.cxx @@ -11,11 +11,14 @@ #include "Keys.hxx" #include "Table.hxx" +#include + #include #include #include #include +#include using namespace ::connectivity; using namespace ::connectivity::firebird; @@ -28,6 +31,7 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::uno; Table::Table(Tables* pTables, @@ -36,9 +40,10 @@ Table::Table(Tables* pTables, OTableHelper(pTables, rConnection, sal_True), - m_rMutex(rMutex) + m_rMutex(rMutex), + m_nPrivileges(0) { - OTableHelper::construct(); + construct(); } Table::Table(Tables* pTables, @@ -55,11 +60,34 @@ Table::Table(Tables* pTables, rDescription, "", ""), - m_rMutex(rMutex) + m_rMutex(rMutex), + m_nPrivileges(0) { - OTableHelper::construct(); + construct(); } +void Table::construct() +{ + OTableHelper::construct(); + if (!isNew()) + { + // TODO: get privileges when in non-embedded mode. + m_nPrivileges = Privilege::DROP | + Privilege::REFERENCE | + Privilege::ALTER | + Privilege::CREATE | + Privilege::READ | + Privilege::DELETE | + Privilege::UPDATE | + Privilege::INSERT | + Privilege::SELECT; + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRIVILEGES), + PROPERTY_ID_PRIVILEGES, + PropertyAttribute::READONLY, + &m_nPrivileges, + ::getCppuType(&m_nPrivileges)); + } +} //----- OTableHelper --------------------------------------------------------- OCollection* Table::createColumns(const TStringVector& rNames) { @@ -228,4 +256,5 @@ OUString Table::getAlterTableColumn(const OUString& rColumn) { return ("ALTER TABLE \"" + getName() + "\" ALTER COLUMN \"" + rColumn + "\" "); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/connectivity/source/drivers/firebird/Table.hxx b/connectivity/source/drivers/firebird/Table.hxx index 41f12c3f7eff..d6354bcd3ff9 100644 --- a/connectivity/source/drivers/firebird/Table.hxx +++ b/connectivity/source/drivers/firebird/Table.hxx @@ -27,6 +27,7 @@ namespace connectivity { private: ::osl::Mutex& m_rMutex; + sal_Int32 m_nPrivileges; /** * Get the ALTER TABLE [TABLE] ALTER [COLUMN] String. @@ -34,6 +35,9 @@ namespace connectivity */ ::rtl::OUString getAlterTableColumn(const ::rtl::OUString& rColumn); + protected: + void construct(); + public: Table(Tables* pTables, ::osl::Mutex& rMutex, @@ -81,7 +85,6 @@ namespace connectivity SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); - }; } // namespace firebird