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 "uiservices.hxx"
22 #include "dbu_reghelper.hxx"
23 #include "moduledbu.hxx"
24 #include "apitools.hxx"
25 #include "unoadmin.hxx"
26 #include "dbustrings.hrc"
27 #include "propertystorage.hxx"
29 #include <com/sun/star/beans/XPropertySetInfo.hpp>
30 #include <com/sun/star/beans/PropertyAttribute.hpp>
31 #include <com/sun/star/sdb/XTextConnectionSettings.hpp>
33 #include <comphelper/processfactory.hxx>
34 #include <svtools/genericunodialog.hxx>
35 #include <cppuhelper/implbase.hxx>
40 using ::com::sun::star::uno::Reference
;
41 using ::com::sun::star::uno::XInterface
;
42 using ::com::sun::star::uno::Exception
;
43 using ::com::sun::star::uno::RuntimeException
;
44 using ::com::sun::star::uno::Any
;
45 using ::com::sun::star::uno::XComponentContext
;
46 using ::com::sun::star::beans::XPropertySetInfo
;
47 using ::com::sun::star::uno::Sequence
;
48 using ::com::sun::star::beans::Property
;
49 using ::com::sun::star::lang::IllegalArgumentException
;
51 namespace PropertyAttribute
= ::com::sun::star::beans::PropertyAttribute
;
53 // OTextConnectionSettingsDialog
55 class OTextConnectionSettingsDialog
;
56 typedef ::cppu::ImplInheritanceHelper
< ODatabaseAdministrationDialog
57 , css::sdb::XTextConnectionSettings
58 > OTextConnectionSettingsDialog_BASE
;
59 typedef ::comphelper::OPropertyArrayUsageHelper
< OTextConnectionSettingsDialog
> OTextConnectionSettingsDialog_PBASE
;
61 class OTextConnectionSettingsDialog
62 :public OTextConnectionSettingsDialog_BASE
63 ,public OTextConnectionSettingsDialog_PBASE
64 ,public ::cppu::WeakImplHelper
< css::sdb::XTextConnectionSettings
>
66 OModuleClient m_aModuleClient
;
67 PropertyValues m_aPropertyValues
;
70 explicit OTextConnectionSettingsDialog( const Reference
<XComponentContext
>& _rContext
);
71 virtual ~OTextConnectionSettingsDialog() override
;
74 virtual css::uno::Sequence
<sal_Int8
> SAL_CALL
getImplementationId()
75 throw (css::uno::RuntimeException
, std::exception
) override
;
77 DECLARE_SERVICE_INFO();
78 /// @throws css::uno::RuntimeException
79 static OUString SAL_CALL
getImplementationName_Static( ) throw (css::uno::RuntimeException
);
80 /// @throws css::uno::RuntimeException
81 static css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames_Static( ) throw(css::uno::RuntimeException
);
82 static css::uno::Reference
< css::uno::XInterface
>
83 SAL_CALL
Create(const css::uno::Reference
< css::lang::XMultiServiceFactory
>&);
84 DECLARE_PROPERTYCONTAINER_DEFAULTS( );
86 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
, const Any
& rValue
) throw(Exception
, std::exception
) override
;
87 virtual sal_Bool SAL_CALL
convertFastPropertyValue( Any
& rConvertedValue
, Any
& rOldValue
, sal_Int32 nHandle
, const Any
& rValue
) throw(IllegalArgumentException
) override
;
88 virtual void SAL_CALL
getFastPropertyValue( Any
& rValue
, sal_Int32 nHandle
) const override
;
90 // Overrides to resolve inheritance ambiguity
91 virtual void SAL_CALL
setPropertyValue(const OUString
& p1
, const css::uno::Any
& p2
) throw (css::uno::RuntimeException
, std::exception
) override
92 { ODatabaseAdministrationDialog::setPropertyValue(p1
, p2
); }
93 virtual css::uno::Any SAL_CALL
getPropertyValue(const OUString
& p1
) throw (css::uno::RuntimeException
, std::exception
) override
94 { return ODatabaseAdministrationDialog::getPropertyValue(p1
); }
95 virtual void SAL_CALL
addPropertyChangeListener(const OUString
& p1
, const css::uno::Reference
<css::beans::XPropertyChangeListener
>& p2
) throw (css::beans::UnknownPropertyException
, css::uno::RuntimeException
, std::exception
) override
96 { ODatabaseAdministrationDialog::addPropertyChangeListener(p1
, p2
); }
97 virtual void SAL_CALL
removePropertyChangeListener(const OUString
& p1
, const css::uno::Reference
<css::beans::XPropertyChangeListener
>& p2
) throw (css::beans::UnknownPropertyException
, css::uno::RuntimeException
, std::exception
) override
98 { ODatabaseAdministrationDialog::removePropertyChangeListener(p1
, p2
); }
99 virtual void SAL_CALL
addVetoableChangeListener(const OUString
& p1
, const css::uno::Reference
<css::beans::XVetoableChangeListener
>& p2
) throw (css::beans::UnknownPropertyException
, css::uno::RuntimeException
, std::exception
) override
100 { ODatabaseAdministrationDialog::addVetoableChangeListener(p1
, p2
); }
101 virtual void SAL_CALL
removeVetoableChangeListener(const OUString
& p1
, const css::uno::Reference
<css::beans::XVetoableChangeListener
>& p2
) throw (css::beans::UnknownPropertyException
, css::uno::RuntimeException
, std::exception
) override
102 { ODatabaseAdministrationDialog::removeVetoableChangeListener(p1
, p2
); }
103 virtual void SAL_CALL
setTitle(const OUString
& p1
) throw (css::uno::RuntimeException
, std::exception
) override
104 { ODatabaseAdministrationDialog::setTitle(p1
); }
105 virtual sal_Int16 SAL_CALL
execute() throw (css::uno::RuntimeException
, std::exception
) override
106 { return ODatabaseAdministrationDialog::execute(); }
109 // OGenericUnoDialog overridables
110 virtual VclPtr
<Dialog
> createDialog( vcl::Window
* _pParent
) override
;
111 using OTextConnectionSettingsDialog_BASE::getFastPropertyValue
;
114 // OTextConnectionSettingsDialog
115 OTextConnectionSettingsDialog::OTextConnectionSettingsDialog( const Reference
<XComponentContext
>& _rContext
)
116 :OTextConnectionSettingsDialog_BASE( _rContext
)
118 TextConnectionSettingsDialog::bindItemStorages( *m_pDatasourceItems
, m_aPropertyValues
);
121 OTextConnectionSettingsDialog::~OTextConnectionSettingsDialog()
125 css::uno::Sequence
<sal_Int8
>
126 OTextConnectionSettingsDialog::getImplementationId()
127 throw (css::uno::RuntimeException
, std::exception
)
129 return css::uno::Sequence
<sal_Int8
>();
132 IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(OTextConnectionSettingsDialog
, "com.sun.star.comp.dbaccess.OTextConnectionSettingsDialog")
133 IMPLEMENT_SERVICE_INFO_SUPPORTS(OTextConnectionSettingsDialog
)
134 IMPLEMENT_SERVICE_INFO_GETSUPPORTED1_STATIC(OTextConnectionSettingsDialog
, "com.sun.star.sdb.TextConnectionSettings")
136 css::uno::Reference
< css::uno::XInterface
>
137 SAL_CALL
OTextConnectionSettingsDialog::Create(const css::uno::Reference
< css::lang::XMultiServiceFactory
>& _rxORB
)
139 return static_cast< XServiceInfo
* >(new OTextConnectionSettingsDialog( comphelper::getComponentContext(_rxORB
)));
142 Reference
< XPropertySetInfo
> SAL_CALL
OTextConnectionSettingsDialog::getPropertySetInfo() throw(RuntimeException
, std::exception
)
144 return createPropertySetInfo( getInfoHelper() );
147 ::cppu::IPropertyArrayHelper
& OTextConnectionSettingsDialog::getInfoHelper()
149 return *getArrayHelper();
152 ::cppu::IPropertyArrayHelper
* OTextConnectionSettingsDialog::createArrayHelper( ) const
154 Sequence
< Property
> aProps
;
155 describeProperties( aProps
);
157 // in addition to the properties registered by the base class, we have
158 // more properties which are not even handled by the PropertyContainer implementation,
159 // but whose values are stored in our item set
160 sal_Int32 nProp
= aProps
.getLength();
161 aProps
.realloc( nProp
+ 6 );
163 aProps
[ nProp
++ ] = Property(
164 OUString( "HeaderLine" ),
165 PROPERTY_ID_HEADER_LINE
,
166 ::cppu::UnoType
< sal_Bool
>::get(),
167 PropertyAttribute::TRANSIENT
170 aProps
[ nProp
++ ] = Property(
171 OUString( "FieldDelimiter" ),
172 PROPERTY_ID_FIELD_DELIMITER
,
173 ::cppu::UnoType
< OUString
>::get(),
174 PropertyAttribute::TRANSIENT
177 aProps
[ nProp
++ ] = Property(
178 OUString( "StringDelimiter" ),
179 PROPERTY_ID_STRING_DELIMITER
,
180 ::cppu::UnoType
< OUString
>::get(),
181 PropertyAttribute::TRANSIENT
184 aProps
[ nProp
++ ] = Property(
185 OUString( "DecimalDelimiter" ),
186 PROPERTY_ID_DECIMAL_DELIMITER
,
187 ::cppu::UnoType
< OUString
>::get(),
188 PropertyAttribute::TRANSIENT
191 aProps
[ nProp
++ ] = Property(
192 OUString( "ThousandDelimiter" ),
193 PROPERTY_ID_THOUSAND_DELIMITER
,
194 ::cppu::UnoType
< OUString
>::get(),
195 PropertyAttribute::TRANSIENT
198 aProps
[ nProp
++ ] = Property(
199 OUString( "CharSet" ),
200 PROPERTY_ID_ENCODING
,
201 ::cppu::UnoType
< OUString
>::get(),
202 PropertyAttribute::TRANSIENT
205 return new ::cppu::OPropertyArrayHelper( aProps
);
208 VclPtr
<Dialog
> OTextConnectionSettingsDialog::createDialog(vcl::Window
* _pParent
)
210 return VclPtr
<TextConnectionSettingsDialog
>::Create( _pParent
, *m_pDatasourceItems
);
213 void SAL_CALL
OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle
, const Any
& _rValue
) throw(Exception
, std::exception
)
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
) throw(IllegalArgumentException
)
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" void SAL_CALL
createRegistryInfo_OTextConnectionSettingsDialog()
263 static ::dbaui::OMultiInstanceAutoRegistration
< ::dbaui::OTextConnectionSettingsDialog
> aAutoRegistration
;
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */