update dev300-m58
[ooovba.git] / extensions / source / abpilot / fieldmappingpage.cxx
blobcb6dd2ba64915f542644b73643355e7292769f81
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: fieldmappingpage.cxx,v $
10 * $Revision: 1.13 $
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_extensions.hxx"
33 #include "fieldmappingpage.hxx"
34 #include "fieldmappingimpl.hxx"
35 #include "addresssettings.hxx"
36 #include "abspilot.hxx"
38 //.........................................................................
39 namespace abp
41 //.........................................................................
43 //=====================================================================
44 //= FieldMappingPage
45 //=====================================================================
46 //---------------------------------------------------------------------
47 FieldMappingPage::FieldMappingPage( OAddessBookSourcePilot* _pParent )
48 :AddressBookSourcePage( _pParent, ModuleRes( RID_PAGE_FIELDMAPPING ) )
49 ,m_aExplanation ( this, ModuleRes( FT_FIELDASSIGMENTEXPL ) )
50 ,m_aInvokeDialog ( this, ModuleRes( PB_INVOKE_FIELDS_DIALOG ) )
51 ,m_aHint ( this, ModuleRes( FT_ASSIGNEDFIELDS ) )
53 FreeResource();
55 m_aInvokeDialog.SetClickHdl( LINK( this, FieldMappingPage, OnInvokeDialog ) );
57 // check the size of the InvokeDialog button - some languages are very ... gossipy here ....
58 // 96349 - 09.01.2002 - fs@openoffice.org
59 sal_Int32 nTextWidth = m_aInvokeDialog.GetTextWidth( m_aInvokeDialog.GetText() );
61 sal_Int32 nBorderSpace = m_aInvokeDialog.LogicToPixel( Point( 4, 0 ), MAP_APPFONT ).X();
62 sal_Int32 nSpace = m_aInvokeDialog.GetOutputSizePixel().Width() - 2 * nBorderSpace;
64 if ( nSpace < nTextWidth )
66 Size aButtonSize = m_aInvokeDialog.GetSizePixel();
67 aButtonSize.Width() += nTextWidth - nSpace;
68 m_aInvokeDialog.SetSizePixel( aButtonSize );
72 //---------------------------------------------------------------------
73 void FieldMappingPage::ActivatePage()
75 AddressBookSourcePage::ActivatePage();
76 m_aInvokeDialog.GrabFocus();
79 //---------------------------------------------------------------------
80 void FieldMappingPage::DeactivatePage()
82 AddressBookSourcePage::DeactivatePage();
85 //---------------------------------------------------------------------
86 void FieldMappingPage::initializePage()
88 AddressBookSourcePage::initializePage();
89 implUpdateHint();
92 //---------------------------------------------------------------------
93 void FieldMappingPage::implUpdateHint()
95 const AddressSettings& rSettings = getSettings();
96 String sHint;
97 if ( 0 == rSettings.aFieldMapping.size() )
98 sHint = String( ModuleRes( RID_STR_NOFIELDSASSIGNED ) );
99 m_aHint.SetText( sHint );
102 //---------------------------------------------------------------------
103 IMPL_LINK( FieldMappingPage, OnInvokeDialog, void*, /*NOTINTERESTEDIN*/ )
105 AddressSettings& rSettings = getSettings();
107 // invoke the dialog doing the mapping
108 if ( fieldmapping::invokeDialog( getORB(), this, getDialog()->getDataSource().getDataSource(), rSettings ) )
110 if ( rSettings.aFieldMapping.size() )
111 getDialog()->travelNext();
112 else
113 implUpdateHint();
116 return 0L;
119 //.........................................................................
120 } // namespace abp
121 //.........................................................................