Logo Search packages:      
Sourcecode: codeblocks version File versions  Download package

wxString wxPdfDocument::Convert2Roman ( int  value ) [static]

Converts an integer number to a roman number.

Parameters:
valueinteger value to be converted
Returns:
the string representation of the integer value as a roman number

Definition at line 2179 of file pdfdoc.cpp.

Referenced by WriteXmlCell().

{
  wxString result = wxEmptyString;

  if (value > 0 && value < 4000)
  {
    static wxString romans = _T("MDCLXVI");
    int pos = 6;  // Point to LAST character in 'romans'
    int currentDigit;

    while (value > 0)
    {
      currentDigit = value % 10;
      if (currentDigit == 4 || currentDigit == 9)
      {
        result.Prepend(romans.Mid(pos  - currentDigit / 4, 1));
        result.Prepend(romans.Mid(pos, 1));
      }
      else
      {
        int x = currentDigit % 5;
        while (x-- > 0)
        {
          result.Prepend(romans.Mid(pos, 1));
        }
        if (currentDigit >= 5)
        {
          result.Prepend(romans.Mid(pos - 1, 1));
        }
      }
      value /= 10;
      pos -= 2;
    }
  }
  else
  {
    result = _T("???");
  }
  return result;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index