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