summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-08-02 14:24:56 +0200
committerAndras Timar <andras.timar@collabora.com>2017-08-09 13:56:51 +0200
commit20241e3b747c1dd8b28dce79bc75230b9bf57752 (patch)
tree7f8ad5cb6f103ae173b7ac90662def67686d61c7 /sc
parent5ae6c3991f5fb875667b487ee585b7e9663efdbb (diff)
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@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/40787 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sc')
-rwxr-xr-xsc/qa/unit/data/xlsx/column-style-autofilter.xlsxbin0 -> 396312 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx17
-rw-r--r--sc/source/filter/oox/sheetdatabuffer.cxx21
3 files changed, 37 insertions, 1 deletions
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
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/column-style-autofilter.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 8873513f7212..5c5e730ef591 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -215,6 +215,7 @@ public:
void testOutlineODS();
void testColumnStyleXLSX();
+ void testColumnStyleAutoFilterXLSX();
void testSharedFormulaHorizontalXLS();
void testSharedFormulaWrappedRefsXLS();
@@ -331,6 +332,7 @@ public:
CPPUNIT_TEST(testPrintRangeODS);
CPPUNIT_TEST(testOutlineODS);
CPPUNIT_TEST(testColumnStyleXLSX);
+ CPPUNIT_TEST(testColumnStyleAutoFilterXLSX);
CPPUNIT_TEST(testSharedFormulaHorizontalXLS);
CPPUNIT_TEST(testSharedFormulaWrappedRefsXLS);
CPPUNIT_TEST(testSharedFormulaBIFF5);
@@ -3270,6 +3272,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 44a0e02fdeb3..dbcc07d5db64 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -453,7 +453,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 )
{