예제 #1
0
파일: OXmlDoc.cs 프로젝트: 24/source_04
        //private int? _width;
        //private int? _height;
        //private long _emuWidth;
        //private long _emuHeight;
        //private OXmlPictureDrawing _pictureDrawing;

        private OXmlPicture(MainDocumentPart mainPart, OXmlPictureElement pictureElement, uint pictureId)
        {
            _mainPart       = mainPart;
            _pictureElement = pictureElement;
            _id             = pictureId;
            //_file = pictureElement.File;
            //_width = pictureElement.Width;
            //_height = pictureElement.Height;
            //_pictureDrawing = pictureElement.PictureDrawing;
        }
예제 #2
0
파일: OXmlDoc.cs 프로젝트: 24/source_04
        private void AddPicture(OXmlPictureElement element)
        {
            //if (_paragraph == null)
            //    AddParagraph();
            AddRun();

            // Drawing : child Inline, Anchor
            // <w:drawing>
            _run.AppendChild(new Drawing(OXmlPicture.Create(_mainPart, element, ++_pictureId)));
        }
예제 #3
0
        //private string _title;
        //private string _description;
        //private long _width;
        //private long _height;

        //private int _rotation = 0;                                                                     // Graphic
        //private bool _horizontalFlip = false;                                                          // Graphic
        //private bool _verticalFlip = false;                                                            // Graphic
        //private EnumValue<A.BlipCompressionValues> _compressionState = A.BlipCompressionValues.Print;  // Graphic
        //private EnumValue<A.ShapeTypeValues> _presetShape = A.ShapeTypeValues.Rectangle;               // Graphic

        //private uint _distanceFromTop = 0;                           // <wp:anchor distT> Distance From Text on Top Edge
        //private uint _distanceFromBottom = 0;                        // <wp:anchor distB> Distance From Text on Bottom Edge
        //private uint _distanceFromLeft = 0;                          // <wp:anchor distL> Distance From Text on Left Edge
        //private uint _distanceFromRight = 0;                         // <wp:anchor distR> Distance From Text on Right Edge
        //private uint _relativePosition = 0;                            // <wp:anchor relativeHeight> Relative Z-Ordering Position
        //private bool _behindDoc = false;                             // <wp:anchor behindDoc> Display Behind Document Text
        //private bool _layoutInCell = false;                          // <wp:anchor layoutInCell> Layout In Table Cell
        //private bool _allowOverlap = false;                          // <wp:anchor allowOverlap> Allow Objects to Overlap
        //private bool _locked = false;                                // <wp:anchor locked> Lock Anchor
        //private bool _hidden = false;                                // <wp:anchor hidden> Hidden
        //private string _editId = null;                               // <wp:anchor wp14:editId> editId (hexBinary value)
        //private string _anchorId = null;                             // <wp:anchor wp14:anchorId> anchorId (hexBinary value)
        //private bool _simplePos = false;                             // <wp:anchor simplePos> Page Positioning
        //private DW.SimplePosition _simplePosition = null;            // child <wp:simplePos x y> Simple Positioning Coordinates
        //private DW.HorizontalPosition _horizontalPosition = null;    // child <wp:positionH> Horizontal Positioning
        //private DW.VerticalPosition _verticalPosition = null;        // child <wp:positionV> Vertical Positioning
        ////private DW.EffectExtent _effectExtent = null;                // child <wp:effectExtent> Object Extents Including Effects
        //private OXmlAnchorWrap _wrap = null;                        // child WrapNone <wp:wrapNone>, WrapSquare <wp:wrapSquare>, WrapTight <wp:wrapTight>, WrapThrough <wp:wrapThrough>, WrapTopBottom <wp:wrapTopAndBottom>,
        //private DW2010.RelativeHeight _relativeHeight = null;        // child <wp14:sizeRelV> RelativeHeight (Office2010 or above)
        //private DW2010.RelativeWidth _relativeWidth = null;          // child <wp14:sizeRelH> RelativeWidth (Office2010 or above)
        ////private OpenXmlElement _wrapElement = null;

        //public int Rotation { get { return _rotation; } set { _rotation = value; } }
        //public bool HorizontalFlip { get { return _horizontalFlip; } set { _horizontalFlip = value; } }
        //public bool VerticalFlip { get { return _verticalFlip; } set { _verticalFlip = value; } }
        //public EnumValue<A.BlipCompressionValues> CompressionState { get { return _compressionState; } set { _compressionState = value; } }
        //public EnumValue<A.ShapeTypeValues> PresetShape { get { return _presetShape; } set { _presetShape = value; } }

        //public uint DistanceFromTop { get { return _distanceFromTop; } set { _distanceFromTop = value; } }
        //public uint DistanceFromBottom { get { return _distanceFromBottom; } set { _distanceFromBottom = value; } }
        //public uint DistanceFromLeft { get { return _distanceFromLeft; } set { _distanceFromLeft = value; } }
        //public uint DistanceFromRight { get { return _distanceFromRight; } set { _distanceFromRight = value; } }
        //public uint RelativePosition { get { return _relativePosition; } set { _relativePosition = value; } }
        //public bool BehindDoc { get { return _behindDoc; } set { _behindDoc = value; } }
        //public bool LayoutInCell { get { return _layoutInCell; } set { _layoutInCell = value; } }
        //public bool AllowOverlap { get { return _allowOverlap; } set { _allowOverlap = value; } }
        //public bool Locked { get { return _locked; } set { _locked = value; } }
        //public bool Hidden { get { return _hidden; } set { _hidden = value; } }
        //public string EditId { get { return _editId; } set { _editId = value; } }
        //public string AnchorId { get { return _anchorId; } set { _anchorId = value; } }
        //public OXmlAnchorWrap Wrap { get { return _wrap; } set { _wrap = value; } }

        //public AnchorDrawing(string embeddedReference, uint id, string name, long width, long height, string title = null, string description = null)
        public OXmlAnchorDrawing(string embeddedReference, uint id, string name, OXmlPictureElement pictureElement)
        {
            _embeddedReference = embeddedReference;
            _id             = id;
            _name           = name;
            _pictureElement = pictureElement;
            //_title = title;
            //_description = description;
            //_width = width;
            //_height = height;
            //UnsetSimplePosition();
        }
예제 #4
0
        private void AddPicture(OXmlElement element)
        {
            if (_paragraph == null)
            {
                throw new PBException("missing begin paragraph");
            }
            if (!(element is OXmlPictureElement))
            {
                throw new PBException("picture element must be a zDocXElementPicture");
            }
            OXmlPictureElement pictureElement = (OXmlPictureElement)element;
            Image   image   = _document.AddImage(pictureElement.File);
            Picture picture = image.CreatePicture();

            Trace.WriteLine("picture width {0} height {1}", picture.Width, picture.Height);
            if (pictureElement.Name != null)
            {
                picture.Name = pictureElement.Name;
            }
            if (pictureElement.Description != null)
            {
                picture.Description = pictureElement.Description;
            }
            if (pictureElement.Width != null)
            {
                picture.Width = (int)pictureElement.Width;
            }
            if (pictureElement.Height != null)
            {
                picture.Height = (int)pictureElement.Height;
            }
            //picture.Rotation = pictureElement.Rotation;
            //picture.FlipHorizontal = pictureElement.HorizontalFlip;
            //picture.FlipVertical = pictureElement.VerticalFlip;
            _paragraph.AppendPicture(picture);
            // option image from google doc :
            //   Aligner, Envelopper, Intercaler, 3.2 mm de marge
            //   In line, Wrap text, Break text, 1/8" margin
            // option image from word :
            //   disposition / position :
            //     horizontal / position absolue -0.1 cm à droite de marge
            //     vertical / position absolue 2.01 cm au dessous de paragraphe
            //     déplacer avec le texte
            //     autoriser le chevauchement de texte
        }
예제 #5
0
        public static OXmlElement CreatePicture(BsonDocument document)
        {
            OXmlPictureElement picture = new OXmlPictureElement();

            picture.File           = document.zGet("File").zAsString();
            picture.Name           = document.zGet("Name").zAsString();
            picture.Description    = document.zGet("Description").zAsString();
            picture.Width          = document.zGet("Width").zAsNullableInt();
            picture.Height         = document.zGet("Height").zAsNullableInt();
            picture.Rotation       = document.zGet("Rotation").zAsInt();
            picture.HorizontalFlip = document.zGet("HorizontalFlip").zAsBoolean();
            picture.VerticalFlip   = document.zGet("VerticalFlip").zAsBoolean();
            //picture.CompressionState = GetCompressionState(element.zGet("Description").zAsString());
            picture.CompressionState = document.zGet("CompressionState").zAsString().zTryParseEnum(A.BlipCompressionValues.Print);
            picture.PresetShape      = document.zGet("PresetShape").zAsString().zTryParseEnum(A.ShapeTypeValues.Rectangle);
            picture.PictureDrawing   = CreatePictureDrawing(document);
            return(picture);
        }
예제 #6
0
파일: OXmlDoc.cs 프로젝트: 24/source_04
 public static OpenXmlCompositeElement Create(MainDocumentPart mainPart, OXmlPictureElement pictureElement, uint pictureId)
 {
     return(new OXmlPicture(mainPart, pictureElement, pictureId)._Create());
 }
