[Libreoffice-commits] core.git: 4 commits - sc/source sc/uiconfig

Markus Mohrhard markus.mohrhard at googlemail.com
Thu Aug 10 16:55:11 UTC 2017


 sc/source/ui/docshell/dataprovider.cxx    |   79 +---------
 sc/source/ui/inc/dataprovider.hxx         |   10 -
 sc/source/ui/inc/dataproviderdlg.hxx      |   10 -
 sc/source/ui/miscdlgs/dataproviderdlg.cxx |  101 ++-----------
 sc/source/ui/view/cellsh2.cxx             |   12 -
 sc/uiconfig/scalc/ui/dataprovider.ui      |  225 ++----------------------------
 6 files changed, 54 insertions(+), 383 deletions(-)

New commits:
commit f50ae88277d7fd652679e1ed763855ccd223f756
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Aug 10 08:23:53 2017 +0200

    external data: some work on the dialog
    
    Change-Id: I4962688db1ccd766a7ff0e379033b5dc19a7462b
    Reviewed-on: https://gerrit.libreoffice.org/40962
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/ui/inc/dataproviderdlg.hxx b/sc/source/ui/inc/dataproviderdlg.hxx
index 05e607157931..0bba15b4e70d 100644
--- a/sc/source/ui/inc/dataproviderdlg.hxx
+++ b/sc/source/ui/inc/dataproviderdlg.hxx
@@ -33,22 +33,14 @@ class DataProviderDlg : public ModalDialog
 
     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;
+    VclPtr<ComboBox>       m_pCBData;
 
     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;
 
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index eaa830cde2c1..8c20f8fff4a6 100644
--- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx
+++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
@@ -25,27 +25,10 @@ DataProviderDlg::DataProviderDlg(ScDocShell *pDocShell, vcl::Window* pParent)
 {
     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");
+    get(m_pCBData, "combobox_db");
 
     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();
 }
@@ -59,21 +42,8 @@ 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();
+    m_pCBData.clear();
     ModalDialog::dispose();
 }
 
@@ -91,78 +61,47 @@ 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()
+void DataProviderDlg::Init()
 {
-    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())
+    ScDBCollection::NamedDBs& rNamedDBs = rDoc.GetDBCollection()->getNamedDBs();
+    for (auto& itr : rNamedDBs)
     {
-        // Invalid range.
-        aRange.SetInvalid();
-        return aRange;
+        OUString aName = itr->GetName();
+        m_pCBData->InsertEntry(aName);
     }
-
-    // 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.
+    OUString aURL = m_pCbUrl->GetText();
+    if (aURL.isEmpty())
+        return;
+
+    OUString maDBDataName = m_pCBData->GetText();
+    if (maDBDataName.isEmpty())
+        return;
+
+    ScDocument& rDoc = mpDocShell->GetDocument();
+    ScDBData* pDBData = rDoc.GetDBCollection()->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(maDBDataName));
+    if (!pDBData)
         return;
 
-    OUString aURL;
-    // TODO : replace those strings with something that is obtained from user
     ExternalDataSource aDataSource(aURL, "org.libreoffice.calc.csv", &mpDocShell->GetDocument());
-    //aDataSource.setDBData(pDBData);
+    aDataSource.setDBData(pDBData);
     mpDocShell->GetDocument().GetExternalDataMapper().insertDataSource(aDataSource);
 }
 
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 7866f7693e9f..abbb35219c0a 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -782,15 +782,11 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
         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();
+            if (aDialog->Execute() == RET_OK)
+            {
+                aDialog->StartImport();
+            }
         }
         break;
         case SID_MANAGE_XML_SOURCE:
diff --git a/sc/uiconfig/scalc/ui/dataprovider.ui b/sc/uiconfig/scalc/ui/dataprovider.ui
index d5872e514160..c3ff826a63eb 100644
--- a/sc/uiconfig/scalc/ui/dataprovider.ui
+++ b/sc/uiconfig/scalc/ui/dataprovider.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.0 -->
 <interface domain="sc">
   <requires lib="gtk+" version="3.0"/>
   <requires lib="LibreOffice" version="1.0"/>
@@ -155,98 +155,37 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkBox" id="box13">
+                          <object class="GtkBox">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="orientation">vertical</property>
-                            <property name="spacing">6</property>
                             <child>
-                              <object class="GtkFrame" id="frame4">
+                              <object class="GtkLabel" id="label_db">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="label_xalign">0</property>
-                                <property name="shadow_type">none</property>
-                                <child>
-                                  <object class="GtkAlignment" id="alignment5">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="top_padding">6</property>
-                                    <property name="left_padding">12</property>
-                                    <child>
-                                      <object class="GtkGrid" id="grid2">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="row_spacing">6</property>
-                                        <property name="column_spacing">6</property>
-                                        <child>
-                                          <object class="GtkRadioButton" id="valuesinline">
-                                            <property name="label" translatable="yes" context="datastreams|valuesinline">value1,value2,...,valueN, and fill into range:</property>
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="receives_default">False</property>
-                                            <property name="use_underline">True</property>
-                                            <property name="xalign">0</property>
-                                            <property name="active">True</property>
-                                            <property name="draw_indicator">True</property>
-                                            <property name="group">addressvalue</property>
-                                          </object>
-                                          <packing>
-                                            <property name="left_attach">0</property>
-                                            <property name="top_attach">0</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkRadioButton" id="addressvalue">
-                                            <property name="label" translatable="yes" context="datastreams|addressvalue">address,value</property>
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="receives_default">False</property>
-                                            <property name="use_underline">True</property>
-                                            <property name="xalign">0</property>
-                                            <property name="draw_indicator">True</property>
-                                            <property name="group">valuesinline</property>
-                                          </object>
-                                          <packing>
-                                            <property name="left_attach">0</property>
-                                            <property name="top_attach">1</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkEntry" id="range">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="hexpand">True</property>
-                                            <property name="invisible_char">●</property>
-                                          </object>
-                                          <packing>
-                                            <property name="left_attach">1</property>
-                                            <property name="top_attach">0</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <placeholder/>
-                                        </child>
-                                      </object>
-                                    </child>
-                                  </object>
-                                </child>
-                                <child type="label">
-                                  <object class="GtkLabel" id="label4">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="label" translatable="yes" context="datastreams|label4">Interpret stream data as</property>
-                                  </object>
-                                </child>
+                                <property name="label" translatable="yes">Database Range:</property>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
                                 <property name="fill">True</property>
-                                <property name="padding">6</property>
                                 <property name="position">0</property>
                               </packing>
                             </child>
                             <child>
-                              <placeholder/>
+                              <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="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
                             </child>
                           </object>
                           <packing>
@@ -255,25 +194,6 @@
                             <property name="position">1</property>
                           </packing>
                         </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="refresh_ui">
-                            <property name="label" translatable="yes" context="datastreams|refresh_ui">Empty lines trigger UI refresh</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="xalign">0</property>
-                            <property name="active">True</property>
-                            <property name="draw_indicator">True</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">3</property>
-                          </packing>
-                        </child>
                       </object>
                     </child>
                   </object>
@@ -296,113 +216,6 @@
                 <property name="position">0</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkBox" id="box3">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <property name="spacing">6</property>
-                <property name="homogeneous">True</property>
-                <child>
-                  <object class="GtkFrame" id="framelimit">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label_xalign">0</property>
-                    <property name="shadow_type">none</property>
-                    <child>
-                      <object class="GtkAlignment" id="alignment3">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="top_padding">6</property>
-                        <property name="left_padding">12</property>
-                        <child>
-                          <object class="GtkGrid" id="grid3">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="vexpand">True</property>
-                            <property name="row_spacing">6</property>
-                            <property name="column_spacing">6</property>
-                            <child>
-                              <object class="GtkRadioButton" id="maxlimit">
-                                <property name="label" translatable="yes" context="datastreams|maxlimit">Limit to:</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="xalign">0</property>
-                                <property name="active">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">unlimited</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">0</property>
-                                <property name="top_attach">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkEntry" id="limit">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="hexpand">True</property>
-                                <property name="invisible_char">●</property>
-                                <property name="text">1000</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="top_attach">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkRadioButton" id="unlimited">
-                                <property name="label" translatable="yes" context="datastreams|unlimited">_Unlimited</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="valign">start</property>
-                                <property name="use_underline">True</property>
-                                <property name="xalign">0</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">maxlimit</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">0</property>
-                                <property name="top_attach">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                    <child type="label">
-                      <object class="GtkLabel" id="label3">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes" context="datastreams|label3">Maximal Amount of Rows</property>
-                        <attributes>
-                          <attribute name="weight" value="bold"/>
-                        </attributes>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
           </object>
           <packing>
             <property name="expand">False</property>
commit 8a7883f40536fa32aab85260f967f5f3f7f53431
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Aug 10 08:22:02 2017 +0200

    external data: make sure we don't use wrapping during copying
    
    Change-Id: Id369ea3be5c318704fa6907df30d11ef0764f65b
    Reviewed-on: https://gerrit.libreoffice.org/40961
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/ui/docshell/dataprovider.cxx b/sc/source/ui/docshell/dataprovider.cxx
index 87288877b22d..97dbea72fa8d 100644
--- a/sc/source/ui/docshell/dataprovider.cxx
+++ b/sc/source/ui/docshell/dataprovider.cxx
@@ -344,10 +344,17 @@ void ScDBDataManager::WriteToDoc(ScDocument& rDoc, ScDBData* pDBData)
     SCCOL nEndCol = MAXCOL;
     SCROW nEndRow = MAXROW;
     rDoc.ShrinkToUsedDataArea(bShrunk, 0, nStartCol, nStartRow, nEndCol, nEndRow, false, true, true);
-    rDoc.SetClipArea(ScRange(nStartCol, nStartRow, 0, nEndCol, nEndRow, 0));
+    ScRange aClipRange(nStartCol, nStartRow, 0, nEndCol, nEndRow, 0);
+    rDoc.SetClipArea(aClipRange);
 
     ScRange aDestRange;
     pDBData->GetArea(aDestRange);
+    SCCOL nColSize = std::min<SCCOL>(aDestRange.aEnd.Col() - aDestRange.aStart.Col(), nEndCol);
+    aDestRange.aEnd.SetCol(aDestRange.aStart.Col() + nColSize);
+
+    SCROW nRowSize = std::min<SCCOL>(aDestRange.aEnd.Row() - aDestRange.aStart.Row(), nEndRow);
+    aDestRange.aEnd.SetRow(aDestRange.aStart.Row() + nRowSize);
+
     ScMarkData aMark;
     aMark.SelectTable(0, true);
     mpDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, &rDoc);
commit 2f2d41d101e0790ea50be3df7d14224357f3f9fb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Aug 10 01:26:22 2017 +0200

    external data: use the existing copy data functionality
    
    Change-Id: Id9eb9bcfaf67a17a945b69d8bc65c7180051f90d
    Reviewed-on: https://gerrit.libreoffice.org/40960
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/ui/docshell/dataprovider.cxx b/sc/source/ui/docshell/dataprovider.cxx
index fac1e2947544..87288877b22d 100644
--- a/sc/source/ui/docshell/dataprovider.cxx
+++ b/sc/source/ui/docshell/dataprovider.cxx
@@ -336,7 +336,6 @@ void CSVDataProvider::Refresh()
     pDocShell->SetDocumentModified();
 }
 
-// TODO: why don't we use existing copy functionality
 void ScDBDataManager::WriteToDoc(ScDocument& rDoc, ScDBData* pDBData)
 {
     bool bShrunk = false;
@@ -345,28 +344,13 @@ void ScDBDataManager::WriteToDoc(ScDocument& rDoc, ScDBData* pDBData)
     SCCOL nEndCol = MAXCOL;
     SCROW nEndRow = MAXROW;
     rDoc.ShrinkToUsedDataArea(bShrunk, 0, nStartCol, nStartRow, nEndCol, nEndRow, false, true, true);
+    rDoc.SetClipArea(ScRange(nStartCol, nStartRow, 0, nEndCol, nEndRow, 0));
 
     ScRange aDestRange;
     pDBData->GetArea(aDestRange);
-    double* pfValue;
-    for (int nRow = nStartRow; nRow < nEndRow; ++nRow)
-    {
-        for (int nCol = nStartCol; nCol < nEndCol; ++nCol)
-        {
-            ScAddress aAddr = ScAddress(nCol, nRow, 0);
-            pfValue = rDoc.GetValueCell(aAddr);
-
-            if (pfValue == nullptr)
-            {
-                OUString aString = rDoc.GetString(nCol, nRow, 0);
-                mpDoc->SetString(aDestRange.aStart.Col() + nCol, aDestRange.aStart.Row() + nRow, aDestRange.aStart.Tab(), aString);
-            }
-            else
-            {
-                mpDoc->SetValue(aDestRange.aStart.Col() + nCol, aDestRange.aStart.Row() + nRow, aDestRange.aStart.Tab(), *pfValue);
-            }
-        }
-    }
+    ScMarkData aMark;
+    aMark.SelectTable(0, true);
+    mpDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, &rDoc);
     ScDocShell* pDocShell = static_cast<ScDocShell*>(mpDoc->GetDocumentShell());
     pDocShell->PostPaint(aDestRange, PaintPartFlags::All);
 }
commit 84c2297b48fb5d37dd2db4695e669e8e67801e18
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Aug 10 01:06:43 2017 +0200

    external data: remove some unnecessary concepts from the csv thread
    
    Change-Id: Ie0299307b32808f91f1043794a149eb8f8d4f948
    Reviewed-on: https://gerrit.libreoffice.org/40959
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/ui/docshell/dataprovider.cxx b/sc/source/ui/docshell/dataprovider.cxx
index 9cafe70e94f5..fac1e2947544 100644
--- a/sc/source/ui/docshell/dataprovider.cxx
+++ b/sc/source/ui/docshell/dataprovider.cxx
@@ -291,34 +291,6 @@ void CSVFetchThread::execute()
     mpIdle->Start();
 }
 
-osl::Mutex& CSVFetchThread::GetLinesMutex()
-{
-    return maMtxLines;
-}
-
-bool CSVFetchThread::HasNewLines()
-{
-    return !maPendingLines.empty();
-}
-
-void CSVFetchThread::WaitForNewLines()
-{
-    maCondConsume.wait();
-    maCondConsume.reset();
-}
-
-LinesType* CSVFetchThread::GetNewLines()
-{
-    LinesType* pLines = maPendingLines.front();
-    maPendingLines.pop();
-    return pLines;
-}
-
-void CSVFetchThread::ResumeFetchStream()
-{
-    maCondReadStream.set();
-}
-
 CSVDataProvider::CSVDataProvider(ScDocument* pDoc, const OUString& rURL, ScDBDataManager* pBDDataManager):
     maURL(rURL),
     mpDocument(pDoc),
@@ -364,28 +336,6 @@ void CSVDataProvider::Refresh()
     pDocShell->SetDocumentModified();
 }
 
-Line CSVDataProvider::GetLine()
-{
-    if (!mpLines || mnLineCount >= mpLines->size())
-    {
-        if (mxCSVFetchThread->IsRequestedTerminate())
-            return Line();
-
-        osl::ResettableMutexGuard aGuard(mxCSVFetchThread->GetLinesMutex());
-        while (!mxCSVFetchThread->HasNewLines() && !mxCSVFetchThread->IsRequestedTerminate())
-        {
-            aGuard.clear();
-            mxCSVFetchThread->WaitForNewLines();
-            aGuard.reset();
-        }
-
-        mpLines = mxCSVFetchThread->GetNewLines();
-        mxCSVFetchThread->ResumeFetchStream();
-    }
-
-    return mpLines->at(mnLineCount++);
-}
-
 // TODO: why don't we use existing copy functionality
 void ScDBDataManager::WriteToDoc(ScDocument& rDoc, ScDBData* pDBData)
 {
diff --git a/sc/source/ui/inc/dataprovider.hxx b/sc/source/ui/inc/dataprovider.hxx
index 6f203889fb37..e3d25317578d 100644
--- a/sc/source/ui/inc/dataprovider.hxx
+++ b/sc/source/ui/inc/dataprovider.hxx
@@ -78,10 +78,6 @@ class CSVFetchThread : public salhelper::Thread
     osl::Mutex maMtxTerminate;
 
     std::queue<LinesType*> maPendingLines;
-    osl::Mutex maMtxLines;
-
-    osl::Condition maCondReadStream;
-    osl::Condition maCondConsume;
 
     orcus::csv::parser_config maConfig;
 
@@ -96,12 +92,6 @@ public:
     bool IsRequestedTerminate();
     void Terminate();
     void EndThread();
-    void EmptyLineQueue(std::queue<LinesType*>& );
-    osl::Mutex& GetLinesMutex();
-    bool HasNewLines();
-    void WaitForNewLines();
-    LinesType* GetNewLines();
-    void ResumeFetchStream();
 
     virtual void execute() override;
 };


More information about the Libreoffice-commits mailing list