Kaydet (Commit) 11a52df2 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Noel Grandin

Replace FNTSIZ_* with a scoped enumeration FontSizeType

Change-Id: Ia6bcaaac60c18abda803f6a40db8a5c5076b9427
Reviewed-on: https://gerrit.libreoffice.org/15101Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 00bf3a42
......@@ -36,11 +36,13 @@
#define ATTR_ITALIC 0x0002
#define FNTSIZ_ABSOLUT 1
#define FNTSIZ_PLUS 2
#define FNTSIZ_MINUS 3
#define FNTSIZ_MULTIPLY 4
#define FNTSIZ_DIVIDE 5
enum class FontSizeType {
ABSOLUT = 1,
PLUS = 2,
MINUS = 3,
MULTIPLY = 4,
DIVIDE = 5
};
// flags to interdict respective status changes
#define FLG_FONT 0x0001
......@@ -143,7 +145,7 @@ public:
SmFace & GetFont() { return aFace; };
void SetFont(const SmFace &rFace);
void SetFontSize(const Fraction &rRelSize, sal_uInt16 nType);
void SetFontSize(const Fraction &rRelSize, FontSizeType nType);
void SetSize(const Fraction &rScale);
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell);
......@@ -1247,20 +1249,20 @@ public:
*/
class SmFontNode : public SmStructureNode
{
sal_uInt16 nSizeType;
FontSizeType nSizeType;
Fraction aFontSize;
public:
SmFontNode(const SmToken &rNodeToken)
: SmStructureNode(NFONT, rNodeToken)
{
nSizeType = FNTSIZ_MULTIPLY;
nSizeType = FontSizeType::MULTIPLY;
aFontSize = Fraction(1L);
}
void SetSizeParameter(const Fraction &rValue, sal_uInt16 nType);
void SetSizeParameter(const Fraction &rValue, FontSizeType nType);
const Fraction & GetSizeParameter() const {return aFontSize;}
const sal_uInt16& GetSizeType() const {return nSizeType;}
const FontSizeType& GetSizeType() const {return nSizeType;}
virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) SAL_OVERRIDE;
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat) SAL_OVERRIDE;
......
......@@ -1368,17 +1368,17 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
OUStringBuffer sStrBuf;
switch(pFontNode->GetSizeType())
{
case FNTSIZ_MULTIPLY:
case FontSizeType::MULTIPLY:
::sax::Converter::convertDouble(sStrBuf,
static_cast<double>(aFrac*Fraction(100.00)));
sStrBuf.append('%');
break;
case FNTSIZ_DIVIDE:
case FontSizeType::DIVIDE:
::sax::Converter::convertDouble(sStrBuf,
static_cast<double>(Fraction(100.00)/aFrac));
sStrBuf.append('%');
break;
case FNTSIZ_ABSOLUT:
case FontSizeType::ABSOLUT:
::sax::Converter::convertDouble(sStrBuf,
static_cast<double>(aFrac));
sStrBuf.append(
......@@ -1395,7 +1395,7 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
Fraction aTemp = Sm100th_mmToPts(pFontNode->GetFont().
GetSize().Height());
if (pFontNode->GetSizeType() == FNTSIZ_MINUS)
if (pFontNode->GetSizeType() == FontSizeType::MINUS)
aTemp-=aFrac;
else
aTemp+=aFrac;
......
......@@ -710,13 +710,13 @@ void SmXMLContext_Helper::ApplyAttrs()
{
if (nFontSize < 100.00)
pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
FNTSIZ_DIVIDE);
FontSizeType::DIVIDE);
else
pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
FNTSIZ_MULTIPLY);
FontSizeType::MULTIPLY);
}
else
pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
pFontNode->SetSizeParameter(Fraction(nFontSize),FontSizeType::ABSOLUT);
pFontNode->SetSubNodes(0,popOrZero(rNodeStack));
rNodeStack.push_front(pFontNode);
......
......@@ -164,7 +164,7 @@ void SmNode::SetFont(const SmFace &rFace)
}
void SmNode::SetFontSize(const Fraction &rSize, sal_uInt16 nType)
void SmNode::SetFontSize(const Fraction &rSize, FontSizeType nType)
//! 'rSize' is in units of pts
{
Size aFntSize;
......@@ -179,23 +179,23 @@ void SmNode::SetFontSize(const Fraction &rSize, sal_uInt16 nType)
aFntSize.Width() = 0;
switch(nType)
{
case FNTSIZ_ABSOLUT:
case FontSizeType::ABSOLUT:
aFntSize.Height() = nHeight;
break;
case FNTSIZ_PLUS:
case FontSizeType::PLUS:
aFntSize.Height() += nHeight;
break;
case FNTSIZ_MINUS:
case FontSizeType::MINUS:
aFntSize.Height() -= nHeight;
break;
case FNTSIZ_MULTIPLY:
case FontSizeType::MULTIPLY:
aFntSize.Height() = (long) (Fraction(aFntSize.Height()) * rSize);
break;
case FNTSIZ_DIVIDE:
case FontSizeType::DIVIDE:
if (rSize != Fraction(0L))
aFntSize.Height() = (long) (Fraction(aFntSize.Height()) / rSize);
break;
......@@ -2038,19 +2038,19 @@ void SmFontNode::CreateTextFromNode(OUString &rText)
rText += "size ";
switch (nSizeType)
{
case FNTSIZ_PLUS:
case FontSizeType::PLUS:
rText += "+";
break;
case FNTSIZ_MINUS:
case FontSizeType::MINUS:
rText += "-";
break;
case FNTSIZ_MULTIPLY:
case FontSizeType::MULTIPLY:
rText += "*";
break;
case FNTSIZ_DIVIDE:
case FontSizeType::DIVIDE:
rText += "/";
break;
case FNTSIZ_ABSOLUT:
case FontSizeType::ABSOLUT:
default:
break;
}
......@@ -2205,7 +2205,7 @@ void SmFontNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
}
void SmFontNode::SetSizeParameter(const Fraction& rValue, sal_uInt16 Type)
void SmFontNode::SetSizeParameter(const Fraction& rValue, FontSizeType Type)
{
nSizeType = Type;
aFontSize = rValue;
......
......@@ -1925,18 +1925,18 @@ void SmParser::FontSize()
{
OSL_ENSURE(m_aCurToken.eType == TSIZE, "Sm : Ooops...");
sal_uInt16 Type;
FontSizeType Type;
SmFontNode *pFontNode = new SmFontNode(m_aCurToken);
NextToken();
switch (m_aCurToken.eType)
{
case TNUMBER: Type = FNTSIZ_ABSOLUT; break;
case TPLUS: Type = FNTSIZ_PLUS; break;
case TMINUS: Type = FNTSIZ_MINUS; break;
case TMULTIPLY: Type = FNTSIZ_MULTIPLY; break;
case TDIVIDEBY: Type = FNTSIZ_DIVIDE; break;
case TNUMBER: Type = FontSizeType::ABSOLUT; break;
case TPLUS: Type = FontSizeType::PLUS; break;
case TMINUS: Type = FontSizeType::MINUS; break;
case TMULTIPLY: Type = FontSizeType::MULTIPLY; break;
case TDIVIDEBY: Type = FontSizeType::DIVIDE; break;
default:
delete pFontNode;
......@@ -1944,7 +1944,7 @@ void SmParser::FontSize()
return;
}
if (Type != FNTSIZ_ABSOLUT)
if (Type != FontSizeType::ABSOLUT)
{
NextToken();
if (m_aCurToken.eType != TNUMBER)
......
......@@ -2113,19 +2113,19 @@ void SmNodeToTextVisitor::Visit( SmFontNode* pNode )
Append( "size " );
switch ( pNode->GetSizeType( ) )
{
case FNTSIZ_PLUS:
case FontSizeType::PLUS:
Append( "+" );
break;
case FNTSIZ_MINUS:
case FontSizeType::MINUS:
Append( "-" );
break;
case FNTSIZ_MULTIPLY:
case FontSizeType::MULTIPLY:
Append( "*" );
break;
case FNTSIZ_DIVIDE:
case FontSizeType::DIVIDE:
Append( "/" );
break;
case FNTSIZ_ABSOLUT:
case FontSizeType::ABSOLUT:
default:
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment