summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/dbase/DIndexes.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/dbase/DIndexes.cxx')
-rw-r--r--connectivity/source/drivers/dbase/DIndexes.cxx51
1 files changed, 18 insertions, 33 deletions
diff --git a/connectivity/source/drivers/dbase/DIndexes.cxx b/connectivity/source/drivers/dbase/DIndexes.cxx
index 1ebce2612098..1ade0679216c 100644
--- a/connectivity/source/drivers/dbase/DIndexes.cxx
+++ b/connectivity/source/drivers/dbase/DIndexes.cxx
@@ -24,20 +24,14 @@
#include <unotools/ucbhelper.hxx>
#include <strings.hrc>
-using namespace ::comphelper;
-
using namespace utl;
using namespace ::connectivity;
using namespace ::dbtools;
using namespace ::connectivity::dbase;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::sdbcx;
-using namespace ::com::sun::star::sdbc;
-using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::lang;
-sdbcx::ObjectType ODbaseIndexes::createObject(const OUString& _rName)
+css::uno::Reference< css::beans::XPropertySet > ODbaseIndexes::createObject(const OUString& _rName)
{
OUString sFile = m_pTable->getConnection()->getURL() +
OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELIMITER) +
@@ -51,23 +45,8 @@ sdbcx::ObjectType ODbaseIndexes::createObject(const OUString& _rName)
::dbtools::throwGenericSQLException( sError, *m_pTable );
}
- sdbcx::ObjectType xRet;
std::unique_ptr<SvStream> pFileStream = ::connectivity::file::OFileTable::createStream_simpleError(sFile, StreamMode::READ | StreamMode::NOCREATE | StreamMode::SHARE_DENYWRITE);
- if(pFileStream)
- {
- pFileStream->SetEndian(SvStreamEndian::LITTLE);
- pFileStream->SetBufferSize(DINDEX_PAGE_SIZE);
- ODbaseIndex::NDXHeader aHeader;
-
- pFileStream->Seek(0);
- ReadHeader(*pFileStream, aHeader);
- pFileStream.reset();
-
- ODbaseIndex* pIndex = new ODbaseIndex(m_pTable,aHeader,_rName);
- xRet = pIndex;
- pIndex->openIndexFile();
- }
- else
+ if(!pFileStream)
{
const OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
STR_COULD_NOT_LOAD_FILE,
@@ -75,7 +54,18 @@ sdbcx::ObjectType ODbaseIndexes::createObject(const OUString& _rName)
) );
::dbtools::throwGenericSQLException( sError, *m_pTable );
}
- return xRet;
+
+ pFileStream->SetEndian(SvStreamEndian::LITTLE);
+ pFileStream->SetBufferSize(DINDEX_PAGE_SIZE);
+ ODbaseIndex::NDXHeader aHeader;
+
+ pFileStream->Seek(0);
+ ReadHeader(*pFileStream, aHeader);
+ pFileStream.reset();
+
+ rtl::Reference<ODbaseIndex> pIndex = new ODbaseIndex(m_pTable,aHeader,_rName);
+ pIndex->openIndexFile();
+ return pIndex;
}
void ODbaseIndexes::impl_refresh( )
@@ -90,16 +80,11 @@ Reference< XPropertySet > ODbaseIndexes::createDescriptor()
}
// XAppend
-sdbcx::ObjectType ODbaseIndexes::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
+css::uno::Reference< css::beans::XPropertySet > ODbaseIndexes::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
{
- Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY);
- if(xTunnel.is())
- {
- ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelId()) );
- if(!pIndex)
- throw SQLException();
+ ODbaseIndex* pIndex = dynamic_cast<ODbaseIndex*>(descriptor.get());
+ if(pIndex)
pIndex->CreateImpl();
- }
return createObject( _rForName );
}
@@ -107,7 +92,7 @@ sdbcx::ObjectType ODbaseIndexes::appendObject( const OUString& _rForName, const
// XDrop
void ODbaseIndexes::dropObject(sal_Int32 _nPos, const OUString& /*_sElementName*/)
{
- auto pIndex = comphelper::getUnoTunnelImplementation<ODbaseIndex>(getObject(_nPos));
+ rtl::Reference<ODbaseIndex> pIndex = dynamic_cast<ODbaseIndex*>(getObject(_nPos).get());
if ( pIndex )
pIndex->DropImpl();
}