private static void GetDrawingModeAndWrapType(OXmlPictureDrawingType drawingType, out OXmlPictureDrawingMode drawingMode, out OXmlAnchorWrapType wrapType)
 {
     switch (drawingType)
     {
         case OXmlPictureDrawingType.Inline:
             drawingMode = OXmlPictureDrawingMode.Inline;
             wrapType = OXmlAnchorWrapType.WrapNone;
             break;
         case OXmlPictureDrawingType.AnchorWrapNone:
             drawingMode = OXmlPictureDrawingMode.Anchor;
             wrapType = OXmlAnchorWrapType.WrapNone;
             break;
         case OXmlPictureDrawingType.AnchorWrapSquare:
             drawingMode = OXmlPictureDrawingMode.Anchor;
             wrapType = OXmlAnchorWrapType.WrapSquare;
             break;
         case OXmlPictureDrawingType.AnchorWrapTight:
             drawingMode = OXmlPictureDrawingMode.Anchor;
             wrapType = OXmlAnchorWrapType.WrapTight;
             break;
         case OXmlPictureDrawingType.AnchorWrapThrough:
             drawingMode = OXmlPictureDrawingMode.Anchor;
             wrapType = OXmlAnchorWrapType.WrapThrough;
             break;
         case OXmlPictureDrawingType.AnchorWrapTopAndBottom:
             drawingMode = OXmlPictureDrawingMode.Anchor;
             wrapType = OXmlAnchorWrapType.WrapTopAndBottom;
             break;
         default:
             throw new PBException($"unknow DrawingType {drawingType}");
     }
 }
        private static OXmlPictureDrawing CreatePictureDrawing(BsonDocument element)
        {
            //string drawingMode = element.zGet("DrawingMode").zAsString();
            //switch (drawingMode.ToLower())
            //{
            //    case "inline":
            //        return new OXmlInlinePictureDrawing();
            //    case "anchor":
            //        return CreateAnchorPictureDrawing(element);
            //    default:
            //        throw new PBException($"unknow oxml drawing mode \"{drawingMode}\"");
            //}
            OXmlPictureDrawingType drawingType = element.zGet("DrawingType").zAsString().zParseEnum <OXmlPictureDrawingType>(ignoreCase: true);
            OXmlPictureDrawingMode drawingMode;
            OXmlAnchorWrapType     wrapType;

            GetDrawingModeAndWrapType(drawingType, out drawingMode, out wrapType);
            switch (drawingMode)
            {
            case OXmlPictureDrawingMode.Inline:
                return(new OXmlInlinePictureDrawing());

            case OXmlPictureDrawingMode.Anchor:
                return(CreateAnchorPictureDrawing(element, wrapType));

            default:
                throw new PBException($"unknow oxml drawing mode \"{drawingMode}\"");
            }
        }
        private static void GetDrawingModeAndWrapType(OXmlPictureDrawingType drawingType, out OXmlPictureDrawingMode drawingMode, out OXmlAnchorWrapType wrapType)
        {
            switch (drawingType)
            {
            case OXmlPictureDrawingType.Inline:
                drawingMode = OXmlPictureDrawingMode.Inline;
                wrapType    = OXmlAnchorWrapType.WrapNone;
                break;

            case OXmlPictureDrawingType.AnchorWrapNone:
                drawingMode = OXmlPictureDrawingMode.Anchor;
                wrapType    = OXmlAnchorWrapType.WrapNone;
                break;

            case OXmlPictureDrawingType.AnchorWrapSquare:
                drawingMode = OXmlPictureDrawingMode.Anchor;
                wrapType    = OXmlAnchorWrapType.WrapSquare;
                break;

            case OXmlPictureDrawingType.AnchorWrapTight:
                drawingMode = OXmlPictureDrawingMode.Anchor;
                wrapType    = OXmlAnchorWrapType.WrapTight;
                break;

            case OXmlPictureDrawingType.AnchorWrapThrough:
                drawingMode = OXmlPictureDrawingMode.Anchor;
                wrapType    = OXmlAnchorWrapType.WrapThrough;
                break;

            case OXmlPictureDrawingType.AnchorWrapTopAndBottom:
                drawingMode = OXmlPictureDrawingMode.Anchor;
                wrapType    = OXmlAnchorWrapType.WrapTopAndBottom;
                break;

            default:
                throw new PBException($"unknow DrawingType {drawingType}");
            }
        }