diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-05-18 17:05:14 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-05-19 15:03:36 +0200 |
commit | 5d8ac801c00fbf1dc16ee8dbfe8167baf7ea0ce0 (patch) | |
tree | e7077c2ad63f69379b6de104c8dc21041a8dc5a1 /editeng | |
parent | 457fabbc358930b71884a97ba9ade4bd26310ce0 (diff) |
SetPhysFont always dereferences its OutputDevice* arg
which is also the case for
ChgPhysFont and GetTextSize
Change-Id: I7e6a1a7eaa77646c53506a73d8946f8df7593e72
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115768
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/accessibility/AccessibleStringWrap.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 40 | ||||
-rw-r--r-- | editeng/source/items/svxfont.cxx | 46 |
4 files changed, 43 insertions, 47 deletions
diff --git a/editeng/source/accessibility/AccessibleStringWrap.cxx b/editeng/source/accessibility/AccessibleStringWrap.cxx index de11c4a0732c..77149d1df70d 100644 --- a/editeng/source/accessibility/AccessibleStringWrap.cxx +++ b/editeng/source/accessibility/AccessibleStringWrap.cxx @@ -43,7 +43,7 @@ void AccessibleStringWrap::GetCharacterBounds( sal_Int32 nIndex, tools::Rectangl DBG_ASSERT(nIndex >= 0, "SvxAccessibleStringWrap::GetCharacterBounds: index value overflow"); - mrFont.SetPhysFont( &mrDev ); + mrFont.SetPhysFont(mrDev); // #108900# Handle virtual position one-past-the end of the string if( nIndex >= maText.getLength() ) diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index dbf4017542cb..76285d237fd8 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3186,7 +3186,7 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, { SvxFont aTmpFont( pPortion->GetNode()->GetCharAttribs().GetDefFont() ); SeekCursor( pPortion->GetNode(), nPos+1, aTmpFont ); - aTmpFont.SetPhysFont( GetRefDevice() ); + aTmpFont.SetPhysFont(*GetRefDevice()); ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage()); nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen() ).Width(); } diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 907b7493d403..454f65286416 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -829,7 +829,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) if ( !bSameLineAgain ) { SeekCursor( pNode, nTmpPos+1, aTmpFont ); - aTmpFont.SetPhysFont( GetRefDevice() ); + aTmpFont.SetPhysFont(*GetRefDevice()); ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage()); if ( IsFixedCellHeight() ) @@ -1042,7 +1042,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) case EE_FEATURE_FIELD: { SeekCursor( pNode, nTmpPos+1, aTmpFont ); - aTmpFont.SetPhysFont( GetRefDevice() ); + aTmpFont.SetPhysFont(*GetRefDevice()); ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage()); OUString aFieldValue = static_cast<const EditCharAttribField*>(pNextFeature)->GetFieldValue(); @@ -1145,7 +1145,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) { DBG_ASSERT( nPortionLen || bProcessingEmptyLine, "Empty Portion - Extra Space?!" ); SeekCursor( pNode, nTmpPos+1, aTmpFont ); - aTmpFont.SetPhysFont( GetRefDevice() ); + aTmpFont.SetPhysFont(*GetRefDevice()); ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage()); if (!bContinueLastPortion) @@ -1371,7 +1371,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) if ( aTextSize.Height() == 0 ) { SeekCursor( pNode, pLine->GetStart()+1, aTmpFont ); - aTmpFont.SetPhysFont( pRefDev ); + aTmpFont.SetPhysFont(*pRefDev); ImplInitDigitMode(*pRefDev, aTmpFont.GetLanguage()); if ( IsFixedCellHeight() ) @@ -1393,7 +1393,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) if ( rTP.GetKind() != PortionKind::LINEBREAK ) { SeekCursor( pNode, nTPos+1, aTmpFont ); - aTmpFont.SetPhysFont( GetRefDevice() ); + aTmpFont.SetPhysFont(*GetRefDevice()); ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage()); RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont ); } @@ -1707,7 +1707,7 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion ) SvxFont aTmpFont; SeekCursor( pParaPortion->GetNode(), bLineBreak ? pParaPortion->GetNode()->Len() : 0, aTmpFont ); - aTmpFont.SetPhysFont( pRefDev ); + aTmpFont.SetPhysFont(*pRefDev); TextPortion* pDummyPortion = new TextPortion( 0 ); pDummyPortion->GetSize() = aTmpFont.GetPhysTxtSize( pRefDev ); @@ -2070,7 +2070,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te // Determine the width of the Hyph-Portion: SvxFont aFont; SeekCursor( pParaPortion->GetNode(), nBreakPos, aFont ); - aFont.SetPhysFont( GetRefDevice() ); + aFont.SetPhysFont(*GetRefDevice()); pHyphPortion->GetSize().setHeight( GetRefDevice()->GetTextHeight() ); pHyphPortion->GetSize().setWidth( GetRefDevice()->GetTextWidth( CH_HYPH ) ); @@ -2368,7 +2368,7 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos sal_Int32 nTxtPortionStart = pPortion->GetTextPortions().GetStartPos( nSplitPortion ); SvxFont aTmpFont( pPortion->GetNode()->GetCharAttribs().GetDefFont() ); SeekCursor( pPortion->GetNode(), nTxtPortionStart+1, aTmpFont ); - aTmpFont.SetPhysFont( GetRefDevice() ); + aTmpFont.SetPhysFont(*GetRefDevice()); GetRefDevice()->Push( PushFlags::TEXTLANGUAGE ); ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage()); Size aSz = aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(), nTxtPortionStart, pTextPortion->GetLen() ); @@ -2760,7 +2760,7 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo // For the current Output device, because otherwise if RefDev=Printer its looks // ugly on the screen! OutputDevice* pDev = pOut ? pOut : GetRefDevice(); - rFont.SetPhysFont( pDev ); + rFont.SetPhysFont(*pDev); FontMetric aMetric( pDev->GetFontMetric() ); // before forcing nPropr to 100%, calculate a new escapement relative to this fake size. @@ -2891,7 +2891,7 @@ void ImpEditEngine::RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics if ( nPropr != 100 ) { rFont.SetPropr( 100 ); - rFont.SetPhysFont( pRefDev ); + rFont.SetPhysFont(*pRefDev); } sal_uInt16 nAscent, nDescent; @@ -2915,7 +2915,7 @@ void ImpEditEngine::RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics { // Lets see what Leading one gets on the screen VclPtr<VirtualDevice> pVDev = GetVirtualDevice( pRefDev->GetMapMode(), pRefDev->GetDrawMode() ); - rFont.SetPhysFont( pVDev ); + rFont.SetPhysFont(*pVDev); aMetric = pVDev->GetFontMetric(); // This is so that the Leading does not count itself out again, @@ -3189,7 +3189,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po aTmpFont.SetTransparent( sal_False ); } #endif - aTmpFont.SetPhysFont( &rOutDev ); + aTmpFont.SetPhysFont(rOutDev); // #114278# Saving both layout mode and language (since I'm // potentially changing both) @@ -3263,7 +3263,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po aTmpFont.SetEscapement( -20 ); aTmpFont.SetPropr( 25 ); - aTmpFont.SetPhysFont( &rOutDev ); + aTmpFont.SetPhysFont(rOutDev); const Size aSlashSize = aTmpFont.QuickGetTextSize( &rOutDev, aSlash, 0, 1 ); Point aSlashPos( aTmpPos ); @@ -3275,7 +3275,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po aTmpFont.SetEscapement( nOldEscapement ); aTmpFont.SetPropr( nOldPropr ); - aTmpFont.SetPhysFont( &rOutDev ); + aTmpFont.SetPhysFont(rOutDev); } } } @@ -3333,7 +3333,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po pTmpDXArray.reset(new tools::Long[ aText.getLength() ]); pDXArray = pTmpDXArray.get(); - aTmpFont.SetPhysFont( GetRefDevice() ); + aTmpFont.SetPhysFont(*GetRefDevice()); aTmpFont.QuickGetTextSize( GetRefDevice(), aText, nTextStart, nTextLen, pTmpDXArray.get() ); // add a meta file comment if we record to a metafile @@ -3360,7 +3360,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po // crash when accessing 0 pointer in pDXArray pTmpDXArray.reset(new tools::Long[ aText.getLength() ]); pDXArray = pTmpDXArray.get(); - aTmpFont.SetPhysFont( GetRefDevice() ); + aTmpFont.SetPhysFont(*GetRefDevice()); aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.getLength(), pTmpDXArray.get() ); } @@ -3488,7 +3488,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po aOutPos = lcl_ImplCalcRotatedPos( aOutPos, aOrigin, nSin, nCos ); aTmpFont.SetOrientation( aTmpFont.GetOrientation()+nOrientation ); - aTmpFont.SetPhysFont( &rOutDev ); + aTmpFont.SetPhysFont(rOutDev); } @@ -3529,7 +3529,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po sal_uInt8 nProp = aTmpFont.GetPropr(); aTmpFont.SetEscapement( 0 ); aTmpFont.SetPropr( 100 ); - aTmpFont.SetPhysFont( &rOutDev ); + aTmpFont.SetPhysFont(rOutDev); OUStringBuffer aBlanks; comphelper::string::padToLength( aBlanks, nTextLen, ' ' ); Point aUnderlinePos( aOutPos ); @@ -3541,7 +3541,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po if ( !nOrientation ) aTmpFont.SetEscapement( nEsc ); aTmpFont.SetPropr( nProp ); - aTmpFont.SetPhysFont( &rOutDev ); + aTmpFont.SetPhysFont(rOutDev); } } Point aRealOutPos( aOutPos ); @@ -3652,7 +3652,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po SeekCursor( rPortion.GetNode(), nIndex+1, aTmpFont, &rOutDev ); aTmpFont.SetTransparent( false ); aTmpFont.SetEscapement( 0 ); - aTmpFont.SetPhysFont( &rOutDev ); + aTmpFont.SetPhysFont(rOutDev); tools::Long nCharWidth = aTmpFont.QuickGetTextSize( &rOutDev, OUString(rTextPortion.GetExtraValue()), 0, 1 ).Width(); sal_Int32 nChars = 2; diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx index 61039b316ac6..f92c6851a8f3 100644 --- a/editeng/source/items/svxfont.cxx +++ b/editeng/source/items/svxfont.cxx @@ -371,13 +371,13 @@ void SvxFont::DoOnCapitals(SvxDoCapitals &rDo) const } -void SvxFont::SetPhysFont( OutputDevice *pOut ) const +void SvxFont::SetPhysFont(OutputDevice& rOut) const { - const vcl::Font& rCurrentFont = pOut->GetFont(); + const vcl::Font& rCurrentFont = rOut.GetFont(); if ( nPropr == 100 ) { if ( !rCurrentFont.IsSameInstance( *this ) ) - pOut->SetFont( *this ); + rOut.SetFont( *this ); } else { @@ -386,19 +386,17 @@ void SvxFont::SetPhysFont( OutputDevice *pOut ) const aNewFont.SetFontSize( Size( aSize.Width() * nPropr / 100, aSize.Height() * nPropr / 100 ) ); if ( !rCurrentFont.IsSameInstance( aNewFont ) ) - pOut->SetFont( aNewFont ); + rOut.SetFont( aNewFont ); } } - -vcl::Font SvxFont::ChgPhysFont( OutputDevice *pOut ) const +vcl::Font SvxFont::ChgPhysFont(OutputDevice& rOut) const { - vcl::Font aOldFont( pOut->GetFont() ); - SetPhysFont( pOut ); + vcl::Font aOldFont(rOut.GetFont()); + SetPhysFont(rOut); return aOldFont; } - Size SvxFont::GetPhysTxtSize( const OutputDevice *pOut, const OUString &rTxt, const sal_Int32 nIdx, const sal_Int32 nLen ) const { @@ -483,25 +481,23 @@ Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt, return aTxtSize; } - -Size SvxFont::GetTextSize( const OutputDevice *pOut, const OUString &rTxt, - const sal_Int32 nIdx, const sal_Int32 nLen ) const +Size SvxFont::GetTextSize(const OutputDevice& rOut, const OUString &rTxt, + const sal_Int32 nIdx, const sal_Int32 nLen) const { sal_Int32 nTmp = nLen; if ( nTmp == SAL_MAX_INT32 ) // already initialized? nTmp = rTxt.getLength(); - Font aOldFont( ChgPhysFont(const_cast<OutputDevice *>(pOut)) ); + Font aOldFont( ChgPhysFont(const_cast<OutputDevice&>(rOut))); Size aTxtSize; if( IsCapital() && !rTxt.isEmpty() ) { - aTxtSize = GetCapitalSize( pOut, rTxt, nIdx, nTmp ); + aTxtSize = GetCapitalSize(&rOut, rTxt, nIdx, nTmp); } - else aTxtSize = GetPhysTxtSize(pOut,rTxt,nIdx,nTmp); - const_cast<OutputDevice *>(pOut)->SetFont( aOldFont ); + else aTxtSize = GetPhysTxtSize(&rOut,rTxt,nIdx,nTmp); + const_cast<OutputDevice&>(rOut).SetFont(aOldFont); return aTxtSize; } - void SvxFont::QuickDrawText( OutputDevice *pOut, const Point &rPos, const OUString &rTxt, const sal_Int32 nIdx, const sal_Int32 nLen, const tools::Long* pDXArray ) const @@ -587,8 +583,8 @@ void SvxFont::DrawPrev( OutputDevice *pOut, Printer* pPrinter, Size aSize = GetFontSize(); aPos.AdjustY( -(( nTmpEsc * aSize.Height() ) / 100) ); } - Font aOldFont( ChgPhysFont( pOut ) ); - Font aOldPrnFont( ChgPhysFont( pPrinter ) ); + Font aOldFont( ChgPhysFont(*pOut) ); + Font aOldPrnFont( ChgPhysFont(*pPrinter) ); if ( IsCapital() ) DrawCapital( pOut, aPos, rTxt, nIdx, nTmp ); @@ -672,12 +668,12 @@ void SvxDoGetCapitalSize::Do( const OUString &_rTxt, const sal_Int32 _nIdx, { sal_uInt8 nProp = pFont->GetPropr(); pFont->SetProprRel( SMALL_CAPS_PERCENTAGE ); - pFont->SetPhysFont( pOut ); + pFont->SetPhysFont( *pOut ); aPartSize.setWidth( pOut->GetTextWidth( _rTxt, _nIdx, _nLen ) ); aPartSize.setHeight( pOut->GetTextHeight() ); aTxtSize.setHeight( aPartSize.Height() ); pFont->SetPropr( nProp ); - pFont->SetPhysFont( pOut ); + pFont->SetPhysFont( *pOut ); } else { @@ -744,11 +740,11 @@ void SvxDoDrawCapital::DoSpace( const bool bDraw ) bool bTrans = pFont->IsTransparent(); pFont->SetWordLineMode( false ); pFont->SetTransparent( true ); - pFont->SetPhysFont( pOut ); + pFont->SetPhysFont(*pOut); pOut->DrawStretchText( aSpacePos, nDiff, " ", 0, 2 ); pFont->SetWordLineMode( bWordWise ); pFont->SetTransparent( bTrans ); - pFont->SetPhysFont( pOut ); + pFont->SetPhysFont(*pOut); } } @@ -774,7 +770,7 @@ void SvxDoDrawCapital::Do( const OUString &_rTxt, const sal_Int32 _nIdx, nProp = pFont->GetPropr(); pFont->SetProprRel( SMALL_CAPS_PERCENTAGE ); } - pFont->SetPhysFont( pOut ); + pFont->SetPhysFont(*pOut); aPartSize.setWidth( pOut->GetTextWidth( _rTxt, _nIdx, _nLen ) ); aPartSize.setHeight( pOut->GetTextHeight() ); @@ -791,7 +787,7 @@ void SvxDoDrawCapital::Do( const OUString &_rTxt, const sal_Int32 _nIdx, pFont->SetStrikeout( eStrike ); if ( !bUpper ) pFont->SetPropr( nProp ); - pFont->SetPhysFont( pOut ); + pFont->SetPhysFont(*pOut); aPos.AdjustX(nWidth-(nKern/2) ); } |