Пример #1
0
        private static OXmlAnchorWrapTight CreateAnchorWrapTight(BsonDocument element)
        {
            OXmlAnchorWrapTight wrapTight = new OXmlAnchorWrapTight();

            if (element != null)
            {
                wrapTight.WrapText          = element.zGet("WrapText").zAsString().zTryParseEnum(DW.WrapTextValues.BothSides);
                wrapTight.DistanceFromLeft  = element.zGet("DistanceFromLeft").zAsNullableInt();
                wrapTight.DistanceFromRight = element.zGet("DistanceFromRight").zAsNullableInt();
                //wrapTight.WrapPolygon = OXmlDoc.CreateWrapPolygon(element.zGet("WrapPolygonHorizontalSize").zAsLong(), element.zGet("WrapPolygonVerticalSize").zAsLong(), element.zGet("WrapPolygonStartPointX").zAsLong(), element.zGet("WrapPolygonStartPointY").zAsLong());
                //wrapTight.WrapPolygon = new OXmlSquare
                //{
                //    StartPointX = element.zGet("WrapPolygonStartPointX").zAsLong(),
                //    StartPointY = element.zGet("WrapPolygonStartPointY").zAsLong(),
                //    HorizontalSize = element.zGet("WrapPolygonHorizontalSize").zAsLong(),
                //    VerticalSize = element.zGet("WrapPolygonVerticalSize").zAsLong()
                //};
                BsonDocument polygon = element.zGet("Polygon").zAsBsonDocument();
                if (polygon != null)
                {
                    wrapTight.WrapPolygon = CreatePolygon(polygon);
                }
                else
                {
                    polygon = element.zGet("Square").zAsBsonDocument();
                    if (polygon != null)
                    {
                        wrapTight.WrapPolygon = CreateSquare(polygon);
                    }
                }
            }
            return(wrapTight);
        }
Пример #2
0
        //public void SetWrapTight(EnumValue<DW.WrapTextValues> wrapText, DW.WrapPolygon wrapPolygon, uint distanceFromLeft = 0, uint distanceFromRight = 0)
        private OpenXmlElement CreateWrapTight(OXmlAnchorWrapTight wrap)
        {
            // Tight Wrapping, <wp:wrapTight>
            DW.WrapTight wrapElement = new DW.WrapTight();

            // Text Wrapping Location, <wp:wrapTight 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.DistanceFromLeft != null)
            {
                // Distance From Text on Left Edge, <wp:wrapTight distL>
                wrapElement.DistanceFromLeft = (uint)wrap.DistanceFromLeft;
            }
            if (wrap.DistanceFromRight != null)
            {
                // Distance From Text on Right Edge, <wp:wrapTight distR>
                wrapElement.DistanceFromRight = (uint)wrap.DistanceFromRight;
            }

            // Tight Wrapping Extents Polygon, <wp:wrapPolygon>
            //wrapElement.WrapPolygon = wrapPolygon;
            //wrapElement.WrapPolygon = CreateSquareWrapPolygon(wrap.SquareSize);
            wrapElement.WrapPolygon = wrap.WrapPolygon.ToWrapPolygon();

            //_wrapElement = wrapElement;
            return(wrapElement);
        }
Пример #3
0
 private static void SerializeWrapTight(BsonWriter bsonWriter, OXmlAnchorWrapTight wrap)
 {
     bsonWriter.WriteStartDocument("WrapTight");
     //if (wrap.WrapText != DW.WrapTextValues.BothSides)
     bsonWriter.WriteString("WrapText", wrap.WrapText.ToString());
     if (wrap.DistanceFromLeft != null)
     {
         bsonWriter.WriteInt32("DistanceFromLeft", (int)wrap.DistanceFromLeft);
     }
     if (wrap.DistanceFromRight != null)
     {
         bsonWriter.WriteInt32("DistanceFromRight", (int)wrap.DistanceFromRight);
     }
     SerializePolygonBase(bsonWriter, wrap.WrapPolygon);
     bsonWriter.WriteEndDocument();
 }