starmath/inc/node.hxx | 30 ++++++++++++++++++++---------- starmath/source/node.cxx | 38 +++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 29 deletions(-)
New commits: commit cc63036369b29d7985e2e773470f6f9aa068f4e2 Author: Takeshi Abe <t...@fixedpoint.jp> Date: Wed May 11 16:29:05 2016 +0900 Convert FLG_* to scoped enum Change-Id: If767fff10a0bb28735578b4ec3dcf7b9e2d326a2 Reviewed-on: https://gerrit.libreoffice.org/24872 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Takeshi Abe <t...@fixedpoint.jp> diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index c6e5419..da58c57 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -26,6 +26,8 @@ #include "rect.hxx" #include "format.hxx" +#include <o3tl/typed_flags_set.hxx> + #include <cassert> #include <memory> #include <vector> @@ -44,13 +46,21 @@ enum class FontSizeType { }; // flags to interdict respective status changes -#define FLG_FONT 0x0001 -#define FLG_SIZE 0x0002 -#define FLG_BOLD 0x0004 -#define FLG_ITALIC 0x0008 -#define FLG_COLOR 0x0010 -#define FLG_VISIBLE 0x0020 -#define FLG_HORALIGN 0x0040 +enum class FontChangeMask { + None = 0x0000, + Face = 0x0001, + Size = 0x0002, + Bold = 0x0004, + Italic = 0x0008, + Color = 0x0010, + Phantom = 0x0020, + HorAlign = 0x0040 +}; + +namespace o3tl +{ + template<> struct typed_flags<FontChangeMask> : is_typed_flags<FontChangeMask, 0x007f> {}; +} class SmVisitor; @@ -93,8 +103,8 @@ class SmNode : public SmRect SmNodeType meType; SmScaleMode meScaleMode; RectHorAlign meRectHorAlign; - sal_uInt16 mnFlags, - mnAttributes; + FontChangeMask mnFlags; + sal_uInt16 mnAttributes; bool mbIsPhantom; bool mbIsSelected; @@ -121,7 +131,7 @@ public: virtual const SmNode * GetLeftMost() const; - sal_uInt16 & Flags() { return mnFlags; } + FontChangeMask &Flags() { return mnFlags; } sal_uInt16 & Attributes() { return mnAttributes; } bool IsPhantom() const { return mbIsPhantom; } diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index 7f2b04d..8b1559d 100644 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -60,7 +60,7 @@ SmNode::SmNode(SmNodeType eNodeType, const SmToken &rNodeToken) , meType( eNodeType ) , meScaleMode( SCALE_NONE ) , meRectHorAlign( RectHorAlign::Left ) - , mnFlags( 0 ) + , mnFlags( FontChangeMask::None ) , mnAttributes( 0 ) , mbIsPhantom( false ) , mbIsSelected( false ) @@ -107,7 +107,7 @@ const SmNode * SmNode::GetLeftMost() const void SmNode::SetPhantom(bool bIsPhantomP) { - if (! (Flags() & FLG_VISIBLE)) + if (! (Flags() & FontChangeMask::Phantom)) mbIsPhantom = bIsPhantomP; bool b = mbIsPhantom; @@ -117,7 +117,7 @@ void SmNode::SetPhantom(bool bIsPhantomP) void SmNode::SetColor(const Color& rColor) { - if (! (Flags() & FLG_COLOR)) + if (! (Flags() & FontChangeMask::Color)) GetFont().SetColor(rColor); ForEachNonNull(this, [&rColor](SmNode *pNode){pNode->SetColor(rColor);}); @@ -127,8 +127,8 @@ void SmNode::SetColor(const Color& rColor) void SmNode::SetAttribut(sal_uInt16 nAttrib) { if ( - (nAttrib == ATTR_BOLD && !(Flags() & FLG_BOLD)) || - (nAttrib == ATTR_ITALIC && !(Flags() & FLG_ITALIC)) + (nAttrib == ATTR_BOLD && !(Flags() & FontChangeMask::Bold)) || + (nAttrib == ATTR_ITALIC && !(Flags() & FontChangeMask::Italic)) ) { mnAttributes |= nAttrib; @@ -141,8 +141,8 @@ void SmNode::SetAttribut(sal_uInt16 nAttrib) void SmNode::ClearAttribut(sal_uInt16 nAttrib) { if ( - (nAttrib == ATTR_BOLD && !(Flags() & FLG_BOLD)) || - (nAttrib == ATTR_ITALIC && !(Flags() & FLG_ITALIC)) + (nAttrib == ATTR_BOLD && !(Flags() & FontChangeMask::Bold)) || + (nAttrib == ATTR_ITALIC && !(Flags() & FontChangeMask::Italic)) ) { mnAttributes &= ~nAttrib; @@ -154,7 +154,7 @@ void SmNode::ClearAttribut(sal_uInt16 nAttrib) void SmNode::SetFont(const SmFace &rFace) { - if (!(Flags() & FLG_FONT)) + if (!(Flags() & FontChangeMask::Face)) GetFont() = rFace; ForEachNonNull(this, [&rFace](SmNode *pNode){pNode->SetFont(rFace);}); @@ -166,7 +166,7 @@ void SmNode::SetFontSize(const Fraction &rSize, FontSizeType nType) { Size aFntSize; - if (!(Flags() & FLG_SIZE)) + if (!(Flags() & FontChangeMask::Size)) { Fraction aVal (SmPtsTo100th_mm(rSize.GetNumerator()), rSize.GetDenominator()); @@ -222,7 +222,7 @@ void SmNode::SetSize(const Fraction &rSize) void SmNode::SetRectHorAlign(RectHorAlign eHorAlign, bool bApplyToSubTree ) { - if (!(Flags() & FLG_HORALIGN)) + if (!(Flags() & FontChangeMask::HorAlign)) meRectHorAlign = eHorAlign; if (bApplyToSubTree) @@ -240,7 +240,7 @@ void SmNode::PrepareAttributes() void SmNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) { mbIsPhantom = false; - mnFlags = 0; + mnFlags = FontChangeMask::None; mnAttributes = 0; switch (rFormat.GetHorAlign()) @@ -591,7 +591,7 @@ void SmLineNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) // Here we use the 'FNT_VARIABLE' font since it's ascent and descent in general fit better // to the rest of the formula compared to the 'FNT_MATH' font. GetFont() = rFormat.GetFont(FNT_VARIABLE); - Flags() |= FLG_FONT; + Flags() |= FontChangeMask::Face; } @@ -1921,7 +1921,7 @@ void SmFontNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) //! prevent overwrites of this font by 'Arrange' or 'SetFont' calls of //! other font nodes (those with lower depth in the tree) - Flags() |= FLG_FONT; + Flags() |= FontChangeMask::Face; } void SmFontNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat) @@ -2507,7 +2507,7 @@ void SmMathSymbolNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocSh GetFont().GetCharSet() == RTL_TEXTENCODING_UNICODE, "wrong charset for character from StarMath/OpenSymbol font"); - Flags() |= FLG_FONT | FLG_ITALIC; + Flags() |= FontChangeMask::Face | FontChangeMask::Italic; }; @@ -2711,7 +2711,7 @@ void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell if (IsBold( GetFont() )) SetAttribut(ATTR_BOLD); - Flags() |= FLG_FONT; + Flags() |= FontChangeMask::Face; if (bIsFromGreekSymbolSet) { @@ -2775,7 +2775,7 @@ void SmPlaceNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) SmNode::Prepare(rFormat, rDocShell); GetFont().SetColor(COL_GRAY); - Flags() |= FLG_COLOR | FLG_FONT | FLG_ITALIC; + Flags() |= FontChangeMask::Color | FontChangeMask::Face | FontChangeMask::Italic; }; @@ -2798,8 +2798,8 @@ void SmErrorNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) SmNode::Prepare(rFormat, rDocShell); GetFont().SetColor(COL_RED); - Flags() |= FLG_VISIBLE | FLG_BOLD | FLG_ITALIC - | FLG_COLOR | FLG_FONT | FLG_SIZE; + Flags() |= FontChangeMask::Phantom | FontChangeMask::Bold | FontChangeMask::Italic + | FontChangeMask::Color | FontChangeMask::Face | FontChangeMask::Size; } @@ -2838,7 +2838,7 @@ void SmBlankNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) // used in Arrange a normal (non-clipped) rectangle is generated GetFont() = rFormat.GetFont(FNT_VARIABLE); - Flags() |= FLG_FONT | FLG_BOLD | FLG_ITALIC; + Flags() |= FontChangeMask::Face | FontChangeMask::Bold | FontChangeMask::Italic; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits