diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-07-29 20:49:29 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-07-30 16:40:56 +0200 |
commit | 8689bd5490b473a7ffb149bbe5f7f0683f679c72 (patch) | |
tree | 896991b9de6e8aa9e00149b8ff7c12873cd73d48 /vcl | |
parent | d4d8fb12e81152ad75d1ab4cabfa300aa982e589 (diff) |
convert TextAlign to scoped enum
Change-Id: Id2c466eacb44f0ea6adba75a0ac0be8be8e7ed4c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119682
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/font.cxx | 6 | ||||
-rw-r--r-- | vcl/qa/cppunit/svm/svmtest.cxx | 2 | ||||
-rw-r--r-- | vcl/source/app/help.cxx | 2 | ||||
-rw-r--r-- | vcl/source/edit/texteng.cxx | 2 | ||||
-rw-r--r-- | vcl/source/filter/eps/eps.cxx | 8 | ||||
-rw-r--r-- | vcl/source/filter/idxf/dxf2mtf.cxx | 2 | ||||
-rw-r--r-- | vcl/source/filter/imet/ios2met.cxx | 2 | ||||
-rw-r--r-- | vcl/source/filter/ipict/ipict.cxx | 2 | ||||
-rw-r--r-- | vcl/source/filter/wmf/emfwr.cxx | 12 | ||||
-rw-r--r-- | vcl/source/filter/wmf/wmfwr.cxx | 22 | ||||
-rw-r--r-- | vcl/source/font/font.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/metaact.cxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/mtfxmldump.cxx | 7 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 12 | ||||
-rw-r--r-- | vcl/source/outdev/font.cxx | 10 | ||||
-rw-r--r-- | vcl/source/outdev/outdevstate.cxx | 2 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 8 | ||||
-rw-r--r-- | vcl/workben/vcldemo.cxx | 2 |
18 files changed, 59 insertions, 48 deletions
diff --git a/vcl/qa/cppunit/font.cxx b/vcl/qa/cppunit/font.cxx index e99bf12a5124..7eca6f1c0c5d 100644 --- a/vcl/qa/cppunit/font.cxx +++ b/vcl/qa/cppunit/font.cxx @@ -86,10 +86,10 @@ void VclFontTest::testAlignment() { vcl::Font aFont; - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Text alignment should be ALIGN_TOP", TextAlign::ALIGN_TOP, aFont.GetAlignment()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Text alignment should be TextAlign::Top", TextAlign::Top, aFont.GetAlignment()); - aFont.SetAlignment(TextAlign::ALIGN_BASELINE); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Text alignment should be ALIGN_BASELINE", TextAlign::ALIGN_BASELINE, aFont.GetAlignment()); + aFont.SetAlignment(TextAlign::Baseline); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Text alignment should be TextAlign::Baseline", TextAlign::Baseline, aFont.GetAlignment()); } diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx index 7a1f4b8f0dba..5f9a4bced6a4 100644 --- a/vcl/qa/cppunit/svm/svmtest.cxx +++ b/vcl/qa/cppunit/svm/svmtest.cxx @@ -1836,7 +1836,7 @@ void SvmTest::testTextAlign() ScopedVclPtrInstance<VirtualDevice> pVirtualDev; setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile); - pVirtualDev->SetTextAlign(TextAlign::ALIGN_BOTTOM); + pVirtualDev->SetTextAlign(TextAlign::Bottom); checkTextAlign(writeAndReadStream(aGDIMetaFile)); checkTextAlign(readFile(u"textalign.svm")); diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx index c77bf57e1bd4..45935937a9c4 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -289,7 +289,7 @@ void HelpTextWindow::ApplySettings(vcl::RenderContext& rRenderContext) const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); SetPointFont(rRenderContext, rStyleSettings.GetHelpFont()); rRenderContext.SetTextColor(rStyleSettings.GetHelpTextColor()); - rRenderContext.SetTextAlign(ALIGN_TOP); + rRenderContext.SetTextAlign(TextAlign::Top); if (rRenderContext.IsNativeControlSupported(ControlType::Tooltip, ControlPart::Entire)) { diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 96ad2c63bc80..95ef0dbcaf91 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -188,7 +188,7 @@ void TextEngine::SetFont( const vcl::Font& rFont ) aFillColor.SetAlpha( 255 ); maFont.SetFillColor( aFillColor ); - maFont.SetAlignment( ALIGN_TOP ); + maFont.SetAlignment(TextAlign::Top); mpRefDev->SetFont( maFont ); mnDefTab = mpRefDev->GetTextWidth(" "); if ( !mnDefTab ) diff --git a/vcl/source/filter/eps/eps.cxx b/vcl/source/filter/eps/eps.cxx index 2da28338c97c..61ea92e0269b 100644 --- a/vcl/source/filter/eps/eps.cxx +++ b/vcl/source/filter/eps/eps.cxx @@ -408,7 +408,7 @@ bool PSWriter::WritePS( const Graphic& rGraphic, SvStream& rTargetStream, Filter eLineCap = SvtGraphicStroke::capButt; eJoinType = SvtGraphicStroke::joinMiter; aBackgroundColor = COL_WHITE; - eTextAlign = ALIGN_BASELINE; + eTextAlign = TextAlign::Baseline; if( pMTF->GetActionSize() ) { @@ -2075,11 +2075,11 @@ void PSWriter::ImplSetAttrForText( const Point& rPoint ) ImplWriteDouble( aSize.Height() ); mpPS->WriteCharPtr( "sf " ); } - if ( eTextAlign != ALIGN_BASELINE ) + if ( eTextAlign != TextAlign::Baseline ) { // PostScript does not know about FontAlignment - if ( eTextAlign == ALIGN_TOP ) // -> so I assume that + if ( eTextAlign == TextAlign::Top ) // -> so I assume that aPoint.AdjustY( aSize.Height() * 4 / 5 ); // the area under the baseline - else if ( eTextAlign == ALIGN_BOTTOM ) // is about 20% of the font size + else if ( eTextAlign == TextAlign::Bottom ) // is about 20% of the font size aPoint.AdjustY( -( aSize.Height() / 5 ) ); } ImplMoveTo( aPoint ); diff --git a/vcl/source/filter/idxf/dxf2mtf.cxx b/vcl/source/filter/idxf/dxf2mtf.cxx index 06aebc3da16b..1b470c63cc7f 100644 --- a/vcl/source/filter/idxf/dxf2mtf.cxx +++ b/vcl/source/filter/idxf/dxf2mtf.cxx @@ -205,7 +205,7 @@ bool DXF2GDIMetaFile::SetFontAttribute(const DXFBasicEntity & rE, short nAngle, aFont.SetTransparent(true); aFont.SetFamily(FAMILY_SWISS); aFont.SetFontSize(Size(0,nHeight)); - aFont.SetAlignment(ALIGN_BASELINE); + aFont.SetAlignment(TextAlign::Baseline); aFont.SetOrientation(Degree10(nAngle)); if (aActFont!=aFont) { aActFont=aFont; diff --git a/vcl/source/filter/imet/ios2met.cxx b/vcl/source/filter/imet/ios2met.cxx index 1d0b83ba1fb3..f1a6057bc8bc 100644 --- a/vcl/source/filter/imet/ios2met.cxx +++ b/vcl/source/filter/imet/ios2met.cxx @@ -2348,7 +2348,7 @@ void OS2METReader::ReadFont(sal_uInt16 nFieldSize) pF->pSucc=pFontList; pFontList=pF; pF->nID=0; pF->aFont.SetTransparent(true); - pF->aFont.SetAlignment(ALIGN_BASELINE); + pF->aFont.SetAlignment(TextAlign::Baseline); auto nPos=pOS2MET->Tell(); auto nMaxPos = nPos + nFieldSize; diff --git a/vcl/source/filter/ipict/ipict.cxx b/vcl/source/filter/ipict/ipict.cxx index 1d22137d0fcf..0c5adf8cfcb7 100644 --- a/vcl/source/filter/ipict/ipict.cxx +++ b/vcl/source/filter/ipict/ipict.cxx @@ -1914,7 +1914,7 @@ void PictReader::ReadPict( SvStream & rStreamPict, GDIMetaFile & rGDIMetaFile ) aActFont.SetCharSet( GetTextEncoding()); aActFont.SetFamily(FAMILY_SWISS); aActFont.SetFontSize(Size(0,12)); - aActFont.SetAlignment(ALIGN_BASELINE); + aActFont.SetAlignment(TextAlign::Baseline); aHRes = aVRes = Fraction( 1, 1 ); diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index 9776de87e182..6c6428959652 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -562,9 +562,15 @@ void EMFWriter::ImplCheckTextAttr() switch( rFont.GetAlignment() ) { - case ALIGN_TOP: nTextAlign = TA_TOP; break; - case ALIGN_BOTTOM: nTextAlign = TA_BOTTOM; break; - default: nTextAlign = TA_BASELINE; break; + case TextAlign::Top: + nTextAlign = TA_TOP; + break; + case TextAlign::Bottom: + nTextAlign = TA_BOTTOM; + break; + case TextAlign::Baseline: + nTextAlign = TA_BASELINE; + break; } nTextAlign |= mnHorTextAlign; diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index 9b3751b9cea9..90e51a4ca93b 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -144,11 +144,11 @@ WMFWriter::WMFWriter() , nMaxRecordSize(0) , nActRecordPos(0) , eSrcRasterOp(RasterOp::OverPaint) - , eSrcTextAlign(ALIGN_BASELINE) + , eSrcTextAlign(TextAlign::Baseline) , pAttrStack(nullptr) , eSrcHorTextAlign(W_TA_LEFT) , eDstROP2(RasterOp::OverPaint) - , eDstTextAlign(ALIGN_BASELINE) + , eDstTextAlign(TextAlign::Baseline) , eDstHorTextAlign(W_TA_LEFT) , bHandleAllocated{} , nDstPenHandle(0) @@ -740,9 +740,15 @@ void WMFWriter::WMFRecord_SetTextAlign(TextAlign eFontAlign, sal_uInt16 eHorText sal_uInt16 nAlign; switch (eFontAlign) { - case ALIGN_TOP: nAlign=W_TA_TOP; break; - case ALIGN_BOTTOM: nAlign=W_TA_BOTTOM; break; - default: nAlign=W_TA_BASELINE; + case TextAlign::Top: + nAlign=W_TA_TOP; + break; + case TextAlign::Bottom: + nAlign=W_TA_BOTTOM; + break; + case TextAlign::Baseline: + nAlign=W_TA_BASELINE; + break; } nAlign|=eHorTextAlign; nAlign|=W_TA_NOUPDATECP; @@ -1453,7 +1459,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) } eSrcTextAlign = aSrcFont.GetAlignment(); aSrcTextColor = aSrcFont.GetColor(); - aSrcFont.SetAlignment( ALIGN_BASELINE ); + aSrcFont.SetAlignment( TextAlign::Baseline ); aSrcFont.SetColor( COL_WHITE ); } break; @@ -1770,11 +1776,11 @@ bool WMFWriter::WriteWMF( const GDIMetaFile& rMTF, SvStream& rTargetStream, vcl::Font aFont; aFont.SetCharSet( GetExtendedTextEncoding( RTL_TEXTENCODING_MS_1252 ) ); aFont.SetColor( COL_WHITE ); - aFont.SetAlignment( ALIGN_BASELINE ); + aFont.SetAlignment( TextAlign::Baseline ); aDstFont = aSrcFont = aFont; CreateSelectDeleteFont(aDstFont); - eDstTextAlign = eSrcTextAlign = ALIGN_BASELINE; + eDstTextAlign = eSrcTextAlign = TextAlign::Baseline; eDstHorTextAlign = eSrcHorTextAlign = W_TA_LEFT; WMFRecord_SetTextAlign( eDstTextAlign, eDstHorTextAlign ); diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx index cc5042fc9506..c2edc3dca403 100644 --- a/vcl/source/font/font.cxx +++ b/vcl/source/font/font.cxx @@ -880,7 +880,7 @@ ImplFont::ImplFont() : mePitch( PITCH_DONTKNOW ), meWidthType( WIDTH_DONTKNOW ), meItalic( ITALIC_NONE ), - meAlign( ALIGN_TOP ), + meAlign( TextAlign::Top ), meUnderline( LINESTYLE_NONE ), meOverline( LINESTYLE_NONE ), meStrikeout( STRIKEOUT_NONE ), diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index d5e4cc81bb94..8f119e569b0a 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -2670,7 +2670,7 @@ void MetaOverlineColorAction::Read( SvStream& rIStm, ImplMetaReadData* ) MetaTextAlignAction::MetaTextAlignAction() : MetaAction ( MetaActionType::TEXTALIGN ), - maAlign ( ALIGN_TOP ) + maAlign ( TextAlign::Top ) {} MetaTextAlignAction::~MetaTextAlignAction() @@ -2695,7 +2695,7 @@ void MetaTextAlignAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) { MetaAction::Write(rOStm, pData); VersionCompatWrite aCompat(rOStm, 1); - rOStm.WriteUInt16( maAlign ); + rOStm.WriteUInt16(static_cast<sal_uInt16>(maAlign)); } void MetaTextAlignAction::Read( SvStream& rIStm, ImplMetaReadData* ) diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx index cccc64df808a..9732b7cd1e9a 100644 --- a/vcl/source/gdi/mtfxmldump.cxx +++ b/vcl/source/gdi/mtfxmldump.cxx @@ -144,10 +144,9 @@ OUString convertTextAlignToString(TextAlign eAlign) { switch (eAlign) { - case ALIGN_BASELINE: return "baseline"; - case ALIGN_BOTTOM: return "bottom"; - case ALIGN_TOP: return "top"; - case TextAlign_FORCE_EQUAL_SIZE: return "equalsize"; + case TextAlign::Baseline: return "baseline"; + case TextAlign::Bottom: return "bottom"; + case TextAlign::Top: return "top"; } return OUString(); } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index ab7926c50b4e..04af468aa0d6 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6235,9 +6235,9 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool } Point aAlignOffset; - if ( eAlign == ALIGN_BOTTOM ) + if ( eAlign == TextAlign::Bottom ) aAlignOffset.AdjustY( -(aRefDevFontMetric.GetDescent()) ); - else if ( eAlign == ALIGN_TOP ) + else if ( eAlign == TextAlign::Top ) aAlignOffset.AdjustY(aRefDevFontMetric.GetAscent() ); if( aAlignOffset.X() || aAlignOffset.Y() ) aAlignOffset = aRotScale.transform( aAlignOffset ); @@ -6406,9 +6406,9 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool tools::Long nEmphHeight2 = nEmphHeight / 2; aOffset += Point( nEmphWidth2, nEmphHeight2 ); - if ( eAlign == ALIGN_BOTTOM ) + if ( eAlign == TextAlign::Bottom ) aOffset.AdjustY( -(GetFontInstance()->mxFontMetric->GetDescent()) ); - else if ( eAlign == ALIGN_TOP ) + else if ( eAlign == TextAlign::Top ) aOffset.AdjustY(GetFontInstance()->mxFontMetric->GetAscent() ); nIndex = 0; @@ -7117,9 +7117,9 @@ void PDFWriterImpl::drawTextLine( const Point& rPos, tools::Long nWidth, FontStr Point aPos( rPos ); TextAlign eAlign = m_aCurrentPDFState.m_aFont.GetAlignment(); - if( eAlign == ALIGN_TOP ) + if( eAlign == TextAlign::Top ) aPos.AdjustY(HCONV( pFontInstance->mxFontMetric->GetAscent() )); - else if( eAlign == ALIGN_BOTTOM ) + else if( eAlign == TextAlign::Bottom ) aPos.AdjustY( -HCONV( pFontInstance->mxFontMetric->GetDescent() ) ); OStringBuffer aLine( 512 ); diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 6c761ec4bf07..220b5ddaa976 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -61,7 +61,7 @@ FontMetric OutputDevice::GetDevFont( int nDevFontIndex ) const aFontMetric.SetPitch( rData.GetPitch() ); aFontMetric.SetWeight( rData.GetWeight() ); aFontMetric.SetItalic( rData.GetItalic() ); - aFontMetric.SetAlignment( TextAlign::ALIGN_TOP ); + aFontMetric.SetAlignment( TextAlign::Top ); aFontMetric.SetWidthType( rData.GetWidthType() ); aFontMetric.SetQuality( rData.GetQuality() ); } @@ -199,7 +199,7 @@ FontMetric OutputDevice::GetFontMetric() const aMetric.SetPitch( xFontMetric->GetPitch() ); aMetric.SetWeight( xFontMetric->GetWeight() ); aMetric.SetItalic( xFontMetric->GetItalic() ); - aMetric.SetAlignment( TextAlign::ALIGN_TOP ); + aMetric.SetAlignment( TextAlign::Top ); aMetric.SetWidthType( xFontMetric->GetWidthType() ); if ( pFontInstance->mnOwnOrientation ) aMetric.SetOrientation( pFontInstance->mnOwnOrientation ); @@ -1017,12 +1017,12 @@ bool OutputDevice::ImplNewFont() const // calculate text offset depending on TextAlignment TextAlign eAlign = maFont.GetAlignment(); - if ( eAlign == ALIGN_BASELINE ) + if ( eAlign == TextAlign::Baseline ) { mnTextOffX = 0; mnTextOffY = 0; } - else if ( eAlign == ALIGN_TOP ) + else if ( eAlign == TextAlign::Top ) { mnTextOffX = 0; mnTextOffY = +pFontInstance->mxFontMetric->GetAscent() + mnEmphasisAscent; @@ -1032,7 +1032,7 @@ bool OutputDevice::ImplNewFont() const aOriginPt.RotateAround( mnTextOffX, mnTextOffY, pFontInstance->mnOrientation ); } } - else // eAlign == ALIGN_BOTTOM + else // eAlign == TextAlign::Bottom { mnTextOffX = 0; mnTextOffY = -pFontInstance->mxFontMetric->GetDescent() + mnEmphasisDescent; diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index 7fa966606744..ec16953d40f2 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -32,7 +32,7 @@ OutDevState::OutDevState() : mbMapActive(false) - , meTextAlign(ALIGN_TOP) + , meTextAlign(TextAlign::Top) , meRasterOp(RasterOp::OverPaint) , mnTextLayoutMode(ComplexTextLayoutFlags::Default) , meTextLanguage(0) diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 25234b9f0341..ef11013a02fe 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1586,9 +1586,9 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const tools::Recta aPos.AdjustY((nHeight-(nFormatLines*nTextHeight))/2 ); // Font alignment - if ( eAlign == ALIGN_BOTTOM ) + if ( eAlign == TextAlign::Bottom ) aPos.AdjustY(nTextHeight ); - else if ( eAlign == ALIGN_BASELINE ) + else if ( eAlign == TextAlign::Baseline ) aPos.AdjustY(rTargetDevice.GetFontMetric().GetAscent() ); // Output all lines except for the last one @@ -1664,9 +1664,9 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const tools::Recta aPos.AdjustX((nWidth-nTextWidth)/2 ); // vertical font alignment - if ( eAlign == ALIGN_BOTTOM ) + if ( eAlign == TextAlign::Bottom ) aPos.AdjustY(nTextHeight ); - else if ( eAlign == ALIGN_BASELINE ) + else if ( eAlign == TextAlign::Baseline ) aPos.AdjustY(rTargetDevice.GetFontMetric().GetAscent() ); if ( nStyle & DrawTextFlags::Bottom ) diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 38557c20b955..65896b1f5efc 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -2034,7 +2034,7 @@ class DemoPopup : public FloatingWindow tools::Rectangle aTextRect(Point(6, 6), aSize); SetTextColor(COL_BLACK); - SetTextAlign(ALIGN_TOP); + SetTextAlign(TextAlign::Top); rRenderContext.DrawText(aTextRect, "This is a standalone help text test", DrawTextFlags::MultiLine|DrawTextFlags::WordBreak| DrawTextFlags::Left|DrawTextFlags::Top); |