1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <stringconstants.hxx>
22 #include <strings.hxx>
24 #include <com/sun/star/container/ElementExistException.hpp>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
28 using namespace ::com::sun::star::uno
;
29 using namespace ::com::sun::star::beans
;
30 using namespace ::com::sun::star::container
;
35 void OCommandDefinition::registerProperties()
37 OCommandDefinition_Impl
& rCommandDefinition
= dynamic_cast< OCommandDefinition_Impl
& >( *m_pImpl
);
38 registerProperty(PROPERTY_COMMAND
, PROPERTY_ID_COMMAND
, PropertyAttribute::BOUND
,
39 &rCommandDefinition
.m_sCommand
, cppu::UnoType
<decltype(rCommandDefinition
.m_sCommand
)>::get());
41 registerProperty(PROPERTY_ESCAPE_PROCESSING
, PROPERTY_ID_ESCAPE_PROCESSING
, PropertyAttribute::BOUND
,
42 &rCommandDefinition
.m_bEscapeProcessing
, cppu::UnoType
<bool>::get());
44 registerProperty(PROPERTY_UPDATE_TABLENAME
, PROPERTY_ID_UPDATE_TABLENAME
, PropertyAttribute::BOUND
,
45 &rCommandDefinition
.m_sUpdateTableName
, cppu::UnoType
<decltype(rCommandDefinition
.m_sUpdateTableName
)>::get());
47 registerProperty(PROPERTY_UPDATE_SCHEMANAME
, PROPERTY_ID_UPDATE_SCHEMANAME
, PropertyAttribute::BOUND
,
48 &rCommandDefinition
.m_sUpdateSchemaName
, cppu::UnoType
<decltype(rCommandDefinition
.m_sUpdateSchemaName
)>::get());
50 registerProperty(PROPERTY_UPDATE_CATALOGNAME
, PROPERTY_ID_UPDATE_CATALOGNAME
, PropertyAttribute::BOUND
,
51 &rCommandDefinition
.m_sUpdateCatalogName
, cppu::UnoType
<decltype(rCommandDefinition
.m_sUpdateCatalogName
)>::get());
52 registerProperty(PROPERTY_LAYOUTINFORMATION
, PROPERTY_ID_LAYOUTINFORMATION
, PropertyAttribute::BOUND
,
53 &rCommandDefinition
.m_aLayoutInformation
, cppu::UnoType
<decltype(rCommandDefinition
.m_aLayoutInformation
)>::get());
56 OCommandDefinition::OCommandDefinition(const Reference
< XComponentContext
>& _xORB
57 ,const Reference
< XInterface
>& _rxContainer
58 ,const TContentPtr
& _pImpl
)
59 :OComponentDefinition(_xORB
,_rxContainer
,_pImpl
,false)
64 OCommandDefinition::~OCommandDefinition()
68 OCommandDefinition::OCommandDefinition( const Reference
< XInterface
>& _rxContainer
69 ,const OUString
& _rElementName
70 ,const Reference
< XComponentContext
>& _xORB
71 ,const TContentPtr
& _pImpl
)
72 :OComponentDefinition(_rxContainer
,_rElementName
,_xORB
,_pImpl
,false)
77 css::uno::Sequence
<sal_Int8
> OCommandDefinition::getImplementationId()
79 return css::uno::Sequence
<sal_Int8
>();
82 css::uno::Sequence
< css::uno::Type
> OCommandDefinition::getTypes()
84 return ::comphelper::concatSequences(
85 OCommandDefinition_Base::getTypes( ),
86 OComponentDefinition::getTypes( )
89 IMPLEMENT_FORWARD_XINTERFACE2( OCommandDefinition
,OComponentDefinition
,OCommandDefinition_Base
)
90 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
OCommandDefinition::getPropertySetInfo()
92 Reference
< XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
95 ::cppu::IPropertyArrayHelper
& OCommandDefinition::getInfoHelper()
97 return *OCommandDefinition_PROP::getArrayHelper();
99 ::cppu::IPropertyArrayHelper
* OCommandDefinition::createArrayHelper( ) const
101 css::uno::Sequence
< css::beans::Property
> aProps
;
102 describeProperties(aProps
);
103 return new ::cppu::OPropertyArrayHelper(aProps
);
107 OUString SAL_CALL
OCommandDefinition::getImplementationName()
109 return u
"com.sun.star.comp.dba.OCommandDefinition"_ustr
;
112 css::uno::Sequence
<OUString
> SAL_CALL
OCommandDefinition::getSupportedServiceNames()
115 u
"com.sun.star.sdb.QueryDefinition"_ustr
,
116 u
"com.sun.star.sdb.CommandDefinition"_ustr
,
117 u
"com.sun.star.ucb.Content"_ustr
121 void SAL_CALL
OCommandDefinition::rename( const OUString
& newName
)
125 sal_Int32 nHandle
= PROPERTY_ID_NAME
;
126 osl::ClearableGuard
< osl::Mutex
> aGuard(m_aMutex
);
127 Any
aOld(m_pImpl
->m_aProps
.aTitle
);
130 fire(&nHandle
, &aNew
, &aOld
, 1, true );
132 m_pImpl
->m_aProps
.aTitle
= newName
;
133 fire(&nHandle
, &aNew
, &aOld
, 1, false );
135 catch(const PropertyVetoException
&)
137 throw ElementExistException(newName
,*this);
141 } // namespace dbaccess
143 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
144 com_sun_star_comp_dba_OCommandDefinition(css::uno::XComponentContext
* context
,
145 css::uno::Sequence
<css::uno::Any
> const &)
147 return cppu::acquire(new dbaccess::OCommandDefinition(
148 context
, nullptr, std::make_shared
<dbaccess::OCommandDefinition_Impl
>() ));
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */