1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_extensions.hxx"
26 #include "fieldmappingpage.hxx"
27 #include "fieldmappingimpl.hxx"
28 #include "addresssettings.hxx"
29 #include "abspilot.hxx"
30 
31 //.........................................................................
32 namespace abp
33 {
34 //.........................................................................
35 
36 	//=====================================================================
37 	//= FieldMappingPage
38 	//=====================================================================
39 	//---------------------------------------------------------------------
FieldMappingPage(OAddessBookSourcePilot * _pParent)40 	FieldMappingPage::FieldMappingPage( OAddessBookSourcePilot* _pParent )
41 		:AddressBookSourcePage( _pParent, ModuleRes( RID_PAGE_FIELDMAPPING ) )
42 		,m_aExplanation		( this, ModuleRes( FT_FIELDASSIGMENTEXPL ) )
43 		,m_aInvokeDialog	( this, ModuleRes( PB_INVOKE_FIELDS_DIALOG ) )
44 		,m_aHint			( this, ModuleRes( FT_ASSIGNEDFIELDS ) )
45 	{
46 		FreeResource();
47 
48 		m_aInvokeDialog.SetClickHdl( LINK( this, FieldMappingPage, OnInvokeDialog ) );
49 
50 		// check the size of the InvokeDialog button - some languages are very ... gossipy here ....
51 		// 96349 - 09.01.2002 - fs@openoffice.org
52 		sal_Int32 nTextWidth = m_aInvokeDialog.GetTextWidth( m_aInvokeDialog.GetText() );
53 
54 		sal_Int32 nBorderSpace = m_aInvokeDialog.LogicToPixel( Point( 4, 0 ), MAP_APPFONT ).X();
55 		sal_Int32 nSpace = m_aInvokeDialog.GetOutputSizePixel().Width() - 2 * nBorderSpace;
56 
57 		if ( nSpace < nTextWidth )
58 		{
59 			Size aButtonSize = m_aInvokeDialog.GetSizePixel();
60 			aButtonSize.Width() += nTextWidth - nSpace;
61 			m_aInvokeDialog.SetSizePixel( aButtonSize );
62 		}
63 	}
64 
65 	//---------------------------------------------------------------------
ActivatePage()66 	void FieldMappingPage::ActivatePage()
67 	{
68 		AddressBookSourcePage::ActivatePage();
69 		m_aInvokeDialog.GrabFocus();
70 	}
71 
72 	//---------------------------------------------------------------------
DeactivatePage()73 	void FieldMappingPage::DeactivatePage()
74 	{
75 		AddressBookSourcePage::DeactivatePage();
76 	}
77 
78 	//---------------------------------------------------------------------
initializePage()79 	void FieldMappingPage::initializePage()
80 	{
81 		AddressBookSourcePage::initializePage();
82 		implUpdateHint();
83 	}
84 
85 	//---------------------------------------------------------------------
implUpdateHint()86 	void FieldMappingPage::implUpdateHint()
87 	{
88 		const AddressSettings& rSettings = getSettings();
89 		String sHint;
90 		if ( 0 == rSettings.aFieldMapping.size() )
91 			sHint = String( ModuleRes( RID_STR_NOFIELDSASSIGNED ) );
92 		m_aHint.SetText( sHint );
93 	}
94 
95 	//---------------------------------------------------------------------
96 	IMPL_LINK( FieldMappingPage, OnInvokeDialog, void*, /*NOTINTERESTEDIN*/ )
97 	{
98 		AddressSettings& rSettings = getSettings();
99 
100 		// invoke the dialog doing the mapping
101 		if ( fieldmapping::invokeDialog( getORB(), this, getDialog()->getDataSource().getDataSource(), rSettings ) )
102 		{
103 			if ( rSettings.aFieldMapping.size() )
104 				getDialog()->travelNext();
105 			else
106 				implUpdateHint();
107 		}
108 
109 		return 0L;
110 	}
111 
112 //.........................................................................
113 }	// namespace abp
114 //.........................................................................
115 
116