summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/attarray.hxx54
-rw-r--r--sc/inc/column.hxx26
-rw-r--r--sc/inc/docpool.hxx6
-rw-r--r--sc/inc/document.hxx16
-rw-r--r--sc/inc/global.hxx2
-rw-r--r--sc/inc/patattr.hxx132
-rw-r--r--sc/inc/poolcach.hxx28
-rw-r--r--sc/inc/scitems.hxx80
-rw-r--r--sc/inc/table.hxx4
9 files changed, 203 insertions, 145 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index a7e1c08a9f49..c1f9195e6445 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -67,24 +67,38 @@ struct ScLineFlags
struct ScMergePatternState
{
std::optional<SfxItemSet> pItemSet;
- const ScPatternAttr* pOld1; ///< existing objects, temporary
- const ScPatternAttr* pOld2;
+ CellAttributeHolder aOld1; ///< existing objects, temporary
+ CellAttributeHolder aOld2;
bool mbValidPatternId;
sal_uInt64 mnPatternId;
- ScMergePatternState() : pOld1(nullptr), pOld2(nullptr),
+ ScMergePatternState() : aOld1(), aOld2(),
mbValidPatternId(true), mnPatternId(0) {}
};
// we store an array of these where the pattern applies to all rows up till nEndRow
-struct ScAttrEntry
+class ScAttrEntry
{
+ CellAttributeHolder aPattern;
+
+public:
+ ScAttrEntry()
+ : aPattern()
+ , nEndRow(0)
+ {}
+
SCROW nEndRow;
- const ScPatternAttr* pPattern;
+
+ const CellAttributeHolder& getCellAttributeHolder() const { return aPattern; }
+ void setCellAttributeHolder(const CellAttributeHolder& rNew) { aPattern = rNew; }
+
+ const ScPatternAttr* getScPatternAttr() const { return aPattern.getScPatternAttr(); }
+ void setScPatternAttr(const ScPatternAttr* pNew, bool bPassingOwnership = false) { aPattern.setScPatternAttr(pNew, bPassingOwnership); }
+
bool operator==( const ScAttrEntry& other ) const
{
- return nEndRow == other.nEndRow && SfxPoolItem::areSame(pPattern, other.pPattern);
+ return nEndRow == other.nEndRow && CellAttributeHolder::areSame(&aPattern, &other.aPattern);
}
};
@@ -125,7 +139,7 @@ public:
#if DEBUG_SC_TESTATTRARRAY
void TestData() const;
#endif
- void Reset( const ScPatternAttr* pPattern);
+ void Reset(const CellAttributeHolder& rPattern);
bool Concat(SCSIZE nPos);
const ScPatternAttr* GetPattern( SCROW nRow ) const;
@@ -144,18 +158,12 @@ public:
void ApplyBlockFrame(const SvxBoxItem& rLineOuter, const SvxBoxInfoItem* pLineInner,
SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight);
- void SetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool bPutToPool = false )
- { SetPatternAreaImpl(nRow, nRow, pPattern, bPutToPool, nullptr, /*bPassingOwnership*/false); }
- const ScPatternAttr* SetPattern( SCROW nRow, std::unique_ptr<ScPatternAttr> pPattern, bool bPutToPool = false )
- { return SetPatternAreaImpl(nRow, nRow, pPattern.release(), bPutToPool, nullptr, /*bPassingOwnership*/true); }
- void SetPatternArea( SCROW nStartRow, SCROW nEndRow, std::unique_ptr<ScPatternAttr> pPattern,
- bool bPutToPool = false, ScEditDataArray* pDataArray = nullptr)
- { SetPatternAreaImpl(nStartRow, nEndRow, pPattern.release(), bPutToPool, pDataArray, /*bPassingOwnership*/true); }
- void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern,
- bool bPutToPool = false, ScEditDataArray* pDataArray = nullptr)
- { SetPatternAreaImpl(nStartRow, nEndRow, pPattern, bPutToPool, pDataArray, /*bPassingOwnership*/false); }
+ void SetPattern( SCROW nRow, const CellAttributeHolder& rPattern )
+ { SetPatternAreaImpl(nRow, nRow, rPattern, nullptr); }
+ void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const CellAttributeHolder& rPattern, ScEditDataArray* pDataArray = nullptr)
+ { SetPatternAreaImpl(nStartRow, nEndRow, rPattern, pDataArray); }
void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle );
- void ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, ScItemPoolCache* pCache,
+ void ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, ScItemPoolCache& rCache,
ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
void SetAttrEntries(std::vector<ScAttrEntry> && vNewData);
void ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
@@ -196,8 +204,7 @@ public:
void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset );
bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const;
- void SetPatternAreaSafe( SCROW nStartRow, SCROW nEndRow,
- const ScPatternAttr* pWantedPattern, bool bDefault );
+ void SetPatternAreaSafe( SCROW nStartRow, SCROW nEndRow, const CellAttributeHolder& rWantedPattern );
void CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, tools::Long nDy, ScAttrArray& rAttrArray );
bool IsEmpty() const;
@@ -227,9 +234,8 @@ public:
SCSIZE Count( SCROW nRow1, SCROW nRow2 ) const;
private:
- const ScPatternAttr* SetPatternAreaImpl( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern,
- bool bPutToPool = false, ScEditDataArray* pDataArray = nullptr,
- bool bPassingPatternOwnership = false );
+ const ScPatternAttr* SetPatternAreaImpl(
+ SCROW nStartRow, SCROW nEndRow, const CellAttributeHolder& rPattern, ScEditDataArray* pDataArray = nullptr);
};
// Iterator for attributes
@@ -287,7 +293,7 @@ inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom )
{
rTop = nRow;
rBottom = std::min( pArray->mvData[nPos].nEndRow, nEndRow );
- pRet = pArray->mvData[nPos].pPattern;
+ pRet = pArray->mvData[nPos].getScPatternAttr();
nRow = rBottom + 1;
++nPos;
}
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 914199be25b5..87273f0f83ba 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -100,7 +100,8 @@ struct ScInterpreterContext;
struct ScNeededSizeOptions
{
- const ScPatternAttr* pPattern;
+ CellAttributeHolder aPattern;
+
bool bFormula;
bool bSkipMerged;
bool bGetFont;
@@ -144,7 +145,7 @@ public:
const ScPatternAttr* GetPattern( SCROW nRow ) const;
const ScPatternAttr* GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const;
- SCROW ApplySelectionCache( ScItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged,
+ SCROW ApplySelectionCache( ScItemPoolCache& rCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged,
SCCOL nCol );
void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr,
ScEditDataArray* pDataArray = nullptr,
@@ -541,9 +542,9 @@ public:
void ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr );
void ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr );
- const ScPatternAttr* SetPattern( SCROW nRow, std::unique_ptr<ScPatternAttr> );
- void SetPattern( SCROW nRow, const ScPatternAttr& );
- void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& );
+ void SetPattern( SCROW nRow, const CellAttributeHolder& rHolder );
+ void SetPattern( SCROW nRow, const ScPatternAttr& rPattern );
+ void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const CellAttributeHolder& );
void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
const ScPatternAttr& rPattern, SvNumFormatType nNewType );
@@ -575,7 +576,7 @@ public:
void RemoveProtected( SCROW nStartRow, SCROW nEndRow );
- SCROW ApplySelectionCache( ScItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged );
+ SCROW ApplySelectionCache( ScItemPoolCache& rCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged );
void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast );
void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
@@ -1031,20 +1032,19 @@ inline void ScColumn::ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt
pAttrArray->ClearItems( nStartRow, nEndRow, pWhich );
}
-inline const ScPatternAttr* ScColumn::SetPattern( SCROW nRow, std::unique_ptr<ScPatternAttr> pPatAttr )
+inline void ScColumn::SetPattern( SCROW nRow, const CellAttributeHolder& rHolder )
{
- return pAttrArray->SetPattern( nRow, std::move(pPatAttr), true/*bPutToPool*/ );
+ return pAttrArray->SetPattern( nRow, rHolder );
}
-inline void ScColumn::SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr )
+inline void ScColumn::SetPattern( SCROW nRow, const ScPatternAttr& rPattern )
{
- pAttrArray->SetPattern( nRow, &rPatAttr, true/*bPutToPool*/ );
+ pAttrArray->SetPattern( nRow, CellAttributeHolder(&rPattern) );
}
-inline void ScColumn::SetPatternArea( SCROW nStartRow, SCROW nEndRow,
- const ScPatternAttr& rPatAttr )
+inline void ScColumn::SetPatternArea( SCROW nStartRow, SCROW nEndRow, const CellAttributeHolder& rHolder )
{
- pAttrArray->SetPatternArea( nStartRow, nEndRow, &rPatAttr, true/*bPutToPool*/ );
+ pAttrArray->SetPatternArea( nStartRow, nEndRow, rHolder );
}
inline void ScColumnData::SetAttrEntries(std::vector<ScAttrEntry> && vNewData)
diff --git a/sc/inc/docpool.hxx b/sc/inc/docpool.hxx
index c73d034f2fb2..614e3d4229b8 100644
--- a/sc/inc/docpool.hxx
+++ b/sc/inc/docpool.hxx
@@ -29,7 +29,6 @@ class ScDocument;
class SC_DLLPUBLIC ScDocumentPool final : public SfxItemPool
{
std::vector<SfxPoolItem*> mvPoolDefaults;
- sal_uInt64 mnCurrentMaxKey;
public:
ScDocumentPool();
@@ -40,15 +39,10 @@ public:
virtual rtl::Reference<SfxItemPool> Clone() const override;
virtual MapUnit GetMetric( sal_uInt16 nWhich ) const override;
- void StyleDeleted( const ScStyleSheet* pStyle ); // delete templates(?) in organizer
- void CellStyleCreated( std::u16string_view rName, const ScDocument& rDoc );
virtual bool GetPresentation( const SfxPoolItem& rItem,
MapUnit ePresentationMetric,
OUString& rText,
const IntlWrapper& rIntl ) const override;
-private:
- virtual void newItem_Callback(const SfxPoolItem& rItem) const override;
- virtual bool newItem_UseDirect(const SfxPoolItem& rItem) const override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 11b65e9262c0..d94b0ef4fb53 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -356,6 +356,14 @@ public:
};
private:
+ // needs to be shared to allow the bIsClip/bIsUndo mechanism to
+ // do the right thing (SCDOCMODE_CLIP, SCDOCMODE_UNDO)
+ mutable std::shared_ptr<CellAttributeHelper> mpCellAttributeHelper;
+
+public:
+ SC_DLLPUBLIC CellAttributeHelper& getCellAttributeHelper() const;
+
+private:
rtl::Reference<ScPoolHelper> mxPoolHelper;
std::shared_ptr<svl::SharedStringPool> mpCellStringPool;
@@ -1939,8 +1947,8 @@ public:
SCTAB nTab, ScMF nFlags );
SC_DLLPUBLIC void SetPattern( const ScAddress&, const ScPatternAttr& rAttr );
- SC_DLLPUBLIC const ScPatternAttr* SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPatternAttr> pAttr );
- SC_DLLPUBLIC const ScPatternAttr* SetPattern( const ScAddress& rPos, std::unique_ptr<ScPatternAttr> pAttr );
+ SC_DLLPUBLIC void SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, const CellAttributeHolder& rHolder );
+ SC_DLLPUBLIC void SetPattern( const ScAddress& rPos, const CellAttributeHolder& rHolder );
SC_DLLPUBLIC void SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr& rAttr );
void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
@@ -2090,7 +2098,6 @@ public:
void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab );
- SC_DLLPUBLIC ScPatternAttr* GetDefPattern() const;
SC_DLLPUBLIC ScDocumentPool* GetPool();
SC_DLLPUBLIC ScStyleSheetPool* GetStyleSheetPool() const;
void GetUnprotectedCells( ScRangeList& rRange, SCTAB nTab ) const;
@@ -2142,9 +2149,6 @@ public:
SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool bHiddenAsZero = true ) const;
- void UpdStlShtPtrsFrmNms();
- void StylesToNames();
-
SC_DLLPUBLIC void CopyStdStylesFrom( const ScDocument& rSrcDoc );
static sal_uInt16 GetSrcVersion() { return nSrcVer; }
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index fe7b8bb407b2..1539858434bc 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -603,7 +603,7 @@ public:
static void InitAddIns();
SC_DLLPUBLIC static void Clear(); // at the end of the program
- static void InitTextHeight(const SfxItemPool* pPool);
+ static void InitTextHeight(SfxItemPool& rPool);
static SvxBrushItem* GetEmptyBrushItem() { return xEmptyBrushItem.get(); }
static SvxBrushItem* GetButtonBrushItem();
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index d6536551f965..361ed40cd25b 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -21,13 +21,14 @@
#include <optional>
-#include <svl/setitem.hxx>
#include <svl/itemset.hxx>
#include <svl/languageoptions.hxx>
#include <tools/degree.hxx>
#include <editeng/svxenum.hxx>
#include "scdllapi.h"
#include "fonthelper.hxx"
+#include "scitems.hxx"
+#include <unordered_set>
namespace vcl { class Font; }
namespace model { class ComplexColor; }
@@ -50,43 +51,106 @@ enum class ScAutoFontColorMode
IgnoreAll ///< like DISPLAY, but ignore stored font and background colors
};
-class SC_DLLPUBLIC ScPatternAttr final : public SfxSetItem
+class ScPatternAttr;
+
+class SC_DLLPUBLIC CellAttributeHelper final
{
- std::optional<OUString> pName;
- mutable std::optional<bool> mxVisible;
- ScStyleSheet* pStyle;
- sal_uInt64 mnPAKey;
+ friend class CellAttributeHolder;
+
+ SfxItemPool& mrSfxItemPool;
+ mutable ScPatternAttr* mpDefaultCellAttribute;
+ mutable std::unordered_set<const ScPatternAttr*> maRegisteredCellAttributes;
+ mutable const ScPatternAttr* mpLastHit;
+ mutable sal_uInt64 mnCurrentMaxKey;
+
+ // only to be used from CellAttributeHolder, so private
+ const ScPatternAttr* registerAndCheck(const ScPatternAttr& rCandidate, bool bPassingOwnership) const;
+ void doUnregister(const ScPatternAttr& rCandidate);
+
public:
- ScPatternAttr(SfxItemSet&& pItemSet, const OUString& rStyleName);
- ScPatternAttr(SfxItemSet&& pItemSet);
- ScPatternAttr(SfxItemPool* pItemPool);
- ScPatternAttr(const ScPatternAttr& rPatternAttr);
+ explicit CellAttributeHelper(SfxItemPool& rSfxItemPool);
+ ~CellAttributeHelper();
+
+ const ScPatternAttr& getDefaultCellAttribute() const;
+ SfxItemPool& GetPool() const { return mrSfxItemPool; }
- virtual ScPatternAttr* Clone( SfxItemPool *pPool = nullptr ) const override;
+ void CellStyleDeleted(const ScStyleSheet& rStyle);
+ void CellStyleCreated(ScDocument& rDoc, std::u16string_view rName);
+ void UpdateAllStyleSheets(ScDocument& rDoc);
+ void AllStylesToNames();
+};
- virtual bool operator==(const SfxPoolItem& rCmp) const override;
+class SC_DLLPUBLIC CellAttributeHolder final
+{
+ const ScPatternAttr* mpScPatternAttr;
- const SfxPoolItem& GetItem( sal_uInt16 nWhichP ) const
- { return GetItemSet().Get(nWhichP); }
- template<class T> const T& GetItem( TypedWhichId<T> nWhich ) const
- { return static_cast<const T&>(GetItem(sal_uInt16(nWhich))); }
+public:
+ CellAttributeHolder(const ScPatternAttr* pScPatternAttr = nullptr, bool bPassingOwnership = false);
+ CellAttributeHolder(const CellAttributeHolder& rHolder);
+ ~CellAttributeHolder();
- static const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet );
- template<class T> static const T& GetItem( TypedWhichId<T> nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
- { return static_cast<const T&>(GetItem(sal_uInt16(nWhich), rItemSet, pCondSet)); }
+ const CellAttributeHolder& operator=(const CellAttributeHolder& rHolder);
+ bool operator==(const CellAttributeHolder& rHolder) const;
- const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet* pCondSet ) const;
- template<class T> const T& GetItem( TypedWhichId<T> nWhich, const SfxItemSet* pCondSet ) const
- { return static_cast<const T&>(GetItem(sal_uInt16(nWhich), pCondSet)); }
+ const ScPatternAttr* getScPatternAttr() const { return mpScPatternAttr; }
+ void setScPatternAttr(const ScPatternAttr* pNew, bool bPassingOwnership = false);
- /// @param pWhich are no ranges, but single IDs, 0-terminated
- bool HasItemsSet( const sal_uInt16* pWhich ) const;
- void ClearItems( const sal_uInt16* pWhich );
+ bool operator!() const { return nullptr == mpScPatternAttr; }
+ explicit operator bool() const { return nullptr != mpScPatternAttr; }
- void DeleteUnchanged( const ScPatternAttr* pOldAttrs );
+ // version that allows nullptrs
+ static bool areSame(const CellAttributeHolder* p1, const CellAttributeHolder* p2);
+};
+
+class SC_DLLPUBLIC ScPatternAttr final
+{
+ friend class CellAttributeHelper;
+
+ SfxItemSet maLocalSfxItemSet;
+ std::optional<OUString> pName;
+ mutable std::optional<bool> mxVisible;
+ ScStyleSheet* pStyle;
+ CellAttributeHelper* pCellAttributeHelper;
+ sal_uInt64 mnPAKey;
+ mutable size_t mnRefCount;
+#ifdef DBG_UTIL
+ sal_uInt32 m_nSerialNumber;
+ bool m_bDeleted;
+#endif
+
+public:
+ ScPatternAttr(CellAttributeHelper& rHelper, const SfxItemSet* pItemSet = nullptr, const OUString* pStyleName = nullptr);
+ ScPatternAttr(const ScPatternAttr& rPatternAttr);
+ ~ScPatternAttr();
+
+ virtual bool operator==(const ScPatternAttr& rCmp) const;
+
+ // version that allows nullptrs
+ static bool areSame(const ScPatternAttr* pItem1, const ScPatternAttr* pItem2);
+ bool isRegistered() const { return 0 != mnRefCount; }
+ bool isDefault() const { return this == &pCellAttributeHelper->getDefaultCellAttribute(); }
+ CellAttributeHelper& getCellAttributeHelper() const { return *pCellAttributeHelper; }
+
+ const SfxItemSet& GetItemSet() const { return maLocalSfxItemSet; }
+ SfxItemSet& GetItemSet() { return maLocalSfxItemSet; }
+
+ const SfxPoolItem& GetItem(sal_uInt16 nWhichP) const { return maLocalSfxItemSet.Get(nWhichP); }
+ template<class T> const T& GetItem( TypedWhichId<T> nWhich ) const
+ { return static_cast<const T&>(GetItem(sal_uInt16(nWhich))); }
+ static const SfxPoolItem& GetItem(sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet);
+ template<class T> static const T& GetItem(TypedWhichId<T> nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet)
+ { return static_cast<const T&>(GetItem(sal_uInt16(nWhich), rItemSet, pCondSet)); }
+ const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet* pCondSet ) const;
+ template<class T> const T& GetItem(TypedWhichId<T> nWhich, const SfxItemSet* pCondSet) const
+ { return static_cast<const T&>(GetItem(sal_uInt16(nWhich), pCondSet)); }
+
+ /// @param pWhich are no ranges, but single IDs, 0-terminated
+ bool HasItemsSet( const sal_uInt16* pWhich ) const;
+ void ClearItems( const sal_uInt16* pWhich );
+ void DeleteUnchanged( const ScPatternAttr* pOldAttrs );
static SvxCellOrientation GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet );
- SvxCellOrientation GetCellOrientation( const SfxItemSet* pCondSet = nullptr ) const;
+ SvxCellOrientation GetCellOrientation( const SfxItemSet* pCondSet = nullptr ) const;
/** Static helper function to fill a font object from the passed item set. */
static void fillFontOnly(vcl::Font& rFont, const SfxItemSet& rItemSet,
@@ -119,7 +183,7 @@ public:
const Color* pBackConfigColor = nullptr,
const Color* pTextConfigColor = nullptr) const
{
- fillColor(rComplexColor, GetItemSet(), eAutoMode, pCondSet, pBackConfigColor, pTextConfigColor);
+ fillColor(rComplexColor, maLocalSfxItemSet, eAutoMode, pCondSet, pBackConfigColor, pTextConfigColor);
}
void fillFontOnly(vcl::Font& rFont,
@@ -128,7 +192,7 @@ public:
const SfxItemSet* pCondSet = nullptr,
SvtScriptType nScript = SvtScriptType::NONE) const
{
- fillFontOnly(rFont, GetItemSet(), pOutDev, pScale, pCondSet, nScript);
+ fillFontOnly(rFont, maLocalSfxItemSet, pOutDev, pScale, pCondSet, nScript);
}
/** Fills a font object from the own item set. */
@@ -140,7 +204,7 @@ public:
const Color* pBackConfigColor = nullptr,
const Color* pTextConfigColor = nullptr) const
{
- fillFont(rFont, GetItemSet(), eAutoMode, pOutDev, pScale, pCondSet, nScript, pBackConfigColor, pTextConfigColor);
+ fillFont(rFont, maLocalSfxItemSet, eAutoMode, pOutDev, pScale, pCondSet, nScript, pBackConfigColor, pTextConfigColor);
}
/** Converts all Calc items contained in rSrcSet to edit engine items and puts them into rEditSet. */
@@ -155,7 +219,7 @@ public:
void FillEditParaItems( SfxItemSet* pSet ) const;
- ScPatternAttr* PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const;
+ CellAttributeHolder MigrateToDocument( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const;
void SetStyleSheet(ScStyleSheet* pNewStyle, bool bClearDirectFormat = true);
const ScStyleSheet* GetStyleSheet() const { return pStyle; }
@@ -180,12 +244,6 @@ public:
void SetPAKey(sal_uInt64 nKey);
sal_uInt64 GetPAKey() const;
- // TODO: tdf#135215: This is a band-aid to detect changes and invalidate the hash,
- // a proper way would be probably to override SfxItemSet::Changed(), but 6cb400f41df0dd10
- // hardcoded SfxSetItem to contain SfxItemSet.
- SfxItemSet& GetItemSet() { mxVisible.reset(); return SfxSetItem::GetItemSet(); }
- using SfxSetItem::GetItemSet;
-
private:
bool CalcVisible() const;
};
diff --git a/sc/inc/poolcach.hxx b/sc/inc/poolcach.hxx
index 6e3c3deda916..5b9057b7faf3 100644
--- a/sc/inc/poolcach.hxx
+++ b/sc/inc/poolcach.hxx
@@ -19,35 +19,33 @@
#pragma once
#include "scdllapi.h"
+#include "patattr.hxx"
#include <vector>
-class SfxItemPool;
+class CellAttributeHelper;
class SfxItemSet;
class SfxPoolItem;
-class ScPatternAttr;
class ScItemPoolCache
{
struct SfxItemModifyImpl
{
- const ScPatternAttr *pOrigItem;
- ScPatternAttr *pPoolItem;
+ const CellAttributeHolder aOriginal;
+ const CellAttributeHolder aModified;
+ SfxItemModifyImpl(const CellAttributeHolder& a, const CellAttributeHolder &b) : aOriginal(a), aModified(b) {}
};
- SfxItemPool *pPool;
- std::vector<SfxItemModifyImpl>
- m_aCache;
- const SfxItemSet *pSetToPut;
- const SfxPoolItem *pItemToPut;
+ CellAttributeHelper& rHelper;
+ std::vector<SfxItemModifyImpl> m_aCache;
+ const SfxItemSet* pSetToPut;
+ const SfxPoolItemHolder aItemToPut;
public:
- ScItemPoolCache( SfxItemPool *pPool,
- const SfxPoolItem *pPutItem );
- ScItemPoolCache( SfxItemPool *pPool,
- const SfxItemSet *pPutSet );
- ~ScItemPoolCache();
+ ScItemPoolCache( CellAttributeHelper& rHelper, const SfxPoolItem& rPutItem );
+ ScItemPoolCache( CellAttributeHelper& rHelper, const SfxItemSet& rPutSet );
+ ~ScItemPoolCache();
- const ScPatternAttr& ApplyTo( const ScPatternAttr& rSetItem );
+ const CellAttributeHolder& ApplyTo( const CellAttributeHolder& rSetItem );
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/scitems.hxx b/sc/inc/scitems.hxx
index dd91e2f63a3c..538624e4c5cb 100644
--- a/sc/inc/scitems.hxx
+++ b/sc/inc/scitems.hxx
@@ -162,48 +162,46 @@ constexpr TypedWhichId<ScCondFormatItem> ATTR_CONDITIONAL (154);
constexpr TypedWhichId<SfxStringItem> ATTR_HYPERLINK (155);
constexpr sal_uInt16 ATTR_PATTERN_END(155); // end cell-attribute-pattern
-
-constexpr TypedWhichId<ScPatternAttr> ATTR_PATTERN (156);
// page attributes
-constexpr TypedWhichId<SvxLRSpaceItem> ATTR_LRSPACE (157); // editor: PageDesc-TabPage
-constexpr TypedWhichId<SvxULSpaceItem> ATTR_ULSPACE (158);
-constexpr TypedWhichId<SvxPageItem> ATTR_PAGE (159);
-constexpr TypedWhichId<SvxPaperBinItem> ATTR_PAGE_PAPERBIN (160);
-constexpr TypedWhichId<SvxSizeItem> ATTR_PAGE_SIZE (161);
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_HORCENTER (162);
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_VERCENTER (163);
-
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_ON (164); // editor: header/footer-page
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_DYNAMIC (165);
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_SHARED (166);
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_SHARED_FIRST (167);
-
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_NOTES (168); // editor: table
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_GRID (169);
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_HEADERS (170);
-constexpr TypedWhichId<ScViewObjectModeItem> ATTR_PAGE_CHARTS (171);
-constexpr TypedWhichId<ScViewObjectModeItem> ATTR_PAGE_OBJECTS (172);
-constexpr TypedWhichId<ScViewObjectModeItem> ATTR_PAGE_DRAWINGS (173);
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_TOPDOWN (174);
-constexpr TypedWhichId<SfxUInt16Item> ATTR_PAGE_SCALE (175);
-constexpr TypedWhichId<SfxUInt16Item> ATTR_PAGE_SCALETOPAGES (176);
-constexpr TypedWhichId<SfxUInt16Item> ATTR_PAGE_FIRSTPAGENO (177);
-
-constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_HEADERLEFT (178); // contents of header/
-constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_FOOTERLEFT (179); // footer (left)
-constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_HEADERRIGHT (180); // contents of header/
-constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_FOOTERRIGHT (181); // footer (right)
-constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_HEADERFIRST (182); // contents of header/
-constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_FOOTERFIRST (183); // footer (first page)
-constexpr TypedWhichId<SvxSetItem> ATTR_PAGE_HEADERSET (184); // the corresponding sets
-constexpr TypedWhichId<SvxSetItem> ATTR_PAGE_FOOTERSET (185);
-
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_FORMULAS (186);
-constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_NULLVALS (187);
-
-constexpr TypedWhichId<ScPageScaleToItem> ATTR_PAGE_SCALETO (188); // #i8868# scale printout to width/height
-
-constexpr TypedWhichId<SfxBoolItem> ATTR_HIDDEN (189);
+constexpr TypedWhichId<SvxLRSpaceItem> ATTR_LRSPACE (156); // editor: PageDesc-TabPage
+constexpr TypedWhichId<SvxULSpaceItem> ATTR_ULSPACE (157);
+constexpr TypedWhichId<SvxPageItem> ATTR_PAGE (158);
+constexpr TypedWhichId<SvxPaperBinItem> ATTR_PAGE_PAPERBIN (159);
+constexpr TypedWhichId<SvxSizeItem> ATTR_PAGE_SIZE (160);
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_HORCENTER (161);
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_VERCENTER (162);
+
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_ON (163); // editor: header/footer-page
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_DYNAMIC (164);
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_SHARED (165);
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_SHARED_FIRST (166);
+
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_NOTES (167); // editor: table
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_GRID (168);
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_HEADERS (169);
+constexpr TypedWhichId<ScViewObjectModeItem> ATTR_PAGE_CHARTS (170);
+constexpr TypedWhichId<ScViewObjectModeItem> ATTR_PAGE_OBJECTS (171);
+constexpr TypedWhichId<ScViewObjectModeItem> ATTR_PAGE_DRAWINGS (172);
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_TOPDOWN (173);
+constexpr TypedWhichId<SfxUInt16Item> ATTR_PAGE_SCALE (174);
+constexpr TypedWhichId<SfxUInt16Item> ATTR_PAGE_SCALETOPAGES (175);
+constexpr TypedWhichId<SfxUInt16Item> ATTR_PAGE_FIRSTPAGENO (176);
+
+constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_HEADERLEFT (177); // contents of header/
+constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_FOOTERLEFT (178); // footer (left)
+constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_HEADERRIGHT (179); // contents of header/
+constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_FOOTERRIGHT (180); // footer (right)
+constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_HEADERFIRST (181); // contents of header/
+constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_FOOTERFIRST (182); // footer (first page)
+constexpr TypedWhichId<SvxSetItem> ATTR_PAGE_HEADERSET (183); // the corresponding sets
+constexpr TypedWhichId<SvxSetItem> ATTR_PAGE_FOOTERSET (184);
+
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_FORMULAS (185);
+constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_NULLVALS (186);
+
+constexpr TypedWhichId<ScPageScaleToItem> ATTR_PAGE_SCALETO (187); // #i8868# scale printout to width/height
+
+constexpr TypedWhichId<SfxBoolItem> ATTR_HIDDEN (188);
constexpr sal_uInt16 ATTR_ENDINDEX(ATTR_HIDDEN); // end of pool-range
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 3b47a52c0ab8..72e78b195986 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -780,7 +780,7 @@ public:
void SetAttrEntries( SCCOL nStartCol, SCCOL nEndCol, std::vector<ScAttrEntry> && vNewData);
void SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr );
- const ScPatternAttr* SetPattern( SCCOL nCol, SCROW nRow, std::unique_ptr<ScPatternAttr> );
+ void SetPattern( SCCOL nCol, SCROW nRow, const CellAttributeHolder& rHolder );
void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr );
void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
const ScPatternAttr& rPattern, SvNumFormatType nNewType );
@@ -810,7 +810,7 @@ public:
bool ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
bool RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags );
- void ApplySelectionCache( ScItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
+ void ApplySelectionCache( ScItemPoolCache& rCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr );
void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true );
void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );