Kaydet (Commit) 38b4b759 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:mergeclasses, merge OOdbcLibWrapper with OOdbcEnumeration

Change-Id: I2e564e90c11bb46022a5e258ad013aeb2fe4ca2e
üst ade2ba50
......@@ -110,7 +110,6 @@ merge cppu::PropertySetMixinImpl with cppu::PropertySetMixin
merge dbaccess::IPropertyContainer with dbaccess::OColumn
merge dbaccess::IRefreshListener with dbaccess::OConnection
merge dbaui::IEntryFilter with dbaui::(anonymous namespace)::FilterByEntryDataId
merge dbaui::OOdbcLibWrapper with dbaui::OOdbcEnumeration
merge dbaui::SbaGridListener with dbaui::SbaXDataBrowserController
merge dbmm::IMigrationProgress with dbmm::ProgressPage
merge dbmm::IProgressConsumer with dbmm::ProgressDelegator
......
......@@ -69,16 +69,8 @@ typedef SQLRETURN (SQL_API* TSQLDataSources) (SQLHENV EnvironmentHandle, SQLUSMA
#endif
// OOdbcLibWrapper
#ifdef HAVE_ODBC_SUPPORT
OOdbcLibWrapper::OOdbcLibWrapper()
:m_pOdbcLib(NULL)
{
}
#endif
bool OOdbcLibWrapper::load(const sal_Char* _pLibPath)
bool OOdbcEnumeration::load(const sal_Char* _pLibPath)
{
m_sLibPath = OUString::createFromAscii(_pLibPath);
#ifdef HAVE_ODBC_SUPPORT
......@@ -90,7 +82,7 @@ bool OOdbcLibWrapper::load(const sal_Char* _pLibPath)
#endif
}
void OOdbcLibWrapper::unload()
void OOdbcEnumeration::unload()
{
#ifdef HAVE_ODBC_SUPPORT
if (isLoaded())
......@@ -101,18 +93,12 @@ void OOdbcLibWrapper::unload()
#endif
}
oslGenericFunction OOdbcLibWrapper::loadSymbol(const sal_Char* _pFunctionName)
oslGenericFunction OOdbcEnumeration::loadSymbol(const sal_Char* _pFunctionName)
{
return osl_getFunctionSymbol(m_pOdbcLib, OUString::createFromAscii(_pFunctionName).pData);
}
OOdbcLibWrapper::~OOdbcLibWrapper()
{
unload();
}
// OOdbcEnumeration
struct OdbcTypesImpl
{
#ifdef HAVE_ODBC_SUPPORT
......@@ -124,8 +110,9 @@ struct OdbcTypesImpl
};
OOdbcEnumeration::OOdbcEnumeration()
:m_pOdbcLib(NULL)
#ifdef HAVE_ODBC_SUPPORT
:m_pAllocHandle(NULL)
,m_pAllocHandle(NULL)
,m_pFreeHandle(NULL)
,m_pSetEnvAttr(NULL)
,m_pDataSources(NULL)
......@@ -161,9 +148,10 @@ OOdbcEnumeration::~OOdbcEnumeration()
{
freeEnv();
delete m_pImpl;
unload();
}
// OOdbcEnumeration
bool OOdbcEnumeration::allocEnv()
{
OSL_ENSURE(isLoaded(), "OOdbcEnumeration::allocEnv: not loaded!");
......
......@@ -38,42 +38,13 @@
namespace dbaui
{
// OOdbcLibWrapper
/** base for helper classes wrapping functionality from an ODBC library
*/
class OOdbcLibWrapper
{
oslModule m_pOdbcLib; // the library handle
OUString m_sLibPath; // the path to the library
public:
#ifdef HAVE_ODBC_SUPPORT
bool isLoaded() const { return NULL != m_pOdbcLib; }
#else
sal_Bool isLoaded() const { return sal_False; }
#endif
OUString getLibraryName() const { return m_sLibPath; }
protected:
#ifndef HAVE_ODBC_SUPPORT
OOdbcLibWrapper() : m_pOdbcLib(NULL) { }
#else
OOdbcLibWrapper();
#endif
~OOdbcLibWrapper();
oslGenericFunction loadSymbol(const sal_Char* _pFunctionName);
/// load the lib
bool load(const sal_Char* _pLibPath);
/// unload the lib
void unload();
};
// OOdbcEnumeration
struct OdbcTypesImpl;
class OOdbcEnumeration : public OOdbcLibWrapper
class OOdbcEnumeration
{
oslModule m_pOdbcLib; // the library handle
OUString m_sLibPath; // the path to the library
#ifdef HAVE_ODBC_SUPPORT
// entry points for ODBC administration
oslGenericFunction m_pAllocHandle;
......@@ -90,11 +61,24 @@ public:
OOdbcEnumeration();
~OOdbcEnumeration();
#ifdef HAVE_ODBC_SUPPORT
bool isLoaded() const { return NULL != m_pOdbcLib; }
#else
bool isLoaded() const { return false; }
#endif
OUString getLibraryName() const { return m_sLibPath; }
void getDatasourceNames(StringBag& _rNames);
protected:
oslGenericFunction loadSymbol(const sal_Char* _pFunctionName);
/// load the lib
bool load(const sal_Char* _pLibPath);
/// unload the lib
void unload();
/// ensure that an ODBC environment is allocated
bool allocEnv();
bool allocEnv();
/// free any allocated ODBC environment
void freeEnv();
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment