Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "commanddefinition.hxx"
21 : #include "apitools.hxx"
22 : #include "dbastrings.hrc"
23 : #include "module_dba.hxx"
24 : #include "services.hxx"
25 :
26 : #include <com/sun/star/lang/DisposedException.hpp>
27 : #include <com/sun/star/beans/PropertyAttribute.hpp>
28 :
29 : #include <tools/debug.hxx>
30 : #include <comphelper/sequence.hxx>
31 :
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;
40 :
41 : // OCommandDefinition
42 20 : extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition()
43 : {
44 20 : static ::dba::OAutoRegistration< ::dbaccess::OCommandDefinition > aAutoRegistration;
45 20 : }
46 :
47 : namespace dbaccess
48 : {
49 :
50 41 : void OCommandDefinition::registerProperties()
51 : {
52 41 : OCommandDefinition_Impl& rCommandDefinition( getCommandDefinition() );
53 : registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
54 41 : &rCommandDefinition.m_sCommand, cppu::UnoType<decltype(rCommandDefinition.m_sCommand)>::get());
55 :
56 : registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
57 41 : &rCommandDefinition.m_bEscapeProcessing, cppu::UnoType<bool>::get());
58 :
59 : registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
60 41 : &rCommandDefinition.m_sUpdateTableName, cppu::UnoType<decltype(rCommandDefinition.m_sUpdateTableName)>::get());
61 :
62 : registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
63 41 : &rCommandDefinition.m_sUpdateSchemaName, cppu::UnoType<decltype(rCommandDefinition.m_sUpdateSchemaName)>::get());
64 :
65 : registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
66 41 : &rCommandDefinition.m_sUpdateCatalogName, cppu::UnoType<decltype(rCommandDefinition.m_sUpdateCatalogName)>::get());
67 : registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
68 41 : &rCommandDefinition.m_aLayoutInformation, cppu::UnoType<decltype(rCommandDefinition.m_aLayoutInformation)>::get());
69 41 : }
70 :
71 0 : OUString OCommandDefinition::getName() throw( ::com::sun::star::uno::RuntimeException )
72 : {
73 0 : return getDefinition().m_aProps.aTitle;
74 : }
75 :
76 0 : OUString OCommandDefinition::getCommand() throw( ::com::sun::star::uno::RuntimeException )
77 : {
78 0 : return getCommandDefinition().m_sCommand;
79 : }
80 :
81 0 : void OCommandDefinition::setCommand(const OUString& p1) throw( ::com::sun::star::uno::RuntimeException )
82 : {
83 0 : setPropertyValue(PROPERTY_COMMAND, Any(p1) );
84 0 : }
85 :
86 0 : bool OCommandDefinition::getEscapeProcessing() throw( ::com::sun::star::uno::RuntimeException )
87 : {
88 0 : return getCommandDefinition().m_bEscapeProcessing;
89 : }
90 :
91 0 : void OCommandDefinition::setEscapeProcessing(bool p1) throw( ::com::sun::star::uno::RuntimeException )
92 : {
93 0 : setPropertyValue(PROPERTY_ESCAPE_PROCESSING, Any(p1) );
94 0 : }
95 :
96 0 : OUString OCommandDefinition::getUpdateTableName() throw( ::com::sun::star::uno::RuntimeException )
97 : {
98 0 : return getCommandDefinition().m_sUpdateTableName;
99 : }
100 :
101 0 : void OCommandDefinition::setUpdateTableName(const OUString& p1) throw( ::com::sun::star::uno::RuntimeException )
102 : {
103 0 : setPropertyValue(PROPERTY_UPDATE_TABLENAME, Any(p1) );
104 0 : }
105 :
106 0 : OUString OCommandDefinition::getUpdateCatalogName() throw( ::com::sun::star::uno::RuntimeException )
107 : {
108 0 : return getCommandDefinition().m_sUpdateCatalogName;
109 : }
110 :
111 0 : void OCommandDefinition::setUpdateCatalogName(const OUString& p1) throw( ::com::sun::star::uno::RuntimeException )
112 : {
113 0 : setPropertyValue(PROPERTY_UPDATE_CATALOGNAME, Any(p1) );
114 0 : }
115 :
116 0 : OUString OCommandDefinition::getUpdateSchemaName() throw( ::com::sun::star::uno::RuntimeException )
117 : {
118 0 : return getCommandDefinition().m_sUpdateSchemaName;
119 : }
120 :
121 0 : void OCommandDefinition::setUpdateSchemaName(const OUString& p1) throw( ::com::sun::star::uno::RuntimeException )
122 : {
123 0 : setPropertyValue(PROPERTY_UPDATE_SCHEMANAME, Any(p1) );
124 0 : }
125 :
126 32 : OCommandDefinition::OCommandDefinition(const Reference< XComponentContext >& _xORB
127 : ,const Reference< XInterface >& _rxContainer
128 : ,const TContentPtr& _pImpl)
129 32 : :OComponentDefinition(_xORB,_rxContainer,_pImpl,false)
130 : {
131 32 : registerProperties();
132 32 : }
133 :
134 82 : OCommandDefinition::~OCommandDefinition()
135 : {
136 82 : }
137 :
138 9 : OCommandDefinition::OCommandDefinition( const Reference< XInterface >& _rxContainer
139 : ,const OUString& _rElementName
140 : ,const Reference< XComponentContext >& _xORB
141 : ,const TContentPtr& _pImpl)
142 9 : :OComponentDefinition(_rxContainer,_rElementName,_xORB,_pImpl,false)
143 : {
144 9 : registerProperties();
145 9 : }
146 :
147 0 : css::uno::Sequence<sal_Int8> OCommandDefinition::getImplementationId()
148 : throw (css::uno::RuntimeException, std::exception)
149 : {
150 0 : return css::uno::Sequence<sal_Int8>();
151 : }
152 :
153 0 : IMPLEMENT_GETTYPES2(OCommandDefinition,OCommandDefinition_Base,OComponentDefinition);
154 3658 : IMPLEMENT_FORWARD_XINTERFACE2( OCommandDefinition,OComponentDefinition,OCommandDefinition_Base)
155 654 : IMPLEMENT_PROPERTYCONTAINER_DEFAULTS2(OCommandDefinition,OCommandDefinition_PROP)
156 :
157 22 : OUString OCommandDefinition::getImplementationName_static( ) throw(RuntimeException)
158 : {
159 22 : return OUString("com.sun.star.comp.dba.OCommandDefinition");
160 : }
161 :
162 2 : OUString SAL_CALL OCommandDefinition::getImplementationName( ) throw(RuntimeException, std::exception)
163 : {
164 2 : return getImplementationName_static();
165 : }
166 :
167 23 : Sequence< OUString > OCommandDefinition::getSupportedServiceNames_static( ) throw(RuntimeException)
168 : {
169 23 : Sequence< OUString > aServices(3);
170 23 : aServices.getArray()[0] = "com.sun.star.sdb.QueryDefinition";
171 23 : aServices.getArray()[1] = "com.sun.star.sdb.CommandDefinition";
172 23 : aServices.getArray()[2] = "com.sun.star.ucb.Content";
173 23 : return aServices;
174 : }
175 :
176 3 : Sequence< OUString > SAL_CALL OCommandDefinition::getSupportedServiceNames( ) throw(RuntimeException, std::exception)
177 : {
178 3 : return getSupportedServiceNames_static();
179 : }
180 :
181 32 : Reference< XInterface > OCommandDefinition::Create(const Reference< XComponentContext >& _rxContext)
182 : {
183 32 : return *(new OCommandDefinition( _rxContext, NULL, TContentPtr( new OCommandDefinition_Impl ) ) );
184 : }
185 :
186 25 : void SAL_CALL OCommandDefinition::rename( const OUString& newName ) throw (SQLException, ElementExistException, RuntimeException, std::exception)
187 : {
188 : try
189 : {
190 25 : sal_Int32 nHandle = PROPERTY_ID_NAME;
191 25 : osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
192 50 : Any aOld = makeAny(m_pImpl->m_aProps.aTitle);
193 25 : aGuard.clear();
194 50 : Any aNew = makeAny(newName);
195 25 : fire(&nHandle, &aNew, &aOld, 1, sal_True );
196 :
197 25 : m_pImpl->m_aProps.aTitle = newName;
198 50 : fire(&nHandle, &aNew, &aOld, 1, sal_False );
199 : }
200 0 : catch(const PropertyVetoException&)
201 : {
202 0 : throw ElementExistException(newName,*this);
203 : }
204 25 : }
205 :
206 : } // namespace dbaccess
207 :
208 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|