tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / svtools / addresstemplate.hxx
blob04ce8d9be68d2e3334c42b75ddc80c003e11d5e8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <config_options.h>
23 #include <memory>
24 #include <svtools/svtdllapi.h>
25 #include <vcl/weld.hxx>
27 namespace com :: sun :: star :: container { class XNameAccess; }
28 namespace com :: sun :: star :: sdbc { class XDataSource; }
29 namespace com :: sun :: star :: sdb { class XDatabaseContext; }
30 namespace com :: sun :: star :: uno { class XComponentContext; }
31 namespace com :: sun :: star :: util { struct AliasProgrammaticPair; }
33 #define FIELD_PAIRS_VISIBLE 5
34 #define FIELD_CONTROLS_VISIBLE 2 * FIELD_PAIRS_VISIBLE
36 namespace svt
38 // = AddressBookSourceDialog
39 struct AddressBookSourceDialogData;
40 class UNLESS_MERGELIBS(SVT_DLLPUBLIC) AddressBookSourceDialog final : public weld::GenericDialogController
42 public:
43 AddressBookSourceDialog(weld::Window* _pParent,
44 const css::uno::Reference< css::uno::XComponentContext >& _rxORB );
46 /** if you use this ctor, the dialog
47 <ul><li>will not store it's data in the configuration (nor initially retrieve it from there)</li>
48 <li>will not allow to change the data source name</li>
49 <li>will not allow to change the table name</li>
50 <li>will not allow to call the data source administration dialog</li>
51 </ul>
53 @param _rxORB
54 a service factory to use for various UNO related needs
55 @param _rxTransientDS
56 the data source to obtain connections from
57 @param _rDataSourceName
58 the to-be name of _rxTransientDS. This is only for displaying this
59 name to the user, since the dialog completely works on _rxTransientDS,
60 and doesn't allow to change this.
61 @param _rTable
62 the table name to display. It must refer to a valid table, relative to a connection
63 obtained from <arg>_rxTransientDS</arg>
65 AddressBookSourceDialog(weld::Window* _pParent,
66 const css::uno::Reference< css::uno::XComponentContext >& _rxORB,
67 const css::uno::Reference< css::sdbc::XDataSource >& _rxTransientDS,
68 const OUString& _rDataSourceName,
69 const OUString& _rTable,
70 const css::uno::Sequence< css::util::AliasProgrammaticPair >& _rMapping
73 virtual ~AddressBookSourceDialog() override;
75 // to be used if the object was constructed for editing a field mapping only
76 void getFieldMapping(
77 css::uno::Sequence< css::util::AliasProgrammaticPair >& _rMapping) const;
79 private:
80 void implConstruct();
82 // implementations
83 void implScrollFields(sal_Int32 nPos, bool bAdjustFocus, bool bAdjustScrollbar);
84 static void implSelectField(weld::ComboBox* pBox, const OUString& rText);
86 void resetTables();
87 void resetFields();
89 // fill in the data sources listbox
90 void initializeDatasources();
92 // initialize the dialog from the configuration data
93 void loadConfiguration();
95 DECL_DLLPRIVATE_LINK(OnFieldScroll, weld::ScrolledWindow&, void);
96 DECL_DLLPRIVATE_LINK(OnFieldSelect, weld::ComboBox&, void);
97 DECL_DLLPRIVATE_LINK(OnAdministrateDatasources, weld::Button&, void);
98 DECL_DLLPRIVATE_STATIC_LINK(AddressBookSourceDialog, OnComboGetFocus, weld::Widget&, void);
99 DECL_DLLPRIVATE_LINK(OnComboLoseFocus, weld::Widget&, void);
100 DECL_DLLPRIVATE_LINK(OnComboSelect, weld::ComboBox&, void);
101 DECL_DLLPRIVATE_LINK(OnOkClicked, weld::Button&, void);
102 DECL_DLLPRIVATE_LINK(OnDelayedInitialize, void*, void);
104 // string to display for "no selection"
105 const OUString m_sNoFieldSelection;
107 /// the DatabaseContext for selecting data sources
108 css::uno::Reference< css::sdb::XDatabaseContext >
109 m_xDatabaseContext;
110 // the ORB for creating objects
111 css::uno::Reference< css::uno::XComponentContext >
112 m_xORB;
113 css::uno::Reference< css::container::XNameAccess >
114 m_xCurrentDatasourceTables;
116 // Controls
117 std::unique_ptr<weld::ComboBox> m_xDatasource;
118 std::unique_ptr<weld::Button> m_xAdministrateDatasources;
119 std::unique_ptr<weld::ComboBox> m_xTable;
120 std::unique_ptr<weld::ScrolledWindow> m_xFieldScroller;
121 std::unique_ptr<weld::Button> m_xOKButton;
122 std::unique_ptr<weld::Widget> m_xGrid;
124 std::unique_ptr<AddressBookSourceDialogData> m_pImpl;
126 } // namespace svt
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */