diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-20 14:15:36 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-05-22 17:51:13 +0000 |
commit | eaba47bce44a373116b0583dc293c8c3238b7bea (patch) | |
tree | 3af5cb6724fcc1e2e61fd154eb616bc0a2f1ddd1 | |
parent | c093af75202f6c9d8e6ae7d8e933b82da6f2c11b (diff) |
Convert XOUTBMP to scoped enum
Change-Id: I8d10cdc78ca73d86bdc9aa08fca591f6eb85eb9e
Reviewed-on: https://gerrit.libreoffice.org/25196
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r-- | include/svx/xoutbmp.hxx | 33 | ||||
-rw-r--r-- | sc/source/filter/html/htmlexp.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/html/htmlexp2.cxx | 10 | ||||
-rw-r--r-- | sc/source/filter/inc/htmlexp.hxx | 2 | ||||
-rw-r--r-- | svx/source/core/extedit.cxx | 2 | ||||
-rw-r--r-- | svx/source/core/graphichelper.cxx | 6 | ||||
-rw-r--r-- | svx/source/dialog/_contdlg.cxx | 6 | ||||
-rw-r--r-- | svx/source/xoutdev/_xoutbmp.cxx | 32 | ||||
-rw-r--r-- | sw/source/filter/html/htmlflywriter.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/html/htmlplug.cxx | 4 |
10 files changed, 58 insertions, 53 deletions
diff --git a/include/svx/xoutbmp.hxx b/include/svx/xoutbmp.hxx index 37dfb307701c..c694625092a0 100644 --- a/include/svx/xoutbmp.hxx +++ b/include/svx/xoutbmp.hxx @@ -24,19 +24,24 @@ #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/beans/PropertyValue.hpp> #include <svx/svxdllapi.h> +#include <o3tl/typed_flags_set.hxx> -#define XOUTBMP_MIRROR_HORZ 0x00000001L -#define XOUTBMP_MIRROR_VERT 0x00000010L - -#define XOUTBMP_CONTOUR_HORZ 0x00000001L -#define XOUTBMP_CONTOUR_VERT 0x00000002L -#define XOUTBMP_CONTOUR_EDGEDETECT 0x00000004L -#define XOUTBMP_DONT_ADD_EXTENSION 0x00000008L - -#define XOUTBMP_DONT_EXPAND_FILENAME 0x10000000L -#define XOUTBMP_USE_GIF_IF_POSSIBLE 0x20000000L -#define XOUTBMP_USE_GIF_IF_SENSIBLE 0x40000000L -#define XOUTBMP_USE_NATIVE_IF_POSSIBLE 0x80000000L +enum class XOutFlags { + NONE = 0x00000000, + MirrorHorz = 0x00000001, + MirrorVert = 0x00000010, + ContourHorz = 0x00000001, + ContourVert = 0x00000002, + ContourEdgeDetect = 0x00000004, + DontAddExtension = 0x00000008, + DontExpandFilename = 0x00010000, + UseGifIfPossible = 0x00020000, + UseGifIfSensible = 0x00040000, + UseNativeIfPossible = 0x00080000, +}; +namespace o3tl { + template<> struct typed_flags<XOutFlags> : is_typed_flags<XOutFlags, 0x000f001f> {}; +} class GraphicFilter; class VirtualDevice; @@ -54,7 +59,7 @@ public: static Graphic MirrorGraphic( const Graphic& rGraphic, const BmpMirrorFlags nMirrorFlags ); static Animation MirrorAnimation( const Animation& rAnimation, bool bHMirr, bool bVMirr ); static sal_uInt16 WriteGraphic( const Graphic& rGraphic, OUString& rFileName, - const OUString& rFilterName, const sal_uIntPtr nFlags = 0L, + const OUString& rFilterName, const XOutFlags nFlags = XOutFlags::NONE, const Size* pMtfSize_100TH_MM = nullptr ); static bool GraphicToBase64(const Graphic& rGraphic, OUString& rOUString); @@ -64,7 +69,7 @@ public: static Bitmap DetectEdges( const Bitmap& rBmp, const sal_uInt8 cThreshold ); - static tools::Polygon GetCountour( const Bitmap& rBmp, const sal_uIntPtr nContourFlags, + static tools::Polygon GetCountour( const Bitmap& rBmp, const XOutFlags nContourFlags, const sal_uInt8 cEdgeDetectThreshold = 50, const Rectangle* pWorkRect = nullptr ); }; diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index cd43d570c210..bc47e99c7301 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -609,7 +609,7 @@ void ScHTMLExport::WriteBody() // Save graphic as (JPG) file aGrfNm = aStreamPath; sal_uInt16 nErr = XOutBitmap::WriteGraphic( *pGrf, aGrfNm, - "JPG", XOUTBMP_USE_NATIVE_IF_POSSIBLE ); + "JPG", XOutFlags::UseNativeIfPossible ); if( !nErr ) // Contains errors, as we have nothing to output { aGrfNm = URIHelper::SmartRel2Abs( diff --git a/sc/source/filter/html/htmlexp2.cxx b/sc/source/filter/html/htmlexp2.cxx index aab92defefab..9c2113ecfd1c 100644 --- a/sc/source/filter/html/htmlexp2.cxx +++ b/sc/source/filter/html/htmlexp2.cxx @@ -140,11 +140,11 @@ void ScHTMLExport::WriteGraphEntry( ScHTMLGraphEntry* pE ) ( pGeo->bMirrored ? 3 : 4 ) : ( pGeo->bMirrored ? 2 : 1 )); bool bHMirr = ( ( nMirrorCase == 2 ) || ( nMirrorCase == 4 ) ); bool bVMirr = ( ( nMirrorCase == 3 ) || ( nMirrorCase == 4 ) ); - sal_uLong nXOutFlags = 0; + XOutFlags nXOutFlags = XOutFlags::NONE; if ( bHMirr ) - nXOutFlags |= XOUTBMP_MIRROR_HORZ; + nXOutFlags |= XOutFlags::MirrorHorz; if ( bVMirr ) - nXOutFlags |= XOUTBMP_MIRROR_VERT; + nXOutFlags |= XOutFlags::MirrorVert; OUString aLinkName; if ( pSGO->IsLinkedGraphic() ) aLinkName = pSGO->GetFileName(); @@ -175,7 +175,7 @@ void ScHTMLExport::WriteGraphEntry( ScHTMLGraphEntry* pE ) } void ScHTMLExport::WriteImage( OUString& rLinkName, const Graphic& rGrf, - const OString& rImgOptions, sal_uLong nXOutFlags ) + const OString& rImgOptions, XOutFlags nXOutFlags ) { // Embedded graphic -> create an image file if( rLinkName.isEmpty() ) @@ -184,7 +184,7 @@ void ScHTMLExport::WriteImage( OUString& rLinkName, const Graphic& rGrf, { // Save as a PNG OUString aGrfNm( aStreamPath ); - nXOutFlags |= XOUTBMP_USE_NATIVE_IF_POSSIBLE; + nXOutFlags |= XOutFlags::UseNativeIfPossible; sal_uInt16 nErr = XOutBitmap::WriteGraphic( rGrf, aGrfNm, "PNG", nXOutFlags ); diff --git a/sc/source/filter/inc/htmlexp.hxx b/sc/source/filter/inc/htmlexp.hxx index 8e8513d68e0f..1be62ff5b2d5 100644 --- a/sc/source/filter/inc/htmlexp.hxx +++ b/sc/source/filter/inc/htmlexp.hxx @@ -137,7 +137,7 @@ class ScHTMLExport : public ScExportBase void WriteGraphEntry( ScHTMLGraphEntry* ); void WriteImage( OUString& rLinkName, const Graphic&, const OString& rImgOptions, - sal_uLong nXOutFlags = 0 ); + XOutFlags nXOutFlags = XOutFlags::NONE ); // nXOutFlags for XOutBitmap::WriteGraphic // write to stream if and only if URL fields in edit cell diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx index d3b16b65a356..8ef16623fb26 100644 --- a/svx/source/core/extedit.cxx +++ b/svx/source/core/extedit.cxx @@ -138,7 +138,7 @@ void ExternalToolEdit::Edit(GraphicObject const*const pGraphicObject) OUString aFilter(rGraphicFilter.GetExportFormatShortName(nFilter)); // Write the Graphic to the file now - XOutBitmap::WriteGraphic(aGraphic, aTempFileName, aFilter, XOUTBMP_USE_NATIVE_IF_POSSIBLE | XOUTBMP_DONT_EXPAND_FILENAME); + XOutBitmap::WriteGraphic(aGraphic, aTempFileName, aFilter, XOutFlags::UseNativeIfPossible | XOutFlags::DontExpandFilename); // There is a possibility that sPath extension might have been changed if the // provided extension is not writable diff --git a/svx/source/core/graphichelper.cxx b/svx/source/core/graphichelper.cxx index b051cbd36e78..4816342a7fbc 100644 --- a/svx/source/core/graphichelper.cxx +++ b/svx/source/core/graphichelper.cxx @@ -192,9 +192,9 @@ OUString GraphicHelper::ExportGraphic( const Graphic& rGraphic, const OUString& OUString aFilter( rGraphicFilter.GetExportFormatShortName( nFilter ) ); XOutBitmap::WriteGraphic( rGraphic, sPath, aFilter, - XOUTBMP_DONT_EXPAND_FILENAME | - XOUTBMP_DONT_ADD_EXTENSION | - XOUTBMP_USE_NATIVE_IF_POSSIBLE ); + XOutFlags::DontExpandFilename | + XOutFlags::DontAddExtension | + XOutFlags::UseNativeIfPossible ); return sPath; } } diff --git a/svx/source/dialog/_contdlg.cxx b/svx/source/dialog/_contdlg.cxx index aacf82b31d82..096511471c29 100644 --- a/svx/source/dialog/_contdlg.cxx +++ b/svx/source/dialog/_contdlg.cxx @@ -106,7 +106,7 @@ tools::PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic, const sal_uIntPtr nFlags ) { Bitmap aBmp; - sal_uIntPtr nContourFlags = XOUTBMP_CONTOUR_HORZ; + XOutFlags nContourFlags = XOutFlags::ContourHorz; if ( rGraphic.GetType() == GRAPHIC_BITMAP ) { @@ -145,7 +145,7 @@ tools::PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic, else { aBmp = rGraphic.GetBitmap(); - nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT; + nContourFlags |= XOutFlags::ContourEdgeDetect; } } else if( rGraphic.GetType() != GRAPHIC_NONE ) @@ -171,7 +171,7 @@ tools::PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic, aBmp = pVDev->GetBitmap( aPt, aSizePix ); } - nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT; + nContourFlags |= XOutFlags::ContourEdgeDetect; } aBmp.SetPrefSize( rGraphic.GetPrefSize() ); diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index 0e7aeceef7e8..8750a2d15087 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -116,7 +116,7 @@ Graphic XOutBitmap::MirrorGraphic( const Graphic& rGraphic, const BmpMirrorFlags } sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName, - const OUString& rFilterName, const sal_uIntPtr nFlags, + const OUString& rFilterName, const XOutFlags nFlags, const Size* pMtfSize_100TH_MM ) { if( rGraphic.GetType() != GRAPHIC_NONE ) @@ -131,7 +131,7 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileNam DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "XOutBitmap::WriteGraphic(...): invalid URL" ); // calculate correct file name - if( !( nFlags & XOUTBMP_DONT_EXPAND_FILENAME ) ) + if( !( nFlags & XOutFlags::DontExpandFilename ) ) { OUString aName( aURL.getBase() ); aName += "_"; @@ -151,7 +151,7 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileNam && aSvgDataPtr->getSvgDataArrayLength() && rFilterName.equalsIgnoreAsciiCase("svg")) { - if(!(nFlags & XOUTBMP_DONT_ADD_EXTENSION)) + if(!(nFlags & XOutFlags::DontAddExtension)) { aURL.setExtension(rFilterName); } @@ -174,9 +174,9 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileNam if( GRFILTER_OK != nErr ) { - if( ( nFlags & XOUTBMP_USE_NATIVE_IF_POSSIBLE ) && - !( nFlags & XOUTBMP_MIRROR_HORZ ) && - !( nFlags & XOUTBMP_MIRROR_VERT ) && + if( ( nFlags & XOutFlags::UseNativeIfPossible ) && + !( nFlags & XOutFlags::MirrorHorz ) && + !( nFlags & XOutFlags::MirrorVert ) && ( rGraphic.GetType() != GRAPHIC_GDIMETAFILE ) && rGraphic.IsLink() ) { // try to write native link @@ -198,7 +198,7 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileNam if( !aExt.isEmpty() ) { - if( 0 == (nFlags & XOUTBMP_DONT_ADD_EXTENSION)) + if( !(nFlags & XOutFlags::DontAddExtension) ) aURL.setExtension( aExt ); rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE ); @@ -222,8 +222,8 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileNam OUString aFilter( rFilterName ); bool bWriteTransGrf = ( aFilter.equalsIgnoreAsciiCase( "transgrf" ) ) || ( aFilter.equalsIgnoreAsciiCase( "gif" ) ) || - ( nFlags & XOUTBMP_USE_GIF_IF_POSSIBLE ) || - ( ( nFlags & XOUTBMP_USE_GIF_IF_SENSIBLE ) && ( bAnimated || bTransparent ) ); + ( nFlags & XOutFlags::UseGifIfPossible ) || + ( ( nFlags & XOutFlags::UseGifIfSensible ) && ( bAnimated || bTransparent ) ); // get filter and extension if( bWriteTransGrf ) @@ -300,19 +300,19 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileNam } // mirror? - if( ( nFlags & XOUTBMP_MIRROR_HORZ ) || ( nFlags & XOUTBMP_MIRROR_VERT ) ) + if( ( nFlags & XOutFlags::MirrorHorz ) || ( nFlags & XOutFlags::MirrorVert ) ) { BmpMirrorFlags nBmpMirrorFlags = BmpMirrorFlags::NONE; - if( nFlags & XOUTBMP_MIRROR_HORZ ) + if( nFlags & XOutFlags::MirrorHorz ) nBmpMirrorFlags |= BmpMirrorFlags::Horizontal; - if( nFlags & XOUTBMP_MIRROR_VERT ) + if( nFlags & XOutFlags::MirrorVert ) nBmpMirrorFlags |= BmpMirrorFlags::Vertical; aGraphic = MirrorGraphic( aGraphic, nBmpMirrorFlags ); } if( ( GRFILTER_FORMAT_NOTFOUND != nFilter ) && ( aGraphic.GetType() != GRAPHIC_NONE ) ) { - if( 0 == (nFlags & XOUTBMP_DONT_ADD_EXTENSION)) + if( !(nFlags & XOutFlags::DontAddExtension) ) aURL.setExtension( aExt ); rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE ); nErr = ExportGraphic( aGraphic, aURL, rFilter, nFilter ); @@ -498,7 +498,7 @@ Bitmap XOutBitmap::DetectEdges( const Bitmap& rBmp, const sal_uInt8 cThreshold ) return aRetBmp; } -tools::Polygon XOutBitmap::GetCountour( const Bitmap& rBmp, const sal_uIntPtr nFlags, +tools::Polygon XOutBitmap::GetCountour( const Bitmap& rBmp, const XOutFlags nFlags, const sal_uInt8 cEdgeDetectThreshold, const Rectangle* pWorkRectPixel ) { @@ -515,7 +515,7 @@ tools::Polygon XOutBitmap::GetCountour( const Bitmap& rBmp, const sal_uIntPtr nF if( ( aWorkRect.GetWidth() > 4 ) && ( aWorkRect.GetHeight() > 4 ) ) { // if the flag is set, we need to detect edges - if( nFlags & XOUTBMP_CONTOUR_EDGEDETECT ) + if( nFlags & XOutFlags::ContourEdgeDetect ) aWorkBmp = DetectEdges( rBmp, cEdgeDetectThreshold ); else aWorkBmp = rBmp; @@ -542,7 +542,7 @@ tools::Polygon XOutBitmap::GetCountour( const Bitmap& rBmp, const sal_uIntPtr nF sal_uInt16 nPolyPos = 0; const BitmapColor aBlack = pAcc->GetBestMatchingColor( Color( COL_BLACK ) ); - if( nFlags & XOUTBMP_CONTOUR_VERT ) + if( nFlags & XOutFlags::ContourVert ) { pPoints1.reset(new Point[ nWidth ]); pPoints2.reset(new Point[ nWidth ]); diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index 591fc649da8b..8ce58c3a01d6 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -1734,8 +1734,8 @@ static Writer & OutHTML_FrameFormatAsImage( Writer& rWrt, const SwFrameFormat& r if( aGraphic.GetType() == GRAPHIC_NONE || XOutBitmap::WriteGraphic( aGraphic, GraphicURL, "JPG", - (XOUTBMP_USE_GIF_IF_POSSIBLE| - XOUTBMP_USE_NATIVE_IF_POSSIBLE) ) != 0 ) + (XOutFlags::UseGifIfPossible| + XOutFlags::UseNativeIfPossible) ) != 0 ) { // leer oder fehlerhaft, da ist nichts auszugeben rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE; @@ -1786,14 +1786,14 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF aGraphicURL = *rHTMLWrt.GetOrigFileName(); pGrfNd->GetGrf( true ); - sal_uLong nFlags = XOUTBMP_USE_GIF_IF_SENSIBLE | - XOUTBMP_USE_NATIVE_IF_POSSIBLE; + XOutFlags nFlags = XOutFlags::UseGifIfSensible | + XOutFlags::UseNativeIfPossible; switch( rMirror.GetValue() ) { - case RES_MIRROR_GRAPH_VERT: nFlags = XOUTBMP_MIRROR_HORZ; break; - case RES_MIRROR_GRAPH_HOR: nFlags = XOUTBMP_MIRROR_VERT; break; + case RES_MIRROR_GRAPH_VERT: nFlags = XOutFlags::MirrorHorz; break; + case RES_MIRROR_GRAPH_HOR: nFlags = XOutFlags::MirrorVert; break; case RES_MIRROR_GRAPH_BOTH: - nFlags = XOUTBMP_MIRROR_VERT | XOUTBMP_MIRROR_HORZ; + nFlags = XOutFlags::MirrorVert | XOutFlags::MirrorHorz; break; } diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 18154b42fc6f..f5bde4e01325 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -1322,8 +1322,8 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame sal_uInt16 nErr = XOutBitmap::WriteGraphic( aGraphic, aGraphicURL, "JPG", - (XOUTBMP_USE_GIF_IF_POSSIBLE | - XOUTBMP_USE_NATIVE_IF_POSSIBLE) ); + (XOutFlags::UseGifIfPossible | + XOutFlags::UseNativeIfPossible) ); if( nErr ) // fehlerhaft, da ist nichts auszugeben { rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE; |