diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2016-05-17 12:30:17 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2016-05-18 02:08:00 +0000 |
commit | 378576a9082d64f0ae2becae8a7e2528999bd7a5 (patch) | |
tree | d6dd4504ad4049d291ce38aabeff19edaecc27e5 /starmath | |
parent | f688acfdae00ebdd891737e533d54368810185e1 (diff) |
Convert ATTR_* to scoped enum
Change-Id: Icbf19ca281c260ba0795c7a8e5745d1e603ac8a5
Reviewed-on: https://gerrit.libreoffice.org/25050
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/node.hxx | 20 | ||||
-rw-r--r-- | starmath/source/node.cxx | 42 |
2 files changed, 35 insertions, 27 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index da58c57351b0..00b457d8d9d5 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -33,8 +33,16 @@ #include <vector> #include <deque> -#define ATTR_BOLD 0x0001 -#define ATTR_ITALIC 0x0002 +enum class FontAttribute { + None = 0x0000, + Bold = 0x0001, + Italic = 0x0002 +}; + +namespace o3tl +{ + template<> struct typed_flags<FontAttribute> : is_typed_flags<FontAttribute, 0x0003> {}; +} enum class FontSizeType { @@ -104,7 +112,7 @@ class SmNode : public SmRect SmScaleMode meScaleMode; RectHorAlign meRectHorAlign; FontChangeMask mnFlags; - sal_uInt16 mnAttributes; + FontAttribute mnAttributes; bool mbIsPhantom; bool mbIsSelected; @@ -132,14 +140,14 @@ public: virtual const SmNode * GetLeftMost() const; FontChangeMask &Flags() { return mnFlags; } - sal_uInt16 & Attributes() { return mnAttributes; } + FontAttribute &Attributes() { return mnAttributes; } bool IsPhantom() const { return mbIsPhantom; } void SetPhantom(bool bIsPhantom); void SetColor(const Color &rColor); - void SetAttribut(sal_uInt16 nAttrib); - void ClearAttribut(sal_uInt16 nAttrib); + void SetAttribut(FontAttribute nAttrib); + void ClearAttribut(FontAttribute nAttrib); const SmFace & GetFont() const { return maFace; }; SmFace & GetFont() { return maFace; }; diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index 58f4df3769ee..71c48ba3bfe4 100644 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -61,7 +61,7 @@ SmNode::SmNode(SmNodeType eNodeType, const SmToken &rNodeToken) , meScaleMode( SCALE_NONE ) , meRectHorAlign( RectHorAlign::Left ) , mnFlags( FontChangeMask::None ) - , mnAttributes( 0 ) + , mnAttributes( FontAttribute::None ) , mbIsPhantom( false ) , mbIsSelected( false ) , mnAccIndex( -1 ) @@ -124,11 +124,11 @@ void SmNode::SetColor(const Color& rColor) } -void SmNode::SetAttribut(sal_uInt16 nAttrib) +void SmNode::SetAttribut(FontAttribute nAttrib) { if ( - (nAttrib == ATTR_BOLD && !(Flags() & FontChangeMask::Bold)) || - (nAttrib == ATTR_ITALIC && !(Flags() & FontChangeMask::Italic)) + (nAttrib == FontAttribute::Bold && !(Flags() & FontChangeMask::Bold)) || + (nAttrib == FontAttribute::Italic && !(Flags() & FontChangeMask::Italic)) ) { mnAttributes |= nAttrib; @@ -138,11 +138,11 @@ void SmNode::SetAttribut(sal_uInt16 nAttrib) } -void SmNode::ClearAttribut(sal_uInt16 nAttrib) +void SmNode::ClearAttribut(FontAttribute nAttrib) { if ( - (nAttrib == ATTR_BOLD && !(Flags() & FontChangeMask::Bold)) || - (nAttrib == ATTR_ITALIC && !(Flags() & FontChangeMask::Italic)) + (nAttrib == FontAttribute::Bold && !(Flags() & FontChangeMask::Bold)) || + (nAttrib == FontAttribute::Italic && !(Flags() & FontChangeMask::Italic)) ) { mnAttributes &= ~nAttrib; @@ -232,8 +232,8 @@ void SmNode::SetRectHorAlign(RectHorAlign eHorAlign, bool bApplyToSubTree ) void SmNode::PrepareAttributes() { - GetFont().SetWeight((Attributes() & ATTR_BOLD) ? WEIGHT_BOLD : WEIGHT_NORMAL); - GetFont().SetItalic((Attributes() & ATTR_ITALIC) ? ITALIC_NORMAL : ITALIC_NONE); + GetFont().SetWeight((Attributes() & FontAttribute::Bold) ? WEIGHT_BOLD : WEIGHT_NORMAL); + GetFont().SetItalic((Attributes() & FontAttribute::Italic) ? ITALIC_NORMAL : ITALIC_NONE); } @@ -241,7 +241,7 @@ void SmNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) { mbIsPhantom = false; mnFlags = FontChangeMask::None; - mnAttributes = 0; + mnAttributes = FontAttribute::None; switch (rFormat.GetHorAlign()) { case AlignLeft: meRectHorAlign = RectHorAlign::Left; break; @@ -1954,10 +1954,10 @@ void SmFontNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat) case TUNKNOWN : break; // no assertion on "font <?> <?>" case TPHANTOM : SetPhantom(true); break; - case TBOLD : SetAttribut(ATTR_BOLD); break; - case TITALIC : SetAttribut(ATTR_ITALIC); break; - case TNBOLD : ClearAttribut(ATTR_BOLD); break; - case TNITALIC : ClearAttribut(ATTR_ITALIC); break; + case TBOLD : SetAttribut(FontAttribute::Bold); break; + case TITALIC : SetAttribut(FontAttribute::Italic); break; + case TNBOLD : ClearAttribut(FontAttribute::Bold); break; + case TNITALIC : ClearAttribut(FontAttribute::Italic); break; case TBLACK : SetColor(Color(COL_BLACK)); break; case TWHITE : SetColor(Color(COL_WHITE)); break; @@ -2163,15 +2163,15 @@ void SmTextNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) GetFont() = rFormat.GetFont(GetFontDesc()); if (IsItalic( GetFont() )) - Attributes() |= ATTR_ITALIC; + Attributes() |= FontAttribute::Italic; if (IsBold( GetFont() )) - Attributes() |= ATTR_BOLD; + Attributes() |= FontAttribute::Bold; // special handling for ':' where it is a token on it's own and is likely // to be used for mathematical notations. (E.g. a:b = 2:3) // In that case it should not be displayed in italic. if (GetToken().aText.getLength() == 1 && GetToken().aText[0] == ':') - Attributes() &= ~ATTR_ITALIC; + Attributes() &= ~FontAttribute::Italic; }; @@ -2720,9 +2720,9 @@ void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell //! see also SmFontStyles::GetStyleName if (IsItalic( GetFont() )) - SetAttribut(ATTR_ITALIC); + SetAttribut(FontAttribute::Italic); if (IsBold( GetFont() )) - SetAttribut(ATTR_BOLD); + SetAttribut(FontAttribute::Bold); Flags() |= FontChangeMask::Face; @@ -2748,9 +2748,9 @@ void SmSpecialNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell } if (bItalic) - Attributes() |= ATTR_ITALIC; + Attributes() |= FontAttribute::Italic; else - Attributes() &= ~ATTR_ITALIC; + Attributes() &= ~FontAttribute::Italic; } }; |