Files
libreoffice/dbaccess/source/core/api/querydescriptor.cxx

267 lines
8.1 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-06-14 17:39:53 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 23:16:46 +00:00
#include <string.h>
2000-09-18 23:16:46 +00:00
#include "querydescriptor.hxx"
#include "apitools.hxx"
2000-10-25 06:32:52 +00:00
#include "dbastrings.hrc"
2000-10-11 10:21:40 +00:00
#include <comphelper/property.hxx>
#include <comphelper/sequence.hxx>
#include <cppuhelper/supportsservice.hxx>
2000-09-18 23:16:46 +00:00
#include <cppuhelper/typeprovider.hxx>
2000-10-25 06:32:52 +00:00
#include <com/sun/star/beans/PropertyAttribute.hpp>
2001-02-23 14:22:32 +00:00
#include "definitioncolumn.hxx"
2001-08-15 12:05:15 +00:00
#include <tools/debug.hxx>
2000-09-18 23:16:46 +00:00
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
2001-08-30 07:07:36 +00:00
using namespace ::com::sun::star::util;
2000-10-11 10:21:40 +00:00
using namespace ::comphelper;
2000-09-18 23:16:46 +00:00
using namespace ::osl;
using namespace ::cppu;
namespace dbaccess
{
// OQueryDescriptor
OQueryDescriptor::OQueryDescriptor()
:OQueryDescriptor_Base(m_aMutex,*this)
,ODataSettings(m_aBHelper,sal_True)
{
registerProperties();
ODataSettings::registerPropertiesFor(this);
}
OQueryDescriptor::OQueryDescriptor(const OQueryDescriptor_Base& _rSource)
:OQueryDescriptor_Base(_rSource,*this)
,ODataSettings(m_aBHelper,sal_True)
{
registerProperties();
ODataSettings::registerPropertiesFor(this);
}
OQueryDescriptor::~OQueryDescriptor()
{
}
IMPLEMENT_TYPEPROVIDER2(OQueryDescriptor,OQueryDescriptor_Base,ODataSettings);
IMPLEMENT_FORWARD_XINTERFACE3( OQueryDescriptor,OWeakObject,OQueryDescriptor_Base,ODataSettings)
2000-09-18 23:16:46 +00:00
void OQueryDescriptor::registerProperties()
{
// the properties which OCommandBase supplies (it has no own registration, as it's not derived from
// a OPropertyStateContainer)
registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND|PropertyAttribute::CONSTRAINED,
2000-09-18 23:16:46 +00:00
&m_sElementName, ::getCppuType(&m_sElementName));
registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
&m_sCommand, ::getCppuType(&m_sCommand));
registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
2000-09-18 23:16:46 +00:00
&m_bEscapeProcessing, ::getBooleanCppuType());
registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
&m_sUpdateTableName, ::getCppuType(&m_sUpdateTableName));
registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
&m_sUpdateSchemaName, ::getCppuType(&m_sUpdateSchemaName));
registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
&m_sUpdateCatalogName, ::getCppuType(&m_sUpdateCatalogName));
2001-02-05 07:58:23 +00:00
registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
2001-02-05 07:58:23 +00:00
&m_aLayoutInformation, ::getCppuType(&m_aLayoutInformation));
2000-09-18 23:16:46 +00:00
}
Reference< XPropertySetInfo > SAL_CALL OQueryDescriptor::getPropertySetInfo( ) throw(RuntimeException)
2000-09-18 23:16:46 +00:00
{
return createPropertySetInfo( getInfoHelper() ) ;
2000-09-18 23:16:46 +00:00
}
::cppu::IPropertyArrayHelper& OQueryDescriptor::getInfoHelper()
{
return *getArrayHelper();
}
::cppu::IPropertyArrayHelper* OQueryDescriptor::createArrayHelper( ) const
2000-09-18 23:16:46 +00:00
{
Sequence< Property > aProps;
describeProperties(aProps);
return new ::cppu::OPropertyArrayHelper(aProps);
2000-09-18 23:16:46 +00:00
}
OQueryDescriptor_Base::OQueryDescriptor_Base(::osl::Mutex& _rMutex,::cppu::OWeakObject& _rMySelf)
:m_bColumnsOutOfDate(sal_True)
,m_rMutex(_rMutex)
2000-09-18 23:16:46 +00:00
{
m_pColumns = new OColumns(_rMySelf, m_rMutex, sal_True,::std::vector< OUString>(), this,this);
}
OQueryDescriptor_Base::OQueryDescriptor_Base(const OQueryDescriptor_Base& _rSource,::cppu::OWeakObject& _rMySelf)
:m_bColumnsOutOfDate(sal_True)
,m_rMutex(_rSource.m_rMutex)
{
m_pColumns = new OColumns(_rMySelf, m_rMutex, sal_True,::std::vector< OUString>(), this,this);
2000-09-18 23:16:46 +00:00
m_sCommand = _rSource.m_sCommand;
m_bEscapeProcessing = _rSource.m_bEscapeProcessing;
m_sUpdateTableName = _rSource.m_sUpdateTableName;
m_sUpdateSchemaName = _rSource.m_sUpdateSchemaName;
m_sUpdateCatalogName = _rSource.m_sUpdateCatalogName;
2001-02-05 07:58:23 +00:00
m_aLayoutInformation = _rSource.m_aLayoutInformation;
2000-09-18 23:16:46 +00:00
}
OQueryDescriptor_Base::~OQueryDescriptor_Base()
2000-09-18 23:16:46 +00:00
{
m_pColumns->acquire();
m_pColumns->disposing();
delete m_pColumns;
2000-09-18 23:16:46 +00:00
}
sal_Int64 SAL_CALL OQueryDescriptor_Base::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException)
2000-09-18 23:16:46 +00:00
{
if (_rIdentifier.getLength() != 16)
2006-11-23 13:19:48 +00:00
return 0;
2000-09-18 23:16:46 +00:00
if (0 == memcmp(getImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ) )
2000-09-18 23:16:46 +00:00
return reinterpret_cast<sal_Int64>(this);
2006-11-23 13:19:48 +00:00
return 0;
2000-09-18 23:16:46 +00:00
}
IMPLEMENT_IMPLEMENTATION_ID(OQueryDescriptor_Base)
void OQueryDescriptor_Base::setColumnsOutOfDate( sal_Bool _bOutOfDate )
2001-08-30 07:07:36 +00:00
{
m_bColumnsOutOfDate = _bOutOfDate;
if ( !m_bColumnsOutOfDate )
m_pColumns->setInitialized();
}
void OQueryDescriptor_Base::implAppendColumn( const OUString& _rName, OColumn* _pColumn )
2001-08-30 07:07:36 +00:00
{
m_pColumns->append( _rName, _pColumn );
}
void OQueryDescriptor_Base::clearColumns( )
2001-08-30 07:07:36 +00:00
{
m_pColumns->clearColumns();
setColumnsOutOfDate();
}
Reference< XNameAccess > SAL_CALL OQueryDescriptor_Base::getColumns( ) throw (RuntimeException)
2000-09-18 23:16:46 +00:00
{
MutexGuard aGuard(m_rMutex);
2001-08-30 07:07:36 +00:00
if ( isColumnsOutOfDate() )
2001-08-30 07:07:36 +00:00
{
// clear the current columns
clearColumns();
2001-08-30 07:07:36 +00:00
// do this before rebuildColumns. This prevents recursion, e.g. in the case where we
// have queries with cyclic references:
// foo := SELECT * FROM bar
// bar := SELECT * FROM foo
setColumnsOutOfDate( sal_False );
// rebuild them
try
{
rebuildColumns();
}
catch ( const Exception& )
{
setColumnsOutOfDate( sal_True );
throw;
}
2001-08-30 07:07:36 +00:00
}
return m_pColumns;
2000-09-18 23:16:46 +00:00
}
OUString SAL_CALL OQueryDescriptor_Base::getImplementationName( ) throw(RuntimeException)
2000-09-18 23:16:46 +00:00
{
return OUString("com.sun.star.sdb.OQueryDescriptor");
2000-09-18 23:16:46 +00:00
}
sal_Bool SAL_CALL OQueryDescriptor_Base::supportsService( const OUString& _rServiceName ) throw(RuntimeException)
2000-09-18 23:16:46 +00:00
{
return cppu::supportsService(this, _rServiceName);
2000-09-18 23:16:46 +00:00
}
Sequence< OUString > SAL_CALL OQueryDescriptor_Base::getSupportedServiceNames( ) throw(RuntimeException)
2000-09-18 23:16:46 +00:00
{
Sequence< OUString > aSupported(2);
2000-09-18 23:16:46 +00:00
aSupported.getArray()[0] = SERVICE_SDB_DATASETTINGS;
aSupported.getArray()[1] = SERVICE_SDB_QUERYDESCRIPTOR;
return aSupported;
}
void OQueryDescriptor_Base::disposeColumns()
2000-09-18 23:16:46 +00:00
{
2001-05-21 08:21:15 +00:00
m_pColumns->disposing();
2000-09-18 23:16:46 +00:00
}
void OQueryDescriptor_Base::columnAppended( const Reference< XPropertySet >& /*_rxSourceDescriptor*/ )
2001-08-15 12:05:15 +00:00
{
// not interested in
2001-08-15 12:05:15 +00:00
}
2000-09-18 23:16:46 +00:00
void OQueryDescriptor_Base::columnDropped(const OUString& /*_sName*/)
{
// not interested in
}
Reference< XPropertySet > OQueryDescriptor_Base::createColumnDescriptor()
{
OSL_FAIL( "OQueryDescriptor_Base::createColumnDescriptor: called why?" );
return NULL;
}
void OQueryDescriptor_Base::rebuildColumns( )
2000-09-18 23:16:46 +00:00
{
}
// IRefreshableColumns
void OQueryDescriptor_Base::refreshColumns()
2000-09-18 23:16:46 +00:00
{
MutexGuard aGuard( m_rMutex );
2000-09-18 23:16:46 +00:00
2001-08-30 07:07:36 +00:00
clearColumns();
rebuildColumns();
2000-09-18 23:16:46 +00:00
}
OColumn* OQueryDescriptor_Base::createColumn( const OUString& /*_rName*/ ) const
2000-09-18 23:16:46 +00:00
{
// creating a column/descriptor for a query/descriptor does not make sense at all
return NULL;
2000-09-18 23:16:46 +00:00
}
2010-10-13 12:23:13 +01:00
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */