1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <textconnectionsettings.hxx>
21 #include "TextConnectionHelper.hxx"
22 #include <dsitems.hxx>
23 #include <stringconstants.hxx>
27 // TextConnectionSettingsDialog
28 TextConnectionSettingsDialog::TextConnectionSettingsDialog(weld::Window
* pParent
, SfxItemSet
& rItems
)
29 : GenericDialogController(pParent
, u
"dbaccess/ui/textconnectionsettings.ui"_ustr
, u
"TextConnectionSettingsDialog"_ustr
)
31 , m_xContainer(m_xBuilder
->weld_widget(u
"TextPageContainer"_ustr
))
32 , m_xOK(m_xBuilder
->weld_button(u
"ok"_ustr
))
33 , m_xTextConnectionHelper(new OTextConnectionHelper(m_xContainer
.get(), TC_HEADER
| TC_SEPARATORS
| TC_CHARSET
))
35 m_xOK
->connect_clicked(LINK(this, TextConnectionSettingsDialog
, OnOK
));
38 TextConnectionSettingsDialog::~TextConnectionSettingsDialog()
42 void TextConnectionSettingsDialog::bindItemStorages( SfxItemSet
& _rSet
, PropertyValues
& _rValues
)
44 _rValues
[ PROPERTY_ID_HEADER_LINE
] = std::make_shared
<SetItemPropertyStorage
>( _rSet
, DSID_TEXTFILEHEADER
);
45 _rValues
[ PROPERTY_ID_FIELD_DELIMITER
] = std::make_shared
<SetItemPropertyStorage
>( _rSet
, DSID_FIELDDELIMITER
);
46 _rValues
[ PROPERTY_ID_STRING_DELIMITER
] = std::make_shared
<SetItemPropertyStorage
>( _rSet
, DSID_TEXTDELIMITER
);
47 _rValues
[ PROPERTY_ID_DECIMAL_DELIMITER
] = std::make_shared
<SetItemPropertyStorage
>( _rSet
, DSID_DECIMALDELIMITER
);
48 _rValues
[ PROPERTY_ID_THOUSAND_DELIMITER
] = std::make_shared
<SetItemPropertyStorage
>( _rSet
, DSID_THOUSANDSDELIMITER
);
49 _rValues
[ PROPERTY_ID_ENCODING
] = std::make_shared
<SetItemPropertyStorage
>( _rSet
, DSID_CHARSET
);
52 short TextConnectionSettingsDialog::run()
54 m_xTextConnectionHelper
->implInitControls(m_rItems
, true);
55 return GenericDialogController::run();
58 IMPL_LINK_NOARG(TextConnectionSettingsDialog
, OnOK
, weld::Button
&, void)
60 if (m_xTextConnectionHelper
->prepareLeave())
62 m_xTextConnectionHelper
->FillItemSet( m_rItems
, false/*bUnused*/ );
63 m_xDialog
->response(RET_OK
);
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */