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_dbaccess.hxx"
30 
31 #include "textconnectionsettings.hxx"
32 #include "TextConnectionHelper.hxx"
33 #include "dbu_resource.hrc"
34 #include "moduledbu.hxx"
35 #include "dsitems.hxx"
36 #include "dbustrings.hrc"
37 
38 /** === begin UNO includes === **/
39 /** === end UNO includes === **/
40 
41 #include <vcl/msgbox.hxx>
42 
43 //........................................................................
44 namespace dbaui
45 {
46 //........................................................................
47 
48 	/** === begin UNO using === **/
49 	/** === end UNO using === **/
50 
51 	//====================================================================
52 	//= TextConnectionSettingsDialog
53 	//====================================================================
54 	//--------------------------------------------------------------------
55     TextConnectionSettingsDialog::TextConnectionSettingsDialog( Window* _pParent, SfxItemSet& _rItems )
56         :ModalDialog( _pParent, ModuleRes( DLG_TEXT_CONNECTION_SETTINGS ) )
57         ,m_aOK( this, ModuleRes( 1 ) )
58         ,m_aCancel( this, ModuleRes( 1 ) )
59         ,m_rItems( _rItems )
60     {
61         m_pTextConnectionHelper.reset( new OTextConnectionHelper( this, TC_HEADER | TC_SEPARATORS | TC_CHARSET ) );
62         FreeResource();
63 
64         m_aOK.SetClickHdl( LINK( this, TextConnectionSettingsDialog, OnOK ) );
65     }
66 
67 	//--------------------------------------------------------------------
68     TextConnectionSettingsDialog::~TextConnectionSettingsDialog()
69     {
70     }
71 
72 	//--------------------------------------------------------------------
73     void TextConnectionSettingsDialog::bindItemStorages( SfxItemSet& _rSet, PropertyValues& _rValues )
74     {
75         _rValues[ PROPERTY_ID_HEADER_LINE ].reset( new SetItemPropertyStorage( _rSet, DSID_TEXTFILEHEADER ) );
76         _rValues[ PROPERTY_ID_FIELD_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_FIELDDELIMITER ) );
77         _rValues[ PROPERTY_ID_STRING_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_TEXTDELIMITER ) );
78         _rValues[ PROPERTY_ID_DECIMAL_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_DECIMALDELIMITER ) );
79         _rValues[ PROPERTY_ID_THOUSAND_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_THOUSANDSDELIMITER ) );
80         _rValues[ PROPERTY_ID_ENCODING ].reset( new SetItemPropertyStorage( _rSet, DSID_CHARSET ) );
81     }
82 
83 	//--------------------------------------------------------------------
84     short TextConnectionSettingsDialog::Execute()
85     {
86         m_pTextConnectionHelper->implInitControls( m_rItems, sal_True );
87         return ModalDialog::Execute();
88     }
89 
90 	//--------------------------------------------------------------------
91     IMPL_LINK( TextConnectionSettingsDialog, OnOK, PushButton*, /*_pButton*/ )
92     {
93         if ( m_pTextConnectionHelper->prepareLeave() )
94         {
95             sal_Bool bUnused = sal_False;
96             m_pTextConnectionHelper->FillItemSet( m_rItems, bUnused );
97             EndDialog( RET_OK );
98             return 1L;
99         }
100 
101         return 0L;
102     }
103 
104 //........................................................................
105 } // namespace dbaui
106 //........................................................................
107