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

Noel Grandin noel.grandin at collabora.co.uk
Sat Feb 3 15:04:42 UTC 2018


 sc/inc/autoform.hxx                                   |    4 +
 sc/inc/column.hxx                                     |    4 +
 sc/inc/document.hxx                                   |   13 +++++
 sc/inc/table.hxx                                      |    4 +
 sc/qa/unit/subsequent_filters-test.cxx                |    6 +-
 sc/qa/unit/ucalc.cxx                                  |    4 -
 sc/source/core/data/clipcontext.cxx                   |    2 
 sc/source/core/data/column.cxx                        |    2 
 sc/source/core/data/column3.cxx                       |   10 ++--
 sc/source/core/data/documen3.cxx                      |    9 +---
 sc/source/core/data/documen4.cxx                      |    2 
 sc/source/core/data/document.cxx                      |   30 ++++---------
 sc/source/core/data/dpobject.cxx                      |    2 
 sc/source/core/data/drwlayer.cxx                      |    2 
 sc/source/core/data/fillinfo.cxx                      |    9 +---
 sc/source/core/data/formulacell.cxx                   |    4 -
 sc/source/core/data/table1.cxx                        |    3 -
 sc/source/core/data/table4.cxx                        |   12 ++---
 sc/source/core/tool/interpr1.cxx                      |    6 --
 sc/source/filter/excel/excimp8.cxx                    |    2 
 sc/source/filter/excel/xistyle.cxx                    |   10 ++--
 sc/source/filter/html/htmlexp.cxx                     |    2 
 sc/source/filter/html/htmlimp.cxx                     |   13 ++---
 sc/source/filter/oox/sheetdatabuffer.cxx              |    8 +--
 sc/source/ui/Accessibility/AccessibleCell.cxx         |   18 ++------
 sc/source/ui/Accessibility/AccessiblePreviewCell.cxx  |    3 -
 sc/source/ui/Accessibility/AccessiblePreviewTable.cxx |    8 +--
 sc/source/ui/Accessibility/AccessibleText.cxx         |   18 ++------
 sc/source/ui/app/transobj.cxx                         |    3 -
 sc/source/ui/docshell/docsh.cxx                       |    6 --
 sc/source/ui/drawfunc/fusel2.cxx                      |    2 
 sc/source/ui/miscdlgs/autofmt.cxx                     |   40 +++++++++---------
 sc/source/ui/unoobj/afmtuno.cxx                       |    2 
 sc/source/ui/unoobj/cellsuno.cxx                      |    4 -
 sc/source/ui/view/cellsh2.cxx                         |    4 -
 sc/source/ui/view/dbfunc.cxx                          |   12 +----
 sc/source/ui/view/dbfunc3.cxx                         |    4 -
 sc/source/ui/view/gridwin.cxx                         |   11 +---
 sc/source/ui/view/gridwin4.cxx                        |    5 --
 sc/source/ui/view/output.cxx                          |   27 +++++-------
 sc/source/ui/view/output2.cxx                         |   10 +---
 sc/source/ui/view/tabview.cxx                         |    4 -
 sc/source/ui/view/tabview2.cxx                        |   10 +---
 sc/source/ui/view/tabview3.cxx                        |    9 +---
 sc/source/ui/view/tabvwsha.cxx                        |    5 --
 sc/source/ui/view/viewdata.cxx                        |    5 --
 sc/source/ui/view/viewfun2.cxx                        |    4 -
 sc/source/ui/view/viewfunc.cxx                        |    4 -
 48 files changed, 178 insertions(+), 203 deletions(-)

New commits:
commit e3308af401013713bbfe27b6df9952586c52f4aa
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Feb 2 12:41:42 2018 +0200

    TypedWhichId in sc
    
    Change-Id: I43558191f65bfb07abfbc92970629d5dd561a04e
    Reviewed-on: https://gerrit.libreoffice.org/49141
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/autoform.hxx b/sc/inc/autoform.hxx
index bb9b886f3e44..b1559dc264de 100644
--- a/sc/inc/autoform.hxx
+++ b/sc/inc/autoform.hxx
@@ -290,6 +290,10 @@ public:
     void            SetIncludeWidthHeight( bool bWidthHeight )  { bIncludeWidthHeight = bWidthHeight; }
 
     const SfxPoolItem*          GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const;
+    template<class T> const T*  GetItem( sal_uInt16 nIndex, TypedWhichId<T> nWhich ) const
+    {
+        return static_cast<const T*>(GetItem(nIndex, sal_uInt16(nWhich)));
+    }
     void                        PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem );
     void                        CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich );
 
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 67dbda8dc8dd..ff22791b6f7c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -447,6 +447,10 @@ public:
         sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
 
     const SfxPoolItem&      GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
+    template<class T> const T&  GetAttr( SCROW nRow, TypedWhichId<T> nWhich ) const
+    {
+        return static_cast<const T&>(GetAttr(nRow, sal_uInt16(nWhich)));
+    }
     const ScPatternAttr*    GetPattern( SCROW nRow ) const;
     const ScPatternAttr*    GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const;
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 10b2bd45213f..baddf99786c4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -41,6 +41,7 @@
 #include <svl/hint.hxx>
 #include <tools/gen.hxx>
 #include <svl/zforlist.hxx>
+#include <svl/typedwhich.hxx>
 
 #include <cassert>
 #include <memory>
@@ -1618,7 +1619,15 @@ public:
                                               double& rResult );
 
     SC_DLLPUBLIC const SfxPoolItem*         GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
+    template<class T> const T*              GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
+    {
+        return static_cast<const T*>(GetAttr(nCol, nRow, nTab, sal_uInt16(nWhich)));
+    }
     SC_DLLPUBLIC const SfxPoolItem*         GetAttr( const ScAddress& rPos, sal_uInt16 nWhich ) const;
+    template<class T> const T*              GetAttr( const ScAddress& rPos, TypedWhichId<T> nWhich ) const
+    {
+        return static_cast<const T*>(GetAttr(rPos, sal_uInt16(nWhich)));
+    }
     SC_DLLPUBLIC const ScPatternAttr*       GetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
     SC_DLLPUBLIC const ScPatternAttr*       GetPattern( const ScAddress& rPos ) const;
     SC_DLLPUBLIC const ScPatternAttr*       GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
@@ -1633,6 +1642,10 @@ public:
                                                            const ScConditionalFormatList& rList,
                                                            const std::vector<sal_uInt32>& rIndex ) const;
     const SfxPoolItem*                      GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const;
+    template<class T> const T*              GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const
+    {
+        return static_cast<const T*>(GetEffItem(nCol, nRow, nTab, sal_uInt16(nWhich)));
+    }
 
     SC_DLLPUBLIC const css::uno::Reference< css::i18n::XBreakIterator >& GetBreakIterator();
     bool                        HasStringWeakCharacters( const OUString& rString );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 9698b4fbc462..c3c65a0b81d5 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -675,6 +675,10 @@ public:
     void SetMergedCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
 
     const SfxPoolItem*      GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const;
+    template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, TypedWhichId<T> nWhich ) const
+    {
+        return static_cast<const T*>(GetAttr(nCol, nRow, sal_uInt16(nWhich)));
+    }
     const ScPatternAttr*    GetPattern( SCCOL nCol, SCROW nRow ) const;
     const ScPatternAttr*    GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const;
 
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index f23786355671..24b93c5e6a8f 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -1270,7 +1270,7 @@ void checkCellValidity( const ScAddress& rValBaseAddr, const ScRange& rRange, co
     SCROW nBRow( rValBaseAddr.Row() );
     SCTAB nTab( static_cast<sal_Int32>(rValBaseAddr.Tab()) );
     //get from the document the data validation entry we are checking against
-    const SfxUInt32Item* pItem = static_cast<const SfxUInt32Item*>(rDoc.GetAttr(nBCol, nBRow, nTab, ATTR_VALIDDATA) );
+    const SfxUInt32Item* pItem = rDoc.GetAttr(nBCol, nBRow, nTab, ATTR_VALIDDATA);
     const ScValidationData* pValData = rDoc.GetValidationEntry( pItem->GetValue() );
     CPPUNIT_ASSERT(pValData);
 
@@ -1279,7 +1279,7 @@ void checkCellValidity( const ScAddress& rValBaseAddr, const ScRange& rRange, co
     {
         for(SCROW j = rRange.aStart.Row(); j <= rRange.aEnd.Row(); ++j)
         {
-            const SfxUInt32Item* pItemTest = static_cast<const SfxUInt32Item*>( rDoc.GetAttr(i, j, nTab, ATTR_VALIDDATA) );
+            const SfxUInt32Item* pItemTest = rDoc.GetAttr(i, j, nTab, ATTR_VALIDDATA);
             const ScValidationData* pValDataTest = rDoc.GetValidationEntry( pItemTest->GetValue() );
             //prevent string operations for occurring unnecessarily
             if(!(pValDataTest && pValData->GetKey() == pValDataTest->GetKey()))
@@ -3402,7 +3402,7 @@ namespace {
 
 void checkValidationFormula(const ScAddress& rPos, const ScDocument& rDoc, const OUString& rExpectedFormula)
 {
-    const SfxUInt32Item* pItem = static_cast<const SfxUInt32Item*>(rDoc.GetAttr(rPos, ATTR_VALIDDATA) );
+    const SfxUInt32Item* pItem = rDoc.GetAttr(rPos, ATTR_VALIDDATA);
     CPPUNIT_ASSERT(pItem);
     sal_uLong nKey = pItem->GetValue();
     const ScValidationData* pData = rDoc.GetValidationEntry(nKey);
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7c47940cc7bd..7651a65a448f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3611,9 +3611,7 @@ void Test::testCopyPasteSkipEmpty()
                     return false;
                 }
 
-                const SvxBrushItem* pBrush =
-                    dynamic_cast<const SvxBrushItem*>(mpDoc->GetAttr(aPos, ATTR_BACKGROUND));
-
+                const SvxBrushItem* pBrush = mpDoc->GetAttr(aPos, ATTR_BACKGROUND);
                 if (!pBrush)
                 {
                     cerr << aPosStr << ": failed to get brush item from the cell." << endl;
diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx
index 6bdabb5bdc82..1f35be3fe9c8 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -335,7 +335,7 @@ bool CopyFromClipContext::isCloneNotes() const
 
 bool CopyFromClipContext::isDateCell( const ScColumn& rCol, SCROW nRow ) const
 {
-    sal_uLong nNumIndex = static_cast<const SfxUInt32Item&>(rCol.GetAttr(nRow, ATTR_VALUE_FORMAT)).GetValue();
+    sal_uLong nNumIndex = rCol.GetAttr(nRow, ATTR_VALUE_FORMAT).GetValue();
     SvNumFormatType nType = mpClipDoc->GetFormatTable()->GetType(nNumIndex);
     return (nType == SvNumFormatType::DATE) || (nType == SvNumFormatType::TIME) || (nType == SvNumFormatType::DATETIME);
 }
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 71c9da711428..412d62385dcb 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1236,7 +1236,7 @@ namespace {
 
 bool canCopyValue(const ScDocument& rDoc, const ScAddress& rPos, InsertDeleteFlags nFlags)
 {
-    sal_uInt32 nNumIndex = static_cast<const SfxUInt32Item*>(rDoc.GetAttr(rPos, ATTR_VALUE_FORMAT))->GetValue();
+    sal_uInt32 nNumIndex = rDoc.GetAttr(rPos, ATTR_VALUE_FORMAT)->GetValue();
     SvNumFormatType nType = rDoc.GetFormatTable()->GetType(nNumIndex);
     if ((nType == SvNumFormatType::DATE) || (nType == SvNumFormatType::TIME) || (nType == SvNumFormatType::DATETIME))
         return ((nFlags & InsertDeleteFlags::DATETIME) != InsertDeleteFlags::NONE);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 29924084437b..3343ea782383 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -654,8 +654,8 @@ public:
 
     bool isDateTime(size_t position)
     {
-        SvNumFormatType nType = mrDoc.GetFormatTable()->GetType(static_cast<const SfxUInt32Item&>(
-                          mrCol.GetAttr(position, ATTR_VALUE_FORMAT)).GetValue());
+        SvNumFormatType nType = mrDoc.GetFormatTable()->GetType(
+                          mrCol.GetAttr(position, ATTR_VALUE_FORMAT).GetValue());
 
         return (nType == SvNumFormatType::DATE) || (nType == SvNumFormatType::TIME) ||
                (nType == SvNumFormatType::DATETIME);
@@ -2785,7 +2785,7 @@ class MaxStringLenHandler
     {
         Color* pColor;
         OUString aString;
-        sal_uInt32 nFormat = static_cast<const SfxUInt32Item&>(mrColumn.GetAttr(nRow, ATTR_VALUE_FORMAT)).GetValue();
+        sal_uInt32 nFormat = mrColumn.GetAttr(nRow, ATTR_VALUE_FORMAT).GetValue();
         ScCellFormat::GetString(rCell, nFormat, aString, &pColor, *mpFormatter, mrColumn.GetDoc());
         sal_Int32 nLen = 0;
         if (mbOctetEncoding)
@@ -2891,8 +2891,8 @@ class MaxNumStringLenHandler
         OUString aString;
         OUString aSep;
         sal_uInt16 nPrec;
-        sal_uInt32 nFormat = static_cast<const SfxUInt32Item&>(
-                mrColumn.GetAttr(nRow, ATTR_VALUE_FORMAT)).GetValue();
+        sal_uInt32 nFormat =
+                mrColumn.GetAttr(nRow, ATTR_VALUE_FORMAT).GetValue();
         if (nFormat % SV_COUNTRY_LANGUAGE_OFFSET)
         {
             aSep = mpFormatter->GetFormatDecimalSep(nFormat);
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index e5262cd23d89..02df3af02fa3 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1486,9 +1486,7 @@ bool ScDocument::HasAutoFilter( SCCOL nCurCol, SCROW nCurRow, SCTAB nCurTab )
 
             for ( nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAutoFilter; nCol++ )
             {
-                nFlag = static_cast<const ScMergeFlagAttr*>(
-                            GetAttr( nCol, nRow, nCurTab, ATTR_MERGE_FLAG ))->
-                                GetValue();
+                nFlag = GetAttr( nCol, nRow, nCurTab, ATTR_MERGE_FLAG )->GetValue();
 
                 if ( !(nFlag & ScMF::Auto) )
                     bHasAutoFilter = false;
@@ -1603,7 +1601,7 @@ void ScDocument::GetDataEntries(
         /*  Try to generate the list from list validation. This part is skipped,
             if bLimit==true, because in that case this function is called to get
             cell values for auto completion on input. */
-        sal_uInt32 nValidation = static_cast< const SfxUInt32Item* >( GetAttr( nCol, nRow, nTab, ATTR_VALIDDATA ) )->GetValue();
+        sal_uInt32 nValidation = GetAttr( nCol, nRow, nTab, ATTR_VALIDDATA )->GetValue();
         if( nValidation )
         {
             const ScValidationData* pData = GetValidationEntry( nValidation );
@@ -2060,8 +2058,7 @@ void ScDocument::DoMerge( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
 
 void ScDocument::RemoveMerge( SCCOL nCol, SCROW nRow, SCTAB nTab )
 {
-    const ScMergeAttr* pAttr = static_cast<const ScMergeAttr*>(
-                                    GetAttr( nCol, nRow, nTab, ATTR_MERGE ));
+    const ScMergeAttr* pAttr = GetAttr( nCol, nRow, nTab, ATTR_MERGE );
 
     if ( pAttr->GetColMerge() <= 1 && pAttr->GetRowMerge() <= 1 )
         return;
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index fd0146242d04..8a0753382e94 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -853,7 +853,7 @@ ScConditionalFormat* ScDocument::GetCondFormat(
                             SCCOL nCol, SCROW nRow, SCTAB nTab ) const
 {
     sal_uInt32 nIndex = 0;
-    const std::vector<sal_uInt32>& rCondFormats = static_cast<const ScCondFormatItem*>(GetAttr(nCol, nRow, nTab, ATTR_CONDITIONAL))->GetCondFormatData();
+    const std::vector<sal_uInt32>& rCondFormats = GetAttr(nCol, nRow, nTab, ATTR_CONDITIONAL)->GetCondFormatData();
 
     if(!rCondFormats.empty())
         nIndex = rCondFormats[0];
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 44bef6c0310e..7d1f821de849 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3810,7 +3810,7 @@ bool ScDocument::HasStringCells( const ScRange& rRange ) const
 
 bool ScDocument::HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
 {
-    sal_uInt32 nValidation = static_cast< const SfxUInt32Item* >( GetAttr( nCol, nRow, nTab, ATTR_VALIDDATA ) )->GetValue();
+    sal_uInt32 nValidation = GetAttr( nCol, nRow, nTab, ATTR_VALIDDATA )->GetValue();
     if( nValidation )
     {
         const ScValidationData* pData = GetValidationEntry( nValidation );
@@ -3822,7 +3822,7 @@ bool ScDocument::HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
 
 bool ScDocument::HasValidationData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
 {
-    sal_uInt32 nValidation = static_cast< const SfxUInt32Item* >( GetAttr( nCol, nRow, nTab, ATTR_VALIDDATA ) )->GetValue();
+    sal_uInt32 nValidation = GetAttr( nCol, nRow, nTab, ATTR_VALIDDATA )->GetValue();
     if( nValidation )
     {
         const ScValidationData* pData = GetValidationEntry( nValidation );
@@ -5218,7 +5218,7 @@ void ScDocument::GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab,
 {
     //TODO: consider page limits for printing !!!!!
 
-    const SvxBoxItem* pThisAttr = static_cast<const SvxBoxItem*>( GetEffItem( nCol, nRow, nTab, ATTR_BORDER ) );
+    const SvxBoxItem* pThisAttr = GetEffItem( nCol, nRow, nTab, ATTR_BORDER );
     OSL_ENSURE(pThisAttr,"where is the attribute?");
 
     const SvxBorderLine* pLeftLine   = pThisAttr->GetLeft();
@@ -5228,29 +5228,25 @@ void ScDocument::GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab,
 
     if ( nCol > 0 )
     {
-        const SvxBorderLine* pOther = static_cast<const SvxBoxItem*>(
-                                GetEffItem( nCol-1, nRow, nTab, ATTR_BORDER ))->GetRight();
+        const SvxBorderLine* pOther = GetEffItem( nCol-1, nRow, nTab, ATTR_BORDER )->GetRight();
         if ( ScHasPriority( pOther, pLeftLine ) )
             pLeftLine = pOther;
     }
     if ( nRow > 0 )
     {
-        const SvxBorderLine* pOther = static_cast<const SvxBoxItem*>(
-                                GetEffItem( nCol, nRow-1, nTab, ATTR_BORDER ))->GetBottom();
+        const SvxBorderLine* pOther = GetEffItem( nCol, nRow-1, nTab, ATTR_BORDER )->GetBottom();
         if ( ScHasPriority( pOther, pTopLine ) )
             pTopLine = pOther;
     }
     if ( nCol < MAXCOL )
     {
-        const SvxBorderLine* pOther = static_cast<const SvxBoxItem*>(
-                                GetEffItem( nCol+1, nRow, nTab, ATTR_BORDER ))->GetLeft();
+        const SvxBorderLine* pOther = GetEffItem( nCol+1, nRow, nTab, ATTR_BORDER )->GetLeft();
         if ( ScHasPriority( pOther, pRightLine ) )
             pRightLine = pOther;
     }
     if ( nRow < MAXROW )
     {
-        const SvxBorderLine* pOther = static_cast<const SvxBoxItem*>(
-                                GetEffItem( nCol, nRow+1, nTab, ATTR_BORDER ))->GetTop();
+        const SvxBorderLine* pOther = GetEffItem( nCol, nRow+1, nTab, ATTR_BORDER )->GetTop();
         if ( ScHasPriority( pOther, pBottomLine ) )
             pBottomLine = pOther;
     }
@@ -5446,8 +5442,7 @@ void ScDocument::ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow,
             SCCOL nOldCol = rStartCol;
             SCROW nOldRow = rStartRow;
             for (nCol=nOldCol; nCol<=nEndCol; nCol++)
-                while (static_cast<const ScMergeFlagAttr*>(GetAttr(nCol,rStartRow,nTab,ATTR_MERGE_FLAG))->
-                            IsVerOverlapped())
+                while (GetAttr(nCol,rStartRow,nTab,ATTR_MERGE_FLAG)->IsVerOverlapped())
                     --rStartRow;
 
             //TODO: pass on ?
@@ -5477,8 +5472,7 @@ void ScDocument::ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow,
                         SCCOL nTempCol = nOldCol;
                         do
                             --nTempCol;
-                        while (static_cast<const ScMergeFlagAttr*>(GetAttr(nTempCol,nAttrRow,nTab,ATTR_MERGE_FLAG))
-                                ->IsHorOverlapped());
+                        while (GetAttr(nTempCol,nAttrRow,nTab,ATTR_MERGE_FLAG)->IsHorOverlapped());
                         if (nTempCol < rStartCol)
                             rStartCol = nTempCol;
                     }
@@ -5690,8 +5684,7 @@ void ScDocument::SkipOverlapped( SCCOL& rCol, SCROW& rRow, SCTAB nTab ) const
 
 bool ScDocument::IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
 {
-    const ScMergeFlagAttr* pAttr = static_cast<const ScMergeFlagAttr*>(
-                                        GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ));
+    const ScMergeFlagAttr* pAttr = GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG );
     if (pAttr)
         return pAttr->IsHorOverlapped();
     else
@@ -5703,8 +5696,7 @@ bool ScDocument::IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
 
 bool ScDocument::IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
 {
-    const ScMergeFlagAttr* pAttr = static_cast<const ScMergeFlagAttr*>(
-                                        GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ));
+    const ScMergeFlagAttr* pAttr = GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG );
     if (pAttr)
         return pAttr->IsVerOverlapped();
     else
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 963de1d40987..0bafb21b85ca 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -945,7 +945,7 @@ ScRange ScDPObject::GetOutputRangeByType( sal_Int32 nType ) const
 
 static bool lcl_HasButton( const ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab )
 {
-    return static_cast<const ScMergeFlagAttr*>(pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->HasPivotButton();
+    return pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG )->HasPivotButton();
 }
 
 void ScDPObject::RefreshAfterLoad()
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 2a22505bbc99..7c1893dedd87 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1735,7 +1735,7 @@ tools::Rectangle ScDrawLayer::GetCellRect( const ScDocument& rDoc, const ScAddre
         ScAddress aEndPos = rPos;
         if( bMergedCell )
         {
-            const ScMergeAttr* pMerge = static_cast< const ScMergeAttr* >( rDoc.GetAttr( rPos.Col(), rPos.Row(), rPos.Tab(), ATTR_MERGE ) );
+            const ScMergeAttr* pMerge = rDoc.GetAttr( rPos, ATTR_MERGE );
             if( pMerge->GetColMerge() > 1 )
                 aEndPos.IncCol( pMerge->GetColMerge() - 1 );
             if( pMerge->GetRowMerge() > 1 )
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 69a12b261736..1e3f2c480abc 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -72,8 +72,7 @@ static void lcl_GetMergeRange( SCCOL nX, SCROW nY, SCSIZE nArrY,
         }
         else
         {
-            ScMF nOverlap = static_cast<const ScMergeFlagAttr*>(pDoc->GetAttr(
-                                rStartX, rStartY, nTab, ATTR_MERGE_FLAG ))->GetValue();
+            ScMF nOverlap = pDoc->GetAttr( rStartX, rStartY, nTab, ATTR_MERGE_FLAG )->GetValue();
             bHOver = bool(nOverlap & ScMF::Hor);
             bVOver = bool(nOverlap & ScMF::Ver);
         }
@@ -95,8 +94,8 @@ static void lcl_GetMergeRange( SCCOL nX, SCROW nY, SCSIZE nArrY,
         }
         else
         {
-            ScMF nOverlap = static_cast<const ScMergeFlagAttr*>(pDoc->GetAttr(
-                                rStartX, rStartY, nTab, ATTR_MERGE_FLAG ))->GetValue();
+            ScMF nOverlap = pDoc->GetAttr(
+                                rStartX, rStartY, nTab, ATTR_MERGE_FLAG )->GetValue();
             bVOver = bool(nOverlap & ScMF::Ver);
         }
     }
@@ -111,7 +110,7 @@ static void lcl_GetMergeRange( SCCOL nX, SCROW nY, SCSIZE nArrY,
                                         GetItem(ATTR_MERGE);
     }
     else
-        pMerge = static_cast<const ScMergeAttr*>( pDoc->GetAttr(rStartX,rStartY,nTab,ATTR_MERGE) );
+        pMerge = pDoc->GetAttr(rStartX,rStartY,nTab,ATTR_MERGE);
 
     rEndX = rStartX + pMerge->GetColMerge() - 1;
     rEndY = rStartY + pMerge->GetRowMerge() - 1;
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 21d8dd015d59..ebaefc38f7d3 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2100,8 +2100,8 @@ void ScFormulaCell::InterpretTail( ScInterpreterContext& rContext, ScInterpretTa
 
         if ( pCode->IsRecalcModeForced() )
         {
-            sal_uLong nValidation = static_cast<const SfxUInt32Item*>(pDocument->GetAttr(
-                    aPos.Col(), aPos.Row(), aPos.Tab(), ATTR_VALIDDATA ))->GetValue();
+            sal_uLong nValidation = pDocument->GetAttr(
+                    aPos.Col(), aPos.Row(), aPos.Tab(), ATTR_VALIDDATA )->GetValue();
             if ( nValidation )
             {
                 const ScValidationData* pData = pDocument->GetValidationEntry( nValidation );
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 428dbc41b081..2e2c2af05aca 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1299,8 +1299,7 @@ bool ScTable::ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
     if (bMarked && !rMark.IsCellMarked(nCol,nRow))
         return false;
 
-    if (bUnprotected && static_cast<const ScProtectionAttr*>(
-                        GetAttr(nCol,nRow,ATTR_PROTECTION))->GetProtection())
+    if (bUnprotected && GetAttr(nCol,nRow,ATTR_PROTECTION)->GetProtection())
         return false;
 
     if (bMarked || bUnprotected)        //TODO: also in other case ???
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 805915768a4d..15aadf998d11 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -261,7 +261,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
     if (eCellType == CELLTYPE_VALUE)
     {
         double fVal;
-        sal_uInt32 nFormat = static_cast<const SfxUInt32Item*>(GetAttr(nCol,nRow,ATTR_VALUE_FORMAT))->GetValue();
+        sal_uInt32 nFormat = GetAttr(nCol,nRow,ATTR_VALUE_FORMAT)->GetValue();
         const SvNumFormatType nFormatType = pDocument->GetFormatTable()->GetType(nFormat);
         bool bDate = (nFormatType  == SvNumFormatType::DATE );
         bool bBooleanCell = (!bDate && nFormatType == SvNumFormatType::LOGICAL);
@@ -2115,11 +2115,11 @@ void ScTable::GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAut
 
 void ScTable::GetAutoFormatFrame(SCCOL nCol, SCROW nRow, sal_uInt16 nFlags, sal_uInt16 nIndex, ScAutoFormatData& rData)
 {
-    const SvxBoxItem* pTheBox = static_cast<const SvxBoxItem*>(GetAttr(nCol, nRow, ATTR_BORDER));
-    const SvxBoxItem* pLeftBox = static_cast<const SvxBoxItem*>(GetAttr(nCol - 1, nRow, ATTR_BORDER));
-    const SvxBoxItem* pTopBox = static_cast<const SvxBoxItem*>(GetAttr(nCol, nRow - 1, ATTR_BORDER));
-    const SvxBoxItem* pRightBox = static_cast<const SvxBoxItem*>(GetAttr(nCol + 1, nRow, ATTR_BORDER));
-    const SvxBoxItem* pBottomBox = static_cast<const SvxBoxItem*>(GetAttr(nCol, nRow + 1, ATTR_BORDER));
+    const SvxBoxItem* pTheBox = GetAttr(nCol, nRow, ATTR_BORDER);
+    const SvxBoxItem* pLeftBox = GetAttr(nCol - 1, nRow, ATTR_BORDER);
+    const SvxBoxItem* pTopBox = GetAttr(nCol, nRow - 1, ATTR_BORDER);
+    const SvxBoxItem* pRightBox = GetAttr(nCol + 1, nRow, ATTR_BORDER);
+    const SvxBoxItem* pBottomBox = GetAttr(nCol, nRow + 1, ATTR_BORDER);
 
     SvxBoxItem aBox( ATTR_BORDER );
     if (nFlags & LF_LEFT)
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index ceab0289184f..e99c549d51dd 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2296,8 +2296,7 @@ void ScInterpreter::ScCell()
                 sal_Unicode c = 0;
                 if (aCell.hasString())
                 {
-                    const SvxHorJustifyItem* pJustAttr = static_cast<const SvxHorJustifyItem*>(
-                        pDok->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_HOR_JUSTIFY ));
+                    const SvxHorJustifyItem* pJustAttr = pDok->GetAttr( aCellPos, ATTR_HOR_JUSTIFY );
                     switch( pJustAttr->GetValue() )
                     {
                         case SvxCellHorJustify::Standard:
@@ -2312,8 +2311,7 @@ void ScInterpreter::ScCell()
             }
             else if( aInfoType == "PROTECT" )
             {   // 1 = cell locked
-                const ScProtectionAttr* pProtAttr = static_cast<const ScProtectionAttr*>(
-                    pDok->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_PROTECTION ));
+                const ScProtectionAttr* pProtAttr = pDok->GetAttr( aCellPos, ATTR_PROTECTION );
                 PushInt( pProtAttr->GetProtection() ? 1 : 0 );
             }
 
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 456468654007..aa3e630f5d09 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -532,7 +532,7 @@ void XclImpAutoFilterData::SetCellAttribs()
     ScDocument& rDoc = pExcRoot->pIR->GetDoc();
     for ( SCCOL nCol = StartCol(); nCol <= EndCol(); nCol++ )
     {
-        ScMF nFlag = static_cast<const ScMergeFlagAttr*>( rDoc.GetAttr( nCol, StartRow(), Tab(), ATTR_MERGE_FLAG ))->GetValue();
+        ScMF nFlag = rDoc.GetAttr( nCol, StartRow(), Tab(), ATTR_MERGE_FLAG )->GetValue();
         rDoc.ApplyAttr( nCol, StartRow(), Tab(), ScMergeFlagAttr( nFlag | ScMF::Auto) );
     }
 }
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index d28ac2fc2853..7cafcf70e7fd 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -1952,10 +1952,10 @@ void XclImpXFRangeBuffer::SetBorderLine( const ScRange& rRange, SCTAB nScTab, Sv
     SCROW nFromScRow = (nLine == SvxBoxItemLine::BOTTOM) ? rRange.aEnd.Row() : rRange.aStart.Row();
     ScDocument& rDoc = GetDoc();
 
-    const SvxBoxItem* pFromItem = static_cast< const SvxBoxItem* >(
-        rDoc.GetAttr( nFromScCol, nFromScRow, nScTab, ATTR_BORDER ) );
-    const SvxBoxItem* pToItem = static_cast< const SvxBoxItem* >(
-        rDoc.GetAttr( rRange.aStart.Col(), rRange.aStart.Row(), nScTab, ATTR_BORDER ) );
+    const SvxBoxItem* pFromItem =
+        rDoc.GetAttr( nFromScCol, nFromScRow, nScTab, ATTR_BORDER );
+    const SvxBoxItem* pToItem =
+        rDoc.GetAttr( rRange.aStart.Col(), rRange.aStart.Row(), nScTab, ATTR_BORDER );
 
     SvxBoxItem aNewItem( *pToItem );
     aNewItem.SetLine( pFromItem->GetLine( nLine ), nLine );
@@ -2046,7 +2046,7 @@ void XclImpXFRangeBuffer::Finalize()
         // #i93609# merged range in a single row: test if manual row height is needed
         if( !bMultiRow )
         {
-            bool bTextWrap = static_cast<const SfxBoolItem*>( rDoc.getDoc().GetAttr( rStart.Col(), rStart.Row(), rStart.Tab(), ATTR_LINEBREAK ) )->GetValue();
+            bool bTextWrap = rDoc.getDoc().GetAttr( rStart, ATTR_LINEBREAK )->GetValue();
             if( !bTextWrap && (rDoc.getDoc().GetCellType( rStart ) == CELLTYPE_EDIT) )
                 if (const EditTextObject* pEditObj = rDoc.getDoc().GetEditText(rStart))
                     bTextWrap = pEditObj->GetParagraphCount() > 1;
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index 8f660d017dd8..46a25549db44 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -881,7 +881,7 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
     OStringBuffer aStrTD(OOO_STRING_SVTOOLS_HTML_tabledata);
 
     // border of the cells
-    const SvxBoxItem* pBorder = static_cast<const SvxBoxItem*>( pDoc->GetAttr( nCol, nRow, nTab, ATTR_BORDER ) );
+    const SvxBoxItem* pBorder = pDoc->GetAttr( nCol, nRow, nTab, ATTR_BORDER );
     if ( pBorder && (pBorder->GetTop() || pBorder->GetBottom() || pBorder->GetLeft() || pBorder->GetRight()) )
     {
         aStrTD.append(' ').append(OOO_STRING_SVTOOLS_HTML_style).
diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx
index 72d56b4d9126..e689c0e18492 100644
--- a/sc/source/filter/html/htmlimp.cxx
+++ b/sc/source/filter/html/htmlimp.cxx
@@ -128,25 +128,24 @@ void ScHTMLImport::WriteToDocument(
         if( (pEntry->nColOverlap > 1) || (pEntry->nRowOverlap > 1) )
         {
             SCTAB nTab = maRange.aStart.Tab();
-            const ScMergeAttr* pItem = static_cast<const ScMergeAttr*>( mpDoc->GetAttr( pEntry->nCol, pEntry->nRow, nTab, ATTR_MERGE ) );
+            const ScMergeAttr* pItem = mpDoc->GetAttr( pEntry->nCol, pEntry->nRow, nTab, ATTR_MERGE );
             if( pItem->IsMerged() )
             {
                 SCCOL nColMerge = pItem->GetColMerge();
                 SCROW nRowMerge = pItem->GetRowMerge();
 
-                const SvxBoxItem* pToItem = static_cast<const SvxBoxItem*>(
-                    mpDoc->GetAttr( pEntry->nCol, pEntry->nRow, nTab, ATTR_BORDER ) );
+                const SvxBoxItem* pToItem = mpDoc->GetAttr( pEntry->nCol, pEntry->nRow, nTab, ATTR_BORDER );
                 SvxBoxItem aNewItem( *pToItem );
                 if( nColMerge > 1 )
                 {
-                    const SvxBoxItem* pFromItem = static_cast<const SvxBoxItem*>(
-                        mpDoc->GetAttr( pEntry->nCol + nColMerge - 1, pEntry->nRow, nTab, ATTR_BORDER ) );
+                    const SvxBoxItem* pFromItem =
+                        mpDoc->GetAttr( pEntry->nCol + nColMerge - 1, pEntry->nRow, nTab, ATTR_BORDER );
                     aNewItem.SetLine( pFromItem->GetLine( SvxBoxItemLine::RIGHT ), SvxBoxItemLine::RIGHT );
                 }
                 if( nRowMerge > 1 )
                 {
-                    const SvxBoxItem* pFromItem = static_cast<const SvxBoxItem*>(
-                        mpDoc->GetAttr( pEntry->nCol, pEntry->nRow + nRowMerge - 1, nTab, ATTR_BORDER ) );
+                    const SvxBoxItem* pFromItem =
+                        mpDoc->GetAttr( pEntry->nCol, pEntry->nRow + nRowMerge - 1, nTab, ATTR_BORDER );
                     aNewItem.SetLine( pFromItem->GetLine( SvxBoxItemLine::BOTTOM ), SvxBoxItemLine::BOTTOM );
                 }
                 mpDoc->ApplyAttr( pEntry->nCol, pEntry->nRow, nTab, aNewItem );
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index 66daf08139f8..d9d98b84532d 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -721,10 +721,10 @@ void lcl_SetBorderLine( ScDocument& rDoc, const ScRange& rRange, SCTAB nScTab, S
     SCCOL nFromScCol = (nLine == SvxBoxItemLine::RIGHT) ? rRange.aEnd.Col() : rRange.aStart.Col();
     SCROW nFromScRow = (nLine == SvxBoxItemLine::BOTTOM) ? rRange.aEnd.Row() : rRange.aStart.Row();
 
-    const SvxBoxItem* pFromItem = static_cast< const SvxBoxItem* >(
-        rDoc.GetAttr( nFromScCol, nFromScRow, nScTab, ATTR_BORDER ) );
-    const SvxBoxItem* pToItem = static_cast< const SvxBoxItem* >(
-        rDoc.GetAttr( rRange.aStart.Col(), rRange.aStart.Row(), nScTab, ATTR_BORDER ) );
+    const SvxBoxItem* pFromItem =
+        rDoc.GetAttr( nFromScCol, nFromScRow, nScTab, ATTR_BORDER );
+    const SvxBoxItem* pToItem =
+        rDoc.GetAttr( rRange.aStart.Col(), rRange.aStart.Row(), nScTab, ATTR_BORDER );
 
     SvxBoxItem aNewItem( *pToItem );
     aNewItem.SetLine( pFromItem->GetLine( nLine ), nLine );
diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx
index 97926be476d4..e589d1dbfa24 100644
--- a/sc/source/ui/Accessibility/AccessibleCell.cxx
+++ b/sc/source/ui/Accessibility/AccessibleCell.cxx
@@ -193,8 +193,7 @@ tools::Rectangle ScAccessibleCell::GetBoundingBox() const
             simply expand the cell size to the width of the unrotated text. */
         if (mpDoc)
         {
-            const SfxInt32Item* pItem = static_cast< const SfxInt32Item* >(
-                mpDoc->GetAttr( maCellAddress.Col(), maCellAddress.Row(), maCellAddress.Tab(), ATTR_ROTATE_VALUE ) );
+            const SfxInt32Item* pItem = mpDoc->GetAttr( maCellAddress, ATTR_ROTATE_VALUE );
             if( pItem && (pItem->GetValue() != 0) )
             {
                 tools::Rectangle aParaRect = GetParagraphBoundingBox();
@@ -328,9 +327,7 @@ bool ScAccessibleCell::IsEditable(
         mpDoc)
     {
         // here I have to test whether the protection of the table should influence this cell.
-        const ScProtectionAttr* pItem = static_cast<const ScProtectionAttr*>(mpDoc->GetAttr(
-            maCellAddress.Col(), maCellAddress.Row(),
-            maCellAddress.Tab(), ATTR_PROTECTION));
+        const ScProtectionAttr* pItem = mpDoc->GetAttr(maCellAddress, ATTR_PROTECTION);
         if (pItem)
             bEditable = !pItem->GetProtection();
     }
@@ -343,9 +340,7 @@ bool ScAccessibleCell::IsOpaque()
     bool bOpaque(true);
     if (mpDoc)
     {
-        const SvxBrushItem* pItem = static_cast<const SvxBrushItem*>(mpDoc->GetAttr(
-            maCellAddress.Col(), maCellAddress.Row(),
-            maCellAddress.Tab(), ATTR_BACKGROUND));
+        const SvxBrushItem* pItem = mpDoc->GetAttr(maCellAddress, ATTR_BACKGROUND);
         if (pItem)
             bOpaque = pItem->GetColor() != COL_TRANSPARENT;
     }
@@ -536,7 +531,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScAccessibleCell::getCharacterAtt
     uno::Sequence< beans::PropertyValue > aAttribs = AccessibleStaticTextBase::getCharacterAttributes( nIndex, aRequestedAttributes );
     beans::PropertyValue *pAttribs = aAttribs.getArray();
 
-    sal_uInt16 nParaIndent = static_cast< const SfxUInt16Item* >( mpDoc->GetAttr( maCellAddress.Col(), maCellAddress.Row(), maCellAddress.Tab(), ATTR_INDENT ) )->GetValue();
+    sal_uInt16 nParaIndent = mpDoc->GetAttr( maCellAddress, ATTR_INDENT )->GetValue();
     if (nParaIndent > 0)
     {
         for (int i = 0; i < aAttribs.getLength(); ++i)
@@ -566,15 +561,14 @@ bool ScAccessibleCell::IsDropdown()
     sal_uInt16 nPosX = maCellAddress.Col();
     sal_uInt16 nPosY = sal_uInt16(maCellAddress.Row());
     sal_uInt16 nTab = maCellAddress.Tab();
-    sal_uInt32 nValidation = static_cast< const SfxUInt32Item* >( mpDoc->GetAttr( nPosX, nPosY, nTab, ATTR_VALIDDATA ) )->GetValue();
+    sal_uInt32 nValidation = mpDoc->GetAttr( nPosX, nPosY, nTab, ATTR_VALIDDATA )->GetValue();
     if( nValidation )
     {
         const ScValidationData* pData = mpDoc->GetValidationEntry( nValidation );
         if( pData && pData->HasSelectionList() )
             return true;
     }
-    const ScMergeFlagAttr* pAttr;
-    pAttr = static_cast<const ScMergeFlagAttr*>(mpDoc->GetAttr( nPosX, nPosY, nTab, ATTR_MERGE_FLAG ));
+    const ScMergeFlagAttr* pAttr = mpDoc->GetAttr( nPosX, nPosY, nTab, ATTR_MERGE_FLAG );
     if( pAttr->HasAutoFilter() )
     {
         return true;
diff --git a/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx b/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx
index 5e19e21cca27..52b5c7f12514 100644
--- a/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx
+++ b/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx
@@ -261,8 +261,7 @@ bool ScAccessiblePreviewCell::IsOpaque()
     bool bOpaque(true);
     if (mpDoc)
     {
-        const SvxBrushItem* pItem = static_cast<const SvxBrushItem*>(mpDoc->GetAttr(
-            maCellAddress.Col(), maCellAddress.Row(), maCellAddress.Tab(), ATTR_BACKGROUND));
+        const SvxBrushItem* pItem = mpDoc->GetAttr(maCellAddress, ATTR_BACKGROUND);
         if (pItem)
             bOpaque = pItem->GetColor() != COL_TRANSPARENT;
     }
diff --git a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx
index 75bd1da4ce98..912d15af153d 100644
--- a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx
+++ b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx
@@ -195,8 +195,8 @@ sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowExtentAt( sal_Int32
     else
     {
         ScDocument& rDoc = mpViewShell->GetDocument();
-        const ScMergeAttr* pItem = static_cast<const ScMergeAttr*>(rDoc.GetAttr(
-            static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE ));
+        const ScMergeAttr* pItem = rDoc.GetAttr(
+            static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE );
         if ( pItem && pItem->GetRowMerge() > 0 )
             nRows = pItem->GetRowMerge();
     }
@@ -226,8 +226,8 @@ sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnExtentAt( sal_In
     else
     {
         ScDocument& rDoc = mpViewShell->GetDocument();
-        const ScMergeAttr* pItem = static_cast<const ScMergeAttr*>(rDoc.GetAttr(
-            static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE ));
+        const ScMergeAttr* pItem = rDoc.GetAttr(
+            static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE );
         if ( pItem && pItem->GetColMerge() > 0 )
             nColumns = pItem->GetColMerge();
     }
diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx
index 2e19fb6a72c3..e904086483fc 100644
--- a/sc/source/ui/Accessibility/AccessibleText.cxx
+++ b/sc/source/ui/Accessibility/AccessibleText.cxx
@@ -710,21 +710,18 @@ SvxTextForwarder* ScAccessibleCellTextData::GetTextForwarder()
 
         // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
         long nIndent = 0;
-        const SvxHorJustifyItem* pHorJustifyItem = static_cast< const SvxHorJustifyItem* >(
-            rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_HOR_JUSTIFY ) );
+        const SvxHorJustifyItem* pHorJustifyItem = rDoc.GetAttr( aCellPos, ATTR_HOR_JUSTIFY );
         SvxCellHorJustify eHorJust = pHorJustifyItem ? pHorJustifyItem->GetValue() : SvxCellHorJustify::Standard;
         if ( eHorJust == SvxCellHorJustify::Left )
         {
-            const SfxUInt16Item* pIndentItem = static_cast< const SfxUInt16Item* >(
-                rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_INDENT ) );
+            const SfxUInt16Item* pIndentItem = rDoc.GetAttr( aCellPos, ATTR_INDENT );
             if ( pIndentItem )
             {
                 nIndent = static_cast< long >( pIndentItem->GetValue() );
             }
         }
 
-        const SvxMarginItem* pMarginItem = static_cast< const SvxMarginItem* >(
-            rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_MARGIN ) );
+        const SvxMarginItem* pMarginItem = rDoc.GetAttr( aCellPos, ATTR_MARGIN );
         ScViewData& rViewData = mpViewShell->GetViewData();
         double nPPTX = rViewData.GetPPTX();
         double nPPTY = rViewData.GetPPTY();
@@ -752,8 +749,7 @@ SvxTextForwarder* ScAccessibleCellTextData::GetTextForwarder()
             return the size of the complete text then, which is used to expand
             the cell bounding box in ScAccessibleCell::GetBoundingBox()
             (see sc/source/ui/Accessibility/AccessibleCell.cxx). */
-        const SfxInt32Item* pItem = static_cast< const SfxInt32Item* >(
-            rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_ROTATE_VALUE ) );
+        const SfxInt32Item* pItem = rDoc.GetAttr( aCellPos, ATTR_ROTATE_VALUE );
         if( pItem && (pItem->GetValue() != 0) )
         {
             pEditEngine->SetPaperSize( Size( LONG_MAX, aSize.getHeight() ) );
@@ -763,8 +759,7 @@ SvxTextForwarder* ScAccessibleCellTextData::GetTextForwarder()
         else
         {
             // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
-            const SfxBoolItem* pLineBreakItem = static_cast< const SfxBoolItem* >(
-                rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_LINEBREAK ) );
+            const SfxBoolItem* pLineBreakItem = rDoc.GetAttr( aCellPos, ATTR_LINEBREAK );
             bool bLineBreak = ( pLineBreakItem && pLineBreakItem->GetValue() );
             if ( !bLineBreak )
             {
@@ -813,8 +808,7 @@ SvxTextForwarder* ScAccessibleCellTextData::GetTextForwarder()
         }
 
         long nOffsetY = 0;
-        const SvxVerJustifyItem* pVerJustifyItem = static_cast< const SvxVerJustifyItem* >(
-            rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_VER_JUSTIFY ) );
+        const SvxVerJustifyItem* pVerJustifyItem = rDoc.GetAttr( aCellPos, ATTR_VER_JUSTIFY );
         SvxCellVerJustify eVerJust = ( pVerJustifyItem ? pVerJustifyItem->GetValue() : SvxCellVerJustify::Standard );
         switch ( eVerJust )
         {
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 258edbdce67c..c1d4f00b6a4d 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -836,8 +836,7 @@ void ScTransferObj::StripRefs( ScDocument* pDoc,
             ScAddress aPos(nCol, nRow, nDestTab);
             if (nErrCode != FormulaError::NONE)
             {
-                if ( static_cast<const SvxHorJustifyItem*>(pDestDoc->GetAttr(
-                        nCol,nRow,nDestTab, ATTR_HOR_JUSTIFY))->GetValue() ==
+                if ( pDestDoc->GetAttr( nCol,nRow,nDestTab, ATTR_HOR_JUSTIFY)->GetValue() ==
                         SvxCellHorJustify::Standard )
                     pDestDoc->ApplyAttr( nCol,nRow,nDestTab,
                             SvxHorJustifyItem(SvxCellHorJustify::Right, ATTR_HOR_JUSTIFY) );
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 358bc1a248ae..607cf964cdf9 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1979,8 +1979,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
         if ( bTabProtect )
         {
             const ScProtectionAttr* pProtAttr =
-                static_cast<const ScProtectionAttr*>( aDocument.GetAttr(
-                                                            nCol, nRow, nTab, ATTR_PROTECTION ));
+                aDocument.GetAttr( nCol, nRow, nTab, ATTR_PROTECTION );
             if ( pProtAttr->GetHideCell() ||
                     ( eType == CELLTYPE_FORMULA && bShowFormulas &&
                       pProtAttr->GetHideFormula() ) )
@@ -2081,8 +2080,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
         if ( bFixedWidth )
         {
             SvxCellHorJustify eHorJust =
-                static_cast<const SvxHorJustifyItem*>( aDocument.GetAttr( nCol, nRow,
-                nTab, ATTR_HOR_JUSTIFY ))->GetValue();
+                aDocument.GetAttr( nCol, nRow, nTab, ATTR_HOR_JUSTIFY )->GetValue();
             lcl_ScDocShell_GetFixedWidthString( aString, aDocument, nTab, nCol,
                     !bString, eHorJust );
             rStream.WriteUnicodeOrByteText( aString );
diff --git a/sc/source/ui/drawfunc/fusel2.cxx b/sc/source/ui/drawfunc/fusel2.cxx
index 6fc497ab8f0b..f9bd23f01ee9 100644
--- a/sc/source/ui/drawfunc/fusel2.cxx
+++ b/sc/source/ui/drawfunc/fusel2.cxx
@@ -140,7 +140,7 @@ bool FuSelection::IsNoteCaptionClicked( const Point& rPos ) const
                 {
                     const ScAddress& rNotePos = pCaptData->maStart;
                     // skip caption objects of notes in protected cells
-                    const ScProtectionAttr* pProtAttr =  static_cast< const ScProtectionAttr* >( rDoc.GetAttr( rNotePos.Col(), rNotePos.Row(), nTab, ATTR_PROTECTION ) );
+                    const ScProtectionAttr* pProtAttr =  rDoc.GetAttr( rNotePos.Col(), rNotePos.Row(), nTab, ATTR_PROTECTION );
                     bool bProtectAttr = pProtAttr->GetProtection() || pProtAttr->GetHideCell();
                     if( !bProtectAttr || !bProtectDoc )
                         return true;
diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx
index f8f2dae645a6..6295da610567 100644
--- a/sc/source/ui/miscdlgs/autofmt.cxx
+++ b/sc/source/ui/miscdlgs/autofmt.cxx
@@ -118,21 +118,21 @@ void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font
         rFont = rCJKFont = rCTLFont = GetFont();
         Size aFontSize( rFont.GetFontSize().Width(), 10 * GetDPIScaleFactor() );
 
-        const SvxFontItem*        pFontItem       = static_cast<const SvxFontItem*>      (pCurData->GetItem( nIndex, ATTR_FONT ));
-        const SvxWeightItem*      pWeightItem     = static_cast<const SvxWeightItem*>    (pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT ));
-        const SvxPostureItem*     pPostureItem    = static_cast<const SvxPostureItem*>   (pCurData->GetItem( nIndex, ATTR_FONT_POSTURE ));
-        const SvxFontItem*        pCJKFontItem    = static_cast<const SvxFontItem*>      (pCurData->GetItem( nIndex, ATTR_CJK_FONT ));
-        const SvxWeightItem*      pCJKWeightItem  = static_cast<const SvxWeightItem*>    (pCurData->GetItem( nIndex, ATTR_CJK_FONT_WEIGHT ));
-        const SvxPostureItem*     pCJKPostureItem = static_cast<const SvxPostureItem*>   (pCurData->GetItem( nIndex, ATTR_CJK_FONT_POSTURE ));
-        const SvxFontItem*        pCTLFontItem    = static_cast<const SvxFontItem*>      (pCurData->GetItem( nIndex, ATTR_CTL_FONT ));
-        const SvxWeightItem*      pCTLWeightItem  = static_cast<const SvxWeightItem*>    (pCurData->GetItem( nIndex, ATTR_CTL_FONT_WEIGHT ));
-        const SvxPostureItem*     pCTLPostureItem = static_cast<const SvxPostureItem*>   (pCurData->GetItem( nIndex, ATTR_CTL_FONT_POSTURE ));
-        const SvxUnderlineItem*   pUnderlineItem  = static_cast<const SvxUnderlineItem*> (pCurData->GetItem( nIndex, ATTR_FONT_UNDERLINE ));
-        const SvxOverlineItem*    pOverlineItem   = static_cast<const SvxOverlineItem*>  (pCurData->GetItem( nIndex, ATTR_FONT_OVERLINE ));
-        const SvxCrossedOutItem*  pCrossedOutItem = static_cast<const SvxCrossedOutItem*>(pCurData->GetItem( nIndex, ATTR_FONT_CROSSEDOUT ));
-        const SvxContourItem*     pContourItem    = static_cast<const SvxContourItem*>   (pCurData->GetItem( nIndex, ATTR_FONT_CONTOUR ));
-        const SvxShadowedItem*    pShadowedItem   = static_cast<const SvxShadowedItem*>  (pCurData->GetItem( nIndex, ATTR_FONT_SHADOWED ));
-        const SvxColorItem*       pColorItem      = static_cast<const SvxColorItem*>     (pCurData->GetItem( nIndex, ATTR_FONT_COLOR ));
+        const SvxFontItem*        pFontItem       = pCurData->GetItem( nIndex, ATTR_FONT );
+        const SvxWeightItem*      pWeightItem     = pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT );
+        const SvxPostureItem*     pPostureItem    = pCurData->GetItem( nIndex, ATTR_FONT_POSTURE );
+        const SvxFontItem*        pCJKFontItem    = pCurData->GetItem( nIndex, ATTR_CJK_FONT );
+        const SvxWeightItem*      pCJKWeightItem  = pCurData->GetItem( nIndex, ATTR_CJK_FONT_WEIGHT );
+        const SvxPostureItem*     pCJKPostureItem = pCurData->GetItem( nIndex, ATTR_CJK_FONT_POSTURE );
+        const SvxFontItem*        pCTLFontItem    = pCurData->GetItem( nIndex, ATTR_CTL_FONT );
+        const SvxWeightItem*      pCTLWeightItem  = pCurData->GetItem( nIndex, ATTR_CTL_FONT_WEIGHT );
+        const SvxPostureItem*     pCTLPostureItem = pCurData->GetItem( nIndex, ATTR_CTL_FONT_POSTURE );
+        const SvxUnderlineItem*   pUnderlineItem  = pCurData->GetItem( nIndex, ATTR_FONT_UNDERLINE );
+        const SvxOverlineItem*    pOverlineItem   = pCurData->GetItem( nIndex, ATTR_FONT_OVERLINE );
+        const SvxCrossedOutItem*  pCrossedOutItem = pCurData->GetItem( nIndex, ATTR_FONT_CROSSEDOUT );
+        const SvxContourItem*     pContourItem    = pCurData->GetItem( nIndex, ATTR_FONT_CONTOUR );
+        const SvxShadowedItem*    pShadowedItem   = pCurData->GetItem( nIndex, ATTR_FONT_SHADOWED );
+        const SvxColorItem*       pColorItem      = pCurData->GetItem( nIndex, ATTR_FONT_COLOR );
 
         lcl_SetFontProperties( rFont, *pFontItem, *pWeightItem, *pPostureItem );
         lcl_SetFontProperties( rCJKFont, *pCJKFontItem, *pCJKWeightItem, *pCJKPostureItem );
@@ -174,13 +174,13 @@ sal_uInt16 ScAutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
 const SvxBoxItem& ScAutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const
 {
     OSL_ENSURE( pCurData, "ScAutoFmtPreview::GetBoxItem - no format data found" );
-    return *static_cast< const SvxBoxItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BORDER ) );
+    return * pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BORDER );
 }
 
 const SvxLineItem& ScAutoFmtPreview::GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const
 {
     OSL_ENSURE( pCurData, "ScAutoFmtPreview::GetDiagItem - no format data found" );
-    return *static_cast< const SvxLineItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), bTLBR ? ATTR_BORDER_TLBR : ATTR_BORDER_BLTR ) );
+    return * pCurData->GetItem( GetFormatIndex( nCol, nRow ), bTLBR ? ATTR_BORDER_TLBR : ATTR_BORDER_BLTR );
 }
 
 void ScAutoFmtPreview::DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow)
@@ -261,7 +261,7 @@ void ScAutoFmtPreview::DrawString(vcl::RenderContext& rRenderContext, size_t nCo
         // Justification:
 
         eJustification  = mbRTL ? SvxCellHorJustify::Right : bJustify ?
-            static_cast<const SvxHorJustifyItem*>(pCurData->GetItem(nFmtIndex, ATTR_HOR_JUSTIFY))->GetValue() :
+            pCurData->GetItem(nFmtIndex, ATTR_HOR_JUSTIFY)->GetValue() :
             SvxCellHorJustify::Standard;
 
         if (pCurData->GetIncludeFont())
@@ -367,8 +367,8 @@ void ScAutoFmtPreview::DrawBackground(vcl::RenderContext& rRenderContext)
         {
             for(size_t nCol = 0; nCol < 5; ++nCol)
             {
-                const SvxBrushItem* pItem = static_cast< const SvxBrushItem* >(
-                    pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BACKGROUND ) );
+                const SvxBrushItem* pItem =
+                    pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BACKGROUND );
 
                 rRenderContext.Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
                 rRenderContext.SetLineColor();
diff --git a/sc/source/ui/unoobj/afmtuno.cxx b/sc/source/ui/unoobj/afmtuno.cxx
index cd7dd861c9ed..f10fc2bb7d55 100644
--- a/sc/source/ui/unoobj/afmtuno.cxx
+++ b/sc/source/ui/unoobj/afmtuno.cxx
@@ -730,7 +730,7 @@ uno::Any SAL_CALL ScAutoFormatFieldObj::getPropertyValue( const OUString& aPrope
                 {
                     case ATTR_STACKED:
                     {
-                        const SfxInt32Item* pRotItem = static_cast<const SfxInt32Item*>(pData->GetItem( nFieldIndex, ATTR_ROTATE_VALUE ));
+                        const SfxInt32Item* pRotItem = pData->GetItem( nFieldIndex, ATTR_ROTATE_VALUE );
                         sal_Int32 nRot = pRotItem ? pRotItem->GetValue() : 0;
                         bool bStacked = static_cast<const SfxBoolItem*>(pItem)->GetValue();
                         SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( aVal );
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 8cee317d4f8b..430e07b663d4 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -3538,8 +3538,8 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentC
                         {
                             //  date/time identification
 
-                            sal_uLong nIndex = static_cast<sal_uLong>(static_cast<const SfxUInt32Item*>(rDoc.GetAttr(
-                                        aIter.GetPos(), ATTR_VALUE_FORMAT))->GetValue());
+                            sal_uLong nIndex = static_cast<sal_uLong>(rDoc.GetAttr(
+                                        aIter.GetPos(), ATTR_VALUE_FORMAT)->GetValue());
                             SvNumFormatType nTyp = rDoc.GetFormatTable()->GetType(nIndex);
                             if ((nTyp == SvNumFormatType::DATE) || (nTyp == SvNumFormatType::TIME) ||
                                     (nTyp == SvNumFormatType::DATETIME))
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 0546f2abc244..1c5c3acb485a 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -838,8 +838,8 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
                     SCROW nCurY = GetViewData()->GetCurY();
                     SCTAB nTab = GetViewData()->GetTabNo();
                     ScAddress aCursorPos( nCurX, nCurY, nTab );
-                    sal_uLong nIndex = static_cast<const SfxUInt32Item*>(pDoc->GetAttr(
-                                nCurX, nCurY, nTab, ATTR_VALIDDATA ))->GetValue();
+                    sal_uLong nIndex = pDoc->GetAttr(
+                                nCurX, nCurY, nTab, ATTR_VALIDDATA )->GetValue();
                     if ( nIndex )
                     {
                         const ScValidationData* pOldData = pDoc->GetValidationEntry( nIndex );
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
index f0ce2668aeaa..707a487c3067 100644
--- a/sc/source/ui/view/dbfunc.cxx
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -290,8 +290,7 @@ void ScDBFunc::ToggleAutoFilter()
 
     for (nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAuto; nCol++)
     {
-        nFlag = static_cast<const ScMergeFlagAttr*>( pDoc->
-                GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+        nFlag = pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG )->GetValue();
 
         if ( !(nFlag & ScMF::Auto) )
             bHasAuto = false;
@@ -303,8 +302,7 @@ void ScDBFunc::ToggleAutoFilter()
 
         for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++)
         {
-            nFlag = static_cast<const ScMergeFlagAttr*>( pDoc->
-                    GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+            nFlag = pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG )->GetValue();
             pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag & ~ScMF::Auto ) );
         }
 
@@ -358,8 +356,7 @@ void ScDBFunc::ToggleAutoFilter()
 
             for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++)
             {
-                nFlag = static_cast<const ScMergeFlagAttr*>( pDoc->
-                        GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+                nFlag = pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG )->GetValue();
                 pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag | ScMF::Auto ) );
             }
             pDocSh->PostPaint(ScRange(aParam.nCol1, nRow, nTab, aParam.nCol2, nRow, nTab),
@@ -403,8 +400,7 @@ void ScDBFunc::HideAutoFilter()
 
     for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++)
     {
-        ScMF nFlag = static_cast<const ScMergeFlagAttr*>( rDoc.
-                                GetAttr( nCol, nRow1, nTab, ATTR_MERGE_FLAG ))->GetValue();
+        ScMF nFlag = rDoc.GetAttr( nCol, nRow1, nTab, ATTR_MERGE_FLAG )->GetValue();
         rDoc.ApplyAttr( nCol, nRow1, nTab, ScMergeFlagAttr( nFlag & ~ScMF::Auto ) );
     }
 
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index b9dae74dc330..91f3a68a6bac 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -845,8 +845,8 @@ bool ScDBFunc::HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32&
                     SCTAB nSelTab = aSelRange.aStart.Tab();
                     if ( pDoc->HasValueData( nSelCol, nSelRow, nSelTab ) )
                     {
-                        sal_uLong nIndex = static_cast<const SfxUInt32Item*>(pDoc->GetAttr(
-                                        nSelCol, nSelRow, nSelTab, ATTR_VALUE_FORMAT))->GetValue();
+                        sal_uLong nIndex = pDoc->GetAttr(
+                                        nSelCol, nSelRow, nSelTab, ATTR_VALUE_FORMAT)->GetValue();
                         SvNumFormatType nType = pDoc->GetFormatTable()->GetType(nIndex);
                         if ( nType == SvNumFormatType::DATE || nType == SvNumFormatType::TIME || nType == SvNumFormatType::DATETIME )
                         {
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index f64f9e932e79..c401fe3f5021 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -361,7 +361,7 @@ static void lcl_UnLockComment( ScDrawView* pView, const Point& rPos, const ScVie
     SdrObject* pObj = pNote ? pNote->GetCaption() : nullptr;
     if( pObj && pObj->GetLogicRect().IsInside( rPos ) && ScDrawLayer::IsNoteCaption( pObj ) )
     {
-        const ScProtectionAttr* pProtAttr =  static_cast< const ScProtectionAttr* > (rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_PROTECTION ) );
+        const ScProtectionAttr* pProtAttr = rDoc.GetAttr( aCellPos, ATTR_PROTECTION );
         bool bProtectAttr = pProtAttr->GetProtection() || pProtAttr->GetHideCell() ;
         bool bProtectDoc =  rDoc.IsTabProtected( aCellPos.Tab() ) || pViewData->GetSfxDocShell()->IsReadOnly() ;
         // unlock internal layer (if not protected), will be relocked in ScDrawView::MarkListHasChanged()
@@ -1109,8 +1109,7 @@ void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow )
 
     sal_Int32 nSelPos = LISTBOX_ENTRY_NOTFOUND;
 
-    sal_uLong nIndex = static_cast<const SfxUInt32Item*>(pDoc->GetAttr(
-                            nCol, nRow, nTab, ATTR_VALIDDATA ))->GetValue();
+    sal_uLong nIndex = pDoc->GetAttr( nCol, nRow, nTab, ATTR_VALIDDATA )->GetValue();
     if ( nIndex )
     {
         const ScValidationData* pData = pDoc->GetValidationEntry( nIndex );
@@ -1671,10 +1670,8 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta
         SCCOL nRealPosX;
         SCROW nRealPosY;
         pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nRealPosX, nRealPosY, false );//the real row/col
-        const ScMergeFlagAttr* pRealPosAttr = static_cast<const ScMergeFlagAttr*>(
-                                    pDoc->GetAttr( nRealPosX, nRealPosY, nTab, ATTR_MERGE_FLAG ));
-        const ScMergeFlagAttr* pAttr = static_cast<const ScMergeFlagAttr*>(
-                                    pDoc->GetAttr( nPosX, nPosY, nTab, ATTR_MERGE_FLAG ));
+        const ScMergeFlagAttr* pRealPosAttr = pDoc->GetAttr( nRealPosX, nRealPosY, nTab, ATTR_MERGE_FLAG );
+        const ScMergeFlagAttr* pAttr = pDoc->GetAttr( nPosX, nPosY, nTab, ATTR_MERGE_FLAG );
         if( pRealPosAttr->HasAutoFilter() )
         {
             SC_MOD()->InputEnterHandler();
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 64cd440e9902..cab9d42deb39 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1699,7 +1699,7 @@ tools::Rectangle ScGridWindow::GetListValButtonRect( const ScAddress& rButtonPos
 
     //  left edge of next cell if there is a non-hidden next column
     SCCOL nNextCol = nCol + 1;
-    const ScMergeAttr* pMerge = static_cast<const ScMergeAttr*>(pDoc->GetAttr( nCol,nRow,nTab, ATTR_MERGE ));
+    const ScMergeAttr* pMerge = pDoc->GetAttr( nCol,nRow,nTab, ATTR_MERGE );
     if ( pMerge->GetColMerge() > 1 )
         nNextCol = nCol + pMerge->GetColMerge();    // next cell after the merged area
     while ( nNextCol <= MAXCOL && pDoc->ColHidden(nNextCol, nTab) )
@@ -1870,8 +1870,7 @@ void ScGridWindow::GetSelectionRects( ::std::vector< tools::Rectangle >& rPixelR
             if (nX2 < nX1)                      // the rest of the merge
             {
                 SCCOL nStartX = nX1;
-                while ( static_cast<const ScMergeFlagAttr*>(pDoc->
-                            GetAttr(nStartX,nY,nTab,ATTR_MERGE_FLAG))->IsHorOverlapped() )
+                while ( pDoc->GetAttr(nStartX,nY,nTab,ATTR_MERGE_FLAG)->IsHorOverlapped() )
                     --nStartX;
                 if (nStartX <= nX2)
                     nLoopEndX = nX1;
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 064bb14ce1a1..40beadf11610 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -456,12 +456,12 @@ void ScOutputData::DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool
                                 if (nVisX <= nX2)
                                     bHOver = pThisRowInfo->pCellInfo[nVisX+1].bHOverlapped;
                                 else
-                                    bHOver = static_cast<const ScMergeFlagAttr*>(mpDoc->GetAttr(
-                                                nVisX,pThisRowInfo->nRowNo,nTab,ATTR_MERGE_FLAG))
+                                    bHOver = mpDoc->GetAttr(
+                                                nVisX,pThisRowInfo->nRowNo,nTab,ATTR_MERGE_FLAG)
                                                 ->IsHorOverlapped();
                                 if (bHOver)
-                                    bHOver = static_cast<const ScMergeFlagAttr*>(mpDoc->GetAttr(
-                                                nXplus1,pThisRowInfo->nRowNo,nTab,ATTR_MERGE_FLAG))
+                                    bHOver = mpDoc->GetAttr(
+                                                nXplus1,pThisRowInfo->nRowNo,nTab,ATTR_MERGE_FLAG)
                                                 ->IsHorOverlapped();
                             }
                         }
@@ -563,11 +563,11 @@ void ScOutputData::DrawGrid(vcl::RenderContext& rRenderContext, bool bGrid, bool
                                 bVOver = pRowInfo[nArrYplus1].pCellInfo[i+1].bVOverlapped;
                             else
                             {
-                                bVOver = static_cast<const ScMergeFlagAttr*>(mpDoc->GetAttr(
-                                            i,nYplus1,nTab,ATTR_MERGE_FLAG))
+                                bVOver = mpDoc->GetAttr(
+                                            i,nYplus1,nTab,ATTR_MERGE_FLAG)
                                             ->IsVerOverlapped()
-                                    &&   static_cast<const ScMergeFlagAttr*>(mpDoc->GetAttr(
-                                            i,nVisY,nTab,ATTR_MERGE_FLAG))
+                                    &&   mpDoc->GetAttr(
+                                            i,nVisY,nTab,ATTR_MERGE_FLAG)
                                             ->IsVerOverlapped();
                                     //! nVisY from Array ??
                             }
@@ -2351,15 +2351,15 @@ void ScOutputData::DrawClipMarks()
                         long nStartPosX = nPosX;
                         long nStartPosY = nPosY;
 
-                        while ( nOverX > 0 && ( static_cast<const ScMergeFlagAttr*>(mpDoc->GetAttr(
-                                nOverX, nOverY, nTab, ATTR_MERGE_FLAG ))->GetValue() & ScMF::Hor ) )
+                        while ( nOverX > 0 && ( mpDoc->GetAttr(
+                                nOverX, nOverY, nTab, ATTR_MERGE_FLAG )->GetValue() & ScMF::Hor ) )
                         {
                             --nOverX;
                             nStartPosX -= nLayoutSign * static_cast<long>( mpDoc->GetColWidth(nOverX,nTab) * mnPPTX );
                         }
 
-                        while ( nOverY > 0 && ( static_cast<const ScMergeFlagAttr*>(mpDoc->GetAttr(
-                                nOverX, nOverY, nTab, ATTR_MERGE_FLAG ))->GetValue() & ScMF::Ver ) )
+                        while ( nOverY > 0 && ( mpDoc->GetAttr(
+                                nOverX, nOverY, nTab, ATTR_MERGE_FLAG )->GetValue() & ScMF::Ver ) )
                         {
                             --nOverY;
                             nStartPosY -= nLayoutSign * static_cast<long>( mpDoc->GetRowHeight(nOverY,nTab) * mnPPTY );
@@ -2368,8 +2368,7 @@ void ScOutputData::DrawClipMarks()
                         long nOutWidth = static_cast<long>( mpDoc->GetColWidth(nOverX,nTab) * mnPPTX );
                         long nOutHeight = static_cast<long>( mpDoc->GetRowHeight(nOverY,nTab) * mnPPTY );
 
-                        const ScMergeAttr* pMerge = static_cast<const ScMergeAttr*>(
-                                    mpDoc->GetAttr( nOverX, nOverY, nTab, ATTR_MERGE ));
+                        const ScMergeAttr* pMerge = mpDoc->GetAttr( nOverX, nOverY, nTab, ATTR_MERGE );
                         SCCOL nCountX = pMerge->GetColMerge();
                         for (SCCOL i=1; i<nCountX; i++)
                             nOutWidth += static_cast<long>( mpDoc->GetColWidth(nOverX+i,nTab) * mnPPTX );
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index f1e1fbd3eccf..bf00ea6d0f86 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -946,8 +946,7 @@ bool ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
         }
         else
         {
-            ScMF nOverlap = static_cast<const ScMergeFlagAttr*>(mpDoc->GetAttr(
-                                rOverX, rOverY, nTab, ATTR_MERGE_FLAG ))->GetValue();
+            ScMF nOverlap = mpDoc->GetAttr(rOverX, rOverY, nTab, ATTR_MERGE_FLAG)->GetValue();
             bHOver = bool(nOverlap & ScMF::Hor);
             bVOver = bool(nOverlap & ScMF::Ver);
         }
@@ -972,8 +971,7 @@ bool ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
         }
         else
         {
-            ScMF nOverlap = static_cast<const ScMergeFlagAttr*>(mpDoc->GetAttr(
-                                rOverX, rOverY, nTab, ATTR_MERGE_FLAG ))->GetValue();
+            ScMF nOverlap = mpDoc->GetAttr( rOverX, rOverY, nTab, ATTR_MERGE_FLAG )->GetValue();
             bVOver = bool(nOverlap & ScMF::Ver);
         }
     }
@@ -1097,8 +1095,8 @@ bool ScOutputData::IsEmptyCellText( const RowInfo* pThisRowInfo, SCCOL nX, SCROW
 
         if ( bIsPrint || bTabProtected )
         {
-            const ScProtectionAttr* pAttr = static_cast<const ScProtectionAttr*>(
-                    mpDoc->GetEffItem( nX, nY, nTab, ATTR_PROTECTION ));
+            const ScProtectionAttr* pAttr =
+                    mpDoc->GetEffItem( nX, nY, nTab, ATTR_PROTECTION );
             if ( bIsPrint && pAttr->GetHidePrint() )
                 bEmpty = true;
             else if ( bTabProtected )
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index ec2e7c98c637..5ac05cb0841d 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2226,9 +2226,9 @@ void ScTabView::StartDataSelect()
 
     // Do autofilter if the current cell has autofilter button.  Otherwise do
     // a normal data select popup.
-    const ScMergeFlagAttr* pAttr = static_cast<const ScMergeFlagAttr*>(
+    const ScMergeFlagAttr* pAttr =
         aViewData.GetDocument()->GetAttr(
-            nCol, nRow, aViewData.GetTabNo(), ATTR_MERGE_FLAG));
+            nCol, nRow, aViewData.GetTabNo(), ATTR_MERGE_FLAG);
 
     if (pAttr->HasAutoFilter())
         pWin->LaunchAutoFilterMenu(nCol, nRow);
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 9653872b00cd..dbd1f892a45e 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -201,8 +201,7 @@ void moveCursorByMergedCell(
         bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
     }
 
-    const ScMergeAttr* pMergeAttr = static_cast<const ScMergeAttr*>(
-        pDoc->GetAttr(nOrigX, nOrigY, nTab, ATTR_MERGE));
+    const ScMergeAttr* pMergeAttr = pDoc->GetAttr(nOrigX, nOrigY, nTab, ATTR_MERGE);
 
     bool bOriginMerged = false;
     SCCOL nColSpan = 1;
@@ -512,8 +511,8 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
             // selection is moving in the upperleft direction, the anchor cell will
             // move to the lower-right corner of the merged anchor cell, and so on.
 
-            pMergeAttr = static_cast<const ScMergeAttr*>(
-                pDocument->GetAttr( nBlockStartXOrig, nBlockStartYOrig, nTab, ATTR_MERGE ) );
+            pMergeAttr =
+                pDocument->GetAttr( nBlockStartXOrig, nBlockStartYOrig, nTab, ATTR_MERGE );
             if ( pMergeAttr->IsMerged() )
             {
                 SCCOL nColSpan = pMergeAttr->GetColMerge();
@@ -538,8 +537,7 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
             // nCurXOffset/nCurYOffset may also be specified in the previous code
             // block, in which case whichever value is greater will take on.
 
-            pMergeAttr = static_cast<const ScMergeAttr*>(
-                pDocument->GetAttr( nCurX, nCurY, nTab, ATTR_MERGE ) );
+            pMergeAttr = pDocument->GetAttr( nCurX, nCurY, nTab, ATTR_MERGE );
             if ( pMergeAttr->IsMerged() )
             {
                 SCCOL nColSpan = pMergeAttr->GetColMerge();
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index f8a5a7b4da53..b346f3904b27 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -724,11 +724,10 @@ void ScTabView::TestHintWindow()
     ScAddress aListValPos;
 
     ScDocument* pDoc = aViewData.GetDocument();
-    const SfxUInt32Item* pItem = static_cast<const SfxUInt32Item*>(
-                                        pDoc->GetAttr( aViewData.GetCurX(),
-                                                       aViewData.GetCurY(),
-                                                       aViewData.GetTabNo(),
-                                                       ATTR_VALIDDATA ));
+    const SfxUInt32Item* pItem = pDoc->GetAttr( aViewData.GetCurX(),
+                                                aViewData.GetCurY(),
+                                                aViewData.GetTabNo(),
+                                                ATTR_VALIDDATA );
     if ( pItem->GetValue() )
     {
         const ScValidationData* pData = pDoc->GetValidationEntry( pItem->GetValue() );
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 0a07e52d20f6..266f44aea649 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -650,9 +650,8 @@ void ScTabViewShell::UpdateInputHandler( bool bForce /* = sal_False */, bool bSt
 
         if (pDoc->IsTabProtected(nTab))
         {
-            const ScProtectionAttr* pProt = static_cast<const ScProtectionAttr*>(
-                                            pDoc->GetAttr( nPosX,nPosY,nTab,
-                                                           ATTR_PROTECTION));
+            const ScProtectionAttr* pProt = pDoc->GetAttr( nPosX,nPosY,nTab,
+                                                           ATTR_PROTECTION);
             bHideFormula = pProt->GetHideFormula();
             bHideAll     = pProt->GetHideCell();
         }
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index a46bf68bb7f3..8d7a3140f4d4 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2334,7 +2334,7 @@ SCROW ScViewData::PrevCellsY( ScVSplitPos eWhichY ) const
 
 bool ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, long& rSizeXPix, long& rSizeYPix ) const
 {
-    const ScMergeAttr* pMerge = static_cast<const ScMergeAttr*>( pDoc->GetAttr( nX,nY,nTabNo, ATTR_MERGE ) );
+    const ScMergeAttr* pMerge = pDoc->GetAttr( nX,nY,nTabNo, ATTR_MERGE );
     if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 )
     {
         long nOutWidth = 0;
@@ -2455,8 +2455,7 @@ void ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich,
 
         if ( bRepair && ( bHOver || bVOver ) )
         {
-            const ScMergeAttr* pMerge = static_cast<const ScMergeAttr*>(
-                                pDoc->GetAttr( rPosX, rPosY, nTabNo, ATTR_MERGE ) );
+            const ScMergeAttr* pMerge = pDoc->GetAttr( rPosX, rPosY, nTabNo, ATTR_MERGE );
             if ( ( bHOver && pMerge->GetColMerge() <= 1 ) ||
                  ( bVOver && pMerge->GetRowMerge() <= 1 ) )
             {
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 67f7f26f4874..de917324290e 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -836,8 +836,8 @@ void ScViewFunc::EnterBlock( const OUString& rString, const EditTextObject* pDat
     if ( PasteFromClip( InsertDeleteFlags::CONTENTS, pInsDoc.get(), ScPasteFunc::NONE, false, false,
             false, INS_NONE, InsertDeleteFlags::ATTRIB ) )
     {
-        const SfxUInt32Item* pItem = static_cast<const SfxUInt32Item*>( pInsDoc->GetAttr(
-            nCol, nRow, nTab, ATTR_VALUE_FORMAT ) );
+        const SfxUInt32Item* pItem = pInsDoc->GetAttr(
+            nCol, nRow, nTab, ATTR_VALUE_FORMAT );
         if ( pItem )
         {   // set number format if incompatible
             // MarkData was already MarkToSimple'ed in PasteFromClip
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 3959bcd28348..4dd346c5d3ab 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -511,8 +511,8 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
         {
             i = *itr;
             aPos.SetTab( i );
-            const sal_uInt32 nIndex = static_cast<const SfxUInt32Item*>( pDoc->GetAttr(
-                        nCol, nRow, i, ATTR_VALUE_FORMAT ))->GetValue();
+            const sal_uInt32 nIndex = pDoc->GetAttr(
+                        nCol, nRow, i, ATTR_VALUE_FORMAT )->GetValue();
             const SvNumFormatType nType = pFormatter->GetType( nIndex);
             if (nType == SvNumFormatType::TEXT ||
                     ((rString[0] == '+' || rString[0] == '-') && nError != FormulaError::NONE && rString == aFormula))


More information about the Libreoffice-commits mailing list