[Libreoffice-commits] core.git: Branch 'private/tvajngerl/staging' - 2 commits - include/o3tl sw/inc sw/qa sw/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Aug 2 06:18:10 UTC 2021
include/o3tl/unit_conversion.hxx | 6 +++++
sw/inc/swtypes.hxx | 25 ++++++++++++++----------
sw/qa/extras/tiledrendering/tiledrendering.cxx | 3 +-
sw/source/core/doc/DocumentStylePoolManager.cxx | 6 ++---
sw/source/core/doc/lineinfo.cxx | 2 -
sw/source/core/edit/edattr.cxx | 9 ++++++--
sw/source/core/frmedt/feshview.cxx | 10 +++++----
sw/source/core/layout/calcmove.cxx | 4 ++-
sw/source/core/unocore/unoframe.cxx | 5 ++--
sw/source/core/unocore/unostyle.cxx | 3 +-
sw/source/filter/html/htmlnum.hxx | 4 +--
sw/source/filter/html/htmlplug.cxx | 9 ++++----
sw/source/filter/html/htmltab.cxx | 4 ++-
sw/source/filter/html/svxcss1.hxx | 3 +-
sw/source/filter/html/swhtml.hxx | 8 +++----
sw/source/filter/html/wrthtml.hxx | 2 -
sw/source/ui/chrdlg/pardlg.cxx | 3 +-
sw/source/ui/dbui/mmlayoutpage.cxx | 10 ++++-----
sw/source/ui/fmtui/tmpdlg.cxx | 3 +-
sw/source/ui/misc/pggrid.cxx | 4 ++-
sw/source/uibase/dochdl/swdtflvr.cxx | 15 +++++++++-----
sw/source/uibase/inc/frmmgr.hxx | 4 +--
sw/source/uibase/ribbar/conform.cxx | 11 ++++++----
sw/source/uibase/ribbar/drawbase.cxx | 10 +++++----
sw/source/uibase/shells/textsh.cxx | 8 ++++---
sw/source/uibase/wrtsh/wrtsh1.cxx | 3 +-
26 files changed, 109 insertions(+), 65 deletions(-)
New commits:
commit 504313fde478a2ff8f7268584670721da7971080
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Jul 25 21:17:24 2021 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Mon Aug 2 15:17:15 2021 +0900
sw: preserve the value in original units to minimize conv. error
Not really an big issue but let's preserve the values in original
units as long as we can without conversion so that the error is
minimal.
Change-Id: I96981eaecac74b591803dbc93e487c1d106ab23c
diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx
index b2c41bd31c94..3cd7740fd849 100644
--- a/sw/inc/swtypes.hxx
+++ b/sw/inc/swtypes.hxx
@@ -69,7 +69,8 @@ constexpr SwTwips DEF_GUTTER_WIDTH = o3tl::convertTwip(tools::Long(3), o3tl::Len
constexpr SwTwips MIN_BORDER_DIST = 28; // ~0.5mm
// Minimal document border: 20mm.
-constexpr SwTwips lMinBorder = o3tl::convertTwip(tools::Long(20), o3tl::Length::mm); // ~20mm
+constexpr tools::Long lMinBorderInMm = tools::Long(20);
+constexpr SwTwips lMinBorder = o3tl::convertTwip(lMinBorderInMm, o3tl::Length::mm);
static_assert(lMinBorder == 1134); // this was the old constant for 20mm, making sure o3tl::convert returns the same value
// Margin left and above document.
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 5d8581f423a9..647983a4beca 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -134,10 +134,12 @@
#include <memory>
-constexpr tools::Long constOleWidth = 11905 - 2 * lMinBorder;
-constexpr tools::Long constOleHeight = o3tl::convertTwip(tools::Long(3), o3tl::Length::cm);
+/* default (A4 format) width of 210mm - 2 * border size (border on both sides) */
+constexpr tools::Long constOleWidthInMm = 210 - 2 * lMinBorderInMm;
-#define OLESIZE constOleWidth, constOleHeight
+constexpr Size constOleSizeTwip(
+ o3tl::convertTwip(constOleWidthInMm, o3tl::Length::cm),
+ o3tl::convertTwip(tools::Long(3), o3tl::Length::cm));
constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_DRAWMODEL = 0x00000001;
constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_HTML = 0x00000002;
@@ -343,7 +345,7 @@ void SwTransferable::InitOle( SfxObjectShell* pDoc )
{
//set OleVisArea. Upper left corner of the page and size of
//RealSize in Twips.
- const Size aSz( OLESIZE );
+ const Size aSz(constOleSizeTwip);
SwRect aVis( Point( DOCUMENTBORDER, DOCUMENTBORDER ), aSz );
pDoc->SetVisArea( aVis.SVRect() );
}
@@ -1157,7 +1159,7 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
//ObjectDescriptor was already filly from the old DocShell.
//Now adjust it. Thus in GetData the first query can still
//be answered with delayed rendering.
- Size aSz( OLESIZE );
+ Size aSz(constOleSizeTwip);
m_aObjDesc.maSize = OutputDevice::LogicToLogic(aSz, MapMode(MapUnit::MapTwip), MapMode(MapUnit::Map100thMM));
PrepareOLE( m_aObjDesc );
@@ -1260,7 +1262,7 @@ bool SwTransferable::CopyGlossary( SwTextBlocks& rGlossary, const OUString& rStr
//ObjectDescriptor was already filled from the old DocShell.
//Now adjust it. Thus in GetData the first query can still
//be answered with delayed rendering.
- Size aSz( OLESIZE );
+ Size aSz(constOleSizeTwip);
m_aObjDesc.maSize = OutputDevice::LogicToLogic(aSz, MapMode(MapUnit::MapTwip), MapMode(MapUnit::Map100thMM));
PrepareOLE( m_aObjDesc );
@@ -3627,7 +3629,7 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
//Now adjust it. Thus in GetData the first query can still
//be answered with delayed rendering.
m_aObjDesc.maDragStartPos = rSttPos;
- m_aObjDesc.maSize = OutputDevice::LogicToLogic( Size( OLESIZE ),
+ m_aObjDesc.maSize = OutputDevice::LogicToLogic(constOleSizeTwip,
MapMode(MapUnit::MapTwip), MapMode(MapUnit::Map100thMM));
PrepareOLE( m_aObjDesc );
AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
commit 992dae2d81425c0bb2001f6f24039eeca0d42a5d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jul 23 08:44:14 2021 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Mon Aug 2 15:17:05 2021 +0900
sw: remove all uses of MM50 with (added) o3tl::convertTwip
MM50 constant is the number of twips for 5mm. This is (ab)used as
a "shortcut" to set or compare various variables through the code
and also to set a multiplied value (like 1cm, 2cm, 4cm) or divided
value (2.5mm, 1.25mm). The problem with this is that converting the
5mm to twip doesn't round up exactly and multiplied and divided
values increase the error even more.
Instead of basing it from MM50 constant, it is just better to use
our o3tl::convert (or the added variant o3tl::convertTwip), which
actually can calculate the conversion at compile time, so there is
no added complexity at runtime and we get a more readable code with
more exact result.
i.e.
o3tl::convertTwip(4, o3tl::Length::cm)
instead of the more cryptic
MM50 * 8
In addition also sanitize and comment the values of the constants
in sw/inc/swtypes.hxx.
Change-Id: I85c306c36207d47ac3dc207094b68d0fb1ca5b70
diff --git a/include/o3tl/unit_conversion.hxx b/include/o3tl/unit_conversion.hxx
index 4c76375737a2..927e8c565a0e 100644
--- a/include/o3tl/unit_conversion.hxx
+++ b/include/o3tl/unit_conversion.hxx
@@ -199,6 +199,12 @@ template <typename N, typename U> constexpr auto convert(N n, U from, U to)
return convert(n, detail::md(from, to), detail::md(to, from));
}
+// Just for convenience as we do this a lot
+template <typename N, typename U> constexpr auto convertTwip(N number, U from)
+{
+ return convert(number, detail::md(from, Length::twip), detail::md(Length::twip, from));
+}
+
// Returns nDefault if intermediate multiplication overflows sal_Int64 (only for integral types).
// On return, bOverflow indicates if overflow happened. nDefault is returned when overflow occurs.
template <typename N, typename U>
diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx
index dd15ce03bb88..b2c41bd31c94 100644
--- a/sw/inc/swtypes.hxx
+++ b/sw/inc/swtypes.hxx
@@ -25,9 +25,9 @@
#include <com/sun/star/i18n/CollatorOptions.hpp>
#include "swdllapi.h"
#include <o3tl/typed_flags_set.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <i18nlangtag/lang.h>
#include <vcl/outdev.hxx>
-#include <svx/flagsdef.hxx>
namespace com::sun::star {
namespace linguistic2{
@@ -55,26 +55,27 @@ typedef tools::Long SwTwips;
constexpr sal_Int32 COMPLETE_STRING = SAL_MAX_INT32;
-constexpr SwTwips cMinHdFtHeight = 56;
+constexpr SwTwips cMinHdFtHeight = 56; // ~1mm
#define MINFLY 23 // Minimal size for FlyFrames.
#define MINLAY 23 // Minimal size for other Frames.
// Default column distance of two text columns corresponds to 0.3 cm.
-constexpr SwTwips DEF_GUTTER_WIDTH = MM50 / 5 * 3;
+constexpr SwTwips DEF_GUTTER_WIDTH = o3tl::convertTwip(tools::Long(3), o3tl::Length::mm);
// Minimal distance (distance to text) for border attribute
// in order not to crock up aligned lines.
-// 28 Twips == 0,4mm
-constexpr SwTwips MIN_BORDER_DIST = 28;
+// 28 Twips == 0,5mm
+constexpr SwTwips MIN_BORDER_DIST = 28; // ~0.5mm
// Minimal document border: 20mm.
-constexpr SwTwips lMinBorder = 1134;
+constexpr SwTwips lMinBorder = o3tl::convertTwip(tools::Long(20), o3tl::Length::mm); // ~20mm
+static_assert(lMinBorder == 1134); // this was the old constant for 20mm, making sure o3tl::convert returns the same value
// Margin left and above document.
// Half of it is gap between the pages.
//TODO: Replace with SwViewOption::defDocumentBorder
-constexpr SwTwips DOCUMENTBORDER = 284;
+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
@@ -95,11 +96,14 @@ constexpr sal_uInt8 NO_NUMLEVEL = 0x20; // "or" with the levels.
// (For more levels the values have to be multiplied with the levels+1;
// levels 0 ..4!)
-constexpr short lBulletIndent = 1440 / 4;
+constexpr short lBulletIndent = o3tl::convertTwip(25, o3tl::Length::in100); // 0.25 inch
constexpr short lBulletFirstLineOffset = -lBulletIndent;
-constexpr sal_uInt16 lNumberIndent = 1440 / 4;
+constexpr sal_uInt16 lNumberIndent = o3tl::convertTwip(25, o3tl::Length::in100); // 0.25 inch
constexpr short lNumberFirstLineOffset = -lNumberIndent;
-constexpr short lOutlineMinTextDistance = 216; // 0.15 inch = 0.38 cm
+constexpr short lOutlineMinTextDistance = o3tl::convertTwip(15, o3tl::Length::in100); // 0.15 inch = 0.38 cm
+
+static_assert(1440 / 4 == lBulletIndent);
+static_assert(216 == lOutlineMinTextDistance);
// Count of SystemField-types of SwDoc.
#define INIT_FLDTYPES 33
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 91f6689f1d73..ad09174796af 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -597,7 +597,8 @@ void SwTiledRenderingTest::testInsertShape()
IDocumentDrawModelAccess &rDrawModelAccess = pWrtShell->GetDoc()->getIDocumentDrawModelAccess();
SdrPage* pPage = rDrawModelAccess.GetDrawModel()->GetPage(0);
SdrObject* pObject = pPage->GetObj(0);
- CPPUNIT_ASSERT_EQUAL(tools::Rectangle(3302, 302, 6698, 3698), pObject->GetSnapRect());
+
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3299, 299), Size(3403, 3403)), pObject->GetSnapRect());
// check that it is in the foreground layer
CPPUNIT_ASSERT_EQUAL(rDrawModelAccess.GetHeavenId().get(), pObject->GetLayer().get());
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx
index 9238622db126..9e454d169b81 100644
--- a/sw/source/core/doc/DocumentStylePoolManager.cxx
+++ b/sw/source/core/doc/DocumentStylePoolManager.cxx
@@ -1669,9 +1669,9 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId )
aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
aSet.Put( SwFormatSurround( css::text::WrapTextMode_PARALLEL ));
// Set the default width to 3.5 cm, use the minimum value for the height
- aSet.Put( SwFormatFrameSize( SwFrameSize::Minimum,
- o3tl::convert(35, o3tl::Length::mm, o3tl::Length::twip),
- MM50 ));
+ aSet.Put(SwFormatFrameSize(SwFrameSize::Minimum,
+ o3tl::convertTwip(35, o3tl::Length::mm),
+ o3tl::convertTwip(5, o3tl::Length::mm)));
}
break;
case RES_POOLFRM_WATERSIGN:
diff --git a/sw/source/core/doc/lineinfo.cxx b/sw/source/core/doc/lineinfo.cxx
index e77e14a174d8..be89d9439ac3 100644
--- a/sw/source/core/doc/lineinfo.cxx
+++ b/sw/source/core/doc/lineinfo.cxx
@@ -52,7 +52,7 @@ const SwLineNumberInfo& SwDoc::GetLineNumberInfo() const
}
SwLineNumberInfo::SwLineNumberInfo() :
- m_nPosFromLeft( MM50 ),
+ m_nPosFromLeft(o3tl::convertTwip(5, o3tl::Length::mm)),
m_nCountBy( 5 ),
m_nDividerCountBy( 3 ),
m_ePos( LINENUMBER_POS_LEFT ),
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 6ab5a3ae9ad8..f1201628ae7f 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -501,8 +501,13 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const
{
bool bRet = true;
+ constexpr sal_uInt16 constTwips_2cm = o3tl::convertTwip(tools::Long(20), o3tl::Length::mm);
+ constexpr tools::Long constTwips_5mm = o3tl::convertTwip(tools::Long(5), o3tl::Length::mm);
+
const SvxTabStopItem& rTabItem = GetDoc()->GetDefault( RES_PARATR_TABSTOP );
- sal_uInt16 nDefDist = o3tl::narrowing<sal_uInt16>(rTabItem.Count() ? rTabItem[0].GetTabPos() : 1134);
+ sal_uInt16 nDefDist = o3tl::narrowing<sal_uInt16>(
+ rTabItem.Count() ? rTabItem[0].GetTabPos() : constTwips_2cm);
+
if( !nDefDist )
return false;
@@ -534,7 +539,7 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const
const sal_uInt32 nFrameWidth = o3tl::narrowing<sal_uInt32>( pFrame->IsVertical() ?
pFrame->getFrameArea().Height() :
pFrame->getFrameArea().Width() );
- bRet = o3tl::narrowing<SwTwips>(nFrameWidth) > ( nNext + MM50 );
+ bRet = o3tl::narrowing<SwTwips>(nFrameWidth) > (nNext + constTwips_5mm);
}
else
bRet = false;
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index ab185b70d893..6d21ceac1ae2 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -1908,11 +1908,13 @@ bool SwFEShell::ImpEndCreate()
// The crsr should not be too far away
bCharBound = true;
+ constexpr tools::Long constTwips_1cm = o3tl::convertTwip(tools::Long(1), o3tl::Length::cm);
tools::Rectangle aRect( aTmp.SVRect() );
- aRect.AdjustLeft( -(MM50*2) );
- aRect.AdjustTop( -(MM50*2) );
- aRect.AdjustRight(MM50*2 );
- aRect.AdjustBottom(MM50*2 );
+ // Extend by 1 cm in each direction
+ aRect.AdjustLeft(-constTwips_1cm);
+ aRect.AdjustTop(-constTwips_1cm);
+ aRect.AdjustRight(constTwips_1cm);
+ aRect.AdjustBottom(constTwips_1cm);
if( !aRect.IsOver( rBound ) && !::GetHtmlMode( GetDoc()->GetDocShell() ))
bCharBound = false;
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index 71a598c229bc..798d1231d1bc 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -860,7 +860,9 @@ void SwPageFrame::MakeAll(vcl::RenderContext* pRenderContext)
if (nWidth < nDefWidth)
nWidth = nDefWidth;
nWidth += + 2 * aBorder.Width();
- nWidth = std::max( nWidth, 2L * aBorder.Width() + 4*MM50 );
+
+ constexpr tools::Long constTwips_2cm = o3tl::convertTwip(tools::Long(2), o3tl::Length::cm);
+ nWidth = std::max(nWidth, 2L * aBorder.Width() + constTwips_2cm);
{
SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 69c726721745..4b7887d4e953 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -879,9 +879,10 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
{
rSizeFound = false;
SwFormatFrameSize aFrameSz;
+ constexpr sal_Int32 constTwips_1cm = o3tl::convertTwip(sal_Int32(1), o3tl::Length::cm);
awt::Size aSize;
- aSize.Width = 2 * MM50;
- aSize.Height = 2 * MM50;
+ aSize.Width = constTwips_1cm;
+ aSize.Height = constTwips_1cm;
::uno::Any aSizeVal;
aSizeVal <<= aSize;
static_cast<SfxPoolItem&>(aFrameSz).PutValue(aSizeVal, MID_FRMSIZE_SIZE|CONVERT_TWIPS);
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 3012637bbe4c..3ba7388593b6 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -2923,7 +2923,8 @@ void SwXPageStyle::SetPropertyValues_Impl(const uno::Sequence<OUString>& rProper
aTempSet.SetParent(&GetDoc()->GetDfltFrameFormat()->GetAttrSet());
aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_ON, true));
- aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50)));
+ constexpr tools::Long constTwips_5mm = o3tl::convertTwip(tools::Long(5), o3tl::Length::mm);
+ aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(constTwips_5mm, constTwips_5mm)));
aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE));
aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE));
aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, true));
diff --git a/sw/source/filter/html/htmlnum.hxx b/sw/source/filter/html/htmlnum.hxx
index 2e7957996509..e155dfda000d 100644
--- a/sw/source/filter/html/htmlnum.hxx
+++ b/sw/source/filter/html/htmlnum.hxx
@@ -22,8 +22,8 @@
#include <swtypes.hxx>
#include <string.h>
-#define HTML_NUMBER_BULLET_MARGINLEFT (MM50*2 + MM50/2)
-#define HTML_NUMBER_BULLET_INDENT (-MM50)
+#define HTML_NUMBER_BULLET_MARGINLEFT (o3tl::convertTwip(tools::Long(125), o3tl::Length::mm10))
+#define HTML_NUMBER_BULLET_INDENT (-o3tl::convertTwip(tools::Long(5), o3tl::Length::mm))
class SwTextNode;
class SwNumRule;
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index 9ae5abc57095..e505624bbe78 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -83,11 +83,12 @@
using namespace com::sun::star;
-#define HTML_DFLT_EMBED_WIDTH ((MM50*5)/2)
-#define HTML_DFLT_EMBED_HEIGHT ((MM50*5)/2)
-#define HTML_DFLT_APPLET_WIDTH ((MM50*5)/2)
-#define HTML_DFLT_APPLET_HEIGHT ((MM50*5)/2)
+#define HTML_DFLT_EMBED_WIDTH (o3tl::convertTwip(tools::Long(125), o3tl::Length::mm10))
+#define HTML_DFLT_EMBED_HEIGHT (o3tl::convertTwip(tools::Long(125), o3tl::Length::mm10))
+
+#define HTML_DFLT_APPLET_WIDTH (o3tl::convertTwip(tools::Long(125), o3tl::Length::mm10))
+#define HTML_DFLT_APPLET_HEIGHT (o3tl::convertTwip(tools::Long(125), o3tl::Length::mm10))
const HtmlFrmOpts HTML_FRMOPTS_EMBED_ALL =
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index e1cc324d73c2..ec1c6a03702f 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -3421,7 +3421,9 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
true );
aFrameSet.Put( SwFormatSurround(eSurround) );
- SwFormatFrameSize aFrameSize( SwFrameSize::Variable, 20*MM50, MINLAY );
+ constexpr tools::Long constTwips_100mm = o3tl::convert(tools::Long(100), o3tl::Length::mm, o3tl::Length::twip);
+
+ SwFormatFrameSize aFrameSize( SwFrameSize::Variable, constTwips_100mm, MINLAY );
aFrameSize.SetWidthPercent( 100 );
aFrameSet.Put( aFrameSize );
diff --git a/sw/source/filter/html/svxcss1.hxx b/sw/source/filter/html/svxcss1.hxx
index fd547a0e9d76..a69850979533 100644
--- a/sw/source/filter/html/svxcss1.hxx
+++ b/sw/source/filter/html/svxcss1.hxx
@@ -202,7 +202,8 @@ class SvxCSS1Parser : public CSS1Parser
std::unique_ptr<SvxCSS1PropertyInfo> m_pSheetPropInfo;
SvxCSS1PropertyInfo *m_pPropInfo;
- static constexpr sal_uInt16 gnMinFixLineSpace = MM50/2; // minimum spacing for fixed line spacing
+ // minimum spacing for fixed line spacing
+ static constexpr sal_uInt16 gnMinFixLineSpace = o3tl::convertTwip(tools::Long(25), o3tl::Length::mm10);
rtl_TextEncoding m_eDefaultEnc;
bool m_bIgnoreFontFamily;
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 3e3b693eb5a8..7aaf6f0aa1c1 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -58,11 +58,11 @@ struct SwPending;
class SvxCSS1PropertyInfo;
struct ImplSVEvent;
-#define HTML_CJK_PARSPACE (MM50/2)
-#define HTML_CTL_PARSPACE (MM50/2)
+constexpr tools::Long HTML_CJK_PARSPACE = o3tl::convertTwip(tools::Long(25), o3tl::Length::mm10); // 2.5mm
+constexpr tools::Long HTML_CTL_PARSPACE = o3tl::convertTwip(tools::Long(25), o3tl::Length::mm10); // 2.5mm
-#define HTML_DFLT_IMG_WIDTH (MM50*4)
-#define HTML_DFLT_IMG_HEIGHT (MM50*2)
+constexpr tools::Long HTML_DFLT_IMG_WIDTH = o3tl::convertTwip(tools::Long(2), o3tl::Length::cm); // 2cm
+constexpr tools::Long HTML_DFLT_IMG_HEIGHT = o3tl::convertTwip(tools::Long(1), o3tl::Length::cm); // 1cm
// some things you often need
extern HTMLOptionEnum<SvxAdjust> const aHTMLPAlignTable[];
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 12f693a72872..fa2b058e03d7 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -66,7 +66,7 @@ namespace utl { class TempFile; }
extern SwAttrFnTab aHTMLAttrFnTab;
-#define HTML_PARSPACE (MM50)
+#define HTML_PARSPACE (o3tl::convertTwip(tools::Long(5), o3tl::Length::mm))
// flags for the output of any kind of frames
// BORDER only possible if OutHTML_Image
diff --git a/sw/source/ui/chrdlg/pardlg.cxx b/sw/source/ui/chrdlg/pardlg.cxx
index aef94f46111a..c351f5b39807 100644
--- a/sw/source/ui/chrdlg/pardlg.cxx
+++ b/sw/source/ui/chrdlg/pardlg.cxx
@@ -167,8 +167,9 @@ void SwParaDlg::PageCreated(const OString& rId, SfxTabPage& rPage)
if (!bDrawParaDlg)
{
// See SvxStdParagraphTabPage::PageCreated: enable RegisterMode, AutoFirstLine, NegativeMode, ContextualMode
+ constexpr tools::Long constTwips_0_5mm = o3tl::convertTwip(tools::Long(5), o3tl::Length::mm10);
aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x0002|0x0004|0x0008|0x0010));
- aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/10));
+ aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, constTwips_0_5mm));
}
rPage.PageCreated(aSet);
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index a6a32ddd76cb..9bd5f381ccb5 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -61,11 +61,11 @@ using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::view;
-#define DEFAULT_LEFT_DISTANCE (MM50*5) // 2,5 cm
-#define DEFAULT_TOP_DISTANCE (MM50*11) // 5,5 cm
-#define GREETING_TOP_DISTANCE (MM50*25) //12,5 cm
-#define DEFAULT_ADDRESS_WIDTH (MM50*15)// 7,5 cm
-#define DEFAULT_ADDRESS_HEIGHT (MM50*7) // 3,5cm
+constexpr tools::Long DEFAULT_LEFT_DISTANCE = o3tl::convertTwip(tools::Long(25), o3tl::Length::mm); // 2,5 cm
+constexpr tools::Long DEFAULT_TOP_DISTANCE = o3tl::convertTwip(tools::Long(55), o3tl::Length::mm); // 5,5 cm
+constexpr tools::Long GREETING_TOP_DISTANCE = o3tl::convertTwip(tools::Long(125), o3tl::Length::mm); //12,5 cm
+constexpr tools::Long DEFAULT_ADDRESS_WIDTH = o3tl::convertTwip(tools::Long(75), o3tl::Length::mm); // 7,5 cm
+constexpr tools::Long DEFAULT_ADDRESS_HEIGHT = o3tl::convertTwip(tools::Long(35), o3tl::Length::mm); // 3,5cm
SwMailMergeLayoutPage::SwMailMergeLayoutPage(weld::Container* pPage, SwMailMergeWizard* pWizard)
: vcl::OWizardPage(pPage, pWizard, "modules/swriter/ui/mmlayoutpage.ui", "MMLayoutPage")
diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx
index 6e797e45a5a4..77551a02319e 100644
--- a/sw/source/ui/fmtui/tmpdlg.cxx
+++ b/sw/source/ui/fmtui/tmpdlg.cxx
@@ -489,7 +489,8 @@ void SwTemplateDlgController::PageCreated(const OString& rId, SfxTabPage &rPage
{
if( rPage.GetItemSet().GetParent() )
{
- aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST,MM50/10));
+ constexpr tools::Long constTwips_0_5mm = o3tl::convertTwip(tools::Long(5), o3tl::Length::mm10);
+ aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, constTwips_0_5mm));
aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x000F));
rPage.PageCreated(aSet);
}
diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx
index 32186b8a8895..d9dedae3a6ee 100644
--- a/sw/source/ui/misc/pggrid.cxx
+++ b/sw/source/ui/misc/pggrid.cxx
@@ -35,11 +35,13 @@
#include <swmodule.hxx>
#include <view.hxx>
+constexpr tools::Long constTwips_5mm = o3tl::convertTwip(tools::Long(5), o3tl::Length::mm);
+
SwTextGridPage::SwTextGridPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet)
: SfxTabPage(pPage, pController, "modules/swriter/ui/textgridpage.ui", "TextGridPage", &rSet)
, m_nRubyUserValue(0)
, m_bRubyUserValue(false)
- , m_aPageSize(MM50, MM50)
+ , m_aPageSize(constTwips_5mm, constTwips_5mm)
, m_bVertical(false)
, m_bSquaredMode(false)
, m_bHRulerChanged(false)
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index c36b6d87837b..5d8581f423a9 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -134,7 +134,10 @@
#include <memory>
-#define OLESIZE 11905 - 2 * lMinBorder, 6 * MM50
+constexpr tools::Long constOleWidth = 11905 - 2 * lMinBorder;
+constexpr tools::Long constOleHeight = o3tl::convertTwip(tools::Long(3), o3tl::Length::cm);
+
+#define OLESIZE constOleWidth, constOleHeight
constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_DRAWMODEL = 0x00000001;
constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_HTML = 0x00000002;
diff --git a/sw/source/uibase/inc/frmmgr.hxx b/sw/source/uibase/inc/frmmgr.hxx
index 27ebc70a66d3..b6d0adf9196e 100644
--- a/sw/source/uibase/inc/frmmgr.hxx
+++ b/sw/source/uibase/inc/frmmgr.hxx
@@ -35,8 +35,8 @@ struct SwPosition;
class SwFormatCol;
class SvGlobalName;
-const SwTwips DFLT_WIDTH = MM50 * 4;
-const SwTwips DFLT_HEIGHT = MM50;
+constexpr SwTwips DFLT_WIDTH = o3tl::convertTwip(tools::Long(20), o3tl::Length::mm);
+constexpr SwTwips DFLT_HEIGHT = o3tl::convertTwip(tools::Long(5), o3tl::Length::mm);
enum class Frmmgr_Type
{
diff --git a/sw/source/uibase/ribbar/conform.cxx b/sw/source/uibase/ribbar/conform.cxx
index f51e9123ca40..993f307b2fac 100644
--- a/sw/source/uibase/ribbar/conform.cxx
+++ b/sw/source/uibase/ribbar/conform.cxx
@@ -89,12 +89,15 @@ void ConstFormControl::Activate(const sal_uInt16 nSlotId)
void ConstFormControl::CreateDefaultObject()
{
+ constexpr tools::Long constTwips_5mm = o3tl::convertTwip(tools::Long(5), o3tl::Length::mm);
+ constexpr tools::Long constTwips_10mm = o3tl::convertTwip(tools::Long(10), o3tl::Length::mm);
+
Point aStartPos(GetDefaultCenterPos());
Point aEndPos(aStartPos);
- aStartPos.AdjustX(-(2 * MM50));
- aStartPos.AdjustY(-MM50);
- aEndPos.AdjustX(2 * MM50);
- aEndPos.AdjustY(MM50);
+ aStartPos.AdjustX(-constTwips_10mm);
+ aStartPos.AdjustY(-constTwips_5mm);
+ aEndPos.AdjustX(constTwips_10mm);
+ aEndPos.AdjustY(constTwips_5mm);
if(!m_pSh->HasDrawView())
m_pSh->MakeDrawView();
diff --git a/sw/source/uibase/ribbar/drawbase.cxx b/sw/source/uibase/ribbar/drawbase.cxx
index b1ee706dfa5d..e3295bf47fc4 100644
--- a/sw/source/uibase/ribbar/drawbase.cxx
+++ b/sw/source/uibase/ribbar/drawbase.cxx
@@ -511,12 +511,14 @@ void SwDrawBase::EnterSelectMode(const MouseEvent& rMEvt)
void SwDrawBase::CreateDefaultObject()
{
+ constexpr tools::Long constTwips_3cm = o3tl::convertTwip(tools::Long(3), o3tl::Length::cm);
+
Point aStartPos = GetDefaultCenterPos();
Point aEndPos(aStartPos);
- aStartPos.AdjustX( -(6 * MM50) );
- aStartPos.AdjustY( -(6 * MM50) );
- aEndPos.AdjustX(6 * MM50 );
- aEndPos.AdjustY(6 * MM50 );
+ aStartPos.AdjustX(-constTwips_3cm);
+ aStartPos.AdjustY(-constTwips_3cm);
+ aEndPos.AdjustX(constTwips_3cm);
+ aEndPos.AdjustY(constTwips_3cm);
tools::Rectangle aRect(aStartPos, aEndPos);
m_pSh->CreateDefaultShape(m_pWin->GetSdrDrawMode(), aRect, m_nSlotId);
}
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx
index af3fc2e21494..3157a17461f0 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -399,9 +399,11 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
Size aWinSize = rEdtWin.GetSizePixel();
Point aStartPos(aWinSize.Width()/2, aWinSize.Height() / 2);
aStartPos = rEdtWin.PixelToLogic(aStartPos);
- aStartPos.AdjustX( -(8 * MM50) );
- aStartPos.AdjustY( -(4 * MM50) );
- Size aSize(16 * MM50, 8 * MM50);
+ constexpr tools::Long constTwips_2cm = o3tl::convertTwip(tools::Long(2), o3tl::Length::cm);
+ constexpr tools::Long constTwips_4cm = o3tl::convertTwip(tools::Long(4), o3tl::Length::cm);
+ aStartPos.AdjustX(-constTwips_4cm);
+ aStartPos.AdjustY(-constTwips_2cm);
+ Size aSize(2 * constTwips_4cm, 2 * constTwips_2cm);
GetShell().LockPaint();
GetShell().StartAllAction();
SwFlyFrameAttrMgr aMgr( true, GetShellPtr(), Frmmgr_Type::TEXT, nullptr );
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 41f71cd26462..6b68da98f171 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -1896,7 +1896,8 @@ void SwWrtShell::ChangeHeaderOrFooter(
rMaster.SetFormatAttr( SwFormatFooter( bOn ));
if( bOn )
{
- SvxULSpaceItem aUL(bHeader ? 0 : MM50, bHeader ? MM50 : 0, RES_UL_SPACE );
+ constexpr tools::Long constTwips_5mm = o3tl::convertTwip(tools::Long(5), o3tl::Length::mm);
+ SvxULSpaceItem aUL(bHeader ? 0 : constTwips_5mm, bHeader ? constTwips_5mm : 0, RES_UL_SPACE );
SwFrameFormat* pFormat = bHeader ?
const_cast<SwFrameFormat*>(rMaster.GetHeader().GetHeaderFormat()) :
const_cast<SwFrameFormat*>(rMaster.GetFooter().GetFooterFormat());
More information about the Libreoffice-commits
mailing list