Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / dbaccess / source / ui / uno / textconnectionsettings_uno.cxx
blob60a75e7e3a6d09190246cfdb0fb04289231f2676
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "textconnectionsettings.hxx"
31 #include "dbu_reghelper.hxx"
32 #include "moduledbu.hxx"
33 #include "apitools.hxx"
34 #include "unoadmin.hxx"
35 #include "dbustrings.hrc"
36 #include "propertystorage.hxx"
38 /** === begin UNO includes === **/
39 #include <com/sun/star/beans/XPropertySetInfo.hpp>
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 /** === end UNO includes === **/
43 #include <comphelper/componentcontext.hxx>
44 #include <svtools/genericunodialog.hxx>
46 //........................................................................
47 namespace dbaui
49 //........................................................................
51 /** === begin UNO using === **/
52 using ::com::sun::star::uno::Reference;
53 using ::com::sun::star::uno::XInterface;
54 using ::com::sun::star::uno::UNO_QUERY;
55 using ::com::sun::star::uno::UNO_QUERY_THROW;
56 using ::com::sun::star::uno::Exception;
57 using ::com::sun::star::uno::RuntimeException;
58 using ::com::sun::star::uno::Any;
59 using ::com::sun::star::uno::makeAny;
60 using ::com::sun::star::beans::XPropertySetInfo;
61 using ::com::sun::star::uno::Sequence;
62 using ::com::sun::star::beans::Property;
63 using ::com::sun::star::lang::IllegalArgumentException;
64 /** === end UNO using === **/
65 namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
67 //====================================================================
68 //= OTextConnectionSettingsDialog
69 //====================================================================
71 class OTextConnectionSettingsDialog;
72 typedef ODatabaseAdministrationDialog OTextConnectionSettingsDialog_BASE;
73 typedef ::comphelper::OPropertyArrayUsageHelper< OTextConnectionSettingsDialog > OTextConnectionSettingsDialog_PBASE;
75 class OTextConnectionSettingsDialog
76 :public OTextConnectionSettingsDialog_BASE
77 ,public OTextConnectionSettingsDialog_PBASE
79 OModuleClient m_aModuleClient;
80 PropertyValues m_aPropertyValues;
82 protected:
83 OTextConnectionSettingsDialog( const ::comphelper::ComponentContext& _rContext );
84 virtual ~OTextConnectionSettingsDialog();
86 public:
87 DECLARE_IMPLEMENTATION_ID( );
88 DECLARE_SERVICE_INFO_STATIC( );
89 DECLARE_PROPERTYCONTAINER_DEFAULTS( );
91 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(Exception);
92 virtual sal_Bool SAL_CALL convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw(IllegalArgumentException);
93 virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const;
95 protected:
96 // OGenericUnoDialog overridables
97 virtual Dialog* createDialog( Window* _pParent );
98 virtual void implInitialize( const com::sun::star::uno::Any& _rValue );
99 protected:
100 using OTextConnectionSettingsDialog_BASE::getFastPropertyValue;
103 //====================================================================
104 //= OTextConnectionSettingsDialog
105 //====================================================================
106 //--------------------------------------------------------------------
107 OTextConnectionSettingsDialog::OTextConnectionSettingsDialog( const ::comphelper::ComponentContext& _rContext )
108 :OTextConnectionSettingsDialog_BASE( _rContext.getLegacyServiceFactory() )
110 TextConnectionSettingsDialog::bindItemStorages( *m_pDatasourceItems, m_aPropertyValues );
113 //---------------------------------------------------------------------
114 OTextConnectionSettingsDialog::~OTextConnectionSettingsDialog()
118 //---------------------------------------------------------------------
119 IMPLEMENT_IMPLEMENTATION_ID( OTextConnectionSettingsDialog )
121 //---------------------------------------------------------------------
122 IMPLEMENT_SERVICE_INFO1_STATIC( OTextConnectionSettingsDialog, "com.sun.star.comp.dbaccess.OTextConnectionSettingsDialog", "com.sun.star.sdb.TextConnectionSettings" )
124 //---------------------------------------------------------------------
125 Reference< XPropertySetInfo > SAL_CALL OTextConnectionSettingsDialog::getPropertySetInfo() throw(RuntimeException)
127 return createPropertySetInfo( getInfoHelper() );
130 //---------------------------------------------------------------------
131 ::cppu::IPropertyArrayHelper& OTextConnectionSettingsDialog::getInfoHelper()
133 return *getArrayHelper();
136 //---------------------------------------------------------------------
137 ::cppu::IPropertyArrayHelper* OTextConnectionSettingsDialog::createArrayHelper( ) const
139 Sequence< Property > aProps;
140 describeProperties( aProps );
142 // in addition to the properties registered by the base class, we have
143 // more properties which are not even handled by the PropertyContainer implementation,
144 // but whose values are stored in our item set
145 sal_Int32 nProp = aProps.getLength();
146 aProps.realloc( nProp + 6 );
148 aProps[ nProp++ ] = Property(
149 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HeaderLine" ) ),
150 PROPERTY_ID_HEADER_LINE,
151 ::cppu::UnoType< sal_Bool >::get(),
152 PropertyAttribute::TRANSIENT
155 aProps[ nProp++ ] = Property(
156 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FieldDelimiter" ) ),
157 PROPERTY_ID_FIELD_DELIMITER,
158 ::cppu::UnoType< ::rtl::OUString >::get(),
159 PropertyAttribute::TRANSIENT
162 aProps[ nProp++ ] = Property(
163 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StringDelimiter" ) ),
164 PROPERTY_ID_STRING_DELIMITER,
165 ::cppu::UnoType< ::rtl::OUString >::get(),
166 PropertyAttribute::TRANSIENT
169 aProps[ nProp++ ] = Property(
170 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DecimalDelimiter" ) ),
171 PROPERTY_ID_DECIMAL_DELIMITER,
172 ::cppu::UnoType< ::rtl::OUString >::get(),
173 PropertyAttribute::TRANSIENT
176 aProps[ nProp++ ] = Property(
177 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThousandDelimiter" ) ),
178 PROPERTY_ID_THOUSAND_DELIMITER,
179 ::cppu::UnoType< ::rtl::OUString >::get(),
180 PropertyAttribute::TRANSIENT
183 aProps[ nProp++ ] = Property(
184 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharSet" ) ),
185 PROPERTY_ID_ENCODING,
186 ::cppu::UnoType< ::rtl::OUString >::get(),
187 PropertyAttribute::TRANSIENT
190 return new ::cppu::OPropertyArrayHelper( aProps );
193 //---------------------------------------------------------------------
194 Dialog* OTextConnectionSettingsDialog::createDialog(Window* _pParent)
196 return new TextConnectionSettingsDialog( _pParent, *m_pDatasourceItems );
199 //---------------------------------------------------------------------
200 void OTextConnectionSettingsDialog::implInitialize(const Any& _rValue)
202 OTextConnectionSettingsDialog_BASE::implInitialize( _rValue );
205 //--------------------------------------------------------------------
206 void SAL_CALL OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw(Exception)
208 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
209 if ( pos != m_aPropertyValues.end() )
211 pos->second->setPropertyValue( _rValue );
213 else
215 OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
219 //--------------------------------------------------------------------
220 sal_Bool SAL_CALL OTextConnectionSettingsDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException)
222 sal_Bool bModified = sal_False;
224 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
225 if ( pos != m_aPropertyValues.end() )
227 // we're lazy here ...
228 _rConvertedValue = _rValue;
229 pos->second->getPropertyValue( _rOldValue );
230 bModified = sal_True;
232 else
234 bModified = OTextConnectionSettingsDialog::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
237 return bModified;
240 //--------------------------------------------------------------------
241 void SAL_CALL OTextConnectionSettingsDialog::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
243 PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
244 if ( pos != m_aPropertyValues.end() )
246 pos->second->getPropertyValue( _rValue );
248 else
250 OTextConnectionSettingsDialog::getFastPropertyValue( _rValue, _nHandle );
254 //........................................................................
255 } // namespace dbaui
256 //........................................................................
258 extern "C" void SAL_CALL createRegistryInfo_OTextConnectionSettingsDialog()
260 static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OTextConnectionSettingsDialog > aAutoRegistration;
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */