Rebased ref, commits from common ancestor: commit 42e916c3be5be328c705d384e8ccf8a40a2d7ef0 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Oct 18 21:28:29 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Oct 26 13:16:08 2022 +0200
editeng: fix rendering of text when "fit to frame" is enabbled This changes the nStretchX and nStretchY from sal_uInt16 to double so the text in text boxes is rendered correctly (text should be resized to the same size as the textbox). Change-Id: Ic92d03043af0abe86f1b67ae15522d0176ebbb51 diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 88bc04a9efed..c8a66d0470a4 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -2266,12 +2266,12 @@ bool EditEngine::HasText( const SvxSearchItem& rSearchItem ) return pImpEditEngine->HasText( rSearchItem ); } -void EditEngine::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY ) +void EditEngine::SetGlobalCharStretching(double nX, double nY) { pImpEditEngine->SetCharStretching( nX, nY ); } -void EditEngine::GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const +void EditEngine::GetGlobalCharStretching(double& rX, double& rY) const { pImpEditEngine->GetCharStretching( rX, rY ); } diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index 6d57c7497c2b..437754d70def 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -71,10 +71,10 @@ void XEditAttribute::SetItem(const SfxPoolItem& rNew) } XParaPortionList::XParaPortionList( - OutputDevice* pRefDev, sal_uInt32 nPW, sal_uInt16 _nStretchX, sal_uInt16 _nStretchY) + OutputDevice* pRefDev, sal_uInt32 nPW, double nStretchX, double nStretchY) : pRefDevPtr(pRefDev) - , nStretchX(_nStretchX) - , nStretchY(_nStretchY) + , mnStretchX(nStretchX) + , mnStretchY(nStretchY) , nPaperWidth(nPW) { } diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx index 250341fd4283..86a2e379be20 100644 --- a/editeng/source/editeng/editobj2.hxx +++ b/editeng/source/editeng/editobj2.hxx @@ -94,12 +94,12 @@ class XParaPortionList ListType maList; VclPtr<OutputDevice> pRefDevPtr; - sal_uInt16 nStretchX; - sal_uInt16 nStretchY; + double mnStretchX; + double mnStretchY; sal_uInt32 nPaperWidth; public: - XParaPortionList(OutputDevice* pRefDev, sal_uInt32 nPW, sal_uInt16 _nStretchX, sal_uInt16 _nStretchY); + XParaPortionList(OutputDevice* pRefDev, sal_uInt32 nPW, double nStretchX, double nStretchY); void push_back(XParaPortion* p); const XParaPortion& operator[](size_t i) const; @@ -108,8 +108,8 @@ public: sal_uInt32 GetPaperWidth() const { return nPaperWidth; } bool RefDevIsVirtual() const {return pRefDevPtr->IsVirtual();} const MapMode& GetRefMapMode() const { return pRefDevPtr->GetMapMode(); } - sal_uInt16 GetStretchX() const { return nStretchX; } - sal_uInt16 GetStretchY() const { return nStretchY; } + double GetStretchX() const { return mnStretchX; } + double GetStretchY() const { return mnStretchY; } }; class ContentInfo diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index b761e3bc4135..20e116b2ab3f 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -528,8 +528,8 @@ private: Color maBackgroundColor; - sal_uInt16 nStretchX; - sal_uInt16 nStretchY; + double mnStretchX; + double mnStretchY; CharCompressType nAsianCompressionMode; @@ -1080,8 +1080,8 @@ public: SvxCellJustifyMethod GetJustifyMethod( sal_Int32 nPara ) const; SvxCellVerJustify GetVerJustification( sal_Int32 nPara ) const; - void SetCharStretching( sal_uInt16 nX, sal_uInt16 nY ); - inline void GetCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const; + void SetCharStretching(double nX, double nY); + inline void GetCharStretching(double& rX, double& rY) const; sal_Int32 GetBigTextObjectStart() const { return nBigTextObjectStart; } @@ -1282,43 +1282,43 @@ inline ParaPortion* ImpEditEngine::FindParaPortion( ContentNode const * pNode ) return GetParaPortions()[ nPos ]; } -inline void ImpEditEngine::GetCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const +inline void ImpEditEngine::GetCharStretching(double& rX, double& rY) const { - rX = nStretchX; - rY = nStretchY; + rX = mnStretchX; + rY = mnStretchY; } inline short ImpEditEngine::GetXValue( short nXValue ) const { - if ( !aStatus.DoStretch() || ( nStretchX == 100 ) ) + if ( !aStatus.DoStretch() || ( mnStretchX == 100.0 ) ) return nXValue; - return static_cast<short>(static_cast<tools::Long>(nXValue)*nStretchX/100); + return short(double(nXValue) * mnStretchX / 100.0); } inline tools::Long ImpEditEngine::GetXValue( tools::Long nXValue ) const { - if ( !aStatus.DoStretch() || ( nStretchX == 100 ) ) + if ( !aStatus.DoStretch() || ( mnStretchX == 100.0 ) ) return nXValue; - return nXValue*nStretchX/100; + return nXValue * mnStretchX / 100.0; } inline short ImpEditEngine::GetYValue( short nYValue ) const { - if ( !aStatus.DoStretch() || ( nStretchY == 100 ) ) + if ( !aStatus.DoStretch() || ( mnStretchY == 100.0 ) ) return nYValue; - return static_cast<short>(static_cast<tools::Long>(nYValue)*nStretchY/100); + return short(double(nYValue) * mnStretchY / 100.0); } inline sal_uInt16 ImpEditEngine::GetYValue( sal_uInt16 nYValue ) const { - if ( !aStatus.DoStretch() || ( nStretchY == 100 ) ) + if ( !aStatus.DoStretch() || ( mnStretchY == 100.0 ) ) return nYValue; - return static_cast<sal_uInt16>(static_cast<tools::Long>(nYValue)*nStretchY/100); + return sal_uInt16(double(nYValue) * mnStretchY / 100.0); } inline PointerStyle ImpEditView::GetPointer() diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 455587bac4a6..c7df8af33337 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -98,8 +98,8 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) : pUndoManager(nullptr), aWordDelimiters(" .,;:-`'?!_=\"{}()[]"), maBackgroundColor(COL_AUTO), - nStretchX(100), - nStretchY(100), + mnStretchX(100.0), + mnStretchY(100.0), nAsianCompressionMode(CharCompressType::NONE), eDefaultHorizontalTextDirection(EEHorizontalTextDirection::Default), nBigTextObjectStart(20), diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index bdaab8a970bc..549d139e335f 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -1050,8 +1050,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) // Search for Tab-Pos... tools::Long nCurPos = nTmpWidth+nStartX; // consider scaling - if ( aStatus.DoStretch() && ( nStretchX != 100 ) ) - nCurPos = nCurPos*100/std::max(static_cast<sal_Int32>(nStretchX), static_cast<sal_Int32>(1)); + if ( aStatus.DoStretch() && ( mnStretchX != 100.0 ) ) + nCurPos = nCurPos * 100.0 / std::max(mnStretchX, 1.0); short nAllSpaceBeforeText = static_cast< short >(rLRItem.GetTextLeft()/* + rLRItem.GetTextLeft()*/ + nSpaceBeforeAndMinLabelWidth); aCurrentTab.aTabStop = pNode->GetContentAttribs().FindTabStop( nCurPos - nAllSpaceBeforeText /*rLRItem.GetTextLeft()*/, aEditDoc.GetDefTab() ); @@ -2982,22 +2982,21 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo if ( aStatus.DoStretch() ) { - if ( nStretchY != 100 ) + if (mnStretchY != 100.0) { - aRealSz.setHeight( aRealSz.Height() * nStretchY ); - aRealSz.setHeight( aRealSz.Height() / 100 ); + aRealSz.setHeight(aRealSz.Height() * mnStretchY); + aRealSz.setHeight(aRealSz.Height() / 100.0); } - if ( nStretchX != 100 ) + if (mnStretchX != 100.0) { - if ( nStretchX == nStretchY && - nRelWidth == 100 ) + if (mnStretchX == mnStretchY && nRelWidth == 100 ) { aRealSz.setWidth( 0 ); } else { - aRealSz.setWidth( aRealSz.Width() * nStretchX ); - aRealSz.setWidth( aRealSz.Width() / 100 ); + aRealSz.setWidth(aRealSz.Width() * mnStretchX); + aRealSz.setWidth(aRealSz.Width() / 100.0); // Also the Kerning: (long due to handle Interim results) tools::Long nKerning = rFont.GetFixKerning(); @@ -3012,16 +3011,16 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo >0 >100 > (Proportional) <0 >100 < (The amount, thus disproportional) */ - if ( ( nKerning < 0 ) && ( nStretchX > 100 ) ) + if (nKerning < 0 && mnStretchX > 100.0) { // disproportional nKerning *= 100; - nKerning /= nStretchX; + nKerning /= mnStretchX; } else if ( nKerning ) { // Proportional - nKerning *= nStretchX; + nKerning *= mnStretchX; nKerning /= 100; } rFont.SetFixKerning( static_cast<short>(nKerning) ); @@ -4428,20 +4427,20 @@ void ImpEditEngine::SetFlatMode( bool bFlat ) pActiveView->ShowCursor(); } -void ImpEditEngine::SetCharStretching( sal_uInt16 nX, sal_uInt16 nY ) +void ImpEditEngine::SetCharStretching(double nX, double nY) { bool bChanged; if ( !IsEffectivelyVertical() ) { - bChanged = nStretchX!=nX || nStretchY!=nY; - nStretchX = nX; - nStretchY = nY; + bChanged = mnStretchX != nX || mnStretchY != nY; + mnStretchX = nX; + mnStretchY = nY; } else { - bChanged = nStretchX!=nY || nStretchY!=nX; - nStretchX = nY; - nStretchY = nX; + bChanged = mnStretchX != nY || mnStretchY != nX; + mnStretchX = nY; + mnStretchY = nX; } if (bChanged && aStatus.DoStretch()) diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index ee9ebe89ff2e..251ac536b46c 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -1083,7 +1083,7 @@ 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(aPaperSize), nStretchX, nStretchY ); + XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), GetColumnWidth(aPaperSize), mnStretchX, mnStretchY ); pTxtObj->SetPortionInfo(std::unique_ptr<XParaPortionList>(pXList)); for ( nNode = nStartNode; nNode <= nEndNode; nNode++ ) { @@ -1169,8 +1169,8 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject if ( pPortionInfo && ( static_cast<tools::Long>(pPortionInfo->GetPaperWidth()) == GetColumnWidth(aPaperSize) ) && ( pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() ) - && ( pPortionInfo->GetStretchX() == nStretchX ) - && ( pPortionInfo->GetStretchY() == nStretchY ) ) + && ( pPortionInfo->GetStretchX() == sal_uInt16(mnStretchX)) + && ( pPortionInfo->GetStretchY() == sal_uInt16(mnStretchY)) ) { if ( (pPortionInfo->GetRefDevPtr() == GetRefDevice()) || (pPortionInfo->RefDevIsVirtual() && GetRefDevice()->IsVirtual()) ) diff --git a/editeng/source/outliner/outlin2.cxx b/editeng/source/outliner/outlin2.cxx index 951f6923563f..68b1d0fb802e 100644 --- a/editeng/source/outliner/outlin2.cxx +++ b/editeng/source/outliner/outlin2.cxx @@ -482,9 +482,8 @@ void Outliner::QuickFormatDoc() pEditEngine->QuickFormatDoc(); } -void Outliner::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY ) +void Outliner::SetGlobalCharStretching(double nX, double nY) { - // reset bullet size sal_Int32 nParagraphs = pParaList->GetParagraphCount(); for ( sal_Int32 nPara = 0; nPara < nParagraphs; nPara++ ) @@ -497,9 +496,9 @@ void Outliner::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY ) pEditEngine->SetGlobalCharStretching( nX, nY ); } -void Outliner::GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const +void Outliner::GetGlobalCharStretching(double& rX, double& rY) const { - pEditEngine->GetGlobalCharStretching( rX, rY ); + pEditEngine->GetGlobalCharStretching(rX, rY); } void Outliner::EraseVirtualDevice() diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index d7ea27662e77..f6b8feab3833 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -840,7 +840,7 @@ vcl::Font Outliner::ImpCalcBulletFont( sal_Int32 nPara ) const } // Use original scale... - sal_uInt16 nStretchX, nStretchY; + double nStretchX, nStretchY; GetGlobalCharStretching(nStretchX, nStretchY); sal_uInt16 nScale = pFmt->GetBulletRelSize() * nStretchY / 100; @@ -887,12 +887,10 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point& bool bRightToLeftPara = pEditEngine->IsRightToLeft( nPara ); tools::Rectangle aBulletArea( ImpCalcBulletArea( nPara, true, false ) ); - sal_uInt16 nStretchX, nStretchY; + double nStretchX, nStretchY; GetGlobalCharStretching(nStretchX, nStretchY); - aBulletArea = tools::Rectangle( Point(aBulletArea.Left()*nStretchX/100, - aBulletArea.Top()), - Size(aBulletArea.GetWidth()*nStretchX/100, - aBulletArea.GetHeight()) ); + aBulletArea = tools::Rectangle( Point(aBulletArea.Left() * nStretchX / 100.0, aBulletArea.Top()), + Size(aBulletArea.GetWidth() * nStretchX / 100.0, aBulletArea.GetHeight()) ); Paragraph* pPara = pParaList->GetParagraph( nPara ); const SvxNumberFormat* pFmt = GetNumberFormat( nPara ); diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index 1252487de836..f5487e779a4b 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -414,8 +414,8 @@ public: void QuickDelete( const ESelection& rSel ); void QuickMarkToBeRepainted( sal_Int32 nPara ); - void SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY ); - void GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const; + void SetGlobalCharStretching(double nX, double nY); + void GetGlobalCharStretching(double& rX, double& rY) const; void SetEditTextObjectPool( SfxItemPool* pPool ); SfxItemPool* GetEditTextObjectPool() const; diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index 03acc7cdc633..c6d57f09a086 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -930,8 +930,8 @@ public: bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder ); bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder, bool* pbBulletPos ); - void SetGlobalCharStretching( sal_uInt16 nX = 100, sal_uInt16 nY = 100 ); - void GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const; + void SetGlobalCharStretching(double nX = 100.0, double nY = 100.0); + void GetGlobalCharStretching(double& rX, double& rY) const; void EraseVirtualDevice(); bool ShouldCreateBigTextObject() const; diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx index b10af08289fa..d8503d0412f7 100644 --- a/sd/source/ui/view/drtxtob.cxx +++ b/sd/source/ui/view/drtxtob.cxx @@ -165,7 +165,7 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) case SID_ATTR_CHAR_STRIKEOUT: case SID_ATTR_CHAR_CASEMAP: { - sal_uInt16 stretchX = 100; + double stretchX = 100.0; SvxScriptSetItem aSetItem( nSlotId, GetPool() ); aSetItem.GetItemSet().Put( aAttrSet, false ); @@ -183,9 +183,9 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) if (OutlineView* pOView = dynamic_cast<OutlineView*>(mpView)) pOLV = pOView->GetViewByWindow(mpViewShell->GetActiveWindow()); - sal_uInt16 stretchY = 100; + double stretchY = 100.0; if( pOutliner ) - pOutliner->GetGlobalCharStretching( stretchX, stretchY ); + pOutliner->GetGlobalCharStretching(stretchX, stretchY); if(pOLV && !pOLV->GetSelection().HasRange()) { diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index fa4dc437ba0b..87fc7d49ad59 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -923,56 +923,88 @@ void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextS tools::Long nXTolMi=nWantWdt/25; // tolerance: -4% tools::Long nXCorr =nWantWdt/20; // correction scale: 5% - tools::Long nX=(nWantWdt*100) /nIsWdt; // calculate X stretching - tools::Long nY=(nWantHgt*100) /nIsHgt; // calculate Y stretching + double nX = (nWantWdt * 100.0) / double(nIsWdt); // calculate X stretching + double nY = (nWantHgt * 100.0) / double(nIsHgt); // calculate Y stretching bool bChkX = true; - if (bNoStretching) { // might only be possible proportionally - if (nX>nY) { nX=nY; bChkX=false; } - else { nY=nX; } + if (bNoStretching) + { // might only be possible proportionally + if (nX > nY) + { + nX = nY; + bChkX = false; + } + else + { + nY=nX; + } } - while (nLoopCount<5 && !bNoMoreLoop) { - if (nX<0) nX=-nX; - if (nX<1) { nX=1; bNoMoreLoop = true; } - if (nX>65535) { nX=65535; bNoMoreLoop = true; } + while (nLoopCount<5 && !bNoMoreLoop) + { + if (nX < 0.0) + nX = -nX; + if (nX < 1.0) + { + nX = 1.0; + bNoMoreLoop = true; + } + if (nX > 65535.0) + { + nX = 65535.0; + bNoMoreLoop = true; + } - if (nY<0) nY=-nY; - if (nY<1) { nY=1; bNoMoreLoop = true; } - if (nY>65535) { nY=65535; bNoMoreLoop = true; } + if (nY < 0.0) + { + nY = -nY; + } + if (nY < 1.0) + { + nY = 1.0; + bNoMoreLoop = true; + } + if (nY > 65535.0) + { + nY = 65535.0; + bNoMoreLoop = true; + } // exception, there is no text yet (horizontal case) - if(nIsWdt <= 1) + if (nIsWdt <= 1.0) { nX = nY; bNoMoreLoop = true; } // exception, there is no text yet (vertical case) - if(nIsHgt <= 1) + if (nIsHgt <= 1) { nY = nX; bNoMoreLoop = true; } - - rOutliner.SetGlobalCharStretching(static_cast<sal_uInt16>(nX),static_cast<sal_uInt16>(nY)); + rOutliner.SetGlobalCharStretching(nX, nY); nLoopCount++; Size aSiz(rOutliner.CalcTextSize()); - tools::Long nXDiff=aSiz.Width()-nWantWdt; + tools::Long nXDiff = aSiz.Width() - nWantWdt; rFitXCorrection=Fraction(nWantWdt,aSiz.Width()); if (((nXDiff>=nXTolMi || !bChkX) && nXDiff<=nXTolPl) || nXDiff==nXDiff0) { bNoMoreLoop = true; } else { // correct stretching factors - tools::Long nMul=nWantWdt; - tools::Long nDiv=aSiz.Width(); - if (std::abs(nXDiff)<=2*nXCorr) { - if (nMul>nDiv) nDiv+=(nMul-nDiv)/2; // but only add half of what we calculated, - else nMul+=(nDiv-nMul)/2; // because the EditEngine calculates wrongly later on + tools::Long nMul = nWantWdt; + tools::Long nDiv = aSiz.Width(); + if (std::abs(nXDiff) <= 2 * nXCorr) + { + if (nMul > nDiv) + nDiv += (nMul - nDiv) / 2.0; // but only add half of what we calculated, + else + nMul += (nDiv - nMul) / 2.0;// because the EditEngine calculates wrongly later on } - nX=nX*nMul/nDiv; - if (bNoStretching) nY=nX; + nX = nX * nMul / nDiv; + if (bNoStretching) + nY = nX; } - nXDiff0=nXDiff; + nXDiff0 = nXDiff; } } @@ -1140,7 +1172,7 @@ void SdrTextObj::ImpInitDrawOutliner( SdrOutliner& rOutl ) const nOutlinerMode = OutlinerMode::TextObject; rOutl.Init( nOutlinerMode ); - rOutl.SetGlobalCharStretching(); + rOutl.SetGlobalCharStretching(100.0, 100.0); EEControlBits nStat=rOutl.GetControlWord(); nStat &= ~EEControlBits(EEControlBits::STRETCHING|EEControlBits::AUTOPAGESIZE); rOutl.SetControlWord(nStat); @@ -1204,8 +1236,8 @@ sal_uInt16 SdrTextObj::GetFontScaleY() const // This eventually calls ImpAutoFitText UpdateOutlinerFormatting(rOutliner, o3tl::temporary(tools::Rectangle())); - sal_uInt16 nStretchY; - rOutliner.GetGlobalCharStretching(o3tl::temporary(sal_uInt16()), nStretchY); + double nStretchY; + rOutliner.GetGlobalCharStretching(o3tl::temporary(double()), nStretchY); return nStretchY; } @@ -1225,7 +1257,8 @@ void SdrTextObj::ImpAutoFitText(SdrOutliner& rOutliner, const Size& rTextSize, // line-breaking text that we need some more samples // loop early-exits if we detect an already attained value - sal_uInt16 nMinStretchX=0, nMinStretchY=0; + double nMinStretchX = 0.0; + double nMinStretchY = 0.0; sal_uInt16 aOldStretchXVals[]={0,0,0,0,0,0,0,0,0,0}; const size_t aStretchArySize=SAL_N_ELEMENTS(aOldStretchXVals); for(unsigned int i=0; i<aStretchArySize; ++i) @@ -1250,15 +1283,15 @@ void SdrTextObj::ImpAutoFitText(SdrOutliner& rOutliner, const Size& rTextSize, // - bulleted words will have to go through more iterations fFactor = std::sqrt(fFactor); - sal_uInt16 nCurrStretchX, nCurrStretchY; + double nCurrStretchX, nCurrStretchY; rOutliner.GetGlobalCharStretching(nCurrStretchX, nCurrStretchY); if (fFactor >= 1.0 ) { // resulting text area fits into available shape rect - // err on the larger stretching, to optimally fill area - nMinStretchX = std::max(nMinStretchX,nCurrStretchX); - nMinStretchY = std::max(nMinStretchY,nCurrStretchY); + nMinStretchX = std::max(nMinStretchX, nCurrStretchX); + nMinStretchY = std::max(nMinStretchY, nCurrStretchY); } aOldStretchXVals[i] = nCurrStretchX; @@ -1267,10 +1300,10 @@ void SdrTextObj::ImpAutoFitText(SdrOutliner& rOutliner, const Size& rTextSize, if (fFactor < 1.0 || nCurrStretchX != 100) { - nCurrStretchX = sal::static_int_cast<sal_uInt16>(nCurrStretchX*fFactor); - nCurrStretchY = sal::static_int_cast<sal_uInt16>(nCurrStretchY*fFactor); - rOutliner.SetGlobalCharStretching(std::min(sal_uInt16(100),nCurrStretchX), - std::min(sal_uInt16(100),nCurrStretchY)); + nCurrStretchX = nCurrStretchX * fFactor; + nCurrStretchY = nCurrStretchY * fFactor; + + rOutliner.SetGlobalCharStretching(std::min(100.0, nCurrStretchX), std::min(100.0, nCurrStretchY)); SAL_INFO("svx", "zoom is " << nCurrStretchX); } } @@ -1283,8 +1316,7 @@ void SdrTextObj::ImpAutoFitText(SdrOutliner& rOutliner, const Size& rTextSize, } SAL_INFO("svx", "final zoom is " << nMinStretchX); - rOutliner.SetGlobalCharStretching(std::min(sal_uInt16(100),nMinStretchX), - std::min(sal_uInt16(100),nMinStretchY)); + rOutliner.SetGlobalCharStretching(std::min(100.0, nMinStretchX), std::min(100.0, nMinStretchY)); } void SdrTextObj::SetupOutlinerFormatting( SdrOutliner& rOutl, tools::Rectangle& rPaintRect ) const diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 0c8928891231..c6b2a8e1e964 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -1223,7 +1223,7 @@ void SdrTextObj::impDecomposeStretchTextPrimitive( // to layout without mirroring const double fScaleX(fabs(aScale.getX()) / aOutlinerScale.getX()); const double fScaleY(fabs(aScale.getY()) / aOutlinerScale.getY()); - rOutliner.SetGlobalCharStretching(static_cast<sal_Int16>(FRound(fScaleX * 100.0)), static_cast<sal_Int16>(FRound(fScaleY * 100.0))); + rOutliner.SetGlobalCharStretching(fScaleX * 100.0, fScaleY * 100.0); // When mirroring in X and Y, // move the null point which was top left to bottom right. commit 8865a3ada97319f5ed78f8f70552645fc8a928ee Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Oct 25 21:04:27 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Oct 26 13:09:11 2022 +0200 svx: SdrTextObj maRect - use getter and add funcs. for maipulation Change-Id: I0a416fa2ac470650c2ef430dbb91bf8d5a8013cd diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 6041a74fe0aa..4446989a7e1c 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -165,7 +165,32 @@ protected: // The "aRect" is also the rect of RectObj and CircObj. // When mbTextFrame=true the text will be formatted into this rect // When mbTextFrame=false the text will be centered around its middle - tools::Rectangle maRect; + tools::Rectangle maRectangle; + + tools::Rectangle const& getRectangle() const + { + return maRectangle; + } + + void setRectangle(tools::Rectangle const& rRectangle) + { + maRectangle = rRectangle; + } + + void setRectangleSize(sal_Int32 nWidth, sal_Int32 nHeight) + { + maRectangle.SetSize(Size(nWidth, nHeight)); + } + + void moveRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta) + { + maRectangle.Move(nXDelta, nYDelta); + } + + void moveRectanglePosition(sal_Int32 nX, sal_Int32 nY) + { + maRectangle.SetPos(Point(nX, nY)); + } // The GeoStat contains the rotation and shear angles GeoStat maGeo; diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 44ecb8fefded..a6a56f417e6d 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -1397,7 +1397,7 @@ void SdrObjCustomShape::AdaptTextMinSize() // check if we need to change anything before creating an SfxItemSet, because that is expensive const bool bResizeShapeToFitText(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT).GetValue()); - tools::Rectangle aTextBound(maRect); + tools::Rectangle aTextBound(getRectangle()); bool bChanged(false); if(bResizeShapeToFitText) bChanged = true; @@ -1432,10 +1432,11 @@ void SdrObjCustomShape::AdaptTextMinSize() SetObjectItemSet(aSet); } -void SdrObjCustomShape::NbcSetSnapRect( const tools::Rectangle& rRect ) +void SdrObjCustomShape::NbcSetSnapRect(const tools::Rectangle& rRectangle) { - maRect = rRect; - ImpJustifyRect(maRect); + tools::Rectangle aRectangle(rRectangle); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); InvalidateRenderGeometry(); AdaptTextMinSize(); @@ -1455,10 +1456,11 @@ void SdrObjCustomShape::SetSnapRect( const tools::Rectangle& rRect ) SendUserCall(SdrUserCallType::Resize,aBoundRect0); } -void SdrObjCustomShape::NbcSetLogicRect( const tools::Rectangle& rRect ) +void SdrObjCustomShape::NbcSetLogicRect(const tools::Rectangle& rRectangle) { - maRect = rRect; - ImpJustifyRect(maRect); + tools::Rectangle aRectangle(rRectangle); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); InvalidateRenderGeometry(); AdaptTextMinSize(); @@ -1515,7 +1517,7 @@ void SdrObjCustomShape::NbcMove( const Size& rSiz ) void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact, const Fraction& ryFact ) { // taking care of handles that should not been changed - tools::Rectangle aOld( maRect ); + tools::Rectangle aOld(getRectangle()); std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles() ); SdrTextObj::NbcResize( rRef, rxFact, ryFact ); @@ -1543,17 +1545,17 @@ void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact, co rInteraction.xInteraction->setControllerPosition( rInteraction.aPosition ); if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_X ) { - sal_Int32 nX = ( rInteraction.aPosition.X - aOld.Left() ) + maRect.Left(); + sal_Int32 nX = ( rInteraction.aPosition.X - aOld.Left() ) + getRectangle().Left(); rInteraction.xInteraction->setControllerPosition(awt::Point(nX, rInteraction.xInteraction->getPosition().Y)); } else if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_NEGX ) { - sal_Int32 nX = maRect.Right() - (aOld.Right() - rInteraction.aPosition.X); + sal_Int32 nX = getRectangle().Right() - (aOld.Right() - rInteraction.aPosition.X); rInteraction.xInteraction->setControllerPosition(awt::Point(nX, rInteraction.xInteraction->getPosition().Y)); } if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_Y ) { - sal_Int32 nY = ( rInteraction.aPosition.Y - aOld.Top() ) + maRect.Top(); + sal_Int32 nY = ( rInteraction.aPosition.Y - aOld.Top() ) + getRectangle().Top(); rInteraction.xInteraction->setControllerPosition(awt::Point(rInteraction.xInteraction->getPosition().X, nY)); } } @@ -1598,7 +1600,7 @@ void SdrObjCustomShape::NbcRotate( const Point& rRef, Degree100 nAngle, double s // the rotation angle for ashapes is stored in fObjectRotation, this rotation // has to be applied to the text object (which is internally using maGeo.nAngle). - SdrTextObj::NbcRotate( maRect.TopLeft(), -maGeo.nRotationAngle, // retrieving the unrotated text object + SdrTextObj::NbcRotate( getRectangle().TopLeft(), -maGeo.nRotationAngle, // retrieving the unrotated text object -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle ); maGeo.nRotationAngle = 0_deg100; // resetting aGeo data @@ -1612,7 +1614,7 @@ void SdrObjCustomShape::NbcRotate( const Point& rRef, Degree100 nAngle, double s nW = nW % 36000_deg100; if ( nW < 0_deg100 ) nW = 36000_deg100 + nW; - SdrTextObj::NbcRotate( maRect.TopLeft(), nW, // applying text rotation + SdrTextObj::NbcRotate( getRectangle().TopLeft(), nW, // applying text rotation sin( toRadians(nW) ), cos( toRadians(nW) ) ); @@ -1723,14 +1725,18 @@ SdrGluePoint SdrObjCustomShape::GetVertexGluePoint(sal_uInt16 nPosNum) const } Point aPt; - switch (nPosNum) { - case 0: aPt=maRect.TopCenter(); aPt.AdjustY( -nWdt ); break; - case 1: aPt=maRect.RightCenter(); aPt.AdjustX(nWdt ); break; - case 2: aPt=maRect.BottomCenter(); aPt.AdjustY(nWdt ); break; - case 3: aPt=maRect.LeftCenter(); aPt.AdjustX( -nWdt ); break; - } - if (maGeo.nShearAngle != 0_deg100) ShearPoint(aPt, maRect.TopLeft(), maGeo.mfTanShearAngle); - if (maGeo.nRotationAngle != 0_deg100) RotatePoint(aPt, maRect.TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); + auto aRectangle = getRectangle(); + switch (nPosNum) + { + case 0: aPt = aRectangle.TopCenter(); aPt.AdjustY( -nWdt ); break; + case 1: aPt = aRectangle.RightCenter(); aPt.AdjustX(nWdt ); break; + case 2: aPt = aRectangle.BottomCenter(); aPt.AdjustY(nWdt ); break; + case 3: aPt = aRectangle.LeftCenter(); aPt.AdjustX( -nWdt ); break; + } + if (maGeo.nShearAngle != 0_deg100) + ShearPoint(aPt, aRectangle.TopLeft(), maGeo.mfTanShearAngle); + if (maGeo.nRotationAngle != 0_deg100) + RotatePoint(aPt, aRectangle.TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); aPt-=GetSnapRect().Center(); SdrGluePoint aGP(aPt); aGP.SetPercent(false); @@ -1779,19 +1785,19 @@ void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded() if (maGeo.nRotationAngle || nShearAngle || bMirroredX || bMirroredY) { - tools::Polygon aPoly( maRect ); + tools::Polygon aPoly(getRectangle()); if( nShearAngle ) { sal_uInt16 nPointCount=aPoly.GetSize(); for (sal_uInt16 i=0; i<nPointCount; i++) - ShearPoint(aPoly[i],maRect.Center(), fTan ); + ShearPoint(aPoly[i], getRectangle().Center(), fTan ); } if (maGeo.nRotationAngle) - aPoly.Rotate( maRect.Center(), to<Degree10>(maGeo.nRotationAngle) ); + aPoly.Rotate( getRectangle().Center(), to<Degree10>(maGeo.nRotationAngle) ); tools::Rectangle aBoundRect( aPoly.GetBoundRect() ); - sal_Int32 nXDiff = aBoundRect.Left() - maRect.Left(); - sal_Int32 nYDiff = aBoundRect.Top() - maRect.Top(); + sal_Int32 nXDiff = aBoundRect.Left() - getRectangle().Left(); + sal_Int32 nYDiff = aBoundRect.Top() - getRectangle().Top(); if (nShearAngle && bMirroredX != bMirroredY) { @@ -1799,7 +1805,7 @@ void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded() fTan = -fTan; } - Point aRef( maRect.GetWidth() / 2, maRect.GetHeight() / 2 ); + Point aRef( getRectangle().GetWidth() / 2, getRectangle().GetHeight() / 2 ); for ( a = 0; a < aNewList.GetCount(); a++ ) { SdrGluePoint& rPoint = aNewList[ a ]; @@ -1810,9 +1816,9 @@ void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded() RotatePoint(aGlue, aRef, sin(basegfx::deg2rad(fObjectRotation)), cos(basegfx::deg2rad(fObjectRotation))); if ( bMirroredX ) - aGlue.setX( maRect.GetWidth() - aGlue.X() ); + aGlue.setX( getRectangle().GetWidth() - aGlue.X() ); if ( bMirroredY ) - aGlue.setY( maRect.GetHeight() - aGlue.Y() ); + aGlue.setY( getRectangle().GetHeight() - aGlue.Y() ); aGlue.AdjustX( -nXDiff ); aGlue.AdjustY( -nYDiff ); rPoint.SetPos( aGlue ); @@ -1937,7 +1943,7 @@ bool SdrObjCustomShape::beginSpecialDrag(SdrDragStat& rDrag) const void SdrObjCustomShape::DragResizeCustomShape( const tools::Rectangle& rNewRect ) { - tools::Rectangle aOld( maRect ); + tools::Rectangle aOld(getRectangle()); bool bOldMirroredX( IsMirroredX() ); bool bOldMirroredY( IsMirroredY() ); @@ -1947,7 +1953,7 @@ void SdrObjCustomShape::DragResizeCustomShape( const tools::Rectangle& rNewRect std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles() ); GeoStat aGeoStat( GetGeoStat() ); - if ( aNewRect.TopLeft()!= maRect.TopLeft() && + if ( aNewRect.TopLeft() != getRectangle().TopLeft() && ( maGeo.nRotationAngle || maGeo.nShearAngle ) ) { Point aNewPos( aNewRect.TopLeft() ); @@ -1955,7 +1961,7 @@ void SdrObjCustomShape::DragResizeCustomShape( const tools::Rectangle& rNewRect if ( maGeo.nRotationAngle ) RotatePoint(aNewPos, aOld.TopLeft(), aGeoStat.mfSinRotationAngle, aGeoStat.mfCosRotationAngle ); aNewRect.SetPos( aNewPos ); } - if ( aNewRect == maRect ) + if (aNewRect == getRectangle()) return; SetLogicRect( aNewRect ); @@ -1991,17 +1997,17 @@ void SdrObjCustomShape::DragResizeCustomShape( const tools::Rectangle& rNewRect { nX = ( rInteraction.aPosition.X - aOld.Right() ); if ( rNewRect.Left() > rNewRect.Right() ) - nX = maRect.Left() - nX; + nX = getRectangle().Left() - nX; else - nX += maRect.Right(); + nX += getRectangle().Right(); } else { nX = ( rInteraction.aPosition.X - aOld.Left() ); if ( rNewRect.Left() > rNewRect.Right() ) - nX = maRect.Right() - nX; + nX = getRectangle().Right() - nX; else - nX += maRect.Left(); + nX += getRectangle().Left(); } rInteraction.xInteraction->setControllerPosition(awt::Point(nX, rInteraction.xInteraction->getPosition().Y)); } @@ -2012,17 +2018,17 @@ void SdrObjCustomShape::DragResizeCustomShape( const tools::Rectangle& rNewRect { nY = ( rInteraction.aPosition.Y - aOld.Bottom() ); if ( rNewRect.Top() > rNewRect.Bottom() ) - nY = maRect.Top() - nY; + nY = getRectangle().Top() - nY; else - nY += maRect.Bottom(); + nY += getRectangle().Bottom(); } else { nY = ( rInteraction.aPosition.Y - aOld.Top() ); if ( rNewRect.Top() > rNewRect.Bottom() ) - nY = maRect.Bottom() - nY; + nY = getRectangle().Bottom() - nY; else - nY += maRect.Top(); + nY += getRectangle().Top(); } rInteraction.xInteraction->setControllerPosition(awt::Point(rInteraction.xInteraction->getPosition().X, nY)); } @@ -2052,7 +2058,7 @@ void SdrObjCustomShape::DragMoveCustomShapeHdl( const Point& rDestination, sal_Int32 nXDiff = aPt.X - aInteractionHandle.aPosition.X; sal_Int32 nYDiff = aPt.Y - aInteractionHandle.aPosition.Y; - maRect.Move( nXDiff, nYDiff ); + moveRectangle(nXDiff, nYDiff); moveOutRectangle(nXDiff, nYDiff); maSnapRect.Move( nXDiff, nYDiff ); SetBoundAndSnapRectsDirty(/*bNotMyself*/true); @@ -2134,12 +2140,12 @@ void SdrObjCustomShape::DragCreateObject( SdrDragStat& rStat ) if ( !aInteractionHandles.empty() ) { sal_Int32 nHandlePos = aInteractionHandles[ aInteractionHandles.size() - 1 ].xInteraction->getPosition().X; - aRect1.Move( maRect.Left() - nHandlePos, 0 ); + aRect1.Move(getRectangle().Left() - nHandlePos, 0); } } ImpJustifyRect( aRect1 ); rStat.SetActionRect( aRect1 ); - maRect = aRect1; + setRectangle(aRect1); SetBoundAndSnapRectsDirty(); for (const auto& rInteraction : aInteractionHandles) @@ -2446,9 +2452,9 @@ tools::Rectangle SdrObjCustomShape::ImpCalculateTextFrame( const bool bHgt, cons { tools::Rectangle aReturnValue; - tools::Rectangle aOldTextRect( maRect ); // <- initial text rectangle + tools::Rectangle aOldTextRect(getRectangle()); // <- initial text rectangle - tools::Rectangle aNewTextRect( maRect ); // <- new text rectangle returned from the custom shape renderer, + tools::Rectangle aNewTextRect(getRectangle()); // <- new text rectangle returned from the custom shape renderer, GetTextBounds( aNewTextRect ); // it depends to the current logical shape size tools::Rectangle aAdjustedTextRect( aNewTextRect ); // <- new text rectangle is being tested by AdjustTextFrameWidthAndHeight to ensure @@ -2457,7 +2463,7 @@ tools::Rectangle SdrObjCustomShape::ImpCalculateTextFrame( const bool bHgt, cons if (aAdjustedTextRect != aNewTextRect && aOldTextRect != aAdjustedTextRect && aNewTextRect.GetWidth() && aNewTextRect.GetHeight()) { - aReturnValue = maRect; + aReturnValue = getRectangle(); double fXScale = static_cast<double>(aOldTextRect.GetWidth()) / static_cast<double>(aNewTextRect.GetWidth()); double fYScale = static_cast<double>(aOldTextRect.GetHeight()) / static_cast<double>(aNewTextRect.GetHeight()); double fRightDiff = static_cast<double>( aAdjustedTextRect.Right() - aNewTextRect.Right() ) * fXScale; @@ -2476,7 +2482,7 @@ tools::Rectangle SdrObjCustomShape::ImpCalculateTextFrame( const bool bHgt, cons bool SdrObjCustomShape::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt) { tools::Rectangle aNewTextRect = ImpCalculateTextFrame(bHgt, bWdt); - const bool bRet = !aNewTextRect.IsEmpty() && aNewTextRect != maRect; + const bool bRet = !aNewTextRect.IsEmpty() && aNewTextRect != getRectangle(); if (bRet && !mbAdjustingTextFrameWidthAndHeight) { mbAdjustingTextFrameWidthAndHeight = true; @@ -2484,7 +2490,7 @@ bool SdrObjCustomShape::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt) // taking care of handles that should not been changed std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles() ); - maRect = aNewTextRect; + setRectangle(aNewTextRect); SetBoundAndSnapRectsDirty(); SetChanged(); @@ -2509,7 +2515,7 @@ bool SdrObjCustomShape::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt) bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight() { tools::Rectangle aNewTextRect = ImpCalculateTextFrame( true/*bHgt*/, true/*bWdt*/ ); - bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != maRect ); + bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != getRectangle()); if ( bRet ) { tools::Rectangle aBoundRect0; @@ -2519,7 +2525,7 @@ bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight() // taking care of handles that should not been changed std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles() ); - maRect = aNewTextRect; + setRectangle(aNewTextRect); SetBoundAndSnapRectsDirty(); for (const auto& rInteraction : aInteractionHandles) @@ -2887,8 +2893,8 @@ void SdrObjCustomShape::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) // invalidating rectangles by SetRectsDirty is not sufficient, // AdjustTextFrameWidthAndHeight() also has to be made, both // actions are done by NbcSetSnapRect - tools::Rectangle aTmp( maRect ); //creating temporary rectangle #i61108# - NbcSetSnapRect( aTmp ); + tools::Rectangle aRectangle(getRectangle()); //creating temporary rectangle #i61108# + NbcSetSnapRect(aRectangle); } } @@ -3109,8 +3115,8 @@ bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegf double fRotate = basegfx::deg2rad(fObjectRotation); double fShearX = toRadians(maGeo.nShearAngle); - // get aRect, this is the unrotated snaprect - tools::Rectangle aRectangle(maRect); + // get aRectangle, this is the unrotated snaprect + tools::Rectangle aRectangle(getRectangle()); bool bMirroredX = IsMirroredX(); bool bMirroredY = IsMirroredY(); @@ -3122,7 +3128,7 @@ bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegf if ( bMirroredX ) { fShearX = -fShearX; - tools::Polygon aPol = Rect2Poly(maRect, aNewGeo); + tools::Polygon aPol = Rect2Poly(getRectangle(), aNewGeo); tools::Rectangle aBoundRect( aPol.GetBoundRect() ); Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() ); @@ -3163,7 +3169,7 @@ bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegf aPol[2]=aPol0[3]; // it was *not* wrong even when the reordering aPol[3]=aPol0[2]; // *seems* to be specific for X-Mirrorings. Oh aPol[4]=aPol0[1]; // will I be happy when this old stuff is |gone| with aw080 (!) - Poly2Rect(aPol,aRectangle,aNewGeo); + Poly2Rect(aPol, aRectangle, aNewGeo); } } diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx index 6a886272bad1..14e7678499c7 100644 --- a/svx/source/svdraw/svdocapt.cxx +++ b/svx/source/svdraw/svdocapt.cxx @@ -308,7 +308,7 @@ bool SdrCaptionObj::beginSpecialDrag(SdrDragStat& rDrag) const return false; rDrag.SetNoSnap(); - rDrag.SetActionRect(maRect); + rDrag.SetActionRect(getRectangle()); Point aHit(rDrag.GetStart()); @@ -341,15 +341,15 @@ bool SdrCaptionObj::applySpecialDrag(SdrDragStat& rDrag) } else { - Point aDelt(rDrag.GetNow()-rDrag.GetStart()); + Point aDelta(rDrag.GetNow()-rDrag.GetStart()); if(!pHdl) { - maRect.Move(aDelt.X(),aDelt.Y()); + moveRectangle(aDelta.X(), aDelta.Y()); } else { - aTailPoly[0] += aDelt; + aTailPoly[0] += aDelta; } ImpRecalcTail(); @@ -408,7 +408,7 @@ void SdrCaptionObj::ImpRecalcTail() { ImpCaptParams aPara; ImpGetCaptParams(aPara); - ImpCalcTail(aPara, aTailPoly, maRect); + ImpCalcTail(aPara, aTailPoly, getRectangle()); SetBoundAndSnapRectsDirty(); SetXPolyDirty(); } @@ -511,14 +511,15 @@ void SdrCaptionObj::ImpCalcTail(const ImpCaptParams& rPara, tools::Polygon& rPol bool SdrCaptionObj::BegCreate(SdrDragStat& rStat) { - if (maRect.IsEmpty()) return false; // Create currently only works with the given Rect + if (getRectangle().IsEmpty()) + return false; // Create currently only works with the given Rect ImpCaptParams aPara; ImpGetCaptParams(aPara); - maRect.SetPos(rStat.GetNow()); + moveRectanglePosition(rStat.GetNow().X(), rStat.GetNow().Y()); aTailPoly[0]=rStat.GetStart(); - ImpCalcTail(aPara,aTailPoly,maRect); - rStat.SetActionRect(maRect); + ImpCalcTail(aPara,aTailPoly, getRectangle()); + rStat.SetActionRect(getRectangle()); return true; } @@ -526,9 +527,9 @@ bool SdrCaptionObj::MovCreate(SdrDragStat& rStat) { ImpCaptParams aPara; ImpGetCaptParams(aPara); - maRect.SetPos(rStat.GetNow()); - ImpCalcTail(aPara,aTailPoly,maRect); - rStat.SetActionRect(maRect); + moveRectanglePosition(rStat.GetNow().X(), rStat.GetNow().Y()); + ImpCalcTail(aPara,aTailPoly, getRectangle()); + rStat.SetActionRect(getRectangle()); SetBoundRectDirty(); m_bSnapRectDirty=true; return true; @@ -538,8 +539,8 @@ bool SdrCaptionObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) { ImpCaptParams aPara; ImpGetCaptParams(aPara); - maRect.SetPos(rStat.GetNow()); - ImpCalcTail(aPara,aTailPoly,maRect); + moveRectanglePosition(rStat.GetNow().X(), rStat.GetNow().Y()); + ImpCalcTail(aPara,aTailPoly, getRectangle()); SetBoundAndSnapRectsDirty(); return (eCmd==SdrCreateCmd::ForceEnd || rStat.GetPointCount()>=2); } @@ -556,7 +557,7 @@ void SdrCaptionObj::BrkCreate(SdrDragStat& /*rStat*/) basegfx::B2DPolyPolygon SdrCaptionObj::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const { basegfx::B2DPolyPolygon aRetval; - const basegfx::B2DRange aRange =vcl::unotools::b2DRectangleFromRectangle(maRect); + const basegfx::B2DRange aRange =vcl::unotools::b2DRectangleFromRectangle(getRectangle()); aRetval.append(basegfx::utils::createPolygonFromRect(aRange)); aRetval.append(aTailPoly.getB2DPolygon()); return aRetval; @@ -598,7 +599,7 @@ Point SdrCaptionObj::GetRelativePos() const const tools::Rectangle& SdrCaptionObj::GetLogicRect() const { - return maRect; + return getRectangle(); } void SdrCaptionObj::NbcSetLogicRect(const tools::Rectangle& rRect) diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index 1207548114bf..ab8bc58ddf85 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -312,14 +312,14 @@ basegfx::B2DPolygon SdrCircObj::ImpCalcXPolyCirc(const SdrCircKind eCircleKind, void SdrCircObj::RecalcXPoly() { - basegfx::B2DPolygon aPolyCirc(ImpCalcXPolyCirc(meCircleKind, maRect, nStartAngle, nEndAngle)); + basegfx::B2DPolygon aPolyCirc(ImpCalcXPolyCirc(meCircleKind, getRectangle(), nStartAngle, nEndAngle)); mpXPoly = XPolygon(aPolyCirc); } OUString SdrCircObj::TakeObjNameSingul() const { TranslateId pID=STR_ObjNameSingulCIRC; - if (maRect.GetWidth() == maRect.GetHeight() && maGeo.nShearAngle==0_deg100) + if (getRectangle().GetWidth() == getRectangle().GetHeight() && maGeo.nShearAngle == 0_deg100) { switch (meCircleKind) { case SdrCircKind::Full: pID=STR_ObjNameSingulCIRC; break; @@ -348,7 +348,7 @@ OUString SdrCircObj::TakeObjNameSingul() const OUString SdrCircObj::TakeObjNamePlural() const { TranslateId pID=STR_ObjNamePluralCIRC; - if (maRect.GetWidth() == maRect.GetHeight() && maGeo.nShearAngle==0_deg100) + if (getRectangle().GetWidth() == getRectangle().GetHeight() && maGeo.nShearAngle == 0_deg100) { switch (meCircleKind) { case SdrCircKind::Full: pID=STR_ObjNamePluralCIRC; break; @@ -376,7 +376,7 @@ rtl::Reference<SdrObject> SdrCircObj::CloneSdrObject(SdrModel& rTargetModel) con basegfx::B2DPolyPolygon SdrCircObj::TakeXorPoly() const { - const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, maRect, nStartAngle, nEndAngle)); + const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, getRectangle(), nStartAngle, nEndAngle)); return basegfx::B2DPolyPolygon(aCircPolygon); } @@ -423,61 +423,61 @@ void SdrCircObj::AddToHdlList(SdrHdlList& rHdlList) const Point aPnt; SdrHdlKind eLocalKind(SdrHdlKind::Move); sal_uInt32 nPNum(0); - + tools::Rectangle aRectangle = getRectangle(); switch (nHdlNum) { case 0: - aPnt = GetAnglePnt(maRect,nStartAngle); + aPnt = GetAnglePnt(aRectangle, nStartAngle); eLocalKind = SdrHdlKind::Circle; nPNum = 1; break; case 1: - aPnt = GetAnglePnt(maRect,nEndAngle); + aPnt = GetAnglePnt(aRectangle, nEndAngle); eLocalKind = SdrHdlKind::Circle; nPNum = 2; break; case 2: - aPnt = maRect.TopLeft(); + aPnt = aRectangle.TopLeft(); eLocalKind = SdrHdlKind::UpperLeft; break; case 3: - aPnt = maRect.TopCenter(); + aPnt = aRectangle.TopCenter(); eLocalKind = SdrHdlKind::Upper; break; case 4: - aPnt = maRect.TopRight(); + aPnt = aRectangle.TopRight(); eLocalKind = SdrHdlKind::UpperRight; break; case 5: - aPnt = maRect.LeftCenter(); + aPnt = aRectangle.LeftCenter(); eLocalKind = SdrHdlKind::Left; break; case 6: - aPnt = maRect.RightCenter(); + aPnt = aRectangle.RightCenter(); eLocalKind = SdrHdlKind::Right; break; case 7: - aPnt = maRect.BottomLeft(); + aPnt = aRectangle.BottomLeft(); eLocalKind = SdrHdlKind::LowerLeft; break; case 8: - aPnt = maRect.BottomCenter(); + aPnt = aRectangle.BottomCenter(); eLocalKind = SdrHdlKind::Lower; break; case 9: - aPnt = maRect.BottomRight(); + aPnt = aRectangle.BottomRight(); eLocalKind = SdrHdlKind::LowerRight; break; } if (maGeo.nShearAngle) { - ShearPoint(aPnt, maRect.TopLeft(), maGeo.mfTanShearAngle); + ShearPoint(aPnt, aRectangle.TopLeft(), maGeo.mfTanShearAngle); } if (maGeo.nRotationAngle) { - RotatePoint(aPnt, maRect.TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); + RotatePoint(aPnt, aRectangle.TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); } std::unique_ptr<SdrHdl> pH(new SdrHdl(aPnt,eLocalKind)); @@ -520,15 +520,15 @@ bool SdrCircObj::applySpecialDrag(SdrDragStat& rDrag) Point aPt(rDrag.GetNow()); if (maGeo.nRotationAngle) - RotatePoint(aPt,maRect.TopLeft(), -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); + RotatePoint(aPt, getRectangle().TopLeft(), -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); if (maGeo.nShearAngle) - ShearPoint(aPt,maRect.TopLeft(), -maGeo.mfTanShearAngle); + ShearPoint(aPt, getRectangle().TopLeft(), -maGeo.mfTanShearAngle); - aPt -= maRect.Center(); + aPt -= getRectangle().Center(); - tools::Long nWdt = maRect.Right() - maRect.Left(); - tools::Long nHgt = maRect.Bottom() - maRect.Top(); + tools::Long nWdt = getRectangle().Right() - getRectangle().Left(); + tools::Long nHgt = getRectangle().Bottom() - getRectangle().Top(); if(nWdt>=nHgt) { @@ -696,7 +696,7 @@ bool SdrCircObj::BegCreate(SdrDragStat& rStat) tools::Rectangle aRect1(rStat.GetStart(), rStat.GetNow()); aRect1.Normalize(); rStat.SetActionRect(aRect1); - maRect = aRect1; + setRectangle(aRect1); ImpSetCreateParams(rStat); return true; } @@ -706,8 +706,8 @@ bool SdrCircObj::MovCreate(SdrDragStat& rStat) ImpSetCreateParams(rStat); ImpCircUser* pU=static_cast<ImpCircUser*>(rStat.GetUser()); rStat.SetActionRect(pU->aR); - maRect = pU->aR; // for ObjName - ImpJustifyRect(maRect); + setRectangle(pU->aR); // for ObjName + ImpJustifyRect(maRectangle); nStartAngle=pU->nStart; nEndAngle=pU->nEnd; SetBoundRectDirty(); @@ -733,16 +733,18 @@ bool SdrCircObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) if (meCircleKind==SdrCircKind::Full) { bRet=rStat.GetPointCount()>=2; if (bRet) { - maRect = pU->aR; - ImpJustifyRect(maRect); + tools::Rectangle aRectangle(pU->aR); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); } } else { rStat.SetNoSnap(rStat.GetPointCount()>=2); rStat.SetOrtho4Possible(rStat.GetPointCount()<2); bRet=rStat.GetPointCount()>=4; if (bRet) { - maRect = pU->aR; - ImpJustifyRect(maRect); + tools::Rectangle aRectangle(pU->aR); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); nStartAngle=pU->nStart; nEndAngle=pU->nEnd; } @@ -809,7 +811,7 @@ PointerStyle SdrCircObj::GetCreatePointer() const void SdrCircObj::NbcMove(const Size& aSize) { - maRect.Move(aSize); + moveRectangle(aSize.Width(), aSize.Height()); moveOutRectangle(aSize.Width(), aSize.Height()); maSnapRect.Move(aSize); SetXPolyDirty(); @@ -880,9 +882,9 @@ void SdrCircObj::NbcMirror(const Point& rRef1, const Point& rRef2) Point aTmpPt1; Point aTmpPt2; if (bFreeMirr) { // some preparations for using an arbitrary axis of reflection - Point aCenter(maRect.Center()); - tools::Long nWdt=maRect.GetWidth()-1; - tools::Long nHgt=maRect.GetHeight()-1; + Point aCenter(getRectangle().Center()); + tools::Long nWdt = getRectangle().GetWidth() - 1; + tools::Long nHgt = getRectangle().GetHeight() - 1; tools::Long nMaxRad=(std::max(nWdt,nHgt)+1) /2; // starting point double a = toRadians(nStartAngle); @@ -898,13 +900,13 @@ void SdrCircObj::NbcMirror(const Point& rRef1, const Point& rRef2) aTmpPt2+=aCenter; if (maGeo.nRotationAngle) { - RotatePoint(aTmpPt1, maRect.TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); - RotatePoint(aTmpPt2, maRect.TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); + RotatePoint(aTmpPt1, getRectangle().TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); + RotatePoint(aTmpPt2, getRectangle().TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); } if (maGeo.nShearAngle) { - ShearPoint(aTmpPt1, maRect.TopLeft(), maGeo.mfTanShearAngle); - ShearPoint(aTmpPt2, maRect.TopLeft(), maGeo.mfTanShearAngle); + ShearPoint(aTmpPt1, getRectangle().TopLeft(), maGeo.mfTanShearAngle); + ShearPoint(aTmpPt2, getRectangle().TopLeft(), maGeo.mfTanShearAngle); } } SdrTextObj::NbcMirror(rRef1,rRef2); @@ -914,16 +916,16 @@ void SdrCircObj::NbcMirror(const Point& rRef1, const Point& rRef2) // unrotate: if (maGeo.nRotationAngle) { - RotatePoint(aTmpPt1, maRect.TopLeft(), -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); // -sin for reversion - RotatePoint(aTmpPt2, maRect.TopLeft(), -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); // -sin for reversion + RotatePoint(aTmpPt1, getRectangle().TopLeft(), -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); // -sin for reversion + RotatePoint(aTmpPt2, getRectangle().TopLeft(), -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); // -sin for reversion } // unshear: if (maGeo.nShearAngle) { - ShearPoint(aTmpPt1, maRect.TopLeft(), -maGeo.mfTanShearAngle); // -tan for reversion - ShearPoint(aTmpPt2, maRect.TopLeft(), -maGeo.mfTanShearAngle); // -tan for reversion + ShearPoint(aTmpPt1, getRectangle().TopLeft(), -maGeo.mfTanShearAngle); // -tan for reversion + ShearPoint(aTmpPt2, getRectangle().TopLeft(), -maGeo.mfTanShearAngle); // -tan for reversion } - Point aCenter(maRect.Center()); + Point aCenter(getRectangle().Center()); aTmpPt1-=aCenter; aTmpPt2-=aCenter; // because it's mirrored, the angles are swapped, too @@ -971,37 +973,37 @@ static void Union(tools::Rectangle& rR, const Point& rP) void SdrCircObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const { - rRect = maRect; + rRect = getRectangle(); if (meCircleKind!=SdrCircKind::Full) { - const Point aPntStart(GetAnglePnt(maRect,nStartAngle)); - const Point aPntEnd(GetAnglePnt(maRect,nEndAngle)); + const Point aPntStart(GetAnglePnt(getRectangle(), nStartAngle)); + const Point aPntEnd(GetAnglePnt(getRectangle(), nEndAngle)); Degree100 a=nStartAngle; Degree100 e=nEndAngle; - rRect.SetLeft(maRect.Right() ); - rRect.SetRight(maRect.Left() ); - rRect.SetTop(maRect.Bottom() ); - rRect.SetBottom(maRect.Top() ); + rRect.SetLeft(getRectangle().Right() ); + rRect.SetRight(getRectangle().Left() ); + rRect.SetTop(getRectangle().Bottom() ); + rRect.SetBottom(getRectangle().Top() ); Union(rRect,aPntStart); Union(rRect,aPntEnd); if ((a<=18000_deg100 && e>=18000_deg100) || (a>e && (a<=18000_deg100 || e>=18000_deg100))) { - Union(rRect,maRect.LeftCenter()); + Union(rRect, getRectangle().LeftCenter()); } if ((a<=27000_deg100 && e>=27000_deg100) || (a>e && (a<=27000_deg100 || e>=27000_deg100))) { - Union(rRect,maRect.BottomCenter()); + Union(rRect, getRectangle().BottomCenter()); } if (a>e) { - Union(rRect,maRect.RightCenter()); + Union(rRect, getRectangle().RightCenter()); } if ((a<=9000_deg100 && e>=9000_deg100) || (a>e && (a<=9000_deg100 || e>=9000_deg100))) { - Union(rRect,maRect.TopCenter()); + Union(rRect, getRectangle().TopCenter()); } if (meCircleKind==SdrCircKind::Section) { - Union(rRect,maRect.Center()); + Union(rRect, getRectangle().Center()); } if (maGeo.nRotationAngle) { Point aDst(rRect.TopLeft()); - aDst-=maRect.TopLeft(); + aDst -= getRectangle().TopLeft(); Point aDst0(aDst); RotatePoint(aDst,Point(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); aDst-=aDst0; @@ -1046,8 +1048,8 @@ void SdrCircObj::NbcSetSnapRect(const tools::Rectangle& rRect) NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0)); NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top())); } else { - maRect=rRect; - ImpJustifyRect(maRect); + setRectangle(rRect); + ImpJustifyRect(maRectangle); } SetBoundAndSnapRectsDirty(); SetXPolyDirty(); @@ -1065,10 +1067,11 @@ sal_uInt32 SdrCircObj::GetSnapPointCount() const Point SdrCircObj::GetSnapPoint(sal_uInt32 i) const { - switch (i) { - case 1 : return GetAnglePnt(maRect,nStartAngle); - case 2 : return GetAnglePnt(maRect,nEndAngle); - default: return maRect.Center(); + switch (i) + { + case 1 : return GetAnglePnt(getRectangle(), nStartAngle); + case 2 : return GetAnglePnt(getRectangle(), nEndAngle); + default: return getRectangle().Center(); } } @@ -1140,7 +1143,7 @@ void SdrCircObj::ImpSetCircInfoToAttr() rtl::Reference<SdrObject> SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const { const bool bFill(meCircleKind != SdrCircKind::Arc); - const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, maRect, nStartAngle, nEndAngle)); + const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, getRectangle(), nStartAngle, nEndAngle)); rtl::Reference<SdrObject> pRet = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aCircPolygon), bFill, bBezier); if(bAddText) diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx index f84ee128a6e0..81bb8bdf79af 100644 --- a/svx/source/svdraw/svdoedge.cxx +++ b/svx/source/svdraw/svdoedge.cxx @@ -1718,7 +1718,7 @@ void SdrEdgeObj::SetEdgeTrackPath( const basegfx::B2DPolyPolygon& rPoly ) // #i110629# also set aRect and maSnapeRect depending on pEdgeTrack const tools::Rectangle aPolygonBounds(pEdgeTrack->GetBoundRect()); - maRect = aPolygonBounds; + setRectangle(aPolygonBounds); maSnapRect = aPolygonBounds; } } @@ -2273,11 +2273,11 @@ void SdrEdgeObj::NbcSetSnapRect(const tools::Rectangle& rRect) if(aOld == rRect) return; - if (maRect.IsEmpty() && 0 == pEdgeTrack->GetPointCount()) + if (getRectangle().IsEmpty() && 0 == pEdgeTrack->GetPointCount()) { // #i110629# When initializing, do not scale on empty Rectangle; this // will mirror the underlying text object (!) - maRect = rRect; + setRectangle(rRect); maSnapRect = rRect; } else diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 1c1be8a7a69a..00981a355e84 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -921,7 +921,7 @@ rtl::Reference<SdrObject> SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAdd ImpSdrGDIMetaFileImport aFilter( getSdrModelFromSdrObject(), GetLayer(), - maRect); + getRectangle()); rtl::Reference<SdrObjGroup> pGrp = new SdrObjGroup(getSdrModelFromSdrObject()); if(aFilter.DoImport(aMtf, *pGrp->GetSubList(), 0)) @@ -933,13 +933,13 @@ rtl::Reference<SdrObject> SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAdd if(aGeoStat.nShearAngle) { aGeoStat.RecalcTan(); - pGrp->NbcShear(maRect.TopLeft(), aGeoStat.nShearAngle, aGeoStat.mfTanShearAngle, false); + pGrp->NbcShear(getRectangle().TopLeft(), aGeoStat.nShearAngle, aGeoStat.mfTanShearAngle, false); } if(aGeoStat.nRotationAngle) { aGeoStat.RecalcSinCos(); - pGrp->NbcRotate(maRect.TopLeft(), aGeoStat.nRotationAngle, aGeoStat.mfSinRotationAngle, aGeoStat.mfCosRotationAngle); + pGrp->NbcRotate(getRectangle().TopLeft(), aGeoStat.nRotationAngle, aGeoStat.mfSinRotationAngle, aGeoStat.mfCosRotationAngle); } } @@ -1105,7 +1105,7 @@ void SdrGrafObj::AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrink } if( bShrinkOnly ) - aPos = maRect.TopLeft(); + aPos = getRectangle().TopLeft(); aPos.AdjustX( -(aSize.Width() / 2) ); aPos.AdjustY( -(aSize.Height() / 2) ); diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index 5e402646ef66..ee53dc085b32 100644 --- a/svx/source/svdraw/svdomeas.cxx +++ b/svx/source/svdraw/svdomeas.cxx @@ -698,7 +698,7 @@ void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const aTextSize2.AdjustWidth( 1 ); aTextSize2.AdjustHeight( 1 ); // because of the Rect-Ctor's odd behavior rRect=tools::Rectangle(aTextPos,aTextSize2); rRect.Normalize(); - const_cast<SdrMeasureObj*>(this)->maRect=rRect; + const_cast<SdrMeasureObj*>(this)->setRectangle(rRect); if (aMPol.nTextAngle != maGeo.nRotationAngle) { const_cast<SdrMeasureObj*>(this)->maGeo.nRotationAngle=aMPol.nTextAngle; diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx index 421ead2fe082..08c6dd2ca095 100644 --- a/svx/source/svdraw/svdomedia.cxx +++ b/svx/source/svdraw/svdomedia.cxx @@ -241,7 +241,7 @@ void SdrMediaObj::AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrin } if( bShrinkOnly ) - aPos = maRect.TopLeft(); + aPos = getRectangle().TopLeft(); aPos.AdjustX( -(aSize.Width() / 2) ); aPos.AdjustY( -(aSize.Height() / 2) ); diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index a5ebed7ce7ce..3661aa260d14 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -1476,8 +1476,8 @@ void SdrOle2Obj::ImpSetVisAreaSize() MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) ); Size aVisSize; if (sal_Int32(aScaleWidth) != 0 && sal_Int32(aScaleHeight) != 0) // avoid div by zero - aVisSize = Size( static_cast<tools::Long>( Fraction( maRect.GetWidth() ) / aScaleWidth ), - static_cast<tools::Long>( Fraction( maRect.GetHeight() ) / aScaleHeight ) ); + aVisSize = Size( static_cast<tools::Long>( Fraction( getRectangle().GetWidth() ) / aScaleWidth ), + static_cast<tools::Long>( Fraction( getRectangle().GetHeight() ) / aScaleHeight ) ); aVisSize = OutputDevice::LogicToLogic( aVisSize, @@ -1503,18 +1503,15 @@ void SdrOle2Obj::ImpSetVisAreaSize() // server changed VisArea to its liking and the VisArea is different than the suggested one // store the new value as given by the object MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) ); - maRect.SetSize( - OutputDevice::LogicToLogic( - aAcceptedVisArea.GetSize(), - MapMode(aNewMapUnit), - MapMode(getSdrModelFromSdrObject().GetScaleUnit()))); + auto aSize = OutputDevice::LogicToLogic(aAcceptedVisArea.GetSize(), MapMode(aNewMapUnit), MapMode(getSdrModelFromSdrObject().GetScaleUnit())); + setRectangleSize(aSize.Width(), aSize.Height()); } // make the new object area known to the client // compared to the "else" branch aRect might have been changed by the object and no additional scaling was applied // WHY this -> OSL_ASSERT( pClient ); if( pClient ) - pClient->SetObjArea(maRect); + pClient->SetObjArea(getRectangle()); // we need a new replacement image as the object has resized itself @@ -1535,7 +1532,7 @@ void SdrOle2Obj::ImpSetVisAreaSize() { if ( pClient ) { - tools::Rectangle aScaleRect(maRect.TopLeft(), aObjAreaSize); + tools::Rectangle aScaleRect(getRectangle().TopLeft(), aObjAreaSize); pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight); } else @@ -1556,8 +1553,8 @@ void SdrOle2Obj::ImpSetVisAreaSize() const MapUnit aMapUnit( VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit(GetAspect()))); - const Point aTL( maRect.TopLeft() ); - const Point aBR( maRect.BottomRight() ); + const Point aTL( getRectangle().TopLeft() ); + const Point aBR( getRectangle().BottomRight() ); const Point aTL2( OutputDevice::LogicToLogic( aTL, @@ -1868,7 +1865,7 @@ bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHei MapMode aMapMode(getSdrModelFromSdrObject().GetScaleUnit()); aObjAreaSize = mpImpl->mxObjRef.GetSize( &aMapMode ); - Size aSize = maRect.GetSize(); + Size aSize = getRectangle().GetSize(); aScaleWidth = Fraction(aSize.Width(), aObjAreaSize.Width() ); aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() ); diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index b304426bf647..6a22074ccc7c 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -1685,7 +1685,7 @@ void SdrPathObj::ImpForceLineAngle() maGeo.RecalcTan(); // for SdrTextObj, keep aRect up to date - maRect = tools::Rectangle::Normalize(aPoint0, aPoint1); + setRectangle(tools::Rectangle::Normalize(aPoint0, aPoint1)); } void SdrPathObj::ImpForceKind() @@ -1749,7 +1749,7 @@ void SdrPathObj::ImpForceKind() // #i10659# for SdrTextObj, keep aRect up to date if(GetPathPoly().count()) { - maRect = lcl_ImpGetBoundRect(GetPathPoly()); + setRectangle(lcl_ImpGetBoundRect(GetPathPoly())); } } @@ -2478,7 +2478,7 @@ void SdrPathObj::NbcSetPoint(const Point& rPnt, sal_uInt32 nHdlNum) if(GetPathPoly().count()) { // #i10659# for SdrTextObj, keep aRect up to date - maRect = lcl_ImpGetBoundRect(GetPathPoly()); + setRectangle(lcl_ImpGetBoundRect(GetPathPoly())); } } diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx index 989fe0685e6b..a11151fb280d 100644 --- a/svx/source/svdraw/svdorect.cxx +++ b/svx/source/svdraw/svdorect.cxx @@ -122,14 +122,14 @@ XPolygon SdrRectObj::ImpCalcXPoly(const tools::Rectangle& rRect1, tools::Long nR aXPoly=aNewPoly; // these angles always relate to the top left corner of aRect - if (maGeo.nShearAngle) ShearXPoly(aXPoly,maRect.TopLeft(),maGeo.mfTanShearAngle); - if (maGeo.nRotationAngle) RotateXPoly(aXPoly,maRect.TopLeft(),maGeo.mfSinRotationAngle,maGeo.mfCosRotationAngle); + if (maGeo.nShearAngle) ShearXPoly(aXPoly, getRectangle().TopLeft(), maGeo.mfTanShearAngle); + if (maGeo.nRotationAngle) RotateXPoly(aXPoly, getRectangle().TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); return aXPoly; } void SdrRectObj::RecalcXPoly() { - mpXPoly = ImpCalcXPoly(maRect,GetEckenradius()); + mpXPoly = ImpCalcXPoly(getRectangle(), GetEckenradius()); } const XPolygon& SdrRectObj::GetXPoly() const @@ -177,11 +177,11 @@ SdrObjKind SdrRectObj::GetObjIdentifier() const void SdrRectObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const { - rRect = maRect; + rRect = getRectangle(); if (maGeo.nShearAngle==0_deg100) return; - tools::Long nDst=FRound((maRect.Bottom()-maRect.Top()) * maGeo.mfTanShearAngle); + tools::Long nDst=FRound((getRectangle().Bottom()-getRectangle().Top()) * maGeo.mfTanShearAngle); if (maGeo.nShearAngle>0_deg100) { Point aRef(rRect.TopLeft()); @@ -210,7 +210,7 @@ OUString SdrRectObj::TakeObjNameSingul() const { pResId = bRounded ? STR_ObjNameSingulPARALRND : STR_ObjNameSingulPARAL; // parallelogram or, maybe, rhombus } - else if (maRect.GetWidth() == maRect.GetHeight()) + else if (getRectangle().GetWidth() == getRectangle().GetHeight()) { pResId = bRounded ? STR_ObjNameSingulQUADRND : STR_ObjNameSingulQUAD; // square } @@ -236,7 +236,7 @@ OUString SdrRectObj::TakeObjNamePlural() const { pResId = bRounded ? STR_ObjNamePluralPARALRND : STR_ObjNamePluralPARAL; // parallelogram or rhombus } - else if (maRect.GetWidth() == maRect.GetHeight()) + else if (getRectangle().GetWidth() == getRectangle().GetHeight()) { pResId = bRounded ? STR_ObjNamePluralQUADRND : STR_ObjNamePluralQUAD; // square } @@ -252,7 +252,7 @@ rtl::Reference<SdrObject> SdrRectObj::CloneSdrObject(SdrModel& rTargetModel) con basegfx::B2DPolyPolygon SdrRectObj::TakeXorPoly() const { XPolyPolygon aXPP; - aXPP.Insert(ImpCalcXPoly(maRect,GetEckenradius())); + aXPP.Insert(ImpCalcXPoly(getRectangle(), GetEckenradius())); return aXPP.getB2DPolyPolygon(); } @@ -289,7 +289,7 @@ void SdrRectObj::AddToHdlList(SdrHdlList& rHdlList) const if(IsTextFrame()) { OSL_ENSURE(!IsTextEditActive(), "Do not use an ImpTextframeHdl for highlighting text in active text edit, this will collide with EditEngine paints (!)"); - std::unique_ptr<SdrHdl> pH(new ImpTextframeHdl(maRect)); + std::unique_ptr<SdrHdl> pH(new ImpTextframeHdl(getRectangle())); pH->SetObj(const_cast<SdrRectObj*>(this)); pH->SetRotationAngle(maGeo.nRotationAngle); rHdlList.AddHdl(std::move(pH)); @@ -299,37 +299,37 @@ void SdrRectObj::AddToHdlList(SdrHdlList& rHdlList) const { Point aPnt; SdrHdlKind eKind = SdrHdlKind::Move; - + auto const& rRectangle = getRectangle(); switch(nHdlNum) { case 1: // Handle for changing the corner radius { tools::Long a = GetEckenradius(); - tools::Long b = std::max(maRect.GetWidth(),maRect.GetHeight())/2; // rounded up, because GetWidth() adds 1 + tools::Long b = std::max(rRectangle.GetWidth(), rRectangle.GetHeight())/2; // rounded up, because GetWidth() adds 1 if (a>b) a=b; if (a<0) a=0; - aPnt=maRect.TopLeft(); + aPnt = rRectangle.TopLeft(); aPnt.AdjustX(a ); eKind = SdrHdlKind::Circle; break; } - case 2: aPnt=maRect.TopLeft(); eKind = SdrHdlKind::UpperLeft; break; - case 3: aPnt=maRect.TopCenter(); eKind = SdrHdlKind::Upper; break; - case 4: aPnt=maRect.TopRight(); eKind = SdrHdlKind::UpperRight; break; - case 5: aPnt=maRect.LeftCenter(); eKind = SdrHdlKind::Left ; break; - case 6: aPnt=maRect.RightCenter(); eKind = SdrHdlKind::Right; break; - case 7: aPnt=maRect.BottomLeft(); eKind = SdrHdlKind::LowerLeft; break; - case 8: aPnt=maRect.BottomCenter(); eKind = SdrHdlKind::Lower; break; - case 9: aPnt=maRect.BottomRight(); eKind = SdrHdlKind::LowerRight; break; + case 2: aPnt = rRectangle.TopLeft(); eKind = SdrHdlKind::UpperLeft; break; + case 3: aPnt = rRectangle.TopCenter(); eKind = SdrHdlKind::Upper; break; + case 4: aPnt = rRectangle.TopRight(); eKind = SdrHdlKind::UpperRight; break; + case 5: aPnt = rRectangle.LeftCenter(); eKind = SdrHdlKind::Left ; break; + case 6: aPnt = rRectangle.RightCenter(); eKind = SdrHdlKind::Right; break; + case 7: aPnt = rRectangle.BottomLeft(); eKind = SdrHdlKind::LowerLeft; break; + case 8: aPnt = rRectangle.BottomCenter(); eKind = SdrHdlKind::Lower; break; + case 9: aPnt = rRectangle.BottomRight(); eKind = SdrHdlKind::LowerRight; break; } if (maGeo.nShearAngle) { - ShearPoint(aPnt,maRect.TopLeft(),maGeo.mfTanShearAngle); + ShearPoint(aPnt,rRectangle.TopLeft(),maGeo.mfTanShearAngle); } if (maGeo.nRotationAngle) { - RotatePoint(aPnt,maRect.TopLeft(),maGeo.mfSinRotationAngle,maGeo.mfCosRotationAngle); + RotatePoint(aPnt,rRectangle.TopLeft(),maGeo.mfSinRotationAngle,maGeo.mfCosRotationAngle); } std::unique_ptr<SdrHdl> pH(new SdrHdl(aPnt,eKind)); @@ -367,9 +367,9 @@ bool SdrRectObj::applySpecialDrag(SdrDragStat& rDrag) Point aPt(rDrag.GetNow()); if (maGeo.nRotationAngle) - RotatePoint(aPt, maRect.TopLeft(), -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); + RotatePoint(aPt, getRectangle().TopLeft(), -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); - sal_Int32 nRad(aPt.X() - maRect.Left()); + sal_Int32 nRad(aPt.X() - getRectangle().Left()); if (nRad < 0) nRad = 0; @@ -405,9 +405,9 @@ OUString SdrRectObj::getSpecialDragComment(const SdrDragStat& rDrag) const // -sin for reversal if (maGeo.nRotationAngle) - RotatePoint(aPt, maRect.TopLeft(), -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); + RotatePoint(aPt, getRectangle().TopLeft(), -maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); - sal_Int32 nRad(aPt.X() - maRect.Left()); + sal_Int32 nRad(aPt.X() - getRectangle().Left()); if(nRad < 0) nRad = 0; @@ -484,14 +484,17 @@ SdrGluePoint SdrRectObj::GetVertexGluePoint(sal_uInt16 nPosNum) const } Point aPt; + auto const& rRectangle = getRectangle(); switch (nPosNum) { - case 0: aPt=maRect.TopCenter(); aPt.AdjustY( -nWdt ); break; - case 1: aPt=maRect.RightCenter(); aPt.AdjustX(nWdt ); break; - case 2: aPt=maRect.BottomCenter(); aPt.AdjustY(nWdt ); break; - case 3: aPt=maRect.LeftCenter(); aPt.AdjustX( -nWdt ); break; + case 0: aPt = rRectangle.TopCenter(); aPt.AdjustY( -nWdt ); break; + case 1: aPt = rRectangle.RightCenter(); aPt.AdjustX(nWdt ); break; + case 2: aPt = rRectangle.BottomCenter(); aPt.AdjustY(nWdt ); break; + case 3: aPt = rRectangle.LeftCenter(); aPt.AdjustX( -nWdt ); break; } - if (maGeo.nShearAngle) ShearPoint(aPt, maRect.TopLeft(), maGeo.mfTanShearAngle); - if (maGeo.nRotationAngle) RotatePoint(aPt, maRect.TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); + if (maGeo.nShearAngle) + ShearPoint(aPt, rRectangle.TopLeft(), maGeo.mfTanShearAngle); + if (maGeo.nRotationAngle) + RotatePoint(aPt, rRectangle.TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); aPt-=GetSnapRect().Center(); SdrGluePoint aGP(aPt); aGP.SetPercent(false); @@ -510,14 +513,17 @@ SdrGluePoint SdrRectObj::GetCornerGluePoint(sal_uInt16 nPosNum) const } Point aPt; + auto const& rRectangle = getRectangle(); switch (nPosNum) { - case 0: aPt=maRect.TopLeft(); aPt.AdjustX( -nWdt ); aPt.AdjustY( -nWdt ); break; - case 1: aPt=maRect.TopRight(); aPt.AdjustX(nWdt ); aPt.AdjustY( -nWdt ); break; - case 2: aPt=maRect.BottomRight(); aPt.AdjustX(nWdt ); aPt.AdjustY(nWdt ); break; - case 3: aPt=maRect.BottomLeft(); aPt.AdjustX( -nWdt ); aPt.AdjustY(nWdt ); break; + case 0: aPt = rRectangle.TopLeft(); aPt.AdjustX( -nWdt ); aPt.AdjustY( -nWdt ); break; + case 1: aPt = rRectangle.TopRight(); aPt.AdjustX(nWdt ); aPt.AdjustY( -nWdt ); break; + case 2: aPt = rRectangle.BottomRight(); aPt.AdjustX(nWdt ); aPt.AdjustY(nWdt ); break; + case 3: aPt = rRectangle.BottomLeft(); aPt.AdjustX( -nWdt ); aPt.AdjustY(nWdt ); break; } - if (maGeo.nShearAngle) ShearPoint(aPt,maRect.TopLeft(),maGeo.mfTanShearAngle); - if (maGeo.nRotationAngle) RotatePoint(aPt,maRect.TopLeft(),maGeo.mfSinRotationAngle,maGeo.mfCosRotationAngle); + if (maGeo.nShearAngle) + ShearPoint(aPt, rRectangle.TopLeft(),maGeo.mfTanShearAngle); + if (maGeo.nRotationAngle) + RotatePoint(aPt, rRectangle.TopLeft(),maGeo.mfSinRotationAngle,maGeo.mfCosRotationAngle); aPt-=GetSnapRect().Center(); SdrGluePoint aGP(aPt); aGP.SetPercent(false); @@ -526,7 +532,7 @@ SdrGluePoint SdrRectObj::GetCornerGluePoint(sal_uInt16 nPosNum) const rtl::Reference<SdrObject> SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const { - XPolygon aXP(ImpCalcXPoly(maRect,GetEckenradius())); + XPolygon aXP(ImpCalcXPoly(getRectangle(), GetEckenradius())); { // TODO: this is only for the moment, until we have the new TakeContour() aXP.Remove(0,1); aXP[aXP.GetPointCount()-1]=aXP[0]; diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 53b32ddf28b2..fa4dc437ba0b 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -101,7 +101,7 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj const & rSource) // #i25616# mbSupportTextIndentingOnLineWidthChange = true; - maRect = rSource.maRect; + maRectangle = rSource.maRectangle; maGeo = rSource.maGeo; maTextSize = rSource.maTextSize; @@ -135,7 +135,6 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj const & rSource) SdrTextObj::SdrTextObj(SdrModel& rSdrModel, const tools::Rectangle& rNewRect) : SdrAttrObj(rSdrModel) - , maRect(rNewRect) , mpEditingOutliner(nullptr) , meTextKind(SdrObjKind::Text) , maTextEditOffset(Point(0, 0)) @@ -147,7 +146,9 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, const tools::Rectangle& rNewRect) , mbTextAnimationAllowed(true) , mbInDownScale(false) { - ImpJustifyRect(maRect); + tools::Rectangle aRectangle(rNewRect); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); // #i25616# mbSupportTextIndentingOnLineWidthChange = true; @@ -173,7 +174,6 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrObjKind eNewTextKind) SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrObjKind eNewTextKind, const tools::Rectangle& rNewRect) : SdrAttrObj(rSdrModel) - , maRect(rNewRect) , mpEditingOutliner(nullptr) , meTextKind(eNewTextKind) , maTextEditOffset(Point(0, 0)) @@ -185,7 +185,9 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrObjKind eNewTextKind, , mbTextAnimationAllowed(true) , mbInDownScale(false) { - ImpJustifyRect(maRect); + tools::Rectangle aRectangle(rNewRect); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); // #i25616# mbSupportTextIndentingOnLineWidthChange = true; @@ -199,14 +201,14 @@ SdrTextObj::~SdrTextObj() void SdrTextObj::FitFrameToTextSize() { - ImpJustifyRect(maRect); + ImpJustifyRect(maRectangle); SdrText* pText = getActiveText(); if(pText==nullptr || !pText->GetOutlinerParaObject()) return; SdrOutliner& rOutliner=ImpGetDrawOutliner(); - rOutliner.SetPaperSize(Size(maRect.Right()-maRect.Left(),maRect.Bottom()-maRect.Top())); + rOutliner.SetPaperSize(Size(getRectangle().Right() - getRectangle().Left(), getRectangle().Bottom() - getRectangle().Top())); rOutliner.SetUpdateLayout(true); rOutliner.SetText(*pText->GetOutlinerParaObject()); Size aNewSize(rOutliner.CalcTextSize()); @@ -214,12 +216,12 @@ void SdrTextObj::FitFrameToTextSize() aNewSize.AdjustWidth( 1 ); // because of possible rounding errors aNewSize.AdjustWidth(GetTextLeftDistance()+GetTextRightDistance() ); aNewSize.AdjustHeight(GetTextUpperDistance()+GetTextLowerDistance() ); - tools::Rectangle aNewRect(maRect); + tools::Rectangle aNewRect(getRectangle()); aNewRect.SetSize(aNewSize); ImpJustifyRect(aNewRect); - if (aNewRect!=maRect) { + + if (aNewRect != getRectangle()) SetLogicRect(aNewRect); - } } void SdrTextObj::NbcSetText(const OUString& rStr) @@ -523,7 +525,7 @@ void SdrTextObj::AdaptTextMinSize() { // Set minimum width. const tools::Long nDist = GetTextLeftDistance() + GetTextRightDistance(); - const tools::Long nW = std::max<tools::Long>(0, maRect.GetWidth() - 1 - nDist); // text width without margins + const tools::Long nW = std::max<tools::Long>(0, getRectangle().GetWidth() - 1 - nDist); // text width without margins aSet.Put(makeSdrTextMinFrameWidthItem(nW)); @@ -538,7 +540,7 @@ void SdrTextObj::AdaptTextMinSize() { // Set Minimum height. const tools::Long nDist = GetTextUpperDistance() + GetTextLowerDistance(); - const tools::Long nH = std::max<tools::Long>(0, maRect.GetHeight() - 1 - nDist); // text height without margins + const tools::Long nH = std::max<tools::Long>(0, getRectangle().GetHeight() - 1 - nDist); // text height without margins aSet.Put(makeSdrTextMinFrameHeightItem(nH)); @@ -610,7 +612,7 @@ void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, tools::Rectangle void SdrTextObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const { - rRect=maRect; + rRect = getRectangle(); } // See also: <unnamed>::getTextAnchorRange in svx/source/sdr/primitive2d/sdrdecompositiontools.cxx @@ -649,7 +651,7 @@ void SdrTextObj::AdjustRectToTextDistance(tools::Rectangle& rAnchorRect) const void SdrTextObj::TakeTextAnchorRect(tools::Rectangle& rAnchorRect) const { - tools::Rectangle aAnkRect(maRect); // the rectangle in which we anchor + tools::Rectangle aAnkRect(getRectangle()); // the rectangle in which we anchor bool bFrame=IsTextFrame(); if (!bFrame) { TakeUnrotatedSnapRect(aAnkRect); @@ -1058,9 +1060,11 @@ rtl::Reference<SdrObject> SdrTextObj::CloneSdrObject(SdrModel& rTargetModel) con basegfx::B2DPolyPolygon SdrTextObj::TakeXorPoly() const { - tools::Polygon aPol(maRect); - if (maGeo.nShearAngle) ShearPoly(aPol,maRect.TopLeft(),maGeo.mfTanShearAngle); - if (maGeo.nRotationAngle) RotatePoly(aPol,maRect.TopLeft(),maGeo.mfSinRotationAngle,maGeo.mfCosRotationAngle); + tools::Polygon aPol(getRectangle()); + if (maGeo.nShearAngle) + ShearPoly(aPol, getRectangle().TopLeft(), maGeo.mfTanShearAngle); + if (maGeo.nRotationAngle) + RotatePoly(aPol, getRectangle().TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); basegfx::B2DPolyPolygon aRetval; aRetval.append(aPol.getB2DPolygon()); @@ -1098,9 +1102,9 @@ void SdrTextObj::RecalcSnapRect() { if (maGeo.nRotationAngle || maGeo.nShearAngle) { - maSnapRect = Rect2Poly(maRect, maGeo).GetBoundRect(); + maSnapRect = Rect2Poly(getRectangle(), maGeo).GetBoundRect(); } else { - maSnapRect = maRect; + maSnapRect = getRectangle(); } } @@ -1112,15 +1116,18 @@ sal_uInt32 SdrTextObj::GetSnapPointCount() const Point SdrTextObj::GetSnapPoint(sal_uInt32 i) const { Point aP; + auto aRectangle = getRectangle(); switch (i) { - case 0: aP=maRect.TopLeft(); break; - case 1: aP=maRect.TopRight(); break; - case 2: aP=maRect.BottomLeft(); break; - case 3: aP=maRect.BottomRight(); break; - default: aP=maRect.Center(); break; - } - if (maGeo.nShearAngle) ShearPoint(aP,maRect.TopLeft(),maGeo.mfTanShearAngle); - if (maGeo.nRotationAngle) RotatePoint(aP,maRect.TopLeft(),maGeo.mfSinRotationAngle,maGeo.mfCosRotationAngle); + case 0: aP = aRectangle.TopLeft(); break; + case 1: aP = aRectangle.TopRight(); break; + case 2: aP = aRectangle.BottomLeft(); break; + case 3: aP = aRectangle.BottomRight(); break; + default: aP = aRectangle.Center(); break; + } + if (maGeo.nShearAngle) + ShearPoint(aP, aRectangle.TopLeft(), maGeo.mfTanShearAngle); + if (maGeo.nRotationAngle) + RotatePoint(aP, aRectangle.TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); return aP; } @@ -1401,7 +1408,7 @@ void SdrTextObj::SaveGeoData(SdrObjGeoData& rGeo) const { SdrAttrObj::SaveGeoData(rGeo); SdrTextObjGeoData& rTGeo=static_cast<SdrTextObjGeoData&>(rGeo); - rTGeo.maRect = maRect; + rTGeo.maRect = getRectangle(); rTGeo.maGeo = maGeo; } @@ -1426,7 +1433,7 @@ drawing::TextFitToSizeType SdrTextObj::GetFitToSize() const const tools::Rectangle& SdrTextObj::GetGeoRect() const { - return maRect; + return getRectangle(); } void SdrTextObj::ForceOutlinerParaObject() @@ -1559,7 +1566,7 @@ bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DP double fShearX = toRadians(maGeo.nShearAngle); // get aRect, this is the unrotated snaprect - tools::Rectangle aRectangle(maRect); + tools::Rectangle aRectangle(getRectangle()); // fill other values basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight()); diff --git a/svx/source/svdraw/svdotxat.cxx b/svx/source/svdraw/svdotxat.cxx index 49f7b2e79d2c..be87d5dd7577 100644 --- a/svx/source/svdraw/svdotxat.cxx +++ b/svx/source/svdraw/svdotxat.cxx @@ -240,7 +240,9 @@ bool SdrTextObj::AdjustTextFrameWidthAndHeight( tools::Rectangle& rR, bool bHgt, bool SdrTextObj::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt) { - bool bRet = AdjustTextFrameWidthAndHeight(maRect,bHgt,bWdt); + tools::Rectangle aRectangle(getRectangle()); + bool bRet = AdjustTextFrameWidthAndHeight(aRectangle, bHgt, bWdt); + setRectangle(aRectangle); if (bRet) { SetBoundAndSnapRectsDirty(); @@ -256,11 +258,11 @@ bool SdrTextObj::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt) bool SdrTextObj::AdjustTextFrameWidthAndHeight() { - tools::Rectangle aNewRect(maRect); - bool bRet=AdjustTextFrameWidthAndHeight(aNewRect); + tools::Rectangle aNewRect(getRectangle()); + bool bRet = AdjustTextFrameWidthAndHeight(aNewRect); if (bRet) { tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); - maRect = aNewRect; + setRectangle(aNewRect); SetBoundAndSnapRectsDirty(); if (auto pRectObj = dynamic_cast<SdrRectObj *>(this)) { // this is a hack pRectObj->SetXPolyDirty(); diff --git a/svx/source/svdraw/svdotxdr.cxx b/svx/source/svdraw/svdotxdr.cxx index a64da65dd1e9..c4a9046d0c0e 100644 --- a/svx/source/svdraw/svdotxdr.cxx +++ b/svx/source/svdraw/svdotxdr.cxx @@ -44,18 +44,21 @@ void SdrTextObj::AddToHdlList(SdrHdlList& rHdlList) const { Point aPnt; SdrHdlKind eKind = SdrHdlKind::UpperLeft; + auto aRectangle = getRectangle(); switch (nHdlNum) { - case 0: aPnt=maRect.TopLeft(); eKind=SdrHdlKind::UpperLeft; break; - case 1: aPnt=maRect.TopCenter(); eKind=SdrHdlKind::Upper; break; - case 2: aPnt=maRect.TopRight(); eKind=SdrHdlKind::UpperRight; break; - case 3: aPnt=maRect.LeftCenter(); eKind=SdrHdlKind::Left ; break; - case 4: aPnt=maRect.RightCenter(); eKind=SdrHdlKind::Right; break; - case 5: aPnt=maRect.BottomLeft(); eKind=SdrHdlKind::LowerLeft; break; - case 6: aPnt=maRect.BottomCenter(); eKind=SdrHdlKind::Lower; break; - case 7: aPnt=maRect.BottomRight(); eKind=SdrHdlKind::LowerRight; break; + case 0: aPnt = aRectangle.TopLeft(); eKind=SdrHdlKind::UpperLeft; break; + case 1: aPnt = aRectangle.TopCenter(); eKind=SdrHdlKind::Upper; break; + case 2: aPnt = aRectangle.TopRight(); eKind=SdrHdlKind::UpperRight; break; + case 3: aPnt = aRectangle.LeftCenter(); eKind=SdrHdlKind::Left ; break; + case 4: aPnt = aRectangle.RightCenter(); eKind=SdrHdlKind::Right; break; + case 5: aPnt = aRectangle.BottomLeft(); eKind=SdrHdlKind::LowerLeft; break; + case 6: aPnt = aRectangle.BottomCenter(); eKind=SdrHdlKind::Lower; break; + case 7: aPnt = aRectangle.BottomRight(); eKind=SdrHdlKind::LowerRight; break; } - if (maGeo.nShearAngle) ShearPoint(aPnt,maRect.TopLeft(),maGeo.mfTanShearAngle); - if (maGeo.nRotationAngle) RotatePoint(aPnt,maRect.TopLeft(),maGeo.mfSinRotationAngle,maGeo.mfCosRotationAngle); + if (maGeo.nShearAngle) + ShearPoint(aPnt, aRectangle.TopLeft(), maGeo.mfTanShearAngle); + if (maGeo.nRotationAngle) + RotatePoint(aPnt, aRectangle.TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); std::unique_ptr<SdrHdl> pH(new SdrHdl(aPnt,eKind)); pH->SetObj(const_cast<SdrTextObj*>(this)); pH->SetRotationAngle(maGeo.nRotationAngle); @@ -71,7 +74,7 @@ bool SdrTextObj::hasSpecialDrag() const tools::Rectangle SdrTextObj::ImpDragCalcRect(const SdrDragStat& rDrag) const { - tools::Rectangle aTmpRect(maRect); + tools::Rectangle aTmpRect(getRectangle()); const SdrHdl* pHdl=rDrag.GetHdl(); SdrHdlKind eHdl=pHdl==nullptr ? SdrHdlKind::Move : pHdl->GetKind(); bool bEcke=(eHdl==SdrHdlKind::UpperLeft || eHdl==SdrHdlKind::UpperRight || eHdl==SdrHdlKind::LowerLeft || eHdl==SdrHdlKind::LowerRight); @@ -92,8 +95,8 @@ tools::Rectangle SdrTextObj::ImpDragCalcRect(const SdrDragStat& rDrag) const if (bTop) aTmpRect.SetTop(aPos.Y() ); if (bBtm) aTmpRect.SetBottom(aPos.Y() ); if (bOrtho) { // Ortho - tools::Long nWdt0=maRect.Right() -maRect.Left(); - tools::Long nHgt0=maRect.Bottom()-maRect.Top(); + tools::Long nWdt0=getRectangle().Right() - getRectangle().Left(); + tools::Long nHgt0=getRectangle().Bottom() - getRectangle().Top(); tools::Long nXMul=aTmpRect.Right() -aTmpRect.Left(); tools::Long nYMul=aTmpRect.Bottom()-aTmpRect.Top(); tools::Long nXDiv=nWdt0; @@ -125,13 +128,13 @@ tools::Rectangle SdrTextObj::ImpDragCalcRect(const SdrDragStat& rDrag) const } } else { // apex handles if ((bLft || bRgt) && nXDiv!=0) { - tools::Long nHgt0b=maRect.Bottom()-maRect.Top(); + tools::Long nHgt0b=getRectangle().Bottom() - getRectangle().Top(); tools::Long nNeed=tools::Long(BigInt(nHgt0b)*BigInt(nXMul)/BigInt(nXDiv)); aTmpRect.AdjustTop( -((nNeed-nHgt0b)/2) ); aTmpRect.SetBottom(aTmpRect.Top()+nNeed ); } if ((bTop || bBtm) && nYDiv!=0) { - tools::Long nWdt0b=maRect.Right()-maRect.Left(); + tools::Long nWdt0b=getRectangle().Right() - getRectangle().Left(); tools::Long nNeed=tools::Long(BigInt(nWdt0b)*BigInt(nYMul)/BigInt(nYDiv)); aTmpRect.AdjustLeft( -((nNeed-nWdt0b)/2) ); aTmpRect.SetRight(aTmpRect.Left()+nNeed ); @@ -150,20 +153,20 @@ bool SdrTextObj::applySpecialDrag(SdrDragStat& rDrag) { tools::Rectangle aNewRect(ImpDragCalcRect(rDrag)); - if(aNewRect.TopLeft() != maRect.TopLeft() && (maGeo.nRotationAngle || maGeo.nShearAngle)) + if(aNewRect.TopLeft() != getRectangle().TopLeft() && (maGeo.nRotationAngle || maGeo.nShearAngle)) { Point aNewPos(aNewRect.TopLeft()); if (maGeo.nShearAngle) - ShearPoint(aNewPos,maRect.TopLeft(),maGeo.mfTanShearAngle); + ShearPoint(aNewPos, getRectangle().TopLeft(), maGeo.mfTanShearAngle); if (maGeo.nRotationAngle) - RotatePoint(aNewPos,maRect.TopLeft(),maGeo.mfSinRotationAngle,maGeo.mfCosRotationAngle); + RotatePoint(aNewPos, getRectangle().TopLeft(), maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); aNewRect.SetPos(aNewPos); } - if (aNewRect != maRect) + if (aNewRect != getRectangle()) { NbcSetLogicRect(aNewRect); } @@ -185,7 +188,7 @@ bool SdrTextObj::BegCreate(SdrDragStat& rStat) tools::Rectangle aRect1(rStat.GetStart(), rStat.GetNow()); aRect1.Normalize(); rStat.SetActionRect(aRect1); - maRect = aRect1; + setRectangle(aRect1); return true; } @@ -195,7 +198,7 @@ bool SdrTextObj::MovCreate(SdrDragStat& rStat) rStat.TakeCreateRect(aRect1); ImpJustifyRect(aRect1); rStat.SetActionRect(aRect1); - maRect = aRect1; // for ObjName + setRectangle(aRect1); // for ObjName SetBoundRectDirty(); m_bSnapRectDirty=true; if (auto pRectObj = dynamic_cast<SdrRectObj *>(this)) { @@ -206,8 +209,10 @@ bool SdrTextObj::MovCreate(SdrDragStat& rStat) bool SdrTextObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) { - rStat.TakeCreateRect(maRect); - ImpJustifyRect(maRect); + tools::Rectangle aRectangle(getRectangle()); + rStat.TakeCreateRect(aRectangle); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); AdaptTextMinSize(); diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index 17d4f8efc126..523a820a4165 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx ... etc. - the rest is truncated