Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svtools / addresstemplate.hxx
blobf59cdf930baa4a8618bc13bda5b0de45502c7339
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 #ifndef INCLUDED_SVTOOLS_ADDRESSTEMPLATE_HXX
21 #define INCLUDED_SVTOOLS_ADDRESSTEMPLATE_HXX
23 #include <memory>
24 #include <svtools/svtdllapi.h>
25 #include <vcl/dialog.hxx>
26 #include <vcl/fixed.hxx>
27 #include <vcl/combobox.hxx>
28 #include <vcl/button.hxx>
29 #include <vcl/layout.hxx>
30 #include <vcl/lstbox.hxx>
31 #include <vcl/scrbar.hxx>
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #include <com/sun/star/util/AliasProgrammaticPair.hpp>
34 #include <com/sun/star/sdb/XDatabaseContext.hpp>
35 #include <com/sun/star/uno/XComponentContext.hpp>
36 #include <com/sun/star/sdbc/XDataSource.hpp>
37 #include <unotools/configitem.hxx>
40 namespace svt
44 // = AddressBookSourceDialog
46 struct AddressBookSourceDialogData;
47 class SVT_DLLPUBLIC AddressBookSourceDialog : public ModalDialog
49 private:
50 // Controls
51 VclPtr<ComboBox> m_pDatasource;
52 VclPtr<PushButton> m_pAdministrateDatasources;
53 VclPtr<ComboBox> m_pTable;
54 VclPtr<ScrollBar> m_pFieldScroller;
56 // string to display for "no selection"
57 const OUString m_sNoFieldSelection;
59 /// the DatabaseContext for selecting data sources
60 css::uno::Reference< css::sdb::XDatabaseContext >
61 m_xDatabaseContext;
62 // the ORB for creating objects
63 css::uno::Reference< css::uno::XComponentContext >
64 m_xORB;
65 css::uno::Reference< css::container::XNameAccess >
66 m_xCurrentDatasourceTables;
68 std::unique_ptr<AddressBookSourceDialogData> m_pImpl;
70 public:
71 AddressBookSourceDialog( vcl::Window* _pParent,
72 const css::uno::Reference< css::uno::XComponentContext >& _rxORB );
74 /** if you use this ctor, the dialog
75 <ul><li>will not store it's data in the configuration (nor initially retrieve it from there)</li>
76 <li>will not allow to change the data source name</li>
77 <li>will not allow to change the table name</li>
78 <li>will not allow to call the data source administration dialog</li>
79 </ul>
81 @param _rxORB
82 a service factory to use for various UNO related needs
83 @param _rxTransientDS
84 the data source to obtain connections from
85 @param _rDataSourceName
86 the to-be name of _rxTransientDS. This is only for displaying this
87 name to the user, since the dialog completely works on _rxTransientDS,
88 and doesn't allow to change this.
89 @param _rTable
90 the table name to display. It must refer to a valid table, relative to a connection
91 obtained from <arg>_rxTransientDS</arg>
93 AddressBookSourceDialog( vcl::Window* _pParent,
94 const css::uno::Reference< css::uno::XComponentContext >& _rxORB,
95 const css::uno::Reference< css::sdbc::XDataSource >& _rxTransientDS,
96 const OUString& _rDataSourceName,
97 const OUString& _rTable,
98 const css::uno::Sequence< css::util::AliasProgrammaticPair >& _rMapping
101 virtual ~AddressBookSourceDialog() override;
102 virtual void dispose() override;
104 // to be used if the object was constructed for editing a field mapping only
105 void getFieldMapping(
106 css::uno::Sequence< css::util::AliasProgrammaticPair >& _rMapping) const;
108 protected:
109 void implConstruct();
111 // Window overridables
112 virtual bool PreNotify( NotifyEvent& _rNEvt ) override;
114 // implementations
115 void implScrollFields(sal_Int32 _nPos, bool _bAdjustFocus, bool _bAdjustScrollbar);
116 static void implSelectField(ListBox* _pBox, const OUString& _rText);
118 void resetTables();
119 void resetFields();
121 // fill in the data sources listbox
122 void initializeDatasources();
124 // initialize the dialog from the configuration data
125 void loadConfiguration();
127 DECL_LINK(OnFieldScroll, ScrollBar*, void);
128 DECL_LINK(OnFieldSelect, ListBox&, void);
129 DECL_LINK(OnAdministrateDatasources, Button*, void);
130 DECL_STATIC_LINK(AddressBookSourceDialog, OnComboGetFocus, Control&, void);
131 DECL_LINK(OnComboLoseFocus, Control&, void);
132 DECL_LINK(OnComboSelect, ComboBox&, void);
133 DECL_LINK(OnOkClicked, Button*, void);
134 DECL_LINK(OnDelayedInitialize, void*, void);
138 } // namespace svt
141 #endif // INCLUDED_SVTOOLS_ADDRESSTEMPLATE_HXX
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */