merged tag ooo/OOO330_m14
[LibreOffice.git] / extensions / source / abpilot / fieldmappingpage.cxx
blobaaf2167d2dc2dea8431ce7247b33267133911d40
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
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"
35 //.........................................................................
36 namespace abp
38 //.........................................................................
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 ) )
50 FreeResource();
52 m_aInvokeDialog.SetClickHdl( LINK( this, FieldMappingPage, OnInvokeDialog ) );
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() );
58 sal_Int32 nBorderSpace = m_aInvokeDialog.LogicToPixel( Point( 4, 0 ), MAP_APPFONT ).X();
59 sal_Int32 nSpace = m_aInvokeDialog.GetOutputSizePixel().Width() - 2 * nBorderSpace;
61 if ( nSpace < nTextWidth )
63 Size aButtonSize = m_aInvokeDialog.GetSizePixel();
64 aButtonSize.Width() += nTextWidth - nSpace;
65 m_aInvokeDialog.SetSizePixel( aButtonSize );
69 //---------------------------------------------------------------------
70 void FieldMappingPage::ActivatePage()
72 AddressBookSourcePage::ActivatePage();
73 m_aInvokeDialog.GrabFocus();
76 //---------------------------------------------------------------------
77 void FieldMappingPage::DeactivatePage()
79 AddressBookSourcePage::DeactivatePage();
82 //---------------------------------------------------------------------
83 void FieldMappingPage::initializePage()
85 AddressBookSourcePage::initializePage();
86 implUpdateHint();
89 //---------------------------------------------------------------------
90 void FieldMappingPage::implUpdateHint()
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 );
99 //---------------------------------------------------------------------
100 IMPL_LINK( FieldMappingPage, OnInvokeDialog, void*, /*NOTINTERESTEDIN*/ )
102 AddressSettings& rSettings = getSettings();
104 // invoke the dialog doing the mapping
105 if ( fieldmapping::invokeDialog( getORB(), this, getDialog()->getDataSource().getDataSource(), rSettings ) )
107 if ( rSettings.aFieldMapping.size() )
108 getDialog()->travelNext();
109 else
110 implUpdateHint();
113 return 0L;
116 //.........................................................................
117 } // namespace abp
118 //.........................................................................