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 .
22 #include <config_options.h>
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
38 // = AddressBookSourceDialog
39 struct AddressBookSourceDialogData
;
40 class UNLESS_MERGELIBS(SVT_DLLPUBLIC
) AddressBookSourceDialog final
: public weld::GenericDialogController
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>
54 a service factory to use for various UNO related needs
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.
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
77 css::uno::Sequence
< css::util::AliasProgrammaticPair
>& _rMapping
) const;
83 void implScrollFields(sal_Int32 nPos
, bool bAdjustFocus
, bool bAdjustScrollbar
);
84 static void implSelectField(weld::ComboBox
* pBox
, const OUString
& rText
);
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
>
110 // the ORB for creating objects
111 css::uno::Reference
< css::uno::XComponentContext
>
113 css::uno::Reference
< css::container::XNameAccess
>
114 m_xCurrentDatasourceTables
;
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
;
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */