cppcanvas/source/inc/implrenderer.hxx | 2 cppcanvas/source/inc/outdevstate.hxx | 2 cppcanvas/source/mtfrenderer/implrenderer.cxx | 2 drawinglayer/source/primitive2d/metafileprimitive2d.cxx | 14 ++-- include/vcl/metaact.hxx | 6 +- include/vcl/outdev.hxx | 2 include/vcl/outdevstate.hxx | 45 ++++++++++------ include/vcl/pdfwriter.hxx | 2 test/source/mtfxmldump.cxx | 8 +- vcl/source/filter/wmf/wmfwr.hxx | 2 vcl/source/gdi/gdimetafiletools.cxx | 6 +- vcl/source/gdi/gdimtf.cxx | 6 +- vcl/source/gdi/metaact.cxx | 8 +- vcl/source/gdi/pdfwriter.cxx | 2 vcl/source/gdi/pdfwriter_impl.cxx | 14 ++-- vcl/source/gdi/pdfwriter_impl.hxx | 6 +- vcl/source/outdev/outdevstate.cxx | 2 17 files changed, 72 insertions(+), 57 deletions(-)
New commits: commit a69f8ea61ce274a5839f1904d1eba9ea91ce6676 Author: Noel Grandin <n...@peralex.com> Date: Thu Aug 21 07:31:11 2014 +0200 vcl: convert push flags to type-safe enum-like class Change-Id: Ib49a0dd5ecee0225f51bea2ff1c0ab5326595a47 diff --git a/cppcanvas/source/inc/implrenderer.hxx b/cppcanvas/source/inc/implrenderer.hxx index 7ff185e..deb3765 100644 --- a/cppcanvas/source/inc/implrenderer.hxx +++ b/cppcanvas/source/inc/implrenderer.hxx @@ -68,7 +68,7 @@ namespace cppcanvas public: OutDevState& getState(); const OutDevState& getState() const; - void pushState(sal_uInt16 nFlags); + void pushState(PushFlags nFlags); void popState(); void clearStateStack(); private: diff --git a/cppcanvas/source/inc/outdevstate.hxx b/cppcanvas/source/inc/outdevstate.hxx index d1e8c1f..15d33ec 100644 --- a/cppcanvas/source/inc/outdevstate.hxx +++ b/cppcanvas/source/inc/outdevstate.hxx @@ -100,7 +100,7 @@ namespace cppcanvas double fontRotation; sal_uInt16 textEmphasisMarkStyle; - sal_uInt16 pushFlags; + PushFlags pushFlags; sal_Int8 textDirection; sal_Int8 textAlignment; sal_Int8 textReliefStyle; diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index 63cb370..837609a 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -261,7 +261,7 @@ namespace cppcanvas return m_aStates.back(); } - void VectorOfOutDevStates::pushState(sal_uInt16 nFlags) + void VectorOfOutDevStates::pushState(PushFlags nFlags) { m_aStates.push_back( getState() ); getState().pushFlags = nFlags; diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index 8f77949..052d43a 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -91,7 +91,7 @@ namespace RasterOp maRasterOp; ComplexTextLayoutMode mnLayoutMode; LanguageType maLanguageType; - sal_uInt16 mnPushFlags; + PushFlags mnPushFlags; /// bitfield /// contains all active markers @@ -118,7 +118,7 @@ namespace maRasterOp(ROP_OVERPAINT), mnLayoutMode(TEXT_LAYOUT_DEFAULT), maLanguageType(0), - mnPushFlags(0), + mnPushFlags(PUSH_NONE), mbLineColor(false), mbFillColor(false), mbTextColor(true), @@ -190,8 +190,8 @@ namespace LanguageType getLanguageType() const { return maLanguageType; } void setLanguageType(LanguageType aNew) { if(aNew != maLanguageType) maLanguageType = aNew; } - sal_uInt16 getPushFlags() const { return mnPushFlags; } - void setPushFlags(sal_uInt16 nNew) { if(nNew != mnPushFlags) mnPushFlags = nNew; } + PushFlags getPushFlags() const { return mnPushFlags; } + void setPushFlags(PushFlags nNew) { if(nNew != mnPushFlags) mnPushFlags = nNew; } bool getLineOrFillActive() const { return (mbLineColor || mbFillColor); } }; @@ -227,7 +227,7 @@ namespace maPropertyHolders.push_back(pNew); } - void Push(sal_uInt16 nPushFlags) + void Push(PushFlags nPushFlags) { if(nPushFlags) { @@ -249,9 +249,9 @@ namespace if(nSize) { const PropertyHolder* pTip = maPropertyHolders.back(); - const sal_uInt16 nPushFlags(pTip->getPushFlags()); + const PushFlags nPushFlags(pTip->getPushFlags()); - if(nPushFlags) + if(nPushFlags != PUSH_NONE) { if(nSize > 1) { diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx index 572a0a2..1f0fd79 100644 --- a/include/vcl/metaact.hxx +++ b/include/vcl/metaact.hxx @@ -1350,7 +1350,7 @@ class VCL_DLLPUBLIC MetaPushAction : public MetaAction { private: - sal_uInt16 mnFlags; + PushFlags mnFlags; virtual bool Compare( const MetaAction& ) const SAL_OVERRIDE; @@ -1364,9 +1364,9 @@ public: virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) SAL_OVERRIDE; virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) SAL_OVERRIDE; - explicit MetaPushAction( sal_uInt16 nFlags ); + explicit MetaPushAction( PushFlags nFlags ); - sal_uInt16 GetFlags() const { return mnFlags; } + PushFlags GetFlags() const { return mnFlags; } }; class VCL_DLLPUBLIC MetaPopAction : public MetaAction diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 61114a1..df0cd27 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -534,7 +534,7 @@ private: public: - void Push( sal_uInt16 nFlags = PUSH_ALL ); + void Push( PushFlags nFlags = PUSH_ALL ); void Pop(); // returns the current stack depth; that is the number of Push() calls minus the number of Pop() calls diff --git a/include/vcl/outdevstate.hxx b/include/vcl/outdevstate.hxx index 847a5f2..578a1a9 100644 --- a/include/vcl/outdevstate.hxx +++ b/include/vcl/outdevstate.hxx @@ -32,23 +32,36 @@ #include <tools/fontenum.hxx> // Flags for OutputDevice::Push() and OutDevState -#define PUSH_LINECOLOR ((sal_uInt16)0x0001) -#define PUSH_FILLCOLOR ((sal_uInt16)0x0002) -#define PUSH_FONT ((sal_uInt16)0x0004) -#define PUSH_TEXTCOLOR ((sal_uInt16)0x0008) -#define PUSH_MAPMODE ((sal_uInt16)0x0010) -#define PUSH_CLIPREGION ((sal_uInt16)0x0020) -#define PUSH_RASTEROP ((sal_uInt16)0x0040) -#define PUSH_TEXTFILLCOLOR ((sal_uInt16)0x0080) -#define PUSH_TEXTALIGN ((sal_uInt16)0x0100) -#define PUSH_REFPOINT ((sal_uInt16)0x0200) -#define PUSH_TEXTLINECOLOR ((sal_uInt16)0x0400) -#define PUSH_TEXTLAYOUTMODE ((sal_uInt16)0x0800) -#define PUSH_TEXTLANGUAGE ((sal_uInt16)0x1000) -#define PUSH_OVERLINECOLOR ((sal_uInt16)0x2000) +enum PushFlags { + PUSH_NONE = ((sal_uInt16)0x0000), + PUSH_LINECOLOR = ((sal_uInt16)0x0001), + PUSH_FILLCOLOR = ((sal_uInt16)0x0002), + PUSH_FONT = ((sal_uInt16)0x0004), + PUSH_TEXTCOLOR = ((sal_uInt16)0x0008), + PUSH_MAPMODE = ((sal_uInt16)0x0010), + PUSH_CLIPREGION = ((sal_uInt16)0x0020), + PUSH_RASTEROP = ((sal_uInt16)0x0040), + PUSH_TEXTFILLCOLOR = ((sal_uInt16)0x0080), + PUSH_TEXTALIGN = ((sal_uInt16)0x0100), + PUSH_REFPOINT = ((sal_uInt16)0x0200), + PUSH_TEXTLINECOLOR = ((sal_uInt16)0x0400), + PUSH_TEXTLAYOUTMODE = ((sal_uInt16)0x0800), + PUSH_TEXTLANGUAGE = ((sal_uInt16)0x1000), + PUSH_OVERLINECOLOR = ((sal_uInt16)0x2000), + PUSH_ALL = ((sal_uInt16)0xFFFF) +}; +// make combining these type-safe +inline PushFlags operator| (PushFlags lhs, PushFlags rhs) +{ + return static_cast<PushFlags>(static_cast<sal_uInt16>(lhs) | static_cast<sal_uInt16>(rhs)); +} +inline PushFlags operator& (PushFlags lhs, PushFlags rhs) +{ + return static_cast<PushFlags>(static_cast<sal_uInt16>(lhs) & static_cast<sal_uInt16>(rhs)); +} + #define PUSH_ALLTEXT (PUSH_TEXTCOLOR | PUSH_TEXTFILLCOLOR | PUSH_TEXTLINECOLOR | PUSH_OVERLINECOLOR | PUSH_TEXTALIGN | PUSH_TEXTLAYOUTMODE | PUSH_TEXTLANGUAGE) #define PUSH_ALLFONT (PUSH_ALLTEXT | PUSH_FONT) -#define PUSH_ALL ((sal_uInt16)0xFFFF) // LayoutModes for Complex Text Layout // These are flag values, i.e they can be combined @@ -108,7 +121,7 @@ public: RasterOp meRasterOp; ComplexTextLayoutMode mnTextLayoutMode; LanguageType meTextLanguage; - sal_uInt16 mnFlags; + PushFlags mnFlags; }; #endif // INCLUDED_VCL_OUTDEVSTATE_HXX diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx index 95a99ed..223dcf3 100644 --- a/include/vcl/pdfwriter.hxx +++ b/include/vcl/pdfwriter.hxx @@ -729,7 +729,7 @@ The following structure describes the permissions used in PDF security /* functions for graphics state */ /* flag values: see vcl/outdev.hxx */ - void Push( sal_uInt16 nFlags = 0xffff ); + void Push( PushFlags nFlags = PUSH_ALL ); void Pop(); void SetClipRegion(); diff --git a/test/source/mtfxmldump.cxx b/test/source/mtfxmldump.cxx index 1a12912..e76eb02 100644 --- a/test/source/mtfxmldump.cxx +++ b/test/source/mtfxmldump.cxx @@ -22,7 +22,7 @@ namespace const size_t constMaxActionType = 513; -OUString flagToString(sal_uInt16 nFlag) +OUString flagToString(PushFlags nFlag) { if (nFlag & PUSH_LINECOLOR) return OUString("PushLineColor"); @@ -56,7 +56,7 @@ OUString flagToString(sal_uInt16 nFlag) return OUString(); } -OUString collectPushFlags(sal_uInt16 nFlags) +OUString collectPushFlags(PushFlags nFlags) { if ((nFlags & PUSH_ALL) == nFlags) return OUString("PushAll"); @@ -69,14 +69,14 @@ OUString collectPushFlags(sal_uInt16 nFlags) for (sal_uInt16 nFlag = 1; nFlag > 0; nFlag <<= 1) { - OUString sFlag = flagToString(nFlag); + OUString sFlag = flagToString(static_cast<PushFlags>(nFlag)); if (!sFlag.isEmpty()) { if (!sFlags.isEmpty()) { sFlags += ","; } - sFlags += flagToString(nFlag); + sFlags += flagToString(static_cast<PushFlags>(nFlag)); } } diff --git a/vcl/source/filter/wmf/wmfwr.hxx b/vcl/source/filter/wmf/wmfwr.hxx index 13bf796..378ece4 100644 --- a/vcl/source/filter/wmf/wmfwr.hxx +++ b/vcl/source/filter/wmf/wmfwr.hxx @@ -40,7 +40,7 @@ struct WMFWriterAttrStackMember Font aFont; MapMode aMapMode; Region aClipRegion; - sal_uInt16 nFlags; + PushFlags nFlags; }; class StarSymbolToMSMultiFont; diff --git a/vcl/source/gdi/gdimetafiletools.cxx b/vcl/source/gdi/gdimetafiletools.cxx index 04d52cb..a0afe28 100644 --- a/vcl/source/gdi/gdimetafiletools.cxx +++ b/vcl/source/gdi/gdimetafiletools.cxx @@ -270,7 +270,7 @@ void clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource) GDIMetaFile aTarget; bool bChanged(false); std::vector< basegfx::B2DPolyPolygon > aClips; - std::vector< sal_uInt16 > aPushFlags; + std::vector< PushFlags > aPushFlags; std::vector< MapMode > aMapModes; // start with empty region @@ -367,7 +367,7 @@ void clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource) case META_PUSH_ACTION : { const MetaPushAction* pA = static_cast< const MetaPushAction* >(pAction); - const sal_uInt16 nFlags(pA->GetFlags()); + const PushFlags nFlags(pA->GetFlags()); aPushFlags.push_back(nFlags); @@ -388,7 +388,7 @@ void clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource) if(aPushFlags.size()) { - const sal_uInt16 nFlags(aPushFlags.back()); + const PushFlags nFlags(aPushFlags.back()); aPushFlags.pop_back(); if(nFlags & PUSH_CLIPREGION) diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 5217f25..480e0ab 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -1402,7 +1402,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai aMapVDev.SetMapMode( GetPrefMapMode() ); std::vector<Rectangle> aClipStack( 1, Rectangle() ); - std::vector<sal_uInt16> aPushFlagStack; + std::vector<PushFlags> aPushFlagStack; Rectangle aBound; @@ -1789,7 +1789,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai { MetaPushAction* pAct = (MetaPushAction*) pAction; aPushFlagStack.push_back( pAct->GetFlags() ); - if( (aPushFlagStack.back() & PUSH_CLIPREGION) != 0 ) + if( aPushFlagStack.back() & PUSH_CLIPREGION ) { Rectangle aRect( aClipStack.back() ); aClipStack.push_back( aRect ); @@ -1800,7 +1800,7 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference, Rectangle* pHai // sanity check if( ! aPushFlagStack.empty() ) { - if( (aPushFlagStack.back() & PUSH_CLIPREGION) != 0 ) + if( aPushFlagStack.back() & PUSH_CLIPREGION ) { if( aClipStack.size() > 1 ) aClipStack.pop_back(); diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index cad74be4..93dbfa6 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -3106,13 +3106,13 @@ void MetaFontAction::Read( SvStream& rIStm, ImplMetaReadData* pData ) MetaPushAction::MetaPushAction() : MetaAction ( META_PUSH_ACTION ), - mnFlags ( 0 ) + mnFlags ( PUSH_NONE ) {} MetaPushAction::~MetaPushAction() {} -MetaPushAction::MetaPushAction( sal_uInt16 nFlags ) : +MetaPushAction::MetaPushAction( PushFlags nFlags ) : MetaAction ( META_PUSH_ACTION ), mnFlags ( nFlags ) {} @@ -3144,7 +3144,9 @@ void MetaPushAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) void MetaPushAction::Read( SvStream& rIStm, ImplMetaReadData* ) { VersionCompat aCompat(rIStm, STREAM_READ); - rIStm.ReadUInt16( mnFlags ); + sal_uInt16 tmp; + rIStm.ReadUInt16( tmp ); + mnFlags = static_cast<PushFlags>(tmp); } MetaPopAction::MetaPopAction() : diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx index 8acf85f..81e29a9 100644 --- a/vcl/source/gdi/pdfwriter.cxx +++ b/vcl/source/gdi/pdfwriter.cxx @@ -224,7 +224,7 @@ void PDFWriter::EndTransparencyGroup( const Rectangle& rRect, sal_uInt16 nTransp pImplementation->endTransparencyGroup( rRect, nTransparentPercent ); } -void PDFWriter::Push( sal_uInt16 nFlags ) +void PDFWriter::Push( PushFlags nFlags ) { pImplementation->push( nFlags ); } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 8b18321..e9a1479 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -4681,7 +4681,7 @@ void PDFWriterImpl::createDefaultPushButtonAppearance( PDFWidget& rButton, const const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); // save graphics state - push( sal::static_int_cast<sal_uInt16>(~0U) ); + push( PUSH_ALL ); // transform relative to control's coordinates since an // appearance stream is a form XObject @@ -4788,7 +4788,7 @@ void PDFWriterImpl::createDefaultEditAppearance( PDFWidget& rEdit, const PDFWrit const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); SvMemoryStream* pEditStream = new SvMemoryStream( 1024, 1024 ); - push( sal::static_int_cast<sal_uInt16>(~0U) ); + push( PUSH_ALL ); // prepare font to use, draw field border Font aFont = drawFieldBorder( rEdit, rWidget, rSettings ); @@ -4840,7 +4840,7 @@ void PDFWriterImpl::createDefaultListBoxAppearance( PDFWidget& rBox, const PDFWr const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); SvMemoryStream* pListBoxStream = new SvMemoryStream( 1024, 1024 ); - push( sal::static_int_cast<sal_uInt16>(~0U) ); + push( PUSH_ALL ); // prepare font to use, draw field border Font aFont = drawFieldBorder( rBox, rWidget, rSettings ); @@ -4891,7 +4891,7 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( PDFWidget& rBox, const PDFW const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); // save graphics state - push( sal::static_int_cast<sal_uInt16>(~0U) ); + push( PUSH_ALL ); if( rWidget.Background || rWidget.Border ) { @@ -5016,7 +5016,7 @@ void PDFWriterImpl::createDefaultRadioButtonAppearance( PDFWidget& rBox, const P const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); // save graphics state - push( sal::static_int_cast<sal_uInt16>(~0U) ); + push( PUSH_ALL ); if( rWidget.Background || rWidget.Border ) { @@ -5104,7 +5104,7 @@ void PDFWriterImpl::createDefaultRadioButtonAppearance( PDFWidget& rBox, const P rBox.m_aRect = aCheckRect; // create appearance streams - push( sal::static_int_cast<sal_uInt16>(~0U) ); + push( PUSH_ALL); SvMemoryStream* pCheckStream = new SvMemoryStream( 256, 256 ); beginRedirect( pCheckStream, aCheckRect ); @@ -10604,7 +10604,7 @@ void PDFWriterImpl::setFont( const Font& rFont ) m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont; } -void PDFWriterImpl::push( sal_uInt16 nFlags ) +void PDFWriterImpl::push( PushFlags nFlags ) { OSL_ENSURE( !m_aGraphicsStack.empty(), "invalid graphics stack" ); m_aGraphicsStack.push_front( m_aGraphicsStack.front() ); diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index ed4013b..2015281 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -713,7 +713,7 @@ private: ComplexTextLayoutMode m_nLayoutMode; LanguageType m_aDigitLanguage; sal_Int32 m_nTransparentPercent; - sal_uInt16 m_nFlags; + PushFlags m_nFlags; sal_uInt16 m_nUpdateFlags; static const sal_uInt16 updateFont = 0x0001; @@ -738,7 +738,7 @@ private: m_nLayoutMode( TEXT_LAYOUT_DEFAULT ), m_aDigitLanguage( 0 ), m_nTransparentPercent( 0 ), - m_nFlags( 0xffff ), + m_nFlags( PUSH_ALL ), m_nUpdateFlags( 0xffff ) {} GraphicsState( const GraphicsState& rState ) : @@ -1104,7 +1104,7 @@ public: { m_aContext.DocumentLocale = rLoc; } /* graphics state */ - void push( sal_uInt16 nFlags ); + void push( PushFlags nFlags ); void pop(); void setFont( const Font& rFont ); diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index 21a7727..77dfe72 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -65,7 +65,7 @@ OutDevState::~OutDevState() } -void OutputDevice::Push( sal_uInt16 nFlags ) +void OutputDevice::Push( PushFlags nFlags ) { if ( mpMetaFile ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits