public static int getTwip(CSSPrimitiveValue cssPrimitiveValue) {

    short ignored = 1;
    float fVal = cssPrimitiveValue.getFloatValue(ignored); // unit type ignored in cssparser
    log.debug("margin-left: " + fVal);
    if (fVal == 0f) {
      return 0;
    }

    int twip;

    short type = cssPrimitiveValue.getPrimitiveType();

    // TODO
    //		CSSPrimitiveValue.CSS_EMS (Unit 3)
    //		(the 'font-size' of the relevant font)
    //
    //		CSSPrimitiveValue.CSS_EMX (Unit 4)
    //		(the 'x-height' of the relevant font)

    if (CSSPrimitiveValue.CSS_PX == type) {
      // Unit 5
      twip = UnitsOfMeasurement.pxToTwip(fVal);
    } else if (CSSPrimitiveValue.CSS_CM == type) {
      // Unit 6
      twip = UnitsOfMeasurement.mmToTwip(fVal * 10);
    } else if (CSSPrimitiveValue.CSS_MM == type) {
      // Unit 7
      twip = UnitsOfMeasurement.mmToTwip(fVal);
    } else if (CSSPrimitiveValue.CSS_IN == type) {
      // Unit 8
      twip = UnitsOfMeasurement.inchToTwip(fVal);
    } else if (CSSPrimitiveValue.CSS_PT == type) {
      // Unit 9
      twip = UnitsOfMeasurement.pointToTwip(fVal);
    } else if (CSSPrimitiveValue.CSS_NUMBER == type) {
      log.error("Indent: No support for unspecified unit: CSS_NUMBER ");
      // http://stackoverflow.com/questions/11479985/what-is-the-default-unit-for-margin-left
      /*
       * In quirks mode (without a doctype), most browsers will try to correct the code by
       * using the unit px. In standards compliance mode (with a proper doctype), most browsers
       * will ignore the style.
       **/
      twip = 0; // TODO: should throw UnsupportedUnitException?
    } else {
      log.error("Indent: No support for unit " + type);
      twip = 0;
    }

    return twip;
  }
 /**
  * Gets the float value in the specified unit.
  *
  * @param unitType the type of unit
  * @return the value
  */
 public double jsxFunction_getFloatValue(final int unitType) {
   return wrappedCssPrimitiveValue_.getFloatValue((short) unitType);
 }