officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu | 5 sc/inc/sc.hrc | 3 sc/sdi/cellsh.sdi | 1 sc/sdi/scalc.sdi | 19 ++ sc/source/ui/inc/dataproviderdlg.hxx | 6 sc/source/ui/miscdlgs/dataproviderdlg.cxx | 33 +++- sc/source/ui/view/cellsh2.cxx | 19 ++ sc/uiconfig/scalc/menubar/menubar.xml | 1 sc/uiconfig/scalc/ui/dataprovider.ui | 77 +++++++++- 9 files changed, 150 insertions(+), 14 deletions(-)
New commits: commit 5b60aeb5cb6306f84f6ec44adbe1033e89a2962c Author: Markus Mohrhard <[email protected]> Date: Sat Aug 19 23:24:51 2017 +0200 external data: improve the external data dialog Change-Id: I417bc57e2b4be56c4e3f51aa47b447ad48f5684d Reviewed-on: https://gerrit.libreoffice.org/41340 Tested-by: Jenkins <[email protected]> Reviewed-by: Markus Mohrhard <[email protected]> diff --git a/sc/source/ui/inc/dataproviderdlg.hxx b/sc/source/ui/inc/dataproviderdlg.hxx index 1281adb0581f..ec519b4e9e35 100644 --- a/sc/source/ui/inc/dataproviderdlg.hxx +++ b/sc/source/ui/inc/dataproviderdlg.hxx @@ -15,6 +15,7 @@ #include <rtl/ref.hxx> #include <vcl/dialog.hxx> #include <vcl/layout.hxx> +#include <vcl/lstbox.hxx> #include "address.hxx" #include "datamapper.hxx" @@ -34,12 +35,15 @@ class DataProviderDlg : public ModalDialog VclPtr<SvtURLBox> m_pCbUrl; VclPtr<PushButton> m_pBtnBrowse; VclPtr<OKButton> m_pBtnOk; - VclPtr<ComboBox> m_pCBData; + VclPtr<ListBox> m_pCBData; + VclPtr<ListBox> m_pCBProvider; + VclPtr<Edit> m_pEdID; DECL_LINK(UpdateClickHdl, Button*, void); DECL_LINK(UpdateComboBoxHdl, ComboBox&, void); DECL_LINK(BrowseHdl, Button*, void); DECL_LINK(EditHdl, Edit&, void); + DECL_LINK(SelectHdl, ListBox&, void); void UpdateEnable(); diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx index c583df378300..7d1bd6150dd3 100644 --- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx +++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx @@ -27,10 +27,13 @@ DataProviderDlg::DataProviderDlg(ScDocShell *pDocShell, vcl::Window* pParent) get(m_pBtnBrowse, "browse"); get(m_pBtnOk, "ok"); get(m_pCBData, "combobox_db"); + get(m_pCBProvider, "combobox_provider"); + get(m_pEdID, "edit_id"); m_pCbUrl->SetSelectHdl( LINK( this, DataProviderDlg, UpdateComboBoxHdl ) ); m_pCbUrl->SetModifyHdl(LINK(this, DataProviderDlg, EditHdl)); m_pBtnBrowse->SetClickHdl( LINK( this, DataProviderDlg, BrowseHdl ) ); + m_pCBData->SetSelectHdl(LINK(this, DataProviderDlg, SelectHdl)); Init(); m_pCBData->Resize(); UpdateEnable(); @@ -47,6 +50,8 @@ void DataProviderDlg::dispose() m_pBtnBrowse.clear(); m_pBtnOk.clear(); m_pCBData.clear(); + m_pCBProvider.clear(); + m_pEdID.clear(); ModalDialog::dispose(); } @@ -75,10 +80,17 @@ IMPL_LINK_NOARG(DataProviderDlg, EditHdl, Edit&, void) UpdateEnable(); } +IMPL_LINK_NOARG(DataProviderDlg, SelectHdl, ListBox&, void) +{ + UpdateEnable(); +} + void DataProviderDlg::UpdateEnable() { - bool bOk = !m_pCbUrl->GetURL().isEmpty(); - m_pBtnOk->Enable(bOk); + bool bEmptyEntry = m_pCbUrl->GetURL().isEmpty() || + m_pCBData->GetSelectEntry().isEmpty() || + m_pCBProvider->GetSelectEntry().isEmpty(); + m_pBtnOk->Enable(!bEmptyEntry); setOptimalLayoutSize(); } @@ -91,6 +103,12 @@ void DataProviderDlg::Init() OUString aName = itr->GetName(); m_pCBData->InsertEntry(aName); } + + std::vector<OUString> aDataProviders = sc::DataProviderFactory::getDataProviders(); + for (auto& itr : aDataProviders) + { + m_pCBProvider->InsertEntry(itr); + } } void DataProviderDlg::StartImport() @@ -99,16 +117,23 @@ void DataProviderDlg::StartImport() if (aURL.isEmpty()) return; - OUString maDBDataName = m_pCBData->GetText(); + OUString maDBDataName = m_pCBData->GetSelectEntry(); if (maDBDataName.isEmpty()) return; + OUString aProvider = m_pCBProvider->GetSelectEntry(); + if (aProvider.isEmpty()) + return; + ScDocument& rDoc = mpDocShell->GetDocument(); ScDBData* pDBData = rDoc.GetDBCollection()->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(maDBDataName)); if (!pDBData) return; - ExternalDataSource aDataSource(aURL, "org.libreoffice.calc.csv", &mpDocShell->GetDocument()); + OUString aID = m_pEdID->GetText(); + + ExternalDataSource aDataSource(aURL, aProvider, &mpDocShell->GetDocument()); + aDataSource.setID(aID); aDataSource.setDBData(pDBData); mpDocShell->GetDocument().GetExternalDataMapper().insertDataSource(aDataSource); } diff --git a/sc/uiconfig/scalc/ui/dataprovider.ui b/sc/uiconfig/scalc/ui/dataprovider.ui index a2a674ead78c..c6deab0572bb 100644 --- a/sc/uiconfig/scalc/ui/dataprovider.ui +++ b/sc/uiconfig/scalc/ui/dataprovider.ui @@ -174,15 +174,9 @@ <object class="GtkComboBox" id="combobox_db"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="has_entry">True</property> - <child internal-child="entry"> - <object class="GtkEntry"> - <property name="can_focus">False</property> - </object> - </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="position">1</property> </packing> @@ -194,6 +188,75 @@ <property name="position">1</property> </packing> </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Data Provider:</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="combobox_provider"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="popup_fixed_width">False</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Search String:</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="edit_id"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> </object> </child> </object> commit 447ecc3cfbae6a3db60d5c04360c4fa1f65eb679 Author: Markus Mohrhard <[email protected]> Date: Sat Aug 19 23:22:57 2017 +0200 external data: add a menu entry to refresh the data Change-Id: I1942488d518be91c3ad03f91d98834e22bfdfb16 Reviewed-on: https://gerrit.libreoffice.org/41339 Tested-by: Jenkins <[email protected]> Reviewed-by: Markus Mohrhard <[email protected]> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index f44986cd64e4..adf23030cec8 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -1590,6 +1590,11 @@ <value xml:lang="en-US">Data Provider...</value> </prop> </node> + <node oor:name=".uno:DataProviderRefresh" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Refresh Data Provider</value> + </prop> + </node> <node oor:name=".uno:ManageXMLSource" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~XML Source...</value> diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index eda54c590d7e..aca25080d5d6 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -85,7 +85,8 @@ #define SID_SCDEFAULTSOPTIONS (SC_VIEW_START + 21) -#define SID_DATA_PROVIDER (SC_VIEW_START + 32) +#define SID_DATA_PROVIDER (SC_VIEW_START + 31) +#define SID_DATA_PROVIDER_REFRESH (SC_VIEW_START + 32) #define SID_DATA_STREAMS_PLAY (SC_VIEW_START + 33) #define SID_DATA_STREAMS_STOP (SC_VIEW_START + 34) #define SID_DATA_STREAMS (SC_VIEW_START + 35) diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index 8db89f78171a..90b62dae89df 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -49,6 +49,7 @@ interface CellSelection SID_DATA_STREAMS_PLAY [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ] SID_DATA_STREAMS_STOP [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ] SID_DATA_PROVIDER [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ] + SID_DATA_PROVIDER_REFRESH [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ] SID_MANAGE_XML_SOURCE [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ] SID_SORT [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ] SID_DATA_FORM [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ] diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index b828206cf121..ffb9f3c59e2b 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -4472,7 +4472,24 @@ SfxVoidItem DataProvider SID_DATA_PROVIDER [ AutoUpdate = FALSE, FastCall = FALSE, - ReadOnlyDoc = TRUE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Data; +] + +SfxVoidItem DataProviderRefresh SID_DATA_PROVIDER_REFRESH +() +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, Toggle = FALSE, Container = FALSE, RecordAbsolute = FALSE, diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 4908f4179136..b03cad6f1fac 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -55,6 +55,7 @@ #include "validat.hxx" #include "validate.hxx" #include "scresid.hxx" +#include "datamapper.hxx" #include "scui_def.hxx" #include "scabstdlg.hxx" @@ -788,6 +789,16 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) } } break; + case SID_DATA_PROVIDER_REFRESH: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + auto& rDataMapper = pDoc->GetExternalDataMapper(); + for (auto& rDataSource : rDataMapper.getDataSources()) + { + rDataSource.refresh(pDoc, false); + } + } + break; case SID_MANAGE_XML_SOURCE: ExecuteXMLSourceDialog(); break; @@ -1196,6 +1207,14 @@ void ScCellShell::GetDBState( SfxItemSet& rSet ) break; case SID_DATA_PROVIDER: break; + case SID_DATA_PROVIDER_REFRESH: + { + ScDocument* pDoc = GetViewData()->GetDocument(); + auto& rDataMapper = pDoc->GetExternalDataMapper(); + if (rDataMapper.getDataSources().empty()) + rSet.DisableItem(nWhich); + } + break; case SID_DATA_STREAMS: case SID_DATA_STREAMS_PLAY: case SID_DATA_STREAMS_STOP: diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index e40766848f09..fd9d62298b52 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -631,6 +631,7 @@ <menu:menuitem menu:id=".uno:DataStreams"/> <menu:menuitem menu:id=".uno:ManageXMLSource"/> <menu:menuitem menu:id=".uno:DataProvider"/> + <menu:menuitem menu:id=".uno:DataProviderRefresh"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:TableOperationDialog"/> <menu:menuitem menu:id=".uno:TextToColumns"/> _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
