Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "svtools/genericunodialog.hxx"
30 : : #include <svtools/addresstemplate.hxx>
31 : : #include <comphelper/extract.hxx>
32 : : #include <cppuhelper/typeprovider.hxx>
33 : : #include <comphelper/property.hxx>
34 : : #include <com/sun/star/sdbc/XDataSource.hpp>
35 : :
36 : : // .......................................................................
37 : : namespace svt
38 : : {
39 : : // .......................................................................
40 : :
41 : : #define UNODIALOG_PROPERTY_ID_ALIASES 100
42 : : #define UNODIALOG_PROPERTY_ALIASES "FieldMapping"
43 : :
44 : : using namespace com::sun::star::uno;
45 : : using namespace com::sun::star::lang;
46 : : using namespace com::sun::star::util;
47 : : using namespace com::sun::star::beans;
48 : : using namespace com::sun::star::sdbc;
49 : :
50 : : //=========================================================================
51 : : //= OAddressBookSourceDialogUno
52 : : //=========================================================================
53 : : typedef OGenericUnoDialog OAddressBookSourceDialogUnoBase;
54 [ # # ][ # # ]: 0 : class OAddressBookSourceDialogUno
[ # # ]
55 : : :public OAddressBookSourceDialogUnoBase
56 : : ,public ::comphelper::OPropertyArrayUsageHelper< OAddressBookSourceDialogUno >
57 : : {
58 : : protected:
59 : : Sequence< AliasProgrammaticPair > m_aAliases;
60 : : Reference< XDataSource > m_xDataSource;
61 : : ::rtl::OUString m_sDataSourceName;
62 : : ::rtl::OUString m_sTable;
63 : :
64 : : protected:
65 : : OAddressBookSourceDialogUno(const Reference< XMultiServiceFactory >& _rxORB);
66 : :
67 : : public:
68 : : // XTypeProvider
69 : : virtual Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(RuntimeException);
70 : :
71 : : // XServiceInfo
72 : : virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
73 : : virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(RuntimeException);
74 : :
75 : : // XServiceInfo - static methods
76 : : static Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( RuntimeException );
77 : : static ::rtl::OUString getImplementationName_Static(void) throw( RuntimeException );
78 : : static Reference< XInterface >
79 : : SAL_CALL Create(const Reference< com::sun::star::lang::XMultiServiceFactory >&);
80 : :
81 : : // XPropertySet
82 : : virtual Reference< XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(RuntimeException);
83 : : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
84 : :
85 : : // OPropertyArrayUsageHelper
86 : : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
87 : :
88 : : protected:
89 : : // OGenericUnoDialog overridables
90 : : virtual Dialog* createDialog(Window* _pParent);
91 : :
92 : : virtual void implInitialize(const com::sun::star::uno::Any& _rValue);
93 : :
94 : : virtual void executedDialog(sal_Int16 _nExecutionResult);
95 : : };
96 : :
97 : :
98 : : //=========================================================================
99 : : //= OAddressBookSourceDialogUno
100 : : //=========================================================================
101 : 0 : Reference< XInterface > SAL_CALL OAddressBookSourceDialogUno_CreateInstance( const Reference< XMultiServiceFactory >& _rxFactory)
102 : : {
103 : 0 : return OAddressBookSourceDialogUno::Create(_rxFactory);
104 : : }
105 : :
106 : : //-------------------------------------------------------------------------
107 : 0 : OAddressBookSourceDialogUno::OAddressBookSourceDialogUno(const Reference< XMultiServiceFactory >& _rxORB)
108 [ # # ][ # # ]: 0 : :OGenericUnoDialog(_rxORB)
109 : : {
110 : : registerProperty(::rtl::OUString(UNODIALOG_PROPERTY_ALIASES), UNODIALOG_PROPERTY_ID_ALIASES, PropertyAttribute::READONLY,
111 [ # # ][ # # ]: 0 : &m_aAliases, getCppuType(&m_aAliases));
112 : 0 : }
113 : :
114 : : //-------------------------------------------------------------------------
115 : 0 : Sequence<sal_Int8> SAL_CALL OAddressBookSourceDialogUno::getImplementationId( ) throw(RuntimeException)
116 : : {
117 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId aId;
118 : 0 : return aId.getImplementationId();
119 : : }
120 : :
121 : : //-------------------------------------------------------------------------
122 : 0 : Reference< XInterface > SAL_CALL OAddressBookSourceDialogUno::Create(const Reference< XMultiServiceFactory >& _rxFactory)
123 : : {
124 [ # # ]: 0 : return *(new OAddressBookSourceDialogUno(_rxFactory));
125 : : }
126 : :
127 : : //-------------------------------------------------------------------------
128 : 0 : ::rtl::OUString SAL_CALL OAddressBookSourceDialogUno::getImplementationName() throw(RuntimeException)
129 : : {
130 : 0 : return getImplementationName_Static();
131 : : }
132 : :
133 : : //-------------------------------------------------------------------------
134 : 0 : ::rtl::OUString OAddressBookSourceDialogUno::getImplementationName_Static() throw(RuntimeException)
135 : : {
136 : 0 : return ::rtl::OUString( "com.sun.star.comp.svtools.OAddressBookSourceDialogUno" );
137 : : }
138 : :
139 : : //-------------------------------------------------------------------------
140 : 0 : ::comphelper::StringSequence SAL_CALL OAddressBookSourceDialogUno::getSupportedServiceNames() throw(RuntimeException)
141 : : {
142 : 0 : return getSupportedServiceNames_Static();
143 : : }
144 : :
145 : : //-------------------------------------------------------------------------
146 : 0 : ::comphelper::StringSequence OAddressBookSourceDialogUno::getSupportedServiceNames_Static() throw(RuntimeException)
147 : : {
148 : 0 : ::comphelper::StringSequence aSupported(1);
149 [ # # ]: 0 : aSupported.getArray()[0] = ::rtl::OUString( "com.sun.star.ui.AddressBookSourceDialog" );
150 : 0 : return aSupported;
151 : : }
152 : :
153 : : //-------------------------------------------------------------------------
154 : 0 : Reference<XPropertySetInfo> SAL_CALL OAddressBookSourceDialogUno::getPropertySetInfo() throw(RuntimeException)
155 : : {
156 : 0 : Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
157 : 0 : return xInfo;
158 : : }
159 : :
160 : : //-------------------------------------------------------------------------
161 : 0 : ::cppu::IPropertyArrayHelper& OAddressBookSourceDialogUno::getInfoHelper()
162 : : {
163 : 0 : return *const_cast<OAddressBookSourceDialogUno*>(this)->getArrayHelper();
164 : : }
165 : :
166 : : //------------------------------------------------------------------------------
167 : 0 : ::cppu::IPropertyArrayHelper* OAddressBookSourceDialogUno::createArrayHelper( ) const
168 : : {
169 [ # # ]: 0 : Sequence< Property > aProps;
170 [ # # ]: 0 : describeProperties(aProps);
171 [ # # ][ # # ]: 0 : return new ::cppu::OPropertyArrayHelper(aProps);
172 : : }
173 : :
174 : : //------------------------------------------------------------------------------
175 : 0 : void OAddressBookSourceDialogUno::executedDialog(sal_Int16 _nExecutionResult)
176 : : {
177 : 0 : OAddressBookSourceDialogUnoBase::executedDialog(_nExecutionResult);
178 : :
179 [ # # ]: 0 : if ( _nExecutionResult )
180 [ # # ]: 0 : if ( m_pDialog )
181 : 0 : static_cast< AddressBookSourceDialog* >( m_pDialog )->getFieldMapping( m_aAliases );
182 : 0 : }
183 : :
184 : : //------------------------------------------------------------------------------
185 : 0 : void OAddressBookSourceDialogUno::implInitialize(const com::sun::star::uno::Any& _rValue)
186 : : {
187 : 0 : PropertyValue aVal;
188 [ # # ][ # # ]: 0 : if (_rValue >>= aVal)
189 : : {
190 [ # # ]: 0 : if (0 == aVal.Name.compareToAscii("DataSource"))
191 : : {
192 : : #if OSL_DEBUG_LEVEL > 0
193 : : sal_Bool bSuccess =
194 : : #endif
195 [ # # ]: 0 : aVal.Value >>= m_xDataSource;
196 : : OSL_ENSURE( bSuccess, "OAddressBookSourceDialogUno::implInitialize: invalid type for DataSource!" );
197 : : return;
198 : : }
199 : :
200 [ # # ]: 0 : if (0 == aVal.Name.compareToAscii("DataSourceName"))
201 : : {
202 : : #if OSL_DEBUG_LEVEL > 0
203 : : sal_Bool bSuccess =
204 : : #endif
205 : 0 : aVal.Value >>= m_sDataSourceName;
206 : : OSL_ENSURE( bSuccess, "OAddressBookSourceDialogUno::implInitialize: invalid type for DataSourceName!" );
207 : : return;
208 : : }
209 : :
210 [ # # ]: 0 : if (0 == aVal.Name.compareToAscii("Command"))
211 : : {
212 : : #if OSL_DEBUG_LEVEL > 0
213 : : sal_Bool bSuccess =
214 : : #endif
215 : 0 : aVal.Value >>= m_sTable;
216 : : OSL_ENSURE( bSuccess, "OAddressBookSourceDialogUno::implInitialize: invalid type for Command!" );
217 : : return;
218 : : }
219 : : }
220 : :
221 [ # # ][ # # ]: 0 : OAddressBookSourceDialogUnoBase::implInitialize( _rValue );
222 : : }
223 : :
224 : : //------------------------------------------------------------------------------
225 : 0 : Dialog* OAddressBookSourceDialogUno::createDialog(Window* _pParent)
226 : : {
227 [ # # ][ # # ]: 0 : if ( m_xDataSource.is() && !m_sTable.isEmpty() )
[ # # ]
228 [ # # ][ # # ]: 0 : return new AddressBookSourceDialog(_pParent, m_aContext.getLegacyServiceFactory(), m_xDataSource, m_sDataSourceName, m_sTable, m_aAliases );
229 : : else
230 [ # # ][ # # ]: 0 : return new AddressBookSourceDialog( _pParent, m_aContext.getLegacyServiceFactory() );
231 : : }
232 : :
233 : : // .......................................................................
234 : : } // namespace svt
235 : : // .......................................................................
236 : :
237 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|