Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / core / dataaccess / commanddefinition.cxx
blob89b2ed39405df0d71a76dc980d5c867e73ef9c61
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "commanddefinition.hxx"
21 #include "apitools.hxx"
22 #include "dbastrings.hrc"
23 #include "module_dba.hxx"
24 #include "services.hxx"
26 #include <com/sun/star/lang/DisposedException.hpp>
27 #include <com/sun/star/beans/PropertyAttribute.hpp>
29 #include <tools/debug.hxx>
30 #include <comphelper/sequence.hxx>
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::sdbc;
34 using namespace ::com::sun::star::lang;
35 using namespace ::com::sun::star::beans;
36 using namespace ::com::sun::star::container;
37 using namespace ::osl;
38 using namespace ::comphelper;
39 using namespace ::cppu;
41 // OCommandDefinition
42 extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition()
44 static ::dba::OAutoRegistration< ::dbaccess::OCommandDefinition > aAutoRegistration;
47 namespace dbaccess
50 void OCommandDefinition::registerProperties()
52 OCommandDefinition_Impl& rCommandDefinition( getCommandDefinition() );
53 registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
54 &rCommandDefinition.m_sCommand, cppu::UnoType<decltype(rCommandDefinition.m_sCommand)>::get());
56 registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
57 &rCommandDefinition.m_bEscapeProcessing, cppu::UnoType<bool>::get());
59 registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
60 &rCommandDefinition.m_sUpdateTableName, cppu::UnoType<decltype(rCommandDefinition.m_sUpdateTableName)>::get());
62 registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
63 &rCommandDefinition.m_sUpdateSchemaName, cppu::UnoType<decltype(rCommandDefinition.m_sUpdateSchemaName)>::get());
65 registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
66 &rCommandDefinition.m_sUpdateCatalogName, cppu::UnoType<decltype(rCommandDefinition.m_sUpdateCatalogName)>::get());
67 registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
68 &rCommandDefinition.m_aLayoutInformation, cppu::UnoType<decltype(rCommandDefinition.m_aLayoutInformation)>::get());
71 OUString OCommandDefinition::getName() throw( ::com::sun::star::uno::RuntimeException )
73 return getDefinition().m_aProps.aTitle;
76 OUString OCommandDefinition::getCommand() throw( ::com::sun::star::uno::RuntimeException )
78 return getCommandDefinition().m_sCommand;
81 void OCommandDefinition::setCommand(const OUString& p1) throw( ::com::sun::star::uno::RuntimeException )
83 setPropertyValue(PROPERTY_COMMAND, Any(p1) );
86 bool OCommandDefinition::getEscapeProcessing() throw( ::com::sun::star::uno::RuntimeException )
88 return getCommandDefinition().m_bEscapeProcessing;
91 void OCommandDefinition::setEscapeProcessing(bool p1) throw( ::com::sun::star::uno::RuntimeException )
93 setPropertyValue(PROPERTY_ESCAPE_PROCESSING, Any(p1) );
96 OUString OCommandDefinition::getUpdateTableName() throw( ::com::sun::star::uno::RuntimeException )
98 return getCommandDefinition().m_sUpdateTableName;
101 void OCommandDefinition::setUpdateTableName(const OUString& p1) throw( ::com::sun::star::uno::RuntimeException )
103 setPropertyValue(PROPERTY_UPDATE_TABLENAME, Any(p1) );
106 OUString OCommandDefinition::getUpdateCatalogName() throw( ::com::sun::star::uno::RuntimeException )
108 return getCommandDefinition().m_sUpdateCatalogName;
111 void OCommandDefinition::setUpdateCatalogName(const OUString& p1) throw( ::com::sun::star::uno::RuntimeException )
113 setPropertyValue(PROPERTY_UPDATE_CATALOGNAME, Any(p1) );
116 OUString OCommandDefinition::getUpdateSchemaName() throw( ::com::sun::star::uno::RuntimeException )
118 return getCommandDefinition().m_sUpdateSchemaName;
121 void OCommandDefinition::setUpdateSchemaName(const OUString& p1) throw( ::com::sun::star::uno::RuntimeException )
123 setPropertyValue(PROPERTY_UPDATE_SCHEMANAME, Any(p1) );
126 OCommandDefinition::OCommandDefinition(const Reference< XComponentContext >& _xORB
127 ,const Reference< XInterface >& _rxContainer
128 ,const TContentPtr& _pImpl)
129 :OComponentDefinition(_xORB,_rxContainer,_pImpl,false)
131 registerProperties();
134 OCommandDefinition::~OCommandDefinition()
138 OCommandDefinition::OCommandDefinition( const Reference< XInterface >& _rxContainer
139 ,const OUString& _rElementName
140 ,const Reference< XComponentContext >& _xORB
141 ,const TContentPtr& _pImpl)
142 :OComponentDefinition(_rxContainer,_rElementName,_xORB,_pImpl,false)
144 registerProperties();
147 css::uno::Sequence<sal_Int8> OCommandDefinition::getImplementationId()
148 throw (css::uno::RuntimeException, std::exception)
150 return css::uno::Sequence<sal_Int8>();
153 IMPLEMENT_GETTYPES2(OCommandDefinition,OCommandDefinition_Base,OComponentDefinition);
154 IMPLEMENT_FORWARD_XINTERFACE2( OCommandDefinition,OComponentDefinition,OCommandDefinition_Base)
155 IMPLEMENT_PROPERTYCONTAINER_DEFAULTS2(OCommandDefinition,OCommandDefinition_PROP)
157 OUString OCommandDefinition::getImplementationName_static( ) throw(RuntimeException)
159 return OUString("com.sun.star.comp.dba.OCommandDefinition");
162 OUString SAL_CALL OCommandDefinition::getImplementationName( ) throw(RuntimeException, std::exception)
164 return getImplementationName_static();
167 Sequence< OUString > OCommandDefinition::getSupportedServiceNames_static( ) throw(RuntimeException)
169 Sequence< OUString > aServices(3);
170 aServices.getArray()[0] = "com.sun.star.sdb.QueryDefinition";
171 aServices.getArray()[1] = "com.sun.star.sdb.CommandDefinition";
172 aServices.getArray()[2] = "com.sun.star.ucb.Content";
173 return aServices;
176 Sequence< OUString > SAL_CALL OCommandDefinition::getSupportedServiceNames( ) throw(RuntimeException, std::exception)
178 return getSupportedServiceNames_static();
181 Reference< XInterface > OCommandDefinition::Create(const Reference< XComponentContext >& _rxContext)
183 return *(new OCommandDefinition( _rxContext, NULL, TContentPtr( new OCommandDefinition_Impl ) ) );
186 void SAL_CALL OCommandDefinition::rename( const OUString& newName ) throw (SQLException, ElementExistException, RuntimeException, std::exception)
190 sal_Int32 nHandle = PROPERTY_ID_NAME;
191 osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
192 Any aOld = makeAny(m_pImpl->m_aProps.aTitle);
193 aGuard.clear();
194 Any aNew = makeAny(newName);
195 fire(&nHandle, &aNew, &aOld, 1, sal_True );
197 m_pImpl->m_aProps.aTitle = newName;
198 fire(&nHandle, &aNew, &aOld, 1, sal_False );
200 catch(const PropertyVetoException&)
202 throw ElementExistException(newName,*this);
206 } // namespace dbaccess
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */