summaryrefslogtreecommitdiff
path: root/dbaccess/source/core/api/tablecontainer.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/core/api/tablecontainer.cxx')
-rw-r--r--dbaccess/source/core/api/tablecontainer.cxx78
1 files changed, 46 insertions, 32 deletions
diff --git a/dbaccess/source/core/api/tablecontainer.cxx b/dbaccess/source/core/api/tablecontainer.cxx
index bc32774fd891..1a7e2a261609 100644
--- a/dbaccess/source/core/api/tablecontainer.cxx
+++ b/dbaccess/source/core/api/tablecontainer.cxx
@@ -17,14 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <apitools.hxx>
#include <tablecontainer.hxx>
#include <table.hxx>
-#include <sal/log.hxx>
#include <comphelper/property.hxx>
#include <comphelper/processfactory.hxx>
#include <core_resource.hxx>
#include <strings.hrc>
+#include <strings.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyState.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
@@ -41,7 +40,7 @@
#include <sdbcoretools.hxx>
#include <ContainerMediator.hxx>
#include <objectnameapproval.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace dbaccess;
using namespace dbtools;
@@ -52,7 +51,6 @@ using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::util;
using namespace ::osl;
using namespace ::comphelper;
using namespace ::cppu;
@@ -63,26 +61,24 @@ namespace
bool lcl_isPropertySetDefaulted(const Sequence< OUString>& _aNames,const Reference<XPropertySet>& _xProp)
{
Reference<XPropertyState> xState(_xProp,UNO_QUERY);
- if ( xState.is() )
+ if ( !xState )
+ return false;
+ const OUString* pIter = _aNames.getConstArray();
+ const OUString* pEnd = pIter + _aNames.getLength();
+ for(;pIter != pEnd;++pIter)
{
- const OUString* pIter = _aNames.getConstArray();
- const OUString* pEnd = pIter + _aNames.getLength();
- for(;pIter != pEnd;++pIter)
+ try
{
- try
- {
- PropertyState aState = xState->getPropertyState(*pIter);
- if ( aState != PropertyState_DEFAULT_VALUE )
- break;
- }
- catch(const Exception&)
- {
- SAL_WARN("dbaccess", "lcl_isPropertySetDefaulted: Exception caught!" );
- }
+ PropertyState aState = xState->getPropertyState(*pIter);
+ if ( aState != PropertyState_DEFAULT_VALUE )
+ break;
+ }
+ catch(const Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("dbaccess", "" );
}
- return ( pIter == pEnd );
}
- return false;
+ return ( pIter == pEnd );
}
}
@@ -124,11 +120,28 @@ OUString OTableContainer::getTableTypeRestriction() const
}
// XServiceInfo
-IMPLEMENT_SERVICE_INFO2(OTableContainer, "com.sun.star.sdb.dbaccess.OTableContainer", SERVICE_SDBCX_CONTAINER, SERVICE_SDBCX_TABLES)
+OUString SAL_CALL OTableContainer::getImplementationName()
+ {
+ return "com.sun.star.sdb.dbaccess.OTableContainer";
+ }
+sal_Bool SAL_CALL OTableContainer::supportsService(const OUString& _rServiceName)
+ {
+ const css::uno::Sequence< OUString > aSupported(getSupportedServiceNames());
+ for (const OUString& s : aSupported)
+ if (s == _rServiceName)
+ return true;
+
+ return false;
+ }
+css::uno::Sequence< OUString > SAL_CALL OTableContainer::getSupportedServiceNames()
+{
+ return { SERVICE_SDBCX_CONTAINER, SERVICE_SDBCX_TABLES };
+}
+
namespace
{
-void lcl_createDefintionObject(const OUString& _rName
+void lcl_createDefinitionObject(const OUString& _rName
,const Reference< XNameContainer >& _xTableDefinitions
,Reference<XPropertySet>& _xTableDefinition
,Reference<XNameAccess>& _xColumnDefinitions)
@@ -142,7 +155,7 @@ void lcl_createDefintionObject(const OUString& _rName
{
// set as folder
_xTableDefinition = TableDefinition::createWithName( ::comphelper::getProcessComponentContext(), _rName );
- _xTableDefinitions->insertByName(_rName,makeAny(_xTableDefinition));
+ _xTableDefinitions->insertByName(_rName,Any(_xTableDefinition));
}
Reference<XColumnsSupplier> xColumnsSupplier(_xTableDefinition,UNO_QUERY);
if ( xColumnsSupplier.is() )
@@ -162,11 +175,11 @@ connectivity::sdbcx::ObjectType OTableContainer::createObject(const OUString& _r
{
Reference<XPropertySet> xTableDefinition;
Reference<XNameAccess> xColumnDefinitions;
- lcl_createDefintionObject(_rName,m_xTableDefinitions,xTableDefinition,xColumnDefinitions);
+ lcl_createDefinitionObject(_rName,m_xTableDefinitions,xTableDefinition,xColumnDefinitions);
if ( xSup.is() )
{
- ODBTableDecorator* pTable = new ODBTableDecorator( m_xConnection, xSup, ::dbtools::getNumberFormats( m_xConnection ) ,xColumnDefinitions);
+ rtl::Reference<ODBTableDecorator> pTable = new ODBTableDecorator( m_xConnection, xSup, ::dbtools::getNumberFormats( m_xConnection ) ,xColumnDefinitions);
xRet = pTable;
pTable->construct();
}
@@ -199,7 +212,7 @@ connectivity::sdbcx::ObjectType OTableContainer::createObject(const OUString& _r
}
}
::comphelper::disposeComponent(xRes);
- ODBTable* pTable = new ODBTable(this
+ rtl::Reference<ODBTable> pTable = new ODBTable(this
,m_xConnection
,sCatalog
,sSchema
@@ -216,7 +229,7 @@ connectivity::sdbcx::ObjectType OTableContainer::createObject(const OUString& _r
if ( !m_pTableMediator.is() )
m_pTableMediator = new OContainerMediator(
- this, m_xTableDefinitions.get() );
+ this, m_xTableDefinitions );
if ( m_pTableMediator.is() )
m_pTableMediator->notifyElementCreated(_rName,xDest);
}
@@ -235,13 +248,13 @@ Reference< XPropertySet > OTableContainer::createDescriptor()
if ( xDataFactory.is() && m_xMetaData.is() )
{
xMasterColumnsSup.set( xDataFactory->createDataDescriptor(), UNO_QUERY );
- ODBTableDecorator* pTable = new ODBTableDecorator( m_xConnection, xMasterColumnsSup, ::dbtools::getNumberFormats( m_xConnection ) ,nullptr);
+ rtl::Reference<ODBTableDecorator> pTable = new ODBTableDecorator( m_xConnection, xMasterColumnsSup, ::dbtools::getNumberFormats( m_xConnection ) ,nullptr);
xRet = pTable;
pTable->construct();
}
else
{
- ODBTable* pTable = new ODBTable(this, m_xConnection);
+ rtl::Reference<ODBTable> pTable = new ODBTable(this, m_xConnection);
xRet = pTable;
pTable->construct();
}
@@ -288,7 +301,7 @@ ObjectType OTableContainer::appendObject( const OUString& _rForName, const Refer
Reference<XPropertySet> xTableDefinition;
Reference<XNameAccess> xColumnDefinitions;
- lcl_createDefintionObject(getNameForObject(descriptor),m_xTableDefinitions,xTableDefinition,xColumnDefinitions);
+ lcl_createDefinitionObject(getNameForObject(descriptor),m_xTableDefinitions,xTableDefinition,xColumnDefinitions);
Reference<XColumnsSupplier> xSup(descriptor,UNO_QUERY);
Reference<XDataDescriptorFactory> xFac(xColumnDefinitions,UNO_QUERY);
Reference<XAppend> xAppend(xColumnDefinitions,UNO_QUERY);
@@ -335,12 +348,13 @@ void OTableContainer::dropObject(sal_Int32 _nPos, const OUString& _sElementName)
xDrop->dropByName(_sElementName);
else
{
- OUString sCatalog,sSchema,sTable,sComposedName;
+ OUString sComposedName;
bool bIsView = false;
Reference<XPropertySet> xTable(getObject(_nPos),UNO_QUERY);
if ( xTable.is() && m_xMetaData.is() )
{
+ OUString sSchema,sCatalog,sTable;
if (m_xMetaData->supportsCatalogsInTableDefinitions())
xTable->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog;
if (m_xMetaData->supportsSchemasInTableDefinitions())
@@ -393,7 +407,7 @@ void SAL_CALL OTableContainer::elementInserted( const ContainerEvent& Event )
ObjectType xName = createObject(sName);
insertElement(sName,xName);
// and notify our listeners
- ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(sName), makeAny(xName), Any());
+ ContainerEvent aEvent(static_cast<XContainer*>(this), Any(sName), Any(xName), Any());
m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent );
}
}