update dev300-m58
[ooovba.git] / dbaccess / source / ui / uno / textconnectionsettings_uno.cxx
blobf176326414c0fb46679db7f6b1f9b2e295406ca1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textconnectionsettings_uno.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #include "textconnectionsettings.hxx"
35 #include "dbu_reghelper.hxx"
36 #include "moduledbu.hxx"
37 #include "apitools.hxx"
38 #include "unoadmin.hxx"
39 #include "dbustrings.hrc"
40 #include "propertystorage.hxx"
42 /** === begin UNO includes === **/
43 #include <com/sun/star/beans/XPropertySetInfo.hpp>
44 #include <com/sun/star/beans/PropertyAttribute.hpp>
45 /** === end UNO includes === **/
47 #include <comphelper/componentcontext.hxx>
48 #include <svtools/genericunodialog.hxx>
50 //........................................................................
51 namespace dbaui
53 //........................................................................
55 /** === begin UNO using === **/
56 using ::com::sun::star::uno::Reference;
57 using ::com::sun::star::uno::XInterface;
58 using ::com::sun::star::uno::UNO_QUERY;
59 using ::com::sun::star::uno::UNO_QUERY_THROW;
60 using ::com::sun::star::uno::Exception;
61 using ::com::sun::star::uno::RuntimeException;
62 using ::com::sun::star::uno::Any;
63 using ::com::sun::star::uno::makeAny;
64 using ::com::sun::star::beans::XPropertySetInfo;
65 using ::com::sun::star::uno::Sequence;
66 using ::com::sun::star::beans::Property;
67 using ::com::sun::star::lang::IllegalArgumentException;
68 /** === end UNO using === **/
69 namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
71 //====================================================================
72 //= OTextConnectionSettingsDialog
73 //====================================================================
75 class OTextConnectionSettingsDialog;
76 typedef ODatabaseAdministrationDialog OTextConnectionSettingsDialog_BASE;
77 typedef ::comphelper::OPropertyArrayUsageHelper< OTextConnectionSettingsDialog > OTextConnectionSettingsDialog_PBASE;
79 class OTextConnectionSettingsDialog
80 :public OTextConnectionSettingsDialog_BASE
81 ,public OTextConnectionSettingsDialog_PBASE
83 OModuleClient m_aModuleClient;
84 PropertyValues m_aPropertyValues;
86 protected:
87 OTextConnectionSettingsDialog( const ::comphelper::ComponentContext& _rContext );
88 virtual ~OTextConnectionSettingsDialog();
90 public:
91 DECLARE_IMPLEMENTATION_ID( );
92 DECLARE_SERVICE_INFO_STATIC( );
93 DECLARE_PROPERTYCONTAINER_DEFAULTS( );
95 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(Exception);
96 virtual sal_Bool SAL_CALL convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw(IllegalArgumentException);
97 virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const;
99 protected:
100 // OGenericUnoDialog overridables
101 virtual Dialog* createDialog( Window* _pParent );
102 virtual void implInitialize( const com::sun::star::uno::Any& _rValue );
103 protected:
104 using OTextConnectionSettingsDialog_BASE::getFastPropertyValue;
107 //====================================================================
108 //= OTextConnectionSettingsDialog
109 //====================================================================
110 //--------------------------------------------------------------------
111 OTextConnectionSettingsDialog::OTextConnectionSettingsDialog( const ::comphelper::ComponentContext& _rContext )
112 :OTextConnectionSettingsDialog_BASE( _rContext.getLegacyServiceFactory() )
114 TextConnectionSettingsDialog::bindItemStorages( *m_pDatasourceItems, m_aPropertyValues );
117 //---------------------------------------------------------------------
118 OTextConnectionSettingsDialog::~OTextConnectionSettingsDialog()
122 //---------------------------------------------------------------------
123 IMPLEMENT_IMPLEMENTATION_ID( OTextConnectionSettingsDialog )
125 //---------------------------------------------------------------------
126 IMPLEMENT_SERVICE_INFO1_STATIC( OTextConnectionSettingsDialog, "com.sun.star.comp.dbaccess.OTextConnectionSettingsDialog", "com.sun.star.sdb.TextConnectionSettings" )
128 //---------------------------------------------------------------------
129 Reference< XPropertySetInfo > SAL_CALL OTextConnectionSettingsDialog::getPropertySetInfo() throw(RuntimeException)
131 return createPropertySetInfo( getInfoHelper() );
134 //---------------------------------------------------------------------
135 ::cppu::IPropertyArrayHelper& OTextConnectionSettingsDialog::getInfoHelper()
137 return *getArrayHelper();
140 //---------------------------------------------------------------------
141 ::cppu::IPropertyArrayHelper* OTextConnectionSettingsDialog::createArrayHelper( ) const
143 Sequence< Property > aProps;
144 describeProperties( aProps );
146 // in addition to the properties registered by the base class, we have
147 // more properties which are not even handled by the PropertyContainer implementation,
148 // but whose values are stored in our item set
149 sal_Int32 nProp = aProps.getLength();
150 aProps.realloc( nProp + 6 );
152 aProps[ nProp++ ] = Property(
153 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HeaderLine" ) ),
154 PROPERTY_ID_HEADER_LINE,
155 ::cppu::UnoType< sal_Bool >::get(),
156 PropertyAttribute::TRANSIENT
159 aProps[ nProp++ ] = Property(
160 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FieldDelimiter" ) ),
161 PROPERTY_ID_FIELD_DELIMITER,
162 ::cppu::UnoType< ::rtl::OUString >::get(),
163 PropertyAttribute::TRANSIENT
166 aProps[ nProp++ ] = Property(
167 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StringDelimiter" ) ),
168 PROPERTY_ID_STRING_DELIMITER,
169 ::cppu::UnoType< ::rtl::OUString >::get(),
170 PropertyAttribute::TRANSIENT
173 aProps[ nProp++ ] = Property(
174 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DecimalDelimiter" ) ),
175 PROPERTY_ID_DECIMAL_DELIMITER,
176 ::cppu::UnoType< ::rtl::OUString >::get(),
177 PropertyAttribute::TRANSIENT
180 aProps[ nProp++ ] = Property(
181 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThousandDelimiter" ) ),
182 PROPERTY_ID_THOUSAND_DELIMITER,
183 ::cppu::UnoType< ::rtl::OUString >::get(),
184 PropertyAttribute::TRANSIENT
187 aProps[ nProp++ ] = Property(
188 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharSet" ) ),
189 PROPERTY_ID_ENCODING,
190 ::cppu::UnoType< ::rtl::OUString >::get(),
191 PropertyAttribute::TRANSIENT
194 return new ::cppu::OPropertyArrayHelper( aProps );
197 //---------------------------------------------------------------------
198 Dialog* OTextConnectionSettingsDialog::createDialog(Window* _pParent)
200 return new TextConnectionSettingsDialog( _pParent, *m_pDatasourceItems );
203 //---------------------------------------------------------------------
204 void OTextConnectionSettingsDialog::implInitialize(const Any& _rValue)
206 OTextConnectionSettingsDialog_BASE::implInitialize( _rValue );
209 //--------------------------------------------------------------------
210 void SAL_CALL OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw(Exception)
212 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
213 if ( pos != m_aPropertyValues.end() )
215 pos->second->setPropertyValue( _rValue );
217 else
219 OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
223 //--------------------------------------------------------------------
224 sal_Bool SAL_CALL OTextConnectionSettingsDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException)
226 sal_Bool bModified = sal_False;
228 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
229 if ( pos != m_aPropertyValues.end() )
231 // we're lazy here ...
232 _rConvertedValue = _rValue;
233 pos->second->getPropertyValue( _rOldValue );
234 bModified = sal_True;
236 else
238 bModified = OTextConnectionSettingsDialog::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
241 return bModified;
244 //--------------------------------------------------------------------
245 void SAL_CALL OTextConnectionSettingsDialog::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
247 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
248 if ( pos != m_aPropertyValues.end() )
250 pos->second->getPropertyValue( _rValue );
252 else
254 OTextConnectionSettingsDialog::getFastPropertyValue( _rValue, _nHandle );
258 //........................................................................
259 } // namespace dbaui
260 //........................................................................
262 extern "C" void SAL_CALL createRegistryInfo_OTextConnectionSettingsDialog()
264 static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OTextConnectionSettingsDialog > aAutoRegistration;