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