Index: sc/source/core/data/table3.cxx =================================================================== --- sc/source/core/data/table3.cxx (revision 1342169) +++ sc/source/core/data/table3.cxx (working copy) @@ -421,12 +421,12 @@ const ScPatternAttr* pPat2 = GetPattern(nCol2, nRow); if (pPat1 != pPat2) { - //maybe the content is the same - if (!(*pPat1 == *pPat2)) - { - SetPattern(nCol1, nRow, *pPat2, sal_True); - SetPattern(nCol2, nRow, *pPat1, sal_True); - } + //Add Reference to avoid pPat1 to be deleted by merge same cell attributes for adjacent cells + if( IsPooledItem( pPat1 ) ) pPat1->AddRef(); + SetPattern(nCol1, nRow, *pPat2, sal_True); + SetPattern(nCol2, nRow, *pPat1, sal_True); + if( IsPooledItem( pPat1 ) ) pPat1->ReleaseRef(); + } } } @@ -443,12 +443,11 @@ const ScPatternAttr* pPat2 = GetPattern(nCol, nRow2); if (pPat1 != pPat2) { - //maybe the content is the same - if (!(*pPat1 == *pPat2)) - { - SetPattern(nCol, nRow1, *pPat2, sal_True); - SetPattern(nCol, nRow2, *pPat1, sal_True); - } + //Add Reference to avoid pPat1 to be deleted by merge same cell attributes for adjacent cells + if( IsPooledItem( pPat1 ) ) pPat1->AddRef(); + SetPattern(nCol, nRow1, *pPat2, sal_True); + SetPattern(nCol, nRow2, *pPat1, sal_True); + if( IsPooledItem( pPat1 ) ) pPat1->ReleaseRef(); } } } Index: svl/inc/svl/poolitem.hxx =================================================================== --- svl/inc/svl/poolitem.hxx (revision 1342169) +++ svl/inc/svl/poolitem.hxx (working copy) @@ -188,8 +188,8 @@ inline void SetKind( sal_uInt16 n ); public: inline sal_uLong AddRef( sal_uLong n = 1 ) const; + inline sal_uLong ReleaseRef( sal_uLong n = 1 ) const; private: - inline sal_uLong ReleaseRef( sal_uLong n = 1 ) const; SVL_DLLPRIVATE long Delete_Impl(void*); #if 0