diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-04-02 23:41:03 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-04-12 00:59:30 +0200 |
commit | a1a497ce11ea8932ad6d8e1a7320fb069c4e4e78 (patch) | |
tree | 2ecbd9c6432ab7cecc559e3f66adf3b0a5ef8e68 /sc | |
parent | 6d95493690def02b15c28f2ab1c9b5831675b326 (diff) |
pivot: use ScPatternAttr not styles for pivot table cell format
Get the ItemSet from the Dxf instead of creating a style from it,
then create a new ScPatterAttr, which is then transported to the
pivot table and used there.
Change-Id: I2ed886d0dd986b587e37330a39d6cd465b3bcf12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165686
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/pivot/PivotTableFormats.hxx | 14 | ||||
-rw-r--r-- | sc/source/core/data/dpoutput.cxx | 19 | ||||
-rw-r--r-- | sc/source/filter/inc/stylesbuffer.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/oox/PivotTableFormat.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/oox/stylesbuffer.cxx | 5 |
5 files changed, 22 insertions, 24 deletions
diff --git a/sc/inc/pivot/PivotTableFormats.hxx b/sc/inc/pivot/PivotTableFormats.hxx index 09f181e7e178..7b65d0df5820 100644 --- a/sc/inc/pivot/PivotTableFormats.hxx +++ b/sc/inc/pivot/PivotTableFormats.hxx @@ -12,6 +12,8 @@ #include <memory> #include <vector> #include <rtl/ustring.hxx> +#include <patattr.hxx> +#include <memory> namespace sc { @@ -19,12 +21,13 @@ struct PivotTableFormat { sal_Int32 nField; sal_Int32 nDataIndex; - OUString aStyleName; + std::shared_ptr<ScPatternAttr> pPattern; - PivotTableFormat(sal_Int32 _nField, sal_Int32 _nDataIndex, OUString _aStyleName) + PivotTableFormat(sal_Int32 _nField, sal_Int32 _nDataIndex, + std::shared_ptr<ScPatternAttr> _pPattern) : nField(_nField) , nDataIndex(_nDataIndex) - , aStyleName(_aStyleName) + , pPattern(_pPattern) { } }; @@ -34,9 +37,10 @@ class PivotTableFormats std::vector<PivotTableFormat> maFormats; public: - void add(sal_Int32 nField, sal_Int32 nDataIndex, OUString const& rStyle) + void add(sal_Int32 nField, sal_Int32 nDataIndex, + std::shared_ptr<ScPatternAttr> const& rpPattern) { - maFormats.emplace_back(nField, nDataIndex, rStyle); + maFormats.emplace_back(nField, nDataIndex, rpPattern); } size_t size() { return maFormats.size(); } diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index f19f0ff57f7e..8847f857a181 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -765,21 +765,6 @@ void ScDPOutput::DataCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const sheet::Data // SubTotal formatting is controlled by headers } -namespace -{ -void lclApplyStyle(ScDocument* pDoc, SCTAB nTab, - SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, - OUString const& rStyleName) -{ - ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool(); - ScStyleSheet* pStyle = static_cast<ScStyleSheet*>(pStlPool->Find(rStyleName, SfxStyleFamily::Para)); - if (pStyle) - { - pDoc->ApplyStyleAreaTab(nCol1, nRow1, nCol2, nRow2, nTab, *pStyle); - } -} -} - void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const sheet::MemberResult& rData, bool bColHeader, tools::Long nLevel ) { @@ -1103,7 +1088,7 @@ void ScDPOutput::outputColumnHeaders(SCTAB nTab, ScDPOutputImpl& rOutputImpl) { if (aFormat.nField == nDimension && aFormat.nDataIndex == nColumnIndex) { - lclApplyStyle(mpDocument, nTab, nColPos, nRowPos, nColPos, mnDataStartRow - 1, aFormat.aStyleName); + mpDocument->ApplyPattern(nColPos, nRowPos, nTab, *aFormat.pPattern); } } } @@ -1207,7 +1192,7 @@ void ScDPOutput::outputRowHeader(SCTAB nTab, ScDPOutputImpl& rOutputImpl) { if (aFormat.nField == nDimension && aFormat.nDataIndex == nRowIndex) { - lclApplyStyle(mpDocument, nTab, nColPos, nRowPos, mnDataStartCol - 1, nRowPos, aFormat.aStyleName); + mpDocument->ApplyPattern(nColPos, nRowPos, nTab, *aFormat.pPattern); } } } diff --git a/sc/source/filter/inc/stylesbuffer.hxx b/sc/source/filter/inc/stylesbuffer.hxx index c462da48ee20..ec6f5800cb66 100644 --- a/sc/source/filter/inc/stylesbuffer.hxx +++ b/sc/source/filter/inc/stylesbuffer.hxx @@ -864,6 +864,8 @@ public: OUString createDxfStyle( sal_Int32 nDxfId ) const; OUString createExtDxfStyle( sal_Int32 nDxfId ) const; + DxfRef getDxf(sal_Int32 nDxfId) const; + void writeFontToItemSet( SfxItemSet& rItemSet, sal_Int32 nFontId, bool bSkipPoolDefs ) const; sal_uInt32 writeNumFmtToItemSet( SfxItemSet& rItemSet, sal_uInt32 nNumFmtId, bool bSkipPoolDefs ) const; /** Writes the specified number format to the passed property map. */ diff --git a/sc/source/filter/oox/PivotTableFormat.cxx b/sc/source/filter/oox/PivotTableFormat.cxx index 1f76d5159a7d..436b76af1bdf 100644 --- a/sc/source/filter/oox/PivotTableFormat.cxx +++ b/sc/source/filter/oox/PivotTableFormat.cxx @@ -75,7 +75,9 @@ void PivotTableFormat::importPivotArea(const oox::AttributeList& rAttribs) void PivotTableFormat::finalizeImport() { - OUString const& rDxfStyle = getStyles().createDxfStyle(mnDxfId); + DxfRef pDxf = getStyles().getDxf(mnDxfId); + auto pPattern = std::make_shared<ScPatternAttr>(getScDocument().getCellAttributeHelper()); + pDxf->fillToItemSet(pPattern->GetItemSet()); ScDPObject* pDPObj = mrPivotTable.getDPObject(); ScDPSaveData* pSaveData = pDPObj->GetSaveData(); @@ -93,7 +95,7 @@ void PivotTableFormat::finalizeImport() auto nField = *pReference->mnField; for (auto index : pReference->maFieldItemsIndices) { - aFormats.add(nField, index, rDxfStyle); + aFormats.add(nField, index, pPattern); } } } diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx index a7be2cb93d7b..234d0365bdec 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -3049,6 +3049,11 @@ OUString StylesBuffer::createExtDxfStyle( sal_Int32 nDxfId ) const return rStyleName; } +DxfRef StylesBuffer::getDxf(sal_Int32 nDxfId) const +{ + return maDxfs.get(nDxfId); +} + void StylesBuffer::writeFontToItemSet( SfxItemSet& rItemSet, sal_Int32 nFontId, bool bSkipPoolDefs ) const { if( Font* pFont = maFonts.get( nFontId ).get() ) |