private static OXmlAnchorWrapSquare CreateAnchorWrapSquare(BsonDocument element)
 {
     OXmlAnchorWrapSquare wrapSquare = new OXmlAnchorWrapSquare();
     wrapSquare.WrapText = element.zGet("WrapText").zAsString().zTryParseEnum(DW.WrapTextValues.BothSides);
     wrapSquare.DistanceFromTop = (uint)element.zGet("DistanceFromTop").zAsInt();
     wrapSquare.DistanceFromBottom = (uint)element.zGet("DistanceFromBottom").zAsInt();
     wrapSquare.DistanceFromLeft = (uint)element.zGet("DistanceFromLeft").zAsInt();
     wrapSquare.DistanceFromRight = (uint)element.zGet("DistanceFromRight").zAsInt();
     wrapSquare.EffectExtent = CreateEffectExtent(element.zGet("EffectExtent").zAsBsonDocument());
     return wrapSquare;
 }
Example #2
0
        //public void SetWrapSquare(EnumValue<DW.WrapTextValues> wrapText, uint distanceFromTop = 0, uint distanceFromBottom = 0, uint distanceFromLeft = 0, uint distanceFromRight = 0, DW.EffectExtent effectExtent = null)
        private OpenXmlElement CreateWrapSquare(OXmlAnchorWrapSquare wrap)
        {
            // <wp:wrapSquare wrapText="bothSides" distB="57150" distT="57150" distL="57150" distR="57150"/>
            // <wp:wrapSquare wrapText="bothSides"/>

            //Square Wrapping, <wp:wrapSquare>
            DW.WrapSquare wrapElement = new DW.WrapSquare();

            // Text Wrapping Location, <wp:wrapSquare wrapText>
            // BothSides - Both Sides ("bothSides"), Left - Left Side Only ("left"), Right - Right Side Only ("right"), Largest - Largest Side Only ("largest")
            //wrapElement.WrapText = wrapText;
            wrapElement.WrapText = wrap.WrapText;

            if (wrap.DistanceFromTop != 0)
                // Distance From Text (Top), <wp:wrapSquare distT>
                wrapElement.DistanceFromTop = wrap.DistanceFromTop;
            if (wrap.DistanceFromBottom != 0)
                // Distance From Text on Bottom Edge, <wp:wrapSquare distB>
                wrapElement.DistanceFromBottom = wrap.DistanceFromBottom;
            if (wrap.DistanceFromLeft != 0)
                // Distance From Text on Left Edge, <wp:wrapSquare distL>
                wrapElement.DistanceFromLeft = wrap.DistanceFromLeft;
            if (wrap.DistanceFromRight != 0)
                // Distance From Text on Right Edge, <wp:wrapSquare distR>
                wrapElement.DistanceFromRight = wrap.DistanceFromRight;

            if (wrap.EffectExtent != null)
                // Object Extents Including Effects <wp:effectExtent>
                //   BottomEdge : Additional Extent on Bottom Edge (b)
                //   LeftEdge   : Additional Extent on Left Edge (l)
                //   RightEdge  : Additional Extent on Right Edge (r)
                //   TopEdge    : Additional Extent on Top Edge (t)
                // <wp:effectExtent b="0" l="0" r="0" t="0"/>
                wrapElement.EffectExtent = wrap.EffectExtent.ToEffectExtent();

            //_wrapElement = wrapElement;
            return wrapElement;
        }
 private static void SerializeWrapSquare(BsonWriter bsonWriter, OXmlAnchorWrapSquare wrap)
 {
     //if (wrap.WrapText != DW.WrapTextValues.BothSides)
     bsonWriter.WriteString("WrapText", wrap.WrapText.ToString());
     if (wrap.DistanceFromTop != 0)
         bsonWriter.WriteInt32("DistanceFromTop", (int)wrap.DistanceFromTop);
     if (wrap.DistanceFromBottom != 0)
         bsonWriter.WriteInt32("DistanceFromBottom", (int)wrap.DistanceFromBottom);
     if (wrap.DistanceFromLeft != 0)
         bsonWriter.WriteInt32("DistanceFromLeft", (int)wrap.DistanceFromLeft);
     if (wrap.DistanceFromRight != 0)
         bsonWriter.WriteInt32("DistanceFromRight", (int)wrap.DistanceFromRight);
     SerializeEffectExtent(bsonWriter, wrap.EffectExtent);
 }