diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-08-11 13:13:35 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-08-11 14:19:24 +0200 |
commit | bfed58821fc3a83fec4a985087cd45fa963bed3e (patch) | |
tree | 427156ed03b2b72069e47d9f1250dc36670c09cf /sc | |
parent | c46950fee11f5207fb8324947280cd565ae483e7 (diff) |
Drop convertMm100ToTwip in favor of the new o3tl::toTwips
Step by step, duplicates from <tools/UnitConversion.hxx> may go
Change-Id: Id4c03ff8adc120ae06dbfdbdfb4f5ff0bb51f489
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120315
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 8 | ||||
-rw-r--r-- | sc/source/core/data/drwlayer.cxx | 13 | ||||
-rw-r--r-- | sc/source/core/data/patattr.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/docoptio.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/oox/worksheethelper.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/unoobj/defltuno.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/unoobj/styleuno.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh3.cxx | 12 |
10 files changed, 33 insertions, 36 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 5f2145714e3a..18dec103b552 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5125,10 +5125,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, convertMm100ToTwip(1000)); + m_pDoc->SetRowHeightRange(0, MAXROW, 0, o3tl::toTwips(1000, o3tl::Length::mm100)); constexpr tools::Long TOLERANCE = 30; //30 hmm for ( SCCOL nCol = 0; nCol < MAXCOL; ++nCol ) - m_pDoc->SetColWidth(nCol, 0, convertMm100ToTwip(1000)); + m_pDoc->SetColWidth(nCol, 0, o3tl::toTwips(1000, o3tl::Length::mm100)); { //Add a rect tools::Rectangle aRect( 4000, 5000, 10000, 7000 ); @@ -5160,9 +5160,9 @@ void Test::testAnchoredRotatedShape() m_pDoc->SetDrawPageSize(0); // increase row 5 by 2000 hmm - m_pDoc->SetRowHeight(5, 0, convertMm100ToTwip(3000)); + m_pDoc->SetRowHeight(5, 0, o3tl::toTwips(3000, o3tl::Length::mm100)); // increase col 6 by 1000 hmm - m_pDoc->SetColWidth(6, 0, convertMm100ToTwip(2000)); + m_pDoc->SetColWidth(6, 0, o3tl::toTwips(2000, o3tl::Length::mm100)); 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 79b52627e015..58c9b8585ecf 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -209,10 +209,7 @@ ScTabSizeChangedHint::~ScTabSizeChangedHint() static void lcl_ReverseTwipsToMM( tools::Rectangle& rRect ) { - rRect.SetLeft(convertMm100ToTwip(rRect.Left())); - rRect.SetRight(convertMm100ToTwip(rRect.Right())); - rRect.SetTop(convertMm100ToTwip(rRect.Top())); - rRect.SetBottom(convertMm100ToTwip(rRect.Bottom())); + rRect = o3tl::convert(rRect, o3tl::Length::mm100, o3tl::Length::twip); } static ScRange lcl_getClipRangeFromClipDoc(ScDocument* pClipDoc, SCTAB nClipTab) @@ -1344,8 +1341,8 @@ bool ScDrawLayer::GetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) co if (bSetHor) { - nStartX = convertMm100ToTwip(nStartX); - nEndX = convertMm100ToTwip(nEndX); + nStartX = o3tl::toTwips(nStartX, o3tl::Length::mm100); + nEndX = o3tl::toTwips(nEndX, o3tl::Length::mm100); tools::Long nWidth; nWidth = 0; @@ -1381,8 +1378,8 @@ bool ScDrawLayer::GetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) co if (bSetVer) { - nStartY = convertMm100ToTwip(nStartY); - nEndY = convertMm100ToTwip(nEndY); + nStartY = o3tl::toTwips(nStartY, o3tl::Length::mm100); + nEndY = o3tl::toTwips(nEndY, o3tl::Length::mm100); SCROW nRow = pDoc->GetRowForHeight( nTab, nStartY); rRange.aStart.SetRow( nRow>0 ? (nRow-1) : 0); nRow = pDoc->GetRowForHeight( nTab, nEndY); diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index fb8e7aee033f..5ce565a98257 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -792,13 +792,13 @@ void ScPatternAttr::GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rDestSet.Put( *static_cast<const SvxFontItem*>(pItem), ATTR_CTL_FONT ); if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT,true,&pItem) == SfxItemState::SET) - rDestSet.Put( SvxFontHeightItem( convertMm100ToTwip( static_cast<const SvxFontHeightItem*>(pItem)->GetHeight() ), + rDestSet.Put( SvxFontHeightItem(o3tl::toTwips(static_cast<const SvxFontHeightItem*>(pItem)->GetHeight(), o3tl::Length::mm100), 100, ATTR_FONT_HEIGHT ) ); if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT_CJK,true,&pItem) == SfxItemState::SET) - rDestSet.Put( SvxFontHeightItem( convertMm100ToTwip( static_cast<const SvxFontHeightItem*>(pItem)->GetHeight() ), + rDestSet.Put( SvxFontHeightItem(o3tl::toTwips(static_cast<const SvxFontHeightItem*>(pItem)->GetHeight(), o3tl::Length::mm100), 100, ATTR_CJK_FONT_HEIGHT ) ); if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT_CTL,true,&pItem) == SfxItemState::SET) - rDestSet.Put( SvxFontHeightItem( convertMm100ToTwip( static_cast<const SvxFontHeightItem*>(pItem)->GetHeight() ), + rDestSet.Put( SvxFontHeightItem(o3tl::toTwips(static_cast<const SvxFontHeightItem*>(pItem)->GetHeight(), o3tl::Length::mm100), 100, ATTR_CTL_FONT_HEIGHT ) ); if (rEditSet.GetItemState(EE_CHAR_WEIGHT,true,&pItem) == SfxItemState::SET) diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx index 5810bff6e8ea..2b54cd2a52d1 100644 --- a/sc/source/core/tool/docoptio.cxx +++ b/sc/source/core/tool/docoptio.cxx @@ -272,7 +272,7 @@ ScDocCfg::ScDocCfg() : case SCDOCLAYOUTOPT_TABSTOP: // TabDistance in ScDocOptions is in twips if (pValues[nProp] >>= nIntVal) - SetTabDistance(static_cast<sal_uInt16>(convertMm100ToTwip(nIntVal))); + SetTabDistance(o3tl::toTwips(nIntVal, o3tl::Length::mm100)); break; } } diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 6d07bfd57cad..a5fc023f8a99 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -1222,7 +1222,7 @@ void WorksheetGlobals::convertColumns( OutlineLevelVec& orColLevels, { for( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol ) { - rDoc.SetColWidthOnly(nCol, nTab, static_cast<sal_uInt16>(convertMm100ToTwip(nWidth))); + rDoc.SetColWidthOnly(nCol, nTab, o3tl::toTwips(nWidth, o3tl::Length::mm100)); } } @@ -1278,7 +1278,7 @@ void WorksheetGlobals::convertRows(OutlineLevelVec& orRowLevels, const ValueRang /* always import the row height, ensures better layout */ ScDocument& rDoc = getScDocument(); rDoc.SetRowHeightOnly(nStartRow, nEndRow, nTab, - static_cast<sal_uInt16>(convertMm100ToTwip(nHeight))); + o3tl::toTwips(nHeight, o3tl::Length::mm100)); 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 21be10d87a39..8828d4dd2af8 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -951,7 +951,7 @@ template<typename TableBorderType> void lcl_fillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const TableBorderType& rBorder ) { ::editeng::SvxBorderLine aLine; - rOuter.SetAllDistances(static_cast<sal_uInt16>(convertMm100ToTwip(rBorder.Distance))); + rOuter.SetAllDistances(o3tl::toTwips(rBorder.Distance, o3tl::Length::mm100)); rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.TopLine ), SvxBoxItemLine::TOP ); rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.BottomLine ), SvxBoxItemLine::BOTTOM ); rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.LeftLine ), SvxBoxItemLine::LEFT ); @@ -2074,7 +2074,7 @@ static void lcl_SetCellProperty( const SfxItemPropertyMapEntry& rEntry, const un if ( !(rValue >>= nIntVal) ) throw lang::IllegalArgumentException(); - rSet.Put(ScIndentItem(static_cast<sal_uInt16>(convertMm100ToTwip(nIntVal)))); + rSet.Put(ScIndentItem(o3tl::toTwips(nIntVal, o3tl::Length::mm100))); } break; @@ -8385,9 +8385,9 @@ void ScTableColumnObj::SetOnePropertyValue(const SfxItemPropertyMapEntry* pEntry if ( aValue >>= nNewWidth ) { // property is 1/100mm, column width is twips - nNewWidth = convertMm100ToTwip(nNewWidth); + nNewWidth = o3tl::toTwips(nNewWidth, o3tl::Length::mm100); rFunc.SetWidthOrHeight( - true, aColArr, nTab, SC_SIZE_ORIGINAL, static_cast<sal_uInt16>(nNewWidth), true, true); + true, aColArr, nTab, SC_SIZE_ORIGINAL, nNewWidth, true, true); } } else if ( pEntry->nWID == SC_WID_UNO_CELLVIS ) @@ -8522,9 +8522,9 @@ void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, if ( aValue >>= nNewHeight ) { // property is 1/100mm, row height is twips - nNewHeight = convertMm100ToTwip(nNewHeight); + nNewHeight = o3tl::toTwips(nNewHeight, o3tl::Length::mm100); rFunc.SetWidthOrHeight( - false, aRowArr, nTab, SC_SIZE_ORIGINAL, static_cast<sal_uInt16>(nNewHeight), true, true); + false, aRowArr, nTab, SC_SIZE_ORIGINAL, nNewHeight, true, true); } } else if ( pEntry->nWID == SC_WID_UNO_CELLVIS ) diff --git a/sc/source/ui/unoobj/defltuno.cxx b/sc/source/ui/unoobj/defltuno.cxx index ae2fe0242892..7015985e5a74 100644 --- a/sc/source/ui/unoobj/defltuno.cxx +++ b/sc/source/ui/unoobj/defltuno.cxx @@ -147,7 +147,7 @@ void SAL_CALL ScDocDefaultsObj::setPropertyValue( sal_Int32 nValue = 0; if (aValue >>= nValue) { - aDocOpt.SetTabDistance(static_cast<sal_uInt16>(convertMm100ToTwip(nValue))); + aDocOpt.SetTabDistance(o3tl::toTwips(nValue, o3tl::Length::mm100)); rDoc.SetDocOptions(aDocOpt); } } diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 5cb03d5aa39b..405f6c11842b 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -4113,7 +4113,7 @@ void SAL_CALL ScTableColumnsObj::setPropertyValue( sal_Int32 nNewWidth = 0; if ( aValue >>= nNewWidth ) rFunc.SetWidthOrHeight( - true, aColArr, nTab, SC_SIZE_ORIGINAL, static_cast<sal_uInt16>(convertMm100ToTwip(nNewWidth)), true, true); + true, aColArr, nTab, SC_SIZE_ORIGINAL, o3tl::toTwips(nNewWidth, o3tl::Length::mm100), true, true); } else if ( aPropertyName == SC_UNONAME_CELLVIS ) { @@ -4328,7 +4328,7 @@ void SAL_CALL ScTableRowsObj::setPropertyValue( // TODO: It's probably cleaner to use a different property name // for this. - rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, static_cast<sal_uInt16>(convertMm100ToTwip(nNewHeight)) ); + rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, o3tl::toTwips(nNewHeight, o3tl::Length::mm100) ); } else { @@ -4351,12 +4351,12 @@ void SAL_CALL ScTableRowsObj::setPropertyValue( // TODO: This is a band-aid fix. Eventually we need to // re-work ods' style import to get it to set styles to // ScDocument directly. - rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, static_cast<sal_uInt16>(convertMm100ToTwip(nNewHeight)) ); + rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, o3tl::toTwips(nNewHeight, o3tl::Length::mm100) ); rDoc.SetManualHeight( nStartRow, nEndRow, nTab, true ); } else rFunc.SetWidthOrHeight( - false, aRowArr, nTab, SC_SIZE_ORIGINAL, static_cast<sal_uInt16>(convertMm100ToTwip(nNewHeight)), true, true); + false, aRowArr, nTab, SC_SIZE_ORIGINAL, o3tl::toTwips(nNewHeight, o3tl::Length::mm100), true, true); } } else if ( aPropertyName == SC_UNONAME_CELLVIS ) diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index 98568aa82994..3ad29af9e515 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -1543,7 +1543,7 @@ void ScStyleObj::setPropertyValue_Impl( std::u16string_view rPropertyName, const { sal_Int16 nVal = 0; *pValue >>= nVal; - rSet.Put(ScIndentItem(static_cast<sal_uInt16>(convertMm100ToTwip(nVal)))); + rSet.Put(ScIndentItem(o3tl::toTwips(nVal, o3tl::Length::mm100))); } break; case ATTR_ROTATE_VALUE: diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index e3f9c79368e0..088c403168d6 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -671,7 +671,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) aRanges.emplace_back(nRow, nRow); } - pTabViewShell->SetWidthOrHeight(false, aRanges, SC_SIZE_DIRECT, convertMm100ToTwip(nHeight)); + pTabViewShell->SetWidthOrHeight(false, aRanges, SC_SIZE_DIRECT, o3tl::toTwips(nHeight, o3tl::Length::mm100)); } else if ( pReqArgs && pReqArgs->HasItem( FID_ROW_HEIGHT, &pHeight ) ) { @@ -679,7 +679,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) // #101390#; the value of the macro is in HMM so use convertMm100ToTwip to convert pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT, - sal::static_int_cast<sal_uInt16>(convertMm100ToTwip(nHeight))); + o3tl::toTwips(nHeight, o3tl::Length::mm100)); if( ! rReq.IsAPI() ) rReq.Done(); } @@ -718,7 +718,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) // #101390#; the value of the macro is in HMM so use convertMm100ToTwip to convert pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL, - sal::static_int_cast<sal_uInt16>( convertMm100ToTwip(rUInt16Item.GetValue()) ) ); + o3tl::toTwips(rUInt16Item.GetValue(), o3tl::Length::mm100) ); ScGlobal::nLastRowHeightExtra = rUInt16Item.GetValue(); if( ! rReq.IsAPI() ) @@ -770,7 +770,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) aRanges.emplace_back(nColumn, nColumn); } - pTabViewShell->SetWidthOrHeight(true, aRanges, SC_SIZE_DIRECT, convertMm100ToTwip(nWidth)); + pTabViewShell->SetWidthOrHeight(true, aRanges, SC_SIZE_DIRECT, o3tl::toTwips(nWidth, o3tl::Length::mm100)); } else if ( pReqArgs && pReqArgs->HasItem( FID_COL_WIDTH, &pWidth ) ) { @@ -778,7 +778,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) // #101390#; the value of the macro is in HMM so use convertMm100ToTwip to convert pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT, - sal::static_int_cast<sal_uInt16>(convertMm100ToTwip(nWidth))); + o3tl::toTwips(nWidth, o3tl::Length::mm100)); if( ! rReq.IsAPI() ) rReq.Done(); } @@ -815,7 +815,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) // #101390#; the value of the macro is in HMM so use convertMm100ToTwip to convert pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL, - sal::static_int_cast<sal_uInt16>( convertMm100ToTwip(rUInt16Item.GetValue()) ) ); + o3tl::toTwips(rUInt16Item.GetValue(), o3tl::Length::mm100) ); ScGlobal::nLastColWidthExtra = rUInt16Item.GetValue(); if( ! rReq.IsAPI() ) |