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 #ifndef INCLUDED_SVTOOLS_ADDRESSTEMPLATE_HXX
21 #define INCLUDED_SVTOOLS_ADDRESSTEMPLATE_HXX
23 #include <svtools/svtdllapi.h>
24 #include <vcl/dialog.hxx>
25 #include <vcl/fixed.hxx>
26 #include <vcl/combobox.hxx>
27 #include <vcl/button.hxx>
28 #include <vcl/layout.hxx>
29 #include <vcl/lstbox.hxx>
30 #include <vcl/scrbar.hxx>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/util/AliasProgrammaticPair.hpp>
33 #include <com/sun/star/sdb/XDatabaseContext.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <com/sun/star/sdbc/XDataSource.hpp>
36 #include <unotools/configitem.hxx>
44 // = AddressBookSourceDialog
46 struct AddressBookSourceDialogData
;
47 class SVT_DLLPUBLIC AddressBookSourceDialog
: public ModalDialog
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 ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XDatabaseContext
>
62 // the ORB for creating objects
63 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>
65 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>
66 m_xCurrentDatasourceTables
;
68 AddressBookSourceDialogData
*
72 AddressBookSourceDialog( vcl::Window
* _pParent
,
73 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxORB
);
75 /** if you use this ctor, the dialog
76 <ul><li>will not store it's data in the configuration (nor initially retrieve it from there)</li>
77 <li>will not allow to change the data source name</li>
78 <li>will not allow to change the table name</li>
79 <li>will not allow to call the data source administration dialog</li>
83 a service factory to use for various UNO related needs
85 the data source to obtain connections from
86 @param _rDataSourceName
87 the to-be name of _rxTransientDS. This is only for displaying this
88 name to the user, since the dialog completely works on _rxTransientDS,
89 and doesn't allow to change this.
91 the table name to display. It must refer to a valid table, relative to a connection
92 obtained from <arg>_rxTransientDS</arg>
94 AddressBookSourceDialog( vcl::Window
* _pParent
,
95 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxORB
,
96 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDataSource
>& _rxTransientDS
,
97 const OUString
& _rDataSourceName
,
98 const OUString
& _rTable
,
99 const ::com::sun::star::uno::Sequence
< ::com::sun::star::util::AliasProgrammaticPair
>& _rMapping
102 virtual ~AddressBookSourceDialog();
103 virtual void dispose() SAL_OVERRIDE
;
105 // to be used if the object was constructed for editing a field mapping only
106 void getFieldMapping(
107 ::com::sun::star::uno::Sequence
< ::com::sun::star::util::AliasProgrammaticPair
>& _rMapping
) const;
110 void implConstruct();
112 // Window overridables
113 virtual bool PreNotify( NotifyEvent
& _rNEvt
) SAL_OVERRIDE
;
116 void implScrollFields(sal_Int32 _nPos
, bool _bAdjustFocus
, bool _bAdjustScrollbar
);
117 static void implSelectField(ListBox
* _pBox
, const OUString
& _rText
);
119 void initalizeListBox(ListBox
* _pList
);
123 // fill in the data sources listbox
124 void initializeDatasources();
126 // initialize the dialog from the configuration data
127 void loadConfiguration();
129 DECL_LINK(OnFieldScroll
, ScrollBar
*);
130 DECL_LINK(OnFieldSelect
, ListBox
*);
131 DECL_LINK(OnAdministrateDatasources
, void*);
132 DECL_STATIC_LINK(AddressBookSourceDialog
, OnComboGetFocus
, ComboBox
*);
133 DECL_LINK(OnComboLoseFocus
, ComboBox
*);
134 DECL_LINK(OnComboSelect
, ComboBox
*);
135 DECL_LINK(OnOkClicked
, void*);
136 DECL_LINK(OnDelayedInitialize
, void*);
144 #endif // INCLUDED_SVTOOLS_ADDRESSTEMPLATE_HXX
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */