xref: /trunk/main/extensions/source/abpilot/fieldmappingimpl.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
12a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52a97ec55SAndrew Rist  * distributed with this work for additional information
62a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
82a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
92a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
112a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
132a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
142a97ec55SAndrew Rist  * software distributed under the License is distributed on an
152a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
172a97ec55SAndrew Rist  * specific language governing permissions and limitations
182a97ec55SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
202a97ec55SAndrew Rist  *************************************************************/
212a97ec55SAndrew Rist 
222a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include "fieldmappingimpl.hxx"
27cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
31cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp>
33cdf0e10cSrcweir #include <tools/debug.hxx>
34cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
35*b63233d8Sdamjan #include <toolkit/helper/vclunohelper.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <vcl/stdtext.hxx>
38cdf0e10cSrcweir #include <com/sun/star/util/AliasProgrammaticPair.hpp>
39cdf0e10cSrcweir #ifndef EXTENSIONS_ABPRESID_HRC
40cdf0e10cSrcweir #include "abpresid.hrc"
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include "componentmodule.hxx"
43cdf0e10cSrcweir #include <unotools/confignode.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir //.........................................................................
46cdf0e10cSrcweir namespace abp
47cdf0e10cSrcweir {
48cdf0e10cSrcweir //.........................................................................
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     using namespace ::utl;
51cdf0e10cSrcweir     using namespace ::com::sun::star::uno;
52cdf0e10cSrcweir     using namespace ::com::sun::star::awt;
53cdf0e10cSrcweir     using namespace ::com::sun::star::util;
54cdf0e10cSrcweir     using namespace ::com::sun::star::lang;
55cdf0e10cSrcweir     using namespace ::com::sun::star::beans;
56cdf0e10cSrcweir     using namespace ::com::sun::star::sdb;
57cdf0e10cSrcweir     using namespace ::com::sun::star::ui::dialogs;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     //---------------------------------------------------------------------
lcl_getDriverSettingsNodeName()60cdf0e10cSrcweir     static const ::rtl::OUString& lcl_getDriverSettingsNodeName()
61cdf0e10cSrcweir     {
62cdf0e10cSrcweir         static const ::rtl::OUString s_sDriverSettingsNodeName =
63cdf0e10cSrcweir             ::rtl::OUString::createFromAscii( "/org.openoffice.Office.DataAccess/DriverSettings/com.sun.star.comp.sdbc.MozabDriver" );
64cdf0e10cSrcweir         return s_sDriverSettingsNodeName;
65cdf0e10cSrcweir     }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     //---------------------------------------------------------------------
lcl_getAddressBookNodeName()68cdf0e10cSrcweir     static const ::rtl::OUString& lcl_getAddressBookNodeName()
69cdf0e10cSrcweir     {
70cdf0e10cSrcweir         static const ::rtl::OUString s_sAddressBookNodeName =
71cdf0e10cSrcweir             ::rtl::OUString::createFromAscii( "/org.openoffice.Office.DataAccess/AddressBook" );
72cdf0e10cSrcweir         return s_sAddressBookNodeName;
73cdf0e10cSrcweir     }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     //.....................................................................
76cdf0e10cSrcweir     namespace fieldmapping
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir     //.....................................................................
79cdf0e10cSrcweir 
80cdf0e10cSrcweir         //-----------------------------------------------------------------
invokeDialog(const Reference<XMultiServiceFactory> & _rxORB,class Window * _pParent,const Reference<XPropertySet> & _rxDataSource,AddressSettings & _rSettings)81cdf0e10cSrcweir         sal_Bool invokeDialog( const Reference< XMultiServiceFactory >& _rxORB, class Window* _pParent,
82cdf0e10cSrcweir             const Reference< XPropertySet >& _rxDataSource, AddressSettings& _rSettings ) SAL_THROW ( ( ) )
83cdf0e10cSrcweir         {
84cdf0e10cSrcweir             _rSettings.aFieldMapping.clear();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir             DBG_ASSERT( _rxORB.is(), "fieldmapping::invokeDialog: invalid service factory!" );
87cdf0e10cSrcweir             DBG_ASSERT( _rxDataSource.is(), "fieldmapping::invokeDialog: invalid data source!" );
88cdf0e10cSrcweir             if ( !_rxORB.is() || !_rxDataSource.is() )
89cdf0e10cSrcweir                 return sal_False;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir             try
92cdf0e10cSrcweir             {
93cdf0e10cSrcweir                 // ........................................................
94cdf0e10cSrcweir                 // the parameters for creating the dialog
95cdf0e10cSrcweir                 Sequence< Any > aArguments(5);
96cdf0e10cSrcweir                 Any* pArguments = aArguments.getArray();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir                 // the parent window
99cdf0e10cSrcweir                 Reference< XWindow > xDialogParent = VCLUnoHelper::GetInterface( _pParent );
100cdf0e10cSrcweir                 *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii( "ParentWindow" ), -1, makeAny( xDialogParent ), PropertyState_DIRECT_VALUE);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir                 // the data source to use
103cdf0e10cSrcweir                 *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii( "DataSource" ), -1, makeAny( _rxDataSource ), PropertyState_DIRECT_VALUE);
104cdf0e10cSrcweir                 *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii( "DataSourceName" ), -1, makeAny( (sal_Bool)_rSettings.bRegisterDataSource ? _rSettings.sRegisteredDataSourceName : _rSettings.sDataSourceName ), PropertyState_DIRECT_VALUE);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir                 // the table to use
107cdf0e10cSrcweir                 *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii( "Command" ), -1, makeAny( _rSettings.sSelectedTable ), PropertyState_DIRECT_VALUE);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir                 // the title
110cdf0e10cSrcweir                 ::rtl::OUString sTitle = String( ModuleRes( RID_STR_FIELDDIALOGTITLE ) );
111cdf0e10cSrcweir                 *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii( "Title" ), -1, makeAny( sTitle ), PropertyState_DIRECT_VALUE);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir                 // ........................................................
114cdf0e10cSrcweir                 // create an instance of the dialog service
115cdf0e10cSrcweir                 static ::rtl::OUString s_sAdressBookFieldAssignmentServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.ui.AddressBookSourceDialog" );
116cdf0e10cSrcweir                 Reference< XExecutableDialog > xDialog(
117cdf0e10cSrcweir                     _rxORB->createInstanceWithArguments( s_sAdressBookFieldAssignmentServiceName, aArguments ),
118cdf0e10cSrcweir                     UNO_QUERY
119cdf0e10cSrcweir                 );
120cdf0e10cSrcweir                 if ( !xDialog.is( ) )
121cdf0e10cSrcweir                 {
122cdf0e10cSrcweir                     ShowServiceNotAvailableError( _pParent, s_sAdressBookFieldAssignmentServiceName, sal_True );
123cdf0e10cSrcweir                     return sal_False;
124cdf0e10cSrcweir                 }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir                 // execute the dialog
127cdf0e10cSrcweir                 if ( xDialog->execute() )
128cdf0e10cSrcweir                 {
129cdf0e10cSrcweir                     // retrieve the field mapping as set by he user
130cdf0e10cSrcweir                     Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir                     Sequence< AliasProgrammaticPair > aMapping;
133cdf0e10cSrcweir #ifdef DBG_UTIL
134cdf0e10cSrcweir                     sal_Bool bSuccess =
135cdf0e10cSrcweir #endif
136cdf0e10cSrcweir                     xDialogProps->getPropertyValue( ::rtl::OUString::createFromAscii( "FieldMapping" ) ) >>= aMapping;
137cdf0e10cSrcweir                     DBG_ASSERT( bSuccess, "fieldmapping::invokeDialog: invalid property type for FieldMapping!" );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir                     // and copy it into the map
140cdf0e10cSrcweir                     const AliasProgrammaticPair* pMapping = aMapping.getConstArray();
141cdf0e10cSrcweir                     const AliasProgrammaticPair* pMappingEnd = pMapping + aMapping.getLength();
142cdf0e10cSrcweir                     for (;pMapping != pMappingEnd; ++pMapping)
143cdf0e10cSrcweir                         _rSettings.aFieldMapping[ pMapping->ProgrammaticName ] = pMapping->Alias;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir                     return sal_True;
146cdf0e10cSrcweir                 }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir             }
149cdf0e10cSrcweir             catch(const Exception&)
150cdf0e10cSrcweir             {
151cdf0e10cSrcweir                 DBG_ERROR("fieldmapping::invokeDialog: caught an exception while executing the dialog!");
152cdf0e10cSrcweir             }
153cdf0e10cSrcweir             return sal_False;
154cdf0e10cSrcweir         }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir         //-----------------------------------------------------------------
defaultMapping(const Reference<XMultiServiceFactory> & _rxORB,MapString2String & _rFieldAssignment)157cdf0e10cSrcweir         void defaultMapping(  const Reference< XMultiServiceFactory >& _rxORB, MapString2String& _rFieldAssignment ) SAL_THROW ( ( ) )
158cdf0e10cSrcweir         {
159cdf0e10cSrcweir             _rFieldAssignment.clear();
160cdf0e10cSrcweir 
161cdf0e10cSrcweir             try
162cdf0e10cSrcweir             {
163cdf0e10cSrcweir                 // what we have:
164cdf0e10cSrcweir                 // a) For the address data source, we need a mapping from programmatic names (1) to real column names
165cdf0e10cSrcweir                 // b) The SDBC driver has a fixed set of columns, which, when returned, are named according to
166cdf0e10cSrcweir                 //    some configuration entries. E.g., the driver displays the field which it knows contains
167cdf0e10cSrcweir                 //    the first name as "First Name" - the latter string is stored in the config.
168cdf0e10cSrcweir                 //    For this, the driver uses programmatic names, too, but they differ from the programmatic names the
169cdf0e10cSrcweir                 //    template documents have.
170cdf0e10cSrcweir                 // So what we need first is a mapping from programmatic names (1) to programmatic names (2)
171cdf0e10cSrcweir                 const sal_Char* pMappingProgrammatics[] =
172cdf0e10cSrcweir                 {
173cdf0e10cSrcweir                     "FirstName",            "FirstName",
174cdf0e10cSrcweir                     "LastName",             "LastName",
175cdf0e10cSrcweir                     "Street",               "HomeAddress",
176cdf0e10cSrcweir                     "Zip",                  "HomeZipCode",
177cdf0e10cSrcweir                     "City",                 "HomeCity",
178cdf0e10cSrcweir                     "State",                "HomeState",
179cdf0e10cSrcweir                     "Country",              "HomeCountry",
180cdf0e10cSrcweir                     "PhonePriv",            "HomePhone",
181cdf0e10cSrcweir                     "PhoneComp",            "WorkPhone",
182cdf0e10cSrcweir                     "PhoneCell",            "CellularNumber",
183cdf0e10cSrcweir                     "Pager",                "PagerNumber",
184cdf0e10cSrcweir                     "Fax",                  "FaxNumber",
185cdf0e10cSrcweir                     "EMail",                "PrimaryEmail",
186cdf0e10cSrcweir                     "URL",                  "WebPage1",
187cdf0e10cSrcweir                     "Note",                 "Notes",
188cdf0e10cSrcweir                     "Altfield1",            "Custom1",
189cdf0e10cSrcweir                     "Altfield2",            "Custom2",
190cdf0e10cSrcweir                     "Altfield3",            "Custom3",
191cdf0e10cSrcweir                     "Altfield4",            "Custom4",
192cdf0e10cSrcweir                     "Title",                "JobTitle",
193cdf0e10cSrcweir                     "Company",              "Company",
194cdf0e10cSrcweir                     "Department",           "Department"
195cdf0e10cSrcweir                 };
196cdf0e10cSrcweir                     // (this list is not complete: both lists of programmatic names are larger in real,
197cdf0e10cSrcweir                     // but this list above is the intersection)
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 
200cdf0e10cSrcweir                 // access the configuration information which the driver uses for determining it's column names
201cdf0e10cSrcweir                 ::rtl::OUString sDriverAliasesNodeName = lcl_getDriverSettingsNodeName();
202cdf0e10cSrcweir                 sDriverAliasesNodeName += ::rtl::OUString::createFromAscii( "/ColumnAliases" );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir                 // create a config node for this
205cdf0e10cSrcweir                 OConfigurationTreeRoot aDriverFieldAliasing = OConfigurationTreeRoot::createWithServiceFactory(
206cdf0e10cSrcweir                     _rxORB, sDriverAliasesNodeName, -1, OConfigurationTreeRoot::CM_READONLY);
207cdf0e10cSrcweir 
208cdf0e10cSrcweir                 // loop through all programmatic pairs
209cdf0e10cSrcweir                 DBG_ASSERT( 0 == ( sizeof( pMappingProgrammatics ) / sizeof( pMappingProgrammatics[ 0 ] ) ) % 2,
210cdf0e10cSrcweir                     "fieldmapping::defaultMapping: invalid programmatic map!" );
211cdf0e10cSrcweir                 // number of pairs
212cdf0e10cSrcweir                 sal_Int32 nIntersectedProgrammatics = sizeof( pMappingProgrammatics ) / sizeof( pMappingProgrammatics[ 0 ] ) / 2;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir                 const sal_Char** pProgrammatic = pMappingProgrammatics;
215cdf0e10cSrcweir                 ::rtl::OUString sAddressProgrammatic;
216cdf0e10cSrcweir                 ::rtl::OUString sDriverProgrammatic;
217cdf0e10cSrcweir                 ::rtl::OUString sDriverUI;
218cdf0e10cSrcweir                 for (   sal_Int32 i=0;
219cdf0e10cSrcweir                         i < nIntersectedProgrammatics;
220cdf0e10cSrcweir                         ++i
221cdf0e10cSrcweir                     )
222cdf0e10cSrcweir                 {
223cdf0e10cSrcweir                     sAddressProgrammatic = ::rtl::OUString::createFromAscii( *pProgrammatic++ );
224cdf0e10cSrcweir                     sDriverProgrammatic = ::rtl::OUString::createFromAscii( *pProgrammatic++ );
225cdf0e10cSrcweir 
226cdf0e10cSrcweir                     if ( aDriverFieldAliasing.hasByName( sDriverProgrammatic ) )
227cdf0e10cSrcweir                     {
228cdf0e10cSrcweir                         aDriverFieldAliasing.getNodeValue( sDriverProgrammatic ) >>= sDriverUI;
229cdf0e10cSrcweir                         if ( 0 == sDriverUI.getLength() )
230cdf0e10cSrcweir                         {
231cdf0e10cSrcweir                             DBG_ERROR( "fieldmapping::defaultMapping: invalid driver UI column name!");
232cdf0e10cSrcweir                         }
233cdf0e10cSrcweir                         else
234cdf0e10cSrcweir                             _rFieldAssignment[ sAddressProgrammatic ] = sDriverUI;
235cdf0e10cSrcweir                     }
236cdf0e10cSrcweir                     else
237cdf0e10cSrcweir                     {
238cdf0e10cSrcweir                         DBG_ERROR( "fieldmapping::defaultMapping: invalid driver programmatic name!" );
239cdf0e10cSrcweir                     }
240cdf0e10cSrcweir                 }
241cdf0e10cSrcweir             }
242cdf0e10cSrcweir             catch( const Exception& )
243cdf0e10cSrcweir             {
244cdf0e10cSrcweir                 DBG_ERROR("fieldmapping::defaultMapping: code is assumed to throw no exceptions!");
245cdf0e10cSrcweir                     // the config nodes we're using herein should not do this ....
246cdf0e10cSrcweir             }
247cdf0e10cSrcweir         }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir         //-----------------------------------------------------------------
writeTemplateAddressFieldMapping(const Reference<XMultiServiceFactory> & _rxORB,const MapString2String & _rFieldAssignment)250cdf0e10cSrcweir         void writeTemplateAddressFieldMapping( const Reference< XMultiServiceFactory >& _rxORB, const MapString2String& _rFieldAssignment ) SAL_THROW ( ( ) )
251cdf0e10cSrcweir         {
252cdf0e10cSrcweir             // want to have a non-const map for easier handling
253cdf0e10cSrcweir             MapString2String aFieldAssignment( _rFieldAssignment );
254cdf0e10cSrcweir 
255cdf0e10cSrcweir             // access the configuration information which the driver uses for determining it's column names
256cdf0e10cSrcweir             const ::rtl::OUString& sAddressBookNodeName = lcl_getAddressBookNodeName();
257cdf0e10cSrcweir 
258cdf0e10cSrcweir             // create a config node for this
259cdf0e10cSrcweir             OConfigurationTreeRoot aAddressBookSettings = OConfigurationTreeRoot::createWithServiceFactory(
260cdf0e10cSrcweir                 _rxORB, sAddressBookNodeName, -1, OConfigurationTreeRoot::CM_UPDATABLE);
261cdf0e10cSrcweir 
262cdf0e10cSrcweir             OConfigurationNode aFields = aAddressBookSettings.openNode( ::rtl::OUString::createFromAscii( "Fields" ) );
263cdf0e10cSrcweir 
264cdf0e10cSrcweir             // loop through all existent fields
265cdf0e10cSrcweir             Sequence< ::rtl::OUString > aExistentFields = aFields.getNodeNames();
266cdf0e10cSrcweir             const ::rtl::OUString* pExistentFields = aExistentFields.getConstArray();
267cdf0e10cSrcweir             const ::rtl::OUString* pExistentFieldsEnd = pExistentFields + aExistentFields.getLength();
268cdf0e10cSrcweir 
269cdf0e10cSrcweir             const ::rtl::OUString sProgrammaticNodeName = ::rtl::OUString::createFromAscii( "ProgrammaticFieldName" );
270cdf0e10cSrcweir             const ::rtl::OUString sAssignedNodeName = ::rtl::OUString::createFromAscii( "AssignedFieldName" );
271cdf0e10cSrcweir 
272cdf0e10cSrcweir             for ( ; pExistentFields != pExistentFieldsEnd; ++pExistentFields )
273cdf0e10cSrcweir             {
274cdf0e10cSrcweir #ifdef DBG_UTIL
275cdf0e10cSrcweir                 ::rtl::OUString sRedundantProgrammaticName;
276cdf0e10cSrcweir                 aFields.openNode( *pExistentFields ).getNodeValue( sProgrammaticNodeName ) >>= sRedundantProgrammaticName;
277cdf0e10cSrcweir #endif
278cdf0e10cSrcweir                 DBG_ASSERT( sRedundantProgrammaticName == *pExistentFields,
279cdf0e10cSrcweir                     "fieldmapping::writeTemplateAddressFieldMapping: inconsistent config data!" );
280cdf0e10cSrcweir                     // there should be a redundancy in the config data .... if this asserts, there isn't anymore!
281cdf0e10cSrcweir 
282cdf0e10cSrcweir                 // do we have a new alias for the programmatic?
283cdf0e10cSrcweir                 MapString2StringIterator aPos = aFieldAssignment.find( *pExistentFields );
284cdf0e10cSrcweir                 if ( aFieldAssignment.end() != aPos )
285cdf0e10cSrcweir                 {   // yes
286cdf0e10cSrcweir                     // -> set a new value
287cdf0e10cSrcweir                     OConfigurationNode aExistentField = aFields.openNode( *pExistentFields );
288cdf0e10cSrcweir                     aExistentField.setNodeValue( sAssignedNodeName, makeAny( aPos->second ) );
289cdf0e10cSrcweir                     // and remove the mapping entry
290cdf0e10cSrcweir                     aFieldAssignment.erase( *pExistentFields );
291cdf0e10cSrcweir                 }
292cdf0e10cSrcweir                 else
293cdf0e10cSrcweir                 {   // no
294cdf0e10cSrcweir                     // -> remove it
295cdf0e10cSrcweir                     aFields.removeNode( *pExistentFields );
296cdf0e10cSrcweir                 }
297cdf0e10cSrcweir             }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir             // now everything remaining in aFieldAssignment marks a mapping entry which was not present
300cdf0e10cSrcweir             // in the config before
301cdf0e10cSrcweir             for (   ConstMapString2StringIterator aNewMapping = aFieldAssignment.begin();
302cdf0e10cSrcweir                     aNewMapping != aFieldAssignment.end();
303cdf0e10cSrcweir                     ++aNewMapping
304cdf0e10cSrcweir                 )
305cdf0e10cSrcweir             {
306cdf0e10cSrcweir                 DBG_ASSERT( !aFields.hasByName( aNewMapping->first ),
307cdf0e10cSrcweir                     "fieldmapping::writeTemplateAddressFieldMapping: inconsistence!" );
308cdf0e10cSrcweir                     // in case the config node for the fields already has the node named <aNewMapping->first>,
309cdf0e10cSrcweir                     // the entry should have been removed from aNewMapping (in the above loop)
310cdf0e10cSrcweir                 OConfigurationNode aNewField =  aFields.createNode( aNewMapping->first );
311cdf0e10cSrcweir                 aNewField.setNodeValue( sProgrammaticNodeName, makeAny( aNewMapping->first ) );
312cdf0e10cSrcweir                 aNewField.setNodeValue( sAssignedNodeName, makeAny( aNewMapping->second ) );
313cdf0e10cSrcweir             }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir             // commit the changes done
316cdf0e10cSrcweir             aAddressBookSettings.commit();
317cdf0e10cSrcweir         }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     //.....................................................................
320cdf0e10cSrcweir     }   // namespace fieldmapping
321cdf0e10cSrcweir     //.....................................................................
322cdf0e10cSrcweir 
323cdf0e10cSrcweir     //.....................................................................
324cdf0e10cSrcweir     namespace addressconfig
325cdf0e10cSrcweir     {
326cdf0e10cSrcweir     //.....................................................................
327cdf0e10cSrcweir 
328cdf0e10cSrcweir         //-----------------------------------------------------------------
writeTemplateAddressSource(const Reference<XMultiServiceFactory> & _rxORB,const::rtl::OUString & _rDataSourceName,const::rtl::OUString & _rTableName)329cdf0e10cSrcweir         void writeTemplateAddressSource( const Reference< XMultiServiceFactory >& _rxORB,
330cdf0e10cSrcweir             const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rTableName ) SAL_THROW ( ( ) )
331cdf0e10cSrcweir         {
332cdf0e10cSrcweir             // access the configuration information which the driver uses for determining it's column names
333cdf0e10cSrcweir             const ::rtl::OUString& sAddressBookNodeName = lcl_getAddressBookNodeName();
334cdf0e10cSrcweir 
335cdf0e10cSrcweir             // create a config node for this
336cdf0e10cSrcweir             OConfigurationTreeRoot aAddressBookSettings = OConfigurationTreeRoot::createWithServiceFactory(
337cdf0e10cSrcweir                 _rxORB, sAddressBookNodeName, -1, OConfigurationTreeRoot::CM_UPDATABLE);
338cdf0e10cSrcweir 
339cdf0e10cSrcweir             aAddressBookSettings.setNodeValue( ::rtl::OUString::createFromAscii( "DataSourceName" ), makeAny( _rDataSourceName ) );
340cdf0e10cSrcweir             aAddressBookSettings.setNodeValue( ::rtl::OUString::createFromAscii( "Command" ), makeAny( _rTableName ) );
341cdf0e10cSrcweir             aAddressBookSettings.setNodeValue( ::rtl::OUString::createFromAscii( "CommandType" ), makeAny( (sal_Int32)CommandType::TABLE ) );
342cdf0e10cSrcweir 
343cdf0e10cSrcweir             // commit the changes done
344cdf0e10cSrcweir             aAddressBookSettings.commit();
345cdf0e10cSrcweir         }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir         //-----------------------------------------------------------------
markPilotSuccess(const Reference<XMultiServiceFactory> & _rxORB)348cdf0e10cSrcweir         void markPilotSuccess( const Reference< XMultiServiceFactory >& _rxORB ) SAL_THROW ( ( ) )
349cdf0e10cSrcweir         {
350cdf0e10cSrcweir             // access the configuration information which the driver uses for determining it's column names
351cdf0e10cSrcweir             const ::rtl::OUString& sAddressBookNodeName = lcl_getAddressBookNodeName();
352cdf0e10cSrcweir 
353cdf0e10cSrcweir             // create a config node for this
354cdf0e10cSrcweir             OConfigurationTreeRoot aAddressBookSettings = OConfigurationTreeRoot::createWithServiceFactory(
355cdf0e10cSrcweir                 _rxORB, sAddressBookNodeName, -1, OConfigurationTreeRoot::CM_UPDATABLE);
356cdf0e10cSrcweir 
357cdf0e10cSrcweir             // set the flag
358cdf0e10cSrcweir             aAddressBookSettings.setNodeValue( ::rtl::OUString::createFromAscii( "AutoPilotCompleted" ), makeAny( (sal_Bool)sal_True ) );
359cdf0e10cSrcweir 
360cdf0e10cSrcweir             // commit the changes done
361cdf0e10cSrcweir             aAddressBookSettings.commit();
362cdf0e10cSrcweir         }
363cdf0e10cSrcweir 
364cdf0e10cSrcweir     //.....................................................................
365cdf0e10cSrcweir     }   // namespace addressconfig
366cdf0e10cSrcweir     //.....................................................................
367cdf0e10cSrcweir 
368cdf0e10cSrcweir //.........................................................................
369cdf0e10cSrcweir }   // namespace abp
370cdf0e10cSrcweir //.........................................................................
371