diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-01-12 20:17:13 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-01-12 20:17:13 +0100 |
commit | 681783c9adf85bde36348f11c03d3a483bf545be (patch) | |
tree | a5b8a4eab1695275b3d2516738b43c0d3f6ee158 | |
parent | fe45359ab818659186672a0ca05979b589dedbfc (diff) |
More loplugin:cstylecast: sc
auto-rewrite with <https://gerrit.libreoffice.org/#/c/47798/> "Enable
loplugin:cstylecast for some more cases" plus
solenv/clang-format/reformat-formatted-files
Change-Id: I987ac3a6d062600a5e21c3462c70595dfaa51796
232 files changed, 1405 insertions, 1412 deletions
diff --git a/sc/inc/appluno.hxx b/sc/inc/appluno.hxx index 58ec1563319c..36b6e9ac92d3 100644 --- a/sc/inc/appluno.hxx +++ b/sc/inc/appluno.hxx @@ -106,7 +106,7 @@ public: virtual sal_Bool SAL_CALL getMoveSelection() override { return getPropertyBool("MoveSelection"); } virtual void SAL_CALL setMoveSelection(sal_Bool p1) override - { setProperty("MoveSelection", (bool)p1); } + { setProperty("MoveSelection", static_cast<bool>(p1)); } virtual sal_Int16 SAL_CALL getMoveDirection() override { return getPropertyInt16("MoveDirection"); } virtual void SAL_CALL setMoveDirection(sal_Int16 p1) override @@ -114,27 +114,27 @@ public: virtual sal_Bool SAL_CALL getEnterEdit() override { return getPropertyBool("EnterEdit"); } virtual void SAL_CALL setEnterEdit(sal_Bool p1) override - { setProperty("EnterEdit", (bool)p1); } + { setProperty("EnterEdit", static_cast<bool>(p1)); } virtual sal_Bool SAL_CALL getExtendFormat() override { return getPropertyBool("ExtendFormat"); } virtual void SAL_CALL setExtendFormat(sal_Bool p1) override - { setProperty("ExtendFormat", (bool)p1); } + { setProperty("ExtendFormat", static_cast<bool>(p1)); } virtual sal_Bool SAL_CALL getRangeFinder() override { return getPropertyBool("RangeFinder"); } virtual void SAL_CALL setRangeFinder(sal_Bool p1) override - { setProperty("RangeFinder", (bool)p1); } + { setProperty("RangeFinder", static_cast<bool>(p1)); } virtual sal_Bool SAL_CALL getExpandReferences() override { return getPropertyBool("ExpandReferences"); } virtual void SAL_CALL setExpandReferences(sal_Bool p1) override - { setProperty("ExpandReferences", (bool)p1); } + { setProperty("ExpandReferences", static_cast<bool>(p1)); } virtual sal_Bool SAL_CALL getMarkHeader() override { return getPropertyBool("MarkHeader"); } virtual void SAL_CALL setMarkHeader(sal_Bool p1) override - { setProperty("MarkHeader", (bool)p1); } + { setProperty("MarkHeader", static_cast<bool>(p1)); } virtual sal_Bool SAL_CALL getUseTabCol() override { return getPropertyBool("UseTabCol"); } virtual void SAL_CALL setUseTabCol(sal_Bool p1) override - { setProperty("UseTabCol", (bool)p1); } + { setProperty("UseTabCol", static_cast<bool>(p1)); } virtual sal_Int16 SAL_CALL getMetric() override { return getPropertyInt16("Metric"); } virtual void SAL_CALL setMetric(sal_Int16 p1) override @@ -146,7 +146,7 @@ public: virtual sal_Bool SAL_CALL getDoAutoComplete() override { return getPropertyBool("DoAutoComplete"); } virtual void SAL_CALL setDoAutoComplete(sal_Bool p1) override - { setProperty("DoAutoComplete", (bool)p1); } + { setProperty("DoAutoComplete", static_cast<bool>(p1)); } virtual sal_Int16 SAL_CALL getStatusBarFunction() override { return getPropertyInt16("StatusBarFunction"); } virtual void SAL_CALL setStatusBarFunction(sal_Int16 p1) override @@ -167,19 +167,19 @@ public: virtual sal_Bool SAL_CALL getPrintAllSheets() override { return getPropertyBool("PrintAllSheets"); } virtual void SAL_CALL setPrintAllSheets(sal_Bool p1) override - { setProperty("PrintAllSheets", (bool)p1); } + { setProperty("PrintAllSheets", static_cast<bool>(p1)); } virtual sal_Bool SAL_CALL getPrintEmptyPages() override { return getPropertyBool("PrintEmptyPages"); } virtual void SAL_CALL setPrintEmptyPages(sal_Bool p1) override - { setProperty("PrintEmptyPages", (bool)p1); } + { setProperty("PrintEmptyPages", static_cast<bool>(p1)); } virtual sal_Bool SAL_CALL getUsePrinterMetrics() override { return getPropertyBool("UsePrinterMetrics"); } virtual void SAL_CALL setUsePrinterMetrics(sal_Bool p1) override - { setProperty("UsePrinterMetrics", (bool)p1); } + { setProperty("UsePrinterMetrics", static_cast<bool>(p1)); } virtual sal_Bool SAL_CALL getReplaceCellsWarning() override { return getPropertyBool("ReplaceCellsWarning"); } virtual void SAL_CALL setReplaceCellsWarning(sal_Bool p1) override - { setProperty("ReplaceCellsWarning", (bool)p1); } + { setProperty("ReplaceCellsWarning", static_cast<bool>(p1)); } // XPropertySet virtual css::uno::Reference< css::beans::XPropertySetInfo > diff --git a/sc/inc/bigrange.hxx b/sc/inc/bigrange.hxx index 5c8fbb5bfab8..995b03d1a36a 100644 --- a/sc/inc/bigrange.hxx +++ b/sc/inc/bigrange.hxx @@ -83,21 +83,21 @@ inline ScAddress ScBigAddress::MakeAddress() const else if ( nCol > MAXCOL ) nColA = MAXCOL; else - nColA = (SCCOL) nCol; + nColA = static_cast<SCCOL>(nCol); if ( nRow < 0 ) nRowA = 0; else if ( nRow > MAXROW ) nRowA = MAXROW; else - nRowA = (SCROW) nRow; + nRowA = static_cast<SCROW>(nRow); if ( nTab < 0 ) nTabA = 0; else if ( nTab > MAXTAB ) nTabA = MAXTAB; else - nTabA = (SCTAB) nTab; + nTabA = static_cast<SCTAB>(nTab); return ScAddress( nColA, nRowA, nTabA ); } diff --git a/sc/inc/chartpos.hxx b/sc/inc/chartpos.hxx index 8666919df0fa..db699ef2e062 100644 --- a/sc/inc/chartpos.hxx +++ b/sc/inc/chartpos.hxx @@ -61,7 +61,7 @@ public: { return nCol < nColCount && nRow < nRowCount; } // data column by column sal_uLong GetIndex( SCCOL nCol, SCROW nRow ) const - { return (sal_uLong) nCol * nRowCount + nRow; } + { return static_cast<sal_uLong>(nCol) * nRowCount + nRow; } const ScAddress* GetPosition( sal_uLong nIndex ) const { diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx index c1bc13f20ae1..fa0da691da9e 100644 --- a/sc/inc/chgtrack.hxx +++ b/sc/inc/chgtrack.hxx @@ -849,7 +849,7 @@ enum ScChangeTrackMergeState // Internally generated actions start at this value (nearly all bits set) // and are decremented, to keep values in a table separated from "normal" actions. -#define SC_CHGTRACK_GENERATED_START ((sal_uInt32) 0xfffffff0) +#define SC_CHGTRACK_GENERATED_START (sal_uInt32(0xfffffff0)) class ScChangeTrack : public utl::ConfigurationListener { diff --git a/sc/inc/convuno.hxx b/sc/inc/convuno.hxx index 8c8f3d55c949..4786ace2a096 100644 --- a/sc/inc/convuno.hxx +++ b/sc/inc/convuno.hxx @@ -65,7 +65,7 @@ inline void ScUnoConversion::FillScAddress( ScAddress& rScAddress, const css::table::CellAddress& rApiAddress ) { - rScAddress.Set( (SCCOL)rApiAddress.Column, (SCROW)rApiAddress.Row, (SCTAB)rApiAddress.Sheet ); + rScAddress.Set( static_cast<SCCOL>(rApiAddress.Column), static_cast<SCROW>(rApiAddress.Row), static_cast<SCTAB>(rApiAddress.Sheet) ); } inline void ScUnoConversion::FillApiAddress( @@ -81,8 +81,8 @@ inline void ScUnoConversion::FillScRange( ScRange& rScRange, const css::table::CellRangeAddress& rApiRange ) { - rScRange.aStart.Set( (SCCOL)rApiRange.StartColumn, (SCROW)rApiRange.StartRow, (SCTAB)rApiRange.Sheet ); - rScRange.aEnd.Set( (SCCOL)rApiRange.EndColumn, (SCROW)rApiRange.EndRow, (SCTAB)rApiRange.Sheet ); + rScRange.aStart.Set( static_cast<SCCOL>(rApiRange.StartColumn), static_cast<SCROW>(rApiRange.StartRow), static_cast<SCTAB>(rApiRange.Sheet) ); + rScRange.aEnd.Set( static_cast<SCCOL>(rApiRange.EndColumn), static_cast<SCROW>(rApiRange.EndRow), static_cast<SCTAB>(rApiRange.Sheet) ); } inline void ScUnoConversion::FillApiRange( diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx index 375daefc5013..8bc3d380b28a 100644 --- a/sc/inc/viewopti.hxx +++ b/sc/inc/viewopti.hxx @@ -55,8 +55,8 @@ enum ScVObjType VOBJ_TYPE_DRAW }; -#define MAX_OPT (sal_uInt16)VOPT_CLIPMARKS+1 -#define MAX_TYPE (sal_uInt16)VOBJ_TYPE_DRAW+1 +#define MAX_OPT sal_uInt16(VOPT_CLIPMARKS)+1 +#define MAX_TYPE sal_uInt16(VOBJ_TYPE_DRAW)+1 #define SC_STD_GRIDCOLOR COL_LIGHTGRAY diff --git a/sc/qa/unit/datatransformation_test.cxx b/sc/qa/unit/datatransformation_test.cxx index f519c61bdc64..4639d4e087d5 100644 --- a/sc/qa/unit/datatransformation_test.cxx +++ b/sc/qa/unit/datatransformation_test.cxx @@ -63,11 +63,11 @@ void ScDataTransformationTest::testColumnRemove() double nVal = m_pDoc->GetValue(nCol, nRow, 0); if (nCol < 5) { - ASSERT_DOUBLES_EQUAL((double)(nCol)*nRow, nVal); + ASSERT_DOUBLES_EQUAL(static_cast<double>(nCol)*nRow, nVal); } else { - ASSERT_DOUBLES_EQUAL((double)(nCol+1)*nRow, nVal); + ASSERT_DOUBLES_EQUAL(static_cast<double>(nCol+1)*nRow, nVal); } } } diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 117c4d21e9e8..bb260aa23080 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -59,7 +59,7 @@ std::ostream& operator<<(std::ostream& rStrm, const ScRangeList& rList) std::ostream& operator<<(std::ostream& rStrm, const Color& rColor) { - rStrm << "Color: R:" << (int)rColor.GetRed() << " G:" << (int)rColor.GetGreen() << " B: " << (int)rColor.GetBlue(); + rStrm << "Color: R:" << static_cast<int>(rColor.GetRed()) << " G:" << static_cast<int>(rColor.GetGreen()) << " B: " << static_cast<int>(rColor.GetBlue()); return rStrm; } diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 06ed9dcdf9ad..0149b0585b0a 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -2078,8 +2078,8 @@ void ScExportTest::testSheetProtectionXLSX() // check has if (aHash.getLength() >= 2) { - CPPUNIT_ASSERT_EQUAL(sal_uInt8(204), (sal_uInt8)aHash[0]); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(61), (sal_uInt8)aHash[1]); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(204), static_cast<sal_uInt8>(aHash[0])); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(61), static_cast<sal_uInt8>(aHash[1])); } // we could flesh out this check I guess CPPUNIT_ASSERT ( !pTabProtect->isOptionEnabled( ScTableProtection::OBJECTS ) ); @@ -3815,8 +3815,8 @@ void ScExportTest::testHiddenRepeatedRowsODS() SCROW nLastRow = 0; bool bHidden = rDoc.RowHidden(0, 0, &nFirstRow, &nLastRow); CPPUNIT_ASSERT(bHidden); - CPPUNIT_ASSERT_EQUAL((SCROW)0, nFirstRow); - CPPUNIT_ASSERT_EQUAL((SCROW)20, nLastRow); + CPPUNIT_ASSERT_EQUAL(SCROW(0), nFirstRow); + CPPUNIT_ASSERT_EQUAL(SCROW(20), nLastRow); xDocSh->DoClose(); } diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 5f1433c8a989..7d69b8eee5ae 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -673,14 +673,14 @@ void ScFiltersTest::testCachedFormulaResultsODS() for(SCROW nRow = 0; nRow < 2; ++nRow) { OUStringBuffer aIsErrorFormula("=ISERROR("); - aIsErrorFormula.append((char)('A'+nCol)).append(OUString::number(nRow)); + aIsErrorFormula.append(static_cast<char>('A'+nCol)).append(OUString::number(nRow)); aIsErrorFormula.append(")"); OUString aFormula = aIsErrorFormula.makeStringAndClear(); rDoc.SetString(nCol, nRow + 2, 2, aFormula); CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8).getStr(), rDoc.GetString(nCol, nRow +2, 2), OUString("TRUE")); OUStringBuffer aIsTextFormula("=ISTEXT("); - aIsTextFormula.append((char)('A'+nCol)).append(OUString::number(nRow)); + aIsTextFormula.append(static_cast<char>('A'+nCol)).append(OUString::number(nRow)); aIsTextFormula.append(")"); rDoc.SetString(nCol, nRow + 4, 2, aIsTextFormula.makeStringAndClear()); CPPUNIT_ASSERT_EQUAL_MESSAGE("", rDoc.GetString(nCol, nRow +4, 2), OUString("FALSE")); @@ -3304,7 +3304,7 @@ void ScFiltersTest::testColumnStyle2XLSX() const SfxPoolItem& rItem = pAttr->GetItem(ATTR_FONT_HEIGHT); const SvxFontHeightItem& rFontHeight = static_cast<const SvxFontHeightItem&>(rItem); sal_uInt16 nHeight = rFontHeight.GetHeight(); - CPPUNIT_ASSERT_EQUAL((sal_uInt16)240, nHeight); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(240), nHeight); } { diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 0fe4d7a4b5c4..21c7200939fd 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -46,7 +46,7 @@ using namespace css; std::ostream& operator<<(std::ostream& os, ViewShellId const & id) { - os << (sal_Int32)id; return os; + os << static_cast<sal_Int32>(id); return os; } namespace diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 175564916e20..d18ba23885c6 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -6509,9 +6509,9 @@ void Test::testUndoDataAnchor() void Test::testEmptyCalcDocDefaults() { - CPPUNIT_ASSERT_EQUAL( (sal_uLong) 0, m_pDoc->GetCellCount() ); - CPPUNIT_ASSERT_EQUAL( (sal_uLong) 0, m_pDoc->GetFormulaGroupCount() ); - CPPUNIT_ASSERT_EQUAL( (sal_uLong) 0, m_pDoc->GetCodeCount() ); + CPPUNIT_ASSERT_EQUAL( sal_uLong(0), m_pDoc->GetCellCount() ); + CPPUNIT_ASSERT_EQUAL( sal_uLong(0), m_pDoc->GetFormulaGroupCount() ); + CPPUNIT_ASSERT_EQUAL( sal_uLong(0), m_pDoc->GetCodeCount() ); CPPUNIT_ASSERT_EQUAL( (int)CharCompressType::NONE, (int)m_pDoc->GetAsianCompression() ); CPPUNIT_ASSERT_EQUAL( false, m_pDoc->HasPrintRange() ); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index bd6fbbaffa64..8c5c8fefab1a 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -1717,7 +1717,7 @@ void Test::testFormulaRefUpdateRange() // Sticky reference including last row. m_pDoc->SetString( 2,0,1, "=SUM(B:B)"); // Reference to last row. - CPPUNIT_ASSERT_EQUAL_MESSAGE("MAXROW changed, adapt unit test.", 1048575, (int)MAXROW); + CPPUNIT_ASSERT_EQUAL_MESSAGE("MAXROW changed, adapt unit test.", 1048575, int(MAXROW)); m_pDoc->SetString( 2,1,1, "=SUM(B1048576:C1048576)"); CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C1.", 3.0, m_pDoc->GetValue(2,0,1)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C2.", 2.0, m_pDoc->GetValue(2,1,1)); @@ -1732,7 +1732,7 @@ void Test::testFormulaRefUpdateRange() // C3 with sticky reference including last column. m_pDoc->SetString( 2,2,1, "=SUM(23:23)"); // C4 with reference to last column. - CPPUNIT_ASSERT_EQUAL_MESSAGE("MAXCOL changed, adapt unit test.", 1023, (int)MAXCOL); + CPPUNIT_ASSERT_EQUAL_MESSAGE("MAXCOL changed, adapt unit test.", 1023, int(MAXCOL)); m_pDoc->SetString( 2,3,1, "=SUM(AMJ22:AMJ23)"); CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C3.", 3.0, m_pDoc->GetValue(2,2,1)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result in C4.", 2.0, m_pDoc->GetValue(2,3,1)); diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx index db91442be673..922856bcae96 100644 --- a/sc/qa/unit/ucalc_sort.cxx +++ b/sc/qa/unit/ucalc_sort.cxx @@ -486,7 +486,7 @@ void Test::testSortInFormulaGroup() m_pDoc->InsertTab(0, "sorttest"); - for ( SCROW i = 0; i < (SCROW) SAL_N_ELEMENTS( aEntries ); ++i ) + for ( SCROW i = 0; i < SCROW(SAL_N_ELEMENTS( aEntries )); ++i ) m_pDoc->SetString( aEntries[i].nCol, aEntries[i].nRow, 0, OUString::createFromAscii( aEntries[i].pData) ); @@ -518,7 +518,7 @@ void Test::testSortInFormulaGroup() { 0, 9, 104.0 }, { 1, 9, 104.0 }, }; - for ( SCROW i = 0; i < (SCROW) SAL_N_ELEMENTS( aEntries ); ++i ) + for ( SCROW i = 0; i < SCROW(SAL_N_ELEMENTS( aEntries )); ++i ) { double val = m_pDoc->GetValue( aEntries[i].nCol, aEntries[i].nRow, 0 ); // fprintf(stderr, "value at %d %d is %g = %g\n", diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index c8a7d50da93c..5b9aafbcb4da 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -210,21 +210,21 @@ bool ScAttrArray::Search( SCROW nRow, SCSIZE& nIndex ) const { i = (nLo + nHi) / 2; if (i > 0) - nStartRow = (long) mvData[i - 1].nEndRow; + nStartRow = static_cast<long>(mvData[i - 1].nEndRow); else nStartRow = -1; - const long nEndRow = (long) mvData[i].nEndRow; - if (nEndRow < (long) nRow) + const long nEndRow = static_cast<long>(mvData[i].nEndRow); + if (nEndRow < static_cast<long>(nRow)) nLo = ++i; else - if (nStartRow >= (long) nRow) + if (nStartRow >= static_cast<long>(nRow)) nHi = --i; else bFound = true; } if (bFound) - nIndex=(SCSIZE)i; + nIndex=static_cast<SCSIZE>(i); else nIndex=0; return bFound; @@ -1128,7 +1128,7 @@ void ScAttrArray::MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLine { pPattern = mvData[i].pPattern; lcl_MergeToFrame( pLineOuter, pLineInner, rFlags, pPattern, bLeft, nDistRight, false, - nEndRow - std::min( mvData[i].nEndRow, (SCROW)(nEndRow-1) ) ); + nEndRow - std::min( mvData[i].nEndRow, static_cast<SCROW>(nEndRow-1) ) ); // nDistBottom here always > 0 } @@ -1234,7 +1234,7 @@ void ScAttrArray::ApplyBlockFrame(const SvxBoxItem& rLineOuter, const SvxBoxInfo SCROW nTmpEnd; for (SCSIZE i=nStartIndex; i<=nEndIndex;) { - nTmpEnd = std::min( (SCROW)(nEndRow-1), mvData[i].nEndRow ); + nTmpEnd = std::min( static_cast<SCROW>(nEndRow-1), mvData[i].nEndRow ); bool bChanged = ApplyFrame(&rLineOuter, pLineInner, nTmpStart, nTmpEnd, bLeft, nDistRight, false, nEndRow - nTmpEnd); nTmpStart = nTmpEnd+1; @@ -1712,7 +1712,7 @@ void ScAttrArray::ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement sal_uInt16 nOldValue = rOldSet.Get( ATTR_INDENT ).GetValue(); sal_uInt16 nNewValue = nOldValue; // To keep Increment indent from running outside the cell1659 - long nColWidth = (long)pDocument->GetColWidth(nCol,nTab); + long nColWidth = static_cast<long>(pDocument->GetColWidth(nCol,nTab)); if ( bIncrement ) { if ( nNewValue < nColWidth-SC_INDENT_STEP ) @@ -2381,8 +2381,8 @@ void ScAttrArray::CopyArea( nStartRow -= nDy; // Source nEndRow -= nDy; - SCROW nDestStart = std::max((long)((long)nStartRow + nDy), (long) 0); - SCROW nDestEnd = std::min((long)((long)nEndRow + nDy), (long) MAXROW); + SCROW nDestStart = std::max(static_cast<long>(static_cast<long>(nStartRow) + nDy), long(0)); + SCROW nDestEnd = std::min(static_cast<long>(static_cast<long>(nEndRow) + nDy), long(MAXROW)); ScDocumentPool* pSourceDocPool = pDocument->GetPool(); ScDocumentPool* pDestDocPool = rAttrArray.pDocument->GetPool(); @@ -2434,12 +2434,12 @@ void ScAttrArray::CopyArea( } rAttrArray.SetPatternArea(nDestStart, - std::min((SCROW)(mvData[i].nEndRow + nDy), nDestEnd), pNewPattern); + std::min(static_cast<SCROW>(mvData[i].nEndRow + nDy), nDestEnd), pNewPattern); } // when pasting from clipboard and skipping filtered rows, the adjusted // end position can be negative - nDestStart = std::max((long)nDestStart, (long)(mvData[i].nEndRow + nDy + 1)); + nDestStart = std::max(static_cast<long>(nDestStart), static_cast<long>(mvData[i].nEndRow + nDy + 1)); } } @@ -2452,8 +2452,8 @@ void ScAttrArray::CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttr nStartRow -= nDy; // Source nEndRow -= nDy; - SCROW nDestStart = std::max((long)((long)nStartRow + nDy), (long) 0); - SCROW nDestEnd = std::min((long)((long)nEndRow + nDy), (long) MAXROW); + SCROW nDestStart = std::max(static_cast<long>(static_cast<long>(nStartRow) + nDy), long(0)); + SCROW nDestEnd = std::min(static_cast<long>(static_cast<long>(nEndRow) + nDy), long(MAXROW)); if ( !rAttrArray.HasAttrib( nDestStart, nDestEnd, HasAttrFlags::Overlapped ) ) { @@ -2492,12 +2492,12 @@ void ScAttrArray::CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttr pNewPattern = pOldPattern->PutInPool( rAttrArray.pDocument, pDocument ); rAttrArray.SetPatternAreaSafe(nDestStart, - std::min((SCROW)(mvData[i].nEndRow + nDy), nDestEnd), pNewPattern, false); + std::min(static_cast<SCROW>(mvData[i].nEndRow + nDy), nDestEnd), pNewPattern, false); } // when pasting from clipboard and skipping filtered rows, the adjusted // end position can be negative - nDestStart = std::max((long)nDestStart, (long)(mvData[i].nEndRow + nDy + 1)); + nDestStart = std::max(static_cast<long>(nDestStart), static_cast<long>(mvData[i].nEndRow + nDy + 1)); } } diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index ac582ec49905..a07f3ac0f1e6 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -484,7 +484,7 @@ Color CalcColor( double nVal, double nVal1, const Color& rCol1, double nVal2, co double GetPercentile( const std::vector<double>& rArray, double fPercentile ) { size_t nSize = rArray.size(); - size_t nIndex = (size_t)::rtl::math::approxFloor( fPercentile * (nSize-1)); + size_t nIndex = static_cast<size_t>(::rtl::math::approxFloor( fPercentile * (nSize-1))); double fDiff = fPercentile * (nSize-1) - ::rtl::math::approxFloor( fPercentile * (nSize-1)); std::vector<double>::const_iterator iter = rArray.begin() + nIndex; if (fDiff == 0.0) diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 9992b79da0f2..f381e01d7c39 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -292,22 +292,22 @@ long ScColumn::GetNeededSize( double nRealOrient = nRotate * F_PI18000; // nRotate is in 1/100 Grad double nCosAbs = fabs( cos( nRealOrient ) ); double nSinAbs = fabs( sin( nRealOrient ) ); - long nHeight = (long)( aSize.Height() * nCosAbs + aSize.Width() * nSinAbs ); + long nHeight = static_cast<long>( aSize.Height() * nCosAbs + aSize.Width() * nSinAbs ); long nWidth; if ( eRotMode == SVX_ROTATE_MODE_STANDARD ) - nWidth = (long)( aSize.Width() * nCosAbs + aSize.Height() * nSinAbs ); + nWidth = static_cast<long>( aSize.Width() * nCosAbs + aSize.Height() * nSinAbs ); else if ( rOptions.bTotalSize ) { - nWidth = (long) ( pDocument->GetColWidth( nCol,nTab ) * nPPT ); + nWidth = static_cast<long>( pDocument->GetColWidth( nCol,nTab ) * nPPT ); bAddMargin = false; // only to the right: //TODO: differ on direction up/down (only Text/whole height) if ( pPattern->GetRotateDir( pCondSet ) == ScRotateDir::Right ) - nWidth += (long)( pDocument->GetRowHeight( nRow,nTab ) * + nWidth += static_cast<long>( pDocument->GetRowHeight( nRow,nTab ) * nPPT * nCosAbs / nSinAbs ); } else - nWidth = (long)( aSize.Height() / nSinAbs ); //TODO: limit? + nWidth = static_cast<long>( aSize.Height() / nSinAbs ); //TODO: limit? if ( bBreak && !rOptions.bTotalSize ) { @@ -325,14 +325,14 @@ long ScColumn::GetNeededSize( { if (bWidth) { - nValue += (long) ( pMargin->GetLeftMargin() * nPPT ) + - (long) ( pMargin->GetRightMargin() * nPPT ); + nValue += static_cast<long>( pMargin->GetLeftMargin() * nPPT ) + + static_cast<long>( pMargin->GetRightMargin() * nPPT ); if ( nIndent ) - nValue += (long) ( nIndent * nPPT ); + nValue += static_cast<long>( nIndent * nPPT ); } else - nValue += (long) ( pMargin->GetTopMargin() * nPPT ) + - (long) ( pMargin->GetBottomMargin() * nPPT ); + nValue += static_cast<long>( pMargin->GetTopMargin() * nPPT ) + + static_cast<long>( pMargin->GetBottomMargin() * nPPT ); } // linebreak done ? @@ -342,7 +342,7 @@ long ScColumn::GetNeededSize( // test with EditEngine the safety at 90% // (due to rounding errors and because EditEngine formats partially differently) - long nDocPixel = (long) ( ( pDocument->GetColWidth( nCol,nTab ) - + long nDocPixel = static_cast<long>( ( pDocument->GetColWidth( nCol,nTab ) - pMargin->GetLeftMargin() - pMargin->GetRightMargin() - nIndent ) * nPPT ); @@ -412,16 +412,16 @@ long ScColumn::GetNeededSize( } // use original width for hidden columns: - long nDocWidth = (long) ( pDocument->GetOriginalWidth(nCol,nTab) * fWidthFactor ); + long nDocWidth = static_cast<long>( pDocument->GetOriginalWidth(nCol,nTab) * fWidthFactor ); SCCOL nColMerge = pMerge->GetColMerge(); if (nColMerge > 1) for (SCCOL nColAdd=1; nColAdd<nColMerge; nColAdd++) - nDocWidth += (long) ( pDocument->GetColWidth(nCol+nColAdd,nTab) * fWidthFactor ); - nDocWidth -= (long) ( pMargin->GetLeftMargin() * fWidthFactor ) - + (long) ( pMargin->GetRightMargin() * fWidthFactor ) + nDocWidth += static_cast<long>( pDocument->GetColWidth(nCol+nColAdd,nTab) * fWidthFactor ); + nDocWidth -= static_cast<long>( pMargin->GetLeftMargin() * fWidthFactor ) + + static_cast<long>( pMargin->GetRightMargin() * fWidthFactor ) + 1; // output size is width-1 pixel (due to gridline) if ( nIndent ) - nDocWidth -= (long) ( nIndent * fWidthFactor ); + nDocWidth -= static_cast<long>( nIndent * fWidthFactor ); // space for AutoFilter button: 20 * nZoom/100 if ( pFlag->HasAutoFilter() && !bTextWysiwyg ) @@ -467,20 +467,20 @@ long ScColumn::GetNeededSize( double nRealOrient = nRotate * F_PI18000; // nRotate is in 1/100 Grad double nCosAbs = fabs( cos( nRealOrient ) ); double nSinAbs = fabs( sin( nRealOrient ) ); - long nHeight = (long)( aSize.Height() * nCosAbs + aSize.Width() * nSinAbs ); + long nHeight = static_cast<long>( aSize.Height() * nCosAbs + aSize.Width() * nSinAbs ); long nWidth; if ( eRotMode == SVX_ROTATE_MODE_STANDARD ) - nWidth = (long)( aSize.Width() * nCosAbs + aSize.Height() * nSinAbs ); + nWidth = static_cast<long>( aSize.Width() * nCosAbs + aSize.Height() * nSinAbs ); else if ( rOptions.bTotalSize ) { - nWidth = (long) ( pDocument->GetColWidth( nCol,nTab ) * nPPT ); + nWidth = static_cast<long>( pDocument->GetColWidth( nCol,nTab ) * nPPT ); bAddMargin = false; if ( pPattern->GetRotateDir( pCondSet ) == ScRotateDir::Right ) - nWidth += (long)( pDocument->GetRowHeight( nRow,nTab ) * + nWidth += static_cast<long>( pDocument->GetRowHeight( nRow,nTab ) * nPPT * nCosAbs / nSinAbs ); } else - nWidth = (long)( aSize.Height() / nSinAbs ); //TODO: limit? + nWidth = static_cast<long>( aSize.Height() / nSinAbs ); //TODO: limit? aSize = Size( nWidth, nHeight ); Size aPixSize = pDev->LogicToPixel( aSize, aHMMMode ); @@ -528,20 +528,20 @@ long ScColumn::GetNeededSize( { if (bWidth) { - nValue += (long) ( pMargin->GetLeftMargin() * nPPT ) + - (long) ( pMargin->GetRightMargin() * nPPT ); + nValue += static_cast<long>( pMargin->GetLeftMargin() * nPPT ) + + static_cast<long>( pMargin->GetRightMargin() * nPPT ); if (nIndent) - nValue += (long) ( nIndent * nPPT ); + nValue += static_cast<long>( nIndent * nPPT ); } else { - nValue += (long) ( pMargin->GetTopMargin() * nPPT ) + - (long) ( pMargin->GetBottomMargin() * nPPT ); + nValue += static_cast<long>( pMargin->GetTopMargin() * nPPT ) + + static_cast<long>( pMargin->GetBottomMargin() * nPPT ); if ( bAsianVertical && pDev->GetOutDevType() != OUTDEV_PRINTER ) { // add 1pt extra (default margin value) for line breaks with SetVertical - nValue += (long) ( 20 * nPPT ); + nValue += static_cast<long>( 20 * nPPT ); } } } @@ -658,8 +658,8 @@ sal_uInt16 ScColumn::GetOptimalColWidth( pPattern->GetFont( aFont, SC_AUTOCOL_BLACK, pDev, &rZoomX ); pDev->SetFont( aFont ); const SvxMarginItem* pMargin = &pPattern->GetItem(ATTR_MARGIN); - long nMargin = (long) ( pMargin->GetLeftMargin() * nPPTX ) + - (long) ( pMargin->GetRightMargin() * nPPTX ); + long nMargin = static_cast<long>( pMargin->GetLeftMargin() * nPPTX ) + + static_cast<long>( pMargin->GetRightMargin() * nPPTX ); // Try to find the row that has the longest string, and measure the width of that string. SvNumberFormatter* pFormatter = pDocument->GetFormatTable(); @@ -724,8 +724,8 @@ sal_uInt16 ScColumn::GetOptimalColWidth( aOptions.pPattern = pPattern; aOptions.bGetFont = (pPattern != pOldPattern || nScript != SvtScriptType::NONE); pOldPattern = pPattern; - sal_uInt16 nThis = (sal_uInt16) GetNeededSize( - nRow, pDev, nPPTX, nPPTY, rZoomX, rZoomY, true, aOptions, &pOldPattern); + sal_uInt16 nThis = static_cast<sal_uInt16>(GetNeededSize( + nRow, pDev, nPPTX, nPPTY, rZoomX, rZoomY, true, aOptions, &pOldPattern)); if (nThis) { if (nThis > nWidth || !bFound) @@ -742,7 +742,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth( if (bFound) { nWidth += 2; - sal_uInt16 nTwips = (sal_uInt16) (nWidth / nPPTX); + sal_uInt16 nTwips = static_cast<sal_uInt16>(nWidth / nPPTX); return nTwips; } else @@ -943,8 +943,7 @@ void ScColumn::GetOptimalHeight( { aOptions.pPattern = pPattern; const ScPatternAttr* pOldPattern = pPattern; - sal_uInt16 nHeight = (sal_uInt16) - ( GetNeededSize( nRow, rCxt.getOutputDevice(), rCxt.getPPTX(), rCxt.getPPTY(), + sal_uInt16 nHeight = static_cast<sal_uInt16>( GetNeededSize( nRow, rCxt.getOutputDevice(), rCxt.getPPTX(), rCxt.getPPTY(), rCxt.getZoomX(), rCxt.getZoomY(), false, aOptions, &pPattern) / rCxt.getPPTY() ); if (nHeight > rHeights.getValue(nRow)) diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index bb5b59dc2416..29924084437b 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -3123,7 +3123,7 @@ public: else { // Both previous and current cells are regular cells. - assert(pPrev->aPos.Row() == (SCROW)(nRow - 1)); + assert(pPrev->aPos.Row() == static_cast<SCROW>(nRow - 1)); xPrevGrp = pPrev->CreateCellGroup(2, eCompState == ScFormulaCell::EqualInvariant); pCur->SetCellGroup(xPrevGrp); ++nRow; diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 4454e8c11fc9..61c46a0e49f0 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -1734,7 +1734,7 @@ void ScColumn::StoreToCache(SvStream& rStrm) const rStrm.WriteUInt64(nLastRow + 1); // the rows are zero based StoreToCacheFunc aFunc(rStrm); - sc::ParseBlock(maCells.begin(), maCells, aFunc, (SCROW)0, nLastRow); + sc::ParseBlock(maCells.begin(), maCells, aFunc, SCROW(0), nLastRow); } void ScColumn::RestoreFromCache(SvStream& rStrm) diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx index 740d3409a4b6..3387d51dc380 100644 --- a/sc/source/core/data/docpool.cxx +++ b/sc/source/core/data/docpool.cxx @@ -434,7 +434,7 @@ static bool lcl_HFPresentation } else { - aText += GetMetricText( (long)nLeftMargin, + aText += GetMetricText( static_cast<long>(nLeftMargin), eCoreMetric, ePresentationMetric, &rIntl ); aText += " " + EditResId(GetMetricId(ePresentationMetric)); } @@ -449,7 +449,7 @@ static bool lcl_HFPresentation } else { - aText += GetMetricText( (long)nRightMargin, + aText += GetMetricText( static_cast<long>(nRightMargin), eCoreMetric, ePresentationMetric, &rIntl ); aText += " " + EditResId(GetMetricId(ePresentationMetric)); } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 4e8e83614d5d..ec2cb2eb6684 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1031,7 +1031,7 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, NumFmtMergeHandler aNumFmtMergeHdl(this, pSrcDoc); sc::CopyToDocContext aCxt(*this); - nDestPos = std::min(nDestPos, (SCTAB)(GetTableCount() - 1)); + nDestPos = std::min(nDestPos, static_cast<SCTAB>(GetTableCount() - 1)); { // scope for bulk broadcast ScBulkBroadcast aBulkBroadcast( pBASM, SfxHintId::ScDataChanged); if (!bResultsOnly) diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 092044704c21..a018a065b1d2 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -1231,7 +1231,7 @@ void ScDocument::GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem, if ( rSearchItem.GetPattern() ) { rCol = 0; - rRow = (SCROW) -1; + rRow = SCROW(-1); } else if ( bReplace ) { @@ -1240,7 +1240,7 @@ void ScDocument::GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem, } else { - rCol = (SCCOL) -1; + rCol = SCCOL(-1); rRow = 0; } } @@ -1248,7 +1248,7 @@ void ScDocument::GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem, { if ( rSearchItem.GetPattern() ) { - rCol = (SCCOL) -1; + rCol = SCCOL(-1); rRow = 0; } else if ( bReplace ) @@ -1259,7 +1259,7 @@ void ScDocument::GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem, else { rCol = 0; - rRow = (SCROW) -1; + rRow = SCROW(-1); } } } @@ -1684,10 +1684,10 @@ tools::Rectangle ScDocument::GetEmbeddedRect() const // 1/100 mm aRect.Bottom() = aRect.Top(); aRect.Bottom() += pTable->GetRowHeight( aEmbedRange.aStart.Row(), aEmbedRange.aEnd.Row()); - aRect.Left() = (long) ( aRect.Left() * HMM_PER_TWIPS ); - aRect.Right() = (long) ( aRect.Right() * HMM_PER_TWIPS ); - aRect.Top() = (long) ( aRect.Top() * HMM_PER_TWIPS ); - aRect.Bottom() = (long) ( aRect.Bottom() * HMM_PER_TWIPS ); + aRect.Left() = static_cast<long>( aRect.Left() * HMM_PER_TWIPS ); + aRect.Right() = static_cast<long>( aRect.Right() * HMM_PER_TWIPS ); + aRect.Top() = static_cast<long>( aRect.Top() * HMM_PER_TWIPS ); + aRect.Bottom() = static_cast<long>( aRect.Bottom() * HMM_PER_TWIPS ); } return aRect; } @@ -1774,13 +1774,13 @@ ScRange ScDocument::GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool bool bEnd; nSize = 0; - nTwips = (long) (aPosRect.Left() / HMM_PER_TWIPS); + nTwips = static_cast<long>(aPosRect.Left() / HMM_PER_TWIPS); SCCOL nX1 = 0; bEnd = false; while (!bEnd) { - nAdd = (long) pTable->GetColWidth(nX1, bHiddenAsZero); + nAdd = static_cast<long>(pTable->GetColWidth(nX1, bHiddenAsZero)); if (nSize+nAdd <= nTwips+1 && nX1<MAXCOL) { nSize += nAdd; @@ -1790,13 +1790,13 @@ ScRange ScDocument::GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool bEnd = true; } - nTwips = (long) (aPosRect.Right() / HMM_PER_TWIPS); + nTwips = static_cast<long>(aPosRect.Right() / HMM_PER_TWIPS); SCCOL nX2 = nX1; bEnd = false; while (!bEnd) { - nAdd = (long) pTable->GetColWidth(nX2, bHiddenAsZero); + nAdd = static_cast<long>(pTable->GetColWidth(nX2, bHiddenAsZero)); if (nSize+nAdd < nTwips && nX2<MAXCOL) { nSize += nAdd; @@ -1807,14 +1807,14 @@ ScRange ScDocument::GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool } nSize = 0; - nTwips = (long) (aPosRect.Top() / HMM_PER_TWIPS); + nTwips = static_cast<long>(aPosRect.Top() / HMM_PER_TWIPS); SCROW nY1 = 0; // Was if(nSize+nAdd<=nTwips+1) inside loop => if(nSize+nAdd<nTwips+2) if (lcl_AddTwipsWhile( nSize, nTwips+2, nY1, MAXROW, pTable, bHiddenAsZero) && nY1 < MAXROW) ++nY1; // original loop ended on last matched +1 unless that was MAXROW - nTwips = (long) (aPosRect.Bottom() / HMM_PER_TWIPS); + nTwips = static_cast<long>(aPosRect.Bottom() / HMM_PER_TWIPS); SCROW nY2 = nY1; // Was if(nSize+nAdd<nTwips) inside loop => if(nSize+nAdd<nTwips) @@ -1958,10 +1958,10 @@ tools::Rectangle ScDocument::GetMMRect( SCCOL nStartCol, SCROW nStartRow, SCCOL aRect.Right() += GetColWidth(i,nTab, bHiddenAsZero); aRect.Bottom() += GetRowHeight( nStartRow, nEndRow, nTab, bHiddenAsZero ); - aRect.Left() = (long)(aRect.Left() * HMM_PER_TWIPS); - aRect.Right() = (long)(aRect.Right() * HMM_PER_TWIPS); - aRect.Top() = (long)(aRect.Top() * HMM_PER_TWIPS); - aRect.Bottom() = (long)(aRect.Bottom() * HMM_PER_TWIPS); + aRect.Left() = static_cast<long>(aRect.Left() * HMM_PER_TWIPS); + aRect.Right() = static_cast<long>(aRect.Right() * HMM_PER_TWIPS); + aRect.Top() = static_cast<long>(aRect.Top() * HMM_PER_TWIPS); + aRect.Bottom() = static_cast<long>(aRect.Bottom() * HMM_PER_TWIPS); if ( IsNegativePage( nTab ) ) ScDrawLayer::MirrorRectRTL( aRect ); diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index c8a71a25bd88..fd0146242d04 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -395,7 +395,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // multiple (repeate aRef.Set( nCol1, nRow1, nTab1, false, true, true ); aForString.append(aRef.GetRefString(this, nTab1)); nCol1++; - nCol2 = std::min( nCol2, (SCCOL)(rParam.aRefFormulaEnd.Col() - + nCol2 = std::min( nCol2, static_cast<SCCOL>(rParam.aRefFormulaEnd.Col() - rParam.aRefFormulaCell.Col() + nCol1 + 1)); } else if (rParam.meMode == ScTabOpParam::Row) // row only @@ -408,7 +408,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // multiple (repeate aRef.Set( nCol1, nRow1, nTab1, true, false, true ); aForString.append(aRef.GetRefString(this, nTab1)); nRow1++; - nRow2 = std::min( nRow2, (SCROW)(rParam.aRefFormulaEnd.Row() - + nRow2 = std::min( nRow2, static_cast<SCROW>(rParam.aRefFormulaEnd.Row() - rParam.aRefFormulaCell.Row() + nRow1 + 1)); } else // both @@ -630,7 +630,7 @@ bool ScDocument::GetSelectionFunction( ScSubTotalFunc eFunc, break; case SUBTOTAL_FUNC_AVE: if (aData.nCount) - rResult = aData.nVal / (double) aData.nCount; + rResult = aData.nVal / static_cast<double>(aData.nCount); else aData.bError = true; break; @@ -664,7 +664,7 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat ) const if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0) { sal_uInt16 nIdx = pFormat->GetSubformatIndex( fVal ); - nPrecision = (short)pFormat->GetFormatPrecision( nIdx ); + nPrecision = static_cast<short>(pFormat->GetFormatPrecision( nIdx )); switch ( nType ) { case SvNumFormatType::PERCENT: // 0.41% == 0.0041 @@ -674,11 +674,11 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat ) const { short nExp = 0; if ( fVal > 0.0 ) - nExp = (short)floor( log10( fVal ) ); + nExp = static_cast<short>(floor( log10( fVal ) )); else if ( fVal < 0.0 ) - nExp = (short)floor( log10( -fVal ) ); + nExp = static_cast<short>(floor( log10( -fVal ) )); nPrecision -= nExp; - short nInteger = (short)pFormat->GetFormatIntegerDigits( nIdx ); + short nInteger = static_cast<short>(pFormat->GetFormatIntegerDigits( nIdx )); if ( nInteger > 1 ) // Engineering notation { short nIncrement = nExp % nInteger; @@ -706,7 +706,7 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat ) const } else { - nPrecision = (short)GetDocOptions().GetStdPrecision(); + nPrecision = static_cast<short>(GetDocOptions().GetStdPrecision()); // #i115512# no rounding for automatic decimals if (nPrecision == static_cast<short>(SvNumberFormatter::UNLIMITED_PRECISION)) return fVal; diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 62fbf6843442..fc38d5add74e 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -624,9 +624,9 @@ bool ScDocument::IdleCalcTextWidth() // true = try next again if (!aScope.hasProgressBar() && pCol->IsFormulaDirty(nRow)) aScope.createProgressBar(); - sal_uInt16 nNewWidth = (sal_uInt16)GetNeededSize( + sal_uInt16 nNewWidth = static_cast<sal_uInt16>(GetNeededSize( aScope.Col(), aScope.Row(), aScope.Tab(), - pDev, nPPTX, nPPTY, aZoomFract,aZoomFract, true, true); // bTotalSize + pDev, nPPTX, nPPTY, aZoomFract,aZoomFract, true, true)); // bTotalSize pColIter->setValue(nNewWidth); aScope.setNeedMore(true); diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx index d2d38231f7b1..3d9ae0ce967b 100644 --- a/sc/source/core/data/documen9.cxx +++ b/sc/source/core/data/documen9.cxx @@ -468,8 +468,8 @@ bool ScDocument::IsPrintEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, for (i=nStartCol; i<=nEndCol; i++) nRight += GetColWidth(i,nTab); - aMMRect.Left() = (long)(nLeft * HMM_PER_TWIPS); - aMMRect.Right() = (long)(nRight * HMM_PER_TWIPS); + aMMRect.Left() = static_cast<long>(nLeft * HMM_PER_TWIPS); + aMMRect.Right() = static_cast<long>(nRight * HMM_PER_TWIPS); } else aMMRect = GetMMRect( nStartCol, nStartRow, nEndCol, nEndRow, nTab ); @@ -680,7 +680,7 @@ bool ScDocument::GetAsianKerning() const void ScDocument::SetAsianKerning(bool bNew) { - nAsianKerning = (sal_uInt8)bNew; + nAsianKerning = static_cast<sal_uInt8>(bNew); if ( mpEditEngine ) mpEditEngine->SetKernAsianPunctuation( static_cast<bool>( nAsianKerning ) ); if ( mpDrawLayer ) diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 1a7f14d95ba5..46ddb669ad04 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -2956,7 +2956,7 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar aCxt, nC1, nR1, nC2, nR2, rMark, nDx, nClipStartRow); } nC1 = nC2 + 1; - nC2 = std::min((SCCOL)(nC1 + nXw), nCol2); + nC2 = std::min(static_cast<SCCOL>(nC1 + nXw), nCol2); } while (nC1 <= nCol2); if (nClipStartRow > nClipEndRow) nClipStartRow = aClipRange.aStart.Row(); @@ -2996,7 +2996,7 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar } nR1 = nR2 + 1; - nR2 = std::min((SCROW)(nR1 + nYw), nRow2); + nR2 = std::min(static_cast<SCROW>(nR1 + nYw), nRow2); } while (nR1 <= nRow2); } @@ -4194,7 +4194,7 @@ sal_uLong ScDocument::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, { // faster for a single row if (nStartRow == nEndRow) - return (sal_uLong) (GetRowHeight( nStartRow, nTab) * fScale); + return static_cast<sal_uLong>(GetRowHeight( nStartRow, nTab) * fScale); // check bounds because this method replaces former for(i=start;i<=end;++i) loops if (nStartRow > nEndRow) diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index 6208789f416e..5f8370180c2c 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -454,7 +454,7 @@ void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam aRef.Set(nCol1, nRow1, nTab, false, true, true); aFormulaBuf.append(aRef.GetRefString(pDoc, nTab)); nCol1++; - nCol2 = std::min( nCol2, (SCCOL)(rParam.aRefFormulaEnd.Col() - + nCol2 = std::min( nCol2, static_cast<SCCOL>(rParam.aRefFormulaEnd.Col() - rParam.aRefFormulaCell.Col() + nCol1 + 1)); } else if (rParam.meMode == ScTabOpParam::Row) // row only diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx index c104a68f2aa9..e32563fd1503 100644 --- a/sc/source/core/data/dpcache.cxx +++ b/sc/source/core/data/dpcache.cxx @@ -709,7 +709,7 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const const ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); // we can only handle one single direct query // #i115431# nField in QueryParam is the sheet column, not the field within the source range - SCCOL nQueryCol = (SCCOL)rEntry.nField; + SCCOL nQueryCol = static_cast<SCCOL>(rEntry.nField); if ( nQueryCol < rParam.nCol1 ) nQueryCol = rParam.nCol1; if ( nQueryCol > rParam.nCol2 ) diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx index f328b04a8f9a..dd81548777a3 100644 --- a/sc/source/core/data/dpgroup.cxx +++ b/sc/source/core/data/dpgroup.cxx @@ -1018,7 +1018,7 @@ long ScDPGroupTableData::GetSourceDim( long nDim ) { if ( getIsDataLayoutDimension( nDim ) ) return nSourceCount; - if ( nDim >= nSourceCount && nDim < nSourceCount +(long) aGroups.size() ) + if ( nDim >= nSourceCount && nDim < nSourceCount +static_cast<long>(aGroups.size()) ) { const ScDPGroupDimension& rGroupDim = aGroups[nDim - nSourceCount]; return rGroupDim.GetSourceDim(); diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index ae9f5a6e0314..48352bac308e 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -153,25 +153,25 @@ void ScDPOutputImpl::OutputDataArea() mnCols.push_back( mnTabEndCol+1); //set last row bottom mnRows.push_back( mnTabEndRow+1); //set last col bottom - bool bAllRows = ( ( mnTabEndRow - mnDataStartRow + 2 ) == (SCROW) mnRows.size() ); + bool bAllRows = ( ( mnTabEndRow - mnDataStartRow + 2 ) == static_cast<SCROW>(mnRows.size()) ); std::sort( mnCols.begin(), mnCols.end()); std::sort( mnRows.begin(), mnRows.end()); - for( SCCOL nCol = 0; nCol < (SCCOL)mnCols.size()-1; nCol ++ ) + for( SCCOL nCol = 0; nCol < static_cast<SCCOL>(mnCols.size())-1; nCol ++ ) { if ( !bAllRows ) { - if ( nCol < (SCCOL)mnCols.size()-2) + if ( nCol < static_cast<SCCOL>(mnCols.size())-2) { - for ( SCROW i = nCol%2; i < (SCROW)mnRows.size()-2; i +=2 ) + for ( SCROW i = nCol%2; i < static_cast<SCROW>(mnRows.size())-2; i +=2 ) OutputBlockFrame( mnCols[nCol], mnRows[i], mnCols[nCol+1]-1, mnRows[i+1]-1 ); if ( mnRows.size()>=2 ) OutputBlockFrame( mnCols[nCol], mnRows[mnRows.size()-2], mnCols[nCol+1]-1, mnRows[mnRows.size()-1]-1 ); } else { - for ( SCROW i = 0 ; i < (SCROW)mnRows.size()-1; i++ ) + for ( SCROW i = 0 ; i < static_cast<SCROW>(mnRows.size())-1; i++ ) OutputBlockFrame( mnCols[nCol], mnRows[i], mnCols[nCol+1]-1, mnRows[i+1]-1 ); } } @@ -785,17 +785,17 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab, //TODO: limit frames to horizontal or vertical? if (bColHeader) { - outputimp.OutputBlockFrame( nCol,nMemberStartRow+(SCROW)nLevel, nCol,nDataStartRow-1 ); + outputimp.OutputBlockFrame( nCol,nMemberStartRow+static_cast<SCROW>(nLevel), nCol,nDataStartRow-1 ); - lcl_SetStyleById( pDoc,nTab, nCol,nMemberStartRow+(SCROW)nLevel, nCol,nDataStartRow-1, + lcl_SetStyleById( pDoc,nTab, nCol,nMemberStartRow+static_cast<SCROW>(nLevel), nCol,nDataStartRow-1, STR_PIVOT_STYLE_TITLE ); lcl_SetStyleById( pDoc,nTab, nCol,nDataStartRow, nCol,nTabEndRow, STR_PIVOT_STYLE_RESULT ); } else { - outputimp.OutputBlockFrame( nMemberStartCol+(SCCOL)nLevel,nRow, nDataStartCol-1,nRow ); - lcl_SetStyleById( pDoc,nTab, nMemberStartCol+(SCCOL)nLevel,nRow, nDataStartCol-1,nRow, + outputimp.OutputBlockFrame( nMemberStartCol+static_cast<SCCOL>(nLevel),nRow, nDataStartCol-1,nRow ); + lcl_SetStyleById( pDoc,nTab, nMemberStartCol+static_cast<SCCOL>(nLevel),nRow, nDataStartCol-1,nRow, STR_PIVOT_STYLE_TITLE ); lcl_SetStyleById( pDoc,nTab, nDataStartCol,nRow, nTabEndCol,nRow, STR_PIVOT_STYLE_RESULT ); @@ -877,20 +877,20 @@ void ScDPOutput::CalcSizes() } nTabStartCol = aStartPos.Col(); - nTabStartRow = aStartPos.Row() + (SCROW)nPageSize; // below page fields + nTabStartRow = aStartPos.Row() + static_cast<SCROW>(nPageSize); // below page fields nMemberStartCol = nTabStartCol; - nMemberStartRow = nTabStartRow + (SCROW) nHeaderSize; - nDataStartCol = nMemberStartCol + (SCCOL)pRowFields.size(); - nDataStartRow = nMemberStartRow + (SCROW)pColFields.size(); + nMemberStartRow = nTabStartRow + static_cast<SCROW>(nHeaderSize); + nDataStartCol = nMemberStartCol + static_cast<SCCOL>(pRowFields.size()); + nDataStartRow = nMemberStartRow + static_cast<SCROW>(pColFields.size()); if ( nColCount > 0 ) - nTabEndCol = nDataStartCol + (SCCOL)nColCount - 1; + nTabEndCol = nDataStartCol + static_cast<SCCOL>(nColCount) - 1; else nTabEndCol = nDataStartCol; // single column will remain empty // if page fields are involved, include the page selection cells if ( !pPageFields.empty() && nTabEndCol < nTabStartCol + 1 ) nTabEndCol = nTabStartCol + 1; if ( nRowCount > 0 ) - nTabEndRow = nDataStartRow + (SCROW)nRowCount - 1; + nTabEndRow = nDataStartRow + static_cast<SCROW>(nRowCount) - 1; else nTabEndRow = nDataStartRow; // single row will remain empty bSizesValid = true; @@ -1012,17 +1012,17 @@ void ScDPOutput::Output() nDataStartCol, nDataStartRow, nTabEndCol, nTabEndRow ); for (size_t nField=0; nField<pColFields.size(); nField++) { - SCCOL nHdrCol = nDataStartCol + (SCCOL)nField; //TODO: check for overflow + SCCOL nHdrCol = nDataStartCol + static_cast<SCCOL>(nField); //TODO: check for overflow FieldCell(nHdrCol, nTabStartRow, nTab, pColFields[nField], true); - SCROW nRowPos = nMemberStartRow + (SCROW)nField; //TODO: check for overflow + SCROW nRowPos = nMemberStartRow + static_cast<SCROW>(nField); //TODO: check for overflow const uno::Sequence<sheet::MemberResult> rSequence = pColFields[nField].maResult; const sheet::MemberResult* pArray = rSequence.getConstArray(); long nThisColCount = rSequence.getLength(); OSL_ENSURE( nThisColCount == nColCount, "count mismatch" ); //TODO: ??? for (long nCol=0; nCol<nThisColCount; nCol++) { - SCCOL nColPos = nDataStartCol + (SCCOL)nCol; //TODO: check for overflow + SCCOL nColPos = nDataStartCol + static_cast<SCCOL>(nCol); //TODO: check for overflow HeaderCell( nColPos, nRowPos, nTab, pArray[nCol], true, nField ); if ( ( pArray[nCol].Flags & sheet::MemberResultFlags::HASMEMBER ) && !( pArray[nCol].Flags & sheet::MemberResultFlags::SUBTOTAL ) ) @@ -1030,7 +1030,7 @@ void ScDPOutput::Output() long nEnd = nCol; while ( nEnd+1 < nThisColCount && ( pArray[nEnd+1].Flags & sheet::MemberResultFlags::CONTINUE ) ) ++nEnd; - SCCOL nEndColPos = nDataStartCol + (SCCOL)nEnd; //TODO: check for overflow + SCCOL nEndColPos = nDataStartCol + static_cast<SCCOL>(nEnd); //TODO: check for overflow if ( nField+1 < pColFields.size()) { if ( nField == pColFields.size() - 2 ) @@ -1062,18 +1062,18 @@ void ScDPOutput::Output() vbSetBorder.resize( nTabEndRow - nDataStartRow + 1, false ); for (size_t nField=0; nField<pRowFields.size(); nField++) { - SCCOL nHdrCol = nTabStartCol + (SCCOL)nField; //TODO: check for overflow + SCCOL nHdrCol = nTabStartCol + static_cast<SCCOL>(nField); //TODO: check for overflow SCROW nHdrRow = nDataStartRow - 1; FieldCell(nHdrCol, nHdrRow, nTab, pRowFields[nField], true); - SCCOL nColPos = nMemberStartCol + (SCCOL)nField; //TODO: check for overflow + SCCOL nColPos = nMemberStartCol + static_cast<SCCOL>(nField); //TODO: check for overflow const uno::Sequence<sheet::MemberResult> rSequence = pRowFields[nField].maResult; const sheet::MemberResult* pArray = rSequence.getConstArray(); long nThisRowCount = rSequence.getLength(); OSL_ENSURE( nThisRowCount == nRowCount, "count mismatch" ); //TODO: ??? for (long nRow=0; nRow<nThisRowCount; nRow++) { - SCROW nRowPos = nDataStartRow + (SCROW)nRow; //TODO: check for overflow + SCROW nRowPos = nDataStartRow + static_cast<SCROW>(nRow); //TODO: check for overflow HeaderCell( nColPos, nRowPos, nTab, pArray[nRow], false, nField ); if ( ( pArray[nRow].Flags & sheet::MemberResultFlags::HASMEMBER ) && !( pArray[nRow].Flags & sheet::MemberResultFlags::SUBTOTAL ) ) @@ -1083,7 +1083,7 @@ void ScDPOutput::Output() long nEnd = nRow; while ( nEnd+1 < nThisRowCount && ( pArray[nEnd+1].Flags & sheet::MemberResultFlags::CONTINUE ) ) ++nEnd; - SCROW nEndRowPos = nDataStartRow + (SCROW)nEnd; //TODO: check for overflow + SCROW nEndRowPos = nDataStartRow + static_cast<SCROW>(nEnd); //TODO: check for overflow outputimp.AddRow( nRowPos ); if ( !vbSetBorder[ nRow ] ) { @@ -1121,13 +1121,13 @@ void ScDPOutput::Output() for (long nRow=0; nRow<nRowCount; nRow++) { - SCROW nRowPos = nDataStartRow + (SCROW)nRow; //TODO: check for overflow + SCROW nRowPos = nDataStartRow + static_cast<SCROW>(nRow); //TODO: check for overflow const sheet::DataResult* pColAry = pRowAry[nRow].getConstArray(); long nThisColCount = pRowAry[nRow].getLength(); OSL_ENSURE( nThisColCount == nColCount, "count mismatch" ); //TODO: ??? for (long nCol=0; nCol<nThisColCount; nCol++) { - SCCOL nColPos = nDataStartCol + (SCCOL)nCol; //TODO: check for overflow + SCCOL nColPos = nDataStartCol + static_cast<SCCOL>(nCol); //TODO: check for overflow DataCell( nColPos, nRowPos, nTab, pColAry[nCol] ); } } diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx index cfb9b6dbbada..d6d6d9e91224 100644 --- a/sc/source/core/data/dpsave.cxx +++ b/sc/source/core/data/dpsave.cxx @@ -149,11 +149,11 @@ void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMemb if ( nVisibleMode != SC_DPSAVEMODE_DONTKNOW ) lcl_SetBoolProperty( xMembProp, - SC_UNO_DP_ISVISIBLE, (bool)nVisibleMode ); + SC_UNO_DP_ISVISIBLE, static_cast<bool>(nVisibleMode) ); if ( nShowDetailsMode != SC_DPSAVEMODE_DONTKNOW ) lcl_SetBoolProperty( xMembProp, - SC_UNO_DP_SHOWDETAILS, (bool)nShowDetailsMode ); + SC_UNO_DP_SHOWDETAILS, static_cast<bool>(nShowDetailsMode) ); if (mpLayoutName) ScUnoHelpFunctions::SetOptionalPropertyValue(xMembProp, SC_UNO_DP_LAYOUTNAME, *mpLayoutName); @@ -538,7 +538,7 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD if ( nUsedHierarchy >= 0 ) { - xDimProp->setPropertyValue( SC_UNO_DP_USEDHIERARCHY, uno::Any((sal_Int32)nUsedHierarchy) ); + xDimProp->setPropertyValue( SC_UNO_DP_USEDHIERARCHY, uno::Any(static_cast<sal_Int32>(nUsedHierarchy)) ); } if ( pReferenceValue ) @@ -603,7 +603,7 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD } if ( nShowEmptyMode != SC_DPSAVEMODE_DONTKNOW ) lcl_SetBoolProperty( xLevProp, - SC_UNO_DP_SHOWEMPTY, (bool)nShowEmptyMode ); + SC_UNO_DP_SHOWEMPTY, static_cast<bool>(nShowEmptyMode) ); lcl_SetBoolProperty( xLevProp, SC_UNO_DP_REPEATITEMLABELS, bRepeatItemLabels ); @@ -1122,10 +1122,10 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie { if ( nIgnoreEmptyMode != SC_DPSAVEMODE_DONTKNOW ) lcl_SetBoolProperty( xSourceProp, - SC_UNO_DP_IGNOREEMPTY, (bool)nIgnoreEmptyMode ); + SC_UNO_DP_IGNOREEMPTY, static_cast<bool>(nIgnoreEmptyMode) ); if ( nRepeatEmptyMode != SC_DPSAVEMODE_DONTKNOW ) lcl_SetBoolProperty( xSourceProp, - SC_UNO_DP_REPEATEMPTY, (bool)nRepeatEmptyMode ); + SC_UNO_DP_REPEATEMPTY, static_cast<bool>(nRepeatEmptyMode) ); } catch(uno::Exception&) { @@ -1212,10 +1212,10 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie { if ( nColumnGrandMode != SC_DPSAVEMODE_DONTKNOW ) lcl_SetBoolProperty( xSourceProp, - SC_UNO_DP_COLGRAND, (bool)nColumnGrandMode ); + SC_UNO_DP_COLGRAND, static_cast<bool>(nColumnGrandMode) ); if ( nRowGrandMode != SC_DPSAVEMODE_DONTKNOW ) lcl_SetBoolProperty( xSourceProp, - SC_UNO_DP_ROWGRAND, (bool)nRowGrandMode ); + SC_UNO_DP_ROWGRAND, static_cast<bool>(nRowGrandMode) ); } } catch(uno::Exception&) diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx index 1e25ab88c514..6b3edc87a034 100644 --- a/sc/source/core/data/dpshttab.cxx +++ b/sc/source/core/data/dpshttab.cxx @@ -149,7 +149,7 @@ sal_uInt32 ScDPTableData::GetNumberFormatByIdx( NfIndexTableOffset eIdx ) bool ScSheetDPData::getIsDataLayoutDimension(long nColumn) { CreateCacheTable(); - return (nColumn ==(long)( aCacheTable.getColSize())); + return (nColumn ==static_cast<long>( aCacheTable.getColSize())); } void ScSheetDPData::SetEmptyFlags( bool bIgnoreEmptyRowsP, bool bRepeatIfEmptyP ) diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx index c8d8a8c5cbe2..aa9ad8926e91 100644 --- a/sc/source/core/data/dptabdat.cxx +++ b/sc/source/core/data/dptabdat.cxx @@ -88,7 +88,7 @@ long ScDPTableData::GetDatePart( long nDateVal, long nHierarchy, long nLevel ) //TODO: use settings for different definitions case 0: nRet = aDate.GetYear(); break; //!... case 1: nRet = aDate.GetWeekOfYear(); break; - case 2: nRet = (long)aDate.GetDayOfWeek(); break; + case 2: nRet = static_cast<long>(aDate.GetDayOfWeek()); break; default: OSL_FAIL("GetDatePart: wrong level"); } @@ -258,7 +258,7 @@ const ScDPItemData* ScDPTableData::GetMemberByIndex( long nDim, long nIndex ) const ::std::vector<SCROW>& nMembers = GetCacheTable().getFieldEntries( nDim ); - return GetCacheTable().getCache().GetItemDataById( (SCCOL) nDim, (SCROW)nMembers[nIndex] ); + return GetCacheTable().getCache().GetItemDataById( static_cast<SCCOL>(nDim), static_cast<SCROW>(nMembers[nIndex]) ); } const ScDPItemData* ScDPTableData::GetMemberById( long nDim, long nId) diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index f54e29113839..94b656a72ccf 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -522,26 +522,26 @@ void ScDPAggData::Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSub case SUBTOTAL_FUNC_AVE: if ( nCount > 0 ) - fResult = fVal / (double) nCount; + fResult = fVal / static_cast<double>(nCount); break; //TODO: use safe mul for fVal * fVal case SUBTOTAL_FUNC_STD: if ( nCount >= 2 ) - fResult = sqrt((fAux - fVal*fVal/(double)(nCount)) / (double)(nCount-1)); + fResult = sqrt((fAux - fVal*fVal/static_cast<double>(nCount)) / static_cast<double>(nCount-1)); break; case SUBTOTAL_FUNC_VAR: if ( nCount >= 2 ) - fResult = (fAux - fVal*fVal/(double)(nCount)) / (double)(nCount-1); + fResult = (fAux - fVal*fVal/static_cast<double>(nCount)) / static_cast<double>(nCount-1); break; case SUBTOTAL_FUNC_STDP: if ( nCount > 0 ) - fResult = sqrt((fAux - fVal*fVal/(double)(nCount)) / (double)nCount); + fResult = sqrt((fAux - fVal*fVal/static_cast<double>(nCount)) / static_cast<double>(nCount)); break; case SUBTOTAL_FUNC_VARP: if ( nCount > 0 ) - fResult = (fAux - fVal*fVal/(double)(nCount)) / (double)nCount; + fResult = (fAux - fVal*fVal/static_cast<double>(nCount)) / static_cast<double>(nCount); break; case SUBTOTAL_FUNC_MED: { @@ -812,19 +812,19 @@ long ScDPResultData::GetRowStartMeasure() const ScSubTotalFunc ScDPResultData::GetMeasureFunction(long nMeasure) const { - OSL_ENSURE((size_t) nMeasure < maMeasureFuncs.size(), "bumm"); + OSL_ENSURE(static_cast<size_t>(nMeasure) < maMeasureFuncs.size(), "bumm"); return maMeasureFuncs[nMeasure]; } const sheet::DataPilotFieldReference& ScDPResultData::GetMeasureRefVal(long nMeasure) const { - OSL_ENSURE((size_t) nMeasure < maMeasureRefs.size(), "bumm"); + OSL_ENSURE(static_cast<size_t>(nMeasure) < maMeasureRefs.size(), "bumm"); return maMeasureRefs[nMeasure]; } sheet::DataPilotFieldOrientation ScDPResultData::GetMeasureRefOrient(long nMeasure) const { - OSL_ENSURE((size_t) nMeasure < maMeasureRefOrients.size(), "bumm"); + OSL_ENSURE(static_cast<size_t>(nMeasure) < maMeasureRefOrients.size(), "bumm"); return maMeasureRefOrients[nMeasure]; } @@ -846,7 +846,7 @@ OUString ScDPResultData::GetMeasureString(long nMeasure, bool bForce, ScSubTotal } else { - OSL_ENSURE((size_t) nMeasure < maMeasureFuncs.size(), "bumm"); + OSL_ENSURE(static_cast<size_t>(nMeasure) < maMeasureFuncs.size(), "bumm"); const ScDPDimension* pDataDim = mrSource.GetDataDimension(nMeasure); if (pDataDim) { @@ -2083,7 +2083,7 @@ void ScDPDataMember::FillDataRow( pDataChild->FillDataRow(pRefChild, rFilterCxt, rSequence, nMeasure, bIsSubTotalRow, rSubState); rFilterCxt.mnCol = nOldCol; // Revert to the old column value before the call. } - rFilterCxt.mnCol += (sal_uInt16)pRefMember->GetSize( nMeasure ); + rFilterCxt.mnCol += static_cast<sal_uInt16>(pRefMember->GetSize( nMeasure )); if ( bTitleLine ) // title column is included in GetSize, so the following --rFilterCxt.mnCol; // positions are calculated with the normal values @@ -3577,7 +3577,7 @@ void ScDPDataDimension::ProcessData( const vector< SCROW >& aDataMembers, const long nCount = maMembers.size(); for (long i=0; i<nCount; i++) { - ScDPDataMember* pMember = maMembers[(sal_uInt16)i]; + ScDPDataMember* pMember = maMembers[static_cast<sal_uInt16>(i)]; // always first member for data layout dim if ( bIsDataLayout || ( !aDataMembers.empty() && pMember->IsNamedItem(aDataMembers[0]) ) ) @@ -3635,7 +3635,7 @@ void ScDPDataDimension::FillDataRow( const ScDPResultMember* pRefMember = pRefDim->GetMember(nMemberPos); if ( pRefMember->IsVisible() ) //TODO: here or in ScDPDataMember::FillDataRow ??? { - const ScDPDataMember* pDataMember = maMembers[(sal_uInt16)nMemberPos]; + const ScDPDataMember* pDataMember = maMembers[static_cast<sal_uInt16>(nMemberPos)]; pDataMember->FillDataRow(pRefMember, rFilterCxt, rSequence, nMemberMeasure, bIsSubTotalRow, rSubState); } } @@ -3663,7 +3663,7 @@ void ScDPDataDimension::UpdateDataRow( const ScDPResultDimension* pRefDim, // Calculate must be called even if the member is not visible (for use as reference value) const ScDPResultMember* pRefMember = pRefDim->GetMember(nMemberPos); - ScDPDataMember* pDataMember = maMembers[(sal_uInt16)nMemberPos]; + ScDPDataMember* pDataMember = maMembers[static_cast<sal_uInt16>(nMemberPos)]; pDataMember->UpdateDataRow( pRefMember, nMemberMeasure, bIsSubTotalRow, rSubState ); } } @@ -3698,7 +3698,7 @@ void ScDPDataDimension::SortMembers( ScDPResultDimension* pRefDim ) ScDPResultMember* pRefMember = pRefDim->GetMember(i); if ( pRefMember->IsVisible() ) //TODO: here or in ScDPDataMember ??? { - ScDPDataMember* pDataMember = maMembers[(sal_uInt16)i]; + ScDPDataMember* pDataMember = maMembers[static_cast<sal_uInt16>(i)]; pDataMember->SortMembers( pRefMember ); } } diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 4aa53ea31b72..ef3318fd4399 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -1542,9 +1542,9 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const OUString& aPropertyName { uno::Any aRet; if ( aPropertyName == SC_UNO_DP_POSITION ) - aRet <<= (sal_Int32) pSource->GetPosition( nDim ); + aRet <<= static_cast<sal_Int32>(pSource->GetPosition( nDim )); else if ( aPropertyName == SC_UNO_DP_USEDHIERARCHY ) - aRet <<= (sal_Int32) getUsedHierarchy(); + aRet <<= static_cast<sal_Int32>(getUsedHierarchy()); else if ( aPropertyName == SC_UNO_DP_ORIENTATION ) { sheet::DataPilotFieldOrientation eVal = getOrientation(); @@ -2225,7 +2225,7 @@ ScDPMembers::ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL ) : case SC_DAPI_LEVEL_YEAR: { const ScDPItemData* pLastNumData = nullptr; - for ( SCROW n = 0; n < (SCROW) pSource->GetData()->GetColumnEntries(nDim).size(); n-- ) + for ( SCROW n = 0; n < static_cast<SCROW>(pSource->GetData()->GetColumnEntries(nDim).size()); n-- ) { const ScDPItemData* pData = GetSrcItemDataByIndex( n ); if ( pData && pData->HasStringData() ) @@ -2241,10 +2241,10 @@ ScDPMembers::ScDPMembers( ScDPSource* pSrc, long nD, long nH, long nL ) : double fLastVal = pLastNumData->GetValue(); long nFirstYear = pSource->GetData()->GetDatePart( - (long)::rtl::math::approxFloor( fFirstVal ), + static_cast<long>(::rtl::math::approxFloor( fFirstVal )), nHier, nLev ); long nLastYear = pSource->GetData()->GetDatePart( - (long)::rtl::math::approxFloor( fLastVal ), + static_cast<long>(::rtl::math::approxFloor( fLastVal )), nHier, nLev ); nMbrCount = nLastYear + 1 - nFirstYear; @@ -2420,7 +2420,7 @@ ScDPMember* ScDPMembers::getByIndex(long nIndex) const double fFirstVal = pSource->GetData()->GetMemberByIndex( nSrcDim, 0 )->GetValue(); long nFirstYear = pSource->GetData()->GetDatePart( - (long)::rtl::math::approxFloor( fFirstVal ), + static_cast<long>(::rtl::math::approxFloor( fFirstVal )), nHier, nLev ); nVal = nFirstYear + nIndex; @@ -2511,7 +2511,7 @@ bool ScDPMember::IsNamedItem(SCROW nIndex) const if (pData->IsValue()) { long nComp = pSource->GetData()->GetDatePart( - (long)::rtl::math::approxFloor( pData->GetValue() ), + static_cast<long>(::rtl::math::approxFloor( pData->GetValue() )), nHier, nLev ); // fValue is converted from integer, so simple comparison works const ScDPItemData* pData2 = GetItemData(); @@ -2658,7 +2658,7 @@ const ScDPItemData* ScDPSource::GetItemDataById(long nDim, long nId) const ScDPItemData* ScDPMembers::GetSrcItemDataByIndex(SCROW nIndex) { const std::vector< SCROW >& memberIds = pSource->GetData()->GetColumnEntries( nDim ); - if ( nIndex >= (long )(memberIds.size()) || nIndex < 0 ) + if ( nIndex >= static_cast<long>(memberIds.size()) || nIndex < 0 ) return nullptr; SCROW nId = memberIds[ nIndex ]; return pSource->GetItemDataById( nDim, nId ); diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx index 3cbc9b28d938..314504ee59d0 100644 --- a/sc/source/core/data/dputil.cxx +++ b/sc/source/core/data/dputil.cxx @@ -316,7 +316,7 @@ sal_Int32 ScDPUtil::getDatePartValue( // (as in the cell functions, ScInterpreter::ScGetHour etc.: seconds are rounded) double fTime = fValue - rtl::math::approxFloor(fValue); - long nSeconds = (long)rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5); + long nSeconds = static_cast<long>(rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5)); switch (nDatePart) { diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 7829b6007544..69a12b261736 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -224,7 +224,7 @@ void initRowInfo(const ScDocument* pDoc, RowInfo* pRowInfo, const SCSIZE nMaxRow RowInfo* pThisRowInfo = &pRowInfo[rArrRow]; pThisRowInfo->pCellInfo = nullptr; // is loaded below - sal_uInt16 nHeight = (sal_uInt16) ( nDocHeight * fRowScale ); + sal_uInt16 nHeight = static_cast<sal_uInt16>( nDocHeight * fRowScale ); if (!nHeight) nHeight = 1; @@ -276,7 +276,7 @@ void initColWidths(RowInfo* pRowInfo, const ScDocument* pDoc, double fColScale, { if (!pDoc->ColHidden(nX, nTab)) { - sal_uInt16 nThisWidth = (sal_uInt16) (pDoc->GetColWidth( nX, nTab ) * fColScale); + sal_uInt16 nThisWidth = static_cast<sal_uInt16>(pDoc->GetColWidth( nX, nTab ) * fColScale); if (!nThisWidth) nThisWidth = 1; @@ -453,7 +453,7 @@ void ScDocument::FillInfo( // TODO: Optimize this loop. if (!ColHidden(nX, nTab)) { - sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * fColScale); + sal_uInt16 nThisWidth = static_cast<sal_uInt16>(GetColWidth( nX, nTab ) * fColScale); if (!nThisWidth) nThisWidth = 1; diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 7c52d3ff9c29..c280d7276681 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -4555,7 +4555,7 @@ bool ScFormulaCell::InterpretFormulaGroup() if (pInterpreter == nullptr || !pInterpreter->interpret(*pDocument, xGroup->mpTopCell->aPos, xGroup, aCode)) { - SAL_INFO("sc.opencl", "interpreting group " << mxGroup << " (state " << (int) mxGroup->meCalcState << ") failed, disabling"); + SAL_INFO("sc.opencl", "interpreting group " << mxGroup << " (state " << static_cast<int>(mxGroup->meCalcState) << ") failed, disabling"); mxGroup->meCalcState = sc::GroupCalcDisabled; // Undo the hack above diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx index 83f0501f5b38..26621c0f8e80 100644 --- a/sc/source/core/data/funcdesc.cxx +++ b/sc/source/core/data/funcdesc.cxx @@ -1166,7 +1166,7 @@ const formula::IFunctionCategory* ScFunctionMgr::getCategory(sal_uInt32 nCategor void ScFunctionMgr::fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription*>& _rLastRUFunctions) const { const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); - sal_uInt16 nLRUFuncCount = std::min( rAppOpt.GetLRUFuncListCount(), (sal_uInt16)LRU_MAX ); + sal_uInt16 nLRUFuncCount = std::min( rAppOpt.GetLRUFuncListCount(), sal_uInt16(LRU_MAX) ); sal_uInt16* pLRUListIds = rAppOpt.GetLRUFuncList(); _rLastRUFunctions.clear(); @@ -1239,7 +1239,7 @@ ScFuncRes::ScFuncRes(const ScFuncDescCore &rEntry, ScFuncDesc* pDesc, bool& rbSu pDesc->pDefArgFlags = new ScFuncDesc::ParameterFlags[nArgs]; for (sal_uInt16 i = 0; i < nArgs; ++i) { - pDesc->pDefArgFlags[i].bOptional = (bool)rEntry.aOptionalArgs[i]; + pDesc->pDefArgFlags[i].bOptional = static_cast<bool>(rEntry.aOptionalArgs[i]); } } diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 7e55499dcd89..be0b44c8782c 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -592,7 +592,7 @@ rtl_TextEncoding ScGlobal::GetCharsetValue( const OUString& rCharSet ) sal_Int32 nVal = rCharSet.toInt32(); if ( nVal == RTL_TEXTENCODING_DONTKNOW ) return osl_getThreadTextEncoding(); - return (rtl_TextEncoding) nVal; + return static_cast<rtl_TextEncoding>(nVal); } // old CharSet values for compatibility else if (rCharSet.equalsIgnoreAsciiCase("ANSI") ) return RTL_TEXTENCODING_MS_1252; diff --git a/sc/source/core/data/markarr.cxx b/sc/source/core/data/markarr.cxx index e159c16ed37e..d296ad05b7cb 100644 --- a/sc/source/core/data/markarr.cxx +++ b/sc/source/core/data/markarr.cxx @@ -71,14 +71,14 @@ bool ScMarkArray::Search( SCROW nRow, SCSIZE& nIndex ) const { i = (nLo + nHi) / 2; if (i > 0) - nStartRow = (long) pData[i - 1].nRow; + nStartRow = static_cast<long>(pData[i - 1].nRow); else nStartRow = -1; - long nEndRow = (long) pData[i].nRow; - if (nEndRow < (long) nRow) + long nEndRow = static_cast<long>(pData[i].nRow); + if (nEndRow < static_cast<long>(nRow)) nLo = ++i; else - if (nStartRow >= (long) nRow) + if (nStartRow >= static_cast<long>(nRow)) nHi = --i; else bFound = true; @@ -88,7 +88,7 @@ bool ScMarkArray::Search( SCROW nRow, SCSIZE& nIndex ) const bFound = false; if (bFound) - nIndex=(SCSIZE)i; + nIndex=static_cast<SCSIZE>(i); else nIndex=0; return bFound; diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 05afb0a14c85..2c701faf5b7f 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -333,7 +333,7 @@ void ScPatternAttr::GetFont( Fraction aFraction( 1,1 ); if (pScale) aFraction = *pScale; - Size aSize( 0, (long) nFontHeight ); + Size aSize( 0, static_cast<long>(nFontHeight) ); MapMode aDestMode = pOutDev->GetMapMode(); MapMode aSrcMode( MapUnit::MapTwip, Point(), aFraction, aFraction ); if (aDestMode.GetMapUnit() == MapUnit::MapPixel && pOutDev->GetDPIX() > 0) @@ -349,7 +349,7 @@ void ScPatternAttr::GetFont( } else /* if pOutDev != NULL */ { - rFont.SetFontSize( Size( 0, (long) nFontHeight ) ); + rFont.SetFontSize( Size( 0, static_cast<long>(nFontHeight) ) ); } // determine effective font color diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx index d5b82e0cd359..0e4e5d172533 100644 --- a/sc/source/core/data/stlsheet.cxx +++ b/sc/source/core/data/stlsheet.cxx @@ -167,7 +167,7 @@ SfxItemSet& ScStyleSheet::GetItemSet() SfxItemSet& rHFSet = aHFSetItem.GetItemSet(); SvxSizeItem aHFSizeItem( // 0,5 cm + distance ATTR_PAGE_SIZE, - Size( 0, (long)( 500 / HMM_PER_TWIPS ) + HFDIST_CM ) ); + Size( 0, long( 500 / HMM_PER_TWIPS ) + HFDIST_CM ) ); SvxULSpaceItem aHFDistItem ( HFDIST_CM,// nUp HFDIST_CM,// nLow diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 7b275495eb3b..d8be03909d21 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -312,8 +312,8 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName, if ( pDrawLayer->ScAddPage( nTab ) ) // sal_False (not inserted) during Undo { pDrawLayer->ScRenamePage( nTab, aName ); - sal_uLong const nx = (sal_uLong) ((double) (MAXCOL+1) * STD_COL_WIDTH * HMM_PER_TWIPS ); - sal_uLong ny = (sal_uLong) ((double) (MAXROW+1) * ScGlobal::nStdRowHeight * HMM_PER_TWIPS ); + sal_uLong const nx = sal_uLong(double(MAXCOL+1) * STD_COL_WIDTH * HMM_PER_TWIPS ); + sal_uLong ny = static_cast<sal_uLong>(double(MAXROW+1) * ScGlobal::nStdRowHeight * HMM_PER_TWIPS ); pDrawLayer->SetPageSize( static_cast<sal_uInt16>(nTab), Size( nx, ny ), false ); } } @@ -1903,7 +1903,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d aCol[rCol].SetTextWidth(nRow, static_cast<sal_uInt16>(nPixel)); } - long nTwips = (long) (nPixel / nPPTX); + long nTwips = static_cast<long>(nPixel / nPPTX); long nDocW = GetColWidth( rCol ); long nMissing = nTwips - nDocW; diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index bf6a7d5f9576..de8eb7a9f5ba 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2989,7 +2989,7 @@ sal_uInt16 ScTable::GetColWidth( SCCOL nCol, bool bHiddenAsZero ) const return mpColWidth->GetValue(nCol); } else - return (sal_uInt16) STD_COL_WIDTH; + return sal_uInt16(STD_COL_WIDTH); } sal_uLong ScTable::GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const @@ -3021,7 +3021,7 @@ sal_uInt16 ScTable::GetOriginalWidth( SCCOL nCol ) const // always the se if (ValidCol(nCol) && mpColWidth) return mpColWidth->GetValue(nCol); else - return (sal_uInt16) STD_COL_WIDTH; + return sal_uInt16(STD_COL_WIDTH); } sal_uInt16 ScTable::GetCommonWidth( SCCOL nEndCol ) const @@ -3139,7 +3139,7 @@ sal_uLong ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZ return nHeight; } else - return (nEndRow - nStartRow + 1) * (sal_uLong)ScGlobal::nStdRowHeight; + return (nEndRow - nStartRow + 1) * static_cast<sal_uLong>(ScGlobal::nStdRowHeight); } sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const @@ -3179,7 +3179,7 @@ sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fS return nHeight; } else - return (sal_uLong) ((nEndRow - nStartRow + 1) * ScGlobal::nStdRowHeight * fScale); + return static_cast<sal_uLong>((nEndRow - nStartRow + 1) * ScGlobal::nStdRowHeight * fScale); } sal_uInt16 ScTable::GetOriginalHeight( SCROW nRow ) const // non-0 even if hidden @@ -3749,8 +3749,8 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos const long nMax = ::std::numeric_limits<long>::max(); // #i113884# Avoid int32 overflow with possible negative results than can cause bad effects. // If the draw page size is smaller than all rows, only the bottom of the sheet is affected. - long x = ( fValX > (double)nMax ) ? nMax : (long) fValX; - long y = ( fValY > (double)nMax ) ? nMax : (long) fValY; + long x = ( fValX > static_cast<double>(nMax) ) ? nMax : static_cast<long>(fValX); + long y = ( fValY > static_cast<double>(nMax) ) ? nMax : static_cast<long>(fValY); if ( IsLayoutRTL() ) // IsNegativePage x = -x; diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 17997bc67b28..3396c50effc7 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -888,7 +888,7 @@ void ScTable::SortReorderByColumn( // Cut formula grouping at row and reference boundaries before the reordering. ScRange aSortRange(nStart, nRow1, nTab, nLast, nRow2, nTab); - for (SCCOL nCol = nStart; nCol <= (SCCOL)nLast; ++nCol) + for (SCCOL nCol = nStart; nCol <= static_cast<SCCOL>(nLast); ++nCol) aCol[nCol].SplitFormulaGroupByRelativeRef(aSortRange); // Collect all listeners of cell broadcasters of sorted range. @@ -897,7 +897,7 @@ void ScTable::SortReorderByColumn( if (!pArray->IsUpdateRefs()) { // Collect listeners of cell broadcasters. - for (SCCOL nCol = nStart; nCol <= (SCCOL)nLast; ++nCol) + for (SCCOL nCol = nStart; nCol <= static_cast<SCCOL>(nLast); ++nCol) aCol[nCol].CollectListeners(aCellListeners, nRow1, nRow2); // Remove any duplicate listener entries. We must ensure that we @@ -939,7 +939,7 @@ void ScTable::SortReorderByColumn( // Reset formula cell positions which became out-of-sync after column reordering. bool bUpdateRefs = pArray->IsUpdateRefs(); - for (SCCOL nCol = nStart; nCol <= (SCCOL)nLast; ++nCol) + for (SCCOL nCol = nStart; nCol <= static_cast<SCCOL>(nLast); ++nCol) aCol[nCol].ResetFormulaCellPositions(nRow1, nRow2, bUpdateRefs); if (pArray->IsUpdateRefs()) @@ -957,7 +957,7 @@ void ScTable::SortReorderByColumn( // Collect all listeners within sorted range ahead of time. std::vector<SvtListener*> aListeners; - for (SCCOL nCol = nStart; nCol <= (SCCOL)nLast; ++nCol) + for (SCCOL nCol = nStart; nCol <= static_cast<SCCOL>(nLast); ++nCol) aCol[nCol].CollectListeners(aListeners, nRow1, nRow2); // Get all area listeners that listen on one column within the range @@ -1008,7 +1008,7 @@ void ScTable::SortReorderByColumn( // Re-join formulas at row boundaries now that all the references have // been adjusted for column reordering. - for (SCCOL nCol = nStart; nCol <= (SCCOL)nLast; ++nCol) + for (SCCOL nCol = nStart; nCol <= static_cast<SCCOL>(nLast); ++nCol) { sc::CellStoreType& rCells = aCol[nCol].maCells; sc::CellStoreType::position_type aPos = rCells.position(nRow1); @@ -2205,7 +2205,7 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam ) ScTokenArray aArr; aArr.AddOpCode( ocSubTotal ); aArr.AddOpCode( ocOpen ); - aArr.AddDouble( (double) eResFunc[nResult] ); + aArr.AddDouble( static_cast<double>(eResFunc[nResult]) ); aArr.AddOpCode( ocSep ); aArr.AddDoubleReference( aRef ); aArr.AddOpCode( ocClose ); diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 14e93b45d1c8..64ac8f3088b1 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -66,7 +66,7 @@ #include <math.h> #include <memory> -#define D_MAX_LONG_ (double) 0x7fffffff +#define D_MAX_LONG_ double(0x7fffffff) namespace { @@ -281,9 +281,9 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, { long nCmpInc = 0; FillDateCmd eType; - long nDDiff = aDate2.GetDay() - (long) aDate1.GetDay(); - long nMDiff = aDate2.GetMonth() - (long) aDate1.GetMonth(); - long nYDiff = aDate2.GetYear() - (long) aDate1.GetYear(); + long nDDiff = aDate2.GetDay() - static_cast<long>(aDate1.GetDay()); + long nMDiff = aDate2.GetMonth() - static_cast<long>(aDate1.GetMonth()); + long nYDiff = aDate2.GetYear() - static_cast<long>(aDate1.GetYear()); if ( nDDiff ) { eType = FILL_DAY; @@ -312,9 +312,9 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } else { - nDDiff = aDate2.GetDay() - (long) aDate1.GetDay(); - nMDiff = aDate2.GetMonth() - (long) aDate1.GetMonth(); - nYDiff = aDate2.GetYear() - (long) aDate1.GetYear(); + nDDiff = aDate2.GetDay() - static_cast<long>(aDate1.GetDay()); + nMDiff = aDate2.GetMonth() - static_cast<long>(aDate1.GetMonth()); + nYDiff = aDate2.GetYear() - static_cast<long>(aDate1.GetYear()); if (nDDiff || ( nMDiff + 12 * nYDiff != nCmpInc )) bVal = false; } @@ -836,7 +836,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW { nCol2 = nCol1; // use only first column nSrcCount = nRow2 - nRow1 + 1; - nIndex = ((long)nEndY) - nRow1; // can be negative + nIndex = static_cast<long>(nEndY) - nRow1; // can be negative if ( nEndY >= nRow1 ) eFillDir = FILL_TO_BOTTOM; else @@ -846,7 +846,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW { nEndY = nRow2 = nRow1; // use only first row nSrcCount = nCol2 - nCol1 + 1; - nIndex = ((long)nEndX) - nCol1; // can be negative + nIndex = static_cast<long>(nEndX) - nCol1; // can be negative if ( nEndX >= nCol1 ) eFillDir = FILL_TO_RIGHT; else @@ -969,11 +969,11 @@ OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW bool bBooleanCell = (pDocument->GetFormatTable()->GetType( nNumFmt) == SvNumFormatType::LOGICAL); if (!bBooleanCell) - nVal += (double) nDelta; + nVal += static_cast<double>(nDelta); } else { - nVal += (double) nDelta; + nVal += static_cast<double>(nDelta); } } @@ -1007,7 +1007,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW aValue = aCell.getString(pDocument); nHeadNoneTail = lcl_DecompValueString( aValue, nVal ); if ( nHeadNoneTail ) - nStart = (double)nVal; + nStart = static_cast<double>(nVal); else nStart = 0.0; } @@ -1027,7 +1027,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW if ( eFillCmd == FILL_LINEAR ) { double nAdd = nInc; - bValueOk = ( SubTotal::SafeMult( nAdd, (double) nIndex ) && + bValueOk = ( SubTotal::SafeMult( nAdd, static_cast<double>(nIndex) ) && SubTotal::SafePlus( nStart, nAdd ) ); } else // date @@ -1050,15 +1050,15 @@ OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW if ( nHeadNoneTail < 0 ) { if (aValue == ScGlobal::GetOrdinalSuffix( nVal)) - aValue = ScGlobal::GetOrdinalSuffix( (sal_Int32)nStart ); + aValue = ScGlobal::GetOrdinalSuffix( static_cast<sal_Int32>(nStart) ); - aValue = lcl_ValueString( (sal_Int32)nStart, nMinDigits ) + aValue; + aValue = lcl_ValueString( static_cast<sal_Int32>(nStart), nMinDigits ) + aValue; } else { if ( nHeadNoneTail == 2 && nStart >= 0 ) // Put back the '+' aValue += "+"; - aValue += lcl_ValueString( (sal_Int32)nStart, nMinDigits ); + aValue += lcl_ValueString( static_cast<sal_Int32>(nStart), nMinDigits ); } } else @@ -1091,7 +1091,7 @@ void ScTable::IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillD const sal_uInt16 nMinYear = 1583; const sal_uInt16 nMaxYear = 9956; - long nInc = (long) nStep; // upper/lower limits ? + long nInc = static_cast<long>(nStep); // upper/lower limits ? Date aNullDate = pDocument->GetFormatTable()->GetNullDate(); Date aDate = aNullDate; aDate.AddDays(rVal); @@ -1151,8 +1151,8 @@ void ScTable::IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillD aDate = Date( 31,12, nMaxYear ); else { - aDate.SetMonth((sal_uInt16) nMonth); - aDate.SetYear((sal_uInt16) nYear); + aDate.SetMonth(static_cast<sal_uInt16>(nMonth)); + aDate.SetYear(static_cast<sal_uInt16>(nYear)); aDate.SetDay( std::min( Date::GetDaysInMonth( nMonth, nYear), nDayOfMonth ) ); } } @@ -1166,7 +1166,7 @@ void ScTable::IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillD else if ( nYear > nMaxYear ) aDate = Date( 31,12, nMaxYear ); else - aDate.SetYear((sal_uInt16) nYear); + aDate.SetYear(static_cast<sal_uInt16>(nYear)); } break; default: @@ -1451,9 +1451,9 @@ void ScTable::FillAutoSimple( { sal_Int32 nNextValue; if (nStringValue < 0) - nNextValue = nStringValue - (sal_Int32)nDelta; + nNextValue = nStringValue - static_cast<sal_Int32>(nDelta); else - nNextValue = nStringValue + (sal_Int32)nDelta; + nNextValue = nStringValue + static_cast<sal_Int32>(nDelta); if ( nHeadNoneTail < 0 ) { @@ -1751,7 +1751,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, // to avoid accumulating rounding errors nVal = nStartVal; double nAdd = nStepValue; - if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) || + if ( !SubTotal::SafeMult( nAdd, static_cast<double>(++nIndex) ) || !SubTotal::SafePlus( nVal, nAdd ) ) bError = true; } @@ -1817,13 +1817,13 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, { if ( nStepValue >= 0 ) { - if ( nMaxValue >= (double)LONG_MAX ) - nMaxValue = (double)LONG_MAX - 1; + if ( nMaxValue >= double(LONG_MAX) ) + nMaxValue = double(LONG_MAX) - 1; } else { - if ( nMaxValue <= (double)LONG_MIN ) - nMaxValue = (double)LONG_MIN + 1; + if ( nMaxValue <= double(LONG_MIN) ) + nMaxValue = double(LONG_MIN) + 1; } OUString aValue; if (eCellType == CELLTYPE_STRING) @@ -1835,14 +1835,14 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, short nHeadNoneTail = lcl_DecompValueString( aValue, nStringValue, &nMinDigits ); if ( nHeadNoneTail ) { - double nStartVal = (double)nStringValue; + double nStartVal = static_cast<double>(nStringValue); double nVal = nStartVal; long nIndex = 0; bool bError = false; bool bOverflow = false; bool bIsOrdinalSuffix = aValue == ScGlobal::GetOrdinalSuffix( - (sal_Int32)nStartVal); + static_cast<sal_Int32>(nStartVal)); rInner = nIStart; while (true) // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes @@ -1859,7 +1859,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, // to avoid accumulating rounding errors nVal = nStartVal; double nAdd = nStepValue; - if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) || + if ( !SubTotal::SafeMult( nAdd, static_cast<double>(++nIndex) ) || !SubTotal::SafePlus( nVal, nAdd ) ) bError = true; } @@ -1898,7 +1898,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, aCol[nCol].SetError(static_cast<SCROW>(nRow), FormulaError::IllegalFPOperation); else { - nStringValue = (sal_Int32)nVal; + nStringValue = static_cast<sal_Int32>(nVal); OUString aStr; if ( nHeadNoneTail < 0 ) { diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index d7dcc367117c..af36752dc05a 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -329,8 +329,8 @@ bool ScTable::Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, if (!bAll && rSearchItem.GetBackward()) { SCROW nLastNonFilteredRow = MAXROW + 1; - nCol = std::min(nCol, (SCCOL)(nLastCol + 1)); - nRow = std::min(nRow, (SCROW)(nLastRow + 1)); + nCol = std::min(nCol, static_cast<SCCOL>(nLastCol + 1)); + nRow = std::min(nRow, static_cast<SCROW>(nLastRow + 1)); if (rSearchItem.GetRowDirection()) { nCol--; diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 433dd55c70a7..946f964cda05 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -533,7 +533,7 @@ bool ScValidationData::IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos bOk = !bIsVal; // only Text if ( bOk ) { - double nLenVal = (double) aString.getLength(); + double nLenVal = static_cast<double>(aString.getLength()); ScRefCellValue aTmpCell(nLenVal); bOk = IsCellValid(aTmpCell, rPos); } @@ -764,8 +764,8 @@ bool ScValidationData::GetSelectionFromFormula( //For external reference and a formula that results in an area or array, date formats are still lost. if ( bRef ) { - pDocument->GetInputString((SCCOL)(nCol+aRange.aStart.Col()), - (SCROW)(nRow+aRange.aStart.Row()), aRange.aStart.Tab() , aValStr); + pDocument->GetInputString(static_cast<SCCOL>(nCol+aRange.aStart.Col()), + static_cast<SCROW>(nRow+aRange.aStart.Row()), aRange.aStart.Tab() , aValStr); } else { diff --git a/sc/source/core/inc/parclass.hxx b/sc/source/core/inc/parclass.hxx index 531c110ac98a..57efd73a849f 100644 --- a/sc/source/core/inc/parclass.hxx +++ b/sc/source/core/inc/parclass.hxx @@ -64,7 +64,7 @@ public: ForceArray or ReferenceOrForceArray. */ static bool HasForceArray( OpCode eOp) { - return 0 <= (short)eOp && + return 0 <= static_cast<short>(eOp) && eOp <= SC_OPCODE_LAST_OPCODE_ID && pData[eOp].bHasForceArray; } diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 0aed2c51bcee..e29ecaac9aaf 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -170,7 +170,7 @@ size_t VectorRef::Marshal( cl_kernel k, int argno, int, cl_program ) if (pHostBuffer) { mpClmem = clCreateBuffer(kEnv.mpkContext, - (cl_mem_flags)CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, + cl_mem_flags(CL_MEM_READ_ONLY) | CL_MEM_USE_HOST_PTR, szHostBuffer, pHostBuffer, &err); if (CL_SUCCESS != err) @@ -183,7 +183,7 @@ size_t VectorRef::Marshal( cl_kernel k, int argno, int, cl_program ) szHostBuffer = sizeof(double); // a dummy small value // Marshal as a buffer of NANs mpClmem = clCreateBuffer(kEnv.mpkContext, - (cl_mem_flags)CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR, + cl_mem_flags(CL_MEM_READ_ONLY) | CL_MEM_ALLOC_HOST_PTR, szHostBuffer, nullptr, &err); if (CL_SUCCESS != err) throw OpenCLError("clCreateBuffer", err, __FILE__, __LINE__); @@ -782,7 +782,7 @@ size_t DynamicKernelStringArgument::Marshal( cl_kernel k, int argno, int, cl_pro { // Marshal strings. Right now we pass hashes of these string mpClmem = clCreateBuffer(kEnv.mpkContext, - (cl_mem_flags)CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR, + cl_mem_flags(CL_MEM_READ_ONLY) | CL_MEM_ALLOC_HOST_PTR, szHostBuffer, nullptr, &err); if (CL_SUCCESS != err) throw OpenCLError("clCreateBuffer", err, __FILE__, __LINE__); @@ -813,7 +813,7 @@ size_t DynamicKernelStringArgument::Marshal( cl_kernel k, int argno, int, cl_pro szHostBuffer = sizeof(cl_int); // a dummy small value // Marshal as a buffer of NANs mpClmem = clCreateBuffer(kEnv.mpkContext, - (cl_mem_flags)CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR, + cl_mem_flags(CL_MEM_READ_ONLY) | CL_MEM_ALLOC_HOST_PTR, szHostBuffer, nullptr, &err); if (CL_SUCCESS != err) throw OpenCLError("clCreateBuffer", err, __FILE__, __LINE__); @@ -1445,7 +1445,7 @@ public: mpDVR->GetArrays()[Base::mnIndex].mpNumericArray); size_t szHostBuffer = nInput * sizeof(double); Base::mpClmem = clCreateBuffer(kEnv.mpkContext, - (cl_mem_flags)CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, + cl_mem_flags(CL_MEM_READ_ONLY) | CL_MEM_USE_HOST_PTR, szHostBuffer, pHostBuffer, &err); SAL_INFO("sc.opencl", "Created buffer " << Base::mpClmem << " size " << nInput << "*" << sizeof(double) << "=" << szHostBuffer << " using host buffer " << pHostBuffer); @@ -1493,7 +1493,7 @@ public: throw OpenCLError("clSetKernelArg", err, __FILE__, __LINE__); // set work group size and execute - size_t global_work_size[] = { 256, (size_t)w }; + size_t global_work_size[] = { 256, static_cast<size_t>(w) }; size_t const local_work_size[] = { 256, 1 }; SAL_INFO("sc.opencl", "Enqueing kernel " << redKernel); err = clEnqueueNDRangeKernel(kEnv.mpkCmdQueue, redKernel, 2, nullptr, @@ -1551,7 +1551,7 @@ public: throw OpenCLError("clSetKernelArg", err, __FILE__, __LINE__); // set work group size and execute - size_t global_work_size1[] = { 256, (size_t)w }; + size_t global_work_size1[] = { 256, static_cast<size_t>(w) }; size_t const local_work_size1[] = { 256, 1 }; SAL_INFO("sc.opencl", "Enqueing kernel " << redKernel); err = clEnqueueNDRangeKernel(kEnv.mpkCmdQueue, redKernel, 2, nullptr, @@ -1581,7 +1581,7 @@ public: mpClmem2 = nullptr; } mpClmem2 = clCreateBuffer(kEnv.mpkContext, - (cl_mem_flags)CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, + cl_mem_flags(CL_MEM_READ_WRITE) | CL_MEM_COPY_HOST_PTR, w * sizeof(double) * 2, pAllBuffer.get(), &err); if (CL_SUCCESS != err) throw OpenCLError("clCreateBuffer", err, __FILE__, __LINE__); @@ -2262,7 +2262,7 @@ public: throw OpenCLError("clSetKernelArg", err, __FILE__, __LINE__); // set work group size and execute - size_t global_work_size[] = { 256, (size_t)nVectorWidth }; + size_t global_work_size[] = { 256, static_cast<size_t>(nVectorWidth) }; size_t const local_work_size[] = { 256, 1 }; SAL_INFO("sc.opencl", "Enqueing kernel " << redKernel); err = clEnqueueNDRangeKernel(kEnv.mpkCmdQueue, redKernel, 2, nullptr, @@ -2346,7 +2346,7 @@ public: if (CL_SUCCESS != err) throw OpenCLError("clSetKernelArg", err, __FILE__, __LINE__); // set work group size and execute - size_t global_work_size[] = { 256, (size_t)nVectorWidth }; + size_t global_work_size[] = { 256, static_cast<size_t>(nVectorWidth) }; size_t const local_work_size[] = { 256, 1 }; SAL_INFO("sc.opencl", "Enqueing kernel " << redKernel); err = clEnqueueNDRangeKernel(kEnv.mpkCmdQueue, redKernel, 2, nullptr, @@ -3745,7 +3745,7 @@ std::string const & DynamicKernel::GetMD5() RTL_DIGEST_LENGTH_MD5); for (sal_uInt8 i : result) { - md5s << std::hex << (int)i; + md5s << std::hex << static_cast<int>(i); } mKernelHash = md5s.str(); } @@ -3877,7 +3877,7 @@ void DynamicKernel::Launch( size_t nr ) cl_int err; // The results mpResClmem = clCreateBuffer(kEnv.mpkContext, - (cl_mem_flags)CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, + cl_mem_flags(CL_MEM_READ_WRITE) | CL_MEM_ALLOC_HOST_PTR, nr * sizeof(double), nullptr, &err); if (CL_SUCCESS != err) throw OpenCLError("clCreateBuffer", err, __FILE__, __LINE__); diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx index ec9aed38a4b8..301deeeabc9a 100644 --- a/sc/source/core/opencl/op_spreadsheet.cxx +++ b/sc/source/core/opencl/op_spreadsheet.cxx @@ -83,7 +83,7 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss, arg += secondParaWidth; CheckSubArgumentIsNan(ss,vSubArguments,arg++); - if (vSubArguments.size() == (unsigned int)(3+(secondParaWidth-1))) + if (vSubArguments.size() == static_cast<unsigned int>(3+(secondParaWidth-1))) { ss << " double tmp"; ss << 3+(secondParaWidth-1); diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx index 1517ae59e6fb..5e33c7323dd8 100644 --- a/sc/source/core/tool/addincol.cxx +++ b/sc/source/core/tool/addincol.cxx @@ -1243,7 +1243,7 @@ bool ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncData& r // AddInArgumentType_CALLER is already left out in FuncData - rDesc.nArgCount = (sal_uInt16)nArgCount; + rDesc.nArgCount = static_cast<sal_uInt16>(nArgCount); if ( nArgCount ) { bool bMultiple = false; diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx index 36ed41b0d8c9..5c93183e7371 100644 --- a/sc/source/core/tool/address.cxx +++ b/sc/source/core/tool/address.cxx @@ -2187,11 +2187,11 @@ static void lcl_ScRange_Format_XL_Header( OUStringBuffer& rString, const ScRange // helpers used in ScRange::Format static inline bool lcl_ColAbsFlagDiffer(const ScRefFlags nFlags) { - return (bool)(nFlags & ScRefFlags::COL_ABS) != (bool)(nFlags & ScRefFlags::COL2_ABS); + return static_cast<bool>(nFlags & ScRefFlags::COL_ABS) != static_cast<bool>(nFlags & ScRefFlags::COL2_ABS); } static inline bool lcl_RowAbsFlagDiffer(const ScRefFlags nFlags) { - return (bool)(nFlags & ScRefFlags::ROW_ABS) != (bool)(nFlags & ScRefFlags::ROW2_ABS); + return static_cast<bool>(nFlags & ScRefFlags::ROW_ABS) != static_cast<bool>(nFlags & ScRefFlags::ROW2_ABS); } OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc, diff --git a/sc/source/core/tool/adiasync.cxx b/sc/source/core/tool/adiasync.cxx index 9b93b3917c48..5f02238a7601 100644 --- a/sc/source/core/tool/adiasync.cxx +++ b/sc/source/core/tool/adiasync.cxx @@ -56,7 +56,7 @@ ScAddInAsync::ScAddInAsync(sal_uLong nHandleP, LegacyFuncData* pFuncData, ScDocu ScAddInAsync::~ScAddInAsync() { // in dTor because of theAddInAsyncTbl.DeleteAndDestroy in ScGlobal::Clear - mpFuncData->Unadvice( (double)nHandle ); + mpFuncData->Unadvice( static_cast<double>(nHandle) ); if ( meType == ParamType::PTR_STRING && pStr ) // include type comparison because of union delete pStr; delete pDocs; diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx index 39480a3680c3..3e875ae1470e 100644 --- a/sc/source/core/tool/appoptio.cxx +++ b/sc/source/core/tool/appoptio.cxx @@ -136,7 +136,7 @@ static void lcl_SetLastFunctions( ScAppOptions& rOpt, const Any& rValue ) const sal_Int32* pArray = aSeq.getConstArray(); std::unique_ptr<sal_uInt16[]> pUShorts(new sal_uInt16[nCount]); for (long i=0; i<nCount; i++) - pUShorts[i] = (sal_uInt16) pArray[i]; + pUShorts[i] = static_cast<sal_uInt16>(pArray[i]); rOpt.SetLRUFuncList( pUShorts.get(), sal::static_int_cast<sal_uInt16>(nCount) ); } @@ -355,7 +355,7 @@ ScAppCfg::ScAppCfg() : nStatusBarFuncMulti = nUIntValTmp; break; case SCLAYOUTOPT_ZOOMVAL: - if (pValues[nProp] >>= nIntVal) SetZoom( (sal_uInt16) nIntVal ); + if (pValues[nProp] >>= nIntVal) SetZoom( static_cast<sal_uInt16>(nIntVal) ); break; case SCLAYOUTOPT_ZOOMTYPE: if (pValues[nProp] >>= nIntVal) SetZoomType( (SvxZoomType) nIntVal ); @@ -426,16 +426,16 @@ ScAppCfg::ScAppCfg() : switch(nProp) { case SCREVISOPT_CHANGE: - if (pValues[nProp] >>= nIntVal) SetTrackContentColor( (sal_uInt32) nIntVal ); + if (pValues[nProp] >>= nIntVal) SetTrackContentColor( static_cast<sal_uInt32>(nIntVal) ); break; case SCREVISOPT_INSERTION: - if (pValues[nProp] >>= nIntVal) SetTrackInsertColor( (sal_uInt32) nIntVal ); + if (pValues[nProp] >>= nIntVal) SetTrackInsertColor( static_cast<sal_uInt32>(nIntVal) ); break; case SCREVISOPT_DELETION: - if (pValues[nProp] >>= nIntVal) SetTrackDeleteColor( (sal_uInt32) nIntVal ); + if (pValues[nProp] >>= nIntVal) SetTrackDeleteColor( static_cast<sal_uInt32>(nIntVal) ); break; case SCREVISOPT_MOVEDENTRY: - if (pValues[nProp] >>= nIntVal) SetTrackMoveColor( (sal_uInt32) nIntVal ); + if (pValues[nProp] >>= nIntVal) SetTrackMoveColor( static_cast<sal_uInt32>(nIntVal) ); break; } } @@ -551,13 +551,13 @@ ScAppCfg::ScAppCfg() : switch(nProp) { case SCLAYOUTOPT_MEASURE: - pValues[nProp] <<= (sal_Int32) GetAppMetric(); + pValues[nProp] <<= static_cast<sal_Int32>(GetAppMetric()); break; case SCLAYOUTOPT_STATUSBAR: pValues[nProp] <<= lcl_ConvertStatusBarFuncSetToSingle( GetStatusFunc() ); break; case SCLAYOUTOPT_ZOOMVAL: - pValues[nProp] <<= (sal_Int32) GetZoom(); + pValues[nProp] <<= static_cast<sal_Int32>(GetZoom()); break; case SCLAYOUTOPT_ZOOMTYPE: pValues[nProp] <<= (sal_Int32) GetZoomType(); @@ -608,16 +608,16 @@ IMPL_LINK_NOARG(ScAppCfg, RevisionCommitHdl, ScLinkConfigItem&, void) switch(nProp) { case SCREVISOPT_CHANGE: - pValues[nProp] <<= (sal_Int32) GetTrackContentColor(); + pValues[nProp] <<= static_cast<sal_Int32>(GetTrackContentColor()); break; case SCREVISOPT_INSERTION: - pValues[nProp] <<= (sal_Int32) GetTrackInsertColor(); + pValues[nProp] <<= static_cast<sal_Int32>(GetTrackInsertColor()); break; case SCREVISOPT_DELETION: - pValues[nProp] <<= (sal_Int32) GetTrackDeleteColor(); + pValues[nProp] <<= static_cast<sal_Int32>(GetTrackDeleteColor()); break; case SCREVISOPT_MOVEDENTRY: - pValues[nProp] <<= (sal_Int32) GetTrackMoveColor(); + pValues[nProp] <<= static_cast<sal_Int32>(GetTrackMoveColor()); break; } } @@ -635,7 +635,7 @@ IMPL_LINK_NOARG(ScAppCfg, ContentCommitHdl, ScLinkConfigItem&, void) switch(nProp) { case SCCONTENTOPT_LINK: - pValues[nProp] <<= (sal_Int32) GetLinkMode(); + pValues[nProp] <<= static_cast<sal_Int32>(GetLinkMode()); break; } } diff --git a/sc/source/core/tool/callform.cxx b/sc/source/core/tool/callform.cxx index 7ff7553172d9..1acfa271e5e3 100644 --- a/sc/source/core/tool/callform.cxx +++ b/sc/source/core/tool/callform.cxx @@ -188,7 +188,7 @@ bool InitExternalFunc(const OUString& rModuleName) if ( fpSetLanguage ) { LanguageType eLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType(); - sal_uInt16 nLanguage = (sal_uInt16) eLanguage; + sal_uInt16 nLanguage = static_cast<sal_uInt16>(eLanguage); (*reinterpret_cast<SetLanguagePtr>(fpSetLanguage))( nLanguage ); } diff --git a/sc/source/core/tool/chartpos.cxx b/sc/source/core/tool/chartpos.cxx index 87138b9885cd..db2469d853e5 100644 --- a/sc/source/core/tool/chartpos.cxx +++ b/sc/source/core/tool/chartpos.cxx @@ -157,7 +157,7 @@ void ScChartPositioner::GlueState() eGlue = ScChartGlue::Cols; return; } - sal_uLong nCR = (sal_uLong)nC * nR; + sal_uLong nCR = static_cast<sal_uLong>(nC) * nR; /* TODO: @@ -183,7 +183,7 @@ void ScChartPositioner::GlueState() nRow2 = pR->aEnd.Row() - nStartRow; for ( nCol = nCol1; nCol <= nCol2; nCol++ ) { - p = pA.get() + (sal_uLong)nCol * nR + nRow1; + p = pA.get() + static_cast<sal_uLong>(nCol) * nR + nRow1; for ( nRow = nRow1; nRow <= nRow2; nRow++, p++ ) *p = CellState::Occupied; } @@ -193,7 +193,7 @@ void ScChartPositioner::GlueState() bool bGlueCols = false; for ( nCol = 0; bGlue && nCol < nC; nCol++ ) { // iterate columns and try to mark as unused - p = pA.get() + (sal_uLong)nCol * nR; + p = pA.get() + static_cast<sal_uLong>(nCol) * nR; for ( nRow = 0; bGlue && nRow < nR; nRow++, p++ ) { if ( *p == CellState::Occupied ) @@ -208,7 +208,7 @@ void ScChartPositioner::GlueState() else *p = CellState::Free; } - if ( bGlue && *(p = (pA.get() + ((((sal_uLong)nCol+1) * nR) - 1))) == CellState::Free ) + if ( bGlue && *(p = (pA.get() + (((static_cast<sal_uLong>(nCol)+1) * nR) - 1))) == CellState::Free ) { // mark column as totally unused *p = CellState::Glue; bGlueCols = true; // one unused column at least @@ -231,7 +231,7 @@ void ScChartPositioner::GlueState() else *p = CellState::Free; } - if ( bGlue && *(p = (pA.get() + ((((sal_uLong)nC-1) * nR) + nRow))) == CellState::Free ) + if ( bGlue && *(p = (pA.get() + (((static_cast<sal_uLong>(nC)-1) * nR) + nRow))) == CellState::Free ) { // mark row as totally unused *p = CellState::Glue; bGlueRows = true; // one unused row at least @@ -477,7 +477,7 @@ ScChartPositionMap::ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows, ppData( new ScAddress* [ nChartCols * nChartRows ] ), ppColHeader( new ScAddress* [ nChartCols ] ), ppRowHeader( new ScAddress* [ nChartRows ] ), - nCount( (sal_uLong) nChartCols * nChartRows ), + nCount( static_cast<sal_uLong>(nChartCols) * nChartRows ), nColCount( nChartCols ), nRowCount( nChartRows ) { diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index 67fe8aee6c41..44f1ab7e2cdc 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -2737,21 +2737,21 @@ void ScChangeTrack::AppendContentRange( const ScRange& rRange, ScRange aRange( rRange ); ScBigRange& r = pLastCutMove->GetBigRange(); SCCOL nTmpCol; - if ( (nTmpCol = (SCCOL) (r.aEnd.Col() - r.aStart.Col())) != (nCol2 - nCol1) ) + if ( (nTmpCol = static_cast<SCCOL>(r.aEnd.Col() - r.aStart.Col())) != (nCol2 - nCol1) ) { aRange.aEnd.SetCol( aRange.aStart.Col() + nTmpCol ); nCol1 += nTmpCol + 1; bDoContents = true; } SCROW nTmpRow; - if ( (nTmpRow = (SCROW) (r.aEnd.Row() - r.aStart.Row())) != (nRow2 - nRow1) ) + if ( (nTmpRow = static_cast<SCROW>(r.aEnd.Row() - r.aStart.Row())) != (nRow2 - nRow1) ) { aRange.aEnd.SetRow( aRange.aStart.Row() + nTmpRow ); nRow1 += nTmpRow + 1; bDoContents = true; } SCTAB nTmpTab; - if ( (nTmpTab = (SCTAB) (r.aEnd.Tab() - r.aStart.Tab())) != (nTab2 - nTab1) ) + if ( (nTmpTab = static_cast<SCTAB>(r.aEnd.Tab() - r.aStart.Tab())) != (nTab2 - nTab1) ) { aRange.aEnd.SetTab( aRange.aStart.Tab() + nTmpTab ); nTab1 += nTmpTab + 1; @@ -4240,7 +4240,7 @@ bool ScChangeTrack::Reject( if ( bRejected ) { // pRefDoc NULL := Do not save deleted Cells - AppendDeleteRange( pAct->GetBigRange().MakeRange(), nullptr, (short) 0, + AppendDeleteRange( pAct->GetBigRange().MakeRange(), nullptr, short(0), pAct->GetActionNumber() ); } } diff --git a/sc/source/core/tool/compare.cxx b/sc/source/core/tool/compare.cxx index c85b85f41295..9dc6181f0909 100644 --- a/sc/source/core/tool/compare.cxx +++ b/sc/source/core/tool/compare.cxx @@ -173,11 +173,11 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions ) fRes = (bMatch ? 0 : 1); } else if (rComp.mbIgnoreCase) - fRes = (double) ScGlobal::GetCollator()->compareString( - rCell1.maStr.getString(), rCell2.maStr.getString()); + fRes = static_cast<double>(ScGlobal::GetCollator()->compareString( + rCell1.maStr.getString(), rCell2.maStr.getString())); else - fRes = (double) ScGlobal::GetCaseCollator()->compareString( - rCell1.maStr.getString(), rCell2.maStr.getString()); + fRes = static_cast<double>(ScGlobal::GetCaseCollator()->compareString( + rCell1.maStr.getString(), rCell2.maStr.getString())); } else if (rComp.meOp == SC_EQUAL || rComp.meOp == SC_NOT_EQUAL) { @@ -187,11 +187,11 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions ) fRes = (rCell1.maStr.getData() == rCell2.maStr.getData()) ? 0 : 1; } else if (rComp.mbIgnoreCase) - fRes = (double) ScGlobal::GetCollator()->compareString( - rCell1.maStr.getString(), rCell2.maStr.getString()); + fRes = static_cast<double>(ScGlobal::GetCollator()->compareString( + rCell1.maStr.getString(), rCell2.maStr.getString())); else - fRes = (double) ScGlobal::GetCaseCollator()->compareString( - rCell1.maStr.getString(), rCell2.maStr.getString()); + fRes = static_cast<double>(ScGlobal::GetCaseCollator()->compareString( + rCell1.maStr.getString(), rCell2.maStr.getString())); } if (nStringQuery && pOptions) diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 955bdce9b717..a7b7b8d9629b 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3526,8 +3526,8 @@ bool ScCompiler::IsColRowName( const OUString& rName ) if ( !bInList && pDoc->GetDocOptions().IsLookUpColRowNames() ) { // search in current sheet long nDistance = 0, nMax = 0; - long nMyCol = (long) aPos.Col(); - long nMyRow = (long) aPos.Row(); + long nMyCol = static_cast<long>(aPos.Col()); + long nMyRow = static_cast<long>(aPos.Row()); bool bTwo = false; ScAddress aOne( 0, 0, aPos.Tab() ); ScAddress aTwo( MAXCOL, MAXROW, aPos.Tab() ); @@ -3550,7 +3550,7 @@ bool ScCompiler::IsColRowName( const OUString& rName ) if ( bFound ) { // stop if everything else is further away - if ( nMax < (long)aAddress.Col() ) + if ( nMax < static_cast<long>(aAddress.Col()) ) break; // aIter } if ( aAddress != aPos ) @@ -3573,7 +3573,7 @@ bool ScCompiler::IsColRowName( const OUString& rName ) nMax = std::max( nMyCol + std::abs( nC ), nMyRow + std::abs( nR ) ); nDistance = nD; } - else if ( !(nRow < aOne.Row() && nMyRow >= (long)aOne.Row()) ) + else if ( !(nRow < aOne.Row() && nMyRow >= static_cast<long>(aOne.Row())) ) { // upper left, only if not further up than the // current entry and nMyRow is below (CellIter @@ -3603,7 +3603,7 @@ bool ScCompiler::IsColRowName( const OUString& rName ) { if ( bFound ) { // stop if everything else is further away - if ( nMax < (long)aIter.GetPos().Col() ) + if ( nMax < static_cast<long>(aIter.GetPos().Col()) ) break; // aIter } CellType eType = aIter.getType(); @@ -3637,7 +3637,7 @@ bool ScCompiler::IsColRowName( const OUString& rName ) nMax = std::max( nMyCol + std::abs( nC ), nMyRow + std::abs( nR ) ); nDistance = nD; } - else if ( !(nRow < aOne.Row() && nMyRow >= (long)aOne.Row()) ) + else if ( !(nRow < aOne.Row() && nMyRow >= static_cast<long>(aOne.Row())) ) { // upper left, only if not further up than the // current entry and nMyRow is below (CellIter @@ -3666,13 +3666,13 @@ bool ScCompiler::IsColRowName( const OUString& rName ) ScAddress aAdr; if ( bTwo ) { - if ( nMyCol >= (long)aOne.Col() && nMyRow >= (long)aOne.Row() ) + if ( nMyCol >= static_cast<long>(aOne.Col()) && nMyRow >= static_cast<long>(aOne.Row()) ) aAdr = aOne; // upper left takes precedence else { - if ( nMyCol < (long)aOne.Col() ) + if ( nMyCol < static_cast<long>(aOne.Col()) ) { // two to the right - if ( nMyRow >= (long)aTwo.Row() ) + if ( nMyRow >= static_cast<long>(aTwo.Row()) ) aAdr = aTwo; // directly right else aAdr = aOne; @@ -4111,7 +4111,7 @@ bool ScCompiler::NextNewToken( bool bInArray ) { ScRawToken aToken; aToken.SetOpCode( ocSpaces ); - aToken.sbyte.cByte = (sal_uInt8) ( nSpaces > 255 ? 255 : nSpaces ); + aToken.sbyte.cByte = static_cast<sal_uInt8>( nSpaces > 255 ? 255 : nSpaces ); if( !static_cast<ScTokenArray*>(pArr)->AddRawToken( aToken ) ) { SetError(FormulaError::CodeOverflow); diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index 0b7ebd3b6bfe..633af20860b9 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -339,8 +339,8 @@ void ScDBData::SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW void ScDBData::MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) { - long nDifX = ((long) nCol1) - ((long) nStartCol); - long nDifY = ((long) nRow1) - ((long) nStartRow); + long nDifX = static_cast<long>(nCol1) - static_cast<long>(nStartCol); + long nDifY = static_cast<long>(nRow1) - static_cast<long>(nStartRow); long nSortDif = bByRow ? nDifX : nDifY; long nSortEnd = bByRow ? static_cast<long>(nCol2) : static_cast<long>(nRow2); diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx index 1cad27649a6c..539d6317eca8 100644 --- a/sc/source/core/tool/ddelink.cxx +++ b/sc/source/core/tool/ddelink.cxx @@ -178,10 +178,10 @@ sfx2::SvBaseLink::UpdateResult ScDdeLink::DataChanged( OUString aEntry; for (SCSIZE nR=0; nR<nRows; nR++) { - aLine = aLinkStr.getToken( (sal_Int32) nR, '\n' ); + aLine = aLinkStr.getToken( static_cast<sal_Int32>(nR), '\n' ); for (SCSIZE nC=0; nC<nCols; nC++) { - aEntry = aLine.getToken( (sal_Int32) nC, '\t' ); + aEntry = aLine.getToken( static_cast<sal_Int32>(nC), '\t' ); sal_uInt32 nIndex = nStdFormat; double fVal = double(); if ( nMode != SC_DDE_TEXT && pFormatter->IsNumberFormat( aEntry, nIndex, fVal ) ) diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx index 5eec4ccc7bed..859d73126c01 100644 --- a/sc/source/core/tool/docoptio.cxx +++ b/sc/source/core/tool/docoptio.cxx @@ -215,22 +215,22 @@ ScDocCfg::ScDocCfg() : SetIter( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); break; case SCCALCOPT_ITER_STEPS: - if (pValues[nProp] >>= nIntVal) SetIterCount( (sal_uInt16) nIntVal ); + if (pValues[nProp] >>= nIntVal) SetIterCount( static_cast<sal_uInt16>(nIntVal) ); break; case SCCALCOPT_ITER_MINCHG: if (pValues[nProp] >>= fDoubleVal) SetIterEps( fDoubleVal ); break; case SCCALCOPT_DATE_DAY: - if (pValues[nProp] >>= nIntVal) nDateDay = (sal_uInt16) nIntVal; + if (pValues[nProp] >>= nIntVal) nDateDay = static_cast<sal_uInt16>(nIntVal); break; case SCCALCOPT_DATE_MONTH: - if (pValues[nProp] >>= nIntVal) nDateMonth = (sal_uInt16) nIntVal; + if (pValues[nProp] >>= nIntVal) nDateMonth = static_cast<sal_uInt16>(nIntVal); break; case SCCALCOPT_DATE_YEAR: - if (pValues[nProp] >>= nIntVal) nDateYear = (sal_Int16) nIntVal; + if (pValues[nProp] >>= nIntVal) nDateYear = static_cast<sal_Int16>(nIntVal); break; case SCCALCOPT_DECIMALS: - if (pValues[nProp] >>= nIntVal) SetStdPrecision( (sal_uInt16) nIntVal ); + if (pValues[nProp] >>= nIntVal) SetStdPrecision( static_cast<sal_uInt16>(nIntVal) ); break; case SCCALCOPT_CASESENSITIVE: // content is reversed @@ -276,7 +276,7 @@ ScDocCfg::ScDocCfg() : case SCDOCLAYOUTOPT_TABSTOP: // TabDistance in ScDocOptions is in twips if (pValues[nProp] >>= nIntVal) - SetTabDistance( (sal_uInt16) HMMToTwips( nIntVal ) ); + SetTabDistance( static_cast<sal_uInt16>(HMMToTwips( nIntVal )) ); break; } } @@ -303,22 +303,22 @@ IMPL_LINK_NOARG(ScDocCfg, CalcCommitHdl, ScLinkConfigItem&, void) pValues[nProp] <<= IsIter(); break; case SCCALCOPT_ITER_STEPS: - pValues[nProp] <<= (sal_Int32) GetIterCount(); + pValues[nProp] <<= static_cast<sal_Int32>(GetIterCount()); break; case SCCALCOPT_ITER_MINCHG: pValues[nProp] <<= GetIterEps(); break; case SCCALCOPT_DATE_DAY: - pValues[nProp] <<= (sal_Int32) nDateDay; + pValues[nProp] <<= static_cast<sal_Int32>(nDateDay); break; case SCCALCOPT_DATE_MONTH: - pValues[nProp] <<= (sal_Int32) nDateMonth; + pValues[nProp] <<= static_cast<sal_Int32>(nDateMonth); break; case SCCALCOPT_DATE_YEAR: - pValues[nProp] <<= (sal_Int32) nDateYear; + pValues[nProp] <<= static_cast<sal_Int32>(nDateYear); break; case SCCALCOPT_DECIMALS: - pValues[nProp] <<= (sal_Int32) GetStdPrecision(); + pValues[nProp] <<= static_cast<sal_Int32>(GetStdPrecision()); break; case SCCALCOPT_CASESENSITIVE: // content is reversed @@ -358,7 +358,7 @@ IMPL_LINK_NOARG(ScDocCfg, LayoutCommitHdl, ScLinkConfigItem&, void) // TabDistance in ScDocOptions is in twips // use only even numbers, so defaults don't get changed // by modifying other settings in the same config item - pValues[nProp] <<= (sal_Int32) TwipsToEvenHMM( GetTabDistance() ); + pValues[nProp] <<= static_cast<sal_Int32>(TwipsToEvenHMM( GetTabDistance() )); break; } } diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx index 90c1ed626fe6..fd1d87701944 100644 --- a/sc/source/core/tool/editutil.cxx +++ b/sc/source/core/tool/editutil.cxx @@ -290,18 +290,18 @@ tools::Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, bool bF long nLayoutSign = bLayoutRTL ? -1 : 1; const ScMergeAttr* pMerge = &pPattern->GetItem(ATTR_MERGE); - long nCellX = (long) ( pDoc->GetColWidth(nCol,nTab) * nPPTX ); + long nCellX = static_cast<long>( pDoc->GetColWidth(nCol,nTab) * nPPTX ); if ( pMerge->GetColMerge() > 1 ) { SCCOL nCountX = pMerge->GetColMerge(); for (SCCOL i=1; i<nCountX; i++) - nCellX += (long) ( pDoc->GetColWidth(nCol+i,nTab) * nPPTX ); + nCellX += static_cast<long>( pDoc->GetColWidth(nCol+i,nTab) * nPPTX ); } - long nCellY = (long) ( pDoc->GetRowHeight(nRow,nTab) * nPPTY ); + long nCellY = static_cast<long>( pDoc->GetRowHeight(nRow,nTab) * nPPTY ); if ( pMerge->GetRowMerge() > 1 ) { SCROW nCountY = pMerge->GetRowMerge(); - nCellY += (long) pDoc->GetScaledRowHeight( nRow+1, nRow+nCountY-1, nTab, nPPTY); + nCellY += static_cast<long>(pDoc->GetScaledRowHeight( nRow+1, nRow+nCountY-1, nTab, nPPTY)); } const SvxMarginItem* pMargin = &pPattern->GetItem(ATTR_MARGIN); @@ -309,14 +309,14 @@ tools::Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, bool bF if ( pPattern->GetItem(ATTR_HOR_JUSTIFY).GetValue() == SvxCellHorJustify::Left ) nIndent = pPattern->GetItem(ATTR_INDENT).GetValue(); - long nPixDifX = (long) ( ( pMargin->GetLeftMargin() + nIndent ) * nPPTX ); + long nPixDifX = static_cast<long>( ( pMargin->GetLeftMargin() + nIndent ) * nPPTX ); aStartPos.X() += nPixDifX * nLayoutSign; - nCellX -= nPixDifX + (long) ( pMargin->GetRightMargin() * nPPTX ); // due to line feed, etc. + nCellX -= nPixDifX + static_cast<long>( pMargin->GetRightMargin() * nPPTX ); // due to line feed, etc. // align vertical position to the one in the table long nPixDifY; - long nTopMargin = (long) ( pMargin->GetTopMargin() * nPPTY ); + long nTopMargin = static_cast<long>( pMargin->GetTopMargin() * nPPTY ); SvxCellVerJustify eJust = pPattern->GetItem(ATTR_VER_JUSTIFY).GetValue(); // asian vertical is always edited top-aligned @@ -340,7 +340,7 @@ tools::Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, bool bF pPattern->GetFont( aFont, SC_AUTOCOL_BLACK, pDev, &aZoomY ); pDev->SetFont(aFont); nTextHeight = pDev->GetTextHeight() + nTopMargin + - (long) ( pMargin->GetBottomMargin() * nPPTY ); + static_cast<long>( pMargin->GetBottomMargin() * nPPTY ); } pDev->SetMapMode(aMode); diff --git a/sc/source/core/tool/inputopt.cxx b/sc/source/core/tool/inputopt.cxx index 8408b8209072..e51586ea10fc 100644 --- a/sc/source/core/tool/inputopt.cxx +++ b/sc/source/core/tool/inputopt.cxx @@ -107,7 +107,7 @@ ScInputCfg::ScInputCfg() : { case SCINPUTOPT_MOVEDIR: if ( pValues[nProp] >>= nIntVal ) - SetMoveDir( (sal_uInt16)nIntVal ); + SetMoveDir( static_cast<sal_uInt16>(nIntVal) ); break; case SCINPUTOPT_MOVESEL: SetMoveSelection( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); @@ -159,7 +159,7 @@ void ScInputCfg::ImplCommit() switch(nProp) { case SCINPUTOPT_MOVEDIR: - pValues[nProp] <<= (sal_Int32) GetMoveDir(); + pValues[nProp] <<= static_cast<sal_Int32>(GetMoveDir()); break; case SCINPUTOPT_MOVESEL: pValues[nProp] <<= GetMoveSelection(); diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 46a3d7df4dd4..ceab0289184f 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -459,7 +459,7 @@ void ScInterpreter::ScChooseJump() if ( bIsValue ) { pJumpMat->SetJump( nC, nR, fVal, - pJump[ (short)fVal ], + pJump[ static_cast<short>(fVal) ], pJump[ nJumpCount ]); } else @@ -488,7 +488,7 @@ void ScInterpreter::ScChooseJump() sal_Int16 nJumpIndex = GetInt16(); if (nGlobalError == FormulaError::NONE && (nJumpIndex >= 1) && (nJumpIndex < nJumpCount)) { - aCode.Jump( pJump[ (short) nJumpIndex ], pJump[ nJumpCount ] ); + aCode.Jump( pJump[ static_cast<short>(nJumpIndex) ], pJump[ nJumpCount ] ); bHaveJump = true; } else @@ -646,8 +646,8 @@ bool ScInterpreter::JumpMatrix( short nStackLevel ) // Do not modify the original range because we use it // to adjust the size of the result matrix if necessary. ScAddress aAdr( aRange.aStart); - sal_uLong nCol = (sal_uLong)aAdr.Col() + nC; - sal_uLong nRow = (sal_uLong)aAdr.Row() + nR; + sal_uLong nCol = static_cast<sal_uLong>(aAdr.Col()) + nC; + sal_uLong nRow = static_cast<sal_uLong>(aAdr.Row()) + nR; if ((nCol > static_cast<sal_uLong>(aRange.aEnd.Col()) && aRange.aEnd.Col() != aRange.aStart.Col()) || (nRow > static_cast<sal_uLong>(aRange.aEnd.Row()) && @@ -1065,7 +1065,7 @@ sc::RangeMatrix ScInterpreter::CompareMat( ScQueryOp eOp, sc::CompareOptions* pO aRes.mpMat->CompareNotEqual(); break; default: - SAL_WARN("sc", "ScInterpreter::QueryMat: unhandled comparison operator: " << (int)eOp); + SAL_WARN("sc", "ScInterpreter::QueryMat: unhandled comparison operator: " << static_cast<int>(eOp)); aRes.mpMat.reset(); return aRes; } @@ -1602,7 +1602,7 @@ void ScInterpreter::ScBitAnd() (num2 >= n2power48) || (num2 < 0)) PushIllegalArgument(); else - PushDouble ((sal_uInt64) num1 & (sal_uInt64) num2); + PushDouble (static_cast<sal_uInt64>(num1) & static_cast<sal_uInt64>(num2)); } void ScInterpreter::ScBitOr() @@ -1617,7 +1617,7 @@ void ScInterpreter::ScBitOr() (num2 >= n2power48) || (num2 < 0)) PushIllegalArgument(); else - PushDouble ((sal_uInt64) num1 | (sal_uInt64) num2); + PushDouble (static_cast<sal_uInt64>(num1) | static_cast<sal_uInt64>(num2)); } void ScInterpreter::ScBitXor() @@ -1632,7 +1632,7 @@ void ScInterpreter::ScBitXor() (num2 >= n2power48) || (num2 < 0)) PushIllegalArgument(); else - PushDouble ((sal_uInt64) num1 ^ (sal_uInt64) num2); + PushDouble (static_cast<sal_uInt64>(num1) ^ static_cast<sal_uInt64>(num2)); } void ScInterpreter::ScBitLshift() @@ -2288,7 +2288,7 @@ void ScInterpreter::ScCell() long nZeroWidth = pPrinter->GetTextWidth( OUString( '0' ) ); pPrinter->SetFont( aOldFont ); pPrinter->SetMapMode( aOldMode ); - int nZeroCount = (int)(pDok->GetColWidth( aCellPos.Col(), aCellPos.Tab() ) / nZeroWidth); + int nZeroCount = static_cast<int>(pDok->GetColWidth( aCellPos.Col(), aCellPos.Tab() ) / nZeroWidth); PushInt( nZeroCount ); } else if( aInfoType == "PREFIX" ) @@ -3349,7 +3349,7 @@ void ScInterpreter::ScCode() RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT | RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT | RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE; - PushInt( (unsigned char) OUStringToOString(OUString(aStr[0]), osl_getThreadTextEncoding(), convertFlags).toChar() ); + PushInt( static_cast<unsigned char>(OUStringToOString(OUString(aStr[0]), osl_getThreadTextEncoding(), convertFlags).toChar()) ); } } @@ -4135,7 +4135,7 @@ void ScInterpreter::ScColumns() SetError(FormulaError::IllegalParameter); } } - PushDouble((double)nVal); + PushDouble(static_cast<double>(nVal)); } void ScInterpreter::ScRows() @@ -4192,7 +4192,7 @@ void ScInterpreter::ScRows() SetError(FormulaError::IllegalParameter); } } - PushDouble((double)nVal); + PushDouble(static_cast<double>(nVal)); } void ScInterpreter::ScSheets() @@ -4239,7 +4239,7 @@ void ScInterpreter::ScSheets() } } } - PushDouble( (double) nVal ); + PushDouble( static_cast<double>(nVal) ); } void ScInterpreter::ScColumn() @@ -4283,7 +4283,7 @@ void ScInterpreter::ScColumn() SCROW nRow1(0); SCTAB nTab1(0); PopSingleRef( nCol1, nRow1, nTab1 ); - nVal = (double) (nCol1 + 1); + nVal = static_cast<double>(nCol1 + 1); } break; case svDoubleRef : @@ -4302,7 +4302,7 @@ void ScInterpreter::ScColumn() if (pResMat) { for (SCCOL i = nCol1; i <= nCol2; i++) - pResMat->PutDouble((double)(i+1), + pResMat->PutDouble(static_cast<double>(i+1), static_cast<SCSIZE>(i-nCol1), 0); PushMatrix(pResMat); return; @@ -4311,7 +4311,7 @@ void ScInterpreter::ScColumn() nVal = 0.0; } else - nVal = (double) (nCol1 + 1); + nVal = static_cast<double>(nCol1 + 1); } break; default: @@ -4364,7 +4364,7 @@ void ScInterpreter::ScRow() SCROW nRow1(0); SCTAB nTab1(0); PopSingleRef( nCol1, nRow1, nTab1 ); - nVal = (double) (nRow1 + 1); + nVal = static_cast<double>(nRow1 + 1); } break; case svDoubleRef : @@ -4383,7 +4383,7 @@ void ScInterpreter::ScRow() if (pResMat) { for (SCROW i = nRow1; i <= nRow2; i++) - pResMat->PutDouble((double)(i+1), 0, + pResMat->PutDouble(static_cast<double>(i+1), 0, static_cast<SCSIZE>(i-nRow1)); PushMatrix(pResMat); return; @@ -4392,7 +4392,7 @@ void ScInterpreter::ScRow() nVal = 0.0; } else - nVal = (double) (nRow1 + 1); + nVal = static_cast<double>(nRow1 + 1); } break; default: @@ -4452,7 +4452,7 @@ void ScInterpreter::ScSheet() if ( nGlobalError != FormulaError::NONE ) nVal = 0; } - PushDouble( (double) nVal ); + PushDouble( static_cast<double>(nVal) ); } } @@ -4896,7 +4896,7 @@ void ScInterpreter::ScMatch() } nDelta = nC - nCol1; } - PushDouble((double) (nDelta + 1)); + PushDouble(static_cast<double>(nDelta + 1)); } else PushIllegalParameter(); @@ -7915,8 +7915,8 @@ void ScInterpreter::ScAddressFunc() } nFlags |= ScRefFlags::VALID | ScRefFlags::ROW_VALID | ScRefFlags::COL_VALID; - SCCOL nCol = (SCCOL) GetInt16(); - SCROW nRow = (SCROW) GetInt32(); + SCCOL nCol = static_cast<SCCOL>(GetInt16()); + SCROW nRow = static_cast<SCROW>(GetInt32()); if( eConv == FormulaGrammar::CONV_XL_R1C1 ) { // YUCK! The XL interface actually treats rel R1C1 refs differently @@ -8004,8 +8004,8 @@ void ScInterpreter::ScOffset() PopSingleRef(nCol1, nRow1, nTab1); if (nParamCount == 3 || (nColNew < 0 && nRowNew < 0)) { - nCol1 = (SCCOL)((long) nCol1 + nColPlus); - nRow1 = (SCROW)((long) nRow1 + nRowPlus); + nCol1 = static_cast<SCCOL>(static_cast<long>(nCol1) + nColPlus); + nRow1 = static_cast<SCROW>(static_cast<long>(nRow1) + nRowPlus); if (!ValidCol(nCol1) || !ValidRow(nRow1)) PushIllegalArgument(); else @@ -8017,10 +8017,10 @@ void ScInterpreter::ScOffset() nColNew = 1; if (nRowNew < 0) nRowNew = 1; - nCol1 = (SCCOL)((long)nCol1+nColPlus); - nRow1 = (SCROW)((long)nRow1+nRowPlus); - nCol2 = (SCCOL)((long)nCol1+nColNew-1); - nRow2 = (SCROW)((long)nRow1+nRowNew-1); + nCol1 = static_cast<SCCOL>(static_cast<long>(nCol1)+nColPlus); + nRow1 = static_cast<SCROW>(static_cast<long>(nRow1)+nRowPlus); + nCol2 = static_cast<SCCOL>(static_cast<long>(nCol1)+nColNew-1); + nRow2 = static_cast<SCROW>(static_cast<long>(nRow1)+nRowNew-1); if (!ValidCol(nCol1) || !ValidRow(nRow1) || !ValidCol(nCol2) || !ValidRow(nRow2)) PushIllegalArgument(); @@ -8042,8 +8042,8 @@ void ScInterpreter::ScOffset() if (nParamCount == 3 || (nColNew < 0 && nRowNew < 0)) { - nCol1 = (SCCOL)((long) nCol1 + nColPlus); - nRow1 = (SCROW)((long) nRow1 + nRowPlus); + nCol1 = static_cast<SCCOL>(static_cast<long>(nCol1) + nColPlus); + nRow1 = static_cast<SCROW>(static_cast<long>(nRow1) + nRowPlus); if (!ValidCol(nCol1) || !ValidRow(nRow1)) PushIllegalArgument(); else @@ -8055,10 +8055,10 @@ void ScInterpreter::ScOffset() nColNew = 1; if (nRowNew < 0) nRowNew = 1; - nCol1 = (SCCOL)((long)nCol1+nColPlus); - nRow1 = (SCROW)((long)nRow1+nRowPlus); - nCol2 = (SCCOL)((long)nCol1+nColNew-1); - nRow2 = (SCROW)((long)nRow1+nRowNew-1); + nCol1 = static_cast<SCCOL>(static_cast<long>(nCol1)+nColPlus); + nRow1 = static_cast<SCROW>(static_cast<long>(nRow1)+nRowPlus); + nCol2 = static_cast<SCCOL>(static_cast<long>(nCol1)+nColNew-1); + nRow2 = static_cast<SCROW>(static_cast<long>(nRow1)+nRowNew-1); nTab2 = nTab1; if (!ValidCol(nCol1) || !ValidRow(nRow1) || !ValidCol(nCol2) || !ValidRow(nRow2)) @@ -8075,10 +8075,10 @@ void ScInterpreter::ScOffset() nColNew = nCol2 - nCol1 + 1; if (nRowNew < 0) nRowNew = nRow2 - nRow1 + 1; - nCol1 = (SCCOL)((long)nCol1+nColPlus); - nRow1 = (SCROW)((long)nRow1+nRowPlus); - nCol2 = (SCCOL)((long)nCol1+nColNew-1); - nRow2 = (SCROW)((long)nRow1+nRowNew-1); + nCol1 = static_cast<SCCOL>(static_cast<long>(nCol1)+nColPlus); + nRow1 = static_cast<SCROW>(static_cast<long>(nRow1)+nRowPlus); + nCol2 = static_cast<SCCOL>(static_cast<long>(nCol1)+nColNew-1); + nRow2 = static_cast<SCROW>(static_cast<long>(nRow1)+nRowNew-1); if (!ValidCol(nCol1) || !ValidRow(nRow1) || !ValidCol(nCol2) || !ValidRow(nRow2) || nTab1 != nTab2) PushIllegalArgument(); @@ -8103,10 +8103,10 @@ void ScInterpreter::ScOffset() nColNew = nCol2 - nCol1 + 1; if (nRowNew < 0) nRowNew = nRow2 - nRow1 + 1; - nCol1 = (SCCOL)((long)nCol1+nColPlus); - nRow1 = (SCROW)((long)nRow1+nRowPlus); - nCol2 = (SCCOL)((long)nCol1+nColNew-1); - nRow2 = (SCROW)((long)nRow1+nRowNew-1); + nCol1 = static_cast<SCCOL>(static_cast<long>(nCol1)+nColPlus); + nRow1 = static_cast<SCROW>(static_cast<long>(nRow1)+nRowPlus); + nCol2 = static_cast<SCCOL>(static_cast<long>(nCol1)+nColNew-1); + nRow2 = static_cast<SCROW>(static_cast<long>(nRow1)+nRowNew-1); if (!ValidCol(nCol1) || !ValidRow(nRow1) || !ValidCol(nCol2) || !ValidRow(nRow2) || nTab1 != nTab2) PushIllegalArgument(); @@ -8135,18 +8135,18 @@ void ScInterpreter::ScIndex() else nArea = 1; if (nParamCount >= 3) - nCol = (SCCOL) GetInt16(); + nCol = static_cast<SCCOL>(GetInt16()); else nCol = 0; if (nParamCount >= 2) - nRow = (SCROW) GetInt32(); + nRow = static_cast<SCROW>(GetInt32()); else nRow = 0; if (GetStackType() == svRefList) nAreaCount = (sp ? pStack[sp-1]->GetRefList()->size() : 0); else nAreaCount = 1; // one reference or array or whatever - if (nGlobalError != FormulaError::NONE || nAreaCount == 0 || (size_t)nArea > nAreaCount) + if (nGlobalError != FormulaError::NONE || nAreaCount == 0 || static_cast<size_t>(nArea) > nAreaCount) { PushError( FormulaError::NoRef); return; @@ -8308,7 +8308,7 @@ void ScInterpreter::ScIndex() PushSingleRef( nCol1, nRow1+nRow-1, nTab1 ); else if ( bRowArray ) { - nCol =(SCCOL) nRow; + nCol =static_cast<SCCOL>(nRow); nRow = 1; PushSingleRef( nCol1+nCol-1, nRow1+nRow-1, nTab1); } @@ -8396,7 +8396,7 @@ void ScInterpreter::ScCurrency() double fVal = GetDouble(); double fFac; if ( fDec != 0.0 ) - fFac = pow( (double)10, fDec ); + fFac = pow( double(10), fDec ); else fFac = 1.0; if (fVal < 0.0) @@ -8409,14 +8409,14 @@ void ScInterpreter::ScCurrency() sal_uLong nIndex = pFormatter->GetStandardFormat( SvNumFormatType::CURRENCY, ScGlobal::eLnge); - if ( (sal_uInt16) fDec != pFormatter->GetFormatPrecision( nIndex ) ) + if ( static_cast<sal_uInt16>(fDec) != pFormatter->GetFormatPrecision( nIndex ) ) { OUString sFormatString = pFormatter->GenerateFormat( nIndex, ScGlobal::eLnge, true, // with thousands separator false, // not red - (sal_uInt16) fDec);// decimal places + static_cast<sal_uInt16>(fDec));// decimal places if (!pFormatter->GetPreviewString(sFormatString, fVal, aStr, @@ -8498,7 +8498,7 @@ void ScInterpreter::ScFixed() double fVal = GetDouble(); double fFac; if ( fDec != 0.0 ) - fFac = pow( (double)10, fDec ); + fFac = pow( double(10), fDec ); else fFac = 1.0; if (fVal < 0.0) @@ -8516,7 +8516,7 @@ void ScInterpreter::ScFixed() ScGlobal::eLnge, bThousand, // with thousands separator false, // not red - (sal_uInt16) fDec);// decimal places + static_cast<sal_uInt16>(fDec));// decimal places if (!pFormatter->GetPreviewString(sFormatString, fVal, aStr, @@ -8555,7 +8555,7 @@ void ScInterpreter::ScFind() sStr.iterateCodePoints( &nIdx ); ++nCnt; } - PushDouble( ( double )nCnt ); + PushDouble( static_cast<double>(nCnt) ); } } } @@ -8587,7 +8587,7 @@ void ScInterpreter::ScLeft() return ; } else - n = (sal_Int32) nVal; + n = static_cast<sal_Int32>(nVal); } else n = 1; @@ -8699,7 +8699,7 @@ void ScInterpreter::ScRightB() return ; } else - n = (sal_Int32) nVal; + n = static_cast<sal_Int32>(nVal); } else n = 1; @@ -8750,7 +8750,7 @@ void ScInterpreter::ScLeftB() return ; } else - n = (sal_Int32) nVal; + n = static_cast<sal_Int32>(nVal); } else n = 1; @@ -8770,8 +8770,8 @@ void ScInterpreter::ScMidB() else { - aStr = lcl_LeftB(aStr, (sal_Int32)fAnfang + (sal_Int32)fCnt - 1); - sal_Int32 nCnt = getLengthB(aStr) - (sal_Int32)fAnfang + 1; + aStr = lcl_LeftB(aStr, static_cast<sal_Int32>(fAnfang) + static_cast<sal_Int32>(fCnt) - 1); + sal_Int32 nCnt = getLengthB(aStr) - static_cast<sal_Int32>(fAnfang) + 1; aStr = lcl_RightB(aStr, std::max<sal_Int32>(nCnt,0)); PushString(aStr); } @@ -8895,7 +8895,7 @@ void ScInterpreter::ScRight() return ; } else - n = (sal_Int32) nVal; + n = static_cast<sal_Int32>(nVal); } else n = 1; @@ -8958,7 +8958,7 @@ void ScInterpreter::ScSearch() sStr.iterateCodePoints( &nIdx ); ++nCnt; } - PushDouble( ( double )nCnt ); + PushDouble( static_cast<double>(nCnt) ); } } } @@ -8968,8 +8968,8 @@ void ScInterpreter::ScMid() { if ( MustHaveParamCount( GetByte(), 3 ) ) { - sal_Int32 nSubLen = ( sal_Int32 )GetStringPositionArgument(); - sal_Int32 nStart = ( sal_Int32 )GetStringPositionArgument(); + sal_Int32 nSubLen = static_cast<sal_Int32>(GetStringPositionArgument()); + sal_Int32 nStart = static_cast<sal_Int32>(GetStringPositionArgument()); OUString aStr = GetString().getString(); if ( nStart < 1 || nSubLen < 0 ) PushIllegalArgument(); @@ -9083,7 +9083,7 @@ void ScInterpreter::ScSubstitute() return; } else - nCnt = (sal_Int32) fCnt; + nCnt = static_cast<sal_Int32>(fCnt); } else nCnt = 0; @@ -9138,7 +9138,7 @@ void ScInterpreter::ScRept() else { const sal_Int32 nLen = aStr.getLength(); - sal_Int32 n = (sal_Int32) fCnt; + sal_Int32 n = static_cast<sal_Int32>(fCnt); OUStringBuffer aRes(n*nLen); while( n-- ) aRes.append(aStr); diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index ab07afe355e0..ad99e99ace38 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -94,7 +94,7 @@ double ScInterpreter::GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int1 if (!bStrict) aDate.AddDays( nDay - 1 ); if (aDate.IsValidAndGregorian()) - return (double) (aDate - pFormatter->GetNullDate()); + return static_cast<double>(aDate - pFormatter->GetNullDate()); else { SetError(FormulaError::NoValue); @@ -107,7 +107,7 @@ void ScInterpreter::ScGetActDate() nFuncFmtType = SvNumFormatType::DATE; Date aActDate( Date::SYSTEM ); long nDiff = aActDate - pFormatter->GetNullDate(); - PushDouble((double) nDiff); + PushDouble(static_cast<double>(nDiff)); } void ScInterpreter::ScGetActTime() @@ -120,52 +120,52 @@ void ScInterpreter::ScGetActTime() aActTime.GetMin() / static_cast<double>(::tools::Time::minutePerDay) + aActTime.GetSec() / static_cast<double>(::tools::Time::secondPerDay) + aActTime.GetNanoSec() / static_cast<double>(::tools::Time::nanoSecPerDay); - PushDouble( (double) nDiff + fTime ); + PushDouble( static_cast<double>(nDiff) + fTime ); } void ScInterpreter::ScGetYear() { Date aDate = pFormatter->GetNullDate(); aDate.AddDays( GetInt32()); - PushDouble( (double) aDate.GetYear() ); + PushDouble( static_cast<double>(aDate.GetYear()) ); } void ScInterpreter::ScGetMonth() { Date aDate = pFormatter->GetNullDate(); aDate.AddDays( GetInt32()); - PushDouble( (double) aDate.GetMonth() ); + PushDouble( static_cast<double>(aDate.GetMonth()) ); } void ScInterpreter::ScGetDay() { Date aDate = pFormatter->GetNullDate(); aDate.AddDays( GetInt32()); - PushDouble((double) aDate.GetDay()); + PushDouble(static_cast<double>(aDate.GetDay())); } void ScInterpreter::ScGetMin() { double fTime = GetDouble(); fTime -= ::rtl::math::approxFloor(fTime); // date part absent - long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) % ::tools::Time::secondPerHour; - PushDouble( (double) (nVal / ::tools::Time::secondPerMinute) ); + long nVal = static_cast<long>(::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5)) % ::tools::Time::secondPerHour; + PushDouble( static_cast<double>(nVal / ::tools::Time::secondPerMinute) ); } void ScInterpreter::ScGetSec() { double fTime = GetDouble(); fTime -= ::rtl::math::approxFloor(fTime); // date part absent - long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) % ::tools::Time::secondPerMinute; - PushDouble( (double) nVal ); + long nVal = static_cast<long>(::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5)) % ::tools::Time::secondPerMinute; + PushDouble( static_cast<double>(nVal) ); } void ScInterpreter::ScGetHour() { double fTime = GetDouble(); fTime -= ::rtl::math::approxFloor(fTime); // date part absent - long nVal = (long)::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5) / ::tools::Time::secondPerHour; - PushDouble((double) nVal); + long nVal = static_cast<long>(::rtl::math::approxFloor(fTime*DATE_TIME_FACTOR+0.5)) / ::tools::Time::secondPerHour; + PushDouble(static_cast<double>(nVal)); } void ScInterpreter::ScGetDateValue() @@ -201,7 +201,7 @@ void ScInterpreter::ScGetDayOfWeek() Date aDate = pFormatter->GetNullDate(); aDate.AddDays( GetInt32()); - int nVal = (int) aDate.GetDayOfWeek(); // MONDAY = 0 + int nVal = static_cast<int>(aDate.GetDayOfWeek()); // MONDAY = 0 switch (nFlag) { case 1: // Sunday = 1 @@ -243,7 +243,7 @@ void ScInterpreter::ScWeeknumOOo() Date aDate = pFormatter->GetNullDate(); aDate.AddDays( GetInt32()); - PushInt( (int) aDate.GetWeekOfYear( nFlag == 1 ? SUNDAY : MONDAY )); + PushInt( static_cast<int>(aDate.GetWeekOfYear( nFlag == 1 ? SUNDAY : MONDAY ))); } } @@ -293,7 +293,7 @@ void ScInterpreter::ScGetWeekOfYear() PushIllegalArgument(); return; } - PushInt( (int) aDate.GetWeekOfYear( eFirstDayOfWeek, nMinimumNumberOfDaysInWeek ) ); + PushInt( static_cast<int>(aDate.GetWeekOfYear( eFirstDayOfWeek, nMinimumNumberOfDaysInWeek )) ); } } @@ -303,7 +303,7 @@ void ScInterpreter::ScGetIsoWeekOfYear() { Date aDate = pFormatter->GetNullDate(); aDate.AddDays( GetInt32()); - PushInt( (int) aDate.GetWeekOfYear() ); + PushInt( static_cast<int>(aDate.GetWeekOfYear()) ); } } @@ -365,7 +365,7 @@ FormulaError ScInterpreter::GetWeekendAndHolidayMasks( // Weekend days defined by string, Sunday...Saturday for ( int i = 0; i < 7; i++ ) - bWeekendMask[ i ] = ( bool ) nWeekendDays[ ( i == 6 ? 0 : i + 1 ) ]; + bWeekendMask[ i ] = static_cast<bool>(nWeekendDays[ ( i == 6 ? 0 : i + 1 ) ]); } } else @@ -561,7 +561,7 @@ void ScInterpreter::ScNetWorkdays( bool bOOXML_Version ) } ++nDate1; } - PushDouble( ( double ) ( bReverse ? -nCnt : nCnt ) ); + PushDouble( static_cast<double>( bReverse ? -nCnt : nCnt ) ); } } } @@ -592,7 +592,7 @@ void ScInterpreter::ScWorkday_MS() nDate += nNullDate; if ( !nDays ) - PushDouble( ( double ) ( nDate - nNullDate ) ); + PushDouble( static_cast<double>( nDate - nNullDate ) ); else { size_t nMax = nSortArray.size(); @@ -632,7 +632,7 @@ void ScInterpreter::ScWorkday_MS() nDays++; } } - PushDouble( ( double ) ( nDate - nNullDate ) ); + PushDouble( static_cast<double>( nDate - nNullDate ) ); } } } @@ -768,11 +768,11 @@ void ScInterpreter::ScGetDiffDate360() else aDate2.SetDay(30); } - PushDouble( (double) nSign * - ( (double) aDate2.GetDay() + (double) aDate2.GetMonth() * 30.0 + - (double) aDate2.GetYear() * 360.0 - - (double) aDate1.GetDay() - (double) aDate1.GetMonth() * 30.0 - - (double)aDate1.GetYear() * 360.0) ); + PushDouble( static_cast<double>(nSign) * + ( static_cast<double>(aDate2.GetDay()) + static_cast<double>(aDate2.GetMonth()) * 30.0 + + static_cast<double>(aDate2.GetYear()) * 360.0 + - static_cast<double>(aDate1.GetDay()) - static_cast<double>(aDate1.GetMonth()) * 30.0 + - static_cast<double>(aDate1.GetYear()) * 360.0) ); } } } @@ -1567,7 +1567,7 @@ void ScInterpreter::ScMIRR() else { double fResult = -fNPV_reinvest / fNPV_invest; - fResult *= pow( fRate1_reinvest, (double)( nCount - 1 ) ); + fResult *= pow( fRate1_reinvest, static_cast<double>( nCount - 1 ) ); fResult = pow( fResult, div( 1.0, (nCount - 1)) ); PushDouble( fResult - 1.0 ); } @@ -1726,7 +1726,7 @@ void ScInterpreter::ScDB() double fSumOffRate = fFirstOffRate; double fMin = fLife; if (fMin > fPeriod) fMin = fPeriod; - sal_uInt16 iMax = (sal_uInt16)::rtl::math::approxFloor(fMin); + sal_uInt16 iMax = static_cast<sal_uInt16>(::rtl::math::approxFloor(fMin)); for (sal_uInt16 i = 2; i <= iMax; i++) { fDb = (fCost - fSumOffRate) * fOffRate; @@ -1743,7 +1743,7 @@ double ScInterpreter::ScInterVDB(double fCost, double fSalvage, double fLife, { double fVdb=0; double fIntEnd = ::rtl::math::approxCeil(fPeriod); - sal_uLong nLoopEnd = (sal_uLong) fIntEnd; + sal_uLong nLoopEnd = static_cast<sal_uLong>(fIntEnd); double fTerm, fSln; // SLN: Straight-Line Depreciation double fSalvageValue = fCost - fSalvage; @@ -1756,8 +1756,8 @@ double ScInterpreter::ScInterVDB(double fCost, double fSalvage, double fLife, { if(!bNowSln) { - fDdb = ScGetDDB(fCost, fSalvage, fLife, (double) i, fFactor); - fSln = fSalvageValue/ (fLife1 - (double) (i-1)); + fDdb = ScGetDDB(fCost, fSalvage, fLife, static_cast<double>(i), fFactor); + fSln = fSalvageValue/ (fLife1 - static_cast<double>(i-1)); if (fSln > fDdb) { @@ -1816,15 +1816,15 @@ void ScInterpreter::ScVDB() { double fIntStart = ::rtl::math::approxFloor(fStart); double fIntEnd = ::rtl::math::approxCeil(fEnd); - sal_uLong nLoopStart = (sal_uLong) fIntStart; - sal_uLong nLoopEnd = (sal_uLong) fIntEnd; + sal_uLong nLoopStart = static_cast<sal_uLong>(fIntStart); + sal_uLong nLoopEnd = static_cast<sal_uLong>(fIntEnd); fVdb = 0.0; if (bNoSwitch) { for (sal_uLong i = nLoopStart + 1; i <= nLoopEnd; i++) { - double fTerm = ScGetDDB(fCost, fSalvage, fLife, (double) i, fFactor); + double fTerm = ScGetDDB(fCost, fSalvage, fLife, static_cast<double>(i), fFactor); //respect partial period in the Beginning/ End: if ( i == nLoopStart+1 ) @@ -2265,9 +2265,9 @@ void ScInterpreter::ScCumIpmt() PushIllegalArgument(); else { - bool bPayInAdvance = ( bool ) fFlag; - sal_uLong nStart = (sal_uLong) fStart; - sal_uLong nEnd = (sal_uLong) fEnd ; + bool bPayInAdvance = static_cast<bool>(fFlag); + sal_uLong nStart = static_cast<sal_uLong>(fStart); + sal_uLong nEnd = static_cast<sal_uLong>(fEnd) ; double fPmt = ScGetPMT(fRate, fNper, fPv, 0.0, bPayInAdvance); double fIpmt = 0.0; if (nStart == 1) @@ -2279,9 +2279,9 @@ void ScInterpreter::ScCumIpmt() for (sal_uLong i = nStart; i <= nEnd; i++) { if (bPayInAdvance) - fIpmt += ScGetFV(fRate, (double)(i-2), fPmt, fPv, true) - fPmt; + fIpmt += ScGetFV(fRate, static_cast<double>(i-2), fPmt, fPv, true) - fPmt; else - fIpmt += ScGetFV(fRate, (double)(i-1), fPmt, fPv, false); + fIpmt += ScGetFV(fRate, static_cast<double>(i-1), fPmt, fPv, false); } fIpmt *= fRate; PushDouble(fIpmt); @@ -2307,11 +2307,11 @@ void ScInterpreter::ScCumPrinc() PushIllegalArgument(); else { - bool bPayInAdvance = ( bool ) fFlag; + bool bPayInAdvance = static_cast<bool>(fFlag); double fPmt = ScGetPMT(fRate, fNper, fPv, 0.0, bPayInAdvance); double fPpmt = 0.0; - sal_uLong nStart = (sal_uLong) fStart; - sal_uLong nEnd = (sal_uLong) fEnd; + sal_uLong nStart = static_cast<sal_uLong>(fStart); + sal_uLong nEnd = static_cast<sal_uLong>(fEnd); if (nStart == 1) { if (bPayInAdvance) @@ -2323,9 +2323,9 @@ void ScInterpreter::ScCumPrinc() for (sal_uLong i = nStart; i <= nEnd; i++) { if (bPayInAdvance) - fPpmt += fPmt - (ScGetFV(fRate, (double)(i-2), fPmt, fPv, true) - fPmt) * fRate; + fPpmt += fPmt - (ScGetFV(fRate, static_cast<double>(i-2), fPmt, fPv, true) - fPmt) * fRate; else - fPpmt += fPmt - ScGetFV(fRate, (double)(i-1), fPmt, fPv, false) * fRate; + fPpmt += fPmt - ScGetFV(fRate, static_cast<double>(i-1), fPmt, fPv, false) * fRate; } PushDouble(fPpmt); } @@ -2657,7 +2657,7 @@ void ScInterpreter::ScStyle() aStyle2 = GetString().getString(); long nTimeOut = 0; // timeout if (nParamCount >= 2) - nTimeOut = (long)(GetDouble()*1000.0); + nTimeOut = static_cast<long>(GetDouble()*1000.0); OUString aStyle1 = GetString().getString(); // Template for immediate if (nTimeOut < 0) @@ -2731,7 +2731,7 @@ void ScInterpreter::ScDde() PushIllegalArgument(); return; } - nMode = (sal_uInt8) nTmp; + nMode = static_cast<sal_uInt8>(nTmp); } OUString aItem = GetString().getString(); OUString aTopic = GetString().getString(); @@ -2848,7 +2848,7 @@ void ScInterpreter::ScBase() { double fLen = ::rtl::math::approxFloor( GetDouble() ); if ( 1.0 <= fLen && fLen < SAL_MAX_UINT16 ) - nMinLen = (sal_Int32) fLen; + nMinLen = static_cast<sal_Int32>(fLen); else if ( fLen == 0.0 ) nMinLen = 1; else @@ -2876,16 +2876,16 @@ void ScInterpreter::ScBase() } sal_Unicode* p = pBuf + nBuf - 1; *p = 0; - if ( fVal <= (sal_uLong)(~0) ) + if ( fVal <= sal_uLong(~0) ) { - sal_uLong nVal = (sal_uLong) fVal; - sal_uLong nBase = (sal_uLong) fBase; + sal_uLong nVal = static_cast<sal_uLong>(fVal); + sal_uLong nBase = static_cast<sal_uLong>(fBase); while ( nVal && p > pBuf ) { *--p = pDigits[ nVal % nBase ]; nVal /= nBase; } - fVal = (double) nVal; + fVal = static_cast<double>(nVal); } else { @@ -2933,9 +2933,9 @@ void ScInterpreter::ScBase() if ( fDig <= 0.0 ) nDig = 0; else if ( fDig >= fBase ) - nDig = ((size_t) fBase) - 1; + nDig = static_cast<size_t>(fBase) - 1; else - nDig = (size_t) fDig; + nDig = static_cast<size_t>(fDig); } *--p = pDigits[ nDig ]; fVal = fInt; @@ -2966,7 +2966,7 @@ void ScInterpreter::ScDecimal() if ( nGlobalError == FormulaError::NONE && 2 <= fBase && fBase <= 36 ) { double fVal = 0.0; - int nBase = (int) fBase; + int nBase = static_cast<int>(fBase); const sal_Unicode* p = aStr.getStr(); while ( *p == ' ' || *p == '\t' ) p++; // strip leading white space @@ -3049,11 +3049,11 @@ void ScInterpreter::ScRoman() { static const sal_Unicode pChars[] = { 'M', 'D', 'C', 'L', 'X', 'V', 'I' }; static const sal_uInt16 pValues[] = { 1000, 500, 100, 50, 10, 5, 1 }; - static const sal_uInt16 nMaxIndex = (sal_uInt16)(SAL_N_ELEMENTS(pValues) - 1); + static const sal_uInt16 nMaxIndex = sal_uInt16(SAL_N_ELEMENTS(pValues) - 1); OUString aRoman; - sal_uInt16 nVal = (sal_uInt16) fVal; - sal_uInt16 nMode = (sal_uInt16) fMode; + sal_uInt16 nVal = static_cast<sal_uInt16>(fVal); + sal_uInt16 nMode = static_cast<sal_uInt16>(fMode); for( sal_uInt16 i = 0; i <= nMaxIndex / 2; i++ ) { @@ -3353,7 +3353,7 @@ void ScInterpreter::ScEuroConvert() double fIntermediate = fVal / fFromRate; if ( fPrecision ) fIntermediate = ::rtl::math::round( fIntermediate, - (int) fPrecision ); + static_cast<int>(fPrecision) ); fRes = fIntermediate * fToRate; } if ( !bFullPrecision ) diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index bf989bb94baa..723c75d8139f 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -203,7 +203,7 @@ double ScInterpreter::gauss(double x) { double xAbs = fabs(x); - sal_uInt16 xShort = (sal_uInt16)::rtl::math::approxFloor(xAbs); + sal_uInt16 xShort = static_cast<sal_uInt16>(::rtl::math::approxFloor(xAbs)); double nVal = 0.0; if (xShort == 0) { @@ -1196,8 +1196,8 @@ void ScInterpreter::ScPermut() else { double nVal = n; - for (sal_uLong i = (sal_uLong)k-1; i >= 1; i--) - nVal *= n-(double)i; + for (sal_uLong i = static_cast<sal_uLong>(k)-1; i >= 1; i--) + nVal *= n-static_cast<double>(i); PushDouble(nVal); } } @@ -1642,7 +1642,7 @@ void ScInterpreter::ScTDist() PushIllegalArgument(); return; } - PushDouble( GetTDist( T, fDF, ( int )fFlag ) ); + PushDouble( GetTDist( T, fDF, static_cast<int>(fFlag) ) ); } void ScInterpreter::ScTDist_T( int nTails ) @@ -1811,7 +1811,7 @@ void ScInterpreter::ScPoissonDist( bool bODFF ) int nEnd = sal::static_int_cast<int>( x ); for (int i = 1; i <= nEnd; i++) { - fSummand = (fSummand * lambda)/(double)i; + fSummand = (fSummand * lambda)/static_cast<double>(i); fSum += fSummand; } PushDouble(fSum); @@ -2716,7 +2716,7 @@ void ScInterpreter::ScTTest() PushIllegalArgument(); return; } - PushDouble( GetTDist( fT, fF, ( int )fTails ) ); + PushDouble( GetTDist( fT, fF, static_cast<int>(fTails) ) ); } void ScInterpreter::ScFTest() @@ -2848,7 +2848,7 @@ void ScInterpreter::ScChiTest() double fDF; if (nC1 == 1 || nR1 == 1) { - fDF = (double)(nC1*nR1 - 1); + fDF = static_cast<double>(nC1*nR1 - 1); if (fDF == 0.0) { PushNoValue(); @@ -2856,7 +2856,7 @@ void ScInterpreter::ScChiTest() } } else - fDF = (double)(nC1-1)*(double)(nR1-1); + fDF = static_cast<double>(nC1-1)*static_cast<double>(nR1-1); PushDouble(GetChiDist(fChi, fDF)); } @@ -3399,7 +3399,7 @@ double ScInterpreter::GetPercentile( vector<double> & rArray, double fPercentile return rArray[0]; else { - size_t nIndex = (size_t)::rtl::math::approxFloor( fPercentile * (nSize-1)); + size_t nIndex = static_cast<size_t>(::rtl::math::approxFloor( fPercentile * (nSize-1))); double fDiff = fPercentile * (nSize-1) - ::rtl::math::approxFloor( fPercentile * (nSize-1)); OSL_ENSURE(nIndex < nSize, "GetPercentile: wrong index(1)"); vector<double>::iterator iter = rArray.begin() + nIndex; @@ -3425,13 +3425,13 @@ double ScInterpreter::GetPercentileExclusive( vector<double> & rArray, double fP SetError( FormulaError::NoValue ); return 0.0; } - if ( fPercentile * nSize1 < 1.0 || fPercentile * nSize1 > (double) ( nSize1 - 1 ) ) + if ( fPercentile * nSize1 < 1.0 || fPercentile * nSize1 > static_cast<double>( nSize1 - 1 ) ) { SetError( FormulaError::IllegalParameter ); return 0.0; } - size_t nIndex = (size_t)::rtl::math::approxFloor( fPercentile * nSize1 - 1 ); + size_t nIndex = static_cast<size_t>(::rtl::math::approxFloor( fPercentile * nSize1 - 1 )); double fDiff = fPercentile * nSize1 - 1 - ::rtl::math::approxFloor( fPercentile * nSize1 - 1 ); OSL_ENSURE(nIndex < ( nSize1 - 1 ), "GetPercentile: wrong index(1)"); vector<double>::iterator iter = rArray.begin() + nIndex; @@ -3625,7 +3625,7 @@ double ScInterpreter::GetPercentrank( ::std::vector<double> & rArray, double fVa if ( bInclusive ) fRes = 0.0; else - fRes = 1.0 / ( double )( nSize + 1 ); + fRes = 1.0 / static_cast<double>( nSize + 1 ); } else { @@ -3647,7 +3647,7 @@ double ScInterpreter::GetPercentrank( ::std::vector<double> & rArray, double fVa if ( bInclusive ) fRes = div( nOldCount, nSize - 1 ); else - fRes = ( double )( i + 1 ) / ( double )( nSize + 1 ); + fRes = static_cast<double>( i + 1 ) / static_cast<double>( nSize + 1 ); } else { @@ -3664,9 +3664,9 @@ double ScInterpreter::GetPercentrank( ::std::vector<double> & rArray, double fVa double fFract = ( fVal - rArray[ nOldCount - 1 ] ) / ( rArray[ nOldCount ] - rArray[ nOldCount - 1 ] ); if ( bInclusive ) - fRes = div( ( double )( nOldCount - 1 ) + fFract, nSize - 1 ); + fRes = div( static_cast<double>( nOldCount - 1 ) + fFract, nSize - 1 ); else - fRes = ( ( double )nOldCount + fFract ) / ( double )( nSize + 1 ); + fRes = ( static_cast<double>(nOldCount) + fFract ) / static_cast<double>( nSize + 1 ); } } } @@ -3690,7 +3690,7 @@ void ScInterpreter::ScTrimMean() PushNoValue(); else { - sal_uLong nIndex = (sal_uLong) ::rtl::math::approxFloor(alpha*(double)nSize); + sal_uLong nIndex = static_cast<sal_uLong>(::rtl::math::approxFloor(alpha*static_cast<double>(nSize))); if (nIndex % 2 != 0) nIndex--; nIndex /= 2; @@ -3698,7 +3698,7 @@ void ScInterpreter::ScTrimMean() double fSum = 0.0; for (SCSIZE i = nIndex; i < nSize-nIndex; i++) fSum += aSortArray[i]; - PushDouble(fSum/(double)(nSize-2*nIndex)); + PushDouble(fSum/static_cast<double>(nSize-2*nIndex)); } } diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 0fbc89b56180..54e221800324 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -430,10 +430,10 @@ bool ScInterpreter::CreateStringArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, return false; // Append a 0-pad-byte if string length is odd // MUST be sal_uInt16 - sal_uInt16 nStrLen = (sal_uInt16) aTmp.getLength(); + sal_uInt16 nStrLen = static_cast<sal_uInt16>(aTmp.getLength()); sal_uInt16 nLen = ( nStrLen + 2 ) & ~1; - if (((sal_uLong)nPos + (5 * sizeof(sal_uInt16)) + nLen) > MAXARRSIZE) + if ((static_cast<sal_uLong>(nPos) + (5 * sizeof(sal_uInt16)) + nLen) > MAXARRSIZE) return false; *p++ = static_cast<sal_uInt16>(nCol); *p++ = static_cast<sal_uInt16>(nRow); @@ -554,9 +554,9 @@ bool ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, return false; // Append a 0-pad-byte if string length is odd // MUST be sal_uInt16 - sal_uInt16 nStrLen = (sal_uInt16) aTmp.getLength(); + sal_uInt16 nStrLen = static_cast<sal_uInt16>(aTmp.getLength()); sal_uInt16 nLen = ( nStrLen + 2 ) & ~1; - if ( ((sal_uLong)nPos + 2 + nLen) > MAXARRSIZE) + if ( (static_cast<sal_uLong>(nPos) + 2 + nLen) > MAXARRSIZE) return false; *p++ = nLen; memcpy( p, aTmp.getStr(), nStrLen + 1); @@ -3281,7 +3281,7 @@ void ScInterpreter::ScMacro() bool bOk = true; for( short i = nParamCount; i && bOk ; i-- ) { - SbxVariable* pPar = refPar->Get( (sal_uInt16) i ); + SbxVariable* pPar = refPar->Get( static_cast<sal_uInt16>(i) ); switch( GetStackType() ) { case svDouble: diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index f52c62fbbb2c..a83e5599c476 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -1649,8 +1649,8 @@ void ScInterpreter::ScPow() { if (fVal1 < 0 && fVal2 != 0.0) { - int i = (int) (1 / fVal2 + ((fVal2 < 0) ? -0.5 : 0.5)); - if (i % 2 != 0 && rtl::math::approxEqual(1 / ((double) i), fVal2)) + int i = static_cast<int>(1 / fVal2 + ((fVal2 < 0) ? -0.5 : 0.5)); + if (i % 2 != 0 && rtl::math::approxEqual(1 / static_cast<double>(i), fVal2)) PushDouble(-pow(-fVal1, fVal2)); else PushDouble(pow(fVal1, fVal2)); diff --git a/sc/source/core/tool/jumpmatrix.cxx b/sc/source/core/tool/jumpmatrix.cxx index c80c8ca1cf0d..b16d5a9a7651 100644 --- a/sc/source/core/tool/jumpmatrix.cxx +++ b/sc/source/core/tool/jumpmatrix.cxx @@ -73,7 +73,7 @@ void ScJumpMatrix::GetDimensions(SCSIZE& rCols, SCSIZE& rRows) const void ScJumpMatrix::SetJump(SCSIZE nCol, SCSIZE nRow, double fBool, short nStart, short nNext) { - mvJump[(sal_uLong)nCol * nRows + nRow].SetJump(fBool, nStart, nNext, SHRT_MAX); + mvJump[static_cast<sal_uLong>(nCol) * nRows + nRow].SetJump(fBool, nStart, nNext, SHRT_MAX); } void ScJumpMatrix::GetJump( @@ -92,13 +92,13 @@ void ScJumpMatrix::GetJump( nCol = 0; nRow = 0; } - mvJump[(sal_uLong)nCol * nRows + nRow]. + mvJump[static_cast<sal_uLong>(nCol) * nRows + nRow]. GetJump(rBool, rStart, rNext, rStop); } void ScJumpMatrix::SetAllJumps(double fBool, short nStart, short nNext, short nStop) { - sal_uLong n = (sal_uLong)nCols * nRows; + sal_uLong n = static_cast<sal_uLong>(nCols) * nRows; for (sal_uLong j = 0; j < n; ++j) { mvJump[j].SetJump(fBool, nStart, diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx index d42e4e6253a2..7464dbf9a843 100644 --- a/sc/source/core/tool/parclass.cxx +++ b/sc/source/core/tool/parclass.cxx @@ -287,7 +287,7 @@ void ScParameterClassification::Init() else { RunData* pRun = &pData[ pRaw->eOp ]; - SAL_WARN_IF(pRun->aData.nParam[0] != Unknown, "sc.core", "already assigned: " << (int)pRaw->eOp); + SAL_WARN_IF(pRun->aData.nParam[0] != Unknown, "sc.core", "already assigned: " << static_cast<int>(pRaw->eOp)); memcpy( &(pRun->aData), &(pRaw->aData), sizeof(CommonData)); // fill 0-initialized fields with real values if ( pRun->aData.nRepeatLast ) @@ -361,7 +361,7 @@ formula::ParamClass ScParameterClassification::GetParameterType( // added to avoid warnings } } - if ( 0 <= (short)eOp && eOp <= SC_OPCODE_LAST_OPCODE_ID ) + if ( 0 <= static_cast<short>(eOp) && eOp <= SC_OPCODE_LAST_OPCODE_ID ) { sal_uInt8 nRepeat; formula::ParamClass eType; diff --git a/sc/source/core/tool/queryentry.cxx b/sc/source/core/tool/queryentry.cxx index c685e7be6222..e794532b285a 100644 --- a/sc/source/core/tool/queryentry.cxx +++ b/sc/source/core/tool/queryentry.cxx @@ -27,8 +27,8 @@ * conjunctions with the flag bQueryByString = FALSE. */ -#define SC_EMPTYFIELDS ((double)0x0042) -#define SC_NONEMPTYFIELDS ((double)0x0043) +#define SC_EMPTYFIELDS (double(0x0042)) +#define SC_NONEMPTYFIELDS (double(0x0043)) bool ScQueryEntry::Item::operator== (const Item& r) const { diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx index 592d01845efa..a0f8ebe552c0 100644 --- a/sc/source/core/tool/rangelst.cxx +++ b/sc/source/core/tool/rangelst.cxx @@ -1547,7 +1547,7 @@ ScRangePair** ScRangePairList::CreateNameSortedArray( size_t& nListCount, ScDocument* pDoc ) const { nListCount = maPairs.size(); - OSL_ENSURE( nListCount * sizeof(ScRangePairNameSort) <= (size_t)~0x1F, + OSL_ENSURE( nListCount * sizeof(ScRangePairNameSort) <= size_t(~0x1F), "ScRangePairList::CreateNameSortedArray nListCount * sizeof(ScRangePairNameSort) > (size_t)~0x1F" ); ScRangePairNameSort* pSortArray = reinterpret_cast<ScRangePairNameSort*>( new sal_uInt8 [ nListCount * sizeof(ScRangePairNameSort) ]); diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index fd7de4b83fa5..8a6255651b08 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -244,7 +244,7 @@ void ScRangeData::GuessPosition() } } - aPos = ScAddress( (SCCOL)(-nMinCol), (SCROW)(-nMinRow), (SCTAB)(-nMinTab) ); + aPos = ScAddress( static_cast<SCCOL>(-nMinCol), static_cast<SCROW>(-nMinRow), static_cast<SCTAB>(-nMinTab) ); } void ScRangeData::GetSymbol( OUString& rSymbol, const FormulaGrammar::Grammar eGrammar ) const @@ -641,9 +641,9 @@ void ScRangeData::InitCode() extern "C" int ScRangeData_QsortNameCompare( const void* p1, const void* p2 ) { - return (int) ScGlobal::GetCollator()->compareString( + return static_cast<int>(ScGlobal::GetCollator()->compareString( (*static_cast<const ScRangeData* const *>(p1))->GetName(), - (*static_cast<const ScRangeData* const *>(p2))->GetName() ); + (*static_cast<const ScRangeData* const *>(p2))->GetName() )); } namespace { diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx index 207733ba6b82..89de8ef80084 100644 --- a/sc/source/core/tool/rangeseq.cxx +++ b/sc/source/core/tool/rangeseq.cxx @@ -53,7 +53,7 @@ static long lcl_DoubleToLong( double fVal ) double fInt = (fVal >= 0.0) ? ::rtl::math::approxFloor( fVal ) : ::rtl::math::approxCeil( fVal ); if ( fInt >= LONG_MIN && fInt <= LONG_MAX ) - return (long)fInt; + return static_cast<long>(fInt); else return 0; // out of range } @@ -74,7 +74,7 @@ bool ScRangeToSequence::FillLongArray( uno::Any& rAny, ScDocument* pDoc, const S sal_Int32* pColAry = aColSeq.getArray(); for (long nCol = 0; nCol < nColCount; nCol++) pColAry[nCol] = lcl_DoubleToLong( pDoc->GetValue( - ScAddress( (SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab ) ) ); + ScAddress( static_cast<SCCOL>(nStartCol+nCol), static_cast<SCROW>(nStartRow+nRow), nTab ) ) ); pRowAry[nRow] = aColSeq; } @@ -127,7 +127,7 @@ bool ScRangeToSequence::FillDoubleArray( uno::Any& rAny, ScDocument* pDoc, const double* pColAry = aColSeq.getArray(); for (long nCol = 0; nCol < nColCount; nCol++) pColAry[nCol] = pDoc->GetValue( - ScAddress( (SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab ) ); + ScAddress( static_cast<SCCOL>(nStartCol+nCol), static_cast<SCROW>(nStartRow+nRow), nTab ) ); pRowAry[nRow] = aColSeq; } @@ -183,7 +183,7 @@ bool ScRangeToSequence::FillStringArray( uno::Any& rAny, ScDocument* pDoc, const for (long nCol = 0; nCol < nColCount; nCol++) { FormulaError nErrCode = pDoc->GetStringForFormula( - ScAddress((SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab), + ScAddress(static_cast<SCCOL>(nStartCol+nCol), static_cast<SCROW>(nStartRow+nRow), nTab), pColAry[nCol] ); if ( nErrCode != FormulaError::NONE ) bHasErrors = true; @@ -256,7 +256,7 @@ bool ScRangeToSequence::FillMixedArray( uno::Any& rAny, ScDocument* pDoc, const { uno::Any& rElement = pColAry[nCol]; - ScAddress aPos( (SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab ); + ScAddress aPos( static_cast<SCCOL>(nStartCol+nCol), static_cast<SCROW>(nStartRow+nRow), nTab ); ScRefCellValue aCell(*pDoc, aPos); if (aCell.isEmpty()) diff --git a/sc/source/core/tool/refreshtimer.cxx b/sc/source/core/tool/refreshtimer.cxx index 196c412102ae..3db86b814be3 100644 --- a/sc/source/core/tool/refreshtimer.cxx +++ b/sc/source/core/tool/refreshtimer.cxx @@ -24,7 +24,7 @@ void ScRefreshTimerControl::SetAllowRefresh( bool b ) { if ( b && nBlockRefresh ) --nBlockRefresh; - else if ( !b && nBlockRefresh < (sal_uInt16)(~0) ) + else if ( !b && nBlockRefresh < sal_uInt16(~0) ) ++nBlockRefresh; } diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index c0078b5f8839..19d4b62394b6 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -361,7 +361,7 @@ static size_t GetElementsMax( size_t nMemory ) // With 1GB that's ~85M elements, or 85 whole columns. constexpr size_t nElemMax = nMemMax / nPerElem; // With MAXROWCOUNT==1048576 and 128 columns => 128M elements, 1.5GB - constexpr size_t nArbitraryLimit = (size_t)MAXROWCOUNT * 128; + constexpr size_t nArbitraryLimit = size_t(MAXROWCOUNT) * 128; // With the constant 1GB from above that's the actual value. return nElemMax < nArbitraryLimit ? nElemMax : nArbitraryLimit; } @@ -1645,7 +1645,7 @@ inline double evaluate( double fVal, ScQueryOp eOp ) ; } - SAL_WARN("sc.core", "evaluate: unhandled comparison operator: " << (int)eOp); + SAL_WARN("sc.core", "evaluate: unhandled comparison operator: " << static_cast<int>(eOp)); return CreateDoubleError( FormulaError::UnknownState); } @@ -3319,7 +3319,7 @@ public: TRet operator()(bool bVal) const { - return maOp((double)bVal, mfVal); + return maOp(static_cast<double>(bVal), mfVal); } double operator()(const svl::SharedString& rStr) const diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx index 4b688654077c..ea55273bbc7c 100644 --- a/sc/source/core/tool/sharedformula.cxx +++ b/sc/source/core/tool/sharedformula.cxx @@ -176,7 +176,7 @@ bool SharedFormulaUtil::joinFormulaCells( else { // neither cells are shared. - assert(rCell1.aPos.Row() == (SCROW)(rPos.first->position + rPos.second)); + assert(rCell1.aPos.Row() == static_cast<SCROW>(rPos.first->position + rPos.second)); xGroup1 = rCell1.CreateCellGroup(2, eState == ScFormulaCell::EqualInvariant); rCell2.SetCellGroup(xGroup1); } diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 6028ac2e1ab0..de5abccd1ae1 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -381,7 +381,7 @@ bool ScRawToken::IsValidReference() const FormulaToken* ScRawToken::CreateToken() const { -#define IF_NOT_OPCODE_ERROR(o,c) SAL_WARN_IF((eOp!=o), "sc.core", #c "::ctor: OpCode " << (int)eOp << " lost, converted to " #o "; maybe inherit from FormulaToken instead!") +#define IF_NOT_OPCODE_ERROR(o,c) SAL_WARN_IF((eOp!=o), "sc.core", #c "::ctor: OpCode " << static_cast<int>(eOp) << " lost, converted to " #o "; maybe inherit from FormulaToken instead!") switch ( GetType() ) { case svByte : diff --git a/sc/source/core/tool/viewopti.cxx b/sc/source/core/tool/viewopti.cxx index 5ab76e2e9cf7..65bf1db49122 100644 --- a/sc/source/core/tool/viewopti.cxx +++ b/sc/source/core/tool/viewopti.cxx @@ -397,7 +397,7 @@ ScViewCfg::ScViewCfg() : if ( pValues[nProp] >>= nIntVal ) { //#i80528# adapt to new range eventually - if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW; + if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int32(VOBJ_MODE_SHOW); SetObjMode( VOBJ_TYPE_OLE, (ScVObjMode)nIntVal); } @@ -406,7 +406,7 @@ ScViewCfg::ScViewCfg() : if ( pValues[nProp] >>= nIntVal ) { //#i80528# adapt to new range eventually - if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW; + if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int32(VOBJ_MODE_SHOW); SetObjMode( VOBJ_TYPE_CHART, (ScVObjMode)nIntVal); } @@ -415,7 +415,7 @@ ScViewCfg::ScViewCfg() : if ( pValues[nProp] >>= nIntVal ) { //#i80528# adapt to new range eventually - if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW; + if(sal_Int32(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int32(VOBJ_MODE_SHOW); SetObjMode( VOBJ_TYPE_DRAW, (ScVObjMode)nIntVal); } @@ -490,7 +490,7 @@ IMPL_LINK_NOARG(ScViewCfg, LayoutCommitHdl, ScLinkConfigItem&, void) switch(nProp) { case SCLAYOUTOPT_GRIDCOLOR: - pValues[nProp] <<= (sal_Int32) GetGridColor().GetColor(); + pValues[nProp] <<= static_cast<sal_Int32>(GetGridColor().GetColor()); break; case SCLAYOUTOPT_GRIDLINES: pValues[nProp] <<= GetOption( VOPT_GRID ); @@ -553,13 +553,13 @@ IMPL_LINK_NOARG(ScViewCfg, DisplayCommitHdl, ScLinkConfigItem&, void) pValues[nProp] <<= GetOption( VOPT_CLIPMARKS ); break; case SCDISPLAYOPT_OBJECTGRA: - pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_OLE ); + pValues[nProp] <<= static_cast<sal_Int32>(GetObjMode( VOBJ_TYPE_OLE )); break; case SCDISPLAYOPT_CHART: - pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_CHART ); + pValues[nProp] <<= static_cast<sal_Int32>(GetObjMode( VOBJ_TYPE_CHART )); break; case SCDISPLAYOPT_DRAWING: - pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_DRAW ); + pValues[nProp] <<= static_cast<sal_Int32>(GetObjMode( VOBJ_TYPE_DRAW )); break; } } @@ -579,22 +579,22 @@ IMPL_LINK_NOARG(ScViewCfg, GridCommitHdl, ScLinkConfigItem&, void) switch(nProp) { case SCGRIDOPT_RESOLU_X: - pValues[nProp] <<= (sal_Int32) rGrid.GetFieldDrawX(); + pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDrawX()); break; case SCGRIDOPT_RESOLU_Y: - pValues[nProp] <<= (sal_Int32) rGrid.GetFieldDrawY(); + pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDrawY()); break; case SCGRIDOPT_SUBDIV_X: - pValues[nProp] <<= (sal_Int32) rGrid.GetFieldDivisionX(); + pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDivisionX()); break; case SCGRIDOPT_SUBDIV_Y: - pValues[nProp] <<= (sal_Int32) rGrid.GetFieldDivisionY(); + pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldDivisionY()); break; case SCGRIDOPT_OPTION_X: - pValues[nProp] <<= (sal_Int32) rGrid.GetFieldSnapX(); + pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldSnapX()); break; case SCGRIDOPT_OPTION_Y: - pValues[nProp] <<= (sal_Int32) rGrid.GetFieldSnapY(); + pValues[nProp] <<= static_cast<sal_Int32>(rGrid.GetFieldSnapY()); break; case SCGRIDOPT_SNAPTOGRID: pValues[nProp] <<= rGrid.GetUseGridSnap(); diff --git a/sc/source/core/tool/zforauto.cxx b/sc/source/core/tool/zforauto.cxx index 25c2c34ef8a6..5d796bf8f11f 100644 --- a/sc/source/core/tool/zforauto.cxx +++ b/sc/source/core/tool/zforauto.cxx @@ -52,7 +52,7 @@ void ScNumFormatAbbrev::Load( SvStream& rStream, rtl_TextEncoding eByteStrSet ) void ScNumFormatAbbrev::Save( SvStream& rStream, rtl_TextEncoding eByteStrSet ) const { rStream.WriteUniOrByteString( sFormatstring, eByteStrSet ); - rStream.WriteUInt16( (sal_uInt16)eSysLanguage ).WriteUInt16( (sal_uInt16)eLanguage ); + rStream.WriteUInt16( static_cast<sal_uInt16>(eSysLanguage) ).WriteUInt16( static_cast<sal_uInt16>(eLanguage) ); } void ScNumFormatAbbrev::PutFormatIndex(sal_uInt32 nFormat, diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx index 9b7dbc678457..c523b072ba02 100644 --- a/sc/source/filter/dif/difimp.cxx +++ b/sc/source/filter/dif/difimp.cxx @@ -591,7 +591,7 @@ const sal_Unicode* DifParser::ScanIntVal( const sal_Unicode* pStart, sal_uInt32& sal_Unicode cAkt = *pStart; if( IsNumber( cAkt ) ) - rRet = ( sal_uInt32 ) ( cAkt - '0' ); + rRet = static_cast<sal_uInt32>( cAkt - '0' ); else return nullptr; @@ -601,7 +601,7 @@ const sal_Unicode* DifParser::ScanIntVal( const sal_Unicode* pStart, sal_uInt32& while( IsNumber( cAkt ) && rRet < ( 0xFFFFFFFF / 10 ) ) { rRet *= 10; - rRet += ( sal_uInt32 ) ( cAkt - '0' ); + rRet += static_cast<sal_uInt32>( cAkt - '0' ); pStart++; cAkt = *pStart; diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 1fec63a82401..aa0c351771a6 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -463,7 +463,7 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pResult, XclImpStream& aIn, std case 0x1E: // Integer [315 266] { sal_uInt16 nUINT16 = aIn.ReaduInt16(); - aStack << aPool.Store( ( double ) nUINT16 ); + aStack << aPool.Store( static_cast<double>(nUINT16) ); break; } case 0x1F: // Number [315 266] @@ -1601,7 +1601,7 @@ void ExcelToSc::DoMulArgs( DefTokenId eId, sal_uInt8 nCnt ) if( aPool.IsSingleOp( eParam[ nLauf ], ocMissing ) ) { if( !nNullParam ) - nNullParam = (sal_uInt16) aPool.Store( 0.0 ); + nNullParam = static_cast<sal_uInt16>(aPool.Store( 0.0 )); eParam[ nLauf ] = nNullParam; } } diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx index b441f729c4c1..824523574c10 100644 --- a/sc/source/filter/excel/excform8.cxx +++ b/sc/source/filter/excel/excform8.cxx @@ -428,7 +428,7 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn, case 0x1E: // Integer [315 266] { sal_uInt16 nUINT16 = aIn.ReaduInt16(); - aStack << aPool.Store( ( double ) nUINT16 ); + aStack << aPool.Store( static_cast<double>(nUINT16) ); break; } case 0x1F: // Number [315 266] @@ -1461,7 +1461,7 @@ void ExcelToSc8::ExcRelToScRel8( sal_uInt16 nRow, sal_uInt16 nC, ScSingleRefData if ( nDiff < 0) { // relative column references wrap around - nRelCol = static_cast<sal_Int16>(256 + (int)nRelCol); + nRelCol = static_cast<sal_Int16>(256 + static_cast<int>(nRelCol)); } rSRD.SetRelCol(nRelCol); } diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index cc69f4ae3c1e..2125a593ae1b 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -172,7 +172,7 @@ sal_uInt16 ExcDummyRec::GetNum() const void ExcBoolRecord::SaveCont( XclExpStream& rStrm ) { - rStrm << (sal_uInt16)(bVal ? 0x0001 : 0x0000); + rStrm << static_cast<sal_uInt16>(bVal ? 0x0001 : 0x0000); } std::size_t ExcBoolRecord::GetLen() const @@ -357,14 +357,14 @@ ExcBundlesheet::ExcBundlesheet( const RootData& rRootData, SCTAB _nTab ) : void ExcBundlesheet::SaveCont( XclExpStream& rStrm ) { m_nOwnPos = rStrm.GetSvStreamPos(); - rStrm << (sal_uInt32) 0x00000000 // dummy (stream position of the sheet) + rStrm << sal_uInt32(0x00000000) // dummy (stream position of the sheet) << nGrbit; rStrm.WriteByteString(aName); // 8 bit length, max 255 chars } std::size_t ExcBundlesheet::GetLen() const { - return 7 + std::min( aName.getLength(), (sal_Int32) 255 ); + return 7 + std::min( aName.getLength(), sal_Int32(255) ); } //--------------------------------------------------------- class ExcDummy_02 - @@ -594,13 +594,13 @@ void ExcFilterCondition::Save( XclExpStream& rStrm ) break; case EXC_AFTYPE_STRING: OSL_ENSURE( pText, "ExcFilterCondition::Save() -- pText is NULL!" ); - rStrm << (sal_uInt32)0 << (sal_uInt8) pText->Len() << (sal_uInt16)0 << (sal_uInt8)0; + rStrm << sal_uInt32(0) << static_cast<sal_uInt8>(pText->Len()) << sal_uInt16(0) << sal_uInt8(0); break; case EXC_AFTYPE_BOOLERR: - rStrm << (sal_uInt8)0 << (sal_uInt8)((fVal != 0) ? 1 : 0) << (sal_uInt32)0 << (sal_uInt16)0; + rStrm << sal_uInt8(0) << static_cast<sal_uInt8>((fVal != 0) ? 1 : 0) << sal_uInt32(0) << sal_uInt16(0); break; default: - rStrm << (sal_uInt32)0 << (sal_uInt32)0; + rStrm << sal_uInt32(0) << sal_uInt32(0); } } @@ -766,7 +766,7 @@ bool XclExpAutofilter::AddEntry( const ScQueryEntry& rEntry ) { if( fVal < 0 ) fVal = 0; if( fVal >= 501 ) fVal = 500; - nFlags |= (nNewFlags | (sal_uInt16)fVal << 7); + nFlags |= (nNewFlags | static_cast<sal_uInt16>(fVal) << 7); } // normal condition else diff --git a/sc/source/filter/excel/fontbuff.cxx b/sc/source/filter/excel/fontbuff.cxx index c7a6a9b5f5d1..2a0a6c07d4f5 100644 --- a/sc/source/filter/excel/fontbuff.cxx +++ b/sc/source/filter/excel/fontbuff.cxx @@ -97,7 +97,7 @@ void LotusFontBuffer::SetHeight( const sal_uInt16 nIndex, const sal_uInt16 nHeig { OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetHeight(): Array too small!" ); if( nIndex < nSize ) - pData[ nIndex ].Height( *( new SvxFontHeightItem( ( sal_uLong ) nHeight * 20, 100, ATTR_FONT_HEIGHT ) ) ); + pData[ nIndex ].Height( *( new SvxFontHeightItem( static_cast<sal_uLong>(nHeight) * 20, 100, ATTR_FONT_HEIGHT ) ) ); } void LotusFontBuffer::SetType( const sal_uInt16 nIndex, const sal_uInt16 nType ) diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index e61eb7a4ba79..757fae01f575 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -496,7 +496,7 @@ void ImportExcel::Columndefault() nColMic = aIn.ReaduInt16(); nColMac = aIn.ReaduInt16(); - OSL_ENSURE( aIn.GetRecLeft() == (std::size_t)(nColMac - nColMic) * 3 + 2, + OSL_ENSURE( aIn.GetRecLeft() == static_cast<std::size_t>(nColMac - nColMic) * 3 + 2, "ImportExcel::Columndefault - wrong record size" ); nColMac--; diff --git a/sc/source/filter/excel/namebuff.cxx b/sc/source/filter/excel/namebuff.cxx index efc575804106..e08a46653666 100644 --- a/sc/source/filter/excel/namebuff.cxx +++ b/sc/source/filter/excel/namebuff.cxx @@ -39,7 +39,7 @@ sal_uInt32 StringHashEntry::MakeHashCode( const OUString& r ) while( cAkt ) { n *= 70; - n += ( sal_uInt32 ) cAkt; + n += static_cast<sal_uInt32>(cAkt); pAkt++; cAkt = *pAkt; } diff --git a/sc/source/filter/excel/tokstack.cxx b/sc/source/filter/excel/tokstack.cxx index 4129b50f2287..0b6ea60ebbeb 100644 --- a/sc/source/filter/excel/tokstack.cxx +++ b/sc/source/filter/excel/tokstack.cxx @@ -472,7 +472,7 @@ const TokenId TokenPool::Store( const OUString& rString ) *ppP_Str[ ppP_Str.m_writemark ] = rString; /* attention truncate to 16 bits */ - pSize[ nElementAkt ] = ( sal_uInt16 ) ppP_Str[ ppP_Str.m_writemark ]->getLength(); + pSize[ nElementAkt ] = static_cast<sal_uInt16>(ppP_Str[ ppP_Str.m_writemark ]->getLength()); nElementAkt++; ppP_Str.m_writemark++; @@ -693,7 +693,7 @@ void TokenPool::Reset() bool TokenPool::IsSingleOp( const TokenId& rId, const DefTokenId eId ) const { - sal_uInt16 nId = (sal_uInt16) rId; + sal_uInt16 nId = static_cast<sal_uInt16>(rId); if( nId && nId <= nElementAkt ) {// existent? nId--; @@ -720,7 +720,7 @@ bool TokenPool::IsSingleOp( const TokenId& rId, const DefTokenId eId ) const const OUString* TokenPool::GetExternal( const TokenId& rId ) const { const OUString* p = nullptr; - sal_uInt16 n = (sal_uInt16) rId; + sal_uInt16 n = static_cast<sal_uInt16>(rId); if( n && n <= nElementAkt ) { n--; diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index bd165ceb279e..537c494cde52 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -785,12 +785,12 @@ OString XclXmlUtils::ToOString( const XclRangeList& rRanges ) OUString XclXmlUtils::ToOUString( const char* s ) { - return OUString( s, (sal_Int32) strlen( s ), RTL_TEXTENCODING_ASCII_US ); + return OUString( s, static_cast<sal_Int32>(strlen( s )), RTL_TEXTENCODING_ASCII_US ); } OUString XclXmlUtils::ToOUString( const ScfUInt16Vec& rBuf, sal_Int32 nStart, sal_Int32 nLength ) { - if( nLength == -1 || ( nLength > ((sal_Int32)rBuf.size() - nStart) ) ) + if( nLength == -1 || ( nLength > (static_cast<sal_Int32>(rBuf.size()) - nStart) ) ) nLength = (rBuf.size() - nStart); return nLength > 0 diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index e8d9bb81062a..98127479cf95 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -783,7 +783,7 @@ void XclExpLabelCell::SaveXml( XclExpXmlStream& rStrm ) // OOXTODO: XML_cm, XML_vm, XML_ph FSEND ); rWorksheet->startElement( XML_v, FSEND ); - rWorksheet->write( (sal_Int32) mnSstIndex ); + rWorksheet->write( static_cast<sal_Int32>(mnSstIndex) ); rWorksheet->endElement( XML_v ); rWorksheet->endElement( XML_c ); } @@ -1520,13 +1520,13 @@ void XclExpDimensions::SetDimensions( void XclExpDimensions::SaveXml( XclExpXmlStream& rStrm ) { ScRange aRange; - aRange.aStart.SetRow( (SCROW) mnFirstUsedXclRow ); - aRange.aStart.SetCol( (SCCOL) mnFirstUsedXclCol ); + aRange.aStart.SetRow( static_cast<SCROW>(mnFirstUsedXclRow) ); + aRange.aStart.SetCol( static_cast<SCCOL>(mnFirstUsedXclCol) ); if( mnFirstFreeXclRow != mnFirstUsedXclRow && mnFirstFreeXclCol != mnFirstUsedXclCol ) { - aRange.aEnd.SetRow( (SCROW) (mnFirstFreeXclRow-1) ); - aRange.aEnd.SetCol( (SCCOL) (mnFirstFreeXclCol-1) ); + aRange.aEnd.SetRow( static_cast<SCROW>(mnFirstFreeXclRow-1) ); + aRange.aEnd.SetCol( static_cast<SCCOL>(mnFirstFreeXclCol-1) ); } aRange.PutInOrder(); @@ -2117,7 +2117,7 @@ void XclExpRow::SaveXml( XclExpXmlStream& rStrm ) // OOXTODO: XML_spans, optional XML_s, haveFormat ? lcl_GetStyleId( rStrm, mnXFIndex ).getStr() : nullptr, XML_customFormat, ToPsz( haveFormat ), - XML_ht, OString::number( (double) mnHeight / 20.0 ).getStr(), + XML_ht, OString::number( static_cast<double>(mnHeight) / 20.0 ).getStr(), XML_hidden, ToPsz( ::get_flag( mnFlags, EXC_ROW_HIDDEN ) ), XML_customHeight, ToPsz( ::get_flag( mnFlags, EXC_ROW_UNSYNCED ) ), XML_outlineLevel, OString::number( mnOutlineLevel ).getStr(), diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx index 4243fd08221e..87f824262b87 100644 --- a/sc/source/filter/excel/xichart.cxx +++ b/sc/source/filter/excel/xichart.cxx @@ -2458,7 +2458,7 @@ void XclImpChChart3d::Convert( ScfPropertySet& rPropSet, bool b3dWallChart ) con } // properties - rPropSet.SetProperty( EXC_CHPROP_3DRELATIVEHEIGHT, (sal_Int32)(maData.mnRelHeight / 2)); // seems to be 200%, change to 100% + rPropSet.SetProperty( EXC_CHPROP_3DRELATIVEHEIGHT, static_cast<sal_Int32>(maData.mnRelHeight / 2)); // seems to be 200%, change to 100% rPropSet.SetProperty( EXC_CHPROP_ROTATIONVERTICAL, nRotationY ); rPropSet.SetProperty( EXC_CHPROP_ROTATIONHORIZONTAL, nRotationX ); rPropSet.SetProperty( EXC_CHPROP_PERSPECTIVE, nPerspective ); @@ -3391,7 +3391,7 @@ Reference< XAxis > XclImpChAxis::CreateAxis( const XclImpChTypeGroup& rTypeGroup // main grid ScfPropertySet aGridProp( xAxis->getGridProperties() ); - aGridProp.SetBoolProperty( EXC_CHPROP_SHOW, (bool)mxMajorGrid ); + aGridProp.SetBoolProperty( EXC_CHPROP_SHOW, static_cast<bool>(mxMajorGrid) ); if( mxMajorGrid ) mxMajorGrid->Convert( GetChRoot(), aGridProp, EXC_CHOBJTYPE_GRIDLINE ); // sub grid @@ -3399,7 +3399,7 @@ Reference< XAxis > XclImpChAxis::CreateAxis( const XclImpChTypeGroup& rTypeGroup if( aSubGridPropSeq.hasElements() ) { ScfPropertySet aSubGridProp( aSubGridPropSeq[ 0 ] ); - aSubGridProp.SetBoolProperty( EXC_CHPROP_SHOW, (bool)mxMinorGrid ); + aSubGridProp.SetBoolProperty( EXC_CHPROP_SHOW, static_cast<bool>(mxMinorGrid) ); if( mxMinorGrid ) mxMinorGrid->Convert( GetChRoot(), aSubGridProp, EXC_CHOBJTYPE_GRIDLINE ); } diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index 3e7f98a2608b..d28ac2fc2853 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -307,7 +307,7 @@ void XclImpFont::FillToItemSet( SfxItemSet& rItemSet, XclFontItemType eType, boo // sc_which = the Calc Which-ID of the item // ee_which = the edit engine Which-ID of the item #define PUTITEM( item, sc_which, ee_which ) \ - ScfTools::PutItem( rItemSet, item, (bEE ? ((sal_uInt16)ee_which) : (sc_which)), bSkipPoolDefs ) + ScfTools::PutItem( rItemSet, item, (bEE ? (static_cast<sal_uInt16>(ee_which)) : (sc_which)), bSkipPoolDefs ) // Font item if( mbFontNameUsed ) diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index 3d4864e5e863..8f660d017dd8 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -273,8 +273,8 @@ sal_uInt16 ScHTMLExport::ToPixel( sal_uInt16 nVal ) { if( nVal ) { - nVal = (sal_uInt16)pAppWin->LogicToPixel( - Size( nVal, nVal ), MapMode( MapUnit::MapTwip ) ).Width(); + nVal = static_cast<sal_uInt16>(pAppWin->LogicToPixel( + Size( nVal, nVal ), MapMode( MapUnit::MapTwip ) ).Width()); if( !nVal ) // If there's a Twip there should also be a Pixel nVal = 1; } @@ -371,7 +371,7 @@ void ScHTMLExport::WriteHeader() } } rStrm.WriteCharPtr( "; " ).WriteCharPtr( "font-size:" ) - .WriteCharPtr( GetFontSizeCss( ( sal_uInt16 ) aHTMLStyle.nFontHeight ) ).WriteCharPtr( " }" ); + .WriteCharPtr( GetFontSizeCss( static_cast<sal_uInt16>(aHTMLStyle.nFontHeight) ) ).WriteCharPtr( " }" ); OUT_LF(); @@ -999,7 +999,7 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab ) sal_uInt32 nFontHeight = rFontHeightItem.GetHeight(); if ( nFontHeight != aHTMLStyle.nFontHeight ) { - nSetFontSizeNumber = GetFontSizeNumber( (sal_uInt16) nFontHeight ); + nSetFontSizeNumber = GetFontSizeNumber( static_cast<sal_uInt16>(nFontHeight) ); if ( nSetFontSizeNumber == aHTMLStyle.nFontSizeNumber ) nSetFontSizeNumber = 0; // no difference, don't set } diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 273330749031..7c3b5d80723d 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -367,13 +367,13 @@ void ScHTMLLayoutParser::MakeCol( ScHTMLColOffset* pOffset, sal_uInt16& nOffset, OSL_ENSURE( pOffset, "ScHTMLLayoutParser::MakeCol - illegal call" ); SCCOL nPos; if ( SeekOffset( pOffset, nOffset, &nPos, nOffsetTol ) ) - nOffset = (sal_uInt16)(*pOffset)[nPos]; + nOffset = static_cast<sal_uInt16>((*pOffset)[nPos]); else pOffset->insert( nOffset ); if ( nWidth ) { if ( SeekOffset( pOffset, nOffset + nWidth, &nPos, nWidthTol ) ) - nWidth = (sal_uInt16)(*pOffset)[nPos] - nOffset; + nWidth = static_cast<sal_uInt16>((*pOffset)[nPos]) - nOffset; else pOffset->insert( nOffset + nWidth ); } @@ -385,7 +385,7 @@ void ScHTMLLayoutParser::MakeColNoRef( ScHTMLColOffset* pOffset, sal_uInt16 nOff OSL_ENSURE( pOffset, "ScHTMLLayoutParser::MakeColNoRef - illegal call" ); SCCOL nPos; if ( SeekOffset( pOffset, nOffset, &nPos, nOffsetTol ) ) - nOffset = (sal_uInt16)(*pOffset)[nPos]; + nOffset = static_cast<sal_uInt16>((*pOffset)[nPos]); else pOffset->insert( nOffset ); if ( nWidth ) @@ -403,16 +403,16 @@ void ScHTMLLayoutParser::ModifyOffset( ScHTMLColOffset* pOffset, sal_uInt16& nOl if ( !SeekOffset( pOffset, nOldOffset, &nPos, nOffsetTol ) ) { if ( SeekOffset( pOffset, nNewOffset, &nPos, nOffsetTol ) ) - nNewOffset = (sal_uInt16)(*pOffset)[nPos]; + nNewOffset = static_cast<sal_uInt16>((*pOffset)[nPos]); else pOffset->insert( nNewOffset ); return ; } - nOldOffset = (sal_uInt16)(*pOffset)[nPos]; + nOldOffset = static_cast<sal_uInt16>((*pOffset)[nPos]); SCCOL nPos2; if ( SeekOffset( pOffset, nNewOffset, &nPos2, nOffsetTol ) ) { - nNewOffset = (sal_uInt16)(*pOffset)[nPos2]; + nNewOffset = static_cast<sal_uInt16>((*pOffset)[nPos2]); return ; } long nDiff = nNewOffset - nOldOffset; @@ -428,7 +428,7 @@ void ScHTMLLayoutParser::ModifyOffset( ScHTMLColOffset* pOffset, sal_uInt16& nOl do { const_cast<sal_uLong&>((*pOffset)[nPos]) += nDiff; - } while ( ++nPos < (sal_uInt16)pOffset->size() ); + } while ( ++nPos < static_cast<sal_uInt16>(pOffset->size()) ); } } @@ -477,7 +477,7 @@ void ScHTMLLayoutParser::Adjust() SCCOL nLastCol = SCCOL_MAX; SCROW nNextRow = 0; SCROW nCurRow = 0; - sal_uInt16 nPageWidth = (sal_uInt16) aPageSize.Width(); + sal_uInt16 nPageWidth = static_cast<sal_uInt16>(aPageSize.Width()); InnerMap* pTab = nullptr; for (auto& pE : maList) { @@ -581,15 +581,15 @@ void ScHTMLLayoutParser::Adjust() SkipLocked(pE.get(), false); if ( pE->nCol != nColBeforeSkip ) { - SCCOL nCount = (SCCOL)maColOffset.size(); + SCCOL nCount = static_cast<SCCOL>(maColOffset.size()); if ( nCount <= pE->nCol ) { - pE->nOffset = (sal_uInt16) maColOffset[nCount-1]; + pE->nOffset = static_cast<sal_uInt16>(maColOffset[nCount-1]); MakeCol( &maColOffset, pE->nOffset, pE->nWidth, nOffsetTolerance, nOffsetTolerance ); } else { - pE->nOffset = (sal_uInt16) maColOffset[pE->nCol]; + pE->nOffset = static_cast<sal_uInt16>(maColOffset[pE->nCol]); } } SCCOL nPos; @@ -625,7 +625,7 @@ sal_uInt16 ScHTMLLayoutParser::GetWidth( const ScEEParseEntry* pE ) nColCntStart + pE->nColOverlap), static_cast<sal_Int32>( pLocalColOffset->size() - 1)); SCCOL nPos = (nTmp < 0 ? 0 : static_cast<SCCOL>(nTmp)); - sal_uInt16 nOff2 = (sal_uInt16) (*pLocalColOffset)[nPos]; + sal_uInt16 nOff2 = static_cast<sal_uInt16>((*pLocalColOffset)[nPos]); if ( pE->nOffset < nOff2 ) return nOff2 - pE->nOffset; return 0; @@ -635,7 +635,7 @@ void ScHTMLLayoutParser::SetWidths() { SCCOL nCol; if ( !nTableWidth ) - nTableWidth = (sal_uInt16) aPageSize.Width(); + nTableWidth = static_cast<sal_uInt16>(aPageSize.Width()); SCCOL nColsPerRow = nMaxCol - nColCntStart; if ( nColsPerRow <= 0 ) nColsPerRow = 1; @@ -648,13 +648,13 @@ void ScHTMLLayoutParser::SetWidths() { MakeColNoRef( pLocalColOffset, nOff, 0, 0, 0 ); } - nTableWidth = (sal_uInt16)(pLocalColOffset->back() - pLocalColOffset->front()); + nTableWidth = static_cast<sal_uInt16>(pLocalColOffset->back() - pLocalColOffset->front()); for ( size_t i = nFirstTableCell, nListSize = maList.size(); i < nListSize; ++i ) { auto& pE = maList[ i ]; if ( pE->nTab == nTable ) { - pE->nOffset = (sal_uInt16) (*pLocalColOffset)[pE->nCol - nColCntStart]; + pE->nOffset = static_cast<sal_uInt16>((*pLocalColOffset)[pE->nCol - nColCntStart]); pE->nWidth = 0; // to be recalculated later } } @@ -761,7 +761,7 @@ void ScHTMLLayoutParser::SetWidths() } if ( !pLocalColOffset->empty() ) { - sal_uInt16 nMax = (sal_uInt16) pLocalColOffset->back(); + sal_uInt16 nMax = static_cast<sal_uInt16>(pLocalColOffset->back()); if ( aPageSize.Width() < nMax ) aPageSize.Width() = nMax; } @@ -794,9 +794,9 @@ void ScHTMLLayoutParser::Colonize( ScEEParseEntry* pE ) nCol = pE->nCol - nColCntStart; SCCOL nCount = static_cast<SCCOL>(pLocalColOffset->size()); if ( nCol < nCount ) - nColOffset = (sal_uInt16) (*pLocalColOffset)[nCol]; + nColOffset = static_cast<sal_uInt16>((*pLocalColOffset)[nCol]); else - nColOffset = (sal_uInt16) (*pLocalColOffset)[nCount - 1]; + nColOffset = static_cast<sal_uInt16>((*pLocalColOffset)[nCount - 1]); } pE->nOffset = nColOffset; sal_uInt16 nWidth = GetWidth( pE ); @@ -818,7 +818,7 @@ void ScHTMLLayoutParser::CloseEntry( const HtmlImportInfo* pInfo ) return ; } if (mxActEntry->nTab == 0) - mxActEntry->nWidth = (sal_uInt16) aPageSize.Width(); + mxActEntry->nWidth = static_cast<sal_uInt16>(aPageSize.Width()); Colonize(mxActEntry.get()); nColCnt = mxActEntry->nCol + mxActEntry->nColOverlap; if ( nMaxCol < nColCnt ) @@ -933,12 +933,12 @@ void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* pInfo ) { case HtmlOptionId::COLSPAN: { - mxActEntry->nColOverlap = (SCCOL)rOption.GetString().toInt32(); + mxActEntry->nColOverlap = static_cast<SCCOL>(rOption.GetString().toInt32()); } break; case HtmlOptionId::ROWSPAN: { - mxActEntry->nRowOverlap = (SCROW)rOption.GetString().toInt32(); + mxActEntry->nRowOverlap = static_cast<SCROW>(rOption.GetString().toInt32()); } break; case HtmlOptionId::ALIGN: @@ -1319,22 +1319,22 @@ void ScHTMLLayoutParser::Image( HtmlImportInfo* pInfo ) break; case HtmlOptionId::WIDTH: { - pImage->aSize.Width() = (long)rOption.GetNumber(); + pImage->aSize.Width() = static_cast<long>(rOption.GetNumber()); } break; case HtmlOptionId::HEIGHT: { - pImage->aSize.Height() = (long)rOption.GetNumber(); + pImage->aSize.Height() = static_cast<long>(rOption.GetNumber()); } break; case HtmlOptionId::HSPACE: { - pImage->aSpace.X() = (long)rOption.GetNumber(); + pImage->aSpace.X() = static_cast<long>(rOption.GetNumber()); } break; case HtmlOptionId::VSPACE: { - pImage->aSpace.Y() = (long)rOption.GetNumber(); + pImage->aSpace.Y() = static_cast<long>(rOption.GetNumber()); } break; default: break; @@ -1404,8 +1404,8 @@ sal_uInt16 ScHTMLLayoutParser::GetWidthPixel( const HTMLOption& rOption ) const OUString& rOptVal = rOption.GetString(); if ( rOptVal.indexOf('%') != -1 ) { // Percent - sal_uInt16 nW = (nTableWidth ? nTableWidth : (sal_uInt16) aPageSize.Width()); - return (sal_uInt16)((rOption.GetNumber() * nW) / 100); + sal_uInt16 nW = (nTableWidth ? nTableWidth : static_cast<sal_uInt16>(aPageSize.Width())); + return static_cast<sal_uInt16>((rOption.GetNumber() * nW) / 100); } else { @@ -1415,7 +1415,7 @@ sal_uInt16 ScHTMLLayoutParser::GetWidthPixel( const HTMLOption& rOption ) return 0; } else - return (sal_uInt16)rOption.GetNumber(); // Pixel + return static_cast<sal_uInt16>(rOption.GetNumber()); // Pixel } } @@ -1469,7 +1469,7 @@ void ScHTMLLayoutParser::FontOn( HtmlImportInfo* pInfo ) break; case HtmlOptionId::SIZE : { - sal_uInt16 nSize = (sal_uInt16) rOption.GetNumber(); + sal_uInt16 nSize = static_cast<sal_uInt16>(rOption.GetNumber()); if ( nSize == 0 ) nSize = 1; else if ( nSize > SC_HTML_FONTSIZES ) diff --git a/sc/source/filter/inc/XclExpChangeTrack.hxx b/sc/source/filter/inc/XclExpChangeTrack.hxx index 45aa21f3e7dd..d32fb53615ec 100644 --- a/sc/source/filter/inc/XclExpChangeTrack.hxx +++ b/sc/source/filter/inc/XclExpChangeTrack.hxx @@ -411,16 +411,16 @@ public: inline void XclExpChTrAction::Write2DAddress( XclExpStream& rStrm, const ScAddress& rAddress ) { - rStrm << (sal_uInt16) rAddress.Row() - << (sal_uInt16) rAddress.Col(); + rStrm << static_cast<sal_uInt16>(rAddress.Row()) + << static_cast<sal_uInt16>(rAddress.Col()); } inline void XclExpChTrAction::Write2DRange( XclExpStream& rStrm, const ScRange& rRange ) { - rStrm << (sal_uInt16) rRange.aStart.Row() - << (sal_uInt16) rRange.aEnd.Row() - << (sal_uInt16) rRange.aStart.Col() - << (sal_uInt16) rRange.aEnd.Col(); + rStrm << static_cast<sal_uInt16>(rRange.aStart.Row()) + << static_cast<sal_uInt16>(rRange.aEnd.Row()) + << static_cast<sal_uInt16>(rRange.aStart.Col()) + << static_cast<sal_uInt16>(rRange.aEnd.Col()); } inline sal_uInt16 XclExpChTrAction::GetTabId( SCTAB nTab ) const diff --git a/sc/source/filter/inc/tokstack.hxx b/sc/source/filter/inc/tokstack.hxx index 9bff3bebaf59..31859199de3e 100644 --- a/sc/source/filter/inc/tokstack.hxx +++ b/sc/source/filter/inc/tokstack.hxx @@ -367,7 +367,7 @@ inline TokenPool& TokenPool::operator <<( const TokenId& rId ) inline TokenPool& TokenPool::operator <<( const DefTokenId eId ) { - if ((sal_uInt32)eId + nScTokenOff >= 0xFFFF) + if (static_cast<sal_uInt32>(eId) + nScTokenOff >= 0xFFFF) { SAL_WARN("sc.filter", "-TokenPool::operator<<: enum too large! " << static_cast<sal_uInt32>(eId)); } @@ -376,7 +376,7 @@ inline TokenPool& TokenPool::operator <<( const DefTokenId eId ) if (!GrowId()) return *this; - pP_Id[ nP_IdAkt ] = ( ( sal_uInt16 ) eId ) + nScTokenOff; + pP_Id[ nP_IdAkt ] = static_cast<sal_uInt16>(eId) + nScTokenOff; nP_IdAkt++; return *this; @@ -423,7 +423,7 @@ const inline ScTokenArray* TokenPool::operator []( const TokenId& rId ) #ifdef DBG_UTIL m_nRek = 0; #endif - GetElement( ( sal_uInt16 ) rId - 1 ); + GetElement( static_cast<sal_uInt16>(rId) - 1 ); } return pScToken; diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx index 75ea7786c9e6..7bb0f453602b 100644 --- a/sc/source/filter/lotus/lotform.cxx +++ b/sc/source/filter/lotus/lotform.cxx @@ -487,7 +487,7 @@ void LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest ) // missing range nNewId = aPool.Store( rR ); else - nNewId = aPool.Store( ( sal_uInt16 ) nId ); + nNewId = aPool.Store( static_cast<sal_uInt16>(nId) ); } aStack << nNewId; @@ -514,7 +514,7 @@ void LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest ) // missing range nNewId = aPool.Store( aCRD ); else - nNewId = aPool.Store( ( sal_uInt16 ) nId ); + nNewId = aPool.Store( static_cast<sal_uInt16>(nId) ); } aStack << nNewId; @@ -528,7 +528,7 @@ void LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest ) { sal_Int16 nVal; Read( nVal ); - aStack << aPool.Store( ( double ) nVal ); + aStack << aPool.Store( static_cast<double>(nVal) ); } break; case FT_ConstString: diff --git a/sc/source/filter/lotus/lotimpop.cxx b/sc/source/filter/lotus/lotimpop.cxx index 00ccefab0ee3..4ee58da7d29c 100644 --- a/sc/source/filter/lotus/lotimpop.cxx +++ b/sc/source/filter/lotus/lotimpop.cxx @@ -143,7 +143,7 @@ void ImportLotus::Columnwidth( sal_uInt16 nRecLen ) Read( nCol ); Read( nSpaces ); // Attention: ambiguous Correction factor! - pD->SetColWidth( static_cast<SCCOL> (nCol), static_cast<SCTAB> (nLTab), ( sal_uInt16 ) ( TWIPS_PER_CHAR * 1.28 * nSpaces ) ); + pD->SetColWidth( static_cast<SCCOL> (nCol), static_cast<SCTAB> (nLTab), static_cast<sal_uInt16>( TWIPS_PER_CHAR * 1.28 * nSpaces ) ); nCnt--; } diff --git a/sc/source/filter/lotus/lotread.cxx b/sc/source/filter/lotus/lotread.cxx index b21cbbb66bca..e218b5536aa3 100644 --- a/sc/source/filter/lotus/lotread.cxx +++ b/sc/source/filter/lotus/lotread.cxx @@ -287,7 +287,7 @@ ErrCode ImportLotus::Read(SvStream& rIn) case 195: if( nExtTab >= 0 ) - rContext.pLotusRoot->maAttrTable.Apply(rContext.pLotusRoot, (SCTAB)nExtTab); + rContext.pLotusRoot->maAttrTable.Apply(rContext.pLotusRoot, static_cast<SCTAB>(nExtTab)); nExtTab++; break; case 197: @@ -302,7 +302,7 @@ ErrCode ImportLotus::Read(SvStream& rIn) } } - rContext.pLotusRoot->maAttrTable.Apply(rContext.pLotusRoot, (SCTAB)nExtTab); + rContext.pLotusRoot->maAttrTable.Apply(rContext.pLotusRoot, static_cast<SCTAB>(nExtTab)); return eRet; } diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx index 295cd2804da0..ffd47264a316 100644 --- a/sc/source/filter/lotus/op.cxx +++ b/sc/source/filter/lotus/op.cxx @@ -51,7 +51,7 @@ #include <map> #include <memory> -static sal_uInt16 nDefWidth = ( sal_uInt16 ) ( TWIPS_PER_CHAR * 10 ); +static sal_uInt16 nDefWidth = sal_uInt16( TWIPS_PER_CHAR * 10 ); void NI(LotusContext& /*rContext*/, SvStream& r, sal_uInt16 n) { @@ -180,7 +180,7 @@ void OP_ColumnWidth(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/) sal_uInt16 nBreite; if( nWidthSpaces ) // assuming 10cpi character set - nBreite = ( sal_uInt16 ) ( TWIPS_PER_CHAR * nWidthSpaces ); + nBreite = static_cast<sal_uInt16>( TWIPS_PER_CHAR * nWidthSpaces ); else { rContext.pDoc->SetColHidden(nCol, nCol, 0, true); @@ -319,7 +319,7 @@ void OP_Window1(LotusContext& rContext, SvStream& r, sal_uInt16 n) r.SeekRel( n - 8 ); // skip the rest - nDefWidth = ( sal_uInt16 ) ( TWIPS_PER_CHAR * nDefWidth ); + nDefWidth = static_cast<sal_uInt16>( TWIPS_PER_CHAR * nDefWidth ); // instead of default, set all Cols in SC by hand for( SCCOL nCol = 0 ; nCol <= MAXCOL ; nCol++ ) diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx index 6a7945e39b34..d6ef48719790 100644 --- a/sc/source/filter/lotus/tool.cxx +++ b/sc/source/filter/lotus/tool.cxx @@ -120,10 +120,10 @@ double SnumToDouble( sal_Int16 nVal ) if( nVal & 0x0001 ) { fVal = pFacts[ ( nVal >> 1 ) & 0x0007 ]; - fVal *= ( sal_Int16 ) ( nVal >> 4 ); + fVal *= static_cast<sal_Int16>( nVal >> 4 ); } else - fVal = ( sal_Int16 ) ( nVal >> 1 ); + fVal = static_cast<sal_Int16>( nVal >> 1 ); return fVal; } @@ -137,9 +137,9 @@ double Snum32ToDouble( sal_uInt32 nValue ) if (temp) { if (nValue & 0x00000010) - fValue /= pow((double)10, temp); + fValue /= pow(double(10), temp); else - fValue *= pow((double)10, temp); + fValue *= pow(double(10), temp); } if (nValue & 0x00000020) diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index c750b45e97c1..053bb6a5b8ed 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -369,7 +369,7 @@ FormulaBuffer::SheetItem FormulaBuffer::getSheetItem( SCTAB nTab ) SheetItem aItem; - if( (size_t) nTab >= maCellFormulas.size() ) + if( static_cast<size_t>(nTab) >= maCellFormulas.size() ) { SAL_WARN( "sc", "Tab " << nTab << " out of bounds " << maCellFormulas.size() ); return aItem; @@ -393,7 +393,7 @@ void FormulaBuffer::createSharedFormulaMapEntry( const ScAddress& rAddress, sal_Int32 nSharedId, const OUString& rTokens ) { - assert( rAddress.Tab() >= 0 && (size_t)rAddress.Tab() < maSharedFormulas.size() ); + assert( rAddress.Tab() >= 0 && static_cast<size_t>(rAddress.Tab()) < maSharedFormulas.size() ); std::vector<SharedFormulaEntry>& rSharedFormulas = maSharedFormulas[ rAddress.Tab() ]; SharedFormulaEntry aEntry(rAddress, rTokens, nSharedId); rSharedFormulas.push_back( aEntry ); @@ -401,14 +401,14 @@ void FormulaBuffer::createSharedFormulaMapEntry( void FormulaBuffer::setCellFormula( const ScAddress& rAddress, const OUString& rTokenStr ) { - assert( rAddress.Tab() >= 0 && (size_t)rAddress.Tab() < maCellFormulas.size() ); + assert( rAddress.Tab() >= 0 && static_cast<size_t>(rAddress.Tab()) < maCellFormulas.size() ); maCellFormulas[ rAddress.Tab() ].emplace_back( rTokenStr, rAddress ); } void FormulaBuffer::setCellFormula( const ScAddress& rAddress, sal_Int32 nSharedId, const OUString& rCellValue, sal_Int32 nValueType ) { - assert( rAddress.Tab() >= 0 && (size_t)rAddress.Tab() < maSharedFormulaIds.size() ); + assert( rAddress.Tab() >= 0 && static_cast<size_t>(rAddress.Tab()) < maSharedFormulaIds.size() ); maSharedFormulaIds[rAddress.Tab()].emplace_back(rAddress, nSharedId, rCellValue, nValueType); } @@ -416,14 +416,14 @@ void FormulaBuffer::setCellArrayFormula( const ScRange& rRangeAddress, const ScA { TokenAddressItem tokenPair( rTokenStr, rTokenAddress ); - assert( rRangeAddress.aStart.Tab() >= 0 && (size_t)rRangeAddress.aStart.Tab() < maCellArrayFormulas.size() ); + assert( rRangeAddress.aStart.Tab() >= 0 && static_cast<size_t>(rRangeAddress.aStart.Tab()) < maCellArrayFormulas.size() ); maCellArrayFormulas[ rRangeAddress.aStart.Tab() ].emplace_back( tokenPair, rRangeAddress ); } void FormulaBuffer::setCellFormulaValue( const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType ) { - assert( rAddress.Tab() >= 0 && (size_t)rAddress.Tab() < maCellFormulaValues.size() ); + assert( rAddress.Tab() >= 0 && static_cast<size_t>(rAddress.Tab()) < maCellFormulaValues.size() ); FormulaValue aVal; aVal.maAddress = rAddress; aVal.maValueStr = rValueStr; diff --git a/sc/source/filter/oox/scenariobuffer.cxx b/sc/source/filter/oox/scenariobuffer.cxx index a57c9294b165..33dd467472df 100644 --- a/sc/source/filter/oox/scenariobuffer.cxx +++ b/sc/source/filter/oox/scenariobuffer.cxx @@ -179,7 +179,7 @@ void SheetScenarios::importScenarios( SequenceInputStream& rStrm ) Scenario& SheetScenarios::createScenario() { - bool bIsActive = maScenarios.size() == (sal_uInt32) maModel.mnShown; + bool bIsActive = maScenarios.size() == static_cast<sal_uInt32>(maModel.mnShown); ScenarioVector::value_type xScenario( new Scenario( *this, mnSheet, bIsActive ) ); maScenarios.push_back( xScenario ); return *xScenario; diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx index 15f1093b03a6..dc5621c08ca5 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -867,7 +867,7 @@ void Font::fillToItemSet( SfxItemSet& rItemSet, bool bEditEngineText, bool bSkip SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maLatinFont.mnFamily ), maApiData.maLatinFont.maName, OUString(), PITCH_DONTKNOW, eTempTextEnc, ATTR_FONT ); - ScfTools::PutItem( rItemSet, aFontItem, bEditEngineText ? (sal_uInt16)EE_CHAR_FONTINFO : ATTR_FONT, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aFontItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_FONTINFO) : ATTR_FONT, bSkipPoolDefs ); } if( !maApiData.maAsianFont.maName.isEmpty() ) { @@ -877,7 +877,7 @@ void Font::fillToItemSet( SfxItemSet& rItemSet, bool bEditEngineText, bool bSkip ScfTools::GetSystemTextEncoding() : eFontEnc; SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maAsianFont.mnFamily ), maApiData.maAsianFont.maName, OUString(), PITCH_DONTKNOW, eTempTextEnc, ATTR_FONT ); - ScfTools::PutItem( rItemSet, aFontItem, bEditEngineText ? (sal_uInt16)EE_CHAR_FONTINFO_CJK : ATTR_CJK_FONT, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aFontItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_FONTINFO_CJK) : ATTR_CJK_FONT, bSkipPoolDefs ); } if( !maApiData.maCmplxFont.maName.isEmpty() ) { @@ -887,7 +887,7 @@ void Font::fillToItemSet( SfxItemSet& rItemSet, bool bEditEngineText, bool bSkip ScfTools::GetSystemTextEncoding() : eFontEnc; SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maCmplxFont.mnFamily ), maApiData.maCmplxFont.maName, OUString(), PITCH_DONTKNOW, eTempTextEnc, ATTR_FONT ); - ScfTools::PutItem( rItemSet, aFontItem, bEditEngineText ? (sal_uInt16)EE_CHAR_FONTINFO_CTL : ATTR_CTL_FONT, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aFontItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_FONTINFO_CTL) : ATTR_CTL_FONT, bSkipPoolDefs ); } } // font height @@ -898,31 +898,31 @@ void Font::fillToItemSet( SfxItemSet& rItemSet, bool bEditEngineText, bool bSkip if( bEditEngineText/* && (eType != XclFontItemType::HeaderFooter) */) // do not convert header/footer height nHeight = (nHeight * 127 + 36) / EXC_POINTS_PER_INCH; // 1 in == 72 pt SvxFontHeightItem aHeightItem( nHeight, 100, ATTR_FONT_HEIGHT ); - ScfTools::PutItem( rItemSet, aHeightItem, bEditEngineText ? (sal_uInt16)EE_CHAR_FONTHEIGHT : ATTR_FONT_HEIGHT, bSkipPoolDefs ); - ScfTools::PutItem( rItemSet, aHeightItem, bEditEngineText ? (sal_uInt16)EE_CHAR_FONTHEIGHT_CJK : ATTR_CJK_FONT_HEIGHT, bSkipPoolDefs ); - ScfTools::PutItem( rItemSet, aHeightItem, bEditEngineText ? (sal_uInt16)EE_CHAR_FONTHEIGHT_CTL : ATTR_CTL_FONT_HEIGHT, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aHeightItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_FONTHEIGHT) : ATTR_FONT_HEIGHT, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aHeightItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_FONTHEIGHT_CJK) : ATTR_CJK_FONT_HEIGHT, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aHeightItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_FONTHEIGHT_CTL) : ATTR_CTL_FONT_HEIGHT, bSkipPoolDefs ); } // font weight if( maUsedFlags.mbWeightUsed ) { ::FontWeight fWeight = vcl::unohelper::ConvertFontWeight( maApiData.maDesc.Weight ); SvxWeightItem aWeightItem( fWeight, ATTR_FONT_WEIGHT ); - ScfTools::PutItem( rItemSet, aWeightItem, bEditEngineText ? (sal_uInt16)EE_CHAR_WEIGHT : ATTR_FONT_WEIGHT, bSkipPoolDefs ); - ScfTools::PutItem( rItemSet, aWeightItem, bEditEngineText ? (sal_uInt16)EE_CHAR_WEIGHT_CTL : ATTR_CTL_FONT_WEIGHT, bSkipPoolDefs ); - ScfTools::PutItem( rItemSet, aWeightItem, bEditEngineText ? (sal_uInt16)EE_CHAR_WEIGHT_CJK : ATTR_CJK_FONT_WEIGHT, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aWeightItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_WEIGHT) : ATTR_FONT_WEIGHT, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aWeightItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_WEIGHT_CTL) : ATTR_CTL_FONT_WEIGHT, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aWeightItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_WEIGHT_CJK) : ATTR_CJK_FONT_WEIGHT, bSkipPoolDefs ); } // font posture if( maUsedFlags.mbPostureUsed ) { SvxPostureItem aPostItem( ( maApiData.maDesc.Slant == css::awt::FontSlant_ITALIC ) ? ITALIC_NORMAL : ITALIC_NONE, ATTR_FONT_POSTURE); - ScfTools::PutItem( rItemSet, aPostItem, bEditEngineText ? (sal_uInt16)EE_CHAR_ITALIC : ATTR_FONT_POSTURE, bSkipPoolDefs ); - ScfTools::PutItem( rItemSet, aPostItem, bEditEngineText ? (sal_uInt16)EE_CHAR_ITALIC_CJK : ATTR_CJK_FONT_POSTURE, bSkipPoolDefs ); - ScfTools::PutItem( rItemSet, aPostItem, bEditEngineText ? (sal_uInt16)EE_CHAR_ITALIC_CTL : ATTR_CTL_FONT_POSTURE, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aPostItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_ITALIC) : ATTR_FONT_POSTURE, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aPostItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_ITALIC_CJK) : ATTR_CJK_FONT_POSTURE, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aPostItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_ITALIC_CTL) : ATTR_CTL_FONT_POSTURE, bSkipPoolDefs ); } // character color if( maUsedFlags.mbColorUsed ) { - ScfTools::PutItem( rItemSet,SvxColorItem( maApiData.mnColor, bEditEngineText ? (sal_uInt16)EE_CHAR_COLOR : ATTR_FONT_COLOR ) , bSkipPoolDefs ); + ScfTools::PutItem( rItemSet,SvxColorItem( maApiData.mnColor, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_COLOR) : ATTR_FONT_COLOR ) , bSkipPoolDefs ); } // underline style if( maUsedFlags.mbUnderlineUsed ) @@ -935,24 +935,24 @@ void Font::fillToItemSet( SfxItemSet& rItemSet, bool bEditEngineText, bool bSkip else eScUnderl = LINESTYLE_NONE; SvxUnderlineItem aUnderlItem( eScUnderl, ATTR_FONT_UNDERLINE ); - ScfTools::PutItem( rItemSet, aUnderlItem, bEditEngineText ? (sal_uInt16)EE_CHAR_UNDERLINE : ATTR_FONT_UNDERLINE, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, aUnderlItem, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_UNDERLINE) : ATTR_FONT_UNDERLINE, bSkipPoolDefs ); } // strike out style if( maUsedFlags.mbStrikeoutUsed ) { - ScfTools::PutItem( rItemSet, SvxCrossedOutItem( maModel.mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, bEditEngineText ? (sal_uInt16)EE_CHAR_STRIKEOUT : ATTR_FONT_CROSSEDOUT ), bEditEngineText ? (sal_uInt16)EE_CHAR_STRIKEOUT : ATTR_FONT_CROSSEDOUT, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, SvxCrossedOutItem( maModel.mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_STRIKEOUT) : ATTR_FONT_CROSSEDOUT ), bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_STRIKEOUT) : ATTR_FONT_CROSSEDOUT, bSkipPoolDefs ); } // outline style if( maUsedFlags.mbOutlineUsed ) { - ScfTools::PutItem( rItemSet, SvxContourItem( maApiData.mbOutline, ATTR_FONT_CONTOUR ), bEditEngineText ? (sal_uInt16)EE_CHAR_OUTLINE : ATTR_FONT_CONTOUR, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, SvxContourItem( maApiData.mbOutline, ATTR_FONT_CONTOUR ), bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_OUTLINE) : ATTR_FONT_CONTOUR, bSkipPoolDefs ); } // shadow style if( maUsedFlags.mbShadowUsed ) { - ScfTools::PutItem( rItemSet, SvxShadowedItem( maApiData.mbShadow, ATTR_FONT_SHADOWED ), bEditEngineText ? (sal_uInt16)EE_CHAR_SHADOW : ATTR_FONT_SHADOWED, bSkipPoolDefs ); + ScfTools::PutItem( rItemSet, SvxShadowedItem( maApiData.mbShadow, ATTR_FONT_SHADOWED ), bEditEngineText ? static_cast<sal_uInt16>(EE_CHAR_SHADOW) : ATTR_FONT_SHADOWED, bSkipPoolDefs ); } if( maUsedFlags.mbEscapementUsed ) { diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 8b61352f5c82..0f0c5370ef12 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -1164,7 +1164,7 @@ void WorksheetGlobals::convertColumns( OutlineLevelVec& orColLevels, { for( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol ) { - rDoc.SetColWidthOnly( nCol, nTab, (sal_uInt16)sc::HMMToTwips( nWidth ) ); + rDoc.SetColWidthOnly( nCol, nTab, static_cast<sal_uInt16>(sc::HMMToTwips( nWidth )) ); } } @@ -1217,7 +1217,7 @@ void WorksheetGlobals::convertRows( OutlineLevelVec& orRowLevels, { /* always import the row height, ensures better layout */ ScDocument& rDoc = getScDocument(); - rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, (sal_uInt16)sc::HMMToTwips(nHeight) ); + rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, static_cast<sal_uInt16>(sc::HMMToTwips(nHeight)) ); if(rModel.mbCustomHeight) rDoc.SetManualHeight( nStartRow, nEndRow, nTab, true ); } diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx index 73da364969c9..6a2a22c1be95 100644 --- a/sc/source/filter/qpro/qproform.cxx +++ b/sc/source/filter/qpro/qproform.cxx @@ -43,7 +43,7 @@ void QProToSc::ReadSRD( ScSingleRefData& rSRD, sal_Int8 nPage, sal_Int8 nCol, sa if( nRelBit & 0x2000 ) { - SCROW nRelRow = (sal_Int16)(nTmp << 3); // This looks weird... Mistake? + SCROW nRelRow = static_cast<sal_Int16>(nTmp << 3); // This looks weird... Mistake? nRelRow /= 8; rSRD.SetRelRow(nRelRow); } @@ -347,7 +347,7 @@ ConvErr QProToSc::Convert( const ScTokenArray*& pArray ) case FT_ConstInt:{ sal_uInt16 nVal; nVal = nIntArray[ nIntCount ]; - aStack << aPool.Store( ( double ) nVal ); + aStack << aPool.Store( static_cast<double>(nVal) ); nIntCount++; } break; diff --git a/sc/source/filter/qpro/qprostyle.cxx b/sc/source/filter/qpro/qprostyle.cxx index ce936da7b9fc..f77aa9f38ef3 100644 --- a/sc/source/filter/qpro/qprostyle.cxx +++ b/sc/source/filter/qpro/qprostyle.cxx @@ -145,7 +145,7 @@ void ScQProStyle::SetFormat( ScDocument *pDoc, sal_uInt8 nCol, sal_uInt16 nRow, rItemSet.Put( SvxUnderlineItem( LINESTYLE_SINGLE, ATTR_FONT_UNDERLINE ) ); if (maFontHeight[ maFont [ nStyle ] ]) - rItemSet.Put( SvxFontHeightItem( (sal_uLong) (20 * maFontHeight[ maFont[ nStyle ] ] ), 100, ATTR_FONT_HEIGHT ) ); + rItemSet.Put( SvxFontHeightItem( static_cast<sal_uLong>(20 * maFontHeight[ maFont[ nStyle ] ] ), 100, ATTR_FONT_HEIGHT ) ); OUString fntName = maFontType[ maFont[ nStyle ] ]; rItemSet.Put( SvxFontItem( FAMILY_SYSTEM, fntName, EMPTY_OUSTRING, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ) ); diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index 8a0bd018edb4..b5175a5f669f 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -453,8 +453,8 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu // Adjust line height, base is 100% zoom Fraction aZoom( 1, 1 ); // Factor is printer to display ratio - double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom / nOutputFactor; - double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom; + double nPPTX = ScGlobal::nScreenPPTX * static_cast<double>(aZoom) / nOutputFactor; + double nPPTY = ScGlobal::nScreenPPTY * static_cast<double>(aZoom); ScopedVclPtrInstance< VirtualDevice > pVirtDev; sc::RowHeightContext aCxt(nPPTX, nPPTY, aZoom, aZoom, pVirtDev); aCxt.setExtraHeight(ScGlobal::nLastRowHeightExtra); @@ -566,8 +566,8 @@ void ScEEImport::InsertGraphic( SCCOL nCol, SCROW nRow, SCTAB nTab, OutputDevice* pDefaultDev = Application::GetDefaultDevice(); Point aCellInsertPos( - (long)((double) mpDoc->GetColOffset( nCol, nTab ) * HMM_PER_TWIPS), - (long)((double) mpDoc->GetRowOffset( nRow, nTab ) * HMM_PER_TWIPS) ); + static_cast<long>(static_cast<double>(mpDoc->GetColOffset( nCol, nTab )) * HMM_PER_TWIPS), + static_cast<long>(static_cast<double>(mpDoc->GetRowOffset( nRow, nTab )) * HMM_PER_TWIPS) ); Point aInsertPos( aCellInsertPos ); Point aSpace; diff --git a/sc/source/filter/rtf/rtfparse.cxx b/sc/source/filter/rtf/rtfparse.cxx index 57bf009e89e4..e324ca18fe14 100644 --- a/sc/source/filter/rtf/rtfparse.cxx +++ b/sc/source/filter/rtf/rtfparse.cxx @@ -39,7 +39,7 @@ ScRTFParser::ScRTFParser( EditEngine* pEditP ) : mnCurPos(0), pActDefault( nullptr ), pDefMerge( nullptr ), - nStartAdjust( (sal_uLong)~0 ), + nStartAdjust( sal_uLong(~0) ), nLastWidth(0), bNewDef( false ) { @@ -126,7 +126,7 @@ bool ScRTFParser::SeekTwips( sal_uInt16 nTwips, SCCOL* pCol ) void ScRTFParser::ColAdjust() { - if ( nStartAdjust != (sal_uLong)~0 ) + if ( nStartAdjust != sal_uLong(~0) ) { SCCOL nCol = 0; for (size_t i = nStartAdjust, nListSize = maList.size(); i < nListSize; ++i) @@ -147,7 +147,7 @@ void ScRTFParser::ColAdjust() if ( nCol > nColMax ) nColMax = nCol; } - nStartAdjust = (sal_uLong)~0; + nStartAdjust = sal_uLong(~0); aColTwips.clear(); } } @@ -340,7 +340,7 @@ void ScRTFParser::ProcToken( RtfImportInfo* pInfo ) mxActEntry->aItemSet.Set(pActDefault->aItemSet); EntryEnd(mxActEntry.get(), pInfo->aSelection); - if ( nStartAdjust == (sal_uLong)~0 ) + if ( nStartAdjust == sal_uLong(~0) ) nStartAdjust = maList.size(); maList.push_back(mxActEntry); NewActEntry(mxActEntry.get()); // New free-flying mxActEntry diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx index 9559c30f7413..13da7b636f54 100644 --- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx @@ -61,12 +61,12 @@ static OString lcl_DateTimeToOString( const DateTime& rDateTime ) static void lcl_WriteDateTime( XclExpStream& rStrm, const DateTime& rDateTime ) { rStrm.SetSliceSize( 7 ); - rStrm << (sal_uInt16) rDateTime.GetYear() - << (sal_uInt8) rDateTime.GetMonth() - << (sal_uInt8) rDateTime.GetDay() - << (sal_uInt8) rDateTime.GetHour() - << (sal_uInt8) rDateTime.GetMin() - << (sal_uInt8) rDateTime.GetSec(); + rStrm << static_cast<sal_uInt16>(rDateTime.GetYear()) + << static_cast<sal_uInt8>(rDateTime.GetMonth()) + << static_cast<sal_uInt8>(rDateTime.GetDay()) + << static_cast<sal_uInt8>(rDateTime.GetHour()) + << static_cast<sal_uInt8>(rDateTime.GetMin()) + << static_cast<sal_uInt8>(rDateTime.GetSec()); rStrm.SetSliceSize( 0 ); } @@ -104,17 +104,17 @@ XclExpUserBView::XclExpUserBView( const OUString& rUsername, const sal_uInt8* pG void XclExpUserBView::SaveCont( XclExpStream& rStrm ) { - rStrm << (sal_uInt32) 0xFF078014 - << (sal_uInt32) 0x00000001; + rStrm << sal_uInt32(0xFF078014) + << sal_uInt32(0x00000001); lcl_WriteGUID( rStrm, aGUID ); rStrm.WriteZeroBytes( 8 ); - rStrm << (sal_uInt32) 1200 - << (sal_uInt32) 1000 - << (sal_uInt16) 1000 - << (sal_uInt16) 0x0CF7 - << (sal_uInt16) 0x0000 - << (sal_uInt16) 0x0001 - << (sal_uInt16) 0x0000; + rStrm << sal_uInt32(1200) + << sal_uInt32(1000) + << sal_uInt16(1000) + << sal_uInt16(0x0CF7) + << sal_uInt16(0x0000) + << sal_uInt16(0x0001) + << sal_uInt16(0x0000); if( sUsername.Len() > 0 ) rStrm << sUsername; } @@ -163,18 +163,18 @@ void XclExpUsersViewBegin::SaveCont( XclExpStream& rStrm ) { lcl_WriteGUID( rStrm, aGUID ); rStrm << nCurrTab - << (sal_uInt32) 100 - << (sal_uInt32) 64 - << (sal_uInt32) 3 - << (sal_uInt32) 0x0000003C - << (sal_uInt16) 0 - << (sal_uInt16) 3 - << (sal_uInt16) 0 - << (sal_uInt16) 3 - << (double) 0 - << (double) 0 - << (sal_Int16) -1 - << (sal_Int16) -1; + << sal_uInt32(100) + << sal_uInt32(64) + << sal_uInt32(3) + << sal_uInt32(0x0000003C) + << sal_uInt16(0) + << sal_uInt16(3) + << sal_uInt16(0) + << sal_uInt16(3) + << double(0) + << double(0) + << sal_Int16(-1) + << sal_Int16(-1); } sal_uInt16 XclExpUsersViewBegin::GetNum() const @@ -189,7 +189,7 @@ std::size_t XclExpUsersViewBegin::GetLen() const void XclExpUsersViewEnd::SaveCont( XclExpStream& rStrm ) { - rStrm << (sal_uInt16) 0x0001; + rStrm << sal_uInt16(0x0001); } sal_uInt16 XclExpUsersViewEnd::GetNum() const @@ -204,7 +204,7 @@ std::size_t XclExpUsersViewEnd::GetLen() const void XclExpChTr0x0191::SaveCont( XclExpStream& rStrm ) { - rStrm << (sal_uInt16) 0x0000; + rStrm << sal_uInt16(0x0000); } sal_uInt16 XclExpChTr0x0191::GetNum() const @@ -219,8 +219,8 @@ std::size_t XclExpChTr0x0191::GetLen() const void XclExpChTr0x0198::SaveCont( XclExpStream& rStrm ) { - rStrm << (sal_uInt16) 0x0006 - << (sal_uInt16) 0x0000; + rStrm << sal_uInt16(0x0006) + << sal_uInt16(0x0000); } sal_uInt16 XclExpChTr0x0198::GetNum() const @@ -251,7 +251,7 @@ std::size_t XclExpChTr0x0192::GetLen() const void XclExpChTr0x0197::SaveCont( XclExpStream& rStrm ) { - rStrm << (sal_uInt16) 0x0000; + rStrm << sal_uInt16(0x0000); } sal_uInt16 XclExpChTr0x0197::GetNum() const @@ -303,9 +303,9 @@ XclExpChTr0x0194::~XclExpChTr0x0194() void XclExpChTr0x0194::SaveCont( XclExpStream& rStrm ) { - rStrm << (sal_uInt32) 0; + rStrm << sal_uInt32(0); lcl_WriteDateTime( rStrm, aDateTime ); - rStrm << (sal_uInt8) 0; + rStrm << sal_uInt8(0); lcl_WriteFixedString( rStrm, sUsername, 147 ); } @@ -325,15 +325,15 @@ XclExpChTrHeader::~XclExpChTrHeader() void XclExpChTrHeader::SaveCont( XclExpStream& rStrm ) { - rStrm << (sal_uInt16) 0x0006 - << (sal_uInt16) 0x0000 - << (sal_uInt16) 0x000D; + rStrm << sal_uInt16(0x0006) + << sal_uInt16(0x0000) + << sal_uInt16(0x000D); lcl_WriteGUID( rStrm, aGUID ); lcl_WriteGUID( rStrm, aGUID ); rStrm << nCount - << (sal_uInt16) 0x0001 - << (sal_uInt32) 0x00000000 - << (sal_uInt16) 0x001E; + << sal_uInt16(0x0001) + << sal_uInt32(0x00000000) + << sal_uInt16(0x001E); } sal_uInt16 XclExpChTrHeader::GetNum() const @@ -515,16 +515,16 @@ XclExpChTrInfo::~XclExpChTrInfo() void XclExpChTrInfo::SaveCont( XclExpStream& rStrm ) { - rStrm << (sal_uInt32) 0xFFFFFFFF - << (sal_uInt32) 0x00000000 - << (sal_uInt32) 0x00000020 - << (sal_uInt16) 0xFFFF; + rStrm << sal_uInt32(0xFFFFFFFF) + << sal_uInt32(0x00000000) + << sal_uInt32(0x00000020) + << sal_uInt16(0xFFFF); lcl_WriteGUID( rStrm, aGUID ); - rStrm << (sal_uInt16) 0x04B0; + rStrm << sal_uInt16(0x04B0); lcl_WriteFixedString( rStrm, sUsername, 113 ); lcl_WriteDateTime( rStrm, aDateTime ); - rStrm << (sal_uInt8) 0x0000 - << (sal_uInt16) 0x0002; + rStrm << sal_uInt8(0x0000) + << sal_uInt16(0x0002); } sal_uInt16 XclExpChTrInfo::GetNum() const @@ -721,7 +721,7 @@ void XclExpChTrAction::SaveCont( XclExpStream& rStrm ) rStrm << nLength << nIndex << nOpCode - << (sal_uInt16)(bAccepted ? EXC_CHTR_ACCEPT : EXC_CHTR_NOTHING); + << static_cast<sal_uInt16>(bAccepted ? EXC_CHTR_ACCEPT : EXC_CHTR_NOTHING); SaveActionData( rStrm ); } @@ -783,22 +783,22 @@ void XclExpChTrData::WriteFormula( XclExpStream& rStrm, const XclExpChTrTabIdBuf { if( aIt->mpUrl && aIt->mpFirstTab ) { - rStrm << *aIt->mpUrl << (sal_uInt8) 0x01 << *aIt->mpFirstTab << (sal_uInt8) 0x02; + rStrm << *aIt->mpUrl << sal_uInt8(0x01) << *aIt->mpFirstTab << sal_uInt8(0x02); } else { bool bSingleTab = aIt->mnFirstXclTab == aIt->mnLastXclTab; rStrm.SetSliceSize( bSingleTab ? 6 : 8 ); - rStrm << (sal_uInt8) 0x01 << (sal_uInt8) 0x02 << (sal_uInt8) 0x00; + rStrm << sal_uInt8(0x01) << sal_uInt8(0x02) << sal_uInt8(0x00); rStrm << rTabIdBuffer.GetId( aIt->mnFirstXclTab ); if( bSingleTab ) - rStrm << (sal_uInt8) 0x02; + rStrm << sal_uInt8(0x02); else - rStrm << (sal_uInt8) 0x00 << rTabIdBuffer.GetId( aIt->mnLastXclTab ); + rStrm << sal_uInt8(0x00) << rTabIdBuffer.GetId( aIt->mnLastXclTab ); } } rStrm.SetSliceSize( 0 ); - rStrm << (sal_uInt8) 0x00; + rStrm << sal_uInt8(0x00); } void XclExpChTrData::Write( XclExpStream& rStrm, const XclExpChTrTabIdBuffer& rTabIdBuffer ) @@ -916,7 +916,7 @@ void XclExpChTrCellContent::GetCellData( rpData->nType = EXC_CHTR_TYPE_STRING; rpData->nSize = 3 + rpData->pString->GetSize(); rXclLength1 = 64 + (sCellStr.getLength() << 1); - rXclLength2 = 6 + (sal_uInt16)(sCellStr.getLength() << 1); + rXclLength2 = 6 + static_cast<sal_uInt16>(sCellStr.getLength() << 1); } break; case CELLTYPE_FORMULA: @@ -953,11 +953,11 @@ void XclExpChTrCellContent::GetCellData( void XclExpChTrCellContent::SaveActionData( XclExpStream& rStrm ) const { WriteTabId( rStrm, aPosition.Tab() ); - rStrm << (sal_uInt16)((pOldData ? (pOldData->nType << 3) : 0x0000) | (pNewData ? pNewData->nType : 0x0000)) - << (sal_uInt16) 0x0000; + rStrm << static_cast<sal_uInt16>((pOldData ? (pOldData->nType << 3) : 0x0000) | (pNewData ? pNewData->nType : 0x0000)) + << sal_uInt16(0x0000); Write2DAddress( rStrm, aPosition ); rStrm << nOldLength - << (sal_uInt32) 0x00000000; + << sal_uInt32(0x00000000); if( pOldData ) pOldData->Write( rStrm, rIdBuffer ); if( pNewData ) @@ -1145,7 +1145,7 @@ void XclExpChTrInsert::SaveActionData( XclExpStream& rStrm ) const sal_uInt16 nFlagVal = mbEndOfList ? 0x0001 : 0x0000; rStrm << nFlagVal; Write2DRange( rStrm, aRange ); - rStrm << (sal_uInt32) 0x00000000; + rStrm << sal_uInt32(0x00000000); } void XclExpChTrInsert::PrepareSaveAction( XclExpStream& rStrm ) const @@ -1212,7 +1212,7 @@ XclExpChTrInsertTab::XclExpChTrInsertTab( const XclExpChTrTabIdBuffer& rTabIdBuffer ) : XclExpChTrAction( rAction, rRoot, rTabIdBuffer, EXC_CHTR_OP_INSTAB ), XclExpRoot( rRoot ), - nTab( (SCTAB) rAction.GetBigRange().aStart.Tab() ) + nTab( static_cast<SCTAB>(rAction.GetBigRange().aStart.Tab()) ) { nLength = 0x0000021C; bForceInfo = true; @@ -1266,12 +1266,12 @@ XclExpChTrMoveRange::XclExpChTrMoveRange( aSourceRange = aDestRange; sal_Int32 nDCols, nDRows, nDTabs; rAction.GetDelta( nDCols, nDRows, nDTabs ); - aSourceRange.aStart.IncRow( (SCROW) -nDRows ); - aSourceRange.aStart.IncCol( (SCCOL) -nDCols ); - aSourceRange.aStart.IncTab( (SCTAB) -nDTabs ); - aSourceRange.aEnd.IncRow( (SCROW) -nDRows ); - aSourceRange.aEnd.IncCol( (SCCOL) -nDCols ); - aSourceRange.aEnd.IncTab( (SCTAB) -nDTabs ); + aSourceRange.aStart.IncRow( static_cast<SCROW>(-nDRows) ); + aSourceRange.aStart.IncCol( static_cast<SCCOL>(-nDCols) ); + aSourceRange.aStart.IncTab( static_cast<SCTAB>(-nDTabs) ); + aSourceRange.aEnd.IncRow( static_cast<SCROW>(-nDRows) ); + aSourceRange.aEnd.IncCol( static_cast<SCCOL>(-nDCols) ); + aSourceRange.aEnd.IncTab( static_cast<SCTAB>(-nDTabs) ); AddDependentContents( rAction, rRoot, rChangeTrack ); } @@ -1285,7 +1285,7 @@ void XclExpChTrMoveRange::SaveActionData( XclExpStream& rStrm ) const Write2DRange( rStrm, aSourceRange ); Write2DRange( rStrm, aDestRange ); WriteTabId( rStrm, aSourceRange.aStart.Tab() ); - rStrm << (sal_uInt32) 0x00000000; + rStrm << sal_uInt32(0x00000000); } void XclExpChTrMoveRange::PrepareSaveAction( XclExpStream& rStrm ) const @@ -1345,8 +1345,8 @@ XclExpChTr0x014A::~XclExpChTr0x014A() void XclExpChTr0x014A::SaveActionData( XclExpStream& rStrm ) const { WriteTabId( rStrm, aRange.aStart.Tab() ); - rStrm << (sal_uInt16) 0x0003 - << (sal_uInt16) 0x0001; + rStrm << sal_uInt16(0x0003) + << sal_uInt16(0x0001); Write2DRange( rStrm, aRange ); } diff --git a/sc/source/filter/xcl97/XclImpChangeTrack.cxx b/sc/source/filter/xcl97/XclImpChangeTrack.cxx index 47b441c10ec7..797075a8b08d 100644 --- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx @@ -257,7 +257,7 @@ void XclImpChangeTrack::ReadCell( break; case EXC_CHTR_TYPE_BOOL: { - double fValue = (double) (pStrm->ReaduInt16() != 0); + double fValue = static_cast<double>(pStrm->ReaduInt16() != 0); if( pStrm->IsValid() ) { rCell.meType = CELLTYPE_VALUE; diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 6a793bb64d73..46b67608087e 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -529,7 +529,7 @@ static void lcl_FillProps( EscherPropertyContainer& rPropOpt, SdrObject* pCaptio // If the Colour is the same as the 'ToolTip' System colour then // use the default rather than the explicit colour value. This will // be incorrect where user has chosen to use this colour explicitly. - Color aColor( (sal_uInt8)nValue, (sal_uInt8)( nValue >> 8 ), (sal_uInt8)( nValue >> 16 ) ); + Color aColor( static_cast<sal_uInt8>(nValue), static_cast<sal_uInt8>( nValue >> 8 ), static_cast<sal_uInt8>( nValue >> 16 ) ); const StyleSettings& rSett = Application::GetSettings().GetStyleSettings(); if( aColor == rSett.GetHelpColor().GetColor() ) { @@ -726,7 +726,7 @@ void XclObjDropDown::WriteSubRecs( XclExpStream& rStrm ) ::insert_value( nDropDownFlags, EXC_OBJ_DROPDOWN_SIMPLE, 0, 2 ); ::set_flag( nDropDownFlags, EXC_OBJ_DROPDOWN_FILTERED, bIsFiltered ); rStrm.StartRecord( EXC_ID_OBJLBSDATA, 16 ); - rStrm << (sal_uInt32)0 << (sal_uInt16)0 << (sal_uInt16)0x0301 << (sal_uInt16)0 + rStrm << sal_uInt32(0) << sal_uInt16(0) << sal_uInt16(0x0301) << sal_uInt16(0) << nDropDownFlags << sal_uInt16( 20 ) << sal_uInt16( 130 ); rStrm.EndRecord(); } @@ -948,7 +948,7 @@ void XclObjOle::WriteSubRecs( XclExpStream& rStrm ) // OBJPICTFMLA subrecord, undocumented as usual XclExpString aName( xOleStg->GetUserName() ); - sal_uInt16 nPadLen = (sal_uInt16)(aName.GetSize() & 0x01); + sal_uInt16 nPadLen = static_cast<sal_uInt16>(aName.GetSize() & 0x01); sal_uInt16 nFmlaLen = static_cast< sal_uInt16 >( 12 + aName.GetSize() + nPadLen ); sal_uInt16 nSubRecLen = nFmlaLen + 6; @@ -1024,20 +1024,20 @@ void XclObjAny::WriteFromTo( XclExpXmlStream& rStrm, const Reference< XShape >& pDrawing->startElement( FSNS( XML_xdr, XML_from ), FSEND ); - XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_col ), (sal_Int32) aRange.aStart.Col() ); + XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_col ), static_cast<sal_Int32>(aRange.aStart.Col()) ); XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_colOff ), oox::drawingml::convertHmmToEmu( aLocation.Left() - aRangeRect.Left() ) ); - XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_row ), (sal_Int32) aRange.aStart.Row() ); + XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_row ), static_cast<sal_Int32>(aRange.aStart.Row()) ); XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_rowOff ), oox::drawingml::convertHmmToEmu( aLocation.Top() - aRangeRect.Top() ) ); pDrawing->endElement( FSNS( XML_xdr, XML_from ) ); pDrawing->startElement( FSNS( XML_xdr, XML_to ), FSEND ); - XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_col ), (sal_Int32) aRange.aEnd.Col() ); + XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_col ), static_cast<sal_Int32>(aRange.aEnd.Col()) ); XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_colOff ), oox::drawingml::convertHmmToEmu( aLocation.Right() - aRangeRect.Right() ) ); - XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_row ), (sal_Int32) aRange.aEnd.Row() ); + XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_row ), static_cast<sal_Int32>(aRange.aEnd.Row()) ); XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_rowOff ), oox::drawingml::convertHmmToEmu( aLocation.Bottom() - aRangeRect.Bottom() ) ); pDrawing->endElement( FSNS( XML_xdr, XML_to ) ); @@ -1420,10 +1420,10 @@ void ExcEScenario::SaveCont( XclExpStream& rStrm ) rStrm << count // number of cells << sal_uInt8(bProtected) // fProtection - << (sal_uInt8) 0 // fHidden - << (sal_uInt8) sName.Len() // length of scen name - << (sal_uInt8) sComment.Len() // length of comment - << (sal_uInt8) sUserName.Len(); // length of user name + << sal_uInt8(0) // fHidden + << static_cast<sal_uInt8>(sName.Len()) // length of scen name + << static_cast<sal_uInt8>(sComment.Len()) // length of comment + << static_cast<sal_uInt8>(sUserName.Len()); // length of user name sName.WriteFlagField( rStrm ); sName.WriteBuffer( rStrm ); @@ -1496,10 +1496,10 @@ ExcEScenarioManager::~ExcEScenarioManager() void ExcEScenarioManager::SaveCont( XclExpStream& rStrm ) { - rStrm << (sal_uInt16) aScenes.size() // number of scenarios + rStrm << static_cast<sal_uInt16>(aScenes.size()) // number of scenarios << nActive // active scen << nActive // last displayed - << (sal_uInt16) 0; // reference areas + << sal_uInt16(0); // reference areas } void ExcEScenarioManager::Save( XclExpStream& rStrm ) diff --git a/sc/source/filter/xml/XMLCellRangeSourceContext.cxx b/sc/source/filter/xml/XMLCellRangeSourceContext.cxx index 74587169d7da..2ccc32306f76 100644 --- a/sc/source/filter/xml/XMLCellRangeSourceContext.cxx +++ b/sc/source/filter/xml/XMLCellRangeSourceContext.cxx @@ -81,7 +81,7 @@ ScXMLCellRangeSourceContext::ScXMLCellRangeSourceContext( { double fTime; if (::sax::Converter::convertDuration( fTime, aIter.toString() )) - pCellRangeSource->nRefresh = std::max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 ); + pCellRangeSource->nRefresh = std::max( static_cast<sal_Int32>(fTime * 86400.0), sal_Int32(0) ); } break; } diff --git a/sc/source/filter/xml/XMLConsolidationContext.cxx b/sc/source/filter/xml/XMLConsolidationContext.cxx index 0e929223284a..cfdbe34a18db 100644 --- a/sc/source/filter/xml/XMLConsolidationContext.cxx +++ b/sc/source/filter/xml/XMLConsolidationContext.cxx @@ -83,7 +83,7 @@ void SAL_CALL ScXMLConsolidationContext::endFastElement( sal_Int32 /*nElement*/ aConsParam.nTab = aTargetAddr.Tab(); aConsParam.eFunction = eFunction; - sal_uInt16 nCount = (sal_uInt16) std::min( ScRangeStringConverter::GetTokenCount( sSourceList ), (sal_Int32)0xFFFF ); + sal_uInt16 nCount = static_cast<sal_uInt16>(std::min( ScRangeStringConverter::GetTokenCount( sSourceList ), sal_Int32(0xFFFF) )); ScArea** ppAreas = nCount ? new ScArea*[ nCount ] : nullptr; if( ppAreas ) { diff --git a/sc/source/filter/xml/XMLTableSourceContext.cxx b/sc/source/filter/xml/XMLTableSourceContext.cxx index 4970fa00e510..5efbe6ef4157 100644 --- a/sc/source/filter/xml/XMLTableSourceContext.cxx +++ b/sc/source/filter/xml/XMLTableSourceContext.cxx @@ -66,7 +66,7 @@ ScXMLTableSourceContext::ScXMLTableSourceContext( ScXMLImport& rImport, case XML_ELEMENT( TABLE, XML_REFRESH_DELAY ): double fTime; if (::sax::Converter::convertDuration( fTime, aIter.toString() )) - nRefresh = std::max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 ); + nRefresh = std::max( static_cast<sal_Int32>(fTime * 86400.0), sal_Int32(0) ); break; } } diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx index 6e3e823c6ae8..a9033196ecbc 100644 --- a/sc/source/filter/xml/xmlcoli.cxx +++ b/sc/source/filter/xml/xmlcoli.cxx @@ -120,7 +120,7 @@ void SAL_CALL ScXMLTableColContext::endFastElement( sal_Int32 /*nElement*/ ) if ( nSheet != pStyle->GetLastSheet() ) { ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rXMLImport.GetModel())->GetSheetSaveData(); - pSheetData->AddColumnStyle( sStyleName, ScAddress( (SCCOL)nCurrentColumn, 0, nSheet ) ); + pSheetData->AddColumnStyle( sStyleName, ScAddress( static_cast<SCCOL>(nCurrentColumn), 0, nSheet ) ); pStyle->SetLastSheet(nSheet); } } diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx index c6d1dde218e3..e513d4e8c0f7 100644 --- a/sc/source/filter/xml/xmldrani.cxx +++ b/sc/source/filter/xml/xmldrani.cxx @@ -177,7 +177,7 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport, { double fTime; if (::sax::Converter::convertDuration( fTime, aIter.toString() )) - nRefresh = std::max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 ); + nRefresh = std::max( static_cast<sal_Int32>(fTime * 86400.0), sal_Int32(0) ); } break; } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 0781246233e7..e9c6a22916f4 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -648,7 +648,7 @@ void ScXMLExport::ExportMeta_() uno::Sequence<beans::NamedValue> stats { - { "TableCount", uno::makeAny((sal_Int32)nTableCount) }, + { "TableCount", uno::makeAny(static_cast<sal_Int32>(nTableCount)) }, { "CellCount", uno::makeAny(nCellCount) }, { "ObjectCount", uno::makeAny(nShapesCount) } }; @@ -1819,7 +1819,7 @@ void ScXMLExport::CopySourceStream( sal_Int32 nStartOffset, sal_Int32 nEndOffset xDestStream->writeBytes( aOutSeq ); } - rNewStart = (sal_Int32)xDestSeek->getPosition(); + rNewStart = static_cast<sal_Int32>(xDestSeek->getPosition()); if ( nStartOffset > nSourceStreamPos ) lcl_SkipBytesInBlocks( xSourceStream, nStartOffset - nSourceStreamPos ); @@ -1834,7 +1834,7 @@ void ScXMLExport::CopySourceStream( sal_Int32 nStartOffset, sal_Int32 nEndOffset } nSourceStreamPos = nEndOffset; - rNewEnd = (sal_Int32)xDestSeek->getPosition(); + rNewEnd = static_cast<sal_Int32>(xDestSeek->getPosition()); } } } @@ -1913,7 +1913,7 @@ void ScXMLExport::ExportContent_() { sal_Int32 nStartOffset = -1; sal_Int32 nEndOffset = -1; - if (pSheetData && pDoc && pDoc->IsStreamValid((SCTAB)nTable) && !pDoc->GetChangeTrack()) + if (pSheetData && pDoc && pDoc->IsStreamValid(static_cast<SCTAB>(nTable)) && !pDoc->GetChangeTrack()) pSheetData->GetStreamPos( nTable, nStartOffset, nEndOffset ); if ( nStartOffset >= 0 && nEndOffset >= 0 && xSourceStream.is() ) @@ -3572,7 +3572,7 @@ void ScXMLExport::WriteAreaLink( const ScMyCell& rMyCell ) if( rAreaLink.nRefresh ) { ::sax::Converter::convertDuration( sValue, - (double)rAreaLink.nRefresh / 86400 ); + static_cast<double>(rAreaLink.nRefresh) / 86400 ); AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sValue.makeStringAndClear() ); } SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, XML_CELL_RANGE_SOURCE, true, true ); @@ -3920,7 +3920,7 @@ void ScXMLExport::WriteTableSource() { OUStringBuffer sBuffer; ::sax::Converter::convertDuration( sBuffer, - (double)nRefresh / 86400 ); + static_cast<double>(nRefresh) / 86400 ); AddAttribute( XML_NAMESPACE_TABLE, XML_REFRESH_DELAY, sBuffer.makeStringAndClear() ); } SvXMLElementExport aSourceElem(*this, XML_NAMESPACE_TABLE, XML_TABLE_SOURCE, true, true); diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 0a7f0a44efa8..b521ebedb7a7 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -1459,7 +1459,7 @@ void ScXMLImport::SetStyleToRanges() { ScSheetSaveData* pSheetData = ScModelObj::getImplementation(GetModel())->GetSheetSaveData(); pSheetData->AddCellStyle( sPrevStyleName, - ScAddress( (SCCOL)rRange.StartColumn, (SCROW)rRange.StartRow, (SCTAB)rRange.Sheet ) ); + ScAddress( static_cast<SCCOL>(rRange.StartColumn), static_cast<SCROW>(rRange.StartRow), static_cast<SCTAB>(rRange.Sheet) ) ); pStyle->SetLastSheet(rRange.Sheet); } } @@ -1935,7 +1935,7 @@ sal_Int32 ScXMLImport::GetByteOffset() uno::Reference<xml::sax::XLocator> xLocator = GetLocator(); uno::Reference<io::XSeekable> xSeek( xLocator, uno::UNO_QUERY ); //! should use different interface if ( xSeek.is() ) - nOffset = (sal_Int32)xSeek->getPosition(); + nOffset = static_cast<sal_Int32>(xSeek->getPosition()); return nOffset; } diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx index b2bfd33eb71f..7f958d459f4d 100644 --- a/sc/source/filter/xml/xmlrowi.cxx +++ b/sc/source/filter/xml/xmlrowi.cxx @@ -69,7 +69,7 @@ ScXMLTableRowContext::ScXMLTableRowContext( ScXMLImport& rImport, break; case XML_ELEMENT( TABLE, XML_NUMBER_ROWS_REPEATED ): { - nRepeatedRows = std::max( it.toInt32(), (sal_Int32) 1 ); + nRepeatedRows = std::max( it.toInt32(), sal_Int32(1) ); nRepeatedRows = std::min( nRepeatedRows, MAXROWCOUNT ); } break; @@ -175,7 +175,7 @@ void SAL_CALL ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/) if ( nSheet != pStyle->GetLastSheet() ) { ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rXMLImport.GetModel())->GetSheetSaveData(); - pSheetData->AddRowStyle( sStyleName, ScAddress( 0, (SCROW)nFirstRow, nSheet ) ); + pSheetData->AddRowStyle( sStyleName, ScAddress( 0, static_cast<SCROW>(nFirstRow), nSheet ) ); pStyle->SetLastSheet(nSheet); } } diff --git a/sc/source/ui/Accessibility/AccessibleCellBase.cxx b/sc/source/ui/Accessibility/AccessibleCellBase.cxx index 26c56e133ca9..0ab07a04f1e9 100644 --- a/sc/source/ui/Accessibility/AccessibleCellBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleCellBase.cxx @@ -415,13 +415,13 @@ OUString ScAccessibleCellBase::getShadowAttrs() sShadowAttrs += OUString::number( nLocationVal ); sShadowAttrs += sInnerSplit; sShadowAttrs += "ShadowWidth="; - sShadowAttrs += OUString::number( (sal_Int32)aShadowFmt.ShadowWidth ) ; + sShadowAttrs += OUString::number( static_cast<sal_Int32>(aShadowFmt.ShadowWidth) ) ; sShadowAttrs += sInnerSplit; sShadowAttrs += "IsTransparent="; - sShadowAttrs += OUString::number( (int)aShadowFmt.IsTransparent ) ; + sShadowAttrs += OUString::number( static_cast<int>(aShadowFmt.IsTransparent) ) ; sShadowAttrs += sInnerSplit; sShadowAttrs += "Color="; - sShadowAttrs += OUString::number( (sal_Int32)aShadowFmt.Color ); + sShadowAttrs += OUString::number( static_cast<sal_Int32>(aShadowFmt.Color) ); sShadowAttrs += sOuterSplit; return sShadowAttrs; } @@ -499,16 +499,16 @@ OUString ScAccessibleCellBase::getBorderAttrs() else//add all the border properties to the return string. { sBorderAttrs += "TopBorder:Color="; - sBorderAttrs += OUString::number( (sal_Int32)aTopBorder.Color ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aTopBorder.Color) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "InnerLineWidth="; - sBorderAttrs += OUString::number( (sal_Int32)aTopBorder.InnerLineWidth ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aTopBorder.InnerLineWidth) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "OuterLineWidth="; - sBorderAttrs += OUString::number( (sal_Int32)aTopBorder.OuterLineWidth ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aTopBorder.OuterLineWidth) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "LineDistance="; - sBorderAttrs += OUString::number( (sal_Int32)aTopBorder.LineDistance ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aTopBorder.LineDistance) ); sBorderAttrs += sOuterSplit; } //bottom border @@ -519,16 +519,16 @@ OUString ScAccessibleCellBase::getBorderAttrs() else { sBorderAttrs += "BottomBorder:Color="; - sBorderAttrs += OUString::number( (sal_Int32)aBottomBorder.Color ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aBottomBorder.Color) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "InnerLineWidth="; - sBorderAttrs += OUString::number( (sal_Int32)aBottomBorder.InnerLineWidth ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aBottomBorder.InnerLineWidth) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "OuterLineWidth="; - sBorderAttrs += OUString::number( (sal_Int32)aBottomBorder.OuterLineWidth ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aBottomBorder.OuterLineWidth) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "LineDistance="; - sBorderAttrs += OUString::number( (sal_Int32)aBottomBorder.LineDistance ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aBottomBorder.LineDistance) ); sBorderAttrs += sOuterSplit; } //left border @@ -539,16 +539,16 @@ OUString ScAccessibleCellBase::getBorderAttrs() else { sBorderAttrs += "LeftBorder:Color="; - sBorderAttrs += OUString::number( (sal_Int32)aLeftBorder.Color ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aLeftBorder.Color) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "InnerLineWidth="; - sBorderAttrs += OUString::number( (sal_Int32)aLeftBorder.InnerLineWidth ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aLeftBorder.InnerLineWidth) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "OuterLineWidth="; - sBorderAttrs += OUString::number( (sal_Int32)aLeftBorder.OuterLineWidth ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aLeftBorder.OuterLineWidth) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "LineDistance="; - sBorderAttrs += OUString::number( (sal_Int32)aLeftBorder.LineDistance ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aLeftBorder.LineDistance) ); sBorderAttrs += sOuterSplit; } //right border @@ -559,16 +559,16 @@ OUString ScAccessibleCellBase::getBorderAttrs() else { sBorderAttrs += "RightBorder:Color="; - sBorderAttrs += OUString::number( (sal_Int32)aRightBorder.Color ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aRightBorder.Color) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "InnerLineWidth="; - sBorderAttrs += OUString::number( (sal_Int32)aRightBorder.InnerLineWidth ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aRightBorder.InnerLineWidth) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "OuterLineWidth="; - sBorderAttrs += OUString::number( (sal_Int32)aRightBorder.OuterLineWidth ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aRightBorder.OuterLineWidth) ); sBorderAttrs += sInnerSplit; sBorderAttrs += "LineDistance="; - sBorderAttrs += OUString::number( (sal_Int32)aRightBorder.LineDistance ); + sBorderAttrs += OUString::number( static_cast<sal_Int32>(aRightBorder.LineDistance) ); sBorderAttrs += sOuterSplit; } return sBorderAttrs; diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx index 580fd0917e53..e5ba30cccc6c 100644 --- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx +++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx @@ -866,7 +866,7 @@ sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleRowSelected( sal_Int32 nR if (mpViewShell) { const ScMarkData& rMarkdata = mpViewShell->GetViewData().GetMarkData(); - bResult = rMarkdata.IsRowMarked((SCROW)nRow); + bResult = rMarkdata.IsRowMarked(static_cast<SCROW>(nRow)); } return bResult; } @@ -887,7 +887,7 @@ sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleColumnSelected( sal_Int32 if (mpViewShell) { const ScMarkData& rMarkdata = mpViewShell->GetViewData().GetMarkData(); - bResult = rMarkdata.IsColumnMarked((SCCOL)nColumn); + bResult = rMarkdata.IsColumnMarked(static_cast<SCCOL>(nColumn)); } return bResult; } diff --git a/sc/source/ui/Accessibility/AccessibleTableBase.cxx b/sc/source/ui/Accessibility/AccessibleTableBase.cxx index 21dbd525d235..94ccd54312ea 100644 --- a/sc/source/ui/Accessibility/AccessibleTableBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleTableBase.cxx @@ -311,8 +311,8 @@ sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleChildCount() // FIXME: representing rows & columns this way is a plain and simple madness. // this needs a radical re-think. - sal_Int64 nMax = ((sal_Int64)(maRange.aEnd.Row() - maRange.aStart.Row() + 1) * - (sal_Int64)(maRange.aEnd.Col() - maRange.aStart.Col() + 1)); + sal_Int64 nMax = (static_cast<sal_Int64>(maRange.aEnd.Row() - maRange.aStart.Row() + 1) * + static_cast<sal_Int64>(maRange.aEnd.Col() - maRange.aStart.Col() + 1)); if (nMax > SAL_MAX_INT32) nMax = SAL_MAX_INT32; if (nMax < 0) diff --git a/sc/source/ui/app/client.cxx b/sc/source/ui/app/client.cxx index a3a8e12f874b..a46ca516a599 100644 --- a/sc/source/ui/app/client.cxx +++ b/sc/source/ui/app/client.cxx @@ -214,7 +214,7 @@ void ScClient::ViewChanged() tools::Rectangle aLogicRect = pDrawObj->GetLogicRect(); Fraction aFractX = GetScaleWidth() * aVisSize.Width(); Fraction aFractY = GetScaleHeight() * aVisSize.Height(); - aVisSize = Size( (long) aFractX, (long) aFractY ); // Scaled for Draw model + aVisSize = Size( static_cast<long>(aFractX), static_cast<long>(aFractY) ); // Scaled for Draw model // pClientData->SetObjArea before pDrawObj->SetLogicRect, so that we don't // calculate wrong scalings: diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx index 2a63c4c367ee..6c8863562f66 100644 --- a/sc/source/ui/app/drwtrans.cxx +++ b/sc/source/ui/app/drwtrans.cxx @@ -246,7 +246,7 @@ ScDrawTransferObj* ScDrawTransferObj::GetOwnClipboard( vcl::Window* pWin ) { sal_Int64 nHandle = xTunnel->getSomething( getUnoTunnelId() ); if ( nHandle ) - pObj = dynamic_cast<ScDrawTransferObj*>(reinterpret_cast<TransferableHelper*>( (sal_IntPtr) nHandle )); + pObj = dynamic_cast<ScDrawTransferObj*>(reinterpret_cast<TransferableHelper*>( static_cast<sal_IntPtr>(nHandle) )); } return pObj; diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index c1b87303e9a4..80620aa35383 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -455,13 +455,13 @@ void ScInputHandler::UpdateRange( sal_uInt16 nIndex, const ScRange& rNew ) DataChanged(); bInRangeUpdate = false; - long nDiff = aNewStr.getLength() - (long)(nOldEnd-nOldStart); + long nDiff = aNewStr.getLength() - static_cast<long>(nOldEnd-nOldStart); rData.aRef = rNew; rData.nSelEnd = rData.nSelEnd + nDiff; rData.nColorData = nNewColor; - sal_uInt16 nCount = (sal_uInt16) pRangeFindList->Count(); + sal_uInt16 nCount = static_cast<sal_uInt16>(pRangeFindList->Count()); for (sal_uInt16 i=nIndex+1; i<nCount; i++) { ScRangeFindData& rNext = pRangeFindList->GetObject( i ); @@ -595,7 +595,7 @@ static sal_Int32 lcl_MatchParenthesis( const OUString& rStr, sal_Int32 nPos ) } if ( nLevel ) return -1; - return (sal_Int32) (p - p0); + return static_cast<sal_Int32>(p - p0); } ScInputHandler::ScInputHandler() diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index a7ff74f109c2..28ff4acbdd1a 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -679,7 +679,7 @@ void ScInputWindow::MouseMove( const MouseEvent& rMEvt ) if (bInResize) { // detect direction - long nResizeThreshold = ((long)TBX_WINDOW_HEIGHT * 0.7); + long nResizeThreshold = (long(TBX_WINDOW_HEIGHT) * 0.7); bool bResetPointerPos = false; // Detect attempt to expand toolbar too much diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index acb719f787de..a6c1cd6662bb 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -223,10 +223,10 @@ void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster* p, Configura { const svtools::ColorConfig& rColors = GetColorConfig(); bool bArrows = - ( ScDetectiveFunc::GetArrowColor() != (ColorData)rColors.GetColorValue(svtools::CALCDETECTIVE).nColor || - ScDetectiveFunc::GetErrorColor() != (ColorData)rColors.GetColorValue(svtools::CALCDETECTIVEERROR).nColor ); + ( ScDetectiveFunc::GetArrowColor() != static_cast<ColorData>(rColors.GetColorValue(svtools::CALCDETECTIVE).nColor) || + ScDetectiveFunc::GetErrorColor() != static_cast<ColorData>(rColors.GetColorValue(svtools::CALCDETECTIVEERROR).nColor) ); bool bComments = - ( ScDetectiveFunc::GetCommentColor() != (ColorData)rColors.GetColorValue(svtools::CALCNOTESBACKGROUND).nColor ); + ( ScDetectiveFunc::GetCommentColor() != static_cast<ColorData>(rColors.GetColorValue(svtools::CALCNOTESBACKGROUND).nColor) ); if ( bArrows || bComments ) { ScDetectiveFunc::InitializeColors(); // get the new colors @@ -734,7 +734,7 @@ void ScModule::InsertEntryToLRUList(sal_uInt16 nFIndex) if(nFIndex != 0) { const ScAppOptions& rAppOpt = GetAppOptions(); - sal_uInt16 nLRUFuncCount = std::min( rAppOpt.GetLRUFuncListCount(), (sal_uInt16)LRU_MAX ); + sal_uInt16 nLRUFuncCount = std::min( rAppOpt.GetLRUFuncListCount(), sal_uInt16(LRU_MAX) ); sal_uInt16* pLRUListIds = rAppOpt.GetLRUFuncList(); sal_uInt16 aIdxList[LRU_MAX]; diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 77e528a0dff0..258edbdce67c 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -207,7 +207,7 @@ ScTransferObj* ScTransferObj::GetOwnClipboard( vcl::Window* pUIWin ) { sal_Int64 nHandle = xTunnel->getSomething( getUnoTunnelId() ); if ( nHandle ) - pObj = dynamic_cast<ScTransferObj*>(reinterpret_cast<TransferableHelper*>( (sal_IntPtr) nHandle )); + pObj = dynamic_cast<ScTransferObj*>(reinterpret_cast<TransferableHelper*>( static_cast<sal_IntPtr>(nHandle) )); } return pObj; @@ -727,8 +727,8 @@ void ScTransferObj::InitDocShell(bool bLimitToPageSize) for (nCol=0; nCol<nStartX; nCol++) nPosX += rDestDoc.GetColWidth( nCol, 0 ); nPosY += rDestDoc.GetRowHeight( 0, nStartY-1, 0 ); - nPosX = (long) ( nPosX * HMM_PER_TWIPS ); - nPosY = (long) ( nPosY * HMM_PER_TWIPS ); + nPosX = static_cast<long>( nPosX * HMM_PER_TWIPS ); + nPosY = static_cast<long>( nPosY * HMM_PER_TWIPS ); aPaperSize.Width() *= 2; // limit OLE object to double of page size aPaperSize.Height() *= 2; @@ -749,8 +749,8 @@ void ScTransferObj::InitDocShell(bool bLimitToPageSize) break; nSizeY += nAdd; } - nSizeX = (long) ( nSizeX * HMM_PER_TWIPS ); - nSizeY = (long) ( nSizeY * HMM_PER_TWIPS ); + nSizeX = static_cast<long>( nSizeX * HMM_PER_TWIPS ); + nSizeY = static_cast<long>( nSizeY * HMM_PER_TWIPS ); // pDocSh->SetVisAreaSize( Size(nSizeX,nSizeY) ); diff --git a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx index d5315da35ae1..7b6d58282db2 100644 --- a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx +++ b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx @@ -353,7 +353,7 @@ void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem ) for ( sal_Int32 j = 0; j < rSnappingPoints.getLength(); ++j ) { const sal_Int32 nSnappingPoint = rSnappingPoints[j]; - aTmpSnappingPoints.insert( (sal_uInt16)nSnappingPoint ); + aTmpSnappingPoints.insert( static_cast<sal_uInt16>(nSnappingPoint) ); } // remove snapping points that are to close to each other: diff --git a/sc/source/ui/dataprovider/csvdataprovider.cxx b/sc/source/ui/dataprovider/csvdataprovider.cxx index a6850edec3de..c787ee4ce0c6 100644 --- a/sc/source/ui/dataprovider/csvdataprovider.cxx +++ b/sc/source/ui/dataprovider/csvdataprovider.cxx @@ -136,7 +136,7 @@ void CSVDataProvider::Import() return; mpDoc.reset(new ScDocument(SCDOCMODE_CLIP)); - mpDoc->ResetClip(mpDocument, (SCTAB)0); + mpDoc->ResetClip(mpDocument, SCTAB(0)); mxCSVFetchThread = new CSVFetchThread(*mpDoc, mrDataSource.getURL(), std::bind(&CSVDataProvider::ImportFinished, this), mrDataSource.getDataTransformation()); mxCSVFetchThread->launch(); diff --git a/sc/source/ui/dataprovider/htmldataprovider.cxx b/sc/source/ui/dataprovider/htmldataprovider.cxx index de1173b274e7..b95b448c1989 100644 --- a/sc/source/ui/dataprovider/htmldataprovider.cxx +++ b/sc/source/ui/dataprovider/htmldataprovider.cxx @@ -231,7 +231,7 @@ void HTMLDataProvider::Import() return; mpDoc.reset(new ScDocument(SCDOCMODE_CLIP)); - mpDoc->ResetClip(mpDocument, (SCTAB)0); + mpDoc->ResetClip(mpDocument, SCTAB(0)); mxHTMLFetchThread = new HTMLFetchThread(*mpDoc, mrDataSource.getURL(), mrDataSource.getID(), std::bind(&HTMLDataProvider::ImportFinished, this), mrDataSource.getDataTransformation()); mxHTMLFetchThread->launch(); diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index 4662e1acc163..3032106518f4 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -236,7 +236,7 @@ OUString ScAsciiOptions::WriteToString() const aOutStr += "," + // Language - OUString::number((sal_uInt16)eLang) + "," + + OUString::number(static_cast<sal_uInt16>(eLang)) + "," + // Import quoted field as text. OUString::boolean( bQuotedFieldAsText ) + "," + // Detect special numbers. diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx index 5c8b1f6489e5..4bad68cdae50 100644 --- a/sc/source/ui/dbgui/csvruler.cxx +++ b/sc/source/ui/dbgui/csvruler.cxx @@ -567,7 +567,7 @@ void ScCsvRuler::ImplDrawBackgrDev() maBackgrDev->SetFillColor(); sal_Int32 nPos; - sal_Int32 nFirstPos = std::max( GetPosFromX( 0 ) - 1, (sal_Int32)0 ); + sal_Int32 nFirstPos = std::max( GetPosFromX( 0 ) - 1, sal_Int32(0) ); sal_Int32 nLastPos = GetPosFromX( GetWidth() ); sal_Int32 nY = (maActiveRect.Top() + maActiveRect.Bottom()) / 2; for( nPos = nFirstPos; nPos <= nLastPos; ++nPos ) diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx index 78932e96091f..00fba720a865 100644 --- a/sc/source/ui/dbgui/filtdlg.cxx +++ b/sc/source/ui/dbgui/filtdlg.cxx @@ -325,17 +325,17 @@ void ScFilterDlg::Init( const SfxItemSet& rArgSet ) (pLbField1->GetSelectedEntryPos() != 0) && (pLbField2->GetSelectedEntryPos() != 0) - ? pLbConnect2->SelectEntryPos( (sal_uInt16)theQueryData.GetEntry(1).eConnect ) + ? pLbConnect2->SelectEntryPos( static_cast<sal_uInt16>(theQueryData.GetEntry(1).eConnect) ) : pLbConnect2->SetNoSelection(); (pLbField2->GetSelectedEntryPos() != 0) && (pLbField3->GetSelectedEntryPos() != 0) - ? pLbConnect3->SelectEntryPos( (sal_uInt16)theQueryData.GetEntry(2).eConnect ) + ? pLbConnect3->SelectEntryPos( static_cast<sal_uInt16>(theQueryData.GetEntry(2).eConnect) ) : pLbConnect3->SetNoSelection(); (pLbField3->GetSelectedEntryPos() != 0) && (pLbField4->GetSelectedEntryPos() != 0) - ? pLbConnect4->SelectEntryPos( (sal_uInt16)theQueryData.GetEntry(3).eConnect ) + ? pLbConnect4->SelectEntryPos( static_cast<sal_uInt16>(theQueryData.GetEntry(3).eConnect) ) : pLbConnect4->SetNoSelection(); if ( pLbField1->GetSelectedEntryPos() == 0 ) { @@ -1169,7 +1169,7 @@ void ScFilterDlg::RefreshEditRow( size_t nOffset ) if (maRefreshExceptQuery.size() < nQENext + 1) maRefreshExceptQuery.resize(nQENext + 1, false); if (theQueryData.GetEntry(nQENext).bDoQuery || maRefreshExceptQuery[nQENext]) - maConnLbArr[i+1]->SelectEntryPos( (sal_uInt16) theQueryData.GetEntry(nQENext).eConnect ); + maConnLbArr[i+1]->SelectEntryPos( static_cast<sal_uInt16>(theQueryData.GetEntry(nQENext).eConnect) ); else maConnLbArr[i+1]->SetNoSelection(); } @@ -1184,7 +1184,7 @@ void ScFilterDlg::RefreshEditRow( size_t nOffset ) if (maRefreshExceptQuery.size() < nQE + 1) maRefreshExceptQuery.resize(nQE + 1, false); if(rEntry.bDoQuery || maRefreshExceptQuery[nQE]) - maConnLbArr[i]->SelectEntryPos( (sal_uInt16) rEntry.eConnect ); + maConnLbArr[i]->SelectEntryPos( static_cast<sal_uInt16>(rEntry.eConnect) ); else maConnLbArr[i]->SetNoSelection(); } diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx index 2959f07048aa..525d8f4a94b2 100644 --- a/sc/source/ui/dbgui/imoptdlg.cxx +++ b/sc/source/ui/dbgui/imoptdlg.cxx @@ -51,7 +51,7 @@ ScImportOptions::ScImportOptions( const OUString& rStr ) bFixedWidth = true; else nFieldSepCode = ScAsciiOptions::GetWeightedFieldSep( aToken, true); - nTextSepCode = (sal_Unicode) rStr.getToken(1,',').toInt32(); + nTextSepCode = static_cast<sal_Unicode>(rStr.getToken(1,',').toInt32()); aStrFont = rStr.getToken(2,','); eCharSet = ScGlobal::GetCharsetValue(aStrFont); diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx index cdb6cf3516eb..6de3a16d1759 100644 --- a/sc/source/ui/dbgui/pfiltdlg.cxx +++ b/sc/source/ui/dbgui/pfiltdlg.cxx @@ -189,7 +189,7 @@ void ScPivotFilterDlg::Init( const SfxItemSet& rArgSet ) aValStr = aStrEmpty; else if (rEntry.IsQueryByNonEmpty()) aValStr = aStrNotEmpty; - sal_uInt16 nCondPos = (sal_uInt16)rEntry.eOp; + sal_uInt16 nCondPos = static_cast<sal_uInt16>(rEntry.eOp); sal_uInt16 nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) ); aFieldLbArr[i]->SelectEntryPos( nFieldSelPos ); @@ -213,12 +213,12 @@ void ScPivotFilterDlg::Init( const SfxItemSet& rArgSet ) (m_pLbField1->GetSelectedEntryPos() != 0) && (m_pLbField2->GetSelectedEntryPos() != 0) - ? m_pLbConnect1->SelectEntryPos( (sal_uInt16)theQueryData.GetEntry(1).eConnect ) + ? m_pLbConnect1->SelectEntryPos( static_cast<sal_uInt16>(theQueryData.GetEntry(1).eConnect) ) : m_pLbConnect1->SetNoSelection(); (m_pLbField2->GetSelectedEntryPos() != 0) && (m_pLbField3->GetSelectedEntryPos() != 0) - ? m_pLbConnect2->SelectEntryPos( (sal_uInt16)theQueryData.GetEntry(2).eConnect ) + ? m_pLbConnect2->SelectEntryPos( static_cast<sal_uInt16>(theQueryData.GetEntry(2).eConnect) ) : m_pLbConnect2->SetNoSelection(); if ( m_pLbField1->GetSelectedEntryPos() == 0 ) diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 4340244a0706..e3aa2a2bfc7f 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -102,7 +102,7 @@ static void lcl_FillCombo( ComboBox& rCombo, const OUString& rList, sal_Unicode { OUString aStr; for ( i=0; i<nCount; i+=2 ) - if ( (sal_Unicode)rList.getToken(i+1,'\t').toInt32() == cSelect ) + if ( static_cast<sal_Unicode>(rList.getToken(i+1,'\t').toInt32()) == cSelect ) aStr = rList.getToken(i,'\t'); if (aStr.isEmpty()) aStr = OUString(cSelect); // Ascii @@ -121,7 +121,7 @@ static sal_Unicode lcl_CharFromCombo( const ComboBox& rCombo, const OUString& rL for ( sal_Int32 i=0; i<nCount; i+=2 ) { if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rList.getToken(i,'\t') ) ) - c = (sal_Unicode)rList.getToken(i+1,'\t').toInt32(); + c = static_cast<sal_Unicode>(rList.getToken(i+1,'\t').toInt32()); } if (!c && !aStr.isEmpty()) { @@ -130,7 +130,7 @@ static sal_Unicode lcl_CharFromCombo( const ComboBox& rCombo, const OUString& rL if( (aStr.getLength() == 1) || (cFirst < '0') || (cFirst > '9') ) c = cFirst; else // keep old behaviour for compatibility (i.e. "39" -> "'") - c = (sal_Unicode) aStr.toInt32(); // Ascii + c = static_cast<sal_Unicode>(aStr.toInt32()); // Ascii } } return c; @@ -616,7 +616,7 @@ void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt ) rOpt.SetCharSetSystem( mbCharSetSystem ); rOpt.SetLanguage(pLbCustomLang->GetSelectLanguage()); rOpt.SetFixedLen( pRbFixed->IsChecked() ); - rOpt.SetStartRow( (long)pNfRow->GetValue() ); + rOpt.SetStartRow( static_cast<long>(pNfRow->GetValue()) ); mpTableBox->FillColumnData( rOpt ); if( pRbSeparated->IsChecked() ) { diff --git a/sc/source/ui/dbgui/scuiimoptdlg.cxx b/sc/source/ui/dbgui/scuiimoptdlg.cxx index 269d0e7e67f6..b67b692de098 100644 --- a/sc/source/ui/dbgui/scuiimoptdlg.cxx +++ b/sc/source/ui/dbgui/scuiimoptdlg.cxx @@ -64,7 +64,7 @@ sal_uInt16 ScDelimiterTable::GetCode( const OUString& rDel ) const { if ( rDel == theDelTab.getToken( i, cSep ) ) { - nCode = (sal_Unicode) theDelTab.getToken( i+1, cSep ).toInt32(); + nCode = static_cast<sal_Unicode>(theDelTab.getToken( i+1, cSep ).toInt32()); i = nCount; } else @@ -84,7 +84,7 @@ OUString ScDelimiterTable::GetDelimiter( sal_Unicode nCode ) const sal_Int32 i = 0; while ( i<nCount ) { - if ( nCode == (sal_Unicode) theDelTab.getToken( i+1, cSep ).toInt32() ) + if ( nCode == static_cast<sal_Unicode>(theDelTab.getToken( i+1, cSep ).toInt32()) ) { aStrDel = theDelTab.getToken( i, cSep ); i = nCount; @@ -318,7 +318,7 @@ sal_uInt16 ScImportOptionsDlg::GetCodeFromCombo( const ComboBox& rEd ) const nCode = pTab->GetCode( aStr ); if ( nCode == 0 ) - nCode = (sal_uInt16)aStr[0]; + nCode = static_cast<sal_uInt16>(aStr[0]); } return nCode; diff --git a/sc/source/ui/dbgui/tpsubt.cxx b/sc/source/ui/dbgui/tpsubt.cxx index ca8bd54b6537..c333c31306bd 100644 --- a/sc/source/ui/dbgui/tpsubt.cxx +++ b/sc/source/ui/dbgui/tpsubt.cxx @@ -384,7 +384,7 @@ IMPL_LINK( ScTpSubTotalGroup, CheckHdl, SvTreeListBox*, pLb, void ) if ( pEntry ) { - mpLbColumns->SelectEntryPos( (sal_uInt16)mpLbColumns->GetModel()->GetAbsPos( pEntry ) ); + mpLbColumns->SelectEntryPos( static_cast<sal_uInt16>(mpLbColumns->GetModel()->GetAbsPos( pEntry )) ); SelectHdl( pLb ); } } diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx index 95fc79d8ed01..a2eb8f095163 100644 --- a/sc/source/ui/docshell/arealink.cxx +++ b/sc/source/ui/docshell/arealink.cxx @@ -292,7 +292,7 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter, if( FindExtRange( aTokenRange, &rSrcDoc, aToken ) ) { // columns: find maximum - nWidth = std::max( nWidth, (SCCOL)(aTokenRange.aEnd.Col() - aTokenRange.aStart.Col() + 1) ); + nWidth = std::max( nWidth, static_cast<SCCOL>(aTokenRange.aEnd.Col() - aTokenRange.aStart.Col() + 1) ); // rows: add row range + 1 empty row nHeight += aTokenRange.aEnd.Row() - aTokenRange.aStart.Row() + 2; } diff --git a/sc/source/ui/docshell/autostyl.cxx b/sc/source/ui/docshell/autostyl.cxx index 98a104c4f8c3..dec13ced11a6 100644 --- a/sc/source/ui/docshell/autostyl.cxx +++ b/sc/source/ui/docshell/autostyl.cxx @@ -26,7 +26,7 @@ static inline sal_uLong TimeNow() // seconds { - return (sal_uLong) time(nullptr); + return static_cast<sal_uLong>(time(nullptr)); } namespace { diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx index 6710ed4659fb..d83fb8be69f4 100644 --- a/sc/source/ui/docshell/dbdocimp.cxx +++ b/sc/source/ui/docshell/dbdocimp.cxx @@ -262,7 +262,7 @@ bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam, uno::Reference<sdbc::XRow> xRow( xRowSet, uno::UNO_QUERY ); if ( nColCount > 0 && xRow.is() ) { - nEndCol = (SCCOL)( rParam.nCol1 + nColCount - 1 ); + nEndCol = static_cast<SCCOL>( rParam.nCol1 + nColCount - 1 ); uno::Sequence<sal_Int32> aColTypes( nColCount ); // column types uno::Sequence<sal_Bool> aColCurr( nColCount ); // currency flag is not in types diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 6f1ba210ff4b..c4f2b2a00168 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1506,8 +1506,8 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium ) if ( bRet && (bSetColWidths || bSetRowHeights) ) { // Adjust column width/row height; base 100% zoom Fraction aZoom( 1, 1 ); - double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom / GetOutputFactor(); // Factor is printer display ratio - double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom; + double nPPTX = ScGlobal::nScreenPPTX * static_cast<double>(aZoom) / GetOutputFactor(); // Factor is printer display ratio + double nPPTY = ScGlobal::nScreenPPTY * static_cast<double>(aZoom); ScopedVclPtrInstance< VirtualDevice > pVirtDev; // all sheets (for Excel import) SCTAB nTabCount = aDocument.GetTableCount(); @@ -1534,7 +1534,7 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium ) nCol, nTab, pVirtDev, nPPTX, nPPTY, aZoom, aZoom, false, &aMark, &aColWidthParam[nCol] ); aDocument.SetColWidth( nCol, nTab, - nWidth + (sal_uInt16)ScGlobal::nLastColWidthExtra ); + nWidth + static_cast<sal_uInt16>(ScGlobal::nLastColWidthExtra) ); } } } @@ -2906,7 +2906,7 @@ void ScDocShell::GetDocStat( ScDocStat& rDocStat ) if ( pPrinter ) for ( SCTAB i=0; i<rDocStat.nTableCount; i++ ) rDocStat.nPageCount = sal::static_int_cast<sal_uInt16>( rDocStat.nPageCount + - (sal_uInt16) ScPrintFunc( this, pPrinter, i ).GetTotalPages() ); + static_cast<sal_uInt16>(ScPrintFunc( this, pPrinter, i ).GetTotalPages()) ); } VclPtr<SfxDocumentInfoDialog> ScDocShell::CreateDocumentInfoDialog( const SfxItemSet &rSet ) diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index 8dff8eb694b2..568e80078c35 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -48,8 +48,8 @@ bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) // Additional tables are created by the first View, if bIsEmpty is still sal_True if( bRet ) { - Size aSize( (long) ( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ), - (long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) ); + Size aSize( long( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ), + static_cast<long>( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) ); // Also adjust start here SetVisAreaOrSize( tools::Rectangle( Point(), aSize ) ); } diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 35f174613450..8eae0400beee 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -388,10 +388,10 @@ void ScDocShell::CalcOutputFactor() pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, pVirtWindow); // font color doesn't matter here pVirtWindow->SetFont(aDefFont); nWindowWidth = pVirtWindow->GetTextWidth(aTestString); - nWindowWidth = (long) ( nWindowWidth / ScGlobal::nScreenPPTX * HMM_PER_TWIPS ); + nWindowWidth = static_cast<long>( nWindowWidth / ScGlobal::nScreenPPTX * HMM_PER_TWIPS ); if (nPrinterWidth && nWindowWidth) - nPrtToScreenFactor = nPrinterWidth / (double) nWindowWidth; + nPrtToScreenFactor = nPrinterWidth / static_cast<double>(nWindowWidth); else { OSL_FAIL("GetTextSize returns 0 ??"); diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 98b8d998d22e..9534919842b7 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1528,7 +1528,7 @@ bool ScDocShell::AdjustPrintZoom( const ScRange& rRange ) long nBlkTwipsX = 0; if (bHeaders) - nBlkTwipsX += (long) PRINT_HEADER_WIDTH; + nBlkTwipsX += long(PRINT_HEADER_WIDTH); SCCOL nStartCol = rRange.aStart.Col(); SCCOL nEndCol = rRange.aEnd.Col(); if ( pRepeatCol && nStartCol >= pRepeatCol->aStart.Col() ) @@ -1546,7 +1546,7 @@ bool ScDocShell::AdjustPrintZoom( const ScRange& rRange ) long nBlkTwipsY = 0; if (bHeaders) - nBlkTwipsY += (long) PRINT_HEADER_HEIGHT; + nBlkTwipsY += long(PRINT_HEADER_HEIGHT); SCROW nStartRow = rRange.aStart.Row(); SCROW nEndRow = rRange.aEnd.Row(); if ( pRepeatRow && nStartRow >= pRepeatRow->aStart.Row() ) @@ -1573,8 +1573,8 @@ bool ScDocShell::AdjustPrintZoom( const ScRange& rRange ) aPhysPage.Height() * 100 / nBlkTwipsY ); if ( nNeeded < ZOOM_MIN ) nNeeded = ZOOM_MIN; // boundary - if ( nNeeded < (long) nNewScale ) - nNewScale = (sal_uInt16) nNeeded; + if ( nNeeded < static_cast<long>(nNewScale) ) + nNewScale = static_cast<sal_uInt16>(nNeeded); bChange = ( nNewScale != nOldScale || nOldPages != 0 ); if ( bChange ) @@ -2078,7 +2078,7 @@ namespace { void SnapHor( const ScDocument& rDoc, SCTAB nTab, long& rVal, SCCOL& rStartCol ) { SCCOL nCol = 0; - long nTwips = (long) (rVal / HMM_PER_TWIPS); + long nTwips = static_cast<long>(rVal / HMM_PER_TWIPS); long nSnap = 0; while ( nCol<MAXCOL ) { @@ -2091,14 +2091,14 @@ void SnapHor( const ScDocument& rDoc, SCTAB nTab, long& rVal, SCCOL& rStartCol ) else break; } - rVal = (long) ( nSnap * HMM_PER_TWIPS ); + rVal = static_cast<long>( nSnap * HMM_PER_TWIPS ); rStartCol = nCol; } void SnapVer( const ScDocument& rDoc, SCTAB nTab, long& rVal, SCROW& rStartRow ) { SCROW nRow = 0; - long nTwips = (long) (rVal / HMM_PER_TWIPS); + long nTwips = static_cast<long>(rVal / HMM_PER_TWIPS); long nSnap = 0; bool bFound = false; @@ -2127,7 +2127,7 @@ void SnapVer( const ScDocument& rDoc, SCTAB nTab, long& rVal, SCROW& rStartRow ) if (!bFound) nRow = MAXROW; // all hidden down to the bottom - rVal = (long) ( nSnap * HMM_PER_TWIPS ); + rVal = static_cast<long>( nSnap * HMM_PER_TWIPS ); rStartRow = nRow; } diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx index 6b611373cd05..f14c8bd8f8b7 100644 --- a/sc/source/ui/docshell/docsh6.cxx +++ b/sc/source/ui/docshell/docsh6.cxx @@ -85,15 +85,15 @@ void ScDocShell::SetVisAreaOrSize( const tools::Rectangle& rVisArea ) // Move the VisArea, otherwise only the upper left position would // be changed in SnapVisArea, and the size would be wrong. - Point aNewPos( 0, std::max( aArea.Top(), (long) 0 ) ); + Point aNewPos( 0, std::max( aArea.Top(), long(0) ) ); if ( bNegativePage ) { - aNewPos.X() = std::min( aArea.Right(), (long) 0 ); + aNewPos.X() = std::min( aArea.Right(), long(0) ); lcl_SetTopRight( aArea, aNewPos ); } else { - aNewPos.X() = std::max( aArea.Left(), (long) 0 ); + aNewPos.X() = std::max( aArea.Left(), long(0) ); aArea.SetPos( aNewPos ); } } diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index f24ccce4dfcb..2d9bc93ccddc 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -893,7 +893,7 @@ ErrCode ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncoding xRowProp->setPropertyValue( SC_DBPROP_ACTIVECONNECTION, uno::Any(xConnection) ); - xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, uno::Any((sal_Int32) sdb::CommandType::TABLE) ); + xRowProp->setPropertyValue( SC_DBPROP_COMMANDTYPE, uno::Any(sal_Int32(sdb::CommandType::TABLE)) ); xRowProp->setPropertyValue( SC_DBPROP_COMMAND, uno::Any(aTabName) ); diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 175f3a6b3a07..12f914b2473d 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1083,10 +1083,10 @@ static bool lcl_PutString( { using namespace ::com::sun::star; bool bSecondCal = false; - sal_uInt16 nDay = (sal_uInt16) rStr.copy( nStart[nDP], nEnd[nDP]+1-nStart[nDP] ).toInt32(); - sal_uInt16 nYear = (sal_uInt16) rStr.copy( nStart[nYP], nEnd[nYP]+1-nStart[nYP] ).toInt32(); + sal_uInt16 nDay = static_cast<sal_uInt16>(rStr.copy( nStart[nDP], nEnd[nDP]+1-nStart[nDP] ).toInt32()); + sal_uInt16 nYear = static_cast<sal_uInt16>(rStr.copy( nStart[nYP], nEnd[nYP]+1-nStart[nYP] ).toInt32()); OUString aMStr = rStr.copy( nStart[nMP], nEnd[nMP]+1-nStart[nMP] ); - sal_Int16 nMonth = (sal_Int16) aMStr.toInt32(); + sal_Int16 nMonth = static_cast<sal_Int16>(aMStr.toInt32()); if (!nMonth) { static const char aSepShortened[] = "SEP"; @@ -1149,11 +1149,11 @@ static bool lcl_PutString( // time fields to zero (ICU calendar instance defaults to current date/time) nHour = nMinute = nSecond = nMilli = 0; if (nFound > 3) - nHour = (sal_Int16) rStr.copy( nStart[3], nEnd[3]+1-nStart[3]).toInt32(); + nHour = static_cast<sal_Int16>(rStr.copy( nStart[3], nEnd[3]+1-nStart[3]).toInt32()); if (nFound > 4) - nMinute = (sal_Int16) rStr.copy( nStart[4], nEnd[4]+1-nStart[4]).toInt32(); + nMinute = static_cast<sal_Int16>(rStr.copy( nStart[4], nEnd[4]+1-nStart[4]).toInt32()); if (nFound > 5) - nSecond = (sal_Int16) rStr.copy( nStart[5], nEnd[5]+1-nStart[5]).toInt32(); + nSecond = static_cast<sal_Int16>(rStr.copy( nStart[5], nEnd[5]+1-nStart[5]).toInt32()); if (nFound > 6) { sal_Unicode cDec = '.'; @@ -1162,7 +1162,7 @@ static bool lcl_PutString( rtl_math_ConversionStatus eStatus; double fV = rtl::math::stringToDouble( aT, cDec, 0, &eStatus ); if (eStatus == rtl_math_ConversionStatus_Ok) - nMilli = (sal_Int16) (1000.0 * fV + 0.5); + nMilli = static_cast<sal_Int16>(1000.0 * fV + 0.5); } pCalendar->setValue( i18n::CalendarFieldIndex::HOUR, nHour ); pCalendar->setValue( i18n::CalendarFieldIndex::MINUTE, nMinute ); @@ -1975,7 +1975,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm ) if( nCol > nEndCol ) nEndCol = nCol; } - if ( 0 <= nFormat && nFormat < (sal_Int32)aFormats.size() && !bInvalidCol && !bInvalidRow ) + if ( 0 <= nFormat && nFormat < static_cast<sal_Int32>(aFormats.size()) && !bInvalidCol && !bInvalidRow ) { sal_uInt32 nKey = aFormats[nFormat]; pDoc->ApplyAttr( nCol, nRow, aRange.aStart.Tab(), diff --git a/sc/source/ui/docshell/pagedata.cxx b/sc/source/ui/docshell/pagedata.cxx index 0b185a6e93af..eadfc8c81614 100644 --- a/sc/source/ui/docshell/pagedata.cxx +++ b/sc/source/ui/docshell/pagedata.cxx @@ -91,7 +91,7 @@ void ScPageBreakData::AddPages() long nPage = pData[0].GetFirstPage(); for (size_t i=0; i+1<nUsed; i++) { - nPage += ((long)pData[i].GetPagesX())*pData[i].GetPagesY(); + nPage += static_cast<long>(pData[i].GetPagesX())*pData[i].GetPagesY(); pData[i+1].SetFirstPage( nPage ); } } diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx index 95122e1c9e0d..b42df285c509 100644 --- a/sc/source/ui/drawfunc/drawsh5.cxx +++ b/sc/source/ui/drawfunc/drawsh5.cxx @@ -221,7 +221,7 @@ void ScDrawShell::ExecuteHLink( const SfxRequest& rReq ) if (!bDone) pViewData->GetViewShell()-> - InsertURL( rName, rURL, rTarget, (sal_uInt16) eMode ); + InsertURL( rName, rURL, rTarget, static_cast<sal_uInt16>(eMode) ); // If "text" is received by InsertURL of ViewShell, then the DrawShell is turned off !!! } diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx index f7f99bc6bd56..36cecff0384a 100644 --- a/sc/source/ui/drawfunc/fuins1.cxx +++ b/sc/source/ui/drawfunc/fuins1.cxx @@ -61,18 +61,18 @@ void ScLimitSizeOnDrawPage( Size& rSize, Point& rPos, const Size& rPage ) if ( rSize.Width() > aPageSize.Width() || rSize.Height() > aPageSize.Height() ) { - double fX = aPageSize.Width() / (double) rSize.Width(); - double fY = aPageSize.Height() / (double) rSize.Height(); + double fX = aPageSize.Width() / static_cast<double>(rSize.Width()); + double fY = aPageSize.Height() / static_cast<double>(rSize.Height()); if ( fX < fY ) { rSize.Width() = aPageSize.Width(); - rSize.Height() = (long) ( rSize.Height() * fX ); + rSize.Height() = static_cast<long>( rSize.Height() * fX ); } else { rSize.Height() = aPageSize.Height(); - rSize.Width() = (long) ( rSize.Width() * fY ); + rSize.Width() = static_cast<long>( rSize.Width() * fY ); } if (!rSize.Width()) diff --git a/sc/source/ui/drawfunc/fupoor.cxx b/sc/source/ui/drawfunc/fupoor.cxx index 4422c944da9a..401c5993463e 100644 --- a/sc/source/ui/drawfunc/fupoor.cxx +++ b/sc/source/ui/drawfunc/fupoor.cxx @@ -203,8 +203,8 @@ bool FuPoor::IsDetectiveHit( const Point& rLogicPos ) { if (ScDetectiveFunc::IsNonAlienArrow( pObject )) { - sal_uInt16 nHitLog = (sal_uInt16) pWindow->PixelToLogic( - Size(pView->GetHitTolerancePixel(),0)).Width(); + sal_uInt16 nHitLog = static_cast<sal_uInt16>(pWindow->PixelToLogic( + Size(pView->GetHitTolerancePixel(),0)).Width()); if(SdrObjectPrimitiveHit(*pObject, rLogicPos, nHitLog, *pPV, nullptr, false)) { bFound = true; diff --git a/sc/source/ui/drawfunc/fusel2.cxx b/sc/source/ui/drawfunc/fusel2.cxx index 4c3318a50ebf..6fc497ab8f0b 100644 --- a/sc/source/ui/drawfunc/fusel2.cxx +++ b/sc/source/ui/drawfunc/fusel2.cxx @@ -58,8 +58,8 @@ bool FuSelection::TestDetective( const SdrPageView* pPV, const Point& rPos ) { if (ScDetectiveFunc::IsNonAlienArrow( pObject )) { - sal_uInt16 nHitLog = (sal_uInt16) pWindow->PixelToLogic( - Size(pView->GetHitTolerancePixel(),0)).Width(); + sal_uInt16 nHitLog = static_cast<sal_uInt16>(pWindow->PixelToLogic( + Size(pView->GetHitTolerancePixel(),0)).Width()); if (SdrObjectPrimitiveHit(*pObject, rPos, nHitLog, *pPV, nullptr, false)) { ScViewData& rViewData = pViewShell->GetViewData(); diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx index f95b6465e07d..38583597b9d2 100644 --- a/sc/source/ui/drawfunc/futext.cxx +++ b/sc/source/ui/drawfunc/futext.cxx @@ -417,7 +417,7 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt) aItemSet.Put( SdrTextAniDirectionItem( SdrTextAniDirection::Left ) ); aItemSet.Put( SdrTextAniCountItem( 1 ) ); aItemSet.Put( SdrTextAniAmountItem( - (sal_Int16)pWindow->PixelToLogic(Size(2,1)).Width()) ); + static_cast<sal_Int16>(pWindow->PixelToLogic(Size(2,1)).Width())) ); pObj->SetMergedItemSetAndBroadcast(aItemSet); } } @@ -683,7 +683,7 @@ SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectan aSet.Put( SdrTextAniKindItem( SdrTextAniKind::Slide ) ); aSet.Put( SdrTextAniDirectionItem( SdrTextAniDirection::Left ) ); aSet.Put( SdrTextAniCountItem( 1 ) ); - aSet.Put( SdrTextAniAmountItem( (sal_Int16)pWindow->PixelToLogic(Size(2,1)).Width()) ); + aSet.Put( SdrTextAniAmountItem( static_cast<sal_Int16>(pWindow->PixelToLogic(Size(2,1)).Width())) ); pObj->SetMergedItemSetAndBroadcast(aSet); } diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index 6c52eb700b4b..1856d0ef4f0c 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -175,7 +175,7 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, pData->SetFStart( 1 ); // after "=" } - pData->SetMode( (sal_uInt16) eMode ); + pData->SetMode( static_cast<sal_uInt16>(eMode) ); OUString rStrExp = GetMeText(); Update(rStrExp); diff --git a/sc/source/ui/inc/navipi.hxx b/sc/source/ui/inc/navipi.hxx index 95ad856bea39..dc62b5080d9f 100644 --- a/sc/source/ui/inc/navipi.hxx +++ b/sc/source/ui/inc/navipi.hxx @@ -148,7 +148,7 @@ public: { xDlg = pNaviDlg; } - SCROW GetRow() { return (SCROW)GetValue(); } + SCROW GetRow() { return static_cast<SCROW>(GetValue()); } void SetRow(SCROW nRow) { SetValue(nRow); } protected: diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index a87f3dbe6f11..26f372a33767 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -602,7 +602,7 @@ public: inline long ScViewData::ToPixel( sal_uInt16 nTwips, double nFactor ) { - long nRet = (long)( nTwips * nFactor ); + long nRet = static_cast<long>( nTwips * nFactor ); if ( !nRet && nTwips ) nRet = 1; return nRet; diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx index 660f38b1d584..c1edb5cc8082 100644 --- a/sc/source/ui/miscdlgs/acredlin.cxx +++ b/sc/source/ui/miscdlgs/acredlin.cxx @@ -1748,13 +1748,13 @@ void ScAcceptChgDlg::Initialize(SfxChildWinInfo *pInfo) if ( !aStr.isEmpty()) { - sal_uInt16 nCount=(sal_uInt16)aStr.toInt32(); + sal_uInt16 nCount=static_cast<sal_uInt16>(aStr.toInt32()); for(sal_uInt16 i=0;i<nCount;i++) { sal_Int32 n1 = aStr.indexOf(';'); aStr = aStr.copy( n1+1 ); - pTheView->SetTab(i, (sal_uInt16)aStr.toInt32(), MapUnit::MapPixel); + pTheView->SetTab(i, static_cast<sal_uInt16>(aStr.toInt32()), MapUnit::MapPixel); } } } diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx index e5276b3f8803..a6ffdfe75389 100644 --- a/sc/source/ui/miscdlgs/autofmt.cxx +++ b/sc/source/ui/miscdlgs/autofmt.cxx @@ -308,7 +308,7 @@ void ScAutoFmtPreview::DrawString(vcl::RenderContext& rRenderContext, size_t nCo // vertical (always center): - aPos.Y() += (mnRowHeight - (sal_uInt16)aStrSize.Height()) / 2; + aPos.Y() += (mnRowHeight - static_cast<sal_uInt16>(aStrSize.Height())) / 2; // horizontal diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx index 24087e0bbd95..1931a73b5cc8 100644 --- a/sc/source/ui/miscdlgs/crnrdlg.cxx +++ b/sc/source/ui/miscdlgs/crnrdlg.cxx @@ -766,7 +766,7 @@ IMPL_LINK_NOARG(ScColRowNameRangesDlg, ColClickHdl, Button*, void) pEdAssign->SetText( aStr ); } ScRange aRange( theCurData ); - aRange.aStart.SetRow( std::min( (long)(theCurArea.aEnd.Row() + 1), (long)MAXROW ) ); + aRange.aStart.SetRow( std::min( static_cast<long>(theCurArea.aEnd.Row() + 1), long(MAXROW) ) ); aRange.aEnd.SetRow( MAXROW ); AdjustColRowData( aRange ); } @@ -786,7 +786,7 @@ IMPL_LINK_NOARG(ScColRowNameRangesDlg, RowClickHdl, Button*, void) pEdAssign->SetText( aStr ); } ScRange aRange( theCurData ); - aRange.aStart.SetCol( static_cast<SCCOL>(std::min( (long)(theCurArea.aEnd.Col() + 1), (long)MAXCOL )) ); + aRange.aStart.SetCol( static_cast<SCCOL>(std::min( static_cast<long>(theCurArea.aEnd.Col() + 1), long(MAXCOL) )) ); aRange.aEnd.SetCol( MAXCOL ); AdjustColRowData( aRange ); } diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx index 7c753326be82..89594f57ab5b 100644 --- a/sc/source/ui/miscdlgs/optsolver.cxx +++ b/sc/source/ui/miscdlgs/optsolver.cxx @@ -459,10 +459,10 @@ void ScOptSolverDlg::ReadConditions() aRowEntry.nOperator = mpOperator[nRow]->GetSelectedEntryPos(); long nVecPos = nScrollPos + nRow; - if ( nVecPos >= (long)maConditions.size() && !aRowEntry.IsDefault() ) + if ( nVecPos >= static_cast<long>(maConditions.size()) && !aRowEntry.IsDefault() ) maConditions.resize( nVecPos + 1 ); - if ( nVecPos < (long)maConditions.size() ) + if ( nVecPos < static_cast<long>(maConditions.size()) ) maConditions[nVecPos] = aRowEntry; // remove default entries at the end @@ -480,7 +480,7 @@ void ScOptSolverDlg::ShowConditions() ScOptConditionRow aRowEntry; long nVecPos = nScrollPos + nRow; - if ( nVecPos < (long)maConditions.size() ) + if ( nVecPos < static_cast<long>(maConditions.size()) ) aRowEntry = maConditions[nVecPos]; mpLeftEdit[nRow]->SetRefString( aRowEntry.aLeftStr ); @@ -490,7 +490,7 @@ void ScOptSolverDlg::ShowConditions() // allow to scroll one page behind the visible or stored rows long nVisible = nScrollPos + EDIT_ROW_COUNT; - long nMax = std::max( nVisible, (long) maConditions.size() ); + long nMax = std::max( nVisible, static_cast<long>(maConditions.size()) ); m_pScrollBar->SetRange( Range( 0, nMax + EDIT_ROW_COUNT ) ); m_pScrollBar->SetThumbPos( nScrollPos ); @@ -502,7 +502,7 @@ void ScOptSolverDlg::EnableButtons() for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow ) { long nVecPos = nScrollPos + nRow; - mpDelButton[nRow]->Enable( nVecPos < (long)maConditions.size() ); + mpDelButton[nRow]->Enable( nVecPos < static_cast<long>(maConditions.size()) ); } } @@ -667,7 +667,7 @@ IMPL_LINK( ScOptSolverDlg, DelBtnHdl, Button*, pBtn, void ) ReadConditions(); long nVecPos = nScrollPos + nRow; - if ( nVecPos < (long)maConditions.size() ) + if ( nVecPos < static_cast<long>(maConditions.size()) ) { maConditions.erase( maConditions.begin() + nVecPos ); ShowConditions(); diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx b/sc/source/ui/miscdlgs/solveroptions.cxx index 59f00ed46851..d9e8ef4bdce6 100644 --- a/sc/source/ui/miscdlgs/solveroptions.cxx +++ b/sc/source/ui/miscdlgs/solveroptions.cxx @@ -184,7 +184,7 @@ const uno::Sequence<beans::PropertyValue>& ScSolverOptionsDialog::GetProperties( // order of entries in list box and maProperties is the same sal_Int32 nEntryCount = maProperties.getLength(); SvTreeList* pModel = m_pLbSettings->GetModel(); - if ( nEntryCount == (sal_Int32)pModel->GetEntryCount() ) + if ( nEntryCount == static_cast<sal_Int32>(pModel->GetEntryCount()) ) { for (sal_Int32 nEntryPos=0; nEntryPos<nEntryCount; ++nEntryPos) { @@ -428,7 +428,7 @@ sal_Int32 ScSolverIntegerDialog::GetValue() const return SAL_MIN_INT32; if ( nValue > SAL_MAX_INT32 ) return SAL_MAX_INT32; - return (sal_Int32) nValue; + return static_cast<sal_Int32>(nValue); } ScSolverValueDialog::ScSolverValueDialog( vcl::Window * pParent ) diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx index e84c61e056dc..a9e650230473 100644 --- a/sc/source/ui/navipi/navipi.cxx +++ b/sc/source/ui/navipi/navipi.cxx @@ -233,7 +233,7 @@ SCCOL ColumnEdit::NumStrToAlpha( OUString& rStr ) SCCOL nColumn = 0; if ( CharClass::isAsciiNumeric(rStr) ) - nColumn = NumToAlpha( (SCCOL)rStr.toInt32(), rStr ); + nColumn = NumToAlpha( static_cast<SCCOL>(rStr.toInt32()), rStr ); else rStr.clear(); @@ -304,7 +304,7 @@ Size RowEdit::GetOptimalSize() const void RowEdit::ExecuteRow() { SCCOL nCol = xDlg->aEdCol->GetCol(); - SCROW nRow = (SCROW)GetValue(); + SCROW nRow = static_cast<SCROW>(GetValue()); if ( (nCol > 0) && (nRow > 0) ) xDlg->SetCurrentCell(nCol - 1, nRow - 1); @@ -923,7 +923,7 @@ void ScNavigatorDlg::SetListMode(NavListMode eMode) if (eMode != NAV_LMODE_NONE) { ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg(); - rCfg.SetListMode( (sal_uInt16) eMode ); + rCfg.SetListMode( static_cast<sal_uInt16>(eMode) ); } if (pNav) diff --git a/sc/source/ui/optdlg/tpcalc.cxx b/sc/source/ui/optdlg/tpcalc.cxx index 4ec601a23ac6..4a2e0a4e1a4a 100644 --- a/sc/source/ui/optdlg/tpcalc.cxx +++ b/sc/source/ui/optdlg/tpcalc.cxx @@ -192,7 +192,7 @@ void ScTpCalcOptions::Reset( const SfxItemSet* /* rCoreAttrs */ ) bool ScTpCalcOptions::FillItemSet( SfxItemSet* rCoreAttrs ) { // every other options are updated in handlers - pLocalOptions->SetIterCount( (sal_uInt16)m_pEdSteps->GetValue() ); + pLocalOptions->SetIterCount( static_cast<sal_uInt16>(m_pEdSteps->GetValue()) ); pLocalOptions->SetIgnoreCase( !m_pBtnCase->IsChecked() ); pLocalOptions->SetCalcAsShown( m_pBtnCalc->IsChecked() ); pLocalOptions->SetMatchWholeCell( m_pBtnMatch->IsChecked() ); diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx index 14bd0695589d..0bd80b7f62db 100644 --- a/sc/source/ui/optdlg/tpformula.cxx +++ b/sc/source/ui/optdlg/tpformula.cxx @@ -116,7 +116,7 @@ void ScTpFormulaOptions::OnFocusSeparatorInput(Edit* pEdit) // Make sure the entire text is selected. sal_Int32 nLen = pEdit->GetText().getLength(); - Selection aSel(0, (sal_uInt16)nLen); + Selection aSel(0, static_cast<sal_uInt16>(nLen)); pEdit->SetSelection(aSel); maOldSepValue = pEdit->GetText(); } diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx index 195259b2fd00..e9d4a1006693 100644 --- a/sc/source/ui/optdlg/tpview.cxx +++ b/sc/source/ui/optdlg/tpview.cxx @@ -188,9 +188,9 @@ void ScTpContentOptions::Reset( const SfxItemSet* rCoreSet ) pAnchorCB ->Check(pLocalOptions->GetOption(VOPT_ANCHOR)); pClipMarkCB->Check(pLocalOptions->GetOption(VOPT_CLIPMARKS)); - pObjGrfLB ->SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_OLE) ); - pDiagramLB ->SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_CHART) ); - pDrawLB ->SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_DRAW) ); + pObjGrfLB ->SelectEntryPos( static_cast<sal_uInt16>(pLocalOptions->GetObjMode(VOBJ_TYPE_OLE)) ); + pDiagramLB ->SelectEntryPos( static_cast<sal_uInt16>(pLocalOptions->GetObjMode(VOBJ_TYPE_CHART)) ); + pDrawLB ->SelectEntryPos( static_cast<sal_uInt16>(pLocalOptions->GetObjMode(VOBJ_TYPE_DRAW)) ); pRowColHeaderCB->Check( pLocalOptions->GetOption(VOPT_HEADER) ); pHScrollCB->Check( pLocalOptions->GetOption(VOPT_HSCROLL) ); @@ -372,7 +372,7 @@ ScTpLayoutOptions::ScTpLayoutOptions( vcl::Window* pParent, { // only use these metrics sal_Int32 nPos = m_pUnitLB->InsertEntry( sMetric ); - m_pUnitLB->SetEntryData( nPos, reinterpret_cast<void*>((sal_IntPtr)eFUnit) ); + m_pUnitLB->SetEntryData( nPos, reinterpret_cast<void*>(static_cast<sal_IntPtr>(eFUnit)) ); } break; default: @@ -426,7 +426,7 @@ bool ScTpLayoutOptions::FillItemSet( SfxItemSet* rCoreSet ) const sal_Int32 nMPos = m_pUnitLB->GetSelectedEntryPos(); if ( m_pUnitLB->IsValueChangedFromSaved() ) { - sal_uInt16 nFieldUnit = (sal_uInt16)reinterpret_cast<sal_IntPtr>(m_pUnitLB->GetEntryData( nMPos )); + sal_uInt16 nFieldUnit = static_cast<sal_uInt16>(reinterpret_cast<sal_IntPtr>(m_pUnitLB->GetEntryData( nMPos ))); rCoreSet->Put( SfxUInt16Item( SID_ATTR_METRIC, nFieldUnit ) ); bRet = true; } diff --git a/sc/source/ui/pagedlg/tptable.cxx b/sc/source/ui/pagedlg/tptable.cxx index 0c9c80f8d141..43a938b2c33b 100644 --- a/sc/source/ui/pagedlg/tptable.cxx +++ b/sc/source/ui/pagedlg/tptable.cxx @@ -327,7 +327,7 @@ bool ScTablePage::FillItemSet( SfxItemSet* rCoreSet ) } else { - sal_uInt16 nPage = (sal_uInt16)( m_pBtnPageNo->IsChecked() + sal_uInt16 nPage = static_cast<sal_uInt16>( m_pBtnPageNo->IsChecked() ? m_pEdPageNo->GetValue() : 0 ); @@ -355,7 +355,7 @@ bool ScTablePage::FillItemSet( SfxItemSet* rCoreSet ) bDataChanged |= lcl_PutScaleItem( GetWhich(SID_SCATTR_PAGE_SCALE), *rCoreSet, rOldSet, *m_pLbScaleMode, SC_TPTABLE_SCALE_PERCENT, - *m_pEdScaleAll, (sal_uInt16)m_pEdScaleAll->GetValue() ); + *m_pEdScaleAll, static_cast<sal_uInt16>(m_pEdScaleAll->GetValue()) ); bDataChanged |= lcl_PutScaleItem2( GetWhich(SID_SCATTR_PAGE_SCALETO), *rCoreSet, rOldSet, @@ -366,7 +366,7 @@ bool ScTablePage::FillItemSet( SfxItemSet* rCoreSet ) bDataChanged |= lcl_PutScaleItem( GetWhich(SID_SCATTR_PAGE_SCALETOPAGES), *rCoreSet, rOldSet, *m_pLbScaleMode, SC_TPTABLE_SCALE_TO_PAGES, - *m_pEdScalePageNum, (sal_uInt16)m_pEdScalePageNum->GetValue() ); + *m_pEdScalePageNum, static_cast<sal_uInt16>(m_pEdScalePageNum->GetValue()) ); return bDataChanged; } diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx index cdb79078bb79..318aa838b891 100644 --- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx +++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx @@ -177,8 +177,8 @@ IMPL_LINK_NOARG( AlignmentPropertyPanel, AngleModifiedHdl, Edit&, void ) FormatDegrees(fTmp); - sal_Int64 nTmp = (sal_Int64)fTmp*100; - SfxInt32Item aAngleItem( SID_ATTR_ALIGN_DEGREES,(sal_uInt32) nTmp); + sal_Int64 nTmp = static_cast<sal_Int64>(fTmp)*100; + SfxInt32Item aAngleItem( SID_ATTR_ALIGN_DEGREES,static_cast<sal_uInt32>(nTmp)); GetBindings()->GetDispatcher()->ExecuteList( SID_ATTR_ALIGN_DEGREES, SfxCallMode::RECORD, { &aAngleItem }); @@ -193,8 +193,8 @@ IMPL_LINK_NOARG( AlignmentPropertyPanel, ClickStackHdl, Button*, void ) IMPL_LINK_NOARG(AlignmentPropertyPanel, MFLeftIndentMdyHdl, Edit&, void) { mpCBXWrapText->EnableTriState(false); - sal_uInt16 nVal = (sal_uInt16)mpMFLeftIndent->GetValue(); - SfxUInt16Item aItem( SID_ATTR_ALIGN_INDENT, (sal_uInt16)CalcToUnit( nVal, MapUnit::MapTwip ) ); + sal_uInt16 nVal = static_cast<sal_uInt16>(mpMFLeftIndent->GetValue()); + SfxUInt16Item aItem( SID_ATTR_ALIGN_INDENT, static_cast<sal_uInt16>(CalcToUnit( nVal, MapUnit::MapTwip )) ); GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_ALIGN_INDENT, SfxCallMode::RECORD, { &aItem }); diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx index a0c9eb940f8f..e56ade71b0d5 100644 --- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx @@ -128,13 +128,13 @@ IMPL_LINK_NOARG( NumberFormatPropertyPanel, NumFormatValueHdl, Edit&, void ) || ( mpBtnEngineering->IsVisible() && mpBtnEngineering->IsEnabled() && mpBtnEngineering->IsChecked() ); bool bNegRed = mpBtnNegRed->IsEnabled() && mpBtnNegRed->IsChecked(); sal_uInt16 nPrecision = (mpEdDecimals->IsEnabled() && mpEdDecimals->IsVisible()) - ? (sal_uInt16)mpEdDecimals->GetValue() + ? static_cast<sal_uInt16>(mpEdDecimals->GetValue()) : (mpEdDenominator->IsEnabled() && mpEdDenominator->IsVisible()) - ? (sal_uInt16)mpEdDenominator->GetValue() - : (sal_uInt16)0; + ? static_cast<sal_uInt16>(mpEdDenominator->GetValue()) + : sal_uInt16(0); sal_uInt16 nLeadZeroes = (mpEdLeadZeroes->IsEnabled()) - ? (sal_uInt16)mpEdLeadZeroes->GetValue() - : (sal_uInt16)0; + ? static_cast<sal_uInt16>(mpEdLeadZeroes->GetValue()) + : sal_uInt16(0); OUString sThousand = OUString::number(static_cast<sal_Int32>(bThousand)); OUString sNegRed = OUString::number(static_cast<sal_Int32>(bNegRed)); diff --git a/sc/source/ui/styleui/styledlg.cxx b/sc/source/ui/styleui/styledlg.cxx index 328b015f5d5f..e68b412fcaa2 100644 --- a/sc/source/ui/styleui/styledlg.cxx +++ b/sc/source/ui/styleui/styledlg.cxx @@ -151,7 +151,7 @@ void ScStyleDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); if (nPageId == m_nPageId) { - aSet.Put (SfxAllEnumItem((sal_uInt16)SID_ENUM_PAGE_MODE, SVX_PAGE_MODE_CENTER)); + aSet.Put (SfxAllEnumItem(sal_uInt16(SID_ENUM_PAGE_MODE), SVX_PAGE_MODE_CENTER)); rTabPage.PageCreated(aSet); } else if (nPageId == m_nHeaderId || nPageId == m_nFooterId) diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 13314009be56..972b8d76032f 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -875,7 +875,7 @@ ScUndoDetective::ScUndoDetective( ScDocShell* pNewDocShell, bIsDelete = ( pOperation == nullptr ); if (!bIsDelete) { - nAction = (sal_uInt16) pOperation->GetOperation(); + nAction = static_cast<sal_uInt16>(pOperation->GetOperation()); aPos = pOperation->GetPos(); } } diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index db0c34d0568c..290457ce4f87 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -277,7 +277,7 @@ void ScUndoDeleteTab::SetChangeTrack() aRange.aStart.SetTab( theTabs[i] ); aRange.aEnd.SetTab( theTabs[i] ); pChangeTrack->AppendDeleteRange( aRange, pRefUndoDoc, - nTmpChangeAction, nEndChangeAction, (short) i ); + nTmpChangeAction, nEndChangeAction, static_cast<short>(i) ); } } else diff --git a/sc/source/ui/unoobj/afmtuno.cxx b/sc/source/ui/unoobj/afmtuno.cxx index 4adf5aa937ec..cd7dd861c9ed 100644 --- a/sc/source/ui/unoobj/afmtuno.cxx +++ b/sc/source/ui/unoobj/afmtuno.cxx @@ -295,7 +295,7 @@ sal_Int32 SAL_CALL ScAutoFormatsObj::getCount() uno::Any SAL_CALL ScAutoFormatsObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; - uno::Reference< container::XNamed > xFormat(GetObjectByIndex_Impl((sal_uInt16)nIndex)); + uno::Reference< container::XNamed > xFormat(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex))); if (!xFormat.is()) throw lang::IndexOutOfBoundsException(); return uno::makeAny(xFormat); @@ -443,7 +443,7 @@ uno::Any SAL_CALL ScAutoFormatObj::getByIndex( sal_Int32 nIndex ) throw lang::IndexOutOfBoundsException(); if (IsInserted()) - return uno::makeAny(uno::Reference< beans::XPropertySet >(GetObjectByIndex_Impl((sal_uInt16)nIndex))); + return uno::makeAny(uno::Reference< beans::XPropertySet >(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex)))); return uno::Any(); } diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx index 2f94542b7875..ead9147989e5 100644 --- a/sc/source/ui/unoobj/appluno.cxx +++ b/sc/source/ui/unoobj/appluno.cxx @@ -350,7 +350,7 @@ void SAL_CALL ScSpreadsheetSettings::setPropertyValue( // ScGlobal::SetUseTabCol does not do much else pUserList->clear(); - sal_uInt16 nCount = (sal_uInt16)aSeq.getLength(); + sal_uInt16 nCount = static_cast<sal_uInt16>(aSeq.getLength()); const OUString* pAry = aSeq.getConstArray(); for (sal_uInt16 i=0; i<nCount; i++) { @@ -395,16 +395,16 @@ uno::Any SAL_CALL ScSpreadsheetSettings::getPropertyValue( const OUString& aProp else if (aPropertyName == SC_UNONAME_ENTERED ) aRet <<= aInpOpt.GetEnterEdit(); else if (aPropertyName == SC_UNONAME_EXPREF ) aRet <<= aInpOpt.GetExpandRefs(); else if (aPropertyName == SC_UNONAME_EXTFMT ) aRet <<= aInpOpt.GetExtendFormat(); - else if (aPropertyName == SC_UNONAME_LINKUPD ) aRet <<= (sal_Int16) aAppOpt.GetLinkMode(); + else if (aPropertyName == SC_UNONAME_LINKUPD ) aRet <<= static_cast<sal_Int16>(aAppOpt.GetLinkMode()); else if (aPropertyName == SC_UNONAME_MARKHDR ) aRet <<= aInpOpt.GetMarkHeader(); else if (aPropertyName == SC_UNONAME_MOVESEL ) aRet <<= aInpOpt.GetMoveSelection(); else if (aPropertyName == SC_UNONAME_RANGEFIN ) aRet <<= aInpOpt.GetRangeFinder(); else if (aPropertyName == SC_UNONAME_USETABCOL ) aRet <<= aInpOpt.GetUseTabCol(); else if (aPropertyName == SC_UNONAME_PRMETRICS ) aRet <<= aInpOpt.GetTextWysiwyg(); else if (aPropertyName == SC_UNONAME_REPLWARN ) aRet <<= aInpOpt.GetReplaceCellsWarn(); - else if (aPropertyName == SC_UNONAME_METRIC ) aRet <<= (sal_Int16) aAppOpt.GetAppMetric(); - else if (aPropertyName == SC_UNONAME_MOVEDIR ) aRet <<= (sal_Int16) aInpOpt.GetMoveDir(); - else if (aPropertyName == SC_UNONAME_STBFUNC ) aRet <<= (sal_Int16) aAppOpt.GetStatusFunc(); + else if (aPropertyName == SC_UNONAME_METRIC ) aRet <<= static_cast<sal_Int16>(aAppOpt.GetAppMetric()); + else if (aPropertyName == SC_UNONAME_MOVEDIR ) aRet <<= static_cast<sal_Int16>(aInpOpt.GetMoveDir()); + else if (aPropertyName == SC_UNONAME_STBFUNC ) aRet <<= static_cast<sal_Int16>(aAppOpt.GetStatusFunc()); else if (aPropertyName == SC_UNONAME_SCALE ) { sal_Int16 nZoomVal = 0; @@ -486,12 +486,12 @@ void SAL_CALL ScRecentFunctionsObj::setRecentFunctionIds( const uno::Sequence<sal_Int32>& aRecentFunctionIds ) { SolarMutexGuard aGuard; - sal_uInt16 nCount = (sal_uInt16) std::min( aRecentFunctionIds.getLength(), (sal_Int32) LRU_MAX ); + sal_uInt16 nCount = static_cast<sal_uInt16>(std::min( aRecentFunctionIds.getLength(), sal_Int32(LRU_MAX) )); const sal_Int32* pAry = aRecentFunctionIds.getConstArray(); std::unique_ptr<sal_uInt16[]> pFuncs(nCount ? new sal_uInt16[nCount] : nullptr); for (sal_uInt16 i=0; i<nCount; i++) - pFuncs[i] = (sal_uInt16)pAry[i]; //! check for valid values? + pFuncs[i] = static_cast<sal_uInt16>(pAry[i]); //! check for valid values? ScModule* pScMod = SC_MOD(); ScAppOptions aNewOpts(pScMod->GetAppOptions()); @@ -529,10 +529,10 @@ static void lcl_FillSequence( uno::Sequence<beans::PropertyValue>& rSequence, co beans::PropertyValue* pArray = rSequence.getArray(); pArray[0].Name = SC_UNONAME_ID; - pArray[0].Value <<= (sal_Int32) rDesc.nFIndex; + pArray[0].Value <<= static_cast<sal_Int32>(rDesc.nFIndex); pArray[1].Name = SC_UNONAME_CATEGORY; - pArray[1].Value <<= (sal_Int32) rDesc.nCategory; + pArray[1].Value <<= static_cast<sal_Int32>(rDesc.nCategory); pArray[2].Name = SC_UNONAME_NAME; if (rDesc.pFuncName) @@ -582,7 +582,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScFunctionListObj::getById( sal_Int if ( !pFuncList ) throw uno::RuntimeException(); // should not happen - sal_uInt16 nCount = (sal_uInt16)pFuncList->GetCount(); + sal_uInt16 nCount = static_cast<sal_uInt16>(pFuncList->GetCount()); for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++) { const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex); @@ -606,7 +606,7 @@ uno::Any SAL_CALL ScFunctionListObj::getByName( const OUString& aName ) if ( !pFuncList ) throw uno::RuntimeException(); // should not happen - sal_uInt16 nCount = (sal_uInt16)pFuncList->GetCount(); + sal_uInt16 nCount = static_cast<sal_uInt16>(pFuncList->GetCount()); for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++) { const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex); @@ -641,7 +641,7 @@ uno::Any SAL_CALL ScFunctionListObj::getByIndex( sal_Int32 nIndex ) if ( !pFuncList ) throw uno::RuntimeException(); // should not happen - if ( nIndex >= 0 && nIndex < (sal_Int32)pFuncList->GetCount() ) + if ( nIndex >= 0 && nIndex < static_cast<sal_Int32>(pFuncList->GetCount()) ) { const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex); if ( pDesc ) diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 995ffc1a19f7..a6c4172c0c80 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -2043,10 +2043,10 @@ uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const OUString& aPropert { case ATTR_VALUE_FORMAT: // default has no language set - aAny <<= (sal_Int32)( static_cast<const SfxUInt32Item&>(rSet.Get(pEntry->nWID)).GetValue() ); + aAny <<= static_cast<sal_Int32>( static_cast<const SfxUInt32Item&>(rSet.Get(pEntry->nWID)).GetValue() ); break; case ATTR_INDENT: - aAny <<= (sal_Int16)( TwipsToHMM(static_cast<const SfxUInt16Item&>( + aAny <<= static_cast<sal_Int16>( TwipsToHMM(static_cast<const SfxUInt16Item&>( rSet.Get(pEntry->nWID)).GetValue()) ); break; default: @@ -2154,7 +2154,7 @@ static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const if ( !(rValue >>= nIntVal) ) throw lang::IllegalArgumentException(); - sal_uLong nNewFormat = (sal_uLong)nIntVal; + sal_uLong nNewFormat = static_cast<sal_uLong>(nIntVal); rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat ); @@ -2184,7 +2184,7 @@ static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const if ( !(rValue >>= nIntVal) ) throw lang::IllegalArgumentException(); - rSet.Put( SfxUInt16Item( rEntry.nWID, (sal_uInt16)HMMToTwips(nIntVal) ) ); + rSet.Put( SfxUInt16Item( rEntry.nWID, static_cast<sal_uInt16>(HMMToTwips(nIntVal)) ) ); } break; @@ -2492,11 +2492,11 @@ void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pE pDataSet->Get( ATTR_LANGUAGE_FORMAT ).GetLanguage(); nOldFormat = rDoc.GetFormatTable()-> GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang ); - rAny <<= (sal_Int32)nOldFormat; + rAny <<= static_cast<sal_Int32>(nOldFormat); } break; case ATTR_INDENT: - rAny <<= (sal_Int16)( TwipsToHMM(static_cast<const SfxUInt16Item&>( + rAny <<= static_cast<sal_Int16>( TwipsToHMM(static_cast<const SfxUInt16Item&>( pDataSet->Get(pEntry->nWID)).GetValue()) ); break; case ATTR_STACKED: @@ -3100,7 +3100,7 @@ ScRangeListRef ScCellRangesBase::GetLimitedChartRanges_Impl( long nDataColumns, nEndRow = MAXROW; ScRangeListRef xChartRanges = new ScRangeList; - xChartRanges->Append( ScRange( 0, 0, nTab, (SCCOL)nEndColumn, (SCROW)nEndRow, nTab ) ); + xChartRanges->Append( ScRange( 0, 0, nTab, static_cast<SCCOL>(nEndColumn), static_cast<SCROW>(nEndRow), nTab ) ); return xChartRanges; } } @@ -3536,8 +3536,8 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentC { // date/time identification - sal_uLong nIndex = (sal_uLong)static_cast<const SfxUInt32Item*>(rDoc.GetAttr( - aIter.GetPos(), ATTR_VALUE_FORMAT))->GetValue(); + sal_uLong nIndex = static_cast<sal_uLong>(static_cast<const SfxUInt32Item*>(rDoc.GetAttr( + aIter.GetPos(), ATTR_VALUE_FORMAT))->GetValue()); SvNumFormatType nTyp = rDoc.GetFormatTable()->GetType(nIndex); if ((nTyp == SvNumFormatType::DATE) || (nTyp == SvNumFormatType::TIME) || (nTyp == SvNumFormatType::DATETIME)) @@ -3648,7 +3648,7 @@ uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl( ScDocument& rDoc = pDocShell->GetDocument(); ScMarkData aMarkData; - SCCOLROW nCmpPos = bColumnDiff ? (SCCOLROW)aCompare.Row : (SCCOLROW)aCompare.Column; + SCCOLROW nCmpPos = bColumnDiff ? static_cast<SCCOLROW>(aCompare.Row) : static_cast<SCCOLROW>(aCompare.Column); // first select everything, where at all something is in the comparison column // (in the second step the selection is cancelled for equal cells) @@ -3740,8 +3740,8 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryIntersec const table::CellRangeAddress& aRange ) { SolarMutexGuard aGuard; - ScRange aMask( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet, - (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet ); + ScRange aMask( static_cast<SCCOL>(aRange.StartColumn), static_cast<SCROW>(aRange.StartRow), aRange.Sheet, + static_cast<SCCOL>(aRange.EndColumn), static_cast<SCROW>(aRange.EndRow), aRange.Sheet ); ScRangeList aNew; for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i ) @@ -4825,7 +4825,7 @@ uno::Reference<table::XCell> ScCellRangeObj::GetCellByPosition_Impl( if ( nPosX <= aRange.aEnd.Col() && nPosY <= aRange.aEnd.Row() ) { - ScAddress aNew( (SCCOL)nPosX, (SCROW)nPosY, aRange.aStart.Tab() ); + ScAddress aNew( static_cast<SCCOL>(nPosX), static_cast<SCROW>(nPosY), aRange.aStart.Tab() ); return new ScCellObj( pDocSh, aNew ); } } @@ -4860,8 +4860,8 @@ uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPositio if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() && nStartY <= nEndY && nEndY <= aRange.aEnd.Row() ) { - ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, aRange.aStart.Tab(), - (SCCOL)nEndX, (SCROW)nEndY, aRange.aEnd.Tab() ); + ScRange aNew( static_cast<SCCOL>(nStartX), static_cast<SCROW>(nStartY), aRange.aStart.Tab(), + static_cast<SCCOL>(nEndX), static_cast<SCROW>(nEndY), aRange.aEnd.Tab() ); return new ScCellRangeObj( pDocSh, aNew ); } } @@ -5229,14 +5229,14 @@ void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress& { bool bError = false; ScTabOpParam aParam; - aParam.aRefFormulaCell = ScRefAddress( (SCCOL)aFormulaRange.StartColumn, - (SCROW)aFormulaRange.StartRow, aFormulaRange.Sheet ); - aParam.aRefFormulaEnd = ScRefAddress( (SCCOL)aFormulaRange.EndColumn, - (SCROW)aFormulaRange.EndRow, aFormulaRange.Sheet ); - aParam.aRefRowCell = ScRefAddress( (SCCOL)aRowCell.Column, - (SCROW)aRowCell.Row, aRowCell.Sheet ); - aParam.aRefColCell = ScRefAddress( (SCCOL)aColumnCell.Column, - (SCROW)aColumnCell.Row, aColumnCell.Sheet ); + aParam.aRefFormulaCell = ScRefAddress( static_cast<SCCOL>(aFormulaRange.StartColumn), + static_cast<SCROW>(aFormulaRange.StartRow), aFormulaRange.Sheet ); + aParam.aRefFormulaEnd = ScRefAddress( static_cast<SCCOL>(aFormulaRange.EndColumn), + static_cast<SCROW>(aFormulaRange.EndRow), aFormulaRange.Sheet ); + aParam.aRefRowCell = ScRefAddress( static_cast<SCCOL>(aRowCell.Column), + static_cast<SCROW>(aRowCell.Row), aRowCell.Sheet ); + aParam.aRefColCell = ScRefAddress( static_cast<SCCOL>(aColumnCell.Column), + static_cast<SCROW>(aColumnCell.Row), aColumnCell.Sheet ); switch (nMode) { @@ -5642,10 +5642,10 @@ uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFil aParam.bHasHeader = true; table::CellRangeAddress aDataAddress(xAddr->getRangeAddress()); - aParam.nCol1 = (SCCOL)aDataAddress.StartColumn; - aParam.nRow1 = (SCROW)aDataAddress.StartRow; - aParam.nCol2 = (SCCOL)aDataAddress.EndColumn; - aParam.nRow2 = (SCROW)aDataAddress.EndRow; + aParam.nCol1 = static_cast<SCCOL>(aDataAddress.StartColumn); + aParam.nRow1 = static_cast<SCROW>(aDataAddress.StartRow); + aParam.nCol2 = static_cast<SCCOL>(aDataAddress.EndColumn); + aParam.nRow2 = static_cast<SCROW>(aDataAddress.EndRow); aParam.nTab = aDataAddress.Sheet; ScDocument& rDoc = pDocSh->GetDocument(); @@ -7125,7 +7125,7 @@ void SAL_CALL ScTableSheetObj::moveRange( const table::CellAddress& aDestination OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "wrong table in CellRangeAddress" ); ScRange aSourceRange; ScUnoConversion::FillScRange( aSourceRange, aSource ); - ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet ); + ScAddress aDestPos( static_cast<SCCOL>(aDestination.Column), static_cast<SCROW>(aDestination.Row), aDestination.Sheet ); (void)pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, true, true, true, true ); } } @@ -7140,7 +7140,7 @@ void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "wrong table in CellRangeAddress" ); ScRange aSourceRange; ScUnoConversion::FillScRange( aSourceRange, aSource ); - ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet ); + ScAddress aDestPos( static_cast<SCCOL>(aDestination.Column), static_cast<SCROW>(aDestination.Row), aDestination.Sheet ); (void)pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, false, true, true, true ); } } @@ -7229,7 +7229,7 @@ void SAL_CALL ScTableSheetObj::setPrintAreas( if ( rDoc.IsUndoEnabled() ) pOldRanges = rDoc.CreatePrintRangeSaver(); - sal_uInt16 nCount = (sal_uInt16) aPrintAreas.getLength(); + sal_uInt16 nCount = static_cast<sal_uInt16>(aPrintAreas.getLength()); rDoc.ClearPrintRanges( nTab ); if (nCount) { @@ -7552,7 +7552,7 @@ sal_Bool SAL_CALL ScTableSheetObj::hideDependents( const table::CellAddress& aPo { SCTAB nTab = GetTab_Impl(); OSL_ENSURE( aPosition.Sheet == nTab, "wrong table in CellAddress" ); - ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab ); + ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); return pDocSh->GetDocFunc().DetectiveDelSucc( aPos ); } return false; @@ -7566,7 +7566,7 @@ sal_Bool SAL_CALL ScTableSheetObj::hidePrecedents( const table::CellAddress& aPo { SCTAB nTab = GetTab_Impl(); OSL_ENSURE( aPosition.Sheet == nTab, "wrong table in CellAddress" ); - ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab ); + ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); return pDocSh->GetDocFunc().DetectiveDelPred( aPos ); } return false; @@ -7580,7 +7580,7 @@ sal_Bool SAL_CALL ScTableSheetObj::showDependents( const table::CellAddress& aPo { SCTAB nTab = GetTab_Impl(); OSL_ENSURE( aPosition.Sheet == nTab, "wrong table in CellAddress" ); - ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab ); + ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); return pDocSh->GetDocFunc().DetectiveAddSucc( aPos ); } return false; @@ -7594,7 +7594,7 @@ sal_Bool SAL_CALL ScTableSheetObj::showPrecedents( const table::CellAddress& aPo { SCTAB nTab = GetTab_Impl(); OSL_ENSURE( aPosition.Sheet == nTab, "wrong table in CellAddress" ); - ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab ); + ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); return pDocSh->GetDocFunc().DetectiveAddPred( aPos ); } return false; @@ -7608,7 +7608,7 @@ sal_Bool SAL_CALL ScTableSheetObj::showErrors( const table::CellAddress& aPositi { SCTAB nTab = GetTab_Impl(); OSL_ENSURE( aPosition.Sheet == nTab, "wrong table in CellAddress" ); - ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab ); + ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); return pDocSh->GetDocFunc().DetectiveAddError( aPos ); } return false; @@ -7826,15 +7826,15 @@ void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAd ScMarkData aMarkData; aMarkData.SelectTable( nTab, true ); - sal_uInt16 nRangeCount = (sal_uInt16)rScenRanges.getLength(); + sal_uInt16 nRangeCount = static_cast<sal_uInt16>(rScenRanges.getLength()); if (nRangeCount) { const table::CellRangeAddress* pAry = rScenRanges.getConstArray(); for (sal_uInt16 i=0; i<nRangeCount; i++) { OSL_ENSURE( pAry[i].Sheet == nTab, "addRanges with wrong Tab" ); - ScRange aOneRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab, - (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab ); + ScRange aOneRange( static_cast<SCCOL>(pAry[i].StartColumn), static_cast<SCROW>(pAry[i].StartRow), nTab, + static_cast<SCCOL>(pAry[i].EndColumn), static_cast<SCROW>(pAry[i].EndRow), nTab ); aMarkData.SetMultiMarkArea( aOneRange ); } @@ -8592,7 +8592,7 @@ void ScTableColumnObj::SetOnePropertyValue(const SfxItemPropertySimpleEntry* pEn // property is 1/100mm, column width is twips nNewWidth = HMMToTwips(nNewWidth); rFunc.SetWidthOrHeight( - true, aColArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewWidth, true, true); + true, aColArr, nTab, SC_SIZE_ORIGINAL, static_cast<sal_uInt16>(nNewWidth), true, true); } } else if ( pEntry->nWID == SC_WID_UNO_CELLVIS ) @@ -8642,8 +8642,8 @@ void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pE // for hidden column, return original height sal_uInt16 nWidth = rDoc.GetOriginalWidth( nCol, nTab ); // property is 1/100mm, column width is twips - nWidth = (sal_uInt16) TwipsToHMM(nWidth); - rAny <<= (sal_Int32)nWidth; + nWidth = static_cast<sal_uInt16>(TwipsToHMM(nWidth)); + rAny <<= static_cast<sal_Int32>(nWidth); } else if ( pEntry->nWID == SC_WID_UNO_CELLVIS ) { @@ -8729,7 +8729,7 @@ void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr // property is 1/100mm, row height is twips nNewHeight = HMMToTwips(nNewHeight); rFunc.SetWidthOrHeight( - false, aRowArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewHeight, true, true); + false, aRowArr, nTab, SC_SIZE_ORIGINAL, static_cast<sal_uInt16>(nNewHeight), true, true); } } else if ( pEntry->nWID == SC_WID_UNO_CELLVIS ) @@ -8788,8 +8788,8 @@ void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr // for hidden row, return original height sal_uInt16 nHeight = rDoc.GetOriginalHeight( nRow, nTab ); // property is 1/100mm, row height is twips - nHeight = (sal_uInt16) TwipsToHMM(nHeight); - rAny <<= (sal_Int32)nHeight; + nHeight = static_cast<sal_uInt16>(TwipsToHMM(nHeight)); + rAny <<= static_cast<sal_Int32>(nHeight); } else if ( pEntry->nWID == SC_WID_UNO_CELLVIS ) { diff --git a/sc/source/ui/unoobj/cellvaluebinding.cxx b/sc/source/ui/unoobj/cellvaluebinding.cxx index 19a6b01961bc..29cb35a199a5 100644 --- a/sc/source/ui/unoobj/cellvaluebinding.cxx +++ b/sc/source/ui/unoobj/cellvaluebinding.cxx @@ -226,7 +226,7 @@ namespace calc if ( m_xCell.is() ) aReturn <<= m_xCell->getValue(); else - aReturn <<= (double)0; + aReturn <<= double(0); break; case TypeClass_LONG: @@ -236,13 +236,13 @@ namespace calc // The list position value in the cell is 1-based. // We subtract 1 from any cell value (no special handling for 0 or negative values). - sal_Int32 nValue = (sal_Int32) rtl::math::approxFloor( m_xCell->getValue() ); + sal_Int32 nValue = static_cast<sal_Int32>(rtl::math::approxFloor( m_xCell->getValue() )); --nValue; aReturn <<= nValue; } else - aReturn <<= (sal_Int32)0; + aReturn <<= sal_Int32(0); break; default: diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index 1becb502b718..556e4aef5bce 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -686,7 +686,7 @@ void SAL_CALL ScChartObj::setRanges( const uno::Sequence<table::CellRangeAddress GetData_Impl( xOldRanges, bColHeaders, bRowHeaders ); ScRangeList* pList = new ScRangeList; - sal_uInt16 nRangeCount = (sal_uInt16)aRanges.getLength(); + sal_uInt16 nRangeCount = static_cast<sal_uInt16>(aRanges.getLength()); if (nRangeCount) { const table::CellRangeAddress* pAry = aRanges.getConstArray(); diff --git a/sc/source/ui/unoobj/cursuno.cxx b/sc/source/ui/unoobj/cursuno.cxx index 4e3677ad3584..edeaa08590f1 100644 --- a/sc/source/ui/unoobj/cursuno.cxx +++ b/sc/source/ui/unoobj/cursuno.cxx @@ -218,8 +218,8 @@ void SAL_CALL ScCellCursorObj::collapseToSize( sal_Int32 nColumns, sal_Int32 nRo if ( nEndY > MAXROW ) nEndY = MAXROW; //! error/exception or so, if too big/small - aNewRange.aEnd.SetCol((SCCOL)nEndX); - aNewRange.aEnd.SetRow((SCROW)nEndY); + aNewRange.aEnd.SetCol(static_cast<SCCOL>(nEndX)); + aNewRange.aEnd.SetRow(static_cast<SCROW>(nEndY)); aNewRange.PutInOrder(); //! really? @@ -398,11 +398,11 @@ void SAL_CALL ScCellCursorObj::gotoOffset( sal_Int32 nColumnOffset, sal_Int32 nR aOneRange.aStart.Row() + nRowOffset >= 0 && aOneRange.aEnd.Row() + nRowOffset <= MAXROW ) { - ScRange aNew( (SCCOL)(aOneRange.aStart.Col() + nColumnOffset), - (SCROW)(aOneRange.aStart.Row() + nRowOffset), + ScRange aNew( static_cast<SCCOL>(aOneRange.aStart.Col() + nColumnOffset), + static_cast<SCROW>(aOneRange.aStart.Row() + nRowOffset), aOneRange.aStart.Tab(), - (SCCOL)(aOneRange.aEnd.Col() + nColumnOffset), - (SCROW)(aOneRange.aEnd.Row() + nRowOffset), + static_cast<SCCOL>(aOneRange.aEnd.Col() + nColumnOffset), + static_cast<SCROW>(aOneRange.aEnd.Row() + nRowOffset), aOneRange.aEnd.Tab() ); SetNewRange( aNew ); } diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index 5522e9555970..a96b35cd0d48 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -421,8 +421,8 @@ void SAL_CALL ScDataPilotTablesObj::insertNewByName( const OUString& aNewName, if (!pNewObj) throw RuntimeException("Failed to get DPObject", static_cast<cppu::OWeakObject*>(this)); - ScRange aOutputRange((SCCOL)aOutputAddress.Column, (SCROW)aOutputAddress.Row, (SCTAB)aOutputAddress.Sheet, - (SCCOL)aOutputAddress.Column, (SCROW)aOutputAddress.Row, (SCTAB)aOutputAddress.Sheet); + ScRange aOutputRange(static_cast<SCCOL>(aOutputAddress.Column), static_cast<SCROW>(aOutputAddress.Row), static_cast<SCTAB>(aOutputAddress.Sheet), + static_cast<SCCOL>(aOutputAddress.Column), static_cast<SCROW>(aOutputAddress.Row), static_cast<SCTAB>(aOutputAddress.Sheet)); pNewObj->SetOutRange(aOutputRange); OUString aName = aNewName; if (aName.isEmpty()) diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index db9420ae2987..4125e91410f7 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -421,8 +421,8 @@ void ScSortDescriptor::FillSortParam( ScSortParam& rParam, const uno::Sequence<b if ( rProp.Value >>= aAddress ) { rParam.nDestTab = aAddress.Sheet; - rParam.nDestCol = (SCCOL)aAddress.Column; - rParam.nDestRow = (SCROW)aAddress.Row; + rParam.nDestCol = static_cast<SCCOL>(aAddress.Column); + rParam.nDestRow = static_cast<SCROW>(aAddress.Row); } } else if (aPropName == SC_UNONAME_ISULIST) @@ -431,7 +431,7 @@ void ScSortDescriptor::FillSortParam( ScSortParam& rParam, const uno::Sequence<b { sal_Int32 nVal = 0; if ( rProp.Value >>= nVal ) - rParam.nUserIndex = (sal_uInt16)nVal; + rParam.nUserIndex = static_cast<sal_uInt16>(nVal); } else if (aPropName == SC_UNONAME_COLLLOC) { @@ -474,7 +474,7 @@ void SAL_CALL ScSubTotalFieldObj::setGroupColumn( sal_Int32 nGroupColumn ) ScSubTotalParam aParam; xParent->GetData(aParam); - aParam.nField[nPos] = (SCCOL)nGroupColumn; + aParam.nField[nPos] = static_cast<SCCOL>(nGroupColumn); xParent->PutData(aParam); } @@ -638,7 +638,7 @@ sal_Int32 SAL_CALL ScSubTotalDescriptorBase::getCount() uno::Any SAL_CALL ScSubTotalDescriptorBase::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; - uno::Reference<sheet::XSubTotalField> xField(GetObjectByIndex_Impl((sal_uInt16)nIndex)); + uno::Reference<sheet::XSubTotalField> xField(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex))); if (!xField.is()) throw lang::IndexOutOfBoundsException(); @@ -692,7 +692,7 @@ void SAL_CALL ScSubTotalDescriptorBase::setPropertyValue( { sal_Int32 nVal = 0; if ( aValue >>= nVal ) - aParam.nUserIndex = (sal_uInt16)nVal; + aParam.nUserIndex = static_cast<sal_uInt16>(nVal); } else if (aPropertyName == SC_UNONAME_MAXFLD ) { @@ -729,9 +729,9 @@ uno::Any SAL_CALL ScSubTotalDescriptorBase::getPropertyValue( const OUString& aP else if (aPropertyName == SC_UNONAME_ULIST || aPropertyName == SC_UNONAME_ENUSLIST ) aRet <<= aParam.bUserDef; else if (aPropertyName == SC_UNONAME_UINDEX || aPropertyName == SC_UNONAME_USINDEX ) - aRet <<= (sal_Int32) aParam.nUserIndex; + aRet <<= static_cast<sal_Int32>(aParam.nUserIndex); else if (aPropertyName == SC_UNONAME_MAXFLD ) - aRet <<= (sal_Int32) MAXSUBTOTAL; + aRet <<= sal_Int32(MAXSUBTOTAL); return aRet; } @@ -871,7 +871,7 @@ void SAL_CALL ScConsolidationDescriptor::setSources( const uno::Sequence<table::CellRangeAddress>& aSources ) { SolarMutexGuard aGuard; - sal_uInt16 nCount = (sal_uInt16)aSources.getLength(); + sal_uInt16 nCount = static_cast<sal_uInt16>(aSources.getLength()); if (nCount) { const table::CellRangeAddress* pAry = aSources.getConstArray(); @@ -905,8 +905,8 @@ void SAL_CALL ScConsolidationDescriptor::setStartOutputPosition( const table::CellAddress& aStartOutputPosition ) { SolarMutexGuard aGuard; - aParam.nCol = (SCCOL)aStartOutputPosition.Column; - aParam.nRow = (SCROW)aStartOutputPosition.Row; + aParam.nCol = static_cast<SCCOL>(aStartOutputPosition.Column); + aParam.nRow = static_cast<SCROW>(aStartOutputPosition.Row); aParam.nTab = aStartOutputPosition.Sheet; } @@ -1424,8 +1424,8 @@ void SAL_CALL ScFilterDescriptorBase::setPropertyValue( if ( aValue >>= aAddress ) { aParam.nDestTab = aAddress.Sheet; - aParam.nDestCol = (SCCOL)aAddress.Column; - aParam.nDestRow = (SCROW)aAddress.Row; + aParam.nDestCol = static_cast<SCCOL>(aAddress.Column); + aParam.nDestRow = static_cast<SCROW>(aAddress.Row); } } else if (aPropertyName == SC_UNONAME_SAVEOUT) @@ -1454,7 +1454,7 @@ uno::Any SAL_CALL ScFilterDescriptorBase::getPropertyValue( const OUString& aPro else if (aPropertyName == SC_UNONAME_ISCASE ) aRet <<= aParam.bCaseSens; else if (aPropertyName == SC_UNONAME_MAXFLD ) - aRet <<= (sal_Int32) aParam.GetEntryCount(); + aRet <<= static_cast<sal_Int32>(aParam.GetEntryCount()); else if (aPropertyName == SC_UNONAME_ORIENT ) { table::TableOrientation eOrient = aParam.bByRow ? table::TableOrientation_ROWS : @@ -1682,8 +1682,8 @@ void SAL_CALL ScDatabaseRangeObj::setDataArea( const table::CellRangeAddress& aD { ScDBData aNewData( *pData ); //! MoveTo ??? - aNewData.SetArea( aDataArea.Sheet, (SCCOL)aDataArea.StartColumn, (SCROW)aDataArea.StartRow, - (SCCOL)aDataArea.EndColumn, (SCROW)aDataArea.EndRow ); + aNewData.SetArea( aDataArea.Sheet, static_cast<SCCOL>(aDataArea.StartColumn), static_cast<SCROW>(aDataArea.StartRow), + static_cast<SCCOL>(aDataArea.EndColumn), static_cast<SCROW>(aDataArea.EndRow) ); ScDBDocFunc aFunc(*pDocShell); aFunc.ModifyDBData(aNewData); } @@ -2189,8 +2189,8 @@ void SAL_CALL ScDatabaseRangesObj::addNewByName( const OUString& aName, { ScDBDocFunc aFunc(*pDocShell); - ScRange aNameRange( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet, - (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet ); + ScRange aNameRange( static_cast<SCCOL>(aRange.StartColumn), static_cast<SCROW>(aRange.StartRow), aRange.Sheet, + static_cast<SCCOL>(aRange.EndColumn), static_cast<SCROW>(aRange.EndRow), aRange.Sheet ); bDone = aFunc.AddDBRange( aName, aNameRange ); } if (!bDone) @@ -2346,8 +2346,8 @@ void ScUnnamedDatabaseRangesObj::setByTable( const table::CellRangeAddress& aRan throw lang::IndexOutOfBoundsException(); ScDBDocFunc aFunc(*pDocShell); - ScRange aUnnamedRange( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet, - (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet ); + ScRange aUnnamedRange( static_cast<SCCOL>(aRange.StartColumn), static_cast<SCROW>(aRange.StartRow), aRange.Sheet, + static_cast<SCCOL>(aRange.EndColumn), static_cast<SCROW>(aRange.EndRow), aRange.Sheet ); bDone = aFunc.AddDBRange( STR_DB_LOCAL_NONAME, aUnnamedRange ); } if (!bDone) @@ -2377,7 +2377,7 @@ sal_Bool ScUnnamedDatabaseRangesObj::hasByTable( sal_Int32 nTab ) { if (pDocShell->GetDocument().GetTableCount() <= nTab) throw lang::IndexOutOfBoundsException(); - if (pDocShell->GetDocument().GetAnonymousDBData((SCTAB) nTab)) + if (pDocShell->GetDocument().GetAnonymousDBData(static_cast<SCTAB>(nTab))) return true; return false; } diff --git a/sc/source/ui/unoobj/dispuno.cxx b/sc/source/ui/unoobj/dispuno.cxx index e8a1818420c4..0f0d25e3f53f 100644 --- a/sc/source/ui/unoobj/dispuno.cxx +++ b/sc/source/ui/unoobj/dispuno.cxx @@ -248,7 +248,7 @@ static void lcl_FillDataSource( frame::FeatureStateEvent& rEvent, const ScImport aDescriptor[svx::DataAccessDescriptorProperty::DataSource] <<= OUString(); aDescriptor[svx::DataAccessDescriptorProperty::Command] <<= OUString(); - aDescriptor[svx::DataAccessDescriptorProperty::CommandType] <<= (sal_Int32)sdb::CommandType::TABLE; + aDescriptor[svx::DataAccessDescriptorProperty::CommandType] <<= sal_Int32(sdb::CommandType::TABLE); } rEvent.State <<= aDescriptor.createPropertyValueSequence(); } diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 901e34a86a31..7322c70493b5 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1420,7 +1420,7 @@ static bool lcl_ParseTarget( const OUString& rTarget, ScRange& rTargetRange, too ( nNumeric = rTarget.toInt32() ) > 0 && nNumeric <= MAXROW+1 ) { // row number is always mapped to cell A(row) on the same sheet - rTargetRange = ScAddress( 0, (SCROW)(nNumeric-1), nSourceTab ); // target row number is 1-based + rTargetRange = ScAddress( 0, static_cast<SCROW>(nNumeric-1), nSourceTab ); // target row number is 1-based bRangeValid = true; // row number } else if ( pDoc->GetTable( rTarget, nNameTab ) ) @@ -2055,14 +2055,10 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec Fraction aScaleX( aLocationPixel.GetWidth(), aLocationMM.GetWidth() ); Fraction aScaleY( aLocationPixel.GetHeight(), aLocationMM.GetHeight() ); - long nX1 = aLocationPixel.Left() + (long) - ( Fraction( aTargetRect.Left() - aLocationMM.Left(), 1 ) * aScaleX ); - long nX2 = aLocationPixel.Left() + (long) - ( Fraction( aTargetRect.Right() - aLocationMM.Left(), 1 ) * aScaleX ); - long nY1 = aLocationPixel.Top() + (long) - ( Fraction( aTargetRect.Top() - aLocationMM.Top(), 1 ) * aScaleY ); - long nY2 = aLocationPixel.Top() + (long) - ( Fraction( aTargetRect.Bottom() - aLocationMM.Top(), 1 ) * aScaleY ); + long nX1 = aLocationPixel.Left() + static_cast<long>( Fraction( aTargetRect.Left() - aLocationMM.Left(), 1 ) * aScaleX ); + long nX2 = aLocationPixel.Left() + static_cast<long>( Fraction( aTargetRect.Right() - aLocationMM.Left(), 1 ) * aScaleX ); + long nY1 = aLocationPixel.Top() + static_cast<long>( Fraction( aTargetRect.Top() - aLocationMM.Top(), 1 ) * aScaleY ); + long nY2 = aLocationPixel.Top() + static_cast<long>( Fraction( aTargetRect.Bottom() - aLocationMM.Top(), 1 ) * aScaleY ); if ( nX1 > aLocationPixel.Right() ) nX1 = aLocationPixel.Right(); if ( nX2 > aLocationPixel.Right() ) nX2 = aLocationPixel.Right(); @@ -2285,8 +2281,8 @@ sheet::GoalResult SAL_CALL ScModelObj::seekGoal( ScDocument& rDoc = pDocShell->GetDocument(); double fValue = 0.0; bool bFound = rDoc.Solver( - (SCCOL)aFormulaPosition.Column, (SCROW)aFormulaPosition.Row, aFormulaPosition.Sheet, - (SCCOL)aVariablePosition.Column, (SCROW)aVariablePosition.Row, aVariablePosition.Sheet, + static_cast<SCCOL>(aFormulaPosition.Column), static_cast<SCROW>(aFormulaPosition.Row), aFormulaPosition.Sheet, + static_cast<SCCOL>(aVariablePosition.Column), static_cast<SCROW>(aVariablePosition.Row), aVariablePosition.Sheet, aGoalValue, fValue ); aResult.Result = fValue; if (bFound) @@ -3286,7 +3282,7 @@ uno::Reference<drawing::XDrawPage> ScDrawPagesObj::GetObjectByIndex_Impl(sal_Int OSL_ENSURE(pDrawLayer,"Cannot create Draw-Layer"); if ( pDrawLayer && nIndex >= 0 && nIndex < pDocShell->GetDocument().GetTableCount() ) { - SdrPage* pPage = pDrawLayer->GetPage((sal_uInt16)nIndex); + SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nIndex)); OSL_ENSURE(pPage,"Draw-Page not found"); if (pPage) { @@ -3606,7 +3602,7 @@ sal_Int32 ScTableSheetsObj::importSheet( uno::Reference< table::XCell > SAL_CALL ScTableSheetsObj::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow, sal_Int32 nSheet ) { SolarMutexGuard aGuard; - uno::Reference<table::XCellRange> xSheet(static_cast<ScCellRangeObj*>(GetObjectByIndex_Impl((sal_uInt16)nSheet))); + uno::Reference<table::XCellRange> xSheet(static_cast<ScCellRangeObj*>(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nSheet)))); if (! xSheet.is()) throw lang::IndexOutOfBoundsException(); @@ -3616,7 +3612,7 @@ uno::Reference< table::XCell > SAL_CALL ScTableSheetsObj::getCellByPosition( sal uno::Reference< table::XCellRange > SAL_CALL ScTableSheetsObj::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom, sal_Int32 nSheet ) { SolarMutexGuard aGuard; - uno::Reference<table::XCellRange> xSheet(static_cast<ScCellRangeObj*>(GetObjectByIndex_Impl((sal_uInt16)nSheet))); + uno::Reference<table::XCellRange> xSheet(static_cast<ScCellRangeObj*>(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nSheet)))); if (! xSheet.is()) throw lang::IndexOutOfBoundsException(); @@ -3791,8 +3787,8 @@ void SAL_CALL ScTableColumnsObj::insertByIndex( sal_Int32 nPosition, sal_Int32 n if ( pDocShell && nCount > 0 && nPosition >= 0 && nStartCol+nPosition <= nEndCol && nStartCol+nPosition+nCount-1 <= MAXCOL ) { - ScRange aRange( (SCCOL)(nStartCol+nPosition), 0, nTab, - (SCCOL)(nStartCol+nPosition+nCount-1), MAXROW, nTab ); + ScRange aRange( static_cast<SCCOL>(nStartCol+nPosition), 0, nTab, + static_cast<SCCOL>(nStartCol+nPosition+nCount-1), MAXROW, nTab ); bDone = pDocShell->GetDocFunc().InsertCells( aRange, nullptr, INS_INSCOLS_BEFORE, true, true ); } if (!bDone) @@ -3806,8 +3802,8 @@ void SAL_CALL ScTableColumnsObj::removeByIndex( sal_Int32 nIndex, sal_Int32 nCou // the range to be deleted has to lie within the object if ( pDocShell && nCount > 0 && nIndex >= 0 && nStartCol+nIndex+nCount-1 <= nEndCol ) { - ScRange aRange( (SCCOL)(nStartCol+nIndex), 0, nTab, - (SCCOL)(nStartCol+nIndex+nCount-1), MAXROW, nTab ); + ScRange aRange( static_cast<SCCOL>(nStartCol+nIndex), 0, nTab, + static_cast<SCCOL>(nStartCol+nIndex+nCount-1), MAXROW, nTab ); bDone = pDocShell->GetDocFunc().DeleteCells( aRange, nullptr, DEL_DELCOLS, true ); } if (!bDone) @@ -3911,7 +3907,7 @@ void SAL_CALL ScTableColumnsObj::setPropertyValue( sal_Int32 nNewWidth = 0; if ( aValue >>= nNewWidth ) rFunc.SetWidthOrHeight( - true, aColArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)HMMToTwips(nNewWidth), true, true); + true, aColArr, nTab, SC_SIZE_ORIGINAL, static_cast<sal_uInt16>(HMMToTwips(nNewWidth)), true, true); } else if ( aPropertyName == SC_UNONAME_CELLVIS ) { @@ -3955,7 +3951,7 @@ uno::Any SAL_CALL ScTableColumnsObj::getPropertyValue( const OUString& aProperty { // for hidden column, return original height sal_uInt16 nWidth = rDoc.GetOriginalWidth( nStartCol, nTab ); - aAny <<= (sal_Int32)TwipsToHMM(nWidth); + aAny <<= static_cast<sal_Int32>(TwipsToHMM(nWidth)); } else if ( aPropertyName == SC_UNONAME_CELLVIS ) { @@ -4030,8 +4026,8 @@ void SAL_CALL ScTableRowsObj::insertByIndex( sal_Int32 nPosition, sal_Int32 nCou if ( pDocShell && nCount > 0 && nPosition >= 0 && nStartRow+nPosition <= nEndRow && nStartRow+nPosition+nCount-1 <= MAXROW ) { - ScRange aRange( 0, (SCROW)(nStartRow+nPosition), nTab, - MAXCOL, (SCROW)(nStartRow+nPosition+nCount-1), nTab ); + ScRange aRange( 0, static_cast<SCROW>(nStartRow+nPosition), nTab, + MAXCOL, static_cast<SCROW>(nStartRow+nPosition+nCount-1), nTab ); bDone = pDocShell->GetDocFunc().InsertCells( aRange, nullptr, INS_INSROWS_BEFORE, true, true ); } if (!bDone) @@ -4045,8 +4041,8 @@ void SAL_CALL ScTableRowsObj::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount // the range to be deleted has to lie within the object if ( pDocShell && nCount > 0 && nIndex >= 0 && nStartRow+nIndex+nCount-1 <= nEndRow ) { - ScRange aRange( 0, (SCROW)(nStartRow+nIndex), nTab, - MAXCOL, (SCROW)(nStartRow+nIndex+nCount-1), nTab ); + ScRange aRange( 0, static_cast<SCROW>(nStartRow+nIndex), nTab, + MAXCOL, static_cast<SCROW>(nStartRow+nIndex+nCount-1), nTab ); bDone = pDocShell->GetDocFunc().DeleteCells( aRange, nullptr, DEL_DELROWS, true ); } if (!bDone) @@ -4121,7 +4117,7 @@ void SAL_CALL ScTableRowsObj::setPropertyValue( // TODO: It's probably cleaner to use a different property name // for this. - rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, (sal_uInt16)HMMToTwips(nNewHeight) ); + rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, static_cast<sal_uInt16>(HMMToTwips(nNewHeight)) ); } else { @@ -4144,12 +4140,12 @@ void SAL_CALL ScTableRowsObj::setPropertyValue( // TODO: This is a band-aid fix. Eventually we need to // re-work ods' style import to get it to set styles to // ScDocument directly. - rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, (sal_uInt16)HMMToTwips(nNewHeight) ); + rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, static_cast<sal_uInt16>(HMMToTwips(nNewHeight)) ); rDoc.SetManualHeight( nStartRow, nEndRow, nTab, true ); } else rFunc.SetWidthOrHeight( - false, aRowArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)HMMToTwips(nNewHeight), true, true); + false, aRowArr, nTab, SC_SIZE_ORIGINAL, static_cast<sal_uInt16>(HMMToTwips(nNewHeight)), true, true); } } else if ( aPropertyName == SC_UNONAME_CELLVIS ) @@ -4212,7 +4208,7 @@ uno::Any SAL_CALL ScTableRowsObj::getPropertyValue( const OUString& aPropertyNam { // for hidden row, return original height sal_uInt16 nHeight = rDoc.GetOriginalHeight( nStartRow, nTab ); - aAny <<= (sal_Int32)TwipsToHMM(nHeight); + aAny <<= static_cast<sal_Int32>(TwipsToHMM(nHeight)); } else if ( aPropertyName == SC_UNONAME_CELLVIS ) { @@ -4333,7 +4329,7 @@ void SAL_CALL ScAnnotationsObj::insertNew( if (pDocShell) { OSL_ENSURE( aPosition.Sheet == nTab, "addAnnotation with a wrong Sheet" ); - ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab ); + ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); pDocShell->GetDocFunc().ReplaceNote( aPos, rText, nullptr, nullptr, true ); } } @@ -4439,7 +4435,7 @@ bool ScScenariosObj::GetScenarioIndex_Impl( const OUString& rName, SCTAB& rIndex { OUString aTabName; ScDocument& rDoc = pDocShell->GetDocument(); - SCTAB nCount = (SCTAB)getCount(); + SCTAB nCount = static_cast<SCTAB>(getCount()); for (SCTAB i=0; i<nCount; i++) if (rDoc.GetName( nTab+i+1, aTabName )) if (aTabName == rName) @@ -4454,7 +4450,7 @@ bool ScScenariosObj::GetScenarioIndex_Impl( const OUString& rName, SCTAB& rIndex ScTableSheetObj* ScScenariosObj::GetObjectByIndex_Impl(sal_Int32 nIndex) { - sal_uInt16 nCount = (sal_uInt16)getCount(); + sal_uInt16 nCount = static_cast<sal_uInt16>(getCount()); if ( pDocShell && nIndex >= 0 && nIndex < nCount ) return new ScTableSheetObj( pDocShell, nTab+static_cast<SCTAB>(nIndex)+1 ); @@ -4480,15 +4476,15 @@ void SAL_CALL ScScenariosObj::addNewByName( const OUString& aName, ScMarkData aMarkData; aMarkData.SelectTable( nTab, true ); - sal_uInt16 nRangeCount = (sal_uInt16)aRanges.getLength(); + sal_uInt16 nRangeCount = static_cast<sal_uInt16>(aRanges.getLength()); if (nRangeCount) { const table::CellRangeAddress* pAry = aRanges.getConstArray(); for (sal_uInt16 i=0; i<nRangeCount; i++) { OSL_ENSURE( pAry[i].Sheet == nTab, "addScenario with a wrong Tab" ); - ScRange aRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab, - (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab ); + ScRange aRange( static_cast<SCCOL>(pAry[i].StartColumn), static_cast<SCROW>(pAry[i].StartRow), nTab, + static_cast<SCCOL>(pAry[i].EndColumn), static_cast<SCROW>(pAry[i].EndRow), nTab ); aMarkData.SetMultiMarkArea( aRange ); } @@ -4576,7 +4572,7 @@ uno::Any SAL_CALL ScScenariosObj::getByName( const OUString& aName ) uno::Sequence<OUString> SAL_CALL ScScenariosObj::getElementNames() { SolarMutexGuard aGuard; - SCTAB nCount = (SCTAB)getCount(); + SCTAB nCount = static_cast<SCTAB>(getCount()); uno::Sequence<OUString> aSeq(nCount); if ( pDocShell ) // otherwise Count = 0 diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx index 5f1279807ec4..3a03ca3dff03 100644 --- a/sc/source/ui/unoobj/filtuno.cxx +++ b/sc/source/ui/unoobj/filtuno.cxx @@ -93,7 +93,7 @@ namespace pProperties[0] >>= nChar; if( nChar >= 0) { - nCharSet = (rtl_TextEncoding) nChar; + nCharSet = static_cast<rtl_TextEncoding>(nChar); return charsetSource::charset_from_user_setting; } } @@ -113,7 +113,7 @@ namespace aValues = aItem.GetProperties( aNames ); pProperties = aValues.getArray(); - pProperties[0] <<= (sal_Int32) nCharSet; + pProperties[0] <<= static_cast<sal_Int32>(nCharSet); aItem.PutProperties(aNames, aValues); } diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 9f2116ac4cf7..0c5aef2f3089 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -293,7 +293,7 @@ void SAL_CALL ScTableConditionalFormat::addNew( { table::CellAddress aAddress; if ( rProp.Value >>= aAddress ) - aEntry.maPos = ScAddress( (SCCOL)aAddress.Column, (SCROW)aAddress.Row, aAddress.Sheet ); + aEntry.maPos = ScAddress( static_cast<SCCOL>(aAddress.Column), static_cast<SCROW>(aAddress.Row), aAddress.Sheet ); } else if ( rProp.Name == SC_UNONAME_SOURCESTR ) { @@ -377,7 +377,7 @@ sal_Int32 SAL_CALL ScTableConditionalFormat::getCount() uno::Any SAL_CALL ScTableConditionalFormat::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; - uno::Reference<sheet::XSheetConditionalEntry> xEntry(GetObjectByIndex_Impl((sal_uInt16)nIndex)); + uno::Reference<sheet::XSheetConditionalEntry> xEntry(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex))); if (!xEntry.is()) throw lang::IndexOutOfBoundsException(); @@ -415,7 +415,7 @@ uno::Any SAL_CALL ScTableConditionalFormat::getByName( const OUString& aName ) for (long i=0; i<nCount; i++) if ( aName == lcl_GetEntryNameFromIndex(i) ) { - xEntry.set(GetObjectByIndex_Impl((sal_uInt16)i)); + xEntry.set(GetObjectByIndex_Impl(static_cast<sal_uInt16>(i))); break; } @@ -561,7 +561,7 @@ table::CellAddress SAL_CALL ScTableConditionalEntry::getSourcePosition() void SAL_CALL ScTableConditionalEntry::setSourcePosition( const table::CellAddress& aSourcePosition ) { SolarMutexGuard aGuard; - aData.maPos.Set( (SCCOL)aSourcePosition.Column, (SCROW)aSourcePosition.Row, aSourcePosition.Sheet ); + aData.maPos.Set( static_cast<SCCOL>(aSourcePosition.Column), static_cast<SCROW>(aSourcePosition.Row), aSourcePosition.Sheet ); } // XSheetConditionalEntry @@ -749,7 +749,7 @@ table::CellAddress SAL_CALL ScTableValidationObj::getSourcePosition() void SAL_CALL ScTableValidationObj::setSourcePosition( const table::CellAddress& aSourcePosition ) { SolarMutexGuard aGuard; - aSrcPos.Set( (SCCOL)aSourcePosition.Column, (SCROW)aSourcePosition.Row, aSourcePosition.Sheet ); + aSrcPos.Set( static_cast<SCCOL>(aSourcePosition.Column), static_cast<SCROW>(aSourcePosition.Row), aSourcePosition.Sheet ); } uno::Sequence<sheet::FormulaToken> SAL_CALL ScTableValidationObj::getTokens( sal_Int32 nIndex ) diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 2069bfdd81ac..d4d1e53b5443 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -329,15 +329,15 @@ public: void visitElem( long nCol, long nRow, sal_Int16 elem ) { - mpDoc->SetValue( (SCCOL) nCol, (SCROW) nRow, 0, elem ); + mpDoc->SetValue( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), 0, elem ); } void visitElem( long nCol, long nRow, sal_Int32 elem ) { - mpDoc->SetValue( (SCCOL) nCol, (SCROW) nRow, 0, elem ); + mpDoc->SetValue( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), 0, elem ); } void visitElem( long nCol, long nRow, const double& elem ) { - mpDoc->SetValue( (SCCOL) nCol, (SCROW) nRow, 0, elem ); + mpDoc->SetValue( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), 0, elem ); } void visitElem( long nCol, long nRow, const OUString& elem ) { @@ -560,7 +560,7 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const OUString& aName, else { // copy data - if ( !lcl_CopyData( pSrcDoc, aSrcRange, pDoc, ScAddress( 0, (SCROW)nDocRow, 0 ) ) ) + if ( !lcl_CopyData( pSrcDoc, aSrcRange, pDoc, ScAddress( 0, static_cast<SCROW>(nDocRow), 0 ) ) ) bOverflow = true; } diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx index 6d038269e1dc..42ac15dcf61f 100644 --- a/sc/source/ui/unoobj/linkuno.cxx +++ b/sc/source/ui/unoobj/linkuno.cxx @@ -191,7 +191,7 @@ void ScSheetLinkObj::ModifyRefreshDelay_Impl( sal_Int32 nRefresh ) { ScTableLink* pLink = GetLink_Impl(); if( pLink ) - pLink->SetRefreshDelay( (sal_uLong) nRefresh ); + pLink->SetRefreshDelay( static_cast<sal_uLong>(nRefresh) ); } // XPropertySet @@ -348,7 +348,7 @@ sal_Int32 ScSheetLinkObj::getRefreshDelay() const sal_Int32 nRet = 0; ScTableLink* pLink = GetLink_Impl(); if (pLink) - nRet = (sal_Int32) pLink->GetRefreshDelay(); + nRet = static_cast<sal_Int32>(pLink->GetRefreshDelay()); return nRet; } @@ -659,7 +659,7 @@ void ScAreaLinkObj::ModifyRefreshDelay_Impl( sal_Int32 nRefresh ) { ScAreaLink* pLink = lcl_GetAreaLink( pDocShell, nPos ); if( pLink ) - pLink->SetRefreshDelay( (sal_uLong) nRefresh ); + pLink->SetRefreshDelay( static_cast<sal_uLong>(nRefresh) ); } // XRefreshable @@ -831,7 +831,7 @@ sal_Int32 ScAreaLinkObj::getRefreshDelay() const sal_Int32 nRet = 0; ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos); if (pLink) - nRet = (sal_Int32) pLink->GetRefreshDelay(); + nRet = static_cast<sal_Int32>(pLink->GetRefreshDelay()); return nRet; } @@ -904,7 +904,7 @@ void ScAreaLinksObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) ScAreaLinkObj* ScAreaLinksObj::GetObjectByIndex_Impl(sal_Int32 nIndex) { if ( pDocShell && nIndex >= 0 && nIndex < getCount() ) - return new ScAreaLinkObj( pDocShell, (size_t)nIndex ); + return new ScAreaLinkObj( pDocShell, static_cast<size_t>(nIndex) ); return nullptr; // not found } @@ -919,7 +919,7 @@ void SAL_CALL ScAreaLinksObj::insertAtPosition( const table::CellAddress& aDestP if (pDocShell) { OUString aFileStr (aFileName); - ScAddress aDestAddr( (SCCOL)aDestPos.Column, (SCROW)aDestPos.Row, aDestPos.Sheet ); + ScAddress aDestAddr( static_cast<SCCOL>(aDestPos.Column), static_cast<SCROW>(aDestPos.Row), aDestPos.Sheet ); aFileStr = ScGlobal::GetAbsDocName( aFileStr, pDocShell ); //! in InsertAreaLink ??? pDocShell->GetDocFunc().InsertAreaLink( aFileStr, aFilter, aFilterOptions, @@ -931,7 +931,7 @@ void SAL_CALL ScAreaLinksObj::insertAtPosition( const table::CellAddress& aDestP void SAL_CALL ScAreaLinksObj::removeByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; - ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, (size_t)nIndex); + ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, static_cast<size_t>(nIndex)); if (pLink) { //! SetAddUndo or what @@ -1217,7 +1217,7 @@ ScDDELinkObj* ScDDELinksObj::GetObjectByIndex_Impl(sal_Int32 nIndex) if (pDocShell) { OUString aAppl, aTopic, aItem; - if ( pDocShell->GetDocument().GetDdeLinkData( (size_t)nIndex, aAppl, aTopic, aItem ) ) + if ( pDocShell->GetDocument().GetDdeLinkData( static_cast<size_t>(nIndex), aAppl, aTopic, aItem ) ) return new ScDDELinkObj( pDocShell, aAppl, aTopic, aItem ); } return nullptr; diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx index cfb60594f039..1caa62e9920c 100644 --- a/sc/source/ui/unoobj/nameuno.cxx +++ b/sc/source/ui/unoobj/nameuno.cxx @@ -276,7 +276,7 @@ table::CellAddress SAL_CALL ScNamedRangeObj::getReferencePosition() void SAL_CALL ScNamedRangeObj::setReferencePosition( const table::CellAddress& aReferencePosition ) { SolarMutexGuard aGuard; - ScAddress aPos( (SCCOL)aReferencePosition.Column, (SCROW)aReferencePosition.Row, aReferencePosition.Sheet ); + ScAddress aPos( static_cast<SCCOL>(aReferencePosition.Column), static_cast<SCROW>(aReferencePosition.Row), aReferencePosition.Sheet ); // GRAM_API for API compatibility. Modify_Impl( nullptr, nullptr, nullptr, &aPos, nullptr,formula::FormulaGrammar::GRAM_API ); } @@ -477,7 +477,7 @@ void SAL_CALL ScNamedRangesObj::addNewByName( const OUString& aName, sal_Int32 nUnoType ) { SolarMutexGuard aGuard; - ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, aPosition.Sheet ); + ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), aPosition.Sheet ); ScRangeData::Type nNewType = ScRangeData::Type::Name; if ( nUnoType & sheet::NamedRangeFlag::FILTER_CRITERIA ) nNewType |= ScRangeData::Type::Criteria; @@ -564,7 +564,7 @@ void SAL_CALL ScNamedRangesObj::removeByName( const OUString& aName ) void SAL_CALL ScNamedRangesObj::outputList( const table::CellAddress& aOutputPosition ) { SolarMutexGuard aGuard; - ScAddress aPos( (SCCOL)aOutputPosition.Column, (SCROW)aOutputPosition.Row, aOutputPosition.Sheet ); + ScAddress aPos( static_cast<SCCOL>(aOutputPosition.Column), static_cast<SCROW>(aOutputPosition.Row), aOutputPosition.Sheet ); if (pDocShell) pDocShell->GetDocFunc().InsertNameList( aPos, true ); } @@ -600,7 +600,7 @@ sal_Int32 SAL_CALL ScNamedRangesObj::getCount() uno::Any SAL_CALL ScNamedRangesObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; - uno::Reference< sheet::XNamedRange > xRange(GetObjectByIndex_Impl((sal_uInt16)nIndex)); + uno::Reference< sheet::XNamedRange > xRange(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex))); if ( !xRange.is() ) throw lang::IndexOutOfBoundsException(); @@ -1090,7 +1090,7 @@ void SAL_CALL ScLabelRangesObj::removeByIndex( sal_Int32 nIndex ) ScDocument& rDoc = pDocShell->GetDocument(); ScRangePairList* pOldList = bColumn ? rDoc.GetColNameRanges() : rDoc.GetRowNameRanges(); - if ( pOldList && nIndex >= 0 && nIndex < (sal_Int32)pOldList->size() ) + if ( pOldList && nIndex >= 0 && nIndex < static_cast<sal_Int32>(pOldList->size()) ) { ScRangePairListRef xNewList(pOldList->Clone()); @@ -1143,7 +1143,7 @@ sal_Int32 SAL_CALL ScLabelRangesObj::getCount() uno::Any SAL_CALL ScLabelRangesObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; - uno::Reference< sheet::XLabelRange > xRange(GetObjectByIndex_Impl((sal_uInt16)nIndex)); + uno::Reference< sheet::XLabelRange > xRange(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex))); if ( !xRange.is() ) throw lang::IndexOutOfBoundsException(); diff --git a/sc/source/ui/unoobj/optuno.cxx b/sc/source/ui/unoobj/optuno.cxx index ae39a0aae238..e74b9471618a 100644 --- a/sc/source/ui/unoobj/optuno.cxx +++ b/sc/source/ui/unoobj/optuno.cxx @@ -81,7 +81,7 @@ bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions, { sal_Int32 nIntVal = 0; if ( aValue >>= nIntVal ) - rOptions.SetIterCount( (sal_uInt16)nIntVal ); + rOptions.SetIterCount( static_cast<sal_uInt16>(nIntVal) ); } break; case PROP_UNO_ITEREPSILON : @@ -140,7 +140,7 @@ uno::Any ScDocOptionsHelper::getPropertyValue( aRet <<= rOptions.IsCalcAsShown(); break; case PROP_UNO_DEFTABSTOP : - aRet <<= (sal_Int16)( rOptions.GetTabDistance() ); + aRet <<= static_cast<sal_Int16>( rOptions.GetTabDistance() ); break; case PROP_UNO_IGNORECASE : aRet <<= rOptions.IsIgnoreCase(); @@ -149,7 +149,7 @@ uno::Any ScDocOptionsHelper::getPropertyValue( aRet <<= rOptions.IsIter(); break; case PROP_UNO_ITERCOUNT: - aRet <<= (sal_Int32)( rOptions.GetIterCount() ); + aRet <<= static_cast<sal_Int32>( rOptions.GetIterCount() ); break; case PROP_UNO_ITEREPSILON: aRet <<= rOptions.GetIterEps(); @@ -173,7 +173,7 @@ uno::Any ScDocOptionsHelper::getPropertyValue( aRet <<= rOptions.IsAutoSpell(); break; case PROP_UNO_STANDARDDEC : - aRet <<= (sal_Int16)( rOptions.GetStdPrecision() ); + aRet <<= static_cast<sal_Int16>( rOptions.GetStdPrecision() ); break; case PROP_UNO_REGEXENABLED: aRet <<= rOptions.IsFormulaRegexEnabled(); diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx index 3741a8a17265..881c5f9834a3 100644 --- a/sc/source/ui/unoobj/scdetect.cxx +++ b/sc/source/ui/unoobj/scdetect.cxx @@ -107,7 +107,7 @@ bool detectThisFormat(SvStream& rStr, const sal_uInt16* pSearch) if( nMuster < 0x0100 ) { // compare bytes - if( ( sal_uInt8 ) nMuster != nByte ) + if( static_cast<sal_uInt8>(nMuster) != nByte ) bSync = false; } else if( nMuster & M_DC ) @@ -115,12 +115,12 @@ bool detectThisFormat(SvStream& rStr, const sal_uInt16* pSearch) } else if( nMuster & M_ALT(0) ) { // alternative Bytes - sal_uInt8 nAnzAlt = ( sal_uInt8 ) nMuster; + sal_uInt8 nAnzAlt = static_cast<sal_uInt8>(nMuster); bSync = false; // first unsynchron while( nAnzAlt > 0 ) { pSearch++; - if( ( sal_uInt8 ) *pSearch == nByte ) + if( static_cast<sal_uInt8>(*pSearch) == nByte ) bSync = true; // only now synchronization nAnzAlt--; } diff --git a/sc/source/ui/unoobj/srchuno.cxx b/sc/source/ui/unoobj/srchuno.cxx index 9c9d52ff56f5..ffd0b1894ca0 100644 --- a/sc/source/ui/unoobj/srchuno.cxx +++ b/sc/source/ui/unoobj/srchuno.cxx @@ -166,9 +166,9 @@ uno::Any SAL_CALL ScCellSearchObj::getPropertyValue( const OUString& aPropertyNa else if (aPropertyName == SC_UNO_SRCHSIMREL) aRet <<= pSearchItem->IsLEVRelaxed(); else if (aPropertyName == SC_UNO_SRCHSTYLES) aRet <<= pSearchItem->GetPattern(); else if (aPropertyName == SC_UNO_SRCHWORDS) aRet <<= pSearchItem->GetWordOnly(); - else if (aPropertyName == SC_UNO_SRCHSIMADD) aRet <<= (sal_Int16) pSearchItem->GetLEVLonger(); - else if (aPropertyName == SC_UNO_SRCHSIMEX) aRet <<= (sal_Int16) pSearchItem->GetLEVOther(); - else if (aPropertyName == SC_UNO_SRCHSIMREM) aRet <<= (sal_Int16) pSearchItem->GetLEVShorter(); + else if (aPropertyName == SC_UNO_SRCHSIMADD) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVLonger()); + else if (aPropertyName == SC_UNO_SRCHSIMEX) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVOther()); + else if (aPropertyName == SC_UNO_SRCHSIMREM) aRet <<= static_cast<sal_Int16>(pSearchItem->GetLEVShorter()); else if (aPropertyName == SC_UNO_SRCHTYPE) aRet <<= (sal_Int16) pSearchItem->GetCellType(); else if (aPropertyName == SC_UNO_SRCHFILTERED) aRet <<= pSearchItem->IsSearchFiltered(); else if (aPropertyName == SC_UNO_SRCHFORMATTED) aRet <<= pSearchItem->IsSearchFormatted(); diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index 3cbecb95c7d4..1b38a451a033 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -626,7 +626,7 @@ ScStyleObj* ScStyleFamilyObj::GetObjectByIndex_Impl(sal_uInt32 nIndex) SfxStyleSheetIterator aIter( pStylePool, eFamily ); if ( nIndex < aIter.Count() ) { - SfxStyleSheetBase* pStyle = aIter[(sal_uInt16)nIndex]; + SfxStyleSheetBase* pStyle = aIter[static_cast<sal_uInt16>(nIndex)]; if ( pStyle ) { return new ScStyleObj( pDocShell, eFamily, pStyle->GetName() ); @@ -1558,7 +1558,7 @@ void ScStyleObj::setPropertyValue_Impl( const OUString& rPropertyName, const Sfx { sal_Int16 nVal = 0; *pValue >>= nVal; - rSet.Put( SfxUInt16Item( pEntry->nWID, (sal_uInt16)HMMToTwips(nVal) ) ); + rSet.Put( SfxUInt16Item( pEntry->nWID, static_cast<sal_uInt16>(HMMToTwips(nVal)) ) ); } break; case ATTR_ROTATE_VALUE: @@ -1651,7 +1651,7 @@ void ScStyleObj::setPropertyValue_Impl( const OUString& rPropertyName, const Sfx for (sal_uInt16 i=0; i<nCount; i++) if ( aName == pPrinter->GetPaperBinName(i) ) { - nTray = (sal_uInt8) i; + nTray = static_cast<sal_uInt8>(i); bFound = true; break; } diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx index 54bec9d48568..5419c1b40833 100644 --- a/sc/source/ui/unoobj/tokenuno.cxx +++ b/sc/source/ui/unoobj/tokenuno.cxx @@ -372,7 +372,7 @@ bool ScTokenConversion::ConvertToTokenSequence( const ScDocument& rDoc, case svByte: // Only the count of spaces is stored as "long". Parameter count is ignored. if ( eOpCode == ocSpaces ) - rAPI.Data <<= (sal_Int32) rToken.GetByte(); + rAPI.Data <<= static_cast<sal_Int32>(rToken.GetByte()); else rAPI.Data.clear(); // no data break; diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index 9e25bbfefec0..511b14ec3498 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -205,7 +205,7 @@ void SAL_CALL ScViewPaneBase::setFirstVisibleColumn(sal_Int32 nFirstVisibleColum (ScSplitPos) nPane; ScHSplitPos eWhichH = WhichH( eWhich ); - long nDeltaX = ((long)nFirstVisibleColumn) - rViewData.GetPosX( eWhichH ); + long nDeltaX = static_cast<long>(nFirstVisibleColumn) - rViewData.GetPosX( eWhichH ); pViewShell->ScrollX( nDeltaX, eWhichH ); } } @@ -238,7 +238,7 @@ void SAL_CALL ScViewPaneBase::setFirstVisibleRow( sal_Int32 nFirstVisibleRow ) (ScSplitPos) nPane; ScVSplitPos eWhichV = WhichV( eWhich ); - long nDeltaY = ((long)nFirstVisibleRow) - rViewData.GetPosY( eWhichV ); + long nDeltaY = static_cast<long>(nFirstVisibleRow) - rViewData.GetPosY( eWhichV ); pViewShell->ScrollY( nDeltaY, eWhichV ); } } @@ -283,8 +283,8 @@ uno::Reference<table::XCellRange> SAL_CALL ScViewPaneBase::getReferredCells() ScDocShell* pDocSh = pViewShell->GetViewData().GetDocShell(); table::CellRangeAddress aAdr(getVisibleRange()); //! helper function with ScRange? - ScRange aRange( (SCCOL)aAdr.StartColumn, (SCROW)aAdr.StartRow, aAdr.Sheet, - (SCCOL)aAdr.EndColumn, (SCROW)aAdr.EndRow, aAdr.Sheet ); + ScRange aRange( static_cast<SCCOL>(aAdr.StartColumn), static_cast<SCROW>(aAdr.StartRow), aAdr.Sheet, + static_cast<SCCOL>(aAdr.EndColumn), static_cast<SCROW>(aAdr.EndRow), aAdr.Sheet ); if ( aRange.aStart == aRange.aEnd ) return new ScCellObj( pDocSh, aRange.aStart ); else @@ -988,7 +988,7 @@ sal_Int32 SAL_CALL ScTabViewObj::getCount() uno::Any SAL_CALL ScTabViewObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; - uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl((sal_uInt16)nIndex)); + uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex))); if (!xPane.is()) throw lang::IndexOutOfBoundsException(); @@ -1126,8 +1126,8 @@ uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rP vcl::Window* pActiveWin = rData.GetActiveWin(); Point aPos = pActiveWin->PixelToLogic(rPoint); - sal_uInt16 nHitLog = (sal_uInt16) pActiveWin->PixelToLogic( - Size(pDrawView->GetHitTolerancePixel(),0)).Width(); + sal_uInt16 nHitLog = static_cast<sal_uInt16>(pActiveWin->PixelToLogic( + Size(pDrawView->GetHitTolerancePixel(),0)).Width()); const size_t nCount(pDrawPage->GetObjCount()); bool bFound(false); @@ -1406,7 +1406,7 @@ sal_Int16 ScTabViewObj::GetZoom() const if (pViewSh) { const Fraction& rZoomY = pViewSh->GetViewData().GetZoomY(); // Y will be shown - return (sal_Int16)long( rZoomY * 100 ); + return static_cast<sal_Int16>(long( rZoomY * 100 )); } return 0; } @@ -1653,7 +1653,7 @@ void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRow aWinStart = pWin->GetPosPixel(); ScViewData& rViewData = pViewSh->GetViewData(); - Point aSplit(rViewData.GetScrPos( (SCCOL)nColumns, (SCROW)nRows, SC_SPLIT_BOTTOMLEFT, true )); + Point aSplit(rViewData.GetScrPos( static_cast<SCCOL>(nColumns), static_cast<SCROW>(nRows), SC_SPLIT_BOTTOMLEFT, true )); aSplit += aWinStart; pViewSh->SplitAtPixel( aSplit ); @@ -1799,7 +1799,7 @@ void SAL_CALL ScTabViewObj::setPropertyValue( if ( aValue >>= nIntVal ) { //#i80528# adapt to new range eventually - if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW; + if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW); aNewOpt.SetObjMode( VOBJ_TYPE_OLE, (ScVObjMode)nIntVal); } @@ -1810,7 +1810,7 @@ void SAL_CALL ScTabViewObj::setPropertyValue( if ( aValue >>= nIntVal ) { //#i80528# adapt to new range eventually - if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW; + if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW); aNewOpt.SetObjMode( VOBJ_TYPE_CHART, (ScVObjMode)nIntVal); } @@ -1821,7 +1821,7 @@ void SAL_CALL ScTabViewObj::setPropertyValue( if ( aValue >>= nIntVal ) { //#i80528# adapt to new range eventually - if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW; + if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW); aNewOpt.SetObjMode( VOBJ_TYPE_DRAW, (ScVObjMode)nIntVal); } @@ -1905,10 +1905,10 @@ uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const OUString& aPropertyName aRet <<= rOpt.GetOption( VOPT_SYNTAX ); else if ( aPropertyName == SC_UNO_VERTSCROLL || aPropertyName == OLD_UNO_VERTSCROLL ) aRet <<= rOpt.GetOption( VOPT_VSCROLL ); - else if ( aPropertyName == SC_UNO_SHOWOBJ ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_OLE ) ); - else if ( aPropertyName == SC_UNO_SHOWCHARTS ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_CHART ) ); - else if ( aPropertyName == SC_UNO_SHOWDRAW ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) ); - else if ( aPropertyName == SC_UNO_GRIDCOLOR ) aRet <<= (sal_Int32)( rOpt.GetGridColor().GetColor() ); + else if ( aPropertyName == SC_UNO_SHOWOBJ ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_OLE ) ); + else if ( aPropertyName == SC_UNO_SHOWCHARTS ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_CHART ) ); + else if ( aPropertyName == SC_UNO_SHOWDRAW ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) ); + else if ( aPropertyName == SC_UNO_GRIDCOLOR ) aRet <<= static_cast<sal_Int32>( rOpt.GetGridColor().GetColor() ); else if ( aPropertyName == SC_UNO_VISAREA ) aRet <<= GetVisArea(); else if ( aPropertyName == SC_UNO_ZOOMTYPE ) aRet <<= GetZoomType(); else if ( aPropertyName == SC_UNO_ZOOMVALUE ) aRet <<= GetZoom(); diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 396eb3fcada3..e576308bcdfe 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -597,10 +597,10 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) ScSplitPos eWhich = pShell->GetViewData().GetActivePart(); sal_Int32 nValueX = pShell->GetViewData().GetPosX(WhichH(eWhich)); sal_Int32 nValueY = pShell->GetViewData().GetPosY(WhichV(eWhich)); - xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaSheetRange->getRow() - 1) ), - uno::makeAny( (sal_Int16)nValueY ), - uno::makeAny( (sal_Int16)(xVbaSheetRange->getColumn() - 1) ), - uno::makeAny( (sal_Int16)nValueX ) ); + xWindow->SmallScroll( uno::makeAny( static_cast<sal_Int16>(xVbaSheetRange->getRow() - 1) ), + uno::makeAny( static_cast<sal_Int16>(nValueY) ), + uno::makeAny( static_cast<sal_Int16>(xVbaSheetRange->getColumn() - 1) ), + uno::makeAny( static_cast<sal_Int16>(nValueX) ) ); gridWindow->GrabFocus(); } else @@ -637,10 +637,10 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) ScSplitPos eWhich = pShell->GetViewData().GetActivePart(); sal_Int32 nValueX = pShell->GetViewData().GetPosX(WhichH(eWhich)); sal_Int32 nValueY = pShell->GetViewData().GetPosY(WhichV(eWhich)); - xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaRange->getRow() - 1) ), - uno::makeAny( (sal_Int16)nValueY ), - uno::makeAny( (sal_Int16)(xVbaRange->getColumn() - 1) ), - uno::makeAny( (sal_Int16)nValueX ) ); + xWindow->SmallScroll( uno::makeAny( static_cast<sal_Int16>(xVbaRange->getRow() - 1) ), + uno::makeAny( static_cast<sal_Int16>(nValueY) ), + uno::makeAny( static_cast<sal_Int16>(xVbaRange->getColumn() - 1) ), + uno::makeAny( static_cast<sal_Int16>(nValueX) ) ); gridWindow->GrabFocus(); } else @@ -941,7 +941,7 @@ ScVbaApplication::getTemplatesPath() OUString SAL_CALL ScVbaApplication::getPathSeparator() { - return OUString( (sal_Unicode) SAL_PATHDELIMITER ); + return OUString( sal_Unicode(SAL_PATHDELIMITER) ); } OUString SAL_CALL diff --git a/sc/source/ui/vba/vbafont.cxx b/sc/source/ui/vba/vbafont.cxx index 3f51efced61f..38efe31db616 100644 --- a/sc/source/ui/vba/vbafont.cxx +++ b/sc/source/ui/vba/vbafont.cxx @@ -90,7 +90,7 @@ uno::Any SAL_CALL ScVbaFont::getColorIndex() { if(mbFormControl) - return uno::Any( (sal_Int32) 0 ); + return uno::Any( sal_Int32(0) ); if ( GetDataSet() ) if ( GetDataSet()->GetItemState( ATTR_FONT_COLOR) == SfxItemState::DONTCARE ) return aNULL(); diff --git a/sc/source/ui/vba/vbainterior.cxx b/sc/source/ui/vba/vbainterior.cxx index 91bfe2fae30e..f8ee6eec03fa 100644 --- a/sc/source/ui/vba/vbainterior.cxx +++ b/sc/source/ui/vba/vbainterior.cxx @@ -82,7 +82,7 @@ static PatternMap aPatternMap( lcl_getPatternMap() ); ScVbaInterior::ScVbaInterior( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< beans::XPropertySet >& xProps, ScDocument* pScDoc ) : ScVbaInterior_BASE( xParent, xContext ), m_xProps(xProps), m_pScDoc( pScDoc ) { // auto color - m_aPattColor.SetColor( (sal_uInt32)0x0 ); + m_aPattColor.SetColor( sal_uInt32(0x0) ); m_nPattern = 0; if ( !m_xProps.is() ) throw lang::IllegalArgumentException("properties", uno::Reference< uno::XInterface >(), 2 ); @@ -129,9 +129,9 @@ ScVbaInterior::SetMixedColor() // set mixed color Color aMixedColor; if( nPattern > 0 ) - aMixedColor = GetPatternColor( Color(nPatternColor), aBackColor, (sal_uInt32)nPattern ); + aMixedColor = GetPatternColor( Color(nPatternColor), aBackColor, static_cast<sal_uInt32>(nPattern) ); else - aMixedColor = GetPatternColor( aBackColor, aBackColor, (sal_uInt32)nPattern ); + aMixedColor = GetPatternColor( aBackColor, aBackColor, static_cast<sal_uInt32>(nPattern) ); sal_Int32 nMixedColor = aMixedColor.GetColor() & COLORMAST; m_xProps->setPropertyValue( BACKCOLOR , uno::makeAny( nMixedColor ) ); } diff --git a/sc/source/ui/vba/vbapagesetup.cxx b/sc/source/ui/vba/vbapagesetup.cxx index 288120c962f8..dd4a0169ee64 100644 --- a/sc/source/ui/vba/vbapagesetup.cxx +++ b/sc/source/ui/vba/vbapagesetup.cxx @@ -516,7 +516,7 @@ void SAL_CALL ScVbaPageSetup::setFirstPageNumber( sal_Int32 firstPageNumber) try { uno::Any aValue; - aValue <<= (sal_Int16)firstPageNumber; + aValue <<= static_cast<sal_Int16>(firstPageNumber); mxPageProps->setPropertyValue("FirstPageNumber", aValue ); } catch (const uno::Exception&) diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index added596c776..3e44a75d22cd 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -209,7 +209,7 @@ static double lcl_TwipsToPoints( sal_uInt16 nVal ) static double lcl_Round2DecPlaces( double nVal ) { - nVal = (nVal * (double)100); + nVal = (nVal * double(100)); long tmp = static_cast<long>(nVal); if ( ( nVal - tmp ) >= 0.5 ) ++tmp; @@ -729,9 +729,9 @@ CellValueSetter::processValue( const uno::Any& aValue, const uno::Reference< tab { uno::Reference< table::XCellRange > xRange( xCell, uno::UNO_QUERY_THROW ); if ( bState ) - xCell->setValue( (double) 1 ); + xCell->setValue( double(1) ); else - xCell->setValue( (double) 0 ); + xCell->setValue( double(0) ); NumFormatHelper cellNumFormat( xRange ); cellNumFormat.setNumberFormat( util::NumberFormat::LOGICAL ); } @@ -2762,8 +2762,8 @@ ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2, bool bForceUseI if ( nStartX <= nEndX && nEndX <= parentAddress.aEnd.Col() && nStartY <= nEndY && nEndY <= parentAddress.aEnd.Row() ) { - ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, parentAddress.aStart.Tab(), - (SCCOL)nEndX, (SCROW)nEndY, parentAddress.aEnd.Tab() ); + ScRange aNew( static_cast<SCCOL>(nStartX), static_cast<SCROW>(nStartY), parentAddress.aStart.Tab(), + static_cast<SCCOL>(nEndX), static_cast<SCROW>(nEndY), parentAddress.aEnd.Tab() ); xCellRange = new ScCellRangeObj( getScDocShell(), aNew ); } } @@ -3555,7 +3555,7 @@ ScVbaRange::End( ::sal_Int32 Direction ) OUString sActiveCell = xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft ); // position current cell upper left of this range - Cells( uno::makeAny( (sal_Int32) 1 ), uno::makeAny( (sal_Int32) 1 ) )->Select(); + Cells( uno::makeAny( sal_Int32(1) ), uno::makeAny( sal_Int32(1) ) )->Select(); uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange ); @@ -4303,7 +4303,7 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, const uno::Ref bool bIsNumeric = false; if ( sCriteria1.startsWith( EQUALS ) ) { - if ( sCriteria1.getLength() == (sal_Int32)strlen(EQUALS) ) + if ( sCriteria1.getLength() == static_cast<sal_Int32>(strlen(EQUALS)) ) rFilterField.Operator = sheet::FilterOperator2::EMPTY; else { @@ -4318,7 +4318,7 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, const uno::Ref } else if ( sCriteria1.startsWith( NOTEQUALS ) ) { - if ( sCriteria1.getLength() == (sal_Int32)strlen(NOTEQUALS) ) + if ( sCriteria1.getLength() == static_cast<sal_Int32>(strlen(NOTEQUALS)) ) rFilterField.Operator = sheet::FilterOperator2::NOT_EMPTY; else { @@ -4885,7 +4885,7 @@ uno::Any ScVbaRange::getShowDetail() ScDocument& rDoc = getDocumentFromRange( mxRange ); ScOutlineTable* pOutlineTable = rDoc.GetOutlineTable(static_cast<SCTAB>(thisAddress.Sheet), true); const ScOutlineArray& rOutlineArray = bColumn ? pOutlineTable->GetColArray(): pOutlineTable->GetRowArray(); - SCCOLROW nPos = bColumn ? (SCCOLROW)(thisAddress.EndColumn-1):(SCCOLROW)(thisAddress.EndRow-1); + SCCOLROW nPos = bColumn ? static_cast<SCCOLROW>(thisAddress.EndColumn-1):static_cast<SCCOLROW>(thisAddress.EndRow-1); const ScOutlineEntry* pEntry = rOutlineArray.GetEntryByPos( 0, nPos ); if( pEntry ) { diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index f4599a40b35f..c77bcb3a409e 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -1465,7 +1465,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) rReq.AppendItem( SfxBoolItem( FN_PARAM_3, bTranspose ) ); rReq.AppendItem( SfxBoolItem( FN_PARAM_4, bAsLink ) ); rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nFunction) ) ); - rReq.AppendItem( SfxInt16Item( FN_PARAM_5, (sal_Int16) eMoveMode ) ); + rReq.AppendItem( SfxInt16Item( FN_PARAM_5, static_cast<sal_Int16>(eMoveMode) ) ); rReq.Done(); } } @@ -2525,7 +2525,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) const OUString& rName = pHyper->GetName(); const OUString& rURL = pHyper->GetURL(); const OUString& rTarget = pHyper->GetTargetFrame(); - sal_uInt16 nType = (sal_uInt16) pHyper->GetInsertMode(); + sal_uInt16 nType = static_cast<sal_uInt16>(pHyper->GetInsertMode()); pTabViewShell->InsertURL( rName, rURL, rTarget, nType ); rReq.Done(); diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index f0a77deca879..d40a11d2dd79 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -576,10 +576,10 @@ void ScCellShell::Execute( SfxRequest& rReq ) if ( pDlg->Execute() == RET_OK ) { long nVal = pDlg->GetInputValue(); - pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT, (sal_uInt16)nVal ); + pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT, static_cast<sal_uInt16>(nVal) ); // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert - rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) ); + rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal)) ) ); rReq.Done(); } @@ -616,11 +616,11 @@ void ScCellShell::Execute( SfxRequest& rReq ) if ( pDlg->Execute() == RET_OK ) { long nVal = pDlg->GetInputValue(); - pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL, (sal_uInt16)nVal ); + pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL, static_cast<sal_uInt16>(nVal) ); ScGlobal::nLastRowHeightExtra = nVal; // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert - rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) ); + rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal)) ) ); rReq.Done(); } @@ -681,10 +681,10 @@ void ScCellShell::Execute( SfxRequest& rReq ) if ( pDlg->Execute() == RET_OK ) { long nVal = pDlg->GetInputValue(); - pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT, (sal_uInt16)nVal ); + pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT, static_cast<sal_uInt16>(nVal) ); // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert - rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal)) ); + rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal))) ); rReq.Done(); } @@ -720,11 +720,11 @@ void ScCellShell::Execute( SfxRequest& rReq ) if ( pDlg->Execute() == RET_OK ) { long nVal = pDlg->GetInputValue(); - pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL, (sal_uInt16)nVal ); + pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL, static_cast<sal_uInt16>(nVal) ); ScGlobal::nLastColWidthExtra = nVal; // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert - rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal) ) ); + rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal)) ) ); rReq.Done(); } } diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx index 246fd7b5238a..f1636efe1509 100644 --- a/sc/source/ui/view/colrowba.cxx +++ b/sc/source/ui/view/colrowba.cxx @@ -74,7 +74,7 @@ sal_uInt16 ScColBar::GetEntrySize( SCCOLROW nEntryNo ) const if (pDoc->ColHidden(static_cast<SCCOL>(nEntryNo), nTab)) return 0; else - return (sal_uInt16) ScViewData::ToPixel( pDoc->GetColWidth( static_cast<SCCOL>(nEntryNo), nTab ), rViewData.GetPPTX() ); + return static_cast<sal_uInt16>(ScViewData::ToPixel( pDoc->GetColWidth( static_cast<SCCOL>(nEntryNo), nTab ), rViewData.GetPPTX() )); } OUString ScColBar::GetEntryText( SCCOLROW nEntryNo ) const @@ -97,7 +97,7 @@ void ScColBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize ) eMode = SC_SIZE_OPTIMAL; } else - nSizeTwips = (sal_uInt16) ( nNewSize / rViewData.GetPPTX() ); + nSizeTwips = static_cast<sal_uInt16>( nNewSize / rViewData.GetPPTX() ); const ScMarkData& rMark = rViewData.GetMarkData(); @@ -196,7 +196,7 @@ void ScColBar::DrawInvert( long nDragPosP ) OUString ScColBar::GetDragHelp( long nVal ) { - long nTwips = (long) ( nVal / pTabView->GetViewData().GetPPTX() ); + long nTwips = static_cast<long>( nVal / pTabView->GetViewData().GetPPTX() ); return lcl_MetricString( nTwips, ScGlobal::GetRscString(STR_TIP_WIDTH) ); } @@ -234,8 +234,8 @@ sal_uInt16 ScRowBar::GetEntrySize( SCCOLROW nEntryNo ) const if (pDoc->RowHidden(nEntryNo, nTab, nullptr, &nLastRow)) return 0; else - return (sal_uInt16) ScViewData::ToPixel( pDoc->GetOriginalHeight( nEntryNo, - nTab ), rViewData.GetPPTY() ); + return static_cast<sal_uInt16>(ScViewData::ToPixel( pDoc->GetOriginalHeight( nEntryNo, + nTab ), rViewData.GetPPTY() )); } OUString ScRowBar::GetEntryText( SCCOLROW nEntryNo ) const @@ -256,7 +256,7 @@ void ScRowBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize ) eMode = SC_SIZE_OPTIMAL; } else - nSizeTwips = (sal_uInt16) ( nNewSize / rViewData.GetPPTY() ); + nSizeTwips = static_cast<sal_uInt16>( nNewSize / rViewData.GetPPTY() ); const ScMarkData& rMark = rViewData.GetMarkData(); @@ -355,7 +355,7 @@ void ScRowBar::DrawInvert( long nDragPosP ) OUString ScRowBar::GetDragHelp( long nVal ) { - long nTwips = (long) ( nVal / pTabView->GetViewData().GetPPTY() ); + long nTwips = static_cast<long>( nVal / pTabView->GetViewData().GetPPTY() ); return lcl_MetricString( nTwips, ScGlobal::GetRscString(STR_TIP_HEIGHT) ); } diff --git a/sc/source/ui/view/drawutil.cxx b/sc/source/ui/view/drawutil.cxx index 435c0854fa5d..ff859eb2074c 100644 --- a/sc/source/ui/view/drawutil.cxx +++ b/sc/source/ui/view/drawutil.cxx @@ -38,7 +38,7 @@ void ScDrawUtil::CalcScale( const ScDocument* pDoc, SCTAB nTab, for (SCCOL i=nStartCol; i<nEndCol; i++) { sal_uInt16 nWidth = pDoc->GetColWidth(i,nTab); - nTwipsX += (long) nWidth; + nTwipsX += static_cast<long>(nWidth); nPixelX += ScViewData::ToPixel( nWidth, nPPTX ); } @@ -63,20 +63,20 @@ void ScDrawUtil::CalcScale( const ScDocument* pDoc, SCTAB nTab, // because ReduceInaccurate is called later anyway. if ( aPixelLog.X() && nTwipsX ) - rScaleX = Fraction( ((double)aPixelLog.X()) * - ((double)rZoomX.GetNumerator()) / - ((double)nTwipsX) / + rScaleX = Fraction( static_cast<double>(aPixelLog.X()) * + static_cast<double>(rZoomX.GetNumerator()) / + static_cast<double>(nTwipsX) / HMM_PER_TWIPS / - ((double)rZoomX.GetDenominator()) ); + static_cast<double>(rZoomX.GetDenominator()) ); else rScaleX = Fraction( 1, 1 ); if ( aPixelLog.Y() && nTwipsY ) - rScaleY = Fraction( ((double)aPixelLog.Y()) * - ((double)rZoomY.GetNumerator()) / - ((double)nTwipsY) / + rScaleY = Fraction( static_cast<double>(aPixelLog.Y()) * + static_cast<double>(rZoomY.GetNumerator()) / + static_cast<double>(nTwipsY) / HMM_PER_TWIPS / - ((double)rZoomY.GetDenominator()) ); + static_cast<double>(rZoomY.GetDenominator()) ); else rScaleY = Fraction( 1, 1 ); diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index 9cbac20a0fc8..2b08da9db8ca 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -614,7 +614,7 @@ void ScEditShell::Execute( SfxRequest& rReq ) if (!bDone) { pViewData->GetViewShell()-> - InsertURL( rName, rURL, rTarget, (sal_uInt16) eMode ); + InsertURL( rName, rURL, rTarget, static_cast<sal_uInt16>(eMode) ); // when "Button", the InsertURL in ViewShell turns the EditShell off // thus the immediate return statement diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index a8cfadc0dfab..ba95dba00a56 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -1232,10 +1232,10 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq ) break; } - const bool bThousand = (bool)sFormat[0].toInt32(); - const bool bNegRed = (bool)sFormat[1].toInt32(); - const sal_uInt16 nPrecision = (sal_uInt16)sFormat[2].toInt32(); - const sal_uInt16 nLeadZeroes = (sal_uInt16)sFormat[3].toInt32(); + const bool bThousand = static_cast<bool>(sFormat[0].toInt32()); + const bool bNegRed = static_cast<bool>(sFormat[1].toInt32()); + const sal_uInt16 nPrecision = static_cast<sal_uInt16>(sFormat[2].toInt32()); + const sal_uInt16 nLeadZeroes = static_cast<sal_uInt16>(sFormat[3].toInt32()); aCode = pFormatter->GenerateFormat( nCurrentNumberFormat,//modify diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 1d1cae4a5dc2..84ad31b969da 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -4654,7 +4654,7 @@ bool ScGridWindow::HitRangeFinder( const Point& rMouse, RfCorner& rCorner, bool bCornerVerticalUp = rMouse.Y() >= aCellStart.Y() && rMouse.Y() <= aCellStart.Y() + 8; // corner is hit only if the mouse is within the cell - sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count(); + sal_uInt16 nCount = static_cast<sal_uInt16>(pRangeFinder->Count()); for (sal_uInt16 i=nCount; i;) { // search backwards so that the last repainted frame is found @@ -4953,10 +4953,10 @@ void ScGridWindow::RFMouseMove( const MouseEvent& rMEvt, bool bUp ) nEndY = MAXROW; } - aNew.aStart.SetCol((SCCOL)nStartX); - aNew.aStart.SetRow((SCROW)nStartY); - aNew.aEnd.SetCol((SCCOL)nEndX); - aNew.aEnd.SetRow((SCROW)nEndY); + aNew.aStart.SetCol(static_cast<SCCOL>(nStartX)); + aNew.aStart.SetRow(static_cast<SCROW>(nStartY)); + aNew.aEnd.SetCol(static_cast<SCCOL>(nEndX)); + aNew.aEnd.SetRow(static_cast<SCROW>(nEndY)); } if ( bUp ) @@ -5244,7 +5244,7 @@ bool ScGridWindow::HasScenarioButton( const Point& rPosPixel, ScRange& rScenRang if (!nBWidth) return false; // No Button drawn yet -> there is none long nBHeight = aButSize.Height(); - long nHSpace = (long)( SC_SCENARIO_HSPACE * pViewData->GetPPTX() ); + long nHSpace = static_cast<long>( SC_SCENARIO_HSPACE * pViewData->GetPPTX() ); //! cache the Ranges in Table!!!! diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 9387c1e6d79c..5bfda7ea5915 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -97,8 +97,8 @@ static void lcl_DrawOneFrame( vcl::RenderContext* pDev, const tools::Rectangle& lcl_LimitRect( aInner, aVisible ); tools::Rectangle aOuter = aInner; - long nHor = (long) ( SC_SCENARIO_HSPACE * nPPTX ); - long nVer = (long) ( SC_SCENARIO_VSPACE * nPPTY ); + long nHor = static_cast<long>( SC_SCENARIO_HSPACE * nPPTX ); + long nVer = static_cast<long>( SC_SCENARIO_VSPACE * nPPTY ); aOuter.Left() -= nHor; aOuter.Right() += nHor; aOuter.Top() -= nVer; @@ -842,7 +842,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI if ( pRangeFinder && !pRangeFinder->IsHidden() && pRangeFinder->GetDocName() == pDocSh->GetTitle() ) { - sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count(); + sal_uInt16 nCount = static_cast<sal_uInt16>(pRangeFinder->Count()); for (sal_uInt16 i=0; i<nCount; i++) { ScRangeFindData& rData = pRangeFinder->GetObject(i); @@ -1461,9 +1461,9 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, long nPageNo = rData.GetFirstPage(); if ( rData.IsTopDown() ) - nPageNo += ((long)nColPos)*nRowBreaks+nRowPos; + nPageNo += static_cast<long>(nColPos)*nRowBreaks+nRowPos; else - nPageNo += ((long)nRowPos)*nColBreaks+nColPos; + nPageNo += static_cast<long>(nRowPos)*nColBreaks+nColPos; OUString aThisPageStr = aPageStr.replaceFirst("%1", OUString::number(nPageNo)); diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx index 96d388c0483e..07b69115fdc8 100644 --- a/sc/source/ui/view/hdrcont.cxx +++ b/sc/source/ui/view/hdrcont.cxx @@ -272,9 +272,9 @@ void ScHeaderControl::Paint( vcl::RenderContext& /*rRenderContext*/, const tools Size aTextSize; if (bVertical) - nBarSize = (sal_uInt16) GetSizePixel().Width(); + nBarSize = static_cast<sal_uInt16>(GetSizePixel().Width()); else - nBarSize = (sal_uInt16) GetSizePixel().Height(); + nBarSize = static_cast<sal_uInt16>(GetSizePixel().Height()); SCCOLROW nPos = GetPos(); @@ -786,7 +786,7 @@ void ScHeaderControl::MouseButtonUp( const MouseEvent& rMEvt ) else { if (bDragMoved) - SetEntrySize( nDragNo, (sal_uInt16) nNewWidth ); + SetEntrySize( nDragNo, static_cast<sal_uInt16>(nNewWidth) ); } } else diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 6cfa4c2861b1..bd3687cd1cd3 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -1220,9 +1220,9 @@ void ScOutputData::DrawExtraShadow(bool bLeft, bool bTop, bool bRight, bool bBot nPosY + pRowInfo[nArrY].nHeight - 1 ); long nSize = pAttr->GetWidth(); - long nSizeX = (long)(nSize*mnPPTX); + long nSizeX = static_cast<long>(nSize*mnPPTX); if (nSizeX >= nMaxWidth) nSizeX = nMaxWidth-1; - long nSizeY = (long)(nSize*mnPPTY); + long nSizeY = static_cast<long>(nSize*mnPPTY); if (nSizeY >= nRowHeight) nSizeY = nRowHeight-1; nSizeX *= nLayoutSign; // used only to add to rectangle values @@ -1562,7 +1562,7 @@ void ScOutputData::DrawRotatedFrame(vcl::RenderContext& rRenderContext) while (nCol > nX) { --nCol; - nPosX -= nLayoutSign * (long)pRowInfo[0].pCellInfo[nCol + 1].nWidth; + nPosX -= nLayoutSign * static_cast<long>(pRowInfo[0].pCellInfo[nCol + 1].nWidth); } } @@ -1582,7 +1582,7 @@ void ScOutputData::DrawRotatedFrame(vcl::RenderContext& rRenderContext) double nCos = cos(nRealOrient); double nSin = sin(nRealOrient); //! restrict !!! - long nSkew = (long)(nRowHeight * nCos / nSin); + long nSkew = static_cast<long>(nRowHeight * nCos / nSin); switch (eRotMode) { @@ -2262,8 +2262,8 @@ void ScOutputData::AddPDFNotes() if ( mpDoc->GetNote(nMergeX, nMergeY, nTab) && ( bIsMerged || ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) ) { - long nNoteWidth = (long)( SC_CLIPMARK_SIZE * mnPPTX ); - long nNoteHeight = (long)( SC_CLIPMARK_SIZE * mnPPTY ); + long nNoteWidth = static_cast<long>( SC_CLIPMARK_SIZE * mnPPTX ); + long nNoteHeight = static_cast<long>( SC_CLIPMARK_SIZE * mnPPTY ); long nMarkX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - nNoteWidth ) * nLayoutSign; if ( bIsMerged || pInfo->bMerged ) @@ -2352,26 +2352,26 @@ void ScOutputData::DrawClipMarks() nOverX, nOverY, nTab, ATTR_MERGE_FLAG ))->GetValue() & ScMF::Hor ) ) { --nOverX; - nStartPosX -= nLayoutSign * (long) ( mpDoc->GetColWidth(nOverX,nTab) * mnPPTX ); + 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 ) ) { --nOverY; - nStartPosY -= nLayoutSign * (long) ( mpDoc->GetRowHeight(nOverY,nTab) * mnPPTY ); + nStartPosY -= nLayoutSign * static_cast<long>( mpDoc->GetRowHeight(nOverY,nTab) * mnPPTY ); } - long nOutWidth = (long) ( mpDoc->GetColWidth(nOverX,nTab) * mnPPTX ); - long nOutHeight = (long) ( mpDoc->GetRowHeight(nOverY,nTab) * mnPPTY ); + 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 )); SCCOL nCountX = pMerge->GetColMerge(); for (SCCOL i=1; i<nCountX; i++) - nOutWidth += (long) ( mpDoc->GetColWidth(nOverX+i,nTab) * mnPPTX ); + nOutWidth += static_cast<long>( mpDoc->GetColWidth(nOverX+i,nTab) * mnPPTX ); SCROW nCountY = pMerge->GetRowMerge(); - nOutHeight += (long) mpDoc->GetScaledRowHeight( nOverY+1, nOverY+nCountY-1, nTab, mnPPTY); + nOutHeight += static_cast<long>(mpDoc->GetScaledRowHeight( nOverY+1, nOverY+nCountY-1, nTab, mnPPTY)); if ( bLayoutRTL ) nStartPosX -= nOutWidth - 1; @@ -2390,9 +2390,9 @@ void ScOutputData::DrawClipMarks() &pInfo->pPatternAttr->GetItem(ATTR_MERGE); SCCOL nCountX = pMerge->GetColMerge(); for (SCCOL i=1; i<nCountX; i++) - nOutWidth += (long) ( mpDoc->GetColWidth(nOverX+i,nTab) * mnPPTX ); + nOutWidth += static_cast<long>( mpDoc->GetColWidth(nOverX+i,nTab) * mnPPTX ); SCROW nCountY = pMerge->GetRowMerge(); - nOutHeight += (long) mpDoc->GetScaledRowHeight( nOverY+1, nOverY+nCountY-1, nTab, mnPPTY); + nOutHeight += static_cast<long>(mpDoc->GetScaledRowHeight( nOverY+1, nOverY+nCountY-1, nTab, mnPPTY)); } long nStartPosX = nPosX; @@ -2409,7 +2409,7 @@ void ScOutputData::DrawClipMarks() else aCellRect.Right() -= 1; - long nMarkPixel = (long)( SC_CLIPMARK_SIZE * mnPPTX ); + long nMarkPixel = static_cast<long>( SC_CLIPMARK_SIZE * mnPPTX ); Size aMarkSize( nMarkPixel, (nMarkPixel-1)*2 ); if ( pInfo->nClipMark & ( bLayoutRTL ? ScClipMark::Right : ScClipMark::Left ) ) diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 9e0d761e64d8..c4d47392f141 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -700,7 +700,7 @@ void ScDrawStringsVars::SetAutoText( const OUString& rAutoText ) if ( !pRefDevice->GetConnectMetaFile() || pRefDevice->GetOutDevType() == OUTDEV_PRINTER ) { double fMul = pOutput->GetStretch(); - aTextSize.Width() = (long)(aTextSize.Width() / fMul + 0.5); + aTextSize.Width() = static_cast<long>(aTextSize.Width() / fMul + 0.5); } aTextSize.Height() = aMetric.GetAscent() + aMetric.GetDescent(); @@ -770,7 +770,7 @@ void ScDrawStringsVars::TextChanged() if ( !pRefDevice->GetConnectMetaFile() || pRefDevice->GetOutDevType() == OUTDEV_PRINTER ) { double fMul = pOutput->GetStretch(); - aTextSize.Width() = (long)(aTextSize.Width() / fMul + 0.5); + aTextSize.Width() = static_cast<long>(aTextSize.Width() / fMul + 0.5); } aTextSize.Height() = aMetric.GetAscent() + aMetric.GetDescent(); @@ -825,12 +825,12 @@ double ScOutputData::GetStretch() if ( mpRefDevice == pFmtDevice ) { MapMode aOld = mpRefDevice->GetMapMode(); - return ((double)aOld.GetScaleY()) / ((double)aOld.GetScaleX()) * ((double)aZoomY) / ((double)aZoomX); + return static_cast<double>(aOld.GetScaleY()) / static_cast<double>(aOld.GetScaleX()) * static_cast<double>(aZoomY) / static_cast<double>(aZoomX); } else { // when formatting for printer, device map mode has already been taken care of - return ((double)aZoomY) / ((double)aZoomX); + return static_cast<double>(aZoomY) / static_cast<double>(aZoomX); } } @@ -1168,7 +1168,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY //! extra member function for width? long nColWidth = ( nCompCol <= nX2 ) ? pRowInfo[0].pCellInfo[nCompCol+1].nWidth : - (long) ( mpDoc->GetColWidth( nCompCol, nTab ) * mnPPTX ); + static_cast<long>( mpDoc->GetColWidth( nCompCol, nTab ) * mnPPTX ); nCellPosX += nColWidth * nLayoutSign; ++nCompCol; } @@ -1177,7 +1177,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY --nCompCol; long nColWidth = ( nCompCol <= nX2 ) ? pRowInfo[0].pCellInfo[nCompCol+1].nWidth : - (long) ( mpDoc->GetColWidth( nCompCol, nTab ) * mnPPTX ); + static_cast<long>( mpDoc->GetColWidth( nCompCol, nTab ) * mnPPTX ); nCellPosX -= nColWidth * nLayoutSign; } @@ -1196,11 +1196,11 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY { sal_uInt16 nDocHeight = mpDoc->GetRowHeight( nCompRow, nTab ); if ( nDocHeight ) - nCellPosY += (long) ( nDocHeight * mnPPTY ); + nCellPosY += static_cast<long>( nDocHeight * mnPPTY ); ++nCompRow; } } - nCellPosY -= (long) mpDoc->GetScaledRowHeight( nCellY, nCompRow-1, nTab, mnPPTY ); + nCellPosY -= static_cast<long>(mpDoc->GetScaledRowHeight( nCellY, nCompRow-1, nTab, mnPPTY )); const ScMergeAttr* pMerge = &rPattern.GetItem( ATTR_MERGE ); bool bMerged = pMerge->IsMerged(); @@ -1216,7 +1216,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY { long nColWidth = ( nCellX+i <= nX2 ) ? pRowInfo[0].pCellInfo[nCellX+i+1].nWidth : - (long) ( mpDoc->GetColWidth( sal::static_int_cast<SCCOL>(nCellX+i), nTab ) * mnPPTX ); + static_cast<long>( mpDoc->GetColWidth( sal::static_int_cast<SCCOL>(nCellX+i), nTab ) * mnPPTX ); nMergeSizeX += nColWidth; } long nMergeSizeY = 0; @@ -1228,7 +1228,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY nDirect = 1; // skip in loop } // following rows always from document - nMergeSizeY += (long) mpDoc->GetScaledRowHeight( nCellY+nDirect, nCellY+nMergeRows-1, nTab, mnPPTY); + nMergeSizeY += static_cast<long>(mpDoc->GetScaledRowHeight( nCellY+nDirect, nCellY+nMergeRows-1, nTab, mnPPTY)); --nMergeSizeX; // leave out the grid horizontally, also for alignment (align between grid lines) @@ -1286,7 +1286,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY while ( nRightMissing > 0 && nRightX < MAXCOL && ( bOverwrite || IsAvailable( nRightX+1, nCellY ) ) ) { ++nRightX; - long nAdd = (long) ( mpDoc->GetColWidth( nRightX, nTab ) * mnPPTX ); + long nAdd = static_cast<long>( mpDoc->GetColWidth( nRightX, nTab ) * mnPPTX ); nRightMissing -= nAdd; rParam.maClipRect.Right() += nAdd * nLayoutSign; @@ -1300,7 +1300,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY rThisRowInfo.pCellInfo[nLeftX].bHideGrid = true; --nLeftX; - long nAdd = (long) ( mpDoc->GetColWidth( nLeftX, nTab ) * mnPPTX ); + long nAdd = static_cast<long>( mpDoc->GetColWidth( nLeftX, nTab ) * mnPPTX ); nLeftMissing -= nAdd; rParam.maClipRect.Left() -= nAdd * nLayoutSign; } @@ -1312,14 +1312,14 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY { rThisRowInfo.pCellInfo[nRightX+1].nClipMark |= ScClipMark::Right; bAnyClipped = true; - long nMarkPixel = (long)( SC_CLIPMARK_SIZE * mnPPTX ); + long nMarkPixel = static_cast<long>( SC_CLIPMARK_SIZE * mnPPTX ); rParam.maClipRect.Right() -= nMarkPixel * nLayoutSign; } if ( nLeftMissing > 0 && bMarkClipped && nLeftX >= nX1 && nLeftX <= nX2 && !bBreak && !bCellIsValue ) { rThisRowInfo.pCellInfo[nLeftX+1].nClipMark |= ScClipMark::Left; bAnyClipped = true; - long nMarkPixel = (long)( SC_CLIPMARK_SIZE * mnPPTX ); + long nMarkPixel = static_cast<long>( SC_CLIPMARK_SIZE * mnPPTX ); rParam.maClipRect.Left() += nMarkPixel * nLayoutSign; } @@ -1802,8 +1802,8 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co else { long nHeight = aVars.GetTextSize().Height() + - (long)(aVars.GetMargin()->GetTopMargin()*mnPPTY) + - (long)(aVars.GetMargin()->GetBottomMargin()*mnPPTY); + static_cast<long>(aVars.GetMargin()->GetTopMargin()*mnPPTY) + + static_cast<long>(aVars.GetMargin()->GetBottomMargin()*mnPPTY); bNeedEdit = ( nHeight > aAreaParam.maClipRect.GetHeight() ); } } @@ -1835,8 +1835,8 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co aVars.SetTextToWidthOrHash(aCell, aAreaParam.mnColWidth - nTotalMargin); nNeededWidth = aVars.GetTextSize().Width() + - (long) ( aVars.GetLeftTotal() * mnPPTX ) + - (long) ( aVars.GetMargin()->GetRightMargin() * mnPPTX ); + static_cast<long>( aVars.GetLeftTotal() * mnPPTX ) + + static_cast<long>( aVars.GetMargin()->GetRightMargin() * mnPPTX ); if ( nNeededWidth <= aAreaParam.maClipRect.GetWidth() ) { // Cell value is no longer clipped. Reset relevant parameters. @@ -1867,17 +1867,17 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co switch (eOutHorJust) { case SvxCellHorJustify::Left: - nJustPosX += (long) ( aVars.GetLeftTotal() * mnPPTX ); + nJustPosX += static_cast<long>( aVars.GetLeftTotal() * mnPPTX ); break; case SvxCellHorJustify::Right: nJustPosX += nAvailWidth - aVars.GetTextSize().Width() - - (long) ( aVars.GetRightTotal() * mnPPTX ); + static_cast<long>( aVars.GetRightTotal() * mnPPTX ); bRightAdjusted = true; break; case SvxCellHorJustify::Center: nJustPosX += ( nAvailWidth - aVars.GetTextSize().Width() + - (long) ( aVars.GetLeftTotal() * mnPPTX ) - - (long) ( aVars.GetMargin()->GetRightMargin() * mnPPTX ) ) / 2; + static_cast<long>( aVars.GetLeftTotal() * mnPPTX ) - + static_cast<long>( aVars.GetMargin()->GetRightMargin() * mnPPTX ) ) / 2; break; default: { @@ -1891,22 +1891,22 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co case SvxCellVerJustify::Top: case SvxCellVerJustify::Block: { - long nTop = (long)( aVars.GetMargin()->GetTopMargin() * mnPPTY ); + long nTop = static_cast<long>( aVars.GetMargin()->GetTopMargin() * mnPPTY ); nJustPosY += nTop; nTestClipHeight += nTop; } break; case SvxCellVerJustify::Bottom: { - long nBot = (long)( aVars.GetMargin()->GetBottomMargin() * mnPPTY ); + long nBot = static_cast<long>( aVars.GetMargin()->GetBottomMargin() * mnPPTY ); nJustPosY += nOutHeight - aVars.GetTextSize().Height() - nBot; nTestClipHeight += nBot; } break; case SvxCellVerJustify::Center: { - long nTop = (long)( aVars.GetMargin()->GetTopMargin() * mnPPTY ); - long nBot = (long)( aVars.GetMargin()->GetBottomMargin() * mnPPTY ); + long nTop = static_cast<long>( aVars.GetMargin()->GetTopMargin() * mnPPTY ); + long nBot = static_cast<long>( aVars.GetMargin()->GetBottomMargin() * mnPPTY ); nJustPosY += ( nOutHeight + nTop - aVars.GetTextSize().Height() - nBot ) / 2; nTestClipHeight += std::abs( nTop - nBot ); @@ -2208,7 +2208,7 @@ static long lcl_GetEditSize( EditEngine& rEngine, bool bWidth, bool bSwap, long if ( nAttrRotate ) { - long nRealWidth = (long) rEngine.CalcTextWidth(); + long nRealWidth = static_cast<long>(rEngine.CalcTextWidth()); long nRealHeight = rEngine.GetTextHeight(); // assuming standard mode, otherwise width isn't used @@ -2217,12 +2217,12 @@ static long lcl_GetEditSize( EditEngine& rEngine, bool bWidth, bool bSwap, long double nAbsCos = fabs( cos( nRealOrient ) ); double nAbsSin = fabs( sin( nRealOrient ) ); if ( bWidth ) - return (long) ( nRealWidth * nAbsCos + nRealHeight * nAbsSin ); + return static_cast<long>( nRealWidth * nAbsCos + nRealHeight * nAbsSin ); else - return (long) ( nRealHeight * nAbsCos + nRealWidth * nAbsSin ); + return static_cast<long>( nRealHeight * nAbsCos + nRealWidth * nAbsSin ); } else if ( bWidth ) - return (long) rEngine.CalcTextWidth(); + return static_cast<long>(rEngine.CalcTextWidth()); else return rEngine.GetTextHeight(); } @@ -2707,7 +2707,7 @@ void ScOutputData::DrawEditParam::adjustForHyperlinkInPDF(Point aURLStart, const if (!bHasURL) return; - long nURLWidth = (long) mpEngine->CalcTextWidth(); + long nURLWidth = static_cast<long>(mpEngine->CalcTextWidth()); long nURLHeight = mpEngine->GetTextHeight(); if (mbBreak) { @@ -3081,7 +3081,7 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam) pClipMarkCell->nClipMark |= ScClipMark::Right; //! also allow left? bAnyClipped = true; - long nMarkPixel = (long)( SC_CLIPMARK_SIZE * mnPPTX ); + long nMarkPixel = static_cast<long>( SC_CLIPMARK_SIZE * mnPPTX ); if ( aAreaParam.maClipRect.Right() - nMarkPixel > aAreaParam.maClipRect.Left() ) aAreaParam.maClipRect.Right() -= nMarkPixel; } @@ -3919,7 +3919,7 @@ void ScOutputData::DrawEditStacked(DrawEditParam& rParam) pClipMarkCell->nClipMark |= ScClipMark::Right; //! also allow left? bAnyClipped = true; - long nMarkPixel = (long)( SC_CLIPMARK_SIZE * mnPPTX ); + long nMarkPixel = static_cast<long>( SC_CLIPMARK_SIZE * mnPPTX ); if ( aAreaParam.maClipRect.Right() - nMarkPixel > aAreaParam.maClipRect.Left() ) aAreaParam.maClipRect.Right() -= nMarkPixel; } @@ -4208,7 +4208,7 @@ void ScOutputData::DrawEditAsianVertical(DrawEditParam& rParam) pClipMarkCell->nClipMark |= ScClipMark::Right; //! also allow left? bAnyClipped = true; - long nMarkPixel = (long)( SC_CLIPMARK_SIZE * mnPPTX ); + long nMarkPixel = static_cast<long>( SC_CLIPMARK_SIZE * mnPPTX ); if ( aAreaParam.maClipRect.Right() - nMarkPixel > aAreaParam.maClipRect.Left() ) aAreaParam.maClipRect.Right() -= nMarkPixel; } @@ -4486,7 +4486,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) for (SCSIZE nArrY=0; nArrY+1<nArrCount; nArrY++) // 0 for the rest of the merged { RowInfo* pThisRowInfo = &pRowInfo[nArrY]; - long nCellHeight = (long) pThisRowInfo->nHeight; + long nCellHeight = static_cast<long>(pThisRowInfo->nHeight); if (nArrY==1) nRowPosY = nScrY; // positions before are calculated individually if ( ( pThisRowInfo->bChanged || nArrY==0 ) && pThisRowInfo->nRotMaxCol != SC_ROTMAX_NONE ) @@ -4535,7 +4535,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) if (aCell.isEmpty() || IsEmptyCellText(pThisRowInfo, nX, nY)) bHidden = true; // nRotateDir is also set without a cell - long nCellWidth = (long) pRowInfo[0].pCellInfo[nX+1].nWidth; + long nCellWidth = static_cast<long>(pRowInfo[0].pCellInfo[nX+1].nWidth); SvxCellHorJustify eHorJust = pPattern->GetItem(ATTR_HOR_JUSTIFY, pCondSet).GetValue(); @@ -4562,7 +4562,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) while (nCol > nX) { --nCol; - nStartX -= nLayoutSign * (long) pRowInfo[0].pCellInfo[nCol+1].nWidth; + nStartX -= nLayoutSign * static_cast<long>(pRowInfo[0].pCellInfo[nCol+1].nWidth); } } } @@ -4579,9 +4579,9 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) { SCCOL nCountX = pMerge->GetColMerge(); for (SCCOL i=1; i<nCountX; i++) - nOutWidth += (long) ( mpDoc->GetColWidth(nX+i,nTab) * mnPPTX ); + nOutWidth += static_cast<long>( mpDoc->GetColWidth(nX+i,nTab) * mnPPTX ); SCROW nCountY = pMerge->GetRowMerge(); - nOutHeight += (long) mpDoc->GetScaledRowHeight( nY+1, nY+nCountY-1, nTab, mnPPTY); + nOutHeight += static_cast<long>(mpDoc->GetScaledRowHeight( nY+1, nY+nCountY-1, nTab, mnPPTY)); } SvxCellVerJustify eVerJust = @@ -4642,10 +4642,10 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) if ( bPixelToLogic ) nTotalHeight = mpRefDevice->PixelToLogic(Size(0,nTotalHeight)).Height(); - long nLeftM = (long) ( (pMargin->GetLeftMargin() + nIndent) * mnPPTX ); - long nTopM = (long) ( pMargin->GetTopMargin() * mnPPTY ); - long nRightM = (long) ( pMargin->GetRightMargin() * mnPPTX ); - long nBottomM = (long) ( pMargin->GetBottomMargin() * mnPPTY ); + long nLeftM = static_cast<long>( (pMargin->GetLeftMargin() + nIndent) * mnPPTX ); + long nTopM = static_cast<long>( pMargin->GetTopMargin() * mnPPTY ); + long nRightM = static_cast<long>( pMargin->GetRightMargin() * mnPPTX ); + long nBottomM = static_cast<long>( pMargin->GetBottomMargin() * mnPPTY ); nStartX += nLeftM; nStartY += nTopM; nOutWidth -= nLeftM + nRightM; @@ -4687,7 +4687,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) //! of rows, as long as the rows can not be outputted individually //! offsetted -> therefore unlimited, so no wrapping. //! With offset rows the following would be correct: - aPaperSize.Width() = (long)(nOutHeight / fabs(nSin)); + aPaperSize.Width() = static_cast<long>(nOutHeight / fabs(nSin)); } else if (eOrient == SvxCellOrientation::Standard) aPaperSize.Width() = nOutWidth; @@ -4737,7 +4737,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) pEngine->SetUpdateMode( true ); // after SetText, before CalcTextWidth/GetTextHeight - long nEngineWidth = (long) pEngine->CalcTextWidth(); + long nEngineWidth = static_cast<long>(pEngine->CalcTextWidth()); long nEngineHeight = pEngine->GetTextHeight(); if (nAttrRotate && bBreak) @@ -4752,8 +4752,8 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) // everything is in pixels long nEnginePixel = mpRefDevice->LogicToPixel( Size(0,nEngineHeight)).Height(); - long nEffHeight = nOutHeight - (long)(nEnginePixel * nAbsCos) + 2; - long nNewWidth = (long)(nEffHeight / nAbsSin) + 2; + long nEffHeight = nOutHeight - static_cast<long>(nEnginePixel * nAbsCos) + 2; + long nNewWidth = static_cast<long>(nEffHeight / nAbsSin) + 2; bool bFits = ( nNewWidth >= aPaperSize.Width() ); if ( bFits ) nSteps = 0; @@ -4763,7 +4763,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) { // can't fit -> fall back to using half height nEffHeight = nOutHeight / 2; - nNewWidth = (long)(nEffHeight / nAbsSin) + 2; + nNewWidth = static_cast<long>(nEffHeight / nAbsSin) + 2; nSteps = 0; } else @@ -4777,7 +4777,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) pEngine->SetPaperSize(aPaperSize); // Scale is always 1 //pEngine->QuickFormatDoc( sal_True ); - nEngineWidth = (long) pEngine->CalcTextWidth(); + nEngineWidth = static_cast<long>(pEngine->CalcTextWidth()); nEngineHeight = pEngine->GetTextHeight(); } } @@ -4793,13 +4793,13 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) double nAbsSin = fabs( nSin ); if ( eRotMode == SVX_ROTATE_MODE_STANDARD ) - nEngineWidth = (long) ( nRealWidth * nAbsCos + + nEngineWidth = static_cast<long>( nRealWidth * nAbsCos + nRealHeight * nAbsSin ); else - nEngineWidth = (long) ( nRealHeight / nAbsSin ); + nEngineWidth = static_cast<long>( nRealHeight / nAbsSin ); //! limit !!! - nEngineHeight = (long) ( nRealHeight * nAbsCos + + nEngineHeight = static_cast<long>( nRealHeight * nAbsCos + nRealWidth * nAbsSin ); } @@ -4825,7 +4825,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) if ( eRotMode != SVX_ROTATE_MODE_STANDARD ) { nGridWidth = aCellSize.Width() + - std::abs((long) ( aCellSize.Height() * nCos / nSin )); + std::abs(static_cast<long>( aCellSize.Height() * nCos / nSin )); bNegative = ( pInfo->nRotateDir == ScRotateDir::Left ); if ( bLayoutRTL ) bNegative = !bNegative; @@ -4871,11 +4871,11 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) // nEngineWidth/nEngineHeight is updated in ShrinkEditEngine // (but width is only valid for standard mode) - nRealWidth = (long) pEngine->CalcTextWidth(); + nRealWidth = static_cast<long>(pEngine->CalcTextWidth()); nRealHeight = pEngine->GetTextHeight(); if ( eRotMode != SVX_ROTATE_MODE_STANDARD ) - nEngineWidth = (long) ( nRealHeight / fabs( nSin ) ); + nEngineWidth = static_cast<long>( nRealHeight / fabs( nSin ) ); } long nClipStartX = nStartX; @@ -5070,8 +5070,8 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) nAddX += ( nUp * nCos / fabs(nSin) ); } - aLogicStart.X() += (long) nAddX; - aLogicStart.Y() += (long) nAddY; + aLogicStart.X() += static_cast<long>(nAddX); + aLogicStart.Y() += static_cast<long>(nAddY); } // bSimClip is not used here (because nOriVal is set) @@ -5089,7 +5089,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) } } - pEngine->Draw( mpDev, aLogicStart, (short)nOriVal ); + pEngine->Draw( mpDev, aLogicStart, static_cast<short>(nOriVal) ); if (bMetaFile) mpDev->Pop(); diff --git a/sc/source/ui/view/output3.cxx b/sc/source/ui/view/output3.cxx index 9cb20ad3c1ad..37da03f697b8 100644 --- a/sc/source/ui/view/output3.cxx +++ b/sc/source/ui/view/output3.cxx @@ -58,8 +58,8 @@ Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY ) aRect.Top() = aRect.Bottom() = -aOffset.Y(); Point aMMOffset( aOffset ); - aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS); - aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS); + aMMOffset.X() = static_cast<long>(aMMOffset.X() * HMM_PER_TWIPS); + aMMOffset.Y() = static_cast<long>(aMMOffset.Y() * HMM_PER_TWIPS); if (!bMetaFile) aMMOffset += Point( nLogStX, nLogStY ); @@ -68,10 +68,10 @@ Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY ) aRect.Right() += mpDoc->GetColWidth( nCol, nTab ); aRect.Bottom() += mpDoc->GetRowHeight( nY1, nY2, nTab ); - aRect.Left() = (long) (aRect.Left() * HMM_PER_TWIPS); - aRect.Top() = (long) (aRect.Top() * HMM_PER_TWIPS); - aRect.Right() = (long) (aRect.Right() * HMM_PER_TWIPS); - aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS); + aRect.Left() = static_cast<long>(aRect.Left() * HMM_PER_TWIPS); + aRect.Top() = static_cast<long>(aRect.Top() * HMM_PER_TWIPS); + aRect.Right() = static_cast<long>(aRect.Right() * HMM_PER_TWIPS); + aRect.Bottom() = static_cast<long>(aRect.Bottom() * HMM_PER_TWIPS); if(pViewShell || pDrawView) { diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx index 86c6821623c1..8fa2d8e3bd0b 100644 --- a/sc/source/ui/view/preview.cxx +++ b/sc/source/ui/view/preview.cxx @@ -351,7 +351,7 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation ) } Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( static_cast<long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom ); bool bDoPrint = ( pFillLocation == nullptr ); @@ -460,15 +460,15 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation ) if (nPrinted) // if not, draw everything grey { aLocalPageSize = pPrintFunc->GetPageSize(); - aLocalPageSize.Width() = (long) (aLocalPageSize.Width() * HMM_PER_TWIPS ); - aLocalPageSize.Height() = (long) (aLocalPageSize.Height() * HMM_PER_TWIPS ); - - nLeftMargin = (long) ( nLeftMargin * HMM_PER_TWIPS ); - nRightMargin = (long) ( nRightMargin * HMM_PER_TWIPS ); - nTopMargin = (long) ( nTopMargin * HMM_PER_TWIPS ); - nBottomMargin = (long) ( nBottomMargin * HMM_PER_TWIPS ); - nHeaderHeight = (long) ( nHeaderHeight * HMM_PER_TWIPS * mnScale / 100 + nTopMargin ); - nFooterHeight = (long) ( nFooterHeight * HMM_PER_TWIPS * mnScale / 100 + nBottomMargin ); + aLocalPageSize.Width() = static_cast<long>(aLocalPageSize.Width() * HMM_PER_TWIPS ); + aLocalPageSize.Height() = static_cast<long>(aLocalPageSize.Height() * HMM_PER_TWIPS ); + + nLeftMargin = static_cast<long>( nLeftMargin * HMM_PER_TWIPS ); + nRightMargin = static_cast<long>( nRightMargin * HMM_PER_TWIPS ); + nTopMargin = static_cast<long>( nTopMargin * HMM_PER_TWIPS ); + nBottomMargin = static_cast<long>( nBottomMargin * HMM_PER_TWIPS ); + nHeaderHeight = static_cast<long>( nHeaderHeight * HMM_PER_TWIPS * mnScale / 100 + nTopMargin ); + nFooterHeight = static_cast<long>( nFooterHeight * HMM_PER_TWIPS * mnScale / 100 + nBottomMargin ); } if (!bStateValid) @@ -543,10 +543,10 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation ) { SetMapMode(aMMMode); SetLineColor( COL_BLACK ); - DrawInvert( (long)( nTopMargin - aOffset.Y() ), PointerStyle::VSizeBar ); - DrawInvert( (long)(nPageEndY - nBottomMargin ), PointerStyle::VSizeBar ); - DrawInvert( (long)( nLeftMargin - aOffset.X() ), PointerStyle::HSizeBar ); - DrawInvert( (long)( nPageEndX - nRightMargin ) , PointerStyle::HSizeBar ); + DrawInvert( static_cast<long>( nTopMargin - aOffset.Y() ), PointerStyle::VSizeBar ); + DrawInvert( static_cast<long>(nPageEndY - nBottomMargin ), PointerStyle::VSizeBar ); + DrawInvert( static_cast<long>( nLeftMargin - aOffset.X() ), PointerStyle::HSizeBar ); + DrawInvert( static_cast<long>( nPageEndX - nRightMargin ) , PointerStyle::HSizeBar ); if( bHeaderOn ) { DrawInvert( nHeaderHeight - aOffset.Y(), PointerStyle::VSizeBar ); @@ -738,7 +738,7 @@ void ScPreview::SetZoom(sal_uInt16 nNewZoom) // apply new MapMode and call UpdateScrollBars to update aOffset Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( static_cast<long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom ); SetMapMode( aMMMode ); @@ -821,8 +821,8 @@ sal_uInt16 ScPreview::GetOptimalZoom(bool bWidthOnly) Size aLocalPageSize = lcl_GetDocPageSize( &pDocShell->GetDocument(), nTab ); if ( aLocalPageSize.Width() && aLocalPageSize.Height() ) { - long nZoomX = (long) ( aWinSize.Width() * 100 / ( aLocalPageSize.Width() * nWinScaleX )); - long nZoomY = (long) ( aWinSize.Height() * 100 / ( aLocalPageSize.Height() * nWinScaleY )); + long nZoomX = static_cast<long>( aWinSize.Width() * 100 / ( aLocalPageSize.Width() * nWinScaleX )); + long nZoomY = static_cast<long>( aWinSize.Height() * 100 / ( aLocalPageSize.Height() * nWinScaleY )); long nOptimal = nZoomX; if (!bWidthOnly && nZoomY<nOptimal) @@ -833,7 +833,7 @@ sal_uInt16 ScPreview::GetOptimalZoom(bool bWidthOnly) if (nOptimal>400) nOptimal = 400; - return (sal_uInt16) nOptimal; + return static_cast<sal_uInt16>(nOptimal); } else return nZoom; @@ -966,7 +966,7 @@ void ScPreview::DataChanged( const DataChangedEvent& rDCEvt ) void ScPreview::MouseButtonDown( const MouseEvent& rMEvt ) { Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( static_cast<long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom ); aButtonDownChangePoint = PixelToLogic( rMEvt.GetPosPixel(),aMMMode ); @@ -1049,7 +1049,7 @@ void ScPreview::MouseButtonDown( const MouseEvent& rMEvt ) void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) { Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( static_cast<long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom ); aButtonUpPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode ); @@ -1103,13 +1103,13 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) ScDocShellModificator aModificator( *pDocShell ); if( bLeftRulerChange && bLeftRulerMove ) { - aLRItem.SetLeft( (long)( aButtonUpPt.X() / HMM_PER_TWIPS + aOffset.X() / HMM_PER_TWIPS )); + aLRItem.SetLeft( static_cast<long>( aButtonUpPt.X() / HMM_PER_TWIPS + aOffset.X() / HMM_PER_TWIPS )); rStyleSet.Put( aLRItem ); pDocShell->SetModified(); } else if( bRightRulerChange && bRightRulerMove ) { - aLRItem.SetRight( (long)( nWidth - aButtonUpPt.X() / HMM_PER_TWIPS - aOffset.X() / HMM_PER_TWIPS )); + aLRItem.SetRight( static_cast<long>( nWidth - aButtonUpPt.X() / HMM_PER_TWIPS - aOffset.X() / HMM_PER_TWIPS )); rStyleSet.Put( aLRItem ); pDocShell->SetModified(); } @@ -1175,13 +1175,13 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) if( bTopRulerMove && bTopRulerChange ) { - aULItem.SetUpperValue( (sal_uInt16)( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS ) ); + aULItem.SetUpperValue( static_cast<sal_uInt16>( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS ) ); rStyleSet.Put( aULItem ); pDocShell->SetModified(); } else if( bBottomRulerMove && bBottomRulerChange ) { - aULItem.SetLowerValue( (sal_uInt16)( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS ) ); + aULItem.SetLowerValue( static_cast<sal_uInt16>( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS ) ); rStyleSet.Put( aULItem ); pDocShell->SetModified(); } @@ -1192,7 +1192,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) { const SfxItemSet& rHeaderSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet(); Size aHeaderSize = rHeaderSet.Get(ATTR_PAGE_SIZE).GetSize(); - aHeaderSize.Height() = (long)( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS - aULItem.GetUpper()); + aHeaderSize.Height() = static_cast<long>( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS - aULItem.GetUpper()); aHeaderSize.Height() = aHeaderSize.Height() * 100 / mnScale; SvxSetItem aNewHeader( rStyleSet.Get(ATTR_PAGE_HEADERSET) ); aNewHeader.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aHeaderSize ) ); @@ -1207,7 +1207,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) { const SfxItemSet& rFooterSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet(); Size aFooterSize = rFooterSet.Get(ATTR_PAGE_SIZE).GetSize(); - aFooterSize.Height() = (long)( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS - aULItem.GetLower() ); + aFooterSize.Height() = static_cast<long>( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS - aULItem.GetLower() ); aFooterSize.Height() = aFooterSize.Height() * 100 / mnScale; SvxSetItem aNewFooter( rStyleSet.Get(ATTR_PAGE_FOOTERSET) ); aNewFooter.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aFooterSize ) ); @@ -1267,20 +1267,20 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) if( !bLayoutRTL ) { - nNewColWidth = (long) ( PixelToLogic( Point( rMEvt.GetPosPixel().X() - mvRight[ nColNumberButttonDown ], 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale; + nNewColWidth = static_cast<long>( PixelToLogic( Point( rMEvt.GetPosPixel().X() - mvRight[ nColNumberButttonDown ], 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale; nNewColWidth += pDocShell->GetDocument().GetColWidth( nColNumberButttonDown, nTab ); } else { - nNewColWidth = (long) ( PixelToLogic( Point( mvRight[ nColNumberButttonDown ] - rMEvt.GetPosPixel().X(), 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale; + nNewColWidth = static_cast<long>( PixelToLogic( Point( mvRight[ nColNumberButttonDown ] - rMEvt.GetPosPixel().X(), 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale; nNewColWidth += pDocShell->GetDocument().GetColWidth( nColNumberButttonDown, nTab ); } if( nNewColWidth >= 0 ) { pDocShell->GetDocFunc().SetWidthOrHeight( - true, aCols, nTab, SC_SIZE_DIRECT, (sal_uInt16)nNewColWidth, true, true); + true, aCols, nTab, SC_SIZE_DIRECT, static_cast<sal_uInt16>(nNewColWidth), true, true); pDocShell->SetModified(); } if ( ValidTab( nTab ) ) @@ -1299,7 +1299,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) void ScPreview::MouseMove( const MouseEvent& rMEvt ) { Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( static_cast<long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom ); Point aMouseMovePoint = PixelToLogic( rMEvt.GetPosPixel(), aMMMode ); @@ -1322,31 +1322,31 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt ) else pPrintFunc = new ScPrintFunc( this, pDocShell, nTab, nFirstAttr[nTab], nTotalPages, nullptr, &aOptions ); - nLeftMargin = (long)( pPrintFunc->GetLeftMargin() * HMM_PER_TWIPS - aOffset.X() ); - nRightMargin = (long)( pPrintFunc->GetRightMargin() * HMM_PER_TWIPS ); - nRightMargin = (long)( nWidth * HMM_PER_TWIPS - nRightMargin - aOffset.X() ); - nTopMargin = (long)( pPrintFunc->GetTopMargin() * HMM_PER_TWIPS - aOffset.Y() ); - nBottomMargin = (long)( pPrintFunc->GetBottomMargin() * HMM_PER_TWIPS ); - nBottomMargin = (long)( nHeight * HMM_PER_TWIPS - nBottomMargin - aOffset.Y() ); + nLeftMargin = static_cast<long>( pPrintFunc->GetLeftMargin() * HMM_PER_TWIPS - aOffset.X() ); + nRightMargin = static_cast<long>( pPrintFunc->GetRightMargin() * HMM_PER_TWIPS ); + nRightMargin = static_cast<long>( nWidth * HMM_PER_TWIPS - nRightMargin - aOffset.X() ); + nTopMargin = static_cast<long>( pPrintFunc->GetTopMargin() * HMM_PER_TWIPS - aOffset.Y() ); + nBottomMargin = static_cast<long>( pPrintFunc->GetBottomMargin() * HMM_PER_TWIPS ); + nBottomMargin = static_cast<long>( nHeight * HMM_PER_TWIPS - nBottomMargin - aOffset.Y() ); if( mnScale > 0 ) { - nHeaderHeight = (long)( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS * mnScale / 100 ); - nFooterHeight = (long)( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS * mnScale / 100 ); + nHeaderHeight = static_cast<long>( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS * mnScale / 100 ); + nFooterHeight = static_cast<long>( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS * mnScale / 100 ); } else { - nHeaderHeight = (long)( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS ); - nFooterHeight = (long)( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS ); + nHeaderHeight = static_cast<long>( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS ); + nFooterHeight = static_cast<long>( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS ); } delete pPrintFunc; } Point aPixPt( rMEvt.GetPosPixel() ); Point aLeftTop = LogicToPixel( Point( nLeftMargin, -aOffset.Y() ) , aMMMode ); - Point aLeftBottom = LogicToPixel( Point( nLeftMargin ,(long)(nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode ); + Point aLeftBottom = LogicToPixel( Point( nLeftMargin ,static_cast<long>(nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode ); Point aRightTop = LogicToPixel( Point( nRightMargin, -aOffset.Y() ), aMMMode ); Point aTopLeft = LogicToPixel( Point( -aOffset.X(), nTopMargin ), aMMMode ); - Point aTopRight = LogicToPixel( Point( (long)(nWidth * HMM_PER_TWIPS - aOffset.X()), nTopMargin ), aMMMode ); + Point aTopRight = LogicToPixel( Point( static_cast<long>(nWidth * HMM_PER_TWIPS - aOffset.X()), nTopMargin ), aMMMode ); Point aBottomLeft = LogicToPixel( Point( -aOffset.X(), nBottomMargin ), aMMMode ); Point aHeaderLeft = LogicToPixel( Point( -aOffset.X(), nHeaderHeight ), aMMMode ); Point aFooderLeft = LogicToPixel( Point( -aOffset.X(), nFooterHeight ), aMMMode ); @@ -1356,7 +1356,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt ) for( SCCOL i=aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ ) { Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode ); - Point aColumnBottom = LogicToPixel( Point( 0, (long)( nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode ); + Point aColumnBottom = LogicToPixel( Point( 0, static_cast<long>( nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode ); long nRight = i < static_cast<SCCOL>(mvRight.size()) ? mvRight[i] : 0; if( aPixPt.X() < ( nRight + 2 ) && ( aPixPt.X() > ( nRight - 2 ) ) && ( aPixPt.X() < aRightTop.X() ) && ( aPixPt.X() > aLeftTop.X() ) && ( aPixPt.Y() > aColumnTop.Y() ) && ( aPixPt.Y() < aColumnBottom.Y() ) && !bLeftRulerMove && !bRightRulerMove @@ -1537,7 +1537,7 @@ css::uno::Reference<css::accessibility::XAccessible> ScPreview::CreateAccessible void ScPreview::DragMove( long nDragMovePos, PointerStyle nFlags ) { Fraction aPreviewZoom( nZoom, 100 ); - Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); + Fraction aHorPrevZoom( static_cast<long>( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 ); MapMode aMMMode( MapUnit::Map100thMM, Point(), aHorPrevZoom, aPreviewZoom ); SetMapMode( aMMMode ); long nPos = nDragMovePos; @@ -1567,12 +1567,12 @@ void ScPreview::DrawInvert( long nDragPos, PointerStyle nFlags ) long nWidth = lcl_GetDocPageSize( &pDocShell->GetDocument(), nTab ).Width(); if( nFlags == PointerStyle::HSizeBar || nFlags == PointerStyle::HSplit ) { - tools::Rectangle aRect( nDragPos, -aOffset.Y(), nDragPos + 1,(long)( ( nHeight * HMM_PER_TWIPS ) - aOffset.Y())); + tools::Rectangle aRect( nDragPos, -aOffset.Y(), nDragPos + 1,static_cast<long>( ( nHeight * HMM_PER_TWIPS ) - aOffset.Y())); Invert( aRect, InvertFlags::N50 ); } else if( nFlags == PointerStyle::VSizeBar ) { - tools::Rectangle aRect( -aOffset.X(), nDragPos,(long)( ( nWidth * HMM_PER_TWIPS ) - aOffset.X() ), nDragPos + 1 ); + tools::Rectangle aRect( -aOffset.X(), nDragPos,static_cast<long>( ( nWidth * HMM_PER_TWIPS ) - aOffset.X() ), nDragPos + 1 ); Invert( aRect, InvertFlags::N50 ); } } diff --git a/sc/source/ui/view/prevloc.cxx b/sc/source/ui/view/prevloc.cxx index cdcc83fcf6dd..4161242f5ff2 100644 --- a/sc/source/ui/view/prevloc.cxx +++ b/sc/source/ui/view/prevloc.cxx @@ -288,14 +288,14 @@ tools::Rectangle ScPreviewLocationData::GetOffsetPixel( const ScAddress& rCellPo { sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab ); if (nDocW) - nPosX += (long) (nDocW * nScaleX); + nPosX += static_cast<long>(nDocW * nScaleX); } - long nSizeX = (long) ( pDoc->GetColWidth( nEndCol, nTab ) * nScaleX ); + long nSizeX = static_cast<long>( pDoc->GetColWidth( nEndCol, nTab ) * nScaleX ); SCROW nEndRow = rCellPos.Row(); - long nPosY = (long) pDoc->GetScaledRowHeight( rRange.aStart.Row(), - nEndRow, nTab, nScaleY); - long nSizeY = (long) ( pDoc->GetRowHeight( nEndRow, nTab ) * nScaleY ); + long nPosY = static_cast<long>(pDoc->GetScaledRowHeight( rRange.aStart.Row(), + nEndRow, nTab, nScaleY)); + long nSizeY = static_cast<long>( pDoc->GetRowHeight( nEndRow, nTab ) * nScaleY ); Size aOffsetLogic( nPosX, nPosY ); Size aSizeLogic( nSizeX, nSizeY ); @@ -553,7 +553,7 @@ void ScPreviewLocationData::GetTableInfo( const tools::Rectangle& rVisiblePixel, if (!pDoc->ColHidden(nCol, nTab)) { sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab ); - long nNextX = nPosX + (long) (nDocW * nScaleX); + long nNextX = nPosX + static_cast<long>(nDocW * nScaleX); long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width(); long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1; @@ -572,7 +572,7 @@ void ScPreviewLocationData::GetTableInfo( const tools::Rectangle& rVisiblePixel, if (!pDoc->ColHidden(nCol, nTab)) { sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nTab ); - long nNextX = nPosX + (long) (nDocW * nScaleX); + long nNextX = nPosX + static_cast<long>(nDocW * nScaleX); long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width(); long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1; @@ -618,7 +618,7 @@ void ScPreviewLocationData::GetTableInfo( const tools::Rectangle& rVisiblePixel, continue; sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab ); - long nNextY = nPosY + (long) (nDocH * nScaleY); + long nNextY = nPosY + static_cast<long>(nDocH * nScaleY); long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height(); long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1; @@ -639,7 +639,7 @@ void ScPreviewLocationData::GetTableInfo( const tools::Rectangle& rVisiblePixel, continue; sal_uInt16 nDocH = pDoc->GetOriginalHeight( nRow, nTab ); - long nNextY = nPosY + (long) (nDocH * nScaleY); + long nNextY = nPosY + static_cast<long>(nDocH * nScaleY); long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height(); long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1; diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index 41b7caa91af7..2bab27e4f3c1 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -246,8 +246,8 @@ bool ScPreviewShell::GetPageSize( Size& aPageSize ) const SfxItemSet* pParamSet = &pStyleSheet->GetItemSet(); aPageSize = pParamSet->Get(ATTR_PAGE_SIZE).GetSize(); - aPageSize.Width() = (long) (aPageSize.Width() * HMM_PER_TWIPS ); - aPageSize.Height() = (long) (aPageSize.Height() * HMM_PER_TWIPS ); + aPageSize.Width() = static_cast<long>(aPageSize.Width() * HMM_PER_TWIPS ); + aPageSize.Height() = static_cast<long>(aPageSize.Height() * HMM_PER_TWIPS ); return true; } @@ -483,14 +483,14 @@ bool ScPreviewShell::ScrollCommand( const CommandEvent& rCEvt ) long nOld = pPreview->GetZoom(); long nNew; if ( pData->GetDelta() < 0 ) - nNew = std::max( (long) MINZOOM, basegfx::zoomtools::zoomOut( nOld )); + nNew = std::max( long(MINZOOM), basegfx::zoomtools::zoomOut( nOld )); else - nNew = std::min( (long) MAXZOOM, basegfx::zoomtools::zoomIn( nOld )); + nNew = std::min( long(MAXZOOM), basegfx::zoomtools::zoomIn( nOld )); if ( nNew != nOld ) { eZoom = SvxZoomType::PERCENT; - pPreview->SetZoom( (sal_uInt16)nNew ); + pPreview->SetZoom( static_cast<sal_uInt16>(nNew) ); } bDone = true; @@ -918,7 +918,7 @@ void ScPreviewShell::ReadUserData(const OUString& rData, bool /* bBrowse */) if (!rData.isEmpty()) { sal_Int32 nIndex = 0; - pPreview->SetZoom((sal_uInt16)rData.getToken(0, SC_USERDATA_SEP, nIndex).toInt32()); + pPreview->SetZoom(static_cast<sal_uInt16>(rData.getToken(0, SC_USERDATA_SEP, nIndex).toInt32())); pPreview->SetPageNo(rData.getToken(0, SC_USERDATA_SEP, nIndex).toInt32()); eZoom = SvxZoomType::PERCENT; } diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 5a7711e9867a..2282d7ec9ebe 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -514,15 +514,15 @@ void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPr long nTwipsSizeX = 0; for (SCCOL i=nX1; i<=nX2; i++) nTwipsSizeX += pDoc->GetColWidth( i, nTab ); - long nTwipsSizeY = (long) pDoc->GetRowHeight( nY1, nY2, nTab ); + long nTwipsSizeY = static_cast<long>(pDoc->GetRowHeight( nY1, nY2, nTab )); // if no lines, still space for the outline frame (20 Twips = 1pt) // (HasLines initializes aLines to 0,0,0,0) nTwipsSizeX += aLines.Left() + std::max( aLines.Right(), 20L ); nTwipsSizeY += aLines.Top() + std::max( aLines.Bottom(), 20L ); - double nScaleX = (double) nDevSizeX / nTwipsSizeX; - double nScaleY = (double) nDevSizeY / nTwipsSizeY; + double nScaleX = static_cast<double>(nDevSizeX) / nTwipsSizeX; + double nScaleY = static_cast<double>(nDevSizeY) / nTwipsSizeY; //! hand over Flag at FillInfo !!!!! ScRange aERange; @@ -548,9 +548,9 @@ void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPr // If no lines, still leave space for grid lines // (would be elseways cut away) - long nAddX = (long)( aLines.Left() * nScaleX ); + long nAddX = static_cast<long>( aLines.Left() * nScaleX ); nScrX += ( nAddX ? nAddX : 1 ); - long nAddY = (long)( aLines.Top() * nScaleY ); + long nAddY = static_cast<long>( aLines.Top() * nScaleY ); nScrY += ( nAddY ? nAddY : 1 ); ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pDoc, nTab, @@ -768,7 +768,7 @@ long ScPrintFunc::TextHeight( const EditTextObject* pObject ) pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false ); - return (long) pEditEngine->GetTextHeight(); + return static_cast<long>(pEditEngine->GetTextHeight()); } // nZoom must be set !!! @@ -932,7 +932,7 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions ) aTableParam.bLeftRight = !aTableParam.bLeftRight; aTableParam.nFirstPageNo = lcl_GetUShort(pParamSet,ATTR_PAGE_FIRSTPAGENO); if (!aTableParam.nFirstPageNo) - aTableParam.nFirstPageNo = (sal_uInt16) nPageStart; // from previous table + aTableParam.nFirstPageNo = static_cast<sal_uInt16>(nPageStart); // from previous table if ( pScaleItem && pScaleToItem && pScaleToPagesItem ) { @@ -1277,10 +1277,10 @@ void ScPrintFunc::DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH, // aFrameRect - outside around frame, without shadow if ( pShadow && pShadow->GetLocation() != SvxShadowLocation::NONE ) { - nLeft += (long) ( pShadow->CalcShadowSpace(SvxShadowItemSide::LEFT) * nScaleX ); - nRight += (long) ( pShadow->CalcShadowSpace(SvxShadowItemSide::RIGHT) * nScaleX ); - nTop += (long) ( pShadow->CalcShadowSpace(SvxShadowItemSide::TOP) * nScaleY ); - nBottom += (long) ( pShadow->CalcShadowSpace(SvxShadowItemSide::BOTTOM) * nScaleY ); + nLeft += static_cast<long>( pShadow->CalcShadowSpace(SvxShadowItemSide::LEFT) * nScaleX ); + nRight += static_cast<long>( pShadow->CalcShadowSpace(SvxShadowItemSide::RIGHT) * nScaleX ); + nTop += static_cast<long>( pShadow->CalcShadowSpace(SvxShadowItemSide::TOP) * nScaleY ); + nBottom += static_cast<long>( pShadow->CalcShadowSpace(SvxShadowItemSide::BOTTOM) * nScaleY ); } tools::Rectangle aFrameRect( Point(nScrX+nLeft, nScrY+nTop), Size(nScrW-nLeft-nRight, nScrH-nTop-nBottom) ); @@ -1288,10 +1288,10 @@ void ScPrintFunc::DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH, // center of frame, to paint lines through OutputData if (pBorderData) { - nLeft += (long) ( lcl_LineTotal(pBorderData->GetLeft()) * nScaleX / 2 ); - nRight += (long) ( lcl_LineTotal(pBorderData->GetRight()) * nScaleX / 2 ); - nTop += (long) ( lcl_LineTotal(pBorderData->GetTop()) * nScaleY / 2 ); - nBottom += (long) ( lcl_LineTotal(pBorderData->GetBottom()) * nScaleY / 2 ); + nLeft += static_cast<long>( lcl_LineTotal(pBorderData->GetLeft()) * nScaleX / 2 ); + nRight += static_cast<long>( lcl_LineTotal(pBorderData->GetRight()) * nScaleX / 2 ); + nTop += static_cast<long>( lcl_LineTotal(pBorderData->GetTop()) * nScaleY / 2 ); + nBottom += static_cast<long>( lcl_LineTotal(pBorderData->GetBottom()) * nScaleY / 2 ); } long nEffHeight = nScrH - nTop - nBottom; long nEffWidth = nScrW - nLeft - nRight; @@ -1325,8 +1325,8 @@ void ScPrintFunc::DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH, { pDev->SetFillColor(pShadow->GetColor()); pDev->SetLineColor(); - long nShadowX = (long) ( pShadow->GetWidth() * nScaleX ); - long nShadowY = (long) ( pShadow->GetWidth() * nScaleY ); + long nShadowX = static_cast<long>( pShadow->GetWidth() * nScaleX ); + long nShadowY = static_cast<long>( pShadow->GetWidth() * nScaleY ); switch (pShadow->GetLocation()) { case SvxShadowLocation::TopLeft: @@ -1380,9 +1380,9 @@ void ScPrintFunc::DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH, nScaleX, nScaleY, false, false ); OSL_ENSURE(aTabInfo.mnArrCount,"nArrCount == 0"); - aTabInfo.mpRowInfo[1].nHeight = (sal_uInt16) nEffHeight; + aTabInfo.mpRowInfo[1].nHeight = static_cast<sal_uInt16>(nEffHeight); aTabInfo.mpRowInfo[0].pCellInfo[1].nWidth = - aTabInfo.mpRowInfo[1].pCellInfo[1].nWidth = (sal_uInt16) nEffWidth; + aTabInfo.mpRowInfo[1].pCellInfo[1].nWidth = static_cast<sal_uInt16>(nEffWidth); ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pBorderDoc.get(), 0, nScrX+nLeft, nScrY+nTop, 0,0, 0,0, nScaleX, nScaleY ); @@ -1403,14 +1403,14 @@ void ScPrintFunc::PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY ) long nOneY = aOnePixel.Height(); SCCOL nCol; - long nHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY); + long nHeight = static_cast<long>(PRINT_HEADER_HEIGHT * nScaleY); long nEndY = nScrY + nHeight - nOneY; long nPosX = nScrX; if ( bLayoutRTL ) { for (nCol=nX1; nCol<=nX2; nCol++) - nPosX += (long)( pDoc->GetColWidth( nCol, nPrintTab ) * nScaleX ); + nPosX += static_cast<long>( pDoc->GetColWidth( nCol, nPrintTab ) * nScaleX ); } else nPosX -= nOneX; @@ -1422,7 +1422,7 @@ void ScPrintFunc::PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY ) sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nPrintTab ); if (nDocW) { - long nWidth = (long) (nDocW * nScaleX); + long nWidth = static_cast<long>(nDocW * nScaleX); long nEndX = nPosX + nWidth * nLayoutSign; pDev->DrawRect( tools::Rectangle( nPosX,nPosY,nEndX,nEndY ) ); @@ -1450,7 +1450,7 @@ void ScPrintFunc::PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY ) bool bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab ); - long nWidth = (long) (PRINT_HEADER_WIDTH * nScaleX); + long nWidth = static_cast<long>(PRINT_HEADER_WIDTH * nScaleX); long nEndX = nScrX + nWidth; long nPosX = nScrX; if ( !bLayoutRTL ) @@ -1466,7 +1466,7 @@ void ScPrintFunc::PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY ) sal_uInt16 nDocH = pDoc->GetRowHeight( nRow, nPrintTab ); if (nDocH) { - long nHeight = (long) (nDocH * nScaleY); + long nHeight = static_cast<long>(nDocH * nScaleY); long nEndY = nPosY + nHeight; pDev->DrawRect( tools::Rectangle( nPosX,nPosY,nEndX,nEndY ) ); @@ -1490,7 +1490,7 @@ void ScPrintFunc::LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY, long nOneX = aOnePixel.Width(); long nOneY = aOnePixel.Height(); - long nHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY); + long nHeight = static_cast<long>(PRINT_HEADER_HEIGHT * nScaleY); long nEndY = nScrY + nHeight - nOneY; long nPosX = nScrX - nOneX; @@ -1498,7 +1498,7 @@ void ScPrintFunc::LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY, { sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nPrintTab ); if (nDocW) - nPosX += (long) (nDocW * nScaleX); + nPosX += static_cast<long>(nDocW * nScaleX); } tools::Rectangle aCellRect( nScrX, nScrY, nPosX, nEndY ); rLocationData.AddColHeaders( aCellRect, nX1, nX2, bRepCol ); @@ -1513,7 +1513,7 @@ void ScPrintFunc::LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY, bool bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab ); - long nWidth = (long) (PRINT_HEADER_WIDTH * nScaleX); + long nWidth = static_cast<long>(PRINT_HEADER_WIDTH * nScaleX); long nEndX = nScrX + nWidth; if ( !bLayoutRTL ) nEndX -= nOneX; @@ -1541,8 +1541,8 @@ void ScPrintFunc::LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, aTwipOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nPrintTab ); Point aMMOffset( aTwipOffset ); - aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS); - aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS); + aMMOffset.X() = static_cast<long>(aMMOffset.X() * HMM_PER_TWIPS); + aMMOffset.Y() = static_cast<long>(aMMOffset.Y() * HMM_PER_TWIPS); aMMOffset += Point( nLogStX, nLogStY ); MapMode aDrawMapMode( MapUnit::Map100thMM, aMMOffset, aLogicMode.GetScaleX(), aLogicMode.GetScaleY() ); @@ -1557,7 +1557,7 @@ void ScPrintFunc::LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, { sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nPrintTab ); if (nDocW) - nPosX += (long) (nDocW * nScaleX); + nPosX += static_cast<long>(nDocW * nScaleX); } long nPosY = nScrY - nOneY; @@ -1834,7 +1834,7 @@ void ScPrintFunc::PrintHF( long nPageNo, bool bHeader, long nStartY, pEditDefaults->Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) ); pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false ); Point aDraw = aStart; - long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight(); + long nDif = aPaperSize.Height() - static_cast<long>(pEditEngine->GetTextHeight()); if (nDif > 0) aDraw.Y() += nDif / 2; pEditEngine->Draw( pDev, aDraw ); @@ -1848,7 +1848,7 @@ void ScPrintFunc::PrintHF( long nPageNo, bool bHeader, long nStartY, pEditDefaults->Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) ); pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false ); Point aDraw = aStart; - long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight(); + long nDif = aPaperSize.Height() - static_cast<long>(pEditEngine->GetTextHeight()); if (nDif > 0) aDraw.Y() += nDif / 2; pEditEngine->Draw( pDev, aDraw ); @@ -1862,7 +1862,7 @@ void ScPrintFunc::PrintHF( long nPageNo, bool bHeader, long nStartY, pEditDefaults->Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) ); pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false ); Point aDraw = aStart; - long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight(); + long nDif = aPaperSize.Height() - static_cast<long>(pEditEngine->GetTextHeight()); if (nDif > 0) aDraw.Y() += nDif / 2; pEditEngine->Draw( pDev, aDraw ); @@ -1955,7 +1955,7 @@ long ScPrintFunc::DoNotes( long nNoteStart, bool bDoPrint, ScPreviewLocationData long ScPrintFunc::PrintNotes( long nPageNo, long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData ) { - if ( nNoteStart >= (long) aNotePosList.size() || !aTableParam.bNotes ) + if ( nNoteStart >= static_cast<long>(aNotePosList.size()) || !aTableParam.bNotes ) return 0; if ( bDoPrint && bClearWin ) @@ -1970,8 +1970,8 @@ long ScPrintFunc::PrintNotes( long nPageNo, long nNoteStart, bool bDoPrint, ScPr pDev->SetLineColor(); pDev->SetFillColor(aBackgroundColor); pDev->DrawRect(tools::Rectangle(Point(), - Size((long)(aPageSize.Width() * nScaleX * 100 / nZoom), - (long)(aPageSize.Height() * nScaleY * 100 / nZoom)))); + Size(static_cast<long>(aPageSize.Width() * nScaleX * 100 / nZoom), + static_cast<long>(aPageSize.Height() * nScaleY * 100 / nZoom)))); } // adjust aPageRect for left/right page @@ -2039,8 +2039,8 @@ void ScPrintFunc::PrintPage( long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCRO pDev->SetLineColor(); pDev->SetFillColor(aBackgroundColor); pDev->DrawRect(tools::Rectangle(Point(), - Size((long)(aPageSize.Width() * nScaleX * 100 / nZoom), - (long)(aPageSize.Height() * nScaleY * 100 / nZoom)))); + Size(static_cast<long>(aPageSize.Width() * nScaleX * 100 / nZoom), + static_cast<long>(aPageSize.Height() * nScaleY * 100 / nZoom)))); } // adjust aPageRect for left/right page @@ -2107,7 +2107,7 @@ void ScPrintFunc::PrintPage( long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCRO for (i=nRepeatStartCol; i<=nRepeatEndCol; i++) nDataWidth += pDoc->GetColWidth( i,nPrintTab ); if (aTableParam.bHeaders) - nDataWidth += (long) PRINT_HEADER_WIDTH; + nDataWidth += long(PRINT_HEADER_WIDTH); if (pBorderItem) nDataWidth += pBorderItem->GetDistance(SvxBoxItemLine::LEFT) + pBorderItem->GetDistance(SvxBoxItemLine::RIGHT); //! Line width? @@ -2130,7 +2130,7 @@ void ScPrintFunc::PrintPage( long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCRO nDataHeight += pDoc->GetRowHeight( nRepeatStartRow, nRepeatEndRow, nPrintTab); if (aTableParam.bHeaders) - nDataHeight += (long) PRINT_HEADER_HEIGHT; + nDataHeight += long(PRINT_HEADER_HEIGHT); if (pBorderItem) nDataHeight += pBorderItem->GetDistance(SvxBoxItemLine::TOP) + pBorderItem->GetDistance(SvxBoxItemLine::BOTTOM); //! Line width? @@ -2153,37 +2153,37 @@ void ScPrintFunc::PrintPage( long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCRO long nContentHeight = 0; if (aTableParam.bHeaders) { - nHeaderWidth = (long) (PRINT_HEADER_WIDTH * nScaleX); - nHeaderHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY); + nHeaderWidth = static_cast<long>(PRINT_HEADER_WIDTH * nScaleX); + nHeaderHeight = static_cast<long>(PRINT_HEADER_HEIGHT * nScaleY); } if (bDoRepCol) for (SCCOL i=nRepeatStartCol; i<=nRepeatEndCol; i++) - nRepeatWidth += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX); + nRepeatWidth += static_cast<long>(pDoc->GetColWidth(i,nPrintTab) * nScaleX); if (bDoRepRow) nRepeatHeight += pDoc->GetScaledRowHeight( nRepeatStartRow, nRepeatEndRow, nPrintTab, nScaleY); for (SCCOL i=nX1; i<=nX2; i++) - nContentWidth += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX); + nContentWidth += static_cast<long>(pDoc->GetColWidth(i,nPrintTab) * nScaleX); nContentHeight += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY); // partition the page - long nStartX = (long) ( nLeftSpace * nScaleX ); - long nStartY = (long) ( nTopSpace * nScaleY ); + long nStartX = static_cast<long>( nLeftSpace * nScaleX ); + long nStartY = static_cast<long>( nTopSpace * nScaleY ); long nInnerStartX = nStartX; long nInnerStartY = nStartY; if (pBorderItem) { - nInnerStartX += (long) ( ( lcl_LineTotal(pBorderItem->GetLeft()) + + nInnerStartX += static_cast<long>( ( lcl_LineTotal(pBorderItem->GetLeft()) + pBorderItem->GetDistance(SvxBoxItemLine::LEFT) ) * nScaleX ); - nInnerStartY += (long) ( ( lcl_LineTotal(pBorderItem->GetTop()) + + nInnerStartY += static_cast<long>( ( lcl_LineTotal(pBorderItem->GetTop()) + pBorderItem->GetDistance(SvxBoxItemLine::TOP) ) * nScaleY ); } if (pShadowItem && pShadowItem->GetLocation() != SvxShadowLocation::NONE) { - nInnerStartX += (long) ( pShadowItem->CalcShadowSpace(SvxShadowItemSide::LEFT) * nScaleX ); - nInnerStartY += (long) ( pShadowItem->CalcShadowSpace(SvxShadowItemSide::TOP) * nScaleY ); + nInnerStartX += static_cast<long>( pShadowItem->CalcShadowSpace(SvxShadowItemSide::LEFT) * nScaleX ); + nInnerStartY += static_cast<long>( pShadowItem->CalcShadowSpace(SvxShadowItemSide::TOP) * nScaleY ); } if ( bLayoutRTL ) @@ -2229,15 +2229,15 @@ void ScPrintFunc::PrintPage( long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCRO long nBorderEndY = nEndY; if (pBorderItem) { - nBorderEndX += (long) ( ( lcl_LineTotal(pBorderItem->GetRight()) + + nBorderEndX += static_cast<long>( ( lcl_LineTotal(pBorderItem->GetRight()) + pBorderItem->GetDistance(SvxBoxItemLine::RIGHT) ) * nScaleX ); - nBorderEndY += (long) ( ( lcl_LineTotal(pBorderItem->GetBottom()) + + nBorderEndY += static_cast<long>( ( lcl_LineTotal(pBorderItem->GetBottom()) + pBorderItem->GetDistance(SvxBoxItemLine::BOTTOM) ) * nScaleY ); } if (pShadowItem && pShadowItem->GetLocation() != SvxShadowLocation::NONE) { - nBorderEndX += (long) ( pShadowItem->CalcShadowSpace(SvxShadowItemSide::RIGHT) * nScaleX ); - nBorderEndY += (long) ( pShadowItem->CalcShadowSpace(SvxShadowItemSide::BOTTOM) * nScaleY ); + nBorderEndX += static_cast<long>( pShadowItem->CalcShadowSpace(SvxShadowItemSide::RIGHT) * nScaleX ); + nBorderEndY += static_cast<long>( pShadowItem->CalcShadowSpace(SvxShadowItemSide::BOTTOM) * nScaleY ); } if ( bDoPrint ) @@ -2484,7 +2484,7 @@ long ScPrintFunc::CountPages() // sets also nPagesX, nP nPages += m_aRanges.m_aPageRows[nY].CountVisible(); } else - nPages += ((long) m_aRanges.m_nPagesX) * m_aRanges.m_nPagesY; + nPages += static_cast<long>(m_aRanges.m_nPagesX) * m_aRanges.m_nPagesY; if ( pPageData ) FillPageData(); } @@ -2499,7 +2499,7 @@ long ScPrintFunc::CountPages() // sets also nPagesX, nP nPages += m_aRanges.m_aPageRows[nY].CountVisible(); } else - nPages += ((long) m_aRanges.m_nPagesX) * m_aRanges.m_nPagesY; + nPages += static_cast<long>(m_aRanges.m_nPagesX) * m_aRanges.m_nPagesY; if ( pPageData ) FillPageData(); } @@ -2580,7 +2580,7 @@ void ScPrintFunc::InitModes() // set MapModes from nZoom etc. { aOffset = Point( aSrcOffset.X()*100/nZoom, aSrcOffset.Y()*100/nZoom ); - long nEffZoom = nZoom * (long) nManualZoom; + long nEffZoom = nZoom * static_cast<long>(nManualZoom); nScaleX = nScaleY = HMM_PER_TWIPS; // output in 1/100 mm Fraction aZoomFract( nEffZoom,10000 ); @@ -2589,7 +2589,7 @@ void ScPrintFunc::InitModes() // set MapModes from nZoom etc. if ( !pPrinter && !bIsRender ) // adjust scale for preview { double nFact = pDocShell->GetOutputFactor(); - aHorFract = Fraction( (long)( nEffZoom / nFact ), 10000 ); + aHorFract = Fraction( static_cast<long>( nEffZoom / nFact ), 10000 ); } aLogicMode = MapMode( MapUnit::Map100thMM, Point(), aHorFract, aZoomFract ); @@ -2597,7 +2597,7 @@ void ScPrintFunc::InitModes() // set MapModes from nZoom etc. Point aLogicOfs( -aOffset.X(), -aOffset.Y() ); aOffsetMode = MapMode( MapUnit::Map100thMM, aLogicOfs, aHorFract, aZoomFract ); - Point aTwipsOfs( (long) ( -aOffset.X() / nScaleX + 0.5 ), (long) ( -aOffset.Y() / nScaleY + 0.5 ) ); + Point aTwipsOfs( static_cast<long>( -aOffset.X() / nScaleX + 0.5 ), static_cast<long>( -aOffset.Y() / nScaleY + 0.5 ) ); aTwipMode = MapMode( MapUnit::MapTwip, aTwipsOfs, aHorFract, aZoomFract ); } @@ -2944,8 +2944,8 @@ Size ScPrintFunc::GetDocPageSize() Size aDocPageSize = aPageRect.GetSize(); if (aTableParam.bHeaders) { - aDocPageSize.Width() -= (long) PRINT_HEADER_WIDTH; - aDocPageSize.Height() -= (long) PRINT_HEADER_HEIGHT; + aDocPageSize.Width() -= long(PRINT_HEADER_WIDTH); + aDocPageSize.Height() -= long(PRINT_HEADER_HEIGHT); } if (pBorderItem) { diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx index f06043c79276..34edfe50b2c7 100644 --- a/sc/source/ui/view/select.cxx +++ b/sc/source/ui/view/select.cxx @@ -494,7 +494,7 @@ bool ScViewFunctionSet::SetCursorAtCell( SCCOL nPosX, SCROW nPosY, bool bScroll long nSizeX = 0; for (SCCOL i=nPosX+1; i<=nEndX; i++) nSizeX += pDoc->GetColWidth( i, nTab ); - long nSizeY = (long) pDoc->GetRowHeight( nPosY+1, nEndY, nTab ); + long nSizeY = static_cast<long>(pDoc->GetRowHeight( nPosY+1, nEndY, nTab )); SCCOL nDelStartX = nStartX; SCROW nDelStartY = nStartY; diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 9e88f11f36e5..070fe7dacd4f 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -765,7 +765,7 @@ void ScTabView::UpdateVarZoom() const Fraction& rOldX = GetViewData().GetZoomX(); const Fraction& rOldY = GetViewData().GetZoomY(); long nOldPercent = long(rOldY * 100); - sal_uInt16 nNewZoom = CalcZoom( eZoomType, (sal_uInt16)nOldPercent ); + sal_uInt16 nNewZoom = CalcZoom( eZoomType, static_cast<sal_uInt16>(nOldPercent) ); Fraction aNew( nNewZoom, 100 ); if ( aNew != rOldX || aNew != rOldY ) @@ -985,12 +985,12 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) // and can't be changed directly const Fraction& rOldY = aViewData.GetZoomY(); - long nOld = (long)( rOldY * 100 ); + long nOld = static_cast<long>( rOldY * 100 ); long nNew; if ( pData->GetDelta() < 0 ) - nNew = std::max( (long) MINZOOM, basegfx::zoomtools::zoomOut( nOld )); + nNew = std::max( long(MINZOOM), basegfx::zoomtools::zoomOut( nOld )); else - nNew = std::min( (long) MAXZOOM, basegfx::zoomtools::zoomIn( nOld )); + nNew = std::min( long(MAXZOOM), basegfx::zoomtools::zoomIn( nOld )); if ( nNew != nOld ) { // scroll wheel doesn't set the AppOptions default @@ -1087,7 +1087,7 @@ IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll, void ) if (bHoriz) { aHelpStr = ScGlobal::GetRscString(STR_COLUMN) + - " " + ScColToAlpha((SCCOL) nScrollPos); + " " + ScColToAlpha(static_cast<SCCOL>(nScrollPos)); aRect.Left() = aMousePos.X(); aRect.Top() = aPos.Y() - 4; @@ -1120,10 +1120,10 @@ IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll, void ) nDelta = 1; break; case ScrollType::PageUp: - if ( pScroll == aHScrollLeft.get() ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_LEFT ); - if ( pScroll == aHScrollRight.get() ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_RIGHT ); - if ( pScroll == aVScrollTop.get() ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_TOP ); - if ( pScroll == aVScrollBottom.get() ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_BOTTOM ); + if ( pScroll == aHScrollLeft.get() ) nDelta = -static_cast<long>(aViewData.PrevCellsX( SC_SPLIT_LEFT )); + if ( pScroll == aHScrollRight.get() ) nDelta = -static_cast<long>(aViewData.PrevCellsX( SC_SPLIT_RIGHT )); + if ( pScroll == aVScrollTop.get() ) nDelta = -static_cast<long>(aViewData.PrevCellsY( SC_SPLIT_TOP )); + if ( pScroll == aVScrollBottom.get() ) nDelta = -static_cast<long>(aViewData.PrevCellsY( SC_SPLIT_BOTTOM )); if (nDelta==0) nDelta=-1; break; case ScrollType::PageDown: @@ -1592,7 +1592,7 @@ void ScTabView::DoHSplit(long nSplitPos) long nLeftWidth = nSplitPos - pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width(); if ( nLeftWidth < 0 ) nLeftWidth = 0; nNewDelta = nOldDelta + aViewData.CellsAtX( nOldDelta, 1, SC_SPLIT_LEFT, - (sal_uInt16) nLeftWidth ); + static_cast<sal_uInt16>(nLeftWidth) ); if ( nNewDelta > MAXCOL ) nNewDelta = MAXCOL; aViewData.SetPosX( SC_SPLIT_RIGHT, nNewDelta ); @@ -1664,7 +1664,7 @@ void ScTabView::DoVSplit(long nSplitPos) long nTopHeight = nSplitPos - pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height(); if ( nTopHeight < 0 ) nTopHeight = 0; nNewDelta = nOldDelta + aViewData.CellsAtY( nOldDelta, 1, SC_SPLIT_TOP, - (sal_uInt16) nTopHeight ); + static_cast<sal_uInt16>(nTopHeight) ); if ( nNewDelta > MAXROW ) nNewDelta = MAXROW; aViewData.SetPosY( SC_SPLIT_BOTTOM, nNewDelta ); @@ -1699,11 +1699,11 @@ Point ScTabView::GetInsertPos() long nPosX = 0; for (SCCOL i=0; i<nCol; i++) nPosX += pDoc->GetColWidth(i,nTab); - nPosX = (long)(nPosX * HMM_PER_TWIPS); + nPosX = static_cast<long>(nPosX * HMM_PER_TWIPS); if ( pDoc->IsNegativePage( nTab ) ) nPosX = -nPosX; - long nPosY = (long) pDoc->GetRowHeight( 0, nRow-1, nTab); - nPosY = (long)(nPosY * HMM_PER_TWIPS); + long nPosY = static_cast<long>(pDoc->GetRowHeight( 0, nRow-1, nTab)); + nPosY = static_cast<long>(nPosY * HMM_PER_TWIPS); return Point(nPosX,nPosY); } @@ -1737,8 +1737,8 @@ Point ScTabView::GetChartInsertPos( const Size& rSize, const ScRange& rCellRange bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); long nLayoutSign = bLayoutRTL ? -1 : 1; - long nDocX = (long)( (double) pDoc->GetColOffset( MAXCOL + 1, nTab ) * HMM_PER_TWIPS ) * nLayoutSign; - long nDocY = (long)( (double) pDoc->GetRowOffset( MAXROW + 1, nTab ) * HMM_PER_TWIPS ); + long nDocX = static_cast<long>( static_cast<double>(pDoc->GetColOffset( MAXCOL + 1, nTab )) * HMM_PER_TWIPS ) * nLayoutSign; + long nDocY = static_cast<long>( static_cast<double>(pDoc->GetRowOffset( MAXROW + 1, nTab )) * HMM_PER_TWIPS ); if ( aVisible.Left() * nLayoutSign > nDocX * nLayoutSign ) aVisible.Left() = nDocX; @@ -2795,7 +2795,7 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) if (pModelObj) aOldSize = pModelObj->getDocumentSize(); - aViewData.SetMaxTiledRow(std::min(std::max(nEndRow, aViewData.GetMaxTiledRow()) + nVisibleRows, (long)MAXTILEDROW)); + aViewData.SetMaxTiledRow(std::min(std::max(nEndRow, aViewData.GetMaxTiledRow()) + nVisibleRows, long(MAXTILEDROW))); Size aNewSize(0, 0); if (pModelObj) @@ -2936,7 +2936,7 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) if (pModelObj) aOldSize = pModelObj->getDocumentSize(); - aViewData.SetMaxTiledCol(std::min(std::max(nEndCol, aViewData.GetMaxTiledCol()) + nVisibleCols, (long)MAXCOL)); + aViewData.SetMaxTiledCol(std::min(std::max(nEndCol, aViewData.GetMaxTiledCol()) + nVisibleCols, long(MAXCOL))); Size aNewSize(0, 0); if (pModelObj) diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index ee2897e38a69..cf4770798a19 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -1125,7 +1125,7 @@ static bool lcl_FitsInWindow( double fScaleX, double fScaleY, sal_uInt16 nZoom, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCCOL nFixPosX, SCROW nFixPosY ) { - double fZoomFactor = (double)Fraction(nZoom,100); + double fZoomFactor = static_cast<double>(Fraction(nZoom,100)); fScaleX *= fZoomFactor; fScaleY *= fZoomFactor; @@ -1137,7 +1137,7 @@ static bool lcl_FitsInWindow( double fScaleX, double fScaleY, sal_uInt16 nZoom, sal_uInt16 nColTwips = pDoc->GetColWidth( nCol, nTab ); if (nColTwips) { - nBlockX += (long)(nColTwips * fScaleX); + nBlockX += static_cast<long>(nColTwips * fScaleX); if (nBlockX > nWindowX) return false; } @@ -1147,7 +1147,7 @@ static bool lcl_FitsInWindow( double fScaleX, double fScaleY, sal_uInt16 nZoom, sal_uInt16 nColTwips = pDoc->GetColWidth( nCol, nTab ); if (nColTwips) { - nBlockX += (long)(nColTwips * fScaleX); + nBlockX += static_cast<long>(nColTwips * fScaleX); if (nBlockX > nWindowX) return false; } @@ -1163,7 +1163,7 @@ static bool lcl_FitsInWindow( double fScaleX, double fScaleY, sal_uInt16 nZoom, sal_uInt16 nRowTwips = pDoc->GetRowHeight(nRow, nTab); if (nRowTwips) { - nBlockY += (long)(nRowTwips * fScaleY); + nBlockY += static_cast<long>(nRowTwips * fScaleY); if (nBlockY > nWindowY) return false; } @@ -1173,7 +1173,7 @@ static bool lcl_FitsInWindow( double fScaleX, double fScaleY, sal_uInt16 nZoom, sal_uInt16 nRowTwips = pDoc->GetRowHeight(nRow, nTab); if (nRowTwips) { - nBlockY += (long)(nRowTwips * fScaleY); + nBlockY += static_cast<long>(nRowTwips * fScaleY); if (nBlockY > nWindowY) return false; } @@ -1350,9 +1350,9 @@ sal_uInt16 ScTabView::CalcZoom( SvxZoomType eType, sal_uInt16 nOldZoom ) double nPPTX = ScGlobal::nScreenPPTX / aViewData.GetDocShell()->GetOutputFactor(); double nPPTY = ScGlobal::nScreenPPTY; - long nZoomX = (long) ( aWinSize.Width() * 100 / + long nZoomX = static_cast<long>( aWinSize.Width() * 100 / ( aPageSize.Width() * nPPTX ) ); - long nZoomY = (long) ( aWinSize.Height() * 100 / + long nZoomY = static_cast<long>( aWinSize.Height() * 100 / ( aPageSize.Height() * nPPTY ) ); if (nZoomX > 0) diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index d1db0c9e9d97..6f40587c4d54 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -2344,7 +2344,7 @@ void ScTabView::PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCRO //!if ( nCol1 > 0 && !aViewData.GetDocument()->IsBlockEmpty( //! aViewData.GetTabNo(), //! 0, nRow1, nCol1-1, nRow2 ) ) - long nMarkPixel = (long)( SC_CLIPMARK_SIZE * aViewData.GetPPTX() ); + long nMarkPixel = static_cast<long>( SC_CLIPMARK_SIZE * aViewData.GetPPTX() ); aStart.X() -= nMarkPixel * nLayoutSign; } @@ -2430,7 +2430,7 @@ void ScTabView::PaintRangeFinder( long nNumber ) if ( pRangeFinder && pRangeFinder->GetDocName() == aViewData.GetDocShell()->GetTitle() ) { SCTAB nTab = aViewData.GetTabNo(); - sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count(); + sal_uInt16 nCount = static_cast<sal_uInt16>(pRangeFinder->Count()); if (nNumber < 0) { diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx index a366f99be4a0..be95dcbab4b5 100644 --- a/sc/source/ui/view/tabview4.cxx +++ b/sc/source/ui/view/tabview4.cxx @@ -369,7 +369,7 @@ static long lcl_GetScrollRange( SCCOLROW nDocEnd, SCCOLROW nPos, SCCOLROW nVis, ++nVis; ++nMax; // for partially visible cells - SCCOLROW nEnd = std::max(nDocEnd, (SCCOLROW)(nPos+nVis)) + nVis; + SCCOLROW nEnd = std::max(nDocEnd, static_cast<SCCOLROW>(nPos+nVis)) + nVis; if (nEnd > nMax) nEnd = nMax; diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index 005399636816..eb76bafe7151 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -581,7 +581,7 @@ void ScTabView::MakeVisible( const tools::Rectangle& rHMMRect ) if (nScrollX > 0) while (nScrollX > 0 && nPosX < MAXCOL) { - nScrollX -= (long) ( pDoc->GetColWidth(nPosX, nTab) * nPPTX ); + nScrollX -= static_cast<long>( pDoc->GetColWidth(nPosX, nTab) * nPPTX ); ++nPosX; ++nLinesX; } @@ -589,14 +589,14 @@ void ScTabView::MakeVisible( const tools::Rectangle& rHMMRect ) while (nScrollX < 0 && nPosX > 0) { --nPosX; - nScrollX += (long) ( pDoc->GetColWidth(nPosX, nTab) * nPPTX ); + nScrollX += static_cast<long>( pDoc->GetColWidth(nPosX, nTab) * nPPTX ); --nLinesX; } if (nScrollY > 0) while (nScrollY > 0 && nPosY < MAXROW) { - nScrollY -= (long) ( pDoc->GetRowHeight(nPosY, nTab) * nPPTY ); + nScrollY -= static_cast<long>( pDoc->GetRowHeight(nPosY, nTab) * nPPTY ); ++nPosY; ++nLinesY; } @@ -604,7 +604,7 @@ void ScTabView::MakeVisible( const tools::Rectangle& rHMMRect ) while (nScrollY < 0 && nPosY > 0) { --nPosY; - nScrollY += (long) ( pDoc->GetRowHeight(nPosY, nTab) * nPPTY ); + nScrollY += static_cast<long>( pDoc->GetRowHeight(nPosY, nTab) * nPPTY ); --nLinesY; } diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index ddd1ef663525..a1450c31bf06 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -381,7 +381,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) { // one-based row numbers - aScAddress.SetRow( (SCROW)(nNumeric - 1) ); + aScAddress.SetRow( static_cast<SCROW>(nNumeric - 1) ); aScAddress.SetCol( rViewData.GetCurX() ); aScAddress.SetTab( nTab ); aScRange = ScRange( aScAddress, aScAddress ); @@ -692,7 +692,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) SvxZoomType eOldZoomType = GetZoomType(); SvxZoomType eNewZoomType = eOldZoomType; const Fraction& rOldY = GetViewData().GetZoomY(); // Y is shown - sal_uInt16 nOldZoom = (sal_uInt16)long( rOldY * 100 ); + sal_uInt16 nOldZoom = static_cast<sal_uInt16>(long( rOldY * 100 )); sal_uInt16 nZoom = nOldZoom; bool bCancel = false; diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index 844eecb01f3a..3c69bb0ce1d4 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -301,7 +301,7 @@ void ScTabViewShell::GetState( SfxItemSet& rSet ) else { const Fraction& rOldY = GetViewData().GetZoomY(); - sal_uInt16 nZoom = (sal_uInt16)long( rOldY * 100 ); + sal_uInt16 nZoom = static_cast<sal_uInt16>(long( rOldY * 100 )); rSet.Put( SvxZoomItem( SvxZoomType::PERCENT, nZoom, nWhich ) ); } break; @@ -313,7 +313,7 @@ void ScTabViewShell::GetState( SfxItemSet& rSet ) else { const Fraction& rOldY = GetViewData().GetZoomY(); - sal_uInt16 nCurrentZoom = (sal_uInt16)long( rOldY * 100 ); + sal_uInt16 nCurrentZoom = static_cast<sal_uInt16>(long( rOldY * 100 )); if( nCurrentZoom ) { diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index a7fe6dc18ce8..90206529602e 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -514,8 +514,8 @@ ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh ) : SetHScrollMode ( true ); SetOutlineMode ( true ); - aScrSize = Size( (long) ( STD_COL_WIDTH * PIXEL_PER_TWIPS * OLE_STD_CELLS_X ), - (long) ( ScGlobal::nStdRowHeight * PIXEL_PER_TWIPS * OLE_STD_CELLS_Y ) ); + aScrSize = Size( long( STD_COL_WIDTH * PIXEL_PER_TWIPS * OLE_STD_CELLS_X ), + static_cast<long>( ScGlobal::nStdRowHeight * PIXEL_PER_TWIPS * OLE_STD_CELLS_Y ) ); maTabData.push_back( new ScViewDataTable ); pThisTab = maTabData[nTabNo]; for (sal_uInt16 j=0; j<4; j++) @@ -824,9 +824,9 @@ void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vec // sanity check - we shouldn't need something this low / big SAL_WARN_IF(rNewX < Fraction(1, 100) || rNewX > Fraction(100, 1), "sc.viewdata", - "fraction rNewX not sensible: " << (double) rNewX); + "fraction rNewX not sensible: " << static_cast<double>(rNewX)); SAL_WARN_IF(rNewY < Fraction(1, 100) || rNewY > Fraction(100, 1), "sc.viewdata", - "fraction rNewY not sensible: " << (double) rNewY); + "fraction rNewY not sensible: " << static_cast<double>(rNewY)); if ( bAll ) { @@ -2043,7 +2043,7 @@ SCCOL ScViewData::CellsAtX( SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX, sal_uI SCCOL nX; sal_uInt16 nScrPosX = 0; - if (nScrSizeX == SC_SIZE_NONE) nScrSizeX = (sal_uInt16) aScrSize.Width(); + if (nScrSizeX == SC_SIZE_NONE) nScrSizeX = static_cast<sal_uInt16>(aScrSize.Width()); if (nDir==1) nX = nPosX; // forwards @@ -2062,7 +2062,7 @@ SCCOL ScViewData::CellsAtX( SCCOL nPosX, SCCOL nDir, ScHSplitPos eWhichX, sal_uI if (nTSize) { long nSizeXPix = ToPixel( nTSize, nPPTX ); - nScrPosX = sal::static_int_cast<sal_uInt16>( nScrPosX + (sal_uInt16) nSizeXPix ); + nScrPosX = sal::static_int_cast<sal_uInt16>( nScrPosX + static_cast<sal_uInt16>(nSizeXPix) ); } } } @@ -2083,7 +2083,7 @@ SCROW ScViewData::CellsAtY( SCROW nPosY, SCROW nDir, ScVSplitPos eWhichY, sal_uI if (pView) const_cast<ScViewData*>(this)->aScrSize.Height() = pView->GetGridHeight(eWhichY); - if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = (sal_uInt16) aScrSize.Height(); + if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = static_cast<sal_uInt16>(aScrSize.Height()); SCROW nY; @@ -2316,7 +2316,7 @@ void ScViewData::SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX ) pThisTab->nPosX[eWhich] = nNewPosX; pThisTab->nTPosX[eWhich] = nTPosX; - pThisTab->nMPosX[eWhich] = (long) (nTPosX * HMM_PER_TWIPS); + pThisTab->nMPosX[eWhich] = static_cast<long>(nTPosX * HMM_PER_TWIPS); pThisTab->nPixPosX[eWhich] = nPixPosX; } else @@ -2359,7 +2359,7 @@ void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY ) pThisTab->nPosY[eWhich] = nNewPosY; pThisTab->nTPosY[eWhich] = nTPosY; - pThisTab->nMPosY[eWhich] = (long) (nTPosY * HMM_PER_TWIPS); + pThisTab->nMPosY[eWhich] = static_cast<long>(nTPosY * HMM_PER_TWIPS); pThisTab->nPixPosY[eWhich] = nPixPosY; } else @@ -2421,7 +2421,7 @@ void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) if (nTSize) { nSizePix = ToPixel( nTSize, nPPTX ); - nScrPosX += (sal_uInt16) nSizePix; + nScrPosX += static_cast<sal_uInt16>(nSizePix); } } @@ -2431,7 +2431,7 @@ void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) if (nTSize) { nSizePix = ToPixel( nTSize, nPPTY ); - nScrPosY += (sal_uInt16) nSizePix; + nScrPosY += static_cast<sal_uInt16>(nSizePix); } } @@ -2446,14 +2446,14 @@ void ScViewData::SetScreenPos( const Point& rVisAreaStart ) bool bEnd; nSize = 0; - nTwips = (long) (rVisAreaStart.X() / HMM_PER_TWIPS); + nTwips = static_cast<long>(rVisAreaStart.X() / HMM_PER_TWIPS); if ( pDoc->IsLayoutRTL( nTabNo ) ) nTwips = -nTwips; SCCOL nX1 = 0; bEnd = false; while (!bEnd) { - nAdd = (long) pDoc->GetColWidth(nX1,nTabNo); + nAdd = static_cast<long>(pDoc->GetColWidth(nX1,nTabNo)); if (nSize+nAdd <= nTwips+1 && nX1<MAXCOL) { nSize += nAdd; @@ -2464,12 +2464,12 @@ void ScViewData::SetScreenPos( const Point& rVisAreaStart ) } nSize = 0; - nTwips = (long) (rVisAreaStart.Y() / HMM_PER_TWIPS); + nTwips = static_cast<long>(rVisAreaStart.Y() / HMM_PER_TWIPS); SCROW nY1 = 0; bEnd = false; while (!bEnd) { - nAdd = (long) pDoc->GetRowHeight(nY1,nTabNo); + nAdd = static_cast<long>(pDoc->GetRowHeight(nY1,nTabNo)); if (nSize+nAdd <= nTwips+1 && nY1<MAXROW) { nSize += nAdd; @@ -2494,10 +2494,8 @@ void ScViewData::SetScreen( const tools::Rectangle& rVisArea ) // here without GetOutputFactor(), since it's for the output into a Metafile aScrSize = rVisArea.GetSize(); - aScrSize.Width() = (long) - ( aScrSize.Width() * ScGlobal::nScreenPPTX / HMM_PER_TWIPS ); - aScrSize.Height() = (long) - ( aScrSize.Height() * ScGlobal::nScreenPPTY / HMM_PER_TWIPS ); + aScrSize.Width() = static_cast<long>( aScrSize.Width() * ScGlobal::nScreenPPTX / HMM_PER_TWIPS ); + aScrSize.Height() = static_cast<long>( aScrSize.Height() * ScGlobal::nScreenPPTY / HMM_PER_TWIPS ); } ScDocFunc& ScViewData::GetDocFunc() const @@ -2572,18 +2570,18 @@ void ScViewData::UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY aHeight *= Fraction( aScrSize.Height(),1 ); aHeight /= aOldY; - aScrSize.Width() = (long) aWidth; - aScrSize.Height() = (long) aHeight; + aScrSize.Width() = static_cast<long>(aWidth); + aScrSize.Height() = static_cast<long>(aHeight); } void ScViewData::CalcPPT() { double nOldPPTX = nPPTX; double nOldPPTY = nPPTY; - nPPTX = ScGlobal::nScreenPPTX * (double) GetZoomX(); + nPPTX = ScGlobal::nScreenPPTX * static_cast<double>(GetZoomX()); if (pDocShell) nPPTX = nPPTX / pDocShell->GetOutputFactor(); // Factor is printer to screen - nPPTY = ScGlobal::nScreenPPTY * (double) GetZoomY(); + nPPTY = ScGlobal::nScreenPPTY * static_cast<double>(GetZoomY()); // if detective objects are present, // try to adjust horizontal scale so the most common column width has minimal rounding errors, @@ -2636,9 +2634,9 @@ void ScViewData::WriteUserData(OUString& rData) // PosX[left]/PosX[right]/PosY[top]/PosY[bottom] // when rows bigger than 8192, "+" instead of "/" - sal_uInt16 nZoom = (sal_uInt16)long(pThisTab->aZoomY * 100); + sal_uInt16 nZoom = static_cast<sal_uInt16>(long(pThisTab->aZoomY * 100)); rData = OUString::number( nZoom ) + "/"; - nZoom = (sal_uInt16)long(pThisTab->aPageZoomY * 100); + nZoom = static_cast<sal_uInt16>(long(pThisTab->aPageZoomY * 100)); rData += OUString::number( nZoom ) + "/"; if (bPagebreak) rData += "1"; @@ -2836,7 +2834,7 @@ void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const rSplitPos = Point( bHSplit ? pViewTab->nHSplitPos : 0, bVSplit ? pViewTab->nVSplitPos : 0 ); rSplitPos = Application::GetDefaultDevice()->PixelToLogic( rSplitPos, MapMode( MapUnit::MapTwip ) ); if( pDocShell ) - rSplitPos.X() = (long)((double)rSplitPos.X() / pDocShell->GetOutputFactor()); + rSplitPos.X() = static_cast<long>(static_cast<double>(rSplitPos.X()) / pDocShell->GetOutputFactor()); } else if( bFrozen ) { @@ -2976,7 +2974,7 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt ) if( pDocShell && SC_MOD()->GetInputOptions().GetTextWysiwyg()) { double nFactor = pDocShell->GetOutputFactor(); - aPixel.X() = (long)( aPixel.X() * nFactor + 0.5 ); + aPixel.X() = static_cast<long>( aPixel.X() * nFactor + 0.5 ); } bHSplit = bHSplit && aPixel.X() > 0; diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index e3ff5a013a01..729cad4210eb 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -174,7 +174,7 @@ bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow ) Fraction aZoomY = GetViewData().GetZoomY(); sal_uInt16 nOldPixel = 0; if (nStartRow == nEndRow) - nOldPixel = (sal_uInt16) (rDoc.GetRowHeight(nStartRow,nTab) * nPPTY); + nOldPixel = static_cast<sal_uInt16>(rDoc.GetRowHeight(nStartRow,nTab) * nPPTY); ScSizeDeviceProvider aProv(pDocSh); if (aProv.IsPrinter()) @@ -192,7 +192,7 @@ bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow ) if (bChanged && ( nStartRow == nEndRow )) { - sal_uInt16 nNewPixel = (sal_uInt16) (rDoc.GetRowHeight(nStartRow,nTab) * nPPTY); + sal_uInt16 nNewPixel = static_cast<sal_uInt16>(rDoc.GetRowHeight(nStartRow,nTab) * nPPTY); if ( nNewPixel == nOldPixel ) bChanged = false; } diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index dd038f35e242..4111afb66aac 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -609,12 +609,12 @@ void ScViewFunc::PasteFromTransferable( const uno::Reference<datatransfer::XTran { sal_Int64 nHandle = xTunnel->getSomething( ScTransferObj::getUnoTunnelId() ); if ( nHandle ) - pOwnClip = reinterpret_cast<ScTransferObj*>( (sal_IntPtr) nHandle); + pOwnClip = reinterpret_cast<ScTransferObj*>( static_cast<sal_IntPtr>(nHandle)); else { nHandle = xTunnel->getSomething( ScDrawTransferObj::getUnoTunnelId() ); if ( nHandle ) - pDrawClip = reinterpret_cast<ScDrawTransferObj*>( (sal_IntPtr) nHandle ); + pDrawClip = reinterpret_cast<ScDrawTransferObj*>( static_cast<sal_IntPtr>(nHandle) ); } } diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx index 7a82ea88b9ea..3f4db0cfba59 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -97,7 +97,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId, if (pDoc->IsNegativePage(nTab)) nXT = -nXT; sal_uLong nYT = pDoc->GetRowHeight( 0, nPosY-1, nTab); - aPos = Point( (long)(nXT * HMM_PER_TWIPS), (long)(nYT * HMM_PER_TWIPS) ); + aPos = Point( static_cast<long>(nXT * HMM_PER_TWIPS), static_cast<long>(nYT * HMM_PER_TWIPS) ); } } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 787d9f9a8352..3959bcd28348 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -305,7 +305,7 @@ static bool lcl_AddFunction( ScAppOptions& rAppOpt, sal_uInt16 nOpCode ) if ( !lcl_FunctionKnown( nOpCode ) ) return false; // not in function list -> no change - sal_uInt16 nNewCount = std::min( (sal_uInt16)(nOldCount + 1), (sal_uInt16)LRU_MAX ); + sal_uInt16 nNewCount = std::min( static_cast<sal_uInt16>(nOldCount + 1), sal_uInt16(LRU_MAX) ); sal_uInt16 nNewList[LRU_MAX]; nNewList[0] = nOpCode; for (nPos=1; nPos<nNewCount; nPos++) @@ -2372,7 +2372,7 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal ) nMargin = sal::static_int_cast<sal_uInt16>( nMargin + pPattern->GetItem(ATTR_INDENT).GetValue() ); - nWidth = (sal_uInt16)(nEdit * pDocSh->GetOutputFactor() / HMM_PER_TWIPS) + nWidth = static_cast<sal_uInt16>(nEdit * pDocSh->GetOutputFactor() / HMM_PER_TWIPS) + nMargin + STD_EXTRA_WIDTH; } } @@ -2393,7 +2393,7 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, bool bOptimal ) long nPixel = rDoc.GetNeededSize( nCol, nRow, nTab, aProv.GetDevice(), nPPTX, nPPTY, aZoomX, aZoomY, true ); - sal_uInt16 nTwips = (sal_uInt16)( nPixel / nPPTX ); + sal_uInt16 nTwips = static_cast<sal_uInt16>( nPixel / nPPTX ); if (nTwips != 0) nWidth = nTwips + STD_EXTRA_WIDTH; else |