[Libreoffice-commits] core.git: sw/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Mar 30 05:14:05 UTC 2021
sw/source/core/attr/format.cxx | 4 +-
sw/source/core/doc/DocumentStylePoolManager.cxx | 44 ++++++++++++------------
sw/source/core/doc/docdesc.cxx | 7 ++-
sw/source/core/inc/GetMetricVal.hxx | 42 ----------------------
4 files changed, 28 insertions(+), 69 deletions(-)
New commits:
commit 906b86154e54969b2dc2349b686947896a0fac03
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Mar 29 21:29:04 2021 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Mar 30 07:13:29 2021 +0200
Use o3tl::convert instead of GetMetricVal
... and drop the latter.
Change-Id: Ia877358bbd8a699b9e8cc4d72dc1fb7c4d0ef980
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113328
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 61149cae8d62..cfbf3a2ba77e 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -26,6 +26,7 @@
#include <frmatr.hxx>
#include <hintids.hxx>
#include <hints.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <osl/diagnose.h>
#include <sal/log.hxx>
#include <svl/grabbagitem.hxx>
@@ -33,7 +34,6 @@
#include <svx/unobrushitemhelper.hxx>
#include <svx/xdef.hxx>
#include <swcache.hxx>
-#include <GetMetricVal.hxx>
using namespace com::sun::star;
@@ -695,7 +695,7 @@ void SwFormat::SetPageFormatToDefault()
{
SvxLRSpaceItem aLR(RES_LR_SPACE);
- sal_Int32 nSize = GetMetricVal(CM_1) * 2;
+ const sal_Int32 nSize = o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip);
aLR.SetLeft(nSize);
aLR.SetRight(nSize);
SvxULSpaceItem aUL(RES_UL_SPACE);
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx
index 7fa92a05befe..5df33094c073 100644
--- a/sw/source/core/doc/DocumentStylePoolManager.cxx
+++ b/sw/source/core/doc/DocumentStylePoolManager.cxx
@@ -30,7 +30,6 @@
#include <charfmt.hxx>
#include <fmtsrnd.hxx>
#include <docary.hxx>
-#include <GetMetricVal.hxx>
#include <pagedesc.hxx>
#include <frmfmt.hxx>
#include <fmtline.hxx>
@@ -58,6 +57,7 @@
#include <editeng/charrotateitem.hxx>
#include <editeng/emphasismarkitem.hxx>
#include <editeng/scriptspaceitem.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <svx/strings.hrc>
#include <svx/dialmgr.hxx>
#include <sal/log.hxx>
@@ -96,7 +96,7 @@ namespace
const sal_uInt16 PT_24 = 24 * 20; // 24 pt
const sal_uInt16 PT_28 = 28 * 20; // 28 pt
- #define HTML_PARSPACE GetMetricVal( CM_05 )
+ const sal_uInt16 HTML_PARSPACE = o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip);
const sal_uInt16 aHeadlineSizes[ 2 * MAXLEVEL ] = {
// we do everything percentual now:
@@ -227,7 +227,7 @@ namespace
bool bHeader, bool bTab )
{
SvxLRSpaceItem aLR( RES_LR_SPACE );
- sal_uInt16 nLeft = nFact ? GetMetricVal( CM_05 ) * nFact : 0;
+ sal_uInt16 nLeft = o3tl::convert(5 * nFact, o3tl::Length::mm, o3tl::Length::twip);
aLR.SetTextLeft( nLeft );
rSet.Put( aLR );
@@ -706,15 +706,15 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
case RES_POOLCOLL_TEXT_IDENT: // Text body indentation
{
SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR.SetTextFirstLineOffset( GetMetricVal( CM_05 ));
+ aLR.SetTextFirstLineOffset(o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip));
aSet.Put( aLR );
}
break;
case RES_POOLCOLL_TEXT_NEGIDENT: // Text body neg. indentation
{
SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR.SetTextFirstLineOffset( -static_cast<short>(GetMetricVal( CM_05 )));
- aLR.SetTextLeft( GetMetricVal( CM_1 ));
+ aLR.SetTextFirstLineOffset(-o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip));
+ aLR.SetTextLeft(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip));
SvxTabStopItem aTStops(RES_PARATR_TABSTOP);
aTStops.Insert( SvxTabStop( 0 ));
@@ -725,7 +725,7 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
case RES_POOLCOLL_TEXT_MOVE: // Text body move
{
SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR.SetTextLeft( GetMetricVal( CM_05 ));
+ aLR.SetTextLeft(o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip));
aSet.Put( aLR );
}
break;
@@ -733,9 +733,9 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
case RES_POOLCOLL_CONFRONTATION: // Text body confrontation
{
SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR.SetTextFirstLineOffset( - short( GetMetricVal( CM_1 ) * 4 +
- GetMetricVal( CM_05)) );
- aLR.SetTextLeft( GetMetricVal( CM_1 ) * 5 );
+ aLR.SetTextFirstLineOffset(
+ -o3tl::convert(45, o3tl::Length::mm, o3tl::Length::twip));
+ aLR.SetTextLeft(o3tl::convert(5, o3tl::Length::cm, o3tl::Length::twip));
SvxTabStopItem aTStops( RES_PARATR_TABSTOP );
aTStops.Insert( SvxTabStop( 0 ));
@@ -746,7 +746,7 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
case RES_POOLCOLL_MARGINAL: // Text body marginal
{
SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR.SetTextLeft( GetMetricVal( CM_1 ) * 4 );
+ aLR.SetTextLeft(o3tl::convert(4, o3tl::Length::cm, o3tl::Length::twip));
aSet.Put( aLR );
}
break;
@@ -938,8 +938,8 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
case RES_POOLCOLL_ENDNOTE: // paragraph style Endnote
{
SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR.SetTextFirstLineOffset( -static_cast<short>( GetMetricVal( CM_05 ) + GetMetricVal( CM_01 ) ) );
- aLR.SetTextLeft( GetMetricVal( CM_05 ) + GetMetricVal( CM_01 ) );
+ aLR.SetTextFirstLineOffset(-o3tl::convert(6, o3tl::Length::mm, o3tl::Length::twip));
+ aLR.SetTextLeft(o3tl::convert(6, o3tl::Length::mm, o3tl::Length::twip));
SetAllScriptItem( aSet, SvxFontHeightItem( PT_10, 100, RES_CHRATR_FONTSIZE ) );
aSet.Put( aLR );
SwFormatLineNumber aLN;
@@ -1345,8 +1345,8 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
case RES_POOLCOLL_HTML_BLOCKQUOTE:
{
SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR.SetLeft( GetMetricVal( CM_1 ));
- aLR.SetRight( GetMetricVal( CM_1 ));
+ aLR.SetLeft(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip));
+ aLR.SetRight(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip));
aSet.Put( aLR );
std::unique_ptr<SvxULSpaceItem> aUL(pNewColl->GetULSpace().Clone());
aUL->SetLower( HTML_PARSPACE );
@@ -1397,7 +1397,7 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
{
std::unique_ptr<SvxLRSpaceItem> aLR(pNewColl->GetLRSpace().Clone());
// We indent by 1 cm. The IDs are always 2 away from each other!
- aLR->SetLeft( GetMetricVal( CM_1 ));
+ aLR->SetLeft(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip));
aSet.Put(std::move(aLR));
}
break;
@@ -1663,7 +1663,7 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId )
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,
- GetMetricVal( CM_1 ) * 3 + GetMetricVal( CM_05 ),
+ o3tl::convert(35, o3tl::Length::mm, o3tl::Length::twip),
MM50 ));
}
break;
@@ -1748,7 +1748,7 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool
SvxLRSpaceItem aLR( RES_LR_SPACE );
{
- aLR.SetLeft( GetMetricVal( CM_1 ) * 2 );
+ aLR.SetLeft(o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip));
aLR.SetRight( aLR.GetLeft() );
}
SvxULSpaceItem aUL( RES_UL_SPACE );
@@ -1823,7 +1823,7 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool
case RES_POOLPAGE_HTML: // "HTML"
{
lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
- aLR.SetRight( GetMetricVal( CM_1 ));
+ aLR.SetRight(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip));
aUL.SetUpper( static_cast<sal_uInt16>(aLR.GetRight()) );
aUL.SetLower( static_cast<sal_uInt16>(aLR.GetRight()) );
aSet.Put( aLR );
@@ -2188,8 +2188,8 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
aFormat.SetCharFormat( pBullCFormat );
aFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
aFormat.SetBulletChar( cBulletChar );
- sal_Int16 nOffs = GetMetricVal( CM_01 ) * 4,
- nOffs2 = GetMetricVal( CM_1 ) * 2;
+ sal_Int16 nOffs = o3tl::convert(4, o3tl::Length::mm, o3tl::Length::twip),
+ nOffs2 = o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip);
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
@@ -2323,7 +2323,7 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
aFormat.SetIncludeUpperLevels( 1 );
aFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
- sal_uInt16 nOffs = GetMetricVal( CM_01 ) * 4;
+ sal_uInt16 nOffs = o3tl::convert(4, o3tl::Length::mm, o3tl::Length::twip);
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 05831ab5e487..8450691eea9c 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -48,7 +48,6 @@
#include <fmtftn.hxx>
#include <txtftn.hxx>
#include <fldbas.hxx>
-#include <GetMetricVal.hxx>
#include <strings.hrc>
#include <hints.hxx>
#include <SwUndoPageDesc.hxx>
@@ -57,6 +56,8 @@
#include <unotools/configmgr.hxx>
#include <unotools/syslocale.hxx>
#include <svx/swframetypes.hxx>
+#include <o3tl/unit_conversion.hxx>
+
#include <com/sun/star/embed/XEmbeddedObject.hpp>
using namespace com::sun::star;
@@ -88,8 +89,8 @@ static void lcl_DefaultPageFormat( sal_uInt16 nPoolFormatId,
sal_Int32 nMinTop, nMinBottom, nMinLeft, nMinRight;
if( RES_POOLPAGE_HTML == nPoolFormatId )
{
- nMinRight = nMinTop = nMinBottom = GetMetricVal( CM_1 );
- nMinLeft = nMinRight * 2;
+ nMinRight = nMinTop = nMinBottom = o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip);
+ nMinLeft = o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip);
}
else if (!utl::ConfigManager::IsFuzzing() && MeasurementSystem::Metric == SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() )
{
diff --git a/sw/source/core/inc/GetMetricVal.hxx b/sw/source/core/inc/GetMetricVal.hxx
deleted file mode 100644
index 9b17975d61cf..000000000000
--- a/sw/source/core/inc/GetMetricVal.hxx
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_SW_SOURCE_CORE_INC_GETMETRICVAL_HXX
-#define INCLUDED_SW_SOURCE_CORE_INC_GETMETRICVAL_HXX
-
-#include <sal/types.h>
-
-#define CM_1 0 // 1 centimeter or 1/2 inch
-#define CM_05 1 // 0.5 centimeter or 1/4 inch
-#define CM_01 2 // 0.1 centimeter or 1/20 inch
-
-inline sal_uInt16 GetMetricVal( int n )
-{
- sal_uInt16 nVal = 567; // 1 cm
-
- if( CM_01 == n )
- nVal /= 10;
- else if( CM_05 == n )
- nVal /= 2;
- return nVal;
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list