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 <textconnectionsettings.hxx>
21 #include <unoadmin.hxx>
22 #include <stringconstants.hxx>
23 #include <propertystorage.hxx>
25 #include <com/sun/star/beans/XPropertySetInfo.hpp>
26 #include <com/sun/star/beans/PropertyAttribute.hpp>
27 #include <com/sun/star/sdb/XTextConnectionSettings.hpp>
29 #include <comphelper/proparrhlp.hxx>
30 #include <connectivity/CommonTools.hxx>
31 #include <toolkit/helper/vclunohelper.hxx>
32 #include <vcl/svapp.hxx>
33 #include <cppuhelper/implbase.hxx>
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
;
46 namespace PropertyAttribute
= ::com::sun::star::beans::PropertyAttribute
;
48 // OTextConnectionSettingsDialog
52 class OTextConnectionSettingsDialog
;
56 typedef ::cppu::ImplInheritanceHelper
< ODatabaseAdministrationDialog
57 , css::sdb::XTextConnectionSettings
58 > OTextConnectionSettingsDialog_BASE
;
59 typedef ::comphelper::OPropertyArrayUsageHelper
< OTextConnectionSettingsDialog
> OTextConnectionSettingsDialog_PBASE
;
63 class OTextConnectionSettingsDialog
64 :public OTextConnectionSettingsDialog_BASE
65 ,public OTextConnectionSettingsDialog_PBASE
67 PropertyValues m_aPropertyValues
;
70 explicit OTextConnectionSettingsDialog( const Reference
<XComponentContext
>& _rContext
);
72 virtual css::uno::Sequence
<sal_Int8
> SAL_CALL
getImplementationId() override
;
74 DECLARE_SERVICE_INFO();
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
;
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
;
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
98 { ODatabaseAdministrationDialog::setTitle(p1
); }
99 virtual sal_Int16 SAL_CALL
execute() override
100 { return ODatabaseAdministrationDialog::execute(); }
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
;
110 // OTextConnectionSettingsDialog
111 OTextConnectionSettingsDialog::OTextConnectionSettingsDialog( const Reference
<XComponentContext
>& _rContext
)
112 :OTextConnectionSettingsDialog_BASE( _rContext
)
114 TextConnectionSettingsDialog::bindItemStorages( *m_pDatasourceItems
, m_aPropertyValues
);
117 css::uno::Sequence
<sal_Int8
>
118 OTextConnectionSettingsDialog::getImplementationId()
120 return css::uno::Sequence
<sal_Int8
>();
123 OUString SAL_CALL
OTextConnectionSettingsDialog::getImplementationName()
125 return u
"com.sun.star.comp.dbaccess.OTextConnectionSettingsDialog"_ustr
;
127 sal_Bool SAL_CALL
OTextConnectionSettingsDialog::supportsService(const OUString
& _rServiceName
)
129 const css::uno::Sequence
< OUString
> aSupported(getSupportedServiceNames());
130 for (const OUString
& s
: aSupported
)
131 if (s
== _rServiceName
)
136 css::uno::Sequence
< OUString
> SAL_CALL
OTextConnectionSettingsDialog::getSupportedServiceNames()
138 return { u
"com.sun.star.sdb.TextConnectionSettings"_ustr
};
141 Reference
< XPropertySetInfo
> SAL_CALL
OTextConnectionSettingsDialog::getPropertySetInfo()
143 return createPropertySetInfo( getInfoHelper() );
146 ::cppu::IPropertyArrayHelper
& OTextConnectionSettingsDialog::getInfoHelper()
148 return *getArrayHelper();
151 ::cppu::IPropertyArrayHelper
* OTextConnectionSettingsDialog::createArrayHelper( ) const
153 Sequence
< Property
> aProps
;
154 describeProperties( aProps
);
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();
163 pProps
[ nProp
++ ] = Property(
165 PROPERTY_ID_HEADER_LINE
,
166 ::cppu::UnoType
< sal_Bool
>::get(),
167 PropertyAttribute::TRANSIENT
170 pProps
[ nProp
++ ] = Property(
171 u
"FieldDelimiter"_ustr
,
172 PROPERTY_ID_FIELD_DELIMITER
,
173 ::cppu::UnoType
< OUString
>::get(),
174 PropertyAttribute::TRANSIENT
177 pProps
[ nProp
++ ] = Property(
178 u
"StringDelimiter"_ustr
,
179 PROPERTY_ID_STRING_DELIMITER
,
180 ::cppu::UnoType
< OUString
>::get(),
181 PropertyAttribute::TRANSIENT
184 pProps
[ nProp
++ ] = Property(
185 u
"DecimalDelimiter"_ustr
,
186 PROPERTY_ID_DECIMAL_DELIMITER
,
187 ::cppu::UnoType
< OUString
>::get(),
188 PropertyAttribute::TRANSIENT
191 pProps
[ nProp
++ ] = Property(
192 u
"ThousandDelimiter"_ustr
,
193 PROPERTY_ID_THOUSAND_DELIMITER
,
194 ::cppu::UnoType
< OUString
>::get(),
195 PropertyAttribute::TRANSIENT
198 pProps
[ nProp
++ ] = Property(
200 PROPERTY_ID_ENCODING
,
201 ::cppu::UnoType
< OUString
>::get(),
202 PropertyAttribute::TRANSIENT
205 return new ::cppu::OPropertyArrayHelper( aProps
);
208 std::unique_ptr
<weld::DialogController
> OTextConnectionSettingsDialog::createDialog(const css::uno::Reference
<css::awt::XWindow
>& rParent
)
210 return std::make_unique
<TextConnectionSettingsDialog
>(Application::GetFrameWeld(rParent
), *m_pDatasourceItems
);
213 void SAL_CALL
OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle
, const Any
& _rValue
)
215 PropertyValues::const_iterator pos
= m_aPropertyValues
.find( _nHandle
);
216 if ( pos
!= m_aPropertyValues
.end() )
218 pos
->second
->setPropertyValue( _rValue
);
222 OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( _nHandle
, _rValue
);
226 sal_Bool SAL_CALL
OTextConnectionSettingsDialog::convertFastPropertyValue( Any
& _rConvertedValue
, Any
& _rOldValue
, sal_Int32 _nHandle
, const Any
& _rValue
)
228 bool bModified
= false;
230 PropertyValues::const_iterator pos
= m_aPropertyValues
.find( _nHandle
);
231 if ( pos
!= m_aPropertyValues
.end() )
233 // we're lazy here ...
234 _rConvertedValue
= _rValue
;
235 pos
->second
->getPropertyValue( _rOldValue
);
240 bModified
= OTextConnectionSettingsDialog::convertFastPropertyValue( _rConvertedValue
, _rOldValue
, _nHandle
, _rValue
);
246 void SAL_CALL
OTextConnectionSettingsDialog::getFastPropertyValue( Any
& _rValue
, sal_Int32 _nHandle
) const
248 PropertyValues::const_iterator pos
= m_aPropertyValues
.find( _nHandle
);
249 if ( pos
!= m_aPropertyValues
.end() )
251 pos
->second
->getPropertyValue( _rValue
);
255 OTextConnectionSettingsDialog::getFastPropertyValue( _rValue
, _nHandle
);
261 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
262 com_sun_star_comp_dbaccess_OTextConnectionSettingsDialog_get_implementation(
263 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const& )
265 return cppu::acquire(static_cast<dbaui::ODatabaseAdministrationDialog
*>(new ::dbaui::OTextConnectionSettingsDialog(context
)));
268 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */