diff options
author | Hossein <hossein@libreoffice.org> | 2022-02-28 00:07:16 +0100 |
---|---|---|
committer | Hossein <hossein@libreoffice.org> | 2022-03-15 13:00:59 +0100 |
commit | 3e7dd04dd8ca1baea4b7918eb7a7080c595c4625 (patch) | |
tree | 385b48cbef6b844f5a1dbaffc8471bafcfb71912 /emfio/source | |
parent | 9b6a44a3d58cb050156f6f5253c14f6e0f79eabf (diff) |
tdf#145614 Convert #define to enum and constexpr
* Converted symbolic constants with #define in mftools.hxx to:
a) 'enum' where facing multiple values of the same category with
similar prefixes, or enums from the [MS-WMF] / [MS-EMF]
b) extracted the underlying integral type from the above documents
c) 'constexpr' where there was a single value
* Where possible, 'enum class' in 'emfio' namespace is used
* Some enums with binary or comparison operations are not converted
MappingMode, TextAlignmentMode, RasterOperations, PenStyle
CharacterSet, ExtTextOutOptions, PitchFont, FamilyFont, WeightFont
Change-Id: I144b2df4722e23d3b0c0aca7880cf603faa80686
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124099
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'emfio/source')
-rw-r--r-- | emfio/source/reader/emfreader.cxx | 23 | ||||
-rw-r--r-- | emfio/source/reader/mtftools.cxx | 168 | ||||
-rw-r--r-- | emfio/source/reader/wmfreader.cxx | 64 |
3 files changed, 140 insertions, 115 deletions
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index f34250f0ba19..54be65c3bcbf 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -349,7 +349,7 @@ bool ImplReadRegion( basegfx::B2DPolyPolygon& rPolyPoly, SvStream& rStream, sal_ rStream.ReadInt32(nRight); rStream.ReadInt32(nBottom); - if (!rStream.good() || nCountRects == 0 || nType != RDH_RECTANGLES) + if (!rStream.good() || nCountRects == 0 || nType != emfio::RDH_RECTANGLES) return false; SAL_INFO("emfio", "\t\tBounds Left: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom); @@ -1019,7 +1019,7 @@ namespace emfio sal_uInt32 nMapMode(0); mpInputStream->ReadUInt32( nMapMode ); SAL_INFO("emfio", "\t\tMapMode: 0x" << std::hex << nMapMode << std::dec); - SetMapMode( nMapMode ); + SetMapMode( static_cast<MappingMode>(nMapMode) ); } break; @@ -1027,7 +1027,7 @@ namespace emfio { mpInputStream->ReadUInt32( nDat32 ); SAL_INFO("emfio", "\t\tBkMode: 0x" << std::hex << nDat32 << std::dec); - SetBkMode( static_cast<BkMode>(nDat32) ); + SetBkMode( static_cast<BackgroundMode>(nDat32) ); } break; @@ -1133,7 +1133,7 @@ namespace emfio XForm aTempXForm; *mpInputStream >> aTempXForm; mpInputStream->ReadUInt32( nMode ); - ModifyWorldTransform( aTempXForm, nMode ); + ModifyWorldTransform( aTempXForm, static_cast<ModifyWorldTransformMode>(nMode) ); } break; @@ -1336,7 +1336,8 @@ namespace emfio { sal_uInt32 nStyle; mpInputStream->ReadUInt32( nStyle ); - CreateObjectIndexed(nIndex, std::make_unique<WinMtfFillStyle>( ReadColor(), ( nStyle == BS_HOLLOW ) )); + BrushStyle eStyle = static_cast<BrushStyle>(nStyle); + CreateObjectIndexed(nIndex, std::make_unique<WinMtfFillStyle>( ReadColor(), ( eStyle == BrushStyle::BS_HOLLOW ) )); } } break; @@ -1466,7 +1467,7 @@ namespace emfio { sal_Int32 nClippingMode(0); mpInputStream->ReadInt32(nClippingMode); - SetClipPath(GetPathObj(), nClippingMode, true); + SetClipPath(GetPathObj(), static_cast<RegionMode>(nClippingMode), true); } break; @@ -1484,7 +1485,7 @@ namespace emfio // This record's region data should be ignored if mode // is RGN_COPY - see EMF spec section 2.3.2.2 - if (nClippingMode == RGN_COPY) + if (static_cast<RegionMode>(nClippingMode) == RegionMode::RGN_COPY) { SetDefaultClipPath(); } @@ -1494,7 +1495,7 @@ namespace emfio if (cbRgnData) ImplReadRegion(aPolyPoly, *mpInputStream, nRemainingRecSize); const tools::PolyPolygon aPolyPolygon(aPolyPoly); - SetClipPath(aPolyPolygon, nClippingMode, false); + SetClipPath(aPolyPolygon, static_cast<RegionMode>(nClippingMode), false); } } } @@ -1912,9 +1913,9 @@ namespace emfio else { const tools::Rectangle aRect( nLeftRect, nTopRect, nRightRect, nBottomRect ); - const BkMode mnBkModeBackup = mnBkMode; + const BackgroundMode mnBkModeBackup = mnBkMode; if ( nOptions & ETO_NO_RECT ) // Don't draw the background rectangle and text background - mnBkMode = BkMode::Transparent; + mnBkMode = BackgroundMode::Transparent; else if ( nOptions & ETO_OPAQUE ) DrawRectWithBGColor( aRect ); @@ -2018,7 +2019,7 @@ namespace emfio Push(); // Save the current clip. It will be restored after text drawing IntersectClipRect( aRect ); } - DrawText(aPos, aText, aDXAry.empty() ? nullptr : &aDXAry, pDYAry.get(), mbRecordPath, nGfxMode); + DrawText(aPos, aText, aDXAry.empty() ? nullptr : &aDXAry, pDYAry.get(), mbRecordPath, static_cast<GraphicsMode>(nGfxMode)); if ( nOptions & ETO_CLIPPED ) Pop(); } diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index f822915a2fc0..5117411fc54f 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -76,23 +76,23 @@ namespace emfio maClip.subtractPolyPolygon(rPolyPolygon); } - void WinMtfClipPath::setClipPath( const basegfx::B2DPolyPolygon& rB2DPoly, sal_Int32 nClippingMode ) + void WinMtfClipPath::setClipPath( const basegfx::B2DPolyPolygon& rB2DPoly, RegionMode nClippingMode ) { switch ( nClippingMode ) { - case RGN_OR : + case RegionMode::RGN_OR : maClip.unionPolyPolygon(rB2DPoly); break; - case RGN_XOR : + case RegionMode::RGN_XOR : maClip.xorPolyPolygon(rB2DPoly); break; - case RGN_DIFF : + case RegionMode::RGN_DIFF : maClip.subtractPolyPolygon(rB2DPoly); break; - case RGN_AND : + case RegionMode::RGN_AND : maClip.intersectPolyPolygon(rB2DPoly); break; - case RGN_COPY : + case RegionMode::RGN_COPY : maClip = basegfx::utils::B2DClipState(rB2DPoly); break; } @@ -181,23 +181,23 @@ namespace emfio FontFamily eFamily; switch ( rFont.lfPitchAndFamily & 0xf0 ) { - case FF_ROMAN: + case FamilyFont::FF_ROMAN: eFamily = FAMILY_ROMAN; break; - case FF_SWISS: + case FamilyFont::FF_SWISS: eFamily = FAMILY_SWISS; break; - case FF_MODERN: + case FamilyFont::FF_MODERN: eFamily = FAMILY_MODERN; break; - case FF_SCRIPT: + case FamilyFont::FF_SCRIPT: eFamily = FAMILY_SCRIPT; break; - case FF_DECORATIVE: + case FamilyFont::FF_DECORATIVE: eFamily = FAMILY_DECORATIVE; break; @@ -517,38 +517,38 @@ namespace emfio double fX2 = fX * maXForm.eM11 + fY * maXForm.eM21 + maXForm.eDx; double fY2 = fX * maXForm.eM12 + fY * maXForm.eM22 + maXForm.eDy; - if ( mnGfxMode == GM_COMPATIBLE ) + if ( meGfxMode == GraphicsMode::GM_COMPATIBLE ) { fX2 -= mnWinOrgX; fY2 -= mnWinOrgY; - switch( mnMapMode ) + switch( meMapMode ) { - case MM_LOENGLISH : + case MappingMode::MM_LOENGLISH : { fX2 = o3tl::convert(fX2, o3tl::Length::in100, o3tl::Length::mm100); fY2 = o3tl::convert(-fY2, o3tl::Length::in100, o3tl::Length::mm100); } break; - case MM_HIENGLISH : + case MappingMode::MM_HIENGLISH : { fX2 = o3tl::convert(fX2, o3tl::Length::in1000, o3tl::Length::mm100); fY2 = o3tl::convert(-fY2, o3tl::Length::in1000, o3tl::Length::mm100); } break; - case MM_TWIPS: + case MappingMode::MM_TWIPS: { fX2 = o3tl::convert(fX2, o3tl::Length::twip, o3tl::Length::mm100); fY2 = o3tl::convert(-fY2, o3tl::Length::twip, o3tl::Length::mm100); } break; - case MM_LOMETRIC : + case MappingMode::MM_LOMETRIC : { fX2 = o3tl::convert(fX2, o3tl::Length::mm10, o3tl::Length::mm100); fY2 = o3tl::convert(-fY2, o3tl::Length::mm10, o3tl::Length::mm100); } break; - case MM_HIMETRIC : // in hundredth of a millimeter + case MappingMode::MM_HIMETRIC : // in hundredth of a millimeter { fY2 *= -1; } @@ -562,7 +562,7 @@ namespace emfio } else { - if ( mnMapMode != MM_TEXT ) + if ( meMapMode != MappingMode::MM_TEXT ) { fX2 /= mnWinExtX; fY2 /= mnWinExtY; @@ -621,34 +621,34 @@ namespace emfio fHeight = rSz.Height() * aScale.getY(); } - if ( mnGfxMode == GM_COMPATIBLE ) + if ( meGfxMode == GraphicsMode::GM_COMPATIBLE ) { - switch( mnMapMode ) + switch( meMapMode ) { - case MM_LOENGLISH : + case MappingMode::MM_LOENGLISH : { fWidth = o3tl::convert(fWidth, o3tl::Length::in100, o3tl::Length::mm100); fHeight = o3tl::convert(-fHeight, o3tl::Length::in100, o3tl::Length::mm100); } break; - case MM_HIENGLISH : + case MappingMode::MM_HIENGLISH : { fWidth = o3tl::convert(fWidth, o3tl::Length::in1000, o3tl::Length::mm100); fHeight = o3tl::convert(-fHeight, o3tl::Length::in1000, o3tl::Length::mm100); } break; - case MM_LOMETRIC : + case MappingMode::MM_LOMETRIC : { fWidth = o3tl::convert(fWidth, o3tl::Length::mm10, o3tl::Length::mm100); fHeight = o3tl::convert(-fHeight, o3tl::Length::mm10, o3tl::Length::mm100); } break; - case MM_HIMETRIC : // in hundredth of millimeters + case MappingMode::MM_HIMETRIC : // in hundredth of millimeters { fHeight *= -1; } break; - case MM_TWIPS: + case MappingMode::MM_TWIPS: { fWidth = o3tl::convert(fWidth, o3tl::Length::twip, o3tl::Length::mm100); fHeight = o3tl::convert(-fHeight, o3tl::Length::twip, o3tl::Length::mm100); @@ -663,7 +663,7 @@ namespace emfio } else { - if ( mnMapMode != MM_TEXT ) + if ( meMapMode != MappingMode::MM_TEXT ) { fWidth /= mnWinExtX; fHeight /= mnWinExtY; @@ -750,56 +750,56 @@ namespace emfio if ( nIndex & ENHMETA_STOCK_OBJECT ) { SAL_INFO ( "emfio", "\t\t ENHMETA_STOCK_OBJECT, StockObject Enumeration: 0x" << std::hex << nIndex ); - sal_uInt16 nStockId = static_cast<sal_uInt8>(nIndex); + StockObject nStockId = static_cast<StockObject>(nIndex); switch( nStockId ) { - case WHITE_BRUSH : + case StockObject::WHITE_BRUSH : { maFillStyle = WinMtfFillStyle( COL_WHITE ); mbFillStyleSelected = true; } break; - case LTGRAY_BRUSH : + case StockObject::LTGRAY_BRUSH : { maFillStyle = WinMtfFillStyle( COL_LIGHTGRAY ); mbFillStyleSelected = true; } break; - case GRAY_BRUSH : + case StockObject::GRAY_BRUSH : { maFillStyle = WinMtfFillStyle( COL_GRAY ); mbFillStyleSelected = true; } break; - case DKGRAY_BRUSH : + case StockObject::DKGRAY_BRUSH : { maFillStyle = WinMtfFillStyle( COL_GRAY7 ); mbFillStyleSelected = true; } break; - case BLACK_BRUSH : + case StockObject::BLACK_BRUSH : { maFillStyle = WinMtfFillStyle( COL_BLACK ); mbFillStyleSelected = true; } break; - case NULL_BRUSH : + case StockObject::NULL_BRUSH : { maFillStyle = WinMtfFillStyle( COL_TRANSPARENT, true ); mbFillStyleSelected = true; } break; - case WHITE_PEN : + case StockObject::WHITE_PEN : { maLineStyle = WinMtfLineStyle( COL_WHITE ); } break; - case BLACK_PEN : + case StockObject::BLACK_PEN : { maLineStyle = WinMtfLineStyle( COL_BLACK ); } break; - case NULL_PEN : + case StockObject::NULL_PEN : { maLineStyle = WinMtfLineStyle( COL_TRANSPARENT, true ); } @@ -865,7 +865,7 @@ namespace emfio mbClockWiseArcDirection = bClockWise; } - void MtfTools::SetBkMode( BkMode nMode ) + void MtfTools::SetBkMode( BackgroundMode nMode ) { mnBkMode = nMode; } @@ -1036,7 +1036,7 @@ namespace emfio maClipPath.moveClipRegion( ImplMap( rSize ) ); } - void MtfTools::SetClipPath( const tools::PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode, bool bIsMapped ) + void MtfTools::SetClipPath( const tools::PolyPolygon& rPolyPolygon, RegionMode eClippingMode, bool bIsMapped ) { if (utl::ConfigManager::IsFuzzing()) return; @@ -1045,12 +1045,12 @@ namespace emfio if (!bIsMapped) { - if (!mbIsMapDevSet && (mnMapMode == MM_ISOTROPIC || mnMapMode == MM_ANISOTROPIC)) + if (!mbIsMapDevSet && (meMapMode == MappingMode::MM_ISOTROPIC || meMapMode == MappingMode::MM_ANISOTROPIC)) aPolyPolygon = ImplScale(aPolyPolygon); else aPolyPolygon = ImplMap(aPolyPolygon); } - maClipPath.setClipPath(aPolyPolygon.getB2DPolyPolygon(), nClippingMode); + maClipPath.setClipPath(aPolyPolygon.getB2DPolyPolygon(), eClippingMode); } void MtfTools::SetDefaultClipPath() @@ -1061,18 +1061,18 @@ namespace emfio MtfTools::MtfTools( GDIMetaFile& rGDIMetaFile, SvStream& rStreamWMF) : mnLatestTextAlign(90), - mnTextAlign(TA_LEFT | TA_TOP | TA_NOUPDATECP), + mnTextAlign(TextAlignmentMode::TA_LEFT | TextAlignmentMode::TA_TOP | TextAlignmentMode::TA_NOUPDATECP), maLatestBkColor(ColorTransparency, 0x12345678), maBkColor(COL_WHITE), mnLatestTextLayoutMode(vcl::text::ComplexTextLayoutFlags::Default), mnTextLayoutMode(vcl::text::ComplexTextLayoutFlags::Default), - mnLatestBkMode(BkMode::NONE), - mnBkMode(BkMode::OPAQUE), + mnLatestBkMode(BackgroundMode::NONE), + mnBkMode(BackgroundMode::OPAQUE), meLatestRasterOp(RasterOp::Invert), meRasterOp(RasterOp::OverPaint), mnRop(), - mnGfxMode(GM_COMPATIBLE), - mnMapMode(MM_TEXT), + meGfxMode(GraphicsMode::GM_COMPATIBLE), + meMapMode(MappingMode::MM_TEXT), mnDevOrgX(0), mnDevOrgY(0), mnDevWidth(1), @@ -1193,7 +1193,7 @@ namespace emfio void MtfTools::UpdateFillStyle() { if ( !mbFillStyleSelected ) // SJ: #i57205# taking care of bkcolor if no brush is selected - maFillStyle = WinMtfFillStyle( maBkColor, mnBkMode == BkMode::Transparent ); + maFillStyle = WinMtfFillStyle( maBkColor, mnBkMode == BackgroundMode::Transparent ); if (!( maLatestFillStyle == maFillStyle ) ) { maLatestFillStyle = maFillStyle; @@ -1323,12 +1323,12 @@ namespace emfio { WinMtfFillStyle aFillStyleBackup = maFillStyle; bool aTransparentBackup = maLineStyle.bTransparent; - BkMode mnBkModeBackup = mnBkMode; + BackgroundMode mnBkModeBackup = mnBkMode; const tools::Polygon aPoly( rRect ); maLineStyle.bTransparent = true; maFillStyle = maBkColor; - mnBkMode = BkMode::OPAQUE; + mnBkMode = BackgroundMode::OPAQUE; ImplSetNonPersistentLineColorTransparenz(); DrawPolygon(aPoly, false); mnBkMode = mnBkModeBackup; // The rectangle needs to be always drawned even if mode is transparent @@ -1644,12 +1644,12 @@ namespace emfio } } - void MtfTools::DrawText( Point& rPosition, OUString const & rText, std::vector<sal_Int32>* pDXArry, tools::Long* pDYArry, bool bRecordPath, sal_Int32 nGfxMode ) + void MtfTools::DrawText( Point& rPosition, OUString const & rText, std::vector<sal_Int32>* pDXArry, tools::Long* pDYArry, bool bRecordPath, GraphicsMode nGfxMode ) { UpdateClipRegion(); rPosition = ImplMap( rPosition ); - sal_Int32 nOldGfxMode = GetGfxMode(); - SetGfxMode( GM_COMPATIBLE ); + GraphicsMode nOldGfxMode = GetGfxMode(); + SetGfxMode( GraphicsMode::GM_COMPATIBLE ); if (pDXArry) { @@ -1722,14 +1722,14 @@ namespace emfio aTmp.SetColor( maTextColor ); aTmp.SetFillColor( maBkColor ); - if( mnBkMode == BkMode::Transparent ) + if( mnBkMode == BackgroundMode::Transparent ) aTmp.SetTransparent( true ); else aTmp.SetTransparent( false ); aTmp.SetAlignment( eTextAlign ); - if ( nGfxMode == GM_ADVANCED ) + if ( nGfxMode == GraphicsMode::GM_ADVANCED ) { // check whether there is a font rotation applied via transformation Point aP1( ImplMap( Point() ) ); @@ -2143,14 +2143,19 @@ namespace emfio if ( !(rSize.Width() && rSize.Height()) ) return; - switch( mnMapMode ) + switch( meMapMode ) { - case MM_ISOTROPIC : - case MM_ANISOTROPIC : + case MappingMode::MM_ISOTROPIC : + case MappingMode::MM_ANISOTROPIC : { mnDevWidth = rSize.Width(); mnDevHeight = rSize.Height(); + break; } + + //do nothing + default: + break; } if (regular) { @@ -2185,7 +2190,7 @@ namespace emfio { if (!mbIsMapDevSet) { - if ( mnMapMode == MM_ISOTROPIC ) //TODO: WHAT ABOUT ANISOTROPIC??? + if ( meMapMode == MappingMode::MM_ISOTROPIC ) //TODO: WHAT ABOUT ANISOTROPIC??? { sal_Int32 nX, nY; if (o3tl::checked_add(mnWinExtX, mnWinOrgX, nX) || o3tl::checked_sub(mnWinExtY, mnWinOrgY, nY)) @@ -2201,10 +2206,10 @@ namespace emfio if (!(rSize.Width() && rSize.Height())) return; - switch( mnMapMode ) + switch( meMapMode ) { - case MM_ISOTROPIC : - case MM_ANISOTROPIC : + case MappingMode::MM_ISOTROPIC : + case MappingMode::MM_ANISOTROPIC : { mnWinExtX = rSize.Width(); mnWinExtY = rSize.Height(); @@ -2213,7 +2218,12 @@ namespace emfio SetDevByWin(); } mbIsMapWinSet = true; + break; } + + default: + //do nothing + break; } } @@ -2245,15 +2255,15 @@ namespace emfio mnMillY = rSize.Height(); } - void MtfTools::SetMapMode( sal_uInt32 nMapMode ) + void MtfTools::SetMapMode( MappingMode nMapMode ) { - mnMapMode = nMapMode; - if ( nMapMode == MM_TEXT && !mbIsMapWinSet ) + meMapMode = nMapMode; + if ( nMapMode == MappingMode::MM_TEXT && !mbIsMapWinSet ) { mnWinExtX = mnDevWidth; mnWinExtY = mnDevHeight; } - else if ( mnMapMode == MM_HIMETRIC ) + else if ( meMapMode == MappingMode::MM_HIMETRIC ) { sal_Int32 nWinExtX, nWinExtY; if (o3tl::checked_multiply<sal_Int32>(mnMillX, 100, nWinExtX) || @@ -2276,24 +2286,24 @@ namespace emfio maXForm.eDy = rXForm.eDy; } - void MtfTools::ModifyWorldTransform( const XForm& rXForm, sal_uInt32 nMode ) + void MtfTools::ModifyWorldTransform( const XForm& rXForm, ModifyWorldTransformMode nMode ) { switch( nMode ) { - case MWT_IDENTITY : + case ModifyWorldTransformMode::MWT_IDENTITY : { maXForm.eM11 = maXForm.eM22 = 1.0f; maXForm.eM12 = maXForm.eM21 = maXForm.eDx = maXForm.eDy = 0.0f; break; } - case MWT_RIGHTMULTIPLY : - case MWT_LEFTMULTIPLY : + case ModifyWorldTransformMode::MWT_RIGHTMULTIPLY : + case ModifyWorldTransformMode::MWT_LEFTMULTIPLY : { const XForm* pLeft; const XForm* pRight; - if ( nMode == MWT_LEFTMULTIPLY ) + if ( nMode == ModifyWorldTransformMode::MWT_LEFTMULTIPLY ) { pLeft = &rXForm; pRight = &maXForm; @@ -2346,7 +2356,7 @@ namespace emfio maXForm.eDy = cF[2][1]; break; } - case MWT_SET: + case ModifyWorldTransformMode::MWT_SET: { SetWorldTransform(rXForm); break; @@ -2366,8 +2376,8 @@ namespace emfio pSave->aTextColor = maTextColor; pSave->nTextAlign = mnTextAlign; pSave->nTextLayoutMode = mnTextLayoutMode; - pSave->nMapMode = mnMapMode; - pSave->nGfxMode = mnGfxMode; + pSave->eMapMode = meMapMode; + pSave->eGfxMode = meGfxMode; pSave->nBkMode = mnBkMode; pSave->aBkColor = maBkColor; pSave->bClockWiseArcDirection = mbClockWiseArcDirection; @@ -2389,8 +2399,8 @@ namespace emfio pSave->maPathObj = maPathObj; pSave->maClipPath = maClipPath; - SAL_INFO("emfio", "\t\t GfxMode: " << mnGfxMode); - SAL_INFO("emfio", "\t\t MapMode: " << mnMapMode); + SAL_INFO("emfio", "\t\t GfxMode: " << static_cast<sal_uInt32>(meGfxMode)); + SAL_INFO("emfio", "\t\t MapMode: " << static_cast<sal_uInt32>(meMapMode)); SAL_INFO("emfio", "\t\t WinOrg: " << mnWinOrgX << ", " << mnWinOrgY); SAL_INFO("emfio", "\t\t WinExt: " << mnWinExtX << " x " << mnWinExtY); SAL_INFO("emfio", "\t\t DevOrg: " << mnDevOrgX << ", " << mnDevOrgY); @@ -2429,8 +2439,8 @@ namespace emfio mnTextAlign = pSave->nTextAlign; mnTextLayoutMode = pSave->nTextLayoutMode; mnBkMode = pSave->nBkMode; - mnGfxMode = pSave->nGfxMode; - mnMapMode = pSave->nMapMode; + meGfxMode = pSave->eGfxMode; + meMapMode = pSave->eMapMode; maBkColor = pSave->aBkColor; mbClockWiseArcDirection = pSave->bClockWiseArcDirection; mbFillStyleSelected = pSave->bFillStyleSelected; @@ -2460,8 +2470,8 @@ namespace emfio meLatestRasterOp = meRasterOp; } - SAL_INFO("emfio", "\t\t GfxMode: " << mnGfxMode); - SAL_INFO("emfio", "\t\t MapMode: " << mnMapMode); + SAL_INFO("emfio", "\t\t GfxMode: " << static_cast<sal_uInt32>(meGfxMode)); + SAL_INFO("emfio", "\t\t MapMode: " << static_cast<sal_uInt32>(meMapMode)); SAL_INFO("emfio", "\t\t WinOrg: " << mnWinOrgX << ", " << mnWinOrgY); SAL_INFO("emfio", "\t\t WinExt: " << mnWinExtX << " x " << mnWinExtY); SAL_INFO("emfio", "\t\t DevOrg: " << mnDevOrgX << ", " << mnDevOrgY); diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index c4d21b3231b1..44615556793f 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -125,10 +125,10 @@ namespace W_META_CREATEREGION = 0x06FF }; - void GetWinExtMax(const Point& rSource, tools::Rectangle& rPlaceableBound, const sal_Int16 nMapMode) + void GetWinExtMax(const Point& rSource, tools::Rectangle& rPlaceableBound, emfio::MappingMode eMapMode) { Point aSource(rSource); - if (nMapMode == MM_HIMETRIC) + if (eMapMode == emfio::MappingMode::MM_HIMETRIC) aSource.setY( -rSource.Y() ); if (aSource.X() < rPlaceableBound.Left()) rPlaceableBound.SetLeft( aSource.X() ); @@ -140,7 +140,7 @@ namespace rPlaceableBound.SetBottom( aSource.Y() ); } - void GetWinExtMax(const tools::Rectangle& rSource, tools::Rectangle& rPlaceableBound, const sal_Int16 nMapMode) + void GetWinExtMax(const tools::Rectangle& rSource, tools::Rectangle& rPlaceableBound, emfio::MappingMode nMapMode) { GetWinExtMax(rSource.TopLeft(), rPlaceableBound, nMapMode); GetWinExtMax(rSource.BottomRight(), rPlaceableBound, nMapMode); @@ -298,7 +298,7 @@ namespace emfio { sal_uInt16 nDat = 0; mpInputStream->ReadUInt16( nDat ); - SetBkMode( static_cast<BkMode>(nDat) ); + SetBkMode( static_cast<BackgroundMode>(nDat) ); } break; @@ -307,7 +307,7 @@ namespace emfio { sal_Int16 nMapMode = 0; mpInputStream->ReadInt16( nMapMode ); - SetMapMode( nMapMode ); + SetMapMode( static_cast<MappingMode>(nMapMode) ); } break; @@ -939,8 +939,9 @@ namespace emfio sal_uInt16 nStyle(0), nColorUsage(0); mpInputStream->ReadUInt16( nStyle ).ReadUInt16( nColorUsage ); + BrushStyle eStyle = static_cast<BrushStyle>(nStyle); SAL_INFO( "emfio", "\t\t Style:" << nStyle << ", ColorUsage: " << nColorUsage ); - if ( nStyle == BS_PATTERN ) // TODO tdf#142625 Add support for pattern + if ( eStyle == BrushStyle::BS_PATTERN ) // TODO tdf#142625 Add support for pattern { SAL_WARN( "emfio", "\tTODO: Pattern brush style is not supported." ); CreateObject(); @@ -1095,8 +1096,9 @@ namespace emfio { sal_uInt16 nBrushStyle = 0; mpInputStream->ReadUInt16( nBrushStyle ); - CreateObject(std::make_unique<WinMtfFillStyle>( ReadColor(), ( nBrushStyle == BS_NULL ) )); - SAL_WARN_IF( (nBrushStyle != BS_SOLID) && (nBrushStyle != BS_NULL), "emfio", "TODO: Brush style not implemented. Please fill the bug report" ); + BrushStyle eBrushStyle = static_cast<BrushStyle>(nBrushStyle); + CreateObject(std::make_unique<WinMtfFillStyle>( ReadColor(), ( eBrushStyle == BrushStyle::BS_NULL ) )); + SAL_WARN_IF( (eBrushStyle != BrushStyle::BS_SOLID) && (eBrushStyle != BrushStyle::BS_NULL), "emfio", "TODO: Brush style not implemented. Please fill the bug report" ); } break; @@ -1191,7 +1193,7 @@ namespace emfio if ( !nObjIndex ) { tools::PolyPolygon aEmptyPolyPoly; - SetClipPath( aEmptyPolyPoly, RGN_COPY, true ); + SetClipPath( aEmptyPolyPoly, RegionMode::RGN_COPY, true ); } } break; @@ -1458,7 +1460,7 @@ namespace emfio if (mpExternalHeader != nullptr && mpExternalHeader->xExt > 0 && mpExternalHeader->yExt > 0 - && (mpExternalHeader->mapMode == MM_ISOTROPIC || mpExternalHeader->mapMode == MM_ANISOTROPIC)) + && (mpExternalHeader->mapMode == MappingMode::MM_ISOTROPIC || mpExternalHeader->mapMode == MappingMode::MM_ANISOTROPIC)) { // #n417818#: If we have an external header then overwrite the bounds! tools::Rectangle aExtRect(0, 0, @@ -1470,7 +1472,7 @@ namespace emfio " left: " << aPlaceableBound.Left() << " top: " << aPlaceableBound.Top() << " right: " << aPlaceableBound.Right() << " bottom: " << aPlaceableBound.Bottom()); - SetMapMode(mpExternalHeader->mapMode); + SetMapMode(static_cast<MappingMode>(mpExternalHeader->mapMode));; } else { @@ -1551,7 +1553,7 @@ namespace emfio mnEMFRec = 0; mnEMFSize = 0; - SetMapMode( MM_ANISOTROPIC ); + SetMapMode( MappingMode::MM_ANISOTROPIC ); SetWinOrg( Point() ); SetWinExt( Size( 1, 1 ) ); SetDevExt( Size( 10000, 10000 ) ); @@ -1671,7 +1673,7 @@ namespace emfio if (nEnd - nPos) { - sal_Int16 nMapMode = MM_ANISOTROPIC; + MappingMode eMapMode = MappingMode::MM_ANISOTROPIC; sal_uInt16 nFunction; sal_uInt32 nRSize; @@ -1732,36 +1734,48 @@ namespace emfio break; case W_META_SETMAPMODE : + { + sal_Int16 nMapMode(0); pStm->ReadInt16( nMapMode ); + eMapMode = static_cast<MappingMode>(nMapMode); + } break; case W_META_MOVETO: case W_META_LINETO: - GetWinExtMax( ReadYX(), aBound, nMapMode ); + { + GetWinExtMax( ReadYX(), aBound, eMapMode ); bBoundsDetermined = true; + } break; case W_META_RECTANGLE: case W_META_INTERSECTCLIPRECT: case W_META_EXCLUDECLIPRECT : case W_META_ELLIPSE: - GetWinExtMax( ReadRectangle(), aBound, nMapMode ); + { + GetWinExtMax( ReadRectangle(), aBound, eMapMode ); bBoundsDetermined = true; + } break; case W_META_ROUNDRECT: + { ReadYXExt(); // size - GetWinExtMax( ReadRectangle(), aBound, nMapMode ); + GetWinExtMax( ReadRectangle(), aBound, eMapMode ); bBoundsDetermined = true; + } break; case W_META_ARC: case W_META_PIE: case W_META_CHORD: + { ReadYX(); // end ReadYX(); // start - GetWinExtMax( ReadRectangle(), aBound, nMapMode ); + GetWinExtMax( ReadRectangle(), aBound, eMapMode ); bBoundsDetermined = true; + } break; case W_META_POLYGON: @@ -1779,7 +1793,7 @@ namespace emfio { for(sal_uInt16 i = 0; i < nPoints; i++ ) { - GetWinExtMax( ReadPoint(), aBound, nMapMode ); + GetWinExtMax( ReadPoint(), aBound, eMapMode ); bBoundsDetermined = true; } } @@ -1840,7 +1854,7 @@ namespace emfio { for (sal_uInt16 i = 0; i < nPoints; i++ ) { - GetWinExtMax( ReadPoint(), aBound, nMapMode ); + GetWinExtMax( ReadPoint(), aBound, eMapMode ); bBoundsDetermined = true; } } @@ -1872,7 +1886,7 @@ namespace emfio { for (sal_uInt16 i = 0; i < nPoints; ++i) { - GetWinExtMax( ReadPoint(), aBound, nMapMode ); + GetWinExtMax( ReadPoint(), aBound, eMapMode ); bBoundsDetermined = true; } } @@ -1893,7 +1907,7 @@ namespace emfio case W_META_SETPIXEL: { ReadColor(); - GetWinExtMax( ReadYX(), aBound, nMapMode ); + GetWinExtMax( ReadYX(), aBound, eMapMode ); bBoundsDetermined = true; } break; @@ -1906,7 +1920,7 @@ namespace emfio if ( nLength ) { pStm->SeekRel( ( nLength + 1 ) &~ 1 ); - GetWinExtMax( ReadYX(), aBound, nMapMode ); + GetWinExtMax( ReadYX(), aBound, eMapMode ); bBoundsDetermined = true; } } @@ -1920,7 +1934,7 @@ namespace emfio // todo: we also have to take care of the text width if( nLen ) { - GetWinExtMax( aPosition, aBound, nMapMode ); + GetWinExtMax( aPosition, aBound, eMapMode ); bBoundsDetermined = true; } } @@ -1958,7 +1972,7 @@ namespace emfio if ( aDestSize.Width() && aDestSize.Height() ) // #92623# do not try to read buggy bitmaps { tools::Rectangle aDestRect( ReadYX(), aDestSize ); - GetWinExtMax( aDestRect, aBound, nMapMode ); + GetWinExtMax( aDestRect, aBound, eMapMode ); bBoundsDetermined = true; } } @@ -1969,7 +1983,7 @@ namespace emfio sal_uInt32 nROP(0); pStm->ReadUInt32( nROP ); Size aSize = ReadYXExt(); - GetWinExtMax( tools::Rectangle( ReadYX(), aSize ), aBound, nMapMode ); + GetWinExtMax( tools::Rectangle( ReadYX(), aSize ), aBound, eMapMode ); bBoundsDetermined = true; } break; |