getGroupDetails method

void getGroupDetails(
  1. XmlElement spElement,
  2. Map<String, double> offsetValues,
  3. Map<String, int> rotFlip,
  4. Map<String, int> widthHeight,
  5. Map<String, String> colorDetails,
)

Implementation

void getGroupDetails(xml.XmlElement spElement, Map<String, double> offsetValues, Map<String, int> rotFlip, Map<String, int> widthHeight,
    Map<String, String> colorDetails) {
  if (spElement.parentElement != null && spElement.parentElement!.name.toString() == "p:grpSp") {
    var grpSpPr = spElement.parentElement!.findAllElements("p:grpSpPr");

    if (grpSpPr.isNotEmpty) {
      var chckOff = grpSpPr.first.findAllElements("a:off");
      if (chckOff.isNotEmpty) {
        var offX = chckOff.first.getAttribute("x");
        if (offX != null) {
          offsetValues["offsetX"] = offsetValues["offsetX"]! + double.parse(offX);
        }
        var offY = chckOff.first.getAttribute("y");
        if (offY != null) {
          offsetValues["offsetY"] = offsetValues["offsetY"]! + double.parse(offY);
        }
      }
      var chkChOff = grpSpPr.first.findAllElements("a:chOff");
      if (chkChOff.isNotEmpty) {
        //print("a:chOff");
        //print(chkChOff);
        var offX = chkChOff.first.getAttribute("x");
        if (offX != null) {
          //print(offsetX);
          offsetValues["offsetX"] = offsetValues["offsetX"]! - double.parse(offX);
          //print(offsetX);
        }
        var offY = chkChOff.first.getAttribute("y");
        if (offY != null) {
          //print(offsetY);
          offsetValues["offsetY"] = offsetValues["offsetY"]! - double.parse(offY);
          //print(offsetY);
        }
      }
      var chkExt = grpSpPr.first.findAllElements("a:ext");

      if (chkExt.isNotEmpty) {
        var extCx = chkExt.first.getAttribute("cx");

        if (extCx != null) {
          widthHeight["width"] = widthHeight["width"]! + int.parse(extCx);
        }
        var extCy = chkExt.first.getAttribute("cy");

        if (extCy != null) {
          widthHeight["height"] = widthHeight["height"]! + int.parse(extCy);
        }
      }

      var chkChExt = grpSpPr.first.findAllElements("a:chExt");

      if (chkChExt.isNotEmpty) {
        var extCx = chkChExt.first.getAttribute("cx");
        if (extCx != null) {
          widthHeight["width"] = widthHeight["width"]! - int.parse(extCx);
        }
        var extCy = chkChExt.first.getAttribute("cy");
        if (extCy != null) {
          widthHeight["height"] = widthHeight["height"]! - int.parse(extCy);
        }
      }

      var chkXfrm = grpSpPr.first.findAllElements("a:xfrm");
      if (chkXfrm.isNotEmpty) {
        var tempRot = chkXfrm.first.getAttribute("rot");
        if (tempRot != null) {
          if (rotFlip["rot"] == null) {
            rotFlip["rot"] = 0;
          }
          rotFlip["rot"] = rotFlip["rot"]! + (int.parse(tempRot) ~/ 60000);
        }
        var tempFlipH = chkXfrm.first.getAttribute("flipH");
        if (tempFlipH != null) {
          rotFlip["flipH"] = int.parse(tempFlipH);
        }
        var tempFlipV = chkXfrm.first.getAttribute("flipV");
        if (tempFlipV != null) {
          rotFlip["flipV"] = int.parse(tempFlipV);
        }
      }
      var chkSolidFill = grpSpPr.first.findAllElements("a:solidFill");
      if (chkSolidFill.isNotEmpty) {
        var chkSchemeClr = chkSolidFill.first.findAllElements("a:schemeClr");
        if (chkSchemeClr.isNotEmpty) {
          var tempVal = chkSchemeClr.first.getAttribute("val");
          if (tempVal != null) {
            colorDetails["clrScheme"] = tempVal;
          }
          var chkLumMod = chkSchemeClr.first.findAllElements("a:lumMod");
          if (chkLumMod.isNotEmpty) {
            var tempLumMod = chkLumMod.first.getAttribute("val");
            if (tempLumMod != null) {
              colorDetails["lumMod"] = tempLumMod;
            }
          }
          var chkLumOff = chkSchemeClr.first.findAllElements("a:lumOff");
          if (chkLumOff.isNotEmpty) {
            var tempLumOff = chkLumOff.first.getAttribute("val");
            if (tempLumOff != null) {
              colorDetails["lumOff"] = tempLumOff;
            }
          }
        }
        var chkRGBClr = chkSolidFill.first.findAllElements("a:srgbClr");
        if (chkRGBClr.isNotEmpty) {
          var tempVal = chkRGBClr.first.getAttribute("val");
          if (tempVal != null) {
            colorDetails["srgbClr"] = tempVal;
          }
        }
      }
    }

    getGroupDetails(spElement.parentElement!, offsetValues, rotFlip, widthHeight, colorDetails);
  }
}