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