1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_extensions.hxx" 30 #include "fieldmappingpage.hxx" 31 #include "fieldmappingimpl.hxx" 32 #include "addresssettings.hxx" 33 #include "abspilot.hxx" 34 35 //......................................................................... 36 namespace abp 37 { 38 //......................................................................... 39 40 //===================================================================== 41 //= FieldMappingPage 42 //===================================================================== 43 //--------------------------------------------------------------------- 44 FieldMappingPage::FieldMappingPage( OAddessBookSourcePilot* _pParent ) 45 :AddressBookSourcePage( _pParent, ModuleRes( RID_PAGE_FIELDMAPPING ) ) 46 ,m_aExplanation ( this, ModuleRes( FT_FIELDASSIGMENTEXPL ) ) 47 ,m_aInvokeDialog ( this, ModuleRes( PB_INVOKE_FIELDS_DIALOG ) ) 48 ,m_aHint ( this, ModuleRes( FT_ASSIGNEDFIELDS ) ) 49 { 50 FreeResource(); 51 52 m_aInvokeDialog.SetClickHdl( LINK( this, FieldMappingPage, OnInvokeDialog ) ); 53 54 // check the size of the InvokeDialog button - some languages are very ... gossipy here .... 55 // 96349 - 09.01.2002 - fs@openoffice.org 56 sal_Int32 nTextWidth = m_aInvokeDialog.GetTextWidth( m_aInvokeDialog.GetText() ); 57 58 sal_Int32 nBorderSpace = m_aInvokeDialog.LogicToPixel( Point( 4, 0 ), MAP_APPFONT ).X(); 59 sal_Int32 nSpace = m_aInvokeDialog.GetOutputSizePixel().Width() - 2 * nBorderSpace; 60 61 if ( nSpace < nTextWidth ) 62 { 63 Size aButtonSize = m_aInvokeDialog.GetSizePixel(); 64 aButtonSize.Width() += nTextWidth - nSpace; 65 m_aInvokeDialog.SetSizePixel( aButtonSize ); 66 } 67 } 68 69 //--------------------------------------------------------------------- 70 void FieldMappingPage::ActivatePage() 71 { 72 AddressBookSourcePage::ActivatePage(); 73 m_aInvokeDialog.GrabFocus(); 74 } 75 76 //--------------------------------------------------------------------- 77 void FieldMappingPage::DeactivatePage() 78 { 79 AddressBookSourcePage::DeactivatePage(); 80 } 81 82 //--------------------------------------------------------------------- 83 void FieldMappingPage::initializePage() 84 { 85 AddressBookSourcePage::initializePage(); 86 implUpdateHint(); 87 } 88 89 //--------------------------------------------------------------------- 90 void FieldMappingPage::implUpdateHint() 91 { 92 const AddressSettings& rSettings = getSettings(); 93 String sHint; 94 if ( 0 == rSettings.aFieldMapping.size() ) 95 sHint = String( ModuleRes( RID_STR_NOFIELDSASSIGNED ) ); 96 m_aHint.SetText( sHint ); 97 } 98 99 //--------------------------------------------------------------------- 100 IMPL_LINK( FieldMappingPage, OnInvokeDialog, void*, /*NOTINTERESTEDIN*/ ) 101 { 102 AddressSettings& rSettings = getSettings(); 103 104 // invoke the dialog doing the mapping 105 if ( fieldmapping::invokeDialog( getORB(), this, getDialog()->getDataSource().getDataSource(), rSettings ) ) 106 { 107 if ( rSettings.aFieldMapping.size() ) 108 getDialog()->travelNext(); 109 else 110 implUpdateHint(); 111 } 112 113 return 0L; 114 } 115 116 //......................................................................... 117 } // namespace abp 118 //......................................................................... 119 120