1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: addresstemplate.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVT_ADDRESSTEMPLATE_HXX_
32 #define _SVT_ADDRESSTEMPLATE_HXX_
34 #include "svtools/svtdllapi.h"
35 #include <vcl/dialog.hxx>
36 #include <vcl/group.hxx>
37 #include <vcl/fixed.hxx>
38 #include <vcl/combobox.hxx>
39 #include <vcl/imagebtn.hxx>
40 #include <vcl/lstbox.hxx>
41 #include <vcl/scrbar.hxx>
42 #include <com/sun/star/container/XNameAccess.hpp>
43 #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
44 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 #include <com/sun/star/util/AliasProgrammaticPair.hpp>
47 #include <com/sun/star/sdbc/XDataSource.hpp>
48 #include <unotools/configitem.hxx>
50 // .......................................................................
53 // .......................................................................
55 // ===================================================================
56 // = AddressBookSourceDialog
57 // ===================================================================
58 struct AddressBookSourceDialogData
;
59 class SVT_DLLPUBLIC AddressBookSourceDialog
: public ModalDialog
63 FixedLine m_aDatasourceFrame
;
64 FixedText m_aDatasourceLabel
;
65 ComboBox m_aDatasource
;
66 PushButton m_aAdministrateDatasources
;
67 FixedText m_aTableLabel
;
70 FixedText m_aFieldsTitle
;
71 Window m_aFieldsFrame
;
73 ScrollBar m_aFieldScroller
;
75 CancelButton m_aCancel
;
78 // string to display for "no selection"
79 const String m_sNoFieldSelection
;
81 /// the DatabaseContext for selecting data sources
82 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>
84 // the ORB for creating objects
85 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>
87 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>
88 m_xCurrentDatasourceTables
;
90 AddressBookSourceDialogData
*
94 AddressBookSourceDialog( Window
* _pParent
,
95 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
);
97 /** if you use this ctor, the dialog
98 <ul><li>will not store it's data in the configuration (nor initially retrieve it from there)</li>
99 <li>will not allow to change the data source name</li>
100 <li>will not allow to change the table name</li>
101 <li>will not allow to call the data source administration dialog</li>
105 a service factory to use for various UNO related needs
106 @param _rxTransientDS
107 the data source to obtain connections from
108 @param _rDataSourceName
109 the to-be name of _rxTransientDS. This is only for displaying this
110 name to the user, since the dialog completely works on _rxTransientDS,
111 and doesn't allow to change this.
113 the table name to display. It must refer to a valid table, relative to a connection
114 obtained from <arg>_rxTransientDS</arg>
116 AddressBookSourceDialog( Window
* _pParent
,
117 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
,
118 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDataSource
>& _rxTransientDS
,
119 const ::rtl::OUString
& _rDataSourceName
,
120 const ::rtl::OUString
& _rTable
,
121 const ::com::sun::star::uno::Sequence
< ::com::sun::star::util::AliasProgrammaticPair
>& _rMapping
124 ~AddressBookSourceDialog();
126 // to be used if the object was constructed for editing a field mapping only
127 void getFieldMapping(
128 ::com::sun::star::uno::Sequence
< ::com::sun::star::util::AliasProgrammaticPair
>& _rMapping
) const;
131 void implConstruct();
133 // Window overridables
134 virtual long PreNotify( NotifyEvent
& _rNEvt
);
137 void implScrollFields(sal_Int32 _nPos
, sal_Bool _bAdjustFocus
, sal_Bool _bAdjustScrollbar
);
138 void implSelectField(ListBox
* _pBox
, const String
& _rText
);
140 void initalizeListBox(ListBox
* _pList
);
144 // fill in the data sources listbox
145 void initializeDatasources();
147 // initialize the dialog from the configuration data
148 void loadConfiguration();
150 DECL_LINK(OnFieldScroll
, ScrollBar
*);
151 DECL_LINK(OnFieldSelect
, ListBox
*);
152 DECL_LINK(OnAdministrateDatasources
, void*);
153 DECL_LINK(OnComboGetFocus
, ComboBox
*);
154 DECL_LINK(OnComboLoseFocus
, ComboBox
*);
155 DECL_LINK(OnComboSelect
, ComboBox
*);
156 DECL_LINK(OnOkClicked
, Button
*);
157 DECL_LINK(OnDelayedInitialize
, void*);
161 // .......................................................................
163 // .......................................................................
165 #endif // _SVT_ADDRESSTEMPLATE_HXX_