include/svx/svdomeas.hxx | 2 +- include/svx/svdotext.hxx | 10 ++++++++-- svx/source/svdraw/svdomeas.cxx | 14 ++++++++------ svx/source/svdraw/svdotext.cxx | 15 ++++++++------- 4 files changed, 25 insertions(+), 16 deletions(-)
New commits: commit 08dd70216aa877cc1973fe44f38f5b74d670e322 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun Jun 8 12:08:10 2025 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sun Jun 8 12:08:10 2025 +0200 svx: change SdrTextObj::maTextSize to gfx::Size2DLWrap Change-Id: I382da7fc4f09f1df21a66ecb36e5930cc9d56d4e diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx index fdff7e43d87a..f8b336f163fe 100644 --- a/include/svx/svdomeas.hxx +++ b/include/svx/svdomeas.hxx @@ -131,7 +131,7 @@ public: SAL_DLLPRIVATE virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool bAddText) const override; SAL_DLLPRIVATE virtual bool BegTextEdit(SdrOutliner& rOutl) override; - SAL_DLLPRIVATE virtual const Size& GetTextSize() const override; + SAL_DLLPRIVATE virtual Size GetTextSize() const override; SAL_DLLPRIVATE virtual void TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override; SAL_DLLPRIVATE virtual void TakeTextAnchorRect(tools::Rectangle& rAnchorRect) const override; diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 5296dbc01ccc..5f8ed57e9e02 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -34,6 +34,7 @@ #include <drawinglayer/primitive2d/Primitive2DContainer.hxx> #include <memory> #include <vector> +#include <basegfx/units/Size2DLWrap.hxx> #include <com/sun/star/drawing/TextFitToSizeType.hpp> @@ -225,7 +226,12 @@ protected: rtl::Reference<SdrText> mxText; // This contains the dimensions of the text - Size maTextSize; + gfx::Size2DLWrap maTextSize; + void setTextSize(Size const& rSize) + { + auto eUnit = getSdrModelFromSdrObject().getUnit(); + maTextSize = gfx::Size2DLWrap::create(rSize, eUnit); + } // an Outliner*, so that // 1. the TextObj won't be edited simultaneously by multiple views, and @@ -429,7 +435,7 @@ public: void SetText(SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat); // FitToSize and Fontwork are not taken into account in GetTextSize()! - virtual const Size& GetTextSize() const; + virtual Size GetTextSize() const; void FitFrameToTextSize(); double GetFontScale() const; diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index 218c2ee9985b..38d392d59955 100644 --- a/svx/source/svdraw/svdomeas.cxx +++ b/svx/source/svdraw/svdomeas.cxx @@ -603,12 +603,13 @@ void SdrMeasureObj::UndirtyText() const rOutliner.SetUpdateLayout(true); rOutliner.UpdateFields(); - Size aSiz(rOutliner.CalcTextSize()); + Size aSize = rOutliner.CalcTextSize(); rOutliner.Clear(); // cast to nonconst three times - const_cast<SdrMeasureObj*>(this)->maTextSize = aSiz; - const_cast<SdrMeasureObj*>(this)->mbTextSizeDirty = false; - const_cast<SdrMeasureObj*>(this)->m_bTextDirty = false; + auto* pThis = const_cast<SdrMeasureObj*>(this); + pThis->setTextSize(aSize); + pThis->mbTextSizeDirty = false; + pThis->m_bTextDirty = false; } void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const @@ -1266,9 +1267,10 @@ bool SdrMeasureObj::BegTextEdit(SdrOutliner& rOutl) return SdrTextObj::BegTextEdit(rOutl); } -const Size& SdrMeasureObj::GetTextSize() const +Size SdrMeasureObj::GetTextSize() const { - if (m_bTextDirty) UndirtyText(); + if (m_bTextDirty) + UndirtyText(); return SdrTextObj::GetTextSize(); } diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 4a1e578bb65b..f9e8d7d4c071 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -254,7 +254,7 @@ void SdrTextObj::NbcSetText(SvStream& rInput, const OUString& rBaseURL, EETextFo Size aSize(rOutliner.CalcTextSize()); rOutliner.Clear(); NbcSetOutlinerParaObject(std::move(pNewText)); - maTextSize=aSize; + setTextSize(aSize); mbTextSizeDirty=false; } @@ -267,25 +267,26 @@ void SdrTextObj::SetText(SvStream& rInput, const OUString& rBaseURL, EETextForma SendUserCall(SdrUserCallType::Resize,aBoundRect0); } -const Size& SdrTextObj::GetTextSize() const +Size SdrTextObj::GetTextSize() const { if (mbTextSizeDirty) { - Size aSiz; + Size aSize; SdrText* pText = getActiveText(); if( pText && pText->GetOutlinerParaObject ()) { SdrOutliner& rOutliner=ImpGetDrawOutliner(); rOutliner.SetText(*pText->GetOutlinerParaObject()); rOutliner.SetUpdateLayout(true); - aSiz=rOutliner.CalcTextSize(); + aSize = rOutliner.CalcTextSize(); rOutliner.Clear(); } // casting to nonconst twice - const_cast<SdrTextObj*>(this)->maTextSize = aSiz; - const_cast<SdrTextObj*>(this)->mbTextSizeDirty = false; + auto pThis = const_cast<SdrTextObj*>(this); + pThis->setTextSize(aSize); + pThis->mbTextSizeDirty = false; } - return maTextSize; + return maTextSize.toToolsSize(); } bool SdrTextObj::IsAutoGrowHeight() const