25#include <osl/diagnose.h>
26#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
27#include <com/sun/star/sdb/XQueriesSupplier.hpp>
28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/beans/PropertyValue.hpp>
30#include <com/sun/star/container/XChild.hpp>
31#include <com/sun/star/sdbc/XDataSource.hpp>
45 uno::Reference<sdbc::XConnection> xConnection)
46 :
SfxDialogController(pParent,
"modules/swriter/ui/selecttabledialog.ui",
"SelectTableDialog")
48 , m_xTable(m_xBuilder->weld_tree_view(
"table"))
49 , m_xPreviewPB(m_xBuilder->weld_button(
"preview"))
54 std::vector<int> aWidths{ o3tl::narrowing<int>(
m_xTable->get_approximate_digit_width() * 30) };
55 m_xTable->set_column_fixed_widths(aWidths);
59 Reference<XTablesSupplier> xTSupplier(
m_xConnection, UNO_QUERY);
62 Reference<XNameAccess> xTables = xTSupplier->getTables();
63 Sequence<OUString> aTables = xTables->getElementNames();
64 const OUString* pTables = aTables.getConstArray();
65 for (
int i = 0;
i < aTables.getLength();
i++)
67 OUString sEntry = pTables[
i];
72 Reference<XQueriesSupplier> xQSupplier(
m_xConnection, UNO_QUERY);
76 Reference<XNameAccess> xQueries = xQSupplier->getQueries();
77 const Sequence<OUString> aQueries = xQueries->getElementNames();
79 for (
const OUString& rQuery : aQueries)
92 int nEntry = m_xTable->get_selected_index();
96 OUString sTableOrQuery = m_xTable->get_text(nEntry, 0);
97 sal_Int32 nCommandType = m_xTable->get_id(nEntry).isEmpty() ? 0 : 1;
99 OUString sDataSourceName;
103 Reference<XDataSource> xSource(xChild->getParent(), UNO_QUERY);
104 Reference<XPropertySet> xPrSet(xSource, UNO_QUERY);
105 xPrSet->getPropertyValue(
"Name") >>= sDataSourceName;
107 OSL_ENSURE(!sDataSourceName.isEmpty(),
"no data source found");
122 int nEntry =
m_xTable->get_selected_index();
125 bIsTable =
m_xTable->get_id(nEntry).isEmpty();
126 return m_xTable->get_text(nEntry, 0);
PropertiesInfo aProperties
Reference< XExecutableDialog > m_xDialog
void SetSelectedTable(std::u16string_view rTable, bool bIsTable)
SwSelectDBTableDialog(weld::Window *pParent, css::uno::Reference< css::sdbc::XConnection > xConnection)
OUString GetSelectedTable(bool &bIsTable)
virtual ~SwSelectDBTableDialog() override
std::unique_ptr< weld::Button > m_xPreviewPB
std::unique_ptr< weld::TreeView > m_xTable
css::uno::Reference< css::sdbc::XConnection > m_xConnection
#define LINK(Instance, Class, Member)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Reference< XConnection > m_xConnection
IMPL_LINK_NOARG(SwSelectDBTableDialog, PreviewHdl, weld::Button &, void)
OUString SwResId(TranslateId aId)