[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source

Tamas Bunth tamas.bunth at collabora.co.uk
Thu Aug 10 20:28:08 UTC 2017


 sc/inc/queryparam.hxx              |    3 ++-
 sc/source/core/tool/queryparam.cxx |   11 ++++++++++-
 sc/source/ui/vba/vbarange.cxx      |    8 +-------
 sc/source/ui/view/gridwin.cxx      |   10 ++++------
 4 files changed, 17 insertions(+), 15 deletions(-)

New commits:
commit b946ab02b246e85c34f8fa77d99e19dacda07fe5
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
Date:   Fri Aug 11 00:45:59 2017 +0200

    tdf#107797 UpdateAutoFilter handle more entries
    
    Prepare UpdateAutoFilterFromMenu to handle more entries.
    
    Filter items can be hold by more than one entries. In that case we have
    to remove all the old entries before updating.
    
    E.g. setting AutoFilter from vba script results in more than one
    entries.
    
    Change-Id: I4f18f26281d0b8e689cd331f9a66f4c344fb6c6b
    Reviewed-on: https://gerrit.libreoffice.org/40967
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>

diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index a96375a8002e..3b406bb49bc5 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -59,7 +59,8 @@ struct ScQueryParamBase
     SC_DLLPUBLIC ScQueryEntry& AppendEntry();
     ScQueryEntry* FindEntryByField(SCCOLROW nField, bool bNew);
     std::vector<ScQueryEntry*> FindAllEntriesByField(SCCOLROW nField);
-    SC_DLLPUBLIC void RemoveEntryByField(SCCOLROW nField);
+    SC_DLLPUBLIC bool RemoveEntryByField(SCCOLROW nField);
+    SC_DLLPUBLIC void RemoveAllEntriesByField(SCCOLROW nField);
     void Resize(size_t nNew);
     void FillInExcelSyntax( svl::SharedStringPool& rPool, const OUString& aCellStr, SCSIZE nIndex,
                             SvNumberFormatter* pFormatter );
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 72fa4919537e..c902d2796bd4 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -161,10 +161,11 @@ std::vector<ScQueryEntry*> ScQueryParamBase::FindAllEntriesByField(SCCOLROW nFie
     return aEntries;
 }
 
-void ScQueryParamBase::RemoveEntryByField(SCCOLROW nField)
+bool ScQueryParamBase::RemoveEntryByField(SCCOLROW nField)
 {
     EntriesType::iterator itr = std::find_if(
         m_Entries.begin(), m_Entries.end(), FindByField(nField));
+    bool bRet = false;
 
     if (itr != m_Entries.end())
     {
@@ -173,7 +174,15 @@ void ScQueryParamBase::RemoveEntryByField(SCCOLROW nField)
             // Make sure that we have at least MAXQUERY number of entries at
             // all times.
             m_Entries.push_back(o3tl::make_unique<ScQueryEntry>());
+        bRet = true;
     }
+
+    return bRet;
+}
+
+void ScQueryParamBase::RemoveAllEntriesByField(SCCOLROW nField)
+{
+    while( RemoveEntryByField( nField ) ) {}
 }
 
 void ScQueryParamBase::Resize(size_t nNew)
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 1de9b9533815..e54bf486f7d8 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -778,12 +778,10 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
     ScQueryParam aParam;
     pDBData->GetQueryParam(aParam);
 
-    if (eMode == Normal && mpAutoFilterPopup->isAllSelected())
-    {
-        // Remove this entry.
-        aParam.RemoveEntryByField(rPos.Col());
-    }
-    else
+    // Remove old entries.
+    aParam.RemoveAllEntriesByField(rPos.Col());
+
+    if( !(eMode == Normal && mpAutoFilterPopup->isAllSelected() ) )
     {
         // Try to use the existing entry for the column (if one exists).
         ScQueryEntry* pEntry = aParam.FindEntryByField(rPos.Col(), true);
commit 7e728965b3f5a37a6f0bd75d616d2acb16c40f71
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
Date:   Fri Aug 11 01:57:55 2017 +0200

    tdf#107858 oovbaapi: Autofilter always has header
    
    If AutoFilter created with vba macro, it should always use a header
    (because Excel does the same), regardless of the type of cells in the
    first row.
    
    Change-Id: I586e092ac62c893b9873cc4b988566d8f00636cc
    Reviewed-on: https://gerrit.libreoffice.org/40969
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 5aae79fd6889..29944d78dccb 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -4438,13 +4438,7 @@ ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const
         xDBRangeProps->setPropertyValue( "AutoFilter", uno::Any(true) );
         // set header (autofilter always need column headers)
         uno::Reference< beans::XPropertySet > xFiltProps( xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY_THROW );
-        bool bHasColHeader = false;
-        ScDocument* pDoc = pShell ? &pShell->GetDocument() : nullptr;
-        if (pDoc)
-        {
-            bHasColHeader = pDoc->HasColHeader(  static_cast< SCCOL >( autoFiltAddress.StartColumn ), static_cast< SCROW >( autoFiltAddress.StartRow ), static_cast< SCCOL >( autoFiltAddress.EndColumn ), static_cast< SCROW >( autoFiltAddress.EndRow ), static_cast< SCTAB >( autoFiltAddress.Sheet ) );
-        }
-        xFiltProps->setPropertyValue( "ContainsHeader", uno::Any( bHasColHeader ) );
+        xFiltProps->setPropertyValue( "ContainsHeader", uno::Any( true ) );
     }
 
     sal_Int32 nField = 0; // *IS* 1 based


More information about the Libreoffice-commits mailing list