sw/inc/calc.hxx | 3 sw/inc/swtable.hxx | 2 sw/qa/core/doc/doc.cxx | 4 sw/qa/extras/odfexport/odfexport.cxx | 10 +- sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 4 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 8 - sw/qa/extras/rtfexport/rtfexport.cxx | 4 sw/qa/extras/rtfexport/rtfexport3.cxx | 2 sw/qa/extras/tiledrendering/tiledrendering.cxx | 2 sw/qa/extras/uiwriter/uiwriter.cxx | 8 - sw/qa/extras/ww8export/ww8export3.cxx | 2 sw/source/core/SwNumberTree/SwNodeNum.cxx | 2 sw/source/core/access/accportions.cxx | 2 sw/source/core/crsr/crsrsh.cxx | 4 sw/source/core/crsr/swcrsr.cxx | 4 sw/source/core/crsr/trvltbl.cxx | 2 sw/source/core/doc/DocumentContentOperationsManager.cxx | 2 sw/source/core/doc/DocumentFieldsManager.cxx | 2 sw/source/core/doc/DocumentLayoutManager.cxx | 2 sw/source/core/doc/DocumentStylePoolManager.cxx | 8 - sw/source/core/doc/doc.cxx | 4 sw/source/core/doc/docdesc.cxx | 4 sw/source/core/doc/docdraw.cxx | 6 - sw/source/core/doc/docfmt.cxx | 2 sw/source/core/doc/docftn.cxx | 10 +- sw/source/core/doc/doclay.cxx | 2 sw/source/core/doc/docnum.cxx | 6 - sw/source/core/doc/docsort.cxx | 2 sw/source/core/doc/doctxm.cxx | 4 sw/source/core/doc/fmtcol.cxx | 2 sw/source/core/doc/htmltbl.cxx | 66 ++++++++-------- sw/source/core/doc/notxtfrm.cxx | 2 sw/source/core/doc/number.cxx | 6 - sw/source/core/doc/tblcpy.cxx | 8 - sw/source/core/doc/tblrwcl.cxx | 24 ++--- sw/source/core/doc/textboxhelper.cxx | 20 ++-- sw/source/core/docnode/ndtbl.cxx | 12 +- sw/source/core/docnode/ndtbl1.cxx | 4 sw/source/core/docnode/section.cxx | 2 sw/source/core/edit/autofmt.cxx | 20 ++-- sw/source/core/edit/edattr.cxx | 8 - sw/source/core/edit/edfld.cxx | 2 sw/source/core/edit/editsh.cxx | 2 sw/source/core/edit/ednumber.cxx | 2 sw/source/core/fields/dbfld.cxx | 2 sw/source/core/fields/expfld.cxx | 8 - sw/source/core/frmedt/fetab.cxx | 8 - sw/source/core/frmedt/tblsel.cxx | 2 sw/source/core/graphic/grfatr.cxx | 2 sw/source/core/inc/tblrwcl.hxx | 2 sw/source/core/inc/wrong.hxx | 2 sw/source/core/layout/atrfrm.cxx | 10 +- sw/source/core/layout/dbg_lay.cxx | 2 sw/source/core/layout/wsfrm.cxx | 4 sw/source/core/table/swnewtable.cxx | 6 - sw/source/core/table/swtable.cxx | 12 +- sw/source/core/text/EnhancedPDFExportHelper.cxx | 4 sw/source/core/text/frmcrsr.cxx | 2 sw/source/core/text/inftxt.cxx | 4 sw/source/core/text/itradj.cxx | 4 sw/source/core/text/itratr.cxx | 4 sw/source/core/text/itrcrsr.cxx | 4 sw/source/core/text/itrform2.cxx | 24 ++--- sw/source/core/text/porfld.cxx | 12 +- sw/source/core/text/porfly.cxx | 6 - sw/source/core/text/porlin.cxx | 4 sw/source/core/text/pormulti.cxx | 10 +- sw/source/core/text/porrst.cxx | 4 sw/source/core/text/portxt.cxx | 2 sw/source/core/text/txtdrop.cxx | 12 +- sw/source/core/text/txtfly.cxx | 2 sw/source/core/text/txtfrm.cxx | 8 - sw/source/core/text/txtftn.cxx | 2 sw/source/core/text/txttab.cxx | 8 - sw/source/core/text/wrong.cxx | 8 - sw/source/core/tox/ToxTextGenerator.cxx | 2 sw/source/core/tox/tox.cxx | 8 - sw/source/core/tox/txmsrt.cxx | 4 sw/source/core/txtnode/atrftn.cxx | 4 sw/source/core/txtnode/fntcache.cxx | 32 +++---- sw/source/core/txtnode/fntcap.cxx | 2 sw/source/core/txtnode/ndtxt.cxx | 12 +- sw/source/core/txtnode/swfont.cxx | 2 sw/source/core/txtnode/thints.cxx | 6 - sw/source/core/txtnode/txtatr2.cxx | 2 sw/source/core/undo/undobj1.cxx | 2 sw/source/core/undo/undraw.cxx | 2 sw/source/core/undo/unnum.cxx | 2 sw/source/core/undo/untbl.cxx | 2 sw/source/core/unocore/unocoll.cxx | 2 sw/source/core/unocore/unoframe.cxx | 8 - sw/source/core/unocore/unoidx.cxx | 8 - sw/source/core/unocore/unoobj.cxx | 4 sw/source/core/unocore/unosett.cxx | 6 - sw/source/core/unocore/unotbl.cxx | 12 +- sw/source/core/view/pagepreviewlayout.cxx | 4 sw/source/filter/basflt/fltini.cxx | 4 sw/source/filter/html/css1atr.cxx | 4 sw/source/filter/html/htmlatr.cxx | 4 sw/source/filter/html/htmldrawreader.cxx | 6 - sw/source/filter/html/htmlflywriter.cxx | 8 - sw/source/filter/html/htmlform.cxx | 8 - sw/source/filter/html/htmlftn.cxx | 2 sw/source/filter/html/htmlgrin.cxx | 2 sw/source/filter/html/htmlnum.cxx | 2 sw/source/filter/html/htmlnumreader.cxx | 8 - sw/source/filter/html/htmlplug.cxx | 2 sw/source/filter/html/htmlsect.cxx | 6 - sw/source/filter/html/htmltab.cxx | 48 +++++------ sw/source/filter/html/htmltabw.cxx | 4 sw/source/filter/html/svxcss1.cxx | 60 +++++++------- sw/source/filter/html/swhtml.cxx | 26 +++--- sw/source/filter/html/wrthtml.cxx | 2 sw/source/filter/writer/wrtswtbl.cxx | 8 - sw/source/filter/ww8/docxattributeoutput.cxx | 2 sw/source/filter/ww8/writerhelper.cxx | 4 sw/source/filter/ww8/wrtw8num.cxx | 2 sw/source/filter/ww8/wrtw8sty.cxx | 2 sw/source/filter/ww8/wrtww8.cxx | 18 ++-- sw/source/filter/ww8/wrtww8gr.cxx | 8 - sw/source/filter/ww8/ww8atr.cxx | 24 ++--- sw/source/filter/ww8/ww8graf.cxx | 8 - sw/source/filter/ww8/ww8graf2.cxx | 2 sw/source/filter/ww8/ww8par.cxx | 12 +- sw/source/filter/ww8/ww8par2.cxx | 10 +- sw/source/filter/ww8/ww8par3.cxx | 12 +- sw/source/filter/ww8/ww8par5.cxx | 12 +- sw/source/filter/ww8/ww8par6.cxx | 14 +-- sw/source/filter/ww8/ww8scan.cxx | 14 +-- sw/source/filter/xml/xmlimpit.cxx | 28 +++--- sw/source/filter/xml/xmliteme.cxx | 4 sw/source/filter/xml/xmlitemm.cxx | 9 +- sw/source/filter/xml/xmlithlp.cxx | 3 sw/source/filter/xml/xmlmeta.cxx | 2 sw/source/filter/xml/xmltble.cxx | 2 sw/source/filter/xml/xmltbli.cxx | 2 sw/source/ui/chrdlg/break.cxx | 2 sw/source/ui/chrdlg/drpcps.cxx | 4 sw/source/ui/chrdlg/numpara.cxx | 2 sw/source/ui/config/optload.cxx | 4 sw/source/ui/config/optpage.cxx | 8 - sw/source/ui/dbui/dbinsdlg.cxx | 2 sw/source/ui/dbui/mmaddressblockpage.cxx | 4 sw/source/ui/envelp/envfmt.cxx | 6 - sw/source/ui/fldui/flddb.cxx | 2 sw/source/ui/fldui/fldvar.cxx | 2 sw/source/ui/frmdlg/column.cxx | 12 +- sw/source/ui/frmdlg/cption.cxx | 2 sw/source/ui/frmdlg/frmpage.cxx | 2 sw/source/ui/frmdlg/wrap.cxx | 8 - sw/source/ui/misc/linenum.cxx | 6 - sw/source/ui/misc/outline.cxx | 6 - sw/source/ui/table/colwd.cxx | 6 - sw/source/ui/table/tabledlg.cxx | 2 sw/source/uibase/app/appenv.cxx | 8 - sw/source/uibase/app/applab.cxx | 4 sw/source/uibase/app/appopt.cxx | 8 - sw/source/uibase/app/docsh2.cxx | 2 sw/source/uibase/app/swmodul1.cxx | 2 sw/source/uibase/config/modcfg.cxx | 8 - sw/source/uibase/config/usrpref.cxx | 2 sw/source/uibase/config/viewopt.cxx | 2 sw/source/uibase/dbui/mailmergehelper.cxx | 12 +- sw/source/uibase/dochdl/gloshdl.cxx | 4 sw/source/uibase/docvw/srcedtw.cxx | 4 sw/source/uibase/fldui/fldmgr.cxx | 12 +- sw/source/uibase/frmdlg/colex.cxx | 8 - sw/source/uibase/frmdlg/colmgr.cxx | 6 - sw/source/uibase/lingu/hhcwrp.cxx | 6 - sw/source/uibase/misc/glosdoc.cxx | 10 +- sw/source/uibase/ribbar/inputwin.cxx | 10 +- sw/source/uibase/ribbar/workctrl.cxx | 6 - sw/source/uibase/shells/basesh.cxx | 2 sw/source/uibase/shells/textfld.cxx | 2 sw/source/uibase/shells/textsh1.cxx | 2 sw/source/uibase/uiview/pview.cxx | 2 sw/source/uibase/uiview/view.cxx | 2 sw/source/uibase/uiview/viewmdi.cxx | 2 sw/source/uibase/uiview/viewsrch.cxx | 2 sw/source/uibase/uiview/viewstat.cxx | 2 sw/source/uibase/uiview/viewtab.cxx | 44 +++++----- sw/source/uibase/uno/unoatxt.cxx | 2 sw/source/uibase/uno/unomod.cxx | 2 sw/source/uibase/utlui/bookctrl.cxx | 2 sw/source/uibase/utlui/gloslst.cxx | 2 sw/source/uibase/wrtsh/wrtsh1.cxx | 12 +- 186 files changed, 641 insertions(+), 638 deletions(-)
New commits: commit 2634bc59092b24217d984a5845365d703bdb08d2 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri May 21 17:44:32 2021 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri May 21 21:09:57 2021 +0200 sw: replace most static_cast<sal_uInt16>() calls with o3tl::narrowing() o3tl::narrowing() is a better way to handle this, as that way the integer conversion is still implicit, which allows detecting integer truncation at runtime (with suitable compiler flags). Change-Id: I499abda3be6943e8c111c56df390e72939586221 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115948 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx index 7590680d72c5..4121cc7f0e72 100644 --- a/sw/inc/calc.hxx +++ b/sw/inc/calc.hxx @@ -27,6 +27,7 @@ #include <rtl/ustrbuf.hxx> #include <tools/solar.h> #include <tools/long.hxx> +#include <o3tl/safeint.hxx> #include "swdllapi.h" class CharClass; @@ -167,7 +168,7 @@ public: ii %= nTableSize; if( pPos ) - *pPos = static_cast<sal_uInt16>(ii); + *pPos = o3tl::narrowing<sal_uInt16>(ii); for( T* pEntry = m_aData[ii].get(); pEntry; pEntry = static_cast<T*>(pEntry->pNext.get()) ) { diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index 6696c94d6cfc..6b27c9ea21e4 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -192,7 +192,7 @@ public: /// Set the new table style name for this table. void SetTableStyleName(const OUString& rName) { maTableStyleName = rName; } - sal_uInt16 GetRowsToRepeat() const { return std::min( static_cast<sal_uInt16>(GetTabLines().size()), m_nRowsToRepeat ); } + sal_uInt16 GetRowsToRepeat() const { return std::min( o3tl::narrowing<sal_uInt16>(GetTabLines().size()), m_nRowsToRepeat ); } void SetRowsToRepeat( sal_uInt16 nNumOfRows ) { m_nRowsToRepeat = nNumOfRows; } bool IsHeadline( const SwTableLine& rLine ) const; diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 68d5992b05be..00b8df8a3c41 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -66,8 +66,8 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextboxTextRotateAngle) SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "textbox-textrotateangle.odt"); SwFrameFormats& rFrameFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFrameFormats.size()); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(RES_DRAWFRMFMT), rFrameFormats[0]->Which()); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(RES_FLYFRMFMT), rFrameFormats[1]->Which()); + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_DRAWFRMFMT), rFrameFormats[0]->Which()); + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_FLYFRMFMT), rFrameFormats[1]->Which()); SvxFrameDirection eActual = rFrameFormats[1]->GetAttrSet().GetItem(RES_FRAMEDIR)->GetValue(); // Without the accompanying fix in place, this test would have failed with: diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index d5efe8a29677..13ace3b1a1fa 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -2951,7 +2951,7 @@ DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.odt") // - Expected: 64 // - Actual : 4 // i.e. numbering type was ARABIC, not ARABIC_ZERO. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO), aMap["NumberingType"].get<sal_uInt16>()); } @@ -2965,7 +2965,7 @@ DECLARE_ODFEXPORT_TEST(testArabicZero3Numbering, "arabic-zero3-numbering.odt") // - Expected: 65 // - Actual : 4 // i.e. numbering type was ARABIC, not ARABIC_ZERO3. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO3), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO3), aMap["NumberingType"].get<sal_uInt16>()); } @@ -2979,7 +2979,7 @@ DECLARE_ODFEXPORT_TEST(testArabicZero4Numbering, "arabic-zero4-numbering.odt") // - Expected: 66 // - Actual : 4 // i.e. numbering type was ARABIC, not ARABIC_ZERO4. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO4), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO4), aMap["NumberingType"].get<sal_uInt16>()); } @@ -2993,7 +2993,7 @@ DECLARE_ODFEXPORT_TEST(testArabicZero5Numbering, "arabic-zero5-numbering.odt") // - Expected: 67 // - Actual : 4 // i.e. numbering type was ARABIC, not ARABIC_ZERO5. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO5), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO5), aMap["NumberingType"].get<sal_uInt16>()); } @@ -3007,7 +3007,7 @@ DECLARE_ODFEXPORT_TEST(testRovasNumbering, "rovas-numbering.odt") // - Expected: 68 // - Actual : 4 // i.e. numbering type was ARABIC, not SZEKELY_ROVAS. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::SZEKELY_ROVAS), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::SZEKELY_ROVAS), aMap["NumberingType"].get<sal_uInt16>()); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 5f3fc94cd8e4..40bcaaa5875b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -339,8 +339,8 @@ DECLARE_OOXMLEXPORT_TEST(testBtlrShape, "btlr-textbox.docx") SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size()); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(RES_DRAWFRMFMT), rFormats[0]->Which()); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(RES_FLYFRMFMT), rFormats[1]->Which()); + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_DRAWFRMFMT), rFormats[0]->Which()); + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_FLYFRMFMT), rFormats[1]->Which()); // Without the accompanying fix in place, this test would have failed with 'Expected: 5, Actual: // 4', i.e. the textbox inherited its writing direction instead of having an explicit btlr // value. diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 24f51850e4ff..293f82ed9c87 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -363,7 +363,7 @@ DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.docx") // - Expected: 64 // - Actual : 4 // i.e. numbering type was ARABIC, not ARABIC_ZERO. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO), aMap["NumberingType"].get<sal_uInt16>()); } @@ -376,7 +376,7 @@ DECLARE_ODFEXPORT_TEST(testArabicZero3Numbering, "arabic-zero3-numbering.docx") // - Expected: 65 // - Actual : 4 // i.e. numbering type was ARABIC, not ARABIC_ZERO3. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO3), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO3), aMap["NumberingType"].get<sal_uInt16>()); } @@ -389,7 +389,7 @@ DECLARE_ODFEXPORT_TEST(testArabicZero4Numbering, "arabic-zero4-numbering.docx") // - Expected: 66 // - Actual : 4 // i.e. numbering type was ARABIC, not ARABIC_ZERO4. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO4), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO4), aMap["NumberingType"].get<sal_uInt16>()); } @@ -402,7 +402,7 @@ DECLARE_ODFEXPORT_TEST(testArabicZero5Numbering, "arabic-zero5-numbering.docx") // - Expected: 67 // - Actual : 4 // i.e. numbering type was ARABIC, not ARABIC_ZERO5. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO5), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO5), aMap["NumberingType"].get<sal_uInt16>()); } diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 049c78bd7f6b..75c4382324e5 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -1135,8 +1135,8 @@ DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf") // Test roundtrip of date in general, and year/month/day in particular. util::DateTime aDate = getProperty<util::DateTime>(xUserDefinedProperties, "d"); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2016), aDate.Year); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), aDate.Month); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(30), aDate.Day); + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(1), aDate.Month); + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(30), aDate.Day); // Test real number. CPPUNIT_ASSERT_EQUAL(3.14, getProperty<double>(xUserDefinedProperties, "pi")); diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx index 4468a97650b5..efbb7c806477 100644 --- a/sw/qa/extras/rtfexport/rtfexport3.cxx +++ b/sw/qa/extras/rtfexport/rtfexport3.cxx @@ -187,7 +187,7 @@ DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.rtf") // - Expected: 64 // - Actual : 4 // i.e. numbering type was ARABIC, not ARABIC_ZERO. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO), aMap["NumberingType"].get<sal_uInt16>()); } diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index aab2a4cc71e8..854fe65c95ca 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1488,7 +1488,7 @@ void SwTiledRenderingTest::testTrackChanges() // Reject the change by id, while the cursor does not cover the tracked change. uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { - {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(pRedline->GetId()))} + {"RejectTrackedChange", uno::makeAny(o3tl::narrowing<sal_uInt16>(pRedline->GetId()))} })); comphelper::dispatchCommand(".uno:RejectTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 8ef3de9d6a60..c47e5402304e 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -2404,7 +2404,7 @@ void SwUiWriterTest::testDeleteTableRedlines() IDocumentRedlineAccess& rIDRA = pDoc->getIDocumentRedlineAccess(); SwExtraRedlineTable& rExtras = rIDRA.GetExtraRedlineTable(); rExtras.DeleteAllTableRedlines(*pDoc, rTable, false, RedlineType::Any); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(0), rExtras.GetSize()); + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(0), rExtras.GetSize()); } void SwUiWriterTest::testXFlatParagraph() @@ -5966,7 +5966,7 @@ void SwUiWriterTest::testRedlineParam() pWrtShell->StartOfSection(); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { - {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(rTable[0]->GetId()))} + {"NextTrackedChange", uno::makeAny(o3tl::narrowing<sal_uInt16>(rTable[0]->GetId()))} })); dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); @@ -5979,7 +5979,7 @@ void SwUiWriterTest::testRedlineParam() pWrtShell->StartOfSection(); aPropertyValues = comphelper::InitPropertySequence( { - {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(rTable[1]->GetId()))} + {"NextTrackedChange", uno::makeAny(o3tl::narrowing<sal_uInt16>(rTable[1]->GetId()))} }); dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); @@ -5990,7 +5990,7 @@ void SwUiWriterTest::testRedlineParam() pWrtShell->StartOfSection(); aPropertyValues = comphelper::InitPropertySequence( { - {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(rTable[1]->GetId()))} + {"RejectTrackedChange", uno::makeAny(o3tl::narrowing<sal_uInt16>(rTable[1]->GetId()))} }); dispatchCommand(mxComponent, ".uno:RejectTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index 4d982dbdb982..691a562ec434 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -139,7 +139,7 @@ DECLARE_WW8EXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.doc") // - Expected: 64 // - Actual : 4 // i.e. numbering type was ARABIC, not ARABIC_ZERO. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO), + CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(style::NumberingType::ARABIC_ZERO), aMap["NumberingType"].get<sal_uInt16>()); } diff --git a/sw/source/core/SwNumberTree/SwNodeNum.cxx b/sw/source/core/SwNumberTree/SwNodeNum.cxx index 6bf92d3eb73a..af92fe21ddc8 100644 --- a/sw/source/core/SwNumberTree/SwNodeNum.cxx +++ b/sw/source/core/SwNumberTree/SwNodeNum.cxx @@ -273,7 +273,7 @@ SwNumberTree::tSwNumTreeNumber SwNodeNum::GetStartValue() const if (nLevel >= 0 && nLevel < MAXLEVEL) { - const SwNumFormat * pFormat = pRule->GetNumFormat( static_cast<sal_uInt16>(nLevel)); + const SwNumFormat * pFormat = pRule->GetNumFormat( o3tl::narrowing<sal_uInt16>(nLevel)); if (pFormat) aResult = pFormat->GetStart(); diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx index 9310a290a184..b1da888d5af7 100644 --- a/sw/source/core/access/accportions.cxx +++ b/sw/source/core/access/accportions.cxx @@ -615,7 +615,7 @@ TextFrameIndex SwAccessiblePortionData::FillSpecialPos( // (if necessary) size_t nRefLine = FindBreak( m_aLineBreaks, nRefPos ); size_t nMyLine = FindBreak( m_aLineBreaks, nPos ); - sal_uInt16 nLineOffset = static_cast<sal_uInt16>( nMyLine - nRefLine ); + sal_uInt16 nLineOffset = o3tl::narrowing<sal_uInt16>( nMyLine - nRefLine ); if( nLineOffset != 0 ) nRefPos = m_aLineBreaks[ nMyLine ]; diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index a7d4d2474613..6f5516d69c1f 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -523,7 +523,7 @@ bool SwCursorShell::UpDown( bool bUp, sal_uInt16 nCnt ) if( !bTableMode ) eUpdateMode = static_cast<CursorFlag>(eUpdateMode | SwCursorShell::UPDOWN | SwCursorShell::CHKRANGE); - UpdateCursor( static_cast<sal_uInt16>(eUpdateMode) ); + UpdateCursor( o3tl::narrowing<sal_uInt16>(eUpdateMode) ); } } return bRet; @@ -2435,7 +2435,7 @@ void SwCursorShell::ShellGetFocus() m_bHasFocus = true; if( !m_bBasicHideCursor && VisArea().Width() ) { - UpdateCursor( static_cast<sal_uInt16>( SwCursorShell::CHKRANGE ) ); + UpdateCursor( o3tl::narrowing<sal_uInt16>( SwCursorShell::CHKRANGE ) ); ShowCursors( m_bSVCursorVis ); } } diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 847a019cf1b9..5ae9e5c78e76 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -1891,7 +1891,7 @@ bool SwCursor::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode, { pTableBox = & pTableBox->FindEndOfRowSpan( pOldTabSttNode->GetTable(), - static_cast<sal_uInt16>(pTableBox->getRowSpan() + m_nRowSpanOffset)); + o3tl::narrowing<sal_uInt16>(pTableBox->getRowSpan() + m_nRowSpanOffset)); SwNodeIndex& rPtIdx = GetPoint()->nNode; SwNodeIndex aNewIdx( *pTableBox->GetSttNd() ); rPtIdx = aNewIdx; @@ -2212,7 +2212,7 @@ bool SwCursor::GoPrevNextCell( bool bNext, sal_uInt16 nCnt ) if ( pTableBox && pTableBox->getRowSpan() > 1 ) { pTableBox = & pTableBox->FindEndOfRowSpan( pTableNd->GetTable(), - static_cast<sal_uInt16>(pTableBox->getRowSpan() + m_nRowSpanOffset)); + o3tl::narrowing<sal_uInt16>(pTableBox->getRowSpan() + m_nRowSpanOffset)); SwNodeIndex aNewIdx( *pTableBox->GetSttNd() ); rPtIdx = aNewIdx; pTableBoxStartNode = rPtIdx.GetNode().FindTableBoxStartNode(); diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx index 5f26c9f23788..8bffbe3505fb 100644 --- a/sw/source/core/crsr/trvltbl.cxx +++ b/sw/source/core/crsr/trvltbl.cxx @@ -61,7 +61,7 @@ bool SwCursorShell::GoNextCell( bool bAppendLine ) pTableNd = IsCursorInTable(); assert (pTableNd); pTableBox = & pTableBox->FindEndOfRowSpan( pTableNd->GetTable(), - static_cast<sal_uInt16>(pTableBox->getRowSpan() + pCursor->GetCursorRowSpanOffset() ) ); + o3tl::narrowing<sal_uInt16>(pTableBox->getRowSpan() + pCursor->GetCursorRowSpanOffset() ) ); pTableBoxStartNode = pTableBox->GetSttNd(); } } diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 88fd7872a41b..254d0fc00085 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -1348,7 +1348,7 @@ namespace //local functions originally from docfmt.cxx if (nLevel >= MAXLEVEL) nLevel = MAXLEVEL - 1; - SwNumFormat aNumFormat = pNumRule->Get(static_cast<sal_uInt16>(nLevel)); + SwNumFormat aNumFormat = pNumRule->Get(o3tl::narrowing<sal_uInt16>(nLevel)); SwCharFormat * pCharFormat = rDoc.FindCharFormatByName(aNumFormat.GetCharFormatName()); diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index b187e709e9b0..aa52a22be144 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -929,7 +929,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl( // Hash table for all string replacements is filled on-the-fly. // Try to fabricate an uneven number. const SwFieldTypes::size_type nHashSize {(( mpFieldTypes->size() / 7 ) + 1 ) * 7}; - const sal_uInt16 nStrFormatCnt = static_cast<sal_uInt16>(nHashSize); + const sal_uInt16 nStrFormatCnt = o3tl::narrowing<sal_uInt16>(nHashSize); OSL_ENSURE( nStrFormatCnt == nHashSize, "Downcasting to sal_uInt16 lost information!" ); SwHashTable<HashStr> aHashStrTable(nStrFormatCnt); diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index d4a92a09a69c..1266e3ea719f 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -135,7 +135,7 @@ SwFrameFormat *DocumentLayoutManager::MakeLayoutFormat( RndStdIds eRequest, cons m_rDoc.GetNodes().MakeTextSection ( aTmpIdx, bHeader ? SwHeaderStartNode : SwFooterStartNode, - m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(static_cast<sal_uInt16>( bHeader + m_rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(o3tl::narrowing<sal_uInt16>( bHeader ? ( eRequest == RndStdIds::HEADERL ? RES_POOLCOLL_HEADERL : eRequest == RndStdIds::HEADERR diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx index 5df33094c073..ff0657aaff48 100644 --- a/sw/source/core/doc/DocumentStylePoolManager.cxx +++ b/sw/source/core/doc/DocumentStylePoolManager.cxx @@ -1753,8 +1753,8 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool } SvxULSpaceItem aUL( RES_UL_SPACE ); { - aUL.SetUpper( static_cast<sal_uInt16>(aLR.GetLeft()) ); - aUL.SetLower( static_cast<sal_uInt16>(aLR.GetLeft()) ); + aUL.SetUpper( o3tl::narrowing<sal_uInt16>(aLR.GetLeft()) ); + aUL.SetLower( o3tl::narrowing<sal_uInt16>(aLR.GetLeft()) ); } SwAttrSet aSet( m_rDoc.GetAttrPool(), aPgFrameFormatSetRange ); @@ -1824,8 +1824,8 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool { lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet ); aLR.SetRight(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); - aUL.SetUpper( static_cast<sal_uInt16>(aLR.GetRight()) ); - aUL.SetLower( static_cast<sal_uInt16>(aLR.GetRight()) ); + aUL.SetUpper( o3tl::narrowing<sal_uInt16>(aLR.GetRight()) ); + aUL.SetLower( o3tl::narrowing<sal_uInt16>(aLR.GetRight()) ); aSet.Put( aLR ); aSet.Put( aUL ); diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 9b3b3bb70991..8fb7040348e2 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -503,7 +503,7 @@ sal_uInt16 PostItField_::GetPageNo( sal_uInt16 nPgNo = pFrame->GetPhyPageNum(); if( rRangeEnum.hasValue( nPgNo, &rPossiblePages )) { - rLineNo = static_cast<sal_uInt16>(pFrame->GetLineCount( nPos ) + + rLineNo = o3tl::narrowing<sal_uInt16>(pFrame->GetLineCount( nPos ) + pFrame->GetAllLines() - pFrame->GetThisLines()); rVirtPgNo = pFrame->GetVirtPageNum(); return nPgNo; @@ -1271,7 +1271,7 @@ void SwDoc::Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImp { SwTextFormatColl* pMyColl = pNd->GetTextColl(); - const sal_uInt16 nHeadLine = static_cast<sal_uInt16>( + const sal_uInt16 nHeadLine = o3tl::narrowing<sal_uInt16>( !pMyColl->IsAssignedToListLevelOfOutlineStyle() ? RES_POOLCOLL_HEADLINE2 : RES_POOLCOLL_HEADLINE1 ); diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index b417ab0add9a..6b63e7a300c3 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -107,8 +107,8 @@ static void lcl_DefaultPageFormat( sal_uInt16 nPoolFormatId, SvxLRSpaceItem aLR( RES_LR_SPACE ); SvxULSpaceItem aUL( RES_UL_SPACE ); - aUL.SetUpper( static_cast<sal_uInt16>(nMinTop) ); - aUL.SetLower( static_cast<sal_uInt16>(nMinBottom) ); + aUL.SetUpper( o3tl::narrowing<sal_uInt16>(nMinTop) ); + aUL.SetLower( o3tl::narrowing<sal_uInt16>(nMinBottom) ); aLR.SetRight( nMinRight ); aLR.SetLeft( nMinLeft ); diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx index c450f4213dc3..edc3a145c11c 100644 --- a/sw/source/core/doc/docdraw.cxx +++ b/sw/source/core/doc/docdraw.cxx @@ -199,7 +199,7 @@ SwDrawContact* SwDoc::GroupSelection( SdrView& rDrawView ) std::unique_ptr<SwUndoDrawGroup> pUndo; if (GetIDocumentUndoRedo().DoesUndo()) - pUndo.reset(new SwUndoDrawGroup( static_cast<sal_uInt16>(rMrkList.GetMarkCount()), *this)); + pUndo.reset(new SwUndoDrawGroup( o3tl::narrowing<sal_uInt16>(rMrkList.GetMarkCount()), *this)); // #i53320# bool bGroupMembersNotPositioned( false ); @@ -335,7 +335,7 @@ void SwDoc::UnGroupSelection( SdrView& rDrawView ) pFormatsAndObjs[i].emplace_back( pFormat, pSubObj ); if( bUndo ) - pUndo->AddObj( static_cast<sal_uInt16>(i2), pFormat ); + pUndo->AddObj( o3tl::narrowing<sal_uInt16>(i2), pFormat ); } } } @@ -419,7 +419,7 @@ bool SwDoc::DeleteSelection( SwDrawView& rDrawView ) { std::unique_ptr<SwUndoDrawDelete> pUndo; if (GetIDocumentUndoRedo().DoesUndo()) - pUndo.reset(new SwUndoDrawDelete( static_cast<sal_uInt16>(rMrkList.GetMarkCount()), *this )); + pUndo.reset(new SwUndoDrawDelete( o3tl::narrowing<sal_uInt16>(rMrkList.GetMarkCount()), *this )); // Destroy ContactObjects, save formats. for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i ) diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 8b1b4b2a9bc0..bd0fb7dff196 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -1675,7 +1675,7 @@ void SwDoc::MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus, const int nListLevel = pTNd->GetActualListLevel(); if ( nListLevel >= 0 ) { - const SwNumFormat& rFormat = pRule->Get(static_cast<sal_uInt16>(nListLevel)); + const SwNumFormat& rFormat = pRule->Get(o3tl::narrowing<sal_uInt16>(nListLevel)); if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { aLS.SetTextLeft( rFormat.GetIndentAt() ); diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx index 286f0b4ad47f..7f2b30ddc615 100644 --- a/sw/source/core/doc/docftn.cxx +++ b/sw/source/core/doc/docftn.cxx @@ -106,7 +106,7 @@ SwPageDesc* SwEndNoteInfo::GetPageDesc(SwDoc& rDoc) const { if(!m_pPageDesc) { - m_pPageDesc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( static_cast<sal_uInt16>( + m_pPageDesc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( o3tl::narrowing<sal_uInt16>( m_bEndNote ? RES_POOLPAGE_ENDNOTE : RES_POOLPAGE_FOOTNOTE ) ); m_aDepends.StartListening(m_pPageDesc); } @@ -139,7 +139,7 @@ void SwEndNoteInfo::SetFootnoteTextColl(SwTextFormatColl& rFormat) SwCharFormat* SwEndNoteInfo::GetCharFormat(SwDoc& rDoc) const { - auto pCharFormatFromDoc = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast<sal_uInt16>( + auto pCharFormatFromDoc = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( o3tl::narrowing<sal_uInt16>( m_bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE ) ); if (m_pCharFormat != pCharFormatFromDoc) { @@ -172,7 +172,7 @@ namespace void SwEndNoteInfo::SetCharFormat(SwCharFormat* pFormat) { lcl_ResetPoolIdForDocAndSync( - static_cast<sal_uInt16>(m_bEndNote + o3tl::narrowing<sal_uInt16>(m_bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE), pFormat, @@ -181,7 +181,7 @@ void SwEndNoteInfo::SetCharFormat(SwCharFormat* pFormat) SwCharFormat* SwEndNoteInfo::GetAnchorCharFormat(SwDoc& rDoc) const { - auto pAnchorFormatFromDoc = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast<sal_uInt16>( + auto pAnchorFormatFromDoc = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( o3tl::narrowing<sal_uInt16>( m_bEndNote ? RES_POOLCHR_ENDNOTE_ANCHOR : RES_POOLCHR_FOOTNOTE_ANCHOR ) ); if(m_pAnchorFormat != pAnchorFormatFromDoc) { @@ -195,7 +195,7 @@ SwCharFormat* SwEndNoteInfo::GetAnchorCharFormat(SwDoc& rDoc) const void SwEndNoteInfo::SetAnchorCharFormat(SwCharFormat* pFormat) { lcl_ResetPoolIdForDocAndSync( - static_cast<sal_uInt16>(m_bEndNote + o3tl::narrowing<sal_uInt16>(m_bEndNote ? RES_POOLCHR_ENDNOTE_ANCHOR : RES_POOLCHR_FOOTNOTE_ANCHOR), pFormat, diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 2da94ef4699c..43b4408ec080 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -311,7 +311,7 @@ SwFlyFrameFormat* SwDoc::MakeFlySection( RndStdIds eAnchorType, if( !pFrameFormat ) pFrameFormat = getIDocumentStylePoolAccess().GetFrameFormatFromPool( RES_POOLFRM_FRAME ); - sal_uInt16 nCollId = static_cast<sal_uInt16>( + sal_uInt16 nCollId = o3tl::narrowing<sal_uInt16>( GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE) ? RES_POOLCOLL_TEXT : RES_POOLCOLL_FRAME ); /* If there is no adjust item in the paragraph style for the content node of the new fly section diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 5e287e84f19d..2420532c5bee 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -246,7 +246,7 @@ bool SwDoc::OutlineUpDown(const SwPaM& rPam, short nOffset, n++; SwTextFormatColl *aTmpColl = - getIDocumentStylePoolAccess().GetTextCollFromPool(static_cast<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + n)); + getIDocumentStylePoolAccess().GetTextCollFromPool(o3tl::narrowing<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + n)); if( aTmpColl->IsAssignedToListLevelOfOutlineStyle() && aTmpColl->GetAssignedOutlineStyleLevel() == n ) @@ -275,7 +275,7 @@ bool SwDoc::OutlineUpDown(const SwPaM& rPam, short nOffset, n--; SwTextFormatColl *aTmpColl = - getIDocumentStylePoolAccess().GetTextCollFromPool(static_cast<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + n)); + getIDocumentStylePoolAccess().GetTextCollFromPool(o3tl::narrowing<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + n)); if( aTmpColl->IsAssignedToListLevelOfOutlineStyle() && aTmpColl->GetAssignedOutlineStyleLevel() == n ) @@ -2556,7 +2556,7 @@ OUString SwDoc::GetUniqueNumRuleName( const OUString* pChkStr, bool bAutoNum ) c if( sNm.startsWith( aName ) ) { // Determine Number and set the Flag - nNum = static_cast<sal_uInt16>(sNm.copy( nNmLen ).toInt32()); + nNum = o3tl::narrowing<sal_uInt16>(sNm.copy( nNmLen ).toInt32()); if( nNum-- && nNum < mpNumRuleTable->size() ) pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 )); } diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 25a664d17bf8..3c2f8c1f019c 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -555,7 +555,7 @@ bool SwDoc::SortTable(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) std::multiset<SwSortBoxElement> aSortList; // When sorting, do not include the first row if the HeaderLine is repeated - for( sal_uInt16 i = static_cast<sal_uInt16>(nStart); i < nCount; ++i) + for( sal_uInt16 i = o3tl::narrowing<sal_uInt16>(nStart); i < nCount; ++i) { aSortList.insert(SwSortBoxElement(i)); } diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index d8e7d30e80e1..2c3ed6902f13 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -1520,7 +1520,7 @@ void SwTOXBaseSection::UpdateContent( SwTOXElement eMyType, std::unique_ptr<SwTOXPara> pNew( MakeSwTOXSortTabBase<SwTOXPara>( pLayout, *pCNd, eMyType, ( USHRT_MAX != nSetLevel ) - ? static_cast<sal_uInt16>(nSetLevel) + ? o3tl::narrowing<sal_uInt16>(nSetLevel) : FORM_ALPHA_DELIMITER ) ); InsertSorted( std::move(pNew) ); } @@ -1570,7 +1570,7 @@ void SwTOXBaseSection::UpdateTable(const SwTextNode* pOwnChapterNode, if( pOutlNd->GetTextColl()->IsAssignedToListLevelOfOutlineStyle()) { const int nTmp = pOutlNd->GetTextColl()->GetAttrOutlineLevel(); - pNew->SetLevel(static_cast<sal_uInt16>(nTmp)); + pNew->SetLevel(o3tl::narrowing<sal_uInt16>(nTmp)); } } } diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx index 6a91ac469294..a0dcda5cff88 100644 --- a/sw/source/core/doc/fmtcol.cxx +++ b/sw/source/core/doc/fmtcol.cxx @@ -588,7 +588,7 @@ void SwTextFormatColl::SetAttrOutlineLevel( int nLevel) { OSL_ENSURE( 0 <= nLevel && nLevel <= MAXLEVEL ,"SwTextFormatColl: Level Out Of Range" ); SetFormatAttr( SfxUInt16Item( RES_PARATR_OUTLINELEVEL, - static_cast<sal_uInt16>(nLevel) ) ); + o3tl::narrowing<sal_uInt16>(nLevel) ) ); } int SwTextFormatColl::GetAttrOutlineLevel() const diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx index 67dc9b9c56b5..41a10d34c10b 100644 --- a/sw/source/core/doc/htmltbl.cxx +++ b/sw/source/core/doc/htmltbl.cxx @@ -314,7 +314,7 @@ sal_uInt16 SwHTMLTableLayout::GetBrowseWidthByVisArea( const SwDoc& rDoc ) SwViewShell const *pVSh = rDoc.getIDocumentLayoutAccess().GetCurrentViewShell(); if( pVSh ) { - return static_cast<sal_uInt16>(pVSh->GetBrowseWidth()); + return o3tl::narrowing<sal_uInt16>(pVSh->GetBrowseWidth()); } return 0; @@ -328,7 +328,7 @@ sal_uInt16 SwHTMLTableLayout::GetBrowseWidth( const SwDoc& rDoc ) { const SwFrame *pPageFrame = pRootFrame->GetLower(); if( pPageFrame ) - return static_cast<sal_uInt16>(pPageFrame->getFramePrintArea().Width()); + return o3tl::narrowing<sal_uInt16>(pPageFrame->getFramePrintArea().Width()); } // #i91658# @@ -367,7 +367,7 @@ sal_uInt16 SwHTMLTableLayout::GetBrowseWidthByTabFrame( rTabFrame.CalcFlyOffsets( nUpperDummy, nLeftOffset, nRightOffset ); nWidth -= (nLeftOffset + nRightOffset); - return static_cast<sal_uInt16>(std::min(nWidth, SwTwips(SAL_MAX_UINT16))); + return o3tl::narrowing<sal_uInt16>(std::min(nWidth, SwTwips(SAL_MAX_UINT16))); } sal_uInt16 SwHTMLTableLayout::GetBrowseWidthByTable( const SwDoc& rDoc ) const @@ -985,7 +985,7 @@ void SwHTMLTableLayout::AutoLayoutPass1() { // the next column gets the rest sal_uInt16 nColWidth = - static_cast<sal_uInt16>((pColumn->GetMax() * nRelLeft) / nFixMax); + o3tl::narrowing<sal_uInt16>((pColumn->GetMax() * nRelLeft) / nFixMax); pColumn->SetWidthOption( nColWidth ); } } @@ -1112,8 +1112,8 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv { sal_uLong nAbsLeftFillL = nAbsLeftFill, nAbsRightFillL = nAbsRightFill; - m_nRelLeftFill = static_cast<sal_uInt16>((nAbsLeftFillL * nRelAvail) / nAbsAvail); - m_nRelRightFill = static_cast<sal_uInt16>((nAbsRightFillL * nRelAvail) / nAbsAvail); + m_nRelLeftFill = o3tl::narrowing<sal_uInt16>((nAbsLeftFillL * nRelAvail) / nAbsAvail); + m_nRelRightFill = o3tl::narrowing<sal_uInt16>((nAbsRightFillL * nRelAvail) / nAbsAvail); nAbsAvail -= (nAbsLeftFill + nAbsRightFill); if( nRelAvail ) @@ -1145,7 +1145,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv // Let's play such games now anyway. We had a graphic in a 1% wide // table and it didn't fit in of course. - nAbsTabWidth = static_cast<sal_uInt16>( (static_cast<sal_uLong>(nAbsAvail) * m_nWidthOption) / 100 ); + nAbsTabWidth = o3tl::narrowing<sal_uInt16>( (static_cast<sal_uLong>(nAbsAvail) * m_nWidthOption) / 100 ); if( IsTopTable() && ( /*MayBeInFlyFrame() ||*/ static_cast<sal_uLong>(nAbsTabWidth) > m_nMin ) ) { @@ -1214,17 +1214,17 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv if( nColMin <= USHRT_MAX ) { pColumn->SetAbsColWidth( - static_cast<sal_uInt16>((nColMin * nAbsTabWidth) / m_nMin) ); + o3tl::narrowing<sal_uInt16>((nColMin * nAbsTabWidth) / m_nMin) ); pColumn->SetRelColWidth( - static_cast<sal_uInt16>((nColMin * m_nRelTabWidth) / m_nMin) ); + o3tl::narrowing<sal_uInt16>((nColMin * m_nRelTabWidth) / m_nMin) ); } else { double nColMinD = nColMin; pColumn->SetAbsColWidth( - static_cast<sal_uInt16>((nColMinD * nAbsTabWidth) / m_nMin) ); + o3tl::narrowing<sal_uInt16>((nColMinD * nAbsTabWidth) / m_nMin) ); pColumn->SetRelColWidth( - static_cast<sal_uInt16>((nColMinD * m_nRelTabWidth) / m_nMin) ); + o3tl::narrowing<sal_uInt16>((nColMinD * m_nRelTabWidth) / m_nMin) ); } nAbs = nAbs + pColumn->GetAbsColWidth(); @@ -1251,17 +1251,17 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv if( nColMin <= USHRT_MAX ) { pColumn->SetAbsColWidth( - static_cast<sal_uInt16>((((nColMin-nRealColMin) * nDistAbs) / nDistMin) + nRealColMin) ); + o3tl::narrowing<sal_uInt16>((((nColMin-nRealColMin) * nDistAbs) / nDistMin) + nRealColMin) ); pColumn->SetRelColWidth( - static_cast<sal_uInt16>((((nColMin-nRealColMin) * nDistRel) / nDistMin) + nRealColMin) ); + o3tl::narrowing<sal_uInt16>((((nColMin-nRealColMin) * nDistRel) / nDistMin) + nRealColMin) ); } else { double nColMinD = nColMin; pColumn->SetAbsColWidth( - static_cast<sal_uInt16>((((nColMinD-nRealColMin) * nDistAbs) / nDistMin) + nRealColMin) ); + o3tl::narrowing<sal_uInt16>((((nColMinD-nRealColMin) * nDistAbs) / nDistMin) + nRealColMin) ); pColumn->SetRelColWidth( - static_cast<sal_uInt16>((((nColMinD-nRealColMin) * nDistRel) / nDistMin) + nRealColMin) ); + o3tl::narrowing<sal_uInt16>((((nColMinD-nRealColMin) * nDistRel) / nDistMin) + nRealColMin) ); } nAbs = nAbs + pColumn->GetAbsColWidth(); @@ -1284,7 +1284,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv // No fixed width, use the maximum. if( !nAbsTabWidth ) - nAbsTabWidth = static_cast<sal_uInt16>(m_nMax); + nAbsTabWidth = o3tl::narrowing<sal_uInt16>(m_nMax); // A top table may also get wider then the available space. if( nAbsTabWidth > nAbsAvail ) @@ -1301,7 +1301,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv { if (nAbsAvail == 0) throw o3tl::divide_by_zero(); - m_nRelTabWidth = static_cast<sal_uInt16>((nAbsTabWidthL * nRelAvail) / nAbsAvail); + m_nRelTabWidth = o3tl::narrowing<sal_uInt16>((nAbsTabWidthL * nRelAvail) / nAbsAvail); } else m_nRelTabWidth = nAbsTabWidth; @@ -1339,7 +1339,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv // The column keeps its width. nFixedCols++; sal_uLong nColMax = pColumn->GetMax(); - pColumn->SetAbsColWidth( static_cast<sal_uInt16>(nColMax) ); + pColumn->SetAbsColWidth( o3tl::narrowing<sal_uInt16>(nColMax) ); sal_uLong nRelColWidth = (nColMax * m_nRelTabWidth) / nAbsTabWidth; @@ -1349,10 +1349,10 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv nRelColWidth++; else if( nChkWidth > nColMax ) nRelColWidth--; - pColumn->SetRelColWidth( static_cast<sal_uInt16>(nRelColWidth) ); + pColumn->SetRelColWidth( o3tl::narrowing<sal_uInt16>(nRelColWidth) ); - nAbs = nAbs + static_cast<sal_uInt16>(nColMax); - nRel = nRel + static_cast<sal_uInt16>(nRelColWidth); + nAbs = nAbs + o3tl::narrowing<sal_uInt16>(nColMax); + nRel = nRel + o3tl::narrowing<sal_uInt16>(nRelColWidth); } } @@ -1381,9 +1381,9 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv { sal_uLong nColMax = pColumn->GetMax(); pColumn->SetAbsColWidth( - static_cast<sal_uInt16>((nColMax * nDistAbsTabWidth) / nDistMax) ); + o3tl::narrowing<sal_uInt16>((nColMax * nDistAbsTabWidth) / nDistMax) ); pColumn->SetRelColWidth( - static_cast<sal_uInt16>((nColMax * nDistRelTabWidth) / nDistMax) ); + o3tl::narrowing<sal_uInt16>((nColMax * nDistRelTabWidth) / nDistMax) ); } nAbs = nAbs + pColumn->GetAbsColWidth(); nRel = nRel + pColumn->GetRelColWidth(); @@ -1400,9 +1400,9 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv { sal_uLong nColMax = GetColumn( i )->GetMax(); GetColumn( i )->SetAbsColWidth( - static_cast<sal_uInt16>((nColMax * nAbsTabWidth) / m_nMax) ); + o3tl::narrowing<sal_uInt16>((nColMax * nAbsTabWidth) / m_nMax) ); GetColumn( i )->SetRelColWidth( - static_cast<sal_uInt16>((nColMax * m_nRelTabWidth) / m_nMax) ); + o3tl::narrowing<sal_uInt16>((nColMax * m_nRelTabWidth) / m_nMax) ); } } } @@ -1413,7 +1413,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv if( !nAbsTabWidth ) nAbsTabWidth = nAbsAvail; if( nAbsTabWidth < m_nMin ) - nAbsTabWidth = static_cast<sal_uInt16>(m_nMin); + nAbsTabWidth = o3tl::narrowing<sal_uInt16>(m_nMin); if( nAbsTabWidth > nAbsAvail ) { @@ -1427,7 +1427,7 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv { if (nAbsAvail == 0) throw o3tl::divide_by_zero(); - m_nRelTabWidth = static_cast<sal_uInt16>((nAbsTabWidthL * nRelAvail) / nAbsAvail); + m_nRelTabWidth = o3tl::narrowing<sal_uInt16>((nAbsTabWidthL * nRelAvail) / nAbsAvail); } else m_nRelTabWidth = nAbsTabWidth; @@ -1442,10 +1442,10 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv ? (nAbsColWidth * m_nRelTabWidth) / nAbsTabWidth : nAbsColWidth; - GetColumn( i )->SetAbsColWidth( static_cast<sal_uInt16>(nAbsColWidth) ); - GetColumn( i )->SetRelColWidth( static_cast<sal_uInt16>(nRelColWidth) ); - nAbs = nAbs + static_cast<sal_uInt16>(nAbsColWidth); - nRel = nRel + static_cast<sal_uInt16>(nRelColWidth); + GetColumn( i )->SetAbsColWidth( o3tl::narrowing<sal_uInt16>(nAbsColWidth) ); + GetColumn( i )->SetRelColWidth( o3tl::narrowing<sal_uInt16>(nRelColWidth) ); + nAbs = nAbs + o3tl::narrowing<sal_uInt16>(nAbsColWidth); + nRel = nRel + o3tl::narrowing<sal_uInt16>(nRelColWidth); } GetColumn( m_nCols-1 )->SetAbsColWidth( nAbsTabWidth - nAbs ); GetColumn( m_nCols-1 )->SetRelColWidth( m_nRelTabWidth - nRel ); @@ -1462,8 +1462,8 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv // Calculate the width of additional cells we use for // aligning inner tables. - sal_uInt16 nAbsDist = static_cast<sal_uInt16>(nAbsAvail-nAbsTabWidth); - sal_uInt16 nRelDist = static_cast<sal_uInt16>(nRelAvail-m_nRelTabWidth); + sal_uInt16 nAbsDist = o3tl::narrowing<sal_uInt16>(nAbsAvail-nAbsTabWidth); + sal_uInt16 nRelDist = o3tl::narrowing<sal_uInt16>(nRelAvail-m_nRelTabWidth); sal_uInt16 nParentInhAbsLeftSpace = 0, nParentInhAbsRightSpace = 0; // Calculate the size and position of the additional cells. diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 76fe94181f0f..e4f2e071afba 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -131,7 +131,7 @@ static void lcl_PaintReplacement( const SwRect &rRect, const OUString &rText, else if ( !rURL.GetURL().isEmpty() ) bVisited = rSh.GetDoc()->IsVisitedURL( rURL.GetURL() ); - SwFormat *pFormat = rSh.GetDoc()->getIDocumentStylePoolAccess().GetFormatFromPool( static_cast<sal_uInt16> + SwFormat *pFormat = rSh.GetDoc()->getIDocumentStylePoolAccess().GetFormatFromPool( o3tl::narrowing<sal_uInt16> (bVisited ? RES_POOLCHR_INET_VISIT : RES_POOLCHR_INET_NORMAL ) ); aCol = pFormat->GetColor().GetValue(); eUnderline = pFormat->GetUnderline().GetLineStyle(); diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index ecd1b119b95e..eb84b1b63a68 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -659,7 +659,7 @@ OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVecto if (nLevel < MAXLEVEL) { - const SwNumFormat& rMyNFormat = Get( static_cast<sal_uInt16>(nLevel) ); + const SwNumFormat& rMyNFormat = Get( o3tl::narrowing<sal_uInt16>(nLevel) ); { css::lang::Locale aLocale( LanguageTag::convertToLocale(nLang)); @@ -789,7 +789,7 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum, if (nListLevel >= MAXLEVEL) nListLevel = MAXLEVEL - 1; - SwNumFormat aFormat( Get( static_cast<sal_uInt16>(nListLevel) ) ); + SwNumFormat aFormat( Get( o3tl::narrowing<sal_uInt16>(nListLevel) ) ); bMakeNumStringForPhantom = aFormat.IsEnumeration() && SVX_NUM_NUMBER_NONE != aFormat.GetNumberingType(); @@ -834,7 +834,7 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum, if ( bInclSuperiorNumLabels && pWorkingNodeNum->GetLevelInListTree() > 0 ) { - sal_uInt8 n = Get( static_cast<sal_uInt16>(pWorkingNodeNum->GetLevelInListTree()) ).GetIncludeUpperLevels(); + sal_uInt8 n = Get( o3tl::narrowing<sal_uInt16>(pWorkingNodeNum->GetLevelInListTree()) ).GetIncludeUpperLevels(); pWorkingNodeNum = dynamic_cast<SwNodeNum*>(pWorkingNodeNum->GetParent()); // skip parents, whose list label is already contained in the actual list label. while ( pWorkingNodeNum && n > 1 ) diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 6bc270801873..337c7bcef619 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -225,7 +225,7 @@ namespace } if( bNoSelection && mnStartCol < USHRT_MAX ) { - sal_uInt16 nIdx = std::min(mnStartCol, static_cast<sal_uInt16>(maLines[0].size())); + sal_uInt16 nIdx = std::min(mnStartCol, o3tl::narrowing<sal_uInt16>(maLines[0].size())); mnStartCol = std::accumulate(maLines[0].begin(), maLines[0].begin() + nIdx, sal_uInt16(0), [](sal_uInt16 sum, const BoxSpanInfo& rInfo) { return sum + rInfo.mnColSpan; }); } @@ -298,7 +298,7 @@ namespace aInfo.mbSelected = true; if( mnStartCol == USHRT_MAX ) { - mnStartCol = static_cast<sal_uInt16>(maLines[nLine].size()); + mnStartCol = o3tl::narrowing<sal_uInt16>(maLines[nLine].size()); if( pSelBoxes->size() < 2 ) { pSelBoxes = nullptr; @@ -352,7 +352,7 @@ namespace const sal_uInt16 nLineCount = rLines.size(); if( nLineCount < mnAddLine ) mnAddLine = nLineCount; - sal_uInt16 nLine = static_cast<sal_uInt16>(maLines.size()); + sal_uInt16 nLine = o3tl::narrowing<sal_uInt16>(maLines.size()); maLines.resize( nLine + mnAddLine ); while( mnAddLine ) { @@ -591,7 +591,7 @@ static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox, : RES_POOLCOLL_TABLE_HDLN == nPoolId ) ) { SwTextFormatColl* pColl = pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( - static_cast<sal_uInt16>( + o3tl::narrowing<sal_uInt16>( RES_POOLCOLL_TABLE == nPoolId ? RES_POOLCOLL_TABLE_HDLN : RES_POOLCOLL_TABLE ) ); diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 818782a5ff1b..18eab679a289 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -672,7 +672,7 @@ void DeleteBox_( SwTable& rTable, SwTableBox* pBox, SwUndo* pUndo, // JP 02.04.97: 1st part for Bug 36271 // First the left/right edges - if( nDelPos + 1 < static_cast<sal_uInt16>(rTableBoxes.size()) ) + if( nDelPos + 1 < o3tl::narrowing<sal_uInt16>(rTableBoxes.size()) ) { SwTableBox* pNxtBox = rTableBoxes[ nDelPos + 1 ]; const SvxBoxItem& rNxtBoxItem = pNxtBox->GetFrameFormat()->GetBox(); @@ -698,7 +698,7 @@ void DeleteBox_( SwTable& rTable, SwTableBox* pBox, SwUndo* pUndo, SwTableBox* pPrvBox = rTableBoxes[ nDelPos - 1 ]; const SvxBoxItem& rPrvBoxItem = pPrvBox->GetFrameFormat()->GetBox(); - SwTableBox* pNxtBox = nDelPos + 1 < static_cast<sal_uInt16>(rTableBoxes.size()) + SwTableBox* pNxtBox = nDelPos + 1 < o3tl::narrowing<sal_uInt16>(rTableBoxes.size()) ? rTableBoxes[ nDelPos + 1 ] : nullptr; if( pPrvBox->GetSttNd() && !rPrvBoxItem.GetRight() && @@ -854,7 +854,7 @@ lcl_FndNxtPrvDelBox( const SwTableLines& rTableLns, --*pCurPos; pAllDelBoxes->erase( pAllDelBoxes->begin() + nFndPos ); } - } while( bNxt ? ( nLinePos + 1 < static_cast<sal_uInt16>(rTableLns.size()) ) : nLinePos != 0 ); + } while( bNxt ? ( nLinePos + 1 < o3tl::narrowing<sal_uInt16>(rTableLns.size()) ) : nLinePos != 0 ); return pFndBox; } @@ -897,7 +897,7 @@ lcl_SaveUpperLowerBorder( SwTable& rTable, const SwTableBox& rBox, pPrvBox = ::lcl_FndNxtPrvDelBox( *pTableLns, nBoxStt, nBoxWidth, nLnPos, false, pAllDelBoxes, pCurPos ); - if( nLnPos + 1 < static_cast<sal_uInt16>(pTableLns->size()) ) // Successor? + if( nLnPos + 1 < o3tl::narrowing<sal_uInt16>(pTableLns->size()) ) // Successor? pNxtBox = ::lcl_FndNxtPrvDelBox( *pTableLns, nBoxStt, nBoxWidth, nLnPos, true, pAllDelBoxes, pCurPos ); @@ -1371,7 +1371,7 @@ static void lcl_Merge_MoveBox(FndBox_ & rFndBox, InsULPara *const pULPara) { // if there are Boxes behind it, move them nPos = pFndTableBox->GetUpper()->GetBoxPos( pFndTableBox ); - if( nPos +1 < static_cast<sal_uInt16>(pBoxes->size()) ) + if( nPos +1 < o3tl::narrowing<sal_uInt16>(pBoxes->size()) ) { nInsPos = pULPara->pInsLine->GetTabBoxes().size(); lcl_CpyBoxes( nPos+1, pBoxes->size(), @@ -1444,7 +1444,7 @@ static void lcl_Merge_MoveLine(FndLine_& rFndLine, InsULPara *const pULPara) } else // If there are Lines after it, move them - if( (nPos = pLines->GetPos( pFndLn )) + 1 < static_cast<sal_uInt16>(pLines->size()) ) + if( (nPos = pLines->GetPos( pFndLn )) + 1 < o3tl::narrowing<sal_uInt16>(pLines->size()) ) { nInsPos = pULPara->pInsBox->GetTabLines().size(); lcl_CpyLines( nPos+1, pLines->size(), *pLines, @@ -1479,7 +1479,7 @@ static void lcl_Merge_MoveLine(FndLine_& rFndLine, InsULPara *const pULPara) } else // If there are Lines after it, move them - if( (nPos = pLines->GetPos( pFndLn )) + 1 < static_cast<sal_uInt16>(pLines->size()) ) + if( (nPos = pLines->GetPos( pFndLn )) + 1 < o3tl::narrowing<sal_uInt16>(pLines->size()) ) lcl_CpyLines( nPos+1, pLines->size(), *pLines, pLMBox ); lcl_CalcWidth( pLMBox ); // calculate the Box's width @@ -1678,7 +1678,7 @@ static sal_uInt16 lcl_GetBoxOffset( const FndBox_& rBox ) { if (pBox==pCmp) break; - nRet = nRet + static_cast<sal_uInt16>(pCmp->GetFrameFormat()->GetFrameSize().GetWidth()); + nRet = nRet + o3tl::narrowing<sal_uInt16>(pCmp->GetFrameFormat()->GetFrameSize().GetWidth()); } pBox = pBox->GetUpper()->GetUpper(); } while( pBox ); @@ -1690,7 +1690,7 @@ static sal_uInt16 lcl_GetLineWidth( const FndLine_& rLine ) sal_uInt16 nRet = 0; for( auto n = rLine.GetBoxes().size(); n; ) { - nRet = nRet + static_cast<sal_uInt16>(rLine.GetBoxes()[--n]->GetBox() + nRet = nRet + o3tl::narrowing<sal_uInt16>(rLine.GetBoxes()[--n]->GetBox() ->GetFrameFormat()->GetFrameSize().GetWidth()); } return nRet; @@ -2202,7 +2202,7 @@ SwTableBox* SwTableLine::FindNextBox( const SwTable& rTable, { nFndPos = GetBoxPos( pSrchBox ); if( USHRT_MAX != nFndPos && - nFndPos + 1 != static_cast<sal_uInt16>(GetTabBoxes().size()) ) + nFndPos + 1 != o3tl::narrowing<sal_uInt16>(GetTabBoxes().size()) ) { pBox = GetTabBoxes()[ nFndPos + 1 ]; while( !pBox->GetTabLines().empty() ) @@ -2216,7 +2216,7 @@ SwTableBox* SwTableLine::FindNextBox( const SwTable& rTable, nFndPos = GetUpper()->GetTabLines().GetPos( pLine ); OSL_ENSURE( USHRT_MAX != nFndPos, "Line is not in the Table" ); // Is there another Line? - if( nFndPos+1 >= static_cast<sal_uInt16>(GetUpper()->GetTabLines().size()) ) + if( nFndPos+1 >= o3tl::narrowing<sal_uInt16>(GetUpper()->GetTabLines().size()) ) return GetUpper()->GetUpper()->FindNextBox( rTable, GetUpper(), bOvrTableLns ); pLine = GetUpper()->GetTabLines()[nFndPos+1]; } @@ -2224,7 +2224,7 @@ SwTableBox* SwTableLine::FindNextBox( const SwTable& rTable, { // Search for the next Line in the Table nFndPos = rTable.GetTabLines().GetPos( pLine ); - if( nFndPos + 1 >= static_cast<sal_uInt16>(rTable.GetTabLines().size()) ) + if( nFndPos + 1 >= o3tl::narrowing<sal_uInt16>(rTable.GetTabLines().size()) ) return nullptr; // there are no more Boxes pLine = rTable.GetTabLines()[ nFndPos+1 ]; diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 9ad8d8c33d57..cba67e1bf74d 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -575,7 +575,7 @@ void SwTextBoxHelper::getProperty(SwFrameFormat const* pShape, sal_uInt16 nWID, break; default: SAL_WARN("sw.core", "SwTextBoxHelper::getProperty: unhandled member-id: " - << static_cast<sal_uInt16>(nMemberID)); + << o3tl::narrowing<sal_uInt16>(nMemberID)); break; } } @@ -633,7 +633,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u break; default: SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: " - << static_cast<sal_uInt16>(nMemberID) + << o3tl::narrowing<sal_uInt16>(nMemberID) << " (which-id: " << nWID << ")"); break; } @@ -650,7 +650,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u break; default: SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: " - << static_cast<sal_uInt16>(nMemberID) + << o3tl::narrowing<sal_uInt16>(nMemberID) << " (which-id: " << nWID << ")"); break; } @@ -674,7 +674,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u break; default: SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: " - << static_cast<sal_uInt16>(nMemberID) + << o3tl::narrowing<sal_uInt16>(nMemberID) << " (which-id: " << nWID << ")"); break; } @@ -714,7 +714,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u break; default: SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: " - << static_cast<sal_uInt16>(nMemberID) + << o3tl::narrowing<sal_uInt16>(nMemberID) << " (which-id: " << nWID << ")"); break; } @@ -743,7 +743,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u break; default: SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: " - << static_cast<sal_uInt16>(nMemberID) + << o3tl::narrowing<sal_uInt16>(nMemberID) << " (which-id: " << nWID << ")"); break; } @@ -768,7 +768,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u break; default: SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: " - << static_cast<sal_uInt16>(nMemberID) + << o3tl::narrowing<sal_uInt16>(nMemberID) << " (which-id: " << nWID << ")"); break; } @@ -787,15 +787,15 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u break; default: SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled member-id: " - << static_cast<sal_uInt16>(nMemberID) + << o3tl::narrowing<sal_uInt16>(nMemberID) << " (which-id: " << nWID << ")"); break; } break; default: SAL_WARN("sw.core", "SwTextBoxHelper::syncProperty: unhandled which-id: " - << nWID << " (member-id: " << static_cast<sal_uInt16>(nMemberID) - << ")"); + << nWID << " (member-id: " + << o3tl::narrowing<sal_uInt16>(nMemberID) << ")"); break; } diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 389923d6f415..d11f09ecf69a 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -362,7 +362,7 @@ const SwTable* SwDoc::InsertTable( const SwInsertTableOptions& rInsTableOpts, if( GetIDocumentUndoRedo().DoesUndo() ) { GetIDocumentUndoRedo().AppendUndo( - std::make_unique<SwUndoInsTable>( rPos, nCols, nRows, static_cast<sal_uInt16>(eAdjust), + std::make_unique<SwUndoInsTable>( rPos, nCols, nRows, o3tl::narrowing<sal_uInt16>(eAdjust), rInsTableOpts, pTAFormat, pColArr, aTableName)); } @@ -651,7 +651,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTableOpts, { GetIDocumentUndoRedo().StartUndo( SwUndoId::TEXTTOTABLE, nullptr ); pUndo = new SwUndoTextToTable( aOriginal, rInsTableOpts, cCh, - static_cast<sal_uInt16>(eAdjust), pTAFormat ); + o3tl::narrowing<sal_uInt16>(eAdjust), pTAFormat ); GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) ); // Do not add splitting the TextNode to the Undo history @@ -1041,13 +1041,13 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh, { // sw_redlinehide: no idea if this makes any sense... TextFrameIndex const nPos(aFInfo.GetFrame()->MapModelToView(pTextNd, nChPos)); - aPosArr.push_back( static_cast<sal_uInt16>( + aPosArr.push_back( o3tl::narrowing<sal_uInt16>( aFInfo.GetCharPos(nPos+TextFrameIndex(1), false)) ); } } aPosArr.push_back( - static_cast<sal_uInt16>(aFInfo.GetFrame()->IsVertical() ? + o3tl::narrowing<sal_uInt16>(aFInfo.GetFrame()->IsVertical() ? aFInfo.GetFrame()->getFramePrintArea().Bottom() : aFInfo.GetFrame()->getFramePrintArea().Right()) ); @@ -2921,7 +2921,7 @@ void SwCollectTableLineBoxes::AddBox( const SwTableBox& rBox ) m_aPositionArr.push_back(m_nWidth); SwTableBox* p = const_cast<SwTableBox*>(&rBox); m_Boxes.push_back(p); - m_nWidth = m_nWidth + static_cast<sal_uInt16>(rBox.GetFrameFormat()->GetFrameSize().GetWidth()); + m_nWidth = m_nWidth + o3tl::narrowing<sal_uInt16>(rBox.GetFrameFormat()->GetFrameSize().GetWidth()); } const SwTableBox* SwCollectTableLineBoxes::GetBoxOfPos( const SwTableBox& rBox ) @@ -2944,7 +2944,7 @@ const SwTableBox* SwCollectTableLineBoxes::GetBoxOfPos( const SwTableBox& rBox ) if( n >= m_aPositionArr.size() ) --n; - m_nWidth = m_nWidth + static_cast<sal_uInt16>(rBox.GetFrameFormat()->GetFrameSize().GetWidth()); + m_nWidth = m_nWidth + o3tl::narrowing<sal_uInt16>(rBox.GetFrameFormat()->GetFrameSize().GetWidth()); pRet = m_Boxes[ n ]; } return pRet; diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 9a4f80ee995a..3df6b3272cee 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -1303,7 +1303,7 @@ sal_uInt16 SwDoc::GetBoxAlign( const SwCursor& rCursor ) const SwFormatVertOrient &rOri = aBoxes[i]->GetFrameFormat()->GetVertOrient(); if( USHRT_MAX == nAlign ) - nAlign = static_cast<sal_uInt16>(rOri.GetVertOrient()); + nAlign = o3tl::narrowing<sal_uInt16>(rOri.GetVertOrient()); else if( rOri.GetVertOrient() != nAlign ) { nAlign = USHRT_MAX; @@ -1339,7 +1339,7 @@ static sal_uInt16 lcl_CalcCellFit( const SwLayoutFrame *pCell ) // To compensate for the accuracy of calculation later on in SwTable::SetTabCols // we keep adding up a little. nRet += COLFUZZY; - return static_cast<sal_uInt16>(std::max( SwTwips(MINLAY), nRet )); + return o3tl::narrowing<sal_uInt16>(std::max( SwTwips(MINLAY), nRet )); } /* The Line is within the Selection but not outlined by the TabCols. diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index c65afd1e5749..9d300621da0e 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -947,7 +947,7 @@ void SwSectionFormat::UpdateParent() if(bIsHidden == pSection->IsHiddenFlag()) { - SwMsgPoolItem aMsgItem(static_cast<sal_uInt16>(bIsHidden + SwMsgPoolItem aMsgItem(o3tl::narrowing<sal_uInt16>(bIsHidden ? RES_SECTION_HIDDEN : RES_SECTION_NOT_HIDDEN)); CallSwClientNotify(sw::LegacyModifyHint(&aMsgItem, &aMsgItem)); diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 637f507734a4..b9b4d8480a7a 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -639,7 +639,7 @@ bool SwAutoFormat::DoTable() case '+': case '|': - aPosArr.push_back( static_cast<sal_uInt16>(aInfo.GetCharPos(n)) ); + aPosArr.push_back( o3tl::narrowing<sal_uInt16>(aInfo.GetCharPos(n)) ); break; default: @@ -665,7 +665,7 @@ bool SwAutoFormat::DoTable() { eHori = text::HoriOrientation::NONE; // then - as last - we need to add the current frame width into the array - aPosArr.push_back( static_cast<sal_uInt16>(m_pCurTextFrame->getFrameArea().Width()) ); + aPosArr.push_back( o3tl::narrowing<sal_uInt16>(m_pCurTextFrame->getFrameArea().Width()) ); } else eHori = text::HoriOrientation::LEFT; @@ -908,7 +908,7 @@ CHECK_ROMAN_1: if( nMod5 == ((3 * nVal) + n10 ) || nMod5 == ((4 * nVal) + n10 ) || nLast == n10 ) - nStart = static_cast<sal_uInt16>(nStart + (n10 * 8)); + nStart = o3tl::narrowing<sal_uInt16>(nStart + (n10 * 8)); else if( nMod5 == 0 || nMod5 == (1 * nVal) || nMod5 == (2 * nVal) ) @@ -927,7 +927,7 @@ CHECK_ROMAN_5: int nMod = nStart % nVal; int n10 = nVal / 5; if( n10 == nMod ) - nStart = static_cast<sal_uInt16>(nStart + (3 * n10)); + nStart = o3tl::narrowing<sal_uInt16>(nStart + (3 * n10)); else if( 0 == nMod ) nStart = nStart + nVal; else @@ -1590,7 +1590,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) else { bChgBullet = true; - SetColl( static_cast<sal_uInt16>(RES_POOLCOLL_BULLET_LEVEL1 + ( std::min( nLvl, cnNumBullColls ) * 4 )) ); + SetColl( o3tl::narrowing<sal_uInt16>(RES_POOLCOLL_BULLET_LEVEL1 + ( std::min( nLvl, cnNumBullColls ) * 4 )) ); } } else @@ -1627,7 +1627,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) { SwNumFormat aFormat( aRule.Get( nLvl ) ); aFormat.SetPrefix( aPrefix.getToken( 0, u'\x0001', nPrefixIdx )); - aFormat.SetStart( static_cast<sal_uInt16>(aPrefix.getToken( 0, u'\x0001', nPrefixIdx ).toInt32())); + aFormat.SetStart( o3tl::narrowing<sal_uInt16>(aPrefix.getToken( 0, u'\x0001', nPrefixIdx ).toInt32())); aFormat.SetSuffix( aPostfix.getToken( 0, u'\x0001' )); aFormat.SetIncludeUpperLevels( 0 ); @@ -1652,7 +1652,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) if( !n ) aFormat.SetPrefix( aPrefix.getToken( 0, u'\x0001', nPrefixIdx )); // token 0, read only on first loop - aFormat.SetStart( static_cast<sal_uInt16>(aPrefix.getToken( 0, u'\x0001', nPrefixIdx ).toInt32() )); + aFormat.SetStart( o3tl::narrowing<sal_uInt16>(aPrefix.getToken( 0, u'\x0001', nPrefixIdx ).toInt32() )); aFormat.SetSuffix( aPostfix.getToken( 0, u'\x0001', nPostfixIdx )); aFormat.SetIncludeUpperLevels( MAXLEVEL ); if( n < aNumTypes.getLength() ) @@ -1687,7 +1687,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) } } else if( !m_aFlags.bAFormatByInput ) - SetColl( static_cast<sal_uInt16>(RES_POOLCOLL_NUM_LEVEL1 + ( std::min( nLvl, cnNumBullColls ) * 4 ) )); + SetColl( o3tl::narrowing<sal_uInt16>(RES_POOLCOLL_NUM_LEVEL1 + ( std::min( nLvl, cnNumBullColls ) * 4 ) )); else bChgEnum = false; } @@ -1811,7 +1811,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces ) || (!nTextPos && IsBlanksInString(*m_pCurTextFrame)) || IsSentenceAtEnd(*m_pCurTextFrame); - SetColl( static_cast<sal_uInt16>( nTextPos + SetColl( o3tl::narrowing<sal_uInt16>( nTextPos ? RES_POOLCOLL_CONFRONTATION : RES_POOLCOLL_TEXT_NEGIDENT ) ); @@ -1889,7 +1889,7 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl ) m_pDoc->GetDocumentRedlineManager().SetAutoFormatRedlineComment( &sText ); } - SetColl( static_cast<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + nLvl ), true ); + SetColl( o3tl::narrowing<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + nLvl ), true ); if( m_aFlags.bAFormatByInput ) { SwTextFormatColl& rNxtColl = m_pCurTextFrame->GetTextNodeForParaProps()->GetTextColl()->GetNextTextFormatColl(); diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index dc8769f2a61a..4df2c7db6e47 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -93,7 +93,7 @@ bool SwEditShell::GetPaMAttr( SwPaM* pPaM, SfxItemSet& rSet, nListLevel = MAXLEVEL - 1; const OUString & aCharFormatName = - pNumRule->Get(static_cast<sal_uInt16>(nListLevel)).GetCharFormatName(); + pNumRule->Get(o3tl::narrowing<sal_uInt16>(nListLevel)).GetCharFormatName(); SwCharFormat * pCharFormat = GetDoc()->FindCharFormatByName(aCharFormatName); @@ -504,7 +504,7 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const bool bRet = true; const SvxTabStopItem& rTabItem = GetDoc()->GetDefault( RES_PARATR_TABSTOP ); - sal_uInt16 nDefDist = static_cast<sal_uInt16>(rTabItem.Count() ? rTabItem[0].GetTabPos() : 1134); + sal_uInt16 nDefDist = o3tl::narrowing<sal_uInt16>(rTabItem.Count() ? rTabItem[0].GetTabPos() : 1134); if( !nDefDist ) return false; @@ -533,7 +533,7 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const SwFrame* pFrame = pCNd->getLayoutFrame( GetLayout() ); if ( pFrame ) { - const sal_uInt16 nFrameWidth = static_cast<sal_uInt16>( pFrame->IsVertical() ? + const sal_uInt16 nFrameWidth = o3tl::narrowing<sal_uInt16>( pFrame->IsVertical() ? pFrame->getFrameArea().Height() : pFrame->getFrameArea().Width() ); bRet = nFrameWidth > ( nNext + MM50 ); @@ -614,7 +614,7 @@ static bool lcl_IsNoEndTextAttrAtPos(SwRootFrame const& rLayout, if (nListLevel >= MAXLEVEL) nListLevel = MAXLEVEL - 1; - const SwNumFormat &rNumFormat = pNumRule->Get( static_cast<sal_uInt16>(nListLevel) ); + const SwNumFormat &rNumFormat = pNumRule->Get( o3tl::narrowing<sal_uInt16>(nListLevel) ); if( SVX_NUM_BITMAP != rNumFormat.GetNumberingType() ) { if ( SVX_NUM_CHAR_SPECIAL == rNumFormat.GetNumberingType() ) diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx index 837f37b94e20..b6bb9055f23d 100644 --- a/sw/source/core/edit/edfld.cxx +++ b/sw/source/core/edit/edfld.cxx @@ -46,7 +46,7 @@ size_t SwEditShell::GetFieldTypeCount(SwFieldIds nResId ) const if(nResId == SwFieldIds::Unknown) { - return static_cast<sal_uInt16>(pFieldTypes->size()); + return o3tl::narrowing<sal_uInt16>(pFieldTypes->size()); } // all types with the same ResId diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 9be63fb05251..eea6cd397b86 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -812,7 +812,7 @@ void SwEditShell::SetNumberingRestart() nListLevel = MAXLEVEL - 1; bIsNodeNum = pTextNd->GetNum()->GetNumber() == - pNumRule->Get( static_cast<sal_uInt16>(nListLevel) ).GetStart(); + pNumRule->Get( o3tl::narrowing<sal_uInt16>(nListLevel) ).GetStart(); } if (bIsNodeNum) { diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index af7ec8178e41..cd4458c276dd 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -900,7 +900,7 @@ sal_uInt16 SwEditShell::GetNodeNumStart( SwPaM* pPaM ) const // return USHRT_MAX, if no list restart value is found. if ( pTextNd && pTextNd->HasAttrListRestartValue() ) { - return static_cast<sal_uInt16>(pTextNd->GetAttrListRestartValue()); + return o3tl::narrowing<sal_uInt16>(pTextNd->GetAttrListRestartValue()); } return USHRT_MAX; } diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx index b93c30d8f8f4..cb849d8f6230 100644 --- a/sw/source/core/fields/dbfld.cxx +++ b/sw/source/core/fields/dbfld.cxx @@ -665,7 +665,7 @@ void SwDBNumSetField::Evaluate(const SwDoc& rDoc) if( m_bCondValid && pMgr && pMgr->IsInMerge() && pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand, true)) { // condition OK -> adjust current Set - pMgr->ToRecordId(std::max(static_cast<sal_uInt16>(m_aPar2.toInt32()), sal_uInt16(1))-1); + pMgr->ToRecordId(std::max(o3tl::narrowing<sal_uInt16>(m_aPar2.toInt32()), sal_uInt16(1))-1); } } diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index ceea88941ddb..6ee39cf4d8a0 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -472,7 +472,7 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_USHORT1: rAny >>= nTmp; - m_nSubType = static_cast<sal_uInt16>(nTmp); + m_nSubType = o3tl::narrowing<sal_uInt16>(nTmp); break; case FIELD_PROP_PAR1: { @@ -484,7 +484,7 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) case FIELD_PROP_SUBTYPE: nTmp = lcl_APIToSubType(rAny); if( nTmp >=0 ) - SetSubType( static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp)); + SetSubType( o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp)); break; case FIELD_PROP_BOOL2: if(*o3tl::doAccess<bool>(rAny)) @@ -697,7 +697,7 @@ void SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { sal_Int32 nSet = lcl_APIToSubType(rAny); if(nSet >=0) - SetType(static_cast<sal_uInt16>(nSet)); + SetType(o3tl::narrowing<sal_uInt16>(nSet)); } break; case FIELD_PROP_PAR2: @@ -1109,7 +1109,7 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) case FIELD_PROP_SUBTYPE: nTmp32 = lcl_APIToSubType(rAny); if(nTmp32 >= 0) - SetSubType(static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp32)); + SetSubType(o3tl::narrowing<sal_uInt16>((GetSubType() & 0xff00) | nTmp32)); break; case FIELD_PROP_PAR3: rAny >>= maPText; diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index bf7f1d2d618e..bd82d5deee2c 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -564,10 +564,10 @@ void SwFEShell::GetTabCols_(SwTabCols &rToFill, const SwFrame *pBox) const } if ( !bDel && - m_pColumnCache->pLastCols->GetLeftMin () == static_cast<sal_uInt16>(nLeftMin) && - m_pColumnCache->pLastCols->GetLeft () == static_cast<sal_uInt16>(aRectFnSet.GetLeft(pTab->getFramePrintArea())) && - m_pColumnCache->pLastCols->GetRight () == static_cast<sal_uInt16>(aRectFnSet.GetRight(pTab->getFramePrintArea()))&& - m_pColumnCache->pLastCols->GetRightMax() == static_cast<sal_uInt16>(nRightMax) - m_pColumnCache->pLastCols->GetLeftMin() ) + m_pColumnCache->pLastCols->GetLeftMin () == o3tl::narrowing<sal_uInt16>(nLeftMin) && + m_pColumnCache->pLastCols->GetLeft () == o3tl::narrowing<sal_uInt16>(aRectFnSet.GetLeft(pTab->getFramePrintArea())) && + m_pColumnCache->pLastCols->GetRight () == o3tl::narrowing<sal_uInt16>(aRectFnSet.GetRight(pTab->getFramePrintArea()))&& + m_pColumnCache->pLastCols->GetRightMax() == o3tl::narrowing<sal_uInt16>(nRightMax) - m_pColumnCache->pLastCols->GetLeftMin() ) { if (m_pColumnCache->pLastCellFrame != pBox) { diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 067786a6c2a2..e5aae5f1a945 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -2364,7 +2364,7 @@ void FndBox_::MakeFrames( SwTable &rTable ) i >= 0 && !pSibling; --i ) { SwTableLine *pLine = m_pLineBehind ? m_pLineBehind : - rTable.GetTabLines()[static_cast<sal_uInt16>(i)]; + rTable.GetTabLines()[o3tl::narrowing<sal_uInt16>(i)]; SwIterator<SwRowFrame,SwFormat> aIter( *pLine->GetFrameFormat() ); pSibling = aIter.First(); while ( pSibling && ( diff --git a/sw/source/core/graphic/grfatr.cxx b/sw/source/core/graphic/grfatr.cxx index 703a06d69d3d..b267a55c19d2 100644 --- a/sw/source/core/graphic/grfatr.cxx +++ b/sw/source/core/graphic/grfatr.cxx @@ -332,7 +332,7 @@ bool SwDrawModeGrf::PutValue( const uno::Any& rVal, sal_Int32 eVal = SWUnoHelper::GetEnumAsInt32( rVal ); if(eVal >= 0 && eVal <= sal_uInt16(GraphicDrawMode::Watermark)) { - SetEnumValue(static_cast<sal_uInt16>(eVal)); + SetEnumValue(o3tl::narrowing<sal_uInt16>(eVal)); return true; } return false; diff --git a/sw/source/core/inc/tblrwcl.hxx b/sw/source/core/inc/tblrwcl.hxx index cc1f0a514769..addc40804f74 100644 --- a/sw/source/core/inc/tblrwcl.hxx +++ b/sw/source/core/inc/tblrwcl.hxx @@ -126,7 +126,7 @@ struct SwGCLineBorder SwGCLineBorder( const SwTableBox& rBox ) : pLines( &rBox.GetTabLines() ), pShareFormats(nullptr), nLinePos( 0 ) {} - bool IsLastLine() const { return nLinePos + 1 >= static_cast<sal_uInt16>(pLines->size()); } + bool IsLastLine() const { return nLinePos + 1 >= o3tl::narrowing<sal_uInt16>(pLines->size()); } }; class SwGCBorder_BoxBrd diff --git a/sw/source/core/inc/wrong.hxx b/sw/source/core/inc/wrong.hxx index dcd8503ef6aa..3d32eae81e2f 100644 --- a/sw/source/core/inc/wrong.hxx +++ b/sw/source/core/inc/wrong.hxx @@ -320,7 +320,7 @@ public: return nIdx < maList.size() ? maList[nIdx].mnPos : 0; } - sal_uInt16 Count() const { return static_cast<sal_uInt16>(maList.size()); } + sal_uInt16 Count() const { return o3tl::narrowing<sal_uInt16>(maList.size()); } void Insert( const OUString& rType, css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag, diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index fe29ecfe2faa..dd434fb6d90c 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -1098,7 +1098,7 @@ bool SwFormatCol::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) const text::TextColumn* pArray = aSetColumns.getConstArray(); m_aColumns.clear(); //max count is 64k here - this is something the array can't do - sal_uInt16 nCount = std::min( static_cast<sal_uInt16>(aSetColumns.getLength()), + sal_uInt16 nCount = std::min( o3tl::narrowing<sal_uInt16>(aSetColumns.getLength()), sal_uInt16(0x3fff) ); sal_uInt16 nWidthSum = 0; // #101224# one column is no column @@ -2269,7 +2269,7 @@ bool SwTextGridItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) sal_Int16 nTmp = 0; bRet = (rVal >>= nTmp); if( bRet && (nTmp >= 0) ) - SetLines( static_cast<sal_uInt16>(nTmp) ); + SetLines( o3tl::narrowing<sal_uInt16>(nTmp) ); else bRet = false; } @@ -2301,15 +2301,15 @@ bool SwTextGridItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEHEIGHT ) { nTmp = std::max<sal_Int32>(nTmp, MIN_TEXTGRID_SIZE); - SetBaseHeight( static_cast<sal_uInt16>(nTmp) ); + SetBaseHeight( o3tl::narrowing<sal_uInt16>(nTmp) ); } else if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEWIDTH ) { nTmp = std::max<sal_Int32>(nTmp, MIN_TEXTGRID_SIZE); - SetBaseWidth( static_cast<sal_uInt16>(nTmp) ); + SetBaseWidth( o3tl::narrowing<sal_uInt16>(nTmp) ); } else - SetRubyHeight( static_cast<sal_uInt16>(nTmp) ); + SetRubyHeight( o3tl::narrowing<sal_uInt16>(nTmp) ); } else bRet = false; diff --git a/sw/source/core/layout/dbg_lay.cxx b/sw/source/core/layout/dbg_lay.cxx index 4f1bc42ecc18..6391f97343d8 100644 --- a/sw/source/core/layout/dbg_lay.cxx +++ b/sw/source/core/layout/dbg_lay.cxx @@ -409,7 +409,7 @@ void SwImplProtocol::CheckLine( OString& rLine ) } break; case 5: - m_nMaxLines = static_cast<sal_uInt16>(nVal); + m_nMaxLines = o3tl::narrowing<sal_uInt16>(nVal); break; case 6: m_aVars.push_back(nVal); diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index ca8cc3c8ef9b..600125e48b9c 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -3412,10 +3412,10 @@ void SwLayoutFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBord } } - const sal_uInt16 nLeft = static_cast<sal_uInt16>(pAttrs->CalcLeft(this)); + const sal_uInt16 nLeft = o3tl::narrowing<sal_uInt16>(pAttrs->CalcLeft(this)); const sal_uInt16 nUpper = bHideWhitespace ? 0 : pAttrs->CalcTop(); - const sal_uInt16 nRight = static_cast<sal_uInt16>(pAttrs->CalcRight(this)); + const sal_uInt16 nRight = o3tl::narrowing<sal_uInt16>(pAttrs->CalcRight(this)); const sal_uInt16 nLower = bHideWhitespace ? 0 : pAttrs->CalcBottom(); const bool bVert = IsVertical() && !IsPageFrame(); diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx index 85592b9a7458..a2506f59bd7c 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -1062,7 +1062,7 @@ SwTableBox& SwTableBox::FindEndOfRowSpan( const SwTable& rTable, sal_uInt16 nMax return *this; if( nMaxStep > --nAbsSpan ) - nMaxStep = static_cast<sal_uInt16>(nAbsSpan); + nMaxStep = o3tl::narrowing<sal_uInt16>(nAbsSpan); const SwTableLine* pMyUpper = GetUpper(); sal_uInt16 nLine = rTable.GetTabLines().GetPos( pMyUpper ); nMaxStep = nLine + nMaxStep; @@ -1388,7 +1388,7 @@ static sal_uInt16 lcl_LineIndex( const SwTable& rTable, const SwSelBoxes& rBoxes nSpan = 0; else if( nSpan ) { - sal_uInt16 nEndOfRowSpan = static_cast<sal_uInt16>(nPos + nRowSpan - 1); + sal_uInt16 nEndOfRowSpan = o3tl::narrowing<sal_uInt16>(nPos + nRowSpan - 1); if( nEndOfRowSpan > nSpan || nSpan == USHRT_MAX ) nSpan = nEndOfRowSpan; } @@ -2101,7 +2101,7 @@ void SwTable::CleanUpBottomRowSpan( sal_uInt16 nDelLines ) if( nRowSp > 1 ) { lcl_ChangeRowSpan( *this, -static_cast<tools::Long>(nDelLines), - static_cast<sal_uInt16>(nLastLine), false ); + o3tl::narrowing<sal_uInt16>(nLastLine), false ); break; } } diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index fda4da0b85d9..64632d69e583 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -717,7 +717,7 @@ static void lcl_ProcessBoxSet( SwTableBox *pBox, Parm &rParm ) SwTableBoxes& rTableBoxes = pBox->GetUpper()->GetTabBoxes(); if( nPos && rTableBoxes[ nPos - 1 ]->getRowSpan() != 1 ) nLeftDiff = 0; - if( nPos + 1 < static_cast<sal_uInt16>(rTableBoxes.size()) && + if( nPos + 1 < o3tl::narrowing<sal_uInt16>(rTableBoxes.size()) && rTableBoxes[ nPos + 1 ]->getRowSpan() != 1 ) nRightDiff = 0; } @@ -1177,7 +1177,7 @@ void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols &rNew, nOldPos = lcl_MulDiv64<tools::Long>(nOldPos, rParm.nOldWish, nOldWidth); if( nOldPos != nNewPos && nNewPos > 0 && nOldPos > 0 ) { - ColChange aChg( static_cast<sal_uInt16>(nOldPos), static_cast<sal_uInt16>(nNewPos) ); + ColChange aChg( o3tl::narrowing<sal_uInt16>(nOldPos), o3tl::narrowing<sal_uInt16>(nNewPos) ); aOldNew.push_back( aChg ); } } @@ -1218,7 +1218,7 @@ void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols &rNew, } aRowSpanPos.clear(); } - if( nCurr+1 < static_cast<sal_uInt16>(rLines.size()) ) + if( nCurr+1 < o3tl::narrowing<sal_uInt16>(rLines.size()) ) { ChangeList aCopy; sal_uInt16 nPos = 0; @@ -1236,7 +1236,7 @@ void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols &rNew, lcl_CalcNewWidths( aRowSpanPos, aCopy, rLines[++j], rParm.nOldWish, nOldWidth, false ); lcl_AdjustWidthsInLine( rLines[j], aCopy, rParm, 0 ); - bGoOn = !aRowSpanPos.empty() && j+1 < static_cast<sal_uInt16>(rLines.size()); + bGoOn = !aRowSpanPos.empty() && j+1 < o3tl::narrowing<sal_uInt16>(rLines.size()); } } ::lcl_AdjustWidthsInLine( rLines[nCurr], aOldNew, rParm, COLFUZZY ); @@ -1305,7 +1305,7 @@ sal_uInt16 SwTable::GetBoxNum( OUString& rStr, bool bFirstPart, nRet = 0; if ( !bPerformValidCheck || lcl_IsValidRowName( rStr ) ) { - nRet = static_cast<sal_uInt16>(rStr.toInt32()); + nRet = o3tl::narrowing<sal_uInt16>(rStr.toInt32()); } rStr.clear(); } @@ -1315,7 +1315,7 @@ sal_uInt16 SwTable::GetBoxNum( OUString& rStr, bool bFirstPart, const OUString aText( rStr.copy( 0, nPos ) ); if ( !bPerformValidCheck || lcl_IsValidRowName( aText ) ) { - nRet = static_cast<sal_uInt16>(aText.toInt32()); + nRet = o3tl::narrowing<sal_uInt16>(aText.toInt32()); } rStr = rStr.copy( nPos+1 ); } diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 088f21c00b10..ba2f0ad9333f 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -424,7 +424,7 @@ void SwTaggedPDFHelper::BeginTag( vcl::PDFWriter::StructElement eType, const OUS ++m_nEndStructureElement; #if OSL_DEBUG_LEVEL > 1 - aStructStack.push_back( static_cast<sal_uInt16>(eType) ); + aStructStack.push_back( o3tl::narrowing<sal_uInt16>(eType) ); #endif // Store the id of the current structure element if @@ -1117,7 +1117,7 @@ void SwTaggedPDFHelper::BeginBlockStructureElements() int nRealLevel = pTextNd->GetAttrOutlineLevel()-1; nRealLevel = std::min(nRealLevel, 5); - nPDFType = static_cast<sal_uInt16>(vcl::PDFWriter::H1 + nRealLevel); + nPDFType = o3tl::narrowing<sal_uInt16>(vcl::PDFWriter::H1 + nRealLevel); switch(nRealLevel) { case 0 : diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx index ce29c020fa4a..5f3045f0504b 100644 --- a/sw/source/core/text/frmcrsr.cxx +++ b/sw/source/core/text/frmcrsr.cxx @@ -1418,7 +1418,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const if( nDiff > 0 ) { nDiff /= nDist; - rFill.Fill().nParaCnt = static_cast<sal_uInt16>(nDiff + 1); + rFill.Fill().nParaCnt = o3tl::narrowing<sal_uInt16>(nDiff + 1); rFill.nLineWidth = 0; rFill.bInner = false; rFill.bEmpty = true; diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 344ccede8962..c399ac758a24 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -426,7 +426,7 @@ void SwTextSizeInfo::GetTextSize( const SwScriptInfo* pSI, const TextFrameIndex aDrawInf.SetSnapToGrid( SnapToGrid() ); aDrawInf.SetKanaComp( nComp ); SwPosSize aSize( m_pFnt->GetTextSize_( aDrawInf ) ); - nMaxSizeDiff = static_cast<sal_uInt16>(aDrawInf.GetKanaDiff()); + nMaxSizeDiff = o3tl::narrowing<sal_uInt16>(aDrawInf.GetKanaDiff()); nMinSize = aSize.Width(); } @@ -955,7 +955,7 @@ static void lcl_DrawSpecial( const SwTextPaintInfo& rTextPaintInfo, const SwLine Point aTmpPos( nX, nY ); rNonConstTextPaintInfo.SetPos( aTmpPos ); sal_uInt16 nOldWidth = rPor.Width(); - const_cast<SwLinePortion&>(rPor).Width( static_cast<sal_uInt16>(aFontSize.Width()) ); + const_cast<SwLinePortion&>(rPor).Width( o3tl::narrowing<sal_uInt16>(aFontSize.Width()) ); rTextPaintInfo.DrawText( aTmp, rPor ); const_cast<SwLinePortion&>(rPor).Width( nOldWidth ); rNonConstTextPaintInfo.SetFont( const_cast<SwFont*>(pOldFnt) ); diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx index a5944e49e357..8e7514cf9be3 100644 --- a/sw/source/core/text/itradj.cxx +++ b/sw/source/core/text/itradj.cxx @@ -488,7 +488,7 @@ SwTwips SwTextAdjuster::CalcKanaAdj( SwLineLayout* pCurrent ) else nCompress = 10000 - nCompress; - ( pCurrent->GetKanaComp() )[ nKanaIdx ] = static_cast<sal_uInt16>(nCompress); + ( pCurrent->GetKanaComp() )[ nKanaIdx ] = o3tl::narrowing<sal_uInt16>(nCompress); nKanaDiffSum = 0; } @@ -524,7 +524,7 @@ SwTwips SwTextAdjuster::CalcKanaAdj( SwLineLayout* pCurrent ) } else if( pPos->InGlueGrp() && pPos->InFixMargGrp() ) { - pPos->Width( static_cast<sal_uInt16>(pPos->Width() - nDecompress) ); + pPos->Width( o3tl::narrowing<sal_uInt16>(pPos->Width() - nDecompress) ); if ( pPos->InTabGrp() ) // set fix width to width diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index f6e298b2d3e0..9571324f8dbe 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -1432,7 +1432,7 @@ sal_uInt16 SwTextFrame::GetScalingOfSelectedText( SwTextIter aLine(this, &aInf); aLine.CharToLine( nStart ); pOut->SetMapMode( aOldMap ); - return static_cast<sal_uInt16>( nWidth ? + return o3tl::narrowing<sal_uInt16>( nWidth ? ( ( 100 * aLine.GetCurr()->Height() ) / nWidth ) : 0 ); } // no frame or no paragraph, we take the height of the character @@ -1442,7 +1442,7 @@ sal_uInt16 SwTextFrame::GetScalingOfSelectedText( pOut->SetMapMode( aOldMap ); SwDrawTextInfo aDrawInf(pSh, *pOut, GetText(), sal_Int32(nStart), 1); - return static_cast<sal_uInt16>( nWidth ? ((100 * aIter.GetFnt()->GetTextSize_( aDrawInf ).Height()) / nWidth ) : 0 ); + return o3tl::narrowing<sal_uInt16>( nWidth ? ((100 * aIter.GetFnt()->GetTextSize_( aDrawInf ).Height()) / nWidth ) : 0 ); } SwTwips SwTextNode::GetWidthOfLeadingTabs() const diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index b728a6ce98ff..f42a84237643 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -142,7 +142,7 @@ namespace { nListLevel = MAXLEVEL - 1; const SwNumFormat& rNumFormat = - rTextNode.GetNumRule()->Get( static_cast<sal_uInt16>(nListLevel) ); + rTextNode.GetNumRule()->Get( o3tl::narrowing<sal_uInt16>(nListLevel) ); if ( rNumFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { bRet = true; @@ -1625,7 +1625,7 @@ TextFrameIndex SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con nTmpY = pPor->Height() - nTmpY; if( nTmpY < 0 ) nTmpY = 0; - nX = static_cast<sal_uInt16>(nTmpY); + nX = o3tl::narrowing<sal_uInt16>(nTmpY); } if( static_cast<SwMultiPortion*>(pPor)->HasBrackets() ) diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index c61e05ea0ab9..e672eabb3fce 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -235,7 +235,7 @@ SwLinePortion *SwTextFormatter::Underflow( SwTextFormatInfo &rInf ) // line width is adjusted, so that pPor does not fit to current // line anymore - rInf.Width( static_cast<sal_uInt16>(rInf.X() + (pPor->Width() ? pPor->Width() - 1 : 0)) ); + rInf.Width( o3tl::narrowing<sal_uInt16>(rInf.X() + (pPor->Width() ? pPor->Width() - 1 : 0)) ); rInf.SetLen( pPor->GetLen() ); rInf.SetFull( false ); if( pFly ) @@ -424,7 +424,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) { SwFontScript nNxtActual = rInf.GetFont()->GetActual(); SwFontScript nLstActual = nNxtActual; - sal_uInt16 nLstHeight = static_cast<sal_uInt16>(rInf.GetFont()->GetHeight()); + sal_uInt16 nLstHeight = o3tl::narrowing<sal_uInt16>(rInf.GetFont()->GetHeight()); bool bAllowBehind = false; const CharClass& rCC = GetAppCharClass(); @@ -467,7 +467,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) if ( pTmpFnt ) { nLstActual = pTmpFnt->GetActual(); - nLstHeight = static_cast<sal_uInt16>(pTmpFnt->GetHeight()); + nLstHeight = o3tl::narrowing<sal_uInt16>(pTmpFnt->GetHeight()); } } } @@ -528,7 +528,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) const SwTwips nRestWidth = rInf.Width() - rInf.X(); if ( nKernWidth <= nRestWidth ) - pGridKernPortion->Width( static_cast<sal_uInt16>(nKernWidth) ); + pGridKernPortion->Width( o3tl::narrowing<sal_uInt16>(nKernWidth) ); } if ( pGridKernPortion != pPor ) @@ -615,7 +615,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) (m_pScriptInfo->ScriptType(nTmp - TextFrameIndex(1)) == css::i18n::ScriptType::ASIAN || m_pScriptInfo->ScriptType(nTmp) == css::i18n::ScriptType::ASIAN) ) { - const sal_uInt16 nDist = static_cast<sal_uInt16>(rInf.GetFont()->GetHeight()/5); + const sal_uInt16 nDist = o3tl::narrowing<sal_uInt16>(rInf.GetFont()->GetHeight()/5); if( nDist ) { @@ -670,7 +670,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) 0; const SwTwips nTmpWidth = i * nGridWidth; const SwTwips nKernWidth = std::min(nTmpWidth - nSumWidth, nRestWidth); - const sal_uInt16 nKernWidth_1 = static_cast<sal_uInt16>(nKernWidth / 2); ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits