editeng/source/editeng/editeng.cxx | 28 ++----------- editeng/source/editeng/impedit.hxx | 41 ++++++++------------ editeng/source/editeng/impedit2.cxx | 4 - editeng/source/editeng/impedit3.cxx | 57 ++++++++++++---------------- editeng/source/editeng/impedit4.cxx | 12 +++-- editeng/source/outliner/outlin2.cxx | 15 +++---- editeng/source/outliner/outliner.cxx | 14 ++---- include/editeng/editdata.hxx | 16 +++++++ include/editeng/editeng.hxx | 8 +-- include/editeng/outliner.hxx | 9 +++- sd/qa/unit/TextFittingTest.cxx | 12 ++--- sd/source/ui/view/drtxtob.cxx | 2 svx/source/svdraw/svdotext.cxx | 24 ++++------- svx/source/svdraw/svdotextdecomposition.cxx | 4 + svx/source/svdraw/svdoutl.cxx | 2 15 files changed, 115 insertions(+), 133 deletions(-)
New commits: commit 0b816d1eeb877699018f1bddc22003c6309020e6 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Apr 1 20:12:09 2024 +0900 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Apr 15 09:20:18 2024 +0200 editeng: combine scaling parameters into ScalingParameters struct This makes dealing with scaling parameters much clearer and it improves readability. Change-Id: I327b6530ef5587972cc0075390704754a33563a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165632 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 4bdbf0f898e8642b0a34195537d1516cc8eee819) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165712 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 260e8dfb5038..35d025c45021 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -2265,35 +2265,19 @@ bool EditEngine::HasText( const SvxSearchItem& rSearchItem ) return pImpEditEngine->HasText( rSearchItem ); } -void EditEngine::setGlobalScale(double fFontScaleX, double fFontScaleY, double fSpacingScaleX, double fSpacingScaleY) +ScalingParameters EditEngine::getScalingParameters() const { - pImpEditEngine->setScale(fFontScaleX, fFontScaleY, fSpacingScaleX, fSpacingScaleY); + return pImpEditEngine->getScalingParameters(); } -void EditEngine::getGlobalSpacingScale(double& rX, double& rY) const +void EditEngine::resetScalingParameters() { - pImpEditEngine->getSpacingScale(rX, rY); + pImpEditEngine->resetScalingParameters(); } -basegfx::B2DTuple EditEngine::getGlobalSpacingScale() const +void EditEngine::setScalingParameters(ScalingParameters const& rScalingParameters) { - double x = 0.0; - double y = 0.0; - pImpEditEngine->getSpacingScale(x, y); - return {x, y}; -} - -void EditEngine::getGlobalFontScale(double& rX, double& rY) const -{ - pImpEditEngine->getFontScale(rX, rY); -} - -basegfx::B2DTuple EditEngine::getGlobalFontScale() const -{ - double x = 0.0; - double y = 0.0; - pImpEditEngine->getFontScale(x, y); - return {x, y}; + pImpEditEngine->setScalingParameters(rScalingParameters); } void EditEngine::setRoundFontSizeToPt(bool bRound) const diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 0aabebe2ab46..34d57e8e9747 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -530,10 +530,7 @@ private: Color maBackgroundColor; - double mfFontScaleX; - double mfFontScaleY; - double mfSpacingScaleX; - double mfSpacingScaleY; + ScalingParameters maScalingParameters; bool mbRoundToNearestPt; CharCompressType mnAsianCompressionMode; @@ -739,34 +736,34 @@ private: double scaleXSpacingValue(tools::Long nXValue) const { - if (!maStatus.DoStretch() || mfSpacingScaleX == 100.0) + if (!maStatus.DoStretch() || maScalingParameters.fSpacingX == 100.0) return nXValue; - return double(nXValue) * mfSpacingScaleX / 100.0; + return double(nXValue) * (maScalingParameters.fSpacingX / 100.0); } double scaleYSpacingValue(sal_uInt16 nYValue) const { - if (!maStatus.DoStretch() || mfSpacingScaleY == 100.0) + if (!maStatus.DoStretch() || maScalingParameters.fSpacingY == 100.0) return nYValue; - return double(nYValue) * mfSpacingScaleY / 100.0; + return double(nYValue) * (maScalingParameters.fSpacingY / 100.0); } - double scaleYFontValue(sal_uInt16 nYValue) const + double scaleXFontValue(tools::Long nXValue) const { - if (!maStatus.DoStretch() || (mfFontScaleY == 100.0)) - return nYValue; + if (!maStatus.DoStretch() || (maScalingParameters.fFontX == 100.0)) + return nXValue; - return double(nYValue) * mfFontScaleY / 100.0; + return double(nXValue) * (maScalingParameters.fFontX / 100.0); } - double scaleXFontValue(tools::Long nXValue) const + double scaleYFontValue(sal_uInt16 nYValue) const { - if (!maStatus.DoStretch() || (mfFontScaleX == 100.0)) - return nXValue; + if (!maStatus.DoStretch() || (maScalingParameters.fFontY == 100.0)) + return nYValue; - return double(nXValue) * mfFontScaleY / 100.0; + return double(nYValue) * (maScalingParameters.fFontY / 100.0); } void setRoundToNearestPt(bool bRound) { mbRoundToNearestPt = bRound; } @@ -1114,18 +1111,16 @@ public: SvxCellJustifyMethod GetJustifyMethod( sal_Int32 nPara ) const; SvxCellVerJustify GetVerJustification( sal_Int32 nPara ) const; - void setScale(double fFontScaleX, double fFontScaleY, double fSpacingScaleX, double fSpacingScaleY); + void setScalingParameters(ScalingParameters const& rScalingParameters); - void getFontScale(double& rX, double& rY) const + void resetScalingParameters() { - rX = mfFontScaleX; - rY = mfFontScaleY; + setScalingParameters(ScalingParameters()); } - void getSpacingScale(double& rX, double& rY) const + ScalingParameters getScalingParameters() { - rX = mfSpacingScaleX; - rY = mfSpacingScaleY; + return maScalingParameters; } sal_Int32 GetBigTextObjectStart() const { return mnBigTextObjectStart; } diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index a2ed3c0566ed..8c5265e1304e 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -102,10 +102,6 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) : pUndoManager(nullptr), aWordDelimiters(" .,;:-`'?!_=\"{}()[]"), maBackgroundColor(COL_AUTO), - mfFontScaleX(100.0), - mfFontScaleY(100.0), - mfSpacingScaleX(100.0), - mfSpacingScaleY(100.0), mbRoundToNearestPt(false), mnAsianCompressionMode(CharCompressType::NONE), eDefaultHorizontalTextDirection(EEHorizontalTextDirection::Default), diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 17699870c6e4..79c943516bc7 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -1011,8 +1011,9 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) // Search for Tab-Pos... tools::Long nCurPos = nTmpWidth + nStartX; // consider scaling - if (maStatus.DoStretch() && (mfFontScaleX != 100.0)) - nCurPos = basegfx::fround(double(nCurPos) * 100.0 / std::max(mfFontScaleX, 1.0)); + double fFontScalingX = maScalingParameters.fFontX; + if (maStatus.DoStretch() && (fFontScalingX != 100.0)) + nCurPos = basegfx::fround(double(nCurPos) * 100.0 / std::max(fFontScalingX, 1.0)); short nAllSpaceBeforeText = static_cast< short >(rLRItem.GetTextLeft()/* + rLRItem.GetTextLeft()*/ + nSpaceBeforeAndMinLabelWidth); aCurrentTab.aTabStop = pNode->GetContentAttribs().FindTabStop( nCurPos - nAllSpaceBeforeText /*rLRItem.GetTextLeft()*/, maEditDoc.GetDefTab() ); @@ -1490,7 +1491,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) sal_uInt16 nPropLineSpace = rLSItem.GetPropLineSpace(); double fProportionalScale = double(nPropLineSpace) / 100.0; constexpr const double f80Percent = 8.0 / 10.0; - double fSpacingFactor = mfSpacingScaleY / 100.0; + double fSpacingFactor = maScalingParameters.fSpacingY / 100.0; if (nPropLineSpace && nPropLineSpace < 100) { // Adapted code from sw/source/core/text/itrform2.cxx @@ -1514,9 +1515,9 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) } else if (rLSItem.GetInterLineSpaceRule() == SvxInterLineSpaceRule::Off) { - if (mfSpacingScaleY < 100.0) + if (maScalingParameters.fSpacingY < 100.0) { - double fSpacingFactor = mfSpacingScaleY / 100.0; + double fSpacingFactor = maScalingParameters.fSpacingY / 100.0; sal_uInt16 nPropLineSpace = basegfx::fround(100.0 * fSpacingFactor); if (nPropLineSpace && nPropLineSpace < 100) { @@ -2991,23 +2992,25 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo if (maStatus.DoStretch()) { - if (mfFontScaleY != 100.0) + if (maScalingParameters.fFontY != 100.0) { double fHeightRounded = roundToNearestPt(aRealSz.Height()); - double fNewHeight = fHeightRounded * (mfFontScaleY / 100.0); + double fNewHeight = fHeightRounded * (maScalingParameters.fFontY / 100.0); fNewHeight = roundToNearestPt(fNewHeight); aRealSz.setHeight(basegfx::fround(fNewHeight)); } - if (mfFontScaleX != 100.0) + if (maScalingParameters.fFontX != 100.0) { - if (mfFontScaleX == mfFontScaleY && nRelWidth == 100 ) + auto fFontX = maScalingParameters.fFontX; + auto fFontY = maScalingParameters.fFontY; + if (fFontX == fFontY && nRelWidth == 100 ) { aRealSz.setWidth( 0 ); } else { double fWidthRounded = roundToNearestPt(aRealSz.Width()); - double fNewWidth = fWidthRounded * (mfFontScaleX / 100.0); + double fNewWidth = fWidthRounded * (fFontX / 100.0); fNewWidth = roundToNearestPt(fNewWidth); aRealSz.setWidth(basegfx::fround(fNewWidth)); @@ -3024,15 +3027,15 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo >0 >100 > (Proportional) <0 >100 < (The amount, thus disproportional) */ - if (nKerning < 0 && mfFontScaleX > 100.0) + if (nKerning < 0 && fFontX > 100.0) { // disproportional - nKerning = basegfx::fround((double(nKerning) * 100.0) / mfFontScaleX); + nKerning = basegfx::fround((double(nKerning) * 100.0) / fFontX); } else if ( nKerning ) { // Proportional - nKerning = basegfx::fround((double(nKerning) * mfFontScaleX) / 100.0); + nKerning = basegfx::fround((double(nKerning) * fFontX) / 100.0); } rFont.SetFixKerning( static_cast<short>(nKerning) ); } @@ -4456,30 +4459,20 @@ void ImpEditEngine::SetFlatMode( bool bFlat ) pActiveView->ShowCursor(); } -void ImpEditEngine::setScale(double fFontScaleX, double fFontScaleY, double fSpacingScaleX, double fSpacingScaleY) +void ImpEditEngine::setScalingParameters(ScalingParameters const& rScalingParameters) { - bool bChanged; + ScalingParameters aNewScalingParameters(rScalingParameters); - if (!IsEffectivelyVertical()) - { - bChanged = mfFontScaleX != fFontScaleX || mfFontScaleY != fFontScaleY || - mfSpacingScaleX != fSpacingScaleX || mfSpacingScaleY != fSpacingScaleY; - mfFontScaleX = fFontScaleX; - mfFontScaleY = fFontScaleY; - mfSpacingScaleX = fSpacingScaleX; - mfSpacingScaleY = fSpacingScaleY; - } - else + if (IsEffectivelyVertical()) { - bChanged = mfFontScaleX != fFontScaleY || mfFontScaleY != fFontScaleX || - mfSpacingScaleX != fSpacingScaleY || mfSpacingScaleY != fSpacingScaleX; - mfFontScaleX = fFontScaleY; - mfFontScaleY = fFontScaleX; - mfSpacingScaleX = fSpacingScaleY; - mfSpacingScaleY = fSpacingScaleX; + std::swap(aNewScalingParameters.fFontX, aNewScalingParameters.fFontY); + std::swap(aNewScalingParameters.fSpacingX, aNewScalingParameters.fSpacingY); } - if (bChanged && maStatus.DoStretch()) + bool bScalingChanged = maScalingParameters != aNewScalingParameters; + maScalingParameters = aNewScalingParameters; + + if (bScalingChanged && maStatus.DoStretch()) { FormatFullDoc(); // (potentially) need everything redrawn diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 0258900725ea..637aebe81f45 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -1112,7 +1112,9 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a // sleeper set up when Olli paragraphs not hacked! if ( bAllowBigObjects && bOnlyFullParagraphs && IsFormatted() && IsUpdateLayout() && ( nTextPortions >= nBigObjectStart ) ) { - XParaPortionList* pXList = new XParaPortionList(GetRefDevice(), GetColumnWidth(maPaperSize), mfFontScaleX, mfFontScaleY, mfSpacingScaleX, mfSpacingScaleY); + XParaPortionList* pXList = new XParaPortionList(GetRefDevice(), GetColumnWidth(maPaperSize), + maScalingParameters.fFontX, maScalingParameters.fFontY, + maScalingParameters.fSpacingX, maScalingParameters.fSpacingY); pTxtObj->SetPortionInfo(std::unique_ptr<XParaPortionList>(pXList)); for ( nNode = nStartNode; nNode <= nEndNode; nNode++ ) { @@ -1198,10 +1200,10 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject if (pPortionInfo && ( static_cast<tools::Long>(pPortionInfo->GetPaperWidth()) == GetColumnWidth(maPaperSize)) && pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() - && pPortionInfo->getFontScaleX() == mfFontScaleX - && pPortionInfo->getFontScaleY() == mfFontScaleY - && pPortionInfo->getSpacingScaleX() == mfSpacingScaleX - && pPortionInfo->getSpacingScaleY() == mfSpacingScaleY) + && pPortionInfo->getFontScaleX() == maScalingParameters.fFontX + && pPortionInfo->getFontScaleY() == maScalingParameters.fFontY + && pPortionInfo->getSpacingScaleX() == maScalingParameters.fSpacingX + && pPortionInfo->getSpacingScaleY() == maScalingParameters.fSpacingY) { if ( (pPortionInfo->GetRefDevPtr() == GetRefDevice()) || (pPortionInfo->RefDevIsVirtual() && GetRefDevice()->IsVirtual()) ) diff --git a/editeng/source/outliner/outlin2.cxx b/editeng/source/outliner/outlin2.cxx index e4d0386cf2c0..268c194652c4 100644 --- a/editeng/source/outliner/outlin2.cxx +++ b/editeng/source/outliner/outlin2.cxx @@ -477,7 +477,12 @@ void Outliner::QuickFormatDoc() pEditEngine->QuickFormatDoc(); } -void Outliner::setGlobalScale(double rFontX, double rFontY, double rSpacingX, double rSpacingY) +ScalingParameters Outliner::getScalingParameters() const +{ + return pEditEngine->getScalingParameters(); +} + +void Outliner::setScalingParameters(ScalingParameters const& rScalingParameters) { // reset bullet size sal_Int32 nParagraphs = pParaList->GetParagraphCount(); @@ -488,13 +493,7 @@ void Outliner::setGlobalScale(double rFontX, double rFontY, double rSpacingX, do pPara->aBulSize.setWidth( -1 ); } - pEditEngine->setGlobalScale(rFontX, rFontY, rSpacingX, rSpacingY); -} - -void Outliner::getGlobalScale(double& rFontX, double& rFontY, double& rSpacingX, double& rSpacingY) const -{ - pEditEngine->getGlobalFontScale(rFontX, rFontY); - pEditEngine->getGlobalSpacingScale(rSpacingX, rSpacingY); + pEditEngine->setScalingParameters(rScalingParameters); } void Outliner::setRoundFontSizeToPt(bool bRound) const diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index bb8a8ac419ec..b6f715da52d0 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -845,12 +845,10 @@ vcl::Font Outliner::ImpCalcBulletFont( sal_Int32 nPara ) const } // Use original scale... - double nStretchY = 100.0; - getGlobalScale(o3tl::temporary(double()), nStretchY, o3tl::temporary(double()), o3tl::temporary(double())); - double fScale = pFmt->GetBulletRelSize() * nStretchY / 100.0; + double fFontScaleY = pFmt->GetBulletRelSize() * (getScalingParameters().fFontY / 100.0); double fScaledLineHeight = aStdFont.GetFontSize().Height(); - fScaledLineHeight *= fScale * 10; + fScaledLineHeight *= fFontScaleY * 10; fScaledLineHeight /= 1000.0; aBulletFont.SetAlignment( ALIGN_BOTTOM ); @@ -893,12 +891,10 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point& tools::Rectangle aBulletArea( ImpCalcBulletArea( nPara, true, false ) ); - double nStretchX = 100.0; - getGlobalScale(o3tl::temporary(double()), o3tl::temporary(double()), - nStretchX, o3tl::temporary(double())); + double fSpacingFactorX = getScalingParameters().fSpacingX / 100.0; - tools::Long nStretchBulletX = basegfx::fround(double(aBulletArea.Left()) * nStretchX / 100.0); - tools::Long nStretchBulletWidth = basegfx::fround(double(aBulletArea.GetWidth()) * nStretchX / 100.0); + tools::Long nStretchBulletX = basegfx::fround(double(aBulletArea.Left()) * fSpacingFactorX); + tools::Long nStretchBulletWidth = basegfx::fround(double(aBulletArea.GetWidth()) * fSpacingFactorX); aBulletArea = tools::Rectangle(Point(nStretchBulletX, aBulletArea.Top()), Size(nStretchBulletWidth, aBulletArea.GetHeight()) ); diff --git a/include/editeng/editdata.hxx b/include/editeng/editdata.hxx index 1762fd86e837..6225ef897b2f 100644 --- a/include/editeng/editdata.hxx +++ b/include/editeng/editdata.hxx @@ -268,6 +268,22 @@ struct ParagraphInfos bool bValid; // A query during formatting is not valid! }; +struct ScalingParameters +{ + double fFontX = 100.0; + double fFontY = 100.0; + double fSpacingX = 100.0; + double fSpacingY = 100.0; + + bool operator==(const ScalingParameters& rOther) const + { + return fFontX == rOther.fFontX + && fFontY == rOther.fFontY + && fSpacingX == rOther.fSpacingX + && fSpacingY == rOther.fSpacingY; + } +}; + struct EECharAttrib { const SfxPoolItem* pAttr; diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index 57e327444a49..a4ab3dfe8303 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -419,12 +419,10 @@ public: void QuickDelete( const ESelection& rSel ); void QuickMarkToBeRepainted( sal_Int32 nPara ); - void setGlobalScale(double fFontScaleX, double fFontScaleY, double fSpacingScaleX, double fSpacingScaleY); - void getGlobalSpacingScale(double& rX, double& rY) const; - basegfx::B2DTuple getGlobalSpacingScale() const; - void getGlobalFontScale(double& rX, double& rY) const; - basegfx::B2DTuple getGlobalFontScale() const; + void setScalingParameters(ScalingParameters const& rScalingParameters); + void resetScalingParameters(); + ScalingParameters getScalingParameters() const; void setRoundFontSizeToPt(bool bRound) const; diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index 35860b762037..ccc7dafe822a 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -936,8 +936,13 @@ public: bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder ); bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder, bool* pbBulletPos ); - void setGlobalScale(double rFontX = 100.0, double rFontY = 100.0, double rSpacingX = 100.0, double rSpacingY = 100.0); - void getGlobalScale(double& rFontX, double& rFontY, double& rSpacingX, double& rSpacingY) const; + ScalingParameters getScalingParameters() const; + void setScalingParameters(ScalingParameters const& rScalingParameters); + void resetScalingParameters() + { + setScalingParameters(ScalingParameters()); + } + void setRoundFontSizeToPt(bool bRound) const; void EraseVirtualDevice(); diff --git a/sd/qa/unit/TextFittingTest.cxx b/sd/qa/unit/TextFittingTest.cxx index 069825a8e620..e88a2680f005 100644 --- a/sd/qa/unit/TextFittingTest.cxx +++ b/sd/qa/unit/TextFittingTest.cxx @@ -74,16 +74,16 @@ CPPUNIT_TEST_FIXTURE(TextFittingTest, testTest) Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(4), pEditEngine->GetParagraphCount()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(87.49, pEditEngine->getGlobalFontScale().getY(), 1E-2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(90.0, pEditEngine->getGlobalSpacingScale().getY(), 1E-2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(87.49, pEditEngine->getScalingParameters().fFontY, 1E-2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(90.0, pEditEngine->getScalingParameters().fSpacingY, 1E-2); // Add paragraph 5 rEditView.SetSelection(ESelection(4, 0, 4, 0)); rEditView.InsertText(u" D5"_ustr); CPPUNIT_ASSERT_EQUAL(sal_Int32(5), pEditEngine->GetParagraphCount()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(54.68, pEditEngine->getGlobalFontScale().getY(), 1E-2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, pEditEngine->getGlobalSpacingScale().getY(), 1E-2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(54.68, pEditEngine->getScalingParameters().fFontY, 1E-2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, pEditEngine->getScalingParameters().fSpacingY, 1E-2); // Add paragraph 6 rEditView.SetSelection(ESelection(5, 0, 5, 0)); @@ -106,8 +106,8 @@ CPPUNIT_TEST_FIXTURE(TextFittingTest, testTest) CPPUNIT_ASSERT_EQUAL(sal_Int32(3), pEditEngine->GetParagraphCount()); // not ideal - scaling should be 100%, but close enough - CPPUNIT_ASSERT_DOUBLES_EQUAL(99.05, pEditEngine->getGlobalFontScale().getY(), 1E-2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, pEditEngine->getGlobalSpacingScale().getY(), 1E-2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(99.05, pEditEngine->getScalingParameters().fFontY, 1E-2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, pEditEngine->getScalingParameters().fSpacingY, 1E-2); // are we still in text edit mode? CPPUNIT_ASSERT_EQUAL(true, pView1->IsTextEdit()); diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx index 710518185dcc..247bec4bbe9b 100644 --- a/sd/source/ui/view/drtxtob.cxx +++ b/sd/source/ui/view/drtxtob.cxx @@ -187,7 +187,7 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) pOLV = pOView->GetViewByWindow(mpViewShell->GetActiveWindow()); if (pOutliner) - pOutliner->getGlobalScale(o3tl::temporary(double()), stretchY, o3tl::temporary(double()), o3tl::temporary(double())); + stretchY = pOutliner->getScalingParameters().fFontY; if(pOLV && !pOLV->GetSelection().HasRange()) { diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index e88e127e4fa0..2193369fac82 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -989,7 +989,7 @@ void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextS nY = nX; bNoMoreLoop = true; } - rOutliner.setGlobalScale(nX, nY); + rOutliner.setScalingParameters({nX, nY}); nLoopCount++; Size aSiz(rOutliner.CalcTextSize()); tools::Long nXDiff = aSiz.Width() - nWantWdt; @@ -1179,7 +1179,7 @@ void SdrTextObj::ImpInitDrawOutliner( SdrOutliner& rOutl ) const nOutlinerMode = OutlinerMode::TextObject; rOutl.Init( nOutlinerMode ); - rOutl.setGlobalScale(100.0, 100.0, 100.0, 100.0); + rOutl.resetScalingParameters(); EEControlBits nStat=rOutl.GetControlWord(); nStat &= ~EEControlBits(EEControlBits::STRETCHING|EEControlBits::AUTOPAGESIZE); @@ -1244,9 +1244,7 @@ double SdrTextObj::GetFontScale() const // This eventually calls ImpAutoFitText UpdateOutlinerFormatting(rOutliner, o3tl::temporary(tools::Rectangle())); - double fScaleY; - rOutliner.getGlobalScale(o3tl::temporary(double()), fScaleY, o3tl::temporary(double()), o3tl::temporary(double())); - return fScaleY; + return rOutliner.getScalingParameters().fFontY; } double SdrTextObj::GetSpacingScale() const @@ -1255,9 +1253,7 @@ double SdrTextObj::GetSpacingScale() const // This eventually calls ImpAutoFitText UpdateOutlinerFormatting(rOutliner, o3tl::temporary(tools::Rectangle())); - double fSpacingScaleY; - rOutliner.getGlobalScale(o3tl::temporary(double()), o3tl::temporary(double()), o3tl::temporary(double()), fSpacingScaleY); - return fSpacingScaleY; + return rOutliner.getScalingParameters().fSpacingY; } void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner ) const @@ -1283,7 +1279,7 @@ void SdrTextObj::autoFitTextForCompatibility(SdrOutliner& rOutliner, const Size& double fMaxScale = rItem.GetMaxScale(); if (fMaxScale > 0.0) { - rOutliner.setGlobalScale(fMaxScale, fMaxScale, 100.0, 100.0); + rOutliner.setScalingParameters({ fMaxScale, fMaxScale, 100.0, 100.0 }); } else { @@ -1303,9 +1299,9 @@ void SdrTextObj::autoFitTextForCompatibility(SdrOutliner& rOutliner, const Size& else fCurrentFitFactor = double(rTextBoxSize.Height()) / aCurrentTextBoxSize.Height(); - double fInitialFontScaleY = 0.0; - double fInitialSpacing = 0.0; - rOutliner.getGlobalScale(o3tl::temporary(double()), fInitialFontScaleY, o3tl::temporary(double()), fInitialSpacing); + auto aParameters = rOutliner.getScalingParameters(); + double fInitialFontScaleY = aParameters.fFontY; + double fInitialSpacing = aParameters.fSpacingY; if (fCurrentFitFactor >= 1.0 && fInitialFontScaleY >= 100.0 && fInitialSpacing >= 100.0) return; @@ -1353,7 +1349,7 @@ void SdrTextObj::autoFitTextForCompatibility(SdrOutliner& rOutliner, const Size& if (fCurrentFitFactor >= fFitFactorTarget) continue; - rOutliner.setGlobalScale(fCurrentFontScale, fCurrentFontScale, 100.0, fCurrentSpacing); + rOutliner.setScalingParameters({ fCurrentFontScale, fCurrentFontScale, 100.0, fCurrentSpacing }); aCurrentTextBoxSize = rOutliner.CalcTextSizeNTP(); aCurrentTextBoxSize.extendBy(0, nExtendTextBoxBy); @@ -1380,7 +1376,7 @@ void SdrTextObj::autoFitTextForCompatibility(SdrOutliner& rOutliner, const Size& } } } - rOutliner.setGlobalScale(fBestFontScale, fBestFontScale, 100.0, fBestSpacing); + rOutliner.setScalingParameters({ fBestFontScale, fBestFontScale, 100.0, fBestSpacing }); } void SdrTextObj::SetupOutlinerFormatting( SdrOutliner& rOutl, tools::Rectangle& rPaintRect ) const diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index a74c6d5b8f3a..84f440b81121 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -1377,7 +1377,9 @@ void SdrTextObj::impDecomposeStretchTextPrimitive( // to layout without mirroring const double fScaleX(fabs(aScale.getX()) / aOutlinerScale.getX()); const double fScaleY(fabs(aScale.getY()) / aOutlinerScale.getY()); - rOutliner.setGlobalScale(fScaleX * 100.0, fScaleY * 100.0, 100.0, 100.0); + ScalingParameters aScalingParameters{fScaleX * 100.0, fScaleY * 100.0}; + + rOutliner.setScalingParameters(aScalingParameters); // When mirroring in X and Y, // move the null point which was top left to bottom right. diff --git a/svx/source/svdraw/svdoutl.cxx b/svx/source/svdraw/svdoutl.cxx index 02bb89e38bda..8198c260e344 100644 --- a/svx/source/svdraw/svdoutl.cxx +++ b/svx/source/svdraw/svdoutl.cxx @@ -50,7 +50,7 @@ void SdrOutliner::SetTextObj( const SdrTextObj* pObj ) nOutlinerMode2 = OutlinerMode::TextObject; Init( nOutlinerMode2 ); - setGlobalScale(100.0, 100.0, 100.0, 100.0); + resetScalingParameters(); EEControlBits nStat = GetControlWord(); nStat &= ~EEControlBits( EEControlBits::STRETCHING | EEControlBits::AUTOPAGESIZE );