LibreOffice Module dbaccess (master) 1
generalpage.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include "adminpages.hxx"
23#include <opendoccontrols.hxx>
24
25namespace dbaui
26{
27 class ODbTypeWizDialogSetup;
28
29 // OGeneralPage
31 {
32 protected:
33 OGeneralPage(weld::Container* pPage, weld::DialogController* pController, const OUString& _rUIXMLDescription, const SfxItemSet& _rItems);
34
36
37 private:
38 std::unique_ptr<weld::Label> m_xSpecialMessage;
39
41 {
44 };
46
49 bool approveDatasourceType( std::u16string_view _sURLPrefix, OUString& _inout_rDisplayName );
50 void insertDatasourceTypeEntryData( const OUString& _sType, const OUString& sDisplayName );
51
52 protected:
53 std::unique_ptr<weld::ComboBox> m_xDatasourceType;
54
57
58 std::vector< OUString>
60
61 public:
62 virtual ~OGeneralPage() override;
63
65 void SetTypeSelectHandler( const Link<OGeneralPage&,void>& _rHandler ) { m_aTypeSelectHandler = _rHandler; }
66
68 const OUString& GetSelectedType() const { return m_eCurrentSelection; }
69
70 protected:
71 // SfxTabPage overridables
72 virtual void Reset( const SfxItemSet* _rCoreAttrs ) override;
73
74 virtual void implInitControls( const SfxItemSet& _rSet, bool _bSaveValue ) override;
75 virtual OUString getDatasourceName( const SfxItemSet& _rSet );
76 virtual bool approveDatasourceType( ::dbaccess::DATASOURCE_TYPE eType, OUString& _inout_rDisplayName );
77
78 // <method>OGenericAdministrationPage::fillControls</method>
79 virtual void fillControls(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
80 // <method>OGenericAdministrationPage::fillWindows</method>
81 virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
82
83 void onTypeSelected(const OUString& _sURLPrefix);
84
89 void initializeTypeList();
90
91 void implSetCurrentType( const OUString& _eType );
92
93 void switchMessage(std::u16string_view _sURLPrefix);
94
96 virtual void setParentTitle( const OUString& _sURLPrefix );
97
98 DECL_LINK(OnDatasourceTypeSelected, weld::ComboBox&, void);
99 };
100
101 // OGeneralPageDialog
103 {
104 public:
105 OGeneralPageDialog(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rItems);
106
107 protected:
108 virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) override;
109
110 virtual void implInitControls( const SfxItemSet& _rSet, bool _bSaveValue ) override;
111 virtual void setParentTitle( const OUString& _sURLPrefix ) override;
112 };
113
114 // OGeneralPageWizard
115 class OGeneralPageWizard final : public OGeneralPage
116 {
117 public:
118 OGeneralPageWizard( weld::Container* pPage, ODbTypeWizDialogSetup* pController, const SfxItemSet& _rItems );
119 virtual ~OGeneralPageWizard() override;
120
122 {
126 };
127
128 private:
129 // dialog controls
130 std::unique_ptr<weld::RadioButton> m_xRB_CreateDatabase;
131 std::unique_ptr<weld::RadioButton> m_xRB_OpenExistingDatabase;
132 std::unique_ptr<weld::RadioButton> m_xRB_ConnectDatabase;
133
134 std::unique_ptr<weld::Label> m_xFT_EmbeddedDBLabel;
135 std::unique_ptr<weld::ComboBox> m_xEmbeddedDBType;
136
137 std::unique_ptr<weld::Label> m_xFT_DocListLabel;
138 std::unique_ptr<OpenDocumentListBox> m_xLB_DocumentList;
139 std::unique_ptr<OpenDocumentButton> m_xPB_OpenDatabase;
140
141 std::unique_ptr<weld::Label> m_xFT_NoEmbeddedDBLabel;
142
143 // state
146
150
153 void insertEmbeddedDBTypeEntryData( const OUString& _sType, const OUString& sDisplayName );
154
155 void EnableControls();
156
157 public:
160
163 OUString GetSelectedDocumentURL() const;
164
165 private:
166 virtual bool FillItemSet( SfxItemSet* _rCoreAttrs ) override;
167
168 virtual void implInitControls( const SfxItemSet& _rSet, bool _bSaveValue ) override;
169 virtual OUString getDatasourceName( const SfxItemSet& _rSet ) override;
170 virtual bool approveDatasourceType( ::dbaccess::DATASOURCE_TYPE eType, OUString& _inout_rDisplayName ) override;
171
172 std::vector< OUString>
174
175 OUString getEmbeddedDBName( const SfxItemSet& _rSet );
177
178 void SetupModeSelected();
179
180 DECL_LINK( OnEmbeddedDBTypeSelected, weld::ComboBox&, void );
181 DECL_LINK( OnSetupModeSelected, weld::Toggleable&, void );
182 DECL_LINK( OnDocumentSelected, weld::ComboBox&, void );
183 DECL_LINK( OnOpenDocument, weld::Button&, void );
184 };
185
186} // namespace dbaui
187
188/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue) override
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
virtual bool FillItemSet(SfxItemSet *_rCoreAttrs) override
virtual void setParentTitle(const OUString &_sURLPrefix) override
sets the title of the parent dialog
OGeneralPageDialog(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &_rItems)
virtual bool approveDatasourceType(::dbaccess::DATASOURCE_TYPE eType, OUString &_inout_rDisplayName) override
virtual bool FillItemSet(SfxItemSet *_rCoreAttrs) override
std::unique_ptr< OpenDocumentListBox > m_xLB_DocumentList
virtual ~OGeneralPageWizard() override
std::unique_ptr< weld::Label > m_xFT_DocListLabel
CreationMode GetDatabaseCreationMode() const
CreationMode m_eOriginalCreationMode
OUString GetSelectedDocumentURL() const
DECL_LINK(OnDocumentSelected, weld::ComboBox &, void)
void SetChooseDocumentHandler(const Link< OGeneralPageWizard &, void > &_rHandler)
Link< OGeneralPageWizard &, void > m_aChooseDocumentHandler
to be called when a document in the RecentDoc list is selected
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue) override
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
OUString getEmbeddedDBName(const SfxItemSet &_rSet)
bool m_bInitEmbeddedDBList
to be called when a recent document has been definitely chosen
OGeneralPageWizard(weld::Container *pPage, ODbTypeWizDialogSetup *pController, const SfxItemSet &_rItems)
std::unique_ptr< weld::RadioButton > m_xRB_OpenExistingDatabase
std::vector< OUString > m_aEmbeddedURLPrefixes
void SetDocumentSelectionHandler(const Link< OGeneralPageWizard &, void > &_rHandler)
std::unique_ptr< weld::Label > m_xFT_NoEmbeddedDBLabel
DECL_LINK(OnOpenDocument, weld::Button &, void)
void insertEmbeddedDBTypeEntryData(const OUString &_sType, const OUString &sDisplayName)
Link< OGeneralPageWizard &, void > m_aCreationModeHandler
std::unique_ptr< weld::RadioButton > m_xRB_ConnectDatabase
std::unique_ptr< weld::Label > m_xFT_EmbeddedDBLabel
virtual OUString getDatasourceName(const SfxItemSet &_rSet) override
std::unique_ptr< weld::ComboBox > m_xEmbeddedDBType
std::unique_ptr< OpenDocumentButton > m_xPB_OpenDatabase
DECL_LINK(OnSetupModeSelected, weld::Toggleable &, void)
std::unique_ptr< weld::RadioButton > m_xRB_CreateDatabase
void SetCreationModeHandler(const Link< OGeneralPageWizard &, void > &_rHandler)
DECL_LINK(OnEmbeddedDBTypeSelected, weld::ComboBox &, void)
Link< OGeneralPageWizard &, void > m_aDocumentSelectionHandler
to be called if a new type is selected
virtual void fillControls(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList) override
will be called inside <method>implInitControls</method> to save the value if necessary
::dbaccess::ODsnTypeCollection * m_pCollection
Definition: generalpage.hxx:56
void SetTypeSelectHandler(const Link< OGeneralPage &, void > &_rHandler)
set a handler which gets called every time the user selects a new type
Definition: generalpage.hxx:65
OGeneralPage(weld::Container *pPage, weld::DialogController *pController, const OUString &_rUIXMLDescription, const SfxItemSet &_rItems)
Definition: generalpage.cxx:52
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue) override
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
virtual ~OGeneralPage() override
Definition: generalpage.cxx:70
virtual void Reset(const SfxItemSet *_rCoreAttrs) override
default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
bool approveDatasourceType(std::u16string_view _sURLPrefix, OUString &_inout_rDisplayName)
std::unique_ptr< weld::Label > m_xSpecialMessage
currently selected type
Definition: generalpage.hxx:38
void insertDatasourceTypeEntryData(const OUString &_sType, const OUString &sDisplayName)
SPECIAL_MESSAGE m_eLastMessage
Definition: generalpage.hxx:45
std::unique_ptr< weld::ComboBox > m_xDatasourceType
Definition: generalpage.hxx:53
void onTypeSelected(const OUString &_sURLPrefix)
void implSetCurrentType(const OUString &_eType)
virtual void setParentTitle(const OUString &_sURLPrefix)
sets the title of the parent dialog
bool m_bInitTypeList
to be called if a new type is selected
Definition: generalpage.hxx:48
DECL_LINK(OnDatasourceTypeSelected, weld::ComboBox &, void)
virtual void fillWindows(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList) override
will be called inside <method>implInitControls</method> to disable if necessary
std::vector< OUString > m_aURLPrefixes
the DSN type collection instance
Definition: generalpage.hxx:59
void switchMessage(std::u16string_view _sURLPrefix)
Link< OGeneralPage &, void > m_aTypeSelectHandler
Definition: generalpage.hxx:47
void initializeTypeList()
Initializes the listbox, which contains entries each representing a connection to an existing databas...
Definition: generalpage.cxx:94
OUString m_eCurrentSelection
Definition: generalpage.hxx:35
const OUString & GetSelectedType() const
get the currently selected datasource type
Definition: generalpage.hxx:68
virtual OUString getDatasourceName(const SfxItemSet &_rSet)
OUString sDisplayName
Definition: generalpage.cxx:79
OUString eType
Definition: generalpage.cxx:78
DATASOURCE_TYPE
known datasource types
Definition: dsntypes.hxx:36