Kaydet (Commit) 213a83ce authored tarafından Jaskaran Singh's avatar Jaskaran Singh Kaydeden (comit) Markus Mohrhard

Add UI for the sc::dataprovider

Change-Id: I29acc8903d5694e46e7575133ee852bbaae6eeee
Reviewed-on: https://gerrit.libreoffice.org/40851Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 772686ad
......@@ -1585,6 +1585,11 @@
<value>1</value>
</prop>
</node>
<node oor:name=".uno:DataProvider" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">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>
......
......@@ -464,6 +464,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/miscdlgs/conflictsdlg \
sc/source/ui/miscdlgs/crnrdlg \
sc/source/ui/miscdlgs/datastreamdlg \
sc/source/ui/miscdlgs/dataproviderdlg \
sc/source/ui/miscdlgs/highred \
sc/source/ui/miscdlgs/mergecellsdialog \
sc/source/ui/miscdlgs/optsolver \
......
......@@ -110,6 +110,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/datafieldoptionsdialog \
sc/uiconfig/scalc/ui/dataform \
sc/uiconfig/scalc/ui/datastreams \
sc/uiconfig/scalc/ui/dataprovider \
sc/uiconfig/scalc/ui/definedatabaserangedialog \
sc/uiconfig/scalc/ui/definename \
sc/uiconfig/scalc/ui/deletecells \
......
......@@ -11,6 +11,9 @@
#define INCLUDED_SC_INC_EXTERNALDATAMAPPER_HXX
#include <memory>
#include <vector>
#include "scdllapi.h"
#include <rtl/ustring.hxx>
......@@ -23,7 +26,7 @@ class ScDBDataManager;
class DataProvider;
class ScDBDataManager;
class ExternalDataSource
class SC_DLLPUBLIC ExternalDataSource
{
private:
......@@ -69,6 +72,8 @@ public:
ExternalDataSource(const OUString& rURL,
const OUString& rProvider);
~ExternalDataSource();
void setUpdateFrequency(double nUpdateFrequency);
void setID(const OUString& rID);
......
......@@ -84,6 +84,8 @@
#define SID_SCFORMULAOPTIONS (SC_VIEW_START + 20)
#define SID_SCDEFAULTSOPTIONS (SC_VIEW_START + 21)
#define SID_DATA_PROVIDER (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)
......
......@@ -48,6 +48,7 @@ interface CellSelection
SID_DATA_STREAMS [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
SID_DATA_STREAMS_PLAY [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
SID_DATA_STREAMS_STOP [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
SID_DATA_PROVIDER [ 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; ]
......
......@@ -4467,6 +4467,23 @@ SfxVoidItem DataStreamsStop SID_DATA_STREAMS_STOP
GroupId = SfxGroupId::Data;
]
SfxVoidItem DataProvider SID_DATA_PROVIDER
()
[
AutoUpdate = FALSE,
FastCall = FALSE,
ReadOnlyDoc = TRUE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
AccelConfig = TRUE,
MenuConfig = TRUE,
ToolBoxConfig = FALSE,
GroupId = SfxGroupId::Data;
]
SfxVoidItem ManageXMLSource SID_MANAGE_XML_SOURCE
(SfxStringItem DbName SID_MANAGE_XML_SOURCE)
[
......
......@@ -65,6 +65,10 @@ ExternalDataSource::ExternalDataSource(const OUString& rURL,
{
}
ExternalDataSource::~ExternalDataSource()
{
}
void ExternalDataSource::setID(const OUString& rID)
{
maID = rID;
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SC_SOURCE_UI_INC_DATAPROVIDERDLG_HXX
#define INCLUDED_SC_SOURCE_UI_INC_DATAPROVIDERDLG_HXX
#include <sal/config.h>
#include <rtl/ref.hxx>
#include <vcl/dialog.hxx>
#include <vcl/layout.hxx>
#include "address.hxx"
#include "datamapper.hxx"
#include "dataprovider.hxx"
class ScDocShell;
class SvtURLBox;
class ScRange;
class ComboBox;
namespace sc {
class DataProviderDlg : public ModalDialog
{
ScDocShell *mpDocShell;
VclPtr<SvtURLBox> m_pCbUrl;
VclPtr<PushButton> m_pBtnBrowse;
VclPtr<RadioButton> m_pRBAddressValue;
VclPtr<CheckBox> m_pCBRefreshOnEmpty;
VclPtr<RadioButton> m_pRBMaxLimit;
VclPtr<RadioButton> m_pRBUnlimited;
VclPtr<Edit> m_pEdRange;
VclPtr<Edit> m_pEdLimit;
VclPtr<OKButton> m_pBtnOk;
VclPtr<VclFrame> m_pVclFrameLimit;
DECL_LINK(UpdateClickHdl, Button*, void);
DECL_LINK(UpdateHdl, Edit&, void);
DECL_LINK(UpdateComboBoxHdl, ComboBox&, void);
DECL_LINK(BrowseHdl, Button*, void);
void UpdateEnable();
ScRange GetStartRange();
std::shared_ptr<ExternalDataSource> mpDataSource;
public:
DataProviderDlg(ScDocShell *pDocShell, vcl::Window* pParent);
virtual ~DataProviderDlg() override;
virtual void dispose() override;
void Init();
void StartImport();
};
}
#endif // INCLUDED_SC_SOURCE_UI_INC_DATAPROVIDERDLG_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <dataproviderdlg.hxx>
#include <sfx2/filedlghelper.hxx>
#include <svtools/inettbc.hxx>
#include <vcl/layout.hxx>
#include <address.hxx>
#include <docsh.hxx>
#include <dbdata.hxx>
#include "datamapper.hxx"
namespace sc {
DataProviderDlg::DataProviderDlg(ScDocShell *pDocShell, vcl::Window* pParent)
: ModalDialog(pParent, "DataProviderDialog", "modules/scalc/ui/dataprovider.ui")
, mpDocShell(pDocShell)
{
get(m_pCbUrl, "url");
get(m_pBtnBrowse, "browse");
get(m_pRBAddressValue, "addressvalue");
get(m_pCBRefreshOnEmpty, "refresh_ui");
//get(m_pRBRangeDown, "rangedown");
//get(m_pRBNoMove, "nomove");
get(m_pRBMaxLimit, "maxlimit");
get(m_pRBUnlimited, "unlimited");
get(m_pEdRange, "range");
get(m_pEdLimit, "limit");
get(m_pBtnOk, "ok");
get(m_pVclFrameLimit, "framelimit");
//get(m_pVclFrameMove, "framemove");
m_pCbUrl->SetSelectHdl( LINK( this, DataProviderDlg, UpdateComboBoxHdl ) );
m_pRBAddressValue->SetClickHdl( LINK( this, DataProviderDlg, UpdateClickHdl ) );
m_pRBAddressValue->Enable(false);
//m_pRBScriptData->Enable(false);
//m_pRBDirectData->Hide();
//m_pRBScriptData->Hide();
//m_pRBNoMove->Hide();
//m_pRBValuesInLine->SetClickHdl( LINK( this, DataProviderDlg, UpdateClickHdl ) );
m_pEdRange->SetModifyHdl( LINK( this, DataProviderDlg, UpdateHdl ) );
m_pBtnBrowse->SetClickHdl( LINK( this, DataProviderDlg, BrowseHdl ) );
UpdateEnable();
}
DataProviderDlg::~DataProviderDlg()
{
disposeOnce();
}
void DataProviderDlg::dispose()
{
m_pCbUrl.clear();
m_pBtnBrowse.clear();
//m_pRBDirectData.clear();
//m_pRBScriptData.clear();
//m_pRBValuesInLine.clear();
m_pRBAddressValue.clear();
m_pCBRefreshOnEmpty.clear();
//m_pRBDataDown.clear();
//m_pRBRangeDown.clear();
//m_pRBNoMove.clear();
m_pRBMaxLimit.clear();
m_pRBUnlimited.clear();
m_pEdRange.clear();
m_pEdLimit.clear();
m_pBtnOk.clear();
m_pVclFrameLimit.clear();
//m_pVclFrameMove.clear();
ModalDialog::dispose();
}
IMPL_LINK_NOARG(DataProviderDlg, BrowseHdl, Button*, void)
{
sfx2::FileDialogHelper aFileDialog(0);
if ( aFileDialog.Execute() != ERRCODE_NONE )
return;
m_pCbUrl->SetText( aFileDialog.GetPath() );
UpdateEnable();
}
IMPL_LINK_NOARG(DataProviderDlg, UpdateClickHdl, Button*, void)
{
UpdateEnable();
}
IMPL_LINK_NOARG(DataProviderDlg, UpdateComboBoxHdl, ComboBox&, void)
{
UpdateEnable();
}
IMPL_LINK_NOARG(DataProviderDlg, UpdateHdl, Edit&, void)
{
UpdateEnable();
}
void DataProviderDlg::UpdateEnable()
{
bool bOk = !m_pCbUrl->GetURL().isEmpty();
if (m_pRBAddressValue->IsChecked())
{
m_pVclFrameLimit->Disable();
//m_pVclFrameMove->Disable();
m_pEdRange->Disable();
}
else
{
m_pVclFrameLimit->Enable();
//m_pVclFrameMove->Enable();
m_pEdRange->Enable();
if (bOk)
{
// Check the given range to make sure it's valid.
ScRange aTest = GetStartRange();
if (!aTest.IsValid())
bOk = false;
}
}
m_pBtnOk->Enable(bOk);
setOptimalLayoutSize();
}
ScRange DataProviderDlg::GetStartRange()
{
OUString aStr = m_pEdRange->GetText();
ScDocument& rDoc = mpDocShell->GetDocument();
ScRange aRange;
ScRefFlags nRes = aRange.Parse(aStr, &rDoc, rDoc.GetAddressConvention());
if ( ((nRes & ScRefFlags::VALID) == ScRefFlags::ZERO) || !aRange.IsValid())
{
// Invalid range.
aRange.SetInvalid();
return aRange;
}
// Make sure it's only one row tall.
if (aRange.aStart.Row() != aRange.aEnd.Row())
aRange.SetInvalid();
return aRange;
}
void DataProviderDlg::Init()
{
// TODO : Get the user specified Url and Range
(void)this;
}
void DataProviderDlg::StartImport()
{
ScRange aRange = GetStartRange();
if (!aRange.IsValid())
// Don't start the stream without a valid range.
return;
OUString aURL;
// TODO : replace those strings with something that is obtained from user
ExternalDataSource aDataSource(aURL, "org.libreoffice.calc.csv");
//aDataSource.setDBData(pDBData);
mpDocShell->GetDocument().GetExternalDataMapper().insertDataSource(aDataSource);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -62,6 +62,7 @@
#include "asciiopt.hxx"
#include "datastream.hxx"
#include "datastreamdlg.hxx"
#include "dataproviderdlg.hxx"
#include "queryentry.hxx"
#include "markdata.hxx"
#include <documentlinkmgr.hxx>
......@@ -778,6 +779,20 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
pStrm->StopImport();
}
break;
case SID_DATA_PROVIDER:
{
ScopedVclPtrInstance< sc::DataProviderDlg > aDialog( GetViewData()->GetDocShell(), pTabViewShell->GetDialogParent() );
//ScDocument *pDoc = GetViewData()->GetDocument();
//sc::DocumentLinkManager& rMgr = pDoc->GetDocLinkManager();
//sc::DataStream* pStrm = rMgr.getDataStream();
//if (pStrm)
aDialog->Init(/**pStrm*/);
aDialog->Execute();
//if (aDialog->Execute() == RET_OK)
//aDialog->StartStream();
}
break;
case SID_MANAGE_XML_SOURCE:
ExecuteXMLSourceDialog();
break;
......@@ -1184,6 +1199,8 @@ void ScCellShell::GetDBState( SfxItemSet& rSet )
}
}
break;
case SID_DATA_PROVIDER:
break;
case SID_DATA_STREAMS:
case SID_DATA_STREAMS_PLAY:
case SID_DATA_STREAMS_STOP:
......
......@@ -630,6 +630,7 @@
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:DataStreams"/>
<menu:menuitem menu:id=".uno:ManageXMLSource"/>
<menu:menuitem menu:id=".uno:DataProvider"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:TableOperationDialog"/>
<menu:menuitem menu:id=".uno:TextToColumns"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
<toolbar:toolbaritem xlink:href=".uno:DataProviderPlay"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:DataProviderStop"/>
</toolbar:toolbar>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment