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 <sfx2/tabdlg.hxx>
23 #include <dsntypes.hxx>
24 #include "IItemSetHelper.hxx"
25 #include <unotools/resmgr.hxx>
28 namespace com::sun::star
{
36 class XMultiServiceFactory
;
44 class ODbDataSourceAdministrationHelper
;
45 /** tab dialog for administrating the office wide registered data sources
47 class ODbAdminDialog final
: public SfxTabDialogController
, public IItemSetHelper
, public IDatabaseSettingsDialog
50 std::unique_ptr
<ODbDataSourceAdministrationHelper
> m_pImpl
;
52 OUString m_sMainPageID
;
55 /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed
56 after the dialog has been destroyed
58 ODbAdminDialog(weld::Window
* pParent
, SfxItemSet
const * _pItems
,
59 const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
);
60 virtual ~ODbAdminDialog() override
;
62 /** create and return an item set for use with the dialog.
63 @param _pTypeCollection pointer to an <type>ODatasourceMap</type>. May be NULL, in this case
64 the pool will not contain a typecollection default.
66 static void createItemSet(std::unique_ptr
<SfxItemSet
>& _rpSet
, rtl::Reference
<SfxItemPool
>& _rpPool
, ::dbaccess::ODsnTypeCollection
* _pTypeCollection
);
67 /** destroy and item set / item pool / pool defaults previously created by <method>createItemSet</method>
69 static void destroyItemSet(std::unique_ptr
<SfxItemSet
>& _rpSet
, rtl::Reference
<SfxItemPool
>& _rpPool
);
71 /** selects the DataSource
73 The name of the data source
75 void selectDataSource(const css::uno::Any
& _aDataSourceName
);
77 virtual const SfxItemSet
* getOutputSet() const override
;
78 virtual SfxItemSet
* getWriteOutputSet() override
;
80 // forwards to ODbDataSourceAdministrationHelper
81 virtual css::uno::Reference
< css::uno::XComponentContext
> getORB() const override
;
82 virtual std::pair
< css::uno::Reference
< css::sdbc::XConnection
>,bool> createConnection() override
;
83 virtual css::uno::Reference
< css::sdbc::XDriver
> getDriver() override
;
84 virtual OUString
getDatasourceType(const SfxItemSet
& _rSet
) const override
;
85 virtual void clearPassword() override
;
86 virtual void saveDatasource() override
;
87 virtual void setTitle(const OUString
& _sTitle
) override
;
88 virtual void enableConfirmSettings( bool _bEnable
) override
;
91 // adds a new detail page and remove all the old ones
92 void addDetailPage(const OUString
& rPageId
, TranslateId pTextId
, CreateTabPage pCreateFunc
);
94 virtual void PageCreated(const OUString
& rId
, SfxTabPage
& _rPage
) override
;
95 virtual short Ok() override
;
97 /// select a datasource with a given name, adjust the item set accordingly, and everything like that ..
98 void impl_selectDataSource(const css::uno::Any
& _aDataSourceName
);
99 /// reset the tag pages according to m_sCurrentDatasource and <arg>_rxDatasource</arg>
100 void impl_resetPages(const css::uno::Reference
< css::beans::XPropertySet
>& _rxDatasource
);
104 AR_LEAVE_MODIFIED
, // something was modified and has successfully been committed
105 AR_KEEP
// don't leave the page (e.g. because an error occurred)
107 /** apply all changes made
109 ApplyResult
implApplyChanges();
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */