MicroStrategy ONE

Retrieve Formatting Information in iOS

Formatting information—such as color coding, images, and quick symbols— is stored in a class called MSIPropertyGroup which is part of the widget grid’s underlying MSIHeaderValue objects. 

The MSIPropertyGroup class defines the following method in order to retrieve formatting information: 

Copy
- (NSString*)propertyByPropertySetID:(NSInteger)propertySetID propertyID:(NSInteger)propertyID;

This method receives two parameters: the Property Set Id and the specific Property Id for which you want to retrieve the formatting value. 

  • Property Set ID

    The Property Set Id is an enumeration called FormatPropertySetNames. This enumeration is defined in Enums.h and represents the following formatting sets:

    Copy
    typedef enum _FormatPropertySetNames{
    FormattingPatterns = 0, FormattingBorder, FormattingFont, FormattingNumber, FormattingAlignment,
    FormattingPadding, FormattingSize, FormattingColumnWidth,FormattingAppearance
    }FormatPropertySetNames;
  • Property ID:

    The Property ID value is related to the Property Set you choose. If you use FormattingPatterns as the FormatPropertySetNames value, you can then retrieve any of the formatting values defined in PatternFormattingProperties.:

    The entire list of available formatting ids are defined in Enums.h and include the following: 

    Copy
    typedef enum _PatternFormattingProperties{
    PatternFormattingFillColor = 1,
    PatternFormattingPatternColor = 2, PatternFormattingPatternStyle = 3, PatternFormattingFillStyle = 4,
    PatternFormattingApplyToGraphThreshold = 5, PatternFormattingGradientColor = 6, PatternFormattingGradientAngle = 7,
    PatternFormattingXOffset = 8, PatternFormattingYOffset = 9
    }PatternFormattingProperties;
     
    typedef enum _BorderFormattingProperties{
    BorderFormattingTopStyle = 3, BorderFormattingLeftStyle = 4, BorderFormattingBottomStyle = 5, BorderFormattingRightStyle = 6,
    BorderFormattingTopColor = 9, BorderFormattingLeftColor = 10, BorderFormattingBottomColor = 11, BorderFormattingRightColor = 12,
    BorderFormattingHInsideStyle = 1, BorderFormattingVInsideStyle = 2, BorderFormattingHInsideColor = 7, BorderFormattingVInsideColor = 8,
    BorderFormatting3DStyle = 13, BorderFormatting3DWeight = 14
    }BorderFormattingProperties;
     
    typedef enum _FontFormattingProperties{
    FontFormattingBold = 2, FontFormattingItalic = 3, FontFormattingStrikeout = 5, FontFormattingUnderline = 6, FontFormattingColor = 7,
    FontFormattingName = 1, FontFormattingSize = 4, FontFormattingScript = 8
    }FontFormattingProperties;
     
    typedef enum _AlignmentFormattingProperties{
    AlignmentFormattingHorizontal = 1,
    AlignmentFormattingVertical = 2,
    AlignmentFormattingTextWrap = 3,
    AlignmentFormattingTextDirection = 4
    }AlignmentFormattingProperties;
     
    typedef enum _NumberFormattingProperties{
    NumberFormattingCategory = 1,   NumberFormattingDecimalPlaces,    NumberFormattingThousandSeparator,
    NumberFormattingCurrencySymbol, NumberFormattingCurrencyPosition, NumberFormattingFormat,
    NumberFormattingNegativeNumbers
    }NumberFormattingProperties;
     
    typedef enum _PaddingFormattingProperties{
    PaddingFormattingLeftPadding = 1, PaddingFormattingRightPadding = 2,
    PaddingFormattingTopPadding = 3,  PaddingFormattingBottomPadding = 4,
    //PaddingFormattingLineSpacing = 5 //not used.
    }PaddingFormattingProperties;
     
    typedef enum _SizeFormattingProperties{
    SizeFormattingHeightMode = 6
    }SizeFormattingProperties;
     
    typedef enum _ColumnWidthFormattingProperties{
    ColumnWidthFormattingColumnScenario = 1
    }ColumnWidthFormattingProperties;
     
    typedef enum _AppearanceFormattingProperties{
    AppearanceFormattingVisible = 2
    }AppearanceFormattingProperties;

Code samples that illustrate how to retrieve formatting information are provided below:

  • The following code snippet illustrates how to retrieve color-coding for fonts and for cells in the report grid. The string color retrieved from the MSIHeaderValue object can be converted to a UIColor by using the convenience method +(UIColor*)colorForColorCode:(NSString*)colorCode in the GraphicUtils class:

    Copy
    MSIHeaderValue *value = ...//retrieve Header Value while iterating on the grid's data
            MSIPropertyGroup *propertyGroup = value.format;
            NSString *colorValueFill = [propertyGroup propertyByPropertySetID:FormattingPatterns propertyID:PatternFormattingFillColor];
            int bgrValueFill = [colorValueFill intValue]; // We got B G R here, but we need RGB
            int rgbValueFill = (bgrValueFill >> 16) + (bgrValueFill & 0x00FF00) + ((bgrValueFill & 0x0000FF) << 16);
            NSString *colorFill = [NSString stringWithFormat:@"%06x", rgbValueFill];
            
            NSString *colorValue = [propertyGroup propertyByPropertySetID:FormattingFont propertyID:FontFormattingColor];
            int bgrValue = [colorValue intValue]; // We got B G R here, but we need RGB
            int rgbValue = (bgrValue >> 16) + (bgrValue & 0x00FF00) + ((bgrValue & 0x0000FF) << 16);
            NSString *color = [NSString stringWithFormat:@"%06x", rgbValue];
            UIColor *theFormatColor = [GraphicUtils colorForColorCode:color];
  • Fonts

    The following code snippet illustrates how to retrieve color-coding for fonts and for cells in the report grid:

    Copy
    MSIHeaderValue *value = ...//retrieve Header Value while iterating on the grid's data
            MSIPropertyGroup *propertyGroup = value.format;
            NSString *fontName = [propertyGroup propertyByPropertySetID:FormattingFont propertyID:FontFormattingName];
  • Cell’s formatted string value:

    The cell’s formatted string value can be retrieved using the headerValue API of the MSIHeaderValue class:

    Copy
    MSIHeaderValue *value = ...//retrieve Header Value while iterating on the grid's data
            NSString *cellValue = value.headerValue;