LibreOffice Module dbaccess (master) 1
commanddefinition.cxx
Go to the documentation of this file.
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 <stringconstants.hxx>
22#include <strings.hxx>
23
24#include <com/sun/star/container/ElementExistException.hpp>
25#include <com/sun/star/beans/PropertyAttribute.hpp>
26
27
28using namespace ::com::sun::star::uno;
29using namespace ::com::sun::star::sdbc;
30using namespace ::com::sun::star::lang;
31using namespace ::com::sun::star::beans;
32using namespace ::com::sun::star::container;
33
34namespace dbaccess
35{
36
38{
39 OCommandDefinition_Impl& rCommandDefinition = dynamic_cast< OCommandDefinition_Impl& >( *m_pImpl );
40 registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
41 &rCommandDefinition.m_sCommand, cppu::UnoType<decltype(rCommandDefinition.m_sCommand)>::get());
42
44 &rCommandDefinition.m_bEscapeProcessing, cppu::UnoType<bool>::get());
45
47 &rCommandDefinition.m_sUpdateTableName, cppu::UnoType<decltype(rCommandDefinition.m_sUpdateTableName)>::get());
48
50 &rCommandDefinition.m_sUpdateSchemaName, cppu::UnoType<decltype(rCommandDefinition.m_sUpdateSchemaName)>::get());
51
53 &rCommandDefinition.m_sUpdateCatalogName, cppu::UnoType<decltype(rCommandDefinition.m_sUpdateCatalogName)>::get());
55 &rCommandDefinition.m_aLayoutInformation, cppu::UnoType<decltype(rCommandDefinition.m_aLayoutInformation)>::get());
56}
57
58OCommandDefinition::OCommandDefinition(const Reference< XComponentContext >& _xORB
59 ,const Reference< XInterface >& _rxContainer
60 ,const TContentPtr& _pImpl)
61 :OComponentDefinition(_xORB,_rxContainer,_pImpl,false)
62{
64}
65
67{
68}
69
70OCommandDefinition::OCommandDefinition( const Reference< XInterface >& _rxContainer
71 ,const OUString& _rElementName
72 ,const Reference< XComponentContext >& _xORB
73 ,const TContentPtr& _pImpl)
74 :OComponentDefinition(_rxContainer,_rElementName,_xORB,_pImpl,false)
75{
77}
78
79css::uno::Sequence<sal_Int8> OCommandDefinition::getImplementationId()
80{
81 return css::uno::Sequence<sal_Int8>();
82}
83
84css::uno::Sequence< css::uno::Type > OCommandDefinition::getTypes()
85{
86 return ::comphelper::concatSequences(
89 );
90}
92css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OCommandDefinition::getPropertySetInfo()
93{
94 Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
95 return xInfo;
96}
98{
100}
102{
103 css::uno::Sequence< css::beans::Property > aProps;
104 describeProperties(aProps);
105 return new ::cppu::OPropertyArrayHelper(aProps);
106}
107
108
110{
111 return "com.sun.star.comp.dba.OCommandDefinition";
112}
113
114css::uno::Sequence<OUString> SAL_CALL OCommandDefinition::getSupportedServiceNames()
115{
116 return {
117 "com.sun.star.sdb.QueryDefinition",
118 "com.sun.star.sdb.CommandDefinition",
119 "com.sun.star.ucb.Content"
120 };
121}
122
123void SAL_CALL OCommandDefinition::rename( const OUString& newName )
124{
125 try
126 {
127 sal_Int32 nHandle = PROPERTY_ID_NAME;
128 osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex);
129 Any aOld(m_pImpl->m_aProps.aTitle);
130 aGuard.clear();
131 Any aNew(newName);
132 fire(&nHandle, &aNew, &aOld, 1, true );
133
134 m_pImpl->m_aProps.aTitle = newName;
135 fire(&nHandle, &aNew, &aOld, 1, false );
136 }
137 catch(const PropertyVetoException&)
138 {
139 throw ElementExistException(newName,*this);
140 }
141}
142
143} // namespace dbaccess
144
145extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
146com_sun_star_comp_dba_OCommandDefinition(css::uno::XComponentContext* context,
147 css::uno::Sequence<css::uno::Any> const &)
148{
149 return cppu::acquire(new dbaccess::OCommandDefinition(
150 context, nullptr, std::make_shared<dbaccess::OCommandDefinition_Impl>() ));
151}
152
153/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::cppu::IPropertyArrayHelper * getArrayHelper()
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
void registerProperty(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
mutable::osl::Mutex m_aMutex
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
css::uno::Sequence< css::beans::PropertyValue > m_aLayoutInformation
Definition: commandbase.hxx:35
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~OCommandDefinition() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual cppu::IPropertyArrayHelper * createArrayHelper() const override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual void SAL_CALL rename(const OUString &newName) override
OCommandDefinition(const css::uno::Reference< css::uno::XComponentContext > &, const css::uno::Reference< css::uno::XInterface > &_xParentContainer, const TContentPtr &_pImpl)
virtual OUString SAL_CALL getImplementationName() override
virtual cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_dba_OCommandDefinition(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
std::shared_ptr< OContentHelper_Impl > TContentPtr
OUString newName(std::u16string_view aNewPrefix, std::u16string_view aOldPrefix, std::u16string_view old_Name)
sal_Int32 nHandle
IMPLEMENT_FORWARD_XINTERFACE2(OStatement, OStatementBase, OStatement_IFACE)
#define PROPERTY_ID_NAME
#define PROPERTY_ID_ESCAPE_PROCESSING
#define PROPERTY_ID_UPDATE_CATALOGNAME
#define PROPERTY_ID_UPDATE_SCHEMANAME
#define PROPERTY_ID_COMMAND
#define PROPERTY_ID_UPDATE_TABLENAME
#define PROPERTY_ID_LAYOUTINFORMATION
constexpr OUStringLiteral PROPERTY_COMMAND(u"Command")
constexpr OUStringLiteral PROPERTY_UPDATE_TABLENAME(u"UpdateTableName")
constexpr OUStringLiteral PROPERTY_UPDATE_SCHEMANAME(u"UpdateSchemaName")
constexpr OUStringLiteral PROPERTY_ESCAPE_PROCESSING(u"EscapeProcessing")
constexpr OUStringLiteral PROPERTY_UPDATE_CATALOGNAME(u"UpdateCatalogName")
constexpr OUStringLiteral PROPERTY_LAYOUTINFORMATION(u"LayoutInformation")