예제 #7
0
        public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
        {
            if (value == null)
            {
                throw new PBException("serialize OXmlPictureElement value is null");
            }
            if (_trace)
            {
                pb.Trace.WriteLine("OXmlPictureElementSerializer.Serialize()");
            }

            OXmlPictureElement element = (OXmlPictureElement)value;

            bsonWriter.WriteStartDocument();
            bsonWriter.WriteString("Type", "Picture");
            bsonWriter.WriteString("File", element.File);
            if (element.Name != null)
            {
                bsonWriter.WriteString("Name", element.Name);
            }
            if (element.Description != null)
            {
                bsonWriter.WriteString("Description", element.Description);
            }
            if (element.Width != null)
            {
                bsonWriter.WriteInt32("Width", (int)element.Width);
            }
            if (element.Height != null)
            {
                bsonWriter.WriteInt32("Height", (int)element.Height);
            }
            if (element.Rotation != 0)
            {
                bsonWriter.WriteInt32("Rotation", element.Rotation);
            }
            if (element.HorizontalFlip)
            {
                bsonWriter.WriteBoolean("HorizontalFlip", element.HorizontalFlip);
            }
            if (element.VerticalFlip)
            {
                bsonWriter.WriteBoolean("VerticalFlip", element.VerticalFlip);
            }
            if (element.CompressionState != A.BlipCompressionValues.Print)
            {
                bsonWriter.WriteString("CompressionState", element.CompressionState.ToString());
            }
            if (element.PresetShape != A.ShapeTypeValues.Rectangle)
            {
                bsonWriter.WriteString("PresetShape", element.PresetShape.ToString());
            }
            //bsonWriter.WriteString("DrawingMode", element.PictureDrawing.DrawingMode.ToString());
            bsonWriter.WriteString("DrawingType", element.PictureDrawing.GetDrawingType().ToString());
            if (element.PictureDrawing.DrawingMode == OXmlPictureDrawingMode.Anchor)
            {
                OXmlAnchorPictureDrawing anchor = (OXmlAnchorPictureDrawing)element.PictureDrawing;
                //bsonWriter.WriteString("WrapType", anchor.Wrap.WrapType.ToString());

                if (anchor.AnchorId != null)
                {
                    bsonWriter.WriteString("AnchorId", anchor.AnchorId);
                }
                if (anchor.EditId != null)
                {
                    bsonWriter.WriteString("EditId", anchor.AnchorId);
                }
                if (anchor.DistanceFromTop != null)
                {
                    bsonWriter.WriteInt32("DistanceFromTop", (int)anchor.DistanceFromTop);
                }
                if (anchor.DistanceFromBottom != null)
                {
                    bsonWriter.WriteInt32("DistanceFromBottom", (int)anchor.DistanceFromBottom);
                }
                if (anchor.DistanceFromLeft != null)
                {
                    bsonWriter.WriteInt32("DistanceFromLeft", (int)anchor.DistanceFromLeft);
                }
                if (anchor.DistanceFromRight != null)
                {
                    bsonWriter.WriteInt32("DistanceFromRight", (int)anchor.DistanceFromRight);
                }

                bsonWriter.WriteString("HorizontalRelativeFrom", anchor.HorizontalPosition.RelativeFrom.ToString());
                if (anchor.HorizontalPosition.PositionOffset != null)
                {
                    bsonWriter.WriteInt32("HorizontalPositionOffset", (int)anchor.HorizontalPosition.PositionOffset);
                }
                if (anchor.HorizontalPosition.HorizontalAlignment != null)
                {
                    bsonWriter.WriteString("HorizontalAlignment", anchor.HorizontalPosition.HorizontalAlignment);
                }
                bsonWriter.WriteString("VerticalRelativeFrom", anchor.VerticalPosition.RelativeFrom.ToString());
                if (anchor.VerticalPosition.PositionOffset != null)
                {
                    bsonWriter.WriteInt32("VerticalPositionOffset", (int)anchor.VerticalPosition.PositionOffset);
                }
                if (anchor.VerticalPosition.VerticalAlignment != null)
                {
                    bsonWriter.WriteString("VerticalAlignment", anchor.VerticalPosition.VerticalAlignment);
                }
                SerializeEffectExtent(bsonWriter, anchor.EffectExtent);
                if (anchor.AllowOverlap)
                {
                    bsonWriter.WriteBoolean("AllowOverlap", anchor.AllowOverlap);
                }
                if (anchor.BehindDoc)
                {
                    bsonWriter.WriteBoolean("BehindDoc", anchor.BehindDoc);
                }
                if (anchor.Hidden)
                {
                    bsonWriter.WriteBoolean("Hidden", anchor.Hidden);
                }
                if (anchor.LayoutInCell)
                {
                    bsonWriter.WriteBoolean("LayoutInCell", anchor.LayoutInCell);
                }
                if (anchor.Locked)
                {
                    bsonWriter.WriteBoolean("Locked", anchor.Locked);
                }
                if (anchor.RelativeHeight != 0)
                {
                    bsonWriter.WriteInt32("RelativeHeight", anchor.RelativeHeight);
                }
                if (anchor.SimplePosition != null)
                {
                    bsonWriter.WriteStartDocument("SimplePosition");
                    bsonWriter.WriteInt64("X", anchor.SimplePosition.X);
                    bsonWriter.WriteInt64("Y", anchor.SimplePosition.Y);
                    bsonWriter.WriteEndDocument();
                }
                switch (anchor.Wrap.WrapType)
                {
                case OXmlAnchorWrapType.WrapSquare:
                    SerializeWrapSquare(bsonWriter, (OXmlAnchorWrapSquare)anchor.Wrap);
                    break;

                case OXmlAnchorWrapType.WrapTight:
                    SerializeWrapTight(bsonWriter, (OXmlAnchorWrapTight)anchor.Wrap);
                    break;

                case OXmlAnchorWrapType.WrapTopAndBottom:
                    SerializeWrapTopBottom(bsonWriter, (OXmlAnchorWrapTopAndBottom)anchor.Wrap);
                    break;

                default:
                    throw new PBException($"WrapType {anchor.Wrap.WrapType} serialize not implemented");
                }
            }
            bsonWriter.WriteEndDocument();
        }