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

Szymon Kłos szymon.klos at collabora.com
Fri Aug 4 08:41:32 UTC 2017


 sc/qa/unit/data/xlsx/column-style-autofilter.xlsx |binary
 sc/qa/unit/subsequent_filters-test.cxx            |   17 +++++++++++++++++
 sc/source/filter/oox/sheetdatabuffer.cxx          |   21 ++++++++++++++++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit bca55386e187e2cb4ab277a597a420f15c6cebcf
Author: Szymon Kłos <szymon.klos at collabora.com>
Date:   Wed Aug 2 14:24:56 2017 +0200

    tdf#91567 Apply pattern without AutoFilter only
    
    When AutoFilter button was placed in first row, was also
    copied to other cells without formatting all over the worksheet.
    Take pattern from first row without AutoFilter button.
    
    Change-Id: Ib2eb12659bf8105e39b469b21386b3232e710007
    Reviewed-on: https://gerrit.libreoffice.org/40675
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/sc/qa/unit/data/xlsx/column-style-autofilter.xlsx b/sc/qa/unit/data/xlsx/column-style-autofilter.xlsx
new file mode 100755
index 000000000000..67b2dd479576
Binary files /dev/null and b/sc/qa/unit/data/xlsx/column-style-autofilter.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 0e838a87496e..f8f6548984b5 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -213,6 +213,7 @@ public:
     void testOutlineODS();
 
     void testColumnStyleXLSX();
+    void testColumnStyleAutoFilterXLSX();
 
     void testSharedFormulaHorizontalXLS();
     void testSharedFormulaWrappedRefsXLS();
@@ -338,6 +339,7 @@ public:
     CPPUNIT_TEST(testPrintRangeODS);
     CPPUNIT_TEST(testOutlineODS);
     CPPUNIT_TEST(testColumnStyleXLSX);
+    CPPUNIT_TEST(testColumnStyleAutoFilterXLSX);
     CPPUNIT_TEST(testSharedFormulaHorizontalXLS);
     CPPUNIT_TEST(testSharedFormulaWrappedRefsXLS);
     CPPUNIT_TEST(testSharedFormulaBIFF5);
@@ -3285,6 +3287,21 @@ void ScFiltersTest::testColumnStyleXLSX()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testColumnStyleAutoFilterXLSX()
+{
+    ScDocShellRef xDocSh = loadDoc("column-style-autofilter.", FORMAT_XLSX);
+    CPPUNIT_ASSERT(xDocSh.is());
+    ScDocument& rDoc = xDocSh->GetDocument();
+
+    const ScPatternAttr* pPattern = rDoc.GetPattern(0, 10, 18);
+    CPPUNIT_ASSERT(pPattern);
+
+    const ScMergeFlagAttr& rAttr = static_cast<const ScMergeFlagAttr&>(pPattern->GetItem(ATTR_MERGE_FLAG));
+    CPPUNIT_ASSERT(!rAttr.HasAutoFilter());
+
+    xDocSh->DoClose();
+}
+
 void ScFiltersTest::testSharedFormulaHorizontalXLS()
 {
     ScDocShellRef xDocSh = loadDoc("shared-formula/horizontal.", FORMAT_XLS);
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index 585a8a1bbcf6..cdd3cf909e92 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -444,7 +444,26 @@ void SheetDataBuffer::finalizeImport()
     {
         RowStyles& rRowStyles = col->second;
         SCCOL nScCol = static_cast< SCCOL >( col->first );
-        const ScPatternAttr* pDefPattern = rDoc.getDoc().GetPattern(nScCol, 0, getSheetIndex());
+
+        // tdf#91567 Get pattern from the first row without AutoFilter
+        const ScPatternAttr* pDefPattern = nullptr;
+        bool bAutoFilter = true;
+        SCROW nScRow = 0;
+        while ( bAutoFilter && nScRow < MAXROW )
+        {
+            pDefPattern = rDoc.getDoc().GetPattern( nScCol, nScRow, getSheetIndex() );
+            if ( pDefPattern )
+            {
+                const ScMergeFlagAttr* pAttr = static_cast<const ScMergeFlagAttr*>( pDefPattern->GetItemSet().GetItem( ATTR_MERGE_FLAG ) );
+                bAutoFilter = pAttr->HasAutoFilter();
+            }
+            else
+                break;
+            nScRow++;
+        }
+        if ( !pDefPattern || nScRow == MAXROW )
+            pDefPattern = rDoc.getDoc().GetDefPattern();
+
         Xf::AttrList aAttrs(pDefPattern);
         for ( RowStyles::iterator rRows = rRowStyles.begin(), rRows_end = rRowStyles.end(); rRows != rRows_end; ++rRows )
         {


More information about the Libreoffice-commits mailing list