Hi, I have submitted a patch for review:
https://gerrit.libreoffice.org/3031 To pull it, you can do: git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/31/3031/1 fdo#46808, convert sdb::QueryDesigner to new style Change-Id: I694dd16920304d0f07369e97c87a4a97b92eadeb --- M dbaccess/source/core/api/query.cxx M dbaccess/source/core/api/querycontainer.cxx M dbaccess/source/core/dataaccess/commandcontainer.cxx M dbaccess/source/core/dataaccess/commanddefinition.cxx M dbaccess/source/core/dataaccess/commanddefinition.hxx M dbaccess/source/inc/stringconstants.hrc M dbaccess/source/inc/stringconstants.inc M offapi/UnoApi_offapi.mk M offapi/com/sun/star/sdb/QueryDefinition.idl A offapi/com/sun/star/sdb/XQueryDefinition.idl M offapi/type_reference/types.rdb 11 files changed, 174 insertions(+), 59 deletions(-) diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx index ed1f073..2d10f92 100644 --- a/dbaccess/source/core/api/query.cxx +++ b/dbaccess/source/core/api/query.cxx @@ -217,7 +217,7 @@ } // XServiceInfo -IMPLEMENT_SERVICE_INFO3(OQuery, "com.sun.star.sdb.dbaccess.OQuery", SERVICE_SDB_DATASETTINGS.ascii, SERVICE_SDB_QUERY.ascii, SERVICE_SDB_QUERYDEFINITION.ascii) +IMPLEMENT_SERVICE_INFO3(OQuery, "com.sun.star.sdb.dbaccess.OQuery", SERVICE_SDB_DATASETTINGS.ascii, SERVICE_SDB_QUERY.ascii, "com.sun.star.sdb.QueryDefinition") // ::com::sun::star::beans::XPropertyChangeListener void SAL_CALL OQuery::propertyChange( const PropertyChangeEvent& _rSource ) throw(RuntimeException) diff --git a/dbaccess/source/core/api/querycontainer.cxx b/dbaccess/source/core/api/querycontainer.cxx index 6ffb474..984b9e8 100644 --- a/dbaccess/source/core/api/querycontainer.cxx +++ b/dbaccess/source/core/api/querycontainer.cxx @@ -27,8 +27,9 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XContainer.hpp> -#include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/container/XContainerApproveBroadcaster.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/sdb/QueryDefinition.hpp> #include <connectivity/dbexception.hxx> @@ -154,10 +155,9 @@ throw DisposedException( ::rtl::OUString(), *this ); // first clone this object's CommandDefinition part - Reference< XPropertySet > xCommandDefinitionPart( - m_aContext->getServiceManager()->createInstanceWithContext( SERVICE_SDB_QUERYDEFINITION, m_aContext), - UNO_QUERY_THROW ); - ::comphelper::copyProperties( _rxDesc, xCommandDefinitionPart ); + Reference< css::sdb::XQueryDefinition > xCommandDefinitionPart = css::sdb::QueryDefinition::create(m_aContext); + + ::comphelper::copyProperties( _rxDesc, Reference<XPropertySet>(xCommandDefinitionPart, UNO_QUERY_THROW) ); // TODO : the columns part of the descriptor has to be copied // create a wrapper for the object (*before* inserting into our command definition container) diff --git a/dbaccess/source/core/dataaccess/commandcontainer.cxx b/dbaccess/source/core/dataaccess/commandcontainer.cxx index 5052af6..eb47000 100644 --- a/dbaccess/source/core/dataaccess/commandcontainer.cxx +++ b/dbaccess/source/core/dataaccess/commandcontainer.cxx @@ -70,7 +70,8 @@ const TContentPtr& pElementContent( rDefinitions.find( _rName )->second ); if ( m_bTables ) return new OComponentDefinition( *this, _rName, m_aContext, pElementContent, m_bTables ); - return new OCommandDefinition( *this, _rName, m_aContext, pElementContent ); + else + return static_cast< css::sdb::XQueryDefinition * > ( new OCommandDefinition( *this, _rName, m_aContext, pElementContent ) ); } Reference< XInterface > SAL_CALL OCommandContainer::createInstanceWithArguments(const Sequence< Any >& /*aArguments*/ ) throw (Exception, RuntimeException) diff --git a/dbaccess/source/core/dataaccess/commanddefinition.cxx b/dbaccess/source/core/dataaccess/commanddefinition.cxx index 8278bff..ba0016b 100644 --- a/dbaccess/source/core/dataaccess/commanddefinition.cxx +++ b/dbaccess/source/core/dataaccess/commanddefinition.cxx @@ -72,6 +72,62 @@ &rCommandDefinition.m_aLayoutInformation, ::getCppuType(&rCommandDefinition.m_aLayoutInformation)); } +rtl::OUString OCommandDefinition::getName() throw( ::com::sun::star::uno::RuntimeException ) +{ + return getDefinition().m_aProps.aTitle; +} + +rtl::OUString OCommandDefinition::getCommand() throw( ::com::sun::star::uno::RuntimeException ) +{ + return getCommandDefinition().m_sCommand; +} + +void OCommandDefinition::setCommand(const rtl::OUString& p1) throw( ::com::sun::star::uno::RuntimeException ) +{ + setPropertyValue(PROPERTY_COMMAND, Any(p1) ); +} + +sal_Bool OCommandDefinition::getEscapeProcessing() throw( ::com::sun::star::uno::RuntimeException ) +{ + return getCommandDefinition().m_bEscapeProcessing; +} + +void OCommandDefinition::setEscapeProcessing(sal_Bool p1) throw( ::com::sun::star::uno::RuntimeException ) +{ + setPropertyValue(PROPERTY_ESCAPE_PROCESSING, Any(p1) ); +} + +rtl::OUString OCommandDefinition::getUpdateTableName() throw( ::com::sun::star::uno::RuntimeException ) +{ + return getCommandDefinition().m_sUpdateTableName; +} + +void OCommandDefinition::setUpdateTableName(const rtl::OUString& p1) throw( ::com::sun::star::uno::RuntimeException ) +{ + setPropertyValue(PROPERTY_UPDATE_TABLENAME, Any(p1) ); +} + +rtl::OUString OCommandDefinition::getUpdateCatalogName() throw( ::com::sun::star::uno::RuntimeException ) +{ + return getCommandDefinition().m_sUpdateCatalogName; +} + +void OCommandDefinition::setUpdateCatalogName(const rtl::OUString& p1) throw( ::com::sun::star::uno::RuntimeException ) +{ + setPropertyValue(PROPERTY_UPDATE_CATALOGNAME, Any(p1) ); +} + +rtl::OUString OCommandDefinition::getUpdateSchemaName() throw( ::com::sun::star::uno::RuntimeException ) +{ + return getCommandDefinition().m_sUpdateSchemaName; +} + +void OCommandDefinition::setUpdateSchemaName(const rtl::OUString& p1) throw( ::com::sun::star::uno::RuntimeException ) +{ + setPropertyValue(PROPERTY_UPDATE_SCHEMANAME, Any(p1) ); +} + + OCommandDefinition::OCommandDefinition(const Reference< XComponentContext >& _xORB ,const Reference< XInterface >& _rxContainer ,const TContentPtr& _pImpl) @@ -114,7 +170,7 @@ Sequence< OUString > OCommandDefinition::getSupportedServiceNames_static( ) throw(RuntimeException) { Sequence< OUString > aServices(3); - aServices.getArray()[0] = SERVICE_SDB_QUERYDEFINITION; + aServices.getArray()[0] = "com.sun.star.sdb.QueryDefinition"; aServices.getArray()[1] = "com.sun.star.sdb.CommandDefinition"; aServices.getArray()[2] = "com.sun.star.ucb.Content"; return aServices; diff --git a/dbaccess/source/core/dataaccess/commanddefinition.hxx b/dbaccess/source/core/dataaccess/commanddefinition.hxx index f2a469b..e8c5403 100644 --- a/dbaccess/source/core/dataaccess/commanddefinition.hxx +++ b/dbaccess/source/core/dataaccess/commanddefinition.hxx @@ -21,16 +21,18 @@ #define _DBA_COREDATAACESS_COMMANDDEFINITION_HXX_ #include "commandbase.hxx" -#include <comphelper/propertycontainer.hxx> #include "apitools.hxx" -#include <comphelper/uno3.hxx> -#include <com/sun/star/sdbcx/XRename.hpp> -#include <cppuhelper/implbase1.hxx> -#include <comphelper/proparrhlp.hxx> -#include "datasettings.hxx" #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/sdbcx/XRename.hpp> +#include <com/sun/star/sdb/XQueryDefinition.hpp> +#include "datasettings.hxx" #include "ContentHelper.hxx" #include "ComponentDefinition.hxx" + +#include <comphelper/propertycontainer.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/implbase2.hxx> //........................................................................ @@ -42,18 +44,19 @@ //= OCommandDefinition - a database "document" which describes a query //========================================================================= class OCommandDefinition_Impl : public OComponentDefinition_Impl - ,public OCommandBase + ,public OCommandBase { public: }; -typedef ::cppu::ImplHelper1 < ::com::sun::star::sdbcx::XRename +typedef ::cppu::ImplHelper2 < ::com::sun::star::sdbcx::XRename, + ::com::sun::star::sdb::XQueryDefinition > OCommandDefinition_Base; class OCommandDefinition; typedef ::comphelper::OPropertyArrayUsageHelper< OCommandDefinition > OCommandDefinition_PROP; -class OCommandDefinition :public OComponentDefinition +class OCommandDefinition : public OComponentDefinition ,public OCommandDefinition_Base ,public OCommandDefinition_PROP { @@ -96,6 +99,47 @@ // XRename virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + // overrides to resolve ambiguity + virtual void SAL_CALL setPropertyValue(const rtl::OUString& p1, const com::sun::star::uno::Any& p2) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { OComponentDefinition::setPropertyValue(p1, p2); } + virtual com::sun::star::uno::Any SAL_CALL getPropertyValue(const rtl::OUString& p1) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { return OComponentDefinition::getPropertyValue(p1); } + virtual void SAL_CALL addPropertyChangeListener(const rtl::OUString& p1, const com::sun::star::uno::Reference<com::sun::star::beans::XPropertyChangeListener>& p2) throw( ::com::sun::star::uno::RuntimeException ) + { OComponentDefinition::addPropertyChangeListener(p1, p2); } + virtual void SAL_CALL removePropertyChangeListener(const rtl::OUString& p1, const com::sun::star::uno::Reference<com::sun::star::beans::XPropertyChangeListener>& p2) throw( ::com::sun::star::uno::RuntimeException ) + { OComponentDefinition::removePropertyChangeListener(p1, p2); } + virtual void SAL_CALL addVetoableChangeListener(const rtl::OUString& p1, const com::sun::star::uno::Reference<com::sun::star::beans::XVetoableChangeListener>& p2) throw( ::com::sun::star::uno::RuntimeException ) + { OComponentDefinition::addVetoableChangeListener(p1, p2); } + virtual void SAL_CALL removeVetoableChangeListener(const rtl::OUString& p1, const com::sun::star::uno::Reference<com::sun::star::beans::XVetoableChangeListener>& p2) throw( ::com::sun::star::uno::RuntimeException ) + { OComponentDefinition::removeVetoableChangeListener(p1, p2); } + virtual com::sun::star::uno::Reference<com::sun::star::ucb::XContentIdentifier> SAL_CALL getIdentifier() throw( ::com::sun::star::uno::RuntimeException ) + { return OComponentDefinition::getIdentifier(); } + virtual rtl::OUString SAL_CALL getContentType() throw( ::com::sun::star::uno::RuntimeException ) + { return OComponentDefinition::getContentType(); } + virtual void SAL_CALL addContentEventListener(const com::sun::star::uno::Reference<com::sun::star::ucb::XContentEventListener>& p1) throw( ::com::sun::star::uno::RuntimeException ) + { OComponentDefinition::addContentEventListener(p1); } + virtual void SAL_CALL removeContentEventListener(const com::sun::star::uno::Reference<com::sun::star::ucb::XContentEventListener>& p1) throw( ::com::sun::star::uno::RuntimeException ) + { OComponentDefinition::removeContentEventListener(p1); } + virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException ) + { OComponentDefinition::dispose(); } + virtual void SAL_CALL addEventListener(const com::sun::star::uno::Reference<com::sun::star::lang::XEventListener>& p1) throw( ::com::sun::star::uno::RuntimeException ) + { OComponentDefinition::addEventListener(p1); } + virtual void SAL_CALL removeEventListener(const com::sun::star::uno::Reference<com::sun::star::lang::XEventListener>& p1) throw( ::com::sun::star::uno::RuntimeException ) + { OComponentDefinition::removeEventListener(p1); } + + // XQueryDefinition properties + virtual rtl::OUString getName() throw( ::com::sun::star::uno::RuntimeException ); + virtual rtl::OUString getCommand() throw( ::com::sun::star::uno::RuntimeException ); + virtual void setCommand(const rtl::OUString&) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool getEscapeProcessing() throw( ::com::sun::star::uno::RuntimeException ); + virtual void setEscapeProcessing(sal_Bool) throw( ::com::sun::star::uno::RuntimeException ); + virtual rtl::OUString getUpdateTableName() throw( ::com::sun::star::uno::RuntimeException ); + virtual void setUpdateTableName(const rtl::OUString&) throw( ::com::sun::star::uno::RuntimeException ); + virtual rtl::OUString getUpdateCatalogName() throw( ::com::sun::star::uno::RuntimeException ); + virtual void setUpdateCatalogName(const rtl::OUString&) throw( ::com::sun::star::uno::RuntimeException ); + virtual rtl::OUString getUpdateSchemaName() throw( ::com::sun::star::uno::RuntimeException ); + virtual void setUpdateSchemaName(const rtl::OUString&) throw( ::com::sun::star::uno::RuntimeException ); + // OPropertySetHelper DECLARE_PROPERTYCONTAINER_DEFAULTS( ); diff --git a/dbaccess/source/inc/stringconstants.hrc b/dbaccess/source/inc/stringconstants.hrc index 8c60d05..0784969 100644 --- a/dbaccess/source/inc/stringconstants.hrc +++ b/dbaccess/source/inc/stringconstants.hrc @@ -365,7 +365,6 @@ DECLARE_CONSTASCII_USTRING(SERVICE_SDB_DATASETTINGS); DECLARE_CONSTASCII_USTRING(SERVICE_SDB_QUERYDESCRIPTOR); DECLARE_CONSTASCII_USTRING(SERVICE_SDB_QUERY); -DECLARE_CONSTASCII_USTRING(SERVICE_SDB_QUERYDEFINITION); DECLARE_CONSTASCII_USTRING(SERVICE_SDB_COLUMNSETTINGS); DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMNS); DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_TABLES); diff --git a/dbaccess/source/inc/stringconstants.inc b/dbaccess/source/inc/stringconstants.inc index 3ce49a0..e72c373 100644 --- a/dbaccess/source/inc/stringconstants.inc +++ b/dbaccess/source/inc/stringconstants.inc @@ -202,7 +202,6 @@ IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_DATASETTINGS, "com.sun.star.sdb.DefinitionSettings"); IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERYDESCRIPTOR, "com.sun.star.sdb.QueryDescriptor"); IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERY, "com.sun.star.sdb.Query"); -IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERYDEFINITION, "com.sun.star.sdb.QueryDefinition"); IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMNS, "com.sun.star.sdbcx.Columns"); IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_TABLES, "com.sun.star.sdbcx.Tables"); IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERIES, "com.sun.star.sdb.Queries"); diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 2c18bf8..7151bc3 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -292,6 +292,7 @@ InteractionHandler \ FilterDialog \ OrderDialog \ + QueryDefinition \ ReportDesign \ TableDefinition \ TextConnectionSettings \ @@ -1042,7 +1043,6 @@ OrderColumn \ PreparedStatement \ Query \ - QueryDefinition \ QueryDescriptor \ QueryDesign \ RelationDesign \ @@ -3125,6 +3125,7 @@ XOfficeDatabaseDocument \ XParametersSupplier \ XQueriesSupplier \ + XQueryDefinition \ XQueryDefinitionsSupplier \ XReportDocumentsSupplier \ XResultSetAccess \ diff --git a/offapi/com/sun/star/sdb/QueryDefinition.idl b/offapi/com/sun/star/sdb/QueryDefinition.idl index 6107e31..2f0f7fe 100644 --- a/offapi/com/sun/star/sdb/QueryDefinition.idl +++ b/offapi/com/sun/star/sdb/QueryDefinition.idl @@ -19,7 +19,7 @@ #ifndef __com_sun_star_sdb_QueryDefinition_idl__ #define __com_sun_star_sdb_QueryDefinition_idl__ -#include <com/sun/star/beans/XPropertySet.idl> +#include <com/sun/star/sdb/XQueryDefinition.idl> module com { module sun { module star { module sdb { @@ -30,44 +30,7 @@ It can be used, if there is a need to execute SQL statement more than once. </p> */ -published service QueryDefinition -{ - - /** access to the owning database definition object. - */ - interface com::sun::star::beans::XPropertySet; - - - /** is the name of the definition. - */ - [readonly, property] string Name; - - - /** is the command of the query, this is typically a select statement. - */ - [property] string Command; - - - /** should we use escape processing for the query. - */ - [property] boolean EscapeProcessing; - - - /** is the name of the table which should be updated. This is usually used - for queries which relate on more than one table. - */ - [property] string UpdateTableName; - - - /** is the name of the update table catalog. - */ - [property] string UpdateCatalogName; - - - /** is the name of the update table schema. - */ - [property] string UpdateSchemaName; -}; +published service QueryDefinition : XQueryDefinition; }; }; }; }; diff --git a/offapi/com/sun/star/sdb/XQueryDefinition.idl b/offapi/com/sun/star/sdb/XQueryDefinition.idl new file mode 100644 index 0000000..064a7bb --- /dev/null +++ b/offapi/com/sun/star/sdb/XQueryDefinition.idl @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ +#ifndef __com_sun_star_sdb_XQueryDefinition_idl__ +#define __com_sun_star_sdb_XQueryDefinition_idl__ + +#include <com/sun/star/beans/XPropertySet.idl> +#include <com/sun/star/ucb/XContent.idl> +#include <com/sun/star/lang/XComponent.idl> + + module com { module sun { module star { module sdb { + + +/** + @since LibreOffice 4.1 + */ +published interface XQueryDefinition +{ + + /** access to the owning database definition object. + */ + interface com::sun::star::beans::XPropertySet; + + interface com::sun::star::ucb::XContent; + + interface com::sun::star::lang::XComponent; + +}; + + +}; }; }; }; + +/*=========================================================================== +===========================================================================*/ +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/type_reference/types.rdb b/offapi/type_reference/types.rdb index f348396..b0c2c88 100644 --- a/offapi/type_reference/types.rdb +++ b/offapi/type_reference/types.rdb Binary files differ -- To view, visit https://gerrit.libreoffice.org/3031 To unsubscribe, visit https://gerrit.libreoffice.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I694dd16920304d0f07369e97c87a4a97b92eadeb Gerrit-PatchSet: 1 Gerrit-Project: core Gerrit-Branch: master Gerrit-Owner: Noel Grandin <noelgran...@gmail.com> _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice