diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-03-24 14:45:43 +0100 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-03-25 14:25:13 +0100 |
commit | 6f2fe8bbc4909f457509391522cae4b8084e69e5 (patch) | |
tree | b3f45b995ebaebfcb3381641834507d5e21f39c0 /emfio | |
parent | 6c333f95fbdec8fa65701507b33ac53ccbccba2f (diff) |
WMF/EMF Convert all index type of Objects to unsigned
Based on WMF and EMF documentation, all indexes should be unsigned.
With this commit it was applied, which simplifies code.
Change-Id: I3257da7e595ace45622c6d865fd4b034dc605cb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113039
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'emfio')
-rw-r--r-- | emfio/inc/mtftools.hxx | 6 | ||||
-rw-r--r-- | emfio/source/reader/mtftools.cxx | 26 | ||||
-rw-r--r-- | emfio/source/reader/wmfreader.cxx | 8 |
3 files changed, 26 insertions, 14 deletions
diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index 286442767d3a..2d31fe4ef4ad 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -605,11 +605,11 @@ namespace emfio void SetTextAlign(sal_uInt32 nAlign); void CreateObject(std::unique_ptr<GDIObj> pObject); - void CreateObjectIndexed(sal_Int32 nIndex, std::unique_ptr<GDIObj> pObject); + void CreateObjectIndexed(sal_uInt32 nIndex, std::unique_ptr<GDIObj> pObject); void CreateObject(); - void DeleteObject(sal_Int32 nIndex); - void SelectObject(sal_Int32 nIndex); + void DeleteObject(sal_uInt32 nIndex); + void SelectObject(sal_uInt32 nIndex); rtl_TextEncoding GetCharSet() const { return maFont.GetCharSet(); }; const vcl::Font& GetFont() const { return maFont; } void SetTextLayoutMode(ComplexTextLayoutFlags nLayoutMode); diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index fdb8496f1563..5a2f5d1ca806 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -782,10 +782,11 @@ namespace emfio return rPolyPolygon; } - void MtfTools::SelectObject( sal_Int32 nIndex ) + void MtfTools::SelectObject( sal_uInt32 nIndex ) { 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); switch( nStockId ) { @@ -802,12 +803,17 @@ namespace emfio } break; case GRAY_BRUSH : - case DKGRAY_BRUSH : { maFillStyle = WinMtfFillStyle( COL_GRAY ); mbFillStyleSelected = true; } break; + case DKGRAY_BRUSH : + { + maFillStyle = WinMtfFillStyle( COL_GRAY7 ); + mbFillStyleSelected = true; + } + break; case BLACK_BRUSH : { maFillStyle = WinMtfFillStyle( COL_BLACK ); @@ -845,13 +851,19 @@ namespace emfio GDIObj *pGDIObj = nullptr; - if ( o3tl::make_unsigned(nIndex) < mvGDIObj.size() ) + if ( nIndex < mvGDIObj.size() ) pGDIObj = mvGDIObj[ nIndex ].get(); if ( pGDIObj ) { + + SAL_INFO ( "emfio", "\t\t Index: " << nIndex ); if (const auto pen = dynamic_cast<WinMtfLineStyle*>(pGDIObj)) + { maLineStyle = *pen; + SAL_INFO ( "emfio", "\t Line Style, Color: 0x" << std::hex << maLineStyle.aLineColor + << ", Weight: " << maLineStyle.aLineInfo.GetWidth() ); + } else if (const auto brush = dynamic_cast<WinMtfFillStyle*>( pGDIObj)) { @@ -958,7 +970,7 @@ namespace emfio mvGDIObj[ nIndex ] = std::move(pObject); } - void MtfTools::CreateObjectIndexed( sal_Int32 nIndex, std::unique_ptr<GDIObj> pObject ) + void MtfTools::CreateObjectIndexed( sal_uInt32 nIndex, std::unique_ptr<GDIObj> pObject ) { if ( ( nIndex & ENHMETA_STOCK_OBJECT ) != 0 ) return; @@ -989,7 +1001,7 @@ namespace emfio } } } - if ( o3tl::make_unsigned(nIndex) >= mvGDIObj.size() ) + if ( nIndex >= mvGDIObj.size() ) ImplResizeObjectArry( nIndex + 16 ); mvGDIObj[ nIndex ] = std::move(pObject); @@ -1000,11 +1012,11 @@ namespace emfio CreateObject(std::make_unique<GDIObj>()); } - void MtfTools::DeleteObject( sal_Int32 nIndex ) + void MtfTools::DeleteObject( sal_uInt32 nIndex ) { if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { - if ( o3tl::make_unsigned(nIndex) < mvGDIObj.size() ) + if ( nIndex < mvGDIObj.size() ) { mvGDIObj[ nIndex ].reset(); } diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 0d79b19a33ae..1da3eda3fb1d 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -775,8 +775,8 @@ namespace emfio case W_META_SELECTOBJECT: { - sal_Int16 nObjIndex = 0; - mpInputStream->ReadInt16( nObjIndex ); + sal_uInt16 nObjIndex = 0; + mpInputStream->ReadUInt16( nObjIndex ); SelectObject( nObjIndex ); } break; @@ -943,8 +943,8 @@ namespace emfio case W_META_DELETEOBJECT: { - sal_Int16 nIndex = 0; - mpInputStream->ReadInt16( nIndex ); + sal_uInt16 nIndex = 0; + mpInputStream->ReadUInt16( nIndex ); DeleteObject( nIndex ); } break; |