core.git: Branch 'private/tvajngerl/length' - 3020 commits - android/.gitignore android/source autogen.sh avmedia/IwyuFilter_avmedia.yaml avmedia/Library_avmediawin.mk avmedia/source basctl/inc basctl/IwyuFilter_basctl.yaml basctl/Library_basctl.mk basctl/sdi basctl/source basctl/uiconfig basctl/UIConfig_basicide.mk basegfx/CppunitTest_basegfx.mk basegfx/source basegfx/test basic/IwyuFilter_basic.yaml basic/qa basic/source binaryurp/IwyuFilter_binaryurp.yaml binaryurp/source bin/check-elf-dynamic-objects bin/find-can-be-private-symbols.functions.results bin/find-mergedlib-can-be-private-symbols.functions.results bin/find-unneeded-includes bin/gbuild-to-ide bin/gen-boost-headers bin/lo-all-static-libs bin/oss-fuzz-setup.sh bin/ui-rules-enforcer.py bin/update_pch bridges/IwyuFilter_bridges.yaml bridges/source BUCK canvas/inc canvas/qa canvas/source canvas/workben chart2/inc chart2/IwyuFilter_chart2.yaml chart2/qa chart2/source chart2/uiconfig codemaker/Executable_cppumaker.mk codemaker/Executable_javamaker.mk codemaker/Executable_pythonmaker.mk codemaker/Executable_rustmaker.mk codemaker/Module_codemaker.mk codemaker/README.md codemaker/source comphelper/inc comphelper/IwyuFilter_comphelper.yaml comphelper/Library_comphelper.mk comphelper/qa comphelper/source compilerplugins/clang .config/2022_cross.vsconfig .config/2022.vsconfig .config/admin_java_and_deps.winget config_host/config_global.h.in config_host/config_skia.h.in config_host.mk.in configmgr/IwyuFilter_configmgr.yaml configmgr/source configure.ac .config/user_steps.winget connectivity/IwyuFilter_connectivity.yaml connectivity/Library_macabdrv1.mk connectivity/Module_connectivity.mk connectivity/qa connectivity/source cppcanvas/qa cppcanvas/source cppuhelper/inc cppuhelper/IwyuFilter_cppuhelper.yaml cppuhelper/source cppu/IwyuFilter_cppu.yaml cppu/qa cppu/source cpputools/source cui/inc cui/IwyuFilter_cui.yaml cui/Library_cui.mk cui/qa cui/source cui/uiconfig cui/UIConfig_cui.mk dbaccess/inc dbac cess/IwyuFilter_dbaccess.yaml dbaccess/qa dbaccess/source dbaccess/uiconfig desktop/Executable_soffice_bin.mk desktop/inc desktop/IwyuFilter_desktop.yaml desktop/Library_deploymentgui.mk desktop/Library_sofficeapp.mk desktop/qa desktop/source desktop/uiconfig desktop/unx dictionaries distro-configs/Jenkins distro-configs/LibreOfficeFlatpak.conf distro-configs/LibreOfficeLinux.conf distro-configs/LibreOfficeOssFuzz.conf distro-configs/LibreOfficeWin64.conf docmodel/Library_docmodel.mk docmodel/source download.lst drawinglayer/inc drawinglayer/IwyuFilter_drawinglayer.yaml drawinglayer/qa drawinglayer/source editeng/CppunitTest_editeng_editeng.mk editeng/CustomTarget_generated.mk editeng/inc editeng/IwyuFilter_editeng.yaml editeng/qa editeng/source embeddedobj/IwyuFilter_embeddedobj.yaml embeddedobj/qa embeddedobj/source embeddedobj/test emfio/inc emfio/qa emfio/source eventattacher/source extensions/CppunitTest_extensions_test_update.mk extensions/IwyuFilter_extensions.yaml extensions /Library_updchk.mk extensions/source extensions/uiconfig external/afdko external/boost external/cairo external/clew external/clucene external/coinmp external/cppunit external/curl external/dtoa external/expat external/fast_float external/fontconfig external/freetype external/gpgmepp external/harfbuzz external/hunspell external/icu external/lcms2 external/libassuan external/libeot external/libgpg-error external/liblangtag external/libmwaw external/libodfgen external/liborcus external/libpng external/libstaroffice external/libwebp external/libwpd external/libwpg external/libwps external/libxml2 external/libxslt external/lpsolve external/mariadb-connector-c external/md4c external/Module_external.mk external/nss external/openldap external/openssl external/pdfium external/poppler external/python3 external/redland external/skia external/zlib external/zxcvbn-c external/zxing extras/Package_tplwizbitmap.mk extras/source filter/Configuration_filter.mk filter/CustomTarget_svg.mk filter/IwyuFi lter_filter.yaml filter/qa filter/source filter/uiconfig forms/IwyuFilter_forms.yaml forms/qa forms/source formula/inc formula/source formula/uiconfig fpicker/source framework/CppunitTest_framework_accelerators.mk framework/inc framework/IwyuFilter_framework.yaml framework/JunitTest_framework_complex.mk framework/Library_fwk.mk framework/Module_framework.mk framework/qa framework/source framework/uiconfig g .gitattributes .gitmodules helpcompiler/IwyuFilter_helpcompiler.yaml helpcompiler/source helpcontent2 hwpfilter/source i18npool/CustomTarget_breakiterator.mk i18npool/Executable_gendict.mk i18npool/IwyuFilter_i18npool.yaml i18npool/Library_i18npool.mk i18npool/Library_localedata_euro.mk i18npool/qa i18npool/source icon-themes/breeze icon-themes/breeze_dark icon-themes/breeze_dark_svg icon-themes/breeze_svg icon-themes/colibre icon-themes/colibre_dark icon-themes/colibre_dark_svg icon-themes/colibre_svg icon-themes/elementary icon-themes/elementary_svg icon-themes/karasa_jaga icon -themes/karasa_jaga_svg icon-themes/sifr icon-themes/sifr_dark icon-themes/sifr_dark_svg icon-themes/sifr_svg icon-themes/sukapura icon-themes/sukapura_dark icon-themes/sukapura_dark_svg icon-themes/sukapura_svg idl/Executable_svidl.mk idl/inc idl/source include/basctl include/basegfx include/basic include/canvas include/com include/comphelper include/connectivity include/cppcanvas include/cppuhelper include/cppunittester include/dbaccess include/desktop include/docmodel include/drawinglayer include/editeng include/embeddedobj include/filter include/formula include/framework include/IwyuFilter_include.yaml include/LibreOfficeKit include/o3tl include/oox include/opencl include/rtl include/sal include/sfx2 include/sot include/svl include/svtools include/svx include/test include/toolkit include/tools include/unotest include/unotools include/vcl include/xmloff include/xmlscript instsetoo_native/CustomTarget_emscripten-install.mk instsetoo_native/inc_openoffice io/IwyuFilter_io.yaml io/s ource ios/UnitTest jurt/Library_jpipe.mk jurt/source jvmfwk/IwyuFilter_jvmfwk.yaml jvmfwk/plugins jvmfwk/qa jvmfwk/source l10ntools/inc l10ntools/source libreofficekit/qa libreofficekit/source lingucomponent/source linguistic/source logerrit lotuswordpro/source m4/ax_boost_filesystem.m4 m4/ax_boost_system.m4 Makefile.fetch Makefile.in o3tl/qa odk/examples odk/Package_examples.mk offapi/com offapi/type_reference offapi/UnoApi_offapi.mk officecfg/registry oox/inc oox/IwyuFilter_oox.yaml oox/Library_oox.mk oox/qa oox/source opencl/source package/inc package/source postprocess/qa pyuno/IwyuFilter_pyuno.yaml pyuno/Module_pyuno.mk pyuno/PythonTest_pyuno_pytests_testvenv.mk pyuno/qa pyuno/source qadevOOo/runner readlicense_oo/docs readlicense_oo/license README.md registry/tools reportbuilder/java reportdesign/CppunitTest_reportdesign_basic_test.mk reportdesign/inc reportdesign/IwyuFilter_reportdesign.yaml reportdesign/JunitTest_reportdesign_complex.mk reportdesign/Library_rpt.mk reportdesi gn/Library_rptxml.mk reportdesign/Module_reportdesign.mk reportdesign/qa reportdesign/source reportdesign/uiconfig reportdesign/util RepositoryExternal.mk Repository.mk RepositoryModule_host.mk ridljar/com ridljar/test rust_uno/build.rs rust_uno/Cargo.toml rust_uno/CustomTarget_cargo.mk rust_uno/CustomTarget_rustmaker.mk rust_uno/example rust_uno/Extension_rust_uno-example.mk rust_uno/.gitignore rust_uno/Library_rust_uno-cpp.mk rust_uno/Library_rust_uno-example.mk rust_uno/Makefile rust_uno/Module_rust_uno.mk rust_uno/src rust_uno/uno_bootstrap.cxx sal/CppunitTest_sal_osl_file_details.mk sal/inc sal/IwyuFilter_sal.yaml sal/Library_sal.mk sal/Module_sal.mk sal/osl sal/qa sal/rtl sal/textenc sax/Library_sax.mk sax/source scaddins/IwyuFilter_scaddins.yaml scaddins/source sc/CppunitTest_sc_basic_types_test.mk sc/CppunitTest_sc_sheetview_test.mk sc/CppunitTest_sc_ucalc_sparkline.mk sc/functions_setup.mk schema/libreoffice sc/inc sc/IwyuFilter_sc.yaml sc/Library_scfilt.mk sc/Library_sc.mk sc/Module_sc.mk sc/qa scripting/java scripting/source sc/sdi sc/source sc/ucalc_setup.mk sc/uiconfig sc/UIConfig_scalc.mk sd/CppunitTest_sd_layout_tests.mk sd/CppunitTest_sd_uimpress.mk sdext/CustomTarget_pdfimport.mk sdext/IwyuFilter_sdext.yaml sdext/qa sdext/source sd/import_setup.mk sd/inc sd/IwyuFilter_sd.yaml sd/Library_sd.mk sd/qa sd/sdi sd/source sd/uiconfig sd/util sfx2/inc sfx2/IwyuFilter_sfx2.yaml sfx2/Library_sfx.mk sfx2/qa sfx2/sdi sfx2/source sfx2/uiconfig shell/source slideshow/inc slideshow/IwyuFilter_slideshow.yaml slideshow/source solenv/bin solenv/clang-format solenv/CompilerTest_compilerplugins_clang.mk solenv/flatpak-manifest.in solenv/gbuild solenv/inc solenv/sanitizers sot/source starmath/CppunitTest_starmath_qa_cppunit.mk starmath/inc starmath/IwyuFilter_starmath.yaml starmath/Library_sm.mk starmath/source starmath/uiconfig static/CustomTarget_emscripten_fs_image.mk static/source stoc/IwyuFilter_stoc.yaml stoc/source store/IwyuFilter_store.yaml svgio/inc svgi o/qa svgio/source svl/IwyuFilter_svl.yaml svl/Library_svl.mk svl/qa svl/source svtools/inc svtools/IwyuFilter_svtools.yaml svtools/qa svtools/source svtools/uiconfig svx/CppunitTest_svx_removewhichrange.mk svx/inc svx/IwyuFilter_svx.yaml svx/Library_svxcore.mk svx/Library_svx.mk svx/qa svx/sdi svx/source svx/uiconfig svx/UIConfig_svx.mk svx/util sw/CppunitTest_sw_a11y.mk sw/CppunitTest_sw_core_unocore.mk sw/CppunitTest_sw_embedded_fonts.mk sw/CppunitTest_sw_filter_md.mk sw/CppunitTest_sw_globalfilter.mk sw/CppunitTest_sw_snap_to_grid.mk sw/CppunitTest_sw_uiwriter11.mk sw/CppunitTest_sw_unowriter.mk sw/CppunitTest_sw_uwriter.mk sw/CppunitTest_sw_writerfilter_dmapper.mk sw/CustomTarget_generated.mk sw/inc sw/IwyuFilter_sw.yaml sw/Library_sw.mk sw/Module_sw.mk sw/qa sw/README.md sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk sysui/desktop test/CppunitTest_test_a11y.mk test/source testtools/source test/user-template toolkit/inc toolkit/IwyuFilter_toolkit.yaml toolkit/Library_tk.mk toolkit/qa toolkit/source tools/inc tools/IwyuFilter_tools.yaml tools/source translations ucbhelper/source ucb/IwyuFilter_ucb.yaml ucb/source udkapi/type_reference UnoControls/IwyuFilter_UnoControls.yaml unoidl/Executable_unoidl-check.mk unoidl/Executable_unoidl-write.mk unoidl/source unotest/Library_embindtest.mk unotest/Module_unotest.mk unotest/source unotools/IwyuFilter_unotools.yaml unotools/source unoxml/source uui/inc uui/source vbahelper/inc vbahelper/IwyuFilter_vbahelper.yaml vbahelper/source vcl/backendtest vcl/commonfuzzer.mk vcl/CppunitTest_vcl_a11y.mk vcl/CppunitTest_vcl_gtk3_a11y.mk vcl/CppunitTest_vcl_unit_conversion.mk vcl/CustomTarget_qt5_moc.mk vcl/CustomTarget_qt6_moc.mk vcl/Executable_pdf2fodgfuzzer.mk vcl/headless vcl/inc vcl/IwyuFilter_vcl.yaml vcl/jsdialog vcl/Library_vcl.mk vcl/Library_vclplug_qt5.mk vcl/Library_vclplug_qt6.mk vcl/Library_vclplug_win.mk vcl/Module_vcl.mk vcl/osx vcl/qa vcl/qt5 vcl/qt6 vcl/quartz vcl/skia vcl/source vcl/uiconfig vcl/UIConfig_v cl.mk vcl/unx vcl/vcl.common.component vcl/vcl.common.component.macosx vcl/vcl.common.component.unx vcl/win vcl/workben winaccessibility/source wizards/com wizards/Package_scriptforge.mk wizards/source writerperfect/inc writerperfect/qa writerperfect/source xmlhelp/source xmloff/CppunitTest_xmloff_text.mk xmloff/CustomTarget_generated.mk xmloff/inc xmloff/IwyuFilter_xmloff.yaml xmloff/qa xmloff/source xmlscript/source xmlsecurity/inc xmlsecurity/IwyuFilter_xmlsecurity.yaml xmlsecurity/Module_xmlsecurity.mk xmlsecurity/source xmlsecurity/workben

Sun, 19 Oct 2025 20:21:29 -0700

Rebased ref, commits from common ancestor:
commit cbd15d29df609880a376c3bf83747e48ed21463e
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Thu Oct 9 15:45:35 2025 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Mon Oct 20 12:19:21 2025 +0900

    don't allow implicit casting SwTwips to Long
    
    Change-Id: I549239bbfd9c7171e158d63d6aa53701d3d3f7cf

diff --git a/sw/inc/fmtornt.hxx b/sw/inc/fmtornt.hxx
index bdf80899985e..d0cca20370f8 100644
--- a/sw/inc/fmtornt.hxx
+++ b/sw/inc/fmtornt.hxx
@@ -38,8 +38,8 @@ class SW_DLLPUBLIC SwFormatVertOrient final : public 
SfxPoolItem
     sal_Int16       m_eRelation;
 public:
     DECLARE_ITEM_TYPE_FUNCTION(SwFormatVertOrient)
-    SwFormatVertOrient( SwTwips nY = 0, sal_Int16 eVert = 
css::text::VertOrientation::NONE,
-                     sal_Int16 eRel = css::text::RelOrientation::PRINT_AREA );
+    SwFormatVertOrient(SwTwips nY = SwTwips(0), sal_Int16 eVert = 
css::text::VertOrientation::NONE,
+                       sal_Int16 eRel = css::text::RelOrientation::PRINT_AREA 
);
     SwFormatVertOrient(SwFormatVertOrient const &) = default; // SfxPoolItem 
copy function dichotomy
 
     /// "Pure virtual methods" of SfxPoolItem.
@@ -83,7 +83,7 @@ class SW_DLLPUBLIC SwFormatHoriOrient final : public 
SfxPoolItem
     bool            m_bPosToggle : 1; ///< Flip position on even pages.
 public:
     DECLARE_ITEM_TYPE_FUNCTION(SwFormatHoriOrient)
-    SwFormatHoriOrient( SwTwips nX = 0, sal_Int16 eHori = 
css::text::HoriOrientation::NONE,
+    SwFormatHoriOrient(SwTwips nX = SwTwips(0), sal_Int16 eHori = 
css::text::HoriOrientation::NONE,
         sal_Int16 eRel = css::text::RelOrientation::PRINT_AREA, bool bPos = 
false );
     SwFormatHoriOrient(SwFormatHoriOrient const &) = default; // SfxPoolItem 
copy function dichotomy
 
diff --git a/sw/inc/pagepreviewlayout.hxx b/sw/inc/pagepreviewlayout.hxx
index 016121e375ee..164daebc6b8f 100644
--- a/sw/inc/pagepreviewlayout.hxx
+++ b/sw/inc/pagepreviewlayout.hxx
@@ -44,8 +44,8 @@ private:
     friend class SwViewShell;
 
     /// number of horizontal and vertical twips for spacing between the pages.
-    static constexpr SwTwips gnXFree = 4 * 142;
-    static constexpr SwTwips gnYFree = 4 * 142;
+    static constexpr SwTwips gnXFree = SwTwips(4 * 142);
+    static constexpr SwTwips gnYFree = SwTwips(4 * 142);
 
     /// view shell the print preview is generated for.
     SwViewShell& mrParentViewShell;
diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx
index a6e54c491e9c..50cdb2893315 100644
--- a/sw/inc/swtypes.hxx
+++ b/sw/inc/swtypes.hxx
@@ -54,7 +54,7 @@ typedef tools::Long SwTwips;
 
 constexpr sal_Int32 COMPLETE_STRING = SAL_MAX_INT32;
 
-constexpr SwTwips cMinHdFtHeight = 56; // ~1mm
+constexpr SwTwips cMinHdFtHeight(56); // ~1mm
 
 #define MINFLY 23   // Minimal size for FlyFrames.
 #define MINLAY 23   // Minimal size for other Frames.
@@ -63,21 +63,21 @@ constexpr SwTwips cMinHdFtHeight = 56; // ~1mm
 constexpr int UNO_TABLE_COLUMN_SUM{10000};
 
 // Default column distance of two text columns corresponds to 0.3 cm.
-constexpr SwTwips DEF_GUTTER_WIDTH = o3tl::toTwips(3, o3tl::Length::mm);
+constexpr SwTwips DEF_GUTTER_WIDTH = o3tl::toTwips(3L, o3tl::Length::mm);
 
 // Minimal distance (distance to text) for border attribute
 // in order not to crock up aligned lines.
 // 28 Twips == 0,5mm
-constexpr SwTwips MIN_BORDER_DIST = 28; // ~0.5mm
+constexpr SwTwips MIN_BORDER_DIST(28); // ~0.5mm
 
 // Minimal document border: 20mm.
 constexpr tools::Long lMinBorderInMm(20);
-constexpr SwTwips lMinBorder = o3tl::toTwips(lMinBorderInMm, o3tl::Length::mm);
+constexpr SwTwips lMinBorder = o3tl::toTwips(SwTwips(lMinBorderInMm), 
o3tl::Length::mm);
 
 // Margin left and above document.
 // Half of it is gap between the pages.
 //TODO: Replace with SwViewOption::defDocumentBorder
-constexpr SwTwips DOCUMENTBORDER = 284; // ~5mm
+constexpr SwTwips DOCUMENTBORDER(284); // ~5mm
 
 // For inserting of captions (what and where to insert).
 // It's here because it is not big enough to justify its own hxx
@@ -96,11 +96,11 @@ constexpr sal_uInt8 MAXLEVEL = 10;
 //  (For more levels the values have to be multiplied with the levels+1;
 //  levels 0 ..4!)
 
-constexpr short lBulletIndent = o3tl::toTwips(25, o3tl::Length::in100); // 
0.25 inch
+constexpr short lBulletIndent = o3tl::toTwips(SwTwips(25), 
o3tl::Length::in100); // 0.25 inch
 constexpr short lBulletFirstLineOffset = -lBulletIndent;
-constexpr sal_uInt16 lNumberIndent = o3tl::toTwips(25, o3tl::Length::in100); 
// 0.25 inch
+constexpr sal_uInt16 lNumberIndent = o3tl::toTwips(SwTwips(25), 
o3tl::Length::in100); // 0.25 inch
 constexpr short lNumberFirstLineOffset = -lNumberIndent;
-constexpr short lOutlineMinTextDistance = o3tl::toTwips(15, 
o3tl::Length::in100); // 0.15 inch = 0.38 cm
+constexpr short lOutlineMinTextDistance = o3tl::toTwips(SwTwips(15), 
o3tl::Length::in100); // 0.15 inch = 0.38 cm
 
 // Count of SystemField-types of SwDoc.
 #define INIT_FLDTYPES   33
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index fdd7d866628b..d28488ad93c5 100644
--- a/sw/source/core/doc/docfly.cxx
+++ b/sw/source/core/doc/docfly.cxx
@@ -383,7 +383,7 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, 
SfxItemSet& rSet, boo
                 && text::HoriOrientation::NONE == 
pHoriOrientItem->GetHoriOrient()
                 && aOldH.GetPos() == pHoriOrientItem->GetPos())
             {
-                SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : 
aOldH.GetPos();
+                SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? SwTwips(0) : 
aOldH.GetPos();
                 nPos += aOldAnchorPos.getX() - aNewAnchorPos.getX();
 
                 assert(aOldH.GetRelationOrient() != 
pHoriOrientItem->GetRelationOrient());
@@ -416,7 +416,7 @@ sal_Int8 SwDoc::SetFlyFrameAnchor( SwFrameFormat& rFormat, 
SfxItemSet& rSet, boo
                 && text::VertOrientation::NONE == 
pVertOrientItem->GetVertOrient()
                 && aOldV.GetPos() == pVertOrientItem->GetPos())
             {
-                SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : 
aOldV.GetPos();
+                SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? SwTwips(0) : 
aOldV.GetPos();
                 nPos += aOldAnchorPos.getY() - aNewAnchorPos.getY();
 
                 assert(aOldV.GetRelationOrient() != 
pVertOrientItem->GetRelationOrient());
diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx
index 1400028ec9da..b915965316f7 100644
--- a/sw/source/core/doc/htmltbl.cxx
+++ b/sw/source/core/doc/htmltbl.cxx
@@ -1621,7 +1621,7 @@ void SwHTMLTableLayout::SetWidths( bool bCallPass2, 
sal_uInt16 nAbsAvail,
     SwTwips nCalcTabWidth = 0;
     for( const SwTableLine *pLine : m_pSwTable->GetTabLines() )
         lcl_ResizeLine( pLine, &nCalcTabWidth );
-    SAL_WARN_IF( std::abs( m_nRelTabWidth-nCalcTabWidth ) >= COLFUZZY, 
"sw.core",
+    SAL_WARN_IF( std::abs(SwTwips(m_nRelTabWidth) - nCalcTabWidth) >= 
COLFUZZY, "sw.core",
                  "Table width is not equal to the row width" );
 
     // Lock the table format when altering it, or else the box formats
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 6c25bdc97543..d7b06bc54a7f 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -62,8 +62,8 @@
 
 using namespace com::sun::star;
 
-#define COLFUZZY 20
-#define ROWFUZZY 10
+constexpr SwTwips COLFUZZY(20);
+constexpr SwTwips ROWFUZZY(10);
 
 #ifdef DBG_UTIL
 #define CHECK_TABLE(t) (t).CheckConsistency();
@@ -752,7 +752,7 @@ void DeleteBox_( SwTable& rTable, SwTableBox* pBox, SwUndo* 
pUndo,
             if( bCalcNewSize )
             {
                 SwFormatFrameSize aNew( pBox->GetFrameFormat()->GetFrameSize() 
);
-                aNew.SetWidth( aNew.GetWidth() + nBoxSz );
+                aNew.SetWidth(SwTwips(aNew.GetWidth()) + nBoxSz);
                 if( pShareFormats )
                     pShareFormats->SetSize( *pBox, aNew );
                 else
@@ -2379,16 +2379,16 @@ static bool lcl_SetSelBoxWidth( SwTableLine* pLine, 
CR_SetBoxWidth& rParam,
 
             // Collect all "ContentBoxes"
             bGreaterBox = (TableChgMode::FixedWidthChangeAbs != rParam.nMode)
-                       && ((nDist + (rParam.bLeft ? 0 : nWidth)) >= 
rParam.nSide);
+                       && ((nDist + (rParam.bLeft ? SwTwips(0) : nWidth)) >= 
rParam.nSide);
             if (bGreaterBox
                 || (!rParam.bBigger
-                    && (std::abs(nDist + ((rParam.nMode != 
TableChgMode::FixedWidthChangeAbs && rParam.bLeft) ? 0 : nWidth) - 
rParam.nSide) < COLFUZZY)))
+                    && (std::abs(nDist + ((rParam.nMode != 
TableChgMode::FixedWidthChangeAbs && rParam.bLeft) ? SwTwips(0) : nWidth) - 
rParam.nSide) < COLFUZZY)))
             {
                 SwTwips nLowerDiff;
                 if( bGreaterBox && TableChgMode::FixedWidthChangeProp == 
rParam.nMode )
                 {
                     // The "other Boxes" have been adapted, so change by this 
value
-                    nLowerDiff = (nDist + ( rParam.bLeft ? 0 : nWidth ) ) - 
rParam.nSide;
+                    nLowerDiff = (nDist + ( rParam.bLeft ? SwTwips(0) : nWidth 
) ) - rParam.nSide;
                     nLowerDiff *= rParam.nDiff;
                     nLowerDiff /= rParam.nMaxSize;
                     nLowerDiff = rParam.nDiff - nLowerDiff;
@@ -2415,8 +2415,8 @@ static bool lcl_SetSelBoxWidth( SwTableLine* pLine, 
CR_SetBoxWidth& rParam,
 
             if( nLowerDiff ||
                  (bGreaterBox = !nOldLower && 
TableChgMode::FixedWidthChangeAbs != rParam.nMode &&
-                    ( nDist + ( rParam.bLeft ? 0 : nWidth ) ) >= rParam.nSide) 
||
-                ( std::abs( nDist + ( (rParam.nMode != 
TableChgMode::FixedWidthChangeAbs && rParam.bLeft) ? 0 : nWidth )
+                    ( nDist + ( rParam.bLeft ? SwTwips(0) : nWidth ) ) >= 
rParam.nSide) ||
+                ( std::abs( nDist + ( (rParam.nMode != 
TableChgMode::FixedWidthChangeAbs && rParam.bLeft) ? SwTwips(0) : nWidth )
                             - rParam.nSide ) < COLFUZZY ))
             {
                 // This column contains the Cursor - so decrease/increase
@@ -2427,7 +2427,7 @@ static bool lcl_SetSelBoxWidth( SwTableLine* pLine, 
CR_SetBoxWidth& rParam,
                     if( bGreaterBox && TableChgMode::FixedWidthChangeProp == 
rParam.nMode )
                     {
                         // The "other Boxes" have been adapted, so change by 
this value
-                        nLowerDiff = (nDist + ( rParam.bLeft ? 0 : nWidth ) ) 
- rParam.nSide;
+                        nLowerDiff = (nDist + ( rParam.bLeft ? SwTwips(0) : 
nWidth ) ) - rParam.nSide;
                         nLowerDiff *= rParam.nDiff;
                         nLowerDiff /= rParam.nMaxSize;
                         nLowerDiff = rParam.nDiff - nLowerDiff;
@@ -2627,9 +2627,9 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, 
TableChgWidthHeightType eTyp
     // Only needed for manipulating the width
     const SwTwips nDist = ::lcl_GetDistance( &rCurrentBox, bLeft );
     SwTwips nDistStt = 0;
-    CR_SetBoxWidth aParam( eType, nRelDiff, nDist,
-                            bLeft ? nDist : rSz.GetWidth() - nDist,
-                            
const_cast<SwTableNode*>(rCurrentBox.GetSttNd()->FindTableNode()) );
+    SwTwips nMax = bLeft ? nDist : SwTwips(rSz.GetWidth()) - nDist;
+    CR_SetBoxWidth aParam(eType, nRelDiff, nDist, nMax,
+                            
const_cast<SwTableNode*>(rCurrentBox.GetSttNd()->FindTableNode()));
     bBigger = aParam.bBigger;
 
     FN_lcl_SetBoxWidth fnSelBox, fnOtherBox;
@@ -2650,7 +2650,7 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, 
TableChgWidthHeightType eTyp
                     !rSz.GetWidthPercent() )
                 {
                     // silence -Wsign-compare on Android with the static cast
-                    bRet = rSz.GetWidth() < static_cast<unsigned 
short>(USHRT_MAX) - nRelDiff;
+                    bRet = rSz.GetWidth() < sal_uInt16(USHRT_MAX) - 
sal_uInt16(nRelDiff);
                     bChgLRSpace = bLeft ? rLR.ResolveLeft({}) >= nAbsDiff
                                         : rLR.ResolveRight({}) >= nAbsDiff;
                 }
@@ -2697,7 +2697,7 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, 
TableChgWidthHeightType eTyp
                 {
                     // If the Table does not have any room to grow, we need to 
create some!
                     // silence -Wsign-compare on Android with the static cast
-                    if( aSz.GetWidth() + nRelDiff > static_cast<unsigned 
short>(USHRT_MAX) )
+                    if (SwTwips(aSz.GetWidth()) + nRelDiff > USHRT_MAX)
                     {
                         // Break down to USHRT_MAX / 2
                         CR_SetBoxWidth aTmpPara( 
TableChgWidthHeightType::ColLeft, aSz.GetWidth() / 2,
@@ -2712,16 +2712,16 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, 
TableChgWidthHeightType eTyp
 
                     if( bLeft )
                         aLR.SetLeft(
-                            
SvxIndentValue::twips(sal_uInt16(aLR.ResolveLeft({}) - nAbsDiff)));
+                            SvxIndentValue::twips(SwTwips(aLR.ResolveLeft({})) 
- nAbsDiff));
                     else
                         aLR.SetRight(
-                            
SvxIndentValue::twips(sal_uInt16(aLR.ResolveRight({}) - nAbsDiff)));
+                            
SvxIndentValue::twips(SwTwips(aLR.ResolveRight({})) - nAbsDiff));
                 }
                 else if( bLeft )
-                    
aLR.SetLeft(SvxIndentValue::twips(sal_uInt16(aLR.ResolveLeft({}) + nAbsDiff)));
+                    
aLR.SetLeft(SvxIndentValue::twips(SwTwips(aLR.ResolveLeft({})) + nAbsDiff));
                 else
                     aLR.SetRight(
-                        SvxIndentValue::twips(sal_uInt16(aLR.ResolveRight({}) 
+ nAbsDiff)));
+                        SvxIndentValue::twips(SwTwips(aLR.ResolveRight({})) + 
nAbsDiff));
 
                 if( bChgLRSpace )
                     GetFrameFormat()->SetFormatAttr( aLR );
@@ -2755,9 +2755,9 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, 
TableChgWidthHeightType eTyp
                 }
 
                 if( bBigger )
-                    aSz.SetWidth( aSz.GetWidth() + nRelDiff );
+                    aSz.SetWidth(SwTwips(aSz.GetWidth()) + nRelDiff);
                 else
-                    aSz.SetWidth( aSz.GetWidth() - nRelDiff );
+                    aSz.SetWidth(SwTwips(aSz.GetWidth()) - nRelDiff);
 
                 if (rSz.GetWidthPercent())
                     aSz.SetWidthPercent(static_cast<sal_uInt8>(
@@ -2786,7 +2786,7 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, 
TableChgWidthHeightType eTyp
                 }
             }
         }
-        else if( bLeft ? nDist != 0 : std::abs( rSz.GetWidth() - nDist ) > 
COLFUZZY )
+        else if( bLeft ? nDist != 0 : std::abs(SwTwips(rSz.GetWidth()) - 
nDist) > COLFUZZY )
         {
             bRet = true;
             if( bLeft && TableChgMode::FixedWidthChangeAbs == m_eTableChgMode )
@@ -2864,7 +2864,7 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, 
TableChgWidthHeightType eTyp
             m_eTableChgMode = eOld;
             return bRet;
         }
-        else if( bLeft ? nDist != 0 : (rSz.GetWidth() - nDist) > COLFUZZY )
+        else if( bLeft ? nDist != 0 : (SwTwips(rSz.GetWidth()) - nDist) > 
COLFUZZY )
         {
             if( bLeft && TableChgMode::FixedWidthChangeAbs == m_eTableChgMode )
                 aParam.bBigger = !bBigger;
@@ -2890,8 +2890,7 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, 
TableChgWidthHeightType eTyp
                 if( bLeft )
                     aParam.nMaxSize = aParam.nSide;
                 else
-                    aParam.nMaxSize = pLine->GetUpper()->GetFrameFormat()->
-                                    GetFrameSize().GetWidth() - aParam.nSide;
+                    aParam.nMaxSize = 
SwTwips(pLine->GetUpper()->GetFrameFormat()->GetFrameSize().GetWidth()) - 
aParam.nSide;
             }
 
             // First, see if there is enough room at all
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 59798f4f0afc..14105982389e 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -1138,10 +1138,10 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& 
rShape, SfxItemSet const&
                     if (!bInlineAnchored)
                     {
                         aVertOrient.SetPos(
-                            (pObj ? pObj->GetRelativePos().getX() : 
aVertOrient.GetPos())
+                            (pObj ? SwTwips(pObj->GetRelativePos().getX()) : 
aVertOrient.GetPos())
                             + aRect.Top());
                         aHoriOrient.SetPos(
-                            (pObj ? pObj->GetRelativePos().getY() : 
aHoriOrient.GetPos())
+                            (pObj ? SwTwips(pObj->GetRelativePos().getY()) : 
aHoriOrient.GetPos())
                             + aRect.Left());
 
                         aTextBoxSet.Put(aVertOrient);
@@ -1396,22 +1396,24 @@ bool 
SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb
                 // case 1: The textbox should be in that position where the 
shape is.
                 // case 2: The shape has negative offset so that have to be 
subtracted
                 // case 3: The shape and its parent shape also has negative 
offset, so subtract
-                aNewVOri.SetPos(
-                    ((pObj->GetRelativePos().getY()) > 0
-                         ? (pShape->GetVertOrient().GetPos() > 0
-                                ? pObj->GetRelativePos().getY()
-                                : pObj->GetRelativePos().getY() - 
pShape->GetVertOrient().GetPos())
-                         : (pShape->GetVertOrient().GetPos() > 0
-                                ? 0 // Is this can be a variation?
-                                : pObj->GetRelativePos().getY() - 
pShape->GetVertOrient().GetPos()))
-                    + aRect.Top());
+                aNewVOri.SetPos(((pObj->GetRelativePos().getY()) > 0
+                                     ? (pShape->GetVertOrient().GetPos() > 0
+                                            ? 
SwTwips(pObj->GetRelativePos().getY())
+                                            : 
SwTwips(pObj->GetRelativePos().getY())
+                                                  - 
pShape->GetVertOrient().GetPos())
+                                     : (pShape->GetVertOrient().GetPos() > 0
+                                            ? SwTwips(0) // Is this can be a 
variation?
+                                            : 
SwTwips(pObj->GetRelativePos().getY())
+                                                  - 
pShape->GetVertOrient().GetPos()))
+                                + aRect.Top());
             }
             else
             {
                 // Simple textboxes: vertical position equals to the vertical 
offset of the shape
-                aNewVOri.SetPos(
-                    ((pShape->GetVertOrient().GetPos()) > 0 ? 
pShape->GetVertOrient().GetPos() : 0)
-                    + aRect.Top());
+                aNewVOri.SetPos(((pShape->GetVertOrient().GetPos()) > 0
+                                     ? pShape->GetVertOrient().GetPos()
+                                     : SwTwips(0))
+                                + aRect.Top());
             }
 
             // Special cases when the shape is aligned to the line
@@ -1466,11 +1468,11 @@ bool 
SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb
                 aNewHOri.SetHoriOrient(text::HoriOrientation::NONE);
 
             aNewHOri.SetPos(
-                (bIsGroupObj && pObj ? pObj->GetRelativePos().getX() : 
aNewHOri.GetPos())
+                (bIsGroupObj && pObj ? SwTwips(pObj->GetRelativePos().getX()) 
: aNewHOri.GetPos())
                 + aRect.Left());
             SwFormatVertOrient aNewVOri(pShape->GetVertOrient());
             aNewVOri.SetPos(
-                (bIsGroupObj && pObj ? pObj->GetRelativePos().getY() : 
aNewVOri.GetPos())
+                (bIsGroupObj && pObj ? SwTwips(pObj->GetRelativePos().getY()) 
: aNewVOri.GetPos())
                 + aRect.Top());
 
             // Get the distance of the child shape inside its parent
diff --git a/sw/source/core/docnode/ndtbl1.cxx 
b/sw/source/core/docnode/ndtbl1.cxx
index 3d08d1f61f4f..e8c9b373c676 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -1428,9 +1428,9 @@ static sal_uInt16 lcl_CalcCellFit( const SwLayoutFrame 
*pCell )
         // pFrame does not necessarily have to be a SwTextFrame!
         const SwTwips nCalcFitToContent = pFrame->IsTextFrame() ?
                                           
const_cast<SwTextFrame*>(static_cast<const 
SwTextFrame*>(pFrame))->CalcFitToContent() :
-                                          
aRectFnSet.GetWidth(pFrame->getFramePrintArea());
+                                          
SwTwips(aRectFnSet.GetWidth(pFrame->getFramePrintArea()));
 
-        nRet = std::max( nRet, nCalcFitToContent + nAdd );
+        nRet = std::max( nRet, SwTwips(nCalcFitToContent + nAdd));
         pFrame = pFrame->GetNext();
     }
     // Surrounding border as well as left and Right Border also need to be 
respected
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index c5689473ee29..97a26d8bf28d 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1565,11 +1565,11 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, 
sal_uInt16 nDigitLevel )
                         }
                     }
 
-                    sal_Int32 nAbsPos = lBulletIndent;
+                    SwTwips nAbsPos = lBulletIndent;
                     SwTwips nSpaceSteps = nLvl
-                                            ? nLeftTextPos / nLvl
+                                            ? SwTwips(nLeftTextPos / nLvl)
                                             : lBulletIndent;
-                    for( sal_uInt8 n = 0; n < MAXLEVEL; ++n, nAbsPos = nAbsPos 
+ nSpaceSteps )
+                    for (sal_uInt8 n = 0; n < MAXLEVEL; ++n, nAbsPos = nAbsPos 
+ nSpaceSteps)
                     {
                         SwNumFormat aFormat( aRule.Get( n ) );
                         aFormat.SetBulletFont( pBullFnt );
@@ -1578,7 +1578,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 
nDigitLevel )
                         // #i93908# clear suffix for bullet lists
                         aFormat.SetListFormat(u""_ustr, u""_ustr, n);
                         aFormat.SetFirstLineOffset( lBulletFirstLineOffset );
-                        aFormat.SetAbsLSpace( nAbsPos );
+                        aFormat.SetAbsLSpace(sal_Int32(nAbsPos));
                         if( !aFormat.GetCharFormat() )
                             aFormat.SetCharFormat( pCFormat );
                         if( bRTL )
@@ -1683,7 +1683,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 
nDigitLevel )
                         aFormat.SetIncludeUpperLevels( MAXLEVEL );
                         if( bDefStep )
                             aFormat.SetAbsLSpace( nLeftTextPos +
-                                
SwNumRule::GetNumIndent(static_cast<sal_uInt8>(n-nLvl)));
+                                
SwTwips(SwNumRule::GetNumIndent(static_cast<sal_uInt8>(n-nLvl))));
                         else
                             aFormat.SetAbsLSpace( nSpaceSteps * n
                                                 + lNumberIndent );
diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index 27c38dbf44b4..c182b939836e 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -1121,7 +1121,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect,
 
         const SwTwips nBaseOfstForFly = ( pFrame->IsTextFrame() && pFly ) ?
                                         static_cast<const 
SwTextFrame*>(pFrame)->GetBaseOffsetForFly( !bWrapThrough ) :
-                                         0;
+                                        SwTwips(0);
         if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
         {
             bVertic = aRectFnSet.IsVert();
@@ -1139,7 +1139,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect,
                 case text::RelOrientation::PRINT_AREA:
                 {
                     aPos += aRectFnSet.GetPos(pFrame->getFramePrintArea());
-                    aPos.setY(aPos.getY() + nBaseOfstForFly);
+                    aPos.setY(SwTwips(aPos.getY()) + nBaseOfstForFly);
                     break;
                 }
                 case text::RelOrientation::PAGE_RIGHT:
@@ -1160,7 +1160,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect,
                 }
                 case text::RelOrientation::FRAME:
                 {
-                    aPos.setY(aPos.getY() + nBaseOfstForFly);
+                    aPos.setY(SwTwips(aPos.getY()) + nBaseOfstForFly);
                     break;
                 }
                 default: break;
@@ -1193,7 +1193,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect,
                 case text::RelOrientation::PRINT_AREA:
                     aPos.setX(pFrame->getFrameArea().Left() + 
pFrame->getFramePrintArea().Left() +
                                pFrame->getFramePrintArea().Width());
-                    aPos.setX(aPos.getX() + nBaseOfstForFly);
+                    aPos.setX(SwTwips(aPos.getX()) + nBaseOfstForFly);
                     break;
 
                 case text::RelOrientation::PAGE_LEFT:
@@ -1211,7 +1211,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect,
                     break;
 
                 case text::RelOrientation::FRAME:
-                    aPos.setX(aPos.getX() + nBaseOfstForFly);
+                    aPos.setX(SwTwips(aPos.getX()) + nBaseOfstForFly);
                     break;
                 default: break;
             }
@@ -1226,7 +1226,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect,
                     break;
                 case text::RelOrientation::PRINT_AREA:
                     aPos += pFrame->getFramePrintArea().Pos();
-                    aPos.setX(aPos.getX() + nBaseOfstForFly);
+                    aPos.setX(SwTwips(aPos.getX()) + nBaseOfstForFly);
                     break;
                 case text::RelOrientation::PAGE_RIGHT:
                     aPos.setX(pPage->getFrameArea().Left() + 
pPage->getFramePrintArea().Right());
@@ -1239,7 +1239,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect,
                     aPos.setX(pPage->getFrameArea().Left());
                     break;
                 case text::RelOrientation::FRAME:
-                    aPos.setX(aPos.getX() + nBaseOfstForFly);
+                    aPos.setX(SwTwips(aPos.getX()) + nBaseOfstForFly);
                     break;
                 default: break;
             }
diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index bf24ab7e928b..1b53e7cf6b3a 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -140,7 +140,7 @@ public:
      * calculated using percentages.
      * Frames that are anchored to this or inner Frames, are also invalidated.
      */
-    void InvaPercentLowers( SwTwips nDiff = 0 );
+    void InvaPercentLowers(SwTwips nDiff = SwTwips(0));
 
     /// Called by Format for Frames and Areas with columns
     void FormatWidthCols( const SwBorderAttrs &, const SwTwips nBorder,
diff --git a/sw/source/core/inc/txtfly.hxx b/sw/source/core/inc/txtfly.hxx
index 17113553a1f8..2e1bc8423462 100644
--- a/sw/source/core/inc/txtfly.hxx
+++ b/sw/source/core/inc/txtfly.hxx
@@ -129,7 +129,7 @@ class SwTextFly
     const SwTextFrame                * m_pMaster;
     std::unique_ptr<SwAnchoredObjList> mpAnchoredObjList;
 
-    tools::Long m_nMinBottom;
+    SwTwips m_nMinBottom;
     tools::Long m_nNextTop;  /// Stores the upper edge of the "next" frame
     SwNodeOffset m_nCurrFrameNodeIndex;
 
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index b68ec8d00c1a..a20127b71846 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -1038,7 +1038,7 @@ public:
 };
 
 
-const SwTwips WIDOW_MAGIC = (SAL_MAX_INT32 - 1)/2;
+constexpr SwTwips WIDOW_MAGIC((SAL_MAX_INT32 - 1) / 2);
 
 } // namespace sw
 
diff --git a/sw/source/core/layout/calcmove.cxx 
b/sw/source/core/layout/calcmove.cxx
index 0c71e22d5e97..02749fc1ccb2 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -2235,7 +2235,7 @@ bool SwContentFrame::WouldFit_( SwTwips nSpace,
                                  bCommonBorder &&
                                  !static_cast<const 
SwTextFrame*>(this)->IsEmpty() ) ?
                                  nUpper :
-                                 0;
+                                 SwTwips(0);
 
                 nUpper += bCommonBorder ?
                           rAttrs.GetBottomLine( *pFrame ) :
diff --git a/sw/source/core/layout/colfrm.cxx b/sw/source/core/layout/colfrm.cxx
index 1d122e8201f4..1675108df4dd 100644
--- a/sw/source/core/layout/colfrm.cxx
+++ b/sw/source/core/layout/colfrm.cxx
@@ -154,7 +154,7 @@ static bool lcl_AddColumns( SwLayoutFrame *pCont, 
sal_uInt16 nCount )
 
     bool bRet;
     SwTwips nMax = pCont->IsPageBodyFrame() ?
-                   pCont->FindPageFrame()->GetMaxFootnoteHeight() : LONG_MAX;
+                   pCont->FindPageFrame()->GetMaxFootnoteHeight() : 
SwTwips(LONG_MAX);
     if ( pNeighbourCol )
     {
         bRet = false;
@@ -363,7 +363,7 @@ void SwLayoutFrame::AdjustColumns( const SwFormatCol 
*pAttr, bool bAdjustAttribu
         {
             const SwTwips nWidth = i == (pAttr->GetNumCols() - 1) ?
                                    nAvail :
-                                   pAttr->CalcColWidth( i, sal_uInt16( 
fnRect.GetWidth(getFramePrintArea()) ) );
+                                   SwTwips(pAttr->CalcColWidth(i, 
sal_uInt16(fnRect.GetWidth(getFramePrintArea()))));
 
             const Size aColSz = fnRect.IsVert() ?
                                 Size( getFramePrintArea().Width(), nWidth ) :
diff --git a/sw/source/core/layout/flowfrm.cxx 
b/sw/source/core/layout/flowfrm.cxx
index 5e1a926b785f..e97bd98eb43a 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -653,7 +653,7 @@ bool SwFlowFrame::PasteTree( SwFrame *pStart, SwLayoutFrame 
*pParent, SwFrame *p
         else
             bRet = true;
 
-        nGrowVal = o3tl::saturating_add(nGrowVal, 
aRectFnSet.GetHeight(pFloat->getFrameArea()));
+        nGrowVal = o3tl::saturating_add(nGrowVal, 
SwTwips(aRectFnSet.GetHeight(pFloat->getFrameArea())));
         if ( pFloat->GetNext() )
             pFloat = pFloat->GetNext();
         else
@@ -1652,7 +1652,7 @@ SwTwips SwFlowFrame::CalcUpperSpace( const SwBorderAttrs 
*pAttrs,
             if( rIDSA.get(DocumentSettingId::PARA_SPACE_MAX) )
             {
                 // FIXME: apply bHalfContextualSpacing for better portability?
-                nUpper = bContextualSpacing ? 0 : nPrevLowerSpace + 
pAttrs->GetULSpace().GetUpper();
+                nUpper = bContextualSpacing ? SwTwips(0) : nPrevLowerSpace + 
SwTwips(pAttrs->GetULSpace().GetUpper());
                 SwTwips nAdd = nPrevLineSpacing;
                 // i#11859 - consideration of the line spacing
                 //      for the upper spacing of a text frame
@@ -1883,7 +1883,7 @@ SwTwips 
SwFlowFrame::GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid() cons
             GetUpperSpaceAmountConsideredForPrevFrame() +
             ( m_rThis.GetUpper()->GetFormat()->GetDoc().IsSquaredPageMode()
               ? GetUpperSpaceAmountConsideredForPageGrid_( CalcUpperSpace( 
nullptr, nullptr, false ) )
-              : 0 );
+              : SwTwips(0) );
     }
 
     return nUpperSpaceAmountConsideredForPrevFrameAndPageGrid;
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 5c5b0fa2afef..3cf5e8c3fd6a 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -216,7 +216,7 @@ SwFlyFrame::SwFlyFrame( SwFlyFrameFormat *pFormat, SwFrame* 
pSib, SwFrame *pAnch
     {
         SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
         aFrm.Width( rFrameSize.GetWidth() );
-        aFrm.Height( rFrameSize.GetHeightSizeType() == SwFrameSize::Variable ? 
MINFLY : rFrameSize.GetHeight() );
+        aFrm.Height( rFrameSize.GetHeightSizeType() == SwFrameSize::Variable ? 
MINFLY : SwTwips(rFrameSize.GetHeight()));
     }
 
     // Fixed or variable Height?
@@ -761,8 +761,8 @@ bool SwFlyFrame::FrameSizeChg( const SwFormatFrameSize 
&rFrameSize )
 
             {
                 SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
-                aFrm.Height( aFrm.Height() - nDiffHeight );
-                aFrm.Width ( aFrm.Width()  - nDiffWidth  );
+                aFrm.Height(SwTwips(aFrm.Height()) - nDiffHeight);
+                aFrm.Width(SwTwips(aFrm.Width())  - nDiffWidth);
             }
 
             // #i68520#
@@ -770,8 +770,8 @@ bool SwFlyFrame::FrameSizeChg( const SwFormatFrameSize 
&rFrameSize )
 
             {
                 SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
-                aPrt.Height( aPrt.Height() - nDiffHeight );
-                aPrt.Width ( aPrt.Width()  - nDiffWidth  );
+                aPrt.Height(SwTwips(aPrt.Height()) - nDiffHeight);
+                aPrt.Width(SwTwips(aPrt.Width())  - nDiffWidth);
             }
 
             ChgLowersProp( aOldSz );
@@ -1373,7 +1373,7 @@ void SwFlyFrame::ChgRelPos( const Point &rNewPos )
     SwFrameFormat *pFormat = GetFormat();
     const bool bVert = GetAnchorFrame()->IsVertical();
     const SwTwips nNewY = bVert ? rNewPos.X() : rNewPos.Y();
-    SwTwips nTmpY = nNewY == LONG_MAX ? 0 : nNewY;
+    SwTwips nTmpY = nNewY == LONG_MAX ? SwTwips(0) : nNewY;
     if( bVert )
         nTmpY = -nTmpY;
     SfxItemSetFixed<RES_VERT_ORIENT, RES_HORI_ORIENT> aSet( 
pFormat->GetDoc().GetAttrPool() );
@@ -1431,7 +1431,7 @@ void SwFlyFrame::ChgRelPos( const Point &rNewPos )
     if ( !IsFlyInContentFrame() )
     {
         const SwTwips nNewX = bVert ? rNewPos.Y() : rNewPos.X();
-        SwTwips nTmpX = nNewX == LONG_MAX ? 0 : nNewX;
+        SwTwips nTmpX = nNewX == LONG_MAX ? SwTwips(0) : nNewX;
         SwFormatHoriOrient aHori( pFormat->GetHoriOrient() );
         // #i34948# - handle also at-page and at-fly anchored
         // Writer fly frames
@@ -1528,7 +1528,7 @@ void SwFlyFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
 
             SwTwips nRemaining = CalcContentHeight(pAttrs, nMinHeight, nUL);
             if( IsMinHeight() && (nRemaining + nUL) < nMinHeight )
-                nRemaining = nMinHeight - nUL;
+                nRemaining = SwTwips(nMinHeight) - nUL;
             // Because the Grow/Shrink of the Flys does not directly
             // set the size - only indirectly by triggering a Format()
             // via Invalidate() - the sizes need to be set here.
@@ -1552,7 +1552,7 @@ void SwFlyFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
                 // anchor.
                 SwTwips nDeadline = GetFlyAnchorBottom(this, *pAnchor);
                 SwTwips nTop = aRectFnSet.GetTop(getFrameArea());
-                SwTwips nBottom = aRectFnSet.GetTop(getFrameArea()) + 
nRemaining;
+                SwTwips nBottom = SwTwips(aRectFnSet.GetTop(getFrameArea())) + 
nRemaining;
                 if (nBottom > nDeadline)
                 {
                     if (nDeadline > nTop)
@@ -1645,7 +1645,7 @@ void SwFlyFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
                 if ( nAutoWidth )
                 {
                     if( SwFrameSize::Minimum == rFrameSz.GetWidthSizeType() )
-                        nNewSize = std::max( nNewSize - nLR, nAutoWidth );
+                        nNewSize = std::max(SwTwips(nNewSize - nLR), 
nAutoWidth);
                     else
                         nNewSize = nAutoWidth;
                 }
@@ -2143,20 +2143,20 @@ void SwFlyFrame::MakeContentPos( const SwBorderAttrs 
&rAttrs )
             if( nAdjust == SDRTEXTVERTADJUST_CENTER )
             {
                 if( aRectFnSet.IsVertL2R() )
-                    aNewContentPos.setX(aNewContentPos.getX() + nDiff/2);
+                    aNewContentPos.setX(SwTwips(aNewContentPos.getX()) + nDiff 
/ 2);
                 else if( aRectFnSet.IsVert() )
-                    aNewContentPos.setX(aNewContentPos.getX() - nDiff/2);
+                    aNewContentPos.setX(SwTwips(aNewContentPos.getX()) - nDiff 
/ 2);
                 else
-                    aNewContentPos.setY(aNewContentPos.getY() + nDiff/2);
+                    aNewContentPos.setY(SwTwips(aNewContentPos.getY()) + nDiff 
/ 2);
             }
             else if( nAdjust == SDRTEXTVERTADJUST_BOTTOM )
             {
                 if( aRectFnSet.IsVertL2R() )
-                    aNewContentPos.setX(aNewContentPos.getX() + nDiff);
+                    aNewContentPos.setX(SwTwips(aNewContentPos.getX()) + 
nDiff);
                 else if( aRectFnSet.IsVert() )
-                    aNewContentPos.setX(aNewContentPos.getX() - nDiff);
+                    aNewContentPos.setX(SwTwips(aNewContentPos.getX()) - 
nDiff);
                 else
-                    aNewContentPos.setY(aNewContentPos.getY() + nDiff);
+                    aNewContentPos.setY(SwTwips(aNewContentPos.getY()) + 
nDiff);
             }
         }
     }
@@ -2299,8 +2299,8 @@ SwTwips SwFlyFrame::Grow_(SwTwips nDist, 
SwResizeLimitReason& reason, bool bTst)
 
     SwRectFnSet aRectFnSet(this);
     SwTwips nSize = aRectFnSet.GetHeight(getFrameArea());
-    if( nSize > 0 && nDist > ( LONG_MAX - nSize ) )
-        nDist = LONG_MAX - nSize;
+    if (nSize > 0 && nDist > (SwTwips(LONG_MAX) - nSize))
+        nDist = SwTwips(LONG_MAX) - nSize;
 
     if ( nDist <= 0 )
     {
@@ -2451,7 +2451,7 @@ SwTwips SwFlyFrame::Shrink_( SwTwips nDist, bool bTst )
             const SwFormatFrameSize& rFormatSize = GetFormat()->GetFrameSize();
             SwTwips nFormatHeight = aRectFnSet.IsVert() ? 
rFormatSize.GetWidth() : rFormatSize.GetHeight();
 
-            nVal = std::min( nDist, nHeight - nFormatHeight );
+            nVal = std::min(nDist, SwTwips(nHeight - nFormatHeight));
         }
 
         if ( nVal <= 0 )
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 67081a263cb1..88b10c09e3e1 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -67,11 +67,11 @@ SwTwips lcl_GetTopForObjPos(const SwContentFrame* pCnt, 
const bool bVert, const
         if ( bVertL2R )
             aResult += 
pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
         else
-            aResult += pCnt->getFrameArea().Width() - 
pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
+            aResult += SwTwips(pCnt->getFrameArea().Width()) - 
pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
         return aResult;
     }
     else
-        return pCnt->getFrameArea().Top() + 
pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
+        return SwTwips(pCnt->getFrameArea().Top()) + 
pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
 }
 
 }
@@ -662,12 +662,12 @@ static const SwFrame * lcl_CalcDownDist( SwDistance &rRet,
             if( bVert )
             {
                 if ( bVertL2R )
-                    rRet.m_nMain = rPt.X() - nTopForObjPos;
+                    rRet.m_nMain = SwTwips(rPt.X()) - nTopForObjPos;
                 else
                     rRet.m_nMain = nTopForObjPos - rPt.X();
             }
             else
-                rRet.m_nMain = rPt.Y() - nTopForObjPos;
+                rRet.m_nMain = SwTwips(rPt.Y()) - nTopForObjPos;
             return pCnt;
         }
         else if ( rPt.Y() <= pUp->getFrameArea().Top() )
@@ -691,7 +691,7 @@ static const SwFrame * lcl_CalcDownDist( SwDistance &rRet,
                 if( bVert )
                 {
                     if ( bVertL2R )
-                        rRet.m_nMain = rPt.X() - nTopForObjPos;
+                        rRet.m_nMain = SwTwips(rPt.X()) - nTopForObjPos;
                     else
                         rRet.m_nMain = nTopForObjPos - rPt.X();
                 }
@@ -906,7 +906,7 @@ static const SwFrame * lcl_CalcDownDist( SwDistance &rRet,
                 if ( pLay->getFrameArea().Contains( rPt ) )
                 {
                     SwTwips nDiff = pLay->IsVertical() ? ( pLay->IsVertLR() ? 
( rPt.X() - nFrameTop ) : ( nFrameTop - rPt.X() ) )
-                                                       : ( rPt.Y() - nFrameTop 
);
+                                                       : ( SwTwips(rPt.Y()) - 
nFrameTop );
                     if( bSct || pSect )
                         rRet.m_nSub += nDiff;
                     else
@@ -1300,7 +1300,7 @@ void SwFlyAtContentFrame::SetAbsPos( const Point &rNew )
             nY -= pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
         }
         else
-            nY = rNew.Y() - pCnt->getFrameArea().Top() - 
pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
+            nY = SwTwips(rNew.Y() - pCnt->getFrameArea().Top()) - 
pCnt->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
     }
     else
     {
@@ -1361,13 +1361,13 @@ void SwFlyAtContentFrame::SetAbsPos( const Point &rNew )
         if( bVert )
         {
             if ( bVertL2R )
-                nY = rNew.X() - nTopForObjPos;
+                nY = SwTwips(rNew.X()) - nTopForObjPos;
             else
                 nY = nTopForObjPos - rNew.X();
         }
         else
         {
-            nY = rNew.Y() - nTopForObjPos;
+            nY = SwTwips(rNew.Y()) - nTopForObjPos;
         }
     }
 
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index 491ce87e82fc..d2f033b2b4d5 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -268,7 +268,7 @@ SwTwips FootnoteSeparatorHeight(SwDoc& rDoc, 
SwPageFootnoteInfo const& rInf)
     }
 
     // Writer style: calculate from the page style.
-    return rInf.GetTopDist() + rInf.GetBottomDist() + rInf.GetLineWidth();
+    return SwTwips(rInf.GetTopDist()) + SwTwips(rInf.GetBottomDist()) + 
SwTwips(rInf.GetLineWidth());
 }
 
 } // namespace sw
diff --git a/sw/source/core/layout/hffrm.cxx b/sw/source/core/layout/hffrm.cxx
index f773e8393911..79a1763e70b2 100644
--- a/sw/source/core/layout/hffrm.cxx
+++ b/sw/source/core/layout/hffrm.cxx
@@ -166,9 +166,9 @@ void SwHeadFootFrame::FormatPrt(SwTwips & nUL, const 
SwBorderAttrs * pAttrs)
 
         /* calculate real vertical space between frame and print area */
         if (IsHeaderFrame())
-            nUL = pAttrs->CalcTop() + nSpace;
+            nUL = SwTwips(pAttrs->CalcTop()) + nSpace;
         else
-            nUL = pAttrs->CalcBottom() + nSpace;
+            nUL = SwTwips(pAttrs->CalcBottom()) + nSpace;
 
         /* set print area */
         SwTwips nLR = pAttrs->CalcLeft( this ) + pAttrs->CalcRight( this );
@@ -185,13 +185,13 @@ void SwHeadFootFrame::FormatPrt(SwTwips & nUL, const 
SwBorderAttrs * pAttrs)
             aPrt.Top(nSpace);
         }
 
-        aPrt.Width(getFrameArea().Width() - nLR);
+        aPrt.Width(SwTwips(getFrameArea().Width()) - nLR);
 
         SwTwips nNewHeight;
 
         if (nUL < getFrameArea().Height())
         {
-            nNewHeight = getFrameArea().Height() - nUL;
+            nNewHeight = SwTwips(getFrameArea().Height()) - nUL;
         }
         else
         {
@@ -210,8 +210,8 @@ void SwHeadFootFrame::FormatPrt(SwTwips & nUL, const 
SwBorderAttrs * pAttrs)
         // Set sizes - the sizes are given by the surrounding Frame, just
         // subtract the borders.
         SwTwips nLR = pAttrs->CalcLeft( this ) + pAttrs->CalcRight( this );
-        aPrt.Width ( getFrameArea().Width() - nLR );
-        aPrt.Height( getFrameArea().Height()- nUL );
+        aPrt.Width (SwTwips(getFrameArea().Width())  - nLR);
+        aPrt.Height(SwTwips(getFrameArea().Height()) - nUL);
     }
 
     setFramePrintAreaValid(true);
@@ -384,7 +384,7 @@ void SwHeadFootFrame::FormatSize(SwTwips nUL, const 
SwBorderAttrs * pAttrs)
                         aFrm.Bottom( nDeadLine );
 
                         SwFrameAreaDefinition::FramePrintAreaWriteAccess 
aPrt(*this);
-                        aPrt.Height( getFrameArea().Height() - nBorder );
+                        aPrt.Height(SwTwips(getFrameArea().Height()) - nBorder 
);
                     }
                 }
 
@@ -591,8 +591,8 @@ SwTwips SwHeadFootFrame::ShrinkFrame( SwTwips nDist, bool 
bTst, bool bInfo )
 
             /* minimal height of print area */
             SwTwips nMinPrtHeight = nMinHeight
-                - pAttrs->CalcTop()
-                - pAttrs->CalcBottom();
+                - SwTwips(pAttrs->CalcTop())
+                - SwTwips(pAttrs->CalcBottom());
 
             if (nMinPrtHeight < 0)
                 nMinPrtHeight = 0;
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index de8e0055e592..1c7b452bc580 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -1426,7 +1426,7 @@ bool SwLayAction::FormatLayout( OutputDevice 
*pRenderContext, SwLayoutFrame *pLa
 
                     // right
                     aSpaceToNextPage = aPageRect;
-                    aSpaceToNextPage.Right( aSpaceToNextPage.Right() + 
nHalfDocBorder );
+                    aSpaceToNextPage.Right(SwTwips(aSpaceToNextPage.Right()) + 
nHalfDocBorder );
                     aSpaceToNextPage.Left( pLay->getFrameArea().Right() );
                     if(!aSpaceToNextPage.IsEmpty())
                         m_pImp->GetShell().AddPaintRect( aSpaceToNextPage );
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index 070b8b8ccf32..2acf86700c2b 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -205,8 +205,9 @@ SwPageFrame::SwPageFrame( SwFrameFormat *pFormat, SwFrame* 
pSib, SwPageDesc *pPg
     }
     else
         m_bHasGrid = false;
-    SetMaxFootnoteHeight( pPgDsc->GetFootnoteInfo().GetHeight() ?
-                     pPgDsc->GetFootnoteInfo().GetHeight() : LONG_MAX );
+    SetMaxFootnoteHeight(
+        pPgDsc->GetFootnoteInfo().GetHeight() ?
+        pPgDsc->GetFootnoteInfo().GetHeight() : SwTwips(LONG_MAX));
     mnFrameType = SwFrameType::Page;
     m_bInvalidLayout = m_bInvalidContent = m_bInvalidSpelling = 
m_bInvalidSmartTags = m_bInvalidAutoCmplWrds = m_bInvalidWordCount = true;
     m_bInvalidFlyLayout = m_bInvalidFlyContent = m_bInvalidFlyInCnt = 
m_bFootnotePage = m_bEndNotePage = false;
@@ -1885,7 +1886,8 @@ void SwRootFrame::ImplCalcBrowseWidth()
 
     mbBrowseWidthValid = true;
     SwViewShell *pSh = getRootFrame()->GetCurrShell();
-    mnBrowseWidth = (!comphelper::LibreOfficeKit::isActive() && pSh)? MINLAY + 
2 * pSh->GetOut()-> PixelToLogic( pSh->GetBrowseBorder() ).Width(): 
MIN_BROWSE_WIDTH;
+    mnBrowseWidth = (!comphelper::LibreOfficeKit::isActive() && pSh) ?
+                        MINLAY + 2 * pSh->GetOut()-> PixelToLogic( 
pSh->GetBrowseBorder() ).Width() : SwTwips(MIN_BROWSE_WIDTH);
 
     do
     {
@@ -2401,12 +2403,10 @@ void SwRootFrame::CheckViewLayout( const SwViewOption* 
pViewOpt, const SwRect* p
                 if ( mbBookMode )
                     pFormatPage = &pPageToAdjust->GetFormatPage();
 
-                const SwTwips nCurrentPageWidth = 
pFormatPage->getFrameArea().Width() + (pFormatPage->IsEmptyPage() ? 0 : 
nSidebarWidth);
+                const SwTwips nCurrentPageWidth = 
pFormatPage->getFrameArea().Width() + (pFormatPage->IsEmptyPage() ? SwTwips(0) 
: nSidebarWidth);
                 const Point aOldPagePos = pPageToAdjust->getFrameArea().Pos();
                 const bool bLeftSidebar = pPageToAdjust->SidebarPosition() == 
sw::sidebarwindows::SidebarPosition::LEFT;
-                const SwTwips nLeftPageAddOffset = bLeftSidebar ?
-                                                   nSidebarWidth :
-                                                   0;
+                const SwTwips nLeftPageAddOffset = bLeftSidebar ? 
nSidebarWidth : SwTwips(0);
 
                 Point aNewPagePos( nBorder + nX, nBorder + nSumRowHeight );
                 Point aNewPagePosWithLeftOffset( nBorder + nX + 
nLeftPageAddOffset, nBorder + nSumRowHeight );
diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index 5d4b7eb173a5..c87975076a81 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -3088,9 +3088,9 @@ SwTwips SwSectionFrame::CalcUndersize() const
 
 SwTwips SwSectionFrame::Undersize()
 {
-    const auto nRet = CalcUndersize();
+    const SwTwips nRet = CalcUndersize();
     m_bUndersized = (nRet > 0);
-    return nRet <= 0 ? 0 : nRet;
+    return nRet <= 0 ? SwTwips(0) : nRet;
 }
 
 void SwSectionFrame::CalcFootnoteContent()
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index a08ce1af68e2..4f95b42e86bd 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3775,7 +3775,7 @@ void SwTabFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
                         //      otherwise non negative wished right indent is 
hold.
                         nRightSpacing = nRightLine +
                                         ( ( (nWishRight+nLeftOffset) < 0 ) ?
-                                            (nWishRight+nLeftOffset) :
+                                            SwTwips(nWishRight + nLeftOffset) :
                                             std::max( SwTwips(0), nWishRight ) 
);
                     }
                 }
@@ -3806,7 +3806,7 @@ void SwTabFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
                         //      otherwise non negative wished left indent is 
hold.
                         nLeftSpacing = nLeftLine +
                                        ( ( (nWishLeft+nRightOffset) < 0 ) ?
-                                           (nWishLeft+nRightOffset) :
+                                           SwTwips(nWishLeft + nRightOffset) :
                                            std::max( SwTwips(0), nWishLeft ) );
                     }
                 }
@@ -3874,7 +3874,7 @@ void SwTabFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
                     }
                     // OD 10.03.2003 #i9040# - consider right and left line 
attribute.
                     const SwTwips nWishRight =
-                            nMax - (nLeftSpacing-pAttrs->CalcLeftLine()) - 
nWishedTableWidth;
+                            nMax - (nLeftSpacing - 
SwTwips(pAttrs->CalcLeftLine())) - nWishedTableWidth;
                     nRightSpacing = nRightLine +
                                     ( (nRightOffset > 0) ?
                                       std::max( nWishRight, 
SwTwips(nRightOffset) ) :
@@ -3971,7 +3971,7 @@ SwTwips SwTabFrame::GrowFrame(SwTwips nDist, 
SwResizeLimitReason& reason, bool b
 
             if ( IsRestrictTableGrowth() )
             {
-                nTmp = std::min( tools::Long(nDist), nReal + nTmp );
+                nTmp = std::min(SwTwips(nDist), nReal + nTmp);
                 nDist = nTmp < 0 ? 0 : nTmp;
             }
         }
@@ -5494,7 +5494,7 @@ void SwRowFrame::AdjustCells( const SwTwips nHeight, 
const bool bHeight )
                 // Use new height for the current row:
                 nSumRowHeight += pToAdjustRow == this ?
                                  nHeight :
-                                 
aRectFnSet.GetHeight(pToAdjustRow->getFrameArea());
+                                 
SwTwips(aRectFnSet.GetHeight(pToAdjustRow->getFrameArea()));
 
                 if ( nRowSpan-- == 1 )
                     break;
@@ -5641,8 +5641,8 @@ SwTwips SwRowFrame::ShrinkFrame( SwTwips nDist, bool 
bTst, bool bInfo )
         const SwFormatFrameSize &rSz = pMod->GetFrameSize();
         SwTwips nMinHeight = 0;
         if (rSz.GetHeightSizeType() == SwFrameSize::Minimum)
-            nMinHeight = std::max(rSz.GetHeight() - 
lcl_calcHeightOfRowBeforeThisFrame(*this),
-                                  tools::Long(0));
+            nMinHeight = std::max(SwTwips(rSz.GetHeight()) - 
lcl_calcHeightOfRowBeforeThisFrame(*this),
+                                  SwTwips(0));
 
         // Only necessary to calculate minimal row height if height
         // of pRow is at least nMinHeight. Otherwise nMinHeight is the
@@ -5677,7 +5677,7 @@ SwTwips SwRowFrame::ShrinkFrame( SwTwips nDist, bool 
bTst, bool bInfo )
         }
 
         SwLayoutFrame* pFrame = GetUpper();
-        SwTwips nTmp = pFrame ? pFrame->Shrink(nReal, bTst) : 0;
+        SwTwips nTmp = pFrame ? pFrame->Shrink(nReal, bTst) : SwTwips(0);
         if ( !bShrinkAnyway && !GetNext() && nTmp != nReal )
         {
             //The last one gets the leftover in the upper and therefore takes
@@ -6076,7 +6076,7 @@ void SwCellFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorder
     // #i26945#
     tools::Long nRemaining = GetTabBox()->getRowSpan() >= 1 ?
                       ::lcl_CalcMinCellHeight( this, 
pTab->IsConsiderObjsForMinCellHeight(), pAttrs ) :
-                      0;
+                      SwTwips(0);
     if ( !isFrameAreaSizeValid() )
     {
         setFrameAreaSizeValid(true);
@@ -6864,7 +6864,7 @@ static SwTwips lcl_CalcHeightOfFirstContentLine( const 
SwRowFrame& rSourceLine )
         pCurrSourceCell = static_cast<const 
SwCellFrame*>(pCurrSourceCell->GetNext());
     }
 
-    return ( LONG_MAX == nHeight ) ? 0 : nHeight;
+    return ( LONG_MAX == nHeight ) ? SwTwips(0) : nHeight;
 }
 
 /// Function to calculate height of first text row
@@ -6973,8 +6973,8 @@ SwTwips SwTabFrame::CalcHeightOfFirstContentLine() const
             SwTwips nMinRowHeight = 0;
             if (rSz.GetHeightSizeType() == SwFrameSize::Minimum)
             {
-                nMinRowHeight = std::max(rSz.GetHeight() - 
lcl_calcHeightOfRowBeforeThisFrame(*pFirstRow),
-                                         tools::Long(0));
+                nMinRowHeight = std::max(SwTwips(rSz.GetHeight()) - 
lcl_calcHeightOfRowBeforeThisFrame(*pFirstRow),
+                                         SwTwips(0));
             }
 
             nTmpHeight += std::max( nHeightOfFirstContentLine, nMinRowHeight );
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 554f5ac37c31..c0c55c5ae2ce 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -2817,7 +2817,7 @@ SwTwips SwLayoutFrame::GrowFrame(SwTwips nDist, 
SwResizeLimitReason& reason, boo
                             }
                         }
                     }
-                    nGrow = pToGrow ? pToGrow->Grow(nReal, reason, bTst, 
bInfo) : 0;
+                    nGrow = pToGrow ? pToGrow->Grow(nReal, reason, bTst, 
bInfo) : SwTwips(0);
                 }
 
                 if( SwNeighbourAdjust::GrowAdjust == nAdjust && nGrow < nReal )
@@ -2826,7 +2826,7 @@ SwTwips SwLayoutFrame::GrowFrame(SwTwips nDist, 
SwResizeLimitReason& reason, boo
                 if ( IsFootnoteFrame() && (nGrow != nReal) && GetNext() )
                 {
                     //Footnotes can replace their successor.
-                    SwTwips nSpace = bTst ? 0 : -nDist;
+                    SwTwips nSpace = bTst ? SwTwips(0) : -nDist;
                     if (const SwFrame *pFrame = GetUpper()->Lower())
                     {
                         do
@@ -3089,7 +3089,7 @@ SwTwips SwLayoutFrame::ShrinkFrame( SwTwips nDist, bool 
bTst, bool bInfo )
                 }
             }
         }
-        nReal = pToShrink ? pToShrink->Shrink( nShrink, bTst, bInfo ) : 0;
+        nReal = pToShrink ? pToShrink->Shrink( nShrink, bTst, bInfo ) : 
SwTwips(0);
         if( ( SwNeighbourAdjust::GrowAdjust == nAdjust || 
SwNeighbourAdjust::AdjustGrow == nAdjust )
             && nReal < nShrink )
             AdjustNeighbourhood( nReal - nShrink );
diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx 
b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
index 0e6b702cc6db..8b02f2c0979e 100644
--- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
@@ -226,7 +226,8 @@ void SwAnchoredObjectPosition::GetVertAlignmentValues(
             _rVertOrientFrame.IsTextFrame()
             ? static_cast<const SwTextFrame&>(_rVertOrientFrame).
                         GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid()
-            : 0;
+            : SwTwips(0);
+
     switch ( _eRelOrient )
     {
         case text::RelOrientation::FRAME:
@@ -415,7 +416,7 @@ SwTwips SwAnchoredObjectPosition::GetVertRelPos(
         {
             nRelPosY += nAlignAreaHeight
                         - (nObjHeight
-                           + (aRectFnSet.IsVert()
+                           + SwTwips(aRectFnSet.IsVert()
                                   ? (aRectFnSet.IsVertL2R() ? 
_rLRSpacing.ResolveRight({})
                                                             : 
_rLRSpacing.ResolveLeft({}))
                                   : _rULSpacing.GetLower()));
@@ -804,7 +805,7 @@ void SwAnchoredObjectPosition::GetHoriAlignmentValues( 
const SwFrame&  _rHoriOri
             bool bIgnoreFlysAnchoredAtFrame = !bWrapThrough;
             nOffset = _rHoriOrientFrame.IsTextFrame() ?
                    static_cast<const 
SwTextFrame&>(_rHoriOrientFrame).GetBaseOffsetForFly( 
bIgnoreFlysAnchoredAtFrame ) :
-                   0;
+                   SwTwips(0);
             break;
         }
     }
@@ -938,7 +939,7 @@ SwTwips SwAnchoredObjectPosition::CalcRelPosX(
         nRelPosX
             += nWidth
                - (nObjWidth
-                  + (aRectFnSet.IsVert() ? _rULSpacing.GetLower() : 
_rLRSpacing.ResolveRight({})));
+                  + SwTwips(aRectFnSet.IsVert() ? _rULSpacing.GetLower() : 
_rLRSpacing.ResolveRight({})));
     else
         nRelPosX += aRectFnSet.IsVert() ? _rULSpacing.GetUpper() : 
_rLRSpacing.ResolveLeft({});
 
@@ -1053,11 +1054,11 @@ SwTwips 
SwAnchoredObjectPosition::AdjustHoriRelPosForDrawAside(
                 {
                     if ( _eHoriOrient == text::HoriOrientation::LEFT )
                     {
-                        SwTwips nTmp = nOtherBot + 1 + _rULSpacing.GetUpper() -
+                        SwTwips nTmp = nOtherBot + SwTwips(1) + 
SwTwips(_rULSpacing.GetUpper()) -
                                        rAnchorTextFrame.getFrameArea().Top();
                         if ( nTmp > nAdjustedRelPosX &&
                              rAnchorTextFrame.getFrameArea().Top() + nTmp +
-                             aObjBoundRect.Height() + _rULSpacing.GetLower()
+                             aObjBoundRect.Height() + 
SwTwips(_rULSpacing.GetLower())
                              <= pObjPage->getFrameArea().Height() + 
pObjPage->getFrameArea().Top() )
                         {
                             nAdjustedRelPosX = nTmp;
@@ -1065,7 +1066,7 @@ SwTwips 
SwAnchoredObjectPosition::AdjustHoriRelPosForDrawAside(
                     }
                     else if ( _eHoriOrient == text::HoriOrientation::RIGHT )
                     {
-                        SwTwips nTmp = nOtherTop - 1 - _rULSpacing.GetLower() -
+                        SwTwips nTmp = nOtherTop - SwTwips(1) - 
SwTwips(_rULSpacing.GetLower()) -
                                        aObjBoundRect.Height() -
                                        rAnchorTextFrame.getFrameArea().Top();
                         if ( nTmp < nAdjustedRelPosX &&
@@ -1090,7 +1091,7 @@ SwTwips 
SwAnchoredObjectPosition::AdjustHoriRelPosForDrawAside(
                 {
                     if ( _eHoriOrient == text::HoriOrientation::LEFT )
                     {
-                        SwTwips nTmp = nOtherRight + 1 + 
_rLRSpacing.ResolveLeft({})
+                        SwTwips nTmp = nOtherRight + SwTwips(1) + 
SwTwips(_rLRSpacing.ResolveLeft({}))
                                        - 
rAnchorTextFrame.getFrameArea().Left();
                         if (nTmp > nAdjustedRelPosX
                             && rAnchorTextFrame.getFrameArea().Left() + nTmp + 
aObjBoundRect.Width()
@@ -1103,7 +1104,7 @@ SwTwips 
SwAnchoredObjectPosition::AdjustHoriRelPosForDrawAside(
                     }
                     else if ( _eHoriOrient == text::HoriOrientation::RIGHT )
                     {
-                        SwTwips nTmp = nOtherLeft - 1 - 
_rLRSpacing.ResolveRight({})
+                        SwTwips nTmp = nOtherLeft - SwTwips(1) - 
SwTwips(_rLRSpacing.ResolveRight({}))
                                        - aObjBoundRect.Width()
                                        - 
rAnchorTextFrame.getFrameArea().Left();
                         if (nTmp < nAdjustedRelPosX
diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx 
b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
index e938d9937078..44f385bd47cc 100644
--- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
@@ -1315,7 +1315,7 @@ void SwToContentAnchoredObjectPosition::CalcOverlap(const 
SwTextFrame* pAnchorFr
 
         // Already formatted, overlaps: resolve the conflict by shifting 
ourselves down.
         SwTwips nYDiff = pAnchoredObj->GetObjRect().Bottom() - 
GetAnchoredObj().GetObjRect().Top();
-        rRelPos.setY(rRelPos.getY() + nYDiff + 1);
+        rRelPos.setY(rRelPos.getY() + nYDiff + SwTwips(1));
         GetAnchoredObj().SetObjTop(nTopOfAnch + rRelPos.Y());
 
         // Store our offset that avoids the overlap. If this is a shape of a 
textbox, then the frame
diff --git 
a/sw/source/core/objectpositioning/tolayoutanchoredobjectposition.cxx 
b/sw/source/core/objectpositioning/tolayoutanchoredobjectposition.cxx
index 04d94185d755..87c41418590d 100644
--- a/sw/source/core/objectpositioning/tolayoutanchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/tolayoutanchoredobjectposition.cxx
@@ -175,7 +175,8 @@ void SwToLayoutAnchoredObjectPosition::CalcPosition()
         else if (text::HoriOrientation::RIGHT == eHoriOrient)
             nRelPosX
                 = nWidth
-                  - (nObjWidth + (aRectFnSet.IsVert() ? rUL.GetLower() : 
rLR.ResolveRight({})));
+                  - (nObjWidth + (aRectFnSet.IsVert() ?
+                                    SwTwips(rUL.GetLower()) : 
SwTwips(rLR.ResolveRight({}))));
         else
             nRelPosX = aRectFnSet.IsVert() ? rUL.GetUpper() : 
rLR.ResolveLeft({});
         nRelPosX += nOffset;
diff --git a/sw/source/core/table/swnewtable.cxx 
b/sw/source/core/table/swnewtable.cxx
index 3a94085227bd..fe894e1c64ae 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -1372,7 +1372,7 @@ static sal_uInt16 lcl_CalculateSplitLineHeights( 
SwSplitLines &rCurr, SwSplitLin
     }
     for( const auto& rSplit : aBoxes )
     {
-        SwTwips nBase = rSplit.first <= nFirst ? 0 :
+        SwTwips nBase = rSplit.first <= nFirst ? SwTwips(0) :
                         pLines[ rSplit.first - nFirst - 1 ];
         SwTwips nDiff = pLines[ rSplit.second - nFirst ] - nBase;
         for( sal_uInt16 i = 1; i < nCnt; ++i )
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 0d737127b621..ac2fd736cd95 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1007,7 +1007,7 @@ static void lcl_AdjustWidthsInLine( SwTableLine* pLine, 
ChangeList& rOldNew,
         SwTwips nNewWidth = nWidth - nRest;
         nRest = 0;
         nBorder += nWidth;
-        if( pCurr != rOldNew.end() && nBorder + nColFuzzy >= pCurr->first )
+        if( pCurr != rOldNew.end() && nBorder + SwTwips(nColFuzzy) >= 
pCurr->first )
         {
             nBorder -= nColFuzzy;
             while( pCurr != rOldNew.end() && nBorder > pCurr->first )
@@ -1015,7 +1015,7 @@ static void lcl_AdjustWidthsInLine( SwTableLine* pLine, 
ChangeList& rOldNew,
             if( pCurr != rOldNew.end() )
             {
                 nBorder += nColFuzzy;
-                if( nBorder + nColFuzzy >= pCurr->first )
+                if( nBorder + SwTwips(nColFuzzy) >= pCurr->first )
                 {
                     if( pCurr->second == pCurr->first )
                         nRest = 0;
@@ -1030,8 +1030,8 @@ static void lcl_AdjustWidthsInLine( SwTableLine* pLine, 
ChangeList& rOldNew,
         {
             if( nNewWidth < 0 )
             {
-                nRest += 1 - nNewWidth;
-                nNewWidth = 1;
+                nRest += SwTwips(1) - nNewWidth;
+                nNewWidth = SwTwips(1);
             }
             SwFormatFrameSize aFormatFrameSize( 
pBox->GetFrameFormat()->GetFrameSize() );
             aFormatFrameSize.SetWidth( nNewWidth );
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index 28a5db42b606..627be3953229 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -516,7 +516,7 @@ bool SwTextFrame::GetTopOfLine( SwTwips& _onTopOfLine,
 }
 
 // Minimum distance of non-empty lines is a little less than 2 cm
-#define FILL_MIN_DIST 1100
+constexpr SwTwips FILL_MIN_DIST(1100);
 
 struct SwFillData
 {
@@ -1460,7 +1460,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
         if( nDiff > 0 )
         {
             nDiff /= nDist;
-            rFill.Fill().nParaCnt = o3tl::narrowing<sal_uInt16>(nDiff + 1);
+            rFill.Fill().nParaCnt = o3tl::narrowing<sal_uInt16>(nDiff + 
SwTwips(1));
             rFill.nLineWidth = 0;
             rFill.bInner = false;
             rFill.bEmpty = true;
@@ -1478,7 +1478,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
             const SvxRightMarginItem& rRightMargin(pSet->GetRightMargin());
 
             SwRect &rRect = rFill.Fill().aCursor;
-            rRect.Top( rFill.Bottom() + (nDiff+1) * nDist - nLineHeight );
+            rRect.Top( rFill.Bottom() + (nDiff + SwTwips(1)) * nDist - 
nLineHeight );
             if( nFirst && nDiff > -1 )
                 rRect.Top( rRect.Top() + nFirst );
             rRect.Height( nLineHeight );
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index fca5696bfb07..83f639066887 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -1497,7 +1497,7 @@ bool SwTextFrame::FormatLine( SwTextFormatter &rLine, 
const bool bPrev )
                 rRepaint.Top( nOldTop );
             if( !rLine.IsUnclipped() || nOldBottom > rRepaint.Bottom() )
             {
-                rRepaint.Bottom( nOldBottom - 1 );
+                rRepaint.Bottom(nOldBottom - SwTwips(1));
                 rLine.SetUnclipped( true );
             }
         }
@@ -1509,7 +1509,7 @@ bool SwTextFrame::FormatLine( SwTextFormatter &rLine, 
const bool bPrev )
                 rRepaint.Top( nTmpTop );
             if( !rLine.IsUnclipped() || nTmpBottom > rRepaint.Bottom() )
             {
-                rRepaint.Bottom( nTmpBottom - 1 );
+                rRepaint.Bottom(nTmpBottom - SwTwips(1));
                 rLine.SetUnclipped( true );
             }
         }
@@ -1517,7 +1517,7 @@ bool SwTextFrame::FormatLine( SwTextFormatter &rLine, 
const bool bPrev )
         {
             if( !rLine.IsUnclipped() || nBottom > rRepaint.Bottom() )
             {
-                rRepaint.Bottom( nBottom - 1 );
+                rRepaint.Bottom(nBottom - SwTwips(1));
                 rLine.SetUnclipped( false );
             }
         }
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index 1088f5e949a3..ef91391ac3d0 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -827,7 +827,7 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, 
SwTextFormatInfo &rInf,
         {
             const TextFrameIndex nHangingLen = m_nBreakPos - m_nCutPos;
             SwPositiveSize aTmpSize = rInf.GetTextSize( &rSI, m_nCutPos, 
nHangingLen );
-            aTmpSize.Width(aTmpSize.Width() + nLeftRightBorderSpace);
+            aTmpSize.Width(aTmpSize.Width() + SwTwips(nLeftRightBorderSpace));
             OSL_ENSURE( !m_pHanging, "A hanging portion is hanging around" );
             m_pHanging.reset( new SwHangingPortion( std::move(aTmpSize) ) );
             m_pHanging->SetLen( nHangingLen );
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 567ab6ab8425..d3ac4d732715 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -770,7 +770,7 @@ void SwTextPaintInfo::DrawText_( const OUString &rText, 
const SwLinePortion &rPo
         aDrawInf.SetPos( aPoint );
         aDrawInf.SetSize( aSize );
         aDrawInf.SetAscent( rPor.GetAscent() );
-        aDrawInf.SetKern( bKern ? rPor.Width() : 0 );
+        aDrawInf.SetKern(bKern ? rPor.Width() : SwTwips(0));
         aDrawInf.SetWrong( bTmpWrong ? m_pWrongList : nullptr );
         aDrawInf.SetGrammarCheck( bTmpGrammarCheck ? m_pGrammarCheckList : 
nullptr );
         aDrawInf.SetSmartTags( bTmpSmart ? m_pSmartTags : nullptr );
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index 64bd6e7dd582..907b02457465 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -35,7 +35,7 @@
 #include "portab.hxx"
 #include <memory>
 
-#define MIN_TAB_WIDTH 60
+constexpr SwTwips MIN_TAB_WIDTH(60);
 
 using namespace ::com::sun::star;
 
@@ -488,7 +488,7 @@ SwTwips SwTextAdjuster::CalcKanaAdj( SwLineLayout* pCurrent 
)
                 nRest = ! bNoCompression &&
                         ( pPos->Width() > MIN_TAB_WIDTH ) ?
                         pPos->Width() - MIN_TAB_WIDTH :
-                        0;
+                        SwTwips(0);
 
                 // for simplifying the handling of left, right ... tabs,
                 // we do expand portions, which are lying behind
@@ -596,7 +596,7 @@ SwMarginPortion *SwTextAdjuster::CalcRightMargin( 
SwLineLayout *pCurrent,
             pLast = pFly;
             if( pFly->GetFix() > nPrtWidth )
                 pFly->Width( ( pFly->GetFix() - nPrtWidth) + pFly->Width() + 
1);
-            nPrtWidth += pFly->Width() + 1;
+            nPrtWidth += pFly->Width() + SwTwips(1);
             aCurrRect.Left( nLeftMar + nPrtWidth );
             pFly = CalcFlyPortion( nRealWidth, aCurrRect );
         }
@@ -861,7 +861,7 @@ void SwTextAdjuster::CalcDropRepaint()
         rRepaint.Top( Y() );
     for( sal_Int32 i = 1; i < GetDropLines(); ++i )
         NextLine();
-    const SwTwips nBottom = Y() + GetLineHeight() - 1;
+    const SwTwips nBottom = Y() + GetLineHeight() - SwTwips(1);
     if( rRepaint.Bottom() < nBottom )
         rRepaint.Bottom( nBottom );
 }
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index 1a8c500ef92f..88074f96c40d 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -100,7 +100,7 @@ static void lcl_GetCharRectInsideField( SwTextSizeInfo& 
rInf, SwRect& rOrig,
             const_cast<SwLinePortion*>(pPor)->SetLen(TextFrameIndex(nLen - 1));
             const SwTwips nX1 = pPor->GetLen() ?
                                 pPor->GetTextSize( rInf ).Width() :
-                                0;
+                                SwTwips(0);
 
             SwTwips nX2 = 0;
             if ( rCMS.m_bRealWidth )
@@ -112,16 +112,14 @@ static void lcl_GetCharRectInsideField( SwTextSizeInfo& 
rInf, SwRect& rOrig,
             const_cast<SwLinePortion*>(pPor)->SetLen( nOldLen );
 
             rOrig.Pos().AdjustX(nX1 );
-            rOrig.Width( ( nX2 > nX1 ) ?
-                         ( nX2 - nX1 ) :
-                           1 );
+            rOrig.Width((nX2 > nX1) ? nX2 - nX1 : SwTwips(1));
         }
     }
     else
     {
         // special cases: no common fields, e.g., graphic number portion,
         // FlyInCntPortions, Notes
-        rOrig.Width( rCMS.m_bRealWidth && rPor.Width() ? rPor.Width() : 1 );
+        rOrig.Width(rCMS.m_bRealWidth && rPor.Width() ? rPor.Width() : 
SwTwips(1));
     }
 }
 
@@ -239,7 +237,7 @@ void SwTextMargin::CtorInitTextMargin( SwTextFrame 
*pNewFrame, SwTextSizeInfo *p
     {
         mnLeft = m_pFrame->getFramePrintArea().Left() + 
m_pFrame->getFrameArea().Left();
         if( mnLeft >= mnRight )   // e.g. with large paragraph indentations in 
slim table columns
-            mnRight = mnLeft + 1; // einen goennen wir uns immer
+            mnRight = mnLeft + SwTwips(1); // einen goennen wir uns immer
     }
 
     if( m_pFrame->IsFollow() && m_pFrame->GetOffset() )
@@ -495,7 +493,7 @@ void SwTextCursor::GetEndCharRect(SwRect* pOrig, const 
TextFrameIndex nOfst,
     pOrig->Pos( GetTopLeft() );
     pOrig->SSize( aCharSize );
     pOrig->Pos().AdjustX(nLast );
-    const SwTwips nTmpRight = Right() - 1;
+    const SwTwips nTmpRight = Right() - SwTwips(1);
     if( pOrig->Left() > nTmpRight )
         pOrig->Pos().setX( nTmpRight );
 
@@ -809,9 +807,8 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, 
TextFrameIndex const nOfst,
 
                         if ( bChgHeight )
                         {
-                            m_pCurr->Height( pOldCurr->Height() - nRubyHeight 
);
-                            m_pCurr->SetRealHeight( pOldCurr->GetRealHeight() -
-                                                  nRubyHeight );
+                            m_pCurr->Height(pOldCurr->Height() - 
SwTwips(nRubyHeight));
+                            m_pCurr->SetRealHeight(pOldCurr->GetRealHeight() - 
SwTwips(nRubyHeight));
                         }
 
                         SwLayoutModeModifier aLayoutModeModifier( 
*GetInfo().GetOut() );
@@ -1399,7 +1396,7 @@ TextFrameIndex 
SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con
     SwTwips x = rPoint.X();
     const SwTwips nLeftMargin  = GetLineStart();
     SwTwips nRightMargin = GetLineEnd() +
-        ( GetCurr()->IsHanging() ? GetCurr()->GetHangingMargin() : 0 );
+        (GetCurr()->IsHanging() ? GetCurr()->GetHangingMargin() : SwTwips(0));
     if( nRightMargin == nLeftMargin )
         nRightMargin += 30;
 
@@ -1469,7 +1466,7 @@ TextFrameIndex 
SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con
         nWidth30 = 0;
     else
         nWidth30 = ! nWidth && pPor->GetLen() && pPor->InToxRefOrFieldGrp() ?
-                     30 :
+                     SwTwips(30) :
                      nWidth;
 
     while (ConsiderNextPortionForCursorOffset(pPor, nWidth30, nX))
@@ -1512,8 +1509,7 @@ TextFrameIndex 
SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con
             nWidth30 = 0;
         else
             nWidth30 = ! nWidth && pPor->GetLen() && 
pPor->InToxRefOrFieldGrp() ?
-                         30 :
-                         nWidth;
+                         SwTwips(30) : nWidth;
         if( !pPor->IsFlyPortion() && !pPor->IsMarginPortion() )
             bLastHyph = pPor->InHyphGrp();
     }
@@ -1541,7 +1537,7 @@ TextFrameIndex 
SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con
 
     if( bFieldInfo && ( nWidth30 < nX || bRightOver || bLeftOver ||
         ( pPor->InNumberGrp() && !pPor->IsFootnoteNumPortion() ) ||
-        ( pPor->IsMarginPortion() && nWidth > nX + 30 ) ) )
+        ( pPor->IsMarginPortion() && nWidth > nX + SwTwips(30) ) ) )
         pCMS->m_bPosCorr = true;
 
     // #i27615#
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 2424ddbcc992..f4c38e632a5e 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -257,7 +257,7 @@ SwLinePortion *SwTextFormatter::Underflow( SwTextFormatInfo 
&rInf )
 
     // line width is adjusted, so that pPor does not fit to current
     // line anymore
-    rInf.Width( rInf.X() + (pPor->Width() ? pPor->Width() - 1 : 0) );
+    rInf.Width( rInf.X() + (pPor->Width() ? pPor->Width() - SwTwips(1) : 
SwTwips(0)) );
     rInf.SetLen( pPor->GetLen() );
     rInf.SetFull( false );
     if( pFly )
@@ -617,7 +617,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf 
)
             if ( nOfst )
             {
                 const sal_uLong i = ( nOfst > 0 ) ?
-                                ( ( nOfst - 1 ) / nGridWidth + 1 ) :
+                                ( (nOfst - SwTwips(1)) / nGridWidth + 1 ) :
                                 0;
                 const SwTwips nKernWidth = i * nGridWidth - nOfst;
                 const SwTwips nRestWidth = rInf.Width() - rInf.X();
@@ -760,7 +760,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf 
)
                 }
 
                 const SwTwips i = nSumWidth ?
-                                 ( nSumWidth - 1 ) / nGridWidth + 1 :
+                                 ( nSumWidth - SwTwips(1) ) / nGridWidth + 1 :
                                  0;
                 const SwTwips nTmpWidth = i * nGridWidth;
                 const SwTwips nKernWidth = std::min(nTmpWidth - nSumWidth, 
nRestWidth);
@@ -936,7 +936,7 @@ void SwTextFormatter::CalcAscent( SwTextFormatInfo &rInf, 
SwLinePortion *pPor )
     if( pPor->InTextGrp() && bCalc )
     {
         pPor->SetAscent(pPor->GetAscent() +
-            rInf.GetFont()->GetTopBorderSpace());
+            SwTwips(rInf.GetFont()->GetTopBorderSpace()));
         pPor->Height(pPor->Height() +
             rInf.GetFont()->GetTopBorderSpace() +
             rInf.GetFont()->GetBottomBorderSpace() );
@@ -1454,7 +1454,7 @@ SwTextPortion *SwTextFormatter::NewTextPortion( 
SwTextFormatInfo &rInf )
     CalcAscent( rInf, pPor );
 
     const SwFont* pTmpFnt = rInf.GetFont();
-    auto nCharWidthGuess = std::min(pTmpFnt->GetHeight(), pPor->GetAscent()) / 
8;
+    auto nCharWidthGuess = std::min(SwTwips(pTmpFnt->GetHeight()), 
pPor->GetAscent()) / 8;
     if (!nCharWidthGuess)
         nCharWidthGuess = 1;
     auto nExpect = rInf.GetIdx() + TextFrameIndex(rInf.GetLineWidth() / 
nCharWidthGuess);
@@ -2104,8 +2104,8 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex 
const nStartPos)
         if( GetInfo().IsStop() )
         {
             m_pCurr->SetLen(TextFrameIndex(0));
-            m_pCurr->Height( GetFrameRstHeight() + 1, false );
-            m_pCurr->SetRealHeight( GetFrameRstHeight() + 1 );
+            m_pCurr->Height(GetFrameRstHeight() + SwTwips(1), false);
+            m_pCurr->SetRealHeight(GetFrameRstHeight() + SwTwips(1));
 
             // Don't oversize the line in case of split flys, so we don't try 
to move the anchor
             // of a precede fly forward, next to its follow.
@@ -2298,7 +2298,7 @@ void SwTextFormatter::CalcRealHeight( bool bNewLine )
                     // require this and it seems harmless to emulate.
                     if (pSpace->GetLineHeight() == 0)
                     {
-                        nLineHeight = m_pCurr->Height() + nRubyHeight;
+                        nLineHeight = m_pCurr->Height() + SwTwips(nRubyHeight);
                     }
 
                     if (nLineHeight < pSpace->GetLineHeight())
@@ -2317,9 +2317,9 @@ void SwTextFormatter::CalcRealHeight( bool bNewLine )
         }
 
         const SwTwips nAsc = m_pCurr->GetAscent() +
-                      ( bRubyTop ?
-                       ( nLineHeight - m_pCurr->Height() + nRubyHeight ) / 2 :
-                       ( nLineHeight - m_pCurr->Height() - nRubyHeight ) / 2 );
+                      (bRubyTop ?
+                       (nLineHeight - m_pCurr->Height() + 
SwTwips(nRubyHeight)) / 2 :
+                       (nLineHeight - m_pCurr->Height() - 
SwTwips(nRubyHeight)) / 2);
 
         m_pCurr->Height( nLineHeight, false );
         m_pCurr->SetAscent( nAsc );
@@ -2536,7 +2536,7 @@ SwTwips SwTextFormatter::CalcBottomLine() const
             if( bRepaint )
             {
                 const_cast<SwRepaint&>(GetInfo().GetParaPortion()
-                    ->GetRepaint()).Bottom( nRet-1 );
+                    ->GetRepaint()).Bottom(nRet - SwTwips(1));
                 const_cast<SwTextFormatInfo&>(GetInfo()).SetPaintOfst( 0 );
             }
         }
@@ -2917,7 +2917,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo 
&rInf )
     }
 
     const tools::Long nLeftMar = GetLeftMargin();
-    const tools::Long nLeftMin = (rInf.X() || GetDropLeft()) ? nLeftMar : 
GetLeftMin();
+    const tools::Long nLeftMin = (rInf.X() || GetDropLeft()) ? 
SwTwips(nLeftMar) : GetLeftMin();
 
     SwRect aLine( rInf.X() + nLeftMin, nTop, rInf.RealWidth() - rInf.X()
                   + nLeftMar - nLeftMin , nHeight );
@@ -3157,7 +3157,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo 
&rInf )
 
     const SwTwips i = nTmpWidth / nGridWidth + 1;
 
-    const SwTwips nNewWidth = ( i - 1 ) * nGridWidth - nOfst;
+    const SwTwips nNewWidth = ( i - SwTwips(1) ) * nGridWidth - nOfst;
     if ( nNewWidth > 0 )
         rInf.Width( nNewWidth );
     else
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 293bca3a9747..590649ec2690 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -389,13 +389,13 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, 
SwSaveClip &rClip,
         }
 
         // We calculate a separate font for underlining.
-        CheckSpecialUnderline( pPor, bAdjustBaseLine ? nOldY : 0 );
+        CheckSpecialUnderline( pPor, bAdjustBaseLine ? nOldY : SwTwips(0));
         SwUnderlineFont* pUnderLineFnt = GetInfo().GetUnderFnt();
         if ( pUnderLineFnt )
         {
             const Point aTmpPoint( GetInfo().X(),
                                    bAdjustBaseLine ?
-                                   pUnderLineFnt->GetPos().Y() :
+                                   SwTwips(pUnderLineFnt->GetPos().Y()) :
                                    nLineBaseLine );
             pUnderLineFnt->SetPos( aTmpPoint );
         }
@@ -580,8 +580,8 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, 
SwSaveClip &rClip,
                 // to show the terminating pilcrow at the correct position, 
and not before that
                 ( ( !( pEndTempl->GetNextPortion() && 
pEndTempl->GetNextPortion()->IsHolePortion() ) &&
                     std::abs( m_pCurr->Width() - 
m_pCurr->GetFirstPortion()->Width() ) <= 1 && m_pCurr->ExtraShrunkWidth() > 0 )
-                        ? m_pCurr->ExtraShrunkWidth() - m_pCurr->Width() : 0 ) 
+
-                    ( GetCurr()->IsHanging() ? GetCurr()->GetHangingMargin() : 
0 ) );
+                        ? m_pCurr->ExtraShrunkWidth() - m_pCurr->Width() : 
SwTwips(0) ) +
+                    ( GetCurr()->IsHanging() ? GetCurr()->GetHangingMargin() : 
SwTwips(0) ) );
             aEnd.Paint( GetInfo() );
             GetInfo().Y( nOldY );
         }
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index 84df842f3af5..0d1967d9e6f1 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -265,11 +265,11 @@ SwTwips SwTextCursor::AdjustBaseLine( const SwLineLayout& 
rLine,
                 // centered inside the whole line.
 
                 //for text refactor
-                const sal_uInt16 nLineNet =  rLine.Height() - nRubyHeight;
+                const sal_uInt16 nLineNet =  rLine.Height() - 
SwTwips(nRubyHeight);
                 //const sal_uInt16 nLineNet = ( nPorHeight > nGridWidth ) ?
                  //                           rLine.Height() - nRubyHeight :
                  //                           nGridWidth;
-                nOfst += ( nLineNet - nPorHeight ) / 2;
+                nOfst += (SwTwips(nLineNet) - nPorHeight) / 2;
                 if ( bRubyTop )
                     nOfst += nRubyHeight;
             }
diff --git a/sw/source/core/text/itrtxt.hxx b/sw/source/core/text/itrtxt.hxx
index eb3a9a859854..442e1cf94521 100644
--- a/sw/source/core/text/itrtxt.hxx
+++ b/sw/source/core/text/itrtxt.hxx
@@ -188,7 +188,7 @@ public:
     bool IsLastBlock() const { return m_bLastBlock; }
     bool IsLastCenter() const { return m_bLastCenter; }
     SvxAdjust GetAdjust() const { return mnAdjust; }
-    SwTwips GetLineWidth() const { return Right() - GetLeftMargin() + 1; }
+    SwTwips GetLineWidth() const { return Right() - GetLeftMargin() + 
SwTwips(1); }
     SwTwips GetLeftMin() const { return std::min(mnFirst, mnLeft); }
     bool HasNegFirst() const { return mnFirst < mnLeft; }
 
@@ -332,7 +332,7 @@ inline SwTwips SwTextMargin::GetLeftMargin() const
 
 inline SwTwips SwTextMargin::Left() const
 {
-    return (mnDropLines >= m_nLineNr && 1 != m_nLineNr) ? mnFirst + mnDropLeft 
: mnLeft;
+    return (mnDropLines >= m_nLineNr && 1 != m_nLineNr) ? SwTwips(mnFirst + 
mnDropLeft) : mnLeft;
 }
 
 
diff --git a/sw/source/core/text/porexp.cxx b/sw/source/core/text/porexp.cxx
index afdf71da21c0..54932c32ab80 100644
--- a/sw/source/core/text/porexp.cxx
+++ b/sw/source/core/text/porexp.cxx
@@ -292,7 +292,7 @@ void SwPostItsPortion::Paint( const SwTextPaintInfo &rInf ) 
const
 SwTwips SwPostItsPortion::GetViewWidth(const SwTextSizeInfo& rInf) const
 {
     // Unbelievable: PostIts are always visible
-    return rInf.OnWin() ? SwViewOption::GetPostItsWidth( rInf.GetOut() ) : 0;
+    return rInf.OnWin() ? SwViewOption::GetPostItsWidth( rInf.GetOut() ) : 
SwTwips(0);
 }
 
 bool SwPostItsPortion::Format( SwTextFormatInfo &rInf )
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index 286e23a85186..91981208fb7f 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -617,11 +617,11 @@ bool SwNumberPortion::Format( SwTextFormatInfo &rInf )
                  
rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::NO_GAP_AFTER_NOTE_NUMBER)))
             {
                 nDiff = rInf.Left()
-                        + rInf.GetTextFrame()
+                        + SwTwips(rInf.GetTextFrame()
                               ->GetTextNodeForParaProps()
                               ->GetSwAttrSet()
                               .GetFirstLineIndent()
-                              .ResolveTextFirstLineOffset({})
+                              .ResolveTextFirstLineOffset({}))
                         - rInf.First() + rInf.ForcedLeftMargin();
             }
             else
@@ -791,7 +791,7 @@ void SwNumberPortion::Paint( const SwTextPaintInfo &rInf ) 
const
                 rInf.GetUnderFnt()->SetPos( aNewPos );
             }
 
-            pThis->Width( nOldWidth - nSpaceOffs + 12 );
+            pThis->Width(nOldWidth - nSpaceOffs + SwTwips(12));
             {
                 SwTextSlot aDiffText( &aInf, this, true, false, u"  "_ustr );
                 aInf.DrawText( *this, aInf.GetLen(), true );
@@ -815,7 +815,7 @@ SwBulletPortion::SwBulletPortion( const sal_UCS4 cBullet,
     SetWhichPor( PortionType::Bullet );
 }
 
-#define GRFNUM_SECURE 10
+constexpr SwTwips GRFNUM_SECURE(10);
 
 SwGrfNumPortion::SwGrfNumPortion(
         const OUString& rGraphicFollowedBy,
@@ -897,7 +897,7 @@ bool SwGrfNumPortion::Format( SwTextFormatInfo &rInf )
     const bool bFull = rInf.Width() < rInf.X() + Width();
     const bool bFly = rInf.GetFly() ||
         ( rInf.GetLast() && rInf.GetLast()->IsFlyPortion() );
-    SetAscent( GetRelPos() > 0 ? GetRelPos() : 0 );
+    SetAscent(GetRelPos() > 0 ? GetRelPos() : SwTwips(0));
     if( GetAscent() > Height() )
         Height( GetAscent() );
 
@@ -915,7 +915,7 @@ bool SwGrfNumPortion::Format( SwTextFormatInfo &rInf )
     rInf.SetNumDone( true );
 //    long nDiff = rInf.Left() - rInf.First() + rInf.ForcedLeftMargin();
     tools::Long nDiff = mbLabelAlignmentPosAndSpaceModeActive
-                 ? 0
+                 ? SwTwips(0)
                  : rInf.Left() - rInf.First() + rInf.ForcedLeftMargin();
     // The TextPortion should at least always start on the
     // left margin
@@ -988,7 +988,7 @@ void SwGrfNumPortion::Paint( const SwTextPaintInfo &rInf ) 
const
 
     if( m_bReplace )
     {
-        const tools::Long nTmpH = GetNextPortion() ? 
GetNextPortion()->GetAscent() : 120;
+        const tools::Long nTmpH = GetNextPortion() ? 
GetNextPortion()->GetAscent() : SwTwips(120);
         aSize = Size( nTmpH, nTmpH );
         aPos.setY( rInf.Y() - nTmpH );
     }
@@ -1324,7 +1324,7 @@ bool SwCombinedPortion::Format( SwTextFormatInfo &rInf )
     // the portion grows. This looks better, if there's a character background.
     if( GetAscent() < nMainAscent )
     {
-        Height( Height() + nMainAscent - GetAscent() );
+        Height( Height() + SwTwips(nMainAscent) - GetAscent() );
         SetAscent( nMainAscent );
     }
     if( Height() < nMainAscent + nMainDescent )
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index b0202f7fecca..d5a9d6e39796 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -123,7 +123,7 @@ bool SwFlyCntPortion::Format( SwTextFormatInfo &rInf )
                                     ( pLastPor->IsKernPortion() ||
                                       pLastPor->IsErgoSumPortion() ) ) ?
                                pLastPor->Width() :
-                               0;
+                               SwTwips(0);
 
         if( nLeft == rInf.X() && ! rInf.GetFly() )
         {
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index d4495587d5f1..584b1a06f7d3 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -374,7 +374,7 @@ void SwDoubleLinePortion::PaintBracket( SwTextPaintInfo 
&rInf,
         return;
     if( !bOpen )
         rInf.X( rInf.X() + Width() - PostWidth() +
-            ( nSpaceAdd > 0 ? CalcSpacing( nSpaceAdd, rInf ) : 0 ) );
+            ( nSpaceAdd > 0 ? CalcSpacing( nSpaceAdd, rInf ) : SwTwips(0)));
 
     SwBlankPortion aBlank( cCh, true );
     aBlank.SetAscent( m_pBracket->nAscent );
@@ -1689,9 +1689,9 @@ void SwTextPainter::PaintMultiPortion( const SwRect 
&rPaint,
                 const sal_uInt16 nAdjustment = ( pLay->Height() - 
pPor->Height() ) / 2 +
                                             pPor->GetAscent();
                 if( rMulti.IsRevers() )
-                    GetInfo().X( nOfst - nAdjustment );
+                    GetInfo().X(nOfst - SwTwips(nAdjustment));
                 else
-                    GetInfo().X( nOfst + nAdjustment );
+                    GetInfo().X(nOfst + SwTwips(nAdjustment));
             }
             else
             {
@@ -1720,7 +1720,7 @@ void SwTextPainter::PaintMultiPortion( const SwRect 
&rPaint,
         }
         else if ( rMulti.IsRuby() && rMulti.OnRight() && GetInfo().IsRuby() )
         {
-            SwTwips nLineDiff = std::max(( rMulti.GetRoot().Height() - 
pPor->Width() ) / 2, static_cast<SwTwips>(0) );
+            SwTwips nLineDiff = std::max(SwTwips((rMulti.GetRoot().Height() - 
pPor->Width()) / 2), SwTwips(0));
             GetInfo().Y( nOfst + nLineDiff );
             // Draw the ruby text on top of the preserved space.
             GetInfo().X( GetInfo().X() - pPor->Height() );
@@ -2080,7 +2080,7 @@ bool SwTextFormatter::BuildMultiPortion( SwTextFormatInfo 
&rInf,
             pUpperFrame = pPage->FindBodyCont();
 
         nMaxWidth = pUpperFrame ?
-                    ( rInf.GetTextFrame()->IsVertical() ?
+                    SwTwips( rInf.GetTextFrame()->IsVertical() ?
                       pUpperFrame->getFramePrintArea().Width() :
                       pUpperFrame->getFramePrintArea().Height() ) :
                     std::numeric_limits<SwTwips>::max();
@@ -2095,7 +2095,7 @@ bool SwTextFormatter::BuildMultiPortion( SwTextFormatInfo 
&rInf,
     m_pMulti = &rMulti;
     SwLineLayout *pOldCurr = m_pCurr;
     TextFrameIndex const nOldStart = GetStart();
-    SwTwips nMinWidth = nTmpX + 1;
+    SwTwips nMinWidth = nTmpX + SwTwips(1);
     SwTwips nActWidth = nMaxWidth;
     const TextFrameIndex nStartIdx = rInf.GetIdx();
     TextFrameIndex nMultiLen = rMulti.GetLen();
@@ -2296,7 +2296,7 @@ bool SwTextFormatter::BuildMultiPortion( SwTextFormatInfo 
&rInf,
             // our guess for multiportion width was too small,
             // we set min to act
             nMinWidth = nActWidth;
-            nActWidth = ( 3 * nMaxWidth + nMinWidth + 3 ) / 4;
+            nActWidth = ( 3 * nMaxWidth + nMinWidth + SwTwips(3) ) / 4;
             if ( nActWidth == nMaxWidth && rInf.GetLineStart() == 
rInf.GetIdx() )
             // we have too less space, we must allow break cuts
             // ( the first multi flag is considered during 
TextPortion::Format_() )
@@ -2310,8 +2310,8 @@ bool SwTextFormatter::BuildMultiPortion( SwTextFormatInfo 
&rInf,
             // Setting this to the portion width ( = rMulti.Width() )
             // can make GetTextBreak inside SwTextGuess::Guess return too small
             // values. Therefore we add some extra twips.
-            if( nActWidth > nTmpX + rMulti.Width() + 6 )
-                nActWidth = nTmpX + rMulti.Width() + 6;
+            if (nActWidth > nTmpX + rMulti.Width() + SwTwips(6))
+                nActWidth = nTmpX + rMulti.Width() + SwTwips(6);
             nMaxWidth = nActWidth;
             nActWidth = ( 3 * nMaxWidth + nMinWidth + 3 ) / 4;
             if( nActWidth >= nMaxWidth )
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index 5d5146e2f8c1..540cb66d9e0f 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -722,7 +722,7 @@ bool SwBookmarkPortion::DoPaint(SwTextPaintInfo const& 
rTextPaintInfo,
     // use also the external leading (line gap) of the portion, but don't use
     // 100% of it because i can't figure out how to baseline align that
     assert(aSize.Height() != 0);
-    auto const nFactor = aSize.Height() > 0 ? (Height() * 95) / aSize.Height() 
: Height();
+    auto const nFactor = aSize.Height() > 0 ? SwTwips((Height() * 95) / 
aSize.Height()) : Height();
     rFont.SetProportion(nFactor);
     rFont.SetWeight(WEIGHT_THIN, rFont.GetActual());
     rFont.SetColor(rTextPaintInfo.GetOpt().GetFieldShadingsColor());
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index 4e15eeab005f..9596ceaf59cc 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -976,8 +976,8 @@ SwAnchoredObjList& SwTextFly::InitAnchoredObjList()
                     const SwFormatVertOrient &rTmpFormat = 
pObjFormat->GetVertOrient();
                     if( text::VertOrientation::BOTTOM != 
rTmpFormat.GetVertOrient() )
                         m_nMinBottom = ( aRectFnSet.IsVert() && m_nMinBottom ) 
?
-                                     std::min( m_nMinBottom, aBound.Left() ) :
-                                     std::max( m_nMinBottom, 
aRectFnSet.GetBottom(aBound) );
+                                     std::min( m_nMinBottom, 
SwTwips(aBound.Left())) :
+                                     std::max( m_nMinBottom, 
SwTwips(aRectFnSet.GetBottom(aBound)));
                 }
 
                 m_bOn = true;
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 30b49c04cdb2..860406167eeb 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -3416,7 +3416,7 @@ SwTestFormat::SwTestFormat( SwTextFrame* pTextFrame, 
const SwFrame* pPre, SwTwip
         {
             aRectFnSet.SetPosY(
                 aFrm,
-                aRectFnSet.GetBottom(pFrame->GetPrev()->getFrameArea()) - ( 
aRectFnSet.IsVert() ? nMaxHeight + 1 : 0 ) );
+                aRectFnSet.GetBottom(pFrame->GetPrev()->getFrameArea()) - ( 
aRectFnSet.IsVert() ? nMaxHeight + 1 : SwTwips(0)));
         }
     }
 
@@ -3437,7 +3437,7 @@ SwTestFormat::SwTestFormat( SwTextFrame* pTextFrame, 
const SwFrame* pPre, SwTwip
 
     {
         SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*pFrame);
-        aRectFnSet.SetHeight( aPrt, std::max( tools::Long(0) , 
aRectFnSet.GetHeight(pFrame->getFrameArea()) - aRectFnSet.GetTop(aPrt) - nLower 
) );
+        aRectFnSet.SetHeight( aPrt, std::max(SwTwips(0) , 
aRectFnSet.GetHeight(pFrame->getFrameArea()) - aRectFnSet.GetTop(aPrt) - 
nLower) );
         aRectFnSet.SetWidth( aPrt, aRectFnSet.GetWidth(pFrame->getFrameArea()) 
- ( rAttrs.CalcLeft( pFrame ) + rAttrs.CalcRight( pFrame ) ) );
     }
 
@@ -3538,7 +3538,7 @@ bool SwTextFrame::WouldFit(SwTwips &rMaxHeight, bool 
&bSplit, bool bTst, bool bM
     // force a MoveFwd
     if (IsWidow() || (aRectFnSet.IsVert()
                         ? (0 == getFrameArea().Left())
-                        : (sw::WIDOW_MAGIC - 20000 < getFrameArea().Bottom())))
+                        : (sw::WIDOW_MAGIC - SwTwips(20000) < 
getFrameArea().Bottom())))
     {
         SetWidow(false);
         if ( GetFollow() )
@@ -3615,7 +3615,7 @@ SwTwips SwTextFrame::GetParHeight() const
 
     // TODO: Refactor and improve code
     const SwLineLayout* pLineLayout = GetPara();
-    SwTwips nHeight = pLineLayout ? pLineLayout->GetRealHeight() : 0;
+    SwTwips nHeight = pLineLayout ? pLineLayout->GetRealHeight() : SwTwips(0);
 
     // Is this paragraph scrolled? Our height until now is at least
     // one line height too low then
@@ -3703,7 +3703,7 @@ SwTwips SwTextFrame::CalcFitToContent()
     SwHookOut aHook( aInf );
 
     // i#54031 - assure minimum of MINLAY twips.
-    const SwTwips nMax = std::max( SwTwips(MINLAY), aLine.CalcFitToContent_() 
+ 1 );
+    const SwTwips nMax = std::max(SwTwips(MINLAY), aLine.CalcFitToContent_() + 
SwTwips(1));
 
     {
         SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
@@ -4316,7 +4316,7 @@ void SwTextFrame::CalcBaseOfstForFly()
 
 SwTwips SwTextFrame::GetBaseVertOffsetForFly(bool 
bIgnoreFlysAnchoredAtThisFrame) const
 {
-    return bIgnoreFlysAnchoredAtThisFrame ? 0 : mnFlyAnchorVertOfstNoWrap;
+    return bIgnoreFlysAnchoredAtThisFrame ? SwTwips(0) : 
mnFlyAnchorVertOfstNoWrap;
 }
 
 /**
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 8a6c1613a774..8c2aba3be88a 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -290,7 +290,7 @@ SwTwips SwTextFrame::GetFootnoteLine( const SwTextFootnote 
*pFootnote ) const
         // the frame is currently locked. We return the previous value.
         return pThis->mnFootnoteLine > 0 ?
                pThis->mnFootnoteLine :
-               IsVertical() ? getFrameArea().Left() : getFrameArea().Bottom();
+               SwTwips(IsVertical() ? getFrameArea().Left() : 
getFrameArea().Bottom());
     }
 
     SwTwips nRet;
@@ -332,7 +332,7 @@ SwTwips SwTextFrame::GetFootnoteFrameHeight_() const
     SwSwapIfSwapped swap(const_cast<SwTextFrame *>(this));
 
     SwTwips nHeight = pRef->IsInFootnoteConnect() ?
-                            1 : pRef->GetFootnoteLine( 
pFootnoteFrame->GetAttr() );
+                            SwTwips(1) : pRef->GetFootnoteLine( 
pFootnoteFrame->GetAttr() );
     if( nHeight )
     {
         // As odd as it may seem: the first Footnote on the page may not touch 
the
diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx
index 22502f918a6d..c6d18d5ae0b9 100644
--- a/sw/source/core/text/txttab.cxx
+++ b/sw/source/core/text/txttab.cxx
@@ -93,9 +93,9 @@ SwTabPortion *SwTextFormatter::NewTabPortion( 
SwTextFormatInfo &rInf, bool bAuto
         // #i91133#
         const SwTwips nTabLeft = bRTL
                                  ? m_pFrame->getFrameArea().Right() -
-                                   ( bTabsRelativeToIndent ? GetTabLeft() : 0 )
-e 
... etc. - the rest is truncated

Reply via email to