22#include <bitmaps.hlst>
24#include <com/sun/star/lang/XMultiServiceFactory.hpp>
25#include <com/sun/star/sdb/XCompletedConnection.hpp>
26#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
27#include <com/sun/star/sdb/XQueriesSupplier.hpp>
28#include <com/sun/star/sdbc/XConnection.hpp>
29#include <com/sun/star/sdb/SQLContext.hpp>
30#include <com/sun/star/sdbc/SQLWarning.hpp>
31#include <com/sun/star/sdb/CommandType.hpp>
32#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
41#include <osl/diagnose.h>
58 :
OControlWizardPage(pPage, pWizard,
"modules/sabpilot/ui/tableselectionpage.ui",
"TableSelectionPage")
59 , m_xTable(m_xBuilder->weld_tree_view(
"table"))
60 , m_xDatasource(m_xBuilder->weld_tree_view(
"datasource"))
61 , m_xSearchDatabase(m_xBuilder->weld_button(
"search"))
62 , m_xSourceBox(m_xBuilder->weld_container(
"sourcebox"))
72 OSL_FAIL(
"OTableSelectionPage::OTableSelectionPage: could not collect the data source names!");
99 if (0 ==
m_xTable->count_selected_rows())
112 OUString sDataSourceName;
113 rContext.
xForm->getPropertyValue(
"DataSourceName") >>= sDataSourceName;
115 Reference< XConnection > xConnection;
116 bool bEmbedded = ::dbtools::isEmbeddedInDatabase( rContext.
xForm, xConnection );
127 OSL_VERIFY( rContext.
xForm->getPropertyValue(
"Command") >>= sCommand );
128 sal_Int32 nCommandType = CommandType::TABLE;
129 OSL_VERIFY( rContext.
xForm->getPropertyValue(
"CommandType") >>= nCommandType );
132 for (sal_Int32 nLookup = 0; nLookup <
m_xTable->n_children(); ++nLookup)
134 if (sCommand ==
m_xTable->get_text(nLookup))
136 if (
m_xTable->get_id(nLookup).toInt32() == nCommandType)
158 Reference< XConnection > xOldConn;
164 rContext.
xForm->setPropertyValue(
"DataSourceName",
Any( sDataSource ) );
166 OUString sCommand =
m_xTable->get_selected_text();
167 sal_Int32 nCommandType =
m_xTable->get_selected_id().toInt32();
169 rContext.
xForm->setPropertyValue(
"Command",
Any( sCommand ) );
170 rContext.
xForm->setPropertyValue(
"CommandType",
Any( nCommandType ) );
189 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
190 FileDialogFlags::NONE, getDialog()->getDialog());
194 OSL_ENSURE(pFilter,
"Filter: StarOffice XML (Base) could not be found!");
197 aFileDlg.
AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
202 OUString sDataSourceName = aFileDlg.
GetPath();
205 m_xDatasource->append_text(sDataSourceName);
206 m_xDatasource->select_text(sDataSourceName);
213 if (_rBox.count_selected_rows())
214 getDialog()->travelNext();
220 if (m_xDatasource.get() == &_rBox)
225 updateDialogTravelUI();
230 void lcl_fillEntries(
weld::TreeView& rListBox,
const Sequence<OUString>& rNames,
const OUString& rImage, sal_Int32 nCommandType)
232 for (
auto const & name : rNames)
234 rListBox.
append(OUString::number(nCommandType), name, rImage);
246 Sequence< OUString > aTableNames;
247 Sequence< OUString > aQueryNames;
251 Reference< XConnection > xConn = _rxConn;
259 OUString sCurrentDatasource =
m_xDatasource->get_selected_text();
260 if (!sCurrentDatasource.isEmpty())
263 Reference< XCompletedConnection > xDatasource;
271 if (
m_xDSContext->getByName(sCurrentDatasource) >>= xDatasource)
277 xConn = xDatasource->connectWithCompletion(xHandler);
282 OSL_FAIL(
"OTableSelectionPage::implFillTables: invalid data source object returned by the context");
286 catch(
const SQLContext& e) { aSQLException <<= e; }
287 catch(
const SQLWarning& e) { aSQLException <<= e; }
288 catch(
const SQLException& e) { aSQLException <<= e; }
291 OSL_FAIL(
"OTableSelectionPage::implFillTables: could not fill the table list!");
301 Reference< XTablesSupplier > xSupplTables(xConn, UNO_QUERY);
302 if ( xSupplTables.is() )
304 Reference< XNameAccess > xTables = xSupplTables->getTables();
306 aTableNames = xTables->getElementNames();
310 Reference< XQueriesSupplier > xSuppQueries( xConn, UNO_QUERY );
311 if ( xSuppQueries.is() )
313 Reference< XNameAccess > xQueries = xSuppQueries->getQueries();
315 aQueryNames = xQueries->getElementNames();
318 catch(
const SQLContext& e) { aSQLException <<= e; }
319 catch(
const SQLWarning& e) { aSQLException <<= e; }
320 catch(
const SQLException& e) { aSQLException <<= e; }
323 OSL_FAIL(
"OTableSelectionPage::implFillTables: could not fill the table list!");
328 if ( aSQLException.hasValue() )
330 Reference< XInteractionRequest > xRequest =
new OInteractionRequest(aSQLException);
336 xHandler->handle(xRequest);
342 lcl_fillEntries(*
m_xTable, aTableNames, BMP_TABLE, CommandType::TABLE);
343 lcl_fillEntries(*
m_xTable, aQueryNames, BMP_QUERY, CommandType::QUERY);
371 if (!rButton.get_active())
378 DBG_ASSERT(
m_pYes,
"OMaybeListSelectionPage::implInitialize: no controls announced!");
379 bool bIsSelection = ! _rSelection.isEmpty();
401 DBG_ASSERT(
m_pYes,
"OMaybeListSelectionPage::Activate: no controls announced!");
410 , m_xDescription(m_xBuilder->weld_label(
"explLabel"))
411 , m_xStoreYes(m_xBuilder->weld_radio_button(
"yesRadiobutton"))
412 , m_xStoreNo(m_xBuilder->weld_radio_button(
"noRadiobutton"))
413 , m_xStoreWhere(m_xBuilder->weld_combo_box(
"storeInFieldCombobox"))
const char *const aFieldNames[]
void SetPageTitle(const OUString &rPageTitle)
static std::shared_ptr< const SfxFilter > GetFilterByName(const OUString &rName)
OControlWizard * getDialog()
css::uno::Reference< css::sdbc::XConnection > getFormConnection() const
virtual void initializePage() override
const OControlWizardContext & getContext() const
void setFormConnection(const css::uno::Reference< css::sdbc::XConnection > &_rxConn, bool _bAutoDispose=true)
static void fillListBox(weld::TreeView &_rList, const css::uno::Sequence< OUString > &_rItems)
css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler(weld::Window *_pWindow) const
returns the com.sun.star.task.InteractionHandler
virtual ~ODBFieldPage() override
virtual bool commitPage(::vcl::WizardTypes::CommitPageReason _eReason) override
std::unique_ptr< weld::RadioButton > m_xStoreYes
std::unique_ptr< weld::ComboBox > m_xStoreWhere
ODBFieldPage(weld::Container *pPage, OControlWizard *pWizard)
virtual void initializePage() override
std::unique_ptr< weld::RadioButton > m_xStoreNo
virtual OUString & getDBFieldSetting()=0
void implCommit(OUString &_rSelection)
virtual ~OMaybeListSelectionPage() override
void announceControls(weld::RadioButton &_rYesButton, weld::RadioButton &_rNoButton, weld::ComboBox &_rSelection)
OMaybeListSelectionPage(weld::Container *pPage, OControlWizard *pWizard, const OUString &rUIXMLDescription, const OUString &rID)
void implInitialize(const OUString &_rSelection)
weld::RadioButton * m_pYes
weld::RadioButton * m_pNo
virtual bool commitPage(::vcl::WizardTypes::CommitPageReason _eReason) override
std::unique_ptr< weld::Container > m_xSourceBox
std::unique_ptr< weld::TreeView > m_xTable
virtual ~OTableSelectionPage() override
virtual bool canAdvance() const override
OTableSelectionPage(weld::Container *pPage, OControlWizard *pParent)
css::uno::Reference< css::sdb::XDatabaseContext > m_xDSContext
std::unique_ptr< weld::Button > m_xSearchDatabase
virtual void initializePage() override
void implFillTables(const css::uno::Reference< css::sdbc::XConnection > &_rxConn=css::uno::Reference< css::sdbc::XConnection >())
std::unique_ptr< weld::TreeView > m_xDatasource
void AddFilter(const OUString &rFilterName, const OUString &rExtension)
void SetDisplayDirectory(const OUString &rPath)
OUString get(NOTATION _eOutputNotation) const
virtual bool canAdvance() const override
virtual bool commitPage(WizardTypes::CommitPageReason _eReason) override
virtual void Activate() override
virtual OUString get_active_text() const=0
void set_active_text(const OUString &rStr)
virtual void connect_toggled(const Link< Toggleable &, void > &rLink)
virtual bool get_active() const=0
virtual void set_active(bool active)=0
void append(TreeIter *pRet=nullptr)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define LINK(Instance, Class, Member)
OUString ModuleRes(TranslateId pId)
IMPL_LINK_NOARG(OTableSelectionPage, OnSearchClicked, weld::Button &, void)
IMPL_LINK(OTableSelectionPage, OnListboxDoubleClicked, weld::TreeView &, _rBox, bool)
css::uno::Reference< css::sdb::XDatabaseContext > xDatasourceContext
css::uno::Reference< css::beans::XPropertySet > xForm