LibreOffice Module dbaccess (master) 1
textconnectionsettings_uno.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
21#include <unoadmin.hxx>
22#include <stringconstants.hxx>
23#include <propertystorage.hxx>
24
25#include <com/sun/star/beans/XPropertySetInfo.hpp>
26#include <com/sun/star/beans/PropertyAttribute.hpp>
27#include <com/sun/star/sdb/XTextConnectionSettings.hpp>
28
32#include <vcl/svapp.hxx>
34
35namespace dbaui
36{
37
38 using ::com::sun::star::uno::Reference;
39 using ::com::sun::star::uno::XInterface;
40 using ::com::sun::star::uno::Any;
41 using ::com::sun::star::uno::XComponentContext;
42 using ::com::sun::star::beans::XPropertySetInfo;
43 using ::com::sun::star::uno::Sequence;
44 using ::com::sun::star::beans::Property;
45
46 namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
47
48 // OTextConnectionSettingsDialog
49
50 namespace {
51
52 class OTextConnectionSettingsDialog;
53
54 }
55
56 typedef ::cppu::ImplInheritanceHelper< ODatabaseAdministrationDialog
57 , css::sdb::XTextConnectionSettings
59 typedef ::comphelper::OPropertyArrayUsageHelper< OTextConnectionSettingsDialog > OTextConnectionSettingsDialog_PBASE;
60
61 namespace {
62
63 class OTextConnectionSettingsDialog
66 {
68
69 public:
70 explicit OTextConnectionSettingsDialog( const Reference<XComponentContext>& _rContext );
71
72 virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override;
73
75 virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
76 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
77 virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override;
78
79
80 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) override;
81 virtual sal_Bool SAL_CALL convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) override;
82 virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const override;
83
84 // Overrides to resolve inheritance ambiguity
85 virtual void SAL_CALL setPropertyValue(const OUString& p1, const css::uno::Any& p2) override
86 { ODatabaseAdministrationDialog::setPropertyValue(p1, p2); }
87 virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& p1) override
88 { return ODatabaseAdministrationDialog::getPropertyValue(p1); }
89 virtual void SAL_CALL addPropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) override
90 { ODatabaseAdministrationDialog::addPropertyChangeListener(p1, p2); }
91 virtual void SAL_CALL removePropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) override
92 { ODatabaseAdministrationDialog::removePropertyChangeListener(p1, p2); }
93 virtual void SAL_CALL addVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) override
94 { ODatabaseAdministrationDialog::addVetoableChangeListener(p1, p2); }
95 virtual void SAL_CALL removeVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) override
96 { ODatabaseAdministrationDialog::removeVetoableChangeListener(p1, p2); }
97 virtual void SAL_CALL setTitle(const OUString& p1) override
99 virtual sal_Int16 SAL_CALL execute() override
101
102 protected:
103 // OGenericUnoDialog overridables
104 virtual std::unique_ptr<weld::DialogController> createDialog(const css::uno::Reference<css::awt::XWindow>& rParent) override;
105 using OTextConnectionSettingsDialog_BASE::getFastPropertyValue;
106 };
107
108 }
109
110 // OTextConnectionSettingsDialog
111 OTextConnectionSettingsDialog::OTextConnectionSettingsDialog( const Reference<XComponentContext>& _rContext )
113 {
114 TextConnectionSettingsDialog::bindItemStorages( *m_pDatasourceItems, m_aPropertyValues );
115 }
116
117 css::uno::Sequence<sal_Int8>
118 OTextConnectionSettingsDialog::getImplementationId()
119 {
120 return css::uno::Sequence<sal_Int8>();
121 }
122
123 OUString SAL_CALL OTextConnectionSettingsDialog::getImplementationName()
124 {
125 return "com.sun.star.comp.dbaccess.OTextConnectionSettingsDialog";
126 }
127 sal_Bool SAL_CALL OTextConnectionSettingsDialog::supportsService(const OUString& _rServiceName)
128 {
129 const css::uno::Sequence< OUString > aSupported(getSupportedServiceNames());
130 for (const OUString& s : aSupported)
131 if (s == _rServiceName)
132 return true;
133
134 return false;
135 }
136 css::uno::Sequence< OUString > SAL_CALL OTextConnectionSettingsDialog::getSupportedServiceNames()
137 {
138 return { "com.sun.star.sdb.TextConnectionSettings" };
139 }
140
141 Reference< XPropertySetInfo > SAL_CALL OTextConnectionSettingsDialog::getPropertySetInfo()
142 {
143 return createPropertySetInfo( getInfoHelper() );
144 }
145
146 ::cppu::IPropertyArrayHelper& OTextConnectionSettingsDialog::getInfoHelper()
147 {
148 return *getArrayHelper();
149 }
150
151 ::cppu::IPropertyArrayHelper* OTextConnectionSettingsDialog::createArrayHelper( ) const
152 {
153 Sequence< Property > aProps;
154 describeProperties( aProps );
155
156 // in addition to the properties registered by the base class, we have
157 // more properties which are not even handled by the PropertyContainer implementation,
158 // but whose values are stored in our item set
159 sal_Int32 nProp = aProps.getLength();
160 aProps.realloc( nProp + 6 );
161 auto pProps = aProps.getArray();
162
163 pProps[ nProp++ ] = Property(
164 "HeaderLine",
167 PropertyAttribute::TRANSIENT
168 );
169
170 pProps[ nProp++ ] = Property(
171 "FieldDelimiter",
174 PropertyAttribute::TRANSIENT
175 );
176
177 pProps[ nProp++ ] = Property(
178 "StringDelimiter",
181 PropertyAttribute::TRANSIENT
182 );
183
184 pProps[ nProp++ ] = Property(
185 "DecimalDelimiter",
188 PropertyAttribute::TRANSIENT
189 );
190
191 pProps[ nProp++ ] = Property(
192 "ThousandDelimiter",
195 PropertyAttribute::TRANSIENT
196 );
197
198 pProps[ nProp++ ] = Property(
199 "CharSet",
202 PropertyAttribute::TRANSIENT
203 );
204
205 return new ::cppu::OPropertyArrayHelper( aProps );
206 }
207
208 std::unique_ptr<weld::DialogController> OTextConnectionSettingsDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
209 {
210 return std::make_unique<TextConnectionSettingsDialog>(Application::GetFrameWeld(rParent), *m_pDatasourceItems);
211 }
212
213 void SAL_CALL OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue )
214 {
215 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
216 if ( pos != m_aPropertyValues.end() )
217 {
218 pos->second->setPropertyValue( _rValue );
219 }
220 else
221 {
222 OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
223 }
224 }
225
226 sal_Bool SAL_CALL OTextConnectionSettingsDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
227 {
228 bool bModified = false;
229
230 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
231 if ( pos != m_aPropertyValues.end() )
232 {
233 // we're lazy here ...
234 _rConvertedValue = _rValue;
235 pos->second->getPropertyValue( _rOldValue );
236 bModified = true;
237 }
238 else
239 {
240 bModified = OTextConnectionSettingsDialog::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
241 }
242
243 return bModified;
244 }
245
246 void SAL_CALL OTextConnectionSettingsDialog::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
247 {
248 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
249 if ( pos != m_aPropertyValues.end() )
250 {
251 pos->second->getPropertyValue( _rValue );
252 }
253 else
254 {
255 OTextConnectionSettingsDialog::getFastPropertyValue( _rValue, _nHandle );
256 }
257 }
258
259} // namespace dbaui
260
261extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
263 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
264{
265 return cppu::acquire(static_cast<dbaui::ODatabaseAdministrationDialog*>(new ::dbaui::OTextConnectionSettingsDialog(context)));
266}
267
268/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define DECLARE_SERVICE_INFO()
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
virtual void SAL_CALL setTitle(const OUString &aTitle) override
virtual sal_Int16 SAL_CALL execute() override
css::uno::Sequence< OUString > getSupportedServiceNames()
::cppu::ImplInheritanceHelper< ODatabaseAdministrationDialog, css::sdb::XTextConnectionSettings > OTextConnectionSettingsDialog_BASE
::comphelper::OPropertyArrayUsageHelper< OTextConnectionSettingsDialog > OTextConnectionSettingsDialog_PBASE
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
::std::map< PropertyId, css::uno::Any > PropertyValues
#define PROPERTY_ID_HEADER_LINE
#define PROPERTY_ID_FIELD_DELIMITER
#define PROPERTY_ID_ENCODING
#define PROPERTY_ID_STRING_DELIMITER
#define PROPERTY_ID_THOUSAND_DELIMITER
#define PROPERTY_ID_DECIMAL_DELIMITER
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_dbaccess_OTextConnectionSettingsDialog_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
PropertyValues m_aPropertyValues
unsigned char sal_Bool
size_t pos