diff options
25 files changed, 76 insertions, 115 deletions
diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx index 523b29794461..417e62d771e0 100644 --- a/editeng/source/uno/unoipset.cxx +++ b/editeng/source/uno/unoipset.cxx @@ -260,10 +260,6 @@ uno::Reference< beans::XPropertySetInfo > const & SvxItemPropertySet::getProper } -#ifndef TWIPS_TO_MM -#define TWIPS_TO_MM(val) ((val * 127 + 36) / 72) -#endif - /** converts the given any with a metric to 100th/mm if needed */ void SvxUnoConvertToMM( const MapUnit eSourceMapUnit, uno::Any & rMetric ) throw() { @@ -275,19 +271,19 @@ void SvxUnoConvertToMM( const MapUnit eSourceMapUnit, uno::Any & rMetric ) throw switch( rMetric.getValueTypeClass() ) { case uno::TypeClass_BYTE: - rMetric <<= static_cast<sal_Int8>(TWIPS_TO_MM(*o3tl::forceAccess<sal_Int8>(rMetric))); + rMetric <<= static_cast<sal_Int8>(TwipsToHMM(*o3tl::forceAccess<sal_Int8>(rMetric))); break; case uno::TypeClass_SHORT: - rMetric <<= static_cast<sal_Int16>(TWIPS_TO_MM(*o3tl::forceAccess<sal_Int16>(rMetric))); + rMetric <<= static_cast<sal_Int16>(TwipsToHMM(*o3tl::forceAccess<sal_Int16>(rMetric))); break; case uno::TypeClass_UNSIGNED_SHORT: - rMetric <<= static_cast<sal_uInt16>(TWIPS_TO_MM(*o3tl::forceAccess<sal_uInt16>(rMetric))); + rMetric <<= static_cast<sal_uInt16>(TwipsToHMM(*o3tl::forceAccess<sal_uInt16>(rMetric))); break; case uno::TypeClass_LONG: - rMetric <<= static_cast<sal_Int32>(TWIPS_TO_MM(*o3tl::forceAccess<sal_Int32>(rMetric))); + rMetric <<= static_cast<sal_Int32>(TwipsToHMM(*o3tl::forceAccess<sal_Int32>(rMetric))); break; case uno::TypeClass_UNSIGNED_LONG: - rMetric <<= static_cast<sal_uInt32>(TWIPS_TO_MM(*o3tl::forceAccess<sal_uInt32>(rMetric))); + rMetric <<= static_cast<sal_uInt32>(TwipsToHMM(*o3tl::forceAccess<sal_uInt32>(rMetric))); break; default: SAL_WARN("editeng", "AW: Missing unit translation to 100th mm, " << OString::number(static_cast<sal_Int32>(rMetric.getValueTypeClass()))); diff --git a/include/svx/unopage.hxx b/include/svx/unopage.hxx index bff0aa5fd5e3..b3bf6bfe47d3 100644 --- a/include/svx/unopage.hxx +++ b/include/svx/unopage.hxx @@ -46,12 +46,6 @@ class SvxShapeGroup; class SvxShapeConnector; enum class SdrInventor : sal_uInt32; -/** -* Macros to convert Twips<->100tel mm -*/ -#define TWIPS_TO_MM(val) ((val * 127 + 36) / 72) -#define MM_TO_TWIPS(val) ((val * 72 + 63) / 127) - class SVXCORE_DLLPUBLIC SvxDrawPage : protected cppu::BaseMutex, public ::cppu::WeakAggImplHelper7< css::drawing::XDrawPage, css::drawing::XShapeGrouper, diff --git a/include/tools/helpers.hxx b/include/tools/helpers.hxx index e105ed355b66..381ecb206d18 100644 --- a/include/tools/helpers.hxx +++ b/include/tools/helpers.hxx @@ -6,8 +6,7 @@ * 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/. */ -#ifndef INCLUDED_TOOLS_HELPERS_HXX -#define INCLUDED_TOOLS_HELPERS_HXX +#pragma once #include <sal/config.h> #include <sal/types.h> @@ -127,6 +126,10 @@ inline sal_Int64 sanitiseMm100ToTwip(sal_Int64 n) return n / 127; // 127 is 2,540 100th-mm divided by 20pts } -#endif +/** +* Convert Twips <-> 100th-mm +*/ +inline constexpr sal_Int64 TwipsToHMM(sal_Int64 nTwips) { return (nTwips * 127 + 36) / 72; } +inline constexpr sal_Int64 HMMToTwips(sal_Int64 nHMM) { return (nHMM * 72 + 63) / 127; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx index e81101f85ec2..6aa8fef0cd04 100644 --- a/oox/source/drawingml/textparagraphpropertiescontext.cxx +++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx @@ -40,6 +40,7 @@ #include <oox/token/namespaces.hxx> #include <oox/token/properties.hxx> #include <oox/token/tokens.hxx> +#include <tools/helpers.hxx> using namespace ::oox::core; using namespace ::com::sun::star::uno; @@ -304,7 +305,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl { TextSpacing& rSpacing = mrTextParagraphProperties.getParaTopMargin(); rSpacing.nUnit = TextSpacing::Unit::Points; - rSpacing.nValue = TWIPS_TO_MM(oBefore.get()); + rSpacing.nValue = TwipsToHMM(oBefore.get()); rSpacing.bHasValue = true; } else @@ -328,7 +329,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl { TextSpacing& rSpacing = mrTextParagraphProperties.getParaBottomMargin(); rSpacing.nUnit = TextSpacing::Unit::Points; - rSpacing.nValue = TWIPS_TO_MM(oAfter.get()); + rSpacing.nValue = TwipsToHMM(oAfter.get()); rSpacing.bHasValue = true; } else @@ -358,7 +359,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl else { rLineSpacing.nUnit = TextSpacing::Unit::Points; - rLineSpacing.nValue = TWIPS_TO_MM(oLineSpacing.get()); + rLineSpacing.nValue = TwipsToHMM(oLineSpacing.get()); } rLineSpacing.bHasValue = true; } diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index f1a3559aa6ad..0a510bf0aad6 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -107,8 +107,6 @@ const SCSIZE MAXSUBTOTAL = 3; namespace sc { - inline ::tools::Long TwipsToHMM( ::tools::Long nTwips ) { return (nTwips * 127 + 36) / 72; } - inline ::tools::Long HMMToTwips( ::tools::Long nHMM ) { return (nHMM * 72 + 63) / 127; } inline ::tools::Long TwipsToEvenHMM( ::tools::Long nTwips ) { return ( (nTwips * 127 + 72) / 144 ) * 2; } } diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 051292ea52e6..aa691d53a754 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -797,12 +797,12 @@ void ScBootstrapFixture::miscRowHeightsTest( TestParam const * aTestValues, unsi SCTAB nTab = aTestValues[ index ].pData[ i ].nTab; int nExpectedHeight = aTestValues[ index ].pData[ i ].nExpectedHeight; if ( nExpectedHeight == -1 ) - nExpectedHeight = sc::TwipsToHMM( ScGlobal::GetStandardRowHeight() ); + nExpectedHeight = TwipsToHMM( ScGlobal::GetStandardRowHeight() ); bool bCheckOpt = ( ( aTestValues[ index ].pData[ i ].nCheck & CHECK_OPTIMAL ) == CHECK_OPTIMAL ); for ( ; nRow <= nEndRow; ++nRow ) { SAL_INFO( "sc.qa", " checking row " << nRow << " for height " << nExpectedHeight ); - int nHeight = sc::TwipsToHMM( rDoc.GetRowHeight(nRow, nTab, false) ); + int nHeight = TwipsToHMM( rDoc.GetRowHeight(nRow, nTab, false) ); if ( bCheckOpt ) { bool bOpt = !(rDoc.GetRowFlags( nRow, nTab ) & CRFlags::ManualSize); diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 89a5eb084244..a8e62602713b 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -3093,7 +3093,7 @@ void ScFiltersTest::testOptimalHeightReset() ScDocument& rDoc = xDocSh->GetDocument(); // open document in read/write mode ( otherwise optimal height stuff won't // be triggered ) *and* you can't delete cell contents. - int nHeight = sc::TwipsToHMM ( rDoc.GetRowHeight(nRow, nTab, false) ); + int nHeight = TwipsToHMM ( rDoc.GetRowHeight(nRow, nTab, false) ); CPPUNIT_ASSERT_EQUAL(1236, nHeight); ScDocFunc &rFunc = xDocSh->GetDocFunc(); @@ -3106,14 +3106,14 @@ void ScFiltersTest::testOptimalHeightReset() CPPUNIT_ASSERT_MESSAGE("DeleteContents failed", bRet); // get the new height of A1 - nHeight = sc::TwipsToHMM( rDoc.GetRowHeight(nRow, nTab, false) ); + nHeight = TwipsToHMM( rDoc.GetRowHeight(nRow, nTab, false) ); // set optimal height for empty row 2 std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(2,2)); rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true); // retrieve optimal height - int nOptimalHeight = sc::TwipsToHMM( rDoc.GetRowHeight(aRowArr[0].mnStart, nTab, false) ); + int nOptimalHeight = TwipsToHMM( rDoc.GetRowHeight(aRowArr[0].mnStart, nTab, false) ); // check if the new height of A1 ( after delete ) is now the optimal height of an empty cell CPPUNIT_ASSERT_EQUAL(nOptimalHeight, nHeight ); diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index cbf2267ce07e..28533ea54e43 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5703,10 +5703,10 @@ void Test::testAnchoredRotatedShape() CPPUNIT_ASSERT_MESSAGE("must have a draw layer", pDrawLayer != nullptr); SdrPage* pPage = pDrawLayer->GetPage(0); CPPUNIT_ASSERT_MESSAGE("must have a draw page", pPage != nullptr); - m_pDoc->SetRowHeightRange( 0, MAXROW, 0, sc::HMMToTwips( 1000 ) ); + m_pDoc->SetRowHeightRange( 0, MAXROW, 0, HMMToTwips( 1000 ) ); constexpr tools::Long TOLERANCE = 30; //30 hmm for ( SCCOL nCol = 0; nCol < MAXCOL; ++nCol ) - m_pDoc->SetColWidth( nCol, 0, sc::HMMToTwips( 1000 ) ); + m_pDoc->SetColWidth( nCol, 0, HMMToTwips( 1000 ) ); { //Add a rect tools::Rectangle aRect( 4000, 5000, 10000, 7000 ); @@ -5738,9 +5738,9 @@ void Test::testAnchoredRotatedShape() m_pDoc->SetDrawPageSize(0); // increase row 5 by 2000 hmm - m_pDoc->SetRowHeight( 5, 0, sc::HMMToTwips( 3000 ) ); + m_pDoc->SetRowHeight( 5, 0, HMMToTwips( 3000 ) ); // increase col 6 by 1000 hmm - m_pDoc->SetColWidth( 6, 0, sc::HMMToTwips( 2000 ) ); + m_pDoc->SetColWidth( 6, 0, HMMToTwips( 2000 ) ); aRotRect.setWidth( aRotRect.GetWidth() + 1000 ); aRotRect.setHeight( aRotRect.GetHeight() + 2000 ); diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 3d2eb834a6c0..6142cc35fb60 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -204,24 +204,13 @@ ScTabSizeChangedHint::~ScTabSizeChangedHint() #define MAXMM 10000000 -static tools::Long TwipsToHmm (tools::Long nVal) -{ - return static_cast< tools::Long >( vcl::ConvertDoubleValue (static_cast<sal_Int64>(nVal), 0, 0, - FieldUnit::TWIP, FieldUnit::MM_100TH) ); -} - -static tools::Long HmmToTwips (tools::Long nVal) -{ - return static_cast< tools::Long > ( vcl::ConvertDoubleValue (static_cast<sal_Int64>(nVal), 0, 0, - FieldUnit::MM_100TH, FieldUnit::TWIP) ); -} static void lcl_ReverseTwipsToMM( tools::Rectangle& rRect ) { - rRect.SetLeft( HmmToTwips( rRect.Left() ) ); - rRect.SetRight( HmmToTwips( rRect.Right() ) ); - rRect.SetTop( HmmToTwips( rRect.Top()) ); - rRect.SetBottom( HmmToTwips(rRect.Bottom()) ); + rRect.SetLeft( HMMToTwips( rRect.Left() ) ); + rRect.SetRight( HMMToTwips( rRect.Right() ) ); + rRect.SetTop( HMMToTwips( rRect.Top()) ); + rRect.SetBottom( HMMToTwips(rRect.Bottom()) ); } static ScRange lcl_getClipRangeFromClipDoc(ScDocument* pClipDoc, SCTAB nClipTab) @@ -764,8 +753,8 @@ void ScDrawLayer::ResizeLastRectFromAnchor(const SdrObject* pObj, ScDrawObjData& SCTAB nTab2 = rData.maEnd.Tab(); Point aPos(pDoc->GetColOffset(nCol1, nTab1, /*bHiddenAsZero*/true), pDoc->GetRowOffset(nRow1, nTab1, /*bHiddenAsZero*/true)); - aPos.setX(TwipsToHmm(aPos.X())); - aPos.setY(TwipsToHmm(aPos.Y())); + aPos.setX(TwipsToHMM(aPos.X())); + aPos.setY(TwipsToHMM(aPos.Y())); aPos += lcl_calcAvailableDiff(*pDoc, nCol1, nRow1, nTab1, rData.maStartOffset); // this sets the needed changed position (translation) @@ -784,8 +773,8 @@ void ScDrawLayer::ResizeLastRectFromAnchor(const SdrObject* pObj, ScDrawObjData& { Point aEnd(pDoc->GetColOffset(nCol2, nTab2, /*bHiddenAsZero*/true), pDoc->GetRowOffset(nRow2, nTab2, /*bHiddenAsZero*/true)); - aEnd.setX(TwipsToHmm(aEnd.X())); - aEnd.setY(TwipsToHmm(aEnd.Y())); + aEnd.setX(TwipsToHMM(aEnd.X())); + aEnd.setY(TwipsToHMM(aEnd.Y())); aEnd += lcl_calcAvailableDiff(*pDoc, nCol2, nRow2, nTab2, rData.maEndOffset); aRect = tools::Rectangle(aPos, aEnd); @@ -1094,8 +1083,8 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati aPos.AdjustX(pDoc->GetColWidth( nCol1, nTab1 ) / 4 ); if (!pDoc->RowHidden(nRow1, nTab1, nullptr, &nLastRow)) aPos.AdjustY(pDoc->GetRowHeight( nRow1, nTab1 ) / 2 ); - aPos.setX(TwipsToHmm( aPos.X() )); - aPos.setY(TwipsToHmm( aPos.Y() )); + aPos.setX(TwipsToHMM( aPos.X() )); + aPos.setY(TwipsToHMM( aPos.Y() )); Point aStartPos = aPos; if ( bNegativePage ) aStartPos.setX( -aStartPos.X() ); // don't modify aPos - used below @@ -1132,8 +1121,8 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati aPos.AdjustX(pDoc->GetColWidth( nCol2, nTab2 ) / 4 ); if (!pDoc->RowHidden(nRow2, nTab2, nullptr, &nLastRow)) aPos.AdjustY(pDoc->GetRowHeight( nRow2, nTab2 ) / 2 ); - aPos.setX(TwipsToHmm( aPos.X() )); - aPos.setY(TwipsToHmm( aPos.Y() )); + aPos.setX(TwipsToHMM( aPos.X() )); + aPos.setY(TwipsToHMM( aPos.Y() )); Point aEndPos = aPos; if ( bNegativePage ) aEndPos.setX( -aEndPos.X() ); // don't modify aPos - used below @@ -1279,16 +1268,16 @@ bool ScDrawLayer::GetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) co SCCOL nEndCol = rRange.aEnd.Col(); for (i=nStartCol; i<=nEndCol; i++) nEndX += pDoc->GetColWidth(i,nTab); - nStartX = TwipsToHmm( nStartX ); - nEndX = TwipsToHmm( nEndX ); + nStartX = TwipsToHMM( nStartX ); + nEndX = TwipsToHMM( nEndX ); } if (!bSetVer) { nStartY = pDoc->GetRowHeight( 0, rRange.aStart.Row()-1, nTab); nEndY = nStartY + pDoc->GetRowHeight( rRange.aStart.Row(), rRange.aEnd.Row(), nTab); - nStartY = TwipsToHmm( nStartY ); - nEndY = TwipsToHmm( nEndY ); + nStartY = TwipsToHMM( nStartY ); + nEndY = TwipsToHMM( nEndY ); } if ( bNegativePage ) @@ -1347,8 +1336,8 @@ bool ScDrawLayer::GetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) co if (bSetHor) { - nStartX = HmmToTwips( nStartX ); - nEndX = HmmToTwips( nEndX ); + nStartX = HMMToTwips( nStartX ); + nEndX = HMMToTwips( nEndX ); tools::Long nWidth; nWidth = 0; @@ -1384,8 +1373,8 @@ bool ScDrawLayer::GetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) co if (bSetVer) { - nStartY = HmmToTwips( nStartY ); - nEndY = HmmToTwips( nEndY ); + nStartY = HMMToTwips( nStartY ); + nEndY = HMMToTwips( nEndY ); SCROW nRow = pDoc->GetRowForHeight( nTab, nStartY); rRange.aStart.SetRow( nRow>0 ? (nRow-1) : 0); nRow = pDoc->GetRowForHeight( nTab, nEndY); @@ -1506,10 +1495,10 @@ bool ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow ) { aTestRect.SetBottom( aTestRect.Top() ); aTestRect.AdjustBottom(pDoc->GetRowHeight( nStartRow, nEndRow, nTab) ); - aTestRect.SetBottom(TwipsToHmm( aTestRect.Bottom() )); + aTestRect.SetBottom(TwipsToHMM( aTestRect.Bottom() )); } - aTestRect.SetTop(TwipsToHmm( aTestRect.Top() )); + aTestRect.SetTop(TwipsToHMM( aTestRect.Top() )); aTestRect.SetLeft( 0 ); aTestRect.SetRight( MAXMM ); diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 2f77588165d2..8db02dcda632 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -49,6 +49,7 @@ #include <svl/zforlist.hxx> #include <vcl/outdev.hxx> #include <tools/fract.hxx> +#include <tools/helpers.hxx> #include <osl/diagnose.h> #include <attrib.hxx> @@ -65,9 +66,6 @@ #include <fillinfo.hxx> #include <boost/functional/hash.hpp> -using sc::HMMToTwips; -using sc::TwipsToHMM; - ScPatternAttr::ScPatternAttr( std::unique_ptr<SfxItemSet>&& pItemSet, const OUString& rStyleName ) : SfxSetItem ( ATTR_PATTERN, std::move(pItemSet) ), pName ( rStyleName ), diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx index a93d114ff797..d70d2eb80d1f 100644 --- a/sc/source/core/tool/docoptio.cxx +++ b/sc/source/core/tool/docoptio.cxx @@ -18,6 +18,7 @@ */ #include <svl/zforlist.hxx> +#include <tools/helpers.hxx> #include <osl/diagnose.h> #include <com/sun/star/uno/Any.hxx> @@ -31,7 +32,6 @@ using namespace utl; using namespace com::sun::star::uno; -using sc::HMMToTwips; using sc::TwipsToEvenHMM; static sal_uInt16 lcl_GetDefaultTabDist() diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index 219110c1a439..6596ea369060 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -25,6 +25,7 @@ #include <scitems.hxx> #include <svl/intitem.hxx> #include <svl/stritem.hxx> +#include <tools/helpers.hxx> #include <editeng/flditem.hxx> #include <document.hxx> #include <dociter.hxx> @@ -1631,7 +1632,7 @@ XclExpColinfo::XclExpColinfo( const XclExpRoot& rRoot, // column width. If column is hidden then we should return real value (not zero) sal_uInt16 nScWidth = rDoc.GetColWidth( nScCol, nScTab, false ); mnWidth = XclTools::GetXclColumnWidth( nScWidth, GetCharWidth() ); - mnScWidth = sc::TwipsToHMM( nScWidth ); + mnScWidth = TwipsToHMM( nScWidth ); // column flags ::set_flag( mnFlags, EXC_COLINFO_HIDDEN, rDoc.ColHidden(nScCol, nScTab) ); @@ -1688,7 +1689,7 @@ void XclExpColinfo::WriteBody( XclExpStream& rStrm ) void XclExpColinfo::SaveXml( XclExpXmlStream& rStrm ) { - const double nExcelColumnWidth = mnScWidth / static_cast< double >( sc::TwipsToHMM( GetCharWidth() ) ); + const double nExcelColumnWidth = mnScWidth / static_cast< double >( TwipsToHMM( GetCharWidth() ) ); // tdf#101363 In MS specification the output value is set with double precision after delimiter: // =Truncate(({width in pixels} - 5)/{Maximum Digit Width} * 100 + 0.5)/100 diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 110ce64ba79c..737a9a432709 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -73,6 +73,7 @@ #include <editeng/eeitem.hxx> #include <editeng/editobj.hxx> #include <editeng/flditem.hxx> +#include <tools/helpers.hxx> namespace oox::xls { @@ -1186,7 +1187,7 @@ void WorksheetGlobals::convertColumns( OutlineLevelVec& orColLevels, { for( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol ) { - rDoc.SetColWidthOnly( nCol, nTab, static_cast<sal_uInt16>(sc::HMMToTwips( nWidth )) ); + rDoc.SetColWidthOnly( nCol, nTab, static_cast<sal_uInt16>(HMMToTwips( nWidth )) ); } } @@ -1239,7 +1240,7 @@ void WorksheetGlobals::convertRows( OutlineLevelVec& orRowLevels, { /* always import the row height, ensures better layout */ ScDocument& rDoc = getScDocument(); - rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, static_cast<sal_uInt16>(sc::HMMToTwips(nHeight)) ); + rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, static_cast<sal_uInt16>(HMMToTwips(nHeight)) ); if(rModel.mbCustomHeight) rDoc.SetManualHeight( nStartRow, nEndRow, nTab, true ); } diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index a12d8d1c9f2f..f332a27d1b93 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -44,6 +44,7 @@ #include <cppuhelper/supportsservice.hxx> #include <float.h> #include <tools/diagnose_ex.h> +#include <tools/helpers.hxx> #include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/util/CellProtection.hpp> @@ -869,9 +870,6 @@ static const SvxItemPropertySet* lcl_GetEditPropertySet() return &aEditPropertySet; } -using sc::HMMToTwips; -using sc::TwipsToHMM; - #define SCCHARPROPERTIES_SERVICE "com.sun.star.style.CharacterProperties" #define SCPARAPROPERTIES_SERVICE "com.sun.star.style.ParagraphProperties" #define SCCELLPROPERTIES_SERVICE "com.sun.star.table.CellProperties" diff --git a/sc/source/ui/unoobj/defltuno.cxx b/sc/source/ui/unoobj/defltuno.cxx index 72618aa4f37f..923178244dbc 100644 --- a/sc/source/ui/unoobj/defltuno.cxx +++ b/sc/source/ui/unoobj/defltuno.cxx @@ -20,6 +20,7 @@ #include <editeng/memberids.h> #include <svl/hint.hxx> #include <svl/itemprop.hxx> +#include <tools/helpers.hxx> #include <vcl/svapp.hxx> #include <i18nlangtag/languagetag.hxx> @@ -65,7 +66,6 @@ static const SfxItemPropertyMapEntry* lcl_GetDocDefaultsMap() return aDocDefaultsMap_Impl; } -using sc::HMMToTwips; using sc::TwipsToEvenHMM; SC_SIMPLE_SERVICE_INFO( ScDocDefaultsObj, "ScDocDefaultsObj", "com.sun.star.sheet.Defaults" ) diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 2bdcf14ab49c..47d1e1f85bf2 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -222,9 +222,6 @@ static const SfxItemPropertyMapEntry* lcl_GetRowsPropertyMap() return aRowsPropertyMap_Impl; } -using sc::HMMToTwips; -using sc::TwipsToHMM; - #define SCMODELOBJ_SERVICE "com.sun.star.sheet.SpreadsheetDocument" #define SCDOCSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetDocumentSettings" #define SCDOC_SERVICE "com.sun.star.document.OfficeDocument" diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index 8df4b3518314..55c317f81901 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -37,6 +37,7 @@ #include <svl/intitem.hxx> #include <svl/zformat.hxx> #include <tools/fract.hxx> +#include <tools/helpers.hxx> #include <osl/diagnose.h> #include <com/sun/star/table/BorderLine.hpp> @@ -385,9 +386,6 @@ static const SfxItemPropertyMap* lcl_GetFooterStyleMap() const SfxStyleFamily aStyleFamilyTypes[SC_STYLE_FAMILY_COUNT] = { SfxStyleFamily::Para, SfxStyleFamily::Page }; -using sc::HMMToTwips; -using sc::TwipsToHMM; - #define SCSTYLE_SERVICE "com.sun.star.style.Style" #define SCCELLSTYLE_SERVICE "com.sun.star.style.CellStyle" #define SCPAGESTYLE_SERVICE "com.sun.star.style.PageStyle" diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index b9442a3ce98b..040b01178f62 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -52,7 +52,6 @@ #define IS_EDITMODE() GetViewData().HasEditView( GetViewData().GetActivePart() ) -using sc::HMMToTwips; using sc::TwipsToEvenHMM; namespace diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 7b213050bf31..bb6d3834cdc4 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -958,8 +958,8 @@ void ScDrawView::SyncForGrid( SdrObject* pObj ) MapMode aDrawMode = pGridWin->GetDrawMapMode(); // find pos anchor position Point aOldPos( rDoc.GetColOffset( aOldStt.Col(), aOldStt.Tab() ), rDoc.GetRowOffset( aOldStt.Row(), aOldStt.Tab() ) ); - aOldPos.setX( sc::TwipsToHMM( aOldPos.X() ) ); - aOldPos.setY( sc::TwipsToHMM( aOldPos.Y() ) ); + aOldPos.setX( TwipsToHMM( aOldPos.X() ) ); + aOldPos.setY( TwipsToHMM( aOldPos.Y() ) ); // find position of same point on the screen ( e.g. grid ) Point aCurPos = pViewData->GetScrPos( aOldStt.Col(), aOldStt.Row(), eWhich, true ); Point aCurPosHmm = pGridWin->PixelToLogic(aCurPos, aDrawMode ); @@ -1035,8 +1035,8 @@ bool ScDrawView::calculateGridOffsetForSdrObject( // find pos anchor position Point aOldPos(rDoc.GetColOffset(aOldStt.Col(), aOldStt.Tab()), rDoc.GetRowOffset(aOldStt.Row(), aOldStt.Tab())); - aOldPos.setX(sc::TwipsToHMM(aOldPos.X())); - aOldPos.setY(sc::TwipsToHMM(aOldPos.Y())); + aOldPos.setX(TwipsToHMM(aOldPos.X())); + aOldPos.setY(TwipsToHMM(aOldPos.Y())); // find position of same point on the screen ( e.g. grid ) ScSplitPos eWhich(pViewData->GetActivePart()); @@ -1083,8 +1083,8 @@ bool ScDrawView::calculateGridOffsetForB2DRange( // find pos anchor position Point aOldPos(rDoc.GetColOffset(aOldStt.Col(), aOldStt.Tab()), rDoc.GetRowOffset(aOldStt.Row(), aOldStt.Tab())); - aOldPos.setX(sc::TwipsToHMM(aOldPos.X())); - aOldPos.setY(sc::TwipsToHMM(aOldPos.Y())); + aOldPos.setX(TwipsToHMM(aOldPos.X())); + aOldPos.setY(TwipsToHMM(aOldPos.Y())); // find position of same point on the screen ( e.g. grid ) ScSplitPos eWhich(pViewData->GetActivePart()); diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx index 1550b733c522..a2e5f43c9d56 100644 --- a/sc/source/ui/view/tabvwsh2.cxx +++ b/sc/source/ui/view/tabvwsh2.cxx @@ -337,8 +337,8 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs)) aInsertPos = rViewData.GetPrintTwipsPosFromTileTwips(aInsertPos); - aInsertPos.setX(sc::TwipsToHMM(aInsertPos.X())); - aInsertPos.setY(sc::TwipsToHMM(aInsertPos.Y())); + aInsertPos.setX(TwipsToHMM(aInsertPos.X())); + aInsertPos.setY(TwipsToHMM(aInsertPos.Y())); aInsertPos.AdjustX( -sal_Int32(nDefaultObjectSizeWidth / 2) ); aInsertPos.AdjustY( -sal_Int32(nDefaultObjectSizeHeight / 2) ); diff --git a/svx/source/table/tablertfexporter.cxx b/svx/source/table/tablertfexporter.cxx index 10707cbc1c21..f3cde67471b5 100644 --- a/svx/source/table/tablertfexporter.cxx +++ b/svx/source/table/tablertfexporter.cxx @@ -77,12 +77,6 @@ SdrTableRtfExporter::SdrTableRtfExporter( SvStream& rStrm, SdrTableObj& rObj ) { } -static tools::Long HundMMToTwips( tools::Long nIn ) -{ - tools::Long nRet = OutputDevice::LogicToLogic( nIn, MapUnit::Map100thMM, MapUnit::MapTwip ); - return nRet; -} - void SdrTableRtfExporter::Write() { mrStrm.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_RTF ); @@ -101,7 +95,7 @@ void SdrTableRtfExporter::Write() Reference< XPropertySet > xSet( xColumns->getByIndex(nCol), UNO_QUERY_THROW ); sal_Int32 nWidth = 0; xSet->getPropertyValue( gsSize ) >>= nWidth; - nPos += HundMMToTwips( nWidth ); + nPos += HMMToTwips( nWidth ); aColumnStart.push_back( nPos ); } catch( Exception& ) diff --git a/svx/source/table/tablertfimporter.cxx b/svx/source/table/tablertfimporter.cxx index c2f510444f8a..cdf25aa67306 100644 --- a/svx/source/table/tablertfimporter.cxx +++ b/svx/source/table/tablertfimporter.cxx @@ -381,12 +381,6 @@ void SdrTableRTFParser::NextColumn() mpActDefault = nullptr; } -static tools::Long TwipsToHundMM( tools::Long nIn ) -{ - tools::Long nRet = OutputDevice::LogicToLogic( nIn, MapUnit::MapTwip, MapUnit::Map100thMM ); - return nRet; -} - void SdrTableRTFParser::ProcToken( RtfImportInfo* pInfo ) { switch ( pInfo->nToken ) @@ -435,7 +429,7 @@ void SdrTableRTFParser::ProcToken( RtfImportInfo* pInfo ) maDefaultList.push_back( pDefault ); - const sal_Int32 nSize = TwipsToHundMM( pInfo->nTokenValue ); + const sal_Int32 nSize = TwipsToHMM( pInfo->nTokenValue ); if ( nSize > mnLastEdge ) InsertColumnEdge( nSize ); diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index a545aaa6c44e..74f71049db2d 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -464,8 +464,8 @@ void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw() { case MapUnit::MapTwip : { - rPoint.A() = MM_TO_TWIPS(rPoint.A()); - rPoint.B() = MM_TO_TWIPS(rPoint.B()); + rPoint.A() = HMMToTwips(rPoint.A()); + rPoint.B() = HMMToTwips(rPoint.B()); break; } default: @@ -548,8 +548,8 @@ void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw() { case MapUnit::MapTwip : { - rPoint.A() = TWIPS_TO_MM(rPoint.A()); - rPoint.B() = TWIPS_TO_MM(rPoint.B()); + rPoint.A() = TwipsToHMM(rPoint.A()); + rPoint.B() = TwipsToHMM(rPoint.B()); break; } default: diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 46811d5855d2..94f0d5abac78 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -862,15 +862,15 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u if (aValue >>= nValue) { if (bAdjustX) - nValue += TWIPS_TO_MM(aRect.getX()); + nValue += TwipsToHMM(aRect.getX()); else if (bAdjustY) - nValue += TWIPS_TO_MM(aRect.getY()); + nValue += TwipsToHMM(aRect.getY()); aValue <<= nValue; } } else if (bAdjustSize) { - awt::Size aSize(TWIPS_TO_MM(aRect.getWidth()), TWIPS_TO_MM(aRect.getHeight())); + awt::Size aSize(TwipsToHMM(aRect.getWidth()), TwipsToHMM(aRect.getHeight())); aValue <<= aSize; } } diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index fa1c5ea5c48f..e6d75e7ceeba 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -3041,8 +3041,8 @@ void SwMSConvertControls::ExportControl(WW8Export &rWW8Wrt, const SdrUnoObj& rFo tools::Rectangle aRect = rFormObj.GetLogicRect(); aRect.SetPos(Point(0,0)); awt::Size aSize; - aSize.Width = TWIPS_TO_MM(aRect.Right()); - aSize.Height = TWIPS_TO_MM(aRect.Bottom()); + aSize.Width = TwipsToHMM(aRect.Right()); + aSize.Height = TwipsToHMM(aRect.Bottom()); //Open the ObjectPool tools::SvRef<SotStorage> xObjPool = rWW8Wrt.GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool); |