merge the formfield patch from ooo-build
[ooovba.git] / svtools / uno / addrtempuno.cxx
bloba8bbe215378a97763aa0ab76354616eeafe54983
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: addrtempuno.cxx,v $
10 * $Revision: 1.8 $
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_svtools.hxx"
33 #include "svtools/genericunodialog.hxx"
34 #ifndef _SVT_DOC_ADDRESSTEMPLATE_HXX_
35 #include "addresstemplate.hxx"
36 #endif
37 #ifndef _CPPUHELPER_EXTRACT_HXX_
38 #include <cppuhelper/extract.hxx>
39 #endif
40 #include <cppuhelper/typeprovider.hxx>
41 #include <comphelper/property.hxx>
42 #include <com/sun/star/sdbc/XDataSource.hpp>
44 class SfxItemSet;
45 class SfxItemPool;
46 class SfxPoolItem;
48 // .......................................................................
49 namespace svt
51 // .......................................................................
53 #define UNODIALOG_PROPERTY_ID_ALIASES 100
54 #define UNODIALOG_PROPERTY_ALIASES "FieldMapping"
56 using namespace com::sun::star::uno;
57 using namespace com::sun::star::lang;
58 using namespace com::sun::star::util;
59 using namespace com::sun::star::beans;
60 using namespace com::sun::star::sdbc;
62 //=========================================================================
63 //= OAddressBookSourceDialogUno
64 //=========================================================================
65 typedef OGenericUnoDialog OAddressBookSourceDialogUnoBase;
66 class OAddressBookSourceDialogUno
67 :public OAddressBookSourceDialogUnoBase
68 ,public ::comphelper::OPropertyArrayUsageHelper< OAddressBookSourceDialogUno >
70 protected:
71 Sequence< AliasProgrammaticPair > m_aAliases;
72 Reference< XDataSource > m_xDataSource;
73 ::rtl::OUString m_sDataSourceName;
74 ::rtl::OUString m_sTable;
76 protected:
77 OAddressBookSourceDialogUno(const Reference< XMultiServiceFactory >& _rxORB);
79 public:
80 // XTypeProvider
81 virtual Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(RuntimeException);
83 // XServiceInfo
84 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
85 virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(RuntimeException);
87 // XServiceInfo - static methods
88 static Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( RuntimeException );
89 static ::rtl::OUString getImplementationName_Static(void) throw( RuntimeException );
90 static Reference< XInterface >
91 SAL_CALL Create(const Reference< com::sun::star::lang::XMultiServiceFactory >&);
93 // XPropertySet
94 virtual Reference< XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(RuntimeException);
95 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
97 // OPropertyArrayUsageHelper
98 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
100 protected:
101 // OGenericUnoDialog overridables
102 virtual Dialog* createDialog(Window* _pParent);
104 virtual void implInitialize(const com::sun::star::uno::Any& _rValue);
106 virtual void executedDialog(sal_Int16 _nExecutionResult);
110 //=========================================================================
111 //= OAddressBookSourceDialogUno
112 //=========================================================================
113 Reference< XInterface > SAL_CALL OAddressBookSourceDialogUno_CreateInstance( const Reference< XMultiServiceFactory >& _rxFactory)
115 return OAddressBookSourceDialogUno::Create(_rxFactory);
118 //-------------------------------------------------------------------------
119 OAddressBookSourceDialogUno::OAddressBookSourceDialogUno(const Reference< XMultiServiceFactory >& _rxORB)
120 :OGenericUnoDialog(_rxORB)
122 registerProperty(::rtl::OUString::createFromAscii(UNODIALOG_PROPERTY_ALIASES), UNODIALOG_PROPERTY_ID_ALIASES, PropertyAttribute::READONLY,
123 &m_aAliases, getCppuType(&m_aAliases));
126 //-------------------------------------------------------------------------
127 Sequence<sal_Int8> SAL_CALL OAddressBookSourceDialogUno::getImplementationId( ) throw(RuntimeException)
129 static ::cppu::OImplementationId aId;
130 return aId.getImplementationId();
133 //-------------------------------------------------------------------------
134 Reference< XInterface > SAL_CALL OAddressBookSourceDialogUno::Create(const Reference< XMultiServiceFactory >& _rxFactory)
136 return *(new OAddressBookSourceDialogUno(_rxFactory));
139 //-------------------------------------------------------------------------
140 ::rtl::OUString SAL_CALL OAddressBookSourceDialogUno::getImplementationName() throw(RuntimeException)
142 return getImplementationName_Static();
145 //-------------------------------------------------------------------------
146 ::rtl::OUString OAddressBookSourceDialogUno::getImplementationName_Static() throw(RuntimeException)
148 return ::rtl::OUString::createFromAscii("com.sun.star.comp.svtools.OAddressBookSourceDialogUno");
151 //-------------------------------------------------------------------------
152 ::comphelper::StringSequence SAL_CALL OAddressBookSourceDialogUno::getSupportedServiceNames() throw(RuntimeException)
154 return getSupportedServiceNames_Static();
157 //-------------------------------------------------------------------------
158 ::comphelper::StringSequence OAddressBookSourceDialogUno::getSupportedServiceNames_Static() throw(RuntimeException)
160 ::comphelper::StringSequence aSupported(1);
161 aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.ui.AddressBookSourceDialog");
162 return aSupported;
165 //-------------------------------------------------------------------------
166 Reference<XPropertySetInfo> SAL_CALL OAddressBookSourceDialogUno::getPropertySetInfo() throw(RuntimeException)
168 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
169 return xInfo;
172 //-------------------------------------------------------------------------
173 ::cppu::IPropertyArrayHelper& OAddressBookSourceDialogUno::getInfoHelper()
175 return *const_cast<OAddressBookSourceDialogUno*>(this)->getArrayHelper();
178 //------------------------------------------------------------------------------
179 ::cppu::IPropertyArrayHelper* OAddressBookSourceDialogUno::createArrayHelper( ) const
181 Sequence< Property > aProps;
182 describeProperties(aProps);
183 return new ::cppu::OPropertyArrayHelper(aProps);
186 //------------------------------------------------------------------------------
187 void OAddressBookSourceDialogUno::executedDialog(sal_Int16 _nExecutionResult)
189 OAddressBookSourceDialogUnoBase::executedDialog(_nExecutionResult);
191 if ( _nExecutionResult )
192 if ( m_pDialog )
193 static_cast< AddressBookSourceDialog* >( m_pDialog )->getFieldMapping( m_aAliases );
196 //------------------------------------------------------------------------------
197 void OAddressBookSourceDialogUno::implInitialize(const com::sun::star::uno::Any& _rValue)
199 PropertyValue aVal;
200 if (_rValue >>= aVal)
202 if (0 == aVal.Name.compareToAscii("DataSource"))
204 #if OSL_DEBUG_LEVEL > 0
205 sal_Bool bSuccess =
206 #endif
207 aVal.Value >>= m_xDataSource;
208 OSL_ENSURE( bSuccess, "OAddressBookSourceDialogUno::implInitialize: invalid type for DataSource!" );
209 return;
212 if (0 == aVal.Name.compareToAscii("DataSourceName"))
214 #if OSL_DEBUG_LEVEL > 0
215 sal_Bool bSuccess =
216 #endif
217 aVal.Value >>= m_sDataSourceName;
218 OSL_ENSURE( bSuccess, "OAddressBookSourceDialogUno::implInitialize: invalid type for DataSourceName!" );
219 return;
222 if (0 == aVal.Name.compareToAscii("Command"))
224 #if OSL_DEBUG_LEVEL > 0
225 sal_Bool bSuccess =
226 #endif
227 aVal.Value >>= m_sTable;
228 OSL_ENSURE( bSuccess, "OAddressBookSourceDialogUno::implInitialize: invalid type for Command!" );
229 return;
233 OAddressBookSourceDialogUnoBase::implInitialize( _rValue );
236 //------------------------------------------------------------------------------
237 Dialog* OAddressBookSourceDialogUno::createDialog(Window* _pParent)
239 if ( m_xDataSource.is() && m_sTable.getLength() )
240 return new AddressBookSourceDialog(_pParent, m_aContext.getLegacyServiceFactory(), m_xDataSource, m_sDataSourceName, m_sTable, m_aAliases );
241 else
242 return new AddressBookSourceDialog( _pParent, m_aContext.getLegacyServiceFactory() );
245 // .......................................................................
246 } // namespace svt
247 // .......................................................................